[Libreoffice-commits] .: sw/source

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Thu Aug 2 01:25:48 PDT 2012


 sw/source/filter/ww8/docxattributeoutput.cxx |   25 ++++++++++++++-----------
 sw/source/filter/ww8/docxattributeoutput.hxx |    2 +-
 2 files changed, 15 insertions(+), 12 deletions(-)

New commits:
commit 0e4846ec20c1aefc554037e8f08255019c08da47
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Thu Aug 2 10:20:59 2012 +0200

    fdo#52610: Fixed several docx export bugs
    
     + hyperlink starting before a field and ending in its results isn't
       valid.
     + when footnotes have hyperlinks we need to add the proper XML
       namespace and output the relations to a different file.
    
    Change-Id: I1c6cb8acba21c35e10bb0497eeaf96bbd73730d1

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index f9df2d1..3cb9d85 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -534,14 +534,6 @@ void DocxAttributeOutput::EndRun()
         m_pSerializer->endElementNS( XML_w, XML_hyperlink );
         m_closeHyperlinkInPreviousRun = false;
     }
-    // prepend the actual run start
-    if ( m_pHyperlinkAttrList )
-    {
-        XFastAttributeListRef xAttrList ( m_pHyperlinkAttrList );
-
-        m_pSerializer->startElementNS( XML_w, XML_hyperlink, xAttrList );
-        m_pHyperlinkAttrList = NULL;
-    }
 
     // Write the hyperlink and toc fields starts
     for ( std::vector<FieldInfos>::iterator pIt = m_Fields.begin(); pIt != m_Fields.end(); )
@@ -560,6 +552,15 @@ void DocxAttributeOutput::EndRun()
         ++pIt;
     }
 
+    // Start the hyperlink after the fields separators or we would generate invalid file
+    if ( m_pHyperlinkAttrList )
+    {
+        XFastAttributeListRef xAttrList ( m_pHyperlinkAttrList );
+
+        m_pSerializer->startElementNS( XML_w, XML_hyperlink, xAttrList );
+        m_pHyperlinkAttrList = NULL;
+    }
+
     DoWriteBookmarks( );
     WriteCommentRanges();
 
@@ -1216,9 +1217,10 @@ bool DocxAttributeOutput::StartURL( const String& rUrl, const String& rTarget )
         {
             OUString osUrl( sUrl );
 
-            ::rtl::OString sId = m_rExport.AddRelation(
-                S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" ),
-                osUrl );
+            OString sId = rtl::OUStringToOString( GetExport().GetFilter().addRelation( m_pSerializer->getOutputStream(),
+                        S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" ),
+                        osUrl, true ), RTL_TEXTENCODING_UTF8 );
+
             m_pHyperlinkAttrList->add( FSNS( XML_r, XML_id), sId.getStr());
         }
         else
@@ -3508,6 +3510,7 @@ void DocxAttributeOutput::FootnotesEndnotes( bool bFootnotes )
 
     m_pSerializer->startElementNS( XML_w, nBody,
             FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
+            FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
             FSEND );
 
     sal_Int32 nIndex = 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index ca863ae..1761009 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -613,7 +613,7 @@ public:
     virtual DocxExport& GetExport();
     const DocxExport& GetExport() const { return const_cast< DocxAttributeOutput* >( this )->GetExport(); }
 
-    /// For eg. the output of the styles, we need to switch the serializer to enother one.
+    /// For eg. the output of the styles, we need to switch the serializer to an other one.
     void SetSerializer( ::sax_fastparser::FSHelperPtr pSerializer ) { m_pSerializer = pSerializer; }
 
     /// Occasionnaly need to use this serializer from the outside


More information about the Libreoffice-commits mailing list