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