[Libreoffice-commits] .: Branch 'libreoffice-3-4' - sw/source

Michael Meeks michael at kemper.freedesktop.org
Thu May 26 02:39:02 PDT 2011


 sw/source/filter/ww8/wrtw8nds.cxx |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

New commits:
commit 87c6a672c577bab7caa7cc87de467da11c60ef44
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Thu May 26 10:37:18 2011 +0100

    fix for ww8 export of relative hyperlinks: i#115297
    
    Actually check that the output URL is relative or absolute. Non mark-only
    URLs doesn't necessarily reflect absolute URLs!

diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 7808f89..863b2ea 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -893,8 +893,12 @@ bool WW8AttributeOutput::StartURL( const String &rUrl, const String &rTarget )
     // now write the picture structur
     sURL = aURL.GetURLNoMark();
 
-    //all links end up in the data stream as absolute references.
-    bool bAbsolute = !bBookMarkOnly;
+    // Compare the URL written by AnalyzeURL with the original one to see if
+    // the output URL is absolute or relative.
+    String sRelativeURL;
+    if ( rUrl.Len() )
+        sRelativeURL = URIHelper::simpleNormalizedMakeRelative( m_rWW8Export.GetWriter().GetBaseURL(), rUrl );
+    bool bAbsolute = sRelativeURL.Equals( rUrl );
 
     static sal_uInt8 aURLData1[] = {
         0,0,0,0,        // len of struct
@@ -912,11 +916,14 @@ bool WW8AttributeOutput::StartURL( const String &rUrl, const String &rTarget )
     };
 
     m_rWW8Export.pDataStrm->Write( aURLData1, sizeof( aURLData1 ) );
+    /* Write HFD Structure */
     sal_uInt8 nAnchor = 0x00;
     if ( sMark.Len() )
         nAnchor = 0x08;
-    m_rWW8Export.pDataStrm->Write( &nAnchor, 1 );
-    m_rWW8Export.pDataStrm->Write( MAGIC_A, sizeof(MAGIC_A) );
+    m_rWW8Export.pDataStrm->Write( &nAnchor, 1 ); // HFDBits
+    m_rWW8Export.pDataStrm->Write( MAGIC_A, sizeof(MAGIC_A) ); //clsid
+
+    /* Write Hyperlink Object see [MS-OSHARED] spec*/
     SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, 0x00000002);
     sal_uInt32 nFlag = bBookMarkOnly ? 0 : 0x01;
     if ( bAbsolute )


More information about the Libreoffice-commits mailing list