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

Markus Mohrhard markus.mohrhard at googlemail.com
Mon Dec 26 02:05:02 UTC 2016


 include/oox/core/xmlfilterbase.hxx   |    2 ++
 oox/source/core/xmlfilterbase.cxx    |   17 ++++++++++++++++-
 oox/source/token/namespaces.hxx.tail |    1 +
 sc/source/filter/excel/xecontent.cxx |    3 ++-
 4 files changed, 21 insertions(+), 2 deletions(-)

New commits:
commit c61981c19335d6a75bf16e1653a2e8bbae81b14d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Dec 25 23:23:11 2016 +0100

    use the existing namespace map for the oox namespace export
    
    Change-Id: I7909b08db556c6c65c1547303f2b899c30feaba4
    Reviewed-on: https://gerrit.libreoffice.org/32425
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx
index 1a9be6a..59043ba 100644
--- a/include/oox/core/xmlfilterbase.hxx
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -236,6 +236,8 @@ public:
     void checkDocumentProperties(
             const css::uno::Reference<css::document::XDocumentProperties>& xDocProps);
 
+    OUString getNamespaceURL(sal_Int32 nNSID) const;
+
 protected:
     virtual css::uno::Reference< css::io::XInputStream >
         implGetInputStream( utl::MediaDescriptor& rMediaDesc ) const override;
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 952bf5e..85cfc9f 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -63,6 +63,7 @@
 #include <tools/datetime.hxx>
 #include <com/sun/star/util/Duration.hpp>
 #include <sax/tools/converter.hxx>
+#include <oox/token/namespacemap.hxx>
 
 using ::com::sun::star::xml::dom::DocumentBuilder;
 using ::com::sun::star::xml::dom::XDocument;
@@ -178,6 +179,7 @@ struct XmlFilterBaseImpl
     const OUString                 maBinSuffix;
     RelationsMap                   maRelationsMap;
     TextFieldStack                 maTextFieldStack;
+    const NamespaceMap&             mrNamespaceMap;
 
     explicit            XmlFilterBaseImpl( const Reference< XComponentContext >& rxContext ) throw( RuntimeException );
     ~XmlFilterBaseImpl();
@@ -186,7 +188,8 @@ struct XmlFilterBaseImpl
 XmlFilterBaseImpl::XmlFilterBaseImpl( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
     mxContext(rxContext),
     maFastParser( rxContext ),
-    maBinSuffix( ".bin" )
+    maBinSuffix( ".bin" ),
+    mrNamespaceMap(StaticNamespaceMap::get())
 {
     // register XML namespaces
     registerNamespaces(maFastParser);
@@ -910,6 +913,18 @@ bool XmlFilterBase::isMSO2007Document() const
     return mbMSO2007;
 }
 
+OUString XmlFilterBase::getNamespaceURL(sal_Int32 nNSID) const
+{
+    auto itr = mxImpl->mrNamespaceMap.maTransitionalNamespaceMap.find(nNSID);
+    if (itr == mxImpl->mrNamespaceMap.maTransitionalNamespaceMap.end())
+    {
+        SAL_WARN("oox", "missing namespace in the namespace map for : " << nNSID);
+        return OUString();
+    }
+
+    return itr->second;
+}
+
 } // namespace core
 } // namespace oox
 
diff --git a/oox/source/token/namespaces.hxx.tail b/oox/source/token/namespaces.hxx.tail
index 17770dc..a52eddf 100644
--- a/oox/source/token/namespaces.hxx.tail
+++ b/oox/source/token/namespaces.hxx.tail
@@ -30,6 +30,7 @@ inline sal_Int32 getNamespace( sal_Int32 nToken ) { return nToken & NMSP_MASK; }
 
 // defines for tokens with specific namespaces
 #define OOX_TOKEN( namespace, token ) (::oox::NMSP_##namespace | ::oox::XML_##token)
+#define OOX_NS( namespace ) (::oox::NMSP_##namespace)
 
 #define A_TOKEN( token )        OOX_TOKEN( dml, token )
 #define AX_TOKEN( token )       OOX_TOKEN( ax, token )
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index ee7ec4b..b74eeb1 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -44,6 +44,7 @@
 #include "xestyle.hxx"
 #include "xename.hxx"
 #include <rtl/uuid.h>
+#include <oox/token/namespaces.hxx>
 
 using namespace ::oox;
 
@@ -1396,7 +1397,7 @@ void XclExpDataBar::SaveXml( XclExpXmlStream& rStrm )
     // extLst entries for Excel 2010 and 2013
     rWorksheet->startElement( XML_extLst, FSEND );
     rWorksheet->startElement( XML_ext,
-                                FSNS( XML_xmlns, XML_x14 ), "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",
+                                FSNS( XML_xmlns, XML_x14 ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls14Lst))).getStr(),
                                 XML_uri, "{B025F937-C7B1-47D3-B67F-A62EFF666E3E}",
                                 FSEND );
 


More information about the Libreoffice-commits mailing list