Issue 115297 - WW8: Export of relative hyperlinks is in a non-portable format, unusable by MS applications
Summary: WW8: Export of relative hyperlinks is in a non-portable format, unusable by M...
Status: CONFIRMED
Alias: None
Product: Writer
Classification: Application
Component: save-export (show other issues)
Version: OOo 3.2.1
Hardware: Unknown All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-28 15:30 UTC by knobo
Modified: 2013-08-07 14:44 UTC (History)
1 user (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
fixing relative paths in hyperlinks to be more portable. (1.36 KB, text/plain)
2010-10-28 20:19 UTC, knobo
no flags Details
Added missing parentheses (1.36 KB, text/plain)
2010-10-28 20:37 UTC, knobo
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description knobo 2010-10-28 15:30:41 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
Comment 1 knobo 2010-10-28 15:39:13 UTC
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.
Comment 2 knobo 2010-10-28 15:43:40 UTC
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( '/', '\\' );
        }
Comment 3 michael.ruess 2010-10-28 17:22:03 UTC
MRU->HBRINKM: please have a look whether the proposed patch can help here. Maybe
this will also fix issue 31267.
Comment 4 knobo 2010-10-28 18:28:03 UTC
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.
Comment 5 knobo 2010-10-28 20:02:55 UTC
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.

Comment 6 knobo 2010-10-28 20:19:05 UTC
Created attachment 72773 [details]
fixing relative paths in hyperlinks to be more portable.
Comment 7 knobo 2010-10-28 20:20:51 UTC
The patch probably needs a good look-over, as I have no idea of what I have done. 
It just works for me.
Comment 8 knobo 2010-10-28 20:37:26 UTC
Created attachment 72775 [details]
Added missing parentheses
Comment 9 knobo 2010-11-02 16:03:44 UTC
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.
Comment 10 Martin Hollmichel 2011-03-16 11:44:30 UTC
set target 3.x since not relevant for 3.4 release.
Comment 11 Pedro Giffuni 2013-01-26 03:37:56 UTC
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!
Comment 12 Rob Weir 2013-03-11 15:00:44 UTC
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