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