Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _VCL_PDFEXTOUTDEVDATA_HXX
30 : : #define _VCL_PDFEXTOUTDEVDATA_HXX
31 : :
32 : : #include <vcl/dllapi.h>
33 : :
34 : : #include <vcl/pdfwriter.hxx>
35 : : #include <vcl/extoutdevdata.hxx>
36 : : #include <vcl/gdimtf.hxx>
37 : : #include <vcl/mapmod.hxx>
38 : : #include <tools/rtti.hxx>
39 : : #include <vector>
40 : : #include <deque>
41 : :
42 : : class Graphic;
43 : :
44 : : namespace vcl { class PDFWriter; }
45 : :
46 : : namespace vcl
47 : : {
48 : :
49 : : /*
50 : : A PDFExtOutDevBookmarkEntry is being created by the EditEngine if
51 : : a bookmark URL has been parsed. The Application is requested to take
52 : : care of each bookmark entry by emptying out the bookmark vector.
53 : : */
54 : 0 : struct PDFExtOutDevBookmarkEntry
55 : : {
56 : : /** ID of the link pointing to the bookmark, or -1 if the entry denotes a destination instead of a link.
57 : : */
58 : : sal_Int32 nLinkId;
59 : :
60 : : /** ID of the named destination denoted by the bookmark, or -1 if the entry denotes a link instead of a named destination.
61 : : */
62 : : sal_Int32 nDestId;
63 : :
64 : : /** link target name, respectively destination name
65 : : */
66 : : rtl::OUString aBookmark;
67 : :
68 : 0 : PDFExtOutDevBookmarkEntry()
69 : : :nLinkId( -1 )
70 : : ,nDestId( -1 )
71 : 0 : ,aBookmark()
72 : : {
73 : 0 : }
74 : : };
75 : :
76 : : /*
77 : : Class that is being set at the OutputDevice allowing the
78 : : application to send enhanced PDF commands like CreateLink
79 : : */
80 : : struct PageSyncData;
81 : : struct GlobalSyncData;
82 : : class VCL_DLLPUBLIC PDFExtOutDevData : public ExtOutDevData
83 : : {
84 : :
85 : : const OutputDevice& mrOutDev;
86 : :
87 : : sal_Bool mbTaggedPDF;
88 : : sal_Bool mbExportNotes;
89 : : sal_Bool mbExportNotesPages;
90 : : sal_Bool mbTransitionEffects;
91 : : sal_Bool mbUseLosslessCompression;
92 : : sal_Bool mbReduceImageResolution;
93 : : sal_Bool mbExportFormFields;
94 : : sal_Bool mbExportBookmarks;
95 : : sal_Bool mbExportHiddenSlides;
96 : : sal_Bool mbExportNDests; //i56629
97 : : sal_Int32 mnFormsFormat;
98 : : sal_Int32 mnPage;
99 : : com::sun::star::lang::Locale maDocLocale;
100 : :
101 : : PageSyncData* mpPageSyncData;
102 : : GlobalSyncData* mpGlobalSyncData;
103 : :
104 : : std::vector< PDFExtOutDevBookmarkEntry > maBookmarks;
105 : :
106 : : public :
107 : :
108 : : TYPEINFO();
109 : : PDFExtOutDevData( const OutputDevice& rOutDev );
110 : : virtual ~PDFExtOutDevData();
111 : :
112 : : sal_Bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction );
113 : : void ResetSyncData();
114 : :
115 : : void PlayGlobalActions( PDFWriter& rWriter );
116 : :
117 : :
118 : :
119 : : sal_Bool GetIsExportNotes() const;
120 : : void SetIsExportNotes( const sal_Bool bExportNotes );
121 : :
122 : : sal_Bool GetIsExportNotesPages() const;
123 : : void SetIsExportNotesPages( const sal_Bool bExportNotesPages );
124 : :
125 : : sal_Bool GetIsExportTaggedPDF() const;
126 : : void SetIsExportTaggedPDF( const sal_Bool bTaggedPDF );
127 : :
128 : : sal_Bool GetIsExportTransitionEffects() const;
129 : : void SetIsExportTransitionEffects( const sal_Bool bTransitionalEffects );
130 : :
131 : : sal_Bool GetIsExportFormFields() const;
132 : : void SetIsExportFormFields( const sal_Bool bExportFormFields );
133 : :
134 : : void SetFormsFormat( const sal_Int32 nFormsFormat );
135 : :
136 : : sal_Bool GetIsExportBookmarks() const;
137 : : void SetIsExportBookmarks( const sal_Bool bExportBookmarks );
138 : :
139 : : sal_Bool GetIsExportHiddenSlides() const;
140 : : void SetIsExportHiddenSlides( const sal_Bool bExportHiddenSlides );
141 : :
142 : : sal_Bool GetIsExportNamedDestinations() const; //i56629
143 : : void SetIsExportNamedDestinations( const sal_Bool bExportNDests ); //i56629
144 : :
145 : : // PageNumber, Compression is being set by the PDFExport
146 : : sal_Int32 GetCurrentPageNumber() const;
147 : : void SetCurrentPageNumber( const sal_Int32 nPage );
148 : :
149 : : sal_Bool GetIsLosslessCompression() const;
150 : : void SetIsLosslessCompression( const sal_Bool bLosslessCompression );
151 : :
152 : : sal_Bool GetIsReduceImageResolution() const;
153 : : void SetIsReduceImageResolution( const sal_Bool bReduceImageResolution );
154 : :
155 : : const com::sun::star::lang::Locale& GetDocumentLocale() const;
156 : : void SetDocumentLocale( const com::sun::star::lang::Locale& rLoc );
157 : :
158 : : std::vector< PDFExtOutDevBookmarkEntry >& GetBookmarks();
159 : :
160 : : /** Start a new group of render output
161 : :
162 : : Use this method to group render output.
163 : : */
164 : : void BeginGroup();
165 : :
166 : : /** End render output
167 : :
168 : : This method ends grouped render output, that can be
169 : : represented by a GfxLink. This is typically used for
170 : : external graphic files, such as JPEGs, EPS files etc.
171 : : The BeginGroup/EndGroup calls must exactly enclose the
172 : : relevant OutputDevice calls issued to render the
173 : : graphic the normal way.
174 : :
175 : : @param rGraphic
176 : : The link to the original graphic
177 : :
178 : : @param nTransparency
179 : : Eight bit transparency value, with 0 denoting full opacity,
180 : : and 255 full transparency.
181 : :
182 : : @param rOutputRect
183 : : The output rectangle of the graphic.
184 : :
185 : : @param rVisibleOutputRect
186 : : The visible part of the output. This might be less than
187 : : rOutputRect, e.g. for cropped graphics.
188 : : */
189 : : void EndGroup( const Graphic& rGraphic,
190 : : sal_uInt8 nTransparency,
191 : : const Rectangle& rOutputRect,
192 : : const Rectangle& rVisibleOutputRect );
193 : : //--->i56629
194 : : /** Create a new named destination to be used in a link to this document from another PDF document
195 : : (see PDF spec 1.4, 8.2.1)
196 : :
197 : : @parm sDestName
198 : : the name this destination will be addressed with from others PDF document
199 : :
200 : : @param rRect
201 : : target rectangle on page to be displayed if dest is jumped to
202 : :
203 : : @param nPageNr
204 : : number of page the dest is on (as returned by NewPage)
205 : : or -1 in which case the current page is used
206 : :
207 : : @param eType
208 : : what dest type to use
209 : :
210 : : @returns
211 : : the destination id (to be used in SetLinkDest) or
212 : : -1 if page id does not exist
213 : : */
214 : : sal_Int32 CreateNamedDest( const String& sDestName, const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
215 : :
216 : : /** registers a destination for which a destinatin ID needs to be known immediately, instead of later on setting it via
217 : : SetLinkDest.
218 : :
219 : : This is used in contexts where a destination is referenced by means other than a link.
220 : :
221 : : Later in the export process, a call to DescribeRegisteredDest must be made, providing the information about
222 : : the destination.
223 : :
224 : : @return
225 : : the unique Id of the destination
226 : : */
227 : : sal_Int32 RegisterDest();
228 : :
229 : : /** provides detailed information about a destination range which previously has been registered using RegisterDest.
230 : : */
231 : : void DescribeRegisteredDest( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
232 : :
233 : : //<---i56629
234 : :
235 : : /** Create a new destination to be used in a link
236 : :
237 : : @param rRect
238 : : target rectangle on page to be displayed if dest is jumped to
239 : :
240 : : @param nPageNr
241 : : number of page the dest is on (as returned by NewPage)
242 : : or -1 in which case the current page is used
243 : :
244 : : @param eType
245 : : what dest type to use
246 : :
247 : : @returns
248 : : the destination id (to be used in SetLinkDest) or
249 : : -1 if page id does not exist
250 : : */
251 : : sal_Int32 CreateDest( const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ );
252 : : /** Create a new link on a page
253 : :
254 : : @param rRect
255 : : active rectangle of the link (that is the area that has to be
256 : : hit to activate the link)
257 : :
258 : : @param nPageNr
259 : : number of page the link is on (as returned by NewPage)
260 : : or -1 in which case the current page is used
261 : :
262 : : @returns
263 : : the link id (to be used in SetLinkDest, SetLinkURL) or
264 : : -1 if page id does not exist
265 : : */
266 : : sal_Int32 CreateLink( const Rectangle& rRect, sal_Int32 nPageNr = -1 );
267 : : /** Set the destination for a link
268 : : <p>will change a URL type link to a dest link if necessary</p>
269 : :
270 : : @param nLinkId
271 : : the link to be changed
272 : :
273 : : @param nDestId
274 : : the dest the link shall point to
275 : : @returns
276 : : 0 for success
277 : : -1 in case the link id does not exist
278 : : -2 in case the dest id does not exist
279 : : */
280 : : sal_Int32 SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId );
281 : : /** Set the URL for a link
282 : : <p>will change a dest type link to an URL type link if necessary</p>
283 : : @param nLinkId
284 : : the link to be changed
285 : :
286 : : @param rURL
287 : : the URL the link shall point to.
288 : : there will be no error checking or any kind of
289 : : conversion done to this parameter execept this:
290 : : it will be output as 7bit Ascii. The URL
291 : : will appear literally in the PDF file produced
292 : :
293 : : @returns
294 : : 0 for success
295 : : -1 in case the link id does not exist
296 : : */
297 : : sal_Int32 SetLinkURL( sal_Int32 nLinkId, const rtl::OUString& rURL );
298 : : /** Create a new outline item
299 : :
300 : : @param nParent
301 : : declares the parent of the new item in the outline hierarchy.
302 : : An invalid value will result in a new toplevel item.
303 : :
304 : : @param rText
305 : : sets the title text of the item
306 : :
307 : : @param nDestId
308 : : declares which Dest (created with CreateDest) the outline item
309 : : will point to
310 : :
311 : : @returns
312 : : the outline item id of the new item
313 : : */
314 : : sal_Int32 CreateOutlineItem( sal_Int32 nParent = 0, const rtl::OUString& rText = rtl::OUString(), sal_Int32 nDestID = -1 );
315 : :
316 : : /** Create a new note on a page
317 : :
318 : : @param rRect
319 : : active rectangle of the note (that is the area that has to be
320 : : hit to popup the annotation)
321 : :
322 : : @param rNote
323 : : specifies the contents of the note
324 : :
325 : : @param nPageNr
326 : : number of page the note is on (as returned by NewPage)
327 : : or -1 in which case the current page is used
328 : : */
329 : : void CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 );
330 : :
331 : : /** begin a new logical structure element
332 : :
333 : : BeginStructureElement/EndStructureElement calls build the logical structure
334 : : of the PDF - the basis for tagged PDF. Structural elements are implemented
335 : : using marked content tags. Each structural element can contain sub elements
336 : : (e.g. a section can contain a heading and a paragraph). The structure hierarchy
337 : : is build automatically from the Begin/EndStructureElement calls.
338 : :
339 : : A structural element need not be contained on one page; e.g. paragraphs often
340 : : run from one page to the next. In this case the corresponding EndStructureElement
341 : : must be called while drawing the next page.
342 : :
343 : : BeginStructureElement and EndStructureElement must be called only after
344 : : <member scope="vcl">PDFWriter::NewPage</member> has been called and before
345 : : <member scope="vcl">PDFWriter::Emit</member>gets called. The current page
346 : : number is an implicit context parameter for Begin/EndStructureElement.
347 : :
348 : : For pagination artifacts that are not part of the logical structure
349 : : of the document (like header, footer or page number) the special
350 : : StructElement <code>NonStructElement</code> exists. To place content
351 : : outside of the struture tree simply call
352 : : <code>BeginStructureElement( NonStructElement )</code> then draw your
353 : : content and then call <code>EndStructureElement()</code>. Any children
354 : : of a <code>NonStructElement</code> will not be part of the structure as well.
355 : :
356 : : @param eType
357 : : denotes what kind of element to begin (e.g. a heading or paragraph)
358 : :
359 : : @param rAlias
360 : : the specified alias will be used as structure tag. Also an entry in the PDF's
361 : : role map will be created mapping alias to regular structure type.
362 : :
363 : : @returns
364 : : the id of the newly created structural element
365 : : */
366 : : sal_Int32 BeginStructureElement( PDFWriter::StructElement eType, const rtl::OUString& rAlias = rtl::OUString() );
367 : : /** end a logical structure element
368 : :
369 : : @see BeginStructureElement
370 : : */
371 : : void EndStructureElement();
372 : : /** set the current structure element
373 : :
374 : : <p>
375 : : For different purposes it may be useful to paint a structure element's
376 : : content discontinously. In that case an already existing structure element
377 : : can be appended to by using <code>SetCurrentStructureElement</code>. The
378 : : refenrenced structure element becomes the current structure element with
379 : : all consequences: all following structure elements are appended as children
380 : : of the current element.
381 : : </p>
382 : :
383 : : @param nElement
384 : : the id of the new current structure element
385 : :
386 : : @returns
387 : : <true/> if the current structure element could be set successfully
388 : : <false/> if the current structure element could not be changed
389 : : (e.g. if the passed element id is invalid)
390 : : */
391 : : bool SetCurrentStructureElement( sal_Int32 nElement );
392 : : /** get the current structure element id
393 : :
394 : : @returns
395 : : the id of the current structure element
396 : : */
397 : : sal_Int32 GetCurrentStructureElement();
398 : :
399 : : /** set a structure attribute on the current structural element
400 : :
401 : : SetStructureAttribute sets an attribute of the current structural element to a
402 : : new value. A consistency check is performed before actually setting the value;
403 : : if the check fails, the function returns <FALSE/> and the attribute remains
404 : : unchanged.
405 : :
406 : : @param eAttr
407 : : denotes what attribute to change
408 : :
409 : : @param eVal
410 : : the value to set the attribute to
411 : :
412 : : @returns
413 : : <TRUE/> if the value was valid and the change has been performed,
414 : : <FALSE/> if the attribute or value was invalid; attribute remains unchanged
415 : : */
416 : : bool SetStructureAttribute( PDFWriter::StructAttribute eAttr, PDFWriter::StructAttributeValue eVal );
417 : : /** set a structure attribute on the current structural element
418 : :
419 : : SetStructureAttributeNumerical sets an attribute of the current structural element
420 : : to a new numerical value. A consistency check is performed before actually setting
421 : : the value; if the check fails, the function returns <FALSE/> and the attribute
422 : : remains unchanged.
423 : :
424 : : @param eAttr
425 : : denotes what attribute to change
426 : :
427 : : @param nValue
428 : : the value to set the attribute to
429 : :
430 : : @returns
431 : : <TRUE/> if the value was valid and the change has been performed,
432 : : <FALSE/> if the attribute or value was invalid; attribute remains unchanged
433 : : */
434 : : bool SetStructureAttributeNumerical( PDFWriter::StructAttribute eAttr, sal_Int32 nValue );
435 : : /** set the bounding box of a structural element
436 : :
437 : : SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox
438 : : attribute can only be applied to <code>Table</code>, <code>Figure</code>,
439 : : <code>Form</code> and <code>Formula</code> elements, a call of this function
440 : : for other element types will be ignored and the BBox attribute not be set.
441 : :
442 : : @param rRect
443 : : the new bounding box for the structural element
444 : : */
445 : : void SetStructureBoundingBox( const Rectangle& rRect );
446 : :
447 : : /** set the ActualText attribute of a structural element
448 : :
449 : : ActualText contains the Unicode text without layout artifacts that is shown by
450 : : a structural element. For example if a line is ended prematurely with a break in
451 : : a word and continued on the next line (e.g. "happen-<newline>stance") the
452 : : corresponding ActualText would contain the unbroken line (e.g. "happenstance").
453 : :
454 : : @param rText
455 : : contains the complete logical text the structural element displays.
456 : : */
457 : : void SetActualText( const String& rText );
458 : :
459 : : /** set the Alt attribute of a strutural element
460 : :
461 : : Alt is s replacement text describing the contents of a structural element. This
462 : : is mainly used by accessibility applications; e.g. a screen reader would read
463 : : the Alt replacement text for an image to a visually impaired user.
464 : :
465 : : @param rText
466 : : contains the replacement text for the structural element
467 : : */
468 : : void SetAlternateText( const String& rText );
469 : :
470 : : /** Sets the transitional effect to be applied when the current page gets shown.
471 : :
472 : : @param eType
473 : : the kind of effect to be used; use Regular to disable transitional effects
474 : : for this page
475 : :
476 : : @param nMilliSec
477 : : the duration of the transitional effect in milliseconds;
478 : : set 0 to disable transitional effects
479 : :
480 : : @param nPageNr
481 : : the page number to apply the effect to; -1 denotes the current page
482 : : */
483 : : void SetPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr = -1 );
484 : :
485 : : /** create a new form control
486 : :
487 : : This function creates a new form control in the PDF and sets its various
488 : : properties. Do not pass an actual AnyWidget as <code>rControlType</code>
489 : : will be cast to the type described by the type member.
490 : :
491 : : @param rControlType
492 : : a descendant of <code>AnyWidget</code> determing the control's properties
493 : : */
494 : : void CreateControl( const PDFWriter::AnyWidget& rControlType, sal_Int32 nPageNr = -1 );
495 : : };
496 : :
497 : : }
498 : :
499 : : #endif
500 : :
501 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|