LCOV - code coverage report
Current view: top level - svtools/source/misc - transfer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 140 982 14.3 %
Date: 2012-08-25 Functions: 28 108 25.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 122 2212 5.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifdef WNT
      30                 :            : #include <prewin.h>
      31                 :            : #include <postwin.h>
      32                 :            : #include <shlobj.h>
      33                 :            : #endif
      34                 :            : #include <osl/mutex.hxx>
      35                 :            : #include <rtl/memory.h>
      36                 :            : #include <rtl/uri.hxx>
      37                 :            : #include <tools/debug.hxx>
      38                 :            : #include <tools/urlobj.hxx>
      39                 :            : #include <unotools/ucbstreamhelper.hxx>
      40                 :            : #include <sot/exchange.hxx>
      41                 :            : #include <sot/storage.hxx>
      42                 :            : #include <vcl/bitmap.hxx>
      43                 :            : #include <vcl/gdimtf.hxx>
      44                 :            : #include <vcl/graph.hxx>
      45                 :            : #include <vcl/cvtgrf.hxx>
      46                 :            : #include <vcl/svapp.hxx>
      47                 :            : #include <vcl/window.hxx>
      48                 :            : #include <comphelper/processfactory.hxx>
      49                 :            : #include <comphelper/servicehelper.hxx>
      50                 :            : #include <sot/filelist.hxx>
      51                 :            : #include <cppuhelper/implbase1.hxx>
      52                 :            : 
      53                 :            : #include <comphelper/seqstream.hxx>
      54                 :            : #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
      55                 :            : #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
      56                 :            : #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
      57                 :            : #include <com/sun/star/datatransfer/XMimeContentType.hpp>
      58                 :            : #include <com/sun/star/frame/XDesktop.hpp>
      59                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      60                 :            : 
      61                 :            : #include "svl/urlbmk.hxx"
      62                 :            : #include "inetimg.hxx"
      63                 :            : #include <svtools/wmf.hxx>
      64                 :            : #include <svtools/imap.hxx>
      65                 :            : #include <svtools/transfer.hxx>
      66                 :            : #include <rtl/strbuf.hxx>
      67                 :            : #include <cstdio>
      68                 :            : 
      69                 :            : // --------------
      70                 :            : // - Namespaces -
      71                 :            : // --------------
      72                 :            : 
      73                 :            : using namespace ::com::sun::star::uno;
      74                 :            : using namespace ::com::sun::star::lang;
      75                 :            : using namespace ::com::sun::star::frame;
      76                 :            : using namespace ::com::sun::star::io;
      77                 :            : using namespace ::com::sun::star::datatransfer;
      78                 :            : using namespace ::com::sun::star::datatransfer::clipboard;
      79                 :            : using namespace ::com::sun::star::datatransfer::dnd;
      80                 :            : 
      81                 :            : // --------------------------------
      82                 :            : // - TransferableObjectDescriptor -
      83                 :            : // --------------------------------
      84                 :            : 
      85                 :            : #define TOD_SIG1 0x01234567
      86                 :            : #define TOD_SIG2 0x89abcdef
      87                 :            : 
      88                 :          0 : SvStream& operator>>( SvStream& rIStm, TransferableObjectDescriptor& rObjDesc )
      89                 :            : {
      90                 :            :     sal_uInt32  nSize, nViewAspect, nSig1, nSig2;
      91                 :            :     //#fdo39428 Remove SvStream operator>>(long&)
      92                 :          0 :     sal_Int32 nTmp(0);
      93                 :            : 
      94         [ #  # ]:          0 :     rIStm >> nSize;
      95         [ #  # ]:          0 :     rIStm >> rObjDesc.maClassName;
      96         [ #  # ]:          0 :     rIStm >> nViewAspect;
      97         [ #  # ]:          0 :     rIStm >> nTmp;
      98                 :          0 :     rObjDesc.maSize.Width() = nTmp;
      99         [ #  # ]:          0 :     rIStm >> nTmp;
     100                 :          0 :     rObjDesc.maSize.Height() = nTmp;
     101         [ #  # ]:          0 :     rIStm >> nTmp;
     102                 :          0 :     rObjDesc.maDragStartPos.X() = nTmp;
     103         [ #  # ]:          0 :     rIStm >> nTmp;
     104                 :          0 :     rObjDesc.maDragStartPos.Y() = nTmp;
     105 [ #  # ][ #  # ]:          0 :     rObjDesc.maTypeName = rIStm.ReadUniOrByteString(osl_getThreadTextEncoding());
                 [ #  # ]
     106 [ #  # ][ #  # ]:          0 :     rObjDesc.maDisplayName = rIStm.ReadUniOrByteString(osl_getThreadTextEncoding());
                 [ #  # ]
     107                 :            : 
     108 [ #  # ][ #  # ]:          0 :     rIStm >> nSig1 >> nSig2;
     109                 :            : 
     110                 :          0 :     rObjDesc.mnViewAspect = static_cast< sal_uInt16 >( nViewAspect );
     111                 :            : 
     112                 :            :     // don't use width/height info from external objects
     113 [ #  # ][ #  # ]:          0 :     if( ( TOD_SIG1 != nSig1 ) || ( TOD_SIG2 != nSig2 ) )
     114                 :            :     {
     115                 :          0 :         rObjDesc.maSize.Width() = 0;
     116                 :          0 :         rObjDesc.maSize.Height() = 0;
     117                 :            :     }
     118                 :            : 
     119                 :          0 :     return rIStm;
     120                 :            : }
     121                 :            : 
     122                 :            : // -----------------------------------------------------------------------------
     123                 :            : 
     124                 :          0 : SvStream& operator<<( SvStream& rOStm, const TransferableObjectDescriptor& rObjDesc )
     125                 :            : {
     126                 :          0 :     const sal_uInt32    nFirstPos = rOStm.Tell(), nViewAspect = rObjDesc.mnViewAspect;
     127                 :          0 :     const sal_uInt32    nSig1 = TOD_SIG1, nSig2 = TOD_SIG2;
     128                 :            : 
     129                 :          0 :     rOStm.SeekRel( 4 );
     130                 :          0 :     rOStm << rObjDesc.maClassName;
     131                 :          0 :     rOStm << nViewAspect;
     132                 :            :     //#fdo39428 Remove SvStream operator<<(long)
     133                 :          0 :     rOStm << sal::static_int_cast<sal_Int32>(rObjDesc.maSize.Width());
     134                 :          0 :     rOStm << sal::static_int_cast<sal_Int32>(rObjDesc.maSize.Height());
     135                 :          0 :     rOStm << sal::static_int_cast<sal_Int32>(rObjDesc.maDragStartPos.X());
     136                 :          0 :     rOStm << sal::static_int_cast<sal_Int32>(rObjDesc.maDragStartPos.Y());
     137         [ #  # ]:          0 :     rOStm.WriteUniOrByteString( rObjDesc.maTypeName, osl_getThreadTextEncoding() );
     138         [ #  # ]:          0 :     rOStm.WriteUniOrByteString( rObjDesc.maDisplayName, osl_getThreadTextEncoding() );
     139                 :          0 :     rOStm << nSig1 << nSig2;
     140                 :            : 
     141                 :          0 :     const sal_uInt32 nLastPos = rOStm.Tell();
     142                 :            : 
     143                 :          0 :     rOStm.Seek( nFirstPos );
     144                 :          0 :     rOStm << ( nLastPos - nFirstPos );
     145                 :          0 :     rOStm.Seek( nLastPos );
     146                 :            : 
     147                 :          0 :     return rOStm;
     148                 :            : }
     149                 :            : 
     150                 :            : // -----------------------------------------------------------------------------
     151                 :            : // the reading of the parameter is done using the special service ::com::sun::star::datatransfer::MimeContentType,
     152                 :            : // a similar approach should be implemented for creation of the mimetype string;
     153                 :            : // for now the set of acceptable characters has to be hardcoded, in future it should be part of the service that creates the mimetype
     154                 :            : 
     155                 :          0 : static ::rtl::OUString ImplGetParameterString( const TransferableObjectDescriptor& rObjDesc )
     156                 :            : {
     157         [ #  # ]:          0 :     const ::rtl::OUString   aChar( RTL_CONSTASCII_USTRINGPARAM( "\"" ));
     158 [ #  # ][ #  # ]:          0 :     const ::rtl::OUString   aClassName( rObjDesc.maClassName.GetHexName() );
                 [ #  # ]
     159                 :          0 :     ::rtl::OUString         aParams;
     160                 :            : 
     161         [ #  # ]:          0 :     if( !aClassName.isEmpty() )
     162                 :            :     {
     163         [ #  # ]:          0 :         aParams += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";classname=\"" ));
     164                 :          0 :         aParams += aClassName;
     165                 :          0 :         aParams += aChar;
     166                 :            :     }
     167                 :            : 
     168         [ #  # ]:          0 :     if( rObjDesc.maTypeName.Len() )
     169                 :            :     {
     170         [ #  # ]:          0 :         aParams += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";typename=\"" ));
     171         [ #  # ]:          0 :         aParams += rObjDesc.maTypeName;
     172                 :          0 :         aParams += aChar;
     173                 :            :     }
     174                 :            : 
     175         [ #  # ]:          0 :     if( rObjDesc.maDisplayName.Len() )
     176                 :            :     {
     177                 :            :         // the display name might contain unacceptable characters, encode all of them
     178                 :            :         // this seems to be the only parameter currently that might contain such characters
     179                 :            :         sal_Bool pToAccept[128];
     180         [ #  # ]:          0 :         for ( sal_Int32 nBInd = 0; nBInd < 128; nBInd++ )
     181                 :          0 :             pToAccept[nBInd] = sal_False;
     182                 :            : 
     183                 :            :         const char aQuotedParamChars[] =
     184                 :          0 :             "()<>@,;:\\\"/[]?=!#$%&'*+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~. ";
     185                 :            : 
     186         [ #  # ]:          0 :         for ( sal_Int32 nInd = 0; nInd < RTL_CONSTASCII_LENGTH(aQuotedParamChars); ++nInd )
     187                 :            :         {
     188                 :          0 :             sal_Unicode nChar = aQuotedParamChars[nInd];
     189         [ #  # ]:          0 :             if ( nChar < 128 )
     190                 :          0 :                 pToAccept[nChar] = sal_True;
     191                 :            :         }
     192                 :            : 
     193         [ #  # ]:          0 :         aParams += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";displayname=\"" ));
     194         [ #  # ]:          0 :         aParams += ::rtl::Uri::encode( rObjDesc.maDisplayName, pToAccept, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 );
     195                 :          0 :         aParams += aChar;
     196                 :            :     }
     197                 :            : 
     198         [ #  # ]:          0 :     aParams += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";viewaspect=\"" ));
     199                 :          0 :     aParams += ::rtl::OUString::valueOf( static_cast< sal_Int32 >( rObjDesc.mnViewAspect ) );
     200                 :          0 :     aParams += aChar;
     201                 :            : 
     202         [ #  # ]:          0 :     aParams += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";width=\"" ));
     203                 :          0 :     aParams += ::rtl::OUString::valueOf( rObjDesc.maSize.Width() );
     204                 :          0 :     aParams += aChar;
     205                 :            : 
     206         [ #  # ]:          0 :     aParams += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";height=\"" ));
     207                 :          0 :     aParams += ::rtl::OUString::valueOf( rObjDesc.maSize.Height() );
     208                 :          0 :     aParams += aChar;
     209                 :            : 
     210         [ #  # ]:          0 :     aParams += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";posx=\"" ));
     211                 :          0 :     aParams += ::rtl::OUString::valueOf( rObjDesc.maDragStartPos.X() );
     212                 :          0 :     aParams += aChar;
     213                 :            : 
     214         [ #  # ]:          0 :     aParams += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ";posy=\"" ));
     215                 :          0 :     aParams += ::rtl::OUString::valueOf( rObjDesc.maDragStartPos.X() );
     216                 :          0 :     aParams += aChar;
     217                 :            : 
     218                 :          0 :     return aParams;
     219                 :            : }
     220                 :            : 
     221                 :            : // -----------------------------------------------------------------------------
     222                 :            : 
     223                 :          0 : static void ImplSetParameterString( TransferableObjectDescriptor& rObjDesc, const DataFlavorEx& rFlavorEx )
     224                 :            : {
     225         [ #  # ]:          0 :     Reference< XMultiServiceFactory >       xFact( ::comphelper::getProcessServiceFactory() );
     226                 :          0 :     Reference< XMimeContentTypeFactory >    xMimeFact;
     227                 :            : 
     228                 :            :     try
     229                 :            :     {
     230         [ #  # ]:          0 :         if( xFact.is() )
     231                 :            :         {
     232         [ #  # ]:          0 :             xMimeFact = Reference< XMimeContentTypeFactory >( xFact->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.datatransfer.MimeContentTypeFactory" )) ),
     233 [ #  # ][ #  # ]:          0 :                                                               UNO_QUERY );
         [ #  # ][ #  # ]
     234                 :            :         }
     235                 :            : 
     236         [ #  # ]:          0 :         if( xMimeFact.is() )
     237                 :            :         {
     238 [ #  # ][ #  # ]:          0 :             Reference< XMimeContentType > xMimeType( xMimeFact->createMimeContentType( rFlavorEx.MimeType ) );
     239                 :            : 
     240         [ #  # ]:          0 :             if( xMimeType.is() )
     241                 :            :             {
     242         [ #  # ]:          0 :                 const ::rtl::OUString aClassNameString(RTL_CONSTASCII_USTRINGPARAM( "classname" ));
     243         [ #  # ]:          0 :                 const ::rtl::OUString aTypeNameString(RTL_CONSTASCII_USTRINGPARAM( "typename" ));
     244         [ #  # ]:          0 :                 const ::rtl::OUString aDisplayNameString(RTL_CONSTASCII_USTRINGPARAM( "displayname" ));
     245         [ #  # ]:          0 :                 const ::rtl::OUString aViewAspectString(RTL_CONSTASCII_USTRINGPARAM( "viewaspect" ));
     246         [ #  # ]:          0 :                 const ::rtl::OUString aWidthString(RTL_CONSTASCII_USTRINGPARAM( "width" ));
     247         [ #  # ]:          0 :                 const ::rtl::OUString aHeightString(RTL_CONSTASCII_USTRINGPARAM( "height" ));
     248         [ #  # ]:          0 :                 const ::rtl::OUString aPosXString(RTL_CONSTASCII_USTRINGPARAM( "posx" ));
     249         [ #  # ]:          0 :                 const ::rtl::OUString aPosYString(RTL_CONSTASCII_USTRINGPARAM( "posy" ));
     250                 :            : 
     251 [ #  # ][ #  # ]:          0 :                 if( xMimeType->hasParameter( aClassNameString ) )
                 [ #  # ]
     252                 :            :                 {
     253 [ #  # ][ #  # ]:          0 :                     rObjDesc.maClassName.MakeId( xMimeType->getParameterValue( aClassNameString ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     254                 :            :                 }
     255                 :            : 
     256 [ #  # ][ #  # ]:          0 :                 if( xMimeType->hasParameter( aTypeNameString ) )
                 [ #  # ]
     257                 :            :                 {
     258 [ #  # ][ #  # ]:          0 :                     rObjDesc.maTypeName = xMimeType->getParameterValue( aTypeNameString );
                 [ #  # ]
     259                 :            :                 }
     260                 :            : 
     261 [ #  # ][ #  # ]:          0 :                 if( xMimeType->hasParameter( aDisplayNameString ) )
                 [ #  # ]
     262                 :            :                 {
     263                 :            :                     // the display name might contain unacceptable characters, in this case they should be encoded
     264                 :            :                     // this seems to be the only parameter currently that might contain such characters
     265 [ #  # ][ #  # ]:          0 :                     rObjDesc.maDisplayName = ::rtl::Uri::decode( xMimeType->getParameterValue( aDisplayNameString ), rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
                 [ #  # ]
     266                 :            :                 }
     267                 :            : 
     268 [ #  # ][ #  # ]:          0 :                 if( xMimeType->hasParameter( aViewAspectString ) )
                 [ #  # ]
     269                 :            :                 {
     270 [ #  # ][ #  # ]:          0 :                     rObjDesc.mnViewAspect = static_cast< sal_uInt16 >( xMimeType->getParameterValue( aViewAspectString ).toInt32() );
     271                 :            :                 }
     272                 :            : 
     273 [ #  # ][ #  # ]:          0 :                 if( xMimeType->hasParameter( aWidthString ) )
                 [ #  # ]
     274                 :            :                 {
     275 [ #  # ][ #  # ]:          0 :                     rObjDesc.maSize.Width() = xMimeType->getParameterValue( aWidthString ).toInt32();
     276                 :            :                 }
     277                 :            : 
     278 [ #  # ][ #  # ]:          0 :                 if( xMimeType->hasParameter( aHeightString ) )
                 [ #  # ]
     279                 :            :                 {
     280 [ #  # ][ #  # ]:          0 :                     rObjDesc.maSize.Height() = xMimeType->getParameterValue( aHeightString ).toInt32();
     281                 :            :                 }
     282                 :            : 
     283 [ #  # ][ #  # ]:          0 :                 if( xMimeType->hasParameter( aPosXString ) )
                 [ #  # ]
     284                 :            :                 {
     285 [ #  # ][ #  # ]:          0 :                     rObjDesc.maDragStartPos.X() = xMimeType->getParameterValue( aPosXString ).toInt32();
     286                 :            :                 }
     287                 :            : 
     288 [ #  # ][ #  # ]:          0 :                 if( xMimeType->hasParameter( aPosYString ) )
                 [ #  # ]
     289                 :            :                 {
     290 [ #  # ][ #  # ]:          0 :                     rObjDesc.maDragStartPos.Y() = xMimeType->getParameterValue( aPosYString ).toInt32();
     291                 :          0 :                 }
     292         [ #  # ]:          0 :             }
     293                 :            :         }
     294                 :            :     }
     295         [ #  # ]:          0 :     catch( const ::com::sun::star::uno::Exception& )
     296                 :            :     {
     297                 :          0 :     }
     298                 :          0 : }
     299                 :            : 
     300                 :            : // -----------------------------------------
     301                 :            : // - TransferableHelper::TerminateListener -
     302                 :            : // -----------------------------------------
     303                 :            : 
     304                 :         46 : TransferableHelper::TerminateListener::TerminateListener( TransferableHelper& rTransferableHelper ) :
     305                 :         46 :     mrParent( rTransferableHelper )
     306                 :            : {
     307                 :         46 : }
     308                 :            : 
     309                 :            : // -----------------------------------------------------------------------------
     310                 :            : 
     311                 :         46 : TransferableHelper::TerminateListener::~TerminateListener()
     312                 :            : {
     313         [ -  + ]:         92 : }
     314                 :            : 
     315                 :            : // -----------------------------------------------------------------------------
     316                 :            : 
     317                 :          0 : void SAL_CALL TransferableHelper::TerminateListener::disposing( const EventObject& ) throw( RuntimeException )
     318                 :            : {
     319                 :          0 : }
     320                 :            : 
     321                 :            : // -----------------------------------------------------------------------------
     322                 :            : 
     323                 :          0 : void SAL_CALL TransferableHelper::TerminateListener::queryTermination( const EventObject& ) throw( TerminationVetoException, RuntimeException )
     324                 :            : {
     325                 :          0 : }
     326                 :            : 
     327                 :            : // -----------------------------------------------------------------------------
     328                 :            : 
     329                 :          0 : void SAL_CALL TransferableHelper::TerminateListener::notifyTermination( const EventObject& ) throw( RuntimeException )
     330                 :            : {
     331                 :          0 :     mrParent.ImplFlush();
     332                 :          0 : }
     333                 :            : 
     334                 :            : // ----------------------
     335                 :            : // - TransferableHelper -
     336                 :            : // ----------------------
     337                 :            : 
     338                 :         46 : TransferableHelper::TransferableHelper() :
     339         [ +  - ]:         46 :     mpFormats( new DataFlavorExVector ),
     340 [ +  - ][ +  - ]:         46 :     mpObjDesc( NULL )
     341                 :            : {
     342                 :         46 : }
     343                 :            : 
     344                 :            : // -----------------------------------------------------------------------------
     345                 :            : 
     346                 :         46 : TransferableHelper::~TransferableHelper()
     347                 :            : {
     348 [ +  + ][ +  - ]:         46 :     delete mpObjDesc;
     349         [ +  - ]:         46 :     delete mpFormats;
     350         [ -  + ]:         46 : }
     351                 :            : 
     352                 :            : // -----------------------------------------------------------------------------
     353                 :            : 
     354                 :          0 : Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor ) throw( UnsupportedFlavorException, IOException, RuntimeException )
     355                 :            : {
     356 [ #  # ][ #  # ]:          0 :     if( !maAny.hasValue() || !mpFormats->size() || ( maLastFormat != rFlavor.MimeType ) )
         [ #  # ][ #  # ]
     357                 :            :     {
     358         [ #  # ]:          0 :         const SolarMutexGuard aGuard;
     359                 :            : 
     360                 :          0 :         maLastFormat = rFlavor.MimeType;
     361                 :          0 :         maAny = Any();
     362                 :            : 
     363                 :            :         try
     364                 :            :         {
     365                 :          0 :             DataFlavor  aSubstFlavor;
     366                 :          0 :             sal_Bool    bDone = sal_False;
     367                 :            : 
     368                 :            :             // add formats if not already done
     369         [ #  # ]:          0 :             if( !mpFormats->size() )
     370         [ #  # ]:          0 :                 AddSupportedFormats();
     371                 :            : 
     372                 :            :             // check alien formats first and try to get a substitution format
     373 [ #  # ][ #  # ]:          0 :             if( SotExchange::GetFormatDataFlavor( FORMAT_STRING, aSubstFlavor ) &&
         [ #  # ][ #  # ]
     374         [ #  # ]:          0 :                 TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) )
     375                 :            :             {
     376         [ #  # ]:          0 :                 GetData( aSubstFlavor );
     377                 :          0 :                 bDone = maAny.hasValue();
     378                 :            :             }
     379 [ #  # ][ #  # ]:          0 :             else if( SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_BMP, aSubstFlavor ) &&
         [ #  # ][ #  # ]
                 [ #  # ]
     380         [ #  # ]:          0 :                      TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) &&
     381         [ #  # ]:          0 :                      SotExchange::GetFormatDataFlavor( FORMAT_BITMAP, aSubstFlavor ) )
     382                 :            :             {
     383         [ #  # ]:          0 :                 GetData( aSubstFlavor );
     384                 :          0 :                 bDone = sal_True;
     385                 :            :             }
     386 [ #  # ][ #  # ]:          0 :             else if( SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_EMF, aSubstFlavor ) &&
         [ #  # ][ #  # ]
                 [ #  # ]
     387         [ #  # ]:          0 :                      TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) &&
     388         [ #  # ]:          0 :                      SotExchange::GetFormatDataFlavor( FORMAT_GDIMETAFILE, aSubstFlavor ) )
     389                 :            :             {
     390         [ #  # ]:          0 :                 GetData( aSubstFlavor );
     391                 :            : 
     392         [ #  # ]:          0 :                 if( maAny.hasValue() )
     393                 :            :                 {
     394         [ #  # ]:          0 :                     Sequence< sal_Int8 > aSeq;
     395                 :            : 
     396 [ #  # ][ #  # ]:          0 :                     if( maAny >>= aSeq )
     397                 :            :                     {
     398 [ #  # ][ #  # ]:          0 :                         SvMemoryStream* pSrcStm = new SvMemoryStream( (char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_WRITE | STREAM_TRUNC );
     399         [ #  # ]:          0 :                         GDIMetaFile     aMtf;
     400                 :            : 
     401         [ #  # ]:          0 :                         *pSrcStm >> aMtf;
     402 [ #  # ][ #  # ]:          0 :                         delete pSrcStm;
     403                 :            : 
     404         [ #  # ]:          0 :                         Graphic         aGraphic( aMtf );
     405         [ #  # ]:          0 :                         SvMemoryStream  aDstStm( 65535, 65535 );
     406                 :            : 
     407 [ #  # ][ #  # ]:          0 :                         if( GraphicConverter::Export( aDstStm, aGraphic, CVT_EMF ) == ERRCODE_NONE )
     408                 :            :                         {
     409         [ #  # ]:          0 :                             maAny <<= ( aSeq = Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aDstStm.GetData() ),
     410 [ #  # ][ #  # ]:          0 :                                                                      aDstStm.Seek( STREAM_SEEK_TO_END ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     411                 :          0 :                             bDone = sal_True;
     412 [ #  # ][ #  # ]:          0 :                         }
                 [ #  # ]
     413         [ #  # ]:          0 :                     }
     414                 :            :                 }
     415                 :            :             }
     416 [ #  # ][ #  # ]:          0 :             else if( SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_WMF, aSubstFlavor ) &&
         [ #  # ][ #  # ]
                 [ #  # ]
     417         [ #  # ]:          0 :                      TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) &&
     418         [ #  # ]:          0 :                      SotExchange::GetFormatDataFlavor( FORMAT_GDIMETAFILE, aSubstFlavor ) )
     419                 :            :             {
     420         [ #  # ]:          0 :                 GetData( aSubstFlavor );
     421                 :            : 
     422         [ #  # ]:          0 :                 if( maAny.hasValue() )
     423                 :            :                 {
     424         [ #  # ]:          0 :                     Sequence< sal_Int8 > aSeq;
     425                 :            : 
     426 [ #  # ][ #  # ]:          0 :                     if( maAny >>= aSeq )
     427                 :            :                     {
     428 [ #  # ][ #  # ]:          0 :                         SvMemoryStream* pSrcStm = new SvMemoryStream( (char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_WRITE | STREAM_TRUNC );
     429         [ #  # ]:          0 :                         GDIMetaFile     aMtf;
     430                 :            : 
     431         [ #  # ]:          0 :                         *pSrcStm >> aMtf;
     432 [ #  # ][ #  # ]:          0 :                         delete pSrcStm;
     433                 :            : 
     434         [ #  # ]:          0 :                         SvMemoryStream  aDstStm( 65535, 65535 );
     435                 :            : 
     436                 :            :                         // taking wmf without file header
     437 [ #  # ][ #  # ]:          0 :                         if ( ConvertGDIMetaFileToWMF( aMtf, aDstStm, NULL, sal_False ) )
     438                 :            :                         {
     439         [ #  # ]:          0 :                             maAny <<= ( aSeq = Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aDstStm.GetData() ),
     440 [ #  # ][ #  # ]:          0 :                                                                      aDstStm.Seek( STREAM_SEEK_TO_END ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     441                 :          0 :                             bDone = sal_True;
     442 [ #  # ][ #  # ]:          0 :                         }
     443         [ #  # ]:          0 :                     }
     444                 :            :                 }
     445                 :            :             }
     446                 :            : 
     447                 :            :             // reset Any if substitute doesn't work
     448 [ #  # ][ #  # ]:          0 :             if( !bDone && maAny.hasValue() )
                 [ #  # ]
     449                 :          0 :                 maAny = Any();
     450                 :            : 
     451                 :            :             // if any is not yet filled, use standard format
     452         [ #  # ]:          0 :             if( !maAny.hasValue() )
     453 [ #  # ][ #  # ]:          0 :                 GetData( rFlavor );
     454                 :            : 
     455                 :            : #ifdef DEBUG
     456                 :            :             if( maAny.hasValue() && ::com::sun::star::uno::TypeClass_STRING != maAny.getValueType().getTypeClass() )
     457                 :            :                 fprintf( stderr, "TransferableHelper delivers sequence of data [ %s ]\n", rtl::OUStringToOString(rFlavor.MimeType, RTL_TEXTENCODING_ASCII_US).getStr() );
     458                 :            : #endif
     459                 :            :         }
     460         [ #  # ]:          0 :         catch( const ::com::sun::star::uno::Exception& )
     461                 :            :         {
     462                 :            :         }
     463                 :            : 
     464         [ #  # ]:          0 :         if( !maAny.hasValue() )
     465 [ #  # ][ #  # ]:          0 :             throw UnsupportedFlavorException();
     466                 :            :     }
     467                 :            : 
     468                 :          0 :     return maAny;
     469                 :            : }
     470                 :            : 
     471                 :            : // -----------------------------------------------------------------------------
     472                 :            : 
     473                 :          0 : Sequence< DataFlavor > SAL_CALL TransferableHelper::getTransferDataFlavors() throw( RuntimeException )
     474                 :            : {
     475         [ #  # ]:          0 :     const SolarMutexGuard aGuard;
     476                 :            : 
     477                 :            :     try
     478                 :            :     {
     479         [ #  # ]:          0 :         if( !mpFormats->size() )
     480         [ #  # ]:          0 :             AddSupportedFormats();
     481                 :            :     }
     482         [ #  # ]:          0 :     catch( const ::com::sun::star::uno::Exception& )
     483                 :            :     {
     484                 :            :     }
     485                 :            : 
     486         [ #  # ]:          0 :     Sequence< DataFlavor >          aRet( mpFormats->size() );
     487                 :          0 :     DataFlavorExVector::iterator    aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
     488                 :          0 :     sal_uInt32                      nCurPos = 0;
     489                 :            : 
     490 [ #  # ][ #  # ]:          0 :     while( aIter != aEnd )
     491                 :            :     {
     492 [ #  # ][ #  # ]:          0 :         aRet[ nCurPos++ ] = *aIter++;
     493                 :            :     }
     494                 :            : 
     495 [ #  # ][ #  # ]:          0 :     return aRet;
     496                 :            : }
     497                 :            : 
     498                 :            : // -----------------------------------------------------------------------------
     499                 :            : 
     500                 :          0 : sal_Bool SAL_CALL TransferableHelper::isDataFlavorSupported( const DataFlavor& rFlavor ) throw( RuntimeException )
     501                 :            : {
     502         [ #  # ]:          0 :     const SolarMutexGuard aGuard;
     503                 :          0 :     sal_Bool            bRet = sal_False;
     504                 :            : 
     505                 :            :     try
     506                 :            :     {
     507         [ #  # ]:          0 :         if( !mpFormats->size() )
     508         [ #  # ]:          0 :             AddSupportedFormats();
     509                 :            :     }
     510         [ #  # ]:          0 :     catch( const ::com::sun::star::uno::Exception& )
     511                 :            :     {
     512                 :            :     }
     513                 :            : 
     514                 :          0 :     DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
     515                 :            : 
     516 [ #  # ][ #  # ]:          0 :     while( aIter != aEnd )
     517                 :            :     {
     518 [ #  # ][ #  # ]:          0 :         if( TransferableDataHelper::IsEqual( *aIter, rFlavor ) )
     519                 :            :         {
     520                 :          0 :             aIter = aEnd;
     521                 :          0 :             bRet = sal_True;
     522                 :            :         }
     523                 :            :         else
     524         [ #  # ]:          0 :             aIter++;
     525                 :            :     }
     526                 :            : 
     527 [ #  # ][ #  # ]:          0 :     return bRet;
     528                 :            : }
     529                 :            : 
     530                 :            : // -----------------------------------------------------------------------------
     531                 :            : 
     532                 :         46 : void SAL_CALL TransferableHelper::lostOwnership( const Reference< XClipboard >&, const Reference< XTransferable >& ) throw( RuntimeException )
     533                 :            : {
     534         [ +  - ]:         46 :     const SolarMutexGuard aGuard;
     535                 :            : 
     536                 :            :     try
     537                 :            :     {
     538         [ +  - ]:         46 :         if( mxTerminateListener.is() )
     539                 :            :         {
     540         [ +  - ]:         46 :             Reference< XMultiServiceFactory > xFact( ::comphelper::getProcessServiceFactory() );
     541                 :            : 
     542         [ +  - ]:         46 :             if( xFact.is() )
     543                 :            :             {
     544 [ +  - ][ +  - ]:         46 :                 Reference< XDesktop > xDesktop( xFact->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" )) ), UNO_QUERY );
         [ +  - ][ +  - ]
     545                 :            : 
     546         [ +  - ]:         46 :                 if( xDesktop.is() )
     547 [ +  - ][ +  - ]:         46 :                     xDesktop->removeTerminateListener( mxTerminateListener );
     548                 :            :             }
     549                 :            : 
     550 [ +  - ][ #  # ]:         46 :             mxTerminateListener = Reference< XTerminateListener >();
     551                 :            :         }
     552                 :            : 
     553         [ +  - ]:         46 :         ObjectReleased();
     554                 :            :     }
     555         [ #  # ]:          0 :     catch( const ::com::sun::star::uno::Exception& )
     556                 :            :     {
     557         [ +  - ]:         46 :     }
     558                 :         46 : }
     559                 :            : 
     560                 :            : // -----------------------------------------------------------------------------
     561                 :            : 
     562                 :          0 : void SAL_CALL TransferableHelper::disposing( const EventObject& ) throw( RuntimeException )
     563                 :            : {
     564                 :          0 : }
     565                 :            : 
     566                 :            : // -----------------------------------------------------------------------------
     567                 :            : 
     568                 :          0 : void SAL_CALL TransferableHelper::dragDropEnd( const DragSourceDropEvent& rDSDE ) throw( RuntimeException )
     569                 :            : {
     570         [ #  # ]:          0 :     const SolarMutexGuard aGuard;
     571                 :            : 
     572                 :            :     try
     573                 :            :     {
     574 [ #  # ][ #  # ]:          0 :         DragFinished( rDSDE.DropSuccess ? ( rDSDE.DropAction & ~DNDConstants::ACTION_DEFAULT ) : DNDConstants::ACTION_NONE );
     575         [ #  # ]:          0 :         ObjectReleased();
     576                 :            :     }
     577         [ #  # ]:          0 :     catch( const ::com::sun::star::uno::Exception& )
     578                 :            :     {
     579         [ #  # ]:          0 :     }
     580         [ #  # ]:          0 : }
     581                 :            : 
     582                 :            : // -----------------------------------------------------------------------------
     583                 :            : 
     584                 :          0 : void SAL_CALL TransferableHelper::dragEnter( const DragSourceDragEvent& ) throw( RuntimeException )
     585                 :            : {
     586                 :          0 : }
     587                 :            : 
     588                 :            : // -----------------------------------------------------------------------------
     589                 :            : 
     590                 :          0 : void SAL_CALL TransferableHelper::dragExit( const DragSourceEvent& ) throw( RuntimeException )
     591                 :            : {
     592                 :          0 : }
     593                 :            : 
     594                 :            : // -----------------------------------------------------------------------------
     595                 :            : 
     596                 :          0 : void SAL_CALL TransferableHelper::dragOver( const DragSourceDragEvent& ) throw( RuntimeException )
     597                 :            : {
     598                 :          0 : }
     599                 :            : 
     600                 :            : // -----------------------------------------------------------------------------
     601                 :            : 
     602                 :          0 : void SAL_CALL TransferableHelper::dropActionChanged( const DragSourceDragEvent& ) throw( RuntimeException )
     603                 :            : {
     604                 :          0 : }
     605                 :            : 
     606                 :            : // -----------------------------------------------------------------------------
     607                 :            : 
     608                 :          0 : sal_Int64 SAL_CALL TransferableHelper::getSomething( const Sequence< sal_Int8 >& rId ) throw( RuntimeException )
     609                 :            : {
     610                 :            :     sal_Int64 nRet;
     611                 :            : 
     612   [ #  #  #  # ]:          0 :     if( ( rId.getLength() == 16 ) &&
                 [ #  # ]
     613                 :          0 :         ( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
     614                 :            :     {
     615                 :          0 :         nRet = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
     616                 :            :     }
     617                 :            :     else
     618                 :          0 :         nRet = 0;
     619                 :            : 
     620                 :          0 :     return nRet;
     621                 :            : }
     622                 :            : 
     623                 :            : // -----------------------------------------------------------------------------
     624                 :            : 
     625                 :          0 : void TransferableHelper::ImplFlush()
     626                 :            : {
     627         [ #  # ]:          0 :     if( mxClipboard.is() )
     628                 :            :     {
     629         [ #  # ]:          0 :         Reference< XFlushableClipboard >    xFlushableClipboard( mxClipboard, UNO_QUERY );
     630         [ #  # ]:          0 :         const sal_uInt32                    nRef = Application::ReleaseSolarMutex();
     631                 :            : 
     632                 :            :         try
     633                 :            :         {
     634         [ #  # ]:          0 :             if( xFlushableClipboard.is() )
     635 [ #  # ][ #  # ]:          0 :                  xFlushableClipboard->flushClipboard();
     636                 :            :         }
     637         [ #  # ]:          0 :         catch( const ::com::sun::star::uno::Exception& )
     638                 :            :         {
     639                 :            :             OSL_FAIL( "Could not flush clipboard" );
     640                 :            :         }
     641                 :            : 
     642         [ #  # ]:          0 :         Application::AcquireSolarMutex( nRef );
     643                 :            :     }
     644         [ #  # ]:          0 : }
     645                 :            : 
     646                 :            : // -----------------------------------------------------------------------------
     647                 :            : 
     648                 :          0 : void TransferableHelper::AddFormat( SotFormatStringId nFormat )
     649                 :            : {
     650                 :          0 :     DataFlavor aFlavor;
     651                 :            : 
     652 [ #  # ][ #  # ]:          0 :     if( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) )
     653         [ #  # ]:          0 :         AddFormat( aFlavor );
     654                 :          0 : }
     655                 :            : 
     656                 :            : // -----------------------------------------------------------------------------
     657                 :            : 
     658                 :          0 : void TransferableHelper::AddFormat( const DataFlavor& rFlavor )
     659                 :            : {
     660                 :          0 :     DataFlavorExVector::iterator    aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
     661                 :          0 :     sal_Bool                        bAdd = sal_True;
     662                 :            : 
     663 [ #  # ][ #  # ]:          0 :     while( aIter != aEnd )
     664                 :            :     {
     665 [ #  # ][ #  # ]:          0 :         if( TransferableDataHelper::IsEqual( *aIter, rFlavor ) )
     666                 :            :         {
     667                 :            :             // update MimeType for SOT_FORMATSTR_ID_OBJECTDESCRIPTOR in every case
     668 [ #  # ][ #  # ]:          0 :             if( ( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR == aIter->mnSotId ) && mpObjDesc )
                 [ #  # ]
     669                 :            :             {
     670                 :          0 :                 DataFlavor aObjDescFlavor;
     671                 :            : 
     672         [ #  # ]:          0 :                 SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDescFlavor );
     673                 :          0 :                 aIter->MimeType = aObjDescFlavor.MimeType;
     674         [ #  # ]:          0 :                 aIter->MimeType += ::ImplGetParameterString( *mpObjDesc );
     675                 :            : 
     676                 :            : #ifdef DEBUG
     677                 :            :                 fprintf( stderr, "TransferableHelper exchanged objectdescriptor [ %s ]\n",
     678                 :            :                          rtl::OUStringToOString(aIter->MimeType, RTL_TEXTENCODING_ASCII_US).getStr() );
     679                 :            : #endif
     680                 :            :             }
     681                 :            : 
     682                 :          0 :             aIter = aEnd;
     683                 :          0 :             bAdd = sal_False;
     684                 :            :         }
     685                 :            :         else
     686         [ #  # ]:          0 :             aIter++;
     687                 :            :     }
     688                 :            : 
     689         [ #  # ]:          0 :     if( bAdd )
     690                 :            :     {
     691                 :          0 :         DataFlavorEx   aFlavorEx;
     692                 :          0 :         DataFlavor     aObjDescFlavor;
     693                 :            : 
     694                 :          0 :         aFlavorEx.MimeType = rFlavor.MimeType;
     695                 :          0 :         aFlavorEx.HumanPresentableName = rFlavor.HumanPresentableName;
     696                 :          0 :         aFlavorEx.DataType = rFlavor.DataType;
     697         [ #  # ]:          0 :         aFlavorEx.mnSotId = SotExchange::RegisterFormat( rFlavor );
     698                 :            : 
     699 [ #  # ][ #  # ]:          0 :         if( ( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR == aFlavorEx.mnSotId ) && mpObjDesc )
     700         [ #  # ]:          0 :             aFlavorEx.MimeType += ::ImplGetParameterString( *mpObjDesc );
     701                 :            : 
     702         [ #  # ]:          0 :         mpFormats->push_back( aFlavorEx );
     703                 :            : 
     704         [ #  # ]:          0 :         if( FORMAT_BITMAP == aFlavorEx.mnSotId )
     705                 :            :         {
     706         [ #  # ]:          0 :             AddFormat( SOT_FORMATSTR_ID_BMP );
     707                 :            :         }
     708         [ #  # ]:          0 :         else if( FORMAT_GDIMETAFILE == aFlavorEx.mnSotId )
     709                 :            :         {
     710         [ #  # ]:          0 :             AddFormat( SOT_FORMATSTR_ID_EMF );
     711         [ #  # ]:          0 :             AddFormat( SOT_FORMATSTR_ID_WMF );
     712                 :          0 :         }
     713                 :            :     }
     714                 :          0 : }
     715                 :            : 
     716                 :            : // -----------------------------------------------------------------------------
     717                 :            : 
     718                 :          0 : void TransferableHelper::RemoveFormat( SotFormatStringId nFormat )
     719                 :            : {
     720                 :          0 :     DataFlavor aFlavor;
     721                 :            : 
     722 [ #  # ][ #  # ]:          0 :     if( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) )
     723         [ #  # ]:          0 :         RemoveFormat( aFlavor );
     724                 :          0 : }
     725                 :            : 
     726                 :            : // -----------------------------------------------------------------------------
     727                 :            : 
     728                 :          0 : void TransferableHelper::RemoveFormat( const DataFlavor& rFlavor )
     729                 :            : {
     730                 :          0 :     DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
     731                 :            : 
     732 [ #  # ][ #  # ]:          0 :     while( aIter != aEnd )
     733                 :            :     {
     734 [ #  # ][ #  # ]:          0 :         if( TransferableDataHelper::IsEqual( *aIter, rFlavor ) )
     735                 :            :         {
     736         [ #  # ]:          0 :             aIter = mpFormats->erase( aIter );
     737                 :          0 :             aEnd = mpFormats->end();
     738                 :            :         }
     739                 :            :         else
     740                 :          0 :             ++aIter;
     741                 :            :     }
     742                 :          0 : }
     743                 :            : 
     744                 :            : // -----------------------------------------------------------------------------
     745                 :            : 
     746                 :         22 : sal_Bool TransferableHelper::HasFormat( SotFormatStringId nFormat )
     747                 :            : {
     748                 :         22 :     DataFlavorExVector::iterator    aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
     749                 :         22 :     sal_Bool                        bRet = sal_False;
     750                 :            : 
     751 [ +  - ][ -  + ]:         22 :     while( aIter != aEnd )
     752                 :            :     {
     753         [ #  # ]:          0 :         if( nFormat == (*aIter).mnSotId )
     754                 :            :         {
     755                 :          0 :             aIter = aEnd;
     756                 :          0 :             bRet = sal_True;
     757                 :            :         }
     758                 :            :         else
     759                 :          0 :             ++aIter;
     760                 :            :     }
     761                 :            : 
     762                 :         22 :     return bRet;
     763                 :            : }
     764                 :            : 
     765                 :            : // -----------------------------------------------------------------------------
     766                 :            : 
     767                 :          0 : void TransferableHelper::ClearFormats()
     768                 :            : {
     769                 :          0 :     mpFormats->clear();
     770                 :          0 :     maAny.clear();
     771                 :          0 : }
     772                 :            : 
     773                 :            : // -----------------------------------------------------------------------------
     774                 :            : 
     775                 :          0 : sal_Bool TransferableHelper::SetAny( const Any& rAny, const DataFlavor& )
     776                 :            : {
     777                 :          0 :     maAny = rAny;
     778                 :          0 :     return( maAny.hasValue() );
     779                 :            : }
     780                 :            : 
     781                 :            : // -----------------------------------------------------------------------------
     782                 :            : 
     783                 :          0 : sal_Bool TransferableHelper::SetString( const ::rtl::OUString& rString, const DataFlavor& rFlavor )
     784                 :            : {
     785                 :          0 :     DataFlavor aFileFlavor;
     786                 :            : 
     787 [ #  # ][ #  # ]:          0 :     if( !rString.isEmpty() &&
         [ #  # ][ #  # ]
     788         [ #  # ]:          0 :         SotExchange::GetFormatDataFlavor( FORMAT_FILE, aFileFlavor ) &&
     789         [ #  # ]:          0 :         TransferableDataHelper::IsEqual( aFileFlavor, rFlavor ) )
     790                 :            :     {
     791 [ #  # ][ #  # ]:          0 :         const rtl::OString aByteStr(rtl::OUStringToOString(rString, osl_getThreadTextEncoding()));
     792         [ #  # ]:          0 :         Sequence< sal_Int8 >    aSeq( aByteStr.getLength() + 1 );
     793                 :            : 
     794 [ #  # ][ #  # ]:          0 :         rtl_copyMemory( aSeq.getArray(), aByteStr.getStr(), aByteStr.getLength() );
     795         [ #  # ]:          0 :         aSeq[ aByteStr.getLength() ] = 0;
     796 [ #  # ][ #  # ]:          0 :         maAny <<= aSeq;
     797                 :            :     }
     798                 :            :     else
     799         [ #  # ]:          0 :         maAny <<= rString;
     800                 :            : 
     801                 :          0 :     return( maAny.hasValue() );
     802                 :            : }
     803                 :            : 
     804                 :            : // -----------------------------------------------------------------------------
     805                 :            : 
     806                 :          0 : sal_Bool TransferableHelper::SetBitmap( const Bitmap& rBitmap, const DataFlavor& )
     807                 :            : {
     808         [ #  # ]:          0 :     if( !rBitmap.IsEmpty() )
     809                 :            :     {
     810         [ #  # ]:          0 :         SvMemoryStream aMemStm( 65535, 65535 );
     811                 :            : 
     812         [ #  # ]:          0 :         aMemStm << rBitmap;
     813 [ #  # ][ #  # ]:          0 :         maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     814                 :            :     }
     815                 :            : 
     816                 :          0 :     return( maAny.hasValue() );
     817                 :            : }
     818                 :            : 
     819                 :            : // -----------------------------------------------------------------------------
     820                 :            : 
     821                 :          0 : sal_Bool TransferableHelper::SetGDIMetaFile( const GDIMetaFile& rMtf, const DataFlavor& )
     822                 :            : {
     823         [ #  # ]:          0 :     if( rMtf.GetActionSize() )
     824                 :            :     {
     825         [ #  # ]:          0 :         SvMemoryStream aMemStm( 65535, 65535 );
     826                 :            : 
     827         [ #  # ]:          0 :         ( (GDIMetaFile&) rMtf ).Write( aMemStm );
     828 [ #  # ][ #  # ]:          0 :         maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     829                 :            :     }
     830                 :            : 
     831                 :          0 :     return( maAny.hasValue() );
     832                 :            : }
     833                 :            : 
     834                 :            : // -----------------------------------------------------------------------------
     835                 :            : 
     836                 :          0 : sal_Bool TransferableHelper::SetGraphic( const Graphic& rGraphic, const DataFlavor& )
     837                 :            : {
     838         [ #  # ]:          0 :     if( rGraphic.GetType() != GRAPHIC_NONE )
     839                 :            :     {
     840         [ #  # ]:          0 :         SvMemoryStream aMemStm( 65535, 65535 );
     841                 :            : 
     842                 :          0 :         aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
     843                 :          0 :         aMemStm.SetCompressMode( COMPRESSMODE_NATIVE );
     844         [ #  # ]:          0 :         aMemStm << rGraphic;
     845 [ #  # ][ #  # ]:          0 :         maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     846                 :            :     }
     847                 :            : 
     848                 :          0 :     return( maAny.hasValue() );
     849                 :            : }
     850                 :            : 
     851                 :            : // -----------------------------------------------------------------------------
     852                 :            : 
     853                 :          0 : sal_Bool TransferableHelper::SetImageMap( const ImageMap& rIMap, const ::com::sun::star::datatransfer::DataFlavor& )
     854                 :            : {
     855         [ #  # ]:          0 :     SvMemoryStream aMemStm( 8192, 8192 );
     856                 :            : 
     857                 :          0 :     aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
     858 [ #  # ][ #  # ]:          0 :     rIMap.Write( aMemStm, String() );
                 [ #  # ]
     859 [ #  # ][ #  # ]:          0 :     maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     860                 :            : 
     861         [ #  # ]:          0 :     return( maAny.hasValue() );
     862                 :            : }
     863                 :            : 
     864                 :            : // -----------------------------------------------------------------------------
     865                 :            : 
     866                 :          0 : sal_Bool TransferableHelper::SetTransferableObjectDescriptor( const TransferableObjectDescriptor& rDesc,
     867                 :            :                                                               const ::com::sun::star::datatransfer::DataFlavor& )
     868                 :            : {
     869         [ #  # ]:          0 :     PrepareOLE( rDesc );
     870                 :            : 
     871         [ #  # ]:          0 :     SvMemoryStream aMemStm( 1024, 1024 );
     872                 :            : 
     873         [ #  # ]:          0 :     aMemStm << rDesc;
     874 [ #  # ][ #  # ]:          0 :     maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Tell() );
         [ #  # ][ #  # ]
     875                 :            : 
     876         [ #  # ]:          0 :     return( maAny.hasValue() );
     877                 :            :  }
     878                 :            : 
     879                 :            : // -----------------------------------------------------------------------------
     880                 :            : 
     881                 :          0 : sal_Bool TransferableHelper::SetINetBookmark( const INetBookmark& rBmk,
     882                 :            :                                               const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
     883                 :            : {
     884                 :          0 :     rtl_TextEncoding eSysCSet = osl_getThreadTextEncoding();
     885                 :            : 
     886   [ #  #  #  #  :          0 :     switch( SotExchange::GetFormat( rFlavor ) )
                      # ]
     887                 :            :     {
     888                 :            :         case( SOT_FORMATSTR_ID_SOLK ):
     889                 :            :         {
     890 [ #  # ][ #  # ]:          0 :             rtl::OString sURL(rtl::OUStringToOString(rBmk.GetURL(), eSysCSet));
     891 [ #  # ][ #  # ]:          0 :             rtl::OString sDesc(rtl::OUStringToOString(rBmk.GetDescription(), eSysCSet));
     892                 :          0 :             rtl::OStringBuffer sOut;
     893         [ #  # ]:          0 :             sOut.append(sURL.getLength());
     894 [ #  # ][ #  # ]:          0 :             sOut.append('@').append(sURL);
     895         [ #  # ]:          0 :             sOut.append(sDesc.getLength());
     896 [ #  # ][ #  # ]:          0 :             sOut.append('@').append(sDesc);
     897                 :            : 
     898         [ #  # ]:          0 :             Sequence< sal_Int8 > aSeq(sOut.getLength());
     899         [ #  # ]:          0 :             memcpy(aSeq.getArray(), sOut.getStr(), sOut.getLength());
     900 [ #  # ][ #  # ]:          0 :             maAny <<= aSeq;
     901                 :            :         }
     902                 :          0 :         break;
     903                 :            : 
     904                 :            :         case( FORMAT_STRING ):
     905         [ #  # ]:          0 :             maAny <<= ::rtl::OUString( rBmk.GetURL() );
     906                 :          0 :             break;
     907                 :            : 
     908                 :            :         case( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ):
     909                 :            :         {
     910 [ #  # ][ #  # ]:          0 :             rtl::OString sURL(rtl::OUStringToOString(rBmk.GetURL(), eSysCSet));
     911         [ #  # ]:          0 :             Sequence< sal_Int8 > aSeq( sURL.getLength() );
     912         [ #  # ]:          0 :             memcpy( aSeq.getArray(), sURL.getStr(), sURL.getLength() );
     913 [ #  # ][ #  # ]:          0 :             maAny <<= aSeq;
     914                 :            :         }
     915                 :          0 :         break;
     916                 :            : 
     917                 :            :         case( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ):
     918                 :            :         {
     919         [ #  # ]:          0 :             Sequence< sal_Int8 > aSeq( 2048 );
     920                 :            : 
     921         [ #  # ]:          0 :             memset( aSeq.getArray(), 0, 2048 );
     922 [ #  # ][ #  # ]:          0 :             strcpy( reinterpret_cast< char* >( aSeq.getArray() ), rtl::OUStringToOString(rBmk.GetURL(), eSysCSet).getStr() );
                 [ #  # ]
     923 [ #  # ][ #  # ]:          0 :             strcpy( reinterpret_cast< char* >( aSeq.getArray() ) + 1024, rtl::OUStringToOString(rBmk.GetDescription(), eSysCSet).getStr() );
                 [ #  # ]
     924                 :            : 
     925 [ #  # ][ #  # ]:          0 :             maAny <<= aSeq;
     926                 :            :         }
     927                 :          0 :         break;
     928                 :            : 
     929                 :            : #ifdef WNT
     930                 :            :         case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
     931                 :            :         {
     932                 :            :             Sequence< sal_Int8 >    aSeq( sizeof( FILEGROUPDESCRIPTOR ) );
     933                 :            :             FILEGROUPDESCRIPTOR*    pFDesc = (FILEGROUPDESCRIPTOR*) aSeq.getArray();
     934                 :            :             FILEDESCRIPTOR&         rFDesc1 = pFDesc->fgd[ 0 ];
     935                 :            : 
     936                 :            :             pFDesc->cItems = 1;
     937                 :            :             memset( &rFDesc1, 0, sizeof( FILEDESCRIPTOR ) );
     938                 :            :             rFDesc1.dwFlags = FD_LINKUI;
     939                 :            : 
     940                 :            :             rtl::OStringBuffer aStr(rtl::OUStringToOString(
     941                 :            :                 rBmk.GetDescription(), eSysCSet));
     942                 :            :             for( sal_uInt16 nChar = 0; nChar < aStr.getLength(); ++nChar )
     943                 :            :                 if( strchr( "\\/:*?\"<>|", aStr[nChar] ) )
     944                 :            :                     aStr.remove(nChar--, 1);
     945                 :            : 
     946                 :            :             aStr.insert(0, RTL_CONSTASCII_STRINGPARAM("Shortcut to "));
     947                 :            :             aStr.append(RTL_CONSTASCII_STRINGPARAM(".URL"));
     948                 :            :             strcpy( rFDesc1.cFileName, aStr.getStr() );
     949                 :            : 
     950                 :            :             maAny <<= aSeq;
     951                 :            :         }
     952                 :            :         break;
     953                 :            : 
     954                 :            :         case SOT_FORMATSTR_ID_FILECONTENT:
     955                 :            :         {
     956                 :            :             String aStr( RTL_CONSTASCII_USTRINGPARAM( "[InternetShortcut]\x0aURL=" ) );
     957                 :            :             maAny <<= ::rtl::OUString( aStr += rBmk.GetURL() );
     958                 :            :         }
     959                 :            :         break;
     960                 :            : #endif
     961                 :            : 
     962                 :            :         default:
     963                 :          0 :         break;
     964                 :            :     }
     965                 :            : 
     966                 :          0 :     return( maAny.hasValue() );
     967                 :            : }
     968                 :            : 
     969                 :            : // -----------------------------------------------------------------------------
     970                 :            : 
     971                 :          0 : sal_Bool TransferableHelper::SetINetImage( const INetImage& rINtImg,
     972                 :            :                                            const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
     973                 :            : {
     974         [ #  # ]:          0 :     SvMemoryStream aMemStm( 1024, 1024 );
     975                 :            : 
     976                 :          0 :     aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
     977 [ #  # ][ #  # ]:          0 :     rINtImg.Write( aMemStm, SotExchange::GetFormat( rFlavor ) );
     978                 :            : 
     979 [ #  # ][ #  # ]:          0 :     maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     980                 :            : 
     981         [ #  # ]:          0 :     return( maAny.hasValue() );
     982                 :            : }
     983                 :            : 
     984                 :            : // -----------------------------------------------------------------------------
     985                 :            : 
     986                 :          0 : sal_Bool TransferableHelper::SetObject( void* pUserObject, sal_uInt32 nUserObjectId, const DataFlavor& rFlavor )
     987                 :            : {
     988 [ #  # ][ #  # ]:          0 :     SotStorageStreamRef xStm( new SotStorageStream( String() ) );
         [ #  # ][ #  # ]
     989                 :            : 
     990                 :          0 :     xStm->SetVersion( SOFFICE_FILEFORMAT_50 );
     991                 :            : 
     992 [ #  # ][ #  # ]:          0 :     if( pUserObject && WriteObject( xStm, pUserObject, nUserObjectId, rFlavor ) )
         [ #  # ][ #  # ]
     993                 :            :     {
     994         [ #  # ]:          0 :         const sal_uInt32        nLen = xStm->Seek( STREAM_SEEK_TO_END );
     995         [ #  # ]:          0 :         Sequence< sal_Int8 >    aSeq( nLen );
     996                 :            : 
     997         [ #  # ]:          0 :         xStm->Seek( STREAM_SEEK_TO_BEGIN );
     998 [ #  # ][ #  # ]:          0 :         xStm->Read( aSeq.getArray(),  nLen );
     999                 :            : 
    1000 [ #  # ][ #  # ]:          0 :         if( nLen && ( SotExchange::GetFormat( rFlavor ) == SOT_FORMAT_STRING ) )
         [ #  # ][ #  # ]
    1001                 :            :         {
    1002                 :            :             //JP 24.7.2001: as I know was this only for the writer application and this
    1003                 :            :             //              writes now UTF16 format into the stream
    1004                 :            :             //JP 6.8.2001:  and now it writes UTF8 because then exist no problem with
    1005                 :            :             //              little / big endians! - Bug 88121
    1006 [ #  # ][ #  # ]:          0 :             maAny <<= ::rtl::OUString( reinterpret_cast< const sal_Char* >( aSeq.getConstArray() ), nLen - 1, RTL_TEXTENCODING_UTF8 );
    1007                 :            :         }
    1008                 :            :         else
    1009 [ #  # ][ #  # ]:          0 :             maAny <<= aSeq;
    1010                 :            :     }
    1011                 :            : 
    1012         [ #  # ]:          0 :     return( maAny.hasValue() );
    1013                 :            : }
    1014                 :            : 
    1015                 :            : // -----------------------------------------------------------------------------
    1016                 :            : 
    1017                 :          0 : sal_Bool TransferableHelper::WriteObject( SotStorageStreamRef&, void*, sal_uInt32, const DataFlavor& )
    1018                 :            : {
    1019                 :            :     OSL_FAIL( "TransferableHelper::WriteObject( ... ) not implemented" );
    1020                 :          0 :     return sal_False;
    1021                 :            : }
    1022                 :            : 
    1023                 :            : // -----------------------------------------------------------------------------
    1024                 :            : 
    1025                 :          0 : void TransferableHelper::DragFinished( sal_Int8 )
    1026                 :            : {
    1027                 :          0 : }
    1028                 :            : 
    1029                 :            : // -----------------------------------------------------------------------------
    1030                 :            : 
    1031                 :         24 : void TransferableHelper::ObjectReleased()
    1032                 :            : {
    1033                 :         24 : }
    1034                 :            : 
    1035                 :            : // -----------------------------------------------------------------------------
    1036                 :            : 
    1037                 :         22 : void TransferableHelper::PrepareOLE( const TransferableObjectDescriptor& rObjDesc )
    1038                 :            : {
    1039         [ -  + ]:         22 :     delete mpObjDesc;
    1040         [ +  - ]:         22 :     mpObjDesc = new TransferableObjectDescriptor( rObjDesc );
    1041                 :            : 
    1042         [ -  + ]:         22 :     if( HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
    1043                 :          0 :         AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
    1044                 :         22 : }
    1045                 :            : 
    1046                 :            : // -----------------------------------------------------------------------------
    1047                 :            : 
    1048                 :          0 : void TransferableHelper::CopyToClipboard( Window *pWindow ) const
    1049                 :            : {
    1050                 :            :     DBG_ASSERT( pWindow, "Window pointer is NULL" );
    1051                 :          0 :     Reference< XClipboard > xClipboard;
    1052                 :            : 
    1053         [ #  # ]:          0 :     if( pWindow )
    1054 [ #  # ][ #  # ]:          0 :         xClipboard = pWindow->GetClipboard();
    1055                 :            : 
    1056         [ #  # ]:          0 :     if( xClipboard.is() )
    1057         [ #  # ]:          0 :         mxClipboard = xClipboard;
    1058                 :            : 
    1059 [ #  # ][ #  # ]:          0 :     if( mxClipboard.is() && !mxTerminateListener.is() )
                 [ #  # ]
    1060                 :            :     {
    1061         [ #  # ]:          0 :         const sal_uInt32 nRef = Application::ReleaseSolarMutex();
    1062                 :            : 
    1063                 :            :         try
    1064                 :            :         {
    1065                 :          0 :             TransferableHelper*                 pThis = const_cast< TransferableHelper* >( this );
    1066         [ #  # ]:          0 :             Reference< XMultiServiceFactory >   xFact( ::comphelper::getProcessServiceFactory() );
    1067                 :            : 
    1068         [ #  # ]:          0 :             if( xFact.is() )
    1069                 :            :             {
    1070 [ #  # ][ #  # ]:          0 :                 Reference< XDesktop > xDesktop( xFact->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" )) ), UNO_QUERY );
         [ #  # ][ #  # ]
    1071                 :            : 
    1072         [ #  # ]:          0 :                 if( xDesktop.is() )
    1073 [ #  # ][ #  # ]:          0 :                     xDesktop->addTerminateListener( pThis->mxTerminateListener = new TerminateListener( *pThis ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1074                 :            :             }
    1075                 :            : 
    1076 [ #  # ][ #  # ]:          0 :             mxClipboard->setContents( pThis, pThis );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1077                 :            :         }
    1078         [ #  # ]:          0 :         catch( const ::com::sun::star::uno::Exception& )
    1079                 :            :         {
    1080                 :            :         }
    1081                 :            : 
    1082         [ #  # ]:          0 :         Application::AcquireSolarMutex( nRef );
    1083                 :          0 :     }
    1084                 :          0 : }
    1085                 :            : 
    1086                 :            : // -----------------------------------------------------------------------------
    1087                 :            : 
    1088                 :         46 : void TransferableHelper::CopyToSelection( Window *pWindow ) const
    1089                 :            : {
    1090                 :            :     DBG_ASSERT( pWindow, "Window pointer is NULL" );
    1091                 :         46 :     Reference< XClipboard > xSelection;
    1092                 :            : 
    1093         [ +  - ]:         46 :     if( pWindow )
    1094 [ +  - ][ +  - ]:         46 :         xSelection = pWindow->GetPrimarySelection();
    1095                 :            : 
    1096 [ +  - ][ +  - ]:         46 :     if( xSelection.is() && !mxTerminateListener.is() )
                 [ +  - ]
    1097                 :            :     {
    1098         [ +  - ]:         46 :         const sal_uInt32 nRef = Application::ReleaseSolarMutex();
    1099                 :            : 
    1100                 :            :         try
    1101                 :            :         {
    1102                 :         46 :             TransferableHelper*                 pThis = const_cast< TransferableHelper* >( this );
    1103         [ +  - ]:         46 :             Reference< XMultiServiceFactory >   xFact( ::comphelper::getProcessServiceFactory() );
    1104                 :            : 
    1105         [ +  - ]:         46 :             if( xFact.is() )
    1106                 :            :             {
    1107 [ +  - ][ +  - ]:         46 :                 Reference< XDesktop > xDesktop( xFact->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" )) ), UNO_QUERY );
         [ +  - ][ +  - ]
    1108                 :            : 
    1109         [ +  - ]:         46 :                 if( xDesktop.is() )
    1110 [ +  - ][ +  - ]:         46 :                     xDesktop->addTerminateListener( pThis->mxTerminateListener = new TerminateListener( *pThis ) );
         [ +  - ][ +  - ]
                 [ +  - ]
    1111                 :            :             }
    1112                 :            : 
    1113 [ +  - ][ +  - ]:         46 :             xSelection->setContents( pThis, pThis );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ #  # ]
    1114                 :            :         }
    1115         [ #  # ]:          0 :         catch( const ::com::sun::star::uno::Exception& )
    1116                 :            :         {
    1117                 :            :         }
    1118                 :            : 
    1119         [ +  - ]:         46 :         Application::AcquireSolarMutex( nRef );
    1120                 :         46 :     }
    1121                 :         46 : }
    1122                 :            : 
    1123                 :            : // -----------------------------------------------------------------------------
    1124                 :            : 
    1125                 :          0 : void TransferableHelper::StartDrag( Window* pWindow, sal_Int8 nDnDSourceActions,
    1126                 :            :                                     sal_Int32 nDnDPointer, sal_Int32 nDnDImage )
    1127                 :            : 
    1128                 :            : {
    1129                 :            :     DBG_ASSERT( pWindow, "Window pointer is NULL" );
    1130         [ #  # ]:          0 :     Reference< XDragSource > xDragSource( pWindow->GetDragSource() );
    1131                 :            : 
    1132         [ #  # ]:          0 :     if( xDragSource.is() )
    1133                 :            :     {
    1134                 :            :         /*
    1135                 :            :          *    #96792# release mouse before actually starting DnD.
    1136                 :            :          *    This is necessary for the X11 DnD implementation to work.
    1137                 :            :          */
    1138 [ #  # ][ #  # ]:          0 :         if( pWindow->IsMouseCaptured() )
    1139         [ #  # ]:          0 :             pWindow->ReleaseMouse();
    1140                 :            : 
    1141         [ #  # ]:          0 :         const Point aPt( pWindow->GetPointerPosPixel() );
    1142                 :            : 
    1143                 :            :         // On Mac OS X we are forced to execute 'startDrag' synchronously
    1144                 :            :         // contrary to the XDragSource interface specification because
    1145                 :            :         // we can receive drag events from the system only in the main
    1146                 :            :         // thread
    1147                 :            : #if !defined(QUARTZ)
    1148         [ #  # ]:          0 :         const sal_uInt32 nRef = Application::ReleaseSolarMutex();
    1149                 :            : #endif
    1150                 :            : 
    1151                 :            :         try
    1152                 :            :         {
    1153         [ #  # ]:          0 :             DragGestureEvent    aEvt;
    1154                 :          0 :             aEvt.DragAction = DNDConstants::ACTION_COPY;
    1155                 :          0 :             aEvt.DragOriginX = aPt.X();
    1156                 :          0 :             aEvt.DragOriginY = aPt.Y();
    1157         [ #  # ]:          0 :             aEvt.DragSource = xDragSource;
    1158                 :            : 
    1159 [ #  # ][ #  # ]:          0 :             xDragSource->startDrag( aEvt, nDnDSourceActions, nDnDPointer, nDnDImage, this, this );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1160                 :            :         }
    1161         [ #  # ]:          0 :         catch( const ::com::sun::star::uno::Exception& )
    1162                 :            :         {
    1163                 :            :         }
    1164                 :            : 
    1165                 :            :         // See above for the reason of this define
    1166                 :            : #if !defined(QUARTZ)
    1167         [ #  # ]:          0 :         Application::AcquireSolarMutex( nRef );
    1168                 :            : #endif
    1169                 :          0 :     }
    1170                 :          0 : }
    1171                 :            : 
    1172                 :            : // -----------------------------------------------------------------------------
    1173                 :            : 
    1174                 :         40 : void TransferableHelper::ClearSelection( Window *pWindow )
    1175                 :            : {
    1176                 :            :     DBG_ASSERT( pWindow, "Window pointer is NULL" );
    1177         [ +  - ]:         40 :     Reference< XClipboard > xSelection( pWindow->GetPrimarySelection() );
    1178                 :            : 
    1179         [ +  - ]:         40 :     if( xSelection.is() )
    1180 [ +  - ][ +  - ]:         40 :         xSelection->setContents( NULL, NULL );
         [ +  - ][ +  - ]
    1181                 :         40 : }
    1182                 :            : 
    1183                 :            : // -----------------------------------------------------------------------------
    1184                 :            : 
    1185                 :          0 : Reference< XClipboard> TransferableHelper::GetSystemClipboard()
    1186                 :            : {
    1187                 :          0 :     Window *pFocusWindow = Application::GetFocusWindow();
    1188                 :            : 
    1189         [ #  # ]:          0 :     if( pFocusWindow )
    1190                 :          0 :         return pFocusWindow->GetClipboard();
    1191                 :            : 
    1192                 :          0 :     return  Reference< XClipboard > ();
    1193                 :            : }
    1194                 :            : 
    1195                 :            : namespace
    1196                 :            : {
    1197                 :            :     class theTransferableHelperUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theTransferableHelperUnoTunnelId > {};
    1198                 :            : }
    1199                 :            : 
    1200                 :          0 : const Sequence< sal_Int8 >& TransferableHelper::getUnoTunnelId()
    1201                 :            : {
    1202                 :          0 :     return theTransferableHelperUnoTunnelId::get().getSeq();
    1203                 :            : }
    1204                 :            : 
    1205                 :            : // ---------------------------------
    1206                 :            : // - TransferableClipboardNotifier -
    1207                 :            : // ---------------------------------
    1208                 :            : 
    1209         [ -  + ]:          4 : class TransferableClipboardNotifier : public ::cppu::WeakImplHelper1< XClipboardListener >
    1210                 :            : {
    1211                 :            : private:
    1212                 :            :     ::osl::Mutex&                   mrMutex;
    1213                 :            :     Reference< XClipboardNotifier > mxNotifier;
    1214                 :            :     TransferableDataHelper*         mpListener;
    1215                 :            : 
    1216                 :            : protected:
    1217                 :            :     // XClipboardListener
    1218                 :            :     virtual void SAL_CALL changedContents( const clipboard::ClipboardEvent& event ) throw (RuntimeException);
    1219                 :            : 
    1220                 :            :     // XEventListener
    1221                 :            :     virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
    1222                 :            : 
    1223                 :            : public:
    1224                 :            :     TransferableClipboardNotifier( const Reference< XClipboard >& _rxClipboard, TransferableDataHelper& _rListener, ::osl::Mutex& _rMutex );
    1225                 :            : 
    1226                 :            :     /// determines whether we're currently listening
    1227                 :          2 :     inline bool isListening() const { return !isDisposed(); }
    1228                 :            : 
    1229                 :            :     /// determines whether the instance is disposed
    1230                 :          2 :     inline bool isDisposed() const { return mpListener == NULL; }
    1231                 :            : 
    1232                 :            :     /// makes the instance non-functional
    1233                 :            :     void    dispose();
    1234                 :            : };
    1235                 :            : 
    1236                 :            : // -----------------------------------------------------------------------------
    1237                 :            : 
    1238                 :          2 : TransferableClipboardNotifier::TransferableClipboardNotifier( const Reference< XClipboard >& _rxClipboard, TransferableDataHelper& _rListener, ::osl::Mutex& _rMutex )
    1239                 :            :     :mrMutex( _rMutex )
    1240                 :            :     ,mxNotifier( _rxClipboard, UNO_QUERY )
    1241         [ +  - ]:          2 :     ,mpListener( &_rListener )
    1242                 :            : {
    1243         [ +  - ]:          2 :     osl_incrementInterlockedCount( &m_refCount );
    1244                 :            :     {
    1245         [ -  + ]:          2 :         if ( mxNotifier.is() )
    1246 [ #  # ][ #  # ]:          0 :             mxNotifier->addClipboardListener( this );
                 [ #  # ]
    1247                 :            :         else
    1248                 :            :             // born dead
    1249                 :          2 :             mpListener = NULL;
    1250                 :            :     }
    1251         [ +  - ]:          2 :     osl_decrementInterlockedCount( &m_refCount );
    1252                 :          2 : }
    1253                 :            : 
    1254                 :            : // -----------------------------------------------------------------------------
    1255                 :            : 
    1256                 :          0 : void SAL_CALL TransferableClipboardNotifier::changedContents( const clipboard::ClipboardEvent& event ) throw (RuntimeException)
    1257                 :            : {
    1258         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
    1259                 :            :         // the SolarMutex here is necessary, since
    1260                 :            :         // - we cannot call mpListener without our own mutex locked
    1261                 :            :         // - Rebind respectively InitFormats (called by Rebind) will
    1262                 :            :         // try to lock the SolarMutex, too
    1263         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( mrMutex );
    1264         [ #  # ]:          0 :     if( mpListener )
    1265 [ #  # ][ #  # ]:          0 :         mpListener->Rebind( event.Contents );
                 [ #  # ]
    1266                 :          0 : }
    1267                 :            : 
    1268                 :            : // -----------------------------------------------------------------------------
    1269                 :            : 
    1270                 :          0 : void SAL_CALL TransferableClipboardNotifier::disposing( const EventObject& ) throw (RuntimeException)
    1271                 :            : {
    1272                 :            :     // clipboard is being disposed. Hmm. Okay, become disfunctional myself.
    1273                 :          0 :     dispose();
    1274                 :          0 : }
    1275                 :            : 
    1276                 :            : // -----------------------------------------------------------------------------
    1277                 :            : 
    1278                 :          2 : void TransferableClipboardNotifier::dispose()
    1279                 :            : {
    1280         [ +  - ]:          2 :     ::osl::MutexGuard aGuard( mrMutex );
    1281                 :            : 
    1282         [ +  - ]:          2 :     Reference< XClipboardListener > xKeepMeAlive( this );
    1283                 :            : 
    1284         [ -  + ]:          2 :     if ( mxNotifier.is() )
    1285 [ #  # ][ #  # ]:          0 :         mxNotifier->removeClipboardListener( this );
                 [ #  # ]
    1286                 :          2 :     mxNotifier.clear();
    1287                 :            : 
    1288         [ +  - ]:          2 :     mpListener = NULL;
    1289                 :          2 : }
    1290                 :            : 
    1291                 :            : // -------------------------------
    1292                 :            : // - TransferableDataHelper_Impl -
    1293                 :            : // -------------------------------
    1294                 :            : 
    1295                 :       3900 : struct TransferableDataHelper_Impl
    1296                 :            : {
    1297                 :            :     ::osl::Mutex                    maMutex;
    1298                 :            :     TransferableClipboardNotifier*  mpClipboardListener;
    1299                 :            : 
    1300                 :       3900 :     TransferableDataHelper_Impl()
    1301                 :       3900 :         :mpClipboardListener( NULL )
    1302                 :            :     {
    1303                 :       3900 :     }
    1304                 :            : };
    1305                 :            : 
    1306                 :            : // --------------------------
    1307                 :            : // - TransferableDataHelper -
    1308                 :            : // --------------------------
    1309                 :            : 
    1310                 :       3900 : TransferableDataHelper::TransferableDataHelper() :
    1311         [ +  - ]:       3900 :     mpFormats( new DataFlavorExVector ),
    1312         [ +  - ]:       3900 :     mpObjDesc( new TransferableObjectDescriptor ),
    1313 [ +  - ][ +  - ]:      11700 :     mpImpl( new TransferableDataHelper_Impl )
         [ +  - ][ +  - ]
    1314                 :            : {
    1315                 :       3900 : }
    1316                 :            : 
    1317                 :            : // -----------------------------------------------------------------------------
    1318                 :            : 
    1319                 :          0 : TransferableDataHelper::TransferableDataHelper( const Reference< ::com::sun::star::datatransfer::XTransferable >& rxTransferable ) :
    1320                 :            :     mxTransfer( rxTransferable ),
    1321         [ #  # ]:          0 :     mpFormats( new DataFlavorExVector ),
    1322         [ #  # ]:          0 :     mpObjDesc( new TransferableObjectDescriptor ),
    1323 [ #  # ][ #  # ]:          0 :     mpImpl( new TransferableDataHelper_Impl )
         [ #  # ][ #  # ]
    1324                 :            : {
    1325         [ #  # ]:          0 :     InitFormats();
    1326                 :          0 : }
    1327                 :            : 
    1328                 :            : // -----------------------------------------------------------------------------
    1329                 :            : 
    1330                 :          0 : TransferableDataHelper::TransferableDataHelper( const TransferableDataHelper& rDataHelper ) :
    1331                 :            :     mxTransfer( rDataHelper.mxTransfer ),
    1332                 :            :     mxClipboard( rDataHelper.mxClipboard ),
    1333         [ #  # ]:          0 :     mpFormats( new DataFlavorExVector( *rDataHelper.mpFormats ) ),
    1334         [ #  # ]:          0 :     mpObjDesc( new TransferableObjectDescriptor( *rDataHelper.mpObjDesc ) ),
    1335 [ #  # ][ #  # ]:          0 :     mpImpl( new TransferableDataHelper_Impl )
         [ #  # ][ #  # ]
    1336                 :            : {
    1337                 :          0 : }
    1338                 :            : 
    1339                 :            : // -----------------------------------------------------------------------------
    1340                 :            : 
    1341                 :          2 : TransferableDataHelper& TransferableDataHelper::operator=( const TransferableDataHelper& rDataHelper )
    1342                 :            : {
    1343         [ +  - ]:          2 :     if ( this != &rDataHelper )
    1344                 :            :     {
    1345         [ +  - ]:          2 :         ::osl::MutexGuard aGuard( mpImpl->maMutex );
    1346                 :            : 
    1347                 :          2 :         bool bWasClipboardListening = ( NULL != mpImpl->mpClipboardListener );
    1348                 :            : 
    1349         [ -  + ]:          2 :         if ( bWasClipboardListening )
    1350         [ #  # ]:          0 :             StopClipboardListening();
    1351                 :            : 
    1352         [ +  - ]:          2 :         mxTransfer = rDataHelper.mxTransfer;
    1353 [ +  - ][ +  - ]:          2 :         delete mpFormats, mpFormats = new DataFlavorExVector( *rDataHelper.mpFormats );
                 [ +  - ]
    1354 [ +  - ][ +  - ]:          2 :         delete mpObjDesc, mpObjDesc = new TransferableObjectDescriptor( *rDataHelper.mpObjDesc );
         [ +  - ][ +  - ]
    1355         [ +  - ]:          2 :         mxClipboard = rDataHelper.mxClipboard;
    1356                 :            : 
    1357         [ -  + ]:          2 :         if ( bWasClipboardListening )
    1358 [ #  # ][ +  - ]:          2 :             StartClipboardListening();
    1359                 :            :     }
    1360                 :            : 
    1361                 :          2 :     return *this;
    1362                 :            : }
    1363                 :            : 
    1364                 :            : // -----------------------------------------------------------------------------
    1365                 :            : 
    1366                 :       3900 : TransferableDataHelper::~TransferableDataHelper()
    1367                 :            : {
    1368         [ +  - ]:       3900 :     StopClipboardListening( );
    1369                 :            :     {
    1370         [ +  - ]:       3900 :         ::osl::MutexGuard aGuard( mpImpl->maMutex );
    1371         [ +  - ]:       3900 :         delete mpFormats, mpFormats = NULL;
    1372 [ +  - ][ +  - ]:       3900 :         delete mpObjDesc, mpObjDesc = NULL;
                 [ +  - ]
    1373                 :            :     }
    1374 [ +  - ][ +  - ]:       3900 :     delete mpImpl;
    1375                 :       3900 : }
    1376                 :            : 
    1377                 :            : // -----------------------------------------------------------------------------
    1378                 :            : 
    1379                 :          0 : void TransferableDataHelper::FillDataFlavorExVector( const Sequence< DataFlavor >& rDataFlavorSeq,
    1380                 :            :                                                      DataFlavorExVector& rDataFlavorExVector )
    1381                 :            : {
    1382                 :            :     try
    1383                 :            :     {
    1384         [ #  # ]:          0 :         Reference< XMultiServiceFactory >       xFact( ::comphelper::getProcessServiceFactory() );
    1385                 :          0 :         Reference< XMimeContentTypeFactory >    xMimeFact;
    1386                 :          0 :         DataFlavorEx                            aFlavorEx;
    1387         [ #  # ]:          0 :         const ::rtl::OUString                   aCharsetStr(RTL_CONSTASCII_USTRINGPARAM( "charset" ));
    1388                 :            : 
    1389         [ #  # ]:          0 :         if( xFact.is() )
    1390         [ #  # ]:          0 :             xMimeFact = Reference< XMimeContentTypeFactory >( xFact->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.datatransfer.MimeContentTypeFactory" )) ),
    1391 [ #  # ][ #  # ]:          0 :                                                               UNO_QUERY );
         [ #  # ][ #  # ]
    1392                 :            : 
    1393         [ #  # ]:          0 :         for( sal_Int32 i = 0; i < rDataFlavorSeq.getLength(); i++ )
    1394                 :            :         {
    1395                 :          0 :             const DataFlavor&               rFlavor = rDataFlavorSeq[ i ];
    1396                 :          0 :             Reference< XMimeContentType >   xMimeType;
    1397                 :            : 
    1398                 :            :             try
    1399                 :            :             {
    1400 [ #  # ][ #  # ]:          0 :                 if( xMimeFact.is() && !rFlavor.MimeType.isEmpty() )
                 [ #  # ]
    1401 [ #  # ][ #  # ]:          0 :                     xMimeType = xMimeFact->createMimeContentType( rFlavor.MimeType );
         [ #  # ][ #  # ]
    1402                 :            :             }
    1403         [ #  # ]:          0 :             catch( const ::com::sun::star::uno::Exception& )
    1404                 :            :             {
    1405                 :            : 
    1406                 :            :             }
    1407                 :            : 
    1408                 :          0 :             aFlavorEx.MimeType = rFlavor.MimeType;
    1409                 :          0 :             aFlavorEx.HumanPresentableName = rFlavor.HumanPresentableName;
    1410                 :          0 :             aFlavorEx.DataType = rFlavor.DataType;
    1411         [ #  # ]:          0 :             aFlavorEx.mnSotId = SotExchange::RegisterFormat( rFlavor );
    1412                 :            : 
    1413         [ #  # ]:          0 :             rDataFlavorExVector.push_back( aFlavorEx );
    1414                 :            : 
    1415                 :            :             // add additional formats for special mime types
    1416         [ #  # ]:          0 :             if( SOT_FORMATSTR_ID_BMP == aFlavorEx.mnSotId )
    1417                 :            :             {
    1418 [ #  # ][ #  # ]:          0 :                 if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_BITMAP, aFlavorEx ) )
    1419                 :            :                 {
    1420                 :          0 :                     aFlavorEx.mnSotId = SOT_FORMAT_BITMAP;
    1421         [ #  # ]:          0 :                     rDataFlavorExVector.push_back( aFlavorEx );
    1422                 :            :                 }
    1423                 :            :             }
    1424 [ #  # ][ #  # ]:          0 :             else if( SOT_FORMATSTR_ID_WMF == aFlavorEx.mnSotId || SOT_FORMATSTR_ID_EMF == aFlavorEx.mnSotId )
    1425                 :            :             {
    1426 [ #  # ][ #  # ]:          0 :                 if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_GDIMETAFILE, aFlavorEx ) )
    1427                 :            :                 {
    1428                 :          0 :                     aFlavorEx.mnSotId = SOT_FORMAT_GDIMETAFILE;
    1429         [ #  # ]:          0 :                     rDataFlavorExVector.push_back( aFlavorEx );
    1430                 :            :                 }
    1431                 :            :             }
    1432         [ #  # ]:          0 :             else if ( SOT_FORMATSTR_ID_HTML_SIMPLE == aFlavorEx.mnSotId  )
    1433                 :            :             {
    1434                 :            :                 // #104735# HTML_SIMPLE may also be inserted without comments
    1435                 :          0 :                 aFlavorEx.mnSotId = SOT_FORMATSTR_ID_HTML_NO_COMMENT;
    1436         [ #  # ]:          0 :                 rDataFlavorExVector.push_back( aFlavorEx );
    1437                 :            :             }
    1438 [ #  # ][ #  # ]:          0 :             else if( xMimeType.is() && xMimeType->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "text/plain" )) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
    1439                 :            :             {
    1440                 :            :                 // add, if it is a UTF-8 byte buffer
    1441 [ #  # ][ #  # ]:          0 :                 if( xMimeType->hasParameter( aCharsetStr ) )
                 [ #  # ]
    1442                 :            :                 {
    1443 [ #  # ][ #  # ]:          0 :                     const ::rtl::OUString aCharset( xMimeType->getParameterValue( aCharsetStr ) );
    1444                 :            : 
    1445 [ #  # ][ #  # ]:          0 :                     if( xMimeType->getParameterValue( aCharsetStr ).equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "unicode" )) ) ||
                 [ #  # ]
           [ #  #  #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                   #  # ]
    1446 [ #  # ][ #  # ]:          0 :                         xMimeType->getParameterValue( aCharsetStr ).equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "utf-16" )) ) )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1447                 :            :                     {
    1448                 :          0 :                         rDataFlavorExVector[ rDataFlavorExVector.size() - 1 ].mnSotId = FORMAT_STRING;
    1449                 :            : 
    1450                 :          0 :                     }
    1451                 :            :                 }
    1452                 :            :             }
    1453 [ #  # ][ #  # ]:          0 :             else if( xMimeType.is() && xMimeType->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "text/rtf" )) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
    1454                 :            :             {
    1455                 :          0 :                 rDataFlavorExVector[ rDataFlavorExVector.size() - 1 ].mnSotId = FORMAT_RTF;
    1456                 :            :             }
    1457 [ #  # ][ #  # ]:          0 :             else if( xMimeType.is() && xMimeType->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "text/html" )) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
    1458                 :            : 
    1459                 :            :             {
    1460                 :          0 :                 rDataFlavorExVector[ rDataFlavorExVector.size() - 1 ].mnSotId = SOT_FORMATSTR_ID_HTML;
    1461                 :            :             }
    1462 [ #  # ][ #  # ]:          0 :             else if( xMimeType.is() && xMimeType->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "text/uri-list" )) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
    1463                 :            :             {
    1464                 :          0 :                 rDataFlavorExVector[ rDataFlavorExVector.size() - 1 ].mnSotId = SOT_FORMAT_FILE_LIST;
    1465                 :            :             }
    1466 [ #  # ][ #  # ]:          0 :             else if( xMimeType.is() && xMimeType->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/x-openoffice-objectdescriptor-xml" )) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
    1467                 :            :             {
    1468                 :          0 :                 rDataFlavorExVector[ rDataFlavorExVector.size() - 1 ].mnSotId = SOT_FORMATSTR_ID_OBJECTDESCRIPTOR;
    1469                 :            :             }
    1470         [ #  # ]:          0 :         }
    1471                 :            :     }
    1472                 :          0 :     catch( const ::com::sun::star::uno::Exception& )
    1473                 :            :     {
    1474                 :            :     }
    1475                 :          0 : }
    1476                 :            : 
    1477                 :            : // -----------------------------------------------------------------------------
    1478                 :            : 
    1479                 :          0 : void TransferableDataHelper::InitFormats()
    1480                 :            : {
    1481         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
    1482         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( mpImpl->maMutex );
    1483                 :            : 
    1484                 :          0 :     mpFormats->clear();
    1485 [ #  # ][ #  # ]:          0 :     delete mpObjDesc, mpObjDesc = new TransferableObjectDescriptor;
         [ #  # ][ #  # ]
    1486                 :            : 
    1487         [ #  # ]:          0 :     if( mxTransfer.is() )
    1488                 :            :     {
    1489 [ #  # ][ #  # ]:          0 :         TransferableDataHelper::FillDataFlavorExVector( mxTransfer->getTransferDataFlavors(), *mpFormats );
         [ #  # ][ #  # ]
    1490                 :            : 
    1491                 :          0 :         DataFlavorExVector::iterator aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
    1492                 :            : 
    1493 [ #  # ][ #  # ]:          0 :         while( aIter != aEnd )
    1494                 :            :         {
    1495         [ #  # ]:          0 :             if( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR == aIter->mnSotId )
    1496                 :            :             {
    1497         [ #  # ]:          0 :                 ImplSetParameterString( *mpObjDesc, *aIter );
    1498                 :          0 :                 aIter = aEnd;
    1499                 :            :             }
    1500                 :            :             else
    1501                 :          0 :                 ++aIter;
    1502                 :            :         }
    1503 [ #  # ][ #  # ]:          0 :     }
    1504                 :          0 : }
    1505                 :            : 
    1506                 :            : // -----------------------------------------------------------------------------
    1507                 :            : 
    1508                 :      56003 : sal_Bool TransferableDataHelper::HasFormat( SotFormatStringId nFormat ) const
    1509                 :            : {
    1510         [ +  - ]:      56003 :     ::osl::MutexGuard aGuard( mpImpl->maMutex );
    1511                 :            : 
    1512                 :      56003 :     DataFlavorExVector::iterator    aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
    1513                 :      56003 :     sal_Bool                        bRet = sal_False;
    1514                 :            : 
    1515 [ +  - ][ -  + ]:      56003 :     while( aIter != aEnd )
    1516                 :            :     {
    1517 [ #  # ][ #  # ]:          0 :         if( nFormat == (*aIter++).mnSotId )
    1518                 :            :         {
    1519                 :          0 :             aIter = aEnd;
    1520                 :          0 :             bRet = sal_True;
    1521                 :            :         }
    1522                 :            :     }
    1523                 :            : 
    1524         [ +  - ]:      56003 :     return bRet;
    1525                 :            : }
    1526                 :            : 
    1527                 :            : // -----------------------------------------------------------------------------
    1528                 :            : 
    1529                 :          0 : sal_Bool TransferableDataHelper::HasFormat( const DataFlavor& rFlavor ) const
    1530                 :            : {
    1531         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( mpImpl->maMutex );
    1532                 :            : 
    1533                 :          0 :     DataFlavorExVector::iterator    aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
    1534                 :          0 :     sal_Bool                        bRet = sal_False;
    1535                 :            : 
    1536 [ #  # ][ #  # ]:          0 :     while( aIter != aEnd )
    1537                 :            :     {
    1538 [ #  # ][ #  # ]:          0 :         if( TransferableDataHelper::IsEqual( rFlavor, *aIter++ ) )
                 [ #  # ]
    1539                 :            :         {
    1540                 :          0 :             aIter = aEnd;
    1541                 :          0 :             bRet = sal_True;
    1542                 :            :         }
    1543                 :            :     }
    1544                 :            : 
    1545         [ #  # ]:          0 :     return bRet;
    1546                 :            : }
    1547                 :            : 
    1548                 :            : // -----------------------------------------------------------------------------
    1549                 :            : 
    1550                 :        125 : sal_uInt32 TransferableDataHelper::GetFormatCount() const
    1551                 :            : {
    1552         [ +  - ]:        125 :     ::osl::MutexGuard aGuard( mpImpl->maMutex );
    1553         [ +  - ]:        125 :     return mpFormats->size();
    1554                 :            : }
    1555                 :            : 
    1556                 :            : // -----------------------------------------------------------------------------
    1557                 :            : 
    1558                 :            : 
    1559                 :          0 : SotFormatStringId TransferableDataHelper::GetFormat( sal_uInt32 nFormat ) const
    1560                 :            : {
    1561         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( mpImpl->maMutex );
    1562                 :            :     DBG_ASSERT( nFormat < mpFormats->size(), "TransferableDataHelper::GetFormat: invalid format index" );
    1563 [ #  # ][ #  # ]:          0 :     return( ( nFormat < mpFormats->size() ) ? (*mpFormats)[ nFormat ].mnSotId : 0 );
    1564                 :            : }
    1565                 :            : 
    1566                 :            : // -----------------------------------------------------------------------------
    1567                 :            : 
    1568                 :          0 : DataFlavor TransferableDataHelper::GetFormatDataFlavor( sal_uInt32 nFormat ) const
    1569                 :            : {
    1570         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( mpImpl->maMutex );
    1571                 :            :     DBG_ASSERT( nFormat < mpFormats->size(), "TransferableDataHelper::GetFormat: invalid format index" );
    1572                 :            : 
    1573                 :          0 :     DataFlavor aRet;
    1574                 :            : 
    1575         [ #  # ]:          0 :     if( nFormat < mpFormats->size() )
    1576                 :          0 :         aRet = (*mpFormats)[ nFormat ];
    1577                 :            : 
    1578         [ #  # ]:          0 :     return aRet;
    1579                 :            : }
    1580                 :            : 
    1581                 :            : // -----------------------------------------------------------------------------
    1582                 :            : 
    1583                 :        747 : Reference< XTransferable > TransferableDataHelper::GetXTransferable() const
    1584                 :            : {
    1585                 :        747 :     Reference< XTransferable > xRet;
    1586                 :            : 
    1587         [ -  + ]:        747 :     if( mxTransfer.is() )
    1588                 :            :     {
    1589                 :            :         try
    1590                 :            :         {
    1591         [ #  # ]:          0 :             xRet = mxTransfer;
    1592                 :            : 
    1593                 :            :             // do a dummy call to check, if this interface is valid (nasty)
    1594 [ #  # ][ #  # ]:          0 :             Sequence< DataFlavor > aTestSeq( xRet->getTransferDataFlavors() );
                 [ #  # ]
    1595                 :            : 
    1596                 :            :         }
    1597   [ #  #  #  # ]:          0 :         catch( const ::com::sun::star::uno::Exception& )
    1598                 :            :         {
    1599         [ #  # ]:          0 :             xRet = Reference< XTransferable >();
    1600                 :            :         }
    1601                 :            :     }
    1602                 :            : 
    1603                 :        747 :     return xRet;
    1604                 :            : }
    1605                 :            : 
    1606                 :            : // -----------------------------------------------------------------------------
    1607                 :            : 
    1608                 :          0 : Any TransferableDataHelper::GetAny( SotFormatStringId nFormat ) const
    1609                 :            : {
    1610                 :          0 :     Any aReturn;
    1611                 :            : 
    1612                 :          0 :     DataFlavor aFlavor;
    1613 [ #  # ][ #  # ]:          0 :     if ( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) )
    1614         [ #  # ]:          0 :         aReturn = GetAny( aFlavor );
    1615                 :            : 
    1616                 :          0 :     return aReturn;
    1617                 :            : }
    1618                 :            : 
    1619                 :            : 
    1620                 :            : // -----------------------------------------------------------------------------
    1621                 :            : 
    1622                 :          0 : Any TransferableDataHelper::GetAny( const DataFlavor& rFlavor ) const
    1623                 :            : {
    1624         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( mpImpl->maMutex );
    1625                 :          0 :     Any aRet;
    1626                 :            : 
    1627                 :            :     try
    1628                 :            :     {
    1629         [ #  # ]:          0 :         if( mxTransfer.is() )
    1630                 :            :         {
    1631                 :          0 :             DataFlavorExVector::iterator    aIter( mpFormats->begin() ), aEnd( mpFormats->end() );
    1632         [ #  # ]:          0 :             const SotFormatStringId         nRequestFormat = SotExchange::GetFormat( rFlavor );
    1633                 :            : 
    1634         [ #  # ]:          0 :             if( nRequestFormat )
    1635                 :            :             {
    1636                 :            :                 // try to get alien format first
    1637 [ #  # ][ #  # ]:          0 :                 while( aIter != aEnd )
    1638                 :            :                 {
    1639 [ #  # ][ #  # ]:          0 :                     if( ( nRequestFormat == (*aIter).mnSotId ) && !rFlavor.MimeType.equalsIgnoreAsciiCase( (*aIter).MimeType ) )
                 [ #  # ]
    1640 [ #  # ][ #  # ]:          0 :                         aRet = mxTransfer->getTransferData( *aIter );
    1641                 :            : 
    1642         [ #  # ]:          0 :                     if( aRet.hasValue() )
    1643                 :          0 :                         aIter = aEnd;
    1644                 :            :                     else
    1645         [ #  # ]:          0 :                         aIter++;
    1646                 :            :                 }
    1647                 :            :             }
    1648                 :            : 
    1649         [ #  # ]:          0 :             if( !aRet.hasValue() )
    1650 [ #  # ][ #  # ]:          0 :                 aRet = mxTransfer->getTransferData( rFlavor );
    1651                 :            :         }
    1652                 :            :     }
    1653         [ #  # ]:          0 :     catch( const ::com::sun::star::uno::Exception& )
    1654                 :            :     {
    1655                 :            :     }
    1656                 :            : 
    1657 [ #  # ][ #  # ]:          0 :     return aRet;
    1658                 :            : }
    1659                 :            : 
    1660                 :            : // -----------------------------------------------------------------------------
    1661                 :            : 
    1662                 :          0 : sal_Bool TransferableDataHelper::GetString( SotFormatStringId nFormat, String& rStr )
    1663                 :            : {
    1664                 :          0 :     ::rtl::OUString aOUString;
    1665         [ #  # ]:          0 :     sal_Bool        bRet = GetString( nFormat, aOUString );
    1666                 :            : 
    1667         [ #  # ]:          0 :     rStr = aOUString;
    1668                 :            : 
    1669                 :          0 :     return bRet;
    1670                 :            : }
    1671                 :            : 
    1672                 :            : // -----------------------------------------------------------------------------
    1673                 :            : 
    1674                 :          0 : sal_Bool TransferableDataHelper::GetString( const DataFlavor& rFlavor, String& rStr )
    1675                 :            : {
    1676                 :          0 :     ::rtl::OUString aOUString;
    1677         [ #  # ]:          0 :     sal_Bool        bRet = GetString( rFlavor, aOUString );
    1678                 :            : 
    1679         [ #  # ]:          0 :     rStr = aOUString;
    1680                 :            : 
    1681                 :          0 :     return bRet;
    1682                 :            : }
    1683                 :            : 
    1684                 :            : // -----------------------------------------------------------------------------
    1685                 :            : 
    1686                 :          0 : sal_Bool TransferableDataHelper::GetString( SotFormatStringId nFormat, ::rtl::OUString& rStr )
    1687                 :            : {
    1688                 :          0 :     DataFlavor aFlavor;
    1689 [ #  # ][ #  # ]:          0 :     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetString( aFlavor, rStr ) );
         [ #  # ][ #  # ]
    1690                 :            : }
    1691                 :            : 
    1692                 :            : // -----------------------------------------------------------------------------
    1693                 :            : 
    1694                 :          0 : sal_Bool TransferableDataHelper::GetString( const DataFlavor& rFlavor, ::rtl::OUString& rStr )
    1695                 :            : {
    1696         [ #  # ]:          0 :     Any         aAny( GetAny( rFlavor ) );
    1697                 :          0 :     sal_Bool    bRet = sal_False;
    1698                 :            : 
    1699         [ #  # ]:          0 :     if( aAny.hasValue() )
    1700                 :            :     {
    1701                 :          0 :         ::rtl::OUString         aOUString;
    1702         [ #  # ]:          0 :         Sequence< sal_Int8 >    aSeq;
    1703                 :            : 
    1704         [ #  # ]:          0 :         if( aAny >>= aOUString )
    1705                 :            :         {
    1706                 :          0 :             rStr = aOUString;
    1707                 :          0 :             bRet = sal_True;
    1708                 :            :         }
    1709 [ #  # ][ #  # ]:          0 :         else if( aAny >>= aSeq )
    1710                 :            :         {
    1711                 :            : 
    1712                 :          0 :             const sal_Char* pChars = reinterpret_cast< const sal_Char* >( aSeq.getConstArray() );
    1713                 :          0 :             sal_Int32       nLen = aSeq.getLength();
    1714                 :            : 
    1715                 :            :             //JP 10.10.2001: 92930 - don't copy the last zero characterinto the string.
    1716                 :            :             //DVO 2002-05-27: strip _all_ trailing zeros
    1717 [ #  # ][ #  # ]:          0 :             while( nLen && ( 0 == *( pChars + nLen - 1 ) ) )
                 [ #  # ]
    1718                 :          0 :                 --nLen;
    1719                 :            : 
    1720 [ #  # ][ #  # ]:          0 :             rStr = ::rtl::OUString( pChars, nLen, osl_getThreadTextEncoding() );
    1721                 :          0 :             bRet = sal_True;
    1722         [ #  # ]:          0 :         }
    1723                 :            :     }
    1724                 :            : 
    1725                 :          0 :     return bRet;
    1726                 :            : }
    1727                 :            : 
    1728                 :            : // -----------------------------------------------------------------------------
    1729                 :            : 
    1730                 :          0 : sal_Bool TransferableDataHelper::GetBitmap( SotFormatStringId nFormat, Bitmap& rBmp )
    1731                 :            : {
    1732                 :          0 :     DataFlavor aFlavor;
    1733 [ #  # ][ #  # ]:          0 :     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetBitmap( aFlavor, rBmp ) );
         [ #  # ][ #  # ]
    1734                 :            : }
    1735                 :            : 
    1736                 :            : // -----------------------------------------------------------------------------
    1737                 :            : 
    1738                 :          0 : sal_Bool TransferableDataHelper::GetBitmap( const DataFlavor& rFlavor, Bitmap& rBmp )
    1739                 :            : {
    1740                 :          0 :     SotStorageStreamRef xStm;
    1741                 :          0 :     DataFlavor          aSubstFlavor;
    1742         [ #  # ]:          0 :     sal_Bool            bRet = GetSotStorageStream( rFlavor, xStm );
    1743                 :            : 
    1744         [ #  # ]:          0 :     if( bRet )
    1745                 :            :     {
    1746         [ #  # ]:          0 :         *xStm >> rBmp;
    1747                 :          0 :         bRet = ( xStm->GetError() == ERRCODE_NONE );
    1748                 :            : 
    1749                 :            :         /* SJ: #110748# At the moment we are having problems with DDB inserted as DIB. The
    1750                 :            :            problem is, that some graphics are inserted much too big because the nXPelsPerMeter
    1751                 :            :            and nYPelsPerMeter of the bitmap fileheader isn't including the correct value.
    1752                 :            :            Due to this reason the following code assumes that bitmaps with a logical size
    1753                 :            :            greater than 50 cm aren't having the correct mapmode set.
    1754                 :            : 
    1755                 :            :            The following code should be removed if DDBs and DIBs are supported via clipboard
    1756                 :            :            properly.
    1757                 :            :         */
    1758         [ #  # ]:          0 :         if ( bRet )
    1759                 :            :         {
    1760         [ #  # ]:          0 :             MapMode aMapMode = rBmp.GetPrefMapMode();
    1761         [ #  # ]:          0 :             if ( aMapMode.GetMapUnit() != MAP_PIXEL )
    1762                 :            :             {
    1763 [ #  # ][ #  # ]:          0 :                 Size aSize = OutputDevice::LogicToLogic( rBmp.GetPrefSize(), aMapMode, MAP_100TH_MM );
                 [ #  # ]
    1764 [ #  # ][ #  # ]:          0 :                 if ( ( aSize.Width() > 5000 ) || ( aSize.Height() > 5000 ) )
                 [ #  # ]
    1765 [ #  # ][ #  # ]:          0 :                     rBmp.SetPrefMapMode( MAP_PIXEL );
                 [ #  # ]
    1766         [ #  # ]:          0 :             }
    1767                 :            :         }
    1768                 :            :     }
    1769                 :            : 
    1770 [ #  # ][ #  # ]:          0 :     if( !bRet &&
         [ #  # ][ #  # ]
                 [ #  # ]
    1771         [ #  # ]:          0 :         HasFormat( SOT_FORMATSTR_ID_BMP ) &&
    1772         [ #  # ]:          0 :         SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_BMP, aSubstFlavor ) &&
    1773         [ #  # ]:          0 :         GetSotStorageStream( aSubstFlavor, xStm ) )
    1774                 :            :     {
    1775         [ #  # ]:          0 :         xStm->ResetError();
    1776         [ #  # ]:          0 :         *xStm >> rBmp;
    1777                 :          0 :         bRet = ( xStm->GetError() == ERRCODE_NONE );
    1778                 :            :     }
    1779                 :            : 
    1780         [ #  # ]:          0 :     return bRet;
    1781                 :            : }
    1782                 :            : 
    1783                 :            : // -----------------------------------------------------------------------------
    1784                 :            : 
    1785                 :          0 : sal_Bool TransferableDataHelper::GetGDIMetaFile( SotFormatStringId nFormat, GDIMetaFile& rMtf )
    1786                 :            : {
    1787                 :          0 :     DataFlavor aFlavor;
    1788 [ #  # ][ #  # ]:          0 :     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetGDIMetaFile( aFlavor, rMtf ) );
         [ #  # ][ #  # ]
    1789                 :            : }
    1790                 :            : 
    1791                 :            : // -----------------------------------------------------------------------------
    1792                 :            : 
    1793                 :          0 : sal_Bool TransferableDataHelper::GetGDIMetaFile( const DataFlavor& rFlavor, GDIMetaFile& rMtf )
    1794                 :            : {
    1795                 :          0 :     SotStorageStreamRef xStm;
    1796                 :          0 :     DataFlavor          aSubstFlavor;
    1797                 :          0 :     sal_Bool            bRet = sal_False;
    1798                 :            : 
    1799 [ #  # ][ #  # ]:          0 :     if( GetSotStorageStream( rFlavor, xStm ) )
    1800                 :            :     {
    1801         [ #  # ]:          0 :         *xStm >> rMtf;
    1802                 :          0 :         bRet = ( xStm->GetError() == ERRCODE_NONE );
    1803                 :            :     }
    1804                 :            : 
    1805 [ #  # ][ #  # ]:          0 :     if( !bRet &&
         [ #  # ][ #  # ]
                 [ #  # ]
    1806         [ #  # ]:          0 :         HasFormat( SOT_FORMATSTR_ID_EMF ) &&
    1807         [ #  # ]:          0 :         SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_EMF, aSubstFlavor ) &&
    1808         [ #  # ]:          0 :         GetSotStorageStream( aSubstFlavor, xStm ) )
    1809                 :            :     {
    1810         [ #  # ]:          0 :         Graphic aGraphic;
    1811                 :            : 
    1812 [ #  # ][ #  # ]:          0 :         if( GraphicConverter::Import( *xStm, aGraphic ) == ERRCODE_NONE )
    1813                 :            :         {
    1814 [ #  # ][ #  # ]:          0 :             rMtf = aGraphic.GetGDIMetaFile();
    1815                 :          0 :             bRet = sal_True;
    1816         [ #  # ]:          0 :         }
    1817                 :            :     }
    1818                 :            : 
    1819 [ #  # ][ #  # ]:          0 :     if( !bRet &&
         [ #  # ][ #  # ]
                 [ #  # ]
    1820         [ #  # ]:          0 :         HasFormat( SOT_FORMATSTR_ID_WMF ) &&
    1821         [ #  # ]:          0 :         SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_WMF, aSubstFlavor ) &&
    1822         [ #  # ]:          0 :         GetSotStorageStream( aSubstFlavor, xStm ) )
    1823                 :            :     {
    1824         [ #  # ]:          0 :         Graphic aGraphic;
    1825                 :            : 
    1826 [ #  # ][ #  # ]:          0 :         if( GraphicConverter::Import( *xStm, aGraphic ) == ERRCODE_NONE )
    1827                 :            :         {
    1828 [ #  # ][ #  # ]:          0 :             rMtf = aGraphic.GetGDIMetaFile();
    1829                 :          0 :             bRet = sal_True;
    1830         [ #  # ]:          0 :         }
    1831                 :            :     }
    1832                 :            : 
    1833         [ #  # ]:          0 :     return bRet;
    1834                 :            : }
    1835                 :            : 
    1836                 :            : // -----------------------------------------------------------------------------
    1837                 :            : 
    1838                 :          0 : sal_Bool TransferableDataHelper::GetGraphic( SotFormatStringId nFormat, Graphic& rGraphic )
    1839                 :            : {
    1840                 :          0 :     DataFlavor aFlavor;
    1841 [ #  # ][ #  # ]:          0 :     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetGraphic( aFlavor, rGraphic ) );
         [ #  # ][ #  # ]
    1842                 :            : }
    1843                 :            : 
    1844                 :            : // -----------------------------------------------------------------------------
    1845                 :            : 
    1846                 :          0 : sal_Bool TransferableDataHelper::GetGraphic( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, Graphic& rGraphic )
    1847                 :            : {
    1848                 :          0 :     DataFlavor  aFlavor;
    1849                 :          0 :     sal_Bool    bRet = sal_False;
    1850                 :            : 
    1851 [ #  # ][ #  # ]:          0 :     if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_BITMAP, aFlavor ) &&
         [ #  # ][ #  # ]
    1852         [ #  # ]:          0 :         TransferableDataHelper::IsEqual( aFlavor, rFlavor ) )
    1853                 :            :     {
    1854         [ #  # ]:          0 :         Bitmap aBmp;
    1855                 :            : 
    1856 [ #  # ][ #  # ]:          0 :         if( ( bRet = GetBitmap( aFlavor, aBmp ) ) == sal_True )
    1857 [ #  # ][ #  # ]:          0 :             rGraphic = aBmp;
         [ #  # ][ #  # ]
    1858                 :            :     }
    1859 [ #  # ][ #  # ]:          0 :     else if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_GDIMETAFILE, aFlavor ) &&
         [ #  # ][ #  # ]
    1860         [ #  # ]:          0 :              TransferableDataHelper::IsEqual( aFlavor, rFlavor ) )
    1861                 :            :     {
    1862         [ #  # ]:          0 :         GDIMetaFile aMtf;
    1863                 :            : 
    1864 [ #  # ][ #  # ]:          0 :         if( ( bRet = GetGDIMetaFile( aFlavor, aMtf ) ) == sal_True )
    1865 [ #  # ][ #  # ]:          0 :             rGraphic = aMtf;
         [ #  # ][ #  # ]
    1866                 :            :     }
    1867                 :            :     else
    1868                 :            :     {
    1869                 :          0 :         SotStorageStreamRef xStm;
    1870                 :            : 
    1871 [ #  # ][ #  # ]:          0 :         if( GetSotStorageStream( rFlavor, xStm ) )
    1872                 :            :         {
    1873         [ #  # ]:          0 :             *xStm >> rGraphic;
    1874                 :          0 :             bRet = ( xStm->GetError() == ERRCODE_NONE );
    1875         [ #  # ]:          0 :         }
    1876                 :            :     }
    1877                 :            : 
    1878                 :          0 :     return bRet;
    1879                 :            : }
    1880                 :            : 
    1881                 :            : // -----------------------------------------------------------------------------
    1882                 :            : 
    1883                 :          0 : sal_Bool TransferableDataHelper::GetImageMap( SotFormatStringId nFormat, ImageMap& rIMap )
    1884                 :            : {
    1885                 :          0 :     DataFlavor aFlavor;
    1886 [ #  # ][ #  # ]:          0 :     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetImageMap( aFlavor, rIMap ) );
         [ #  # ][ #  # ]
    1887                 :            : }
    1888                 :            : 
    1889                 :            : // -----------------------------------------------------------------------------
    1890                 :            : 
    1891                 :          0 : sal_Bool TransferableDataHelper::GetImageMap( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, ImageMap& rIMap )
    1892                 :            : {
    1893                 :          0 :     SotStorageStreamRef xStm;
    1894         [ #  # ]:          0 :     sal_Bool            bRet = GetSotStorageStream( rFlavor, xStm );
    1895                 :            : 
    1896         [ #  # ]:          0 :     if( bRet )
    1897                 :            :     {
    1898 [ #  # ][ #  # ]:          0 :         rIMap.Read( *xStm, String() );
                 [ #  # ]
    1899                 :          0 :         bRet = ( xStm->GetError() == ERRCODE_NONE );
    1900                 :            :     }
    1901                 :            : 
    1902         [ #  # ]:          0 :     return bRet;
    1903                 :            : }
    1904                 :            : 
    1905                 :            : // -----------------------------------------------------------------------------
    1906                 :            : 
    1907                 :          0 : sal_Bool TransferableDataHelper::GetTransferableObjectDescriptor( SotFormatStringId nFormat, TransferableObjectDescriptor& rDesc )
    1908                 :            : {
    1909                 :          0 :     DataFlavor aFlavor;
    1910 [ #  # ][ #  # ]:          0 :     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetTransferableObjectDescriptor( aFlavor, rDesc ) );
         [ #  # ][ #  # ]
    1911                 :            : }
    1912                 :            : 
    1913                 :            : // -----------------------------------------------------------------------------
    1914                 :            : 
    1915                 :          0 : sal_Bool TransferableDataHelper::GetTransferableObjectDescriptor( const ::com::sun::star::datatransfer::DataFlavor&, TransferableObjectDescriptor& rDesc )
    1916                 :            : {
    1917                 :          0 :     rDesc = *mpObjDesc;
    1918                 :          0 :     return true;
    1919                 :            : }
    1920                 :            : 
    1921                 :            : // -----------------------------------------------------------------------------
    1922                 :            : 
    1923                 :          0 : sal_Bool TransferableDataHelper::GetINetBookmark( SotFormatStringId nFormat, INetBookmark& rBmk )
    1924                 :            : {
    1925                 :          0 :     DataFlavor aFlavor;
    1926 [ #  # ][ #  # ]:          0 :     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetINetBookmark( aFlavor, rBmk ) );
         [ #  # ][ #  # ]
    1927                 :            : }
    1928                 :            : 
    1929                 :            : // -----------------------------------------------------------------------------
    1930                 :            : 
    1931                 :          0 : sal_Bool TransferableDataHelper::GetINetBookmark( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, INetBookmark& rBmk )
    1932                 :            : {
    1933                 :          0 :     sal_Bool bRet = sal_False;
    1934         [ #  # ]:          0 :     if( HasFormat( rFlavor ))
    1935                 :            :     {
    1936                 :          0 :     const SotFormatStringId nFormat = SotExchange::GetFormat( rFlavor );
    1937      [ #  #  # ]:          0 :     switch( nFormat )
    1938                 :            :     {
    1939                 :            :         case( SOT_FORMATSTR_ID_SOLK ):
    1940                 :            :         case( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ):
    1941                 :            :         {
    1942         [ #  # ]:          0 :             String aString;
    1943 [ #  # ][ #  # ]:          0 :             if( GetString( rFlavor, aString ) )
    1944                 :            :             {
    1945         [ #  # ]:          0 :                 if( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR == nFormat )
    1946                 :            :                 {
    1947 [ #  # ][ #  # ]:          0 :                     rBmk = INetBookmark( aString, aString );
                 [ #  # ]
    1948                 :          0 :                     bRet = sal_True;
    1949                 :            :                 }
    1950                 :            :                 else
    1951                 :            :                 {
    1952 [ #  # ][ #  # ]:          0 :                     String      aURL, aDesc;
    1953 [ #  # ][ #  # ]:          0 :                     sal_uInt16  nStart = aString.Search( '@' ), nLen = (sal_uInt16) aString.ToInt32();
    1954                 :            : 
    1955 [ #  # ][ #  # ]:          0 :                     if( !nLen && aString.GetChar( 0 ) != '0' )
    1956                 :            :                     {
    1957                 :            :                         DBG_WARNING( "SOLK: 1. len=0" );
    1958                 :            :                     }
    1959 [ #  # ][ #  # ]:          0 :                     if( nStart == STRING_NOTFOUND || nLen > aString.Len() - nStart - 3 )
    1960                 :            :                     {
    1961                 :            :                         DBG_WARNING( "SOLK: 1. illegal start or wrong len" );
    1962                 :            :                     }
    1963 [ #  # ][ #  # ]:          0 :                     aURL = aString.Copy( nStart + 1, nLen );
                 [ #  # ]
    1964                 :            : 
    1965         [ #  # ]:          0 :                     aString.Erase( 0, nStart + 1 + nLen );
    1966         [ #  # ]:          0 :                     nStart = aString.Search( '@' );
    1967         [ #  # ]:          0 :                     nLen = (sal_uInt16) aString.ToInt32();
    1968                 :            : 
    1969 [ #  # ][ #  # ]:          0 :                     if( !nLen && aString.GetChar( 0 ) != '0' )
    1970                 :            :                     {
    1971                 :            :                         DBG_WARNING( "SOLK: 2. len=0" );
    1972                 :            :                     }
    1973 [ #  # ][ #  # ]:          0 :                     if( nStart == STRING_NOTFOUND || nLen > aString.Len() - nStart - 1 )
    1974                 :            :                     {
    1975                 :            :                         DBG_WARNING( "SOLK: 2. illegal start or wrong len" );
    1976                 :            :                     }
    1977 [ #  # ][ #  # ]:          0 :                     aDesc = aString.Copy( nStart+1, nLen );
                 [ #  # ]
    1978                 :            : 
    1979 [ #  # ][ #  # ]:          0 :                     rBmk = INetBookmark( aURL, aDesc );
                 [ #  # ]
    1980 [ #  # ][ #  # ]:          0 :                     bRet = sal_True;
    1981                 :            :                 }
    1982         [ #  # ]:          0 :             }
    1983                 :            :         }
    1984                 :          0 :         break;
    1985                 :            : 
    1986                 :            :         case( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ):
    1987                 :            :         {
    1988         [ #  # ]:          0 :             Sequence< sal_Int8 > aSeq;
    1989                 :            : 
    1990 [ #  # ][ #  # ]:          0 :             if( GetSequence( rFlavor, aSeq ) && ( 2048 == aSeq.getLength() ) )
         [ #  # ][ #  # ]
    1991                 :            :             {
    1992         [ #  # ]:          0 :                 rBmk = INetBookmark( String( reinterpret_cast< const sal_Char* >( aSeq.getConstArray() ), osl_getThreadTextEncoding() ),
    1993         [ #  # ]:          0 :                                      String( reinterpret_cast< const sal_Char* >( aSeq.getConstArray() ) + 1024, osl_getThreadTextEncoding() ) );
           [ #  #  #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1994                 :          0 :                 bRet = sal_True;
    1995         [ #  # ]:          0 :             }
    1996                 :            :         }
    1997                 :          0 :         break;
    1998                 :            : 
    1999                 :            : #ifdef WNT
    2000                 :            :         case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
    2001                 :            :         {
    2002                 :            :             Sequence< sal_Int8 > aSeq;
    2003                 :            : 
    2004                 :            :             if( GetSequence( rFlavor, aSeq ) && aSeq.getLength() )
    2005                 :            :             {
    2006                 :            :                 FILEGROUPDESCRIPTOR* pFDesc = (FILEGROUPDESCRIPTOR*) aSeq.getConstArray();
    2007                 :            : 
    2008                 :            :                 if( pFDesc->cItems )
    2009                 :            :                 {
    2010                 :            :                     rtl::OString aDesc( pFDesc->fgd[ 0 ].cFileName );
    2011                 :            :                     rtl_TextEncoding    eTextEncoding = osl_getThreadTextEncoding();
    2012                 :            : 
    2013                 :            :                     if( ( aDesc.getLength() > 4 ) && aDesc.copy(aDesc.getLength() - 4).equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM(".URL")) )
    2014                 :            :                     {
    2015                 :            :                         SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( INetURLObject( rtl::OStringToOUString(aDesc, eTextEncoding) ).GetMainURL( INetURLObject::NO_DECODE ),
    2016                 :            :                                                                                   STREAM_STD_READ );
    2017                 :            : 
    2018                 :            :                         if( !pStream || pStream->GetError() )
    2019                 :            :                         {
    2020                 :            :                             DataFlavor aFileContentFlavor;
    2021                 :            : 
    2022                 :            :                             aSeq.realloc( 0 );
    2023                 :            :                             delete pStream;
    2024                 :            : 
    2025                 :            :                             if( SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_FILECONTENT, aFileContentFlavor ) &&
    2026                 :            :                                 GetSequence( aFileContentFlavor, aSeq ) && aSeq.getLength() )
    2027                 :            :                             {
    2028                 :            :                                 pStream = new SvMemoryStream( (sal_Char*) aSeq.getConstArray(), aSeq.getLength(), STREAM_STD_READ );
    2029                 :            :                             }
    2030                 :            :                             else
    2031                 :            :                                 pStream = NULL;
    2032                 :            :                         }
    2033                 :            : 
    2034                 :            :                         if( pStream )
    2035                 :            :                         {
    2036                 :            :                             rtl::OString aLine;
    2037                 :            :                             sal_Bool    bSttFnd = sal_False;
    2038                 :            : 
    2039                 :            :                             while( pStream->ReadLine( aLine ) )
    2040                 :            :                             {
    2041                 :            :                                 if (aLine.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("[InternetShortcut]")))
    2042                 :            :                                     bSttFnd = sal_True;
    2043                 :            :                                 else if (bSttFnd && aLine.copy(0, 4).equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("URL=")))
    2044                 :            :                                 {
    2045                 :            :                                     rBmk = INetBookmark( rtl::OStringToOUString(aLine.copy(4), eTextEncoding),
    2046                 :            :                                                          rtl::OStringToOUString(aDesc.copy(0, aDesc.getLength() - 4), eTextEncoding) );
    2047                 :            :                                     bRet = sal_True;
    2048                 :            :                                     break;
    2049                 :            :                                 }
    2050                 :            :                             }
    2051                 :            : 
    2052                 :            :                             delete pStream;
    2053                 :            :                         }
    2054                 :            :                     }
    2055                 :            :                 }
    2056                 :            :             }
    2057                 :            :         }
    2058                 :            :         break;
    2059                 :            : #endif
    2060                 :            : 
    2061                 :            :     }
    2062                 :            :     }
    2063                 :          0 :     return bRet;
    2064                 :            : }
    2065                 :            : 
    2066                 :            : // -----------------------------------------------------------------------------
    2067                 :            : 
    2068                 :          0 : sal_Bool TransferableDataHelper::GetINetImage( SotFormatStringId nFormat,
    2069                 :            :                                                 INetImage& rINtImg )
    2070                 :            : {
    2071                 :          0 :     DataFlavor aFlavor;
    2072 [ #  # ][ #  # ]:          0 :     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetINetImage( aFlavor, rINtImg ) );
         [ #  # ][ #  # ]
    2073                 :            : }
    2074                 :            : 
    2075                 :            : // -----------------------------------------------------------------------------
    2076                 :            : 
    2077                 :          0 : sal_Bool TransferableDataHelper::GetINetImage(
    2078                 :            :         const ::com::sun::star::datatransfer::DataFlavor& rFlavor,
    2079                 :            :         INetImage& rINtImg )
    2080                 :            : {
    2081                 :          0 :     SotStorageStreamRef xStm;
    2082         [ #  # ]:          0 :     sal_Bool bRet = GetSotStorageStream( rFlavor, xStm );
    2083                 :            : 
    2084         [ #  # ]:          0 :     if( bRet )
    2085 [ #  # ][ #  # ]:          0 :         bRet = rINtImg.Read( *xStm, SotExchange::GetFormat( rFlavor ) );
    2086         [ #  # ]:          0 :     return bRet;
    2087                 :            : }
    2088                 :            : 
    2089                 :            : // -----------------------------------------------------------------------------
    2090                 :            : 
    2091                 :          0 : sal_Bool TransferableDataHelper::GetFileList( SotFormatStringId nFormat,
    2092                 :            :                                                 FileList& rFileList )
    2093                 :            : {
    2094                 :          0 :     DataFlavor aFlavor;
    2095 [ #  # ][ #  # ]:          0 :     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetFileList( aFlavor, rFileList ) );
         [ #  # ][ #  # ]
    2096                 :            : }
    2097                 :            : 
    2098                 :            : // -----------------------------------------------------------------------------
    2099                 :            : 
    2100                 :          0 : sal_Bool TransferableDataHelper::GetFileList(
    2101                 :            :             const ::com::sun::star::datatransfer::DataFlavor&,
    2102                 :            :             FileList& rFileList )
    2103                 :            : {
    2104                 :          0 :     SotStorageStreamRef xStm;
    2105                 :          0 :     sal_Bool            bRet = sal_False;
    2106                 :            : 
    2107 [ #  # ][ #  # ]:          0 :     for( sal_uInt32 i = 0, nFormatCount = GetFormatCount(); ( i < nFormatCount ) && !bRet; ++i )
         [ #  # ][ #  # ]
    2108                 :            :     {
    2109 [ #  # ][ #  # ]:          0 :         if( SOT_FORMAT_FILE_LIST == GetFormat( i ) )
    2110                 :            :         {
    2111         [ #  # ]:          0 :             const DataFlavor aFlavor( GetFormatDataFlavor( i ) );
    2112                 :            : 
    2113 [ #  # ][ #  # ]:          0 :             if( GetSotStorageStream( aFlavor, xStm ) )
    2114                 :            :             {
    2115         [ #  # ]:          0 :                 if( aFlavor.MimeType.indexOf( "text/uri-list" ) > -1 )
    2116                 :            :                 {
    2117                 :          0 :                     rtl::OString aDiskString;
    2118                 :            : 
    2119 [ #  # ][ #  # ]:          0 :                     while( xStm->ReadLine( aDiskString ) )
    2120 [ #  # ][ #  # ]:          0 :                         if( !aDiskString.isEmpty() && aDiskString[0] != '#' )
                 [ #  # ]
    2121 [ #  # ][ #  # ]:          0 :                             rFileList.AppendFile( rtl::OStringToOUString(aDiskString, RTL_TEXTENCODING_UTF8) );
         [ #  # ][ #  # ]
    2122                 :            : 
    2123                 :          0 :                     bRet = sal_True;
    2124                 :            :                  }
    2125                 :            :                  else
    2126         [ #  # ]:          0 :                     bRet = ( ( *xStm >> rFileList ).GetError() == ERRCODE_NONE );
    2127                 :          0 :             }
    2128                 :            :         }
    2129                 :            :     }
    2130                 :            : 
    2131         [ #  # ]:          0 :     return bRet;
    2132                 :            : }
    2133                 :            : 
    2134                 :            : // -----------------------------------------------------------------------------
    2135                 :            : 
    2136                 :          0 : sal_Bool TransferableDataHelper::GetSequence( SotFormatStringId nFormat, Sequence< sal_Int8 >& rSeq )
    2137                 :            : {
    2138                 :          0 :     DataFlavor aFlavor;
    2139 [ #  # ][ #  # ]:          0 :     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetSequence( aFlavor, rSeq ) );
         [ #  # ][ #  # ]
    2140                 :            : }
    2141                 :            : 
    2142                 :            : // -----------------------------------------------------------------------------
    2143                 :            : 
    2144                 :          0 : sal_Bool TransferableDataHelper::GetSequence( const DataFlavor& rFlavor, Sequence< sal_Int8 >& rSeq )
    2145                 :            : {
    2146                 :            : #ifdef DEBUG
    2147                 :            :     fprintf( stderr, "TransferableDataHelper requests sequence of data\n" );
    2148                 :            : #endif
    2149                 :            : 
    2150         [ #  # ]:          0 :     const Any aAny( GetAny( rFlavor ) );
    2151 [ #  # ][ #  # ]:          0 :     return( aAny.hasValue() && ( aAny >>= rSeq ) );
                 [ #  # ]
    2152                 :            : }
    2153                 :            : 
    2154                 :            : // -----------------------------------------------------------------------------
    2155                 :            : 
    2156                 :          0 : sal_Bool TransferableDataHelper::GetSotStorageStream( SotFormatStringId nFormat, SotStorageStreamRef& rxStream )
    2157                 :            : {
    2158                 :          0 :     DataFlavor aFlavor;
    2159 [ #  # ][ #  # ]:          0 :     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetSotStorageStream( aFlavor, rxStream ) );
         [ #  # ][ #  # ]
    2160                 :            : }
    2161                 :            : 
    2162                 :            : // -----------------------------------------------------------------------------
    2163                 :            : 
    2164                 :          0 : sal_Bool TransferableDataHelper::GetSotStorageStream( const DataFlavor& rFlavor, SotStorageStreamRef& rxStream )
    2165                 :            : {
    2166         [ #  # ]:          0 :     Sequence< sal_Int8 >    aSeq;
    2167         [ #  # ]:          0 :     sal_Bool                bRet = GetSequence( rFlavor, aSeq );
    2168                 :            : 
    2169         [ #  # ]:          0 :     if( bRet )
    2170                 :            :     {
    2171 [ #  # ][ #  # ]:          0 :         rxStream = new SotStorageStream( String() );
         [ #  # ][ #  # ]
                 [ #  # ]
    2172         [ #  # ]:          0 :         rxStream->Write( aSeq.getConstArray(), aSeq.getLength() );
    2173         [ #  # ]:          0 :         rxStream->Seek( 0 );
    2174                 :            :     }
    2175                 :            : 
    2176         [ #  # ]:          0 :     return bRet;
    2177                 :            : }
    2178                 :            : 
    2179                 :          0 : sal_Bool TransferableDataHelper::GetInputStream( SotFormatStringId nFormat, Reference < XInputStream >& rxStream )
    2180                 :            : {
    2181                 :          0 :     DataFlavor aFlavor;
    2182 [ #  # ][ #  # ]:          0 :     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetInputStream( aFlavor, rxStream ) );
         [ #  # ][ #  # ]
    2183                 :            : }
    2184                 :            : 
    2185                 :            : // -----------------------------------------------------------------------------
    2186                 :            : 
    2187                 :          0 : sal_Bool TransferableDataHelper::GetInputStream( const DataFlavor& rFlavor, Reference < XInputStream >& rxStream )
    2188                 :            : {
    2189         [ #  # ]:          0 :     Sequence< sal_Int8 >    aSeq;
    2190         [ #  # ]:          0 :     sal_Bool                bRet = GetSequence( rFlavor, aSeq );
    2191                 :            : 
    2192         [ #  # ]:          0 :     if( bRet )
    2193 [ #  # ][ #  # ]:          0 :           rxStream = new ::comphelper::SequenceInputStream( aSeq );
                 [ #  # ]
    2194                 :            : 
    2195         [ #  # ]:          0 :     return bRet;
    2196                 :            : }
    2197                 :            : 
    2198                 :            : // -----------------------------------------------------------------------------
    2199                 :            : 
    2200                 :          0 : void TransferableDataHelper::Rebind( const Reference< XTransferable >& _rxNewContent )
    2201                 :            : {
    2202                 :          0 :     mxTransfer = _rxNewContent;
    2203                 :          0 :     InitFormats();
    2204                 :          0 : }
    2205                 :            : 
    2206                 :            : // -----------------------------------------------------------------------------
    2207                 :            : 
    2208                 :          2 : sal_Bool TransferableDataHelper::StartClipboardListening( )
    2209                 :            : {
    2210         [ +  - ]:          2 :     ::osl::MutexGuard aGuard( mpImpl->maMutex );
    2211                 :            : 
    2212         [ +  - ]:          2 :     StopClipboardListening( );
    2213                 :            : 
    2214         [ +  - ]:          2 :     mpImpl->mpClipboardListener = new TransferableClipboardNotifier( mxClipboard, *this, mpImpl->maMutex );
    2215                 :          2 :     mpImpl->mpClipboardListener->acquire();
    2216                 :            : 
    2217 [ +  - ][ +  - ]:          2 :     return mpImpl->mpClipboardListener->isListening();
    2218                 :            : }
    2219                 :            : 
    2220                 :            : // -----------------------------------------------------------------------------
    2221                 :            : 
    2222                 :       3902 : void TransferableDataHelper::StopClipboardListening( )
    2223                 :            : {
    2224         [ +  - ]:       3902 :     ::osl::MutexGuard aGuard( mpImpl->maMutex );
    2225                 :            : 
    2226         [ +  + ]:       3902 :     if ( mpImpl->mpClipboardListener )
    2227                 :            :     {
    2228         [ +  - ]:          2 :         mpImpl->mpClipboardListener->dispose();
    2229                 :          2 :         mpImpl->mpClipboardListener->release();
    2230                 :          2 :         mpImpl->mpClipboardListener = NULL;
    2231         [ +  - ]:       3902 :     }
    2232                 :       3902 : }
    2233                 :            : 
    2234                 :            : // -----------------------------------------------------------------------------
    2235                 :            : 
    2236                 :       3878 : TransferableDataHelper TransferableDataHelper::CreateFromSystemClipboard( Window * pWindow )
    2237                 :            : {
    2238                 :            :     DBG_ASSERT( pWindow, "Window pointer is NULL" );
    2239                 :            : 
    2240                 :       3878 :     Reference< XClipboard > xClipboard;
    2241         [ +  - ]:       3878 :     TransferableDataHelper  aRet;
    2242                 :            : 
    2243         [ +  - ]:       3878 :     if( pWindow )
    2244 [ +  - ][ +  - ]:       3878 :         xClipboard = pWindow->GetClipboard();
    2245                 :            : 
    2246         [ +  - ]:       3878 :     if( xClipboard.is() )
    2247                 :            :     {
    2248                 :            :         try
    2249                 :            :         {
    2250 [ +  - ][ +  - ]:       3878 :             Reference< XTransferable > xTransferable( xClipboard->getContents() );
    2251                 :            : 
    2252         [ -  + ]:       3878 :             if( xTransferable.is() )
    2253                 :            :             {
    2254 [ #  # ][ #  # ]:          0 :                 aRet = TransferableDataHelper( xTransferable );
                 [ #  # ]
    2255                 :            :                 // also copy the clipboard
    2256         [ #  # ]:          0 :                 aRet.mxClipboard = xClipboard;
    2257         [ #  # ]:       3878 :             }
    2258                 :            :         }
    2259         [ #  # ]:          0 :         catch( const ::com::sun::star::uno::Exception& )
    2260                 :            :         {
    2261                 :            :         }
    2262                 :            :     }
    2263                 :            : 
    2264                 :       3878 :     return aRet;
    2265                 :            : }
    2266                 :            : 
    2267                 :            : 
    2268                 :            : // -----------------------------------------------------------------------------
    2269                 :            : 
    2270                 :          0 : TransferableDataHelper TransferableDataHelper::CreateFromSelection( Window* pWindow )
    2271                 :            : {
    2272                 :            :     DBG_ASSERT( pWindow, "Window pointer is NULL" );
    2273                 :            : 
    2274                 :          0 :     Reference< XClipboard > xSelection;
    2275         [ #  # ]:          0 :        TransferableDataHelper   aRet;
    2276                 :            : 
    2277         [ #  # ]:          0 :     if( pWindow )
    2278 [ #  # ][ #  # ]:          0 :         xSelection = pWindow->GetPrimarySelection();
    2279                 :            : 
    2280         [ #  # ]:          0 :     if( xSelection.is() )
    2281                 :            :        {
    2282         [ #  # ]:          0 :         const sal_uInt32 nRef = Application::ReleaseSolarMutex();
    2283                 :            : 
    2284                 :            :           try
    2285                 :            :         {
    2286 [ #  # ][ #  # ]:          0 :             Reference< XTransferable > xTransferable( xSelection->getContents() );
    2287                 :            : 
    2288         [ #  # ]:          0 :             if( xTransferable.is() )
    2289                 :            :                {
    2290 [ #  # ][ #  # ]:          0 :                 aRet = TransferableDataHelper( xTransferable );
                 [ #  # ]
    2291         [ #  # ]:          0 :                    aRet.mxClipboard = xSelection;
    2292         [ #  # ]:          0 :             }
    2293                 :            :            }
    2294         [ #  # ]:          0 :         catch( const ::com::sun::star::uno::Exception& )
    2295                 :            :         {
    2296                 :            :            }
    2297                 :            : 
    2298         [ #  # ]:          0 :         Application::AcquireSolarMutex( nRef );
    2299                 :            :     }
    2300                 :            : 
    2301                 :          0 :     return aRet;
    2302                 :            : }
    2303                 :            : 
    2304                 :            : // -----------------------------------------------------------------------------
    2305                 :          0 : sal_Bool TransferableDataHelper::IsEqual( const ::com::sun::star::datatransfer::DataFlavor& rInternalFlavor,
    2306                 :            :                                           const ::com::sun::star::datatransfer::DataFlavor& rRequestFlavor,
    2307                 :            :                                           sal_Bool )
    2308                 :            : {
    2309         [ #  # ]:          0 :     Reference< XMultiServiceFactory >       xFact( ::comphelper::getProcessServiceFactory() );
    2310                 :          0 :     Reference< XMimeContentTypeFactory >    xMimeFact;
    2311                 :          0 :     sal_Bool                                bRet = sal_False;
    2312                 :            : 
    2313                 :            :     try
    2314                 :            :     {
    2315         [ #  # ]:          0 :         if( xFact.is() )
    2316         [ #  # ]:          0 :             xMimeFact = Reference< XMimeContentTypeFactory >( xFact->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.datatransfer.MimeContentTypeFactory" )) ),
    2317 [ #  # ][ #  # ]:          0 :                                                               UNO_QUERY );
         [ #  # ][ #  # ]
    2318                 :            : 
    2319         [ #  # ]:          0 :         if( xMimeFact.is() )
    2320                 :            :         {
    2321 [ #  # ][ #  # ]:          0 :             Reference< XMimeContentType > xRequestType1( xMimeFact->createMimeContentType( rInternalFlavor.MimeType ) );
    2322 [ #  # ][ #  # ]:          0 :             Reference< XMimeContentType > xRequestType2( xMimeFact->createMimeContentType( rRequestFlavor.MimeType ) );
    2323                 :            : 
    2324 [ #  # ][ #  # ]:          0 :             if( xRequestType1.is() && xRequestType2.is() )
                 [ #  # ]
    2325                 :            :             {
    2326 [ #  # ][ #  # ]:          0 :                 if( xRequestType1->getFullMediaType().equalsIgnoreAsciiCase( xRequestType2->getFullMediaType() ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2327                 :            :                 {
    2328 [ #  # ][ #  # ]:          0 :                     if( xRequestType1->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "text/plain" )) ) )
         [ #  # ][ #  # ]
    2329                 :            :                     {
    2330                 :            :                         // special handling for text/plain media types
    2331         [ #  # ]:          0 :                         const ::rtl::OUString aCharsetString(RTL_CONSTASCII_USTRINGPARAM( "charset" ));
    2332                 :            : 
    2333 [ #  # ][ #  # ]:          0 :                         if( !xRequestType2->hasParameter( aCharsetString ) ||
           [ #  #  #  #  
           #  # ][ #  # ]
    2334 [ #  # ][ #  # ]:          0 :                             xRequestType2->getParameterValue( aCharsetString ).equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "utf-16" )) ) ||
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    2335 [ #  # ][ #  # ]:          0 :                             xRequestType2->getParameterValue( aCharsetString ).equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "unicode" )) ) )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    2336                 :            :                         {
    2337                 :          0 :                             bRet = sal_True;
    2338                 :          0 :                         }
    2339                 :            :                     }
    2340 [ #  # ][ #  # ]:          0 :                     else if( xRequestType1->getFullMediaType().equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/x-openoffice" )) ) )
         [ #  # ][ #  # ]
    2341                 :            :                     {
    2342                 :            :                         // special handling for application/x-openoffice media types
    2343         [ #  # ]:          0 :                         const ::rtl::OUString aFormatString(RTL_CONSTASCII_USTRINGPARAM( "windows_formatname" ));
    2344                 :            : 
    2345 [ #  # ][ #  # ]:          0 :                         if( xRequestType1->hasParameter( aFormatString ) &&
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    2346 [ #  # ][ #  # ]:          0 :                             xRequestType2->hasParameter( aFormatString ) &&
    2347 [ #  # ][ #  # ]:          0 :                             xRequestType1->getParameterValue( aFormatString ).equalsIgnoreAsciiCase( xRequestType2->getParameterValue( aFormatString ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    2348                 :            :                         {
    2349                 :          0 :                             bRet = sal_True;
    2350                 :          0 :                         }
    2351                 :            :                     }
    2352                 :            :                     else
    2353                 :          0 :                         bRet = sal_True;
    2354                 :            :                 }
    2355         [ #  # ]:          0 :             }
    2356                 :            :         }
    2357                 :            :     }
    2358         [ #  # ]:          0 :     catch( const ::com::sun::star::uno::Exception& )
    2359                 :            :     {
    2360                 :          0 :         bRet = rInternalFlavor.MimeType.equalsIgnoreAsciiCase( rRequestFlavor.MimeType );
    2361                 :            :     }
    2362                 :            : 
    2363                 :          0 :     return bRet;
    2364                 :            : }
    2365                 :            : 
    2366                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10