summaryrefslogtreecommitdiff
path: root/filter/source/pdf/pdfexport.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'filter/source/pdf/pdfexport.cxx')
-rw-r--r--filter/source/pdf/pdfexport.cxx233
1 files changed, 116 insertions, 117 deletions
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index d0f5796694cb..000bcb3deed4 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -18,63 +18,60 @@
*/
-#include "pdfexport.hxx"
-#include "impdialog.hxx"
-
-#include "pdf.hrc"
#include <osl/file.hxx>
-#include "tools/urlobj.hxx"
-#include "tools/fract.hxx"
-#include "tools/poly.hxx"
-#include "vcl/mapmod.hxx"
-#include "vcl/virdev.hxx"
-#include "vcl/metaact.hxx"
-#include "vcl/gdimtf.hxx"
-#include "vcl/jobset.hxx"
-#include "vcl/bitmapaccess.hxx"
-#include "vcl/svapp.hxx"
-#include "toolkit/awt/vclxdevice.hxx"
+#include <tools/urlobj.hxx>
+#include <tools/fract.hxx>
+#include <tools/poly.hxx>
+#include <vcl/mapmod.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/metaact.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/jobset.hxx>
+#include <vcl/bitmapaccess.hxx>
+#include <vcl/svapp.hxx>
#include <vcl/FilterConfigItem.hxx>
#include <vcl/graphicfilter.hxx>
#include <vcl/settings.hxx>
-#include "svl/solar.hrc"
-#include "comphelper/sequence.hxx"
-#include "comphelper/string.hxx"
-#include "comphelper/storagehelper.hxx"
-#include "unotools/streamwrap.hxx"
-#include "com/sun/star/io/XSeekable.hpp"
-
-#include "basegfx/polygon/b2dpolygon.hxx"
-#include "basegfx/polygon/b2dpolypolygon.hxx"
-#include "basegfx/polygon/b2dpolygontools.hxx"
-
-#include "unotools/saveopt.hxx"
-
-#include "vcl/graphictools.hxx"
-#include "com/sun/star/beans/XPropertySet.hpp"
-#include "com/sun/star/configuration/theDefaultProvider.hpp"
-#include "com/sun/star/awt/Rectangle.hpp"
-#include "com/sun/star/awt/XDevice.hpp"
-#include "com/sun/star/util/MeasureUnit.hpp"
-#include "com/sun/star/frame/XModel.hpp"
-#include "com/sun/star/frame/ModuleManager.hpp"
-#include "com/sun/star/frame/XStorable.hpp"
-#include "com/sun/star/frame/XController.hpp"
-#include "com/sun/star/document/XDocumentProperties.hpp"
-#include "com/sun/star/document/XDocumentPropertiesSupplier.hpp"
-#include "com/sun/star/container/XNameAccess.hpp"
-#include "com/sun/star/view/XViewSettingsSupplier.hpp"
-#include "com/sun/star/task/XInteractionRequest.hpp"
-#include "com/sun/star/task/PDFExportException.hpp"
-
-#include "unotools/configmgr.hxx"
-#include "cppuhelper/exc_hlp.hxx"
+#include <vcl/graphictools.hxx>
+#include <svl/solar.hrc>
+#include <comphelper/sequence.hxx>
+#include <comphelper/string.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <toolkit/awt/vclxdevice.hxx>
+#include <unotools/streamwrap.hxx>
+#include <unotools/saveopt.hxx>
+#include <unotools/configmgr.hxx>
+#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/compbase.hxx>
-#include "cppuhelper/basemutex.hxx"
+#include <cppuhelper/basemutex.hxx>
+
+#include "pdfexport.hxx"
+#include "impdialog.hxx"
+#include "pdf.hrc"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/configuration/theDefaultProvider.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/awt/XDevice.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/view/XViewSettingsSupplier.hpp>
+#include <com/sun/star/task/XInteractionRequest.hpp>
+#include <com/sun/star/task/PDFExportException.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
-#include "com/sun/star/lang/XServiceInfo.hpp"
-#include "com/sun/star/drawing/XShapes.hpp"
-#include "com/sun/star/graphic/XGraphicProvider.hpp"
#include <memory>
using namespace ::com::sun::star;
@@ -85,9 +82,6 @@ using namespace ::com::sun::star::view;
using namespace ::com::sun::star::graphic;
-// - PDFExport -
-
-
PDFExport::PDFExport( const Reference< XComponent >& rxSrcDoc,
const Reference< task::XStatusIndicator >& rxStatusIndicator,
const Reference< task::XInteractionHandler >& rxIH,
@@ -138,7 +132,7 @@ PDFExport::PDFExport( const Reference< XComponent >& rxSrcDoc,
mbCanCopyOrExtract ( true ),
mbCanExtractForAccessibility( true ),
-//--->i56629
+ // #i56629
mbExportRelativeFsysLinks ( false ),
mnDefaultLinkAction ( 0 ),
mbConvertOOoTargetToPDFTarget( false ),
@@ -148,13 +142,11 @@ PDFExport::PDFExport( const Reference< XComponent >& rxSrcDoc,
}
-
PDFExport::~PDFExport()
{
}
-
bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter,
Reference< css::view::XRenderable >& rRenderable,
const Any& rSelection,
@@ -246,7 +238,7 @@ bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter,
}
else
{
- bRet = true; // #i18334# SJ: nPageCount == 0,
+ bRet = true; // #i18334# nPageCount == 0,
rPDFWriter.NewPage( 10000, 10000 ); // creating dummy page
rPDFWriter.SetMapMode( MAP_100TH_MM );
}
@@ -260,10 +252,14 @@ bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter,
class PDFExportStreamDoc : public vcl::PDFOutputStream
{
+private:
+
Reference< XComponent > m_xSrcDoc;
Sequence< beans::NamedValue > m_aPreparedPassword;
- public:
- PDFExportStreamDoc( const Reference< XComponent >& xDoc, const Sequence<beans::NamedValue>& rPwd )
+
+public:
+
+ PDFExportStreamDoc( const Reference< XComponent >& xDoc, const Sequence<beans::NamedValue>& rPwd )
: m_xSrcDoc( xDoc ),
m_aPreparedPassword( rPwd )
{}
@@ -272,10 +268,12 @@ class PDFExportStreamDoc : public vcl::PDFOutputStream
virtual void write( const Reference< XOutputStream >& xStream ) override;
};
+
PDFExportStreamDoc::~PDFExportStreamDoc()
{
}
+
void PDFExportStreamDoc::write( const Reference< XOutputStream >& xStream )
{
Reference< css::frame::XStorable > xStore( m_xSrcDoc, UNO_QUERY );
@@ -301,6 +299,7 @@ void PDFExportStreamDoc::write( const Reference< XOutputStream >& xStream )
}
}
+
static OUString getMimetypeForDocument( const Reference< XComponentContext >& xContext,
const Reference< XComponent >& xDoc ) throw()
{
@@ -373,6 +372,7 @@ static OUString getMimetypeForDocument( const Reference< XComponentContext >& xC
return aDocMimetype;
}
+
bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& rFilterData )
{
INetURLObject aURL( rFile );
@@ -473,7 +473,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
rFilterData[ nData ].Value >>= mnFormsFormat;
else if ( rFilterData[ nData ].Name == "AllowDuplicateFieldNames" )
rFilterData[ nData ].Value >>= mbAllowDuplicateFieldNames;
-//viewer properties
+ // viewer properties
else if ( rFilterData[ nData ].Name == "HideViewerToolbar" )
rFilterData[ nData ].Value >>= mbHideViewerToolbar;
else if ( rFilterData[ nData ].Name == "HideViewerMenubar" )
@@ -504,7 +504,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
rFilterData[ nData ].Value >>= mbAddStream;
else if ( rFilterData[ nData ].Name == "Watermark" )
rFilterData[ nData ].Value >>= msWatermark;
-//now all the security related properties...
+ // now all the security related properties...
else if ( rFilterData[ nData ].Name == "EncryptFile" )
rFilterData[ nData ].Value >>= mbEncrypt;
else if ( rFilterData[ nData ].Name == "DocumentOpenPassword" )
@@ -525,15 +525,15 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
rFilterData[ nData ].Value >>= mbCanCopyOrExtract;
else if ( rFilterData[ nData ].Name == "EnableTextAccessForAccessibilityTools" )
rFilterData[ nData ].Value >>= mbCanExtractForAccessibility;
-//--->i56629 links extra (relative links and other related stuff)
- else if ( rFilterData[ nData ].Name == "ExportLinksRelativeFsys" )
- rFilterData[ nData ].Value >>= mbExportRelativeFsysLinks;
- else if ( rFilterData[ nData ].Name == "PDFViewSelection" )
- rFilterData[ nData ].Value >>= mnDefaultLinkAction;
- else if ( rFilterData[ nData ].Name == "ConvertOOoTargetToPDFTarget" )
- rFilterData[ nData ].Value >>= mbConvertOOoTargetToPDFTarget;
- else if ( rFilterData[ nData ].Name == "ExportBookmarksToPDFDestination" )
- rFilterData[ nData ].Value >>= mbExportBmkToDest;
+ // i56629 links extra (relative links and other related stuff)
+ else if ( rFilterData[ nData ].Name == "ExportLinksRelativeFsys" )
+ rFilterData[ nData ].Value >>= mbExportRelativeFsysLinks;
+ else if ( rFilterData[ nData ].Name == "PDFViewSelection" )
+ rFilterData[ nData ].Value >>= mnDefaultLinkAction;
+ else if ( rFilterData[ nData ].Name == "ConvertOOoTargetToPDFTarget" )
+ rFilterData[ nData ].Value >>= mbConvertOOoTargetToPDFTarget;
+ else if ( rFilterData[ nData ].Name == "ExportBookmarksToPDFDestination" )
+ rFilterData[ nData ].Value >>= mbExportBmkToDest;
else if ( rFilterData[ nData ].Name == "ExportBookmarks" )
rFilterData[ nData ].Value >>= mbExportBookmarks;
else if ( rFilterData[ nData ].Name == "ExportHiddenSlides" )
@@ -555,9 +555,10 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
else if ( rFilterData[ nData ].Name == "SignatureTSA" )
rFilterData[ nData ].Value >>= msSignTSA;
}
+
aContext.URL = aURL.GetMainURL(INetURLObject::DECODE_TO_IURI);
-//set the correct version, depending on user request
+ // set the correct version, depending on user request
switch( mnPDFTypeSelection )
{
default:
@@ -566,22 +567,18 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
break;
case 1:
aContext.Version = vcl::PDFWriter::PDF_A_1;
- //force the tagged PDF as well
- mbUseTaggedPDF = true;
- //force disabling of form conversion
- mbExportFormFields = false;
- // PDF/A does not allow transparencies
- mbRemoveTransparencies = true;
- // no encryption
- mbEncrypt = false;
+ mbUseTaggedPDF = true; // force the tagged PDF as well
+ mbExportFormFields = false; // force disabling of form conversion
+ mbRemoveTransparencies = true; // PDF/A does not allow transparencies
+ mbEncrypt = false; // no encryption
xEnc.clear();
break;
}
-//copy in context the values default in the constructor or set by the FilterData sequence of properties
+ // copy in context the values default in the constructor or set by the FilterData sequence of properties
aContext.Tagged = mbUseTaggedPDF;
-//values used in viewer
+ // values used in viewer
aContext.HideViewerToolbar = mbHideViewerToolbar;
aContext.HideViewerMenubar = mbHideViewerMenubar;
aContext.HideViewerWindowControls = mbHideViewerWindowControls;
@@ -645,26 +642,25 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
aContext.FirstPageLeft = mbFirstPageLeft;
-//check if PDF/A, which does not allow encryption
+ // check if PDF/A, which does not allow encryption
if( aContext.Version != vcl::PDFWriter::PDF_A_1 )
{
-//set values needed in encryption
-//set encryption level, fixed, but here it can set by the UI if needed.
-// true is 128 bit, false 40
-//note that in 40 bit mode the UI needs reworking, since the current UI is meaningfull only for
-//128bit security mode
+ // set values needed in encryption
+ // set encryption level, fixed, but here it can set by the UI if needed.
+ // true is 128 bit, false 40
+ // note that in 40 bit mode the UI needs reworking, since the current UI is meaningfull only for
+ // 128bit security mode
aContext.Encryption.Security128bit = true;
-//set check for permission change password
-// if not enabled and no permission password, force permissions to default as if PDF where without encryption
+ // set check for permission change password
+ // if not enabled and no permission password, force permissions to default as if PDF where without encryption
if( mbRestrictPermissions && (xEnc.is() || !aPermissionPassword.isEmpty()) )
{
- mbEncrypt = true;
-//permission set as desired, done after
+ mbEncrypt = true; // permission set as desired, done after
}
else
{
-//force permission to default
+ // force permission to default
mnPrintAllowed = 2 ;
mnChangesAllowed = 4 ;
mbCanCopyOrExtract = true;
@@ -673,7 +669,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
switch( mnPrintAllowed )
{
- case 0: //initialized when aContext is build, means no printing
+ case 0: // initialized when aContext is build, means no printing
break;
default:
case 2:
@@ -685,7 +681,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
switch( mnChangesAllowed )
{
- case 0: //already in struct PDFSecPermissions CTOR
+ case 0: // already in struct PDFSecPermissions CTOR
break;
case 1:
aContext.Encryption.CanAssemble = true;
@@ -740,41 +736,42 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
}
aContext.AllowDuplicateFieldNames = mbAllowDuplicateFieldNames;
- //get model
+ // get model
Reference< frame::XModel > xModel( mxSrcDoc, UNO_QUERY );
{
-//---> i56629 Relative link stuff
-//set the base URL of the file:
-//then base URL
+ // #i56629: Relative link stuff
+ // set the base URL of the file: then base URL
aContext.BaseURL = xModel->getURL();
-//relative link option is private to PDF Export filter and limited to local filesystem only
+ // relative link option is private to PDF Export filter and limited to local filesystem only
aContext.RelFsys = mbExportRelativeFsysLinks;
-//determine the default acton for PDF links
+ // determine the default acton for PDF links
switch( mnDefaultLinkAction )
{
default:
-//default: URI, without fragment conversion (the bookmark in PDF may not work)
+ // default: URI, without fragment conversion (the bookmark in PDF may not work)
case 0:
aContext.DefaultLinkAction = vcl::PDFWriter::URIAction;
break;
-//view PDF through the reader application
case 1:
+ // view PDF through the reader application
aContext.ForcePDFAction = true;
aContext.DefaultLinkAction = vcl::PDFWriter::LaunchAction;
break;
-//view PDF through an Internet browser
case 2:
+ // view PDF through an Internet browser
aContext.DefaultLinkAction = vcl::PDFWriter::URIActionDestination;
break;
}
aContext.ConvertOOoTargetToPDFTarget = mbConvertOOoTargetToPDFTarget;
-// check for Link Launch action, not allowed on PDF/A-1
-// this code chunk checks when the filter is called from scripting
+
+ // check for Link Launch action, not allowed on PDF/A-1
+ // this code chunk checks when the filter is called from scripting
if( aContext.Version == vcl::PDFWriter::PDF_A_1 &&
aContext.DefaultLinkAction == vcl::PDFWriter::LaunchAction )
- { //force the similar allowed URI action
+ {
+ // force the similar allowed URI action
aContext.DefaultLinkAction = vcl::PDFWriter::URIActionDestination;
- //and remove the remote goto action forced on PDF file
+ // and remove the remote goto action forced on PDF file
aContext.ForcePDFAction = false;
}
}
@@ -787,7 +784,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
aContext.SignCertificate = maSignCertificate;
aContext.SignTSA = msSignTSA;
-// all context data set, time to create the printing device
+ // all context data set, time to create the printing device
std::unique_ptr<vcl::PDFWriter> pPDFWriter(new vcl::PDFWriter( aContext, xEnc ));
OutputDevice* pOut = pPDFWriter->GetReferenceDevice();
@@ -852,7 +849,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
if ( aCreator == "Writer" )
{
- //i92835 if Writer is in web layout mode this has to be switched to normal view and back to web view in the end
+ // #i92835: if Writer is in web layout mode this has to be switched to normal view and back to web view in the end
try
{
Reference< view::XViewSettingsSupplier > xVSettingsSupplier( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
@@ -880,9 +877,9 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
if ( mbExportNotesPages && aCreator == "Impress" )
{
- uno::Reference< drawing::XShapes > xShapes; // sj: do not allow to export notes when
- if ( ! ( aSelection >>= xShapes ) ) // exporting a selection -> todo: in the dialog
- bSecondPassForImpressNotes = true; // the export notes checkbox needs to be disabled
+ uno::Reference< drawing::XShapes > xShapes; // do not allow to export notes when exporting a selection
+ if ( ! ( aSelection >>= xShapes ) ) // TODO: in the dialog the export notes checkbox needs to be disabled
+ bSecondPassForImpressNotes = true;
}
if( aPageRange.isEmpty() )
@@ -958,6 +955,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
return bRet;
}
+
namespace
{
@@ -975,12 +973,14 @@ public:
virtual uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL getContinuations() throw (uno::RuntimeException, std::exception) override;
};
+
PDFErrorRequest::PDFErrorRequest( const task::PDFExportException& i_rExc ) :
PDFErrorRequestBase( m_aMutex ),
maExc( i_rExc )
{
}
+
uno::Any SAL_CALL PDFErrorRequest::getRequest() throw (uno::RuntimeException, std::exception)
{
osl::MutexGuard const guard( m_aMutex );
@@ -990,12 +990,14 @@ uno::Any SAL_CALL PDFErrorRequest::getRequest() throw (uno::RuntimeException, st
return aRet;
}
+
uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL PDFErrorRequest::getContinuations() throw (uno::RuntimeException, std::exception)
{
return uno::Sequence< uno::Reference< task::XInteractionContinuation > >();
}
-} // namespace
+} // end anonymous namespace
+
void PDFExport::showErrors( const std::set< vcl::PDFWriter::ErrorCode >& rErrors )
{
@@ -1009,7 +1011,6 @@ void PDFExport::showErrors( const std::set< vcl::PDFWriter::ErrorCode >& rErrors
}
-
bool PDFExport::ImplExportPage( vcl::PDFWriter& rWriter, vcl::PDFExtOutDevData& rPDFExtOutDevData, const GDIMetaFile& rMtf )
{
const Size aSizePDF( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_POINT ) );
@@ -1051,7 +1052,6 @@ bool PDFExport::ImplExportPage( vcl::PDFWriter& rWriter, vcl::PDFExtOutDevData&
}
-
void PDFExport::ImplWriteWatermark( vcl::PDFWriter& rWriter, const Size& rPageSize )
{
vcl::Font aFont( OUString( "Helvetica" ), Size( 0, 3*rPageSize.Height()/4 ) );
@@ -1119,5 +1119,4 @@ void PDFExport::ImplWriteWatermark( vcl::PDFWriter& rWriter, const Size& rPageSi
rWriter.Pop();
}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */