1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_PDFEXTOUTDEVDATA_HXX
21 #define INCLUDED_VCL_PDFEXTOUTDEVDATA_HXX
23 #include <vcl/dllapi.h>
25 #include <vcl/pdfwriter.hxx>
26 #include <vcl/extoutdevdata.hxx>
37 A PDFExtOutDevBookmarkEntry is being created by the EditEngine if
38 a bookmark URL has been parsed. The Application is requested to take
39 care of each bookmark entry by emptying out the bookmark vector.
41 struct PDFExtOutDevBookmarkEntry
43 /** ID of the link pointing to the bookmark, or -1 if the entry denotes a destination instead of a link.
47 /** ID of the named destination denoted by the bookmark, or -1 if the entry denotes a link instead of a named destination.
51 /** link target name, respectively destination name
55 PDFExtOutDevBookmarkEntry()
64 Class that is being set at the OutputDevice allowing the
65 application to send enhanced PDF commands like CreateLink
68 struct GlobalSyncData
;
69 class VCL_DLLPUBLIC PDFExtOutDevData
: public ExtOutDevData
72 const OutputDevice
& mrOutDev
;
76 bool mbExportNotesPages
;
77 bool mbTransitionEffects
;
78 bool mbUseLosslessCompression
;
79 bool mbReduceImageResolution
;
80 bool mbExportFormFields
;
81 bool mbExportBookmarks
;
82 bool mbExportHiddenSlides
;
83 bool mbSinglePageSheets
;
84 bool mbExportNDests
; //i56629
86 sal_Int32 mnCompressionQuality
;
87 css::lang::Locale maDocLocale
;
89 std::unique_ptr
<PageSyncData
> mpPageSyncData
;
90 std::unique_ptr
<GlobalSyncData
> mpGlobalSyncData
;
92 std::vector
< PDFExtOutDevBookmarkEntry
> maBookmarks
;
93 std::vector
<OUString
> maChapterNames
;
97 PDFExtOutDevData( const OutputDevice
& rOutDev
);
98 virtual ~PDFExtOutDevData() override
;
100 bool PlaySyncPageAct( PDFWriter
& rWriter
, sal_uInt32
& rCurGDIMtfAction
, const GDIMetaFile
& rMtf
);
101 void ResetSyncData();
103 void PlayGlobalActions( PDFWriter
& rWriter
);
105 bool GetIsExportNotes() const { return mbExportNotes
;}
106 void SetIsExportNotes( const bool bExportNotes
);
108 bool GetIsExportNotesPages() const { return mbExportNotesPages
;}
109 void SetIsExportNotesPages( const bool bExportNotesPages
);
111 bool GetIsExportTaggedPDF() const { return mbTaggedPDF
;}
112 void SetIsExportTaggedPDF( const bool bTaggedPDF
);
114 bool GetIsExportTransitionEffects() const { return mbTransitionEffects
;}
115 void SetIsExportTransitionEffects( const bool bTransitionalEffects
);
117 bool GetIsExportFormFields() const { return mbExportFormFields
;}
118 void SetIsExportFormFields( const bool bExportFormFields
);
120 bool GetIsExportBookmarks() const { return mbExportBookmarks
;}
121 void SetIsExportBookmarks( const bool bExportBookmarks
);
123 bool GetIsExportHiddenSlides() const { return mbExportHiddenSlides
;}
124 void SetIsExportHiddenSlides( const bool bExportHiddenSlides
);
126 void SetIsSinglePageSheets( const bool bSinglePageSheets
);
128 bool GetIsExportNamedDestinations() const { return mbExportNDests
;} //i56629
129 void SetIsExportNamedDestinations( const bool bExportNDests
); //i56629
131 // PageNumber, Compression is being set by the PDFExport
132 sal_Int32
GetCurrentPageNumber() const { return mnPage
;}
133 void SetCurrentPageNumber( const sal_Int32 nPage
);
135 bool GetIsLosslessCompression() const { return mbUseLosslessCompression
;}
136 void SetIsLosslessCompression( const bool bLosslessCompression
);
138 void SetCompressionQuality( const sal_Int32 nQuality
);
140 bool GetIsReduceImageResolution() const { return mbReduceImageResolution
;}
141 void SetIsReduceImageResolution( const bool bReduceImageResolution
);
143 const css::lang::Locale
& GetDocumentLocale() const { return maDocLocale
;}
144 void SetDocumentLocale( const css::lang::Locale
& rLoc
);
146 std::vector
< PDFExtOutDevBookmarkEntry
>& GetBookmarks() { return maBookmarks
;}
147 const std::vector
<OUString
>& GetChapterNames() const { return maChapterNames
; }
149 const Graphic
& GetCurrentGraphic() const;
151 /** Start a new group of render output
153 Use this method to group render output.
157 /** End render output
159 This method ends grouped render output, that can be
160 represented by a GfxLink. This is typically used for
161 external graphic files, such as JPEGs, EPS files etc.
162 The BeginGroup/EndGroup calls must exactly enclose the
163 relevant OutputDevice calls issued to render the
164 graphic the normal way.
167 The link to the original graphic
170 Eight bit transparency value, with 0 denoting full opacity,
171 and 255 full transparency.
174 The output rectangle of the graphic.
176 @param rVisibleOutputRect
177 The visible part of the output. This might be less than
178 rOutputRect, e.g. for cropped graphics.
180 void EndGroup( const Graphic
& rGraphic
,
181 sal_uInt8 nTransparency
,
182 const tools::Rectangle
& rOutputRect
,
183 const tools::Rectangle
& rVisibleOutputRect
);
185 /// Detect if stream is compressed enough to avoid de-compress / scale & re-compress
186 bool HasAdequateCompression( const Graphic
&rGraphic
,
187 const tools::Rectangle
&rOutputRect
,
188 const tools::Rectangle
&rVisibleOutputRect
) const;
191 /** Create a new named destination to be used in a link to this document from another PDF document
192 (see PDF spec 1.4, 8.2.1)
195 the name this destination will be addressed with from others PDF document
198 target rectangle on page to be displayed if dest is jumped to
201 number of page the dest is on (as returned by NewPage)
202 or -1 in which case the current page is used
205 the destination id (to be used in SetLinkDest) or
206 -1 if page id does not exist
208 sal_Int32
CreateNamedDest( const OUString
& sDestName
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
= -1 );
210 /** registers a destination for which a destination ID needs to be known immediately, instead of later on setting it via
213 This is used in contexts where a destination is referenced by means other than a link.
215 Later in the export process, a call to DescribeRegisteredDest must be made, providing the information about
219 the unique Id of the destination
221 sal_Int32
RegisterDest();
223 /** provides detailed information about a destination range which previously has been registered using RegisterDest.
225 void DescribeRegisteredDest( sal_Int32 nDestId
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, PDFWriter::DestAreaType eType
= PDFWriter::DestAreaType::XYZ
);
229 /** Create a new destination to be used in a link
232 target rectangle on page to be displayed if dest is jumped to
235 number of page the dest is on (as returned by NewPage)
236 or -1 in which case the current page is used
239 what dest type to use
242 the destination id (to be used in SetLinkDest) or
243 -1 if page id does not exist
245 sal_Int32
CreateDest( const tools::Rectangle
& rRect
, sal_Int32 nPageNr
= -1, PDFWriter::DestAreaType eType
= PDFWriter::DestAreaType::XYZ
);
246 /** Create a new link on a page
249 active rectangle of the link (that is the area that has to be
250 hit to activate the link)
253 number of page the link is on (as returned by NewPage)
254 or -1 in which case the current page is used
257 the link id (to be used in SetLinkDest, SetLinkURL) or
258 -1 if page id does not exist
260 sal_Int32
CreateLink( const tools::Rectangle
& rRect
, sal_Int32 nPageNr
= -1 );
262 /// Create a Screen annotation.
263 sal_Int32
CreateScreen(const tools::Rectangle
& rRect
, sal_Int32 nPageNr
);
265 /** Set the destination for a link
266 <p>will change a URL type link to a dest link if necessary</p>
269 the link to be changed
272 the dest the link shall point to
274 void SetLinkDest( sal_Int32 nLinkId
, sal_Int32 nDestId
);
275 /** Set the URL for a link
276 <p>will change a dest type link to a URL type link if necessary</p>
278 the link to be changed
281 the URL the link shall point to.
282 there will be no error checking or any kind of
283 conversion done to this parameter execept this:
284 it will be output as 7bit Ascii. The URL
285 will appear literally in the PDF file produced
287 void SetLinkURL( sal_Int32 nLinkId
, const OUString
& rURL
);
289 /// Set URL for a linked Screen annotation.
290 void SetScreenURL(sal_Int32 nScreenId
, const OUString
& rURL
);
291 /// Set URL for an embedded Screen annotation.
292 void SetScreenStream(sal_Int32 nScreenId
, const OUString
& rURL
);
294 /** Create a new outline item
297 declares the parent of the new item in the outline hierarchy.
298 An invalid value will result in a new toplevel item.
301 sets the title text of the item
304 declares which Dest (created with CreateDest) the outline item
308 the outline item id of the new item
310 sal_Int32
CreateOutlineItem( sal_Int32 nParent
, const OUString
& rText
, sal_Int32 nDestID
);
312 /** Create a new note on a page
315 active rectangle of the note (that is the area that has to be
316 hit to popup the annotation)
319 specifies the contents of the note
322 number of page the note is on (as returned by NewPage)
323 or -1 in which case the current page is used
325 void CreateNote( const tools::Rectangle
& rRect
, const PDFNote
& rNote
, sal_Int32 nPageNr
= -1 );
327 /** begin a new logical structure element
329 BeginStructureElement/EndStructureElement calls build the logical structure
330 of the PDF - the basis for tagged PDF. Structural elements are implemented
331 using marked content tags. Each structural element can contain sub elements
332 (e.g. a section can contain a heading and a paragraph). The structure hierarchy
333 is build automatically from the Begin/EndStructureElement calls.
335 A structural element need not be contained on one page; e.g. paragraphs often
336 run from one page to the next. In this case the corresponding EndStructureElement
337 must be called while drawing the next page.
339 BeginStructureElement and EndStructureElement must be called only after
340 PDFWriter::NewPage has been called and before
341 PDFWriter::Emit gets called. The current page
342 number is an implicit context parameter for Begin/EndStructureElement.
344 For pagination artifacts that are not part of the logical structure
345 of the document (like header, footer or page number) the special
346 StructElement NonStructElement exists. To place content
347 outside of the structure tree simply call
348 BeginStructureElement( NonStructElement ) then draw your
349 content and then call EndStructureElement(). Any children
350 of a NonStructElement will not be part of the structure as well.
353 denotes what kind of element to begin (e.g. a heading or paragraph)
356 the specified alias will be used as structure tag. Also an entry in the PDF's
357 role map will be created mapping alias to regular structure type.
360 the id of the newly created structural element
362 sal_Int32
BeginStructureElement( PDFWriter::StructElement eType
, const OUString
& rAlias
= OUString() );
363 /** end a logical structure element
365 @see BeginStructureElement
367 void EndStructureElement();
368 /** set the current structure element
371 For different purposes it may be useful to paint a structure element's
372 content discontinuously. In that case an already existing structure element
373 can be appended to by using SetCurrentStructureElement. The
374 referenced structure element becomes the current structure element with
375 all consequences: all following structure elements are appended as children
376 of the current element.
380 the id of the new current structure element
383 True if the current structure element could be set successfully
384 False if the current structure element could not be changed
385 (e.g. if the passed element id is invalid)
387 bool SetCurrentStructureElement( sal_Int32 nElement
);
388 /** get the current structure element id
391 the id of the current structure element
393 sal_Int32
GetCurrentStructureElement() const;
395 /** set a structure attribute on the current structural element
397 SetStructureAttribute sets an attribute of the current structural element to a
398 new value. A consistency check is performed before actually setting the value;
399 if the check fails, the function returns False and the attribute remains
403 denotes what attribute to change
406 the value to set the attribute to
408 void SetStructureAttribute( PDFWriter::StructAttribute eAttr
, PDFWriter::StructAttributeValue eVal
);
409 /** set a structure attribute on the current structural element
411 SetStructureAttributeNumerical sets an attribute of the current structural element
412 to a new numerical value. A consistency check is performed before actually setting
413 the value; if the check fails, the function returns False and the attribute
417 denotes what attribute to change
420 the value to set the attribute to
422 void SetStructureAttributeNumerical( PDFWriter::StructAttribute eAttr
, sal_Int32 nValue
);
423 /** set the bounding box of a structural element
425 SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox
426 attribute can only be applied to Table, Figure,
427 Form and Formula elements, a call of this function
428 for other element types will be ignored and the BBox attribute not be set.
431 the new bounding box for the structural element
433 void SetStructureBoundingBox( const tools::Rectangle
& rRect
);
435 /** set the ActualText attribute of a structural element
437 ActualText contains the Unicode text without layout artifacts that is shown by
438 a structural element. For example if a line is ended prematurely with a break in
439 a word and continued on the next line (e.g. "happen-<newline>stance") the
440 corresponding ActualText would contain the unbroken line (e.g. "happenstance").
443 contains the complete logical text the structural element displays.
445 void SetActualText( const OUString
& rText
);
447 /** set the Alt attribute of a strutural element
449 Alt is s replacement text describing the contents of a structural element. This
450 is mainly used by accessibility applications; e.g. a screen reader would read
451 the Alt replacement text for an image to a visually impaired user.
454 contains the replacement text for the structural element
456 void SetAlternateText( const OUString
& rText
);
458 /** Sets the transitional effect to be applied when the current page gets shown.
461 the kind of effect to be used; use Regular to disable transitional effects
465 the duration of the transitional effect in milliseconds;
466 set 0 to disable transitional effects
468 void SetPageTransition( PDFWriter::PageTransition eType
, sal_uInt32 nMilliSec
);
470 /** create a new form control
472 This function creates a new form control in the PDF and sets its various
473 properties. Do not pass an actual AnyWidget as rControlType
474 will be cast to the type described by the type member.
477 a descendant of AnyWidget determining the control's properties
479 void CreateControl( const PDFWriter::AnyWidget
& rControlType
);
486 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */