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