Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / pdfextoutdevdata.hxx
blob85541fe1817bcfcfcddb3db9144e62c9c2c1648f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
27 #include <vcl/gdimtf.hxx>
28 #include <vcl/mapmod.hxx>
29 #include <tools/rtti.hxx>
30 #include <vector>
31 #include <deque>
33 class Graphic;
35 namespace vcl { class PDFWriter; }
37 namespace vcl
41 A PDFExtOutDevBookmarkEntry is being created by the EditEngine if
42 a bookmark URL has been parsed. The Application is requested to take
43 care of each bookmark entry by emptying out the bookmark vector.
45 struct PDFExtOutDevBookmarkEntry
47 /** ID of the link pointing to the bookmark, or -1 if the entry denotes a destination instead of a link.
49 sal_Int32 nLinkId;
51 /** ID of the named destination denoted by the bookmark, or -1 if the entry denotes a link instead of a named destination.
53 sal_Int32 nDestId;
55 /** link target name, respectively destination name
57 OUString aBookmark;
59 PDFExtOutDevBookmarkEntry()
60 :nLinkId( -1 )
61 ,nDestId( -1 )
62 ,aBookmark()
68 Class that is being set at the OutputDevice allowing the
69 application to send enhanced PDF commands like CreateLink
71 struct PageSyncData;
72 struct GlobalSyncData;
73 class VCL_DLLPUBLIC PDFExtOutDevData : public ExtOutDevData
76 const OutputDevice& mrOutDev;
78 bool mbTaggedPDF;
79 bool mbExportNotes;
80 bool mbExportNotesPages;
81 bool mbTransitionEffects;
82 bool mbUseLosslessCompression;
83 bool mbReduceImageResolution;
84 bool mbExportFormFields;
85 bool mbExportBookmarks;
86 bool mbExportHiddenSlides;
87 bool mbExportNDests; //i56629
88 sal_Int32 mnFormsFormat;
89 sal_Int32 mnPage;
90 com::sun::star::lang::Locale maDocLocale;
92 PageSyncData* mpPageSyncData;
93 GlobalSyncData* mpGlobalSyncData;
95 std::vector< PDFExtOutDevBookmarkEntry > maBookmarks;
97 public :
99 TYPEINFO_OVERRIDE();
100 PDFExtOutDevData( const OutputDevice& rOutDev );
101 virtual ~PDFExtOutDevData();
103 bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction );
104 void ResetSyncData();
106 void PlayGlobalActions( PDFWriter& rWriter );
110 bool GetIsExportNotes() const { return mbExportNotes;}
111 void SetIsExportNotes( const bool bExportNotes );
113 bool GetIsExportNotesPages() const { return mbExportNotesPages;}
114 void SetIsExportNotesPages( const bool bExportNotesPages );
116 bool GetIsExportTaggedPDF() const { return mbTaggedPDF;}
117 void SetIsExportTaggedPDF( const bool bTaggedPDF );
119 bool GetIsExportTransitionEffects() const { return mbTransitionEffects;}
120 void SetIsExportTransitionEffects( const bool bTransitionalEffects );
122 bool GetIsExportFormFields() const { return mbExportFormFields;}
123 void SetIsExportFormFields( const bool bExportFormFields );
125 void SetFormsFormat( const sal_Int32 nFormsFormat );
127 bool GetIsExportBookmarks() const { return mbExportBookmarks;}
128 void SetIsExportBookmarks( const bool bExportBookmarks );
130 bool GetIsExportHiddenSlides() const { return mbExportHiddenSlides;}
131 void SetIsExportHiddenSlides( const bool bExportHiddenSlides );
133 bool GetIsExportNamedDestinations() const { return mbExportNDests;} //i56629
134 void SetIsExportNamedDestinations( const bool bExportNDests ); //i56629
136 // PageNumber, Compression is being set by the PDFExport
137 sal_Int32 GetCurrentPageNumber() const { return mnPage;}
138 void SetCurrentPageNumber( const sal_Int32 nPage );
140 bool GetIsLosslessCompression() const { return mbUseLosslessCompression;}
141 void SetIsLosslessCompression( const bool bLosslessCompression );
143 bool GetIsReduceImageResolution() const { return mbReduceImageResolution;}
144 void SetIsReduceImageResolution( const bool bReduceImageResolution );
146 const com::sun::star::lang::Locale& GetDocumentLocale() const { return maDocLocale;}
147 void SetDocumentLocale( const com::sun::star::lang::Locale& rLoc );
149 std::vector< PDFExtOutDevBookmarkEntry >& GetBookmarks() { return maBookmarks;}
151 /** Start a new group of render output
153 Use this method to group render output.
155 void BeginGroup();
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.
166 @param rGraphic
167 The link to the original graphic
169 @param nTransparency
170 Eight bit transparency value, with 0 denoting full opacity,
171 and 255 full transparency.
173 @param rOutputRect
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 Rectangle& rOutputRect,
183 const Rectangle& rVisibleOutputRect );
184 //--->i56629
185 /** Create a new named destination to be used in a link to this document from another PDF document
186 (see PDF spec 1.4, 8.2.1)
188 @param sDestName
189 the name this destination will be addressed with from others PDF document
191 @param rRect
192 target rectangle on page to be displayed if dest is jumped to
194 @param nPageNr
195 number of page the dest is on (as returned by NewPage)
196 or -1 in which case the current page is used
198 @param eType
199 what dest type to use
201 @returns
202 the destination id (to be used in SetLinkDest) or
203 -1 if page id does not exist
205 sal_Int32 CreateNamedDest( const OUString& sDestName, const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
207 /** registers a destination for which a destinatin ID needs to be known immediately, instead of later on setting it via
208 SetLinkDest.
210 This is used in contexts where a destination is referenced by means other than a link.
212 Later in the export process, a call to DescribeRegisteredDest must be made, providing the information about
213 the destination.
215 @return
216 the unique Id of the destination
218 sal_Int32 RegisterDest();
220 /** provides detailed information about a destination range which previously has been registered using RegisterDest.
222 void DescribeRegisteredDest( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
224 //<---i56629
226 /** Create a new destination to be used in a link
228 @param rRect
229 target rectangle on page to be displayed if dest is jumped to
231 @param nPageNr
232 number of page the dest is on (as returned by NewPage)
233 or -1 in which case the current page is used
235 @param eType
236 what dest type to use
238 @returns
239 the destination id (to be used in SetLinkDest) or
240 -1 if page id does not exist
242 sal_Int32 CreateDest( const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
243 /** Create a new link on a page
245 @param rRect
246 active rectangle of the link (that is the area that has to be
247 hit to activate the link)
249 @param nPageNr
250 number of page the link is on (as returned by NewPage)
251 or -1 in which case the current page is used
253 @returns
254 the link id (to be used in SetLinkDest, SetLinkURL) or
255 -1 if page id does not exist
257 sal_Int32 CreateLink( const Rectangle& rRect, sal_Int32 nPageNr = -1 );
258 /** Set the destination for a link
259 <p>will change a URL type link to a dest link if necessary</p>
261 @param nLinkId
262 the link to be changed
264 @param nDestId
265 the dest the link shall point to
266 @returns
267 0 for success
268 -1 in case the link id does not exist
269 -2 in case the dest id does not exist
271 sal_Int32 SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId );
272 /** Set the URL for a link
273 <p>will change a dest type link to an URL type link if necessary</p>
274 @param nLinkId
275 the link to be changed
277 @param rURL
278 the URL the link shall point to.
279 there will be no error checking or any kind of
280 conversion done to this parameter execept this:
281 it will be output as 7bit Ascii. The URL
282 will appear literally in the PDF file produced
284 @returns
285 0 for success
286 -1 in case the link id does not exist
288 sal_Int32 SetLinkURL( sal_Int32 nLinkId, const OUString& rURL );
289 /** Create a new outline item
291 @param nParent
292 declares the parent of the new item in the outline hierarchy.
293 An invalid value will result in a new toplevel item.
295 @param rText
296 sets the title text of the item
298 @param nDestID
299 declares which Dest (created with CreateDest) the outline item
300 will point to
302 @returns
303 the outline item id of the new item
305 sal_Int32 CreateOutlineItem( sal_Int32 nParent = 0, const OUString& rText = OUString(), sal_Int32 nDestID = -1 );
307 /** Create a new note on a page
309 @param rRect
310 active rectangle of the note (that is the area that has to be
311 hit to popup the annotation)
313 @param rNote
314 specifies the contents of the note
316 @param nPageNr
317 number of page the note is on (as returned by NewPage)
318 or -1 in which case the current page is used
320 void CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 );
322 /** begin a new logical structure element
324 BeginStructureElement/EndStructureElement calls build the logical structure
325 of the PDF - the basis for tagged PDF. Structural elements are implemented
326 using marked content tags. Each structural element can contain sub elements
327 (e.g. a section can contain a heading and a paragraph). The structure hierarchy
328 is build automatically from the Begin/EndStructureElement calls.
330 A structural element need not be contained on one page; e.g. paragraphs often
331 run from one page to the next. In this case the corresponding EndStructureElement
332 must be called while drawing the next page.
334 BeginStructureElement and EndStructureElement must be called only after
335 PDFWriter::NewPage has been called and before
336 PDFWriter::Emit gets called. The current page
337 number is an implicit context parameter for Begin/EndStructureElement.
339 For pagination artifacts that are not part of the logical structure
340 of the document (like header, footer or page number) the special
341 StructElement NonStructElement exists. To place content
342 outside of the struture tree simply call
343 BeginStructureElement( NonStructElement ) then draw your
344 content and then call EndStructureElement(). Any children
345 of a NonStructElement will not be part of the structure as well.
347 @param eType
348 denotes what kind of element to begin (e.g. a heading or paragraph)
350 @param rAlias
351 the specified alias will be used as structure tag. Also an entry in the PDF's
352 role map will be created mapping alias to regular structure type.
354 @returns
355 the id of the newly created structural element
357 sal_Int32 BeginStructureElement( PDFWriter::StructElement eType, const OUString& rAlias = OUString() );
358 /** end a logical structure element
360 @see BeginStructureElement
362 void EndStructureElement();
363 /** set the current structure element
366 For different purposes it may be useful to paint a structure element's
367 content discontinously. In that case an already existing structure element
368 can be appended to by using SetCurrentStructureElement. The
369 refenrenced structure element becomes the current structure element with
370 all consequences: all following structure elements are appended as children
371 of the current element.
372 </p>
374 @param nElement
375 the id of the new current structure element
377 @returns
378 True if the current structure element could be set successfully
379 False if the current structure element could not be changed
380 (e.g. if the passed element id is invalid)
382 bool SetCurrentStructureElement( sal_Int32 nElement );
383 /** get the current structure element id
385 @returns
386 the id of the current structure element
388 sal_Int32 GetCurrentStructureElement();
390 /** set a structure attribute on the current structural element
392 SetStructureAttribute sets an attribute of the current structural element to a
393 new value. A consistency check is performed before actually setting the value;
394 if the check fails, the function returns False and the attribute remains
395 unchanged.
397 @param eAttr
398 denotes what attribute to change
400 @param eVal
401 the value to set the attribute to
403 @returns
404 True if the value was valid and the change has been performed,
405 False if the attribute or value was invalid; attribute remains unchanged
407 bool SetStructureAttribute( PDFWriter::StructAttribute eAttr, PDFWriter::StructAttributeValue eVal );
408 /** set a structure attribute on the current structural element
410 SetStructureAttributeNumerical sets an attribute of the current structural element
411 to a new numerical value. A consistency check is performed before actually setting
412 the value; if the check fails, the function returns False and the attribute
413 remains unchanged.
415 @param eAttr
416 denotes what attribute to change
418 @param nValue
419 the value to set the attribute to
421 @returns
422 True if the value was valid and the change has been performed,
423 False if the attribute or value was invalid; attribute remains unchanged
425 bool SetStructureAttributeNumerical( PDFWriter::StructAttribute eAttr, sal_Int32 nValue );
426 /** set the bounding box of a structural element
428 SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox
429 attribute can only be applied to Table, Figure,
430 Form and Formula elements, a call of this function
431 for other element types will be ignored and the BBox attribute not be set.
433 @param rRect
434 the new bounding box for the structural element
436 void SetStructureBoundingBox( const Rectangle& rRect );
438 /** set the ActualText attribute of a structural element
440 ActualText contains the Unicode text without layout artifacts that is shown by
441 a structural element. For example if a line is ended prematurely with a break in
442 a word and continued on the next line (e.g. "happen-<newline>stance") the
443 corresponding ActualText would contain the unbroken line (e.g. "happenstance").
445 @param rText
446 contains the complete logical text the structural element displays.
448 void SetActualText( const OUString& rText );
450 /** set the Alt attribute of a strutural element
452 Alt is s replacement text describing the contents of a structural element. This
453 is mainly used by accessibility applications; e.g. a screen reader would read
454 the Alt replacement text for an image to a visually impaired user.
456 @param rText
457 contains the replacement text for the structural element
459 void SetAlternateText( const OUString& rText );
461 /** Sets the transitional effect to be applied when the current page gets shown.
463 @param eType
464 the kind of effect to be used; use Regular to disable transitional effects
465 for this page
467 @param nMilliSec
468 the duration of the transitional effect in milliseconds;
469 set 0 to disable transitional effects
471 @param nPageNr
472 the page number to apply the effect to; -1 denotes the current page
474 void SetPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr = -1 );
476 /** create a new form control
478 This function creates a new form control in the PDF and sets its various
479 properties. Do not pass an actual AnyWidget as rControlType
480 will be cast to the type described by the type member.
482 @param rControlType
483 a descendant of AnyWidget determing the control's properties
485 @param nPageNr
486 the page number to apply the effect to; -1 denotes the current page
488 void CreateControl( const PDFWriter::AnyWidget& rControlType, sal_Int32 nPageNr = -1 );
493 #endif
495 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */