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