Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "vcl/pdfextoutdevdata.hxx"
21 : #include "vcl/graph.hxx"
22 : #include "vcl/outdev.hxx"
23 : #include "vcl/gfxlink.hxx"
24 : #include "vcl/dllapi.h"
25 : #include "basegfx/polygon/b2dpolygon.hxx"
26 : #include "basegfx/polygon/b2dpolygontools.hxx"
27 :
28 :
29 : #include <boost/shared_ptr.hpp>
30 : #include <set>
31 : #include <map>
32 :
33 : namespace vcl
34 : {
35 : struct SAL_DLLPRIVATE PDFExtOutDevDataSync
36 : {
37 : enum Action{ CreateNamedDest,
38 : CreateDest,
39 : CreateLink,
40 : SetLinkDest,
41 : SetLinkURL,
42 : RegisterDest,
43 : CreateOutlineItem,
44 : SetOutlineItemParent,
45 : SetOutlineItemText,
46 : SetOutlineItemDest,
47 : CreateNote,
48 : SetAutoAdvanceTime,
49 : SetPageTransition,
50 :
51 : BeginStructureElement,
52 : EndStructureElement,
53 : SetCurrentStructureElement,
54 : SetStructureAttribute,
55 : SetStructureAttributeNumerical,
56 : SetStructureBoundingBox,
57 : SetActualText,
58 : SetAlternateText,
59 : CreateControl,
60 : BeginGroup,
61 : EndGroup,
62 : EndGroupGfxLink
63 : };
64 :
65 : sal_uInt32 nIdx;
66 : Action eAct;
67 : };
68 :
69 0 : struct SAL_DLLPRIVATE PDFLinkDestination
70 : {
71 : Rectangle mRect;
72 : MapMode mMapMode;
73 : sal_Int32 mPageNr;
74 : PDFWriter::DestAreaType mAreaType;
75 : };
76 :
77 0 : struct SAL_DLLPRIVATE GlobalSyncData
78 : {
79 : std::deque< PDFExtOutDevDataSync::Action > mActions;
80 : std::deque< MapMode > mParaMapModes;
81 : std::deque< Rectangle > mParaRects;
82 : std::deque< sal_Int32 > mParaInts;
83 : std::deque< sal_uInt32 > mParauInts;
84 : std::deque< rtl::OUString > mParaOUStrings;
85 : std::deque< PDFWriter::DestAreaType > mParaDestAreaTypes;
86 : std::deque< PDFNote > mParaPDFNotes;
87 : std::deque< PDFWriter::PageTransition > mParaPageTransitions;
88 : ::std::map< sal_Int32, PDFLinkDestination > mFutureDestinations;
89 :
90 : sal_Int32 GetMappedId();
91 : sal_Int32 GetMappedStructId( sal_Int32 );
92 :
93 : sal_Int32 mCurId;
94 : std::vector< sal_Int32 > mParaIds;
95 : std::vector< sal_Int32 > mStructIdMap;
96 :
97 : sal_Int32 mCurrentStructElement;
98 : std::vector< sal_Int32 > mStructParents;
99 0 : GlobalSyncData() :
100 : mCurId ( 0 ),
101 0 : mCurrentStructElement( 0 )
102 : {
103 0 : mStructParents.push_back( 0 );
104 0 : mStructIdMap.push_back( 0 );
105 0 : }
106 : void PlayGlobalActions( PDFWriter& rWriter );
107 : };
108 :
109 0 : sal_Int32 GlobalSyncData::GetMappedId()
110 : {
111 0 : sal_Int32 nLinkId = mParaInts.front();
112 0 : mParaInts.pop_front();
113 :
114 : /* negative values are intentionally passed as invalid IDs
115 : * e.g. to create a new top level outline item
116 : */
117 0 : if( nLinkId >= 0 )
118 : {
119 0 : if ( (sal_uInt32)nLinkId < mParaIds.size() )
120 0 : nLinkId = mParaIds[ nLinkId ];
121 : else
122 0 : nLinkId = -1;
123 :
124 : DBG_ASSERT( nLinkId >= 0, "unmapped id in GlobalSyncData" );
125 : }
126 :
127 0 : return nLinkId;
128 : }
129 :
130 0 : sal_Int32 GlobalSyncData::GetMappedStructId( sal_Int32 nStructId )
131 : {
132 0 : if ( (sal_uInt32)nStructId < mStructIdMap.size() )
133 0 : nStructId = mStructIdMap[ nStructId ];
134 : else
135 0 : nStructId = -1;
136 :
137 : DBG_ASSERT( nStructId >= 0, "unmapped structure id in GlobalSyncData" );
138 :
139 0 : return nStructId;
140 : }
141 :
142 0 : void GlobalSyncData::PlayGlobalActions( PDFWriter& rWriter )
143 : {
144 0 : std::deque< PDFExtOutDevDataSync::Action >::iterator aIter( mActions.begin() );
145 0 : std::deque< PDFExtOutDevDataSync::Action >::iterator aEnd( mActions.end() );
146 0 : while( aIter != aEnd )
147 : {
148 0 : switch( *aIter )
149 : {
150 : case PDFExtOutDevDataSync::CreateNamedDest : //i56629
151 : {
152 0 : rWriter.Push( PUSH_MAPMODE );
153 0 : rWriter.SetMapMode( mParaMapModes.front() );
154 0 : mParaMapModes.pop_front();
155 0 : mParaIds.push_back( rWriter.CreateNamedDest( mParaOUStrings.front(), mParaRects.front(), mParaInts.front(), mParaDestAreaTypes.front() ) );
156 0 : mParaOUStrings.pop_front();
157 0 : mParaRects.pop_front();
158 0 : mParaInts.pop_front();
159 0 : mParaDestAreaTypes.pop_front();
160 0 : rWriter.Pop();
161 : }
162 0 : break;
163 : case PDFExtOutDevDataSync::CreateDest :
164 : {
165 0 : rWriter.Push( PUSH_MAPMODE );
166 0 : rWriter.SetMapMode( mParaMapModes.front() );
167 0 : mParaMapModes.pop_front();
168 0 : mParaIds.push_back( rWriter.CreateDest( mParaRects.front(), mParaInts.front(), mParaDestAreaTypes.front() ) );
169 0 : mParaRects.pop_front();
170 0 : mParaInts.pop_front();
171 0 : mParaDestAreaTypes.pop_front();
172 0 : rWriter.Pop();
173 : }
174 0 : break;
175 : case PDFExtOutDevDataSync::CreateLink :
176 : {
177 0 : rWriter.Push( PUSH_MAPMODE );
178 0 : rWriter.SetMapMode( mParaMapModes.front() );
179 0 : mParaMapModes.pop_front();
180 0 : mParaIds.push_back( rWriter.CreateLink( mParaRects.front(), mParaInts.front() ) );
181 : // resolve LinkAnnotation structural attribute
182 0 : rWriter.SetLinkPropertyID( mParaIds.back(), sal_Int32(mParaIds.size()-1) );
183 0 : mParaRects.pop_front();
184 0 : mParaInts.pop_front();
185 0 : rWriter.Pop();
186 : }
187 0 : break;
188 : case PDFExtOutDevDataSync::SetLinkDest :
189 : {
190 0 : sal_Int32 nLinkId = GetMappedId();
191 0 : sal_Int32 nDestId = GetMappedId();
192 0 : rWriter.SetLinkDest( nLinkId, nDestId );
193 : }
194 0 : break;
195 : case PDFExtOutDevDataSync::SetLinkURL :
196 : {
197 0 : sal_Int32 nLinkId = GetMappedId();
198 0 : rWriter.SetLinkURL( nLinkId, mParaOUStrings.front() );
199 0 : mParaOUStrings.pop_front();
200 : }
201 0 : break;
202 : case PDFExtOutDevDataSync::RegisterDest :
203 : {
204 0 : const sal_Int32 nDestId = mParaInts.front();
205 0 : mParaInts.pop_front();
206 : OSL_ENSURE( mFutureDestinations.find( nDestId ) != mFutureDestinations.end(),
207 : "GlobalSyncData::PlayGlobalActions: DescribeRegisteredRequest has not been called for that destination!" );
208 :
209 0 : PDFLinkDestination& rDest = mFutureDestinations[ nDestId ];
210 :
211 0 : rWriter.Push( PUSH_MAPMODE );
212 0 : rWriter.SetMapMode( rDest.mMapMode );
213 0 : mParaIds.push_back( rWriter.RegisterDestReference( nDestId, rDest.mRect, rDest.mPageNr, rDest.mAreaType ) );
214 0 : rWriter.Pop();
215 : }
216 0 : break;
217 : case PDFExtOutDevDataSync::CreateOutlineItem :
218 : {
219 0 : sal_Int32 nParent = GetMappedId();
220 0 : sal_Int32 nLinkId = GetMappedId();
221 0 : mParaIds.push_back( rWriter.CreateOutlineItem( nParent, mParaOUStrings.front(), nLinkId ) );
222 0 : mParaOUStrings.pop_front();
223 : }
224 0 : break;
225 : case PDFExtOutDevDataSync::SetOutlineItemParent :
226 : {
227 0 : sal_Int32 nItem = GetMappedId();
228 0 : sal_Int32 nNewParent = GetMappedId();
229 0 : rWriter.SetOutlineItemParent( nItem, nNewParent );
230 : }
231 0 : break;
232 : case PDFExtOutDevDataSync::SetOutlineItemText :
233 : {
234 0 : sal_Int32 nItem = GetMappedId();
235 0 : rWriter.SetOutlineItemText( nItem, mParaOUStrings.front() );
236 0 : mParaOUStrings.pop_front();
237 : }
238 0 : break;
239 : case PDFExtOutDevDataSync::SetOutlineItemDest :
240 : {
241 0 : sal_Int32 nItem = GetMappedId();
242 0 : sal_Int32 nDestId = GetMappedId();
243 0 : rWriter.SetOutlineItemDest( nItem, nDestId );
244 : }
245 0 : break;
246 : case PDFExtOutDevDataSync::CreateNote :
247 : {
248 0 : rWriter.Push( PUSH_MAPMODE );
249 0 : rWriter.SetMapMode( mParaMapModes.front() );
250 0 : rWriter.CreateNote( mParaRects.front(), mParaPDFNotes.front(), mParaInts.front() );
251 0 : mParaMapModes.pop_front();
252 0 : mParaRects.pop_front();
253 0 : mParaPDFNotes.pop_front();
254 0 : mParaInts.pop_front();
255 : }
256 0 : break;
257 : case PDFExtOutDevDataSync::SetAutoAdvanceTime :
258 : {
259 0 : rWriter.SetAutoAdvanceTime( mParauInts.front(), mParaInts.front() );
260 0 : mParauInts.pop_front();
261 0 : mParaInts.pop_front();
262 : }
263 0 : break;
264 : case PDFExtOutDevDataSync::SetPageTransition :
265 : {
266 0 : rWriter.SetPageTransition( mParaPageTransitions.front(), mParauInts.front(), mParaInts.front() );
267 0 : mParaPageTransitions.pop_front();
268 0 : mParauInts.pop_front();
269 0 : mParaInts.pop_front();
270 : }
271 0 : break;
272 : case PDFExtOutDevDataSync::BeginStructureElement:
273 : case PDFExtOutDevDataSync::EndStructureElement:
274 : case PDFExtOutDevDataSync::SetCurrentStructureElement:
275 : case PDFExtOutDevDataSync::SetStructureAttribute:
276 : case PDFExtOutDevDataSync::SetStructureAttributeNumerical:
277 : case PDFExtOutDevDataSync::SetStructureBoundingBox:
278 : case PDFExtOutDevDataSync::SetActualText:
279 : case PDFExtOutDevDataSync::SetAlternateText:
280 : case PDFExtOutDevDataSync::CreateControl:
281 : case PDFExtOutDevDataSync::BeginGroup:
282 : case PDFExtOutDevDataSync::EndGroup:
283 : case PDFExtOutDevDataSync::EndGroupGfxLink:
284 0 : break;
285 : }
286 0 : aIter++;
287 : }
288 0 : }
289 :
290 0 : struct SAL_DLLPRIVATE PageSyncData
291 : {
292 : std::deque< PDFExtOutDevDataSync > mActions;
293 : std::deque< Rectangle > mParaRects;
294 : std::deque< sal_Int32 > mParaInts;
295 : std::deque< rtl::OUString > mParaOUStrings;
296 : std::deque< PDFWriter::StructElement > mParaStructElements;
297 : std::deque< PDFWriter::StructAttribute > mParaStructAttributes;
298 : std::deque< PDFWriter::StructAttributeValue > mParaStructAttributeValues;
299 : std::deque< Graphic > mGraphics;
300 : std::deque< ::boost::shared_ptr< PDFWriter::AnyWidget > >
301 : mControls;
302 : GlobalSyncData* mpGlobalData;
303 :
304 : sal_Bool mbGroupIgnoreGDIMtfActions;
305 :
306 0 : PageSyncData( GlobalSyncData* pGlobal ) : mbGroupIgnoreGDIMtfActions ( sal_False ) { mpGlobalData = pGlobal; }
307 :
308 : void PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDataSync::Action eAct );
309 : sal_Bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const PDFExtOutDevData& rOutDevData );
310 : };
311 0 : void PageSyncData::PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDataSync::Action eAct )
312 : {
313 0 : GDIMetaFile* pMtf = rOutDev.GetConnectMetaFile();
314 : DBG_ASSERT( pMtf, "PageSyncData::PushAction -> no ConnectMetaFile !!!" );
315 :
316 : PDFExtOutDevDataSync aSync;
317 0 : aSync.eAct = eAct;
318 0 : if ( pMtf )
319 0 : aSync.nIdx = pMtf->GetActionSize();
320 : else
321 0 : aSync.nIdx = 0x7fffffff; // sync not possible
322 0 : mActions.push_back( aSync );
323 0 : }
324 0 : sal_Bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const PDFExtOutDevData& rOutDevData )
325 : {
326 0 : sal_Bool bRet = sal_False;
327 0 : if ( mActions.size() && ( mActions.front().nIdx == rCurGDIMtfAction ) )
328 : {
329 0 : bRet = sal_True;
330 0 : PDFExtOutDevDataSync aDataSync = mActions.front();
331 0 : mActions.pop_front();
332 0 : switch( aDataSync.eAct )
333 : {
334 : case PDFExtOutDevDataSync::BeginStructureElement :
335 : {
336 0 : sal_Int32 nNewEl = rWriter.BeginStructureElement( mParaStructElements.front(), mParaOUStrings.front() ) ;
337 0 : mParaStructElements.pop_front();
338 0 : mParaOUStrings.pop_front();
339 0 : mpGlobalData->mStructIdMap.push_back( nNewEl );
340 : }
341 0 : break;
342 : case PDFExtOutDevDataSync::EndStructureElement :
343 : {
344 0 : rWriter.EndStructureElement();
345 : }
346 0 : break;
347 : case PDFExtOutDevDataSync::SetCurrentStructureElement:
348 : {
349 0 : rWriter.SetCurrentStructureElement( mpGlobalData->GetMappedStructId( mParaInts.front() ) );
350 0 : mParaInts.pop_front();
351 : }
352 0 : break;
353 : case PDFExtOutDevDataSync::SetStructureAttribute :
354 : {
355 0 : rWriter.SetStructureAttribute( mParaStructAttributes.front(), mParaStructAttributeValues.front() );
356 0 : mParaStructAttributeValues.pop_front();
357 0 : mParaStructAttributes.pop_front();
358 : }
359 0 : break;
360 : case PDFExtOutDevDataSync::SetStructureAttributeNumerical :
361 : {
362 0 : rWriter.SetStructureAttributeNumerical( mParaStructAttributes.front(), mParaInts.front() );
363 0 : mParaStructAttributes.pop_front();
364 0 : mParaInts.pop_front();
365 : }
366 0 : break;
367 : case PDFExtOutDevDataSync::SetStructureBoundingBox :
368 : {
369 0 : rWriter.SetStructureBoundingBox( mParaRects.front() );
370 0 : mParaRects.pop_front();
371 : }
372 0 : break;
373 : case PDFExtOutDevDataSync::SetActualText :
374 : {
375 0 : rWriter.SetActualText( mParaOUStrings.front() );
376 0 : mParaOUStrings.pop_front();
377 : }
378 0 : break;
379 : case PDFExtOutDevDataSync::SetAlternateText :
380 : {
381 0 : rWriter.SetAlternateText( mParaOUStrings.front() );
382 0 : mParaOUStrings.pop_front();
383 : }
384 0 : break;
385 : case PDFExtOutDevDataSync::CreateControl:
386 : {
387 0 : ::boost::shared_ptr< PDFWriter::AnyWidget > pControl( mControls.front() );
388 : DBG_ASSERT( pControl.get(), "PageSyncData::PlaySyncPageAct: invalid widget!" );
389 0 : if ( pControl.get() )
390 0 : rWriter.CreateControl( *pControl );
391 0 : mControls.pop_front();
392 : }
393 0 : break;
394 : case PDFExtOutDevDataSync::BeginGroup :
395 : {
396 : /* first determining if this BeginGroup is starting a GfxLink,
397 : by searching for a EndGroup or a EndGroupGfxLink */
398 0 : mbGroupIgnoreGDIMtfActions = sal_False;
399 0 : std::deque< PDFExtOutDevDataSync >::iterator aBeg = mActions.begin();
400 0 : std::deque< PDFExtOutDevDataSync >::iterator aEnd = mActions.end();
401 0 : while ( aBeg != aEnd )
402 : {
403 0 : if ( aBeg->eAct == PDFExtOutDevDataSync::EndGroup )
404 : {
405 0 : break;
406 : }
407 0 : else if ( aBeg->eAct == PDFExtOutDevDataSync::EndGroupGfxLink )
408 : {
409 0 : if ( rOutDevData.GetIsLosslessCompression() && !rOutDevData.GetIsReduceImageResolution() )
410 : {
411 0 : Graphic& rGraphic = mGraphics.front();
412 0 : if ( rGraphic.IsLink() && rGraphic.GetLink().GetType() == GFX_LINK_TYPE_NATIVE_JPG )
413 : {
414 0 : mbGroupIgnoreGDIMtfActions = sal_True;
415 : }
416 : }
417 0 : break;
418 : }
419 0 : ++aBeg;
420 : }
421 : }
422 0 : break;
423 : case PDFExtOutDevDataSync::EndGroup :
424 : {
425 0 : mbGroupIgnoreGDIMtfActions = sal_False;
426 : }
427 0 : break;
428 : case PDFExtOutDevDataSync::EndGroupGfxLink :
429 : {
430 0 : Rectangle aOutputRect, aVisibleOutputRect;
431 0 : Graphic aGraphic( mGraphics.front() );
432 :
433 0 : mGraphics.pop_front();
434 0 : mParaInts.pop_front(); //Transparency
435 0 : aOutputRect = mParaRects.front();
436 0 : mParaRects.pop_front();
437 0 : aVisibleOutputRect = mParaRects.front();
438 0 : mParaRects.pop_front();
439 :
440 0 : if ( mbGroupIgnoreGDIMtfActions )
441 : {
442 0 : sal_Bool bClippingNeeded = ( aOutputRect != aVisibleOutputRect ) && !aVisibleOutputRect.IsEmpty();
443 :
444 0 : GfxLink aGfxLink( aGraphic.GetLink() );
445 0 : if ( aGfxLink.GetType() == GFX_LINK_TYPE_NATIVE_JPG )
446 : {
447 0 : if ( bClippingNeeded )
448 : {
449 0 : rWriter.Push();
450 : basegfx::B2DPolyPolygon aRect( basegfx::tools::createPolygonFromRect(
451 0 : basegfx::B2DRectangle( aVisibleOutputRect.Left(), aVisibleOutputRect.Top(),
452 0 : aVisibleOutputRect.Right(), aVisibleOutputRect.Bottom() ) ) );
453 0 : rWriter.SetClipRegion( aRect);
454 : }
455 0 : Bitmap aMask;
456 0 : SvMemoryStream aTmp;
457 0 : const sal_uInt8* pData = aGfxLink.GetData();
458 0 : sal_uInt32 nBytes = aGfxLink.GetDataSize();
459 0 : if( pData && nBytes )
460 : {
461 0 : aTmp.Write( pData, nBytes );
462 0 : rWriter.DrawJPGBitmap( aTmp, aGraphic.GetBitmap().GetBitCount() > 8, aGraphic.GetSizePixel(), aOutputRect, aMask );
463 : }
464 :
465 0 : if ( bClippingNeeded )
466 0 : rWriter.Pop();
467 : }
468 0 : mbGroupIgnoreGDIMtfActions = sal_False;
469 0 : }
470 : }
471 0 : break;
472 : case PDFExtOutDevDataSync::CreateNamedDest:
473 : case PDFExtOutDevDataSync::CreateDest:
474 : case PDFExtOutDevDataSync::CreateLink:
475 : case PDFExtOutDevDataSync::SetLinkDest:
476 : case PDFExtOutDevDataSync::SetLinkURL:
477 : case PDFExtOutDevDataSync::RegisterDest:
478 : case PDFExtOutDevDataSync::CreateOutlineItem:
479 : case PDFExtOutDevDataSync::SetOutlineItemParent:
480 : case PDFExtOutDevDataSync::SetOutlineItemText:
481 : case PDFExtOutDevDataSync::SetOutlineItemDest:
482 : case PDFExtOutDevDataSync::CreateNote:
483 : case PDFExtOutDevDataSync::SetAutoAdvanceTime:
484 : case PDFExtOutDevDataSync::SetPageTransition:
485 0 : break;
486 : }
487 : }
488 0 : else if ( mbGroupIgnoreGDIMtfActions )
489 : {
490 0 : rCurGDIMtfAction++;
491 0 : bRet = sal_True;
492 : }
493 0 : return bRet;
494 : }
495 :
496 0 : TYPEINIT1(PDFExtOutDevData,ExtOutDevData);
497 0 : PDFExtOutDevData::PDFExtOutDevData( const OutputDevice& rOutDev ) :
498 : mrOutDev ( rOutDev ),
499 : mbTaggedPDF ( sal_False ),
500 : mbExportNotes ( sal_True ),
501 : mbExportNotesPages ( sal_False ),
502 : mbTransitionEffects ( sal_True ),
503 : mbUseLosslessCompression( sal_True ),
504 : mbReduceImageResolution ( sal_False ),
505 : mbExportHiddenSlides ( sal_False ),
506 : mbExportNDests ( sal_False ),
507 : mnFormsFormat ( 0 ),
508 : mnPage ( -1 ),
509 : mpPageSyncData ( NULL ),
510 0 : mpGlobalSyncData ( new GlobalSyncData() )
511 : {
512 0 : mpPageSyncData = new PageSyncData( mpGlobalSyncData );
513 0 : }
514 :
515 0 : PDFExtOutDevData::~PDFExtOutDevData()
516 : {
517 0 : delete mpPageSyncData;
518 0 : delete mpGlobalSyncData;
519 0 : }
520 :
521 0 : const com::sun::star::lang::Locale& PDFExtOutDevData::GetDocumentLocale() const
522 : {
523 0 : return maDocLocale;
524 : }
525 0 : void PDFExtOutDevData::SetDocumentLocale( const com::sun::star::lang::Locale& rLoc )
526 : {
527 0 : maDocLocale = rLoc;
528 0 : }
529 0 : sal_Int32 PDFExtOutDevData::GetCurrentPageNumber() const
530 : {
531 0 : return mnPage;
532 : }
533 0 : void PDFExtOutDevData::SetCurrentPageNumber( const sal_Int32 nPage )
534 : {
535 0 : mnPage = nPage;
536 0 : }
537 0 : sal_Bool PDFExtOutDevData::GetIsLosslessCompression() const
538 : {
539 0 : return mbUseLosslessCompression;
540 : }
541 0 : void PDFExtOutDevData::SetIsLosslessCompression( const sal_Bool bUseLosslessCompression )
542 : {
543 0 : mbUseLosslessCompression = bUseLosslessCompression;
544 0 : }
545 0 : sal_Bool PDFExtOutDevData::GetIsReduceImageResolution() const
546 : {
547 0 : return mbReduceImageResolution;
548 : }
549 0 : void PDFExtOutDevData::SetIsReduceImageResolution( const sal_Bool bReduceImageResolution )
550 : {
551 0 : mbReduceImageResolution = bReduceImageResolution;
552 0 : }
553 0 : sal_Bool PDFExtOutDevData::GetIsExportNotes() const
554 : {
555 0 : return mbExportNotes;
556 : }
557 0 : void PDFExtOutDevData::SetIsExportNotes( const sal_Bool bExportNotes )
558 : {
559 0 : mbExportNotes = bExportNotes;
560 0 : }
561 0 : sal_Bool PDFExtOutDevData::GetIsExportNotesPages() const
562 : {
563 0 : return mbExportNotesPages;
564 : }
565 0 : void PDFExtOutDevData::SetIsExportNotesPages( const sal_Bool bExportNotesPages )
566 : {
567 0 : mbExportNotesPages = bExportNotesPages;
568 0 : }
569 0 : sal_Bool PDFExtOutDevData::GetIsExportTaggedPDF() const
570 : {
571 0 : return mbTaggedPDF;
572 : }
573 0 : void PDFExtOutDevData::SetIsExportTaggedPDF( const sal_Bool bTaggedPDF )
574 : {
575 0 : mbTaggedPDF = bTaggedPDF;
576 0 : }
577 0 : sal_Bool PDFExtOutDevData::GetIsExportTransitionEffects() const
578 : {
579 0 : return mbTransitionEffects;
580 : }
581 0 : void PDFExtOutDevData::SetIsExportTransitionEffects( const sal_Bool bTransitionEffects )
582 : {
583 0 : mbTransitionEffects = bTransitionEffects;
584 0 : }
585 0 : sal_Bool PDFExtOutDevData::GetIsExportFormFields() const
586 : {
587 0 : return mbExportFormFields;
588 : }
589 0 : void PDFExtOutDevData::SetIsExportFormFields( const sal_Bool bExportFomtFields )
590 : {
591 0 : mbExportFormFields = bExportFomtFields;
592 0 : }
593 0 : void PDFExtOutDevData::SetFormsFormat( const sal_Int32 nFormsFormat )
594 : {
595 0 : mnFormsFormat = nFormsFormat;
596 0 : }
597 0 : sal_Bool PDFExtOutDevData::GetIsExportBookmarks() const
598 : {
599 0 : return mbExportBookmarks;
600 : }
601 0 : void PDFExtOutDevData::SetIsExportBookmarks( const sal_Bool bExportBookmarks )
602 : {
603 0 : mbExportBookmarks = bExportBookmarks;
604 0 : }
605 0 : sal_Bool PDFExtOutDevData::GetIsExportHiddenSlides() const
606 : {
607 0 : return mbExportHiddenSlides;
608 : }
609 0 : void PDFExtOutDevData::SetIsExportHiddenSlides( const sal_Bool bExportHiddenSlides )
610 : {
611 0 : mbExportHiddenSlides = bExportHiddenSlides;
612 0 : }
613 0 : std::vector< PDFExtOutDevBookmarkEntry >& PDFExtOutDevData::GetBookmarks()
614 : {
615 0 : return maBookmarks;
616 : }
617 0 : sal_Bool PDFExtOutDevData::GetIsExportNamedDestinations() const
618 : {
619 0 : return mbExportNDests;
620 : }
621 0 : void PDFExtOutDevData::SetIsExportNamedDestinations( const sal_Bool bExportNDests )
622 : {
623 0 : mbExportNDests = bExportNDests;
624 0 : }
625 0 : void PDFExtOutDevData::ResetSyncData()
626 : {
627 0 : *mpPageSyncData = PageSyncData( mpGlobalSyncData );
628 0 : }
629 0 : sal_Bool PDFExtOutDevData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rIdx )
630 : {
631 0 : return mpPageSyncData->PlaySyncPageAct( rWriter, rIdx, *this );
632 : }
633 0 : void PDFExtOutDevData::PlayGlobalActions( PDFWriter& rWriter )
634 : {
635 0 : mpGlobalSyncData->PlayGlobalActions( rWriter );
636 0 : }
637 :
638 : /* global actions, syncronisation to the recorded metafile isn't needed,
639 : all actions will be played after the last page was recorded
640 : */
641 : //--->i56629
642 0 : sal_Int32 PDFExtOutDevData::CreateNamedDest(const String& sDestName, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
643 : {
644 0 : mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateNamedDest );
645 0 : mpGlobalSyncData->mParaOUStrings.push_back( sDestName );
646 0 : mpGlobalSyncData->mParaRects.push_back( rRect );
647 0 : mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
648 0 : mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
649 0 : mpGlobalSyncData->mParaDestAreaTypes.push_back( eType );
650 :
651 0 : return mpGlobalSyncData->mCurId++;
652 : }
653 : //<---i56629
654 0 : sal_Int32 PDFExtOutDevData::RegisterDest()
655 : {
656 0 : const sal_Int32 nLinkDestID = mpGlobalSyncData->mCurId++;
657 0 : mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::RegisterDest );
658 0 : mpGlobalSyncData->mParaInts.push_back( nLinkDestID );
659 :
660 0 : return nLinkDestID;
661 : }
662 0 : void PDFExtOutDevData::DescribeRegisteredDest( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
663 : {
664 : OSL_PRECOND( nDestId != -1, "PDFExtOutDevData::DescribeRegisteredDest: invalid destination Id!" );
665 0 : PDFLinkDestination aLinkDestination;
666 0 : aLinkDestination.mRect = rRect;
667 0 : aLinkDestination.mMapMode = mrOutDev.GetMapMode();
668 0 : aLinkDestination.mPageNr = nPageNr == -1 ? mnPage : nPageNr;
669 0 : aLinkDestination.mAreaType = eType;
670 0 : mpGlobalSyncData->mFutureDestinations[ nDestId ] = aLinkDestination;
671 0 : }
672 0 : sal_Int32 PDFExtOutDevData::CreateDest( const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
673 : {
674 0 : mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateDest );
675 0 : mpGlobalSyncData->mParaRects.push_back( rRect );
676 0 : mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
677 0 : mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
678 0 : mpGlobalSyncData->mParaDestAreaTypes.push_back( eType );
679 0 : return mpGlobalSyncData->mCurId++;
680 : }
681 0 : sal_Int32 PDFExtOutDevData::CreateLink( const Rectangle& rRect, sal_Int32 nPageNr )
682 : {
683 0 : mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateLink );
684 0 : mpGlobalSyncData->mParaRects.push_back( rRect );
685 0 : mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
686 0 : mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
687 0 : return mpGlobalSyncData->mCurId++;
688 : }
689 0 : sal_Int32 PDFExtOutDevData::SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId )
690 : {
691 0 : mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetLinkDest );
692 0 : mpGlobalSyncData->mParaInts.push_back( nLinkId );
693 0 : mpGlobalSyncData->mParaInts.push_back( nDestId );
694 0 : return 0;
695 : }
696 0 : sal_Int32 PDFExtOutDevData::SetLinkURL( sal_Int32 nLinkId, const rtl::OUString& rURL )
697 : {
698 0 : mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetLinkURL );
699 0 : mpGlobalSyncData->mParaInts.push_back( nLinkId );
700 0 : mpGlobalSyncData->mParaOUStrings.push_back( rURL );
701 0 : return 0;
702 : }
703 0 : sal_Int32 PDFExtOutDevData::CreateOutlineItem( sal_Int32 nParent, const rtl::OUString& rText, sal_Int32 nDestID )
704 : {
705 0 : mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateOutlineItem );
706 0 : mpGlobalSyncData->mParaInts.push_back( nParent );
707 0 : mpGlobalSyncData->mParaOUStrings.push_back( rText );
708 0 : mpGlobalSyncData->mParaInts.push_back( nDestID );
709 0 : return mpGlobalSyncData->mCurId++;
710 : }
711 0 : void PDFExtOutDevData::CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr )
712 : {
713 0 : mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateNote );
714 0 : mpGlobalSyncData->mParaRects.push_back( rRect );
715 0 : mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
716 0 : mpGlobalSyncData->mParaPDFNotes.push_back( rNote );
717 0 : mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
718 0 : }
719 0 : void PDFExtOutDevData::SetPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr )
720 : {
721 0 : mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetPageTransition );
722 0 : mpGlobalSyncData->mParaPageTransitions.push_back( eType );
723 0 : mpGlobalSyncData->mParauInts.push_back( nMilliSec );
724 0 : mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
725 0 : }
726 :
727 : /* local (page), actions have to be played synchroniously to the actions of
728 : of the recorded metafile (created by each xRenderable->render()) */
729 0 : sal_Int32 PDFExtOutDevData::BeginStructureElement( PDFWriter::StructElement eType, const rtl::OUString& rAlias )
730 : {
731 0 : mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::BeginStructureElement );
732 0 : mpPageSyncData->mParaStructElements.push_back( eType );
733 0 : mpPageSyncData->mParaOUStrings.push_back( rAlias );
734 : // need a global id
735 0 : sal_Int32 nNewId = mpGlobalSyncData->mStructParents.size();
736 0 : mpGlobalSyncData->mStructParents.push_back( mpGlobalSyncData->mCurrentStructElement );
737 0 : mpGlobalSyncData->mCurrentStructElement = nNewId;
738 0 : return nNewId;
739 : }
740 0 : void PDFExtOutDevData::EndStructureElement()
741 : {
742 0 : mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::EndStructureElement );
743 0 : mpGlobalSyncData->mCurrentStructElement = mpGlobalSyncData->mStructParents[ mpGlobalSyncData->mCurrentStructElement ];
744 0 : }
745 0 : bool PDFExtOutDevData::SetCurrentStructureElement( sal_Int32 nStructId )
746 : {
747 0 : bool bSuccess = false;
748 0 : if( sal_uInt32(nStructId) < mpGlobalSyncData->mStructParents.size() )
749 : {
750 0 : mpGlobalSyncData->mCurrentStructElement = nStructId;
751 0 : mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetCurrentStructureElement );
752 0 : mpPageSyncData->mParaInts.push_back( nStructId );
753 0 : bSuccess = true;
754 : }
755 0 : return bSuccess;
756 : }
757 0 : sal_Int32 PDFExtOutDevData::GetCurrentStructureElement()
758 : {
759 0 : return mpGlobalSyncData->mCurrentStructElement;
760 : }
761 0 : bool PDFExtOutDevData::SetStructureAttribute( PDFWriter::StructAttribute eAttr, PDFWriter::StructAttributeValue eVal )
762 : {
763 0 : mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetStructureAttribute );
764 0 : mpPageSyncData->mParaStructAttributes.push_back( eAttr );
765 0 : mpPageSyncData->mParaStructAttributeValues.push_back( eVal );
766 0 : return true;
767 : }
768 0 : bool PDFExtOutDevData::SetStructureAttributeNumerical( PDFWriter::StructAttribute eAttr, sal_Int32 nValue )
769 : {
770 0 : mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetStructureAttributeNumerical );
771 0 : mpPageSyncData->mParaStructAttributes.push_back( eAttr );
772 0 : mpPageSyncData->mParaInts.push_back( nValue );
773 0 : return true;
774 : }
775 0 : void PDFExtOutDevData::SetStructureBoundingBox( const Rectangle& rRect )
776 : {
777 0 : mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetStructureBoundingBox );
778 0 : mpPageSyncData->mParaRects.push_back( rRect );
779 0 : }
780 0 : void PDFExtOutDevData::SetActualText( const String& rText )
781 : {
782 0 : mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetActualText );
783 0 : mpPageSyncData->mParaOUStrings.push_back( rText );
784 0 : }
785 0 : void PDFExtOutDevData::SetAlternateText( const String& rText )
786 : {
787 0 : mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetAlternateText );
788 0 : mpPageSyncData->mParaOUStrings.push_back( rText );
789 0 : }
790 :
791 0 : void PDFExtOutDevData::CreateControl( const PDFWriter::AnyWidget& rControlType, sal_Int32 /*nPageNr*/ )
792 : {
793 0 : mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::CreateControl );
794 :
795 0 : ::boost::shared_ptr< PDFWriter::AnyWidget > pClone( rControlType.Clone() );
796 0 : mpPageSyncData->mControls.push_back( pClone );
797 0 : }
798 :
799 0 : void PDFExtOutDevData::BeginGroup()
800 : {
801 0 : mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::BeginGroup );
802 0 : }
803 :
804 0 : void PDFExtOutDevData::EndGroup( const Graphic& rGraphic,
805 : sal_uInt8 nTransparency,
806 : const Rectangle& rOutputRect,
807 : const Rectangle& rVisibleOutputRect )
808 : {
809 0 : mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::EndGroupGfxLink );
810 0 : mpPageSyncData->mGraphics.push_back( rGraphic );
811 0 : mpPageSyncData->mParaInts.push_back( nTransparency );
812 0 : mpPageSyncData->mParaRects.push_back( rOutputRect );
813 0 : mpPageSyncData->mParaRects.push_back( rVisibleOutputRect );
814 0 : }
815 :
816 : }
817 :
818 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|