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