diff options
author | Caolán McNamara <caolanm@redhat.com> | 2010-12-02 11:18:12 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2010-12-03 11:11:58 +0000 |
commit | ff438bb4118916f5f12c9dadac0078812f783e48 (patch) | |
tree | 52ca4559a69aeee94a724815c72143897c52be37 /vcl/source/gdi/pdfwriter_impl.cxx | |
parent | 47b589156c55d1c0ee52f72d95a7f7ea53fd1483 (diff) |
Resolves: #i115788# URIs must be exported as 7bit ASCII
(cherry picked from commit 8b074d17a7e81f075dfe30236dfcd1b0e9f36ad2)
Diffstat (limited to 'vcl/source/gdi/pdfwriter_impl.cxx')
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index ccd6bc173634..8cade3431ee1 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -4614,6 +4614,7 @@ we check in the following sequence: nSetRelative++; rtl::OUString aFragment = aTargetURL.GetMark( INetURLObject::NO_DECODE /*DECODE_WITH_CHARSET*/ ); //fragment as is, + bool bIsURI=false; //URI: 12.6.4.7, URI Actions, URI must be encoded in 7-bit-ASCII if( nSetGoToRMode == 0 ) switch( m_aContext.DefaultLinkAction ) { @@ -4621,6 +4622,7 @@ we check in the following sequence: case PDFWriter::URIAction : case PDFWriter::URIActionDestination : aLine.append( "/URI/URI" ); + bIsURI=true; break; case PDFWriter::LaunchAction: // now: @@ -4632,7 +4634,10 @@ we check in the following sequence: // and will force the use of URI when the protocol is not file:// if( (aFragment.getLength() > 0 && !bTargetHasPDFExtension) || eTargetProtocol != INET_PROT_FILE ) + { aLine.append( "/URI/URI" ); + bIsURI=true; + } else aLine.append( "/Launch/F" ); break; @@ -4640,7 +4645,8 @@ we check in the following sequence: //fragment are encoded in the same way as in the named destination processing rtl::OUString aURLNoMark = aTargetURL.GetURLNoMark( INetURLObject::DECODE_WITH_CHARSET ); if( nSetGoToRMode ) - {//add the fragment + { + //add the fragment aLine.append("/GoToR"); aLine.append("/F"); appendLiteralStringEncrypt( nSetRelative ? INetURLObject::GetRelURL( m_aContext.BaseURL, aURLNoMark, @@ -4665,13 +4671,23 @@ we check in the following sequence: //substitute the fragment aTargetURL.SetMark( aLineLoc.getStr() ); } - rtl::OUString aURL = aTargetURL.GetMainURL( (nSetRelative || eTargetProtocol == INET_PROT_FILE) ? INetURLObject::DECODE_WITH_CHARSET : INetURLObject::NO_DECODE ); -// check if we have a URL available, if the string is empty, set it as the original one -// if( aURL.getLength() == 0 ) -// appendLiteralStringEncrypt( rLink.m_aURL , rLink.m_nObject, aLine ); -// else + if (bIsURI) + { + //If we're writing to URI/URI we must e in 7-bit ASCII, so encode anything else as %XX + rtl::OUString aURL = aTargetURL.GetMainURL(INetURLObject::NO_DECODE); + appendLiteralStringEncrypt( nSetRelative ? INetURLObject::GetRelURL(m_aContext.BaseURL, aURL) : + aURL , rLink.m_nObject, aLine ); + } + else + { + //TO-DO: Depending on the interpretation of 12.6.4.5 we + //may be able to use appendUnicodeTextStringEncrypt + //here for the INetURLObject::DECODE_WITH_CHARSET case + //to ensure that the string doesn't get mangled + rtl::OUString aURL = aTargetURL.GetMainURL( (nSetRelative || eTargetProtocol == INET_PROT_FILE) ? INetURLObject::DECODE_WITH_CHARSET : INetURLObject::NO_DECODE ); appendLiteralStringEncrypt( nSetRelative ? INetURLObject::GetRelURL( m_aContext.BaseURL, aURL ) : aURL , rLink.m_nObject, aLine ); + } } //<--- i56629 } |