Lines 48-53
Link Here
|
48 |
#include <tools/debug.hxx> |
48 |
#include <tools/debug.hxx> |
49 |
#include <tools/zcodec.hxx> |
49 |
#include <tools/zcodec.hxx> |
50 |
#include <tools/stream.hxx> |
50 |
#include <tools/stream.hxx> |
|
|
51 |
|
52 |
#include <tools/urlobj.hxx> //for relative url |
53 |
|
51 |
#include <vcl/virdev.hxx> |
54 |
#include <vcl/virdev.hxx> |
52 |
#include <vcl/bmpacc.hxx> |
55 |
#include <vcl/bmpacc.hxx> |
53 |
#include <vcl/bitmapex.hxx> |
56 |
#include <vcl/bitmapex.hxx> |
Lines 3849-3856
bool PDFWriterImpl::emitLinkAnnotations(
Link Here
|
3849 |
} |
3852 |
} |
3850 |
else |
3853 |
else |
3851 |
{ |
3854 |
{ |
3852 |
aLine.append( "/A<</Type/Action/S/URI/URI" ); |
3855 |
/*--->i56629 |
3853 |
appendLiteralStringEncrypt( rLink.m_aURL, rLink.m_nObject, aLine ); |
3856 |
destination is external to the document, so |
|
|
3857 |
we check in the following sequence: |
3858 |
|
3859 |
if target type is neither .pdf, nor .od?, nor then |
3860 |
check if relative or absolute and act accordingly (URI or 'launch application' as requested) |
3861 |
end processing |
3862 |
else if target is .od[tpd]: then |
3863 |
if conversion of type from od[tpd] to pdf is requested, convert it and this becomes the new target file |
3864 |
processing continue |
3865 |
|
3866 |
if (new)target is .pdf : then |
3867 |
if GotToR is requested, then |
3868 |
convert the target in GoToR where the fragment of the URI is |
3869 |
considered the named destination in the target file, set relative or absolute as requested |
3870 |
else strip the fragment from URL and then set URI or 'launch application' as requested |
3871 |
*/ |
3872 |
//FIXME: check if the decode mechanism for URL processing is the correct one!! |
3873 |
//extract target file type |
3874 |
INetURLObject aUrlObj( m_aContext.BaseURL ); |
3875 |
INetURLObject aTargetURL( rLink.m_aURL ); |
3876 |
sal_Int32 nChangeFileExtensionToPDF = 0; |
3877 |
sal_Int32 nSetGoToRMode = 0; |
3878 |
rtl::OUString aFileExtension = aTargetURL.GetFileExtension(); |
3879 |
if( aFileExtension.getLength() > 0 ) |
3880 |
{ |
3881 |
if( m_aContext.ConvertOOoTargetToPDFTarget ) |
3882 |
{ |
3883 |
//examine the file type (.odt. .odp, odg, ods |
3884 |
if( aFileExtension.equalsIgnoreAsciiCase(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "odt" ) ) ) ) |
3885 |
nChangeFileExtensionToPDF++; |
3886 |
else if( aFileExtension.equalsIgnoreAsciiCase(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "odp" ) ) ) ) |
3887 |
nChangeFileExtensionToPDF++; |
3888 |
else if( aFileExtension.equalsIgnoreAsciiCase(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "odg" ) ) ) ) |
3889 |
nChangeFileExtensionToPDF++; |
3890 |
else if( aFileExtension.equalsIgnoreAsciiCase(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ods" ) ) ) ) |
3891 |
nChangeFileExtensionToPDF++; |
3892 |
if( nChangeFileExtensionToPDF ) |
3893 |
aTargetURL.setExtension(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "pdf" ) ) ); |
3894 |
} |
3895 |
//check if extension is pdf, see if GoToR should be forced |
3896 |
if( m_aContext.ForcePDFAction&& |
3897 |
aTargetURL.GetFileExtension().equalsIgnoreAsciiCase(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "pdf" ) ) ) ) |
3898 |
nSetGoToRMode++; |
3899 |
} |
3900 |
//prepare the URL, if relative or not |
3901 |
INetProtocol eBaseProtocol = aUrlObj.GetProtocol(); |
3902 |
INetProtocol eTargetProtocol = aTargetURL.GetProtocol(); |
3903 |
//queue the string common to all types of actions |
3904 |
aLine.append( "/A<</Type/Action/S"); |
3905 |
sal_Int32 nSetRelative = 0; |
3906 |
//check if relative file link is requested and if the protocol is 'file://' |
3907 |
if( m_aContext.RelFsys && eBaseProtocol == eTargetProtocol && eTargetProtocol == INET_PROT_FILE ) |
3908 |
nSetRelative++; |
3909 |
|
3910 |
if( nSetGoToRMode == 0 ) |
3911 |
switch( m_aContext.DefaultLinkAction ) |
3912 |
{ |
3913 |
default: |
3914 |
case PDFWriter::URIAction : |
3915 |
aLine.append( "/URI/URI" ); |
3916 |
break; |
3917 |
case PDFWriter::LaunchAction: |
3918 |
aLine.append( "/Launch/F" ); |
3919 |
break; |
3920 |
case PDFWriter::GoToRAction: |
3921 |
nSetGoToRMode++; |
3922 |
break; |
3923 |
} |
3924 |
if( nSetGoToRMode ) |
3925 |
{//add the fragment |
3926 |
rtl::OUString aFragment = aTargetURL.GetMark( INetURLObject::NO_DECODE /*DECODE_WITH_CHARSET*/ ); //fragment as is, |
3927 |
//the same coding as in the Named destination processing |
3928 |
rtl::OUString aURLNoMark = aTargetURL.GetURLNoMark( INetURLObject::DECODE_WITH_CHARSET ); |
3929 |
aLine.append("/GoToR"); |
3930 |
if( aFragment.getLength() > 0 ) |
3931 |
{ |
3932 |
aLine.append("/D/"); |
3933 |
appendName( aFragment , aLine ); |
3934 |
} |
3935 |
aLine.append("/F"); |
3936 |
appendLiteralStringEncrypt( nSetRelative ? INetURLObject::GetRelURL( m_aContext.BaseURL, aURLNoMark ) : |
3937 |
aURLNoMark, rLink.m_nObject, aLine ); |
3938 |
} |
3939 |
else |
3940 |
{ |
3941 |
rtl::OUString aURL = aTargetURL.GetMainURL( INetURLObject::DECODE_WITH_CHARSET ); |
3942 |
appendLiteralStringEncrypt( nSetRelative ? INetURLObject::GetRelURL( m_aContext.BaseURL, aURL ) : |
3943 |
aURL , rLink.m_nObject, aLine ); |
3944 |
} |
3945 |
//<--- |
3854 |
aLine.append( ">>\n" ); |
3946 |
aLine.append( ">>\n" ); |
3855 |
} |
3947 |
} |
3856 |
if( rLink.m_nStructParent > 0 ) |
3948 |
if( rLink.m_nStructParent > 0 ) |
Lines 4817-4822
bool PDFWriterImpl::emitCatalog()
Link Here
|
4817 |
if( ! it->emit( nTreeNode ) ) |
4909 |
if( ! it->emit( nTreeNode ) ) |
4818 |
return false; |
4910 |
return false; |
4819 |
|
4911 |
|
|
|
4912 |
sal_Int32 nNamedDestinationsDictionary = emitNamedDestinations(); |
4913 |
|
4820 |
sal_Int32 nOutlineDict = emitOutline(); |
4914 |
sal_Int32 nOutlineDict = emitOutline(); |
4821 |
|
4915 |
|
4822 |
sal_Int32 nStructureDict = 0; |
4916 |
sal_Int32 nStructureDict = 0; |
Lines 4882-4888
bool PDFWriterImpl::emitCatalog()
Link Here
|
4882 |
"<</Type/Catalog/Pages " ); |
4976 |
"<</Type/Catalog/Pages " ); |
4883 |
aLine.append( nTreeNode ); |
4977 |
aLine.append( nTreeNode ); |
4884 |
aLine.append( " 0 R\n" ); |
4978 |
aLine.append( " 0 R\n" ); |
4885 |
|
4979 |
//--->i56629 |
|
|
4980 |
//check if there are named destinations to emit (root must be inside the catalog) |
4981 |
if( nNamedDestinationsDictionary ) |
4982 |
{ |
4983 |
aLine.append("/Dests "); |
4984 |
aLine.append( nNamedDestinationsDictionary ); |
4985 |
aLine.append( " 0 R\n" ); |
4986 |
} |
4987 |
|
4886 |
if( m_aContext.PageLayout != PDFWriter::DefaultLayout ) |
4988 |
if( m_aContext.PageLayout != PDFWriter::DefaultLayout ) |
4887 |
switch( m_aContext.PageLayout ) |
4989 |
switch( m_aContext.PageLayout ) |
4888 |
{ |
4990 |
{ |
Lines 5103-5108
sal_Int32 PDFWriterImpl::emitInfoDict( )
Link Here
|
5103 |
return nObject; |
5205 |
return nObject; |
5104 |
} |
5206 |
} |
5105 |
|
5207 |
|
|
|
5208 |
//--->i56629 |
5209 |
// part of this it may be shared with method appendDest |
5210 |
// |
5211 |
sal_Int32 PDFWriterImpl::emitNamedDestinations() |
5212 |
{ |
5213 |
sal_Int32 nCount = m_aNamedDests.size(); |
5214 |
if( nCount <= 0 ) |
5215 |
return 0;//define internal error |
5216 |
|
5217 |
//get the object number for all the destinations |
5218 |
sal_Int32 nObject = createObject(); |
5219 |
|
5220 |
if( updateObject( nObject ) ) |
5221 |
{ |
5222 |
//emit the dictionary |
5223 |
OStringBuffer aLine( 1024 ); |
5224 |
aLine.append( nObject ); |
5225 |
aLine.append( " 0 obj\n" |
5226 |
"<<" ); |
5227 |
|
5228 |
sal_Int32 nDestID; |
5229 |
for( nDestID = 0; nDestID < nCount; nDestID++ ) |
5230 |
{ |
5231 |
|
5232 |
const PDFNamedDest& rDest = m_aNamedDests[ nDestID ]; |
5233 |
// In order to correctly function both under an Internet browser and directly with a reader (provided the reader has |
5234 |
// the feature) we need to set the name of the destination the same way it will be encoded |
5235 |
// in an Internet link |
5236 |
INetURLObject aLocalURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "http://ahost.ax" ) ) ); //dummy location, won't be used |
5237 |
aLocalURL.SetMark( rDest.m_aDestName ); |
5238 |
|
5239 |
const rtl::OUString aName = aLocalURL.GetMark( INetURLObject::NO_DECODE ); //same coding as |
5240 |
// in link creation ( see PDFWriterImpl::emitLinkAnnotations ) |
5241 |
const PDFPage& rDestPage = m_aPages[ rDest.m_nPage ]; |
5242 |
|
5243 |
aLine.append( '/' ); |
5244 |
appendName( aName, aLine ); // this conversion must be done wen using link to target ( see in emitCatalog ) |
5245 |
aLine.append(' '); //verificare !! |
5246 |
aLine.append( '[' ); |
5247 |
aLine.append( rDestPage.m_nPageObject ); |
5248 |
aLine.append( " 0 R" ); |
5249 |
|
5250 |
switch( rDest.m_eType ) |
5251 |
{ |
5252 |
case PDFWriter::XYZ: |
5253 |
default: |
5254 |
aLine.append( "/XYZ " ); |
5255 |
appendFixedInt( rDest.m_aRect.Left(), aLine ); |
5256 |
aLine.append( ' ' ); |
5257 |
appendFixedInt( rDest.m_aRect.Bottom(), aLine ); |
5258 |
aLine.append( " 0" ); |
5259 |
break; |
5260 |
case PDFWriter::Fit: |
5261 |
aLine.append( "/Fit" ); |
5262 |
break; |
5263 |
case PDFWriter::FitRectangle: |
5264 |
aLine.append( "/FitR " ); |
5265 |
appendFixedInt( rDest.m_aRect.Left(), aLine ); |
5266 |
aLine.append( ' ' ); |
5267 |
appendFixedInt( rDest.m_aRect.Top(), aLine ); |
5268 |
aLine.append( ' ' ); |
5269 |
appendFixedInt( rDest.m_aRect.Right(), aLine ); |
5270 |
aLine.append( ' ' ); |
5271 |
appendFixedInt( rDest.m_aRect.Bottom(), aLine ); |
5272 |
break; |
5273 |
case PDFWriter::FitHorizontal: |
5274 |
aLine.append( "/FitH " ); |
5275 |
appendFixedInt( rDest.m_aRect.Bottom(), aLine ); |
5276 |
break; |
5277 |
case PDFWriter::FitVertical: |
5278 |
aLine.append( "/FitV " ); |
5279 |
appendFixedInt( rDest.m_aRect.Left(), aLine ); |
5280 |
break; |
5281 |
case PDFWriter::FitPageBoundingBox: |
5282 |
aLine.append( "/FitB" ); |
5283 |
break; |
5284 |
case PDFWriter::FitPageBoundingBoxHorizontal: |
5285 |
aLine.append( "/FitBH " ); |
5286 |
appendFixedInt( rDest.m_aRect.Bottom(), aLine ); |
5287 |
break; |
5288 |
case PDFWriter::FitPageBoundingBoxVertical: |
5289 |
aLine.append( "/FitBV " ); |
5290 |
appendFixedInt( rDest.m_aRect.Left(), aLine ); |
5291 |
break; |
5292 |
} |
5293 |
aLine.append( ']' ); |
5294 |
|
5295 |
} |
5296 |
//close |
5297 |
aLine.append( ">>\nendobj\n\n" ); |
5298 |
if( ! writeBuffer( aLine.getStr(), aLine.getLength() ) ) |
5299 |
nObject = 0; |
5300 |
} |
5301 |
else |
5302 |
nObject = 0; |
5303 |
|
5304 |
return nObject; |
5305 |
} |
5306 |
//<--- |
5307 |
|
5106 |
bool PDFWriterImpl::emitTrailer() |
5308 |
bool PDFWriterImpl::emitTrailer() |
5107 |
{ |
5309 |
{ |
5108 |
// emit doc info |
5310 |
// emit doc info |
Lines 9221-9226
sal_Int32 PDFWriterImpl::createLink( con
Link Here
|
9221 |
return nRet; |
9423 |
return nRet; |
9222 |
} |
9424 |
} |
9223 |
|
9425 |
|
|
|
9426 |
//--->i56629 |
9427 |
sal_Int32 PDFWriterImpl::createNamedDest( const rtl::OUString& sDestName, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType ) |
9428 |
{ |
9429 |
if( nPageNr < 0 ) |
9430 |
nPageNr = m_nCurrentPage; |
9431 |
|
9432 |
if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) |
9433 |
return -1; |
9434 |
|
9435 |
sal_Int32 nRet = m_aNamedDests.size(); |
9436 |
|
9437 |
m_aNamedDests.push_back( PDFNamedDest() ); |
9438 |
m_aNamedDests.back().m_aDestName = sDestName; |
9439 |
m_aNamedDests.back().m_nPage = nPageNr; |
9440 |
m_aNamedDests.back().m_eType = eType; |
9441 |
m_aNamedDests.back().m_aRect = rRect; |
9442 |
// convert to default user space now, since the mapmode may change |
9443 |
m_aPages[nPageNr].convertRect( m_aNamedDests.back().m_aRect ); |
9444 |
|
9445 |
return nRet; |
9446 |
} |
9447 |
//<--- |
9448 |
|
9224 |
sal_Int32 PDFWriterImpl::createDest( const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType ) |
9449 |
sal_Int32 PDFWriterImpl::createDest( const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType ) |
9225 |
{ |
9450 |
{ |
9226 |
if( nPageNr < 0 ) |
9451 |
if( nPageNr < 0 ) |