LCOV - code coverage report
Current view: top level - svx/source/gallery2 - galmisc.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 33 255 12.9 %
Date: 2015-06-13 12:38:46 Functions: 6 29 20.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sal/config.h>
      21             : 
      22             : #include <sot/storage.hxx>
      23             : #include <unotools/streamwrap.hxx>
      24             : #include <unotools/ucbstreamhelper.hxx>
      25             : #include <comphelper/processfactory.hxx>
      26             : #include <comphelper/string.hxx>
      27             : #include <ucbhelper/content.hxx>
      28             : #include <tools/resmgr.hxx>
      29             : #include <tools/urlobj.hxx>
      30             : #include <svl/solar.hrc>
      31             : #include <svl/urihelper.hxx>
      32             : #include <vcl/graphicfilter.hxx>
      33             : #include <svl/itempool.hxx>
      34             : #include <sfx2/docfile.hxx>
      35             : #include <avmedia/mediawindow.hxx>
      36             : #include <vcl/svapp.hxx>
      37             : #include <vcl/settings.hxx>
      38             : #include <svx/svdpage.hxx>
      39             : #include <svx/svdograf.hxx>
      40             : #include <svx/fmmodel.hxx>
      41             : #include <svx/fmview.hxx>
      42             : #include <svx/unomodel.hxx>
      43             : #include "codec.hxx"
      44             : #include "gallery.hrc"
      45             : #include "svx/gallery1.hxx"
      46             : #include "svx/galtheme.hxx"
      47             : #include "svx/galmisc.hxx"
      48             : #include <com/sun/star/sdbc/XResultSet.hpp>
      49             : #include <com/sun/star/ucb/XContentAccess.hpp>
      50             : #include <com/sun/star/ucb/TransferInfo.hpp>
      51             : #include <com/sun/star/ucb/NameClash.hpp>
      52             : #include <boost/scoped_ptr.hpp>
      53             : 
      54             : using namespace ::com::sun::star;
      55             : 
      56           5 : ResMgr* GetGalleryResMgr()
      57             : {
      58             :     static ResMgr* pGalleryResMgr = NULL;
      59             : 
      60           5 :     if( !pGalleryResMgr )
      61             :     {
      62             :         pGalleryResMgr = ResMgr::CreateResMgr(
      63           1 :             "gal", Application::GetSettings().GetUILanguageTag() );
      64             :     }
      65             : 
      66           5 :     return pGalleryResMgr;
      67             : }
      68             : 
      69           0 : BitmapEx GalleryResGetBitmapEx( sal_uInt32 nId )
      70             : {
      71           0 :     BitmapEx aBmpEx( GAL_RES( nId ) );
      72             : 
      73           0 :     if( !aBmpEx.IsTransparent() )
      74           0 :             aBmpEx = BitmapEx( aBmpEx.GetBitmap(), COL_LIGHTMAGENTA );
      75             : 
      76           0 :     return aBmpEx;
      77             : }
      78             : 
      79           0 : IMPL_STATIC_LINK(
      80             :     SgaUserDataFactory, MakeUserData, SdrObjFactory*, pObjFactory )
      81             : {
      82           0 :     if ( pObjFactory->nInventor == IV_IMAPINFO && pObjFactory->nIdentifier == ID_IMAPINFO )
      83           0 :         pObjFactory->pNewData = new SgaIMapInfo;
      84             : 
      85           0 :     return 0L;
      86             : }
      87             : 
      88         503 : GalleryGraphicImportRet GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic,
      89             :                              OUString& rFilterName, bool bShowProgress )
      90             : {
      91         503 :     GalleryGraphicImportRet  nRet = GalleryGraphicImportRet::IMPORT_NONE;
      92         503 :     SfxMedium   aMedium( rURL.GetMainURL( INetURLObject::NO_DECODE ), StreamMode::READ );
      93             : 
      94         503 :     aMedium.Download();
      95             : 
      96         503 :     SvStream* pIStm = aMedium.GetInStream();
      97             : 
      98         503 :     if( pIStm )
      99             :     {
     100         503 :         GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
     101         503 :         boost::scoped_ptr<GalleryProgress> pProgress(bShowProgress ? new GalleryProgress( &rGraphicFilter ) : NULL);
     102             :         sal_uInt16              nFormat;
     103             : 
     104         503 :         if( !rGraphicFilter.ImportGraphic( rGraphic, rURL.GetMainURL( INetURLObject::NO_DECODE ), *pIStm, GRFILTER_FORMAT_DONTKNOW, &nFormat ) )
     105             :         {
     106         468 :             rFilterName = rGraphicFilter.GetImportFormatName( nFormat );
     107         468 :             nRet = GalleryGraphicImportRet::IMPORT_FILE;
     108         503 :         }
     109             :     }
     110             : 
     111         503 :     return nRet;
     112             : }
     113             : 
     114           0 : bool GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel )
     115             : {
     116             :     sal_uInt32  nVersion;
     117           0 :     bool        bRet = false;
     118             : 
     119           0 :     if( GalleryCodec::IsCoded( rIStm, nVersion ) )
     120             :     {
     121           0 :         SvMemoryStream  aMemStm( 65535, 65535 );
     122           0 :         GalleryCodec    aCodec( rIStm );
     123             : 
     124           0 :         aCodec.Read( aMemStm );
     125           0 :         aMemStm.Seek( 0UL );
     126             : 
     127           0 :         if( 1 == nVersion )
     128             :         {
     129             :             OSL_FAIL( "staroffice binary file formats are no longer supported inside the gallery!" );
     130           0 :             bRet = false;
     131             :         }
     132           0 :         else if( 2 == nVersion )
     133             :         {
     134             :             // recall to read as XML
     135           0 :             bRet = GallerySvDrawImport( aMemStm, rModel );
     136           0 :         }
     137             :      }
     138             :     else
     139             :     {
     140             :         // read as XML
     141           0 :         uno::Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( rIStm ) );
     142             : 
     143           0 :         rModel.GetItemPool().SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
     144           0 :         uno::Reference< lang::XComponent > xComponent;
     145             : 
     146           0 :         bRet = SvxDrawingLayerImport( &rModel, xInputStream, xComponent, "com.sun.star.comp.Draw.XMLOasisImporter" );
     147           0 :         if( !bRet || (rModel.GetPageCount() == 0) )
     148             :         {
     149           0 :             rIStm.Seek(0);
     150           0 :             bRet = SvxDrawingLayerImport( &rModel, xInputStream, xComponent, "com.sun.star.comp.Draw.XMLImporter" );
     151           0 :         }
     152             : 
     153             :     }
     154             : 
     155           0 :     return bRet;
     156             : }
     157             : 
     158           0 : bool CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap )
     159             : {
     160           0 :     bool bRet = false;
     161             : 
     162           0 :     if ( rModel.GetPageCount() )
     163             :     {
     164           0 :         const SdrPage*      pPage = rModel.GetPage( 0 );
     165           0 :         const SdrObject*    pObj = pPage->GetObj( 0 );
     166             : 
     167           0 :         if ( pPage->GetObjCount() == 1 && pObj->ISA( SdrGrafObj ) )
     168             :         {
     169           0 :             const sal_uInt16 nCount = pObj->GetUserDataCount();
     170             : 
     171             :             // Exist in the user data an IMap information?
     172           0 :             for ( sal_uInt16 i = 0; i < nCount; i++ )
     173             :             {
     174           0 :                 const SdrObjUserData* pUserData = pObj->GetUserData( i );
     175             : 
     176           0 :                 if ( ( pUserData->GetInventor() == IV_IMAPINFO ) && ( pUserData->GetId() == ID_IMAPINFO ) )
     177             :                 {
     178           0 :                     rGraphic = static_cast<const SdrGrafObj*>( pObj )->GetGraphic();
     179           0 :                     rImageMap = static_cast<const SgaIMapInfo*>( pUserData )->GetImageMap();
     180           0 :                     bRet = true;
     181           0 :                     break;
     182             :                 }
     183             :             }
     184             :         }
     185             :     }
     186             : 
     187           0 :     return bRet;
     188             : }
     189             : 
     190           0 : OUString GetReducedString( const INetURLObject& rURL, sal_Int32 nMaxLen )
     191             : {
     192           0 :     OUString aReduced( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) );
     193             : 
     194           0 :     aReduced = aReduced.getToken( comphelper::string::getTokenCount(aReduced, '/') - 1, '/' );
     195             : 
     196           0 :     if( INetProtocol::PrivSoffice != rURL.GetProtocol() )
     197             :     {
     198             :         sal_Unicode     aDelimiter;
     199           0 :         const OUString  aPath( rURL.getFSysPath( INetURLObject::FSYS_DETECT, &aDelimiter ) );
     200           0 :         const OUString  aName( aReduced );
     201             : 
     202           0 :         if( aPath.getLength() > nMaxLen )
     203             :         {
     204           0 :             sal_Int32 nPathPrefixLen = nMaxLen - aName.getLength() - 4;
     205             : 
     206           0 :             if (nPathPrefixLen >= 0)
     207             :             {
     208           0 :                 aReduced = aPath.copy(0, nPathPrefixLen);
     209           0 :                 aReduced += "...";
     210           0 :                 aReduced += OUString(aDelimiter);
     211           0 :                 aReduced += aName;
     212             :             }
     213             :             else
     214             :             {
     215           0 :                 aReduced += "...";
     216           0 :                 aReduced += OUString(aDelimiter);
     217           0 :                 aReduced += "...";
     218           0 :                 aReduced += aName.copy( aName.getLength() - (nMaxLen - 7) );
     219             :             }
     220             :         }
     221             :         else
     222           0 :             aReduced = aPath;
     223             :     }
     224             : 
     225           0 :     return aReduced;
     226             : }
     227             : 
     228           0 : OUString GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL )
     229             : {
     230           0 :     OUString aRet;
     231             : 
     232           0 :     if( rSvDrawObjURL.GetProtocol() == INetProtocol::PrivSoffice &&
     233           0 :         comphelper::string::getTokenCount(rSvDrawObjURL.GetMainURL( INetURLObject::NO_DECODE ), '/') == 3 )
     234             :     {
     235           0 :         aRet = rSvDrawObjURL.GetMainURL( INetURLObject::NO_DECODE ).getToken( 2, '/' );
     236             :     }
     237             : 
     238           0 :     return aRet;
     239             : }
     240             : 
     241         766 : bool FileExists( const INetURLObject& rURL )
     242             : {
     243         766 :     bool bRet = false;
     244             : 
     245         766 :     if( rURL.GetProtocol() != INetProtocol::NotValid )
     246             :     {
     247             :         try
     248             :         {
     249         766 :             ::ucbhelper::Content        aCnt( rURL.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
     250        1532 :             OUString    aTitle;
     251             : 
     252         898 :             aCnt.getPropertyValue("Title") >>= aTitle;
     253        1400 :             bRet = ( !aTitle.isEmpty() );
     254             :         }
     255           0 :         catch( const ucb::ContentCreationException& )
     256             :         {
     257             :         }
     258           0 :         catch( const uno::RuntimeException& )
     259             :         {
     260             :         }
     261         132 :         catch( const uno::Exception& )
     262             :         {
     263             :         }
     264             :     }
     265             : 
     266         766 :     return bRet;
     267             : }
     268             : 
     269           0 : bool CreateDir( const INetURLObject& rURL )
     270             : {
     271           0 :     bool bRet = FileExists( rURL );
     272             : 
     273           0 :     if( !bRet )
     274             :     {
     275             :         try
     276             :         {
     277           0 :             uno::Reference< ucb::XCommandEnvironment >  aCmdEnv;
     278           0 :             INetURLObject                           aNewFolderURL( rURL );
     279           0 :             INetURLObject                           aParentURL( aNewFolderURL ); aParentURL.removeSegment();
     280           0 :             ::ucbhelper::Content                    aParent( aParentURL.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv, comphelper::getProcessComponentContext() );
     281           0 :             uno::Sequence< OUString >               aProps( 1 );
     282           0 :             uno::Sequence< uno::Any >               aValues( 1 );
     283             : 
     284           0 :             aProps[0] = "Title";
     285           0 :             aValues[0] = uno::makeAny( OUString( aNewFolderURL.GetName() ) );
     286             : 
     287           0 :         ::ucbhelper::Content aContent( aNewFolderURL.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv, comphelper::getProcessComponentContext() );
     288           0 :         bRet = aParent.insertNewContent( OUString("application/vnd.sun.staroffice.fsys-folder"), aProps, aValues, aContent );
     289             :         }
     290           0 :         catch( const ucb::ContentCreationException& )
     291             :         {
     292             :         }
     293           0 :         catch( const uno::RuntimeException& )
     294             :         {
     295             :         }
     296           0 :         catch( const uno::Exception& )
     297             :         {
     298             :         }
     299             :     }
     300             : 
     301           0 :     return bRet;
     302             : }
     303             : 
     304           0 : bool CopyFile(  const INetURLObject& rSrcURL, const INetURLObject& rDstURL )
     305             : {
     306           0 :     bool bRet = false;
     307             : 
     308             :     try
     309             :     {
     310           0 :         ::ucbhelper::Content aDestPath( rDstURL.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
     311             : 
     312             :         aDestPath.executeCommand( OUString("transfer"),
     313             :                                   uno::makeAny( ucb::TransferInfo( sal_False, rSrcURL.GetMainURL( INetURLObject::NO_DECODE ),
     314           0 :                                                 rDstURL.GetName(), ucb::NameClash::OVERWRITE ) ) );
     315           0 :         bRet = true;
     316             :     }
     317           0 :     catch( const ucb::ContentCreationException& )
     318             :     {
     319             :     }
     320           0 :     catch( const uno::RuntimeException& )
     321             :     {
     322             :     }
     323           0 :     catch( const uno::Exception& )
     324             :     {
     325             :     }
     326             : 
     327           0 :     return bRet;
     328             : }
     329             : 
     330          24 : bool KillFile( const INetURLObject& rURL )
     331             : {
     332          24 :     bool bRet = FileExists( rURL );
     333             : 
     334          24 :     if( bRet )
     335             :     {
     336             :         try
     337             :         {
     338          23 :             ::ucbhelper::Content aCnt( rURL.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
     339          23 :             aCnt.executeCommand( OUString("delete"), uno::makeAny( true ) );
     340             :         }
     341           0 :         catch( const ucb::ContentCreationException& )
     342             :         {
     343           0 :             bRet = false;
     344             :         }
     345           0 :         catch( const uno::RuntimeException& )
     346             :         {
     347           0 :             bRet = false;
     348             :         }
     349           0 :         catch( const uno::Exception& )
     350             :         {
     351           0 :             bRet = false;
     352             :         }
     353             :     }
     354             : 
     355          24 :     return bRet;
     356             : }
     357             : 
     358             : 
     359           0 : GalleryProgress::GalleryProgress( GraphicFilter* pFilter ) :
     360           0 :     mpFilter( pFilter )
     361             : {
     362             : 
     363           0 :     uno::Reference< lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
     364             : 
     365           0 :     uno::Reference< awt::XProgressMonitor > xMonitor( xMgr->createInstance(
     366           0 :                                                       OUString("com.sun.star.awt.XProgressMonitor") ),
     367           0 :                                                       uno::UNO_QUERY );
     368             : 
     369           0 :     if ( xMonitor.is() )
     370             :     {
     371           0 :         mxProgressBar = uno::Reference< awt::XProgressBar >( xMonitor, uno::UNO_QUERY );
     372             : 
     373           0 :         if( mxProgressBar.is() )
     374             :         {
     375           0 :             OUString aProgressText;
     376             : 
     377           0 :             if( mpFilter )
     378             :             {
     379           0 :                 aProgressText = GAL_RESSTR(RID_SVXSTR_GALLERY_FILTER);
     380             : //              mpFilter->SetUpdatePercentHdl( LINK( this, GalleryProgress, Update ) );     // sj: progress wasn't working up from SO7 at all
     381             : //                                                                                          // so I am removing this. The gallery progress should
     382             : //                                                                                          // be changed to use the XStatusIndicator instead of XProgressMonitor
     383             :             }
     384             :             else
     385           0 :                 aProgressText = "Gallery";
     386             : 
     387           0 :             xMonitor->addText( "Gallery", aProgressText, sal_False ) ;
     388           0 :             mxProgressBar->setRange( 0, GALLERY_PROGRESS_RANGE );
     389             :         }
     390           0 :     }
     391           0 : }
     392             : 
     393           0 : GalleryProgress::~GalleryProgress()
     394             : {
     395           0 : }
     396             : 
     397           0 : void GalleryProgress::Update( sal_uIntPtr nVal, sal_uIntPtr nMaxVal )
     398             : {
     399           0 :     if( mxProgressBar.is() && nMaxVal )
     400           0 :         mxProgressBar->setValue( std::min( (sal_uIntPtr)( (double) nVal / nMaxVal * GALLERY_PROGRESS_RANGE ), (sal_uIntPtr) GALLERY_PROGRESS_RANGE ) );
     401           0 : }
     402             : 
     403             : 
     404           0 : GalleryTransferable::GalleryTransferable( GalleryTheme* pTheme, sal_uIntPtr nObjectPos, bool bLazy ) :
     405             :     mpTheme( pTheme ),
     406           0 :     meObjectKind( mpTheme->GetObjectKind( nObjectPos ) ),
     407             :     mnObjectPos( nObjectPos ),
     408             :     mpGraphicObject( NULL ),
     409             :     mpImageMap( NULL ),
     410           0 :     mpURL( NULL )
     411             : {
     412             : 
     413           0 :     InitData( bLazy );
     414           0 : }
     415             : 
     416           0 : GalleryTransferable::~GalleryTransferable()
     417             : {
     418           0 : }
     419             : 
     420           0 : void GalleryTransferable::InitData( bool bLazy )
     421             : {
     422           0 :     switch( meObjectKind )
     423             :     {
     424             :         case( SGA_OBJ_SVDRAW ):
     425             :         {
     426           0 :             if( !bLazy )
     427             :             {
     428           0 :                 if( !mpGraphicObject )
     429             :                 {
     430           0 :                     Graphic aGraphic;
     431             : 
     432           0 :                     if( mpTheme->GetGraphic( mnObjectPos, aGraphic ) )
     433           0 :                         mpGraphicObject = new GraphicObject( aGraphic );
     434             :                 }
     435             : 
     436           0 :                 if( !mxModelStream.Is() )
     437             :                 {
     438           0 :                     mxModelStream = new SotStorageStream( "" );
     439           0 :                     mxModelStream->SetBufferSize( 16348 );
     440             : 
     441           0 :                     if( !mpTheme->GetModelStream( mnObjectPos, mxModelStream ) )
     442           0 :                         mxModelStream.Clear();
     443             :                     else
     444           0 :                         mxModelStream->Seek( 0 );
     445             :                 }
     446             :             }
     447             :         }
     448           0 :         break;
     449             : 
     450             :         case( SGA_OBJ_ANIM ):
     451             :         case( SGA_OBJ_BMP ):
     452             :         case( SGA_OBJ_INET ):
     453             :         case( SGA_OBJ_SOUND ):
     454             :         {
     455           0 :             if( !mpURL )
     456             :             {
     457           0 :                 mpURL = new INetURLObject;
     458             : 
     459           0 :                 if( !mpTheme->GetURL( mnObjectPos, *mpURL ) )
     460           0 :                     delete mpURL, mpURL = NULL;
     461             :             }
     462             : 
     463           0 :             if( ( SGA_OBJ_SOUND != meObjectKind ) && !mpGraphicObject )
     464             :             {
     465           0 :                 Graphic aGraphic;
     466             : 
     467           0 :                 if( mpTheme->GetGraphic( mnObjectPos, aGraphic ) )
     468           0 :                     mpGraphicObject = new GraphicObject( aGraphic );
     469             :             }
     470             :         }
     471           0 :         break;
     472             : 
     473             :         default:
     474             :             OSL_FAIL( "GalleryTransferable::GalleryTransferable: invalid object type" );
     475           0 :         break;
     476             :     }
     477           0 : }
     478             : 
     479           0 : void GalleryTransferable::AddSupportedFormats()
     480             : {
     481           0 :     if( SGA_OBJ_SVDRAW == meObjectKind )
     482             :     {
     483           0 :         AddFormat( SotClipboardFormatId::DRAWING );
     484           0 :         AddFormat( SotClipboardFormatId::SVXB );
     485           0 :         AddFormat( SotClipboardFormatId::GDIMETAFILE );
     486           0 :         AddFormat( SotClipboardFormatId::BITMAP );
     487             :     }
     488             :     else
     489             :     {
     490           0 :         if( mpURL )
     491           0 :             AddFormat( SotClipboardFormatId::SIMPLE_FILE );
     492             : 
     493           0 :         if( mpGraphicObject )
     494             :         {
     495           0 :             AddFormat( SotClipboardFormatId::SVXB );
     496             : 
     497           0 :             if( mpGraphicObject->GetType() == GRAPHIC_GDIMETAFILE )
     498             :             {
     499           0 :                 AddFormat( SotClipboardFormatId::GDIMETAFILE );
     500           0 :                 AddFormat( SotClipboardFormatId::BITMAP );
     501             :             }
     502             :             else
     503             :             {
     504           0 :                 AddFormat( SotClipboardFormatId::BITMAP );
     505           0 :                 AddFormat( SotClipboardFormatId::GDIMETAFILE );
     506             :             }
     507             :         }
     508             :     }
     509           0 : }
     510             : 
     511           0 : bool GalleryTransferable::GetData( const datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ )
     512             : {
     513           0 :     SotClipboardFormatId nFormat = SotExchange::GetFormat( rFlavor );
     514           0 :     bool        bRet = false;
     515             : 
     516           0 :     InitData( false );
     517             : 
     518           0 :     if( ( SotClipboardFormatId::DRAWING == nFormat ) && ( SGA_OBJ_SVDRAW == meObjectKind ) )
     519             :     {
     520           0 :         bRet = ( mxModelStream.Is() && SetObject( &mxModelStream, SotClipboardFormatId::NONE, rFlavor ) );
     521             :     }
     522           0 :     else if( ( SotClipboardFormatId::SVIM == nFormat ) && mpImageMap )
     523             :     {
     524             :         // TODO/MBA: do we need a BaseURL here?!
     525           0 :         bRet = SetImageMap( *mpImageMap, rFlavor );
     526             :     }
     527           0 :     else if( ( SotClipboardFormatId::SIMPLE_FILE == nFormat ) && mpURL )
     528             :     {
     529           0 :         bRet = SetString( mpURL->GetMainURL( INetURLObject::NO_DECODE ), rFlavor );
     530             :     }
     531           0 :     else if( ( SotClipboardFormatId::SVXB == nFormat ) && mpGraphicObject )
     532             :     {
     533           0 :         bRet = SetGraphic( mpGraphicObject->GetGraphic(), rFlavor );
     534             :     }
     535           0 :     else if( ( SotClipboardFormatId::GDIMETAFILE == nFormat ) && mpGraphicObject )
     536             :     {
     537           0 :         bRet = SetGDIMetaFile( mpGraphicObject->GetGraphic().GetGDIMetaFile(), rFlavor );
     538             :     }
     539           0 :     else if( ( SotClipboardFormatId::BITMAP == nFormat ) && mpGraphicObject )
     540             :     {
     541           0 :         bRet = SetBitmapEx( mpGraphicObject->GetGraphic().GetBitmapEx(), rFlavor );
     542             :     }
     543             : 
     544           0 :     return bRet;
     545             : }
     546             : 
     547           0 : bool GalleryTransferable::WriteObject( tools::SvRef<SotStorageStream>& rxOStm, void* pUserObject,
     548             :                                            SotClipboardFormatId, const datatransfer::DataFlavor& )
     549             : {
     550           0 :     bool bRet = false;
     551             : 
     552           0 :     if( pUserObject )
     553             :     {
     554           0 :         rxOStm->WriteStream( *static_cast< SotStorageStream* >( pUserObject ) );
     555           0 :         bRet = ( rxOStm->GetError() == ERRCODE_NONE );
     556             :     }
     557             : 
     558           0 :     return bRet;
     559             : }
     560             : 
     561           0 : void GalleryTransferable::DragFinished( sal_Int8 nDropAction )
     562             : {
     563           0 :     mpTheme->SetDragging( false );
     564           0 :     mpTheme->SetDragPos( 0 );
     565           0 :     if ( nDropAction )
     566             :     {
     567           0 :         vcl::Window *pFocusWindow = Application::GetFocusWindow();
     568           0 :         if ( pFocusWindow )
     569           0 :             pFocusWindow->GrabFocusToDocument();
     570             :     }
     571           0 : }
     572             : 
     573           0 : void GalleryTransferable::ObjectReleased()
     574             : {
     575           0 :     mxModelStream.Clear();
     576           0 :     delete mpGraphicObject, mpGraphicObject = NULL;
     577           0 :     delete mpImageMap, mpImageMap = NULL;
     578           0 :     delete mpURL, mpURL = NULL;
     579           0 : }
     580             : 
     581           0 : void GalleryTransferable::CopyToClipboard( vcl::Window* pWindow )
     582             : {
     583           0 :     TransferableHelper::CopyToClipboard( pWindow );
     584           0 : }
     585             : 
     586           0 : void GalleryTransferable::StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions,
     587             :                                      sal_Int32 nDragPointer, sal_Int32 nDragImage )
     588             : {
     589           0 :     INetURLObject aURL;
     590             : 
     591           0 :     if( mpTheme->GetURL( mnObjectPos, aURL ) && ( aURL.GetProtocol() != INetProtocol::NotValid ) )
     592             :     {
     593           0 :         mpTheme->SetDragging( true );
     594           0 :         mpTheme->SetDragPos( mnObjectPos );
     595           0 :         TransferableHelper::StartDrag( pWindow, nDragSourceActions, nDragPointer, nDragImage );
     596           0 :     }
     597         435 : }
     598             : 
     599             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11