summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-12-24 13:15:27 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-04-16 05:02:26 +0200
commit93e0a48d09456578527d1e498f708edbeae19667 (patch)
tree6c3ea916278c904ced23b69518742b135dff9316
parent4d64bd4cbf652c5286272edc271f45ec447b10b8 (diff)
first stab at replacing hard coded relationships with calls to a method
Change-Id: I4d1fd6ac3d32180972d82c67a81adf4953e3a82d Reviewed-on: https://gerrit.libreoffice.org/32409 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--include/oox/token/relationship.hxx25
-rw-r--r--oox/Library_oox.mk1
-rw-r--r--oox/source/token/relationship.cxx33
-rw-r--r--oox/source/token/relationship.inc1
-rw-r--r--sc/source/filter/excel/xecontent.cxx3
5 files changed, 62 insertions, 1 deletions
diff --git a/include/oox/token/relationship.hxx b/include/oox/token/relationship.hxx
new file mode 100644
index 000000000000..4b697b705de6
--- /dev/null
+++ b/include/oox/token/relationship.hxx
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <oox/dllapi.h>
+
+#include <rtl/ustring.hxx>
+
+namespace oox {
+
+enum class Relationship
+{
+ HYPERLINK
+};
+
+OUString OOX_DLLPUBLIC getRelationship(Relationship eRelationship);
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index 3d6c684d3fc4..3b4a6ac80744 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -288,6 +288,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\
oox/source/token/namespacemap \
oox/source/token/propertynames \
oox/source/token/tokenmap \
+ oox/source/token/relationship \
oox/source/vml/vmldrawing \
oox/source/vml/vmldrawingfragment \
oox/source/vml/vmlformatting \
diff --git a/oox/source/token/relationship.cxx b/oox/source/token/relationship.cxx
new file mode 100644
index 000000000000..f98e31cbbb6e
--- /dev/null
+++ b/oox/source/token/relationship.cxx
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <oox/token/relationship.hxx>
+
+#include <map>
+
+namespace oox {
+
+OUString getRelationship(Relationship eRelationship)
+{
+ static const std::map<Relationship, OUString> aMap =
+ {
+#include "relationship.inc"
+ };
+
+ auto itr = aMap.find(eRelationship);
+ if (itr != aMap.end())
+ return itr->second;
+
+ SAL_WARN("oox", "could not find an entry for the relationship: " << (int) eRelationship);
+ return OUString();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/token/relationship.inc b/oox/source/token/relationship.inc
new file mode 100644
index 000000000000..b36c627530c6
--- /dev/null
+++ b/oox/source/token/relationship.inc
@@ -0,0 +1 @@
+{Relationship::HYPERLINK, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"},
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index aad8d951606e..a243b80d58b8 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -45,6 +45,7 @@
#include "xename.hxx"
#include <rtl/uuid.h>
#include <oox/token/namespaces.hxx>
+#include <oox/token/relationship.hxx>
using namespace ::oox;
@@ -503,7 +504,7 @@ void XclExpHyperlink::WriteEmbeddedData( XclExpStream& rStrm )
void XclExpHyperlink::SaveXml( XclExpXmlStream& rStrm )
{
OUString sId = !msTarget.isEmpty() ? rStrm.addRelation( rStrm.GetCurrentStream()->getOutputStream(),
- XclXmlUtils::ToOUString( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" ),
+ oox::getRelationship(Relationship::HYPERLINK),
msTarget, true ) : OUString();
rStrm.GetCurrentStream()->singleElement( XML_hyperlink,
XML_ref, XclXmlUtils::ToOString( maScPos ).getStr(),