LCOV - code coverage report
Current view: top level - libreoffice/svx/source/gallery2 - galobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 270 0.0 %
Date: 2012-12-17 Functions: 0 34 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      22             : #include <sfx2/objsh.hxx>
      23             : #include <sfx2/docfac.hxx>
      24             : 
      25             : #include <comphelper/classids.hxx>
      26             : #include <comphelper/string.hxx>
      27             : #include <unotools/pathoptions.hxx>
      28             : 
      29             : #include <tools/rcid.h>
      30             : #include <tools/vcompat.hxx>
      31             : #include <tools/helpers.hxx>
      32             : #include <vcl/virdev.hxx>
      33             : #include <svl/itempool.hxx>
      34             : #include <svx/fmmodel.hxx>
      35             : #include <svx/fmview.hxx>
      36             : #include <svx/fmpage.hxx>
      37             : #include "gallery.hrc"
      38             : #include "svx/galmisc.hxx"
      39             : #include "galobj.hxx"
      40             : #include <vcl/svapp.hxx>
      41             : 
      42             : #include "gallerydrawmodel.hxx"
      43             : 
      44             : using namespace ::com::sun::star;
      45             : 
      46             : // -------------
      47             : // - SgaObject -
      48             : // -------------
      49             : 
      50           0 : SgaObject::SgaObject() :
      51             :         bIsValid    ( sal_False ),
      52           0 :         bIsThumbBmp ( sal_True )
      53             : {
      54           0 : }
      55             : 
      56             : // ------------------------------------------------------------------------
      57             : 
      58           0 : sal_Bool SgaObject::CreateThumb( const Graphic& rGraphic )
      59             : {
      60           0 :     sal_Bool bRet = sal_False;
      61             : 
      62           0 :     if( rGraphic.GetType() == GRAPHIC_BITMAP )
      63             :     {
      64           0 :         BitmapEx    aBmpEx( rGraphic.GetBitmapEx() );
      65           0 :         Size        aBmpSize( aBmpEx.GetSizePixel() );
      66             : 
      67           0 :         if( aBmpSize.Width() && aBmpSize.Height() )
      68             :         {
      69           0 :             const Color aWhite( COL_WHITE );
      70             : 
      71           0 :             if( aBmpEx.GetPrefMapMode().GetMapUnit() != MAP_PIXEL &&
      72           0 :                 aBmpEx.GetPrefSize().Width() > 0 &&
      73           0 :                 aBmpEx.GetPrefSize().Height() > 0 )
      74             :             {
      75           0 :                 Size aLogSize( OutputDevice::LogicToLogic( aBmpEx.GetPrefSize(), aBmpEx.GetPrefMapMode(), MAP_100TH_MM ) );
      76             : 
      77           0 :                 if( aLogSize.Width() > 0 && aLogSize.Height() > 0 )
      78             :                 {
      79           0 :                     double  fFactorLog = static_cast< double >( aLogSize.Width() ) / aLogSize.Height();
      80           0 :                     double  fFactorPix = static_cast< double >( aBmpSize.Width() ) / aBmpSize.Height();
      81             : 
      82           0 :                     if( fFactorPix > fFactorLog )
      83           0 :                         aBmpSize.Width() = FRound( aBmpSize.Height() * fFactorLog );
      84             :                     else
      85           0 :                         aBmpSize.Height() = FRound( aBmpSize.Width() / fFactorLog );
      86             : 
      87           0 :                     aBmpEx.SetSizePixel( aBmpSize );
      88             :                 }
      89             :             }
      90             : 
      91           0 :             aThumbBmp = aBmpEx.GetBitmap( &aWhite );
      92             : 
      93           0 :             if( ( aBmpSize.Width() <= S_THUMB ) && ( aBmpSize.Height() <= S_THUMB ) )
      94             :             {
      95           0 :                 aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
      96           0 :                 bRet = sal_True;
      97             :             }
      98             :             else
      99             :             {
     100           0 :                 const float fFactor  = (float) aBmpSize.Width() / aBmpSize.Height();
     101             :                 const Size  aNewSize( Max( (long) (fFactor < 1. ? S_THUMB * fFactor : S_THUMB), 8L ),
     102           0 :                                       Max( (long) (fFactor < 1. ? S_THUMB : S_THUMB / fFactor), 8L ) );
     103             : 
     104           0 :                 if( aThumbBmp.Scale( (double) aNewSize.Width() / aBmpSize.Width(),
     105           0 :                                      (double) aNewSize.Height() / aBmpSize.Height(), BMP_SCALE_BEST ) )
     106             :                 {
     107           0 :                     aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
     108           0 :                     bRet = sal_True;
     109             :                 }
     110             :             }
     111           0 :         }
     112             :     }
     113           0 :     else if( rGraphic.GetType() == GRAPHIC_GDIMETAFILE )
     114             :     {
     115           0 :         const Size aPrefSize( rGraphic.GetPrefSize() );
     116           0 :         const double fFactor  = (double)aPrefSize.Width() / (double)aPrefSize.Height();
     117           0 :         Size aSize( S_THUMB, S_THUMB );
     118           0 :         if ( fFactor < 1.0 )
     119           0 :             aSize.Width() = (sal_Int32)( S_THUMB * fFactor );
     120             :         else
     121           0 :             aSize.Height() = (sal_Int32)( S_THUMB / fFactor );
     122             : 
     123           0 :         const GraphicConversionParameters aParameters(aSize);
     124           0 :         aThumbBmp = rGraphic.GetBitmap(aParameters);
     125             : 
     126           0 :         if( !aThumbBmp.IsEmpty() )
     127             :         {
     128           0 :             aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
     129           0 :             bRet = sal_True;
     130             :         }
     131             :     }
     132             : 
     133           0 :     return bRet;
     134             : }
     135             : 
     136             : // ------------------------------------------------------------------------
     137             : 
     138           0 : void SgaObject::WriteData( SvStream& rOut, const String& rDestDir ) const
     139             : {
     140             :     static const sal_uInt32 nInventor = COMPAT_FORMAT( 'S', 'G', 'A', '3' );
     141             : 
     142           0 :     rOut << nInventor << (sal_uInt16) 0x0004 << GetVersion() << (sal_uInt16) GetObjKind();
     143           0 :     rOut << bIsThumbBmp;
     144             : 
     145           0 :     if( bIsThumbBmp )
     146             :     {
     147           0 :         const sal_uInt16    nOldCompressMode = rOut.GetCompressMode();
     148           0 :         const sal_uIntPtr       nOldVersion = rOut.GetVersion();
     149             : 
     150           0 :         rOut.SetCompressMode( COMPRESSMODE_ZBITMAP );
     151           0 :         rOut.SetVersion( SOFFICE_FILEFORMAT_50 );
     152             : 
     153           0 :         rOut << aThumbBmp;
     154             : 
     155           0 :         rOut.SetVersion( nOldVersion );
     156           0 :         rOut.SetCompressMode( nOldCompressMode );
     157             :     }
     158             :     else
     159           0 :         rOut << aThumbMtf;
     160             : 
     161           0 :     String aURLWithoutDestDir = String(aURL.GetMainURL( INetURLObject::NO_DECODE ));
     162           0 :     aURLWithoutDestDir.SearchAndReplace(rDestDir, String());
     163           0 :     write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOut, aURLWithoutDestDir, RTL_TEXTENCODING_UTF8);
     164           0 : }
     165             : 
     166             : // ------------------------------------------------------------------------
     167             : 
     168           0 : void SgaObject::ReadData(SvStream& rIn, sal_uInt16& rReadVersion )
     169             : {
     170             :     sal_uInt32      nTmp32;
     171             :     sal_uInt16      nTmp16;
     172             : 
     173           0 :     rIn >> nTmp32 >> nTmp16 >> rReadVersion >> nTmp16 >> bIsThumbBmp;
     174             : 
     175           0 :     if( bIsThumbBmp )
     176           0 :         rIn >> aThumbBmp;
     177             :     else
     178           0 :         rIn >> aThumbMtf;
     179             : 
     180           0 :     rtl::OUString aTmpStr = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIn, RTL_TEXTENCODING_UTF8);
     181           0 :     aURL = INetURLObject(aTmpStr);
     182           0 : }
     183             : 
     184             : // ------------------------------------------------------------------------
     185             : 
     186           0 : const String SgaObject::GetTitle() const
     187             : {
     188           0 :     String aReturnValue( aTitle );
     189           0 :     if ( !getenv( "GALLERY_SHOW_PRIVATE_TITLE" ) )
     190             :     {
     191           0 :         if ( comphelper::string::getTokenCount(aReturnValue, ':') == 3 )
     192             :         {
     193           0 :             String      aPrivateInd  ( aReturnValue.GetToken( 0, ':' ) );
     194           0 :             String      aResourceName( aReturnValue.GetToken( 1, ':' ) );
     195           0 :             sal_Int32   nResId       ( aReturnValue.GetToken( 2, ':' ).ToInt32() );
     196           0 :             if ( aReturnValue.GetToken( 0, ':' ).EqualsAscii( "private" ) &&
     197           0 :                 aResourceName.Len() && ( nResId > 0 ) && ( nResId < 0x10000 ) )
     198             :             {
     199           0 :                 rtl::OString aMgrName(rtl::OUStringToOString(aResourceName, RTL_TEXTENCODING_UTF8));
     200             :                 ResMgr* pResMgr = ResMgr::CreateResMgr( aMgrName.getStr(),
     201           0 :                             Application::GetSettings().GetUILanguageTag().getLocale() );
     202           0 :                 if ( pResMgr )
     203             :                 {
     204           0 :                     ResId aResId( (sal_uInt16)nResId, *pResMgr );
     205           0 :                     aResId.SetRT( RSC_STRING );
     206           0 :                     if ( pResMgr->IsAvailable( aResId ) )
     207             :                     {
     208           0 :                         aReturnValue = aResId.toString();
     209             :                     }
     210           0 :                     delete pResMgr;
     211           0 :                 }
     212           0 :             }
     213             :         }
     214             :     }
     215           0 :     return aReturnValue;
     216             : }
     217             : 
     218             : // ------------------------------------------------------------------------
     219             : 
     220           0 : void SgaObject::SetTitle( const String& rTitle )
     221             : {
     222           0 :     aTitle = rTitle;
     223           0 : }
     224             : 
     225             : // ------------------------------------------------------------------------
     226             : 
     227           0 : SvStream& operator<<( SvStream& rOut, const SgaObject& rObj )
     228             : {
     229           0 :     rObj.WriteData( rOut, String() );
     230           0 :     return rOut;
     231             : }
     232             : 
     233             : // ------------------------------------------------------------------------
     234             : 
     235           0 : SvStream& operator>>( SvStream& rIn, SgaObject& rObj )
     236             : {
     237             :     sal_uInt16 nReadVersion;
     238             : 
     239           0 :     rObj.ReadData( rIn, nReadVersion );
     240           0 :     rObj.bIsValid = ( rIn.GetError() == ERRCODE_NONE );
     241             : 
     242           0 :     return rIn;
     243             : }
     244             : 
     245             : // ----------------
     246             : // - SgaObjectBmp -
     247             : // ----------------
     248             : 
     249           0 : SgaObjectBmp::SgaObjectBmp()
     250             : {
     251           0 : }
     252             : 
     253             : // ------------------------------------------------------------------------
     254             : 
     255           0 : SgaObjectBmp::SgaObjectBmp( const INetURLObject& rURL )
     256             : {
     257           0 :     Graphic aGraphic;
     258           0 :     String  aFilter;
     259             : 
     260           0 :     if ( SGA_IMPORT_NONE != GalleryGraphicImport( rURL, aGraphic, aFilter ) )
     261           0 :         Init( aGraphic, rURL );
     262           0 : }
     263             : 
     264             : // ------------------------------------------------------------------------
     265             : 
     266           0 : SgaObjectBmp::SgaObjectBmp( const Graphic& rGraphic, const INetURLObject& rURL, const String& )
     267             : {
     268           0 :     if( FileExists( rURL ) )
     269           0 :         Init( rGraphic, rURL );
     270           0 : }
     271             : 
     272             : // ------------------------------------------------------------------------
     273             : 
     274           0 : void SgaObjectBmp::Init( const Graphic& rGraphic, const INetURLObject& rURL )
     275             : {
     276           0 :     aURL = rURL;
     277           0 :     bIsValid = CreateThumb( rGraphic );
     278           0 : }
     279             : 
     280             : // ------------------------------------------------------------------------
     281             : 
     282           0 : void SgaObjectBmp::WriteData( SvStream& rOut, const String& rDestDir ) const
     283             : {
     284             :     // Version setzen
     285           0 :     SgaObject::WriteData( rOut, rDestDir );
     286             :     char aDummy[ 10 ];
     287           0 :     rOut.Write( aDummy, 10 );
     288           0 :     write_lenPrefixed_uInt8s_FromOString<sal_uInt16>(rOut, rtl::OString()); //dummy
     289           0 :     write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOut, aTitle, RTL_TEXTENCODING_UTF8);
     290           0 : }
     291             : 
     292             : // ------------------------------------------------------------------------
     293             : 
     294           0 : void SgaObjectBmp::ReadData( SvStream& rIn, sal_uInt16& rReadVersion )
     295             : {
     296             : 
     297           0 :     SgaObject::ReadData( rIn, rReadVersion );
     298           0 :     rIn.SeekRel( 10 ); // 16, 16, 32, 16
     299           0 :     read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rIn); //dummy
     300             : 
     301           0 :     if( rReadVersion >= 5 )
     302           0 :         aTitle = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIn, RTL_TEXTENCODING_UTF8);
     303           0 : }
     304             : 
     305             : // ------------------
     306             : // - SgaObjectSound -
     307             : // ------------------
     308             : DBG_NAME(SgaObjectSound)
     309             : 
     310           0 : SgaObjectSound::SgaObjectSound() :
     311           0 :     eSoundType( SOUND_STANDARD )
     312             : {
     313             :     DBG_CTOR(SgaObjectSound,NULL);
     314           0 : }
     315             : 
     316             : // ------------------------------------------------------------------------
     317             : 
     318           0 : SgaObjectSound::SgaObjectSound( const INetURLObject& rURL ) :
     319           0 :     eSoundType( SOUND_STANDARD )
     320             : {
     321             :     DBG_CTOR(SgaObjectSound,NULL);
     322             : 
     323           0 :     if( FileExists( rURL ) )
     324             :     {
     325           0 :         aURL = rURL;
     326           0 :         aThumbBmp = Bitmap( Size( 1, 1 ), 1 );
     327           0 :         bIsValid = sal_True;
     328             :     }
     329             :     else
     330           0 :         bIsValid = sal_False;
     331           0 : }
     332             : 
     333             : // ------------------------------------------------------------------------
     334             : 
     335           0 : SgaObjectSound::~SgaObjectSound()
     336             : {
     337             :     DBG_DTOR(SgaObjectSound,NULL);
     338           0 : }
     339             : 
     340             : // ------------------------------------------------------------------------
     341             : 
     342           0 : Bitmap SgaObjectSound::GetThumbBmp() const
     343             : {
     344             :     sal_uInt16 nId;
     345             : 
     346           0 :     switch( eSoundType )
     347             :     {
     348           0 :         case( SOUND_COMPUTER ): nId = RID_SVXBMP_GALLERY_SOUND_1; break;
     349           0 :         case( SOUND_MISC ): nId = RID_SVXBMP_GALLERY_SOUND_2; break;
     350           0 :         case( SOUND_MUSIC ): nId = RID_SVXBMP_GALLERY_SOUND_3; break;
     351           0 :         case( SOUND_NATURE ): nId = RID_SVXBMP_GALLERY_SOUND_4; break;
     352           0 :         case( SOUND_SPEECH ): nId = RID_SVXBMP_GALLERY_SOUND_5; break;
     353           0 :         case( SOUND_TECHNIC ): nId = RID_SVXBMP_GALLERY_SOUND_6; break;
     354           0 :         case( SOUND_ANIMAL ): nId = RID_SVXBMP_GALLERY_SOUND_7; break;
     355             : 
     356             :         // standard
     357             :         default:
     358           0 :              nId = RID_SVXBMP_GALLERY_MEDIA;
     359           0 :         break;
     360             :     }
     361             : 
     362           0 :     const BitmapEx  aBmpEx( GAL_RES( nId ) );
     363           0 :     const Color     aTransColor( COL_WHITE );
     364             : 
     365           0 :     return aBmpEx.GetBitmap( &aTransColor );
     366             : }
     367             : 
     368             : // ------------------------------------------------------------------------
     369             : 
     370           0 : void SgaObjectSound::WriteData( SvStream& rOut, const String& rDestDir ) const
     371             : {
     372           0 :     SgaObject::WriteData( rOut, rDestDir );
     373           0 :     rOut << (sal_uInt16) eSoundType;
     374           0 :     write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOut, aTitle, RTL_TEXTENCODING_UTF8);
     375           0 : }
     376             : 
     377             : // ------------------------------------------------------------------------
     378             : 
     379           0 : void SgaObjectSound::ReadData( SvStream& rIn, sal_uInt16& rReadVersion )
     380             : {
     381           0 :     SgaObject::ReadData( rIn, rReadVersion );
     382             : 
     383           0 :     if( rReadVersion >= 5 )
     384             :     {
     385             :         sal_uInt16      nTmp16;
     386             : 
     387           0 :         rIn >> nTmp16; eSoundType = (GalSoundType) nTmp16;
     388             : 
     389           0 :         if( rReadVersion >= 6 )
     390           0 :             aTitle = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIn, RTL_TEXTENCODING_UTF8);
     391             :     }
     392           0 : }
     393             : 
     394             : // -----------------
     395             : // - SgaObjectAnim -
     396             : // -----------------
     397             : 
     398           0 : SgaObjectAnim::SgaObjectAnim()
     399             : {
     400           0 : }
     401             : 
     402             : // ------------------------------------------------------------------------
     403             : 
     404           0 : SgaObjectAnim::SgaObjectAnim( const Graphic& rGraphic,
     405             :                               const INetURLObject& rURL,
     406           0 :                               const String& )
     407             : {
     408           0 :     aURL = rURL;
     409           0 :     bIsValid = CreateThumb( rGraphic );
     410           0 : }
     411             : 
     412             : // -----------------
     413             : // - SgaObjectINet -
     414             : // -----------------
     415             : 
     416           0 : SgaObjectINet::SgaObjectINet()
     417             : {
     418           0 : }
     419             : 
     420             : // ------------------------------------------------------------------------
     421             : 
     422           0 : SgaObjectINet::SgaObjectINet( const Graphic& rGraphic, const INetURLObject& rURL, const String& rFormatName ) :
     423           0 :             SgaObjectAnim   ( rGraphic, rURL, rFormatName )
     424             : {
     425           0 : }
     426             : 
     427             : // -------------------
     428             : // - SgaObjectSvDraw -
     429             : // -------------------
     430             : 
     431           0 : SgaObjectSvDraw::SgaObjectSvDraw()
     432             : {
     433           0 : }
     434             : 
     435             : // ------------------------------------------------------------------------
     436             : 
     437           0 : SgaObjectSvDraw::SgaObjectSvDraw( const FmFormModel& rModel, const INetURLObject& rURL )
     438             : {
     439           0 :     aURL = rURL;
     440           0 :     bIsValid = CreateThumb( rModel );
     441           0 : }
     442             : 
     443             : // ------------------------------------------------------------------------
     444             : DBG_NAME(SvxGalleryDrawModel)
     445             : 
     446           0 : SvxGalleryDrawModel::SvxGalleryDrawModel()
     447           0 : : mpFormModel( 0 )
     448             : {
     449             :     DBG_CTOR(SvxGalleryDrawModel,NULL);
     450             : 
     451           0 :     const String sFactoryURL(RTL_CONSTASCII_USTRINGPARAM("sdraw"));
     452             : 
     453           0 :     mxDoc = SfxObjectShell::CreateObjectByFactoryName( sFactoryURL );
     454             : 
     455           0 :     if( mxDoc.Is() )
     456             :     {
     457           0 :         mxDoc->DoInitNew(0);
     458             : 
     459           0 :         uno::Reference< lang::XUnoTunnel > xTunnel( mxDoc->GetModel(), uno::UNO_QUERY );
     460           0 :         if( xTunnel.is() )
     461             :         {
     462             :             mpFormModel = dynamic_cast< FmFormModel* >(
     463           0 :                 reinterpret_cast<SdrModel*>(xTunnel->getSomething(SdrModel::getUnoTunnelImplementationId())));
     464           0 :             if( mpFormModel )
     465             :             {
     466           0 :                 mpFormModel->InsertPage( mpFormModel->AllocPage( false ) );
     467             :             }
     468           0 :         }
     469           0 :     }
     470           0 : }
     471             : 
     472             : // ------------------------------------------------------------------------
     473             : 
     474           0 : SvxGalleryDrawModel::~SvxGalleryDrawModel()
     475             : {
     476           0 :     if( mxDoc.Is() )
     477           0 :         mxDoc->DoClose();
     478             : 
     479             :     DBG_DTOR(SvxGalleryDrawModel,NULL);
     480           0 : }
     481             : 
     482             : // ------------------------------------------------------------------------
     483             : 
     484           0 : SgaObjectSvDraw::SgaObjectSvDraw( SvStream& rIStm, const INetURLObject& rURL )
     485             : {
     486           0 :     SvxGalleryDrawModel aModel;
     487             : 
     488           0 :     if( aModel.GetModel() )
     489             :     {
     490           0 :         if( GallerySvDrawImport( rIStm, *aModel.GetModel()  ) )
     491             :         {
     492           0 :             aURL = rURL;
     493           0 :             bIsValid = CreateThumb( *aModel.GetModel()  );
     494             :         }
     495           0 :     }
     496           0 : }
     497             : 
     498             : // ------------------------------------------------------------------------
     499             : 
     500           0 : sal_Bool SgaObjectSvDraw::CreateThumb( const FmFormModel& rModel )
     501             : {
     502           0 :     Graphic     aGraphic;
     503           0 :     ImageMap    aImageMap;
     504           0 :     sal_Bool        bRet = sal_False;
     505             : 
     506           0 :     if ( CreateIMapGraphic( rModel, aGraphic, aImageMap ) )
     507           0 :         bRet = SgaObject::CreateThumb( aGraphic );
     508             :     else
     509             :     {
     510           0 :         VirtualDevice aVDev;
     511             : 
     512           0 :         aVDev.SetOutputSizePixel( Size( S_THUMB*2, S_THUMB*2 ) );
     513             : 
     514           0 :         bRet = DrawCentered( &aVDev, rModel );
     515           0 :         if( bRet )
     516             :         {
     517           0 :             aThumbBmp = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
     518             : 
     519           0 :             Size aMS( 2, 2 );
     520           0 :             BmpFilterParam aParam( aMS );
     521           0 :             aThumbBmp.Filter( BMP_FILTER_MOSAIC, &aParam );
     522           0 :             aThumbBmp.Scale( Size( S_THUMB, S_THUMB ) );
     523             : 
     524           0 :             aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
     525           0 :         }
     526             :     }
     527             : 
     528           0 :     return bRet;
     529             : }
     530             : 
     531             : // ------------------------------------------------------------------------
     532             : 
     533           0 : sal_Bool SgaObjectSvDraw::DrawCentered( OutputDevice* pOut, const FmFormModel& rModel )
     534             : {
     535           0 :     const FmFormPage*   pPage = static_cast< const FmFormPage* >( rModel.GetPage( 0 ) );
     536           0 :     sal_Bool                bRet = sal_False;
     537             : 
     538           0 :     if( pOut && pPage )
     539             :     {
     540           0 :         const Rectangle aObjRect( pPage->GetAllObjBoundRect() );
     541           0 :         const Size      aOutSizePix( pOut->GetOutputSizePixel() );
     542             : 
     543           0 :         if( aObjRect.GetWidth() && aObjRect.GetHeight() && aOutSizePix.Width() > 2 && aOutSizePix.Height() > 2 )
     544             :         {
     545           0 :             FmFormView      aView( const_cast< FmFormModel* >( &rModel ), pOut );
     546           0 :             MapMode         aMap( rModel.GetScaleUnit() );
     547           0 :             Rectangle       aDrawRectPix( Point( 1, 1 ), Size( aOutSizePix.Width() - 2, aOutSizePix.Height() - 2 ) );
     548           0 :             const double    fFactor  = (double) aObjRect.GetWidth() / aObjRect.GetHeight();
     549           0 :             Fraction        aFrac( FRound( fFactor < 1. ? aDrawRectPix.GetWidth() * fFactor : aDrawRectPix.GetWidth() ),
     550           0 :                                    pOut->LogicToPixel( aObjRect.GetSize(), aMap ).Width() );
     551             : 
     552           0 :             aMap.SetScaleX( aFrac );
     553           0 :             aMap.SetScaleY( aFrac );
     554             : 
     555           0 :             const Size aDrawSize( pOut->PixelToLogic( aDrawRectPix.GetSize(), aMap ) );
     556           0 :             Point aOrigin( pOut->PixelToLogic( aDrawRectPix.TopLeft(), aMap ) );
     557             : 
     558           0 :             aOrigin.X() += ( ( aDrawSize.Width() - aObjRect.GetWidth() ) >> 1 ) - aObjRect.Left();
     559           0 :             aOrigin.Y() += ( ( aDrawSize.Height() - aObjRect.GetHeight() ) >> 1 ) - aObjRect.Top();
     560           0 :             aMap.SetOrigin( aOrigin );
     561             : 
     562           0 :             aView.SetPageVisible( sal_False );
     563           0 :             aView.SetBordVisible( sal_False );
     564           0 :             aView.SetGridVisible( sal_False );
     565           0 :             aView.SetHlplVisible( sal_False );
     566           0 :             aView.SetGlueVisible( sal_False );
     567             : 
     568           0 :             pOut->Push();
     569           0 :             pOut->SetMapMode( aMap );
     570           0 :             aView.ShowSdrPage( const_cast< FmFormPage* >( pPage ));
     571           0 :             aView.CompleteRedraw( pOut, Rectangle( pOut->PixelToLogic( Point() ), pOut->GetOutputSize() ) );
     572           0 :             pOut->Pop();
     573             : 
     574           0 :             bRet = sal_True;
     575             :         }
     576             :     }
     577             : 
     578           0 :     return bRet;
     579             : }
     580             : 
     581             : // ------------------------------------------------------------------------
     582             : 
     583           0 : void SgaObjectSvDraw::WriteData( SvStream& rOut, const String& rDestDir ) const
     584             : {
     585           0 :     SgaObject::WriteData( rOut, rDestDir );
     586           0 :     write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOut, aTitle, RTL_TEXTENCODING_UTF8);
     587           0 : }
     588             : 
     589             : // ------------------------------------------------------------------------
     590             : 
     591           0 : void SgaObjectSvDraw::ReadData( SvStream& rIn, sal_uInt16& rReadVersion )
     592             : {
     593           0 :     SgaObject::ReadData( rIn, rReadVersion );
     594             : 
     595           0 :     if( rReadVersion >= 5 )
     596           0 :         aTitle = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIn, RTL_TEXTENCODING_UTF8);
     597           0 : }
     598             : 
     599             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10