bump product version to 4.2.0.1
[LibreOffice.git] / vcl / source / gdi / pdfextoutdevdata.cxx
bloba06315ff700e4e02b71b7b9dad52ae8dd0966fb1
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 #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"
29 #include <boost/shared_ptr.hpp>
30 #include <set>
31 #include <map>
33 namespace vcl
35 struct SAL_DLLPRIVATE PDFExtOutDevDataSync
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,
51 BeginStructureElement,
52 EndStructureElement,
53 SetCurrentStructureElement,
54 SetStructureAttribute,
55 SetStructureAttributeNumerical,
56 SetStructureBoundingBox,
57 SetActualText,
58 SetAlternateText,
59 CreateControl,
60 BeginGroup,
61 EndGroup,
62 EndGroupGfxLink
65 sal_uInt32 nIdx;
66 Action eAct;
69 struct SAL_DLLPRIVATE PDFLinkDestination
71 Rectangle mRect;
72 MapMode mMapMode;
73 sal_Int32 mPageNr;
74 PDFWriter::DestAreaType mAreaType;
77 struct SAL_DLLPRIVATE GlobalSyncData
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;
90 sal_Int32 GetMappedId();
91 sal_Int32 GetMappedStructId( sal_Int32 );
93 sal_Int32 mCurId;
94 std::vector< sal_Int32 > mParaIds;
95 std::vector< sal_Int32 > mStructIdMap;
97 sal_Int32 mCurrentStructElement;
98 std::vector< sal_Int32 > mStructParents;
99 GlobalSyncData() :
100 mCurId ( 0 ),
101 mCurrentStructElement( 0 )
103 mStructParents.push_back( 0 );
104 mStructIdMap.push_back( 0 );
106 void PlayGlobalActions( PDFWriter& rWriter );
109 sal_Int32 GlobalSyncData::GetMappedId()
111 sal_Int32 nLinkId = mParaInts.front();
112 mParaInts.pop_front();
114 /* negative values are intentionally passed as invalid IDs
115 * e.g. to create a new top level outline item
117 if( nLinkId >= 0 )
119 if ( (sal_uInt32)nLinkId < mParaIds.size() )
120 nLinkId = mParaIds[ nLinkId ];
121 else
122 nLinkId = -1;
124 DBG_ASSERT( nLinkId >= 0, "unmapped id in GlobalSyncData" );
127 return nLinkId;
130 sal_Int32 GlobalSyncData::GetMappedStructId( sal_Int32 nStructId )
132 if ( (sal_uInt32)nStructId < mStructIdMap.size() )
133 nStructId = mStructIdMap[ nStructId ];
134 else
135 nStructId = -1;
137 DBG_ASSERT( nStructId >= 0, "unmapped structure id in GlobalSyncData" );
139 return nStructId;
142 void GlobalSyncData::PlayGlobalActions( PDFWriter& rWriter )
144 for (std::deque< PDFExtOutDevDataSync::Action >::const_iterator aIter( mActions.begin() ), aEnd( mActions.end() ) ;
145 aIter != aEnd ; ++aIter)
147 switch( *aIter )
149 case PDFExtOutDevDataSync::CreateNamedDest : //i56629
151 rWriter.Push( PUSH_MAPMODE );
152 rWriter.SetMapMode( mParaMapModes.front() );
153 mParaMapModes.pop_front();
154 mParaIds.push_back( rWriter.CreateNamedDest( mParaOUStrings.front(), mParaRects.front(), mParaInts.front(), mParaDestAreaTypes.front() ) );
155 mParaOUStrings.pop_front();
156 mParaRects.pop_front();
157 mParaInts.pop_front();
158 mParaDestAreaTypes.pop_front();
159 rWriter.Pop();
161 break;
162 case PDFExtOutDevDataSync::CreateDest :
164 rWriter.Push( PUSH_MAPMODE );
165 rWriter.SetMapMode( mParaMapModes.front() );
166 mParaMapModes.pop_front();
167 mParaIds.push_back( rWriter.CreateDest( mParaRects.front(), mParaInts.front(), mParaDestAreaTypes.front() ) );
168 mParaRects.pop_front();
169 mParaInts.pop_front();
170 mParaDestAreaTypes.pop_front();
171 rWriter.Pop();
173 break;
174 case PDFExtOutDevDataSync::CreateLink :
176 rWriter.Push( PUSH_MAPMODE );
177 rWriter.SetMapMode( mParaMapModes.front() );
178 mParaMapModes.pop_front();
179 mParaIds.push_back( rWriter.CreateLink( mParaRects.front(), mParaInts.front() ) );
180 // resolve LinkAnnotation structural attribute
181 rWriter.SetLinkPropertyID( mParaIds.back(), sal_Int32(mParaIds.size()-1) );
182 mParaRects.pop_front();
183 mParaInts.pop_front();
184 rWriter.Pop();
186 break;
187 case PDFExtOutDevDataSync::SetLinkDest :
189 sal_Int32 nLinkId = GetMappedId();
190 sal_Int32 nDestId = GetMappedId();
191 rWriter.SetLinkDest( nLinkId, nDestId );
193 break;
194 case PDFExtOutDevDataSync::SetLinkURL :
196 sal_Int32 nLinkId = GetMappedId();
197 rWriter.SetLinkURL( nLinkId, mParaOUStrings.front() );
198 mParaOUStrings.pop_front();
200 break;
201 case PDFExtOutDevDataSync::RegisterDest :
203 const sal_Int32 nDestId = mParaInts.front();
204 mParaInts.pop_front();
205 OSL_ENSURE( mFutureDestinations.find( nDestId ) != mFutureDestinations.end(),
206 "GlobalSyncData::PlayGlobalActions: DescribeRegisteredRequest has not been called for that destination!" );
208 PDFLinkDestination& rDest = mFutureDestinations[ nDestId ];
210 rWriter.Push( PUSH_MAPMODE );
211 rWriter.SetMapMode( rDest.mMapMode );
212 mParaIds.push_back( rWriter.RegisterDestReference( nDestId, rDest.mRect, rDest.mPageNr, rDest.mAreaType ) );
213 rWriter.Pop();
215 break;
216 case PDFExtOutDevDataSync::CreateOutlineItem :
218 sal_Int32 nParent = GetMappedId();
219 sal_Int32 nLinkId = GetMappedId();
220 mParaIds.push_back( rWriter.CreateOutlineItem( nParent, mParaOUStrings.front(), nLinkId ) );
221 mParaOUStrings.pop_front();
223 break;
224 case PDFExtOutDevDataSync::SetOutlineItemParent :
226 sal_Int32 nItem = GetMappedId();
227 sal_Int32 nNewParent = GetMappedId();
228 rWriter.SetOutlineItemParent( nItem, nNewParent );
230 break;
231 case PDFExtOutDevDataSync::SetOutlineItemText :
233 sal_Int32 nItem = GetMappedId();
234 rWriter.SetOutlineItemText( nItem, mParaOUStrings.front() );
235 mParaOUStrings.pop_front();
237 break;
238 case PDFExtOutDevDataSync::SetOutlineItemDest :
240 sal_Int32 nItem = GetMappedId();
241 sal_Int32 nDestId = GetMappedId();
242 rWriter.SetOutlineItemDest( nItem, nDestId );
244 break;
245 case PDFExtOutDevDataSync::CreateNote :
247 rWriter.Push( PUSH_MAPMODE );
248 rWriter.SetMapMode( mParaMapModes.front() );
249 rWriter.CreateNote( mParaRects.front(), mParaPDFNotes.front(), mParaInts.front() );
250 mParaMapModes.pop_front();
251 mParaRects.pop_front();
252 mParaPDFNotes.pop_front();
253 mParaInts.pop_front();
255 break;
256 case PDFExtOutDevDataSync::SetAutoAdvanceTime :
258 rWriter.SetAutoAdvanceTime( mParauInts.front(), mParaInts.front() );
259 mParauInts.pop_front();
260 mParaInts.pop_front();
262 break;
263 case PDFExtOutDevDataSync::SetPageTransition :
265 rWriter.SetPageTransition( mParaPageTransitions.front(), mParauInts.front(), mParaInts.front() );
266 mParaPageTransitions.pop_front();
267 mParauInts.pop_front();
268 mParaInts.pop_front();
270 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 break;
288 struct SAL_DLLPRIVATE PageSyncData
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;
302 bool mbGroupIgnoreGDIMtfActions;
304 PageSyncData( GlobalSyncData* pGlobal ) : mbGroupIgnoreGDIMtfActions ( false ) { mpGlobalData = pGlobal; }
306 void PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDataSync::Action eAct );
307 sal_Bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const PDFExtOutDevData& rOutDevData );
309 void PageSyncData::PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDataSync::Action eAct )
311 GDIMetaFile* pMtf = rOutDev.GetConnectMetaFile();
312 DBG_ASSERT( pMtf, "PageSyncData::PushAction -> no ConnectMetaFile !!!" );
314 PDFExtOutDevDataSync aSync;
315 aSync.eAct = eAct;
316 if ( pMtf )
317 aSync.nIdx = pMtf->GetActionSize();
318 else
319 aSync.nIdx = 0x7fffffff; // sync not possible
320 mActions.push_back( aSync );
322 sal_Bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const PDFExtOutDevData& rOutDevData )
324 sal_Bool bRet = sal_False;
325 if ( mActions.size() && ( mActions.front().nIdx == rCurGDIMtfAction ) )
327 bRet = sal_True;
328 PDFExtOutDevDataSync aDataSync = mActions.front();
329 mActions.pop_front();
330 switch( aDataSync.eAct )
332 case PDFExtOutDevDataSync::BeginStructureElement :
334 sal_Int32 nNewEl = rWriter.BeginStructureElement( mParaStructElements.front(), mParaOUStrings.front() ) ;
335 mParaStructElements.pop_front();
336 mParaOUStrings.pop_front();
337 mpGlobalData->mStructIdMap.push_back( nNewEl );
339 break;
340 case PDFExtOutDevDataSync::EndStructureElement :
342 rWriter.EndStructureElement();
344 break;
345 case PDFExtOutDevDataSync::SetCurrentStructureElement:
347 rWriter.SetCurrentStructureElement( mpGlobalData->GetMappedStructId( mParaInts.front() ) );
348 mParaInts.pop_front();
350 break;
351 case PDFExtOutDevDataSync::SetStructureAttribute :
353 rWriter.SetStructureAttribute( mParaStructAttributes.front(), mParaStructAttributeValues.front() );
354 mParaStructAttributeValues.pop_front();
355 mParaStructAttributes.pop_front();
357 break;
358 case PDFExtOutDevDataSync::SetStructureAttributeNumerical :
360 rWriter.SetStructureAttributeNumerical( mParaStructAttributes.front(), mParaInts.front() );
361 mParaStructAttributes.pop_front();
362 mParaInts.pop_front();
364 break;
365 case PDFExtOutDevDataSync::SetStructureBoundingBox :
367 rWriter.SetStructureBoundingBox( mParaRects.front() );
368 mParaRects.pop_front();
370 break;
371 case PDFExtOutDevDataSync::SetActualText :
373 rWriter.SetActualText( mParaOUStrings.front() );
374 mParaOUStrings.pop_front();
376 break;
377 case PDFExtOutDevDataSync::SetAlternateText :
379 rWriter.SetAlternateText( mParaOUStrings.front() );
380 mParaOUStrings.pop_front();
382 break;
383 case PDFExtOutDevDataSync::CreateControl:
385 ::boost::shared_ptr< PDFWriter::AnyWidget > pControl( mControls.front() );
386 DBG_ASSERT( pControl.get(), "PageSyncData::PlaySyncPageAct: invalid widget!" );
387 if ( pControl.get() )
388 rWriter.CreateControl( *pControl );
389 mControls.pop_front();
391 break;
392 case PDFExtOutDevDataSync::BeginGroup :
394 /* first determining if this BeginGroup is starting a GfxLink,
395 by searching for a EndGroup or a EndGroupGfxLink */
396 mbGroupIgnoreGDIMtfActions = false;
397 std::deque< PDFExtOutDevDataSync >::iterator aBeg = mActions.begin();
398 std::deque< PDFExtOutDevDataSync >::iterator aEnd = mActions.end();
399 while ( aBeg != aEnd )
401 if ( aBeg->eAct == PDFExtOutDevDataSync::EndGroup )
403 break;
405 else if ( aBeg->eAct == PDFExtOutDevDataSync::EndGroupGfxLink )
407 if ( rOutDevData.GetIsLosslessCompression() && !rOutDevData.GetIsReduceImageResolution() )
409 Graphic& rGraphic = mGraphics.front();
410 if ( rGraphic.IsLink() && rGraphic.GetLink().GetType() == GFX_LINK_TYPE_NATIVE_JPG )
412 mbGroupIgnoreGDIMtfActions = true;
415 break;
417 ++aBeg;
420 break;
421 case PDFExtOutDevDataSync::EndGroup :
423 mbGroupIgnoreGDIMtfActions = false;
425 break;
426 case PDFExtOutDevDataSync::EndGroupGfxLink :
428 Rectangle aOutputRect, aVisibleOutputRect;
429 Graphic aGraphic( mGraphics.front() );
431 mGraphics.pop_front();
432 mParaInts.pop_front(); //Transparency
433 aOutputRect = mParaRects.front();
434 mParaRects.pop_front();
435 aVisibleOutputRect = mParaRects.front();
436 mParaRects.pop_front();
438 if ( mbGroupIgnoreGDIMtfActions )
440 bool bClippingNeeded = ( aOutputRect != aVisibleOutputRect ) && !aVisibleOutputRect.IsEmpty();
442 GfxLink aGfxLink( aGraphic.GetLink() );
443 if ( aGfxLink.GetType() == GFX_LINK_TYPE_NATIVE_JPG )
445 if ( bClippingNeeded )
447 rWriter.Push();
448 basegfx::B2DPolyPolygon aRect( basegfx::tools::createPolygonFromRect(
449 basegfx::B2DRectangle( aVisibleOutputRect.Left(), aVisibleOutputRect.Top(),
450 aVisibleOutputRect.Right(), aVisibleOutputRect.Bottom() ) ) );
451 rWriter.SetClipRegion( aRect);
453 Bitmap aMask;
454 SvMemoryStream aTmp;
455 const sal_uInt8* pData = aGfxLink.GetData();
456 sal_uInt32 nBytes = aGfxLink.GetDataSize();
457 if( pData && nBytes )
459 aTmp.Write( pData, nBytes );
460 rWriter.DrawJPGBitmap( aTmp, aGraphic.GetBitmap().GetBitCount() > 8, aGraphic.GetSizePixel(), aOutputRect, aMask );
463 if ( bClippingNeeded )
464 rWriter.Pop();
466 mbGroupIgnoreGDIMtfActions = false;
469 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 break;
486 else if ( mbGroupIgnoreGDIMtfActions )
488 rCurGDIMtfAction++;
489 bRet = sal_True;
491 return bRet;
494 TYPEINIT1(PDFExtOutDevData,ExtOutDevData);
495 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 mpGlobalSyncData ( new GlobalSyncData() )
510 mpPageSyncData = new PageSyncData( mpGlobalSyncData );
513 PDFExtOutDevData::~PDFExtOutDevData()
515 delete mpPageSyncData;
516 delete mpGlobalSyncData;
519 const com::sun::star::lang::Locale& PDFExtOutDevData::GetDocumentLocale() const
521 return maDocLocale;
523 void PDFExtOutDevData::SetDocumentLocale( const com::sun::star::lang::Locale& rLoc )
525 maDocLocale = rLoc;
527 sal_Int32 PDFExtOutDevData::GetCurrentPageNumber() const
529 return mnPage;
531 void PDFExtOutDevData::SetCurrentPageNumber( const sal_Int32 nPage )
533 mnPage = nPage;
535 sal_Bool PDFExtOutDevData::GetIsLosslessCompression() const
537 return mbUseLosslessCompression;
539 void PDFExtOutDevData::SetIsLosslessCompression( const sal_Bool bUseLosslessCompression )
541 mbUseLosslessCompression = bUseLosslessCompression;
543 sal_Bool PDFExtOutDevData::GetIsReduceImageResolution() const
545 return mbReduceImageResolution;
547 void PDFExtOutDevData::SetIsReduceImageResolution( const sal_Bool bReduceImageResolution )
549 mbReduceImageResolution = bReduceImageResolution;
551 sal_Bool PDFExtOutDevData::GetIsExportNotes() const
553 return mbExportNotes;
555 void PDFExtOutDevData::SetIsExportNotes( const sal_Bool bExportNotes )
557 mbExportNotes = bExportNotes;
559 sal_Bool PDFExtOutDevData::GetIsExportNotesPages() const
561 return mbExportNotesPages;
563 void PDFExtOutDevData::SetIsExportNotesPages( const sal_Bool bExportNotesPages )
565 mbExportNotesPages = bExportNotesPages;
567 sal_Bool PDFExtOutDevData::GetIsExportTaggedPDF() const
569 return mbTaggedPDF;
571 void PDFExtOutDevData::SetIsExportTaggedPDF( const sal_Bool bTaggedPDF )
573 mbTaggedPDF = bTaggedPDF;
575 sal_Bool PDFExtOutDevData::GetIsExportTransitionEffects() const
577 return mbTransitionEffects;
579 void PDFExtOutDevData::SetIsExportTransitionEffects( const sal_Bool bTransitionEffects )
581 mbTransitionEffects = bTransitionEffects;
583 sal_Bool PDFExtOutDevData::GetIsExportFormFields() const
585 return mbExportFormFields;
587 void PDFExtOutDevData::SetIsExportFormFields( const sal_Bool bExportFomtFields )
589 mbExportFormFields = bExportFomtFields;
591 void PDFExtOutDevData::SetFormsFormat( const sal_Int32 nFormsFormat )
593 mnFormsFormat = nFormsFormat;
595 sal_Bool PDFExtOutDevData::GetIsExportBookmarks() const
597 return mbExportBookmarks;
599 void PDFExtOutDevData::SetIsExportBookmarks( const sal_Bool bExportBookmarks )
601 mbExportBookmarks = bExportBookmarks;
603 sal_Bool PDFExtOutDevData::GetIsExportHiddenSlides() const
605 return mbExportHiddenSlides;
607 void PDFExtOutDevData::SetIsExportHiddenSlides( const sal_Bool bExportHiddenSlides )
609 mbExportHiddenSlides = bExportHiddenSlides;
611 std::vector< PDFExtOutDevBookmarkEntry >& PDFExtOutDevData::GetBookmarks()
613 return maBookmarks;
615 sal_Bool PDFExtOutDevData::GetIsExportNamedDestinations() const
617 return mbExportNDests;
619 void PDFExtOutDevData::SetIsExportNamedDestinations( const sal_Bool bExportNDests )
621 mbExportNDests = bExportNDests;
623 void PDFExtOutDevData::ResetSyncData()
625 *mpPageSyncData = PageSyncData( mpGlobalSyncData );
627 sal_Bool PDFExtOutDevData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rIdx )
629 return mpPageSyncData->PlaySyncPageAct( rWriter, rIdx, *this );
631 void PDFExtOutDevData::PlayGlobalActions( PDFWriter& rWriter )
633 mpGlobalSyncData->PlayGlobalActions( rWriter );
636 /* global actions, syncronisation to the recorded metafile isn't needed,
637 all actions will be played after the last page was recorded
639 //--->i56629
640 sal_Int32 PDFExtOutDevData::CreateNamedDest(const OUString& sDestName, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
642 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateNamedDest );
643 mpGlobalSyncData->mParaOUStrings.push_back( sDestName );
644 mpGlobalSyncData->mParaRects.push_back( rRect );
645 mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
646 mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
647 mpGlobalSyncData->mParaDestAreaTypes.push_back( eType );
649 return mpGlobalSyncData->mCurId++;
651 //<---i56629
652 sal_Int32 PDFExtOutDevData::RegisterDest()
654 const sal_Int32 nLinkDestID = mpGlobalSyncData->mCurId++;
655 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::RegisterDest );
656 mpGlobalSyncData->mParaInts.push_back( nLinkDestID );
658 return nLinkDestID;
660 void PDFExtOutDevData::DescribeRegisteredDest( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
662 OSL_PRECOND( nDestId != -1, "PDFExtOutDevData::DescribeRegisteredDest: invalid destination Id!" );
663 PDFLinkDestination aLinkDestination;
664 aLinkDestination.mRect = rRect;
665 aLinkDestination.mMapMode = mrOutDev.GetMapMode();
666 aLinkDestination.mPageNr = nPageNr == -1 ? mnPage : nPageNr;
667 aLinkDestination.mAreaType = eType;
668 mpGlobalSyncData->mFutureDestinations[ nDestId ] = aLinkDestination;
670 sal_Int32 PDFExtOutDevData::CreateDest( const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
672 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateDest );
673 mpGlobalSyncData->mParaRects.push_back( rRect );
674 mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
675 mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
676 mpGlobalSyncData->mParaDestAreaTypes.push_back( eType );
677 return mpGlobalSyncData->mCurId++;
679 sal_Int32 PDFExtOutDevData::CreateLink( const Rectangle& rRect, sal_Int32 nPageNr )
681 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateLink );
682 mpGlobalSyncData->mParaRects.push_back( rRect );
683 mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
684 mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
685 return mpGlobalSyncData->mCurId++;
687 sal_Int32 PDFExtOutDevData::SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId )
689 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetLinkDest );
690 mpGlobalSyncData->mParaInts.push_back( nLinkId );
691 mpGlobalSyncData->mParaInts.push_back( nDestId );
692 return 0;
694 sal_Int32 PDFExtOutDevData::SetLinkURL( sal_Int32 nLinkId, const OUString& rURL )
696 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetLinkURL );
697 mpGlobalSyncData->mParaInts.push_back( nLinkId );
698 mpGlobalSyncData->mParaOUStrings.push_back( rURL );
699 return 0;
701 sal_Int32 PDFExtOutDevData::CreateOutlineItem( sal_Int32 nParent, const OUString& rText, sal_Int32 nDestID )
703 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateOutlineItem );
704 mpGlobalSyncData->mParaInts.push_back( nParent );
705 mpGlobalSyncData->mParaOUStrings.push_back( rText );
706 mpGlobalSyncData->mParaInts.push_back( nDestID );
707 return mpGlobalSyncData->mCurId++;
709 void PDFExtOutDevData::CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr )
711 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateNote );
712 mpGlobalSyncData->mParaRects.push_back( rRect );
713 mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
714 mpGlobalSyncData->mParaPDFNotes.push_back( rNote );
715 mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
717 void PDFExtOutDevData::SetPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr )
719 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetPageTransition );
720 mpGlobalSyncData->mParaPageTransitions.push_back( eType );
721 mpGlobalSyncData->mParauInts.push_back( nMilliSec );
722 mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
725 /* local (page), actions have to be played synchroniously to the actions of
726 of the recorded metafile (created by each xRenderable->render()) */
727 sal_Int32 PDFExtOutDevData::BeginStructureElement( PDFWriter::StructElement eType, const OUString& rAlias )
729 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::BeginStructureElement );
730 mpPageSyncData->mParaStructElements.push_back( eType );
731 mpPageSyncData->mParaOUStrings.push_back( rAlias );
732 // need a global id
733 sal_Int32 nNewId = mpGlobalSyncData->mStructParents.size();
734 mpGlobalSyncData->mStructParents.push_back( mpGlobalSyncData->mCurrentStructElement );
735 mpGlobalSyncData->mCurrentStructElement = nNewId;
736 return nNewId;
738 void PDFExtOutDevData::EndStructureElement()
740 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::EndStructureElement );
741 mpGlobalSyncData->mCurrentStructElement = mpGlobalSyncData->mStructParents[ mpGlobalSyncData->mCurrentStructElement ];
743 bool PDFExtOutDevData::SetCurrentStructureElement( sal_Int32 nStructId )
745 bool bSuccess = false;
746 if( sal_uInt32(nStructId) < mpGlobalSyncData->mStructParents.size() )
748 mpGlobalSyncData->mCurrentStructElement = nStructId;
749 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetCurrentStructureElement );
750 mpPageSyncData->mParaInts.push_back( nStructId );
751 bSuccess = true;
753 return bSuccess;
755 sal_Int32 PDFExtOutDevData::GetCurrentStructureElement()
757 return mpGlobalSyncData->mCurrentStructElement;
759 bool PDFExtOutDevData::SetStructureAttribute( PDFWriter::StructAttribute eAttr, PDFWriter::StructAttributeValue eVal )
761 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetStructureAttribute );
762 mpPageSyncData->mParaStructAttributes.push_back( eAttr );
763 mpPageSyncData->mParaStructAttributeValues.push_back( eVal );
764 return true;
766 bool PDFExtOutDevData::SetStructureAttributeNumerical( PDFWriter::StructAttribute eAttr, sal_Int32 nValue )
768 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetStructureAttributeNumerical );
769 mpPageSyncData->mParaStructAttributes.push_back( eAttr );
770 mpPageSyncData->mParaInts.push_back( nValue );
771 return true;
773 void PDFExtOutDevData::SetStructureBoundingBox( const Rectangle& rRect )
775 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetStructureBoundingBox );
776 mpPageSyncData->mParaRects.push_back( rRect );
778 void PDFExtOutDevData::SetActualText( const OUString& rText )
780 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetActualText );
781 mpPageSyncData->mParaOUStrings.push_back( rText );
783 void PDFExtOutDevData::SetAlternateText( const OUString& rText )
785 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetAlternateText );
786 mpPageSyncData->mParaOUStrings.push_back( rText );
789 void PDFExtOutDevData::CreateControl( const PDFWriter::AnyWidget& rControlType, sal_Int32 /*nPageNr*/ )
791 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::CreateControl );
793 ::boost::shared_ptr< PDFWriter::AnyWidget > pClone( rControlType.Clone() );
794 mpPageSyncData->mControls.push_back( pClone );
797 void PDFExtOutDevData::BeginGroup()
799 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::BeginGroup );
802 void PDFExtOutDevData::EndGroup( const Graphic& rGraphic,
803 sal_uInt8 nTransparency,
804 const Rectangle& rOutputRect,
805 const Rectangle& rVisibleOutputRect )
807 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::EndGroupGfxLink );
808 mpPageSyncData->mGraphics.push_back( rGraphic );
809 mpPageSyncData->mParaInts.push_back( nTransparency );
810 mpPageSyncData->mParaRects.push_back( rOutputRect );
811 mpPageSyncData->mParaRects.push_back( rVisibleOutputRect );
816 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */