diff options
Diffstat (limited to 'vcl/inc/vcl/pdfwriter.hxx')
-rw-r--r-- | vcl/inc/vcl/pdfwriter.hxx | 135 |
1 files changed, 88 insertions, 47 deletions
diff --git a/vcl/inc/vcl/pdfwriter.hxx b/vcl/inc/vcl/pdfwriter.hxx index f87ef312c8de..b1f76046678d 100644 --- a/vcl/inc/vcl/pdfwriter.hxx +++ b/vcl/inc/vcl/pdfwriter.hxx @@ -39,7 +39,8 @@ #include <vcl/font.hxx> #include <vcl/graphictools.hxx> -#include <com/sun/star/io/XOutputStream.hpp> +#include "com/sun/star/io/XOutputStream.hpp" +#include "com/sun/star/beans/XMaterialHolder.hpp" #include <list> #include <vector> @@ -48,6 +49,7 @@ class Font; class Point; class OutputDevice; +class GDIMetaFile; class MapMode; class Polygon; class LineInfo; @@ -62,15 +64,7 @@ class Wallpaper; namespace vcl { -struct PDFDocInfo -{ - String Title; // document title - String Author; // document author - String Subject; // subject - String Keywords; // keywords - String Creator; // application that created the original document - String Producer; // OpenOffice -}; +class PDFExtOutDevData; struct PDFNote { @@ -236,7 +230,7 @@ public: rtl::OUString Name; // a distinct name to identify the control rtl::OUString Description;// descriptive text for the contro (e.g. for tool tip) rtl::OUString Text; // user text to appear on the control - USHORT TextStyle; // style flags + sal_uInt16 TextStyle; // style flags bool ReadOnly; Rectangle Location; // describes the area filled by the control bool Border; // true: widget should have a border, false: no border @@ -469,7 +463,7 @@ public: FitVisible, ActionZoom }; -// These emuns are treated as integer while reading/writing to configuration +// These enums are treated as integer while reading/writing to configuration enum PDFPageLayout { DefaultLayout, @@ -490,20 +484,35 @@ public: /* The following structure describes the permissions used in PDF security */ - struct PDFSecPermissions + struct PDFEncryptionProperties { -//for both 40 and 128 bit security, see 3.5.2 PDF v 1.4 table 3.15, v 1.5 and v 1.6 table 3.20. - bool CanPrintTheDocument; + + bool Security128bit; // true to select 128 bit encryption, false for 40 bit + //for both 40 and 128 bit security, see 3.5.2 PDF v 1.4 table 3.15, v 1.5 and v 1.6 table 3.20. + bool CanPrintTheDocument; bool CanModifyTheContent; bool CanCopyOrExtract; bool CanAddOrModify; -//for revision 3 (bit 128 security) only + //for revision 3 (bit 128 security) only bool CanFillInteractive; bool CanExtractForAccessibility; bool CanAssemble; bool CanPrintFull; -//permission default set for 128 bit, accessibility only - PDFSecPermissions() : + + // encryption will only happen if EncryptionKey is not empty + // EncryptionKey is actually a construct out of OValue, UValue and DocumentIdentifier + // if these do not match, behavior is undefined, most likely an invalid PDF will be produced + // OValue, UValue, EncryptionKey and DocumentIdentifier can be computed from + // PDFDocInfo, Owner password and User password used the InitEncryption method which + // implements the algorithms described in the PDF reference chapter 3.5: Encryption + std::vector<sal_uInt8> OValue; + std::vector<sal_uInt8> UValue; + std::vector<sal_uInt8> EncryptionKey; + std::vector<sal_uInt8> DocumentIdentifier; + + //permission default set for 128 bit, accessibility only + PDFEncryptionProperties() : + Security128bit ( true ), CanPrintTheDocument ( false ), CanModifyTheContent ( false ), CanCopyOrExtract ( false ), @@ -513,6 +522,25 @@ The following structure describes the permissions used in PDF security CanAssemble ( false ), CanPrintFull ( false ) {} + + + bool Encrypt() const + { return ! OValue.empty() && ! UValue.empty() && ! DocumentIdentifier.empty(); } + }; + + struct PDFDocInfo + { + String Title; // document title + String Author; // document author + String Subject; // subject + String Keywords; // keywords + String Creator; // application that created the original document + String Producer; // OpenOffice + }; + + enum ColorMode + { + DrawColor, DrawGreyscale }; struct PDFWriterContext @@ -571,14 +599,13 @@ The following structure describes the permissions used in PDF security sal_Int32 InitialPage; sal_Int32 OpenBookmarkLevels; // -1 means all levels - struct PDFSecPermissions AccessPermissions; - - bool Encrypt; // main encryption flag, must be true to encript - bool Security128bit; // true to select 128 bit encryption, false for 40 bit - rtl::OUString OwnerPassword; // owner password for PDF, in clear text - rtl::OUString UserPassword; // user password for PDF, in clear text + PDFWriter::PDFEncryptionProperties Encryption; + PDFWriter::PDFDocInfo DocumentInfo; com::sun::star::lang::Locale DocumentLocale; // defines the document default language + sal_uInt32 DPIx, DPIy; // how to handle MapMode( MAP_PIXEL ) + // 0 here specifies a default handling + PDFWriter::ColorMode ColorMode; PDFWriterContext() : RelFsys( false ), //i56629, i49415?, i64585? @@ -605,13 +632,14 @@ The following structure describes the permissions used in PDF security FirstPageLeft( false ), InitialPage( 1 ), OpenBookmarkLevels( -1 ), - AccessPermissions( ), - Encrypt( false ), - Security128bit( true ) + Encryption(), + DPIx( 0 ), + DPIy( 0 ), + ColorMode( PDFWriter::DrawColor ) {} }; - PDFWriter( const PDFWriterContext& rContext ); + PDFWriter( const PDFWriterContext& rContext, const com::sun::star::uno::Reference< com::sun::star::beans::XMaterialHolder >& ); ~PDFWriter(); /** Returns an OutputDevice for formatting @@ -636,17 +664,24 @@ The following structure describes the permissions used in PDF security returns the page id of the new page */ sal_Int32 NewPage( sal_Int32 nPageWidth = 0, sal_Int32 nPageHeight = 0, Orientation eOrientation = Inherit ); + /** Play a metafile like an outputdevice would do + */ + struct PlayMetafileContext + { + int m_nMaxImageResolution; + bool m_bOnlyLosslessCompression; + int m_nJPEGQuality; + bool m_bTransparenciesWereRemoved; + + PlayMetafileContext() + : m_nMaxImageResolution( 0 ) + , m_bOnlyLosslessCompression( false ) + , m_nJPEGQuality( 90 ) + , m_bTransparenciesWereRemoved( false ) + {} - /* - * set document info; due to the use of document information in building the PDF document ID, must be called before - * emitting anything. - */ - void SetDocInfo( const PDFDocInfo& rInfo ); - - /* - * get currently set document info - */ - const PDFDocInfo& GetDocInfo() const; + }; + void PlayMetafile( const GDIMetaFile&, const PlayMetafileContext&, vcl::PDFExtOutDevData* pDevDat = NULL ); /* sets the document locale originally passed with the context to a new value * only affects the output if used before calling <code>Emit/code>. @@ -665,9 +700,15 @@ The following structure describes the permissions used in PDF security PDFVersion GetVersion() const; + static com::sun::star::uno::Reference< com::sun::star::beans::XMaterialHolder > + InitEncryption( const rtl::OUString& i_rOwnerPassword, + const rtl::OUString& i_rUserPassword, + bool b128Bit + ); + /* functions for graphics state */ /* flag values: see vcl/outdev.hxx */ - void Push( USHORT nFlags = 0xffff ); + void Push( sal_uInt16 nFlags = 0xffff ); void Pop(); void SetClipRegion(); @@ -676,9 +717,9 @@ The following structure describes the permissions used in PDF security void IntersectClipRegion( const Rectangle& rRect ); void IntersectClipRegion( const basegfx::B2DPolyPolygon& rRegion ); - void SetAntialiasing( USHORT nMode = 0 ); + void SetAntialiasing( sal_uInt16 nMode = 0 ); - void SetLayoutMode( ULONG nMode ); + void SetLayoutMode( sal_uLong nMode ); void SetDigitLanguage( LanguageType eLang ); void SetLineColor( const Color& rColor ); @@ -709,16 +750,16 @@ The following structure describes the permissions used in PDF security FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, - BOOL bUnderlineAbove = FALSE ); + sal_Bool bUnderlineAbove = sal_False ); void DrawTextArray( const Point& rStartPt, const XubString& rStr, const sal_Int32* pDXAry = NULL, xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN ); - void DrawStretchText( const Point& rStartPt, ULONG nWidth, + void DrawStretchText( const Point& rStartPt, sal_uLong nWidth, const XubString& rStr, xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN ); void DrawText( const Rectangle& rRect, - const XubString& rStr, USHORT nStyle = 0 ); + const XubString& rStr, sal_uInt16 nStyle = 0 ); void DrawPixel( const Point& rPt, const Color& rColor ); void DrawPixel( const Point& rPt ) @@ -738,7 +779,7 @@ The following structure describes the permissions used in PDF security void DrawPolyPolygon( const PolyPolygon& rPolyPoly ); void DrawRect( const Rectangle& rRect ); void DrawRect( const Rectangle& rRect, - ULONG nHorzRount, ULONG nVertRound ); + sal_uLong nHorzRount, sal_uLong nVertRound ); void DrawEllipse( const Rectangle& rRect ); void DrawArc( const Rectangle& rRect, const Point& rStartPt, const Point& rEndPt ); @@ -778,7 +819,7 @@ The following structure describes the permissions used in PDF security void DrawWallpaper( const Rectangle& rRect, const Wallpaper& rWallpaper ); void DrawTransparent( const PolyPolygon& rPolyPoly, - USHORT nTransparencePercent ); + sal_uInt16 nTransparencePercent ); /** Start a transparency group @@ -811,7 +852,7 @@ The following structure describes the permissions used in PDF security @param nTransparencePercent The transparency factor */ - void EndTransparencyGroup( const Rectangle& rBoundRect, USHORT nTransparencePercent ); + void EndTransparencyGroup( const Rectangle& rBoundRect, sal_uInt16 nTransparencePercent ); /** End a transparency group with an alpha mask |