// converts point from ref device coordinates to // page coordinates and appends the point to the buffer // if pOutPoint is set it will be updated to the emitted point // (in PDF map mode, that is 10th of point) void appendPoint( const Point& rPoint, OStringBuffer& rBuffer ) const; // appends a B2DPoint without further transformation void appendPixelPoint( const basegfx::B2DPoint& rPoint, OStringBuffer& rBuffer ) const; // appends a rectangle void appendRect( const tools::Rectangle& rRect, OStringBuffer& rBuffer ) const; // converts a rectangle to 10th points page space void convertRect( tools::Rectangle& rRect ) const; // appends a polygon optionally closing it void appendPolygon( const tools::Polygon& rPoly, OStringBuffer& rBuffer, bool bClose = true ) const; // appends a polygon optionally closing it void appendPolygon( const basegfx::B2DPolygon& rPoly, OStringBuffer& rBuffer ) const; // appends a polypolygon optionally closing the subpaths void appendPolyPolygon( const tools::PolyPolygon& rPolyPoly, OStringBuffer& rBuffer ) const; // appends a polypolygon optionally closing the subpaths void appendPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPoly, OStringBuffer& rBuffer ) const; // 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 // if pOutLength is set it will be updated to the emitted length // (in PDF map mode, that is 10th of point) void appendMappedLength( sal_Int32 nLength, OStringBuffer& rBuffer, bool bVertical = true, sal_Int32* pOutLength = nullptr ) const; // the same for double values void appendMappedLength( double fLength, OStringBuffer& rBuffer, bool bVertical = true, sal_Int32 nPrecision = 5 ) const; // appends LineInfo // returns false if too many dash array entry were created for // the implementation limits of some PDF readers bool appendLineInfo( const LineInfo& rInfo, OStringBuffer& rBuffer ) const; // appends a horizontal waveline with vertical offset (helper for drawWaveLine) void appendWaveLine( sal_Int32 nLength, sal_Int32 nYOffset, sal_Int32 nDelta, OStringBuffer& rBuffer ) const;
/// Contains information to emit a reference XObject. struct ReferenceXObjectEmit
{ /// ID of the Form XObject, if any.
sal_Int32 m_nFormObject; /// ID of the vector/embedded object, if m_nFormObject is used.
sal_Int32 m_nEmbeddedObject; /// ID of the bitmap object, if m_nFormObject is used.
sal_Int32 m_nBitmapObject; /// Size of the bitmap replacement, in pixels.
Size m_aPixelSize; /// PDF data from the graphic object, if not writing a reference XObject.
sal_Int32 m_nExternalPDFDataIndex;
sal_Int32 m_nExternalPDFPageIndex;
struct PDFLink : public PDFAnnotation
{
sal_Int32 m_nDest; // set to -1 for URL, to a dest else
OUString m_aURL;
sal_Int32 m_nStructParent; // struct parent entry
OUString m_AltText;
/// A PDF embedded file. struct PDFEmbeddedFile
{ /// ID of the file.
sal_Int32 m_nObject;
OUString m_aSubType; /// Contents of the file.
BinaryDataContainer m_aDataContainer;
std::unique_ptr<PDFOutputStream> m_pStream;
PDFEmbeddedFile()
: m_nObject(0)
{
}
};
struct PDFPopupAnnotation : public PDFAnnotation
{ /// ID of the parent object.
sal_Int32 m_nParentObject;
};
struct PDFNoteEntry : public PDFAnnotation
{
vcl::pdf::PDFNote m_aContents;
PDFPopupAnnotation m_aPopUpAnnotation;
sal_Int32 m_nStructParent;
PDFNoteEntry()
: m_nStructParent(-1)
{}
};
/// A PDF Screen annotation. struct PDFScreen : public PDFAnnotation
{ /// Linked video.
OUString m_aURL; /// Embedded video.
OUString m_aTempFileURL; /// ID of the EmbeddedFile object.
sal_Int32 m_nTempFileObject; /// alternative text description
OUString m_AltText;
sal_Int32 m_nStructParent;
OUString m_MimeType;
struct PDFWidget : public PDFAnnotation
{
PDFWriter::WidgetType m_eType;
OString m_aName;
OUString m_aDescription;
OUString m_aText;
DrawTextFlags m_nTextStyle;
OUString m_aValue;
OString m_aDAString;
OString m_aDRDict;
OString m_aMKDict;
OString m_aMKDictCAString; // i12626, added to be able to encrypt the /CA text string // since the object number is not known at the moment // of filling m_aMKDict, the string will be encrypted when emitted. // the /CA string MUST BE the last added to m_aMKDict // see code for details
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
std::vector<sal_Int32> m_aKidsIndex; // widget children, contains index to m_aWidgets
OUString m_aOnValue;
OUString m_aOffValue;
sal_Int32 m_nTabOrder; // lowest number gets first in tab order
sal_Int32 m_nRadioGroup;
sal_Int32 m_nMaxLen;
PDFWriter::FormatType m_nFormat;
OUString m_aCurrencySymbol;
sal_Int32 m_nDecimalAccuracy; bool m_bPrependCurrencySymbol;
OUString m_aTimeFormat;
OUString m_aDateFormat; bool m_bSubmit; bool m_bSubmitGet;
sal_Int32 m_nDest;
std::vector<OUString> m_aListEntries;
std::vector<sal_Int32> m_aSelectedEntries; typedef std::unordered_map<OString, SvMemoryStream*> PDFAppearanceStreams;
std::unordered_map<OString, PDFAppearanceStreams> m_aAppearances;
sal_Int32 m_nStructParent = -1;
MapMode m_aMapMode; // PDFWriterImpl scaled units
StyleSettings m_aWidgetStyleSettings;
std::vector< PDFPage > m_aPages; /* maps object numbers to file offsets (needed for xref) */
std::vector< sal_uInt64 > m_aObjects; /* contains Bitmaps until they are written to the
* file stream as XObjects*/
std::list< BitmapEmit > m_aBitmaps; /* contains JPG streams until written to file */
std::vector<JPGEmit> m_aJPGs; /*--->i56629 contains all named destinations ever set during the PDF creation, destinationidisalwaysthedestination'spositioninthisvector
*/
std::vector<PDFNamedDest> m_aNamedDests; /* contains all dests ever set during the PDF creation, destidisalwaysthedest'spositioninthisvector
*/
std::vector<PDFDest> m_aDests; /** contains destinations accessible via a public Id, instead of being linked to by an ordinary link
*/
::std::map< sal_Int32, sal_Int32 > m_aDestinationIdTranslation; /* contains all links ever set during PDF creation, linkidisalwaysthelink'spositioninthisvector
*/
std::vector<PDFLink> m_aLinks; /// Contains all screen annotations.
std::vector<PDFScreen> m_aScreens; /// Contains embedded files.
std::vector<PDFEmbeddedFile> m_aEmbeddedFiles;
/* makes correctly encoded for export to PDF URLS
*/
css::uno::Reference< css::util::XURLTransformer > m_xTrans; /* maps arbitrary link ids for structure attributes to real link ids (forsetLinkPropertyId)
*/
std::map<sal_Int32, sal_Int32> m_aLinkPropertyMap; /* contains all outline items, object0istheoutlineroot
*/
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;
std::stack<sal_Int32> m_StructElementStack; /* structure parent tree */
std::vector< OString > m_aStructParentTree; /* emit structure marks currently (aka. NonStructElement or not)
*/ bool m_bEmitStructure; /* role map of struct tree root */
std::unordered_map< OString, OString >
m_aRoleMap; /* structure elements (object ids) that should have ID */
std::unordered_set<sal_Int32> m_StructElemObjsWithID;
/* contains all widgets used in the PDF */
std::vector<PDFWidget> m_aWidgets;
std::vector<PDFWidgetCopy> m_aCopiedWidgets;
/* maps radio group id to index of radio group control in m_aWidgets */
std::map< sal_Int32, sal_Int32 > m_aRadioGroupWidgets; /* unordered_map for field names, used to ensure unique field names */
std::unordered_map< OString, sal_Int32 > m_aFieldNameMap;
/* contains Bitmaps for gradient functions until they are written
* to the file stream */
std::list< GradientEmit > m_aGradients; /* contains bitmap tiling patterns */
std::vector< TilingEmit > m_aTilings;
std::vector< TransparencyEmit > m_aTransparentObjects; /* contains all font subsets in use */
std::map<const vcl::font::PhysicalFontFace*, FontSubset> m_aSubsets;
std::map<const vcl::font::PhysicalFontFace*, EmbedFont> m_aSystemFonts;
std::map<const vcl::font::PhysicalFontFace*, FontSubset> m_aType3Fonts;
sal_Int32 m_nNextFID;
/// Cache some most recent bitmaps we've exported, in case we encounter them again..
o3tl::lru_map<BitmapChecksum,
std::shared_ptr<SvMemoryStream>> m_aPDFBmpCache;
sal_Int32 m_nCurrentPage;
sal_Int32 m_nCatalogObject; // object number of the main signature dictionary
sal_Int32 m_nSignatureObject;
sal_Int64 m_nSignatureContentOffset;
sal_Int64 m_nSignatureLastByteRangeNoOffset;
sal_Int32 m_nResourceDict;
ResourceDict m_aGlobalResourceDict;
sal_Int32 m_nFontDictObject;
std::map< sal_Int32, sal_Int32 > m_aBuildinFontToObjectMap;
/* string to hold the PDF creation date */
OString m_aCreationDateString; /* string to hold the PDF creation date, for PDF/A metadata */
OString m_aCreationMetaDateString; /* the buffer where the data are encrypted, dynamically allocated */
std::vector<sal_uInt8> m_vEncryptionBuffer;
private: /* creates fonts and subsets that will be emitted later */ void registerGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace*, const LogicalFontInstance* pFont, const std::vector<sal_Ucs>&, sal_Int32, sal_uInt8&, sal_Int32&); void registerSimpleGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace*, conststd::vector<sal_Ucs>&, sal_Int32, sal_uInt8&, sal_Int32&);
/* emits a text object according to the passed layout */ /* TODO: remove rText as soon as SalLayout will change so that rText is not necessary anymore */ void drawVerticalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, const Matrix3& rRotScale, double fAngle, double fXScale, sal_Int32 nFontHeight ); void drawHorizontalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, bool bFirst, double fAngle, double fXScale, sal_Int32 nFontHeight, sal_Int32 nPixelFontHeight ); void drawLayout( SalLayout& rLayout, const OUString& rText, bool bTextLines ); void drawRelief( SalLayout& rLayout, const OUString& rText, bool bTextLines ); void drawShadow( SalLayout& rLayout, const OUString& rText, bool bTextLines );
/* writes differences between graphics stack and current real PDF *statetothefile
*/ void updateGraphicsState(Mode mode = Mode::DEFAULT);
/* writes a transparency group object */ void writeTransparentObject( TransparencyEmit& rObject );
/* writes an XObject of type image, may create asecondforthemask
*/ bool writeBitmapObject( const BitmapEmit& rObject ); /* writes an XObject of type mask image
*/ bool writeBitmapMaskObject( sal_Int32 nMaskObject, const AlphaMask& rAlphaMask );
void writeJPG( const JPGEmit& rEmit ); /// Writes the form XObject proxy for the image. void writeReferenceXObject(const ReferenceXObjectEmit& rEmit);
/* 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, const Graphic& rGraphic, std::list<BitmapEmit>& rBitmaps, ResourceDict& rResourceDict, std::list<StreamRedirect>& rOutputStreams ); const BitmapEmit& createBitmapEmit( const BitmapEx& rBitmapEx, const Graphic& rGraphic );
/* 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 const & rObject ); /* creates a GradientEmit and returns its object number */
sal_Int32 createGradient( const Gradient& rGradient, const Size& rSize );
/* writes all tilings */ bool emitTilings(); /* writes all gradient patterns */ bool emitGradients(); /* writes a builtin font object and returns its objectid (or 0 in case of failure ) */
sal_Int32 emitBuildinFont( const pdf::BuildinFontFace*, sal_Int32 nObject ); /* writes a type1 system font object and returns its mapping from font ids to object ids (or 0 in case of failure ) */
std::map< sal_Int32, sal_Int32 > emitSystemFont(const vcl::font::PhysicalFontFace*, EmbedFont const &); /* writes a type3 font object and appends it to the font id mapping, or returns false in case of failure */ bool emitType3Font(const vcl::font::PhysicalFontFace*, const FontSubset&, std::map<sal_Int32, sal_Int32>&); /* writes a font descriptor and returns its object id (or 0) */
sal_Int32 emitFontDescriptor(const vcl::font::PhysicalFontFace*, FontSubsetInfo const &, sal_Int32 nSubsetID, sal_Int32 nStream); /* writes a ToUnicode cmap, returns the corresponding stream object */
sal_Int32 createToUnicodeCMap( sal_uInt8 const * pEncoding, const std::vector<sal_Ucs>& CodeUnits, const sal_Int32* pCodeUnitsPerGlyph, const sal_Int32* pEncToUnicodeIndex, uint32_t nGlyphs );
// write the appearance streams of a widget bool emitAppearances( PDFWidget& rWidget, OStringBuffer& rAnnotDict ); // clean up radio button "On" values void ensureUniqueRadioOnValues(); // write all widgets bool emitWidgetAnnotations(); // writes all annotation objects bool emitAnnotations(); /// Writes embedded files. bool emitEmbeddedFiles(); //write the named destination stuff
sal_Int32 emitNamedDestinations();//i56629 // writes outline dict and tree
sal_Int32 emitOutline(); template<typename T> void AppendAnnotKid(PDFStructureElement& i_rEle, T & rAnnot); // puts the attribute objects of a structure element into the returned string, // helper for emitStructure
OString emitStructureAttributes( PDFStructureElement& rEle ); //--->i94258 // the maximum array elements allowed for PDF array object staticconst sal_uInt32 ncMaxPDFArraySize = 8191; //check if internal dummy container are needed in the structure elements void addInternalStructureContainer( PDFStructureElement& rEle ); //<---i94258 // writes namespaces void emitNamespaces(); // writes document structure
sal_Int32 emitStructure( PDFStructureElement& rEle ); // writes structure parent tree
sal_Int32 emitStructParentTree( sal_Int32 nTreeObject ); // writes structure IDTree
sal_Int32 emitStructIDTree(sal_Int32 nTreeObject); // writes page tree and catalog bool emitCatalog(); // writes signature dictionary object bool emitSignature(); // creates a PKCS7 object using the ByteRange and overwrite /Contents // of the signature dictionary bool finalizeSignature(); //writes encrypt
sal_Int32 emitEncrypt(); // writes xref and trailer bool emitTrailer(); // emits info dict (if applicable)
sal_Int32 emitInfoDict( );
// 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();
void beginStructureElementMCSeq(); enumclass EndMode { Default, OnlyStruct }; void endStructureElementMCSeq(EndMode = EndMode::Default); /** checks whether a non struct element lies in the ancestor hierarchy ofthecurrentstructureelement
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.