LCOV - code coverage report
Current view: top level - vcl/source/gdi - pdfextoutdevdata.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 406 0.0 %
Date: 2014-04-14 Functions: 0 72 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10