[Libreoffice] Export hyperlinks to .doc

Knut Olav Bøhmer bohmer at gmail.com
Fri May 20 04:48:13 PDT 2011


Hi,

Exporting hyperlinks to .doc is done wrong in LibreOffice Writer. There is a
flag (hlstmfIsAbsolute) that is set to 1. It should be 0, because all links
are exported relative.


Before I make a patch, give me input on this.

B - hlstmfIsAbsolute (1 bit): A bit that specifies whether this hyperlink is
an absolute path or
relative path.
Value Meaning
0 This hyperlink is a relative path.
1 This hyperlink is an absolute path.

The patch I have used for some time, that works for me and some hundred
users is:

diff --git a/sw/source/filter/ww8/wrtw8nds.cxx
b/sw/source/filter/ww8/wrtw8nds.cxx
index 4db4999..d5f7327 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -918,7 +918,7 @@ bool WW8AttributeOutput::StartURL( const String &rUrl,
const String &rTarget )
     SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, 0x00000002);
     sal_uInt32 nFlag = bBookMarkOnly ? 0 : 0x01;
     if ( bAbsolute )
-        nFlag |= 0x02;
+        nFlag |= 0x00;
     if ( sMark.Len() )
         nFlag |= 0x08;
     SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, nFlag );


But I guess a better patch would be (which I have not tested):

diff --git a/sw/source/filter/ww8/wrtw8nds.cxx
b/sw/source/filter/ww8/wrtw8nds.cxx
index 4db4999..d5f7327 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -918,7 +918,7 @@ bool WW8AttributeOutput::StartURL( const String &rUrl,
const String &rTarget )
     SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, 0x00000002);
     sal_uInt32 nFlag = bBookMarkOnly ? 0 : 0x01;
     if ( bAbsolute )
-        nFlag |= 0x02;
+        nFlag |= 0x00;
     if ( sMark.Len() )
         nFlag |= 0x08;
     SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, nFlag );


Anyway, this is very easy to test for anyone.
1. Create a document with a hyperlink.
2. Save it as .doc
3. Open it in MS Word
4. Ctrl Click on the link
5 and, look.. It does not work

6. Apply my patch
7. repeat point 1,2,3,4
8. and look.. It works :)



-- 
Knut Olav Bøhmer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20110520/c5c60ad4/attachment.htm>


More information about the LibreOffice mailing list