2002-07-08 13:18:58 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 11:09:02 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2002-07-08 13:18:58 +00:00
|
|
|
*
|
2005-09-09 11:09:02 +00:00
|
|
|
* $RCSfile: pdfwriter_impl.hxx,v $
|
2002-07-08 13:18:58 +00:00
|
|
|
*
|
2006-07-10 16:26:01 +00:00
|
|
|
* $Revision: 1.40 $
|
2002-07-08 13:18:58 +00:00
|
|
|
*
|
2006-07-10 16:26:01 +00:00
|
|
|
* last change: $Author: obo $ $Date: 2006-07-10 17:26:01 $
|
2002-07-08 13:18:58 +00:00
|
|
|
*
|
2005-09-09 11:09:02 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2002-07-08 13:18:58 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 11:09:02 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2002-07-08 13:18:58 +00:00
|
|
|
*
|
2005-09-09 11:09:02 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2002-07-08 13:18:58 +00:00
|
|
|
*
|
2005-09-09 11:09:02 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2002-07-08 13:18:58 +00:00
|
|
|
*
|
2005-09-09 11:09:02 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2002-07-08 13:18:58 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#ifndef _VCL_PDFWRITER_IMPL_HXX
|
|
|
|
#define _VCL_PDFWRITER_IMPL_HXX
|
|
|
|
|
|
|
|
#ifndef _VCL_PDFWRITER_HXX
|
|
|
|
#include <pdfwriter.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _RTL_USTRING_HXX
|
|
|
|
#include <rtl/ustring.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _OSL_FILE_H
|
|
|
|
#include <osl/file.h>
|
|
|
|
#endif
|
|
|
|
#ifndef _GEN_HXX
|
|
|
|
#include <tools/gen.hxx>
|
|
|
|
#endif
|
2002-09-11 13:59:26 +00:00
|
|
|
#ifndef _STREAM_HXX
|
|
|
|
#include <tools/stream.hxx>
|
|
|
|
#endif
|
2002-07-08 13:18:58 +00:00
|
|
|
#ifndef _SV_OUTDEV_HXX
|
|
|
|
#include <outdev.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_BITMAPEX_HXX
|
|
|
|
#include <bitmapex.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_GRADIENT_HXX
|
|
|
|
#include <gradient.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_HATCH_HXX
|
|
|
|
#include <hatch.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_WALL_HXX
|
|
|
|
#include <wall.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_OUTDATA_HXX
|
|
|
|
#include <outdata.hxx>
|
|
|
|
#endif
|
2002-07-24 15:09:45 +00:00
|
|
|
#ifndef _RTL_STRBUF_HXX
|
|
|
|
#include <rtl/strbuf.hxx>
|
|
|
|
#endif
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
2004-09-08 15:22:06 +00:00
|
|
|
#include <hash_map>
|
2002-07-08 13:18:58 +00:00
|
|
|
#include <list>
|
|
|
|
|
2002-07-15 11:04:39 +00:00
|
|
|
class SalLayout;
|
2002-07-20 14:54:30 +00:00
|
|
|
class ImplLayoutArgs;
|
2004-07-13 08:29:20 +00:00
|
|
|
class ImplFontData;
|
|
|
|
class ImplFontSelectData;
|
|
|
|
class ImplFontMetricData;
|
2002-07-20 14:54:30 +00:00
|
|
|
struct FontSubsetInfo;
|
2002-07-29 15:26:35 +00:00
|
|
|
class ZCodec;
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
namespace vcl
|
|
|
|
{
|
|
|
|
|
2003-03-27 16:59:30 +00:00
|
|
|
class PDFSalLayout;
|
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
class PDFWriterImpl
|
|
|
|
{
|
2003-03-27 16:59:30 +00:00
|
|
|
friend class PDFSalLayout;
|
2002-07-15 11:04:39 +00:00
|
|
|
public:
|
|
|
|
// definition of structs
|
2002-07-20 14:54:30 +00:00
|
|
|
struct BuiltinFont
|
|
|
|
{
|
2002-07-22 11:44:39 +00:00
|
|
|
const char * m_pName; // Name
|
|
|
|
const char * m_pStyleName; // StyleName
|
|
|
|
const char * m_pPSName; // PSName
|
2002-07-20 14:54:30 +00:00
|
|
|
int m_nAscent;
|
|
|
|
int m_nDescent;
|
|
|
|
FontFamily m_eFamily; // Family
|
|
|
|
CharSet m_eCharSet; // CharSet
|
|
|
|
FontPitch m_ePitch; // Pitch
|
|
|
|
FontWidth m_eWidthType; // WidthType
|
|
|
|
FontWeight m_eWeight; // Weight
|
|
|
|
FontItalic m_eItalic; // Italic
|
|
|
|
int m_aWidths[256]; // character metrics
|
|
|
|
};
|
2002-07-15 11:04:39 +00:00
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
struct PDFPage
|
|
|
|
{
|
|
|
|
PDFWriterImpl* m_pWriter;
|
|
|
|
sal_Int32 m_nPageWidth; // in inch/72
|
|
|
|
sal_Int32 m_nPageHeight; // in inch/72
|
|
|
|
PDFWriter::Orientation m_eOrientation;
|
|
|
|
sal_Int32 m_nPageObject;
|
2004-09-08 15:22:06 +00:00
|
|
|
sal_Int32 m_nPageIndex;
|
2002-07-08 13:18:58 +00:00
|
|
|
sal_Int32 m_nStreamObject;
|
|
|
|
sal_Int32 m_nStreamLengthObject;
|
|
|
|
sal_uInt64 m_nBeginStreamPos;
|
2004-09-08 15:22:06 +00:00
|
|
|
std::vector<sal_Int32> m_aAnnotations;
|
|
|
|
std::vector<sal_Int32> m_aMCIDParents;
|
|
|
|
PDFWriter::PageTransition m_eTransition;
|
|
|
|
sal_uInt32 m_nTransTime;
|
|
|
|
sal_uInt32 m_nDuration;
|
2005-03-29 11:57:34 +00:00
|
|
|
bool m_bHasWidgets;
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
PDFPage( PDFWriterImpl* pWriter, sal_Int32 nPageWidth, sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation );
|
|
|
|
~PDFPage();
|
|
|
|
|
|
|
|
void beginStream();
|
|
|
|
void endStream();
|
|
|
|
bool emit( sal_Int32 nParentPage );
|
|
|
|
|
|
|
|
// converts point from ref device coordinates to
|
|
|
|
// page coordinates and appends the point to the buffer
|
|
|
|
// if bNeg is true, the coordinates are inverted AFTER transformation
|
|
|
|
// to page (useful for transformation matrices
|
2003-12-01 08:54:35 +00:00
|
|
|
// if pOutPoint is set it will be updated to the emitted point
|
|
|
|
// (in PDF map mode, that is 10th of point)
|
2004-09-08 15:22:06 +00:00
|
|
|
void appendPoint( const Point& rPoint, rtl::OStringBuffer& rBuffer, bool bNeg = false, Point* pOutPoint = NULL ) const;
|
2002-07-08 13:18:58 +00:00
|
|
|
// appends a rectangle
|
2004-09-08 15:22:06 +00:00
|
|
|
void appendRect( const Rectangle& rRect, rtl::OStringBuffer& rBuffer ) const;
|
2002-07-24 15:09:45 +00:00
|
|
|
// converts a rectangle to 10th points page space
|
2004-09-08 15:22:06 +00:00
|
|
|
void convertRect( Rectangle& rRect ) const;
|
2002-07-08 13:18:58 +00:00
|
|
|
// appends a polygon optionally closing it
|
2004-09-08 15:22:06 +00:00
|
|
|
void appendPolygon( const Polygon& rPoly, rtl::OStringBuffer& rBuffer, bool bClose = true ) const;
|
2002-07-08 13:18:58 +00:00
|
|
|
// appends a polypolygon optionally closing the subpaths
|
2004-09-08 15:22:06 +00:00
|
|
|
void appendPolyPolygon( const PolyPolygon& rPolyPoly, rtl::OStringBuffer& rBuffer, bool bClose = true ) const;
|
2002-07-08 13:18:58 +00:00
|
|
|
// converts a length (either vertical or horizontal; this
|
|
|
|
// can be important if the source MapMode is not
|
|
|
|
// symmetrical) to page length and appends it to the buffer
|
2003-12-01 08:54:35 +00:00
|
|
|
// if pOutLength is set it will be updated to the emitted length
|
|
|
|
// (in PDF map mode, that is 10th of point)
|
2004-09-08 15:22:06 +00:00
|
|
|
void appendMappedLength( sal_Int32 nLength, rtl::OStringBuffer& rBuffer, bool bVertical = true, sal_Int32* pOutLength = NULL ) const;
|
2002-10-10 14:06:37 +00:00
|
|
|
// the same for double values
|
2004-09-08 15:22:06 +00:00
|
|
|
void appendMappedLength( double fLength, rtl::OStringBuffer& rBuffer, bool bVertical = true, sal_Int32* pOutLength = NULL ) const;
|
2002-07-08 13:18:58 +00:00
|
|
|
// appends LineInfo
|
2006-01-26 17:09:36 +00:00
|
|
|
// returns false if too many dash array entry were created for
|
|
|
|
// the implementation limits of some PDF readers
|
|
|
|
bool appendLineInfo( const LineInfo& rInfo, rtl::OStringBuffer& rBuffer ) const;
|
2002-07-29 11:48:30 +00:00
|
|
|
// appends a horizontal waveline with vertical offset (helper for drawWaveLine)
|
2004-09-08 15:22:06 +00:00
|
|
|
void appendWaveLine( sal_Int32 nLength, sal_Int32 nYOffset, sal_Int32 nDelta, rtl::OStringBuffer& rBuffer ) const;
|
|
|
|
|
|
|
|
sal_Int32 getWidth() const { return m_nPageWidth ? m_nPageWidth : m_pWriter->m_nInheritedPageWidth; }
|
|
|
|
sal_Int32 getHeight() const { return m_nPageHeight ? m_nPageHeight : m_pWriter->m_nInheritedPageHeight; }
|
2002-07-08 13:18:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
friend struct PDFPage;
|
|
|
|
|
2002-09-20 10:17:06 +00:00
|
|
|
struct BitmapID
|
|
|
|
{
|
|
|
|
Size m_aPixelSize;
|
|
|
|
sal_Int32 m_nSize;
|
|
|
|
sal_Int32 m_nChecksum;
|
|
|
|
sal_Int32 m_nMaskChecksum;
|
|
|
|
|
|
|
|
BitmapID() : m_nSize( 0 ), m_nChecksum( 0 ), m_nMaskChecksum( 0 ) {}
|
|
|
|
|
|
|
|
BitmapID& operator=( const BitmapID& rCopy )
|
|
|
|
{
|
|
|
|
m_aPixelSize = rCopy.m_aPixelSize;
|
|
|
|
m_nSize = rCopy.m_nSize;
|
|
|
|
m_nChecksum = rCopy.m_nChecksum;
|
|
|
|
m_nMaskChecksum = rCopy.m_nMaskChecksum;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==( const BitmapID& rComp )
|
|
|
|
{
|
|
|
|
return (m_aPixelSize == rComp.m_aPixelSize &&
|
|
|
|
m_nSize == rComp.m_nSize &&
|
|
|
|
m_nChecksum == rComp.m_nChecksum &&
|
|
|
|
m_nMaskChecksum == rComp.m_nMaskChecksum );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
struct BitmapEmit
|
|
|
|
{
|
2002-09-20 10:17:06 +00:00
|
|
|
BitmapID m_aID;
|
2002-07-08 13:18:58 +00:00
|
|
|
BitmapEx m_aBitmap;
|
|
|
|
sal_Int32 m_nObject;
|
2002-09-12 15:59:36 +00:00
|
|
|
bool m_bDrawMask;
|
|
|
|
|
|
|
|
BitmapEmit() : m_bDrawMask( false ) {}
|
2002-07-08 13:18:58 +00:00
|
|
|
};
|
|
|
|
|
2002-09-11 12:38:55 +00:00
|
|
|
struct JPGEmit
|
|
|
|
{
|
2002-09-20 10:17:06 +00:00
|
|
|
BitmapID m_aID;
|
2002-09-11 12:38:55 +00:00
|
|
|
SvMemoryStream* m_pStream;
|
|
|
|
Bitmap m_aMask;
|
|
|
|
sal_Int32 m_nObject;
|
2005-07-06 08:20:47 +00:00
|
|
|
bool m_bTrueColor;
|
2002-09-11 12:38:55 +00:00
|
|
|
|
|
|
|
JPGEmit() : m_pStream( NULL ) {}
|
|
|
|
~JPGEmit() { delete m_pStream; }
|
|
|
|
};
|
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
struct GradientEmit
|
|
|
|
{
|
|
|
|
Gradient m_aGradient;
|
|
|
|
Size m_aSize;
|
|
|
|
sal_Int32 m_nObject;
|
|
|
|
};
|
|
|
|
|
|
|
|
// for bitmap tilings (drawWallpaper)
|
|
|
|
struct BitmapPatternEmit
|
|
|
|
{
|
|
|
|
sal_Int32 m_nObject;
|
|
|
|
sal_Int32 m_nBitmapObject;
|
|
|
|
Rectangle m_aRectangle;
|
|
|
|
};
|
|
|
|
|
2002-07-24 15:09:45 +00:00
|
|
|
// for transparency group XObjects
|
|
|
|
struct TransparencyEmit
|
|
|
|
{
|
|
|
|
sal_Int32 m_nObject;
|
2004-09-08 15:22:06 +00:00
|
|
|
sal_Int32 m_nExtGStateObject;
|
2002-07-24 15:09:45 +00:00
|
|
|
double m_fAlpha;
|
|
|
|
Rectangle m_aBoundRect;
|
2004-09-08 15:22:06 +00:00
|
|
|
SvMemoryStream* m_pContentStream;
|
|
|
|
SvMemoryStream* m_pSoftMaskStream;
|
|
|
|
|
|
|
|
TransparencyEmit()
|
|
|
|
: m_nObject( 0 ),
|
|
|
|
m_nExtGStateObject( -1 ),
|
|
|
|
m_fAlpha( 0.0 ),
|
|
|
|
m_pContentStream( NULL ),
|
|
|
|
m_pSoftMaskStream( NULL )
|
|
|
|
{}
|
|
|
|
~TransparencyEmit()
|
|
|
|
{
|
|
|
|
delete m_pContentStream;
|
|
|
|
delete m_pSoftMaskStream;
|
|
|
|
}
|
2002-07-24 15:09:45 +00:00
|
|
|
};
|
|
|
|
|
2002-07-15 11:04:39 +00:00
|
|
|
// font subsets
|
|
|
|
struct GlyphEmit
|
|
|
|
{
|
|
|
|
sal_uInt8 m_nSubsetGlyphID;
|
|
|
|
sal_Unicode m_aUnicode;
|
|
|
|
};
|
|
|
|
typedef std::map< long, GlyphEmit > FontEmitMapping;
|
|
|
|
struct FontEmit
|
|
|
|
{
|
|
|
|
sal_Int32 m_nFontID;
|
|
|
|
FontEmitMapping m_aMapping;
|
|
|
|
|
|
|
|
FontEmit( sal_Int32 nID ) : m_nFontID( nID ) {}
|
|
|
|
};
|
|
|
|
typedef std::list< FontEmit > FontEmitList;
|
|
|
|
struct Glyph
|
|
|
|
{
|
|
|
|
sal_Int32 m_nFontID;
|
|
|
|
sal_uInt8 m_nSubsetGlyphID;
|
|
|
|
};
|
|
|
|
typedef std::map< long, Glyph > FontMapping;
|
|
|
|
|
|
|
|
struct FontSubset
|
|
|
|
{
|
|
|
|
FontEmitList m_aSubsets;
|
|
|
|
FontMapping m_aMapping;
|
|
|
|
};
|
|
|
|
typedef std::map< ImplFontData*, FontSubset > FontSubsetData;
|
|
|
|
|
2003-04-17 14:18:15 +00:00
|
|
|
struct EmbedCode
|
|
|
|
{
|
|
|
|
sal_Unicode m_aUnicode;
|
|
|
|
rtl::OString m_aName;
|
|
|
|
};
|
|
|
|
struct EmbedEncoding
|
|
|
|
{
|
|
|
|
sal_Int32 m_nFontID;
|
|
|
|
std::vector< EmbedCode > m_aEncVector;
|
|
|
|
std::map< sal_Unicode, sal_Int8 > m_aCMap;
|
|
|
|
};
|
|
|
|
struct EmbedFont
|
|
|
|
{
|
|
|
|
sal_Int32 m_nNormalFontID;
|
|
|
|
std::list< EmbedEncoding > m_aExtendedEncodings;
|
|
|
|
};
|
|
|
|
typedef std::map< ImplFontData*, EmbedFont > FontEmbedData;
|
2004-09-08 15:22:06 +00:00
|
|
|
|
|
|
|
struct PDFDest
|
|
|
|
{
|
|
|
|
sal_Int32 m_nPage;
|
|
|
|
PDFWriter::DestAreaType m_eType;
|
|
|
|
Rectangle m_aRect;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PDFOutlineEntry
|
|
|
|
{
|
|
|
|
sal_Int32 m_nParentID;
|
|
|
|
sal_Int32 m_nObject;
|
|
|
|
sal_Int32 m_nParentObject;
|
|
|
|
sal_Int32 m_nNextObject;
|
|
|
|
sal_Int32 m_nPrevObject;
|
|
|
|
std::vector< sal_Int32 > m_aChildren;
|
|
|
|
rtl::OUString m_aTitle;
|
|
|
|
sal_Int32 m_nDestID;
|
|
|
|
|
|
|
|
PDFOutlineEntry()
|
|
|
|
: m_nParentID( -1 ),
|
|
|
|
m_nObject( 0 ),
|
|
|
|
m_nParentObject( 0 ),
|
|
|
|
m_nNextObject( 0 ),
|
|
|
|
m_nPrevObject( 0 ),
|
|
|
|
m_nDestID( -1 )
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PDFAnnotation
|
|
|
|
{
|
|
|
|
sal_Int32 m_nObject;
|
|
|
|
Rectangle m_aRect;
|
|
|
|
sal_Int32 m_nPage;
|
|
|
|
|
|
|
|
PDFAnnotation()
|
|
|
|
: m_nObject( -1 ),
|
|
|
|
m_nPage( -1 )
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PDFLink : public PDFAnnotation
|
|
|
|
{
|
|
|
|
sal_Int32 m_nDest; // set to -1 for URL, to a dest else
|
|
|
|
rtl::OUString m_aURL;
|
2005-11-01 09:33:03 +00:00
|
|
|
sal_Int32 m_nStructParent; // struct parent entry
|
2004-09-08 15:22:06 +00:00
|
|
|
|
|
|
|
PDFLink()
|
2005-11-01 09:33:03 +00:00
|
|
|
: m_nDest( -1 ),
|
|
|
|
m_nStructParent( -1 )
|
2004-09-08 15:22:06 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PDFNoteEntry : public PDFAnnotation
|
|
|
|
{
|
|
|
|
PDFNote m_aContents;
|
|
|
|
|
|
|
|
PDFNoteEntry()
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::hash_map< rtl::OString, SvMemoryStream*, rtl::OStringHash > PDFAppearanceStreams;
|
|
|
|
typedef std::hash_map< rtl::OString, PDFAppearanceStreams, rtl::OStringHash > PDFAppearanceMap;
|
|
|
|
|
|
|
|
struct PDFWidget : public PDFAnnotation
|
|
|
|
{
|
|
|
|
PDFWriter::WidgetType m_eType;
|
|
|
|
rtl::OString m_aName;
|
|
|
|
rtl::OUString m_aDescription;
|
|
|
|
rtl::OUString m_aText;
|
|
|
|
USHORT m_nTextStyle;
|
|
|
|
rtl::OUString m_aValue;
|
|
|
|
rtl::OString m_aDAString;
|
|
|
|
rtl::OString m_aMKDict;
|
|
|
|
sal_Int32 m_nFlags;
|
|
|
|
sal_Int32 m_nParent; // if not 0, parent's object number
|
|
|
|
std::vector<sal_Int32> m_aKids; // widget children, contains object numbers
|
2005-10-19 10:49:22 +00:00
|
|
|
std::vector<sal_Int32> m_aKidsIndex; // widget children, contains index to m_aWidgets
|
|
|
|
rtl::OUString m_aOnValue;
|
2005-03-29 11:57:34 +00:00
|
|
|
sal_Int32 m_nTabOrder; // lowest number gets first in tab order
|
2004-09-08 15:22:06 +00:00
|
|
|
sal_Int32 m_nRadioGroup;
|
|
|
|
sal_Int32 m_nMaxLen;
|
2006-07-10 16:26:01 +00:00
|
|
|
bool m_bSubmit;
|
|
|
|
sal_Int32 m_nDest;
|
2004-09-08 15:22:06 +00:00
|
|
|
std::list<rtl::OUString> m_aListEntries;
|
|
|
|
PDFAppearanceMap m_aAppearances;
|
|
|
|
PDFWidget()
|
|
|
|
: m_eType( PDFWriter::PushButton ),
|
|
|
|
m_nTextStyle( 0 ),
|
|
|
|
m_nFlags( 0 ),
|
|
|
|
m_nParent( 0 ),
|
|
|
|
m_nRadioGroup( -1 ),
|
2006-07-10 16:26:01 +00:00
|
|
|
m_nMaxLen( 0 ),
|
|
|
|
m_bSubmit( false ),
|
|
|
|
m_nDest( -1 )
|
2004-09-08 15:22:06 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PDFStructureAttribute
|
|
|
|
{
|
|
|
|
PDFWriter::StructAttributeValue eValue;
|
|
|
|
sal_Int32 nValue;
|
|
|
|
|
|
|
|
PDFStructureAttribute()
|
|
|
|
: eValue( PDFWriter::Invalid ),
|
|
|
|
nValue( 0 )
|
|
|
|
{}
|
|
|
|
|
|
|
|
PDFStructureAttribute( PDFWriter::StructAttributeValue eVal )
|
|
|
|
: eValue( eVal ),
|
|
|
|
nValue( 0 )
|
|
|
|
{}
|
|
|
|
|
|
|
|
PDFStructureAttribute( sal_Int32 nVal )
|
|
|
|
: eValue( PDFWriter::Invalid ),
|
|
|
|
nValue( nVal )
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<PDFWriter::StructAttribute, PDFStructureAttribute > PDFStructAttributes;
|
|
|
|
|
2005-03-29 11:57:34 +00:00
|
|
|
struct PDFStructureElementKid // for Kids entries
|
|
|
|
{
|
|
|
|
sal_Int32 nObject; // an object number if nMCID is -1,
|
|
|
|
// else the page object relevant to MCID
|
|
|
|
sal_Int32 nMCID; // an MCID if >= 0
|
|
|
|
|
|
|
|
PDFStructureElementKid( sal_Int32 nObj ) : nObject( nObj ), nMCID( -1 ) {}
|
|
|
|
PDFStructureElementKid( sal_Int32 MCID, sal_Int32 nPage ) : nObject( nPage ), nMCID( MCID ) {}
|
|
|
|
};
|
|
|
|
|
2004-09-08 15:22:06 +00:00
|
|
|
struct PDFStructureElement
|
|
|
|
{
|
|
|
|
sal_Int32 m_nObject;
|
|
|
|
PDFWriter::StructElement m_eType;
|
|
|
|
sal_Int32 m_nOwnElement; // index into structure vector
|
|
|
|
sal_Int32 m_nParentElement; // index into structure vector
|
|
|
|
sal_Int32 m_nFirstPageObject;
|
|
|
|
bool m_bOpenMCSeq;
|
|
|
|
std::list< sal_Int32 > m_aChildren; // indices into strucure vector
|
2005-03-29 11:57:34 +00:00
|
|
|
std::list< PDFStructureElementKid > m_aKids;
|
2004-09-08 15:22:06 +00:00
|
|
|
PDFStructAttributes m_aAttributes;
|
|
|
|
Rectangle m_aBBox;
|
|
|
|
rtl::OUString m_aActualText;
|
|
|
|
rtl::OUString m_aAltText;
|
|
|
|
|
|
|
|
// m_aContents contains the element's marked content sequence
|
|
|
|
// as pairs of (page nr, MCID)
|
|
|
|
|
|
|
|
PDFStructureElement()
|
|
|
|
: m_nObject( 0 ),
|
|
|
|
m_eType( PDFWriter::NonStructElement ),
|
|
|
|
m_nOwnElement( -1 ),
|
|
|
|
m_nParentElement( -1 ),
|
|
|
|
m_nFirstPageObject( 0 ),
|
|
|
|
m_bOpenMCSeq( false )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
static const sal_Char* getStructureTag( PDFWriter::StructElement );
|
|
|
|
static const sal_Char* getAttributeTag( PDFWriter::StructAttribute eAtr );
|
|
|
|
static const sal_Char* getAttributeValueTag( PDFWriter::StructAttributeValue eVal );
|
|
|
|
|
2004-10-28 09:33:41 +00:00
|
|
|
// returns true if compression was done
|
|
|
|
// else false
|
|
|
|
static bool compressStream( SvMemoryStream* );
|
|
|
|
|
2006-01-26 17:09:36 +00:00
|
|
|
static void convertLineInfoToExtLineInfo( const LineInfo& rIn, PDFWriter::ExtLineInfo& rOut );
|
2002-07-15 11:04:39 +00:00
|
|
|
private:
|
2002-07-20 14:54:30 +00:00
|
|
|
static const BuiltinFont m_aBuiltinFonts[14];
|
|
|
|
|
2004-09-08 15:22:06 +00:00
|
|
|
OutputDevice* m_pReferenceDevice;
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2004-09-08 15:22:06 +00:00
|
|
|
MapMode m_aMapMode; // PDFWriterImpl scaled units
|
|
|
|
std::vector< PDFPage > m_aPages;
|
|
|
|
PDFDocInfo m_aDocInfo;
|
2002-07-08 13:18:58 +00:00
|
|
|
/* maps object numbers to file offsets (needed for xref) */
|
2004-09-08 15:22:06 +00:00
|
|
|
std::vector< sal_uInt64 > m_aObjects;
|
2002-07-08 13:18:58 +00:00
|
|
|
/* contains Bitmaps until they are written to the
|
|
|
|
* file stream as XObjects*/
|
2004-09-08 15:22:06 +00:00
|
|
|
std::list< BitmapEmit > m_aBitmaps;
|
|
|
|
/* contains JPG streams until written to file */
|
|
|
|
std::list<JPGEmit> m_aJPGs;
|
|
|
|
/* contains all dests ever set during the PDF creation,
|
|
|
|
dest id is always the dest's position in this vector
|
|
|
|
*/
|
|
|
|
std::vector<PDFDest> m_aDests;
|
|
|
|
/* contains all links ever set during PDF creation,
|
|
|
|
link id is always the link's position in this vector
|
|
|
|
*/
|
|
|
|
std::vector<PDFLink> m_aLinks;
|
|
|
|
/* maps arbitrary link ids for structure attributes to real link ids
|
|
|
|
(for setLinkPropertyId)
|
|
|
|
*/
|
|
|
|
std::map<sal_Int32, sal_Int32> m_aLinkPropertyMap;
|
|
|
|
/* contains all outline items,
|
|
|
|
object 0 is the outline root
|
2002-09-11 12:38:55 +00:00
|
|
|
*/
|
2004-09-08 15:22:06 +00:00
|
|
|
std::vector<PDFOutlineEntry> m_aOutline;
|
|
|
|
/* contains all notes set during PDF creation
|
|
|
|
*/
|
|
|
|
std::vector<PDFNoteEntry> m_aNotes;
|
|
|
|
/* the root of the structure tree
|
|
|
|
*/
|
|
|
|
std::vector<PDFStructureElement> m_aStructure;
|
|
|
|
/* current object in the structure hierarchy
|
|
|
|
*/
|
|
|
|
sal_Int32 m_nCurrentStructElement;
|
2005-11-01 09:33:03 +00:00
|
|
|
/* structure parent tree */
|
|
|
|
std::vector< rtl::OString > m_aStructParentTree;
|
2004-09-08 15:22:06 +00:00
|
|
|
/* emit strucure marks currently (aka. NonStructElement or not)
|
|
|
|
*/
|
|
|
|
bool m_bEmitStructure;
|
|
|
|
bool m_bNewMCID;
|
|
|
|
|
|
|
|
/* contains all widgets used in the PDF
|
|
|
|
*/
|
|
|
|
std::vector<PDFWidget> m_aWidgets;
|
|
|
|
/* maps radio group id to index of radio group control in m_aWidgets */
|
|
|
|
std::map< sal_Int32, sal_Int32 > m_aRadioGroupWidgets;
|
|
|
|
/* used to store control id during beginControlAppearance/endControlAppearance */
|
|
|
|
sal_Int32 m_nCurrentControl;
|
2005-10-19 10:49:22 +00:00
|
|
|
/* hash_map for field names, used to ensure unique field names */
|
|
|
|
std::hash_map< rtl::OString, sal_Int32, rtl::OStringHash > m_aFieldNameMap;
|
2002-09-11 12:38:55 +00:00
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
/* contains Bitmaps for gradient functions until they are written
|
|
|
|
* to the file stream */
|
2004-09-08 15:22:06 +00:00
|
|
|
std::list< GradientEmit > m_aGradients;
|
2002-07-08 13:18:58 +00:00
|
|
|
/* contains bitmap tiling patterns */
|
2004-09-08 15:22:06 +00:00
|
|
|
std::list< BitmapPatternEmit > m_aTilings;
|
|
|
|
std::list< TransparencyEmit > m_aTransparentObjects;
|
2002-07-15 11:04:39 +00:00
|
|
|
/* contains all font subsets in use */
|
2004-09-08 15:22:06 +00:00
|
|
|
FontSubsetData m_aSubsets;
|
|
|
|
FontEmbedData m_aEmbeddedFonts;
|
|
|
|
sal_Int32 m_nNextFID;
|
|
|
|
|
|
|
|
sal_Int32 m_nInheritedPageWidth; // in inch/72
|
|
|
|
sal_Int32 m_nInheritedPageHeight; // in inch/72
|
|
|
|
PDFWriter::Orientation m_eInheritedOrientation;
|
|
|
|
sal_Int32 m_nCurrentPage;
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2004-09-08 15:22:06 +00:00
|
|
|
sal_Int32 m_nCatalogObject;
|
|
|
|
sal_Int32 m_nResourceDict;
|
|
|
|
sal_Int32 m_nFontResourceDict;
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2004-09-08 15:22:06 +00:00
|
|
|
PDFWriter::PDFWriterContext m_aContext;
|
|
|
|
oslFileHandle m_aFile;
|
|
|
|
bool m_bOpen;
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2004-09-08 15:22:06 +00:00
|
|
|
|
|
|
|
/* output redirection; e.g. to accumulate content streams for
|
|
|
|
XObjects
|
|
|
|
*/
|
|
|
|
struct StreamRedirect
|
|
|
|
{
|
|
|
|
SvStream* m_pStream;
|
|
|
|
MapMode m_aMapMode;
|
|
|
|
};
|
|
|
|
std::list< StreamRedirect > m_aOutputStreams;
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
// graphics state
|
|
|
|
struct GraphicsState
|
|
|
|
{
|
|
|
|
Font m_aFont;
|
|
|
|
MapMode m_aMapMode;
|
|
|
|
Color m_aLineColor;
|
|
|
|
Color m_aFillColor;
|
|
|
|
Color m_aTextLineColor;
|
|
|
|
Region m_aClipRegion;
|
|
|
|
sal_Int32 m_nAntiAlias;
|
|
|
|
sal_Int32 m_nLayoutMode;
|
2006-01-26 17:09:36 +00:00
|
|
|
LanguageType m_aDigitLanguage;
|
2002-07-08 13:18:58 +00:00
|
|
|
sal_Int32 m_nTransparentPercent;
|
2002-09-27 09:00:34 +00:00
|
|
|
sal_uInt16 m_nFlags;
|
2005-03-29 11:57:34 +00:00
|
|
|
sal_uInt16 m_nUpdateFlags;
|
|
|
|
|
|
|
|
static const sal_uInt16 updateFont = 0x0001;
|
|
|
|
static const sal_uInt16 updateMapMode = 0x0002;
|
|
|
|
static const sal_uInt16 updateLineColor = 0x0004;
|
|
|
|
static const sal_uInt16 updateFillColor = 0x0008;
|
|
|
|
static const sal_uInt16 updateTextLineColor = 0x0010;
|
|
|
|
static const sal_uInt16 updateClipRegion = 0x0020;
|
|
|
|
static const sal_uInt16 updateAntiAlias = 0x0040;
|
|
|
|
static const sal_uInt16 updateLayoutMode = 0x0080;
|
|
|
|
static const sal_uInt16 updateTransparentPercent = 0x0100;
|
2006-01-26 17:09:36 +00:00
|
|
|
static const sal_uInt16 updateDigitLanguage = 0x0200;
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
GraphicsState() :
|
|
|
|
m_aLineColor( COL_TRANSPARENT ),
|
|
|
|
m_aFillColor( COL_TRANSPARENT ),
|
2003-04-11 16:29:22 +00:00
|
|
|
m_aTextLineColor( COL_TRANSPARENT ),
|
2002-09-17 10:15:44 +00:00
|
|
|
m_nAntiAlias( 1 ),
|
2002-07-15 11:04:39 +00:00
|
|
|
m_nLayoutMode( 0 ),
|
2002-09-27 09:00:34 +00:00
|
|
|
m_nTransparentPercent( 0 ),
|
2005-03-29 11:57:34 +00:00
|
|
|
m_nFlags( 0xffff ),
|
|
|
|
m_nUpdateFlags( 0xffff )
|
2002-09-27 09:00:34 +00:00
|
|
|
{}
|
2002-07-08 13:18:58 +00:00
|
|
|
GraphicsState( const GraphicsState& rState ) :
|
|
|
|
m_aFont( rState.m_aFont ),
|
|
|
|
m_aMapMode( rState.m_aMapMode ),
|
|
|
|
m_aLineColor( rState.m_aLineColor ),
|
|
|
|
m_aFillColor( rState.m_aFillColor ),
|
|
|
|
m_aTextLineColor( rState.m_aTextLineColor ),
|
|
|
|
m_aClipRegion( rState.m_aClipRegion ),
|
|
|
|
m_nAntiAlias( rState.m_nAntiAlias ),
|
|
|
|
m_nLayoutMode( rState.m_nLayoutMode ),
|
2002-09-27 09:00:34 +00:00
|
|
|
m_nTransparentPercent( rState.m_nTransparentPercent ),
|
2005-03-29 11:57:34 +00:00
|
|
|
m_nFlags( rState.m_nFlags ),
|
|
|
|
m_nUpdateFlags( rState.m_nUpdateFlags )
|
2002-07-08 13:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GraphicsState& operator=(const GraphicsState& rState )
|
|
|
|
{
|
|
|
|
m_aFont = rState.m_aFont;
|
|
|
|
m_aMapMode = rState.m_aMapMode;
|
|
|
|
m_aLineColor = rState.m_aLineColor;
|
|
|
|
m_aFillColor = rState.m_aFillColor;
|
|
|
|
m_aTextLineColor = rState.m_aTextLineColor;
|
|
|
|
m_aClipRegion = rState.m_aClipRegion;
|
|
|
|
m_nAntiAlias = rState.m_nAntiAlias;
|
|
|
|
m_nLayoutMode = rState.m_nLayoutMode;
|
|
|
|
m_nTransparentPercent = rState.m_nTransparentPercent;
|
2002-09-27 09:00:34 +00:00
|
|
|
m_nFlags = rState.m_nFlags;
|
2005-03-29 11:57:34 +00:00
|
|
|
m_nUpdateFlags = rState.m_nUpdateFlags;
|
2002-07-08 13:18:58 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
2004-09-08 15:22:06 +00:00
|
|
|
std::list< GraphicsState > m_aGraphicsStack;
|
|
|
|
GraphicsState m_aCurrentPDFState;
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2004-09-08 15:22:06 +00:00
|
|
|
ZCodec* m_pCodec;
|
|
|
|
SvMemoryStream* m_pMemStream;
|
2002-07-29 15:26:35 +00:00
|
|
|
|
2002-07-15 11:04:39 +00:00
|
|
|
/* creates fonts and subsets that will be emitted later */
|
2004-06-17 11:19:44 +00:00
|
|
|
void registerGlyphs( int nGlyphs, sal_Int32* pGlyphs, sal_Unicode* pUnicodes, sal_uInt8* pMappedGlyphs, sal_Int32* pMappedFontObjects, ImplFontData* pFallbackFonts[] );
|
2002-07-15 11:04:39 +00:00
|
|
|
|
|
|
|
/* emits a text object according to the passed layout */
|
2002-07-20 14:54:30 +00:00
|
|
|
/* TODO: remove rText as soon as SalLayout will change so that rText is not necessary anymore */
|
2002-10-10 14:06:37 +00:00
|
|
|
void drawLayout( SalLayout& rLayout, const String& rText, bool bTextLines );
|
2003-08-25 12:54:19 +00:00
|
|
|
void drawRelief( SalLayout& rLayout, const String& rText, bool bTextLines );
|
|
|
|
void drawShadow( SalLayout& rLayout, const String& rText, bool bTextLines );
|
2002-07-15 11:04:39 +00:00
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
/* writes differences between graphics stack and current real PDF
|
|
|
|
* state to the file
|
|
|
|
*/
|
|
|
|
void updateGraphicsState();
|
|
|
|
|
2002-07-24 15:09:45 +00:00
|
|
|
/* writes a transparency group object */
|
|
|
|
bool writeTransparentObject( TransparencyEmit& rObject );
|
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
/* writes an XObject of type image, may create
|
|
|
|
a second for the mask
|
|
|
|
*/
|
|
|
|
bool writeBitmapObject( BitmapEmit& rObject, bool bMask = false );
|
2002-09-11 12:38:55 +00:00
|
|
|
|
|
|
|
bool writeJPG( JPGEmit& rEmit );
|
|
|
|
|
2002-09-20 10:17:06 +00:00
|
|
|
/* tries to find the bitmap by its id and returns its emit data if exists,
|
|
|
|
else creates a new emit data block */
|
|
|
|
const BitmapEmit& createBitmapEmit( const BitmapEx& rBitmapEx, bool bDrawMask = false );
|
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
/* writes the Do operation inside the content stream */
|
|
|
|
void drawBitmap( const Point& rDestPt, const Size& rDestSize, const BitmapEmit& rBitmap, const Color& rFillColor );
|
|
|
|
/* write the function object for a Gradient */
|
|
|
|
bool writeGradientFunction( GradientEmit& rObject );
|
|
|
|
/* creates a GradientEmit and returns its object number */
|
|
|
|
sal_Int32 createGradient( const Gradient& rGradient, const Size& rSize );
|
2003-12-01 08:54:35 +00:00
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
/* writes all tilings */
|
|
|
|
bool emitTilings();
|
|
|
|
/* writes all gradient patterns */
|
|
|
|
bool emitGradients();
|
2002-07-20 14:54:30 +00:00
|
|
|
/* writes a builtin font object and returns its objectid (or 0 in case of failure ) */
|
|
|
|
sal_Int32 emitBuiltinFont( ImplFontData* pFont );
|
2003-04-17 14:18:15 +00:00
|
|
|
/* writes a type1 embedded font object and returns its mapping from font ids to object ids (or 0 in case of failure ) */
|
|
|
|
std::map< sal_Int32, sal_Int32 > emitEmbeddedFont( ImplFontData* pFont, EmbedFont& rEmbed );
|
2002-07-20 14:54:30 +00:00
|
|
|
/* writes a font descriptor and returns its object id (or 0) */
|
|
|
|
sal_Int32 emitFontDescriptor( ImplFontData* pFont, FontSubsetInfo& rInfo, sal_Int32 nSubsetID, sal_Int32 nStream );
|
|
|
|
/* writes a ToUnicode cmap, returns the corresponding stream object */
|
|
|
|
sal_Int32 createToUnicodeCMap( sal_uInt8* pEncoding, sal_Unicode* pUnicodes, int nGlyphs );
|
2004-09-08 15:22:06 +00:00
|
|
|
|
|
|
|
/* get resource dict object number */
|
|
|
|
sal_Int32 getResourceDictObj()
|
|
|
|
{
|
|
|
|
if( m_nResourceDict <= 0 )
|
|
|
|
m_nResourceDict = createObject();
|
|
|
|
return m_nResourceDict;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get font dict object number */
|
|
|
|
sal_Int32 getFontDictObj()
|
|
|
|
{
|
|
|
|
if( m_nFontResourceDict <= 0 )
|
|
|
|
m_nFontResourceDict = createObject();
|
|
|
|
return m_nFontResourceDict;
|
|
|
|
}
|
|
|
|
|
2002-07-15 11:04:39 +00:00
|
|
|
/* writes a the font dictionary and emits all font objects
|
|
|
|
* returns object id of font directory (or 0 on error)
|
2002-07-08 13:18:58 +00:00
|
|
|
*/
|
2002-07-15 11:04:39 +00:00
|
|
|
sal_Int32 emitFonts();
|
2002-07-08 13:18:58 +00:00
|
|
|
/* writes the Resource dictionary;
|
|
|
|
* returns dict object id (or 0 on error)
|
|
|
|
*/
|
|
|
|
sal_Int32 emitResources();
|
2004-09-08 15:22:06 +00:00
|
|
|
// appends a dest
|
|
|
|
bool appendDest( sal_Int32 nDestID, rtl::OStringBuffer& rBuffer );
|
|
|
|
// write all links
|
|
|
|
bool emitLinkAnnotations();
|
|
|
|
// write all notes
|
|
|
|
bool emitNoteAnnotations();
|
|
|
|
// write the appearance streams of a widget
|
|
|
|
bool emitAppearances( PDFWidget& rWidget, rtl::OStringBuffer& rAnnotDict );
|
2005-10-19 10:49:22 +00:00
|
|
|
// clean up radio button "On" values
|
|
|
|
void ensureUniqueRadioOnValues();
|
2004-09-08 15:22:06 +00:00
|
|
|
// write all widgets
|
|
|
|
bool emitWidgetAnnotations();
|
|
|
|
// writes all annotation objects
|
|
|
|
bool emitAnnotations();
|
|
|
|
// writes the dest dict for the catalog
|
|
|
|
sal_Int32 emitDestDict();
|
|
|
|
// writes outline dict and tree
|
|
|
|
sal_Int32 emitOutline();
|
|
|
|
// puts the attribute objects of a structure element into the returned string,
|
|
|
|
// helper for emitStructure
|
|
|
|
rtl::OString emitStructureAttributes( PDFStructureElement& rEle );
|
|
|
|
// writes document structure
|
|
|
|
sal_Int32 emitStructure( PDFStructureElement& rEle );
|
|
|
|
// writes structure parent tree
|
2005-11-01 09:33:03 +00:00
|
|
|
sal_Int32 emitStructParentTree( sal_Int32 nTreeObject );
|
2002-07-08 13:18:58 +00:00
|
|
|
// writes page tree and catalog
|
|
|
|
bool emitCatalog();
|
|
|
|
// writes xref and trailer
|
|
|
|
bool emitTrailer();
|
2004-09-08 15:22:06 +00:00
|
|
|
// emits info dict (if applicable), passes back the contents of all values written
|
|
|
|
// for recommend file id computation
|
|
|
|
sal_Int32 emitInfoDict( rtl::OString& rIDOut );
|
|
|
|
|
2005-03-29 11:57:34 +00:00
|
|
|
// acrobat reader 5 and 6 use the order of the annotations
|
|
|
|
// as their tab order; since PDF1.5 one can make the
|
|
|
|
// tab order explicit by using the structure tree
|
|
|
|
void sortWidgets();
|
|
|
|
|
2004-09-08 15:22:06 +00:00
|
|
|
// default appearences for widgets
|
2005-10-19 10:49:22 +00:00
|
|
|
sal_Int32 findRadioGroupWidget( const PDFWriter::RadioButtonWidget& rRadio );
|
2004-09-08 15:22:06 +00:00
|
|
|
Font replaceFont( const Font& rControlFont, const Font& rAppSetFont );
|
|
|
|
|
2005-07-06 08:20:47 +00:00
|
|
|
// used for edit and listbox
|
|
|
|
Font drawFieldBorder( PDFWidget&, const PDFWriter::AnyWidget&, const StyleSettings& );
|
|
|
|
|
2004-09-08 15:22:06 +00:00
|
|
|
void createDefaultPushButtonAppearance( PDFWidget&, const PDFWriter::PushButtonWidget& rWidget );
|
|
|
|
void createDefaultCheckBoxAppearance( PDFWidget&, const PDFWriter::CheckBoxWidget& rWidget );
|
|
|
|
void createDefaultRadioButtonAppearance( PDFWidget&, const PDFWriter::RadioButtonWidget& rWidget );
|
|
|
|
void createDefaultEditAppearance( PDFWidget&, const PDFWriter::EditWidget& rWidget );
|
|
|
|
void createDefaultListBoxAppearance( PDFWidget&, const PDFWriter::ListBoxWidget& rWidget );
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2005-10-19 10:49:22 +00:00
|
|
|
/* ensure proper escapement and uniqueness of field names */
|
|
|
|
rtl::OString convertWidgetFieldName( const rtl::OUString& rString );
|
2002-07-08 13:18:58 +00:00
|
|
|
/* adds an entry to m_aObjects and returns its index+1,
|
|
|
|
* sets the offset to ~0
|
|
|
|
*/
|
|
|
|
sal_Int32 createObject();
|
|
|
|
/* sets the offset of object n to the current position of output file+1
|
|
|
|
*/
|
|
|
|
bool updateObject( sal_Int32 n );
|
|
|
|
|
|
|
|
bool writeBuffer( const void* pBuffer, sal_uInt64 nBytes );
|
2002-07-29 15:26:35 +00:00
|
|
|
void beginCompression();
|
|
|
|
void endCompression();
|
2004-09-08 15:22:06 +00:00
|
|
|
void beginRedirect( SvStream* pStream, const Rectangle& );
|
|
|
|
SvStream* endRedirect();
|
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
void endPage();
|
2002-10-23 17:30:55 +00:00
|
|
|
|
2004-09-08 15:22:06 +00:00
|
|
|
void beginStructureElementMCSeq();
|
|
|
|
void endStructureElementMCSeq();
|
|
|
|
/** checks whether a non struct element lies in the ancestor hierarchy
|
|
|
|
of the current structure element
|
|
|
|
|
|
|
|
@returns
|
|
|
|
<true/> if no NonStructElement was found in ancestor path and tagged
|
|
|
|
PDF output is enabled
|
|
|
|
<false/> else
|
|
|
|
*/
|
|
|
|
bool checkEmitStructure();
|
|
|
|
|
2002-10-23 17:30:55 +00:00
|
|
|
/* draws an emphasis mark */
|
|
|
|
void drawEmphasisMark( long nX, long nY, const PolyPolygon& rPolyPoly, BOOL bPolyLine, const Rectangle& rRect1, const Rectangle& rRect2 );
|
2002-07-08 13:18:58 +00:00
|
|
|
public:
|
2004-09-08 15:22:06 +00:00
|
|
|
PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext );
|
2002-07-08 13:18:58 +00:00
|
|
|
~PDFWriterImpl();
|
|
|
|
|
2002-07-15 11:04:39 +00:00
|
|
|
/* for OutputDevice so the reference device can have a list
|
|
|
|
* that contains only suitable fonts (subsettable or builtin)
|
|
|
|
* produces a new font list
|
|
|
|
*/
|
|
|
|
ImplDevFontList* filterDevFontList( ImplDevFontList* pFontList );
|
2002-07-20 14:54:30 +00:00
|
|
|
/* for OutputDevice: get layout for builtin fonts
|
|
|
|
*/
|
|
|
|
bool isBuiltinFont( ImplFontData* pFont ) const;
|
2003-03-27 16:59:30 +00:00
|
|
|
SalLayout* GetTextLayout( ImplLayoutArgs& rArgs, ImplFontSelectData* pFont );
|
2002-07-20 14:54:30 +00:00
|
|
|
void getFontMetric( ImplFontSelectData* pFont, ImplFontMetricData* pMetric ) const;
|
2002-07-15 11:04:39 +00:00
|
|
|
|
|
|
|
|
2002-10-23 17:30:55 +00:00
|
|
|
/* for documentation of public functions please see pdfwriter.hxx */
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
OutputDevice* getReferenceDevice();
|
|
|
|
|
|
|
|
/* document structure */
|
|
|
|
sal_Int32 newPage( sal_Int32 nPageWidth , sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation );
|
|
|
|
bool emit();
|
|
|
|
|
2004-09-08 15:22:06 +00:00
|
|
|
PDFWriter::PDFVersion getVersion() const { return m_aContext.Version; }
|
2003-05-28 11:31:14 +00:00
|
|
|
void setDocInfo( const PDFDocInfo& rInfo );
|
|
|
|
const PDFDocInfo& getDocInfo() const { return m_aDocInfo; }
|
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
/* graphics state */
|
2002-09-27 09:00:34 +00:00
|
|
|
void push( sal_uInt16 nFlags );
|
|
|
|
void pop();
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2005-04-20 09:51:34 +00:00
|
|
|
void setFont( const Font& rFont );
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2002-09-11 08:55:40 +00:00
|
|
|
void setMapMode( const MapMode& rMapMode );
|
|
|
|
void setMapMode() { setMapMode( m_aMapMode ); }
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
const MapMode& getMapMode() { return m_aGraphicsStack.front().m_aMapMode; }
|
|
|
|
|
|
|
|
void setLineColor( const Color& rColor )
|
2005-03-29 11:57:34 +00:00
|
|
|
{
|
|
|
|
m_aGraphicsStack.front().m_aLineColor = ImplIsColorTransparent(rColor) ? Color( COL_TRANSPARENT ) : rColor;
|
|
|
|
m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateLineColor;
|
|
|
|
}
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
void setFillColor( const Color& rColor )
|
2005-03-29 11:57:34 +00:00
|
|
|
{
|
|
|
|
m_aGraphicsStack.front().m_aFillColor = ImplIsColorTransparent(rColor) ? Color( COL_TRANSPARENT ) : rColor;
|
|
|
|
m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFillColor;
|
|
|
|
}
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
void setTextLineColor()
|
2005-03-29 11:57:34 +00:00
|
|
|
{
|
|
|
|
m_aGraphicsStack.front().m_aTextLineColor = Color( COL_TRANSPARENT );
|
|
|
|
m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateTextLineColor;
|
|
|
|
}
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
void setTextLineColor( const Color& rColor )
|
2005-03-29 11:57:34 +00:00
|
|
|
{
|
|
|
|
m_aGraphicsStack.front().m_aTextLineColor = rColor;
|
|
|
|
m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateTextLineColor;
|
|
|
|
}
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
void setTextFillColor( const Color& rColor )
|
|
|
|
{
|
|
|
|
m_aGraphicsStack.front().m_aFont.SetFillColor( rColor );
|
2006-06-19 18:30:07 +00:00
|
|
|
m_aGraphicsStack.front().m_aFont.SetTransparent( ImplIsColorTransparent( rColor ) ? TRUE : FALSE );
|
2005-03-29 11:57:34 +00:00
|
|
|
m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
|
2002-07-08 13:18:58 +00:00
|
|
|
}
|
|
|
|
void setTextFillColor()
|
|
|
|
{
|
|
|
|
m_aGraphicsStack.front().m_aFont.SetFillColor( Color( COL_TRANSPARENT ) );
|
|
|
|
m_aGraphicsStack.front().m_aFont.SetTransparent( TRUE );
|
2005-03-29 11:57:34 +00:00
|
|
|
m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
|
2002-07-08 13:18:58 +00:00
|
|
|
}
|
|
|
|
void setTextColor( const Color& rColor )
|
2005-03-29 11:57:34 +00:00
|
|
|
{
|
|
|
|
m_aGraphicsStack.front().m_aFont.SetColor( rColor );
|
|
|
|
m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
|
|
|
|
}
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
void clearClipRegion()
|
2005-03-29 11:57:34 +00:00
|
|
|
{
|
|
|
|
m_aGraphicsStack.front().m_aClipRegion.SetNull();
|
|
|
|
m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateClipRegion;
|
|
|
|
}
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2002-09-19 10:47:41 +00:00
|
|
|
void setClipRegion( const Region& rRegion );
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2002-09-19 10:47:41 +00:00
|
|
|
void moveClipRegion( sal_Int32 nX, sal_Int32 nY );
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2002-09-19 10:47:41 +00:00
|
|
|
bool intersectClipRegion( const Rectangle& rRect );
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2002-09-19 10:47:41 +00:00
|
|
|
bool intersectClipRegion( const Region& rRegion );
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
void setLayoutMode( sal_Int32 nLayoutMode )
|
2005-03-29 11:57:34 +00:00
|
|
|
{
|
|
|
|
m_aGraphicsStack.front().m_nLayoutMode = nLayoutMode;
|
|
|
|
m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateLayoutMode;
|
|
|
|
}
|
2002-07-08 13:18:58 +00:00
|
|
|
|
2006-01-26 17:09:36 +00:00
|
|
|
void setDigitLanguage( LanguageType eLang )
|
|
|
|
{
|
|
|
|
m_aGraphicsStack.front().m_aDigitLanguage = eLang;
|
|
|
|
m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateDigitLanguage;
|
|
|
|
}
|
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
void setTextAlign( TextAlign eAlign )
|
2005-03-29 11:57:34 +00:00
|
|
|
{
|
|
|
|
m_aGraphicsStack.front().m_aFont.SetAlign( eAlign );
|
|
|
|
m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateFont;
|
|
|
|
}
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
void setAntiAlias( sal_Int32 nAntiAlias )
|
2005-03-29 11:57:34 +00:00
|
|
|
{
|
|
|
|
m_aGraphicsStack.front().m_nAntiAlias = nAntiAlias;
|
|
|
|
m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsState::updateAntiAlias;
|
|
|
|
}
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
/* actual drawing functions */
|
2002-10-08 18:38:58 +00:00
|
|
|
void drawText( const Point& rPos, const String& rText, xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, bool bTextLines = true );
|
2004-06-17 11:19:44 +00:00
|
|
|
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 );
|
2002-07-20 14:54:30 +00:00
|
|
|
void drawStretchText( const Point& rPos, ULONG nWidth, const String& rText,
|
2002-10-08 18:38:58 +00:00
|
|
|
xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN,
|
|
|
|
bool bTextLines = true );
|
|
|
|
void drawText( const Rectangle& rRect, const String& rOrigStr, USHORT nStyle, bool bTextLines = true );
|
2002-07-29 11:48:30 +00:00
|
|
|
void drawTextLine( const Point& rPos, long nWidth, FontStrikeout eStrikeout, FontUnderline eUnderline, bool bUnderlineAbove );
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
void drawLine( const Point& rStart, const Point& rStop );
|
|
|
|
void drawLine( const Point& rStart, const Point& rStop, const LineInfo& rInfo );
|
|
|
|
void drawPolygon( const Polygon& rPoly );
|
|
|
|
void drawPolyPolygon( const PolyPolygon& rPolyPoly );
|
|
|
|
void drawPolyLine( const Polygon& rPoly );
|
|
|
|
void drawPolyLine( const Polygon& rPoly, const LineInfo& rInfo );
|
2004-10-28 09:33:41 +00:00
|
|
|
void drawPolyLine( const Polygon& rPoly, const PDFWriter::ExtLineInfo& rInfo );
|
2002-07-29 11:48:30 +00:00
|
|
|
void drawWaveLine( const Point& rStart, const Point& rStop, sal_Int32 nDelta, sal_Int32 nLineWidth );
|
2002-07-08 13:18:58 +00:00
|
|
|
|
|
|
|
void drawPixel( const Point& rPt, const Color& rColor );
|
|
|
|
void drawPixel( const Polygon& rPts, const Color* pColors = NULL );
|
|
|
|
|
|
|
|
void drawRectangle( const Rectangle& rRect );
|
|
|
|
void drawRectangle( const Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVertRound );
|
|
|
|
void drawEllipse( const Rectangle& rRect );
|
|
|
|
void drawArc( const Rectangle& rRect, const Point& rStart, const Point& rStop, bool bWithPie, bool bWidthChord );
|
|
|
|
|
|
|
|
void drawBitmap( const Point& rDestPoint, const Size& rDestSize, const Bitmap& rBitmap );
|
|
|
|
void drawBitmap( const Point& rDestPoint, const Size& rDestSize, const BitmapEx& rBitmap );
|
|
|
|
void drawMask( const Point& rDestPoint, const Size& rDestSize, const Bitmap& rBitmap, const Color& rFillColor );
|
2005-07-06 08:20:47 +00:00
|
|
|
void drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const Size& rSizePixel, const Rectangle& rTargetArea, const Bitmap& rMask );
|
2002-09-11 12:38:55 +00:00
|
|
|
|
2002-07-08 13:18:58 +00:00
|
|
|
void drawGradient( const Rectangle& rRect, const Gradient& rGradient );
|
|
|
|
void drawGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient );
|
|
|
|
void drawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch );
|
|
|
|
void drawWallpaper( const Rectangle& rRect, const Wallpaper& rWall );
|
|
|
|
void drawTransparent( const PolyPolygon& rPolyPoly, sal_uInt32 nTransparentPercent );
|
2004-09-08 15:22:06 +00:00
|
|
|
void beginTransparencyGroup();
|
|
|
|
void endTransparencyGroup( const Rectangle& rBoundingBox, sal_uInt32 nTransparentPercent );
|
|
|
|
void endTransparencyGroup( const Rectangle& rBoundingBox, const Bitmap& rAlphaMask );
|
|
|
|
|
|
|
|
void emitComment( const char* pComment );
|
|
|
|
|
|
|
|
// links
|
|
|
|
sal_Int32 createLink( const Rectangle& rRect, sal_Int32 nPageNr = -1 );
|
|
|
|
sal_Int32 createDest( const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
|
|
|
|
sal_Int32 setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId );
|
|
|
|
sal_Int32 setLinkURL( sal_Int32 nLinkId, const rtl::OUString& rURL );
|
|
|
|
void setLinkPropertyId( sal_Int32 nLinkId, sal_Int32 nPropertyId );
|
|
|
|
|
|
|
|
// outline
|
|
|
|
sal_Int32 createOutlineItem( sal_Int32 nParent = 0, const rtl::OUString& rText = rtl::OUString(), sal_Int32 nDestID = -1 );
|
|
|
|
sal_Int32 setOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent );
|
|
|
|
sal_Int32 setOutlineItemText( sal_Int32 nItem, const rtl::OUString& rText );
|
|
|
|
sal_Int32 setOutlineItemDest( sal_Int32 nItem, sal_Int32 nDestID );
|
|
|
|
|
|
|
|
// notes
|
|
|
|
void createNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 );
|
|
|
|
// structure elements
|
|
|
|
sal_Int32 beginStructureElement( PDFWriter::StructElement eType );
|
|
|
|
void endStructureElement();
|
|
|
|
bool setCurrentStructureElement( sal_Int32 nElement );
|
|
|
|
sal_Int32 getCurrentStructureElement();
|
|
|
|
bool setStructureAttribute( enum PDFWriter::StructAttribute eAttr, enum PDFWriter::StructAttributeValue eVal );
|
|
|
|
bool setStructureAttributeNumerical( enum PDFWriter::StructAttribute eAttr, sal_Int32 nValue );
|
|
|
|
void setStructureBoundingBox( const Rectangle& rRect );
|
|
|
|
void setActualText( const String& rText );
|
|
|
|
void setAlternateText( const String& rText );
|
|
|
|
|
|
|
|
// transitional effects
|
|
|
|
void setAutoAdvanceTime( sal_uInt32 nSeconds, sal_Int32 nPageNr = -1 );
|
|
|
|
void setPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr = -1 );
|
|
|
|
|
|
|
|
// controls
|
|
|
|
sal_Int32 createControl( const PDFWriter::AnyWidget& rControl, sal_Int32 nPageNr = -1 );
|
|
|
|
void beginControlAppearance( sal_Int32 nControl );
|
|
|
|
bool endControlAppearance( PDFWriter::WidgetState eState );
|
|
|
|
|
|
|
|
// helper: eventually begin marked content sequence and
|
|
|
|
// emit a comment in debug case
|
2006-06-19 18:30:07 +00:00
|
|
|
void MARK( const char*
|
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
|
|
|
pString
|
|
|
|
#endif
|
|
|
|
)
|
2004-09-08 15:22:06 +00:00
|
|
|
{
|
|
|
|
beginStructureElementMCSeq();
|
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
|
|
|
emitComment( pString );
|
|
|
|
#endif
|
|
|
|
}
|
2002-07-08 13:18:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //_VCL_PDFEXPORT_HXX
|