LCOV - code coverage report
Current view: top level - svx/source/unodraw - UnoGraphicExporter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 193 526 36.7 %
Date: 2012-08-25 Functions: 15 28 53.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 204 1178 17.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <vector>
      31                 :            : #include <osl/mutex.hxx>
      32                 :            : #include <com/sun/star/io/XOutputStream.hpp>
      33                 :            : #include <com/sun/star/container/XChild.hpp>
      34                 :            : #include <com/sun/star/frame/XModel.hpp>
      35                 :            : #include <com/sun/star/document/XFilter.hpp>
      36                 :            : #include <com/sun/star/document/XExporter.hpp>
      37                 :            : #include <com/sun/star/document/XMimeTypeInfo.hpp>
      38                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      39                 :            : #include <com/sun/star/lang/XComponent.hpp>
      40                 :            : #include <com/sun/star/drawing/XShape.hpp>
      41                 :            : #include <com/sun/star/drawing/XDrawPage.hpp>
      42                 :            : #include <com/sun/star/graphic/XGraphic.hpp>
      43                 :            : #include <com/sun/star/graphic/XGraphicRenderer.hpp>
      44                 :            : #include <com/sun/star/task/XStatusIndicator.hpp>
      45                 :            : #include <com/sun/star/task/XInteractionHandler.hpp>
      46                 :            : #include <com/sun/star/task/XInteractionContinuation.hpp>
      47                 :            : 
      48                 :            : #include <rtl/logfile.hxx>
      49                 :            : #include <comphelper/interaction.hxx>
      50                 :            : #include <framework/interaction.hxx>
      51                 :            : #include <com/sun/star/drawing/GraphicFilterRequest.hpp>
      52                 :            : #include <com/sun/star/util/URL.hpp>
      53                 :            : #include <cppuhelper/implbase4.hxx>
      54                 :            : #include <osl/diagnose.h>
      55                 :            : #include <vcl/metaact.hxx>
      56                 :            : #include <vcl/svapp.hxx>
      57                 :            : #include <vcl/virdev.hxx>
      58                 :            : #include <svtools/FilterConfigItem.hxx>
      59                 :            : #include <svl/outstrm.hxx>
      60                 :            : #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
      61                 :            : #include <svx/sdr/contact/viewobjectcontact.hxx>
      62                 :            : #include <svx/sdr/contact/viewcontact.hxx>
      63                 :            : #include <svx/sdr/contact/displayinfo.hxx>
      64                 :            : #include <svx/sdr/contact/viewcontactofsdrobj.hxx>
      65                 :            : #include <editeng/numitem.hxx>
      66                 :            : #include <svx/svdpagv.hxx>
      67                 :            : #include <svx/svdograf.hxx>
      68                 :            : #include "svx/xoutbmp.hxx"
      69                 :            : #include "svtools/filter.hxx"
      70                 :            : #include "svx/unoapi.hxx"
      71                 :            : #include <svx/svdpage.hxx>
      72                 :            : #include <svx/svdmodel.hxx>
      73                 :            : #include <svx/fmview.hxx>
      74                 :            : #include <svx/fmmodel.hxx>
      75                 :            : #include <svx/unopage.hxx>
      76                 :            : #include <svx/pageitem.hxx>
      77                 :            : #include <editeng/eeitem.hxx>
      78                 :            : #include <svx/svdoutl.hxx>
      79                 :            : #include <editeng/flditem.hxx>
      80                 :            : 
      81                 :            : #include "boost/scoped_ptr.hpp"
      82                 :            : 
      83                 :            : #define MAX_EXT_PIX         2048
      84                 :            : 
      85                 :            : using namespace ::comphelper;
      86                 :            : using namespace ::osl;
      87                 :            : using ::rtl::OUString;
      88                 :            : using namespace ::cppu;
      89                 :            : using namespace ::com::sun::star;
      90                 :            : using namespace ::com::sun::star::uno;
      91                 :            : using namespace ::com::sun::star::util;
      92                 :            : using namespace ::com::sun::star::container;
      93                 :            : using namespace ::com::sun::star::drawing;
      94                 :            : using namespace ::com::sun::star::lang;
      95                 :            : using namespace ::com::sun::star::document;
      96                 :            : using namespace ::com::sun::star::frame;
      97                 :            : using namespace ::com::sun::star::beans;
      98                 :            : using namespace ::com::sun::star::task;
      99                 :            : #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
     100                 :            : 
     101                 :            : // #i102251#
     102                 :            : #include <editeng/editstat.hxx>
     103                 :            : 
     104                 :            : //////////////////////////////////////////////////////////////////////////////
     105                 :            : 
     106                 :            : namespace svx
     107                 :            : {
     108         [ +  - ]:         90 :     struct ExportSettings
     109                 :            :     {
     110                 :            :         OUString maFilterName;
     111                 :            :         OUString maMediaType;
     112                 :            :         URL maURL;
     113                 :            :         com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > mxOutputStream;
     114                 :            :         com::sun::star::uno::Reference< com::sun::star::graphic::XGraphicRenderer > mxGraphicRenderer;
     115                 :            :         com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator >    mxStatusIndicator;
     116                 :            :         com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > mxInteractionHandler;
     117                 :            : 
     118                 :            :         sal_Int32 mnWidth;
     119                 :            :         sal_Int32 mnHeight;
     120                 :            :         sal_Bool mbExportOnlyBackground;
     121                 :            :         sal_Bool mbScrollText;
     122                 :            :         sal_Bool mbUseHighContrast;
     123                 :            :         sal_Bool mbTranslucent;
     124                 :            : 
     125                 :            :         Sequence< PropertyValue >   maFilterData;
     126                 :            : 
     127                 :            :         Fraction    maScaleX;
     128                 :            :         Fraction    maScaleY;
     129                 :            : 
     130                 :            :         ExportSettings( SdrModel* pDoc );
     131                 :            :     };
     132                 :            : 
     133                 :         90 :     ExportSettings::ExportSettings( SdrModel* pDoc )
     134                 :            :     : mnWidth( 0 )
     135                 :            :     , mnHeight( 0 )
     136                 :            :     , mbExportOnlyBackground( false )
     137                 :            :     , mbScrollText( false )
     138                 :            :     , mbUseHighContrast( false )
     139                 :            :     , mbTranslucent( sal_False )
     140                 :            :     , maScaleX( 1, 1 )
     141 [ +  - ][ +  - ]:         90 :     , maScaleY( 1, 1 )
                 [ +  - ]
     142                 :            :     {
     143         [ +  - ]:         90 :         if( pDoc )
     144                 :            :         {
     145         [ +  - ]:         90 :             maScaleX = pDoc->GetScaleFraction();
     146         [ +  - ]:         90 :             maScaleY = pDoc->GetScaleFraction();
     147                 :            :         }
     148                 :         90 :     }
     149                 :            : 
     150                 :            :     /** implements a component to export shapes or pages to external graphic formats.
     151                 :            : 
     152                 :            :         @implements com.sun.star.drawing.GraphicExportFilter
     153                 :            :     */
     154                 :            :     class GraphicExporter : public WeakImplHelper4< XFilter, XExporter, XServiceInfo, XMimeTypeInfo >
     155                 :            :     {
     156                 :            :     public:
     157                 :            :         GraphicExporter();
     158                 :            :         virtual ~GraphicExporter();
     159                 :            : 
     160                 :            :         // XFilter
     161                 :            :         virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& aDescriptor ) throw(RuntimeException);
     162                 :            :         virtual void SAL_CALL cancel(  ) throw(RuntimeException);
     163                 :            : 
     164                 :            :         // XExporter
     165                 :            :         virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException);
     166                 :            : 
     167                 :            :         // XServiceInfo
     168                 :            :         virtual OUString SAL_CALL getImplementationName(  ) throw(RuntimeException);
     169                 :            :         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
     170                 :            :         virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw(RuntimeException);
     171                 :            : 
     172                 :            :         // XMimeTypeInfo
     173                 :            :         virtual sal_Bool SAL_CALL supportsMimeType( const ::rtl::OUString& MimeTypeName ) throw (RuntimeException);
     174                 :            :         virtual Sequence< OUString > SAL_CALL getSupportedMimeTypeNames(  ) throw (RuntimeException);
     175                 :            : 
     176                 :            :         VirtualDevice* CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWidthPixel, sal_uIntPtr nHeightPixel ) const;
     177                 :            : 
     178                 :            :         DECL_LINK( CalcFieldValueHdl, EditFieldInfo* );
     179                 :            : 
     180                 :            :         void ParseSettings( const Sequence< PropertyValue >& aDescriptor, ExportSettings& rSettings );
     181                 :            :         bool GetGraphic( ExportSettings& rSettings, Graphic& aGraphic, sal_Bool bVectorType );
     182                 :            : 
     183                 :            :     private:
     184                 :            :         Reference< XShape >     mxShape;
     185                 :            :         Reference< XDrawPage >  mxPage;
     186                 :            :         Reference< XShapes >    mxShapes;
     187                 :            : 
     188                 :            :         SvxDrawPage*        mpUnoPage;
     189                 :            : 
     190                 :            :         Link                maOldCalcFieldValueHdl;
     191                 :            :         sal_Int32           mnPageNumber;
     192                 :            :         SdrPage*            mpCurrentPage;
     193                 :            :         SdrModel*           mpDoc;
     194                 :            :     };
     195                 :            : 
     196                 :         90 :     SVX_DLLPUBLIC Reference< XInterface > SAL_CALL GraphicExporter_createInstance(const Reference< XMultiServiceFactory > & )
     197                 :            :         throw( Exception )
     198                 :            :     {
     199         [ +  - ]:         90 :         return (XWeak*)new GraphicExporter();
     200                 :            :     }
     201                 :            : 
     202                 :          9 :     SVX_DLLPUBLIC Sequence< OUString > SAL_CALL GraphicExporter_getSupportedServiceNames()
     203                 :            :         throw()
     204                 :            :     {
     205                 :          9 :         Sequence< OUString > aSupportedServiceNames( 1 );
     206 [ +  - ][ +  - ]:          9 :         aSupportedServiceNames[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicExportFilter" ) );
     207                 :          9 :         return aSupportedServiceNames;
     208                 :            :     }
     209                 :            : 
     210                 :         79 :     SVX_DLLPUBLIC OUString SAL_CALL GraphicExporter_getImplementationName()
     211                 :            :         throw()
     212                 :            :     {
     213                 :         79 :         return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Draw.GraphicExporter" ) );
     214                 :            :     }
     215                 :            : 
     216                 :            :     /** creates a bitmap that is optionaly transparent from a metafile
     217                 :            :     */
     218                 :          0 :     BitmapEx GetBitmapFromMetaFile( const GDIMetaFile& rMtf, sal_Bool bTransparent, const Size* pSize )
     219                 :            :     {
     220         [ #  # ]:          0 :         Graphic     aGraphic( rMtf );
     221         [ #  # ]:          0 :         BitmapEx    aBmpEx;
     222                 :            : 
     223                 :            :         // #i102089# support user's settings of AA and LineSnap when the MetaFile gets
     224                 :            :         // rasterconverted to a bitmap
     225         [ #  # ]:          0 :         const SvtOptionsDrawinglayer aDrawinglayerOpt;
     226                 :            :         const GraphicConversionParameters aParameters(
     227                 :            :             pSize ? *pSize : Size(0, 0),
     228                 :            :             true, // allow unlimited size
     229         [ #  # ]:          0 :             aDrawinglayerOpt.IsAntiAliasing(),
     230 [ #  # ][ #  # ]:          0 :             aDrawinglayerOpt.IsSnapHorVerLinesToDiscrete());
     231                 :            : 
     232         [ #  # ]:          0 :         if( bTransparent )
     233                 :            :         {
     234 [ #  # ][ #  # ]:          0 :             Graphic aMaskGraphic(rMtf.GetMonochromeMtf(COL_BLACK));
                 [ #  # ]
     235         [ #  # ]:          0 :             Bitmap  aMaskBmp(aMaskGraphic.GetBitmap(aParameters));
     236                 :            : 
     237         [ #  # ]:          0 :             aMaskBmp.Convert(BMP_CONVERSION_1BIT_THRESHOLD);
     238 [ #  # ][ #  # ]:          0 :             aBmpEx = BitmapEx(aGraphic.GetBitmap(aParameters), aMaskBmp);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     239                 :            :         }
     240                 :            :         else
     241                 :            :         {
     242 [ #  # ][ #  # ]:          0 :             aBmpEx = BitmapEx(aGraphic.GetBitmap(aParameters));
         [ #  # ][ #  # ]
                 [ #  # ]
     243                 :            :         }
     244                 :            : 
     245         [ #  # ]:          0 :         aBmpEx.SetPrefMapMode( rMtf.GetPrefMapMode() );
     246                 :          0 :         aBmpEx.SetPrefSize( rMtf.GetPrefSize() );
     247                 :            : 
     248 [ #  # ][ #  # ]:          0 :         return aBmpEx;
     249                 :            :     }
     250                 :            : 
     251                 :          0 :     Size* CalcSize( sal_Int32 nWidth, sal_Int32 nHeight, const Size& aBoundSize, Size& aOutSize )
     252                 :            :     {
     253 [ #  # ][ #  # ]:          0 :         if( (nWidth == 0) && (nHeight == 0) )
     254                 :          0 :             return NULL;
     255                 :            : 
     256 [ #  # ][ #  # ]:          0 :         if( (nWidth == 0) && (nHeight != 0) && (aBoundSize.Height() != 0) )
         [ #  # ][ #  # ]
     257                 :            :         {
     258                 :          0 :             nWidth = ( nHeight * aBoundSize.Width() ) / aBoundSize.Height();
     259                 :            :         }
     260 [ #  # ][ #  # ]:          0 :         else if( (nWidth != 0) && (nHeight == 0) && (aBoundSize.Width() != 0) )
         [ #  # ][ #  # ]
     261                 :            :         {
     262                 :          0 :             nHeight = ( nWidth * aBoundSize.Height() ) / aBoundSize.Width();
     263                 :            :         }
     264                 :            : 
     265                 :          0 :         aOutSize.Width() = nWidth;
     266                 :          0 :         aOutSize.Height() = nHeight;
     267                 :            : 
     268                 :          0 :         return &aOutSize;
     269                 :            :     }
     270                 :            : }
     271                 :            : 
     272                 :            : class ImplExportCheckVisisbilityRedirector : public ::sdr::contact::ViewObjectContactRedirector
     273                 :            : {
     274                 :            : public:
     275                 :            :     ImplExportCheckVisisbilityRedirector( SdrPage* pCurrentPage );
     276                 :            :     virtual ~ImplExportCheckVisisbilityRedirector();
     277                 :            : 
     278                 :            :     virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
     279                 :            :         const sdr::contact::ViewObjectContact& rOriginal,
     280                 :            :         const sdr::contact::DisplayInfo& rDisplayInfo);
     281                 :            : 
     282                 :            : private:
     283                 :            :     SdrPage*    mpCurrentPage;
     284                 :            : };
     285                 :            : 
     286                 :         90 : ImplExportCheckVisisbilityRedirector::ImplExportCheckVisisbilityRedirector( SdrPage* pCurrentPage )
     287                 :         90 : :   ViewObjectContactRedirector(), mpCurrentPage( pCurrentPage )
     288                 :            : {
     289                 :         90 : }
     290                 :            : 
     291                 :         90 : ImplExportCheckVisisbilityRedirector::~ImplExportCheckVisisbilityRedirector()
     292                 :            : {
     293         [ -  + ]:         90 : }
     294                 :            : 
     295                 :       7673 : drawinglayer::primitive2d::Primitive2DSequence ImplExportCheckVisisbilityRedirector::createRedirectedPrimitive2DSequence(
     296                 :            :     const sdr::contact::ViewObjectContact& rOriginal,
     297                 :            :     const sdr::contact::DisplayInfo& rDisplayInfo)
     298                 :            : {
     299                 :       7673 :     SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
     300                 :            : 
     301         [ +  + ]:       7673 :     if(pObject)
     302                 :            :     {
     303                 :       7313 :         SdrPage* pPage = mpCurrentPage;
     304         [ -  + ]:       7313 :         if( pPage == 0 )
     305                 :          0 :             pPage = pObject->GetPage();
     306                 :            : 
     307 [ +  - ][ +  - ]:       7313 :         if( (pPage == 0) || pPage->checkVisibility(rOriginal, rDisplayInfo, false) )
                 [ +  - ]
     308                 :            :         {
     309                 :       7313 :             return ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
     310                 :            :         }
     311                 :            : 
     312                 :          0 :         return drawinglayer::primitive2d::Primitive2DSequence();
     313                 :            :     }
     314                 :            :     else
     315                 :            :     {
     316                 :            :         // not an object, maybe a page
     317                 :       7673 :         return ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
     318                 :            :     }
     319                 :            : }
     320                 :            : 
     321                 :            : using namespace ::svx;
     322                 :            : 
     323                 :         90 : GraphicExporter::GraphicExporter()
     324         [ +  - ]:         90 : : mpUnoPage( NULL ), mnPageNumber(-1), mpCurrentPage(0), mpDoc( NULL )
     325                 :            : {
     326                 :         90 : }
     327                 :            : 
     328                 :         90 : GraphicExporter::~GraphicExporter()
     329                 :            : {
     330         [ -  + ]:        180 : }
     331                 :            : 
     332                 :          0 : IMPL_LINK(GraphicExporter, CalcFieldValueHdl, EditFieldInfo*, pInfo)
     333                 :            : {
     334         [ #  # ]:          0 :     if( pInfo )
     335                 :            :     {
     336         [ #  # ]:          0 :         if( mpCurrentPage )
     337                 :            :         {
     338                 :          0 :             pInfo->SetSdrPage( mpCurrentPage );
     339                 :            :         }
     340         [ #  # ]:          0 :         else if( mnPageNumber != -1 )
     341                 :            :         {
     342                 :          0 :             const SvxFieldData* pField = pInfo->GetField().GetField();
     343 [ #  # ][ #  # ]:          0 :             if( pField && pField->ISA( SvxPageField ) )
                 [ #  # ]
     344                 :            :             {
     345         [ #  # ]:          0 :                 String aPageNumValue;
     346                 :          0 :                 sal_Bool bUpper = sal_False;
     347                 :            : 
     348 [ #  # ][ #  #  :          0 :                 switch(mpDoc->GetPageNumType())
             #  #  #  # ]
     349                 :            :                 {
     350                 :            :                     case SVX_CHARS_UPPER_LETTER:
     351         [ #  # ]:          0 :                         aPageNumValue += (sal_Unicode)(char)((mnPageNumber - 1) % 26 + 'A');
     352                 :          0 :                         break;
     353                 :            :                     case SVX_CHARS_LOWER_LETTER:
     354         [ #  # ]:          0 :                         aPageNumValue += (sal_Unicode)(char)((mnPageNumber - 1) % 26 + 'a');
     355                 :          0 :                         break;
     356                 :            :                     case SVX_ROMAN_UPPER:
     357                 :          0 :                         bUpper = sal_True;
     358                 :            :                     case SVX_ROMAN_LOWER:
     359 [ #  # ][ #  # ]:          0 :                         aPageNumValue += SvxNumberFormat::CreateRomanString(mnPageNumber, bUpper);
                 [ #  # ]
     360                 :          0 :                         break;
     361                 :            :                     case SVX_NUMBER_NONE:
     362         [ #  # ]:          0 :                         aPageNumValue.Erase();
     363         [ #  # ]:          0 :                         aPageNumValue += sal_Unicode(' ');
     364                 :          0 :                         break;
     365                 :            :                     default:
     366 [ #  # ][ #  # ]:          0 :                         aPageNumValue += String::CreateFromInt32( (sal_Int32)mnPageNumber );
                 [ #  # ]
     367                 :            :                 }
     368                 :            : 
     369         [ #  # ]:          0 :                 pInfo->SetRepresentation( aPageNumValue );
     370                 :            : 
     371         [ #  # ]:          0 :                 return(0);
     372                 :            :             }
     373                 :            :         }
     374                 :            :     }
     375                 :            : 
     376                 :          0 :     long nRet = maOldCalcFieldValueHdl.Call( pInfo );
     377                 :            : 
     378 [ #  # ][ #  # ]:          0 :     if( pInfo && mpCurrentPage )
     379                 :          0 :         pInfo->SetSdrPage( 0 );
     380                 :            : 
     381                 :          0 :     return nRet;
     382                 :            : }
     383                 :            : 
     384                 :            : /** creates an virtual device for the given page
     385                 :            : 
     386                 :            :     @return the returned VirtualDevice is owned by the caller
     387                 :            : */
     388                 :          0 : VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWidthPixel, sal_uIntPtr nHeightPixel ) const
     389                 :            : {
     390 [ #  # ][ #  # ]:          0 :     VirtualDevice*  pVDev = new VirtualDevice();
     391         [ #  # ]:          0 :     MapMode         aMM( MAP_100TH_MM );
     392                 :            : 
     393                 :          0 :     Point aPoint( 0, 0 );
     394         [ #  # ]:          0 :     Size aPageSize(pPage->GetSize());
     395                 :            : 
     396                 :            :     // use scaling?
     397         [ #  # ]:          0 :     if( nWidthPixel )
     398                 :            :     {
     399 [ #  # ][ #  # ]:          0 :         const Fraction aFrac( (long) nWidthPixel, pVDev->LogicToPixel( aPageSize, aMM ).Width() );
     400                 :            : 
     401         [ #  # ]:          0 :         aMM.SetScaleX( aFrac );
     402                 :            : 
     403         [ #  # ]:          0 :         if( nHeightPixel == 0 )
     404         [ #  # ]:          0 :             aMM.SetScaleY( aFrac );
     405                 :            :     }
     406                 :            : 
     407         [ #  # ]:          0 :     if( nHeightPixel )
     408                 :            :     {
     409 [ #  # ][ #  # ]:          0 :         const Fraction aFrac( (long) nHeightPixel, pVDev->LogicToPixel( aPageSize, aMM ).Height() );
     410                 :            : 
     411         [ #  # ]:          0 :         if( nWidthPixel == 0 )
     412         [ #  # ]:          0 :             aMM.SetScaleX( aFrac );
     413                 :            : 
     414         [ #  # ]:          0 :         aMM.SetScaleY( aFrac );
     415                 :            :     }
     416                 :            : 
     417         [ #  # ]:          0 :     pVDev->SetMapMode( aMM );
     418                 :            : #ifdef DBG_UTIL
     419                 :            :     sal_Bool bAbort = !
     420                 :            : #endif
     421         [ #  # ]:          0 :         pVDev->SetOutputSize(aPageSize);
     422                 :            :     DBG_ASSERT(!bAbort, "virt. Device nicht korrekt erzeugt");
     423                 :            : 
     424 [ #  # ][ #  # ]:          0 :     SdrView* pView = new SdrView(mpDoc, pVDev);
     425         [ #  # ]:          0 :     pView->SetPageVisible( sal_False );
     426         [ #  # ]:          0 :     pView->SetBordVisible( sal_False );
     427         [ #  # ]:          0 :     pView->SetGridVisible( sal_False );
     428         [ #  # ]:          0 :     pView->SetHlplVisible( sal_False );
     429         [ #  # ]:          0 :     pView->SetGlueVisible( sal_False );
     430         [ #  # ]:          0 :     pView->ShowSdrPage(pPage);
     431 [ #  # ][ #  # ]:          0 :     Region aRegion (Rectangle( aPoint, aPageSize ) );
     432                 :            : 
     433         [ #  # ]:          0 :     ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
     434                 :            : 
     435         [ #  # ]:          0 :     pView->CompleteRedraw(pVDev, aRegion, &aRedirector);
     436                 :            : 
     437 [ #  # ][ #  # ]:          0 :     delete pView;
     438 [ #  # ][ #  # ]:          0 :     return pVDev;
                 [ #  # ]
     439                 :            : }
     440                 :            : 
     441                 :         90 : void GraphicExporter::ParseSettings( const Sequence< PropertyValue >& aDescriptor, ExportSettings& rSettings )
     442                 :            : {
     443                 :         90 :     sal_Int32 nArgs = aDescriptor.getLength();
     444                 :         90 :     const PropertyValue* pValues = aDescriptor.getConstArray();
     445         [ +  + ]:        360 :     while( nArgs-- )
     446                 :            :     {
     447         [ +  + ]:        270 :         if ( pValues->Name == "FilterName" )
     448                 :            :         {
     449                 :         90 :             pValues->Value >>= rSettings.maFilterName;
     450                 :            :         }
     451         [ -  + ]:        180 :         else if ( pValues->Name == "MediaType" )
     452                 :            :         {
     453                 :          0 :             pValues->Value >>= rSettings.maMediaType;
     454                 :            :         }
     455         [ -  + ]:        180 :         else if ( pValues->Name == "URL" )
     456                 :            :         {
     457         [ #  # ]:          0 :             if( !( pValues->Value >>= rSettings.maURL ) )
     458                 :            :             {
     459                 :          0 :                 pValues->Value >>= rSettings.maURL.Complete;
     460                 :            :             }
     461                 :            :         }
     462         [ +  + ]:        180 :         else if ( pValues->Name == "OutputStream" )
     463                 :            :         {
     464                 :         90 :             pValues->Value >>= rSettings.mxOutputStream;
     465                 :            :         }
     466         [ -  + ]:         90 :         else if ( pValues->Name == "GraphicRenderer" )
     467                 :            :         {
     468                 :          0 :             pValues->Value >>= rSettings.mxGraphicRenderer;
     469                 :            :         }
     470         [ -  + ]:         90 :         else if ( pValues->Name == "StatusIndicator" )
     471                 :            :         {
     472                 :          0 :             pValues->Value >>= rSettings.mxStatusIndicator;
     473                 :            :         }
     474         [ -  + ]:         90 :         else if ( pValues->Name == "InteractionHandler" )
     475                 :            :         {
     476                 :          0 :             pValues->Value >>= rSettings.mxInteractionHandler;
     477                 :            :         }
     478         [ -  + ]:         90 :         else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Width" ) ) )  // for compatibility reasons, deprecated
     479                 :            :         {
     480                 :          0 :             pValues->Value >>= rSettings.mnWidth;
     481                 :            :         }
     482         [ -  + ]:         90 :         else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Height" ) ) ) // for compatibility reasons, deprecated
     483                 :            :         {
     484                 :          0 :             pValues->Value >>= rSettings.mnHeight;
     485                 :            :         }
     486         [ -  + ]:         90 :         else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ExportOnlyBackground" ) ) )   // for compatibility reasons, deprecated
     487                 :            :         {
     488                 :          0 :             pValues->Value >>= rSettings.mbExportOnlyBackground;
     489                 :            :         }
     490         [ +  - ]:         90 :         else if ( pValues->Name == "FilterData" )
     491                 :            :         {
     492                 :         90 :             pValues->Value >>= rSettings.maFilterData;
     493                 :            : 
     494                 :         90 :             sal_Int32 nFilterArgs = rSettings.maFilterData.getLength();
     495                 :         90 :             PropertyValue* pDataValues = rSettings.maFilterData.getArray();
     496         [ +  + ]:        810 :             while( nFilterArgs-- )
     497                 :            :             {
     498         [ -  + ]:        720 :                 if ( pDataValues->Name == "Translucent" )
     499                 :            :                 {
     500         [ #  # ]:          0 :                     if ( !( pDataValues->Value >>= rSettings.mbTranslucent ) )  // SJ: TODO: The GIF Transparency is stored as int32 in
     501                 :            :                     {                                               // configuration files, this has to be changed to boolean
     502                 :          0 :                         sal_Int32 nTranslucent = 0;
     503         [ #  # ]:          0 :                         if ( pDataValues->Value >>= nTranslucent )
     504                 :          0 :                             rSettings.mbTranslucent = nTranslucent != 0;
     505                 :            :                     }
     506                 :            :                 }
     507         [ -  + ]:        720 :                 else if ( pDataValues->Name == "PixelWidth" )
     508                 :            :                 {
     509                 :          0 :                     pDataValues->Value >>= rSettings.mnWidth;
     510                 :            :                 }
     511         [ -  + ]:        720 :                 else if ( pDataValues->Name == "PixelHeight" )
     512                 :            :                 {
     513                 :          0 :                     pDataValues->Value >>= rSettings.mnHeight;
     514                 :            :                 }
     515         [ -  + ]:        720 :                 else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Width" ) ) )  // for compatibility reasons, deprecated
     516                 :            :                 {
     517                 :          0 :                     pDataValues->Value >>= rSettings.mnWidth;
     518                 :          0 :                     pDataValues->Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PixelWidth" ) );
     519                 :            :                 }
     520         [ -  + ]:        720 :                 else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Height" ) ) ) // for compatibility reasons, deprecated
     521                 :            :                 {
     522                 :          0 :                     pDataValues->Value >>= rSettings.mnHeight;
     523                 :          0 :                     pDataValues->Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PixelHeight" ) );
     524                 :            :                 }
     525         [ +  + ]:        720 :                 else if ( pDataValues->Name == "ExportOnlyBackground" )
     526                 :            :                 {
     527                 :         90 :                     pDataValues->Value >>= rSettings.mbExportOnlyBackground;
     528                 :            :                 }
     529         [ +  + ]:        630 :                 else if ( pDataValues->Name == "HighContrast" )
     530                 :            :                 {
     531                 :         90 :                     pDataValues->Value >>= rSettings.mbUseHighContrast;
     532                 :            :                 }
     533         [ -  + ]:        540 :                 else if ( pDataValues->Name == "PageNumber" )
     534                 :            :                 {
     535                 :          0 :                     pDataValues->Value >>= mnPageNumber;
     536                 :            :                 }
     537         [ -  + ]:        540 :                 else if ( pDataValues->Name == "ScrollText" )
     538                 :            :                 {
     539                 :            :                     // #110496# Read flag solitary scroll text metafile
     540                 :          0 :                     pDataValues->Value >>= rSettings.mbScrollText;
     541                 :            :                 }
     542         [ +  + ]:        540 :                 else if ( pDataValues->Name == "CurrentPage" )
     543                 :            :                 {
     544                 :         90 :                     Reference< XDrawPage >  xPage;
     545         [ +  - ]:         90 :                     pDataValues->Value >>= xPage;
     546         [ +  - ]:         90 :                     if( xPage.is() )
     547                 :            :                     {
     548         [ +  - ]:         90 :                         SvxDrawPage* pUnoPage = SvxDrawPage::getImplementation( xPage );
     549 [ +  - ][ +  - ]:         90 :                         if( pUnoPage && pUnoPage->GetSdrPage() )
                 [ +  - ]
     550                 :         90 :                             mpCurrentPage = pUnoPage->GetSdrPage();
     551                 :         90 :                     }
     552                 :            :                 }
     553         [ +  + ]:        450 :                 else if ( pDataValues->Name == "ScaleXNumerator" )
     554                 :            :                 {
     555                 :         90 :                     sal_Int32 nVal = 1;
     556         [ +  - ]:         90 :                     if( pDataValues->Value >>= nVal )
     557 [ +  - ][ +  - ]:         90 :                         rSettings.maScaleX = Fraction( nVal, rSettings.maScaleX.GetDenominator() );
     558                 :            :                 }
     559         [ +  + ]:        360 :                 else if ( pDataValues->Name == "ScaleXDenominator" )
     560                 :            :                 {
     561                 :         90 :                     sal_Int32 nVal = 1;
     562         [ +  - ]:         90 :                     if( pDataValues->Value >>= nVal )
     563 [ +  - ][ +  - ]:         90 :                         rSettings.maScaleX = Fraction( rSettings.maScaleX.GetNumerator(), nVal );
     564                 :            :                 }
     565         [ +  + ]:        270 :                 else if ( pDataValues->Name == "ScaleYNumerator" )
     566                 :            :                 {
     567                 :         90 :                     sal_Int32 nVal = 1;
     568         [ +  - ]:         90 :                     if( pDataValues->Value >>= nVal )
     569 [ +  - ][ +  - ]:         90 :                         rSettings.maScaleY = Fraction( nVal, rSettings.maScaleY.GetDenominator() );
     570                 :            :                 }
     571         [ +  + ]:        180 :                 else if ( pDataValues->Name == "ScaleYDenominator" )
     572                 :            :                 {
     573                 :         90 :                     sal_Int32 nVal = 1;
     574         [ +  - ]:         90 :                     if( pDataValues->Value >>= nVal )
     575 [ +  - ][ +  - ]:         90 :                         rSettings.maScaleY = Fraction( rSettings.maScaleY.GetNumerator(), nVal );
     576                 :            :                 }
     577                 :            : 
     578                 :        720 :                 pDataValues++;
     579                 :            :             }
     580                 :            :         }
     581                 :            : 
     582                 :        270 :         pValues++;
     583                 :            :     }
     584                 :            : 
     585                 :            :     // putting the StatusIndicator that we got from the MediaDescriptor into our local FilterData copy
     586         [ -  + ]:         90 :     if ( rSettings.mxStatusIndicator.is() )
     587                 :            :     {
     588         [ #  # ]:          0 :         rtl::OUString sStatusIndicator( RTL_CONSTASCII_USTRINGPARAM( "StatusIndicator" ) );
     589                 :          0 :         int i = rSettings.maFilterData.getLength();
     590         [ #  # ]:          0 :         rSettings.maFilterData.realloc( i + 1 );
     591         [ #  # ]:          0 :         rSettings.maFilterData[ i ].Name = sStatusIndicator;
     592 [ #  # ][ #  # ]:          0 :         rSettings.maFilterData[ i ].Value <<= rSettings.mxStatusIndicator;
     593                 :            :     }
     594                 :         90 : }
     595                 :            : 
     596                 :         90 : bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic, sal_Bool bVectorType )
     597                 :            : {
     598                 :            :     RTL_LOGFILE_CONTEXT( aLog, "UnoGraphicExporter::GetGraphic (thb)" );
     599                 :            : 
     600 [ +  - ][ -  + ]:         90 :     if( !mpDoc || !mpUnoPage )
     601                 :          0 :         return false;
     602                 :            : 
     603                 :         90 :     SdrPage* pPage = mpUnoPage->GetSdrPage();
     604         [ -  + ]:         90 :     if( !pPage )
     605                 :          0 :         return false;
     606                 :            : 
     607         [ +  - ]:         90 :     VirtualDevice       aVDev;
     608         [ +  - ]:         90 :     const MapMode       aMap( mpDoc->GetScaleUnit(), Point(), rSettings.maScaleX, rSettings.maScaleY );
     609                 :            : 
     610         [ +  - ]:         90 :     SdrOutliner& rOutl=mpDoc->GetDrawOutliner(NULL);
     611                 :         90 :     maOldCalcFieldValueHdl = rOutl.GetCalcFieldValueHdl();
     612         [ +  - ]:         90 :     rOutl.SetCalcFieldValueHdl( LINK(this, GraphicExporter, CalcFieldValueHdl) );
     613 [ +  - ][ +  - ]:         90 :     rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor() );
     614                 :            : 
     615                 :            :     // #i102251#
     616         [ +  - ]:         90 :     const sal_uInt32 nOldCntrl(rOutl.GetControlWord());
     617                 :         90 :     sal_uInt32 nCntrl = nOldCntrl & ~EE_CNTRL_ONLINESPELLING;
     618         [ +  - ]:         90 :     rOutl.SetControlWord(nCntrl);
     619                 :            : 
     620                 :         90 :     SdrObject* pTempBackgroundShape = 0;
     621         [ +  - ]:         90 :     std::vector< SdrObject* > aShapes;
     622                 :         90 :     bool bRet = true;
     623                 :            : 
     624                 :            :     // export complete page?
     625         [ +  - ]:         90 :     if ( !mxShape.is() )
     626                 :            :     {
     627         [ -  + ]:         90 :         if( rSettings.mbExportOnlyBackground )
     628                 :            :         {
     629         [ #  # ]:          0 :             const SdrPageProperties* pCorrectProperties = pPage->getCorrectSdrPageProperties();
     630                 :            : 
     631         [ #  # ]:          0 :             if(pCorrectProperties)
     632                 :            :             {
     633 [ #  # ][ #  # ]:          0 :                 pTempBackgroundShape = new SdrRectObj(Rectangle(Point(0,0), pPage->GetSize()));
         [ #  # ][ #  # ]
     634 [ #  # ][ #  # ]:          0 :                 pTempBackgroundShape->SetMergedItemSet(pCorrectProperties->GetItemSet());
     635 [ #  # ][ #  # ]:          0 :                 pTempBackgroundShape->SetMergedItem(XLineStyleItem(XLINE_NONE));
                 [ #  # ]
     636 [ #  # ][ #  # ]:          0 :                 pTempBackgroundShape->NbcSetStyleSheet(pCorrectProperties->GetStyleSheet(), true);
     637         [ #  # ]:          0 :                 aShapes.push_back(pTempBackgroundShape);
     638                 :            :             }
     639                 :            :         }
     640                 :            :         else
     641                 :            :         {
     642         [ +  - ]:         90 :             const Size aSize( pPage->GetSize() );
     643                 :            : 
     644                 :            :             // generate a bitmap to convert it to a pixel format.
     645                 :            :             // For gif pictures there can also be a vector format used (bTranslucent)
     646 [ -  + ][ #  # ]:         90 :             if ( !bVectorType && !rSettings.mbTranslucent )
     647                 :            :             {
     648                 :          0 :                 long nWidthPix = 0;
     649                 :          0 :                 long nHeightPix = 0;
     650 [ #  # ][ #  # ]:          0 :                 if ( rSettings.mnWidth > 0 && rSettings.mnHeight > 0 )
     651                 :            :                 {
     652                 :          0 :                     nWidthPix = rSettings.mnWidth;
     653                 :          0 :                     nHeightPix = rSettings.mnHeight;
     654                 :            :                 }
     655                 :            :                 else
     656                 :            :                 {
     657 [ #  # ][ #  # ]:          0 :                     const Size aSizePix( Application::GetDefaultDevice()->LogicToPixel( aSize, aMap ) );
     658 [ #  # ][ #  # ]:          0 :                     if (aSizePix.Width() > MAX_EXT_PIX || aSizePix.Height() > MAX_EXT_PIX)
                 [ #  # ]
     659                 :            :                     {
     660         [ #  # ]:          0 :                         if (aSizePix.Width() > MAX_EXT_PIX)
     661                 :          0 :                             nWidthPix = MAX_EXT_PIX;
     662                 :            :                         else
     663                 :          0 :                             nWidthPix = aSizePix.Width();
     664         [ #  # ]:          0 :                         if (aSizePix.Height() > MAX_EXT_PIX)
     665                 :          0 :                             nHeightPix = MAX_EXT_PIX;
     666                 :            :                         else
     667                 :          0 :                             nHeightPix = aSizePix.Height();
     668                 :            : 
     669                 :          0 :                         double fWidthDif = aSizePix.Width() / nWidthPix;
     670                 :          0 :                         double fHeightDif = aSizePix.Height() / nHeightPix;
     671                 :            : 
     672         [ #  # ]:          0 :                         if (fWidthDif > fHeightDif)
     673                 :          0 :                             nHeightPix = static_cast<long>(aSizePix.Height() / fWidthDif);
     674                 :            :                         else
     675                 :          0 :                             nWidthPix = static_cast<long>(aSizePix.Width() / fHeightDif);
     676                 :            :                     }
     677                 :            :                     else
     678                 :            :                     {
     679                 :          0 :                         nWidthPix = aSizePix.Width();
     680                 :          0 :                         nHeightPix = aSizePix.Height();
     681                 :            :                     }
     682                 :            :                 }
     683                 :            : 
     684                 :          0 :                 boost::scoped_ptr< SdrView > pLocalView;
     685 [ #  # ][ #  # ]:          0 :                 if( PTR_CAST( FmFormModel, mpDoc ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     686                 :            :                 {
     687 [ #  # ][ #  # ]:          0 :                     pLocalView.reset( new FmFormView( PTR_CAST( FmFormModel, mpDoc ), &aVDev ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     688                 :            :                 }
     689                 :            :                 else
     690                 :            :                 {
     691 [ #  # ][ #  # ]:          0 :                     pLocalView.reset( new SdrView( mpDoc, &aVDev ) );
                 [ #  # ]
     692                 :            :                 }
     693                 :            : 
     694                 :            : 
     695         [ #  # ]:          0 :                 VirtualDevice*  pVDev = CreatePageVDev( pPage, nWidthPix, nHeightPix );
     696                 :            : 
     697         [ #  # ]:          0 :                 if( pVDev )
     698                 :            :                 {
     699 [ #  # ][ #  # ]:          0 :                     aGraphic = pVDev->GetBitmap( Point(), pVDev->GetOutputSize() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     700         [ #  # ]:          0 :                     aGraphic.SetPrefMapMode( aMap );
     701         [ #  # ]:          0 :                     aGraphic.SetPrefSize( aSize );
     702 [ #  # ][ #  # ]:          0 :                     delete pVDev;
     703         [ #  # ]:          0 :                 }
     704                 :            :             }
     705                 :            :             // create a metafile to export a vector format
     706                 :            :             else
     707                 :            :             {
     708         [ +  - ]:         90 :                 GDIMetaFile aMtf;
     709                 :            : 
     710         [ +  - ]:         90 :                 aVDev.SetMapMode( aMap );
     711         [ -  + ]:         90 :                 if( rSettings.mbUseHighContrast )
     712         [ #  # ]:          0 :                     aVDev.SetDrawMode( aVDev.GetDrawMode() | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
     713         [ +  - ]:         90 :                 aVDev.EnableOutput( sal_False );
     714         [ +  - ]:         90 :                 aMtf.Record( &aVDev );
     715                 :         90 :                 Size aNewSize;
     716                 :            : 
     717                 :            :                 // create a view
     718                 :         90 :                 boost::scoped_ptr< SdrView > pView;
     719 [ +  - ][ +  - ]:         90 :                 if( PTR_CAST( FmFormModel, mpDoc ) )
         [ -  + ][ #  # ]
         [ -  + ][ +  - ]
     720                 :            :                 {
     721 [ #  # ][ #  # ]:          0 :                     pView.reset(new FmFormView( PTR_CAST( FmFormModel, mpDoc ), &aVDev ));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     722                 :            :                 }
     723                 :            :                 else
     724                 :            :                 {
     725 [ +  - ][ +  - ]:         90 :                     pView.reset(new SdrView( mpDoc, &aVDev ));
                 [ +  - ]
     726                 :            :                 }
     727                 :            : 
     728         [ +  - ]:         90 :                 pView->SetBordVisible( sal_False );
     729         [ +  - ]:         90 :                 pView->SetPageVisible( sal_False );
     730         [ +  - ]:         90 :                 pView->ShowSdrPage( pPage );
     731                 :            : 
     732 [ +  - ][ +  - ]:         90 :                 const Point aNewOrg( pPage->GetLftBorder(), pPage->GetUppBorder() );
     733 [ +  - ][ +  - ]:         90 :                 aNewSize = Size( aSize.Width() - pPage->GetLftBorder() - pPage->GetRgtBorder(),
     734 [ +  - ][ +  - ]:        180 :                                  aSize.Height() - pPage->GetUppBorder() - pPage->GetLwrBorder() );
     735         [ +  - ]:         90 :                 const Rectangle aClipRect( aNewOrg, aNewSize );
     736         [ +  - ]:         90 :                 MapMode         aVMap( aMap );
     737                 :            : 
     738         [ +  - ]:         90 :                 aVDev.Push();
     739         [ +  - ]:         90 :                 aVMap.SetOrigin( Point( -aNewOrg.X(), -aNewOrg.Y() ) );
     740         [ +  - ]:         90 :                 aVDev.SetRelativeMapMode( aVMap );
     741         [ +  - ]:         90 :                 aVDev.IntersectClipRegion( aClipRect );
     742                 :            : 
     743                 :            :                 // Use new StandardCheckVisisbilityRedirector
     744         [ +  - ]:         90 :                 ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
     745                 :            : 
     746 [ +  - ][ +  - ]:         90 :                 pView->CompleteRedraw(&aVDev, Region(Rectangle(Point(), aNewSize)), &aRedirector);
         [ +  - ][ +  - ]
     747                 :            : 
     748         [ +  - ]:         90 :                 aVDev.Pop();
     749                 :            : 
     750         [ +  - ]:         90 :                 aMtf.Stop();
     751         [ +  - ]:         90 :                 aMtf.WindStart();
     752         [ +  - ]:         90 :                 aMtf.SetPrefMapMode( aMap );
     753                 :         90 :                 aMtf.SetPrefSize( aNewSize );
     754                 :            : 
     755                 :            :                 // AW: Here the current version was filtering out the META_CLIPREGION_ACTIONs
     756                 :            :                 // from the metafile. I asked some other developers why this was done, but no
     757                 :            :                 // one knew a direct reason. Since it's in for long time, it may be an old
     758                 :            :                 // piece of code. MetaFiles save and load ClipRegions with polygons with preserving
     759                 :            :                 // the polygons, so a resolution-indepent roundtrip is supported. Removed this
     760                 :            :                 // code since it destroys some MetaFiles where ClipRegions are used. Anyways,
     761                 :            :                 // just filtering them out is a hack, at least the encapsulated content would need
     762                 :            :                 // to be clipped geometrically.
     763 [ +  - ][ +  - ]:         90 :                 aGraphic = Graphic(aMtf);
                 [ +  - ]
     764                 :            : 
     765         [ +  - ]:         90 :                 pView->HideSdrPage();
     766                 :            : 
     767         [ -  + ]:         90 :                 if( rSettings.mbTranslucent )
     768                 :            :                 {
     769                 :          0 :                     Size aOutSize;
     770 [ #  # ][ #  # ]:          0 :                     aGraphic = GetBitmapFromMetaFile( aGraphic.GetGDIMetaFile(), sal_True, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aNewSize, aOutSize ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     771 [ +  - ][ +  - ]:         90 :                 }
         [ +  - ][ +  - ]
     772                 :            :             }
     773                 :            :         }
     774                 :            :     }
     775                 :            : 
     776                 :            :     // export only single shape or shape collection
     777                 :            :     else
     778                 :            :     {
     779                 :            :         // build list of SdrObject
     780         [ #  # ]:          0 :         if( mxShapes.is() )
     781                 :            :         {
     782                 :          0 :             Reference< XShape > xShape;
     783 [ #  # ][ #  # ]:          0 :             const sal_Int32 nCount = mxShapes->getCount();
     784                 :            : 
     785         [ #  # ]:          0 :             for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
     786                 :            :             {
     787 [ #  # ][ #  # ]:          0 :                 mxShapes->getByIndex( nIndex ) >>= xShape;
                 [ #  # ]
     788                 :          0 :                 SdrObject* pObj = GetSdrObjectFromXShape( xShape );
     789         [ #  # ]:          0 :                 if( pObj )
     790         [ #  # ]:          0 :                     aShapes.push_back( pObj );
     791                 :          0 :             }
     792                 :            :         }
     793                 :            :         else
     794                 :            :         {
     795                 :            :             // only one shape
     796                 :          0 :             SdrObject* pObj = GetSdrObjectFromXShape( mxShape );
     797         [ #  # ]:          0 :             if( pObj )
     798         [ #  # ]:          0 :                 aShapes.push_back( pObj );
     799                 :            :         }
     800                 :            : 
     801         [ #  # ]:          0 :         if( aShapes.empty() )
     802                 :          0 :             bRet = false;
     803                 :            :     }
     804                 :            : 
     805 [ +  - ][ -  + ]:         90 :     if( bRet && !aShapes.empty() )
                 [ -  + ]
     806                 :            :     {
     807                 :            :         // special treatment for only one SdrGrafObj that has text
     808                 :          0 :         sal_Bool bSingleGraphic = sal_False;
     809                 :            : 
     810         [ #  # ]:          0 :         if( 1 == aShapes.size() )
     811                 :            :         {
     812         [ #  # ]:          0 :             if( !bVectorType )
     813                 :            :             {
     814         [ #  # ]:          0 :                 SdrObject* pObj = aShapes.front();
     815 [ #  # ][ #  # ]:          0 :                 if( pObj && pObj->ISA( SdrGrafObj ) && !( (SdrGrafObj*) pObj )->HasText() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     816                 :            :                 {
     817 [ #  # ][ #  # ]:          0 :                     aGraphic = ( (SdrGrafObj*) pObj )->GetTransformedGraphic();
                 [ #  # ]
     818 [ #  # ][ #  # ]:          0 :                     if ( aGraphic.GetType() == GRAPHIC_BITMAP )
     819                 :            :                     {
     820         [ #  # ]:          0 :                         Size aSizePixel( aGraphic.GetSizePixel() );
     821 [ #  # ][ #  #  :          0 :                         if( rSettings.mnWidth && rSettings.mnHeight &&
             #  #  #  # ]
                 [ #  # ]
     822                 :          0 :                             ( ( rSettings.mnWidth != aSizePixel.Width() ) ||
     823                 :          0 :                               ( rSettings.mnHeight != aSizePixel.Height() ) ) )
     824                 :            :                         {
     825         [ #  # ]:          0 :                             BitmapEx aBmpEx( aGraphic.GetBitmapEx() );
     826         [ #  # ]:          0 :                             aBmpEx.Scale( Size( rSettings.mnWidth, rSettings.mnHeight ) );
     827 [ #  # ][ #  # ]:          0 :                             aGraphic = aBmpEx;
         [ #  # ][ #  # ]
     828                 :            :                         }
     829                 :            :                     }
     830                 :          0 :                     bSingleGraphic = sal_True;
     831                 :            :                 }
     832                 :            :             }
     833         [ #  # ]:          0 :             else if( rSettings.mbScrollText )
     834                 :            :             {
     835         [ #  # ]:          0 :                 SdrObject* pObj = aShapes.front();
     836 [ #  # ][ #  # ]:          0 :                 if( pObj && pObj->ISA( SdrTextObj )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     837         [ #  # ]:          0 :                     && ( (SdrTextObj*) pObj )->HasText() )
     838                 :            :                 {
     839         [ #  # ]:          0 :                     Rectangle aScrollRectangle;
     840         [ #  # ]:          0 :                     Rectangle aPaintRectangle;
     841                 :            : 
     842                 :            :                     const boost::scoped_ptr< GDIMetaFile > pMtf(
     843                 :            :                         ( (SdrTextObj*) pObj )->GetTextScrollMetaFileAndRectangle(
     844         [ #  # ]:          0 :                         aScrollRectangle, aPaintRectangle ) );
     845                 :            : 
     846                 :            :                     // take the larger one of the two rectangles (that
     847                 :            :                     // should be the bound rect of the retrieved
     848                 :            :                     // metafile)
     849         [ #  # ]:          0 :                     Rectangle aTextRect;
     850                 :            : 
     851 [ #  # ][ #  # ]:          0 :                     if( aScrollRectangle.IsInside( aPaintRectangle ) )
     852                 :          0 :                         aTextRect = aScrollRectangle;
     853                 :            :                     else
     854                 :          0 :                         aTextRect = aPaintRectangle;
     855                 :            : 
     856                 :            :                     // setup pref size and mapmode
     857         [ #  # ]:          0 :                     pMtf->SetPrefSize( aTextRect.GetSize() );
     858                 :            : 
     859                 :            :                     // set actual origin (mtf is at actual shape
     860                 :            :                     // output position)
     861         [ #  # ]:          0 :                     MapMode aLocalMapMode( aMap );
     862                 :            :                     aLocalMapMode.SetOrigin(
     863                 :          0 :                         Point( -aPaintRectangle.Left(),
     864         [ #  # ]:          0 :                                -aPaintRectangle.Top() ) );
     865         [ #  # ]:          0 :                     pMtf->SetPrefMapMode( aLocalMapMode );
     866                 :            : 
     867                 :            :                     pMtf->AddAction( new MetaCommentAction(
     868                 :            :                                          "XTEXT_SCROLLRECT", 0,
     869                 :            :                                          reinterpret_cast<sal_uInt8 const*>(&aScrollRectangle),
     870 [ #  # ][ #  # ]:          0 :                                          sizeof( Rectangle ) ) );
                 [ #  # ]
     871                 :            :                     pMtf->AddAction( new MetaCommentAction(
     872                 :            :                                          "XTEXT_PAINTRECT", 0,
     873                 :            :                                          reinterpret_cast<sal_uInt8 const*>(&aPaintRectangle),
     874 [ #  # ][ #  # ]:          0 :                                          sizeof( Rectangle ) ) );
                 [ #  # ]
     875                 :            : 
     876 [ #  # ][ #  # ]:          0 :                     aGraphic = Graphic( *pMtf );
                 [ #  # ]
     877                 :            : 
     878 [ #  # ][ #  # ]:          0 :                     bSingleGraphic = sal_True;
     879                 :            :                 }
     880                 :            :             }
     881                 :            :         }
     882                 :            : 
     883         [ #  # ]:          0 :         if( !bSingleGraphic )
     884                 :            :         {
     885                 :            :             // create a metafile for all shapes
     886         [ #  # ]:          0 :             VirtualDevice   aOut;
     887                 :            : 
     888                 :            :             // calculate bound rect for all shapes
     889         [ #  # ]:          0 :             Rectangle aBound;
     890                 :            : 
     891                 :            :             {
     892                 :          0 :                 std::vector< SdrObject* >::iterator aIter = aShapes.begin();
     893                 :          0 :                 const std::vector< SdrObject* >::iterator aEnd = aShapes.end();
     894                 :            : 
     895 [ #  # ][ #  # ]:          0 :                 while( aIter != aEnd )
     896                 :            :                 {
     897 [ #  # ][ #  # ]:          0 :                     SdrObject* pObj = (*aIter++);
     898         [ #  # ]:          0 :                     Rectangle aR1(pObj->GetCurrentBoundRect());
     899 [ #  # ][ #  # ]:          0 :                     if (aBound.IsEmpty())
     900                 :          0 :                         aBound=aR1;
     901                 :            :                     else
     902         [ #  # ]:          0 :                         aBound.Union(aR1);
     903                 :            :                 }
     904                 :            :             }
     905                 :            : 
     906         [ #  # ]:          0 :             aOut.EnableOutput( sal_False );
     907         [ #  # ]:          0 :             aOut.SetMapMode( aMap );
     908         [ #  # ]:          0 :             if( rSettings.mbUseHighContrast )
     909         [ #  # ]:          0 :                 aOut.SetDrawMode( aVDev.GetDrawMode() | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
     910                 :            : 
     911         [ #  # ]:          0 :             GDIMetaFile aMtf;
     912         [ #  # ]:          0 :             aMtf.Clear();
     913         [ #  # ]:          0 :             aMtf.Record( &aOut );
     914                 :            : 
     915         [ #  # ]:          0 :             MapMode aOutMap( aMap );
     916         [ #  # ]:          0 :             aOutMap.SetOrigin( Point( -aBound.TopLeft().X(), -aBound.TopLeft().Y() ) );
     917         [ #  # ]:          0 :             aOut.SetRelativeMapMode( aOutMap );
     918                 :            : 
     919         [ #  # ]:          0 :             sdr::contact::DisplayInfo aDisplayInfo;
     920                 :            : 
     921         [ #  # ]:          0 :             if(mpCurrentPage)
     922                 :            :             {
     923 [ #  # ][ #  # ]:          0 :                 if(mpCurrentPage->TRG_HasMasterPage() && pPage->IsMasterPage())
                 [ #  # ]
     924                 :            :                 {
     925                 :            :                     // MasterPage is processed as another page's SubContent
     926 [ #  # ][ #  # ]:          0 :                     aDisplayInfo.SetProcessLayers(mpCurrentPage->TRG_GetMasterPageVisibleLayers());
     927         [ #  # ]:          0 :                     aDisplayInfo.SetSubContentActive(true);
     928                 :            :                 }
     929                 :            :             }
     930                 :            : 
     931         [ #  # ]:          0 :             if(!aShapes.empty())
     932                 :            :             {
     933                 :            :                 // more effective way to paint a vector of SdrObjects. Hand over the processed page
     934                 :            :                 // to have it in the
     935         [ #  # ]:          0 :                 sdr::contact::ObjectContactOfObjListPainter aMultiObjectPainter(aOut, aShapes, mpCurrentPage);
     936         [ #  # ]:          0 :                 ImplExportCheckVisisbilityRedirector aCheckVisibilityRedirector(mpCurrentPage);
     937         [ #  # ]:          0 :                 aMultiObjectPainter.SetViewObjectContactRedirector(&aCheckVisibilityRedirector);
     938                 :            : 
     939 [ #  # ][ #  # ]:          0 :                 aMultiObjectPainter.ProcessDisplay(aDisplayInfo);
                 [ #  # ]
     940                 :            :             }
     941                 :            : 
     942         [ #  # ]:          0 :             aMtf.Stop();
     943         [ #  # ]:          0 :             aMtf.WindStart();
     944                 :            : 
     945         [ #  # ]:          0 :             const Size  aExtSize( aOut.PixelToLogic( Size( 0, 0  ) ) );
     946         [ #  # ]:          0 :             Size        aBoundSize( aBound.GetWidth() + ( aExtSize.Width() ),
     947         [ #  # ]:          0 :                                     aBound.GetHeight() + ( aExtSize.Height() ) );
     948                 :            : 
     949         [ #  # ]:          0 :             aMtf.SetPrefMapMode( aMap );
     950                 :          0 :             aMtf.SetPrefSize( aBoundSize );
     951                 :            : 
     952         [ #  # ]:          0 :             if( !bVectorType )
     953                 :            :             {
     954                 :          0 :                 Size aOutSize;
     955 [ #  # ][ #  # ]:          0 :                 aGraphic = GetBitmapFromMetaFile( aMtf, rSettings.mbTranslucent, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aBoundSize, aOutSize ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     956                 :            :             }
     957                 :            :             else
     958                 :            :             {
     959 [ #  # ][ #  # ]:          0 :                 aGraphic = aMtf;
                 [ #  # ]
     960 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
     961                 :            :         }
     962                 :            :     }
     963                 :            : 
     964         [ -  + ]:         90 :     if(pTempBackgroundShape)
     965                 :            :     {
     966         [ #  # ]:          0 :         SdrObject::Free(pTempBackgroundShape);
     967                 :            :     }
     968                 :            : 
     969                 :         90 :     rOutl.SetCalcFieldValueHdl( maOldCalcFieldValueHdl );
     970                 :            : 
     971                 :            :     // #i102251#
     972         [ +  - ]:         90 :     rOutl.SetControlWord(nOldCntrl);
     973                 :            : 
     974 [ +  - ][ +  - ]:         90 :     return bRet;
     975                 :            : 
     976                 :            : }
     977                 :            : 
     978                 :            : // XFilter
     979                 :         90 : sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDescriptor )
     980                 :            :     throw(RuntimeException)
     981                 :            : {
     982                 :            :     RTL_LOGFILE_CONTEXT( aLog, "UnoGraphicExporter::export (thb)" );
     983                 :            : 
     984         [ +  - ]:         90 :     ::SolarMutexGuard aGuard;
     985                 :            : 
     986         [ -  + ]:         90 :     if( NULL == mpUnoPage )
     987                 :          0 :         return sal_False;
     988                 :            : 
     989 [ +  - ][ -  + ]:         90 :     if( NULL == mpUnoPage->GetSdrPage() || NULL == mpDoc )
                 [ -  + ]
     990                 :          0 :         return sal_False;
     991                 :            : 
     992         [ +  - ]:         90 :     GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
     993                 :            : 
     994                 :            :     // get the arguments from the descriptor
     995         [ +  - ]:         90 :     ExportSettings aSettings( mpDoc );
     996         [ +  - ]:         90 :     ParseSettings( aDescriptor, aSettings );
     997                 :            : 
     998                 :         90 :     const sal_uInt16    nFilter = !aSettings.maMediaType.isEmpty()
     999 [ #  # ][ -  + ]:         90 :                             ? rFilter.GetExportFormatNumberForMediaType( aSettings.maMediaType )
         [ #  # ][ #  # ]
    1000 [ #  # ][ +  - ]:         90 :                             : rFilter.GetExportFormatNumberForShortName( aSettings.maFilterName );
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
                 [ -  + ]
    1001         [ +  - ]:         90 :     sal_Bool            bVectorType = !rFilter.IsExportPixelFormat( nFilter );
    1002                 :            : 
    1003                 :            :     // create the output stuff
    1004         [ +  - ]:         90 :     Graphic aGraphic;
    1005                 :            : 
    1006 [ +  - ][ +  - ]:         90 :     sal_uInt16 nStatus = GetGraphic( aSettings, aGraphic, bVectorType ) ? GRFILTER_OK : GRFILTER_FILTERERROR;
    1007                 :            : 
    1008         [ +  - ]:         90 :     if( nStatus == GRFILTER_OK )
    1009                 :            :     {
    1010                 :            :         // export graphic only if it has a size
    1011         [ +  - ]:         90 :         const Size aGraphSize( aGraphic.GetPrefSize() );
    1012 [ +  - ][ -  + ]:         90 :         if ( ( aGraphSize.Width() == 0 ) || ( aGraphSize.Height() == 0 ) )
                 [ -  + ]
    1013                 :            :         {
    1014                 :          0 :             nStatus = GRFILTER_FILTERERROR;
    1015                 :            :         }
    1016                 :            :         else
    1017                 :            :         {
    1018                 :            :             // now we have a graphic, so export it
    1019         [ -  + ]:         90 :             if( aSettings.mxGraphicRenderer.is() )
    1020                 :            :             {
    1021                 :            :                 // render graphic directly into given renderer
    1022 [ #  # ][ #  # ]:          0 :                 aSettings.mxGraphicRenderer->render( aGraphic.GetXGraphic() );
                 [ #  # ]
    1023                 :            :             }
    1024         [ +  - ]:         90 :             else if( aSettings.mxOutputStream.is() )
    1025                 :            :             {
    1026                 :            :                 // TODO: Either utilize optional XSeekable functionality for the
    1027                 :            :                 // SvOutputStream, or adapt the graphic filter to not seek anymore.
    1028         [ +  - ]:         90 :                 SvMemoryStream aStream( 1024, 1024 );
    1029                 :            : 
    1030 [ +  - ][ +  - ]:         90 :                 nStatus = rFilter.ExportGraphic( aGraphic, String(), aStream, nFilter, &aSettings.maFilterData );
                 [ +  - ]
    1031                 :            : 
    1032                 :            :                 // copy temp stream to XOutputStream
    1033         [ +  - ]:         90 :                 SvOutputStream aOutputStream( aSettings.mxOutputStream );
    1034         [ +  - ]:         90 :                 aStream.Seek(0);
    1035 [ +  - ][ +  - ]:         90 :                 aOutputStream << aStream;
                 [ +  - ]
    1036                 :            :             }
    1037                 :            :             else
    1038                 :            :             {
    1039         [ #  # ]:          0 :                 INetURLObject aURLObject( aSettings.maURL.Complete );
    1040                 :            :                 DBG_ASSERT( aURLObject.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
    1041                 :            : 
    1042 [ #  # ][ #  # ]:         90 :                 nStatus = XOutBitmap::ExportGraphic( aGraphic, aURLObject, rFilter, nFilter, &aSettings.maFilterData );
    1043                 :            :             }
    1044                 :            :         }
    1045                 :            :     }
    1046                 :            : 
    1047 [ -  + ][ #  # ]:         90 :     if ( aSettings.mxInteractionHandler.is() && ( nStatus != GRFILTER_OK ) )
                 [ -  + ]
    1048                 :            :     {
    1049                 :          0 :         Any aInteraction;
    1050         [ #  # ]:          0 :         Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > lContinuations(1);
    1051         [ #  # ]:          0 :         ::comphelper::OInteractionApprove* pApprove = new ::comphelper::OInteractionApprove();
    1052 [ #  # ][ #  # ]:          0 :         lContinuations[0] = Reference< XInteractionContinuation >(static_cast< XInteractionContinuation* >(pApprove), UNO_QUERY);
         [ #  # ][ #  # ]
    1053                 :            : 
    1054         [ #  # ]:          0 :         GraphicFilterRequest aErrorCode;
    1055                 :          0 :         aErrorCode.ErrCode = nStatus;
    1056         [ #  # ]:          0 :         aInteraction <<= aErrorCode;
    1057 [ #  # ][ #  # ]:          0 :         aSettings.mxInteractionHandler->handle( framework::InteractionRequest::CreateRequest( aInteraction, lContinuations ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1058                 :            :     }
    1059 [ +  - ][ +  - ]:         90 :     return nStatus == GRFILTER_OK;
                 [ +  - ]
    1060                 :            : }
    1061                 :            : 
    1062                 :          0 : void SAL_CALL GraphicExporter::cancel()
    1063                 :            :     throw(RuntimeException)
    1064                 :            : {
    1065                 :          0 : }
    1066                 :            : 
    1067                 :            : // XExporter
    1068                 :            : 
    1069                 :            : /** the source 'document' could be a XDrawPage, a XShape or a generic XShapes */
    1070                 :         90 : void SAL_CALL GraphicExporter::setSourceDocument( const Reference< lang::XComponent >& xComponent )
    1071                 :            :     throw(IllegalArgumentException, RuntimeException)
    1072                 :            : {
    1073         [ +  - ]:         90 :     ::SolarMutexGuard aGuard;
    1074                 :            : 
    1075         [ +  - ]:         90 :     mxShapes = NULL;
    1076                 :         90 :     mpUnoPage = NULL;
    1077                 :            : 
    1078                 :            :     try
    1079                 :            :     {
    1080                 :            :     // any break inside this one loop while will throw a IllegalArgumentException
    1081                 :            :     do
    1082                 :            :     {
    1083 [ +  - ][ +  - ]:         90 :         mxPage = Reference< XDrawPage >::query( xComponent );
    1084 [ +  - ][ +  - ]:         90 :         mxShapes = Reference< XShapes >::query( xComponent );
    1085 [ +  - ][ +  - ]:         90 :         mxShape = Reference< XShape >::query( xComponent );
    1086                 :            : 
    1087                 :            :         // Step 1: try a generic XShapes
    1088 [ #  # ][ #  # ]:         90 :         if( !mxPage.is() && !mxShape.is() && mxShapes.is() )
         [ -  + ][ -  + ]
    1089                 :            :         {
    1090                 :            :             // we do not support empty shape collections
    1091 [ #  # ][ #  # ]:          0 :             if( 0 == mxShapes->getCount() )
                 [ #  # ]
    1092                 :          0 :                 break;
    1093                 :            : 
    1094                 :            :             // get first shape to detect corresponding page and model
    1095 [ #  # ][ #  # ]:          0 :             mxShapes->getByIndex(0) >>= mxShape;
                 [ #  # ]
    1096                 :            :         }
    1097                 :            :         else
    1098                 :            :         {
    1099         [ +  - ]:         90 :             mxShapes = NULL;
    1100                 :            :         }
    1101                 :            : 
    1102                 :            :         // Step 2: try a shape
    1103         [ -  + ]:         90 :         if( mxShape.is() )
    1104                 :            :         {
    1105         [ #  # ]:          0 :             if( NULL == GetSdrObjectFromXShape( mxShape ) )
    1106                 :            :                 break;
    1107                 :            : 
    1108                 :            :             // get page for this shape
    1109         [ #  # ]:          0 :             Reference< XChild > xChild( mxShape, UNO_QUERY );
    1110         [ #  # ]:          0 :             if( !xChild.is() )
    1111                 :            :                 break;
    1112                 :            : 
    1113                 :          0 :             Reference< XInterface > xInt;
    1114         [ #  # ]:          0 :             do
           [ #  #  #  # ]
    1115                 :            :             {
    1116 [ #  # ][ #  # ]:          0 :                 xInt = xChild->getParent();
                 [ #  # ]
    1117 [ #  # ][ #  # ]:          0 :                 mxPage = Reference< XDrawPage >::query( xInt );
    1118         [ #  # ]:          0 :                 if( !mxPage.is() )
    1119 [ #  # ][ #  # ]:          0 :                     xChild = Reference< XChild >::query( xInt );
    1120                 :            :             }
    1121                 :          0 :             while( !mxPage.is() && xChild.is() );
    1122                 :            : 
    1123         [ #  # ]:          0 :             if( !mxPage.is() )
    1124 [ #  # ][ #  # ]:          0 :                 break;
    1125                 :            :         }
    1126                 :            : 
    1127                 :            :         // Step 3: check the page
    1128         [ -  + ]:         90 :         if( !mxPage.is() )
    1129                 :          0 :             break;
    1130                 :            : 
    1131         [ +  - ]:         90 :         mpUnoPage = SvxDrawPage::getImplementation( mxPage );
    1132                 :            : 
    1133 [ +  - ][ -  + ]:         90 :         if( NULL == mpUnoPage || NULL == mpUnoPage->GetSdrPage() )
                 [ -  + ]
    1134                 :          0 :             break;
    1135                 :            : 
    1136         [ +  - ]:         90 :         mpDoc = mpUnoPage->GetSdrPage()->GetModel();
    1137                 :            : 
    1138                 :            :         // Step 4:  If we got a generic XShapes test all contained shapes
    1139                 :            :         //          if they belong to the same XDrawPage
    1140                 :            : 
    1141         [ -  + ]:         90 :         if( mxShapes.is() )
    1142                 :            :         {
    1143                 :          0 :             SdrPage* pPage = mpUnoPage->GetSdrPage();
    1144                 :            :             SdrObject* pObj;
    1145                 :          0 :             Reference< XShape > xShape;
    1146                 :            : 
    1147                 :          0 :             sal_Bool bOk = sal_True;
    1148                 :            : 
    1149 [ #  # ][ #  # ]:          0 :             const sal_Int32 nCount = mxShapes->getCount();
    1150                 :            : 
    1151                 :            :             // test all but the first shape if they have the same page than
    1152                 :            :             // the first shape
    1153 [ #  # ][ #  # ]:          0 :             for( sal_Int32 nIndex = 1; bOk && ( nIndex < nCount ); nIndex++ )
                 [ #  # ]
    1154                 :            :             {
    1155 [ #  # ][ #  # ]:          0 :                 mxShapes->getByIndex( nIndex ) >>= xShape;
                 [ #  # ]
    1156                 :          0 :                 pObj = GetSdrObjectFromXShape( xShape );
    1157 [ #  # ][ #  # ]:          0 :                 bOk = pObj && pObj->GetPage() == pPage;
                 [ #  # ]
    1158                 :            :             }
    1159                 :            : 
    1160         [ #  # ]:          0 :             if( !bOk )
    1161 [ #  # ][ #  # ]:          0 :                 break;
    1162                 :            :         }
    1163                 :            : 
    1164                 :            :         // no errors so far
    1165                 :         90 :         return;
    1166                 :            :     }
    1167                 :            :     while( 0 );
    1168                 :            :     }
    1169         [ #  # ]:          0 :     catch( Exception& )
    1170                 :            :     {
    1171                 :            :     }
    1172                 :            : 
    1173 [ #  # ][ +  - ]:         90 :     throw IllegalArgumentException();
    1174                 :            : }
    1175                 :            : 
    1176                 :            : // XServiceInfo
    1177                 :          0 : OUString SAL_CALL GraphicExporter::getImplementationName(  )
    1178                 :            :     throw(RuntimeException)
    1179                 :            : {
    1180                 :          0 :     return GraphicExporter_getImplementationName();
    1181                 :            : }
    1182                 :            : 
    1183                 :          0 : sal_Bool SAL_CALL GraphicExporter::supportsService( const OUString& ServiceName )
    1184                 :            :     throw(RuntimeException)
    1185                 :            : {
    1186                 :          0 :     Sequence< OUString > aSeq( GraphicExporter_getSupportedServiceNames() );
    1187                 :          0 :     sal_Int32 nArgs = aSeq.getLength();
    1188                 :          0 :     const OUString* pService = aSeq.getConstArray();
    1189         [ #  # ]:          0 :     while( nArgs-- )
    1190         [ #  # ]:          0 :         if( *pService++ == ServiceName )
    1191                 :          0 :             return sal_True;
    1192                 :            : 
    1193         [ #  # ]:          0 :     return sal_False;
    1194                 :            : }
    1195                 :            : 
    1196                 :          0 : Sequence< OUString > SAL_CALL GraphicExporter::getSupportedServiceNames(  )
    1197                 :            :     throw(RuntimeException)
    1198                 :            : {
    1199                 :          0 :     return GraphicExporter_getSupportedServiceNames();
    1200                 :            : }
    1201                 :            : 
    1202                 :            : // XMimeTypeInfo
    1203                 :          0 : sal_Bool SAL_CALL GraphicExporter::supportsMimeType( const OUString& MimeTypeName ) throw (RuntimeException)
    1204                 :            : {
    1205         [ #  # ]:          0 :     const String aMimeTypeName( MimeTypeName );
    1206                 :            : 
    1207         [ #  # ]:          0 :     GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
    1208         [ #  # ]:          0 :     sal_uInt16 nCount = rFilter.GetExportFormatCount();
    1209                 :            :     sal_uInt16 nFilter;
    1210         [ #  # ]:          0 :     for( nFilter = 0; nFilter < nCount; nFilter++ )
    1211                 :            :     {
    1212 [ #  # ][ #  # ]:          0 :         if( aMimeTypeName.Equals( rFilter.GetExportFormatMediaType( nFilter ) ) )
         [ #  # ][ #  # ]
    1213                 :            :         {
    1214                 :          0 :             return sal_True;
    1215                 :            :         }
    1216                 :            :     }
    1217                 :            : 
    1218         [ #  # ]:          0 :     return sal_False;
    1219                 :            : }
    1220                 :            : 
    1221                 :          0 : Sequence< OUString > SAL_CALL GraphicExporter::getSupportedMimeTypeNames(  ) throw (RuntimeException)
    1222                 :            : {
    1223                 :          0 :     GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
    1224                 :          0 :     sal_uInt16 nCount = rFilter.GetExportFormatCount();
    1225                 :            :     sal_uInt16 nFilter;
    1226                 :          0 :     sal_uInt16 nFound = 0;
    1227                 :            : 
    1228                 :          0 :     Sequence< OUString > aSeq( nCount );
    1229         [ #  # ]:          0 :     OUString* pStr = aSeq.getArray();
    1230                 :            : 
    1231         [ #  # ]:          0 :     for( nFilter = 0; nFilter < nCount; nFilter++ )
    1232                 :            :     {
    1233 [ #  # ][ #  # ]:          0 :         OUString aMimeType( rFilter.GetExportFormatMediaType( nFilter ) );
                 [ #  # ]
    1234         [ #  # ]:          0 :         if( !aMimeType.isEmpty() )
    1235                 :            :         {
    1236                 :          0 :             *pStr++ = aMimeType;
    1237                 :          0 :             nFound++;
    1238                 :            :         }
    1239                 :          0 :     }
    1240                 :            : 
    1241         [ #  # ]:          0 :     if( nFound < nCount )
    1242         [ #  # ]:          0 :         aSeq.realloc( nFound );
    1243                 :            : 
    1244                 :          0 :     return aSeq;
    1245                 :            : }
    1246                 :            : 
    1247                 :          0 : Graphic SvxGetGraphicForShape( SdrObject& rShape, bool bVector )
    1248                 :            : {
    1249                 :          0 :     Graphic aGraphic;
    1250                 :            :     try
    1251                 :            :     {
    1252         [ #  # ]:          0 :         rtl::Reference< GraphicExporter > xExporter( new GraphicExporter() );
    1253 [ #  # ][ #  # ]:          0 :         Reference< XComponent > xComp( rShape.getUnoShape(), UNO_QUERY_THROW );
    1254         [ #  # ]:          0 :         xExporter->setSourceDocument( xComp );
    1255 [ #  # ][ #  # ]:          0 :         ExportSettings aSettings( rShape.GetModel() );
    1256 [ #  # ][ #  # ]:          0 :         xExporter->GetGraphic( aSettings, aGraphic, bVector );
                 [ #  # ]
    1257                 :            :     }
    1258         [ #  # ]:          0 :     catch( Exception& )
    1259                 :            :     {
    1260                 :            :         OSL_FAIL("SvxGetGraphicForShape(), exception caught!");
    1261                 :            :     }
    1262                 :          0 :     return aGraphic;
    1263                 :            : }
    1264                 :            : 
    1265                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10