[Libreoffice-commits] core.git: include/oox oox/Library_oox.mk oox/source sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Sun Apr 16 03:02:52 UTC 2017


 include/oox/token/relationship.hxx   |   25 +++++++++++++++++++++++++
 oox/Library_oox.mk                   |    1 +
 oox/source/token/relationship.cxx    |   33 +++++++++++++++++++++++++++++++++
 oox/source/token/relationship.inc    |    1 +
 sc/source/filter/excel/xecontent.cxx |    3 ++-
 5 files changed, 62 insertions(+), 1 deletion(-)

New commits:
commit 93e0a48d09456578527d1e498f708edbeae19667
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Dec 24 13:15:27 2016 +0100

    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 at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

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(),


More information about the Libreoffice-commits mailing list