LCOV - code coverage report
Current view: top level - vcl/source/gdi - pdfextoutdevdata.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 380 0.3 %
Date: 2015-06-13 12:38:46 Functions: 1 59 1.7 %
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 <set>
      29             : #include <memory>
      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( PushFlags::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( PushFlags::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( PushFlags::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( PushFlags::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( PushFlags::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< std::shared_ptr< PDFWriter::AnyWidget > >
     298             :                                                     mControls;
     299             :     GlobalSyncData*                                 mpGlobalData;
     300             : 
     301             :     bool                                        mbGroupIgnoreGDIMtfActions;
     302             : 
     303           0 :     explicit 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 :                 std::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      214281 : 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             :     mbExportFormFields      ( false ),
     503             :     mbExportBookmarks       ( false ),
     504             :     mbExportHiddenSlides    ( false ),
     505             :     mbExportNDests          ( false ),
     506             :     mnFormsFormat           ( 0 ),
     507             :     mnPage                  ( -1 ),
     508             :     mpPageSyncData          ( NULL ),
     509           0 :     mpGlobalSyncData        ( new GlobalSyncData() )
     510             : {
     511           0 :     mpPageSyncData = new PageSyncData( mpGlobalSyncData );
     512           0 : }
     513             : 
     514           0 : PDFExtOutDevData::~PDFExtOutDevData()
     515             : {
     516           0 :     delete mpPageSyncData;
     517           0 :     delete mpGlobalSyncData;
     518           0 : }
     519             : 
     520           0 : void PDFExtOutDevData::SetDocumentLocale( const com::sun::star::lang::Locale& rLoc )
     521             : {
     522           0 :     maDocLocale = rLoc;
     523           0 : }
     524           0 : void PDFExtOutDevData::SetCurrentPageNumber( const sal_Int32 nPage )
     525             : {
     526           0 :     mnPage = nPage;
     527           0 : }
     528           0 : void PDFExtOutDevData::SetIsLosslessCompression( const bool bUseLosslessCompression )
     529             : {
     530           0 :     mbUseLosslessCompression = bUseLosslessCompression;
     531           0 : }
     532           0 : void PDFExtOutDevData::SetIsReduceImageResolution( const bool bReduceImageResolution )
     533             : {
     534           0 :     mbReduceImageResolution = bReduceImageResolution;
     535           0 : }
     536           0 : void PDFExtOutDevData::SetIsExportNotes( const bool bExportNotes )
     537             : {
     538           0 :     mbExportNotes = bExportNotes;
     539           0 : }
     540           0 : void PDFExtOutDevData::SetIsExportNotesPages( const bool bExportNotesPages )
     541             : {
     542           0 :     mbExportNotesPages = bExportNotesPages;
     543           0 : }
     544           0 : void PDFExtOutDevData::SetIsExportTaggedPDF( const bool bTaggedPDF )
     545             : {
     546           0 :     mbTaggedPDF = bTaggedPDF;
     547           0 : }
     548           0 : void PDFExtOutDevData::SetIsExportTransitionEffects( const bool bTransitionEffects )
     549             : {
     550           0 :     mbTransitionEffects = bTransitionEffects;
     551           0 : }
     552           0 : void PDFExtOutDevData::SetIsExportFormFields( const bool bExportFomtFields )
     553             : {
     554           0 :     mbExportFormFields = bExportFomtFields;
     555           0 : }
     556           0 : void PDFExtOutDevData::SetFormsFormat( const sal_Int32 nFormsFormat )
     557             : {
     558           0 :     mnFormsFormat = nFormsFormat;
     559           0 : }
     560           0 : void PDFExtOutDevData::SetIsExportBookmarks( const bool bExportBookmarks )
     561             : {
     562           0 :     mbExportBookmarks = bExportBookmarks;
     563           0 : }
     564           0 : void PDFExtOutDevData::SetIsExportHiddenSlides( const bool bExportHiddenSlides )
     565             : {
     566           0 :     mbExportHiddenSlides = bExportHiddenSlides;
     567           0 : }
     568           0 : void PDFExtOutDevData::SetIsExportNamedDestinations( const bool bExportNDests )
     569             : {
     570           0 :     mbExportNDests = bExportNDests;
     571           0 : }
     572           0 : void PDFExtOutDevData::ResetSyncData()
     573             : {
     574           0 :     *mpPageSyncData = PageSyncData( mpGlobalSyncData );
     575           0 : }
     576           0 : bool PDFExtOutDevData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rIdx )
     577             : {
     578           0 :     return mpPageSyncData->PlaySyncPageAct( rWriter, rIdx, *this );
     579             : }
     580           0 : void PDFExtOutDevData::PlayGlobalActions( PDFWriter& rWriter )
     581             : {
     582           0 :     mpGlobalSyncData->PlayGlobalActions( rWriter );
     583           0 : }
     584             : 
     585             : /* global actions, synchronisation to the recorded metafile isn't needed,
     586             :    all actions will be played after the last page was recorded
     587             : */
     588             : //--->i56629
     589           0 : sal_Int32 PDFExtOutDevData::CreateNamedDest(const OUString& sDestName,  const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
     590             : {
     591           0 :     mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateNamedDest );
     592           0 :     mpGlobalSyncData->mParaOUStrings.push_back( sDestName );
     593           0 :     mpGlobalSyncData->mParaRects.push_back( rRect );
     594           0 :     mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
     595           0 :     mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
     596           0 :     mpGlobalSyncData->mParaDestAreaTypes.push_back( eType );
     597             : 
     598           0 :     return mpGlobalSyncData->mCurId++;
     599             : }
     600             : //<---i56629
     601           0 : sal_Int32 PDFExtOutDevData::RegisterDest()
     602             : {
     603           0 :     const sal_Int32 nLinkDestID = mpGlobalSyncData->mCurId++;
     604           0 :     mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::RegisterDest );
     605           0 :     mpGlobalSyncData->mParaInts.push_back( nLinkDestID );
     606             : 
     607           0 :     return nLinkDestID;
     608             : }
     609           0 : void PDFExtOutDevData::DescribeRegisteredDest( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
     610             : {
     611             :     OSL_PRECOND( nDestId != -1, "PDFExtOutDevData::DescribeRegisteredDest: invalid destination Id!" );
     612           0 :     PDFLinkDestination aLinkDestination;
     613           0 :     aLinkDestination.mRect = rRect;
     614           0 :     aLinkDestination.mMapMode = mrOutDev.GetMapMode();
     615           0 :     aLinkDestination.mPageNr = nPageNr == -1 ? mnPage : nPageNr;
     616           0 :     aLinkDestination.mAreaType = eType;
     617           0 :     mpGlobalSyncData->mFutureDestinations[ nDestId ] = aLinkDestination;
     618           0 : }
     619           0 : sal_Int32 PDFExtOutDevData::CreateDest( const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType )
     620             : {
     621           0 :     mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateDest );
     622           0 :     mpGlobalSyncData->mParaRects.push_back( rRect );
     623           0 :     mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
     624           0 :     mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
     625           0 :     mpGlobalSyncData->mParaDestAreaTypes.push_back( eType );
     626           0 :     return mpGlobalSyncData->mCurId++;
     627             : }
     628           0 : sal_Int32 PDFExtOutDevData::CreateLink( const Rectangle& rRect, sal_Int32 nPageNr )
     629             : {
     630           0 :     mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateLink );
     631           0 :     mpGlobalSyncData->mParaRects.push_back( rRect );
     632           0 :     mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
     633           0 :     mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
     634           0 :     return mpGlobalSyncData->mCurId++;
     635             : }
     636           0 : sal_Int32 PDFExtOutDevData::SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId )
     637             : {
     638           0 :     mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetLinkDest );
     639           0 :     mpGlobalSyncData->mParaInts.push_back( nLinkId );
     640           0 :     mpGlobalSyncData->mParaInts.push_back( nDestId );
     641           0 :     return 0;
     642             : }
     643           0 : sal_Int32 PDFExtOutDevData::SetLinkURL( sal_Int32 nLinkId, const OUString& rURL )
     644             : {
     645           0 :     mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetLinkURL );
     646           0 :     mpGlobalSyncData->mParaInts.push_back( nLinkId );
     647           0 :     mpGlobalSyncData->mParaOUStrings.push_back( rURL );
     648           0 :     return 0;
     649             : }
     650           0 : sal_Int32 PDFExtOutDevData::CreateOutlineItem( sal_Int32 nParent, const OUString& rText, sal_Int32 nDestID )
     651             : {
     652           0 :     mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateOutlineItem );
     653           0 :     mpGlobalSyncData->mParaInts.push_back( nParent );
     654           0 :     mpGlobalSyncData->mParaOUStrings.push_back( rText );
     655           0 :     mpGlobalSyncData->mParaInts.push_back( nDestID );
     656           0 :     return mpGlobalSyncData->mCurId++;
     657             : }
     658           0 : void PDFExtOutDevData::CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr )
     659             : {
     660           0 :     mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateNote );
     661           0 :     mpGlobalSyncData->mParaRects.push_back( rRect );
     662           0 :     mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
     663           0 :     mpGlobalSyncData->mParaPDFNotes.push_back( rNote );
     664           0 :     mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
     665           0 : }
     666           0 : void PDFExtOutDevData::SetPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr )
     667             : {
     668           0 :     mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetPageTransition );
     669           0 :     mpGlobalSyncData->mParaPageTransitions.push_back( eType );
     670           0 :     mpGlobalSyncData->mParauInts.push_back( nMilliSec );
     671           0 :     mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
     672           0 : }
     673             : 
     674             : /* local (page), actions have to be played synchroniously to the actions of
     675             :    of the recorded metafile (created by each xRenderable->render()) */
     676           0 :    sal_Int32 PDFExtOutDevData::BeginStructureElement( PDFWriter::StructElement eType, const OUString& rAlias )
     677             : {
     678           0 :     mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::BeginStructureElement );
     679           0 :     mpPageSyncData->mParaStructElements.push_back( eType );
     680           0 :     mpPageSyncData->mParaOUStrings.push_back( rAlias );
     681             :     // need a global id
     682           0 :     sal_Int32 nNewId = mpGlobalSyncData->mStructParents.size();
     683           0 :     mpGlobalSyncData->mStructParents.push_back( mpGlobalSyncData->mCurrentStructElement );
     684           0 :     mpGlobalSyncData->mCurrentStructElement = nNewId;
     685           0 :     return nNewId;
     686             : }
     687           0 : void PDFExtOutDevData::EndStructureElement()
     688             : {
     689           0 :     mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::EndStructureElement );
     690           0 :     mpGlobalSyncData->mCurrentStructElement = mpGlobalSyncData->mStructParents[ mpGlobalSyncData->mCurrentStructElement ];
     691           0 : }
     692           0 : bool PDFExtOutDevData::SetCurrentStructureElement( sal_Int32 nStructId )
     693             : {
     694           0 :     bool bSuccess = false;
     695           0 :     if( sal_uInt32(nStructId) < mpGlobalSyncData->mStructParents.size() )
     696             :     {
     697           0 :         mpGlobalSyncData->mCurrentStructElement = nStructId;
     698           0 :         mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetCurrentStructureElement );
     699           0 :         mpPageSyncData->mParaInts.push_back( nStructId );
     700           0 :         bSuccess = true;
     701             :     }
     702           0 :     return bSuccess;
     703             : }
     704           0 : sal_Int32 PDFExtOutDevData::GetCurrentStructureElement()
     705             : {
     706           0 :     return mpGlobalSyncData->mCurrentStructElement;
     707             : }
     708           0 : bool PDFExtOutDevData::SetStructureAttribute( PDFWriter::StructAttribute eAttr, PDFWriter::StructAttributeValue eVal )
     709             : {
     710           0 :     mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetStructureAttribute );
     711           0 :     mpPageSyncData->mParaStructAttributes.push_back( eAttr );
     712           0 :     mpPageSyncData->mParaStructAttributeValues.push_back( eVal );
     713           0 :     return true;
     714             : }
     715           0 : bool PDFExtOutDevData::SetStructureAttributeNumerical( PDFWriter::StructAttribute eAttr, sal_Int32 nValue )
     716             : {
     717           0 :     mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetStructureAttributeNumerical );
     718           0 :     mpPageSyncData->mParaStructAttributes.push_back( eAttr );
     719           0 :     mpPageSyncData->mParaInts.push_back( nValue );
     720           0 :     return true;
     721             : }
     722           0 : void PDFExtOutDevData::SetStructureBoundingBox( const Rectangle& rRect )
     723             : {
     724           0 :     mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetStructureBoundingBox );
     725           0 :     mpPageSyncData->mParaRects.push_back( rRect );
     726           0 : }
     727           0 : void PDFExtOutDevData::SetActualText( const OUString& rText )
     728             : {
     729           0 :     mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetActualText );
     730           0 :     mpPageSyncData->mParaOUStrings.push_back( rText );
     731           0 : }
     732           0 : void PDFExtOutDevData::SetAlternateText( const OUString& rText )
     733             : {
     734           0 :     mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetAlternateText );
     735           0 :     mpPageSyncData->mParaOUStrings.push_back( rText );
     736           0 : }
     737             : 
     738           0 : void PDFExtOutDevData::CreateControl( const PDFWriter::AnyWidget& rControlType, sal_Int32 /*nPageNr*/ )
     739             : {
     740           0 :     mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::CreateControl );
     741             : 
     742           0 :     std::shared_ptr< PDFWriter::AnyWidget > pClone( rControlType.Clone() );
     743           0 :     mpPageSyncData->mControls.push_back( pClone );
     744           0 : }
     745             : 
     746           0 : void PDFExtOutDevData::BeginGroup()
     747             : {
     748           0 :     mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::BeginGroup );
     749           0 : }
     750             : 
     751           0 : void PDFExtOutDevData::EndGroup( const Graphic&     rGraphic,
     752             :                                  sal_uInt8              nTransparency,
     753             :                                  const Rectangle&   rOutputRect,
     754             :                                  const Rectangle&   rVisibleOutputRect )
     755             : {
     756           0 :     mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::EndGroupGfxLink );
     757           0 :     mpPageSyncData->mGraphics.push_back( rGraphic );
     758           0 :     mpPageSyncData->mParaInts.push_back( nTransparency );
     759           0 :     mpPageSyncData->mParaRects.push_back( rOutputRect );
     760           0 :     mpPageSyncData->mParaRects.push_back( rVisibleOutputRect );
     761           0 : }
     762             : 
     763             : }
     764             : 
     765             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11