xref: /trunk/main/vcl/source/gdi/pdfwriter_impl.hxx (revision c1e8cc3a)
10d63794cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
30d63794cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
40d63794cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
50d63794cSAndrew Rist  * distributed with this work for additional information
60d63794cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
70d63794cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
80d63794cSAndrew Rist  * "License"); you may not use this file except in compliance
90d63794cSAndrew Rist  * with the License.  You may obtain a copy of the License at
100d63794cSAndrew Rist  *
110d63794cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
120d63794cSAndrew Rist  *
130d63794cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
140d63794cSAndrew Rist  * software distributed under the License is distributed on an
150d63794cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
160d63794cSAndrew Rist  * KIND, either express or implied.  See the License for the
170d63794cSAndrew Rist  * specific language governing permissions and limitations
180d63794cSAndrew Rist  * under the License.
190d63794cSAndrew Rist  *
200d63794cSAndrew Rist  *************************************************************/
210d63794cSAndrew Rist 
220d63794cSAndrew Rist 
23cdf0e10cSrcweir #ifndef _VCL_PDFWRITER_IMPL_HXX
24cdf0e10cSrcweir #define _VCL_PDFWRITER_IMPL_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "vcl/pdfwriter.hxx"
27cdf0e10cSrcweir #include "rtl/ustring.hxx"
28cdf0e10cSrcweir #include "osl/file.h"
29cdf0e10cSrcweir #include "tools/gen.hxx"
30cdf0e10cSrcweir #include "tools/stream.hxx"
31cdf0e10cSrcweir #include "vcl/outdev.hxx"
32cdf0e10cSrcweir #include "vcl/bitmapex.hxx"
33cdf0e10cSrcweir #include "vcl/gradient.hxx"
34cdf0e10cSrcweir #include "vcl/hatch.hxx"
35cdf0e10cSrcweir #include "vcl/wall.hxx"
36cdf0e10cSrcweir #include "outdata.hxx"
37cdf0e10cSrcweir #include "rtl/strbuf.hxx"
38cdf0e10cSrcweir #include "rtl/cipher.h"
39cdf0e10cSrcweir #include "rtl/digest.h"
40cdf0e10cSrcweir #include "com/sun/star/util/XURLTransformer.hpp"
41cdf0e10cSrcweir #include "com/sun/star/lang/Locale.hpp"
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <sallayout.hxx>
44cdf0e10cSrcweir #include "pdffontcache.hxx"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <vector>
47cdf0e10cSrcweir #include <map>
48cdf0e10cSrcweir #include <hash_map>
49cdf0e10cSrcweir #include <list>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include <boost/shared_array.hpp>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir class ImplFontSelectData;
54cdf0e10cSrcweir class ImplFontMetricData;
55cdf0e10cSrcweir class FontSubsetInfo;
56cdf0e10cSrcweir class ZCodec;
57cdf0e10cSrcweir class EncHashTransporter;
58cdf0e10cSrcweir struct BitStreamState;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir // the maximum password length
61cdf0e10cSrcweir #define ENCRYPTED_PWD_SIZE     32
62cdf0e10cSrcweir #define MD5_DIGEST_SIZE        16
63cdf0e10cSrcweir #define SECUR_40BIT_KEY         5
64cdf0e10cSrcweir // security 128 bit
65cdf0e10cSrcweir #define SECUR_128BIT_KEY       16
66cdf0e10cSrcweir // maximum length of MD5 digest input, in step 2 of algorithm 3.1
67cdf0e10cSrcweir // PDF spec ver. 1.4: see there for details
68cdf0e10cSrcweir #define MAXIMUM_RC4_KEY_LENGTH (SECUR_128BIT_KEY+3+2)
69cdf0e10cSrcweir 
70cdf0e10cSrcweir namespace vcl
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 
73cdf0e10cSrcweir class PDFSalLayout;
74cdf0e10cSrcweir class PDFStreamIf;
75cdf0e10cSrcweir class Matrix3;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir class PDFWriterImpl
78cdf0e10cSrcweir {
79cdf0e10cSrcweir     friend class PDFSalLayout;
80cdf0e10cSrcweir     friend class PDFStreamIf;
81cdf0e10cSrcweir public:
82cdf0e10cSrcweir     // definition of structs
83cdf0e10cSrcweir     struct BuiltinFont
84cdf0e10cSrcweir     {
85cdf0e10cSrcweir         const char *        		m_pName;                     // Name
86cdf0e10cSrcweir         const char *        		m_pStyleName;                // StyleName
87cdf0e10cSrcweir         const char *        		m_pPSName;					 // PSName
88cdf0e10cSrcweir         int							m_nAscent;
89cdf0e10cSrcweir         int							m_nDescent;
90cdf0e10cSrcweir         FontFamily					m_eFamily;                   // Family
91cdf0e10cSrcweir 		CharSet						m_eCharSet;                  // CharSet
92cdf0e10cSrcweir 	    FontPitch					m_ePitch;                    // Pitch
93cdf0e10cSrcweir 		FontWidth					m_eWidthType;                // WidthType
94cdf0e10cSrcweir 		FontWeight					m_eWeight;                   // Weight
95cdf0e10cSrcweir 		FontItalic					m_eItalic;                   // Italic
96cdf0e10cSrcweir         int							m_aWidths[256];				 // character metrics
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         rtl::OString getNameObject() const;
99cdf0e10cSrcweir     };
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     enum ResourceKind { ResXObject, ResExtGState, ResShading, ResPattern };
103cdf0e10cSrcweir     typedef std::map< rtl::OString, sal_Int32 > ResourceMap;
104cdf0e10cSrcweir     struct ResourceDict
105cdf0e10cSrcweir     {
106cdf0e10cSrcweir         // note: handle fonts globally for performance
107cdf0e10cSrcweir         ResourceMap m_aXObjects;
108cdf0e10cSrcweir         ResourceMap m_aExtGStates;
109cdf0e10cSrcweir         ResourceMap m_aShadings;
110cdf0e10cSrcweir         ResourceMap m_aPatterns;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir         void append( rtl::OStringBuffer&, sal_Int32 nFontDictObject );
113cdf0e10cSrcweir     };
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     struct PDFPage
116cdf0e10cSrcweir     {
117cdf0e10cSrcweir         PDFWriterImpl*				m_pWriter;
118cdf0e10cSrcweir         sal_Int32					m_nPageWidth;			// in inch/72
119cdf0e10cSrcweir         sal_Int32					m_nPageHeight;			// in inch/72
120cdf0e10cSrcweir         PDFWriter::Orientation		m_eOrientation;
121cdf0e10cSrcweir         sal_Int32					m_nPageObject;
122cdf0e10cSrcweir         sal_Int32					m_nPageIndex;
123cdf0e10cSrcweir         std::vector<sal_Int32>		m_aStreamObjects;
124cdf0e10cSrcweir         sal_Int32					m_nStreamLengthObject;
125cdf0e10cSrcweir         sal_uInt64					m_nBeginStreamPos;
126cdf0e10cSrcweir         std::vector<sal_Int32>		m_aAnnotations;
127cdf0e10cSrcweir         std::vector<sal_Int32>		m_aMCIDParents;
128cdf0e10cSrcweir         PDFWriter::PageTransition	m_eTransition;
129cdf0e10cSrcweir         sal_uInt32					m_nTransTime;
130cdf0e10cSrcweir         sal_uInt32					m_nDuration;
131cdf0e10cSrcweir         bool                        m_bHasWidgets;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         PDFPage( PDFWriterImpl* pWriter, sal_Int32 nPageWidth, sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation );
134cdf0e10cSrcweir         ~PDFPage();
135cdf0e10cSrcweir 
136cdf0e10cSrcweir         void beginStream();
137cdf0e10cSrcweir         void endStream();
138cdf0e10cSrcweir         bool emit( sal_Int32 nParentPage );
139cdf0e10cSrcweir 
140cdf0e10cSrcweir         // converts point from ref device coordinates to
141cdf0e10cSrcweir         // page coordinates and appends the point to the buffer
142cdf0e10cSrcweir         // if bNeg is true, the coordinates are inverted AFTER transformation
143cdf0e10cSrcweir         // to page (useful for transformation matrices
144cdf0e10cSrcweir         // if pOutPoint is set it will be updated to the emitted point
145cdf0e10cSrcweir         // (in PDF map mode, that is 10th of point)
146cdf0e10cSrcweir         void appendPoint( const Point& rPoint, rtl::OStringBuffer& rBuffer, bool bNeg = false, Point* pOutPoint = NULL ) const;
147cdf0e10cSrcweir         // appends a B2DPoint without further transformation
148cdf0e10cSrcweir         void appendPixelPoint( const basegfx::B2DPoint& rPoint, rtl::OStringBuffer& rBuffer ) const;
149cdf0e10cSrcweir         // appends a rectangle
150cdf0e10cSrcweir         void appendRect( const Rectangle& rRect, rtl::OStringBuffer& rBuffer ) const;
151cdf0e10cSrcweir         // converts a rectangle to 10th points page space
152cdf0e10cSrcweir         void convertRect( Rectangle& rRect ) const;
153cdf0e10cSrcweir         // appends a polygon optionally closing it
154cdf0e10cSrcweir         void appendPolygon( const Polygon& rPoly, rtl::OStringBuffer& rBuffer, bool bClose = true ) const;
155cdf0e10cSrcweir         // appends a polygon optionally closing it
156cdf0e10cSrcweir         void appendPolygon( const basegfx::B2DPolygon& rPoly, rtl::OStringBuffer& rBuffer, bool bClose = true ) const;
157cdf0e10cSrcweir         // appends a polypolygon optionally closing the subpaths
158cdf0e10cSrcweir         void appendPolyPolygon( const PolyPolygon& rPolyPoly, rtl::OStringBuffer& rBuffer, bool bClose = true ) const;
159cdf0e10cSrcweir         // appends a polypolygon optionally closing the subpaths
160cdf0e10cSrcweir         void appendPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPoly, rtl::OStringBuffer& rBuffer, bool bClose = true ) const;
161cdf0e10cSrcweir         // converts a length (either vertical or horizontal; this
162cdf0e10cSrcweir         // can be important if the source MapMode is not
163cdf0e10cSrcweir         // symmetrical) to page length and appends it to the buffer
164cdf0e10cSrcweir         // if pOutLength is set it will be updated to the emitted length
165cdf0e10cSrcweir         // (in PDF map mode, that is 10th of point)
166cdf0e10cSrcweir         void appendMappedLength( sal_Int32 nLength, rtl::OStringBuffer& rBuffer, bool bVertical = true, sal_Int32* pOutLength = NULL ) const;
167cdf0e10cSrcweir         // the same for double values
168cdf0e10cSrcweir         void appendMappedLength( double fLength, rtl::OStringBuffer& rBuffer, bool bVertical = true, sal_Int32* pOutLength = NULL, sal_Int32 nPrecision = 5 ) const;
169cdf0e10cSrcweir         // appends LineInfo
170cdf0e10cSrcweir         // returns false if too many dash array entry were created for
171cdf0e10cSrcweir         // the implementation limits of some PDF readers
172cdf0e10cSrcweir         bool appendLineInfo( const LineInfo& rInfo, rtl::OStringBuffer& rBuffer ) const;
173cdf0e10cSrcweir         // appends a horizontal waveline with vertical offset (helper for drawWaveLine)
174cdf0e10cSrcweir         void appendWaveLine( sal_Int32 nLength, sal_Int32 nYOffset, sal_Int32 nDelta, rtl::OStringBuffer& rBuffer ) const;
175cdf0e10cSrcweir 
getWidthvcl::PDFWriterImpl::PDFPage176cdf0e10cSrcweir         sal_Int32 getWidth() const { return m_nPageWidth ? m_nPageWidth : m_pWriter->m_nInheritedPageWidth; }
getHeightvcl::PDFWriterImpl::PDFPage177cdf0e10cSrcweir         sal_Int32 getHeight() const { return m_nPageHeight ? m_nPageHeight : m_pWriter->m_nInheritedPageHeight; }
178cdf0e10cSrcweir     };
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     friend struct PDFPage;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     struct BitmapID
183cdf0e10cSrcweir     {
184cdf0e10cSrcweir         Size		m_aPixelSize;
185cdf0e10cSrcweir         sal_Int32	m_nSize;
186cdf0e10cSrcweir         sal_Int32	m_nChecksum;
187cdf0e10cSrcweir         sal_Int32	m_nMaskChecksum;
188cdf0e10cSrcweir 
BitmapIDvcl::PDFWriterImpl::BitmapID189cdf0e10cSrcweir         BitmapID() : m_nSize( 0 ), m_nChecksum( 0 ), m_nMaskChecksum( 0 ) {}
190cdf0e10cSrcweir 
operator =vcl::PDFWriterImpl::BitmapID191cdf0e10cSrcweir         BitmapID& operator=( const BitmapID& rCopy )
192cdf0e10cSrcweir         {
193cdf0e10cSrcweir             m_aPixelSize	= rCopy.m_aPixelSize;
194cdf0e10cSrcweir             m_nSize			= rCopy.m_nSize;
195cdf0e10cSrcweir             m_nChecksum		= rCopy.m_nChecksum;
196cdf0e10cSrcweir             m_nMaskChecksum	= rCopy.m_nMaskChecksum;
197cdf0e10cSrcweir             return *this;
198cdf0e10cSrcweir         }
199cdf0e10cSrcweir 
operator ==vcl::PDFWriterImpl::BitmapID200cdf0e10cSrcweir         bool operator==( const BitmapID& rComp )
201cdf0e10cSrcweir         {
202cdf0e10cSrcweir             return (m_aPixelSize == rComp.m_aPixelSize &&
203cdf0e10cSrcweir                     m_nSize == rComp.m_nSize &&
204cdf0e10cSrcweir                     m_nChecksum == rComp.m_nChecksum &&
205cdf0e10cSrcweir                     m_nMaskChecksum == rComp.m_nMaskChecksum );
206cdf0e10cSrcweir         }
207cdf0e10cSrcweir     };
208cdf0e10cSrcweir 
209cdf0e10cSrcweir     struct BitmapEmit
210cdf0e10cSrcweir     {
211cdf0e10cSrcweir         BitmapID	m_aID;
212cdf0e10cSrcweir         BitmapEx	m_aBitmap;
213cdf0e10cSrcweir         sal_Int32	m_nObject;
214cdf0e10cSrcweir         bool		m_bDrawMask;
215cdf0e10cSrcweir 
BitmapEmitvcl::PDFWriterImpl::BitmapEmit216cdf0e10cSrcweir         BitmapEmit() : m_bDrawMask( false ) {}
217cdf0e10cSrcweir     };
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     struct JPGEmit
220cdf0e10cSrcweir     {
221cdf0e10cSrcweir         BitmapID			m_aID;
222cdf0e10cSrcweir         SvMemoryStream*		m_pStream;
223cdf0e10cSrcweir         Bitmap				m_aMask;
224cdf0e10cSrcweir         sal_Int32			m_nObject;
225cdf0e10cSrcweir         bool                m_bTrueColor;
226cdf0e10cSrcweir 
JPGEmitvcl::PDFWriterImpl::JPGEmit227cdf0e10cSrcweir         JPGEmit() : m_pStream( NULL ) {}
~JPGEmitvcl::PDFWriterImpl::JPGEmit228cdf0e10cSrcweir         ~JPGEmit() { delete m_pStream; }
229cdf0e10cSrcweir     };
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     struct GradientEmit
232cdf0e10cSrcweir     {
233cdf0e10cSrcweir         Gradient	m_aGradient;
234cdf0e10cSrcweir         Size		m_aSize;
235cdf0e10cSrcweir         sal_Int32	m_nObject;
236cdf0e10cSrcweir     };
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 	// for tilings (drawWallpaper, begin/endPattern)
239cdf0e10cSrcweir     struct TilingEmit
240cdf0e10cSrcweir     {
241cdf0e10cSrcweir         sal_Int32                   m_nObject;
242cdf0e10cSrcweir         Rectangle                   m_aRectangle;
243cdf0e10cSrcweir         Size                        m_aCellSize;
244cdf0e10cSrcweir         SvtGraphicFill::Transform   m_aTransform;
245cdf0e10cSrcweir         ResourceDict                m_aResources;
246cdf0e10cSrcweir         SvMemoryStream*             m_pTilingStream;
247cdf0e10cSrcweir 
TilingEmitvcl::PDFWriterImpl::TilingEmit248cdf0e10cSrcweir         TilingEmit()
249cdf0e10cSrcweir                 : m_nObject( 0 ),
250cdf0e10cSrcweir                   m_pTilingStream( NULL )
251cdf0e10cSrcweir         {}
252cdf0e10cSrcweir     };
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     // for transparency group XObjects
255cdf0e10cSrcweir     struct TransparencyEmit
256cdf0e10cSrcweir     {
257cdf0e10cSrcweir         sal_Int32			m_nObject;
258cdf0e10cSrcweir         sal_Int32			m_nExtGStateObject;
259cdf0e10cSrcweir         double				m_fAlpha;
260cdf0e10cSrcweir         Rectangle			m_aBoundRect;
261cdf0e10cSrcweir         SvMemoryStream*		m_pContentStream;
262cdf0e10cSrcweir         SvMemoryStream*		m_pSoftMaskStream;
263cdf0e10cSrcweir 
TransparencyEmitvcl::PDFWriterImpl::TransparencyEmit264cdf0e10cSrcweir         TransparencyEmit()
265cdf0e10cSrcweir                 : m_nObject( 0 ),
266cdf0e10cSrcweir                   m_nExtGStateObject( -1 ),
267cdf0e10cSrcweir                   m_fAlpha( 0.0 ),
268cdf0e10cSrcweir                   m_pContentStream( NULL ),
269cdf0e10cSrcweir                   m_pSoftMaskStream( NULL )
270cdf0e10cSrcweir         {}
~TransparencyEmitvcl::PDFWriterImpl::TransparencyEmit271cdf0e10cSrcweir         ~TransparencyEmit()
272cdf0e10cSrcweir         {
273cdf0e10cSrcweir             delete m_pContentStream;
274cdf0e10cSrcweir             delete m_pSoftMaskStream;
275cdf0e10cSrcweir         }
276cdf0e10cSrcweir     };
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     // font subsets
279cdf0e10cSrcweir     class GlyphEmit
280cdf0e10cSrcweir     {
281cdf0e10cSrcweir         // performance: actually this should probably a vector;
282cdf0e10cSrcweir         sal_Ucs		                    m_aBufferedUnicodes[3];
283cdf0e10cSrcweir         sal_Int32                       m_nUnicodes;
284cdf0e10cSrcweir         sal_Int32                       m_nMaxUnicodes;
285cdf0e10cSrcweir         boost::shared_array<sal_Ucs>    m_pUnicodes;
286cdf0e10cSrcweir         sal_uInt8                       m_nSubsetGlyphID;
287cdf0e10cSrcweir 
288cdf0e10cSrcweir     public:
GlyphEmit()289cdf0e10cSrcweir         GlyphEmit() : m_nUnicodes(0), m_nSubsetGlyphID(0)
290cdf0e10cSrcweir         {
291cdf0e10cSrcweir             rtl_zeroMemory( m_aBufferedUnicodes, sizeof( m_aBufferedUnicodes ) );
292cdf0e10cSrcweir             m_nMaxUnicodes = sizeof(m_aBufferedUnicodes)/sizeof(m_aBufferedUnicodes[0]);
293cdf0e10cSrcweir         }
~GlyphEmit()294cdf0e10cSrcweir         ~GlyphEmit()
295cdf0e10cSrcweir         {
296cdf0e10cSrcweir         }
297cdf0e10cSrcweir 
setGlyphId(sal_uInt8 i_nId)298cdf0e10cSrcweir         void setGlyphId( sal_uInt8 i_nId ) { m_nSubsetGlyphID = i_nId; }
getGlyphId() const299cdf0e10cSrcweir         sal_uInt8 getGlyphId() const { return m_nSubsetGlyphID; }
300cdf0e10cSrcweir 
addCode(sal_Ucs i_cCode)301cdf0e10cSrcweir         void addCode( sal_Ucs i_cCode )
302cdf0e10cSrcweir         {
303cdf0e10cSrcweir             if( m_nUnicodes == m_nMaxUnicodes )
304cdf0e10cSrcweir             {
305cdf0e10cSrcweir                 sal_Ucs* pNew = new sal_Ucs[ 2 * m_nMaxUnicodes];
306cdf0e10cSrcweir                 if( m_pUnicodes.get() )
307cdf0e10cSrcweir                     rtl_copyMemory( pNew, m_pUnicodes.get(), m_nMaxUnicodes * sizeof(sal_Ucs) );
308cdf0e10cSrcweir                 else
309cdf0e10cSrcweir                     rtl_copyMemory( pNew, m_aBufferedUnicodes, m_nMaxUnicodes * sizeof(sal_Ucs) );
310cdf0e10cSrcweir                 m_pUnicodes.reset( pNew );
311cdf0e10cSrcweir                 m_nMaxUnicodes *= 2;
312cdf0e10cSrcweir             }
313cdf0e10cSrcweir             if( m_pUnicodes.get() )
314cdf0e10cSrcweir                 m_pUnicodes[ m_nUnicodes++ ] = i_cCode;
315cdf0e10cSrcweir             else
316cdf0e10cSrcweir                 m_aBufferedUnicodes[ m_nUnicodes++ ] = i_cCode;
317cdf0e10cSrcweir         }
countCodes() const318cdf0e10cSrcweir         sal_Int32 countCodes() const { return m_nUnicodes; }
getCode(sal_Int32 i_nIndex) const319cdf0e10cSrcweir         sal_Ucs getCode( sal_Int32 i_nIndex ) const
320cdf0e10cSrcweir         {
321cdf0e10cSrcweir             sal_Ucs nRet = 0;
322cdf0e10cSrcweir             if( i_nIndex < m_nUnicodes )
323cdf0e10cSrcweir                 nRet = m_pUnicodes.get() ? m_pUnicodes[ i_nIndex ] : m_aBufferedUnicodes[ i_nIndex ];
324cdf0e10cSrcweir             return nRet;
325cdf0e10cSrcweir         }
326cdf0e10cSrcweir     };
327cdf0e10cSrcweir     typedef std::map< sal_GlyphId, GlyphEmit > FontEmitMapping;
328cdf0e10cSrcweir     struct FontEmit
329cdf0e10cSrcweir     {
330cdf0e10cSrcweir         sal_Int32			m_nFontID;
331cdf0e10cSrcweir         FontEmitMapping		m_aMapping;
332cdf0e10cSrcweir 
FontEmitvcl::PDFWriterImpl::FontEmit333cdf0e10cSrcweir         FontEmit( sal_Int32 nID ) : m_nFontID( nID ) {}
334cdf0e10cSrcweir     };
335cdf0e10cSrcweir     typedef std::list< FontEmit > FontEmitList;
336cdf0e10cSrcweir     struct Glyph
337cdf0e10cSrcweir     {
338cdf0e10cSrcweir         sal_Int32	m_nFontID;
339cdf0e10cSrcweir         sal_uInt8	m_nSubsetGlyphID;
340cdf0e10cSrcweir     };
341cdf0e10cSrcweir     typedef std::map< sal_GlyphId, Glyph > FontMapping;
342cdf0e10cSrcweir     struct FontSubset
343cdf0e10cSrcweir     {
344cdf0e10cSrcweir         FontEmitList		m_aSubsets;
345cdf0e10cSrcweir         FontMapping			m_aMapping;
346cdf0e10cSrcweir     };
347cdf0e10cSrcweir     typedef std::map< const ImplFontData*, FontSubset > FontSubsetData;
348cdf0e10cSrcweir     struct EmbedCode
349cdf0e10cSrcweir     {
350cdf0e10cSrcweir         sal_Ucs				m_aUnicode;
351cdf0e10cSrcweir         rtl::OString		m_aName;
352cdf0e10cSrcweir     };
353cdf0e10cSrcweir     struct EmbedEncoding
354cdf0e10cSrcweir     {
355cdf0e10cSrcweir         sal_Int32						m_nFontID;
356cdf0e10cSrcweir         std::vector< EmbedCode >		m_aEncVector;
357cdf0e10cSrcweir         std::map< sal_Ucs, sal_Int8 >	m_aCMap;
358cdf0e10cSrcweir     };
359cdf0e10cSrcweir     struct EmbedFont
360cdf0e10cSrcweir     {
361cdf0e10cSrcweir         sal_Int32						m_nNormalFontID;
362cdf0e10cSrcweir         std::list< EmbedEncoding >		m_aExtendedEncodings;
363cdf0e10cSrcweir 
EmbedFontvcl::PDFWriterImpl::EmbedFont364cdf0e10cSrcweir         EmbedFont() : m_nNormalFontID( 0 ) {}
365cdf0e10cSrcweir     };
366cdf0e10cSrcweir     typedef std::map< const ImplFontData*, EmbedFont > FontEmbedData;
367cdf0e10cSrcweir 
368cdf0e10cSrcweir     struct PDFDest
369cdf0e10cSrcweir     {
370cdf0e10cSrcweir         sal_Int32					m_nPage;
371cdf0e10cSrcweir         PDFWriter::DestAreaType		m_eType;
372cdf0e10cSrcweir         Rectangle					m_aRect;
373cdf0e10cSrcweir     };
374cdf0e10cSrcweir 
375cdf0e10cSrcweir //--->i56629
376cdf0e10cSrcweir     struct PDFNamedDest
377cdf0e10cSrcweir     {
378cdf0e10cSrcweir         rtl::OUString               m_aDestName;
379cdf0e10cSrcweir         sal_Int32					m_nPage;
380cdf0e10cSrcweir         PDFWriter::DestAreaType		m_eType;
381cdf0e10cSrcweir         Rectangle					m_aRect;
382cdf0e10cSrcweir     };
383cdf0e10cSrcweir //<---
384cdf0e10cSrcweir 
385cdf0e10cSrcweir     struct PDFOutlineEntry
386cdf0e10cSrcweir     {
387cdf0e10cSrcweir         sal_Int32					m_nParentID;
388cdf0e10cSrcweir         sal_Int32					m_nObject;
389cdf0e10cSrcweir         sal_Int32					m_nParentObject;
390cdf0e10cSrcweir         sal_Int32					m_nNextObject;
391cdf0e10cSrcweir         sal_Int32					m_nPrevObject;
392cdf0e10cSrcweir         std::vector< sal_Int32 >	m_aChildren;
393cdf0e10cSrcweir         rtl::OUString				m_aTitle;
394cdf0e10cSrcweir         sal_Int32					m_nDestID;
395cdf0e10cSrcweir 
PDFOutlineEntryvcl::PDFWriterImpl::PDFOutlineEntry396cdf0e10cSrcweir         PDFOutlineEntry()
397cdf0e10cSrcweir                 : m_nParentID( -1 ),
398cdf0e10cSrcweir                   m_nObject( 0 ),
399cdf0e10cSrcweir                   m_nParentObject( 0 ),
400cdf0e10cSrcweir                   m_nNextObject( 0 ),
401cdf0e10cSrcweir                   m_nPrevObject( 0 ),
402cdf0e10cSrcweir                   m_nDestID( -1 )
403cdf0e10cSrcweir         {}
404cdf0e10cSrcweir     };
405cdf0e10cSrcweir 
406cdf0e10cSrcweir     struct PDFAnnotation
407cdf0e10cSrcweir     {
408cdf0e10cSrcweir         sal_Int32					m_nObject;
409cdf0e10cSrcweir         Rectangle					m_aRect;
410cdf0e10cSrcweir         sal_Int32					m_nPage;
411cdf0e10cSrcweir 
PDFAnnotationvcl::PDFWriterImpl::PDFAnnotation412cdf0e10cSrcweir         PDFAnnotation()
413cdf0e10cSrcweir                 : m_nObject( -1 ),
414cdf0e10cSrcweir                   m_nPage( -1 )
415cdf0e10cSrcweir         {}
416cdf0e10cSrcweir     };
417cdf0e10cSrcweir 
418cdf0e10cSrcweir     struct PDFLink : public PDFAnnotation
419cdf0e10cSrcweir     {
420cdf0e10cSrcweir         sal_Int32					m_nDest; // set to -1 for URL, to a dest else
421cdf0e10cSrcweir         rtl::OUString				m_aURL;
422cdf0e10cSrcweir         sal_Int32                   m_nStructParent; // struct parent entry
423cdf0e10cSrcweir 
PDFLinkvcl::PDFWriterImpl::PDFLink424cdf0e10cSrcweir         PDFLink()
425cdf0e10cSrcweir                 : m_nDest( -1 ),
426cdf0e10cSrcweir                   m_nStructParent( -1 )
427cdf0e10cSrcweir         {}
428cdf0e10cSrcweir     };
429cdf0e10cSrcweir 
430cdf0e10cSrcweir     struct PDFNoteEntry : public PDFAnnotation
431cdf0e10cSrcweir     {
432cdf0e10cSrcweir         PDFNote						m_aContents;
433cdf0e10cSrcweir 
PDFNoteEntryvcl::PDFWriterImpl::PDFNoteEntry434cdf0e10cSrcweir         PDFNoteEntry()
435cdf0e10cSrcweir         {}
436cdf0e10cSrcweir     };
437cdf0e10cSrcweir 
438cdf0e10cSrcweir     typedef std::hash_map< rtl::OString, SvMemoryStream*, rtl::OStringHash > PDFAppearanceStreams;
439cdf0e10cSrcweir     typedef std::hash_map< rtl::OString, PDFAppearanceStreams, rtl::OStringHash > PDFAppearanceMap;
440cdf0e10cSrcweir 
441cdf0e10cSrcweir     struct PDFWidget : public PDFAnnotation
442cdf0e10cSrcweir     {
443cdf0e10cSrcweir         PDFWriter::WidgetType		m_eType;
444cdf0e10cSrcweir         rtl::OString				m_aName;
445cdf0e10cSrcweir         rtl::OUString				m_aDescription;
446cdf0e10cSrcweir         rtl::OUString				m_aText;
447cdf0e10cSrcweir         sal_uInt16						m_nTextStyle;
448cdf0e10cSrcweir         rtl::OUString				m_aValue;
449cdf0e10cSrcweir         rtl::OString                m_aDAString;
450cdf0e10cSrcweir         rtl::OString                m_aDRDict;
451cdf0e10cSrcweir         rtl::OString				m_aMKDict;
452cdf0e10cSrcweir 		rtl::OString				m_aMKDictCAString;	// i12626, added to be able to encrypt the /CA text string
453cdf0e10cSrcweir 														// since the object number is not known at the moment
454cdf0e10cSrcweir 														// of filling m_aMKDict, the string will be encrypted when emitted.
455cdf0e10cSrcweir 														// the /CA string MUST BE the last added to m_aMKDict
456cdf0e10cSrcweir 														// see code for details
457cdf0e10cSrcweir         sal_Int32					m_nFlags;
458cdf0e10cSrcweir         sal_Int32					m_nParent; // if not 0, parent's object number
459cdf0e10cSrcweir         std::vector<sal_Int32>		m_aKids; // widget children, contains object numbers
460cdf0e10cSrcweir         std::vector<sal_Int32>      m_aKidsIndex; // widget children, contains index to m_aWidgets
461cdf0e10cSrcweir         rtl::OUString               m_aOnValue;
462cdf0e10cSrcweir         sal_Int32                   m_nTabOrder; // lowest number gets first in tab order
463cdf0e10cSrcweir         sal_Int32					m_nRadioGroup;
464cdf0e10cSrcweir         sal_Int32					m_nMaxLen;
465cdf0e10cSrcweir         bool                        m_bSubmit;
466cdf0e10cSrcweir         bool                        m_bSubmitGet;
467cdf0e10cSrcweir         sal_Int32                   m_nDest;
468cdf0e10cSrcweir         std::vector<rtl::OUString>	m_aListEntries;
469cdf0e10cSrcweir         std::vector<sal_Int32>      m_aSelectedEntries;
470cdf0e10cSrcweir         PDFAppearanceMap			m_aAppearances;
PDFWidgetvcl::PDFWriterImpl::PDFWidget471cdf0e10cSrcweir         PDFWidget()
472cdf0e10cSrcweir                 : m_eType( PDFWriter::PushButton ),
473cdf0e10cSrcweir                   m_nTextStyle( 0 ),
474cdf0e10cSrcweir                   m_nFlags( 0 ),
475cdf0e10cSrcweir                   m_nParent( 0 ),
476cdf0e10cSrcweir                   m_nRadioGroup( -1 ),
477cdf0e10cSrcweir                   m_nMaxLen( 0 ),
478cdf0e10cSrcweir                   m_bSubmit( false ),
479cdf0e10cSrcweir                   m_bSubmitGet( false ),
480cdf0e10cSrcweir                   m_nDest( -1 )
481cdf0e10cSrcweir         {}
482cdf0e10cSrcweir     };
483cdf0e10cSrcweir 
484cdf0e10cSrcweir     struct PDFStructureAttribute
485cdf0e10cSrcweir     {
486cdf0e10cSrcweir         PDFWriter::StructAttributeValue		eValue;
487cdf0e10cSrcweir         sal_Int32							nValue;
488cdf0e10cSrcweir 
PDFStructureAttributevcl::PDFWriterImpl::PDFStructureAttribute489cdf0e10cSrcweir         PDFStructureAttribute()
490cdf0e10cSrcweir                 : eValue( PDFWriter::Invalid ),
491cdf0e10cSrcweir                   nValue( 0 )
492cdf0e10cSrcweir         {}
493cdf0e10cSrcweir 
PDFStructureAttributevcl::PDFWriterImpl::PDFStructureAttribute494cdf0e10cSrcweir         PDFStructureAttribute( PDFWriter::StructAttributeValue eVal )
495cdf0e10cSrcweir                 : eValue( eVal ),
496cdf0e10cSrcweir                   nValue( 0 )
497cdf0e10cSrcweir         {}
498cdf0e10cSrcweir 
PDFStructureAttributevcl::PDFWriterImpl::PDFStructureAttribute499cdf0e10cSrcweir         PDFStructureAttribute( sal_Int32 nVal )
500cdf0e10cSrcweir                 : eValue( PDFWriter::Invalid ),
501cdf0e10cSrcweir                   nValue( nVal )
502cdf0e10cSrcweir         {}
503cdf0e10cSrcweir     };
504cdf0e10cSrcweir 
505cdf0e10cSrcweir     typedef std::map<PDFWriter::StructAttribute, PDFStructureAttribute > PDFStructAttributes;
506cdf0e10cSrcweir 
507cdf0e10cSrcweir     struct PDFStructureElementKid // for Kids entries
508cdf0e10cSrcweir     {
509cdf0e10cSrcweir         sal_Int32 nObject;  // an object number if nMCID is -1,
510cdf0e10cSrcweir                             // else the page object relevant to MCID
511cdf0e10cSrcweir         sal_Int32 nMCID;    // an MCID if >= 0
512cdf0e10cSrcweir 
PDFStructureElementKidvcl::PDFWriterImpl::PDFStructureElementKid513cdf0e10cSrcweir         PDFStructureElementKid( sal_Int32 nObj ) : nObject( nObj ), nMCID( -1 ) {}
PDFStructureElementKidvcl::PDFWriterImpl::PDFStructureElementKid514cdf0e10cSrcweir         PDFStructureElementKid( sal_Int32 MCID, sal_Int32 nPage ) : nObject( nPage ), nMCID( MCID ) {}
515cdf0e10cSrcweir     };
516cdf0e10cSrcweir 
517cdf0e10cSrcweir     struct PDFStructureElement
518cdf0e10cSrcweir     {
519cdf0e10cSrcweir         sal_Int32											m_nObject;
520cdf0e10cSrcweir         PDFWriter::StructElement							m_eType;
521cdf0e10cSrcweir         rtl::OString                                        m_aAlias;
522cdf0e10cSrcweir         sal_Int32											m_nOwnElement; // index into structure vector
523cdf0e10cSrcweir         sal_Int32											m_nParentElement; // index into structure vector
524cdf0e10cSrcweir         sal_Int32											m_nFirstPageObject;
525cdf0e10cSrcweir         bool												m_bOpenMCSeq;
526cdf0e10cSrcweir         std::list< sal_Int32 >								m_aChildren; // indexes into structure vector
527cdf0e10cSrcweir         std::list< PDFStructureElementKid >                 m_aKids;
528cdf0e10cSrcweir         PDFStructAttributes									m_aAttributes;
529cdf0e10cSrcweir         Rectangle											m_aBBox;
530cdf0e10cSrcweir         rtl::OUString										m_aActualText;
531cdf0e10cSrcweir         rtl::OUString										m_aAltText;
532cdf0e10cSrcweir         com::sun::star::lang::Locale                        m_aLocale;
533cdf0e10cSrcweir 
534cdf0e10cSrcweir         // m_aContents contains the element's marked content sequence
535cdf0e10cSrcweir         // as pairs of (page nr, MCID)
536cdf0e10cSrcweir 
PDFStructureElementvcl::PDFWriterImpl::PDFStructureElement537cdf0e10cSrcweir         PDFStructureElement()
538cdf0e10cSrcweir                 : m_nObject( 0 ),
539cdf0e10cSrcweir                   m_eType( PDFWriter::NonStructElement ),
540cdf0e10cSrcweir                   m_nOwnElement( -1 ),
541cdf0e10cSrcweir                   m_nParentElement( -1 ),
542cdf0e10cSrcweir                   m_nFirstPageObject( 0 ),
543cdf0e10cSrcweir                   m_bOpenMCSeq( false )
544cdf0e10cSrcweir         {
545cdf0e10cSrcweir         }
546cdf0e10cSrcweir 
547cdf0e10cSrcweir     };
548cdf0e10cSrcweir 
549cdf0e10cSrcweir     struct PDFAddStream
550cdf0e10cSrcweir     {
551cdf0e10cSrcweir         rtl::OUString           m_aMimeType;
552cdf0e10cSrcweir         PDFOutputStream*        m_pStream;
553cdf0e10cSrcweir         sal_Int32               m_nStreamObject;
554cdf0e10cSrcweir         bool                    m_bCompress;
555cdf0e10cSrcweir 
PDFAddStreamvcl::PDFWriterImpl::PDFAddStream556cdf0e10cSrcweir         PDFAddStream() : m_pStream( NULL ), m_nStreamObject( 0 ), m_bCompress( true ) {}
557cdf0e10cSrcweir     };
558cdf0e10cSrcweir 
559cdf0e10cSrcweir 
560cdf0e10cSrcweir     // helper structure for drawLayout and friends
561cdf0e10cSrcweir     struct PDFGlyph
562cdf0e10cSrcweir     {
563cdf0e10cSrcweir         Point       m_aPos;
564cdf0e10cSrcweir         sal_Int32   m_nNativeWidth;
565cdf0e10cSrcweir         sal_Int32   m_nGlyphId;
566cdf0e10cSrcweir         sal_Int32   m_nMappedFontId;
567cdf0e10cSrcweir         sal_uInt8   m_nMappedGlyphId;
568cdf0e10cSrcweir 
PDFGlyphvcl::PDFWriterImpl::PDFGlyph569cdf0e10cSrcweir         PDFGlyph( const Point& rPos,
570cdf0e10cSrcweir                   sal_Int32 nNativeWidth,
571cdf0e10cSrcweir                   sal_Int32 nGlyphId,
572cdf0e10cSrcweir                   sal_Int32 nFontId,
573cdf0e10cSrcweir                   sal_uInt8 nMappedGlyphId )
574cdf0e10cSrcweir         : m_aPos( rPos ), m_nNativeWidth( nNativeWidth ), m_nGlyphId( nGlyphId ),
575cdf0e10cSrcweir           m_nMappedFontId( nFontId ), m_nMappedGlyphId( nMappedGlyphId )
576cdf0e10cSrcweir         {}
577cdf0e10cSrcweir     };
578cdf0e10cSrcweir 
579cdf0e10cSrcweir 
580cdf0e10cSrcweir     static const sal_Char* getStructureTag( PDFWriter::StructElement );
581cdf0e10cSrcweir     static const sal_Char* getAttributeTag( PDFWriter::StructAttribute eAtr );
582cdf0e10cSrcweir     static const sal_Char* getAttributeValueTag( PDFWriter::StructAttributeValue eVal );
583cdf0e10cSrcweir 
584cdf0e10cSrcweir     // returns true if compression was done
585cdf0e10cSrcweir     // else false
586cdf0e10cSrcweir     static bool compressStream( SvMemoryStream* );
587cdf0e10cSrcweir 
588cdf0e10cSrcweir     static void convertLineInfoToExtLineInfo( const LineInfo& rIn, PDFWriter::ExtLineInfo& rOut );
589cdf0e10cSrcweir private:
590cdf0e10cSrcweir     static const BuiltinFont m_aBuiltinFonts[14];
591cdf0e10cSrcweir 
592cdf0e10cSrcweir     OutputDevice*						m_pReferenceDevice;
593cdf0e10cSrcweir 
594cdf0e10cSrcweir     MapMode								m_aMapMode; // PDFWriterImpl scaled units
595cdf0e10cSrcweir     std::vector< PDFPage >				m_aPages;
596cdf0e10cSrcweir     /* maps object numbers to file offsets (needed for xref) */
597cdf0e10cSrcweir     std::vector< sal_uInt64 >			m_aObjects;
598cdf0e10cSrcweir     /* contains Bitmaps until they are written to the
599cdf0e10cSrcweir      *  file stream as XObjects*/
600cdf0e10cSrcweir     std::list< BitmapEmit >				m_aBitmaps;
601cdf0e10cSrcweir     /* contains JPG streams until written to file     */
602cdf0e10cSrcweir     std::list<JPGEmit>					m_aJPGs;
603cdf0e10cSrcweir     /*--->i56629 contains all named destinations ever set during the PDF creation,
604cdf0e10cSrcweir        destination id is always the destination's position in this vector
605cdf0e10cSrcweir      */
606cdf0e10cSrcweir     std::vector<PDFNamedDest>		    m_aNamedDests;
607cdf0e10cSrcweir     //<---
608cdf0e10cSrcweir     /* contains all dests ever set during the PDF creation,
609cdf0e10cSrcweir        dest id is always the dest's position in this vector
610cdf0e10cSrcweir      */
611cdf0e10cSrcweir     std::vector<PDFDest>				m_aDests;
612cdf0e10cSrcweir     /** contains destinations accessible via a public Id, instead of being linked to by an ordinary link
613cdf0e10cSrcweir     */
614cdf0e10cSrcweir     ::std::map< sal_Int32, sal_Int32 >  m_aDestinationIdTranslation;
615cdf0e10cSrcweir     /* contains all links ever set during PDF creation,
616cdf0e10cSrcweir        link id is always the link's position in this vector
617cdf0e10cSrcweir     */
618cdf0e10cSrcweir     std::vector<PDFLink>				m_aLinks;
619cdf0e10cSrcweir     /* makes correctly encoded for export to PDF URLS
620cdf0e10cSrcweir     */
621cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > m_xTrans;
622cdf0e10cSrcweir     /* maps arbitrary link ids for structure attributes to real link ids
623cdf0e10cSrcweir        (for setLinkPropertyId)
624cdf0e10cSrcweir     */
625cdf0e10cSrcweir     std::map<sal_Int32, sal_Int32>		m_aLinkPropertyMap;
626cdf0e10cSrcweir     /* contains all outline items,
627cdf0e10cSrcweir        object 0 is the outline root
628cdf0e10cSrcweir      */
629cdf0e10cSrcweir     std::vector<PDFOutlineEntry>		m_aOutline;
630cdf0e10cSrcweir     /* contains all notes set during PDF creation
631cdf0e10cSrcweir      */
632cdf0e10cSrcweir     std::vector<PDFNoteEntry>			m_aNotes;
633cdf0e10cSrcweir 	/* the root of the structure tree
634cdf0e10cSrcweir      */
635cdf0e10cSrcweir     std::vector<PDFStructureElement>	m_aStructure;
636cdf0e10cSrcweir     /* current object in the structure hierarchy
637cdf0e10cSrcweir      */
638cdf0e10cSrcweir     sal_Int32							m_nCurrentStructElement;
639cdf0e10cSrcweir     /* structure parent tree */
640cdf0e10cSrcweir     std::vector< rtl::OString >         m_aStructParentTree;
641cdf0e10cSrcweir     /* emit strucure marks currently (aka. NonStructElement or not)
642cdf0e10cSrcweir      */
643cdf0e10cSrcweir     bool								m_bEmitStructure;
644cdf0e10cSrcweir     bool								m_bNewMCID;
645cdf0e10cSrcweir     /* role map of struct tree root */
646cdf0e10cSrcweir     std::hash_map< rtl::OString, rtl::OString, rtl::OStringHash >
647cdf0e10cSrcweir                                         m_aRoleMap;
648cdf0e10cSrcweir 
649cdf0e10cSrcweir     /* contains all widgets used in the PDF
650cdf0e10cSrcweir      */
651cdf0e10cSrcweir     std::vector<PDFWidget>				m_aWidgets;
652cdf0e10cSrcweir     /* maps radio group id to index of radio group control in m_aWidgets */
653cdf0e10cSrcweir     std::map< sal_Int32, sal_Int32 >	m_aRadioGroupWidgets;
654cdf0e10cSrcweir     /* used to store control id during beginControlAppearance/endControlAppearance */
655cdf0e10cSrcweir     sal_Int32							m_nCurrentControl;
656cdf0e10cSrcweir     /* hash_map for field names, used to ensure unique field names */
657cdf0e10cSrcweir     std::hash_map< rtl::OString, sal_Int32, rtl::OStringHash > m_aFieldNameMap;
658cdf0e10cSrcweir 
659cdf0e10cSrcweir     /* contains Bitmaps for gradient functions until they are written
660cdf0e10cSrcweir      *  to the file stream */
661cdf0e10cSrcweir     std::list< GradientEmit >			m_aGradients;
662cdf0e10cSrcweir     /* contains bitmap tiling patterns */
663cdf0e10cSrcweir     std::vector< TilingEmit >		    m_aTilings;
664cdf0e10cSrcweir     std::list< TransparencyEmit >		m_aTransparentObjects;
665cdf0e10cSrcweir     /*  contains all font subsets in use */
666cdf0e10cSrcweir     FontSubsetData						m_aSubsets;
667cdf0e10cSrcweir     bool                                m_bEmbedStandardFonts;
668cdf0e10cSrcweir     FontEmbedData						m_aEmbeddedFonts;
669cdf0e10cSrcweir     FontEmbedData                       m_aSystemFonts;
670cdf0e10cSrcweir     sal_Int32							m_nNextFID;
671cdf0e10cSrcweir     PDFFontCache                        m_aFontCache;
672cdf0e10cSrcweir 
673cdf0e10cSrcweir     sal_Int32							m_nInheritedPageWidth;  // in inch/72
674cdf0e10cSrcweir     sal_Int32							m_nInheritedPageHeight; // in inch/72
675cdf0e10cSrcweir     PDFWriter::Orientation				m_eInheritedOrientation;
676cdf0e10cSrcweir     sal_Int32							m_nCurrentPage;
677cdf0e10cSrcweir 
678cdf0e10cSrcweir     sal_Int32							m_nCatalogObject;
679cdf0e10cSrcweir     sal_Int32							m_nResourceDict;
680cdf0e10cSrcweir     ResourceDict                        m_aGlobalResourceDict;
681cdf0e10cSrcweir     sal_Int32                           m_nFontDictObject;
682cdf0e10cSrcweir     std::map< sal_Int32, sal_Int32 >    m_aBuiltinFontToObjectMap;
683cdf0e10cSrcweir 
684cdf0e10cSrcweir     PDFWriter::PDFWriterContext			m_aContext;
685cdf0e10cSrcweir     oslFileHandle						m_aFile;
686cdf0e10cSrcweir     bool								m_bOpen;
687cdf0e10cSrcweir 
688cdf0e10cSrcweir 
689cdf0e10cSrcweir     /* output redirection; e.g. to accumulate content streams for
690cdf0e10cSrcweir        XObjects
691cdf0e10cSrcweir      */
692cdf0e10cSrcweir     struct StreamRedirect
693cdf0e10cSrcweir     {
694cdf0e10cSrcweir         SvStream*		m_pStream;
695cdf0e10cSrcweir         MapMode   		m_aMapMode;
696cdf0e10cSrcweir         Rectangle       m_aTargetRect;
697cdf0e10cSrcweir         ResourceDict    m_aResourceDict;
698cdf0e10cSrcweir     };
699cdf0e10cSrcweir     std::list< StreamRedirect >			m_aOutputStreams;
700cdf0e10cSrcweir 
701cdf0e10cSrcweir     // graphics state
702cdf0e10cSrcweir     struct GraphicsState
703cdf0e10cSrcweir     {
704cdf0e10cSrcweir         Font			                 m_aFont;
705cdf0e10cSrcweir         MapMode			                 m_aMapMode;
706cdf0e10cSrcweir         Color			                 m_aLineColor;
707cdf0e10cSrcweir         Color			                 m_aFillColor;
708cdf0e10cSrcweir         Color			                 m_aTextLineColor;
709cdf0e10cSrcweir         Color			                 m_aOverlineColor;
710cdf0e10cSrcweir         basegfx::B2DPolyPolygon			 m_aClipRegion;
711cdf0e10cSrcweir         bool                             m_bClipRegion;
712cdf0e10cSrcweir         sal_Int32		                 m_nAntiAlias;
713cdf0e10cSrcweir         sal_Int32		                 m_nLayoutMode;
714cdf0e10cSrcweir         LanguageType                     m_aDigitLanguage;
715cdf0e10cSrcweir         sal_Int32		                 m_nTransparentPercent;
716cdf0e10cSrcweir         sal_uInt16		                 m_nFlags;
717cdf0e10cSrcweir         sal_uInt16                       m_nUpdateFlags;
718cdf0e10cSrcweir 
719cdf0e10cSrcweir         static const sal_uInt16 updateFont                  = 0x0001;
720cdf0e10cSrcweir         static const sal_uInt16 updateMapMode               = 0x0002;
721cdf0e10cSrcweir         static const sal_uInt16 updateLineColor             = 0x0004;
722cdf0e10cSrcweir         static const sal_uInt16 updateFillColor             = 0x0008;
723cdf0e10cSrcweir         static const sal_uInt16 updateTextLineColor         = 0x0010;
724cdf0e10cSrcweir         static const sal_uInt16 updateOverlineColor         = 0x0020;
725cdf0e10cSrcweir         static const sal_uInt16 updateClipRegion            = 0x0040;
726cdf0e10cSrcweir         static const sal_uInt16 updateAntiAlias             = 0x0080;
727cdf0e10cSrcweir         static const sal_uInt16 updateLayoutMode            = 0x0100;
728cdf0e10cSrcweir         static const sal_uInt16 updateTransparentPercent    = 0x0200;
729cdf0e10cSrcweir         static const sal_uInt16 updateDigitLanguage         = 0x0400;
730cdf0e10cSrcweir 
GraphicsStatevcl::PDFWriterImpl::GraphicsState731cdf0e10cSrcweir         GraphicsState() :
732cdf0e10cSrcweir                 m_aLineColor( COL_TRANSPARENT ),
733cdf0e10cSrcweir                 m_aFillColor( COL_TRANSPARENT ),
734cdf0e10cSrcweir                 m_aTextLineColor( COL_TRANSPARENT ),
735cdf0e10cSrcweir                 m_aOverlineColor( COL_TRANSPARENT ),
736cdf0e10cSrcweir                 m_bClipRegion( false ),
737cdf0e10cSrcweir                 m_nAntiAlias( 1 ),
738cdf0e10cSrcweir                 m_nLayoutMode( 0 ),
739cdf0e10cSrcweir                 m_aDigitLanguage( 0 ),
740cdf0e10cSrcweir                 m_nTransparentPercent( 0 ),
741cdf0e10cSrcweir                 m_nFlags( 0xffff ),
742cdf0e10cSrcweir                 m_nUpdateFlags( 0xffff )
743cdf0e10cSrcweir         {}
GraphicsStatevcl::PDFWriterImpl::GraphicsState744cdf0e10cSrcweir         GraphicsState( const GraphicsState& rState ) :
745cdf0e10cSrcweir                 m_aFont( rState.m_aFont ),
746cdf0e10cSrcweir                 m_aMapMode( rState.m_aMapMode ),
747cdf0e10cSrcweir                 m_aLineColor( rState.m_aLineColor ),
748cdf0e10cSrcweir                 m_aFillColor( rState.m_aFillColor ),
749cdf0e10cSrcweir                 m_aTextLineColor( rState.m_aTextLineColor ),
750cdf0e10cSrcweir                 m_aOverlineColor( rState.m_aOverlineColor ),
751cdf0e10cSrcweir                 m_aClipRegion( rState.m_aClipRegion ),
752cdf0e10cSrcweir                 m_bClipRegion( rState.m_bClipRegion ),
753cdf0e10cSrcweir                 m_nAntiAlias( rState.m_nAntiAlias ),
754cdf0e10cSrcweir                 m_nLayoutMode( rState.m_nLayoutMode ),
755cdf0e10cSrcweir                 m_aDigitLanguage( rState.m_aDigitLanguage ),
756cdf0e10cSrcweir                 m_nTransparentPercent( rState.m_nTransparentPercent ),
757cdf0e10cSrcweir                 m_nFlags( rState.m_nFlags ),
758cdf0e10cSrcweir                 m_nUpdateFlags( rState.m_nUpdateFlags )
759cdf0e10cSrcweir         {
760cdf0e10cSrcweir         }
761cdf0e10cSrcweir 
operator =vcl::PDFWriterImpl::GraphicsState762cdf0e10cSrcweir         GraphicsState& operator=(const GraphicsState& rState )
763cdf0e10cSrcweir         {
764cdf0e10cSrcweir             m_aFont					= rState.m_aFont;
765cdf0e10cSrcweir             m_aMapMode				= rState.m_aMapMode;
766cdf0e10cSrcweir             m_aLineColor			= rState.m_aLineColor;
767cdf0e10cSrcweir             m_aFillColor			= rState.m_aFillColor;
768cdf0e10cSrcweir             m_aTextLineColor		= rState.m_aTextLineColor;
769cdf0e10cSrcweir             m_aOverlineColor		= rState.m_aOverlineColor;
770cdf0e10cSrcweir             m_aClipRegion			= rState.m_aClipRegion;
771cdf0e10cSrcweir             m_bClipRegion           = rState.m_bClipRegion;
772cdf0e10cSrcweir             m_nAntiAlias			= rState.m_nAntiAlias;
773cdf0e10cSrcweir             m_nLayoutMode			= rState.m_nLayoutMode;
774cdf0e10cSrcweir             m_aDigitLanguage        = rState.m_aDigitLanguage;
775cdf0e10cSrcweir             m_nTransparentPercent	= rState.m_nTransparentPercent;
776cdf0e10cSrcweir             m_nFlags				= rState.m_nFlags;
777cdf0e10cSrcweir             m_nUpdateFlags          = rState.m_nUpdateFlags;
778cdf0e10cSrcweir             return *this;
779cdf0e10cSrcweir         }
780cdf0e10cSrcweir     };
781cdf0e10cSrcweir     std::list< GraphicsState >				m_aGraphicsStack;
782cdf0e10cSrcweir     GraphicsState							m_aCurrentPDFState;
783cdf0e10cSrcweir 
784cdf0e10cSrcweir     ZCodec*									m_pCodec;
785cdf0e10cSrcweir     SvMemoryStream*							m_pMemStream;
786cdf0e10cSrcweir 
787cdf0e10cSrcweir     std::vector< PDFAddStream >             m_aAdditionalStreams;
788cdf0e10cSrcweir     std::set< PDFWriter::ErrorCode >        m_aErrors;
789cdf0e10cSrcweir 
790cdf0e10cSrcweir     rtlDigest                               m_aDocDigest;
791cdf0e10cSrcweir 
792cdf0e10cSrcweir /*
793cdf0e10cSrcweir variables for PDF security
794cdf0e10cSrcweir i12626
795cdf0e10cSrcweir */
796cdf0e10cSrcweir /* used to cipher the stream data and for password management */
797cdf0e10cSrcweir 	rtlCipher								m_aCipher;
798cdf0e10cSrcweir 	rtlDigest								m_aDigest;
799cdf0e10cSrcweir 	/* pad string used for password in Standard security handler */
800cdf0e10cSrcweir 	static const sal_uInt8					s_nPadString[ENCRYPTED_PWD_SIZE];
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 	/* the encryption key, formed with the user password according to algorithm 3.2, maximum length is 16 bytes + 3 + 2
803cdf0e10cSrcweir 	for 128 bit security   */
804cdf0e10cSrcweir 	sal_Int32								m_nKeyLength; // key length, 16 or 5
805cdf0e10cSrcweir 	sal_Int32								m_nRC4KeyLength; // key length, 16 or 10, to be input to the algorith 3.1
806cdf0e10cSrcweir 
807cdf0e10cSrcweir 	/* set to true if the following stream must be encrypted, used inside writeBuffer() */
808cdf0e10cSrcweir 	sal_Bool								m_bEncryptThisStream;
809cdf0e10cSrcweir 
810cdf0e10cSrcweir 	/* the numerical value of the access permissions, according to PDF spec, must be signed */
811cdf0e10cSrcweir 	sal_Int32                               m_nAccessPermissions;
812cdf0e10cSrcweir 	/* string to hold the PDF creation date */
813cdf0e10cSrcweir 	rtl::OString						    m_aCreationDateString;
814cdf0e10cSrcweir 	/* string to hold the PDF creation date, for PDF/A metadata */
815cdf0e10cSrcweir 	rtl::OString						    m_aCreationMetaDateString;
816cdf0e10cSrcweir 	/* the buffer where the data are encrypted, dynamically allocated */
817cdf0e10cSrcweir 	sal_uInt8								*m_pEncryptionBuffer;
818cdf0e10cSrcweir 	/* size of the buffer */
819cdf0e10cSrcweir 	sal_Int32								m_nEncryptionBufferSize;
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 	/* check and reallocate the buffer for encryption */
822*c1e8cc3aSDon Lewis 	sal_Bool checkEncryptionBufferSize( sal_Int32 newSize );
823cdf0e10cSrcweir 	/* this function implements part of the PDF spec algorithm 3.1 in encryption, the rest (the actual encryption) is in PDFWriterImpl::writeBuffer */
824*c1e8cc3aSDon Lewis     void checkAndEnableStreamEncryption( sal_Int32 nObject );
825cdf0e10cSrcweir 
disableStreamEncryption()826cdf0e10cSrcweir 	void disableStreamEncryption() { m_bEncryptThisStream = false; };
827cdf0e10cSrcweir 
828cdf0e10cSrcweir 	/* */
829*c1e8cc3aSDon Lewis     void enableStringEncryption( sal_Int32 nObject );
830cdf0e10cSrcweir 
831cdf0e10cSrcweir // test if the encryption is active, if yes than encrypt the unicode string  and add to the OStringBuffer parameter
832cdf0e10cSrcweir 	void appendUnicodeTextStringEncrypt( const rtl::OUString& rInString, const sal_Int32 nInObjectNumber, rtl::OStringBuffer& rOutBuffer );
833cdf0e10cSrcweir 
834cdf0e10cSrcweir 	void appendLiteralStringEncrypt( const rtl::OUString& rInString, const sal_Int32 nInObjectNumber, rtl::OStringBuffer& rOutBuffer, rtl_TextEncoding nEnc = RTL_TEXTENCODING_ASCII_US );
835cdf0e10cSrcweir 	void appendLiteralStringEncrypt( const rtl::OString& rInString, const sal_Int32 nInObjectNumber, rtl::OStringBuffer& rOutBuffer );
836cdf0e10cSrcweir 	void appendLiteralStringEncrypt( rtl::OStringBuffer& rInString, const sal_Int32 nInObjectNumber, rtl::OStringBuffer& rOutBuffer );
837cdf0e10cSrcweir 
838cdf0e10cSrcweir     /* creates fonts and subsets that will be emitted later */
839cdf0e10cSrcweir     void registerGlyphs( int nGlyphs, sal_GlyphId* pGlyphs, sal_Int32* pGlpyhWidths, sal_Ucs* pUnicodes, sal_Int32* pUnicodesPerGlyph, sal_uInt8* pMappedGlyphs, sal_Int32* pMappedFontObjects, const ImplFontData* pFallbackFonts[] );
840cdf0e10cSrcweir 
841cdf0e10cSrcweir     /*  emits a text object according to the passed layout */
842cdf0e10cSrcweir     /* TODO: remove rText as soon as SalLayout will change so that rText is not necessary anymore */
843cdf0e10cSrcweir     void drawVerticalGlyphs( const std::vector<PDFGlyph>& rGlyphs, rtl::OStringBuffer& rLine, const Point& rAlignOffset, const Matrix3& rRotScale, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight );
844cdf0e10cSrcweir     void drawHorizontalGlyphs( const std::vector<PDFGlyph>& rGlyphs, rtl::OStringBuffer& rLine, const Point& rAlignOffset, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight, sal_Int32 nPixelFontHeight );
845cdf0e10cSrcweir     void drawLayout( SalLayout& rLayout, const String& rText, bool bTextLines );
846cdf0e10cSrcweir     void drawRelief( SalLayout& rLayout, const String& rText, bool bTextLines );
847cdf0e10cSrcweir     void drawShadow( SalLayout& rLayout, const String& rText, bool bTextLines );
848cdf0e10cSrcweir 
849cdf0e10cSrcweir     /*  writes differences between graphics stack and current real PDF
850cdf0e10cSrcweir      *   state to the file
851cdf0e10cSrcweir      */
852cdf0e10cSrcweir     void updateGraphicsState();
853cdf0e10cSrcweir 
854cdf0e10cSrcweir     /* writes a transparency group object */
855cdf0e10cSrcweir     bool writeTransparentObject( TransparencyEmit& rObject );
856cdf0e10cSrcweir 
857cdf0e10cSrcweir     /* writes an XObject of type image, may create
858cdf0e10cSrcweir        a second for the mask
859cdf0e10cSrcweir      */
860cdf0e10cSrcweir     bool writeBitmapObject( BitmapEmit& rObject, bool bMask = false );
861cdf0e10cSrcweir 
862cdf0e10cSrcweir     bool writeJPG( JPGEmit& rEmit );
863cdf0e10cSrcweir 
864cdf0e10cSrcweir     /* tries to find the bitmap by its id and returns its emit data if exists,
865cdf0e10cSrcweir        else creates a new emit data block */
866cdf0e10cSrcweir     const BitmapEmit& createBitmapEmit( const BitmapEx& rBitmapEx, bool bDrawMask = false );
867cdf0e10cSrcweir 
868cdf0e10cSrcweir     /* writes the Do operation inside the content stream */
869cdf0e10cSrcweir     void drawBitmap( const Point& rDestPt, const Size& rDestSize, const BitmapEmit& rBitmap, const Color& rFillColor );
870cdf0e10cSrcweir     /* write the function object for a Gradient */
871cdf0e10cSrcweir     bool writeGradientFunction( GradientEmit& rObject );
872cdf0e10cSrcweir     /* creates a GradientEmit and returns its object number */
873cdf0e10cSrcweir     sal_Int32 createGradient(  const Gradient& rGradient, const Size& rSize );
874cdf0e10cSrcweir 
875cdf0e10cSrcweir     /* writes all tilings */
876cdf0e10cSrcweir     bool emitTilings();
877cdf0e10cSrcweir     /* writes all gradient patterns */
878cdf0e10cSrcweir     bool emitGradients();
879cdf0e10cSrcweir     /* writes a builtin font object and returns its objectid (or 0 in case of failure ) */
880cdf0e10cSrcweir     sal_Int32 emitBuiltinFont( const ImplFontData*, sal_Int32 nObject = -1 );
881cdf0e10cSrcweir     /* writes a type1 embedded font object and returns its mapping from font ids to object ids (or 0 in case of failure ) */
882cdf0e10cSrcweir     std::map< sal_Int32, sal_Int32 > emitEmbeddedFont( const ImplFontData*, EmbedFont& );
883cdf0e10cSrcweir     /* writes a type1 system font object and returns its mapping from font ids to object ids (or 0 in case of failure ) */
884cdf0e10cSrcweir     std::map< sal_Int32, sal_Int32 > emitSystemFont( const ImplFontData*, EmbedFont& );
885cdf0e10cSrcweir     /* writes a font descriptor and returns its object id (or 0) */
886cdf0e10cSrcweir     sal_Int32 emitFontDescriptor( const ImplFontData*, FontSubsetInfo&, sal_Int32 nSubsetID, sal_Int32 nStream );
887cdf0e10cSrcweir     /* writes a ToUnicode cmap, returns the corresponding stream object */
888cdf0e10cSrcweir     sal_Int32 createToUnicodeCMap( sal_uInt8* pEncoding, sal_Ucs* pUnicodes, sal_Int32* pUnicodesPerGlyph, sal_Int32* pEncToUnicodeIndex, int nGlyphs );
889cdf0e10cSrcweir 
890cdf0e10cSrcweir     /* get resource dict object number */
getResourceDictObj()891cdf0e10cSrcweir     sal_Int32 getResourceDictObj()
892cdf0e10cSrcweir     {
893cdf0e10cSrcweir         if( m_nResourceDict <= 0 )
894cdf0e10cSrcweir             m_nResourceDict = createObject();
895cdf0e10cSrcweir         return m_nResourceDict;
896cdf0e10cSrcweir     }
897cdf0e10cSrcweir     /* get the font dict object */
getFontDictObject()898cdf0e10cSrcweir     sal_Int32 getFontDictObject()
899cdf0e10cSrcweir     {
900cdf0e10cSrcweir         if( m_nFontDictObject <= 0 )
901cdf0e10cSrcweir             m_nFontDictObject = createObject();
902cdf0e10cSrcweir         return m_nFontDictObject;
903cdf0e10cSrcweir     }
904cdf0e10cSrcweir     /* push resource into current (redirected) resource dict */
905cdf0e10cSrcweir     void pushResource( ResourceKind eKind, const rtl::OString& rResource, sal_Int32 nObject );
906cdf0e10cSrcweir 
907cdf0e10cSrcweir     void appendBuiltinFontsToDict( rtl::OStringBuffer& rDict ) const;
908cdf0e10cSrcweir     /* writes a the font dictionary and emits all font objects
909cdf0e10cSrcweir      * returns object id of font directory (or 0 on error)
910cdf0e10cSrcweir      */
911cdf0e10cSrcweir     bool emitFonts();
912cdf0e10cSrcweir 	/* writes the Resource dictionary;
913cdf0e10cSrcweir      * returns dict object id (or 0 on error)
914cdf0e10cSrcweir      */
915cdf0e10cSrcweir     sal_Int32 emitResources();
916cdf0e10cSrcweir     // appends a dest
917cdf0e10cSrcweir     bool appendDest( sal_Int32 nDestID, rtl::OStringBuffer& rBuffer );
918cdf0e10cSrcweir     // write all links
919cdf0e10cSrcweir     bool emitLinkAnnotations();
920cdf0e10cSrcweir     // write all notes
921cdf0e10cSrcweir     bool emitNoteAnnotations();
922cdf0e10cSrcweir     // write the appearance streams of a widget
923cdf0e10cSrcweir     bool emitAppearances( PDFWidget& rWidget, rtl::OStringBuffer& rAnnotDict );
924cdf0e10cSrcweir     // clean up radio button "On" values
925cdf0e10cSrcweir     void ensureUniqueRadioOnValues();
926cdf0e10cSrcweir     // write all widgets
927cdf0e10cSrcweir     bool emitWidgetAnnotations();
928cdf0e10cSrcweir     // writes all annotation objects
929cdf0e10cSrcweir     bool emitAnnotations();
930cdf0e10cSrcweir     // writes the dest dict for the catalog
931cdf0e10cSrcweir     sal_Int32 emitDestDict();
932cdf0e10cSrcweir     //write the named destination stuff
933cdf0e10cSrcweir     sal_Int32 emitNamedDestinations();//i56629
934cdf0e10cSrcweir     // writes outline dict and tree
935cdf0e10cSrcweir     sal_Int32 emitOutline();
936cdf0e10cSrcweir     // puts the attribute objects of a structure element into the returned string,
937cdf0e10cSrcweir     // helper for emitStructure
938cdf0e10cSrcweir     rtl::OString emitStructureAttributes( PDFStructureElement& rEle );
939cdf0e10cSrcweir     //--->i94258
940cdf0e10cSrcweir     // the maximum array elements allowed for PDF array object
941cdf0e10cSrcweir     static const sal_uInt32 ncMaxPDFArraySize = 8191;
942cdf0e10cSrcweir     //check if internal dummy container are needed in the structure elements
943cdf0e10cSrcweir     void addInternalStructureContainer( PDFStructureElement& rEle );
944cdf0e10cSrcweir     //<---i94258
945cdf0e10cSrcweir     // writes document structure
946cdf0e10cSrcweir     sal_Int32 emitStructure( PDFStructureElement& rEle );
947cdf0e10cSrcweir     // writes structure parent tree
948cdf0e10cSrcweir     sal_Int32 emitStructParentTree( sal_Int32 nTreeObject );
949cdf0e10cSrcweir     // writes page tree and catalog
950cdf0e10cSrcweir     bool emitCatalog();
951cdf0e10cSrcweir     // writes xref and trailer
952cdf0e10cSrcweir     bool emitTrailer();
953cdf0e10cSrcweir     // emit additional streams collected; also create there object numbers
954cdf0e10cSrcweir     bool emitAdditionalStreams();
955cdf0e10cSrcweir     // emits info dict (if applicable)
956cdf0e10cSrcweir     sal_Int32 emitInfoDict( );
957cdf0e10cSrcweir 
958cdf0e10cSrcweir     // acrobat reader 5 and 6 use the order of the annotations
959cdf0e10cSrcweir     // as their tab order; since PDF1.5 one can make the
960cdf0e10cSrcweir     // tab order explicit by using the structure tree
961cdf0e10cSrcweir     void sortWidgets();
962cdf0e10cSrcweir 
963cdf0e10cSrcweir     // updates the count numbers of outline items
964cdf0e10cSrcweir     sal_Int32 updateOutlineItemCount( std::vector< sal_Int32 >& rCounts,
965cdf0e10cSrcweir                                       sal_Int32 nItemLevel,
966cdf0e10cSrcweir                                       sal_Int32 nCurrentItemId );
96786e1cf34SPedro Giffuni     // default appearances for widgets
968cdf0e10cSrcweir     sal_Int32 findRadioGroupWidget( const PDFWriter::RadioButtonWidget& rRadio );
969cdf0e10cSrcweir     Font replaceFont( const Font& rControlFont, const Font& rAppSetFont );
970cdf0e10cSrcweir     sal_Int32 getBestBuiltinFont( const Font& rFont );
971cdf0e10cSrcweir     sal_Int32 getSystemFont( const Font& i_rFont );
972cdf0e10cSrcweir 
973cdf0e10cSrcweir     // used for edit and listbox
974cdf0e10cSrcweir     Font drawFieldBorder( PDFWidget&, const PDFWriter::AnyWidget&, const StyleSettings& );
975cdf0e10cSrcweir 
976cdf0e10cSrcweir     void createDefaultPushButtonAppearance( PDFWidget&, const PDFWriter::PushButtonWidget& rWidget );
977cdf0e10cSrcweir     void createDefaultCheckBoxAppearance( PDFWidget&, const PDFWriter::CheckBoxWidget& rWidget );
978cdf0e10cSrcweir     void createDefaultRadioButtonAppearance( PDFWidget&, const PDFWriter::RadioButtonWidget& rWidget );
979cdf0e10cSrcweir     void createDefaultEditAppearance( PDFWidget&, const PDFWriter::EditWidget& rWidget );
980cdf0e10cSrcweir     void createDefaultListBoxAppearance( PDFWidget&, const PDFWriter::ListBoxWidget& rWidget );
981cdf0e10cSrcweir 
982cdf0e10cSrcweir     /* ensure proper escapement and uniqueness of field names */
983cdf0e10cSrcweir     void createWidgetFieldName( sal_Int32 i_nWidgetsIndex, const PDFWriter::AnyWidget& i_rInWidget );
984cdf0e10cSrcweir     /* adds an entry to m_aObjects and returns its index+1,
985cdf0e10cSrcweir      * sets the offset to ~0
986cdf0e10cSrcweir      */
987cdf0e10cSrcweir     sal_Int32 createObject();
988cdf0e10cSrcweir     /* sets the offset of object n to the current position of output file+1
989cdf0e10cSrcweir      */
990cdf0e10cSrcweir     bool updateObject( sal_Int32 n );
991cdf0e10cSrcweir 
992cdf0e10cSrcweir     bool writeBuffer( const void* pBuffer, sal_uInt64 nBytes );
993cdf0e10cSrcweir     void beginCompression();
994cdf0e10cSrcweir     void endCompression();
995cdf0e10cSrcweir     void beginRedirect( SvStream* pStream, const Rectangle& );
996cdf0e10cSrcweir     // returns an empty rect if no redirection is happending
997cdf0e10cSrcweir     Rectangle getRedirectTargetRect() const;
998cdf0e10cSrcweir     SvStream* endRedirect();
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir     void endPage();
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir     void beginStructureElementMCSeq();
1003cdf0e10cSrcweir     void endStructureElementMCSeq();
1004cdf0e10cSrcweir     /** checks whether a non struct element lies in the ancestor hierarchy
1005cdf0e10cSrcweir         of the current structure element
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir         @returns
1008cdf0e10cSrcweir         <true/> if no NonStructElement was found in ancestor path and tagged
1009cdf0e10cSrcweir         PDF output is enabled
1010cdf0e10cSrcweir         <false/> else
1011cdf0e10cSrcweir      */
1012cdf0e10cSrcweir     bool checkEmitStructure();
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir     /* draws an emphasis mark */
1015cdf0e10cSrcweir     void drawEmphasisMark(  long nX, long nY, const PolyPolygon& rPolyPoly, sal_Bool bPolyLine, const Rectangle& rRect1, const Rectangle& rRect2 );
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir     /* true if PDF/A-1a or PDF/A-1b is output */
1018cdf0e10cSrcweir     sal_Bool        m_bIsPDF_A1;
1019cdf0e10cSrcweir     PDFWriter&      m_rOuterFace;
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir     /*
1022cdf0e10cSrcweir     i12626
1023cdf0e10cSrcweir     methods for PDF security
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir     pad a password according  algorithm 3.2, step 1 */
1026cdf0e10cSrcweir     static void padPassword( const rtl::OUString& i_rPassword, sal_uInt8* o_pPaddedPW );
1027cdf0e10cSrcweir     /* algorithm 3.2: compute an encryption key */
1028cdf0e10cSrcweir 	static bool computeEncryptionKey( EncHashTransporter*,
1029cdf0e10cSrcweir 	                                  vcl::PDFWriter::PDFEncryptionProperties& io_rProperties,
1030cdf0e10cSrcweir 	                                  sal_Int32 i_nAccessPermissions
1031cdf0e10cSrcweir 	                                 );
1032cdf0e10cSrcweir 	/* algorithm 3.3: computing the encryption dictionary'ss owner password value ( /O ) */
1033cdf0e10cSrcweir 	static bool computeODictionaryValue( const sal_uInt8* i_pPaddedOwnerPassword, const sal_uInt8* i_pPaddedUserPassword,
1034cdf0e10cSrcweir 	                                     std::vector< sal_uInt8 >& io_rOValue,
1035cdf0e10cSrcweir 	                                     sal_Int32 i_nKeyLength
1036cdf0e10cSrcweir 	                                    );
1037cdf0e10cSrcweir 	/* algorithm 3.4 or 3.5: computing the encryption dictionary's user password value ( /U ) revision 2 or 3 of the standard security handler */
1038cdf0e10cSrcweir 	static bool computeUDictionaryValue( EncHashTransporter* i_pTransporter,
1039cdf0e10cSrcweir 	                                     vcl::PDFWriter::PDFEncryptionProperties& io_rProperties,
1040cdf0e10cSrcweir 	                                     sal_Int32 i_nKeyLength,
1041cdf0e10cSrcweir 	                                     sal_Int32 i_nAccessPermissions
1042cdf0e10cSrcweir 	                                    );
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir 	static void computeDocumentIdentifier( std::vector< sal_uInt8 >& o_rIdentifier,
1045cdf0e10cSrcweir 	                                       const vcl::PDFWriter::PDFDocInfo& i_rDocInfo,
1046cdf0e10cSrcweir 	                                       rtl::OString& o_rCString1,
1047cdf0e10cSrcweir 	                                       rtl::OString& o_rCString2
1048cdf0e10cSrcweir 	                                      );
1049cdf0e10cSrcweir 	static sal_Int32 computeAccessPermissions( const vcl::PDFWriter::PDFEncryptionProperties& i_rProperties,
1050cdf0e10cSrcweir 	                                           sal_Int32& o_rKeyLength, sal_Int32& o_rRC4KeyLength );
1051cdf0e10cSrcweir     void setupDocInfo();
1052cdf0e10cSrcweir     bool prepareEncryption( const com::sun::star::uno::Reference< com::sun::star::beans::XMaterialHolder >& );
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir 	// helper for playMetafile
1055cdf0e10cSrcweir     void implWriteGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient,
1056cdf0e10cSrcweir                             VirtualDevice* pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& );
1057cdf0e10cSrcweir     void implWriteBitmapEx( const Point& rPoint, const Size& rSize, const BitmapEx& rBitmapEx,
1058cdf0e10cSrcweir                            VirtualDevice* pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& );
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir     // helpers for CCITT 1bit bitmap stream
1061cdf0e10cSrcweir     void putG4Bits( sal_uInt32 i_nLength, sal_uInt32 i_nCode, BitStreamState& io_rState );
1062cdf0e10cSrcweir     void putG4Span( long i_nSpan, bool i_bWhitePixel, BitStreamState& io_rState );
1063cdf0e10cSrcweir     void writeG4Stream( BitmapReadAccess* i_pBitmap );
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir     // color helper functions
1066cdf0e10cSrcweir     void appendStrokingColor( const Color& rColor, rtl::OStringBuffer& rBuffer );
1067cdf0e10cSrcweir     void appendNonStrokingColor( const Color& rColor, rtl::OStringBuffer& rBuffer );
1068cdf0e10cSrcweir public:
1069cdf0e10cSrcweir     PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext, const com::sun::star::uno::Reference< com::sun::star::beans::XMaterialHolder >&, PDFWriter& );
1070cdf0e10cSrcweir     ~PDFWriterImpl();
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir     static com::sun::star::uno::Reference< com::sun::star::beans::XMaterialHolder >
1073cdf0e10cSrcweir            initEncryption( const rtl::OUString& i_rOwnerPassword,
1074cdf0e10cSrcweir                            const rtl::OUString& i_rUserPassword,
1075cdf0e10cSrcweir                            bool b128Bit );
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir     /*	for OutputDevice so the reference device can have a list
1078cdf0e10cSrcweir      *	that contains only suitable fonts (subsettable or builtin)
1079cdf0e10cSrcweir      *	produces a new font list
1080cdf0e10cSrcweir      */
1081cdf0e10cSrcweir     ImplDevFontList* filterDevFontList( ImplDevFontList* pFontList );
1082cdf0e10cSrcweir     /*  for OutputDevice: get layout for builtin fonts
1083cdf0e10cSrcweir      */
1084cdf0e10cSrcweir     bool isBuiltinFont( const ImplFontData* ) const;
1085cdf0e10cSrcweir     SalLayout* GetTextLayout( ImplLayoutArgs& rArgs, ImplFontSelectData* pFont );
1086cdf0e10cSrcweir     void getFontMetric( ImplFontSelectData* pFont, ImplFontMetricData* pMetric ) const;
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir 
1089cdf0e10cSrcweir     /* for documentation of public functions please see pdfwriter.hxx */
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir     OutputDevice* getReferenceDevice();
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir     /* document structure */
1094cdf0e10cSrcweir     sal_Int32 newPage( sal_Int32 nPageWidth , sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation );
1095cdf0e10cSrcweir     bool emit();
1096cdf0e10cSrcweir     std::set< PDFWriter::ErrorCode > getErrors();
insertError(PDFWriter::ErrorCode eErr)1097cdf0e10cSrcweir     void insertError( PDFWriter::ErrorCode eErr ) { m_aErrors.insert( eErr ); }
1098cdf0e10cSrcweir     void playMetafile( const GDIMetaFile&, vcl::PDFExtOutDevData*, const vcl::PDFWriter::PlayMetafileContext&, VirtualDevice* pDummyDev = NULL );
1099cdf0e10cSrcweir 
getCurPageSize() const1100cdf0e10cSrcweir     Size getCurPageSize() const
1101cdf0e10cSrcweir     {
1102cdf0e10cSrcweir         Size aSize;
1103cdf0e10cSrcweir         if( m_nCurrentPage >= 0 && m_nCurrentPage < (sal_Int32)m_aPages.size() )
1104cdf0e10cSrcweir             aSize = Size( m_aPages[ m_nCurrentPage ].m_nPageWidth, m_aPages[ m_nCurrentPage ].m_nPageHeight );
1105cdf0e10cSrcweir         return aSize;
1106cdf0e10cSrcweir     }
1107cdf0e10cSrcweir 
getVersion() const1108cdf0e10cSrcweir     PDFWriter::PDFVersion getVersion() const { return m_aContext.Version; }
1109cdf0e10cSrcweir 
setDocumentLocale(const com::sun::star::lang::Locale & rLoc)1110cdf0e10cSrcweir     void setDocumentLocale( const com::sun::star::lang::Locale& rLoc )
1111cdf0e10cSrcweir     { m_aContext.DocumentLocale = rLoc; }
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir 
1114cdf0e10cSrcweir     /* graphics state */
1115cdf0e10cSrcweir     void push( sal_uInt16 nFlags );
1116cdf0e10cSrcweir     void pop();
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir     void setFont( const Font& rFont );
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir     void setMapMode( const MapMode& rMapMode );
setMapMode()1121cdf0e10cSrcweir     void setMapMode() { setMapMode( m_aMapMode ); }
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir 
getMapMode()1124cdf0e10cSrcweir     const MapMode& getMapMode() { return m_aGraphicsStack.front().m_aMapMode; }
1125cdf0e10cSrcweir 
setLineColor(const Color & rColor)1126cdf0e10cSrcweir     void setLineColor( const Color& rColor )
1127cdf0e10cSrcweir     {
1128cdf0e10cSrcweir         m_aGraphicsStack.front().m_aLineColor = ImplIsColorTransparent(rColor) ? Color( COL_TRANSPARENT ) : rColor;
1129cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateLineColor;
1130cdf0e10cSrcweir     }
1131cdf0e10cSrcweir 
setFillColor(const Color & rColor)1132cdf0e10cSrcweir     void setFillColor( const Color& rColor )
1133cdf0e10cSrcweir     {
1134cdf0e10cSrcweir         m_aGraphicsStack.front().m_aFillColor = ImplIsColorTransparent(rColor) ? Color( COL_TRANSPARENT ) : rColor;
1135cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFillColor;
1136cdf0e10cSrcweir     }
1137cdf0e10cSrcweir 
setTextLineColor()1138cdf0e10cSrcweir     void setTextLineColor()
1139cdf0e10cSrcweir     {
1140cdf0e10cSrcweir         m_aGraphicsStack.front().m_aTextLineColor = Color( COL_TRANSPARENT );
1141cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateTextLineColor;
1142cdf0e10cSrcweir     }
1143cdf0e10cSrcweir 
setTextLineColor(const Color & rColor)1144cdf0e10cSrcweir     void setTextLineColor( const Color& rColor )
1145cdf0e10cSrcweir     {
1146cdf0e10cSrcweir         m_aGraphicsStack.front().m_aTextLineColor = rColor;
1147cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateTextLineColor;
1148cdf0e10cSrcweir     }
1149cdf0e10cSrcweir 
setOverlineColor()1150cdf0e10cSrcweir     void setOverlineColor()
1151cdf0e10cSrcweir     {
1152cdf0e10cSrcweir         m_aGraphicsStack.front().m_aOverlineColor = Color( COL_TRANSPARENT );
1153cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateOverlineColor;
1154cdf0e10cSrcweir     }
1155cdf0e10cSrcweir 
setOverlineColor(const Color & rColor)1156cdf0e10cSrcweir     void setOverlineColor( const Color& rColor )
1157cdf0e10cSrcweir     {
1158cdf0e10cSrcweir         m_aGraphicsStack.front().m_aOverlineColor = rColor;
1159cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateOverlineColor;
1160cdf0e10cSrcweir     }
1161cdf0e10cSrcweir 
setTextFillColor(const Color & rColor)1162cdf0e10cSrcweir     void setTextFillColor( const Color& rColor )
1163cdf0e10cSrcweir     {
1164cdf0e10cSrcweir         m_aGraphicsStack.front().m_aFont.SetFillColor( rColor );
1165cdf0e10cSrcweir         m_aGraphicsStack.front().m_aFont.SetTransparent( ImplIsColorTransparent( rColor ) ? sal_True : sal_False );
1166cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
1167cdf0e10cSrcweir     }
setTextFillColor()1168cdf0e10cSrcweir     void setTextFillColor()
1169cdf0e10cSrcweir     {
1170cdf0e10cSrcweir         m_aGraphicsStack.front().m_aFont.SetFillColor( Color( COL_TRANSPARENT ) );
1171cdf0e10cSrcweir         m_aGraphicsStack.front().m_aFont.SetTransparent( sal_True );
1172cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
1173cdf0e10cSrcweir     }
setTextColor(const Color & rColor)1174cdf0e10cSrcweir     void setTextColor( const Color& rColor )
1175cdf0e10cSrcweir     {
1176cdf0e10cSrcweir         m_aGraphicsStack.front().m_aFont.SetColor( rColor );
1177cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
1178cdf0e10cSrcweir     }
1179cdf0e10cSrcweir 
clearClipRegion()1180cdf0e10cSrcweir     void clearClipRegion()
1181cdf0e10cSrcweir     {
1182cdf0e10cSrcweir         m_aGraphicsStack.front().m_aClipRegion.clear();
1183cdf0e10cSrcweir         m_aGraphicsStack.front().m_bClipRegion = false;
1184cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateClipRegion;
1185cdf0e10cSrcweir     }
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir     void setClipRegion( const basegfx::B2DPolyPolygon& rRegion );
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir     void moveClipRegion( sal_Int32 nX, sal_Int32 nY );
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir     bool intersectClipRegion( const Rectangle& rRect );
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir     bool intersectClipRegion( const basegfx::B2DPolyPolygon& rRegion );
1194cdf0e10cSrcweir 
setLayoutMode(sal_Int32 nLayoutMode)1195cdf0e10cSrcweir     void setLayoutMode( sal_Int32 nLayoutMode )
1196cdf0e10cSrcweir     {
1197cdf0e10cSrcweir         m_aGraphicsStack.front().m_nLayoutMode = nLayoutMode;
1198cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateLayoutMode;
1199cdf0e10cSrcweir     }
1200cdf0e10cSrcweir 
setDigitLanguage(LanguageType eLang)1201cdf0e10cSrcweir     void setDigitLanguage( LanguageType eLang )
1202cdf0e10cSrcweir     {
1203cdf0e10cSrcweir         m_aGraphicsStack.front().m_aDigitLanguage = eLang;
1204cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateDigitLanguage;
1205cdf0e10cSrcweir     }
1206cdf0e10cSrcweir 
setTextAlign(TextAlign eAlign)1207cdf0e10cSrcweir     void setTextAlign( TextAlign eAlign )
1208cdf0e10cSrcweir     {
1209cdf0e10cSrcweir         m_aGraphicsStack.front().m_aFont.SetAlign( eAlign );
1210cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
1211cdf0e10cSrcweir     }
1212cdf0e10cSrcweir 
setAntiAlias(sal_Int32 nAntiAlias)1213cdf0e10cSrcweir     void setAntiAlias( sal_Int32 nAntiAlias )
1214cdf0e10cSrcweir     {
1215cdf0e10cSrcweir         m_aGraphicsStack.front().m_nAntiAlias = nAntiAlias;
1216cdf0e10cSrcweir         m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateAntiAlias;
1217cdf0e10cSrcweir     }
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir     /* actual drawing functions */
1220cdf0e10cSrcweir     void drawText( const Point& rPos, const String& rText, xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, bool bTextLines = true );
1221cdf0e10cSrcweir     void drawTextArray( const Point& rPos, const String& rText, const sal_Int32* pDXArray = NULL, xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, bool bTextLines = true );
1222cdf0e10cSrcweir     void drawStretchText( const Point& rPos, sal_uLong nWidth, const String& rText,
1223cdf0e10cSrcweir                           xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN,
1224cdf0e10cSrcweir                           bool bTextLines = true  );
1225cdf0e10cSrcweir     void drawText( const Rectangle& rRect, const String& rOrigStr, sal_uInt16 nStyle, bool bTextLines = true  );
1226cdf0e10cSrcweir     void drawTextLine( const Point& rPos, long nWidth, FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, bool bUnderlineAbove );
1227cdf0e10cSrcweir     void drawWaveTextLine( rtl::OStringBuffer& aLine, long nWidth, FontUnderline eTextLine, Color aColor, bool bIsAbove );
1228cdf0e10cSrcweir     void drawStraightTextLine( rtl::OStringBuffer& aLine, long nWidth, FontUnderline eTextLine, Color aColor, bool bIsAbove );
1229cdf0e10cSrcweir     void drawStrikeoutLine( rtl::OStringBuffer& aLine, long nWidth, FontStrikeout eStrikeout, Color aColor );
1230cdf0e10cSrcweir     void drawStrikeoutChar( const Point& rPos, long nWidth, FontStrikeout eStrikeout );
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir     void drawLine( const Point& rStart, const Point& rStop );
1233cdf0e10cSrcweir     void drawLine( const Point& rStart, const Point& rStop, const LineInfo& rInfo );
1234cdf0e10cSrcweir     void drawPolygon( const Polygon& rPoly );
1235cdf0e10cSrcweir     void drawPolyPolygon( const PolyPolygon& rPolyPoly );
1236cdf0e10cSrcweir     void drawPolyLine( const Polygon& rPoly );
1237cdf0e10cSrcweir     void drawPolyLine( const Polygon& rPoly, const LineInfo& rInfo );
1238cdf0e10cSrcweir     void drawPolyLine( const Polygon& rPoly, const PDFWriter::ExtLineInfo& rInfo );
1239cdf0e10cSrcweir     void drawWaveLine( const Point& rStart, const Point& rStop, sal_Int32 nDelta, sal_Int32 nLineWidth );
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir     void drawPixel( const Point& rPt, const Color& rColor );
1242cdf0e10cSrcweir     void drawPixel( const Polygon& rPts, const Color* pColors = NULL );
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir     void drawRectangle( const Rectangle& rRect );
1245cdf0e10cSrcweir     void drawRectangle( const Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVertRound );
1246cdf0e10cSrcweir     void drawEllipse( const Rectangle& rRect );
1247cdf0e10cSrcweir     void drawArc( const Rectangle& rRect, const Point& rStart, const Point& rStop, bool bWithPie, bool bWidthChord );
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir     void drawBitmap( const Point& rDestPoint, const Size& rDestSize, const Bitmap& rBitmap );
1250cdf0e10cSrcweir     void drawBitmap( const Point& rDestPoint, const Size& rDestSize, const BitmapEx& rBitmap );
1251cdf0e10cSrcweir     void drawMask( const Point& rDestPoint, const Size& rDestSize, const Bitmap& rBitmap, const Color& rFillColor );
1252cdf0e10cSrcweir     void drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const Size& rSizePixel, const Rectangle& rTargetArea, const Bitmap& rMask );
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir     void drawGradient( const Rectangle& rRect, const Gradient& rGradient );
1255cdf0e10cSrcweir     void drawGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient );
1256cdf0e10cSrcweir     void drawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch );
1257cdf0e10cSrcweir     void drawWallpaper( const Rectangle& rRect, const Wallpaper& rWall );
1258cdf0e10cSrcweir     void drawTransparent( const PolyPolygon& rPolyPoly, sal_uInt32 nTransparentPercent );
1259cdf0e10cSrcweir     void beginTransparencyGroup();
1260cdf0e10cSrcweir     void endTransparencyGroup( const Rectangle& rBoundingBox, sal_uInt32 nTransparentPercent );
1261cdf0e10cSrcweir     void endTransparencyGroup( const Rectangle& rBoundingBox, const Bitmap& rAlphaMask );
1262cdf0e10cSrcweir     void beginPattern( const Rectangle& rCell );
1263cdf0e10cSrcweir     sal_Int32 endPattern( const SvtGraphicFill::Transform& rTransform );
1264cdf0e10cSrcweir     void drawPolyPolygon( const PolyPolygon& rPolyPoly, sal_Int32 nPattern, bool bEOFill );
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir     void emitComment( const char* pComment );
1267cdf0e10cSrcweir 
1268cdf0e10cSrcweir     //--->i56629 named destinations
1269cdf0e10cSrcweir     sal_Int32 createNamedDest( const rtl::OUString& sDestName, const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir     //--->i59651
1272cdf0e10cSrcweir     //emits output intent
1273cdf0e10cSrcweir     sal_Int32   emitOutputIntent();
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir     //emits the document metadata
1276cdf0e10cSrcweir     sal_Int32   emitDocumentMetadata();
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir     // links
1279cdf0e10cSrcweir     sal_Int32 createLink( const Rectangle& rRect, sal_Int32 nPageNr = -1 );
1280cdf0e10cSrcweir     sal_Int32 createDest( const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
1281cdf0e10cSrcweir     sal_Int32 registerDestReference( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
1282cdf0e10cSrcweir     sal_Int32 setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId );
1283cdf0e10cSrcweir     sal_Int32 setLinkURL( sal_Int32 nLinkId, const rtl::OUString& rURL );
1284cdf0e10cSrcweir     void setLinkPropertyId( sal_Int32 nLinkId, sal_Int32 nPropertyId );
1285cdf0e10cSrcweir 
1286cdf0e10cSrcweir     // outline
1287cdf0e10cSrcweir     sal_Int32 createOutlineItem( sal_Int32 nParent = 0, const rtl::OUString& rText = rtl::OUString(), sal_Int32 nDestID = -1 );
1288cdf0e10cSrcweir     sal_Int32 setOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent );
1289cdf0e10cSrcweir     sal_Int32 setOutlineItemText( sal_Int32 nItem, const rtl::OUString& rText );
1290cdf0e10cSrcweir     sal_Int32 setOutlineItemDest( sal_Int32 nItem, sal_Int32 nDestID );
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir     // notes
1293cdf0e10cSrcweir     void createNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 );
1294cdf0e10cSrcweir     // structure elements
1295cdf0e10cSrcweir     sal_Int32 beginStructureElement( PDFWriter::StructElement eType, const rtl::OUString& rAlias );
1296cdf0e10cSrcweir     void endStructureElement();
1297cdf0e10cSrcweir     bool setCurrentStructureElement( sal_Int32 nElement );
1298cdf0e10cSrcweir     sal_Int32 getCurrentStructureElement();
1299cdf0e10cSrcweir     bool setStructureAttribute( enum PDFWriter::StructAttribute eAttr, enum PDFWriter::StructAttributeValue eVal );
1300cdf0e10cSrcweir     bool setStructureAttributeNumerical( enum PDFWriter::StructAttribute eAttr, sal_Int32 nValue );
1301cdf0e10cSrcweir     void setStructureBoundingBox( const Rectangle& rRect );
1302cdf0e10cSrcweir     void setActualText( const String& rText );
1303cdf0e10cSrcweir     void setAlternateText( const String& rText );
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir     // transitional effects
1306cdf0e10cSrcweir     void setAutoAdvanceTime( sal_uInt32 nSeconds, sal_Int32 nPageNr = -1 );
1307cdf0e10cSrcweir     void setPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr = -1 );
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir     // controls
1310cdf0e10cSrcweir     sal_Int32 createControl( const PDFWriter::AnyWidget& rControl, sal_Int32 nPageNr = -1 );
1311cdf0e10cSrcweir     void beginControlAppearance( sal_Int32 nControl );
1312cdf0e10cSrcweir     bool endControlAppearance( PDFWriter::WidgetState eState );
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir     // additional streams
1315cdf0e10cSrcweir     void addStream( const String& rMimeType, PDFOutputStream* pStream, bool bCompress );
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir     // helper: eventually begin marked content sequence and
1318cdf0e10cSrcweir     // emit a comment in debug case
MARK(const char * pString)1319cdf0e10cSrcweir     void MARK( const char*
1320cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1321cdf0e10cSrcweir         pString
1322cdf0e10cSrcweir #endif
1323cdf0e10cSrcweir         )
1324cdf0e10cSrcweir     {
1325cdf0e10cSrcweir         beginStructureElementMCSeq();
1326cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1327cdf0e10cSrcweir         emitComment( pString );
1328cdf0e10cSrcweir #endif
1329cdf0e10cSrcweir     }
1330cdf0e10cSrcweir };
1331cdf0e10cSrcweir 
1332cdf0e10cSrcweir }
1333cdf0e10cSrcweir 
1334cdf0e10cSrcweir #endif //_VCL_PDFEXPORT_HXX
1335cdf0e10cSrcweir 
1336cdf0e10cSrcweir 
1337