Apache OpenOffice (AOO) Bugzilla – Issue 115297
WW8: Export of relative hyperlinks is in a non-portable format, unusable by MS applications
Last modified: 2013-08-07 14:44:35 UTC
To reproduce (method 1): Create a new "Microsoft Word 97/2000/XP" .doc document writer. Insert a hyperlink to another .doc document. Save. Open the document Microsoft Word Viewer, and the hyperlink does not work. To reproduce (method 2): Open an important .doc file that you've got with one or more hyperlink in OpenOffice.org, save it. Now your document is broken :P
The problem is that OpenOffice.org uses "/" in the path in stead of "\". As OpenOffice.org is more flexible then MS Word and friends, we should probably export relativ hyperlinks with \ in the path to avoid irritating and locking out 99% of Office-application users.
I found the following code in wrtw8nds.cxx I guess we should add an extra check for ../ and replace every "/" with "\" // special case for the absolute windows names // (convert '/c:/foo/bar.doc' into 'c:\foo\bar.doc') sal_Unicode aDrive = ( sURL.Len() > 1 )? sURL.GetChar( 1 ): 0; if ( sURL.EqualsAscii( "/", 0, 1 ) && ( ( aDrive >= 'A' && aDrive <= 'Z' ) || ( aDrive >= 'a' && aDrive <= 'z' ) ) && sURL.EqualsAscii( ":", 2, 1 ) ) { sURL.Erase( 0, 1 ); sURL.SearchAndReplaceAll( '/', '\\' ); }
MRU->HBRINKM: please have a look whether the proposed patch can help here. Maybe this will also fix issue 31267.
It did not solve the problem. I have to look in a different place. There where some places the / was converted to \, but not in the right place. I'll try again later tonight.
in the following function: bool WW8AttributeOutput::AnalyzeURL( const String& rUrl, const String& rTarget, String* pLinkURL, String* pMark ) { I changed if ( sURL.Len() ){ sURL = URIHelper::simpleNormalizedMakeRelative( m_rWW8Export.GetWriter().GetBaseURL(), sURL ); to if ( sURL.Len() ){ sURL = URIHelper::simpleNormalizedMakeRelative( m_rWW8Export.GetWriter().GetBaseURL(), sURL ); sURL.SearchAndReplaceAll( '/', '\\' ); } And my problem was solved.
Created attachment 72773 [details] fixing relative paths in hyperlinks to be more portable.
The patch probably needs a good look-over, as I have no idea of what I have done. It just works for me.
Created attachment 72775 [details] Added missing parentheses
I'm not sure how I came to the conclusion that it worked. I have found out that OOo saves all hyperlinks with the "absolute-link" attr set. I unset it now, I have tested it and putting it in production now. I'll let you know how it goes.
set target 3.x since not relevant for 3.4 release.
Unfortunately the patches here don't fix the issue. In LibreOffice the issue was fixed by a patch to sw/source/filter/ww8/wrtw8nds.cxx in function WW8AttributeOutput::StartURL by introducing a check in line 942. The log says: Actually check that the output URL is relative or absolute. Non mark-only URLs doesn't necessarily reflect absolute URLs!
I'm adding this comment to all open issues with Issue Type == PATCH. We have 220 such issues, many of them quite old. I apologize for that. We need your help in prioritizing which patches should be integrated into our next release, Apache OpenOffice 4.0. If you have submitted a patch and think it is applicable for AOO 4.0, please respond with a comment to let us know. On the other hand, if the patch is no longer relevant, please let us know that as well. If you have any general questions or want to discuss this further, please send a note to our dev mailing list: dev@openoffice.apache.org Thanks! -Rob