LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/misc - transfer2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 37 256 14.5 %
Date: 2012-12-17 Functions: 11 51 21.6 %
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 <osl/mutex.hxx>
      21             : #include <unotools/ucbstreamhelper.hxx>
      22             : #include <sot/exchange.hxx>
      23             : #include <sot/storage.hxx>
      24             : #include <vcl/bitmap.hxx>
      25             : #include <vcl/gdimtf.hxx>
      26             : #include <vcl/graph.hxx>
      27             : #include <vcl/svapp.hxx>
      28             : #include <vcl/window.hxx>
      29             : #include <comphelper/processfactory.hxx>
      30             : #include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp>
      31             : #include "svl/urlbmk.hxx"
      32             : #include <svtools/inetimg.hxx>
      33             : #include <svtools/imap.hxx>
      34             : #include <svtools/transfer.hxx>
      35             : 
      36             : // --------------
      37             : // - Namespaces -
      38             : // --------------
      39             : 
      40             : using namespace ::com::sun::star::uno;
      41             : using namespace ::com::sun::star::lang;
      42             : using namespace ::com::sun::star::io;
      43             : using namespace ::com::sun::star::datatransfer;
      44             : using namespace ::com::sun::star::datatransfer::clipboard;
      45             : using namespace ::com::sun::star::datatransfer::dnd;
      46             : 
      47             : // -----------------------------------------
      48             : // - DragSourceHelper::DragGestureListener -
      49             : // -----------------------------------------
      50             : 
      51         568 : DragSourceHelper::DragGestureListener::DragGestureListener( DragSourceHelper& rDragSourceHelper ) :
      52         568 :     mrParent( rDragSourceHelper )
      53             : {
      54         568 : }
      55             : 
      56             : // -----------------------------------------------------------------------------
      57             : 
      58         300 : DragSourceHelper::DragGestureListener::~DragGestureListener()
      59             : {
      60         300 : }
      61             : 
      62             : // -----------------------------------------------------------------------------
      63             : 
      64           0 : void SAL_CALL DragSourceHelper::DragGestureListener::disposing( const EventObject& ) throw( RuntimeException )
      65             : {
      66           0 : }
      67             : 
      68             : // -----------------------------------------------------------------------------
      69             : 
      70           0 : void SAL_CALL DragSourceHelper::DragGestureListener::dragGestureRecognized( const DragGestureEvent& rDGE ) throw( RuntimeException )
      71             : {
      72           0 :     const SolarMutexGuard aGuard;
      73             : 
      74           0 :     const Point aPtPixel( rDGE.DragOriginX, rDGE.DragOriginY );
      75           0 :     mrParent.StartDrag( rDGE.DragAction, aPtPixel );
      76           0 : }
      77             : 
      78             : // --------------------
      79             : // - DragSourceHelper -
      80             : // --------------------
      81             : 
      82         568 : DragSourceHelper::DragSourceHelper( Window* pWindow ) :
      83         568 :     mxDragGestureRecognizer( pWindow->GetDragGestureRecognizer() )
      84             : {
      85         568 :     if( mxDragGestureRecognizer.is() )
      86             :     {
      87         568 :         mxDragGestureListener = new DragSourceHelper::DragGestureListener( *this );
      88         568 :         mxDragGestureRecognizer->addDragGestureListener( mxDragGestureListener );
      89             :     }
      90         568 : }
      91             : 
      92             : // -----------------------------------------------------------------------------
      93             : 
      94         300 : DragSourceHelper::~DragSourceHelper()
      95             : {
      96         150 :     if( mxDragGestureRecognizer.is()  )
      97         150 :         mxDragGestureRecognizer->removeDragGestureListener( mxDragGestureListener );
      98         150 : }
      99             : 
     100             : // -----------------------------------------------------------------------------
     101             : 
     102           0 : void DragSourceHelper::StartDrag( sal_Int8, const Point& )
     103             : {
     104           0 : }
     105             : 
     106             : // ----------------------------------------
     107             : // - DropTargetHelper::DropTargetListener -
     108             : // ----------------------------------------
     109             : 
     110         554 : DropTargetHelper::DropTargetListener::DropTargetListener( DropTargetHelper& rDropTargetHelper ) :
     111             :     mrParent( rDropTargetHelper ),
     112         554 :     mpLastDragOverEvent( NULL )
     113             : {
     114         554 : }
     115             : 
     116             : // -----------------------------------------------------------------------------
     117             : 
     118         420 : DropTargetHelper::DropTargetListener::~DropTargetListener()
     119             : {
     120         140 :     delete mpLastDragOverEvent;
     121         280 : }
     122             : 
     123             : // -----------------------------------------------------------------------------
     124             : 
     125           0 : void SAL_CALL DropTargetHelper::DropTargetListener::disposing( const EventObject& ) throw( RuntimeException )
     126             : {
     127           0 : }
     128             : 
     129             : // -----------------------------------------------------------------------------
     130             : 
     131           0 : void SAL_CALL DropTargetHelper::DropTargetListener::drop( const DropTargetDropEvent& rDTDE ) throw( RuntimeException )
     132             : {
     133           0 :     const SolarMutexGuard aGuard;
     134             : 
     135             :     try
     136             :     {
     137           0 :         AcceptDropEvent  aAcceptEvent;
     138           0 :         ExecuteDropEvent aExecuteEvt( rDTDE.DropAction & ~DNDConstants::ACTION_DEFAULT, Point( rDTDE.LocationX, rDTDE.LocationY ), rDTDE );
     139           0 :         sal_Int8         nRet = DNDConstants::ACTION_NONE;
     140             : 
     141           0 :         aExecuteEvt.mbDefault = ( ( rDTDE.DropAction & DNDConstants::ACTION_DEFAULT ) != 0 );
     142             : 
     143             :         // in case of a default action, call ::AcceptDrop first and use the returned
     144             :         // accepted action as the execute action in the call to ::ExecuteDrop
     145           0 :         aAcceptEvent.mnAction = aExecuteEvt.mnAction;
     146           0 :         aAcceptEvent.maPosPixel = aExecuteEvt.maPosPixel;
     147           0 :         (DropTargetEvent&)( aAcceptEvent.maDragEvent ) = (DropTargetEvent&) rDTDE;
     148           0 :         ( (DropTargetDragEvent&)( aAcceptEvent.maDragEvent ) ).DropAction = rDTDE.DropAction;
     149           0 :         ( (DropTargetDragEvent&)( aAcceptEvent.maDragEvent ) ).LocationX = rDTDE.LocationX;
     150           0 :         ( (DropTargetDragEvent&)( aAcceptEvent.maDragEvent ) ).LocationY = rDTDE.LocationY;
     151           0 :         ( (DropTargetDragEvent&)( aAcceptEvent.maDragEvent ) ).SourceActions = rDTDE.SourceActions;
     152           0 :         aAcceptEvent.mbLeaving = sal_False;
     153           0 :         aAcceptEvent.mbDefault = aExecuteEvt.mbDefault;
     154             : 
     155           0 :         nRet = mrParent.AcceptDrop( aAcceptEvent );
     156             : 
     157           0 :         if( DNDConstants::ACTION_NONE != nRet )
     158             :         {
     159           0 :             rDTDE.Context->acceptDrop( nRet );
     160             : 
     161           0 :             if( aExecuteEvt.mbDefault )
     162           0 :                 aExecuteEvt.mnAction = nRet;
     163             : 
     164           0 :             nRet = mrParent.ExecuteDrop( aExecuteEvt );
     165             :         }
     166             : 
     167           0 :         rDTDE.Context->dropComplete( DNDConstants::ACTION_NONE != nRet );
     168             : 
     169           0 :         if( mpLastDragOverEvent )
     170             :         {
     171           0 :             delete mpLastDragOverEvent;
     172           0 :             mpLastDragOverEvent = NULL;
     173           0 :         }
     174             :     }
     175           0 :     catch( const ::com::sun::star::uno::Exception& )
     176             :     {
     177           0 :     }
     178           0 : }
     179             : 
     180             : // -----------------------------------------------------------------------------
     181             : 
     182           0 : void SAL_CALL DropTargetHelper::DropTargetListener::dragEnter( const DropTargetDragEnterEvent& rDTDEE ) throw( RuntimeException )
     183             : {
     184           0 :     const SolarMutexGuard aGuard;
     185             : 
     186             :     try
     187             :     {
     188           0 :         mrParent.ImplBeginDrag( rDTDEE.SupportedDataFlavors );
     189             :     }
     190           0 :     catch( const ::com::sun::star::uno::Exception& )
     191             :     {
     192             :     }
     193             : 
     194           0 :     dragOver( rDTDEE );
     195           0 : }
     196             : 
     197             : // -----------------------------------------------------------------------------
     198             : 
     199           0 : void SAL_CALL DropTargetHelper::DropTargetListener::dragOver( const DropTargetDragEvent& rDTDE ) throw( RuntimeException )
     200             : {
     201           0 :     const SolarMutexGuard aGuard;
     202             : 
     203             :     try
     204             :     {
     205           0 :         if( mpLastDragOverEvent )
     206           0 :             delete mpLastDragOverEvent;
     207             : 
     208           0 :         mpLastDragOverEvent = new AcceptDropEvent( rDTDE.DropAction & ~DNDConstants::ACTION_DEFAULT, Point( rDTDE.LocationX, rDTDE.LocationY ), rDTDE );
     209           0 :         mpLastDragOverEvent->mbDefault = ( ( rDTDE.DropAction & DNDConstants::ACTION_DEFAULT ) != 0 );
     210             : 
     211           0 :         const sal_Int8 nRet = mrParent.AcceptDrop( *mpLastDragOverEvent );
     212             : 
     213           0 :         if( DNDConstants::ACTION_NONE == nRet )
     214           0 :             rDTDE.Context->rejectDrag();
     215             :         else
     216           0 :             rDTDE.Context->acceptDrag( nRet );
     217             :     }
     218           0 :     catch( const ::com::sun::star::uno::Exception& )
     219             :     {
     220           0 :     }
     221           0 : }
     222             : 
     223             : // -----------------------------------------------------------------------------
     224             : 
     225           0 : void SAL_CALL DropTargetHelper::DropTargetListener::dragExit( const DropTargetEvent& ) throw( RuntimeException )
     226             : {
     227           0 :     const SolarMutexGuard aGuard;
     228             : 
     229             :     try
     230             :     {
     231           0 :         if( mpLastDragOverEvent )
     232             :         {
     233           0 :             mpLastDragOverEvent->mbLeaving = sal_True;
     234           0 :             mrParent.AcceptDrop( *mpLastDragOverEvent );
     235           0 :             delete mpLastDragOverEvent;
     236           0 :             mpLastDragOverEvent = NULL;
     237             :         }
     238             : 
     239           0 :         mrParent.ImplEndDrag();
     240             :     }
     241           0 :     catch( const ::com::sun::star::uno::Exception& )
     242             :     {
     243           0 :     }
     244           0 : }
     245             : 
     246             : 
     247             : // -----------------------------------------------------------------------------
     248             : 
     249           0 : void SAL_CALL DropTargetHelper::DropTargetListener::dropActionChanged( const DropTargetDragEvent& ) throw( RuntimeException )
     250             : {
     251           0 : }
     252             : 
     253             : // --------------------
     254             : // - DropTargetHelper -
     255             : // --------------------
     256             : 
     257         554 : DropTargetHelper::DropTargetHelper( Window* pWindow ) :
     258         554 :     mxDropTarget( pWindow->GetDropTarget() ),
     259        1108 :     mpFormats( new DataFlavorExVector )
     260             : {
     261         554 :     ImplConstruct();
     262         554 : }
     263             : 
     264             : // -----------------------------------------------------------------------------
     265             : 
     266           0 : DropTargetHelper::DropTargetHelper( const Reference< XDropTarget >& rxDropTarget ) :
     267             :     mxDropTarget( rxDropTarget ),
     268           0 :     mpFormats( new DataFlavorExVector )
     269             : {
     270           0 :     ImplConstruct();
     271           0 : }
     272             : 
     273             : // -----------------------------------------------------------------------------
     274             : 
     275         280 : DropTargetHelper::~DropTargetHelper()
     276             : {
     277         140 :     if( mxDropTarget.is() )
     278         140 :         mxDropTarget->removeDropTargetListener( mxDropTargetListener );
     279             : 
     280         140 :     delete mpFormats;
     281         140 : }
     282             : 
     283             : // -----------------------------------------------------------------------------
     284             : 
     285         554 : void DropTargetHelper::ImplConstruct()
     286             : {
     287         554 :     if( mxDropTarget.is() )
     288             :     {
     289         554 :         mxDropTargetListener = new DropTargetHelper::DropTargetListener( *this );
     290         554 :         mxDropTarget->addDropTargetListener( mxDropTargetListener );
     291         554 :         mxDropTarget->setActive( sal_True );
     292             :     }
     293         554 : }
     294             : 
     295             : // -----------------------------------------------------------------------------
     296             : 
     297           0 : void DropTargetHelper::ImplBeginDrag( const Sequence< DataFlavor >& rSupportedDataFlavors )
     298             : {
     299           0 :     mpFormats->clear();
     300           0 :     TransferableDataHelper::FillDataFlavorExVector( rSupportedDataFlavors, *mpFormats );
     301           0 : }
     302             : 
     303             : // -----------------------------------------------------------------------------
     304             : 
     305           0 : void DropTargetHelper::ImplEndDrag()
     306             : {
     307           0 :     mpFormats->clear();
     308           0 : }
     309             : 
     310             : // -----------------------------------------------------------------------------
     311             : 
     312           0 : sal_Int8 DropTargetHelper::AcceptDrop( const AcceptDropEvent& )
     313             : {
     314           0 :     return( DNDConstants::ACTION_NONE );
     315             : }
     316             : 
     317             : // -----------------------------------------------------------------------------
     318             : 
     319           0 : sal_Int8 DropTargetHelper::ExecuteDrop( const ExecuteDropEvent& )
     320             : {
     321           0 :     return( DNDConstants::ACTION_NONE );
     322             : }
     323             : 
     324             : // -----------------------------------------------------------------------------
     325             : 
     326           0 : sal_Bool DropTargetHelper::IsDropFormatSupported( SotFormatStringId nFormat )
     327             : {
     328           0 :     DataFlavorExVector::iterator    aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
     329           0 :     sal_Bool                        bRet = sal_False;
     330             : 
     331           0 :     while( aIter != aEnd )
     332             :     {
     333           0 :         if( nFormat == (*aIter++).mnSotId )
     334             :         {
     335           0 :             bRet = sal_True;
     336           0 :             aIter = aEnd;
     337             :         }
     338             :     }
     339             : 
     340           0 :     return bRet;
     341             : }
     342             : 
     343             : // -----------------------------------------------------------------------------
     344             : 
     345           0 : sal_Bool DropTargetHelper::IsDropFormatSupported( const DataFlavor& rFlavor )
     346             : {
     347           0 :     DataFlavorExVector::iterator    aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
     348           0 :     sal_Bool                        bRet = sal_False;
     349             : 
     350           0 :     while( aIter != aEnd )
     351             :     {
     352           0 :         if( TransferableDataHelper::IsEqual( rFlavor, *aIter++ ) )
     353             :         {
     354           0 :             bRet = sal_True;
     355           0 :             aIter = aEnd;
     356             :         }
     357             :     }
     358             : 
     359           0 :     return bRet;
     360             : }
     361             : 
     362             : // -----------------------------------------------------------------------------
     363             : // TransferDataContainer
     364             : // -----------------------------------------------------------------------------
     365             : 
     366           0 : struct TDataCntnrEntry_Impl
     367             : {
     368             :     ::com::sun::star::uno::Any aAny;
     369             :     SotFormatStringId nId;
     370             : };
     371             : 
     372             : // -----------------------------------------------------------------------------
     373             : 
     374             : typedef ::std::list< TDataCntnrEntry_Impl > TDataCntnrEntryList;
     375             : 
     376             : // -----------------------------------------------------------------------------
     377             : 
     378             : struct TransferDataContainer_Impl
     379             : {
     380             :     TDataCntnrEntryList aFmtList;
     381             :     Link aFinshedLnk;
     382             :     INetBookmark* pBookmk;
     383             :     Graphic* pGrf;
     384             : 
     385           0 :     TransferDataContainer_Impl()
     386           0 :         : pBookmk( 0 ), pGrf( 0 )
     387             :     {
     388           0 :     }
     389             : 
     390           0 :     ~TransferDataContainer_Impl()
     391           0 :     {
     392           0 :         delete pBookmk;
     393           0 :         delete pGrf;
     394           0 :     }
     395             : };
     396             : 
     397             : // -----------------------------------------------------------------------------
     398             : 
     399           0 : TransferDataContainer::TransferDataContainer()
     400           0 :     : pImpl( new TransferDataContainer_Impl )
     401             : {
     402           0 : }
     403             : 
     404             : // -----------------------------------------------------------------------------
     405             : 
     406           0 : TransferDataContainer::~TransferDataContainer()
     407             : {
     408           0 :     delete pImpl;
     409           0 : }
     410             : 
     411             : // -----------------------------------------------------------------------------
     412             : 
     413           0 : void TransferDataContainer::AddSupportedFormats()
     414             : {
     415           0 : }
     416             : 
     417             : // -----------------------------------------------------------------------------
     418             : 
     419           0 : sal_Bool TransferDataContainer::GetData( const
     420             :             ::com::sun::star::datatransfer::DataFlavor& rFlavor )
     421             : {
     422           0 :     TDataCntnrEntryList::iterator   aIter( pImpl->aFmtList.begin() ),
     423           0 :                                     aEnd( pImpl->aFmtList.end() );
     424           0 :     sal_Bool bFnd = sal_False;
     425           0 :     sal_uLong nFmtId = SotExchange::GetFormat( rFlavor );
     426             : 
     427             :     // test first the list
     428           0 :     for( ; aIter != aEnd; ++aIter )
     429             :     {
     430           0 :         TDataCntnrEntry_Impl& rEntry = (TDataCntnrEntry_Impl&)*aIter;
     431           0 :         if( nFmtId == rEntry.nId )
     432             :         {
     433           0 :             bFnd = SetAny( rEntry.aAny, rFlavor );
     434           0 :             break;
     435             :         }
     436             :     }
     437             : 
     438             :     // test second the bookmark pointer
     439           0 :     if( !bFnd )
     440           0 :         switch( nFmtId )
     441             :         {
     442             :          case SOT_FORMAT_STRING:
     443             :          case SOT_FORMATSTR_ID_SOLK:
     444             :          case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
     445             :          case SOT_FORMATSTR_ID_FILECONTENT:
     446             :          case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
     447             :          case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR:
     448           0 :             if( pImpl->pBookmk )
     449           0 :                 bFnd = SetINetBookmark( *pImpl->pBookmk, rFlavor );
     450           0 :             break;
     451             : 
     452             :         case SOT_FORMATSTR_ID_SVXB:
     453             :         case SOT_FORMAT_BITMAP:
     454             :         case SOT_FORMAT_GDIMETAFILE:
     455           0 :             if( pImpl->pGrf )
     456           0 :                 bFnd = SetGraphic( *pImpl->pGrf, rFlavor );
     457           0 :             break;
     458             :         }
     459             : 
     460           0 :     return bFnd;
     461             : }
     462             : 
     463             : // -----------------------------------------------------------------------------
     464             : 
     465           0 : void TransferDataContainer::CopyINetBookmark( const INetBookmark& rBkmk )
     466             : {
     467           0 :     if( !pImpl->pBookmk )
     468           0 :         pImpl->pBookmk = new INetBookmark( rBkmk );
     469             :     else
     470           0 :         *pImpl->pBookmk = rBkmk;
     471             : 
     472           0 :      AddFormat( SOT_FORMAT_STRING );
     473           0 :      AddFormat( SOT_FORMATSTR_ID_SOLK );
     474           0 :      AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
     475           0 :      AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
     476           0 :      AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
     477           0 :      AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
     478           0 : }
     479             : 
     480             : // -----------------------------------------------------------------------------
     481             : 
     482           0 : void TransferDataContainer::CopyAnyData( sal_uLong nFormatId,
     483             :                                         const sal_Char* pData, sal_uLong nLen )
     484             : {
     485           0 :     if( nLen )
     486             :     {
     487           0 :         TDataCntnrEntry_Impl aEntry;
     488           0 :         aEntry.nId = nFormatId;
     489             : 
     490           0 :         Sequence< sal_Int8 > aSeq( nLen  );
     491           0 :         memcpy( aSeq.getArray(), pData, nLen );
     492           0 :         aEntry.aAny <<= aSeq;
     493           0 :         pImpl->aFmtList.push_back( aEntry );
     494           0 :          AddFormat( nFormatId );
     495             :     }
     496           0 : }
     497             : 
     498             : // -----------------------------------------------------------------------------
     499             : 
     500           0 : void TransferDataContainer::CopyByteString( sal_uLong nFormatId,
     501             :                                             const rtl::OString& rStr )
     502             : {
     503           0 :     CopyAnyData( nFormatId, rStr.getStr(), rStr.getLength() );
     504           0 : }
     505             : 
     506             : // -----------------------------------------------------------------------------
     507             : 
     508           0 : void TransferDataContainer::CopyINetImage( const INetImage& rINtImg )
     509             : {
     510           0 :     SvMemoryStream aMemStm( 1024, 1024 );
     511           0 :     aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
     512           0 :     rINtImg.Write( aMemStm, SOT_FORMATSTR_ID_INET_IMAGE );
     513           0 :     CopyAnyData( SOT_FORMATSTR_ID_INET_IMAGE, (sal_Char*)aMemStm.GetData(),
     514           0 :                     aMemStm.Seek( STREAM_SEEK_TO_END ) );
     515           0 : }
     516             : 
     517             : // -----------------------------------------------------------------------------
     518             : 
     519           0 : void TransferDataContainer::CopyImageMap( const ImageMap& rImgMap )
     520             : {
     521           0 :     SvMemoryStream aMemStm( 8192, 8192 );
     522           0 :     aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
     523           0 :     rImgMap.Write( aMemStm, String() );
     524           0 :     CopyAnyData( SOT_FORMATSTR_ID_SVIM, (sal_Char*)aMemStm.GetData(),
     525           0 :                     aMemStm.Seek( STREAM_SEEK_TO_END ) );
     526           0 : }
     527             : 
     528             : // -----------------------------------------------------------------------------
     529             : 
     530           0 : void TransferDataContainer::CopyGraphic( const Graphic& rGrf )
     531             : {
     532           0 :     GraphicType nType = rGrf.GetType();
     533           0 :     if( GRAPHIC_NONE != nType )
     534             :     {
     535           0 :         if( !pImpl->pGrf )
     536           0 :             pImpl->pGrf = new Graphic( rGrf );
     537             :         else
     538           0 :             *pImpl->pGrf = rGrf;
     539             : 
     540           0 :         AddFormat( SOT_FORMATSTR_ID_SVXB );
     541           0 :         if( GRAPHIC_BITMAP == nType )
     542           0 :             AddFormat( SOT_FORMAT_BITMAP );
     543           0 :         else if( GRAPHIC_GDIMETAFILE == nType )
     544           0 :             AddFormat( SOT_FORMAT_GDIMETAFILE );
     545             :     }
     546           0 : }
     547             : 
     548             : // -----------------------------------------------------------------------------
     549             : 
     550           0 : void TransferDataContainer::CopyString( sal_uInt16 nFmt, const String& rStr )
     551             : {
     552           0 :     if( rStr.Len() )
     553             :     {
     554           0 :         TDataCntnrEntry_Impl aEntry;
     555           0 :         aEntry.nId = nFmt;
     556           0 :         rtl::OUString aStr( rStr );
     557           0 :         aEntry.aAny <<= aStr;
     558           0 :         pImpl->aFmtList.push_back( aEntry );
     559           0 :          AddFormat( aEntry.nId );
     560             :     }
     561           0 : }
     562             : 
     563             : // -----------------------------------------------------------------------------
     564             : 
     565           0 : void TransferDataContainer::CopyString( const String& rStr )
     566             : {
     567           0 :     CopyString( SOT_FORMAT_STRING, rStr );
     568           0 : }
     569             : 
     570             : // -----------------------------------------------------------------------------
     571             : 
     572           0 : void TransferDataContainer::CopyAny( sal_uInt16 nFmt,
     573             :                                     const ::com::sun::star::uno::Any& rAny )
     574             : {
     575           0 :     TDataCntnrEntry_Impl aEntry;
     576           0 :     aEntry.nId = nFmt;
     577           0 :     aEntry.aAny = rAny;
     578           0 :     pImpl->aFmtList.push_back( aEntry );
     579           0 :     AddFormat( aEntry.nId );
     580           0 : }
     581             : 
     582             : // -----------------------------------------------------------------------------
     583             : 
     584           0 : sal_Bool TransferDataContainer::HasAnyData() const
     585             : {
     586           0 :     return pImpl->aFmtList.begin() != pImpl->aFmtList.end() ||
     587           0 :             0 != pImpl->pBookmk;
     588             : }
     589             : 
     590             : // -----------------------------------------------------------------------------
     591             : 
     592           0 : void TransferDataContainer::StartDrag(
     593             :         Window* pWindow, sal_Int8 nDragSourceActions,
     594             :         const Link& rLnk, sal_Int32 nDragPointer, sal_Int32 nDragImage )
     595             : {
     596           0 :     pImpl->aFinshedLnk = rLnk;
     597             :     TransferableHelper::StartDrag( pWindow, nDragSourceActions,
     598           0 :                                     nDragPointer, nDragImage );
     599           0 : }
     600             : 
     601             : // -----------------------------------------------------------------------------
     602             : 
     603           0 : void TransferDataContainer::DragFinished( sal_Int8 nDropAction )
     604             : {
     605           0 :     if( pImpl->aFinshedLnk.IsSet() )
     606           0 :         pImpl->aFinshedLnk.Call( &nDropAction );
     607           0 : }
     608             : 
     609             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10