[Libreoffice-commits] .: sw/source

Lubos Lunak llunak at kemper.freedesktop.org
Thu Nov 4 10:06:29 PDT 2010


 sw/source/filter/ww8/docxexport.cxx |   30 ++++++++++++++++--------------
 sw/source/filter/ww8/docxexport.hxx |    6 ++++--
 2 files changed, 20 insertions(+), 16 deletions(-)

New commits:
commit edc9823ec553119bcf8487a84d847ff1c4a5f92a
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Nov 4 17:29:36 2010 +0100

    setup xml namespaces also for footers and headers (bnc#581954)

diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index c836cd1..146f123 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -63,6 +63,7 @@
 #include <rtl/ustrbuf.hxx>
 #include <vcl/font.hxx>
 
+using namespace sax_fastparser;
 using namespace ::comphelper;
 using namespace ::com::sun::star;
 
@@ -552,9 +553,7 @@ void DocxExport::WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char*
         pFS = m_pFilter->openFragmentStreamWithSerializer( OUStringBuffer().appendAscii( "word/" ).append( aName ).makeStringAndClear(),
                     S( "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml" ) );
 
-        pFS->startElementNS( XML_w, XML_hdr,
-                FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
-                FSEND );
+        pFS->startElementNS( XML_w, XML_hdr, MainXmlNamespaces( pFS ));
     }
     else
     {
@@ -567,9 +566,7 @@ void DocxExport::WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char*
         pFS = m_pFilter->openFragmentStreamWithSerializer( OUStringBuffer().appendAscii( "word/" ).append( aName ).makeStringAndClear(),
                     S( "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml" ) );
 
-        pFS->startElementNS( XML_w, XML_ftr,
-                FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
-                FSEND );
+        pFS->startElementNS( XML_w, XML_ftr, MainXmlNamespaces( pFS ));
     }
 
     // switch the serializer to redirect the output to word/styles.xml
@@ -651,14 +648,7 @@ VMLExport& DocxExport::VMLExporter()
 void DocxExport::WriteMainText()
 {
     // setup the namespaces
-    m_pDocumentFS->startElementNS( XML_w, XML_document,
-            FSNS( XML_xmlns, XML_o ), "urn:schemas-microsoft-com:office:office",
-            FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
-            FSNS( XML_xmlns, XML_v ), "urn:schemas-microsoft-com:vml",
-            FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
-            FSNS( XML_xmlns, XML_w10 ), "urn:schemas-microsoft-com:office:word",
-            FSNS( XML_xmlns, XML_wp ), "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
-            FSEND );
+    m_pDocumentFS->startElementNS( XML_w, XML_document, MainXmlNamespaces( m_pDocumentFS ));
 
     // body
     m_pDocumentFS->startElementNS( XML_w, XML_body, FSEND );
@@ -678,6 +668,18 @@ void DocxExport::WriteMainText()
     m_pDocumentFS->endElementNS( XML_w, XML_document );
 }
 
+XFastAttributeListRef DocxExport::MainXmlNamespaces( FSHelperPtr serializer )
+{
+    FastAttributeList* pAttr = serializer->createAttrList();
+    pAttr->add( FSNS( XML_xmlns, XML_o ), "urn:schemas-microsoft-com:office:office" );
+    pAttr->add( FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships" );
+    pAttr->add( FSNS( XML_xmlns, XML_v ), "urn:schemas-microsoft-com:vml" );
+    pAttr->add( FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main" );
+    pAttr->add( FSNS( XML_xmlns, XML_w10 ), "urn:schemas-microsoft-com:office:word" );
+    pAttr->add( FSNS( XML_xmlns, XML_wp ), "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" );
+    return XFastAttributeListRef( pAttr );
+}
+
 DocxExport::DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam )
     : MSWordExportBase( pDocument, pCurrentPam, pOriginalPam ),
       m_pFilter( pFilter ),
diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx
index 81d2a02..2a7fcd0 100644
--- a/sw/source/filter/ww8/docxexport.hxx
+++ b/sw/source/filter/ww8/docxexport.hxx
@@ -33,6 +33,7 @@
 #include "wrtww8.hxx"
 
 #include <sax/fshelper.hxx>
+#include <sax/fastattribs.hxx>
 #include <rtl/ustring.hxx>
 
 #include <cstdio>
@@ -157,8 +158,6 @@ protected:
 
     virtual void OutputLinkedOLE( const rtl::OUString& );
 
-
-
     virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, ULONG nLnNum );
 
     virtual void SectionBreaksAndFrames( const SwTxtNode& /*rNode*/ ) {}
@@ -188,6 +187,9 @@ private:
     /// Write docProps/core.xml
     void WriteProperties();
 
+    /// All xml namespaces to be used at the top of any text .xml file (main doc, headers, footers,...)
+    sax_fastparser::XFastAttributeListRef MainXmlNamespaces( sax_fastparser::FSHelperPtr serializer );
+
 public:
     /// FIXME this is temporary, remotely reminding the method of the same
     /// name in WW8Export.


More information about the Libreoffice-commits mailing list