Update ooo320-m1
[ooovba.git] / vcl / source / gdi / pdfextoutdevdata.cxx
blob8ed7dc132ec11c3cf739db6a4bd9a44f131d1842
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pdfextoutdevdata.cxx,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
33 #include <vcl/pdfextoutdevdata.hxx>
34 #include <vcl/graph.hxx>
35 #include <vcl/outdev.hxx>
36 #include <vcl/gfxlink.hxx>
39 #include <boost/shared_ptr.hpp>
40 #include <set>
42 namespace vcl
44 struct PDFExtOutDevDataSync
46 enum Action{ CreateNamedDest,
47 CreateDest,
48 CreateLink,
49 SetLinkDest,
50 SetLinkURL,
51 CreateOutlineItem,
52 SetOutlineItemParent,
53 SetOutlineItemText,
54 SetOutlineItemDest,
55 CreateNote,
56 SetAutoAdvanceTime,
57 SetPageTransition,
59 BeginStructureElement,
60 EndStructureElement,
61 SetCurrentStructureElement,
62 SetStructureAttribute,
63 SetStructureAttributeNumerical,
64 SetStructureBoundingBox,
65 SetActualText,
66 SetAlternateText,
67 CreateControl,
68 BeginGroup,
69 EndGroup,
70 EndGroupGfxLink
73 sal_uInt32 nIdx;
74 Action eAct;
77 struct 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< rtl::OUString > mParaOUStrings;
85 std::deque< PDFWriter::DestAreaType > mParaDestAreaTypes;
86 std::deque< PDFNote > mParaPDFNotes;
87 std::deque< PDFWriter::PageTransition > mParaPageTransitions;
89 sal_Int32 GetMappedId();
90 sal_Int32 GetMappedStructId( sal_Int32 );
92 sal_Int32 mCurId;
93 std::vector< sal_Int32 > mParaIds;
94 std::vector< sal_Int32 > mStructIdMap;
96 sal_Int32 mCurrentStructElement;
97 std::vector< sal_Int32 > mStructParents;
98 GlobalSyncData() :
99 mCurId ( 0 ),
100 mCurrentStructElement( 0 )
102 mStructParents.push_back( 0 );
103 mStructIdMap.push_back( 0 );
105 void PlayGlobalActions( PDFWriter& rWriter );
108 sal_Int32 GlobalSyncData::GetMappedId()
110 sal_Int32 nLinkId = mParaInts.front();
111 mParaInts.pop_front();
113 /* negative values are intentionally passed as invalid IDs
114 * e.g. to create a new top level outline item
116 if( nLinkId >= 0 )
118 if ( (sal_uInt32)nLinkId < mParaIds.size() )
119 nLinkId = mParaIds[ nLinkId ];
120 else
121 nLinkId = -1;
123 DBG_ASSERT( nLinkId >= 0, "unmapped id in GlobalSyncData" );
126 return nLinkId;
129 sal_Int32 GlobalSyncData::GetMappedStructId( sal_Int32 nStructId )
131 if ( (sal_uInt32)nStructId < mStructIdMap.size() )
132 nStructId = mStructIdMap[ nStructId ];
133 else
134 nStructId = -1;
136 DBG_ASSERT( nStructId >= 0, "unmapped structure id in GlobalSyncData" );
138 return nStructId;
141 void GlobalSyncData::PlayGlobalActions( PDFWriter& rWriter )
143 std::deque< PDFExtOutDevDataSync::Action >::iterator aIter( mActions.begin() );
144 std::deque< PDFExtOutDevDataSync::Action >::iterator aEnd( mActions.end() );
145 while( aIter != aEnd )
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::CreateOutlineItem :
203 sal_Int32 nParent = GetMappedId();
204 sal_Int32 nLinkId = GetMappedId();
205 mParaIds.push_back( rWriter.CreateOutlineItem( nParent, mParaOUStrings.front(), nLinkId ) );
206 mParaOUStrings.pop_front();
208 break;
209 case PDFExtOutDevDataSync::SetOutlineItemParent :
211 sal_Int32 nItem = GetMappedId();
212 sal_Int32 nNewParent = GetMappedId();
213 rWriter.SetOutlineItemParent( nItem, nNewParent );
215 break;
216 case PDFExtOutDevDataSync::SetOutlineItemText :
218 sal_Int32 nItem = GetMappedId();
219 rWriter.SetOutlineItemText( nItem, mParaOUStrings.front() );
220 mParaOUStrings.pop_front();
222 break;
223 case PDFExtOutDevDataSync::SetOutlineItemDest :
225 sal_Int32 nItem = GetMappedId();
226 sal_Int32 nDestId = GetMappedId();
227 rWriter.SetOutlineItemDest( nItem, nDestId );
229 break;
230 case PDFExtOutDevDataSync::CreateNote :
232 rWriter.Push( PUSH_MAPMODE );
233 rWriter.SetMapMode( mParaMapModes.front() );
234 rWriter.CreateNote( mParaRects.front(), mParaPDFNotes.front(), mParaInts.front() );
235 mParaMapModes.pop_front();
236 mParaRects.pop_front();
237 mParaPDFNotes.pop_front();
238 mParaInts.pop_front();
240 break;
241 case PDFExtOutDevDataSync::SetAutoAdvanceTime :
243 rWriter.SetAutoAdvanceTime( mParauInts.front(), mParaInts.front() );
244 mParauInts.pop_front();
245 mParaInts.pop_front();
247 break;
248 case PDFExtOutDevDataSync::SetPageTransition :
250 rWriter.SetPageTransition( mParaPageTransitions.front(), mParauInts.front(), mParaInts.front() );
251 mParaPageTransitions.pop_front();
252 mParauInts.pop_front();
253 mParaInts.pop_front();
255 break;
256 case PDFExtOutDevDataSync::BeginStructureElement:
257 case PDFExtOutDevDataSync::EndStructureElement:
258 case PDFExtOutDevDataSync::SetCurrentStructureElement:
259 case PDFExtOutDevDataSync::SetStructureAttribute:
260 case PDFExtOutDevDataSync::SetStructureAttributeNumerical:
261 case PDFExtOutDevDataSync::SetStructureBoundingBox:
262 case PDFExtOutDevDataSync::SetActualText:
263 case PDFExtOutDevDataSync::SetAlternateText:
264 case PDFExtOutDevDataSync::CreateControl:
265 case PDFExtOutDevDataSync::BeginGroup:
266 case PDFExtOutDevDataSync::EndGroup:
267 case PDFExtOutDevDataSync::EndGroupGfxLink:
268 break;
270 aIter++;
274 struct PageSyncData
276 std::deque< PDFExtOutDevDataSync > mActions;
277 std::deque< Rectangle > mParaRects;
278 std::deque< sal_Int32 > mParaInts;
279 std::deque< rtl::OUString > mParaOUStrings;
280 std::deque< PDFWriter::StructElement > mParaStructElements;
281 std::deque< PDFWriter::StructAttribute > mParaStructAttributes;
282 std::deque< PDFWriter::StructAttributeValue > mParaStructAttributeValues;
283 std::deque< Graphic > mGraphics;
284 std::deque< ::boost::shared_ptr< PDFWriter::AnyWidget > >
285 mControls;
286 std::set< ::rtl::OUString > mControlNames;
288 GlobalSyncData* mpGlobalData;
290 sal_Bool mbGroupIgnoreGDIMtfActions;
292 PageSyncData( GlobalSyncData* pGlobal ) : mbGroupIgnoreGDIMtfActions ( sal_False ) { mpGlobalData = pGlobal; }
294 void PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDataSync::Action eAct );
295 sal_Bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const PDFExtOutDevData& rOutDevData );
297 void PageSyncData::PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDataSync::Action eAct )
299 GDIMetaFile* pMtf = rOutDev.GetConnectMetaFile();
300 DBG_ASSERT( pMtf, "PageSyncData::PushAction -> no ConnectMetaFile !!!" );
302 PDFExtOutDevDataSync aSync;
303 aSync.eAct = eAct;
304 if ( pMtf )
305 aSync.nIdx = pMtf->GetActionCount();
306 else
307 aSync.nIdx = 0x7fffffff; // sync not possible
308 mActions.push_back( aSync );
310 sal_Bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const PDFExtOutDevData& rOutDevData )
312 sal_Bool bRet = sal_False;
313 if ( mActions.size() && ( mActions.front().nIdx == rCurGDIMtfAction ) )
315 bRet = sal_True;
316 PDFExtOutDevDataSync aDataSync = mActions.front();
317 mActions.pop_front();
318 switch( aDataSync.eAct )
320 case PDFExtOutDevDataSync::BeginStructureElement :
322 sal_Int32 nNewEl = rWriter.BeginStructureElement( mParaStructElements.front(), mParaOUStrings.front() ) ;
323 mParaStructElements.pop_front();
324 mParaOUStrings.pop_front();
325 mpGlobalData->mStructIdMap.push_back( nNewEl );
327 break;
328 case PDFExtOutDevDataSync::EndStructureElement :
330 rWriter.EndStructureElement();
332 break;
333 case PDFExtOutDevDataSync::SetCurrentStructureElement:
335 rWriter.SetCurrentStructureElement( mpGlobalData->GetMappedStructId( mParaInts.front() ) );
336 mParaInts.pop_front();
338 break;
339 case PDFExtOutDevDataSync::SetStructureAttribute :
341 rWriter.SetStructureAttribute( mParaStructAttributes.front(), mParaStructAttributeValues.front() );
342 mParaStructAttributeValues.pop_front();
343 mParaStructAttributes.pop_front();
345 break;
346 case PDFExtOutDevDataSync::SetStructureAttributeNumerical :
348 rWriter.SetStructureAttributeNumerical( mParaStructAttributes.front(), mParaInts.front() );
349 mParaStructAttributes.pop_front();
350 mParaInts.pop_front();
352 break;
353 case PDFExtOutDevDataSync::SetStructureBoundingBox :
355 rWriter.SetStructureBoundingBox( mParaRects.front() );
356 mParaRects.pop_front();
358 break;
359 case PDFExtOutDevDataSync::SetActualText :
361 rWriter.SetActualText( mParaOUStrings.front() );
362 mParaOUStrings.pop_front();
364 break;
365 case PDFExtOutDevDataSync::SetAlternateText :
367 rWriter.SetAlternateText( mParaOUStrings.front() );
368 mParaOUStrings.pop_front();
370 break;
371 case PDFExtOutDevDataSync::CreateControl:
373 ::boost::shared_ptr< PDFWriter::AnyWidget > pControl( mControls.front() );
374 DBG_ASSERT( pControl.get(), "PageSyncData::PlaySyncPageAct: invalid widget!" );
375 if ( pControl.get() )
376 rWriter.CreateControl( *pControl );
377 mControls.pop_front();
378 mControlNames.erase( pControl->Name );
380 break;
381 case PDFExtOutDevDataSync::BeginGroup :
383 /* first determining if this BeginGroup is starting a GfxLink,
384 by searching for a EndGroup or a EndGroupGfxLink */
385 mbGroupIgnoreGDIMtfActions = sal_False;
386 std::deque< PDFExtOutDevDataSync >::iterator aBeg = mActions.begin();
387 std::deque< PDFExtOutDevDataSync >::iterator aEnd = mActions.end();
388 while ( aBeg != aEnd )
390 if ( aBeg->eAct == PDFExtOutDevDataSync::EndGroup )
392 break;
394 else if ( aBeg->eAct == PDFExtOutDevDataSync::EndGroupGfxLink )
396 if ( rOutDevData.GetIsLosslessCompression() && !rOutDevData.GetIsReduceImageResolution() )
398 Graphic& rGraphic = mGraphics.front();
399 if ( rGraphic.IsLink() && rGraphic.GetLink().GetType() == GFX_LINK_TYPE_NATIVE_JPG )
401 mbGroupIgnoreGDIMtfActions = sal_True;
404 break;
406 aBeg++;
409 break;
410 case PDFExtOutDevDataSync::EndGroup :
412 mbGroupIgnoreGDIMtfActions = sal_False;
414 break;
415 case PDFExtOutDevDataSync::EndGroupGfxLink :
417 sal_Int32 nTransparency;
418 Rectangle aOutputRect, aVisibleOutputRect;
419 Graphic aGraphic( mGraphics.front() );
421 mGraphics.pop_front();
422 nTransparency = mParaInts.front();
423 mParaInts.pop_front();
424 aOutputRect = mParaRects.front();
425 mParaRects.pop_front();
426 aVisibleOutputRect = mParaRects.front();
427 mParaRects.pop_front();
429 if ( mbGroupIgnoreGDIMtfActions )
431 sal_Bool bClippingNeeded = ( aOutputRect != aVisibleOutputRect ) && !aVisibleOutputRect.IsEmpty();
433 GfxLink aGfxLink( aGraphic.GetLink() );
434 if ( aGfxLink.GetType() == GFX_LINK_TYPE_NATIVE_JPG )
436 if ( bClippingNeeded )
438 rWriter.Push();
439 rWriter.SetClipRegion( aVisibleOutputRect );
441 Bitmap aMask;
442 SvMemoryStream aTmp;
443 const sal_uInt8* pData = aGfxLink.GetData();
444 sal_uInt32 nBytes = aGfxLink.GetDataSize();
445 if( pData && nBytes )
447 aTmp.Write( pData, nBytes );
448 rWriter.DrawJPGBitmap( aTmp, aGraphic.GetBitmap().GetBitCount() > 8, aGraphic.GetSizePixel(), aOutputRect, aMask );
451 if ( bClippingNeeded )
452 rWriter.Pop();
454 mbGroupIgnoreGDIMtfActions = sal_False;
457 break;
458 case PDFExtOutDevDataSync::CreateNamedDest:
459 case PDFExtOutDevDataSync::CreateDest:
460 case PDFExtOutDevDataSync::CreateLink:
461 case PDFExtOutDevDataSync::SetLinkDest:
462 case PDFExtOutDevDataSync::SetLinkURL:
463 case PDFExtOutDevDataSync::CreateOutlineItem:
464 case PDFExtOutDevDataSync::SetOutlineItemParent:
465 case PDFExtOutDevDataSync::SetOutlineItemText:
466 case PDFExtOutDevDataSync::SetOutlineItemDest:
467 case PDFExtOutDevDataSync::CreateNote:
468 case PDFExtOutDevDataSync::SetAutoAdvanceTime:
469 case PDFExtOutDevDataSync::SetPageTransition:
470 break;
473 else if ( mbGroupIgnoreGDIMtfActions )
475 rCurGDIMtfAction++;
476 bRet = sal_True;
478 return bRet;
481 TYPEINIT1(PDFExtOutDevData,ExtOutDevData);
482 PDFExtOutDevData::PDFExtOutDevData( const OutputDevice& rOutDev ) :
483 mrOutDev ( rOutDev ),
484 mbTaggedPDF ( sal_False ),
485 mbExportNotes ( sal_True ),
486 mbTransitionEffects ( sal_True ),
487 mbUseLosslessCompression( sal_True ),
488 mbReduceImageResolution ( sal_False ),
489 mbExportNDests ( sal_False ),
490 mnFormsFormat ( 0 ),
491 mnPage ( -1 ),
492 mpPageSyncData ( NULL ),
493 mpGlobalSyncData ( new GlobalSyncData() )
495 mpPageSyncData = new PageSyncData( mpGlobalSyncData );
498 PDFExtOutDevData::~PDFExtOutDevData()
500 delete mpPageSyncData;
501 delete mpGlobalSyncData;
504 const com::sun::star::lang::Locale& PDFExtOutDevData::GetDocumentLocale() const
506 return maDocLocale;
508 void PDFExtOutDevData::SetDocumentLocale( const com::sun::star::lang::Locale& rLoc )
510 maDocLocale = rLoc;
512 sal_Int32 PDFExtOutDevData::GetCurrentPageNumber() const
514 return mnPage;
516 void PDFExtOutDevData::SetCurrentPageNumber( const sal_Int32 nPage )
518 mnPage = nPage;
520 sal_Bool PDFExtOutDevData::GetIsLosslessCompression() const
522 return mbUseLosslessCompression;
524 void PDFExtOutDevData::SetIsLosslessCompression( const sal_Bool bUseLosslessCompression )
526 mbUseLosslessCompression = bUseLosslessCompression;
528 sal_Bool PDFExtOutDevData::GetIsReduceImageResolution() const
530 return mbReduceImageResolution;
532 void PDFExtOutDevData::SetIsReduceImageResolution( const sal_Bool bReduceImageResolution )
534 mbReduceImageResolution = bReduceImageResolution;
536 sal_Bool PDFExtOutDevData::GetIsExportNotes() const
538 return mbExportNotes;
540 void PDFExtOutDevData::SetIsExportNotes( const sal_Bool bExportNotes )
542 mbExportNotes = bExportNotes;
544 sal_Bool PDFExtOutDevData::GetIsExportTaggedPDF() const
546 return mbTaggedPDF;
548 void PDFExtOutDevData::SetIsExportTaggedPDF( const sal_Bool bTaggedPDF )
550 mbTaggedPDF = bTaggedPDF;
552 sal_Bool PDFExtOutDevData::GetIsExportTransitionEffects() const
554 return mbTransitionEffects;
556 void PDFExtOutDevData::SetIsExportTransitionEffects( const sal_Bool bTransitionEffects )
558 mbTransitionEffects = bTransitionEffects;
560 sal_Bool PDFExtOutDevData::GetIsExportFormFields() const
562 return mbExportFormFields;
564 void PDFExtOutDevData::SetIsExportFormFields( const sal_Bool bExportFomtFields )
566 mbExportFormFields = bExportFomtFields;
568 sal_Int32 PDFExtOutDevData::GetFormsFormat() const
570 return mnFormsFormat;
572 void PDFExtOutDevData::SetFormsFormat( const sal_Int32 nFormsFormat )
574 mnFormsFormat = nFormsFormat;
576 sal_Bool PDFExtOutDevData::GetIsExportBookmarks() const
578 return mbExportBookmarks;
580 void PDFExtOutDevData::SetIsExportBookmarks( const sal_Bool bExportBookmarks )
582 mbExportBookmarks = bExportBookmarks;
584 std::vector< PDFExtOutDevBookmarkEntry >& PDFExtOutDevData::GetBookmarks()
586 return maBookmarks;
588 sal_Bool PDFExtOutDevData::GetIsExportNamedDestinations() const
590 return mbExportNDests;
592 void PDFExtOutDevData::SetIsExportNamedDestinations( const sal_Bool bExportNDests )
594 mbExportNDests = bExportNDests;
596 void PDFExtOutDevData::ResetSyncData()
598 *mpPageSyncData = PageSyncData( mpGlobalSyncData );
600 sal_Bool PDFExtOutDevData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rIdx )
602 return mpPageSyncData->PlaySyncPageAct( rWriter, rIdx, *this );
604 void PDFExtOutDevData::PlayGlobalActions( PDFWriter& rWriter )
606 mpGlobalSyncData->PlayGlobalActions( rWriter );
609 /* global actions, syncronisation to the recorded metafile isn't needed,
610 all actions will be played after the last page was recorded
612 //--->i56629
613 sal_Int32 PDFExtOutDevData::CreateNamedDest(const String& sDestName, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
615 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateNamedDest );
616 mpGlobalSyncData->mParaOUStrings.push_back( sDestName );
617 mpGlobalSyncData->mParaRects.push_back( rRect );
618 mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
619 mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
620 mpGlobalSyncData->mParaDestAreaTypes.push_back( eType );
621 return mpGlobalSyncData->mCurId++;
623 //<---i56629
624 sal_Int32 PDFExtOutDevData::CreateDest( const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
626 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateDest );
627 mpGlobalSyncData->mParaRects.push_back( rRect );
628 mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
629 mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
630 mpGlobalSyncData->mParaDestAreaTypes.push_back( eType );
631 return mpGlobalSyncData->mCurId++;
633 sal_Int32 PDFExtOutDevData::CreateLink( const Rectangle& rRect, sal_Int32 nPageNr )
635 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateLink );
636 mpGlobalSyncData->mParaRects.push_back( rRect );
637 mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
638 mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
639 return mpGlobalSyncData->mCurId++;
641 sal_Int32 PDFExtOutDevData::SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId )
643 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetLinkDest );
644 mpGlobalSyncData->mParaInts.push_back( nLinkId );
645 mpGlobalSyncData->mParaInts.push_back( nDestId );
646 return 0;
648 sal_Int32 PDFExtOutDevData::SetLinkURL( sal_Int32 nLinkId, const rtl::OUString& rURL )
650 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetLinkURL );
651 mpGlobalSyncData->mParaInts.push_back( nLinkId );
652 mpGlobalSyncData->mParaOUStrings.push_back( rURL );
653 return 0;
655 sal_Int32 PDFExtOutDevData::CreateOutlineItem( sal_Int32 nParent, const rtl::OUString& rText, sal_Int32 nDestID )
657 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateOutlineItem );
658 mpGlobalSyncData->mParaInts.push_back( nParent );
659 mpGlobalSyncData->mParaOUStrings.push_back( rText );
660 mpGlobalSyncData->mParaInts.push_back( nDestID );
661 return mpGlobalSyncData->mCurId++;
663 sal_Int32 PDFExtOutDevData::SetOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent )
665 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetOutlineItemParent );
666 mpGlobalSyncData->mParaInts.push_back( nItem );
667 mpGlobalSyncData->mParaInts.push_back( nNewParent );
668 return 0;
670 sal_Int32 PDFExtOutDevData::SetOutlineItemText( sal_Int32 nItem, const rtl::OUString& rText )
672 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetOutlineItemText );
673 mpGlobalSyncData->mParaInts.push_back( nItem );
674 mpGlobalSyncData->mParaOUStrings.push_back( rText );
675 return 0;
677 sal_Int32 PDFExtOutDevData::SetOutlineItemDest( sal_Int32 nItem, sal_Int32 nDestID )
679 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetOutlineItemDest );
680 mpGlobalSyncData->mParaInts.push_back( nItem );
681 mpGlobalSyncData->mParaInts.push_back( nDestID );
682 return 0;
684 void PDFExtOutDevData::CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr )
686 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateNote );
687 mpGlobalSyncData->mParaRects.push_back( rRect );
688 mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
689 mpGlobalSyncData->mParaPDFNotes.push_back( rNote );
690 mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
692 void PDFExtOutDevData::SetAutoAdvanceTime( sal_uInt32 nSeconds, sal_Int32 nPageNr )
694 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetAutoAdvanceTime );
695 mpGlobalSyncData->mParauInts.push_back( nSeconds );
696 mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
698 void PDFExtOutDevData::SetPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr )
700 mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetPageTransition );
701 mpGlobalSyncData->mParaPageTransitions.push_back( eType );
702 mpGlobalSyncData->mParauInts.push_back( nMilliSec );
703 mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
706 /* local (page), actions have to be played synchroniously to the actions of
707 of the recorded metafile (created by each xRenderable->render()) */
708 sal_Int32 PDFExtOutDevData::BeginStructureElement( PDFWriter::StructElement eType, const rtl::OUString& rAlias )
710 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::BeginStructureElement );
711 mpPageSyncData->mParaStructElements.push_back( eType );
712 mpPageSyncData->mParaOUStrings.push_back( rAlias );
713 // need a global id
714 sal_Int32 nNewId = mpGlobalSyncData->mStructParents.size();
715 mpGlobalSyncData->mStructParents.push_back( mpGlobalSyncData->mCurrentStructElement );
716 mpGlobalSyncData->mCurrentStructElement = nNewId;
717 return nNewId;
719 void PDFExtOutDevData::EndStructureElement()
721 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::EndStructureElement );
722 mpGlobalSyncData->mCurrentStructElement = mpGlobalSyncData->mStructParents[ mpGlobalSyncData->mCurrentStructElement ];
724 bool PDFExtOutDevData::SetCurrentStructureElement( sal_Int32 nStructId )
726 bool bSuccess = false;
727 if( sal_uInt32(nStructId) < mpGlobalSyncData->mStructParents.size() )
729 mpGlobalSyncData->mCurrentStructElement = nStructId;
730 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetCurrentStructureElement );
731 mpPageSyncData->mParaInts.push_back( nStructId );
732 bSuccess = true;
734 return bSuccess;
736 sal_Int32 PDFExtOutDevData::GetCurrentStructureElement()
738 return mpGlobalSyncData->mCurrentStructElement;
740 bool PDFExtOutDevData::SetStructureAttribute( PDFWriter::StructAttribute eAttr, PDFWriter::StructAttributeValue eVal )
742 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetStructureAttribute );
743 mpPageSyncData->mParaStructAttributes.push_back( eAttr );
744 mpPageSyncData->mParaStructAttributeValues.push_back( eVal );
745 return true;
747 bool PDFExtOutDevData::SetStructureAttributeNumerical( PDFWriter::StructAttribute eAttr, sal_Int32 nValue )
749 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetStructureAttributeNumerical );
750 mpPageSyncData->mParaStructAttributes.push_back( eAttr );
751 mpPageSyncData->mParaInts.push_back( nValue );
752 return true;
754 void PDFExtOutDevData::SetStructureBoundingBox( const Rectangle& rRect )
756 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetStructureBoundingBox );
757 mpPageSyncData->mParaRects.push_back( rRect );
759 void PDFExtOutDevData::SetActualText( const String& rText )
761 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetActualText );
762 mpPageSyncData->mParaOUStrings.push_back( rText );
764 void PDFExtOutDevData::SetAlternateText( const String& rText )
766 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetAlternateText );
767 mpPageSyncData->mParaOUStrings.push_back( rText );
770 void PDFExtOutDevData::CreateControl( const PDFWriter::AnyWidget& rControlType, sal_Int32 /*nPageNr*/ )
772 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::CreateControl );
774 ::boost::shared_ptr< PDFWriter::AnyWidget > pClone( rControlType.Clone() );
775 // ensure a unique name
776 ::rtl::OUString sUniqueName( pClone->Name );
777 sal_Int32 nUniqueNumber( 0 );
778 while ( mpPageSyncData->mControlNames.find( sUniqueName ) != mpPageSyncData->mControlNames.end() )
780 sUniqueName = pClone->Name + ::rtl::OUString::valueOf( ++nUniqueNumber );
782 pClone->Name = sUniqueName;
783 mpPageSyncData->mControlNames.insert( pClone->Name );
785 mpPageSyncData->mControls.push_back( pClone );
788 void PDFExtOutDevData::BeginGroup()
790 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::BeginGroup );
793 void PDFExtOutDevData::EndGroup()
795 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::EndGroup );
797 void PDFExtOutDevData::EndGroup( const Graphic& rGraphic,
798 BYTE nTransparency,
799 const Rectangle& rOutputRect,
800 const Rectangle& rVisibleOutputRect )
802 mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::EndGroupGfxLink );
803 mpPageSyncData->mGraphics.push_back( rGraphic );
804 mpPageSyncData->mParaInts.push_back( nTransparency );
805 mpPageSyncData->mParaRects.push_back( rOutputRect );
806 mpPageSyncData->mParaRects.push_back( rVisibleOutputRect );