LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/dochdl - swdtflvr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 11 1760 0.6 %
Date: 2012-12-27 Functions: 4 65 6.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/embed/XVisualObject.hpp>
      21             : #include <com/sun/star/embed/XTransactedObject.hpp>
      22             : #include <com/sun/star/embed/Aspects.hpp>
      23             : #include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
      24             : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      25             : 
      26             : #include <svtools/embedtransfer.hxx>
      27             : #include <svtools/insdlg.hxx>
      28             : #include <unotools/tempfile.hxx>
      29             : #include <comphelper/processfactory.hxx>
      30             : #include <comphelper/servicehelper.hxx>
      31             : #include <comphelper/storagehelper.hxx>
      32             : #include <comphelper/string.hxx>
      33             : #include <unotools/ucbstreamhelper.hxx>
      34             : #include <sot/filelist.hxx>
      35             : #include <svx/svxdlg.hxx>
      36             : #include <toolkit/helper/vclunohelper.hxx>
      37             : #include <osl/endian.h>
      38             : #include <sfx2/linkmgr.hxx>
      39             : #include <tools/urlobj.hxx>
      40             : #include <vcl/wrkwin.hxx>
      41             : #include <vcl/msgbox.hxx>
      42             : #include <sfx2/dispatch.hxx>
      43             : #include <svl/stritem.hxx>
      44             : #include <svtools/imap.hxx>
      45             : #include <sot/storage.hxx>
      46             : #include <vcl/graph.hxx>
      47             : #include <svl/urihelper.hxx>
      48             : #include <svx/svdmodel.hxx>
      49             : #include <svx/xexch.hxx>
      50             : #include <svx/xmlexchg.hxx>
      51             : #include <svx/dbaexchange.hxx>
      52             : #include <svx/clipfmtitem.hxx>
      53             : #include <sfx2/mieclip.hxx>
      54             : #include <svx/svdetc.hxx>
      55             : #include <svx/xoutbmp.hxx>
      56             : #include <svl/urlbmk.hxx>
      57             : #include <svtools/htmlout.hxx>
      58             : #include <svx/hlnkitem.hxx>
      59             : #include <svtools/inetimg.hxx>
      60             : #include <editeng/paperinf.hxx>
      61             : #include <svx/fmview.hxx>
      62             : #include <editeng/scripttypeitem.hxx>
      63             : #include <sfx2/docfilt.hxx>
      64             : #include <svtools/imapobj.hxx>
      65             : #include <sfx2/docfile.hxx>
      66             : #include <unotools/transliterationwrapper.hxx>
      67             : #include <unotools/streamwrap.hxx>
      68             : #include <svtools/filter.hxx>
      69             : 
      70             : #include <svx/unomodel.hxx>
      71             : #include <fmturl.hxx>
      72             : #include <fmtinfmt.hxx>
      73             : #include <fmtfsize.hxx>
      74             : #include <swdtflvr.hxx>
      75             : #include <shellio.hxx>
      76             : #include <ddefld.hxx>
      77             : #include <doc.hxx>
      78             : #include <IDocumentUndoRedo.hxx>
      79             : #include <pagedesc.hxx>
      80             : #include <IMark.hxx>
      81             : #include <docary.hxx>
      82             : #include <section.hxx>
      83             : #include <ndtxt.hxx>
      84             : #include <edtwin.hxx>
      85             : #include <navicont.hxx>
      86             : #include <swcont.hxx>
      87             : #include <wrtsh.hxx>
      88             : #include <swmodule.hxx>
      89             : #include <view.hxx>
      90             : #include <docsh.hxx>
      91             : #include <wdocsh.hxx>
      92             : #include <fldbas.hxx>       //DDE
      93             : #include <swundo.hxx>       // for Undo-Ids
      94             : #include <pam.hxx>
      95             : #include <ndole.hxx>
      96             : #include <swwait.hxx>
      97             : #include <viewopt.hxx>
      98             : #include <swerror.h>
      99             : #include <SwCapObjType.hxx>
     100             : #include <cmdid.h>
     101             : #include <dochdl.hrc>
     102             : #include <comcore.hrc> // #111827#
     103             : #include <sot/stg.hxx>
     104             : #include <svx/svditer.hxx>
     105             : #include <editeng/eeitem.hxx>
     106             : #include <editeng/fhgtitem.hxx>
     107             : #include <svx/svdpage.hxx>
     108             : #include <avmedia/mediawindow.hxx>
     109             : #include <swcrsr.hxx>
     110             : #include <SwRewriter.hxx>
     111             : #include <globals.hrc>
     112             : #include <osl/mutex.hxx>
     113             : #include <vcl/svapp.hxx>
     114             : #include <swserv.hxx>
     115             : #include <switerator.hxx>
     116             : 
     117             : extern sal_Bool bFrmDrag;
     118             : extern sal_Bool bDDINetAttr;
     119             : extern sal_Bool bExecuteDrag;
     120             : 
     121             : 
     122             : #define OLESIZE 11905 - 2 * lMinBorder, 6 * MM50
     123             : 
     124             : #define SWTRANSFER_OBJECTTYPE_DRAWMODEL         0x00000001
     125             : #define SWTRANSFER_OBJECTTYPE_HTML              0x00000002
     126             : #define SWTRANSFER_OBJECTTYPE_RTF               0x00000004
     127             : #define SWTRANSFER_OBJECTTYPE_STRING            0x00000008
     128             : #define SWTRANSFER_OBJECTTYPE_SWOLE             0x00000010
     129             : #define SWTRANSFER_OBJECTTYPE_DDE               0x00000020
     130             : 
     131             : #define SWTRANSFER_GRAPHIC_INSERTED             0x00000040
     132             : 
     133             : using namespace ::svx;
     134             : using ::rtl::OUString;
     135             : using namespace ::com::sun::star;
     136             : using namespace ::com::sun::star::uno;
     137             : using namespace ::com::sun::star::datatransfer;
     138             : using namespace nsTransferBufferType;
     139             : 
     140             : #define DDE_TXT_ENCODING    osl_getThreadTextEncoding()
     141             : 
     142             : class SwTrnsfrDdeLink : public ::sfx2::SvBaseLink
     143             : {
     144             :     String sName;
     145             :     ::sfx2::SvLinkSourceRef refObj;
     146             :     SwTransferable& rTrnsfr;
     147             :     SwDocShell* pDocShell;
     148             :     sal_uLong nOldTimeOut;
     149             :     sal_Bool bDelBookmrk : 1;
     150             :     sal_Bool bInDisconnect : 1;
     151             : 
     152             :     sal_Bool FindDocShell();
     153             : 
     154             :     using sfx2::SvBaseLink::Disconnect;
     155             : 
     156             : protected:
     157             :     virtual ~SwTrnsfrDdeLink();
     158             : 
     159             : public:
     160             :     SwTrnsfrDdeLink( SwTransferable& rTrans, SwWrtShell& rSh );
     161             : 
     162             :     virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
     163             :         const String& rMimeType, const ::com::sun::star::uno::Any & rValue );
     164             :     virtual void Closed();
     165             : 
     166             :     sal_Bool WriteData( SvStream& rStrm );
     167             : 
     168             :     void Disconnect( sal_Bool bRemoveDataAdvise );
     169             : };
     170             : 
     171             : // helper class for Action and Undo enclosing
     172             : class SwTrnsfrActionAndUndo
     173             : {
     174             :     SwWrtShell *pSh;
     175             :     SwUndoId eUndoId;
     176             : public:
     177           0 :     SwTrnsfrActionAndUndo( SwWrtShell *pS, SwUndoId nId,
     178             :                            const SwRewriter * pRewriter = 0,
     179             :                            sal_Bool bDelSel = sal_False)
     180           0 :         : pSh( pS ), eUndoId( nId )
     181             :     {
     182           0 :         pSh->StartUndo( eUndoId, pRewriter );
     183           0 :         if( bDelSel )
     184           0 :             pSh->DelRight();
     185           0 :         pSh->StartAllAction();
     186           0 :     }
     187           0 :     ~SwTrnsfrActionAndUndo()
     188             :     {
     189           0 :         pSh->EndUndo();
     190           0 :         pSh->EndAllAction();
     191           0 :     }
     192             : };
     193             : 
     194           0 : SwTransferable::SwTransferable( SwWrtShell& rSh )
     195             :     : pWrtShell( &rSh ),
     196             :     pCreatorView( 0 ),
     197             :     pClpDocFac( 0 ),
     198             :     pClpGraphic( 0 ),
     199             :     pClpBitmap( 0 ),
     200             :     pOrigGrf( 0 ),
     201             :     pBkmk( 0 ),
     202             :     pImageMap( 0 ),
     203             :     pTargetURL( 0 ),
     204           0 :     eBufferType( TRNSFR_NONE )
     205             : {
     206           0 :     rSh.GetView().AddTransferable(*this);
     207           0 :     SwDocShell* pDShell = rSh.GetDoc()->GetDocShell();
     208           0 :     if( pDShell )
     209             :     {
     210           0 :         pDShell->FillTransferableObjectDescriptor( aObjDesc );
     211           0 :         if( pDShell->GetMedium() )
     212             :         {
     213           0 :             const INetURLObject& rURLObj = pDShell->GetMedium()->GetURLObject();
     214             :             aObjDesc.maDisplayName = URIHelper::removePassword(
     215             :                                 rURLObj.GetMainURL( INetURLObject::NO_DECODE ),
     216             :                                 INetURLObject::WAS_ENCODED,
     217           0 :                                    INetURLObject::DECODE_UNAMBIGUOUS );
     218             :         }
     219             : 
     220           0 :         PrepareOLE( aObjDesc );
     221             :     }
     222           0 : }
     223             : 
     224           0 : SwTransferable::~SwTransferable()
     225             : {
     226           0 :     Application::GetSolarMutex().acquire();
     227             : 
     228             :     // the DDELink still needs the WrtShell!
     229           0 :     if( refDdeLink.Is() )
     230             :     {
     231           0 :         ((SwTrnsfrDdeLink*)&refDdeLink)->Disconnect( sal_True );
     232           0 :         refDdeLink.Clear();
     233             :     }
     234             : 
     235           0 :     pWrtShell = 0;
     236             : 
     237             :     // release reference to the document so that aDocShellRef will delete
     238             :     // it (if aDocShellRef is set). Otherwise, the OLE nodes keep references
     239             :     // to their sub-storage when the storage is already dead.
     240           0 :     delete pClpDocFac;
     241             : 
     242             :     // first close, then the Ref. can be cleared as well, so that
     243             :     // the DocShell really gets deleted!
     244           0 :     if( aDocShellRef.Is() )
     245             :     {
     246           0 :         SfxObjectShell * pObj = aDocShellRef;
     247           0 :         SwDocShell* pDocSh = (SwDocShell*)pObj;
     248           0 :         pDocSh->DoClose();
     249             :     }
     250           0 :     aDocShellRef.Clear();
     251             : 
     252           0 :     SwModule* pMod = SW_MOD();
     253           0 :     if(pMod)
     254             :     {
     255           0 :         if ( pMod->pDragDrop == this )
     256           0 :             pMod->pDragDrop = 0;
     257           0 :         else if ( pMod->pXSelection == this )
     258           0 :             pMod->pXSelection = 0;
     259             :     }
     260             : 
     261           0 :     delete pClpGraphic;
     262           0 :     delete pClpBitmap;
     263           0 :     delete pImageMap;
     264           0 :     delete pTargetURL;
     265           0 :     delete pBkmk;
     266             : 
     267             : 
     268           0 :     eBufferType = TRNSFR_NONE;
     269             : 
     270           0 :     Application::GetSolarMutex().release();
     271           0 : }
     272             : 
     273           0 : static SwDoc * lcl_GetDoc(SwDocFac & rDocFac)
     274             : {
     275           0 :     SwDoc *const pDoc = rDocFac.GetDoc();
     276             :     OSL_ENSURE( pDoc, "Document not found" );
     277           0 :     if (pDoc)
     278             :     {
     279           0 :         pDoc->SetClipBoard( true );
     280             :     }
     281           0 :     return pDoc;
     282             : }
     283             : 
     284           0 : void SwTransferable::ObjectReleased()
     285             : {
     286           0 :     SwModule *pMod = SW_MOD();
     287           0 :     if( this == pMod->pDragDrop )
     288           0 :         pMod->pDragDrop = 0;
     289           0 :     else if( this == pMod->pXSelection )
     290           0 :         pMod->pXSelection = 0;
     291           0 : }
     292             : 
     293           0 : void SwTransferable::AddSupportedFormats()
     294             : {
     295             :     // only need if we are the current XSelection Object
     296           0 :     SwModule *pMod = SW_MOD();
     297           0 :     if( this == pMod->pXSelection )
     298             :     {
     299           0 :         SetDataForDragAndDrop( Point( 0,0) );
     300             :     }
     301           0 : }
     302             : 
     303          39 : void SwTransferable::InitOle( SfxObjectShell* pDoc, SwDoc& rDoc )
     304             : {
     305             :     //set OleVisArea. Upper left corner of the page and size of
     306             :     //RealSize in Twips.
     307          39 :     const Size aSz( OLESIZE );
     308          39 :     SwRect aVis( Point( DOCUMENTBORDER, DOCUMENTBORDER ), aSz );
     309          39 :     pDoc->SetVisArea( aVis.SVRect() );
     310          39 :     rDoc.set(IDocumentSettingAccess::BROWSE_MODE, true );
     311          39 : }
     312             : 
     313           0 : uno::Reference < embed::XEmbeddedObject > SwTransferable::FindOLEObj( sal_Int64& nAspect ) const
     314             : {
     315           0 :     uno::Reference < embed::XEmbeddedObject > xObj;
     316           0 :     if( pClpDocFac )
     317             :     {
     318           0 :         SwIterator<SwCntntNode,SwFmtColl> aIter( *pClpDocFac->GetDoc()->GetDfltGrfFmtColl() );
     319           0 :         for( SwCntntNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
     320           0 :             if( ND_OLENODE == pNd->GetNodeType() )
     321             :             {
     322           0 :                 xObj = ((SwOLENode*)pNd)->GetOLEObj().GetOleRef();
     323           0 :                 nAspect = ((SwOLENode*)pNd)->GetAspect();
     324           0 :                 break;
     325           0 :             }
     326             :     }
     327           0 :     return xObj;
     328             : }
     329             : 
     330           0 : Graphic* SwTransferable::FindOLEReplacementGraphic() const
     331             : {
     332           0 :     if( pClpDocFac )
     333             :     {
     334           0 :         SwIterator<SwCntntNode,SwFmtColl> aIter( *pClpDocFac->GetDoc()->GetDfltGrfFmtColl() );
     335           0 :         for( SwCntntNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
     336           0 :             if( ND_OLENODE == pNd->GetNodeType() )
     337             :             {
     338           0 :                 return ((SwOLENode*)pNd)->GetGraphic();
     339           0 :             }
     340             :     }
     341             : 
     342           0 :     return NULL;
     343             : }
     344             : 
     345           0 : void SwTransferable::RemoveDDELinkFormat( const Window& rWin )
     346             : {
     347           0 :     RemoveFormat( SOT_FORMATSTR_ID_LINK );
     348           0 :     CopyToClipboard( (Window*)&rWin );
     349           0 : }
     350             : 
     351             : namespace
     352             : {
     353             :     //Resolves: fdo#40717 surely when we create a clipboard document we should
     354             :     //overwrite the clipboard documents styles and settings with that of the
     355             :     //source, so that we can WYSIWYG paste. If we want that the destinations
     356             :     //styles are used over the source styles, that's a matter of the
     357             :     //destination paste code to handle, not the source paste code.
     358           0 :     void lclOverWriteDoc(SwWrtShell &rSrcWrtShell, SwDoc &rDest)
     359             :     {
     360           0 :         const SwDoc &rSrc = *rSrcWrtShell.GetDoc();
     361             : 
     362           0 :         rDest.ReplaceCompatabilityOptions(rSrc);
     363           0 :         rDest.ReplaceDefaults(rSrc);
     364             : 
     365             :         //It would probably make most sense here to only insert the styles used
     366             :         //by the selection, e.g. apply SwDoc::IsUsed on styles ?
     367           0 :         rDest.ReplaceStyles(rSrc, false);
     368             : 
     369           0 :         rSrcWrtShell.Copy(&rDest);
     370           0 :     }
     371             : }
     372             : 
     373           0 : sal_Bool SwTransferable::GetData( const DATA_FLAVOR& rFlavor )
     374             : {
     375           0 :     sal_uInt32  nFormat = SotExchange::GetFormat( rFlavor );
     376             : 
     377             :     // we can only fullfil the request if
     378             :     // 1) we have data for this format
     379             :     // 2) we have either a clipboard document (pClpDocFac), or
     380             :     //    we have a SwWrtShell (so we can generate a new clipboard document)
     381           0 :     if( !HasFormat( nFormat ) || ( pClpDocFac == NULL && pWrtShell == NULL ) )
     382           0 :         return sal_False;
     383             : 
     384           0 :     if( !pClpDocFac )
     385             :     {
     386           0 :         SelectionType nSelectionType = pWrtShell->GetSelectionType();
     387             : 
     388             : // SEL_GRF comes from ContentType of editsh
     389           0 :         if( (nsSelectionType::SEL_GRF | nsSelectionType::SEL_DRW_FORM) & nSelectionType )
     390             :         {
     391           0 :             pClpGraphic = new Graphic;
     392           0 :             if( !pWrtShell->GetDrawObjGraphic( FORMAT_GDIMETAFILE, *pClpGraphic ))
     393           0 :                 pOrigGrf = pClpGraphic;
     394           0 :             pClpBitmap = new Graphic;
     395           0 :             if( !pWrtShell->GetDrawObjGraphic( FORMAT_BITMAP, *pClpBitmap ))
     396           0 :                 pOrigGrf = pClpBitmap;
     397             : 
     398             :             // is it an URL-Button ?
     399           0 :             String sURL, sDesc;
     400           0 :             if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
     401             :             {
     402           0 :                 pBkmk = new INetBookmark( sURL, sDesc );
     403           0 :                 eBufferType = TRNSFR_INETFLD;
     404           0 :             }
     405             :         }
     406             : 
     407           0 :         pClpDocFac = new SwDocFac;
     408           0 :         SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac);
     409             : 
     410           0 :         pTmpDoc->LockExpFlds();     // never update fields - leave text as it is
     411           0 :         lclOverWriteDoc(*pWrtShell, *pTmpDoc);
     412             : 
     413             :         // in CORE a new one was created (OLE-Objekte copied!)
     414           0 :         aDocShellRef = pTmpDoc->GetTmpDocShell();
     415           0 :         if( aDocShellRef.Is() )
     416           0 :             SwTransferable::InitOle( aDocShellRef, *pTmpDoc );
     417           0 :         pTmpDoc->SetTmpDocShell( (SfxObjectShell*)NULL );
     418             : 
     419           0 :         if( nSelectionType & nsSelectionType::SEL_TXT && !pWrtShell->HasMark() )
     420             :         {
     421           0 :             SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
     422             : 
     423           0 :             Point aPos( SwEditWin::GetDDStartPosX(), SwEditWin::GetDDStartPosY());
     424             : 
     425             :             sal_Bool bSelect = bExecuteDrag &&
     426           0 :                             pWrtShell->GetView().GetDocShell() &&
     427           0 :                             !pWrtShell->GetView().GetDocShell()->IsReadOnly();
     428           0 :             if( pWrtShell->GetContentAtPos( aPos, aCntntAtPos, bSelect ) )
     429             :             {
     430             :                 pBkmk = new INetBookmark(
     431           0 :                         ((SwFmtINetFmt*)aCntntAtPos.aFnd.pAttr)->GetValue(),
     432           0 :                         aCntntAtPos.sStr );
     433           0 :                 eBufferType = TRNSFR_INETFLD;
     434           0 :                 if( bSelect )
     435           0 :                     pWrtShell->SelectTxtAttr( RES_TXTATR_INETFMT );
     436           0 :             }
     437             :         }
     438           0 :         if( pWrtShell->IsFrmSelected() )
     439             :         {
     440           0 :              SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_URL, RES_URL );
     441           0 :             pWrtShell->GetFlyFrmAttr( aSet );
     442           0 :             const SwFmtURL& rURL = (SwFmtURL&)aSet.Get( RES_URL );
     443           0 :             if( rURL.GetMap() )
     444           0 :                 pImageMap = new ImageMap( *rURL.GetMap() );
     445           0 :             else if( rURL.GetURL().Len() )
     446             :                 pTargetURL = new INetImage( aEmptyStr, rURL.GetURL(),
     447             :                                             rURL.GetTargetFrameName(),
     448           0 :                                             aEmptyStr, Size() );
     449             :         }
     450             :     }
     451             : 
     452           0 :     sal_Bool    bOK = sal_False;
     453           0 :     if( TRNSFR_OLE == eBufferType )
     454             :     {
     455             :         //TODO/MBA: testing - is this the "single OLE object" case?!
     456             :         // get OLE-Object from ClipDoc and get the data from that.
     457           0 :         sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; // will be set in the next statement
     458           0 :         uno::Reference < embed::XEmbeddedObject > xObj = FindOLEObj( nAspect );
     459           0 :         Graphic* pOLEGraph = FindOLEReplacementGraphic();
     460           0 :         if( xObj.is() )
     461             :         {
     462           0 :             TransferableDataHelper aD( new SvEmbedTransferHelper( xObj, pOLEGraph, nAspect ) );
     463           0 :             uno::Any aAny( aD.GetAny( rFlavor ));
     464           0 :             if( aAny.hasValue() )
     465           0 :                 bOK = SetAny( aAny, rFlavor );
     466             :         }
     467             : 
     468             :         // the following solution will be used in the case when the object can not generate the image
     469             :         // TODO/LATER: in future the transferhelper must probably be created based on object and the replacement stream
     470           0 :         if ( nFormat == SOT_FORMAT_GDIMETAFILE )
     471             :         {
     472           0 :             pOLEGraph = FindOLEReplacementGraphic();
     473           0 :             if ( pOLEGraph )
     474           0 :                 bOK = SetGDIMetaFile( pOLEGraph->GetGDIMetaFile(), rFlavor );
     475           0 :         }
     476             :     }
     477             :     else
     478             :     {
     479           0 :         switch( nFormat )
     480             :         {
     481             :         case SOT_FORMATSTR_ID_LINK:
     482           0 :             if( refDdeLink.Is() )
     483           0 :                 bOK = SetObject( &refDdeLink,
     484           0 :                                     SWTRANSFER_OBJECTTYPE_DDE, rFlavor );
     485           0 :             break;
     486             : 
     487             :         case SOT_FORMATSTR_ID_OBJECTDESCRIPTOR:
     488             :         case SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR:
     489           0 :             bOK = SetTransferableObjectDescriptor( aObjDesc, rFlavor );
     490           0 :             break;
     491             : 
     492             :         case SOT_FORMATSTR_ID_DRAWING:
     493             :             {
     494           0 :                 SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
     495           0 :                 bOK = SetObject( pDoc->GetDrawModel(),
     496           0 :                                 SWTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor );
     497             :             }
     498           0 :             break;
     499             : 
     500             :         case SOT_FORMAT_STRING:
     501             :         {
     502           0 :             SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
     503           0 :             bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_STRING, rFlavor );
     504             :         }
     505           0 :         break;
     506             :         case SOT_FORMAT_RTF:
     507             :         {
     508           0 :             SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
     509           0 :             bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_RTF, rFlavor );
     510             :         }
     511           0 :             break;
     512             : 
     513             :         case SOT_FORMATSTR_ID_HTML:
     514             :         {
     515           0 :             SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
     516           0 :             bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_HTML, rFlavor );
     517             :         }
     518           0 :             break;
     519             : 
     520             :         case SOT_FORMATSTR_ID_SVXB:
     521           0 :             if( eBufferType & TRNSFR_GRAPHIC && pOrigGrf )
     522           0 :                 bOK = SetGraphic( *pOrigGrf, rFlavor );
     523           0 :             break;
     524             : 
     525             :         case SOT_FORMAT_GDIMETAFILE:
     526           0 :             if( eBufferType & TRNSFR_GRAPHIC )
     527           0 :                 bOK = SetGDIMetaFile( pClpGraphic->GetGDIMetaFile(), rFlavor );
     528           0 :             break;
     529             :         case SOT_FORMAT_BITMAP:
     530             :             // Neither pClpBitmap nor pClpGraphic are necessarily set
     531           0 :             if( (eBufferType & TRNSFR_GRAPHIC) && (pClpBitmap != 0 || pClpGraphic != 0))
     532             :                 bOK = SetBitmap( (pClpBitmap ? pClpBitmap
     533             :                                              : pClpGraphic)->GetBitmap(),
     534           0 :                                  rFlavor );
     535           0 :             break;
     536             : 
     537             :         case SOT_FORMATSTR_ID_SVIM:
     538           0 :             if( pImageMap )
     539           0 :                 bOK = SetImageMap( *pImageMap, rFlavor );
     540           0 :             break;
     541             : 
     542             :         case SOT_FORMATSTR_ID_INET_IMAGE:
     543           0 :             if( pTargetURL )
     544           0 :                 bOK = SetINetImage( *pTargetURL, rFlavor );
     545           0 :             break;
     546             : 
     547             :         case SOT_FORMATSTR_ID_SOLK:
     548             :         case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
     549             :         case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
     550             :         case SOT_FORMATSTR_ID_FILECONTENT:
     551             :         case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR:
     552             :         case SOT_FORMAT_FILE:
     553           0 :             if( (TRNSFR_INETFLD & eBufferType) && pBkmk )
     554           0 :                 bOK = SetINetBookmark( *pBkmk, rFlavor );
     555           0 :             break;
     556             : 
     557             :         case SOT_FORMATSTR_ID_EMBED_SOURCE:
     558           0 :             if( !aDocShellRef.Is() )
     559             :             {
     560           0 :                 SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
     561             :                 SwDocShell* pNewDocSh = new SwDocShell( pDoc,
     562           0 :                                          SFX_CREATE_MODE_EMBEDDED );
     563           0 :                 aDocShellRef = pNewDocSh;
     564           0 :                 aDocShellRef->DoInitNew( NULL );
     565           0 :                 SwTransferable::InitOle( aDocShellRef, *pDoc );
     566             :             }
     567           0 :             bOK = SetObject( &aDocShellRef, SWTRANSFER_OBJECTTYPE_SWOLE,
     568           0 :                             rFlavor );
     569           0 :             break;
     570             :         }
     571             :     }
     572           0 :     return bOK;
     573             : }
     574             : 
     575           0 : sal_Bool SwTransferable::WriteObject( SotStorageStreamRef& xStream,
     576             :                                     void* pObject, sal_uInt32 nObjectType,
     577             :                                     const DATA_FLAVOR& /*rFlavor*/ )
     578             : {
     579           0 :     sal_Bool bRet = sal_False;
     580           0 :     WriterRef xWrt;
     581             : 
     582           0 :     switch( nObjectType )
     583             :     {
     584             :     case SWTRANSFER_OBJECTTYPE_DRAWMODEL:
     585             :         {
     586             :             // dont change the sequence of commands
     587           0 :             SdrModel *pModel = (SdrModel*)pObject;
     588           0 :             xStream->SetBufferSize( 16348 );
     589             : 
     590             :             // for the changed pool defaults from drawing layer pool set those
     591             :             // attributes as hard attributes to preserve them for saving
     592           0 :             const SfxItemPool& rItemPool = pModel->GetItemPool();
     593           0 :             const SvxFontHeightItem& rDefaultFontHeight = (const SvxFontHeightItem&)rItemPool.GetDefaultItem(EE_CHAR_FONTHEIGHT);
     594             : 
     595             :             // SW should have no MasterPages
     596             :             OSL_ENSURE(0L == pModel->GetMasterPageCount(), "SW with MasterPages (!)");
     597             : 
     598           0 :             for(sal_uInt16 a(0); a < pModel->GetPageCount(); a++)
     599             :             {
     600           0 :                 const SdrPage* pPage = pModel->GetPage(a);
     601           0 :                 SdrObjListIter aIter(*pPage, IM_DEEPNOGROUPS);
     602             : 
     603           0 :                 while(aIter.IsMore())
     604             :                 {
     605           0 :                     SdrObject* pObj = aIter.Next();
     606           0 :                     const SvxFontHeightItem& rItem = (const SvxFontHeightItem&)pObj->GetMergedItem(EE_CHAR_FONTHEIGHT);
     607             : 
     608           0 :                     if(rItem.GetHeight() == rDefaultFontHeight.GetHeight())
     609             :                     {
     610           0 :                         pObj->SetMergedItem(rDefaultFontHeight);
     611             :                     }
     612             :                 }
     613           0 :             }
     614             : 
     615             :             {
     616           0 :                 uno::Reference<io::XOutputStream> xDocOut( new utl::OOutputStreamWrapper( *xStream ) );
     617           0 :                 if( SvxDrawingLayerExport( pModel, xDocOut ) )
     618           0 :                     xStream->Commit();
     619             :             }
     620             : 
     621           0 :             bRet = ERRCODE_NONE == xStream->GetError();
     622             :         }
     623           0 :         break;
     624             : 
     625             :     case SWTRANSFER_OBJECTTYPE_SWOLE:
     626             :         {
     627           0 :             SfxObjectShell*   pEmbObj = (SfxObjectShell*) pObject;
     628             :             try
     629             :             {
     630           0 :                 ::utl::TempFile     aTempFile;
     631           0 :                 aTempFile.EnableKillingFile();
     632             :                 uno::Reference< embed::XStorage > xWorkStore =
     633           0 :                     ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
     634             : 
     635             :                 // write document storage
     636           0 :                 pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, sal_False );
     637             :                 // mba: no BaseURL for clipboard
     638           0 :                 SfxMedium aMedium( xWorkStore, String() );
     639           0 :                 bRet = pEmbObj->DoSaveObjectAs( aMedium, sal_False );
     640           0 :                 pEmbObj->DoSaveCompleted();
     641             : 
     642           0 :                 uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
     643           0 :                 if ( xTransact.is() )
     644           0 :                     xTransact->commit();
     645             : 
     646           0 :                 SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ );
     647           0 :                 if( pSrcStm )
     648             :                 {
     649           0 :                     xStream->SetBufferSize( 0xff00 );
     650           0 :                     *xStream << *pSrcStm;
     651           0 :                     delete pSrcStm;
     652             :                 }
     653             : 
     654           0 :                 bRet = sal_True;
     655             : 
     656           0 :                 xWorkStore->dispose();
     657           0 :                 xWorkStore = uno::Reference < embed::XStorage >();
     658           0 :                 xStream->Commit();
     659             :             }
     660           0 :             catch (const uno::Exception&)
     661             :             {
     662             :             }
     663             : 
     664           0 :             bRet = ( xStream->GetError() == ERRCODE_NONE );
     665             :         }
     666           0 :         break;
     667             : 
     668             : 
     669             :     case SWTRANSFER_OBJECTTYPE_DDE:
     670             :         {
     671           0 :             xStream->SetBufferSize( 1024 );
     672           0 :             SwTrnsfrDdeLink* pDdeLnk = (SwTrnsfrDdeLink*)pObject;
     673           0 :             if( pDdeLnk->WriteData( *xStream ) )
     674             :             {
     675           0 :                 xStream->Commit();
     676           0 :                 bRet = ERRCODE_NONE == xStream->GetError();
     677             :             }
     678             :         }
     679           0 :         break;
     680             : 
     681             :     case SWTRANSFER_OBJECTTYPE_HTML:
     682           0 :         GetHTMLWriter( aEmptyStr, String(), xWrt );
     683           0 :         break;
     684             : 
     685             :     case SWTRANSFER_OBJECTTYPE_RTF:
     686           0 :         GetRTFWriter( aEmptyStr, String(), xWrt );
     687           0 :         break;
     688             : 
     689             :     case SWTRANSFER_OBJECTTYPE_STRING:
     690           0 :         GetASCWriter( aEmptyStr, String(), xWrt );
     691           0 :         if( xWrt.Is() )
     692             :         {
     693           0 :             SwAsciiOptions aAOpt;
     694           0 :             aAOpt.SetCharSet( RTL_TEXTENCODING_UTF8 );
     695           0 :             xWrt->SetAsciiOptions( aAOpt );
     696             : 
     697             :             // no start char for clipboard
     698           0 :             xWrt->bUCS2_WithStartChar = sal_False;
     699             :         }
     700           0 :         break;
     701             :     }
     702             : 
     703           0 :     if( xWrt.Is() )
     704             :     {
     705           0 :         SwDoc* pDoc = (SwDoc*)pObject;
     706           0 :         xWrt->bWriteClipboardDoc = sal_True;
     707           0 :         xWrt->bWriteOnlyFirstTable = 0 != (TRNSFR_TABELLE & eBufferType);
     708           0 :         xWrt->SetShowProgress( sal_False );
     709             : 
     710             : #if defined(DEBUGPASTE)
     711             :         SvFileStream aPasteDebug(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
     712             :             "PASTEBUFFER.debug")), STREAM_WRITE|STREAM_TRUNC);
     713             :         SwWriter aDbgWrt( aPasteDebug, *pDoc );
     714             :         aDbgWrt.Write( xWrt );
     715             : #endif
     716             : 
     717           0 :         SwWriter aWrt( *xStream, *pDoc );
     718           0 :         if( !IsError( aWrt.Write( xWrt )) )
     719             :         {
     720           0 :             *xStream << '\0';               // terminate with a zero
     721           0 :             xStream->Commit();
     722           0 :             bRet = sal_True;
     723           0 :         }
     724             :     }
     725             : 
     726           0 :     return bRet;
     727             : }
     728             : 
     729           0 : int SwTransferable::Cut()
     730             : {
     731           0 :     int nRet = Copy( sal_True );
     732           0 :     if( nRet )
     733           0 :         DeleteSelection();
     734           0 :     return nRet;
     735             : }
     736             : 
     737           0 : void SwTransferable::DeleteSelection()
     738             : {
     739           0 :     if(!pWrtShell)
     740           0 :         return;
     741             :     // ask for type of selection before action-bracketing
     742           0 :     const int nSelection = pWrtShell->GetSelectionType();
     743           0 :     pWrtShell->StartUndo( UNDO_DELETE );
     744           0 :     if( ( nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL ) & nSelection )
     745           0 :         pWrtShell->IntelligentCut( nSelection );
     746           0 :     pWrtShell->DelRight();
     747           0 :     pWrtShell->EndUndo( UNDO_DELETE );
     748             : }
     749             : 
     750           0 : int SwTransferable::PrepareForCopy( sal_Bool bIsCut )
     751             : {
     752           0 :     int nRet = 1;
     753           0 :     if(!pWrtShell)
     754           0 :         return 0;
     755             : 
     756           0 :     String sGrfNm;
     757           0 :     const int nSelection = pWrtShell->GetSelectionType();
     758           0 :     if( nSelection == nsSelectionType::SEL_GRF )
     759             :     {
     760           0 :         pClpGraphic = new Graphic;
     761           0 :         if( !pWrtShell->GetDrawObjGraphic( FORMAT_GDIMETAFILE, *pClpGraphic ))
     762           0 :             pOrigGrf = pClpGraphic;
     763           0 :         pClpBitmap = new Graphic;
     764           0 :         if( !pWrtShell->GetDrawObjGraphic( FORMAT_BITMAP, *pClpBitmap ))
     765           0 :             pOrigGrf = pClpBitmap;
     766             : 
     767           0 :         pClpDocFac = new SwDocFac;
     768           0 :         SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
     769           0 :         pWrtShell->Copy( pDoc );
     770             : 
     771           0 :         if (pOrigGrf && !pOrigGrf->GetBitmap().IsEmpty())
     772           0 :           AddFormat( SOT_FORMATSTR_ID_SVXB );
     773             : 
     774           0 :         PrepareOLE( aObjDesc );
     775           0 :         AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
     776             : 
     777           0 :         const Graphic* pGrf = pWrtShell->GetGraphic();
     778           0 :         if( pGrf && pGrf->IsSupportedGraphic() )
     779             :         {
     780           0 :             AddFormat( FORMAT_GDIMETAFILE );
     781           0 :             AddFormat( FORMAT_BITMAP );
     782             :         }
     783           0 :         eBufferType = TRNSFR_GRAPHIC;
     784           0 :         pWrtShell->GetGrfNms( &sGrfNm, 0 );
     785             :     }
     786           0 :     else if ( nSelection == nsSelectionType::SEL_OLE )
     787             :     {
     788           0 :         pClpDocFac = new SwDocFac;
     789           0 :         SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
     790           0 :         aDocShellRef = new SwDocShell( pDoc, SFX_CREATE_MODE_EMBEDDED);
     791           0 :         aDocShellRef->DoInitNew( NULL );
     792           0 :         pWrtShell->Copy( pDoc );
     793             : 
     794           0 :         AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
     795             : 
     796             :         // --> OD #i98753#
     797             :         // set size of embedded object at the object description structure
     798           0 :         aObjDesc.maSize = OutputDevice::LogicToLogic( pWrtShell->GetObjSize(), MAP_TWIP, MAP_100TH_MM );
     799             :         // <--
     800           0 :         PrepareOLE( aObjDesc );
     801           0 :         AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
     802             : 
     803           0 :         AddFormat( FORMAT_GDIMETAFILE );
     804           0 :         eBufferType = TRNSFR_OLE;
     805             :     }
     806             :     // Is there anything to provide anyway?
     807           0 :     else if ( pWrtShell->IsSelection() || pWrtShell->IsFrmSelected() ||
     808           0 :               pWrtShell->IsObjSelected() )
     809             :     {
     810           0 :         SwWait *pWait = 0;
     811           0 :         if( pWrtShell->ShouldWait() )
     812           0 :             pWait = new SwWait( *pWrtShell->GetView().GetDocShell(), sal_True );
     813             : 
     814           0 :         pClpDocFac = new SwDocFac;
     815             : 
     816             :         // create additional cursor so that equal treatment of keyboard
     817             :         // and mouse selection is possible.
     818             :         // In AddMode with keyboard selection, the new cursor is not created
     819             :         // before the cursor is moved after end of selection.
     820           0 :         if( pWrtShell->IsAddMode() && pWrtShell->SwCrsrShell::HasSelection() )
     821           0 :             pWrtShell->CreateCrsr();
     822             : 
     823           0 :         SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac);
     824             : 
     825           0 :         pTmpDoc->LockExpFlds();     // nie die Felder updaten - Text so belassen
     826           0 :         lclOverWriteDoc(*pWrtShell, *pTmpDoc);
     827             : 
     828             :         {
     829           0 :             IDocumentMarkAccess* const pMarkAccess = pTmpDoc->getIDocumentMarkAccess();
     830           0 :             ::std::vector< ::sw::mark::IMark* > vDdeMarks;
     831             :             // find all DDE-Bookmarks
     832           0 :             for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
     833           0 :                 ppMark != pMarkAccess->getMarksEnd();
     834             :                 ++ppMark)
     835             :             {
     836           0 :                 if(IDocumentMarkAccess::DDE_BOOKMARK == IDocumentMarkAccess::GetType(**ppMark))
     837           0 :                     vDdeMarks.push_back(ppMark->get());
     838             :             }
     839             :             // remove all DDE-Bookmarks, they are invalid inside the clipdoc!
     840           0 :             for(::std::vector< ::sw::mark::IMark* >::iterator ppMark = vDdeMarks.begin();
     841           0 :                 ppMark != vDdeMarks.end();
     842             :                 ++ppMark)
     843           0 :                 pMarkAccess->deleteMark(*ppMark);
     844             :         }
     845             : 
     846             :         // a new one was created in CORE (OLE-Objekte copied!)
     847           0 :         aDocShellRef = pTmpDoc->GetTmpDocShell();
     848           0 :         if( aDocShellRef.Is() )
     849           0 :             SwTransferable::InitOle( aDocShellRef, *pTmpDoc );
     850           0 :         pTmpDoc->SetTmpDocShell( (SfxObjectShell*)NULL );
     851             : 
     852           0 :         if( pWrtShell->IsObjSelected() )
     853           0 :             eBufferType = TRNSFR_DRAWING;
     854             :         else
     855             :         {
     856           0 :             eBufferType = TRNSFR_DOCUMENT;
     857           0 :             if (pWrtShell->IntelligentCut(nSelection, sal_False) != SwWrtShell::NO_WORD)
     858           0 :                 eBufferType = (TransferBufferType)(TRNSFR_DOCUMENT_WORD | eBufferType);
     859             :         }
     860             : 
     861           0 :         int bDDELink = pWrtShell->IsSelection();
     862           0 :         if( nSelection & nsSelectionType::SEL_TBL_CELLS )
     863             :         {
     864           0 :             eBufferType = (TransferBufferType)(TRNSFR_TABELLE | eBufferType);
     865           0 :             bDDELink = pWrtShell->HasWholeTabSelection();
     866             :         }
     867             : 
     868             :         //When someone needs it, we 'OLE' him something
     869           0 :         AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
     870             : 
     871             :         //put RTF ahead of  the OLE's Metafile to have less loss
     872           0 :         if( !pWrtShell->IsObjSelected() )
     873             :         {
     874           0 :             AddFormat( FORMAT_RTF );
     875           0 :             AddFormat( SOT_FORMATSTR_ID_HTML );
     876             :         }
     877           0 :         if( pWrtShell->IsSelection() )
     878           0 :             AddFormat( FORMAT_STRING );
     879             : 
     880           0 :         if( nSelection & ( nsSelectionType::SEL_DRW | nsSelectionType::SEL_DRW_FORM ))
     881             :         {
     882           0 :             AddFormat( SOT_FORMATSTR_ID_DRAWING );
     883           0 :             if ( nSelection & nsSelectionType::SEL_DRW )
     884             :             {
     885           0 :                 AddFormat( FORMAT_GDIMETAFILE );
     886           0 :                 AddFormat( FORMAT_BITMAP );
     887             :             }
     888           0 :             eBufferType = (TransferBufferType)( TRNSFR_GRAPHIC | eBufferType );
     889             : 
     890           0 :             pClpGraphic = new Graphic;
     891           0 :             if( !pWrtShell->GetDrawObjGraphic( FORMAT_GDIMETAFILE, *pClpGraphic ))
     892           0 :                 pOrigGrf = pClpGraphic;
     893           0 :             pClpBitmap = new Graphic;
     894           0 :             if( !pWrtShell->GetDrawObjGraphic( FORMAT_BITMAP, *pClpBitmap ))
     895           0 :                 pOrigGrf = pClpBitmap;
     896             : 
     897             :             // is it an URL-Button ?
     898           0 :             String sURL, sDesc;
     899           0 :             if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
     900             :             {
     901           0 :                 AddFormat( FORMAT_STRING );
     902           0 :                  AddFormat( SOT_FORMATSTR_ID_SOLK );
     903           0 :                  AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
     904           0 :                  AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
     905           0 :                  AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
     906           0 :                  AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
     907           0 :                 eBufferType = (TransferBufferType)( TRNSFR_INETFLD | eBufferType );
     908           0 :                 nRet = sal_True;
     909           0 :             }
     910             :         }
     911             : 
     912             :         // at Cut, DDE-Link doesn't make sense!!
     913             :         SwDocShell* pDShell;
     914           0 :         if( !bIsCut && bDDELink &&
     915           0 :             0 != ( pDShell = pWrtShell->GetDoc()->GetDocShell()) &&
     916           0 :             SFX_CREATE_MODE_STANDARD == pDShell->GetCreateMode() )
     917             :         {
     918           0 :             AddFormat( SOT_FORMATSTR_ID_LINK );
     919           0 :             refDdeLink = new SwTrnsfrDdeLink( *this, *pWrtShell );
     920             :         }
     921             : 
     922             :         //ObjectDescriptor was already filly from the old DocShell.
     923             :         //Now adjust it. Thus in GetData the first query can still
     924             :         //be answered with delayed rendering.
     925           0 :         aObjDesc.mbCanLink = sal_False;
     926           0 :         Size aSz( OLESIZE );
     927           0 :         aObjDesc.maSize = OutputDevice::LogicToLogic( aSz, MAP_TWIP, MAP_100TH_MM );
     928             : 
     929           0 :         PrepareOLE( aObjDesc );
     930           0 :         AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
     931             : 
     932           0 :         delete pWait;
     933             :     }
     934             :     else
     935           0 :         nRet = 0;
     936             : 
     937           0 :     if( pWrtShell->IsFrmSelected() )
     938             :     {
     939           0 :         SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_URL, RES_URL );
     940           0 :         pWrtShell->GetFlyFrmAttr( aSet );
     941           0 :         const SwFmtURL& rURL = (SwFmtURL&)aSet.Get( RES_URL );
     942           0 :         if( rURL.GetMap() )
     943             :         {
     944           0 :             pImageMap = new ImageMap( *rURL.GetMap() );
     945           0 :             AddFormat( SOT_FORMATSTR_ID_SVIM );
     946             :         }
     947           0 :         else if( rURL.GetURL().Len() )
     948             :         {
     949             :             pTargetURL = new INetImage( sGrfNm, rURL.GetURL(),
     950             :                                         rURL.GetTargetFrameName(),
     951           0 :                                         aEmptyStr, Size() );
     952           0 :             AddFormat( SOT_FORMATSTR_ID_INET_IMAGE );
     953           0 :         }
     954             :     }
     955             : 
     956           0 :     return nRet;
     957             : }
     958             : 
     959           0 : int SwTransferable::Copy( sal_Bool bIsCut )
     960             : {
     961           0 :     int nRet = PrepareForCopy( bIsCut );
     962           0 :     if ( nRet )
     963             :     {
     964           0 :         CopyToClipboard( &pWrtShell->GetView().GetEditWin() );
     965             :     }
     966           0 :     return nRet;
     967             : }
     968             : 
     969           0 : int SwTransferable::CalculateAndCopy()
     970             : {
     971           0 :     if(!pWrtShell)
     972           0 :         return 0;
     973           0 :     SwWait aWait( *pWrtShell->GetView().GetDocShell(), sal_True );
     974             : 
     975           0 :     String aStr( pWrtShell->Calculate() );
     976             : 
     977           0 :     pClpDocFac = new SwDocFac;
     978           0 :     SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac);
     979           0 :     pWrtShell->Copy(pDoc, & aStr);
     980           0 :     eBufferType = TRNSFR_DOCUMENT;
     981           0 :     AddFormat( FORMAT_STRING );
     982             : 
     983           0 :     CopyToClipboard( &pWrtShell->GetView().GetEditWin() );
     984             : 
     985           0 :     return 1;
     986             : }
     987             : 
     988           0 : int SwTransferable::CopyGlossary( SwTextBlocks& rGlossary,
     989             :                                     const String& rStr )
     990             : {
     991           0 :     if(!pWrtShell)
     992           0 :         return 0;
     993           0 :     SwWait aWait( *pWrtShell->GetView().GetDocShell(), sal_True );
     994             : 
     995           0 :     pClpDocFac = new SwDocFac;
     996           0 :     SwDoc *const pCDoc = lcl_GetDoc(*pClpDocFac);
     997             : 
     998           0 :     SwNodes& rNds = pCDoc->GetNodes();
     999           0 :     SwNodeIndex aNodeIdx( *rNds.GetEndOfContent().StartOfSectionNode() );
    1000           0 :     SwCntntNode* pCNd = rNds.GoNext( &aNodeIdx ); // go to 1st ContentNode
    1001           0 :     SwPaM aPam( *pCNd );
    1002             : 
    1003           0 :     pCDoc->LockExpFlds();   // never update fields - leave text as it is
    1004             : 
    1005           0 :     pCDoc->InsertGlossary( rGlossary, rStr, aPam, 0 );
    1006             : 
    1007             :     // a new one was created in CORE (OLE-Objects copied!)
    1008           0 :     aDocShellRef = pCDoc->GetTmpDocShell();
    1009           0 :     if( aDocShellRef.Is() )
    1010           0 :         SwTransferable::InitOle( aDocShellRef, *pCDoc );
    1011           0 :     pCDoc->SetTmpDocShell( (SfxObjectShell*)NULL );
    1012             : 
    1013           0 :     eBufferType = TRNSFR_DOCUMENT;
    1014             : 
    1015             :     //When someone needs it, we 'OLE' her something.
    1016           0 :     AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
    1017           0 :     AddFormat( FORMAT_RTF );
    1018           0 :     AddFormat( SOT_FORMATSTR_ID_HTML );
    1019           0 :     AddFormat( FORMAT_STRING );
    1020             : 
    1021             :     //ObjectDescriptor was already filled from the old DocShell.
    1022             :     //Now adjust it. Thus in GetData the first query can still
    1023             :     //be answered with delayed rendering.
    1024           0 :     aObjDesc.mbCanLink = sal_False;
    1025           0 :     Size aSz( OLESIZE );
    1026           0 :     aObjDesc.maSize = OutputDevice::LogicToLogic( aSz, MAP_TWIP, MAP_100TH_MM );
    1027             : 
    1028           0 :     PrepareOLE( aObjDesc );
    1029           0 :     AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
    1030             : 
    1031           0 :     CopyToClipboard( &pWrtShell->GetView().GetEditWin() );
    1032             : 
    1033           0 :     return 1;
    1034             : }
    1035             : 
    1036           0 : static inline uno::Reference < XTransferable > * lcl_getTransferPointer ( uno::Reference < XTransferable > &xRef )
    1037             : {
    1038           0 :     return &xRef;
    1039             : }
    1040             : 
    1041           0 : sal_Bool SwTransferable::IsPaste( const SwWrtShell& rSh,
    1042             :                               const TransferableDataHelper& rData )
    1043             : {
    1044             :     // Check the common case first: We can always paste our own data!
    1045             :     // If _only_ the internal format can be pasted, this check will
    1046             :     // yield 'true', while the one below would give a (wrong) result 'false'.
    1047             : 
    1048           0 :     bool bIsPaste = ( GetSwTransferable( rData ) != NULL );
    1049             : 
    1050             :     // if it's not our own data, we need to have a closer look:
    1051           0 :     if( ! bIsPaste )
    1052             :     {
    1053             :         // determine the proper paste action, and return true if we find one
    1054           0 :         uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
    1055             : 
    1056           0 :         sal_uInt16 nDestination = SwTransferable::GetSotDestination( rSh );
    1057             :         sal_uInt16 nSourceOptions =
    1058             :                     (( EXCHG_DEST_DOC_TEXTFRAME == nDestination ||
    1059             :                        EXCHG_DEST_SWDOC_FREE_AREA == nDestination ||
    1060             :                        EXCHG_DEST_DOC_TEXTFRAME_WEB == nDestination ||
    1061             :                        EXCHG_DEST_SWDOC_FREE_AREA_WEB == nDestination )
    1062             :                                     ? EXCHG_IN_ACTION_COPY
    1063           0 :                      : EXCHG_IN_ACTION_MOVE);
    1064             : 
    1065             :         sal_uLong nFormat;          // output param for GetExchangeAction
    1066             :         sal_uInt16 nEventAction;    // output param for GetExchangeAction
    1067             :         sal_uInt16 nAction = SotExchange::GetExchangeAction(
    1068           0 :                                 rData.GetDataFlavorExVector(),
    1069             :                                 nDestination,
    1070             :                                 nSourceOptions,             /* ?? */
    1071             :                                 EXCHG_IN_ACTION_DEFAULT,    /* ?? */
    1072             :                                 nFormat, nEventAction, 0,
    1073           0 :                                 lcl_getTransferPointer ( xTransferable ) );
    1074             : 
    1075             :         // if we find a suitable action, we can paste!
    1076           0 :         bIsPaste = (EXCHG_INOUT_ACTION_NONE != nAction);
    1077             :     }
    1078             : 
    1079           0 :     return bIsPaste;
    1080             : }
    1081             : 
    1082           0 : int SwTransferable::Paste( SwWrtShell& rSh, TransferableDataHelper& rData )
    1083             : {
    1084           0 :     sal_uInt16 nEventAction, nAction=0,
    1085           0 :            nDestination = SwTransferable::GetSotDestination( rSh );
    1086           0 :     sal_uLong nFormat = 0;
    1087             : 
    1088           0 :     if( GetSwTransferable( rData ) )
    1089             :     {
    1090           0 :         nAction = EXCHG_OUT_ACTION_INSERT_PRIVATE;
    1091             :     }
    1092             :     else
    1093             :     {
    1094             :         sal_uInt16 nSourceOptions =
    1095             :                     (( EXCHG_DEST_DOC_TEXTFRAME == nDestination ||
    1096             :                     EXCHG_DEST_SWDOC_FREE_AREA == nDestination ||
    1097             :                     EXCHG_DEST_DOC_TEXTFRAME_WEB == nDestination ||
    1098             :                     EXCHG_DEST_SWDOC_FREE_AREA_WEB == nDestination )
    1099             :                                     ? EXCHG_IN_ACTION_COPY
    1100           0 :                                     : EXCHG_IN_ACTION_MOVE);
    1101           0 :         uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
    1102             :         nAction = SotExchange::GetExchangeAction(
    1103           0 :                                     rData.GetDataFlavorExVector(),
    1104             :                                     nDestination,
    1105             :                                     nSourceOptions,             /* ?? */
    1106             :                                     EXCHG_IN_ACTION_DEFAULT,    /* ?? */
    1107             :                                     nFormat, nEventAction, 0,
    1108           0 :                                     lcl_getTransferPointer ( xTransferable ) );
    1109             :     }
    1110             : 
    1111             :     // special case for tables from draw application
    1112           0 :     if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ == (nAction & EXCHG_ACTION_MASK) )
    1113             :     {
    1114           0 :         if( rData.HasFormat( SOT_FORMAT_RTF ) )
    1115             :         {
    1116           0 :             nAction = EXCHG_OUT_ACTION_INSERT_STRING | (nAction & !EXCHG_ACTION_MASK);
    1117           0 :             nFormat = SOT_FORMAT_RTF;
    1118             :         }
    1119             :     }
    1120             : 
    1121             :     return EXCHG_INOUT_ACTION_NONE != nAction &&
    1122             :             SwTransferable::PasteData( rData, rSh, nAction, nFormat,
    1123           0 :                                         nDestination, sal_False, sal_False );
    1124             : }
    1125             : 
    1126           0 : int SwTransferable::PasteData( TransferableDataHelper& rData,
    1127             :                             SwWrtShell& rSh, sal_uInt16 nAction, sal_uLong nFormat,
    1128             :                             sal_uInt16 nDestination, sal_Bool bIsPasteFmt,
    1129             :                             sal_Bool bIsDefault,
    1130             :                             const Point* pPt, sal_Int8 nDropAction,
    1131             :                             sal_Bool bPasteSelection )
    1132             : {
    1133           0 :     SwWait aWait( *rSh.GetView().
    1134           0 :         GetDocShell(), sal_False );
    1135           0 :     SwTrnsfrActionAndUndo* pAction = 0;
    1136           0 :     SwModule* pMod = SW_MOD();
    1137             : 
    1138           0 :     int nRet = 0;
    1139           0 :     bool bCallAutoCaption = false;
    1140             : 
    1141           0 :     if( pPt )
    1142             :     {
    1143             :         // external Drop
    1144           0 :         if( bPasteSelection ? !pMod->pXSelection : !pMod->pDragDrop )
    1145             :         {
    1146           0 :             switch( nDestination )
    1147             :             {
    1148             :             case EXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP:
    1149             :             case EXCHG_DEST_DOC_LNKD_GRAPHOBJ:
    1150             :             case EXCHG_DEST_DOC_GRAPH_W_IMAP:
    1151             :             case EXCHG_DEST_DOC_GRAPHOBJ:
    1152             :             case EXCHG_DEST_DOC_OLEOBJ:
    1153             :             case EXCHG_DEST_DOC_DRAWOBJ:
    1154             :             case EXCHG_DEST_DOC_URLBUTTON:
    1155             :             case EXCHG_DEST_DOC_GROUPOBJ:
    1156             :                 // select frames/objects
    1157           0 :                 SwTransferable::SetSelInShell( rSh, sal_True, pPt );
    1158           0 :                 break;
    1159             : 
    1160             :             default:
    1161           0 :                 SwTransferable::SetSelInShell( rSh, sal_False, pPt );
    1162           0 :                 break;
    1163             :             }
    1164             :         }
    1165             :     }
    1166           0 :     else if( ( !GetSwTransferable( rData ) || bIsPasteFmt ) &&
    1167           0 :             !rSh.IsTableMode() && rSh.HasSelection() )
    1168             :     {
    1169             :         // then delete the selections
    1170             : 
    1171             :         //don't delete selected content
    1172             :         // - at table-selection
    1173             :         // - at ReRead of a graphic/DDEData
    1174             :         // - at D&D, for the right selection was taken care of
    1175             :         //      in Drop-Handler
    1176           0 :         sal_Bool bDelSel = sal_False;
    1177           0 :         switch( nDestination )
    1178             :         {
    1179             :         case EXCHG_DEST_DOC_TEXTFRAME:
    1180             :         case EXCHG_DEST_SWDOC_FREE_AREA:
    1181             :         case EXCHG_DEST_DOC_TEXTFRAME_WEB:
    1182             :         case EXCHG_DEST_SWDOC_FREE_AREA_WEB:
    1183           0 :             bDelSel = sal_True;
    1184           0 :             break;
    1185             :         }
    1186             : 
    1187           0 :         if( bDelSel )
    1188             :             // #i34830#
    1189             :             pAction = new SwTrnsfrActionAndUndo( &rSh, UNDO_PASTE_CLIPBOARD, NULL,
    1190           0 :                                                  sal_True );
    1191             :     }
    1192             : 
    1193           0 :     SwTransferable *pTrans=0, *pTunneledTrans=GetSwTransferable( rData );
    1194             : 
    1195           0 :     if( pPt && ( bPasteSelection ? 0 != ( pTrans = pMod->pXSelection )
    1196             :                                  : 0 != ( pTrans = pMod->pDragDrop) ))
    1197             :     {
    1198             :         // then internal Drag & Drop or XSelection
    1199             :         nRet = pTrans->PrivateDrop( rSh, *pPt, DND_ACTION_MOVE == nDropAction,
    1200           0 :                                     bPasteSelection );
    1201             :     }
    1202           0 :     else if( !pPt && pTunneledTrans &&
    1203             :             EXCHG_OUT_ACTION_INSERT_PRIVATE == nAction )
    1204             :     {
    1205             :         // then internal paste
    1206           0 :         nRet = pTunneledTrans->PrivatePaste( rSh );
    1207             :     }
    1208           0 :     else if( EXCHG_INOUT_ACTION_NONE != nAction )
    1209             :     {
    1210           0 :         if( !pAction )
    1211             :         {
    1212           0 :             pAction = new SwTrnsfrActionAndUndo( &rSh, UNDO_PASTE_CLIPBOARD);
    1213             :         }
    1214             : 
    1215             :         // in Drag&Drop MessageBoxes must not be showed
    1216           0 :         sal_Bool bMsg = 0 == pPt;
    1217           0 :         sal_uInt8 nActionFlags = static_cast< sal_uInt8 >(( nAction >> 8 ) & 0xFF);
    1218             : 
    1219           0 :         sal_uInt16 nClearedAction = ( nAction & EXCHG_ACTION_MASK );
    1220             :         // delete selections
    1221             : 
    1222           0 :         switch( nClearedAction )
    1223             :         {
    1224             :         case EXCHG_OUT_ACTION_INSERT_PRIVATE:
    1225             :             OSL_ENSURE( pPt, "EXCHG_OUT_ACTION_INSERT_PRIVATE: what should happen here?" );
    1226           0 :             break;
    1227             : 
    1228             :         case EXCHG_OUT_ACTION_MOVE_PRIVATE:
    1229             :             OSL_ENSURE( pPt, "EXCHG_OUT_ACTION_MOVE_PRIVATE: what should happen here?" );
    1230           0 :             break;
    1231             : 
    1232             : 
    1233             :         case EXCHG_IN_ACTION_MOVE:
    1234             :         case EXCHG_IN_ACTION_COPY:
    1235             :         case EXCHG_IN_ACTION_LINK:
    1236             :         case EXCHG_OUT_ACTION_INSERT_HTML:
    1237             :         case EXCHG_OUT_ACTION_INSERT_STRING:
    1238             :         case EXCHG_OUT_ACTION_INSERT_IMAGEMAP:
    1239             :         case EXCHG_OUT_ACTION_REPLACE_IMAGEMAP:
    1240             : 
    1241             :             // then we have to use the format
    1242           0 :             switch( nFormat )
    1243             :             {
    1244             :             case SOT_FORMATSTR_ID_DRAWING:
    1245             :                 nRet = SwTransferable::_PasteSdrFormat( rData, rSh,
    1246             :                                                 SW_PASTESDR_INSERT, pPt,
    1247           0 :                                                 nActionFlags );
    1248           0 :                 break;
    1249             : 
    1250             :             case SOT_FORMATSTR_ID_HTML:
    1251             :             case SOT_FORMATSTR_ID_HTML_SIMPLE:
    1252             :             case SOT_FORMATSTR_ID_HTML_NO_COMMENT:
    1253             :             case SOT_FORMAT_RTF:
    1254             :             case SOT_FORMAT_STRING:
    1255             :                 nRet = SwTransferable::_PasteFileContent( rData, rSh,
    1256           0 :                                                             nFormat, bMsg );
    1257           0 :                 break;
    1258             : 
    1259             :             case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
    1260             :                 {
    1261           0 :                     INetBookmark aBkmk;
    1262           0 :                     if( rData.GetINetBookmark( nFormat, aBkmk ) )
    1263             :                     {
    1264           0 :                         SwFmtINetFmt aFmt( aBkmk.GetURL(), aEmptyStr );
    1265           0 :                         rSh.InsertURL( aFmt, aBkmk.GetDescription() );
    1266           0 :                         nRet = 1;
    1267           0 :                     }
    1268             :                 }
    1269           0 :                 break;
    1270             : 
    1271             :             case SOT_FORMATSTR_ID_SD_OLE:
    1272             :                 nRet = SwTransferable::_PasteOLE( rData, rSh, nFormat,
    1273           0 :                                                     nActionFlags, bMsg );
    1274           0 :                 break;
    1275             : 
    1276             :             case SOT_FORMATSTR_ID_SVIM:
    1277           0 :                 nRet = SwTransferable::_PasteImageMap( rData, rSh );
    1278           0 :                 break;
    1279             : 
    1280             :             case SOT_FORMATSTR_ID_SVXB:
    1281             :             case SOT_FORMAT_BITMAP:
    1282             :             case SOT_FORMAT_GDIMETAFILE:
    1283             :                 nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
    1284             :                                                 SW_PASTESDR_INSERT,pPt,
    1285           0 :                                                 nActionFlags, bMsg );
    1286           0 :                 break;
    1287             : 
    1288             :             case SOT_FORMATSTR_ID_XFORMS:
    1289             :             case SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE:
    1290             :             case SOT_FORMATSTR_ID_SBA_DATAEXCHANGE:
    1291             :             case SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE:
    1292             :                 nRet = SwTransferable::_PasteDBData( rData, rSh, nFormat,
    1293             :                                             EXCHG_IN_ACTION_LINK == nClearedAction,
    1294           0 :                                             pPt, bMsg );
    1295           0 :                 break;
    1296             : 
    1297             :             case SOT_FORMAT_FILE:
    1298             :                 nRet = SwTransferable::_PasteFileName( rData, rSh, nFormat,
    1299             :                                 ( EXCHG_IN_ACTION_MOVE == nClearedAction
    1300             :                                     ? SW_PASTESDR_REPLACE
    1301             :                                     : EXCHG_IN_ACTION_LINK == nClearedAction
    1302             :                                         ? SW_PASTESDR_SETATTR
    1303             :                                         : SW_PASTESDR_INSERT),
    1304           0 :                                 pPt, nActionFlags, bMsg );
    1305           0 :                 break;
    1306             : 
    1307             :             case SOT_FORMAT_FILE_LIST:
    1308             :                 // then insert as graphics only
    1309             :                 nRet = SwTransferable::_PasteFileList( rData, rSh,
    1310             :                                     EXCHG_IN_ACTION_LINK == nClearedAction,
    1311           0 :                                     pPt, bMsg );
    1312           0 :                 break;
    1313             : 
    1314             :             case SOT_FORMATSTR_ID_SONLK:
    1315           0 :                 if( pPt )
    1316             :                 {
    1317           0 :                     NaviContentBookmark aBkmk;
    1318           0 :                     if( aBkmk.Paste( rData ) )
    1319             :                     {
    1320           0 :                         if(bIsDefault)
    1321             :                         {
    1322           0 :                             switch(aBkmk.GetDefaultDragType())
    1323             :                             {
    1324           0 :                                 case REGION_MODE_NONE: nClearedAction = EXCHG_IN_ACTION_COPY; break;
    1325           0 :                                 case REGION_MODE_EMBEDDED: nClearedAction = EXCHG_IN_ACTION_MOVE; break;
    1326           0 :                                 case REGION_MODE_LINK: nClearedAction = EXCHG_IN_ACTION_LINK; break;
    1327             :                             }
    1328             :                         }
    1329           0 :                         rSh.NavigatorPaste( aBkmk, nClearedAction );
    1330           0 :                         nRet = 1;
    1331           0 :                     }
    1332             :                 }
    1333           0 :                 break;
    1334             : 
    1335             :             case SOT_FORMATSTR_ID_INET_IMAGE:
    1336             :             case SOT_FORMATSTR_ID_NETSCAPE_IMAGE:
    1337             :                 nRet = SwTransferable::_PasteTargetURL( rData, rSh,
    1338             :                                                         SW_PASTESDR_INSERT,
    1339           0 :                                                         pPt, sal_True );
    1340           0 :                 break;
    1341             : 
    1342             :             default:
    1343             :                 OSL_ENSURE( pPt, "unknown format" );
    1344             :             }
    1345           0 :             break;
    1346             : 
    1347             :         case EXCHG_OUT_ACTION_INSERT_FILE:
    1348             :             nRet = SwTransferable::_PasteFileName( rData, rSh, nFormat,
    1349             :                                         SW_PASTESDR_INSERT, pPt,
    1350           0 :                                         nActionFlags, bMsg );
    1351           0 :             if( nRet & SWTRANSFER_GRAPHIC_INSERTED )
    1352           0 :                 bCallAutoCaption = true;
    1353           0 :             break;
    1354             : 
    1355             :         case EXCHG_OUT_ACTION_INSERT_OLE:
    1356             :             nRet = SwTransferable::_PasteOLE( rData, rSh, nFormat,
    1357           0 :                                                 nActionFlags,bMsg );
    1358           0 :             break;
    1359             : 
    1360             :         case EXCHG_OUT_ACTION_INSERT_DDE:
    1361             :             {
    1362           0 :                 sal_Bool bReRead = 0 != CNT_HasGrf( rSh.GetCntType() );
    1363           0 :                 nRet = SwTransferable::_PasteDDE( rData, rSh, bReRead, bMsg );
    1364             :             }
    1365           0 :             break;
    1366             : 
    1367             :         case EXCHG_OUT_ACTION_INSERT_HYPERLINK:
    1368             :             {
    1369           0 :                 String sURL, sDesc;
    1370           0 :                 if( SOT_FORMAT_FILE == nFormat )
    1371             :                 {
    1372           0 :                     if( rData.GetString( nFormat, sURL ) && sURL.Len() )
    1373             :                     {
    1374           0 :                         SwTransferable::_CheckForURLOrLNKFile( rData, sURL, &sDesc );
    1375           0 :                         if( !sDesc.Len() )
    1376           0 :                             sDesc = sURL;
    1377           0 :                         nRet = 1;
    1378             :                     }
    1379             :                 }
    1380             :                 else
    1381             :                 {
    1382           0 :                     INetBookmark aBkmk;
    1383           0 :                     if( rData.GetINetBookmark( nFormat, aBkmk ) )
    1384             :                     {
    1385           0 :                         sURL = aBkmk.GetURL();
    1386           0 :                         sDesc = aBkmk.GetDescription();
    1387           0 :                         nRet = 1;
    1388           0 :                     }
    1389             :                 }
    1390             : 
    1391           0 :                 if( nRet )
    1392             :                 {
    1393           0 :                     SwFmtINetFmt aFmt( sURL, aEmptyStr );
    1394           0 :                     rSh.InsertURL( aFmt, sDesc );
    1395           0 :                 }
    1396             :             }
    1397           0 :             break;
    1398             : 
    1399             :         case EXCHG_OUT_ACTION_GET_ATTRIBUTES:
    1400           0 :             switch( nFormat )
    1401             :             {
    1402             :             case SOT_FORMATSTR_ID_DRAWING:
    1403             :                 nRet = SwTransferable::_PasteSdrFormat( rData, rSh,
    1404             :                                                 SW_PASTESDR_SETATTR, pPt,
    1405           0 :                                                 nActionFlags );
    1406           0 :                 break;
    1407             :             case SOT_FORMATSTR_ID_SVXB:
    1408             :             case SOT_FORMAT_GDIMETAFILE:
    1409             :             case SOT_FORMAT_BITMAP:
    1410             :             case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
    1411             :             case SOT_FORMAT_FILE:
    1412             :             case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
    1413             :             case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR:
    1414             :                 nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
    1415             :                                                 SW_PASTESDR_SETATTR, pPt,
    1416           0 :                                                 nActionFlags, bMsg );
    1417           0 :                 break;
    1418             :             default:
    1419             :                 OSL_FAIL( "unknown format" );
    1420             :             }
    1421             : 
    1422           0 :             break;
    1423             : 
    1424             :         case EXCHG_OUT_ACTION_INSERT_DRAWOBJ:
    1425             :             nRet = SwTransferable::_PasteSdrFormat( rData, rSh,
    1426             :                                                 SW_PASTESDR_INSERT, pPt,
    1427           0 :                                                 nActionFlags );
    1428           0 :             break;
    1429             :         case EXCHG_OUT_ACTION_INSERT_SVXB:
    1430             :         case EXCHG_OUT_ACTION_INSERT_GDIMETAFILE:
    1431             :         case EXCHG_OUT_ACTION_INSERT_BITMAP:
    1432             :         case EXCHG_OUT_ACTION_INSERT_GRAPH:
    1433             :             nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
    1434             :                                                 SW_PASTESDR_INSERT, pPt,
    1435           0 :                                                 nActionFlags, bMsg );
    1436           0 :             break;
    1437             : 
    1438             :         case EXCHG_OUT_ACTION_REPLACE_DRAWOBJ:
    1439             :             nRet = SwTransferable::_PasteSdrFormat( rData, rSh,
    1440             :                                                 SW_PASTESDR_REPLACE, pPt,
    1441           0 :                                                 nActionFlags );
    1442           0 :             break;
    1443             : 
    1444             :         case EXCHG_OUT_ACTION_REPLACE_SVXB:
    1445             :         case EXCHG_OUT_ACTION_REPLACE_GDIMETAFILE:
    1446             :         case EXCHG_OUT_ACTION_REPLACE_BITMAP:
    1447             :         case EXCHG_OUT_ACTION_REPLACE_GRAPH:
    1448             :             nRet = SwTransferable::_PasteGrf( rData, rSh, nFormat,
    1449             :                                                 SW_PASTESDR_REPLACE,pPt,
    1450           0 :                                                 nActionFlags, bMsg );
    1451           0 :             break;
    1452             : 
    1453             :         case EXCHG_OUT_ACTION_INSERT_INTERACTIVE:
    1454           0 :             nRet = SwTransferable::_PasteAsHyperlink( rData, rSh, nFormat );
    1455           0 :             break;
    1456             : 
    1457             :         default:
    1458             :             OSL_FAIL("unknown action" );
    1459             :         }
    1460             :     }
    1461             : 
    1462           0 :     if( !bPasteSelection && rSh.IsFrmSelected() )
    1463             :     {
    1464           0 :         rSh.EnterSelFrmMode();
    1465             :         //force ::SelectShell
    1466           0 :         rSh.GetView().StopShellTimer();
    1467             :     }
    1468             : 
    1469           0 :     delete pAction;
    1470           0 :     if( bCallAutoCaption )
    1471           0 :         rSh.GetView().AutoCaption( GRAPHIC_CAP );
    1472             : 
    1473           0 :     return nRet;
    1474             : }
    1475             : 
    1476           0 : sal_uInt16 SwTransferable::GetSotDestination( const SwWrtShell& rSh,
    1477             :                                             const Point* pPt )
    1478             : {
    1479           0 :     sal_uInt16 nRet = EXCHG_INOUT_ACTION_NONE;
    1480             : 
    1481             :     ObjCntType eOType;
    1482           0 :     if( pPt )
    1483             :     {
    1484           0 :         SdrObject *pObj = 0;
    1485           0 :         eOType = rSh.GetObjCntType( *pPt, pObj );
    1486             :     }
    1487             :     else
    1488           0 :         eOType = rSh.GetObjCntTypeOfSelection();
    1489             : 
    1490           0 :     switch( eOType )
    1491             :     {
    1492             :     case OBJCNT_GRF:
    1493             :         {
    1494             :             sal_Bool bIMap, bLink;
    1495           0 :             if( pPt )
    1496             :             {
    1497           0 :                 bIMap = 0 != rSh.GetFmtFromObj( *pPt )->GetURL().GetMap();
    1498           0 :                 String aDummy;
    1499           0 :                 rSh.GetGrfAtPos( *pPt, aDummy, bLink );
    1500             :             }
    1501             :             else
    1502             :             {
    1503           0 :                 bIMap = 0 != rSh.GetFlyFrmFmt()->GetURL().GetMap();
    1504           0 :                 String aDummy;
    1505           0 :                 rSh.GetGrfNms( &aDummy, 0 );
    1506           0 :                 bLink = 0 != aDummy.Len();
    1507             :             }
    1508             : 
    1509           0 :             if( bLink && bIMap )
    1510           0 :                 nRet = EXCHG_DEST_DOC_LNKD_GRAPH_W_IMAP;
    1511           0 :             else if( bLink )
    1512           0 :                 nRet = EXCHG_DEST_DOC_LNKD_GRAPHOBJ;
    1513           0 :             else if( bIMap )
    1514           0 :                 nRet = EXCHG_DEST_DOC_GRAPH_W_IMAP;
    1515             :             else
    1516           0 :                 nRet = EXCHG_DEST_DOC_GRAPHOBJ;
    1517             :         }
    1518           0 :         break;
    1519             : 
    1520             :     case OBJCNT_FLY:
    1521           0 :         if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
    1522           0 :             nRet = EXCHG_DEST_DOC_TEXTFRAME_WEB;
    1523             :         else
    1524           0 :             nRet = EXCHG_DEST_DOC_TEXTFRAME;
    1525           0 :         break;
    1526           0 :     case OBJCNT_OLE:        nRet = EXCHG_DEST_DOC_OLEOBJ;       break;
    1527             : 
    1528             :     case OBJCNT_CONTROL:    /* no Action avail */
    1529           0 :     case OBJCNT_SIMPLE:     nRet = EXCHG_DEST_DOC_DRAWOBJ;      break;
    1530           0 :     case OBJCNT_URLBUTTON:  nRet = EXCHG_DEST_DOC_URLBUTTON;    break;
    1531           0 :     case OBJCNT_GROUPOBJ:   nRet = EXCHG_DEST_DOC_GROUPOBJ;     break;
    1532             : 
    1533             : // what do we do at multiple selections???
    1534             :     default:
    1535             :         {
    1536           0 :             if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
    1537           0 :                 nRet = EXCHG_DEST_SWDOC_FREE_AREA_WEB;
    1538             :             else
    1539           0 :                 nRet = EXCHG_DEST_SWDOC_FREE_AREA;
    1540             :         }
    1541             :     }
    1542             : 
    1543           0 :     return nRet;
    1544             : }
    1545             : 
    1546           0 : int SwTransferable::_PasteFileContent( TransferableDataHelper& rData,
    1547             :                                     SwWrtShell& rSh, sal_uLong nFmt, sal_Bool bMsg )
    1548             : {
    1549           0 :     sal_uInt16 nResId = MSG_CLPBRD_FORMAT_ERROR;
    1550           0 :     int nRet = 0;
    1551             : 
    1552           0 :     MSE40HTMLClipFormatObj aMSE40ClpObj;
    1553             : 
    1554           0 :     SotStorageStreamRef xStrm;
    1555           0 :     SvStream* pStream = 0;
    1556           0 :     SwRead pRead = 0;
    1557           0 :     rtl::OUString sData;
    1558           0 :     switch( nFmt )
    1559             :     {
    1560             :     case SOT_FORMAT_STRING:
    1561             :         {
    1562           0 :             pRead = ReadAscii;
    1563           0 :             if( rData.GetString( nFmt, sData ) )
    1564             :             {
    1565             :                 pStream = new SvMemoryStream( (void*)sData.getStr(),
    1566           0 :                             sData.getLength() * sizeof( sal_Unicode ),
    1567           0 :                             STREAM_READ );
    1568             : #ifdef OSL_BIGENDIAN
    1569             :                 pStream->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
    1570             : #else
    1571           0 :                 pStream->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
    1572             : #endif
    1573             : 
    1574           0 :                 SwAsciiOptions aAOpt;
    1575           0 :                 aAOpt.SetCharSet( RTL_TEXTENCODING_UCS2 );
    1576           0 :                 pRead->GetReaderOpt().SetASCIIOpts( aAOpt );
    1577           0 :                 break;
    1578             :             }
    1579             :         }
    1580             :         // no break - because then test if we get a stream
    1581             : 
    1582             :     default:
    1583           0 :         if( rData.GetSotStorageStream( nFmt, xStrm ) )
    1584             :         {
    1585           0 :             if( ( SOT_FORMATSTR_ID_HTML_SIMPLE == nFmt ) ||
    1586             :                 ( SOT_FORMATSTR_ID_HTML_NO_COMMENT == nFmt ) )
    1587             :             {
    1588           0 :                 pStream = aMSE40ClpObj.IsValid( *xStrm );
    1589           0 :                 pRead = ReadHTML;
    1590           0 :                 pRead->SetReadUTF8( sal_True );
    1591             : 
    1592             :                 sal_Bool bNoComments =
    1593           0 :                     ( nFmt == SOT_FORMATSTR_ID_HTML_NO_COMMENT );
    1594           0 :                 pRead->SetIgnoreHTMLComments( bNoComments );
    1595             :             }
    1596             :             else
    1597             :             {
    1598           0 :                 pStream = &xStrm;
    1599           0 :                 if( SOT_FORMAT_RTF == nFmt )
    1600           0 :                     pRead = SwReaderWriter::GetReader( READER_WRITER_RTF );
    1601           0 :                 else if( !pRead )
    1602             :                 {
    1603           0 :                     pRead = ReadHTML;
    1604           0 :                     pRead->SetReadUTF8( sal_True );
    1605             :                 }
    1606             :             }
    1607             :         }
    1608           0 :         break;
    1609             :     }
    1610             : 
    1611           0 :     if( pStream && pRead )
    1612             :     {
    1613           0 :         Link aOldLink( rSh.GetChgLnk() );
    1614           0 :         rSh.SetChgLnk( Link() );
    1615             : 
    1616           0 :         const SwPosition& rInsPos = *rSh.GetCrsr()->Start();
    1617           0 :         SwReader aReader( *pStream, aEmptyStr, String(), *rSh.GetCrsr() );
    1618           0 :         rSh.SaveTblBoxCntnt( &rInsPos );
    1619           0 :         if( IsError( aReader.Read( *pRead )) )
    1620           0 :             nResId = ERR_CLPBRD_READ;
    1621             :         else
    1622           0 :             nResId = 0, nRet = 1;
    1623             : 
    1624           0 :         rSh.SetChgLnk( aOldLink );
    1625           0 :         if( nRet )
    1626           0 :             rSh.CallChgLnk();
    1627             :     }
    1628             :     else
    1629           0 :         nResId = MSG_CLPBRD_FORMAT_ERROR;
    1630             : 
    1631             :     // Exist a SvMemoryStream? (data in the OUString and xStrm is empty)
    1632           0 :     if( pStream && !xStrm.Is() )
    1633           0 :         delete pStream;
    1634             : 
    1635           0 :     if( bMsg && nResId )
    1636             :     {
    1637           0 :         InfoBox( 0, SW_RES( nResId )).Execute();
    1638             :     }
    1639           0 :     return nRet;
    1640             : }
    1641             : 
    1642           0 : int SwTransferable::_PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
    1643             :                                 sal_uLong nFmt, sal_uInt8 nActionFlags, sal_Bool bMsg )
    1644             : {
    1645           0 :     int nRet = 0;
    1646           0 :     TransferableObjectDescriptor aObjDesc;
    1647           0 :     uno::Reference < io::XInputStream > xStrm;
    1648           0 :     uno::Reference < embed::XStorage > xStore;
    1649           0 :     Reader* pRead = 0;
    1650             : 
    1651             :     // Get the preferred format
    1652             :     SotFormatStringId nId;
    1653           0 :     if( rData.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ ) )
    1654           0 :         nId = SOT_FORMATSTR_ID_EMBEDDED_OBJ;
    1655           0 :     else if( rData.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ) &&
    1656           0 :              rData.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ))
    1657           0 :         nId = SOT_FORMATSTR_ID_EMBED_SOURCE;
    1658             :     else
    1659           0 :         nId = 0;
    1660             : 
    1661           0 :     if( nId && rData.GetInputStream( nId, xStrm ) && xStrm.is() )
    1662             :     {
    1663             :         // if there is an embedded object, first try if it's a writer object
    1664             :         // this will be inserted into the document by using a Reader
    1665             :         try
    1666             :         {
    1667           0 :             xStore = comphelper::OStorageHelper::GetStorageFromInputStream( xStrm );
    1668           0 :             switch( SotStorage::GetFormatID( xStore ) )
    1669             :             {
    1670             :                 case SOT_FORMATSTR_ID_STARWRITER_60:
    1671             :                 case SOT_FORMATSTR_ID_STARWRITERWEB_60:
    1672             :                 case SOT_FORMATSTR_ID_STARWRITERGLOB_60:
    1673             :                 case SOT_FORMATSTR_ID_STARWRITER_8:
    1674             :                 case SOT_FORMATSTR_ID_STARWRITERWEB_8:
    1675             :                 case SOT_FORMATSTR_ID_STARWRITERGLOB_8:
    1676           0 :                     pRead = ReadXML;
    1677           0 :                     break;
    1678             :                 default:
    1679             :                     try
    1680             :                     {
    1681           0 :                         uno::Reference < lang::XComponent > xComp( xStore, uno::UNO_QUERY );
    1682           0 :                         xComp->dispose();
    1683           0 :                         xStore = 0;
    1684             :                     }
    1685           0 :                     catch (const uno::Exception&)
    1686             :                     {
    1687             :                     }
    1688             : 
    1689           0 :                     break;
    1690             :             }
    1691             :         }
    1692           0 :         catch (const uno::Exception&)
    1693             :         {
    1694             :             // it wasn't a storage, but maybe it's a useful stream
    1695             :         }
    1696             : 
    1697           0 :         nFmt = nId;
    1698             :     }
    1699             : 
    1700           0 :     if( pRead )
    1701             :     {
    1702           0 :         SwPaM &rPAM = *rSh.GetCrsr();
    1703           0 :         SwReader aReader( xStore, aEmptyStr, rPAM );
    1704           0 :         if( !IsError( aReader.Read( *pRead )) )
    1705           0 :             nRet = 1;
    1706           0 :         else if( bMsg )
    1707           0 :             InfoBox( 0, SW_RES(ERR_CLPBRD_READ) ).Execute();
    1708             :     }
    1709             :     else
    1710             :     {
    1711             :            // temporary storage until the object is inserted
    1712           0 :         uno::Reference< embed::XStorage > xTmpStor;
    1713           0 :         uno::Reference < embed::XEmbeddedObject > xObj;
    1714           0 :         ::rtl::OUString aName;
    1715           0 :            comphelper::EmbeddedObjectContainer aCnt;
    1716             : 
    1717           0 :         if ( xStrm.is() )
    1718             :         {
    1719           0 :             if ( !rData.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) )
    1720             :             {
    1721             :                 OSL_ENSURE( !xStrm.is(), "An object without descriptor in clipboard!");
    1722             :             }
    1723             :         }
    1724             :         else
    1725             :         {
    1726           0 :             if( rData.HasFormat( nFmt = SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE ) && rData.GetTransferableObjectDescriptor( nFmt, aObjDesc ) )
    1727             :              {
    1728           0 :                 if ( !rData.GetInputStream( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE, xStrm ) )
    1729           0 :                     rData.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE, xStrm );
    1730             : 
    1731           0 :                 if ( !xStrm.is() )
    1732             :                 {
    1733             :                     // This is MSOLE object that should be created by direct using of system clipboard
    1734             :                     try
    1735             :                     {
    1736           0 :                         xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage();
    1737             :                         uno::Reference < embed::XEmbedObjectClipboardCreator > xClipboardCreator(
    1738           0 :                             ::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString(
    1739           0 :                                             RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.MSOLEObjectSystemCreator")) ),
    1740           0 :                             uno::UNO_QUERY_THROW );
    1741             : 
    1742           0 :                         embed::InsertedObjectInfo aInfo = xClipboardCreator->createInstanceInitFromClipboard(
    1743             :                                                             xTmpStor,
    1744             :                                                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "DummyName" ) ),
    1745           0 :                                                             uno::Sequence< beans::PropertyValue >() );
    1746             : 
    1747             :                         // TODO/LATER: in future InsertedObjectInfo will be used to get container related information
    1748             :                         // for example whether the object should be an iconified one
    1749           0 :                         xObj = aInfo.Object;
    1750             :                     }
    1751           0 :                     catch (const uno::Exception&)
    1752             :                     {
    1753             :                     }
    1754             :                 }
    1755             :             }
    1756             :         }
    1757             : 
    1758           0 :         if ( xStrm.is() && !xObj.is() )
    1759           0 :             xObj = aCnt.InsertEmbeddedObject( xStrm, aName );
    1760             : 
    1761           0 :         if( xObj.is() )
    1762             :         {
    1763           0 :             svt::EmbeddedObjectRef xObjRef( xObj, aObjDesc.mnViewAspect );
    1764             : 
    1765             :             // try to get the replacement image from the clipboard
    1766           0 :             Graphic aGraphic;
    1767           0 :             sal_uLong nGrFormat = 0;
    1768             : 
    1769             :             // insert replacement image ( if there is one ) into the object helper
    1770           0 :             if ( nGrFormat )
    1771             :             {
    1772           0 :                 datatransfer::DataFlavor aDataFlavor;
    1773           0 :                 SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
    1774           0 :                    xObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
    1775             :             }
    1776           0 :             else if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
    1777             :             {
    1778             :                 // it is important to have an icon, let an empty graphic be used
    1779             :                 // if no other graphic is provided
    1780             :                 // TODO/LATER: in future a default bitmap could be used
    1781           0 :                 ::rtl::OUString aMimeType;
    1782           0 :                 MapMode aMapMode( MAP_100TH_MM );
    1783           0 :                 aGraphic.SetPrefSize( Size( 2500, 2500 ) );
    1784           0 :                 aGraphic.SetPrefMapMode( aMapMode );
    1785           0 :                    xObjRef.SetGraphic( aGraphic, aMimeType );
    1786             :             }
    1787             : 
    1788             :             //set size. This is a hack because of handing over, size should be
    1789             :             //passed to the InsertOle!!!!!!!!!!
    1790           0 :             Size aSize;
    1791           0 :             if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
    1792             :             {
    1793           0 :                    if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
    1794           0 :                     aSize = aObjDesc.maSize;
    1795             :                 else
    1796             :                 {
    1797           0 :                     MapMode aMapMode( MAP_100TH_MM );
    1798           0 :                     aSize = xObjRef.GetSize( &aMapMode );
    1799             :                 }
    1800             :             }
    1801           0 :             else if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
    1802             :             {
    1803           0 :                 aSize = Size( aObjDesc.maSize );    //always 100TH_MM
    1804           0 :                 MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
    1805           0 :                 aSize = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aUnit );
    1806           0 :                 awt::Size aSz;
    1807             :                 try
    1808             :                 {
    1809           0 :                     aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
    1810             :                 }
    1811           0 :                 catch (const embed::NoVisualAreaSizeException&)
    1812             :                 {
    1813             :                     // in this case the provided size is used
    1814             :                 }
    1815             : 
    1816           0 :                 if ( aSz.Width != aSize.Width() || aSz.Height != aSize.Height() )
    1817             :                 {
    1818           0 :                     aSz.Width = aSize.Width();
    1819           0 :                     aSz.Height = aSize.Height();
    1820           0 :                     xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
    1821             :                 }
    1822             :             }
    1823             :             else
    1824             :             {
    1825             :                 // the descriptor contains the wrong object size
    1826             :                 // the following call will let the MSOLE objects cache the size if it is possible
    1827             :                 // it should be done while the object is running
    1828             :                 try
    1829             :                 {
    1830           0 :                     xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
    1831             :                 }
    1832           0 :                 catch (const uno::Exception&)
    1833             :                 {
    1834             :                 }
    1835             :             }
    1836             :             //End of Hack!
    1837             : 
    1838           0 :             rSh.InsertOleObject( xObjRef );
    1839           0 :             nRet = 1;
    1840             : 
    1841           0 :             if( nRet && ( nActionFlags &
    1842             :                 ( EXCHG_OUT_ACTION_FLAG_INSERT_TARGETURL >> 8) ))
    1843           0 :                 SwTransferable::_PasteTargetURL( rData, rSh, 0, 0, sal_False );
    1844             : 
    1845             :             // let the object be unloaded if possible
    1846           0 :             SwOLEObj::UnloadObject( xObj, rSh.GetDoc(), embed::Aspects::MSOLE_CONTENT );
    1847           0 :         }
    1848             :     }
    1849           0 :     return nRet;
    1850             : }
    1851             : 
    1852           0 : int SwTransferable::_PasteTargetURL( TransferableDataHelper& rData,
    1853             :                                     SwWrtShell& rSh, sal_uInt16 nAction,
    1854             :                                     const Point* pPt, sal_Bool bInsertGRF )
    1855             : {
    1856           0 :     int nRet = 0;
    1857           0 :     INetImage aINetImg;
    1858           0 :     if( ( rData.HasFormat( SOT_FORMATSTR_ID_INET_IMAGE ) &&
    1859           0 :           rData.GetINetImage( SOT_FORMATSTR_ID_INET_IMAGE, aINetImg )) ||
    1860           0 :         ( rData.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_IMAGE ) &&
    1861           0 :           rData.GetINetImage( SOT_FORMATSTR_ID_NETSCAPE_IMAGE, aINetImg )) )
    1862             :     {
    1863           0 :         if( aINetImg.GetImageURL().Len() && bInsertGRF )
    1864             :         {
    1865           0 :             String sURL( aINetImg.GetImageURL() );
    1866           0 :             SwTransferable::_CheckForURLOrLNKFile( rData, sURL );
    1867             : 
    1868             :             //!!! check at FileSystem - only then it make sense to test graphics !!!
    1869           0 :             Graphic aGrf;
    1870           0 :             GraphicFilter &rFlt = GraphicFilter::GetGraphicFilter();
    1871           0 :             nRet = GRFILTER_OK == GraphicFilter::LoadGraphic( sURL, aEmptyStr, aGrf, &rFlt );
    1872           0 :             if( nRet )
    1873             :             {
    1874           0 :                 switch( nAction )
    1875             :                 {
    1876             :                 case SW_PASTESDR_INSERT:
    1877           0 :                     SwTransferable::SetSelInShell( rSh, sal_False, pPt );
    1878           0 :                     rSh.Insert( sURL, aEmptyStr, aGrf );
    1879           0 :                     break;
    1880             : 
    1881             :                 case SW_PASTESDR_REPLACE:
    1882           0 :                     if( rSh.IsObjSelected() )
    1883             :                     {
    1884           0 :                         rSh.ReplaceSdrObj( sURL, aEmptyStr, &aGrf );
    1885           0 :                         Point aPt( pPt ? *pPt : rSh.GetCrsrDocPos() );
    1886           0 :                         SwTransferable::SetSelInShell( rSh, sal_True, &aPt );
    1887             :                     }
    1888             :                     else
    1889           0 :                         rSh.ReRead( sURL, aEmptyStr, &aGrf );
    1890           0 :                     break;
    1891             : 
    1892             :                 case SW_PASTESDR_SETATTR:
    1893           0 :                     if( rSh.IsObjSelected() )
    1894           0 :                         rSh.Paste( aGrf );
    1895           0 :                     else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() )
    1896           0 :                         rSh.ReRead( sURL, aEmptyStr, &aGrf );
    1897             :                     else
    1898             :                     {
    1899           0 :                         SwTransferable::SetSelInShell( rSh, sal_False, pPt );
    1900           0 :                         rSh.Insert( sURL, aEmptyStr, aGrf );
    1901             :                     }
    1902           0 :                     break;
    1903             :                 default:
    1904           0 :                     nRet = 0;
    1905             :                 }
    1906           0 :             }
    1907             :         }
    1908             :         else
    1909           0 :             nRet = 1;
    1910             :     }
    1911             : 
    1912           0 :     if( nRet )
    1913             :     {
    1914           0 :         SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
    1915           0 :         rSh.GetFlyFrmAttr( aSet );
    1916           0 :         SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
    1917             : 
    1918           0 :         if( aURL.GetURL() != aINetImg.GetTargetURL() ||
    1919           0 :             aURL.GetTargetFrameName() != aINetImg.GetTargetFrame() )
    1920             :         {
    1921           0 :             aURL.SetURL( aINetImg.GetTargetURL(), sal_False );
    1922           0 :             aURL.SetTargetFrameName( aINetImg.GetTargetFrame() );
    1923           0 :             aSet.Put( aURL );
    1924           0 :             rSh.SetFlyFrmAttr( aSet );
    1925           0 :         }
    1926             :     }
    1927           0 :     return nRet;
    1928             : }
    1929             : 
    1930           0 : void SwTransferable::SetSelInShell( SwWrtShell& rSh, sal_Bool bSelectFrm,
    1931             :                                         const Point* pPt )
    1932             : {
    1933           0 :     if( bSelectFrm )
    1934             :     {
    1935             :         // select frames/objects
    1936           0 :         if( pPt && !rSh.GetView().GetViewFrame()->GetDispatcher()->IsLocked() )
    1937             :         {
    1938           0 :             rSh.GetView().NoRotate();
    1939           0 :             if( rSh.SelectObj( *pPt ))
    1940             :             {
    1941           0 :                 rSh.HideCrsr();
    1942           0 :                 rSh.EnterSelFrmMode( pPt );
    1943           0 :                 bFrmDrag = sal_True;
    1944             :             }
    1945             :         }
    1946             :     }
    1947             :     else
    1948             :     {
    1949           0 :         if( rSh.IsFrmSelected() || rSh.IsObjSelected() )
    1950             :         {
    1951           0 :             rSh.UnSelectFrm();
    1952           0 :             rSh.LeaveSelFrmMode();
    1953           0 :             rSh.GetView().GetEditWin().StopInsFrm();
    1954           0 :             bFrmDrag = sal_False;
    1955             :         }
    1956           0 :         else if( rSh.GetView().GetDrawFuncPtr() )
    1957           0 :             rSh.GetView().GetEditWin().StopInsFrm();
    1958             : 
    1959           0 :         rSh.EnterStdMode();
    1960           0 :         if( pPt )
    1961           0 :             rSh.SwCrsrShell::SetCrsr( *pPt, sal_True );
    1962             :     }
    1963           0 : }
    1964             : 
    1965           0 : int SwTransferable::_PasteDDE( TransferableDataHelper& rData,
    1966             :                                 SwWrtShell& rWrtShell, sal_Bool bReReadGrf,
    1967             :                                 sal_Bool bMsg )
    1968             : {
    1969             :     // data from Clipboardformat
    1970           0 :     String aApp, aTopic, aItem;
    1971             : 
    1972             :     {
    1973           0 :         SotStorageStreamRef xStrm;
    1974           0 :         if( !rData.GetSotStorageStream( SOT_FORMATSTR_ID_LINK, xStrm ))
    1975             :         {
    1976             :             OSL_ENSURE( !&rWrtShell, "DDE Data not found." );
    1977           0 :             return 0;
    1978             :         }   // report useful error!!
    1979             : 
    1980           0 :         rtl_TextEncoding eEncoding = DDE_TXT_ENCODING;
    1981           0 :         aApp = read_zeroTerminated_uInt8s_ToOUString(*xStrm, eEncoding);
    1982           0 :         aTopic = read_zeroTerminated_uInt8s_ToOUString(*xStrm, eEncoding);
    1983           0 :         aItem = read_zeroTerminated_uInt8s_ToOUString(*xStrm, eEncoding);
    1984             :     }
    1985             : 
    1986           0 :     String aCmd;
    1987           0 :     sfx2::MakeLnkName( aCmd, &aApp, aTopic, aItem );
    1988             : 
    1989             :     // do we want to read in a graphic now?
    1990             :     sal_uLong nFormat;
    1991           0 :     if( !rData.HasFormat( FORMAT_RTF ) &&
    1992           0 :         !rData.HasFormat( SOT_FORMATSTR_ID_HTML ) &&
    1993           0 :         !rData.HasFormat( FORMAT_STRING ) &&
    1994           0 :         (rData.HasFormat( nFormat = FORMAT_GDIMETAFILE ) ||
    1995           0 :          rData.HasFormat( nFormat = FORMAT_BITMAP )) )
    1996             :     {
    1997           0 :         Graphic aGrf;
    1998           0 :         int nRet = rData.GetGraphic( nFormat, aGrf );
    1999           0 :         if( nRet )
    2000             :         {
    2001           0 :             rtl::OUString sLnkTyp("DDE");
    2002           0 :             if ( bReReadGrf )
    2003           0 :                 rWrtShell.ReRead( aCmd, sLnkTyp, &aGrf );
    2004             :             else
    2005           0 :                 rWrtShell.Insert( aCmd, sLnkTyp, aGrf );
    2006             :         }
    2007           0 :         return nRet;
    2008             :     }
    2009             : 
    2010           0 :     SwFieldType* pTyp = 0;
    2011           0 :     sal_uInt16 i = 1,j;
    2012           0 :     String aName;
    2013           0 :     sal_Bool bAlreadyThere = sal_False, bDoublePaste = sal_False;
    2014           0 :     sal_uInt16 nSize = rWrtShell.GetFldTypeCount();
    2015           0 :     const ::utl::TransliterationWrapper& rColl = ::GetAppCmpStrIgnore();
    2016             : 
    2017           0 :     do {
    2018           0 :         aName = aApp;
    2019           0 :         aName += String::CreateFromInt32( i );
    2020           0 :         for( j = INIT_FLDTYPES; j < nSize; j++ )
    2021             :         {
    2022           0 :             pTyp = rWrtShell.GetFldType( j );
    2023           0 :             if( RES_DDEFLD == pTyp->Which() )
    2024             :             {
    2025           0 :                 String sTmp( ((SwDDEFieldType*)pTyp)->GetCmd() );
    2026           0 :                 if( rColl.isEqual( sTmp, aCmd ) &&
    2027           0 :                     sfx2::LINKUPDATE_ALWAYS == ((SwDDEFieldType*)pTyp)->GetType() )
    2028             :                 {
    2029           0 :                     aName = pTyp->GetName();
    2030           0 :                     bDoublePaste = sal_True;
    2031             :                     break;
    2032             :                 }
    2033           0 :                 else if( rColl.isEqual( aName, pTyp->GetName() ) )
    2034           0 :                     break;
    2035             :             }
    2036             :         }
    2037           0 :         if( j == nSize )
    2038           0 :             bAlreadyThere = sal_False;
    2039             :         else
    2040             :         {
    2041           0 :             bAlreadyThere = sal_True;
    2042           0 :             i++;
    2043             :         }
    2044             :     }
    2045             :     while( bAlreadyThere && !bDoublePaste );
    2046             : 
    2047           0 :     if( !bDoublePaste )
    2048             :     {
    2049           0 :         SwDDEFieldType aType( aName, aCmd, sfx2::LINKUPDATE_ALWAYS );
    2050           0 :         pTyp = rWrtShell.InsertFldType( aType );
    2051             :     }
    2052             : 
    2053             : 
    2054           0 :     SwDDEFieldType* pDDETyp = (SwDDEFieldType*)pTyp;
    2055             : 
    2056           0 :     String aExpand;
    2057           0 :     if( rData.GetString( FORMAT_STRING, aExpand ))
    2058             :     {
    2059             :         do {            // middle checked loop
    2060             : 
    2061             :             // When data comes from a spreadsheet, we add a DDE-table
    2062           0 :             if( ( rData.HasFormat( SOT_FORMATSTR_ID_SYLK ) ||
    2063           0 :                   rData.HasFormat( SOT_FORMATSTR_ID_SYLK_BIGCAPS ) ) &&
    2064           0 :                 aExpand.Len() &&
    2065           0 :                  ( 1 < comphelper::string::getTokenCount(aExpand, '\n') ||
    2066           0 :                        comphelper::string::getTokenCount(aExpand, '\t') ) )
    2067             :             {
    2068           0 :                 String sTmp( aExpand );
    2069           0 :                 xub_StrLen nRows = comphelper::string::getTokenCount(sTmp, '\n');
    2070           0 :                 if( nRows )
    2071           0 :                     --nRows;
    2072           0 :                 sTmp = sTmp.GetToken( 0, '\n' );
    2073           0 :                 xub_StrLen nCols = comphelper::string::getTokenCount(sTmp, '\t');
    2074             : 
    2075             :                 // at least one column & row must be there
    2076           0 :                 if( !nRows || !nCols )
    2077             :                 {
    2078           0 :                     if( bMsg )
    2079           0 :                         InfoBox(0, SW_RESSTR(STR_NO_TABLE)).Execute();
    2080           0 :                     pDDETyp = 0;
    2081             :                     break;
    2082             :                 }
    2083             : 
    2084             :                 rWrtShell.InsertDDETable(
    2085             :                     SwInsertTableOptions( tabopts::SPLIT_LAYOUT, 1 ), // TODO MULTIHEADER
    2086           0 :                     pDDETyp, nRows, nCols );
    2087             :             }
    2088           0 :             else if( 1 < comphelper::string::getTokenCount(aExpand, '\n') )
    2089             :             {
    2090             :                 // multiple paragraphs -> insert a protected section
    2091           0 :                 if( rWrtShell.HasSelection() )
    2092           0 :                     rWrtShell.DelRight();
    2093             : 
    2094           0 :                 SwSectionData aSect( DDE_LINK_SECTION, aName );
    2095           0 :                 aSect.SetLinkFileName( aCmd );
    2096           0 :                 aSect.SetProtectFlag(true);
    2097           0 :                 rWrtShell.InsertSection( aSect );
    2098             : 
    2099           0 :                 pDDETyp = 0;                // remove FieldTypes again
    2100             :             }
    2101             :             else
    2102             :             {
    2103             :                 // Einfuegen
    2104           0 :                 SwDDEField aSwDDEField( pDDETyp );
    2105           0 :                 rWrtShell.Insert( aSwDDEField );
    2106             :             }
    2107             : 
    2108             :         } while( sal_False );
    2109             :     }
    2110             :     else
    2111           0 :         pDDETyp = 0;                        // remove FieldTypes again
    2112             : 
    2113           0 :     if( !pDDETyp && !bDoublePaste )
    2114             :     {
    2115             :         // remove FieldType again - error occured!
    2116           0 :         for( j = nSize; j >= INIT_FLDTYPES; --j )
    2117           0 :             if( pTyp == rWrtShell.GetFldType( j ) )
    2118             :             {
    2119           0 :                 rWrtShell.RemoveFldType( j );
    2120           0 :                 break;
    2121             :             }
    2122             :     }
    2123             : 
    2124           0 :     return 1;
    2125             : }
    2126             : 
    2127           0 : int SwTransferable::_PasteSdrFormat(  TransferableDataHelper& rData,
    2128             :                                     SwWrtShell& rSh, sal_uInt16 nAction,
    2129             :                                     const Point* pPt, sal_uInt8 nActionFlags )
    2130             : {
    2131           0 :     int nRet = 0;
    2132           0 :     SotStorageStreamRef xStrm;
    2133           0 :     if( rData.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStrm ))
    2134             :     {
    2135           0 :         xStrm->SetVersion( SOFFICE_FILEFORMAT_50 );
    2136           0 :         rSh.Paste( *xStrm, nAction, pPt );
    2137           0 :         nRet = 1;
    2138             : 
    2139           0 :         if( nRet && ( nActionFlags &
    2140             :             ( EXCHG_OUT_ACTION_FLAG_INSERT_TARGETURL >> 8) ))
    2141           0 :             SwTransferable::_PasteTargetURL( rData, rSh, 0, 0, sal_False );
    2142             :     }
    2143           0 :     return nRet;
    2144             : }
    2145             : 
    2146           0 : int SwTransferable::_PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
    2147             :                                 sal_uLong nFmt, sal_uInt16 nAction, const Point* pPt,
    2148             :                                 sal_uInt8 nActionFlags, sal_Bool /*bMsg*/ )
    2149             : {
    2150           0 :     int nRet = 0;
    2151             : 
    2152           0 :     Graphic aGrf;
    2153           0 :     INetBookmark aBkmk;
    2154           0 :     sal_Bool bCheckForGrf = sal_False, bCheckForImageMap = sal_False;
    2155             : 
    2156           0 :     switch( nFmt )
    2157             :     {
    2158             :     case SOT_FORMAT_BITMAP:
    2159             :     case SOT_FORMAT_GDIMETAFILE:
    2160           0 :         nRet = rData.GetGraphic( nFmt, aGrf );
    2161           0 :         break;
    2162             : 
    2163             :     case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
    2164             :     case SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR:
    2165             :     case SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR:
    2166           0 :         if( 0 != ( nRet = rData.GetINetBookmark( nFmt, aBkmk ) ))
    2167             :         {
    2168           0 :             if( SW_PASTESDR_SETATTR == nAction )
    2169           0 :                 nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK;
    2170             :             else
    2171           0 :                 bCheckForGrf = sal_True;
    2172             :         }
    2173           0 :         break;
    2174             : 
    2175             :     case SOT_FORMAT_FILE:
    2176             :         {
    2177           0 :             String sTxt;
    2178           0 :             if( 0 != ( nRet = rData.GetString( nFmt, sTxt ) ) )
    2179             :             {
    2180           0 :                 String sDesc;
    2181           0 :                 SwTransferable::_CheckForURLOrLNKFile( rData, sTxt, &sDesc );
    2182             : 
    2183             :                 aBkmk = INetBookmark(
    2184             :                         URIHelper::SmartRel2Abs(INetURLObject(), sTxt, Link(), false ),
    2185           0 :                         sDesc );
    2186           0 :                 bCheckForGrf = sal_True;
    2187           0 :                 bCheckForImageMap = SW_PASTESDR_REPLACE == nAction;
    2188           0 :             }
    2189             :         }
    2190           0 :         break;
    2191             : 
    2192             :     default:
    2193           0 :         nRet = rData.GetGraphic( nFmt, aGrf );
    2194           0 :         break;
    2195             :     }
    2196             : 
    2197           0 :     if( bCheckForGrf )
    2198             :     {
    2199             :         //!!! check at FileSystem - only then it makes sense to test the graphics !!!
    2200           0 :         GraphicFilter &rFlt = GraphicFilter::GetGraphicFilter();
    2201           0 :         nRet = GRFILTER_OK == GraphicFilter::LoadGraphic( aBkmk.GetURL(), aEmptyStr,
    2202           0 :                                             aGrf, &rFlt );
    2203           0 :         if( !nRet && SW_PASTESDR_SETATTR == nAction &&
    2204             :             SOT_FORMAT_FILE == nFmt &&
    2205             :             // only at frame selection
    2206           0 :             rSh.IsFrmSelected() )
    2207             :         {
    2208             :             // then set as hyperlink after the graphic
    2209           0 :             nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK;
    2210           0 :             nRet = sal_True;
    2211             :         }
    2212             :     }
    2213             : 
    2214           0 :     if( nRet )
    2215             :     {
    2216           0 :         String sURL;
    2217           0 :         if( rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
    2218           0 :             sURL = aBkmk.GetURL();
    2219             : 
    2220           0 :         switch( nAction )
    2221             :         {
    2222             :         case SW_PASTESDR_INSERT:
    2223           0 :             SwTransferable::SetSelInShell( rSh, sal_False, pPt );
    2224           0 :             rSh.Insert( sURL, aEmptyStr, aGrf );
    2225           0 :         break;
    2226             : 
    2227             :         case SW_PASTESDR_REPLACE:
    2228           0 :             if( rSh.IsObjSelected() )
    2229             :             {
    2230           0 :                 rSh.ReplaceSdrObj( sURL, aEmptyStr, &aGrf );
    2231           0 :                 Point aPt( pPt ? *pPt : rSh.GetCrsrDocPos() );
    2232           0 :                 SwTransferable::SetSelInShell( rSh, sal_True, &aPt );
    2233             :             }
    2234             :             else
    2235           0 :                 rSh.ReRead( sURL, aEmptyStr, &aGrf );
    2236           0 :             break;
    2237             : 
    2238             :         case SW_PASTESDR_SETATTR:
    2239           0 :             if( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK == nFmt )
    2240             :             {
    2241           0 :                 if( rSh.IsFrmSelected() )
    2242             :                 {
    2243           0 :                     SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
    2244           0 :                     rSh.GetFlyFrmAttr( aSet );
    2245           0 :                     SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
    2246           0 :                     aURL.SetURL( aBkmk.GetURL(), sal_False );
    2247           0 :                     aSet.Put( aURL );
    2248           0 :                     rSh.SetFlyFrmAttr( aSet );
    2249             :                 }
    2250             :             }
    2251           0 :             else if( rSh.IsObjSelected() )
    2252           0 :                 rSh.Paste( aGrf );
    2253           0 :             else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() )
    2254           0 :                 rSh.ReRead( sURL, aEmptyStr, &aGrf );
    2255             :             else
    2256             :             {
    2257           0 :                 SwTransferable::SetSelInShell( rSh, sal_False, pPt );
    2258           0 :                 rSh.Insert( aBkmk.GetURL(), aEmptyStr, aGrf );
    2259             :             }
    2260           0 :             break;
    2261             :         default:
    2262           0 :             nRet = 0;
    2263           0 :         }
    2264             :     }
    2265             : 
    2266           0 :     if( nRet )
    2267             :     {
    2268             : 
    2269           0 :         if( nActionFlags &
    2270             :             (( EXCHG_OUT_ACTION_FLAG_INSERT_IMAGEMAP |
    2271             :                 EXCHG_OUT_ACTION_FLAG_REPLACE_IMAGEMAP ) >> 8) )
    2272           0 :             SwTransferable::_PasteImageMap( rData, rSh );
    2273             : 
    2274           0 :         if( nActionFlags &
    2275             :             ( EXCHG_OUT_ACTION_FLAG_INSERT_TARGETURL >> 8) )
    2276           0 :             SwTransferable::_PasteTargetURL( rData, rSh, 0, 0, sal_False );
    2277             :     }
    2278           0 :     else if( bCheckForImageMap )
    2279             :     {
    2280             :         // or should the file be an ImageMap-File?
    2281           0 :         ImageMap aMap;
    2282           0 :         SfxMedium aMed( INetURLObject(aBkmk.GetURL()).GetFull(),
    2283           0 :                             STREAM_STD_READ );
    2284           0 :         SvStream* pStream = aMed.GetInStream();
    2285           0 :         if( pStream != NULL  &&
    2286           0 :             !pStream->GetError()  &&
    2287             :             // mba: no BaseURL for clipboard functionality
    2288           0 :             aMap.Read( *pStream, IMAP_FORMAT_DETECT, String() ) == IMAP_ERR_OK &&
    2289           0 :             aMap.GetIMapObjectCount() )
    2290             :         {
    2291           0 :             SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
    2292           0 :             rSh.GetFlyFrmAttr( aSet );
    2293           0 :             SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
    2294           0 :             aURL.SetMap( &aMap );
    2295           0 :             aSet.Put( aURL );
    2296           0 :             rSh.SetFlyFrmAttr( aSet );
    2297           0 :             nRet = 1;
    2298           0 :         }
    2299             :     }
    2300             : 
    2301           0 :     return nRet;
    2302             : }
    2303             : 
    2304           0 : int SwTransferable::_PasteImageMap( TransferableDataHelper& rData,
    2305             :                                     SwWrtShell& rSh )
    2306             : {
    2307           0 :     int nRet = 0;
    2308           0 :     if( rData.HasFormat( SOT_FORMATSTR_ID_SVIM ))
    2309             :     {
    2310           0 :         SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
    2311           0 :         rSh.GetFlyFrmAttr( aSet );
    2312           0 :         SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
    2313           0 :         const ImageMap* pOld = aURL.GetMap();
    2314             : 
    2315             :         // set or replace, that is the question
    2316           0 :         ImageMap aImageMap;
    2317           0 :         if( rData.GetImageMap( SOT_FORMATSTR_ID_SVIM, aImageMap ) &&
    2318           0 :             ( !pOld || aImageMap != *pOld ))
    2319             :         {
    2320           0 :             aURL.SetMap( &aImageMap );
    2321           0 :             aSet.Put( aURL );
    2322           0 :             rSh.SetFlyFrmAttr( aSet );
    2323             :         }
    2324           0 :         nRet = 1;
    2325             :     }
    2326           0 :     return nRet;
    2327             : }
    2328             : 
    2329           0 : int SwTransferable::_PasteAsHyperlink( TransferableDataHelper& rData,
    2330             :                                         SwWrtShell& rSh, sal_uLong nFmt )
    2331             : {
    2332           0 :     int nRet = 0;
    2333           0 :     String sFile;
    2334           0 :     if( rData.GetString( nFmt, sFile ) && sFile.Len() )
    2335             :     {
    2336           0 :         String sDesc;
    2337           0 :         SwTransferable::_CheckForURLOrLNKFile( rData, sFile, &sDesc );
    2338             : 
    2339             :         // first, make the URL absolute
    2340           0 :         INetURLObject aURL;
    2341           0 :         aURL.SetSmartProtocol( INET_PROT_FILE );
    2342           0 :         aURL.SetSmartURL( sFile );
    2343           0 :         sFile = aURL.GetMainURL( INetURLObject::NO_DECODE );
    2344             : 
    2345           0 :         switch( rSh.GetObjCntTypeOfSelection() )
    2346             :         {
    2347             :         case OBJCNT_FLY:
    2348             :         case OBJCNT_GRF:
    2349             :         case OBJCNT_OLE:
    2350             :             {
    2351           0 :                 SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
    2352           0 :                 rSh.GetFlyFrmAttr( aSet );
    2353           0 :                 SwFmtURL aURL2( (SwFmtURL&)aSet.Get( RES_URL ) );
    2354           0 :                 aURL2.SetURL( sFile, sal_False );
    2355           0 :                 if( !aURL2.GetName().Len() )
    2356           0 :                     aURL2.SetName( sFile );
    2357           0 :                 aSet.Put( aURL2 );
    2358           0 :                 rSh.SetFlyFrmAttr( aSet );
    2359             :             }
    2360           0 :             break;
    2361             : 
    2362             :         default:
    2363             :             {
    2364             :                 rSh.InsertURL( SwFmtINetFmt( sFile, aEmptyStr ),
    2365           0 :                                 sDesc.Len() ? sDesc : sFile );
    2366             :             }
    2367             :         }
    2368           0 :         nRet = sal_True;
    2369             :     }
    2370           0 :     return nRet;
    2371             : }
    2372             : 
    2373           0 : int SwTransferable::_PasteFileName( TransferableDataHelper& rData,
    2374             :                                     SwWrtShell& rSh, sal_uLong nFmt,
    2375             :                                     sal_uInt16 nAction, const Point* pPt,
    2376             :                                     sal_uInt8 nActionFlags, sal_Bool bMsg )
    2377             : {
    2378             :     int nRet = SwTransferable::_PasteGrf( rData, rSh, nFmt, nAction,
    2379           0 :                                             pPt, nActionFlags, bMsg );
    2380           0 :     if( nRet )
    2381           0 :         nRet |= SWTRANSFER_GRAPHIC_INSERTED;
    2382           0 :     if( !nRet )
    2383             :     {
    2384           0 :         String sFile, sDesc;
    2385           0 :         if( rData.GetString( nFmt, sFile ) && sFile.Len() )
    2386             :         {
    2387           0 :             INetURLObject aMediaURL;
    2388             : 
    2389           0 :             aMediaURL.SetSmartURL( sFile );
    2390           0 :             const String aMediaURLStr( aMediaURL.GetMainURL( INetURLObject::NO_DECODE ) );
    2391             : 
    2392           0 :             if( ::avmedia::MediaWindow::isMediaURL( aMediaURLStr ) )
    2393             :             {
    2394           0 :                 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, aMediaURLStr );
    2395           0 :                 rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(
    2396             :                                 SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON,
    2397           0 :                                 &aMediaURLItem, 0L );
    2398             :             }
    2399             :             else
    2400             :             {
    2401           0 :                 sal_Bool bIsURLFile = SwTransferable::_CheckForURLOrLNKFile( rData, sFile, &sDesc );
    2402             : 
    2403             :                 //Own FileFormat? --> insert, not for StarWriter/Web
    2404           0 :                 String sFileURL = URIHelper::SmartRel2Abs(INetURLObject(), sFile, Link(), false );
    2405             :                 const SfxFilter* pFlt = SW_PASTESDR_SETATTR == nAction
    2406             :                         ? 0 : SwIoSystem::GetFileFilter(
    2407           0 :                         sFileURL, aEmptyStr );
    2408           0 :                 if( pFlt && !rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
    2409             :                 {
    2410             :     // and then pull up the insert-region-dialog by PostUser event
    2411             :                     SwSectionData * pSect = new SwSectionData(
    2412             :                                     FILE_LINK_SECTION,
    2413           0 :                                     rSh.GetDoc()->GetUniqueSectionName() );
    2414           0 :                     pSect->SetLinkFileName( sFileURL );
    2415           0 :                     pSect->SetProtectFlag( true );
    2416             : 
    2417             :                     Application::PostUserEvent( STATIC_LINK( &rSh, SwWrtShell,
    2418           0 :                                                 InsertRegionDialog ), pSect );
    2419           0 :                     nRet = 1;
    2420             :                     }
    2421           0 :                 else if( SW_PASTESDR_SETATTR == nAction ||
    2422             :                         ( bIsURLFile && SW_PASTESDR_INSERT == nAction ))
    2423             :                 {
    2424             :                     //we can insert foreign files as links after all
    2425             : 
    2426             :                     // first, make the URL absolute
    2427           0 :                     INetURLObject aURL;
    2428           0 :                     aURL.SetSmartProtocol( INET_PROT_FILE );
    2429           0 :                     aURL.SetSmartURL( sFile );
    2430           0 :                     sFile = aURL.GetMainURL( INetURLObject::NO_DECODE );
    2431             : 
    2432           0 :                     switch( rSh.GetObjCntTypeOfSelection() )
    2433             :                     {
    2434             :                     case OBJCNT_FLY:
    2435             :                     case OBJCNT_GRF:
    2436             :                     case OBJCNT_OLE:
    2437             :                         {
    2438           0 :                             SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
    2439           0 :                             rSh.GetFlyFrmAttr( aSet );
    2440           0 :                             SwFmtURL aURL2( (SwFmtURL&)aSet.Get( RES_URL ) );
    2441           0 :                             aURL2.SetURL( sFile, sal_False );
    2442           0 :                             if( !aURL2.GetName().Len() )
    2443           0 :                                 aURL2.SetName( sFile );
    2444           0 :                             aSet.Put( aURL2 );
    2445           0 :                             rSh.SetFlyFrmAttr( aSet );
    2446             :                         }
    2447           0 :                         break;
    2448             : 
    2449             :                     default:
    2450             :                         {
    2451             :                             rSh.InsertURL( SwFmtINetFmt( sFile, aEmptyStr ),
    2452           0 :                                             sDesc.Len() ? sDesc : sFile );
    2453             :                         }
    2454             :                     }
    2455           0 :                     nRet = sal_True;
    2456           0 :                 }
    2457           0 :             }
    2458           0 :         }
    2459             :     }
    2460           0 :     return nRet;
    2461             : }
    2462             : 
    2463           0 : int SwTransferable::_PasteDBData( TransferableDataHelper& rData,
    2464             :                                     SwWrtShell& rSh, sal_uLong nFmt, sal_Bool bLink,
    2465             :                                     const Point* pDragPt, sal_Bool bMsg )
    2466             : {
    2467           0 :     int nRet = 0;
    2468           0 :     String sTxt;
    2469           0 :     if( rData.GetString( nFmt, sTxt ) && sTxt.Len() )
    2470             :     {
    2471             :         sal_uInt16 nWh = SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE == nFmt
    2472             :                     ? 0
    2473             :                     : SOT_FORMATSTR_ID_SBA_DATAEXCHANGE == nFmt
    2474             :                                 ? (bLink
    2475             :                                     ? FN_QRY_MERGE_FIELD
    2476             :                                     : FN_QRY_INSERT)
    2477             :                                 : (bLink
    2478             :                                     ? 0
    2479           0 :                                     : FN_QRY_INSERT_FIELD );
    2480           0 :         DataFlavorExVector& rVector = rData.GetDataFlavorExVector();
    2481           0 :         sal_Bool bHaveColumnDescriptor = OColumnTransferable::canExtractColumnDescriptor(rVector, CTF_COLUMN_DESCRIPTOR | CTF_CONTROL_EXCHANGE);
    2482           0 :         if ( SOT_FORMATSTR_ID_XFORMS == nFmt )
    2483             :         {
    2484             :             SdrObject* pObj;
    2485           0 :             rSh.MakeDrawView();
    2486           0 :             FmFormView* pFmView = PTR_CAST( FmFormView, rSh.GetDrawView() );
    2487           0 :             if(pFmView) {
    2488           0 :                 const OXFormsDescriptor &rDesc = OXFormsTransferable::extractDescriptor(rData);
    2489           0 :                 if(0 != (pObj = pFmView->CreateXFormsControl(rDesc)))
    2490             :                 {
    2491           0 :                     rSh.SwFEShell::InsertDrawObj( *pObj, *pDragPt );
    2492             :                 }
    2493             :             }
    2494             :         }
    2495           0 :         else if( nWh )
    2496             :         {
    2497           0 :             SfxUsrAnyItem* pConnectionItem  = 0;
    2498           0 :             SfxUsrAnyItem* pCursorItem      = 0;
    2499           0 :             SfxUsrAnyItem* pColumnItem      = 0;
    2500           0 :             SfxUsrAnyItem* pSourceItem      = 0;
    2501           0 :             SfxUsrAnyItem* pCommandItem     = 0;
    2502           0 :             SfxUsrAnyItem* pCommandTypeItem = 0;
    2503           0 :             SfxUsrAnyItem* pColumnNameItem  = 0;
    2504           0 :             SfxUsrAnyItem* pSelectionItem   = 0;
    2505             : 
    2506           0 :             sal_Bool bDataAvailable = sal_True;
    2507           0 :             ODataAccessDescriptor aDesc;
    2508           0 :             if(bHaveColumnDescriptor)
    2509           0 :                 aDesc = OColumnTransferable::extractColumnDescriptor(rData);
    2510           0 :             else if(ODataAccessObjectTransferable::canExtractObjectDescriptor(rVector) )
    2511           0 :                 aDesc = ODataAccessObjectTransferable::extractObjectDescriptor(rData);
    2512             :             else
    2513           0 :                 bDataAvailable = sal_False;
    2514             : 
    2515           0 :             if ( bDataAvailable )
    2516             :             {
    2517           0 :                 pConnectionItem = new SfxUsrAnyItem(FN_DB_CONNECTION_ANY, aDesc[daConnection]);
    2518           0 :                 pColumnItem = new SfxUsrAnyItem(FN_DB_COLUMN_ANY, aDesc[daColumnObject]);
    2519           0 :                 pSourceItem = new SfxUsrAnyItem(FN_DB_DATA_SOURCE_ANY, makeAny(aDesc.getDataSource()));
    2520           0 :                 pCommandItem = new SfxUsrAnyItem(FN_DB_DATA_COMMAND_ANY, aDesc[daCommand]);
    2521           0 :                 pCommandTypeItem = new SfxUsrAnyItem(FN_DB_DATA_COMMAND_TYPE_ANY, aDesc[daCommandType]);
    2522           0 :                 pColumnNameItem = new SfxUsrAnyItem(FN_DB_DATA_COLUMN_NAME_ANY, aDesc[daColumnName]);
    2523           0 :                 pSelectionItem = new SfxUsrAnyItem(FN_DB_DATA_SELECTION_ANY, aDesc[daSelection]);
    2524           0 :                 pCursorItem = new SfxUsrAnyItem(FN_DB_DATA_CURSOR_ANY, aDesc[daCursor]);
    2525             :             }
    2526             : 
    2527           0 :             SwView& rView = rSh.GetView();
    2528             :             //force ::SelectShell
    2529           0 :             rView.StopShellTimer();
    2530             : 
    2531           0 :             SfxStringItem aDataDesc( nWh, sTxt );
    2532             :             rView.GetViewFrame()->GetDispatcher()->Execute(
    2533             :                                 nWh, SFX_CALLMODE_ASYNCHRON, &aDataDesc,
    2534             :                                 pConnectionItem, pColumnItem,
    2535             :                                 pSourceItem, pCommandItem, pCommandTypeItem,
    2536           0 :                                 pColumnNameItem, pSelectionItem, pCursorItem,0L);
    2537           0 :             delete pConnectionItem;
    2538           0 :             delete pColumnItem;
    2539           0 :             delete pSourceItem;
    2540           0 :             delete pCommandItem;
    2541           0 :             delete pCommandTypeItem;
    2542           0 :             delete pColumnNameItem;
    2543           0 :             delete pCursorItem;
    2544             :         }
    2545             :         else
    2546             :         {
    2547             :             SdrObject* pObj;
    2548           0 :             rSh.MakeDrawView();
    2549           0 :             FmFormView* pFmView = PTR_CAST( FmFormView, rSh.GetDrawView() );
    2550           0 :             if (pFmView && bHaveColumnDescriptor)
    2551             :             {
    2552           0 :                 if ( 0 != (pObj = pFmView->CreateFieldControl( OColumnTransferable::extractColumnDescriptor(rData) ) ) )
    2553           0 :                     rSh.SwFEShell::InsertDrawObj( *pObj, *pDragPt );
    2554             :             }
    2555             :         }
    2556           0 :         nRet = 1;
    2557             :     }
    2558           0 :     else if( bMsg )
    2559             :     {
    2560           0 :         InfoBox( 0, SW_RES(MSG_CLPBRD_FORMAT_ERROR)).Execute();
    2561             :     }
    2562           0 :     return nRet;
    2563             : }
    2564             : 
    2565           0 : int SwTransferable::_PasteFileList( TransferableDataHelper& rData,
    2566             :                                     SwWrtShell& rSh, sal_Bool bLink,
    2567             :                                     const Point* pPt, sal_Bool bMsg )
    2568             : {
    2569           0 :     int nRet = 0;
    2570           0 :     FileList aFileList;
    2571           0 :     if( rData.GetFileList( SOT_FORMAT_FILE_LIST, aFileList ) &&
    2572           0 :         aFileList.Count() )
    2573             :     {
    2574           0 :         sal_uInt16 nAct = bLink ? SW_PASTESDR_SETATTR : SW_PASTESDR_INSERT;
    2575           0 :         String sFlyNm;
    2576             :         // iterate over the filelist
    2577           0 :         for( sal_uLong n = 0, nEnd = aFileList.Count(); n < nEnd; ++n )
    2578             :         {
    2579           0 :             TransferDataContainer* pHlp = new TransferDataContainer;
    2580           0 :             pHlp->CopyString( FORMAT_FILE, aFileList.GetFile( n ));
    2581           0 :             TransferableDataHelper aData( pHlp );
    2582             : 
    2583           0 :             if( SwTransferable::_PasteFileName( aData, rSh, SOT_FORMAT_FILE, nAct,
    2584           0 :                                             pPt, sal_False, bMsg ))
    2585             :             {
    2586           0 :                 if( bLink )
    2587             :                 {
    2588           0 :                     sFlyNm = rSh.GetFlyName();
    2589           0 :                     SwTransferable::SetSelInShell( rSh, sal_False, pPt );
    2590             :                 }
    2591           0 :                 nRet = 1;
    2592             :             }
    2593           0 :         }
    2594           0 :         if( sFlyNm.Len() )
    2595           0 :             rSh.GotoFly( sFlyNm );
    2596             :     }
    2597           0 :     else if( bMsg )
    2598             :     {
    2599           0 :         InfoBox( 0, SW_RES(MSG_CLPBRD_FORMAT_ERROR)).Execute();
    2600             :     }
    2601           0 :     return nRet;
    2602             : }
    2603             : 
    2604           0 : sal_Bool SwTransferable::_CheckForURLOrLNKFile( TransferableDataHelper& rData,
    2605             :                                         String& rFileName, String* pTitle )
    2606             : {
    2607           0 :     sal_Bool bIsURLFile = sal_False;
    2608           0 :     INetBookmark aBkmk;
    2609           0 :     if( rData.GetINetBookmark( SOT_FORMATSTR_ID_SOLK, aBkmk ) )
    2610             :     {
    2611           0 :         rFileName = aBkmk.GetURL();
    2612           0 :         if( pTitle )
    2613           0 :             *pTitle = aBkmk.GetDescription();
    2614           0 :         bIsURLFile = sal_True;
    2615             :     }
    2616             :     else
    2617             :     {
    2618           0 :         xub_StrLen nLen = rFileName.Len();
    2619           0 :         if( 4 < nLen && '.' == rFileName.GetChar( nLen - 4 ))
    2620             :         {
    2621           0 :             String sExt( rFileName.Copy( nLen - 3 ));
    2622           0 :             if( sExt.EqualsIgnoreCaseAscii( "url" ))
    2623             :             {
    2624             :                 OSL_ENSURE( !&rFileName, "how do we read today .URL - Files?" );
    2625           0 :             }
    2626             :         }
    2627             :     }
    2628           0 :     return bIsURLFile;
    2629             : }
    2630             : 
    2631           0 : sal_Bool SwTransferable::IsPasteSpecial( const SwWrtShell& rWrtShell,
    2632             :                                      const TransferableDataHelper& rData )
    2633             : {
    2634             :     // we can paste-special if there's an entry in the paste-special-format list
    2635           0 :     SvxClipboardFmtItem aClipboardFmtItem(0);
    2636           0 :     FillClipFmtItem( rWrtShell, rData, aClipboardFmtItem);
    2637           0 :     return aClipboardFmtItem.Count() > 0;
    2638             : }
    2639             : 
    2640           0 : int SwTransferable::PasteFormat( SwWrtShell& rSh,
    2641             :                                     TransferableDataHelper& rData,
    2642             :                                     sal_uLong nFormat )
    2643             : {
    2644           0 :     SwWait aWait( *rSh.GetView().GetDocShell(), sal_False );
    2645           0 :     int nRet = 0;
    2646             : 
    2647           0 :     sal_uLong nPrivateFmt = FORMAT_PRIVATE;
    2648           0 :     SwTransferable *pClipboard = GetSwTransferable( rData );
    2649           0 :     if( pClipboard &&
    2650             :         ((TRNSFR_DOCUMENT|TRNSFR_GRAPHIC|TRNSFR_OLE) & pClipboard->eBufferType ))
    2651           0 :         nPrivateFmt = SOT_FORMATSTR_ID_EMBED_SOURCE;
    2652             : 
    2653           0 :     if( pClipboard && nPrivateFmt == nFormat )
    2654           0 :         nRet = pClipboard->PrivatePaste( rSh );
    2655           0 :     else if( rData.HasFormat( nFormat ) )
    2656             :     {
    2657           0 :         uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
    2658             :         sal_uInt16 nEventAction,
    2659           0 :                nDestination = SwTransferable::GetSotDestination( rSh ),
    2660             :                nSourceOptions =
    2661             :                     (( EXCHG_DEST_DOC_TEXTFRAME == nDestination ||
    2662             :                        EXCHG_DEST_SWDOC_FREE_AREA == nDestination ||
    2663             :                        EXCHG_DEST_DOC_TEXTFRAME_WEB == nDestination ||
    2664             :                        EXCHG_DEST_SWDOC_FREE_AREA_WEB == nDestination )
    2665             :                                         ? EXCHG_IN_ACTION_COPY
    2666           0 :                                         : EXCHG_IN_ACTION_MOVE),
    2667             :                nAction = SotExchange::GetExchangeAction(
    2668           0 :                                     rData.GetDataFlavorExVector(),
    2669             :                                     nDestination,
    2670             :                                     nSourceOptions,             /* ?? */
    2671             :                                     EXCHG_IN_ACTION_DEFAULT,    /* ?? */
    2672             :                                     nFormat, nEventAction, nFormat,
    2673           0 :                                     lcl_getTransferPointer ( xTransferable ) );
    2674             : 
    2675           0 :         if( EXCHG_INOUT_ACTION_NONE != nAction )
    2676             :             nRet = SwTransferable::PasteData( rData, rSh, nAction, nFormat,
    2677           0 :                                                 nDestination, sal_True, sal_False );
    2678             :     }
    2679           0 :     return nRet;
    2680             : }
    2681             : 
    2682           0 : int SwTransferable::_TestAllowedFormat( const TransferableDataHelper& rData,
    2683             :                                         sal_uLong nFormat, sal_uInt16 nDestination )
    2684             : {
    2685           0 :     sal_uInt16 nAction = EXCHG_INOUT_ACTION_NONE, nEventAction;
    2686           0 :     if( rData.HasFormat( nFormat )) {
    2687           0 :         uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
    2688             :         nAction = SotExchange::GetExchangeAction(
    2689           0 :                         rData.GetDataFlavorExVector(),
    2690             :                         nDestination, EXCHG_IN_ACTION_COPY,
    2691             :                         EXCHG_IN_ACTION_COPY, nFormat,
    2692             :                         nEventAction, nFormat,
    2693           0 :                         lcl_getTransferPointer ( xTransferable ) );
    2694             :     }
    2695           0 :     return EXCHG_INOUT_ACTION_NONE != nAction;
    2696             : }
    2697             : 
    2698             : /**
    2699             :  * the list of formats which will be offered to the user in the 'Paste
    2700             :  * Special...' dialog and the paste button menu
    2701             :  */
    2702             : static sal_uInt16 aPasteSpecialIds[] =
    2703             : {
    2704             :     SOT_FORMATSTR_ID_HTML,
    2705             :     SOT_FORMATSTR_ID_HTML_SIMPLE,
    2706             :     SOT_FORMATSTR_ID_HTML_NO_COMMENT,
    2707             :     FORMAT_RTF,
    2708             :     FORMAT_STRING,
    2709             :     SOT_FORMATSTR_ID_SONLK,
    2710             :     SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK,
    2711             :     SOT_FORMATSTR_ID_DRAWING,
    2712             :     SOT_FORMATSTR_ID_SVXB,
    2713             :     FORMAT_GDIMETAFILE,
    2714             :     FORMAT_BITMAP,
    2715             :     SOT_FORMATSTR_ID_SVIM,
    2716             :     SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR,
    2717             :     0
    2718             : };
    2719             : 
    2720           0 : int SwTransferable::PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& rData )
    2721             : {
    2722             :     // Plain text == unformatted
    2723           0 :     return SwTransferable::PasteFormat( rSh, rData, SOT_FORMAT_STRING );
    2724             : }
    2725             : 
    2726           0 : int SwTransferable::PasteSpecial( SwWrtShell& rSh, TransferableDataHelper& rData, sal_uLong& rFormatUsed )
    2727             : {
    2728           0 :     int nRet = 0;
    2729           0 :     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    2730           0 :     SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( &rSh.GetView().GetEditWin() );
    2731             : 
    2732           0 :     DataFlavorExVector aFormats( rData.GetDataFlavorExVector() );
    2733           0 :     TransferableObjectDescriptor aDesc;
    2734             : 
    2735           0 :     sal_uInt16 nDest = SwTransferable::GetSotDestination( rSh );
    2736             : 
    2737           0 :     SwTransferable *pClipboard = GetSwTransferable( rData );
    2738           0 :     if( pClipboard )
    2739             :     {
    2740           0 :         aDesc = pClipboard->aObjDesc;
    2741             :         sal_uInt16 nResId;
    2742           0 :         if( pClipboard->eBufferType & TRNSFR_DOCUMENT )
    2743           0 :             nResId = STR_PRIVATETEXT;
    2744           0 :         else if( pClipboard->eBufferType & TRNSFR_GRAPHIC )
    2745           0 :             nResId = STR_PRIVATEGRAPHIC;
    2746           0 :         else if( pClipboard->eBufferType == TRNSFR_OLE )
    2747           0 :             nResId = STR_PRIVATEOLE;
    2748             :         else
    2749           0 :             nResId = 0;
    2750             : 
    2751           0 :         if( nResId )
    2752             :         {
    2753           0 :             if( STR_PRIVATEOLE == nResId || STR_PRIVATEGRAPHIC == nResId )
    2754             :             {
    2755             :                 // add SOT_FORMATSTR_ID_EMBED_SOURCE to the formats. This
    2756             :                 // format display then the private format name.
    2757           0 :                 DataFlavorEx aFlavorEx;
    2758           0 :                 aFlavorEx.mnSotId = SOT_FORMATSTR_ID_EMBED_SOURCE;
    2759           0 :                 aFormats.insert( aFormats.begin(), aFlavorEx );
    2760             :             }
    2761             :             pDlg->SetObjName( pClipboard->aObjDesc.maClassName,
    2762           0 :                                 SW_RES( nResId ) );
    2763           0 :             pDlg->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE, aEmptyStr );
    2764             :         }
    2765             :     }
    2766             :     else
    2767             :     {
    2768           0 :         if( rData.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
    2769             :             rData.GetTransferableObjectDescriptor(
    2770           0 :                                 SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDesc );
    2771             : 
    2772           0 :         if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_EMBED_SOURCE, nDest ))
    2773           0 :             pDlg->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE, aEmptyStr );
    2774           0 :         if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_LINK_SOURCE, nDest ))
    2775           0 :             pDlg->Insert( SOT_FORMATSTR_ID_LINK_SOURCE, aEmptyStr );
    2776             :     }
    2777             : 
    2778           0 :     if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_LINK, nDest ))
    2779           0 :         pDlg->Insert( SOT_FORMATSTR_ID_LINK, SW_RES(STR_DDEFORMAT) );
    2780             : 
    2781           0 :     for( sal_uInt16* pIds = aPasteSpecialIds; *pIds; ++pIds )
    2782           0 :         if( SwTransferable::_TestAllowedFormat( rData, *pIds, nDest ))
    2783           0 :             pDlg->Insert( *pIds, aEmptyStr );
    2784             : 
    2785           0 :     sal_uLong nFormat = pDlg->GetFormat( rData.GetTransferable() );
    2786             : 
    2787           0 :     if( nFormat )
    2788           0 :         nRet = SwTransferable::PasteFormat( rSh, rData, nFormat );
    2789             : 
    2790           0 :     if ( nRet )
    2791           0 :         rFormatUsed = nFormat;
    2792             : 
    2793           0 :     delete pDlg;
    2794           0 :     return nRet;
    2795             : }
    2796             : 
    2797           0 : void SwTransferable::FillClipFmtItem( const SwWrtShell& rSh,
    2798             :                                 const TransferableDataHelper& rData,
    2799             :                                 SvxClipboardFmtItem & rToFill )
    2800             : {
    2801           0 :     sal_uInt16 nDest = SwTransferable::GetSotDestination( rSh );
    2802             : 
    2803           0 :     SwTransferable *pClipboard = GetSwTransferable( rData );
    2804           0 :     if( pClipboard )
    2805             :     {
    2806             :         sal_uInt16 nResId;
    2807           0 :         if( pClipboard->eBufferType & TRNSFR_DOCUMENT )
    2808           0 :             nResId = STR_PRIVATETEXT;
    2809           0 :         else if( pClipboard->eBufferType & TRNSFR_GRAPHIC )
    2810           0 :             nResId = STR_PRIVATEGRAPHIC;
    2811           0 :         else if( pClipboard->eBufferType == TRNSFR_OLE )
    2812           0 :             nResId = STR_PRIVATEOLE;
    2813             :         else
    2814           0 :             nResId = 0;
    2815             : 
    2816           0 :         if( nResId )
    2817             :             rToFill.AddClipbrdFormat( SOT_FORMATSTR_ID_EMBED_SOURCE,
    2818           0 :                                         SW_RESSTR( nResId ) );
    2819             :     }
    2820             :     else
    2821             :     {
    2822           0 :         TransferableObjectDescriptor aDesc;
    2823           0 :         if( rData.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
    2824             :             ((TransferableDataHelper&)rData).GetTransferableObjectDescriptor(
    2825           0 :                                 SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDesc );
    2826             : 
    2827           0 :         if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_EMBED_SOURCE, nDest ))
    2828             :             rToFill.AddClipbrdFormat( SOT_FORMATSTR_ID_EMBED_SOURCE,
    2829           0 :                                             aDesc.maTypeName );
    2830           0 :         if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_LINK_SOURCE, nDest ))
    2831           0 :             rToFill.AddClipbrdFormat( SOT_FORMATSTR_ID_LINK_SOURCE );
    2832             : 
    2833             :         SotFormatStringId nFormat;
    2834           0 :         if ( rData.HasFormat(nFormat = SOT_FORMATSTR_ID_EMBED_SOURCE_OLE) || rData.HasFormat(nFormat = SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE) )
    2835             :         {
    2836           0 :             String sName,sSource;
    2837           0 :             if ( SvPasteObjectHelper::GetEmbeddedName(rData,sName,sSource,nFormat) )
    2838           0 :                 rToFill.AddClipbrdFormat( nFormat, sName );
    2839           0 :         }
    2840             :     }
    2841             : 
    2842           0 :     if( SwTransferable::_TestAllowedFormat( rData, SOT_FORMATSTR_ID_LINK, nDest ))
    2843           0 :         rToFill.AddClipbrdFormat( SOT_FORMATSTR_ID_LINK, SW_RESSTR(STR_DDEFORMAT) );
    2844             : 
    2845           0 :     for( sal_uInt16* pIds = aPasteSpecialIds; *pIds; ++pIds )
    2846           0 :         if( SwTransferable::_TestAllowedFormat( rData, *pIds, nDest ))
    2847           0 :             rToFill.AddClipbrdFormat( *pIds, aEmptyStr );
    2848           0 : }
    2849             : 
    2850           0 : void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
    2851             : {
    2852           0 :     if(!pWrtShell)
    2853           0 :         return;
    2854           0 :     String sGrfNm;
    2855           0 :     const int nSelection = pWrtShell->GetSelectionType();
    2856           0 :     if( nsSelectionType::SEL_GRF == nSelection)
    2857             :     {
    2858           0 :         AddFormat( SOT_FORMATSTR_ID_SVXB );
    2859           0 :         const Graphic* pGrf = pWrtShell->GetGraphic();
    2860           0 :         if ( pGrf && pGrf->IsSupportedGraphic() )
    2861             :         {
    2862           0 :             AddFormat( FORMAT_GDIMETAFILE );
    2863           0 :             AddFormat( FORMAT_BITMAP );
    2864             :         }
    2865           0 :         eBufferType = TRNSFR_GRAPHIC;
    2866           0 :         pWrtShell->GetGrfNms( &sGrfNm, 0 );
    2867             :     }
    2868           0 :     else if( nsSelectionType::SEL_OLE == nSelection )
    2869             :     {
    2870           0 :         AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
    2871           0 :         PrepareOLE( aObjDesc );
    2872           0 :         AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
    2873           0 :         AddFormat( FORMAT_GDIMETAFILE );
    2874           0 :         eBufferType = TRNSFR_OLE;
    2875             :     }
    2876             :     //Is there anything to provide anyway?
    2877           0 :     else if ( pWrtShell->IsSelection() || pWrtShell->IsFrmSelected() ||
    2878           0 :               pWrtShell->IsObjSelected() )
    2879             :     {
    2880           0 :         if( pWrtShell->IsObjSelected() )
    2881           0 :             eBufferType = TRNSFR_DRAWING;
    2882             :         else
    2883             :         {
    2884           0 :             eBufferType = TRNSFR_DOCUMENT;
    2885           0 :             if( SwWrtShell::NO_WORD !=
    2886           0 :                 pWrtShell->IntelligentCut( nSelection, sal_False ))
    2887             :                 eBufferType = TransferBufferType( TRNSFR_DOCUMENT_WORD
    2888           0 :                                                     | eBufferType);
    2889             :         }
    2890             : 
    2891           0 :         if( nSelection & nsSelectionType::SEL_TBL_CELLS )
    2892           0 :             eBufferType = (TransferBufferType)(TRNSFR_TABELLE | eBufferType);
    2893             : 
    2894           0 :         AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
    2895             : 
    2896             :         //put RTF ahead of the OLE's Metafile for less loss
    2897           0 :         if( !pWrtShell->IsObjSelected() )
    2898             :         {
    2899           0 :             AddFormat( FORMAT_RTF );
    2900           0 :             AddFormat( SOT_FORMATSTR_ID_HTML );
    2901             :         }
    2902           0 :         if( pWrtShell->IsSelection() )
    2903           0 :             AddFormat( FORMAT_STRING );
    2904             : 
    2905           0 :         if( nSelection & ( nsSelectionType::SEL_DRW | nsSelectionType::SEL_DRW_FORM ))
    2906             :         {
    2907           0 :             AddFormat( SOT_FORMATSTR_ID_DRAWING );
    2908           0 :             if ( nSelection & nsSelectionType::SEL_DRW )
    2909             :             {
    2910           0 :                 AddFormat( FORMAT_GDIMETAFILE );
    2911           0 :                 AddFormat( FORMAT_BITMAP );
    2912             :             }
    2913           0 :             eBufferType = (TransferBufferType)( TRNSFR_GRAPHIC | eBufferType );
    2914             : 
    2915           0 :             pClpGraphic = new Graphic;
    2916           0 :             if( !pWrtShell->GetDrawObjGraphic( FORMAT_GDIMETAFILE, *pClpGraphic ))
    2917           0 :                 pOrigGrf = pClpGraphic;
    2918           0 :             pClpBitmap = new Graphic;
    2919           0 :             if( !pWrtShell->GetDrawObjGraphic( FORMAT_BITMAP, *pClpBitmap ))
    2920           0 :                 pOrigGrf = pClpBitmap;
    2921             : 
    2922             :             // is it an URL-Button ?
    2923           0 :             String sURL, sDesc;
    2924           0 :             if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
    2925             :             {
    2926           0 :                 AddFormat( FORMAT_STRING );
    2927           0 :                  AddFormat( SOT_FORMATSTR_ID_SOLK );
    2928           0 :                  AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
    2929           0 :                  AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
    2930           0 :                  AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
    2931           0 :                  AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
    2932           0 :                 eBufferType = (TransferBufferType)( TRNSFR_INETFLD | eBufferType );
    2933           0 :             }
    2934             :         }
    2935             : 
    2936             :         //ObjectDescriptor was already filled from the old DocShell.
    2937             :         //Now adjust it. Thus in GetData the first query can still
    2938             :         //be answered with delayed rendering.
    2939           0 :         aObjDesc.mbCanLink = sal_False;
    2940           0 :         aObjDesc.maDragStartPos = rSttPos;
    2941             :         aObjDesc.maSize = OutputDevice::LogicToLogic( Size( OLESIZE ),
    2942           0 :                                                 MAP_TWIP, MAP_100TH_MM );
    2943           0 :         PrepareOLE( aObjDesc );
    2944           0 :         AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
    2945             :     }
    2946           0 :     else if( nSelection & nsSelectionType::SEL_TXT && !pWrtShell->HasMark() )
    2947             :     {
    2948             :         // is only one field - selected?
    2949           0 :         SwContentAtPos aCntntAtPos( SwContentAtPos::SW_INETATTR );
    2950           0 :         Point aPos( SwEditWin::GetDDStartPosX(), SwEditWin::GetDDStartPosY());
    2951             : 
    2952           0 :         if( pWrtShell->GetContentAtPos( aPos, aCntntAtPos ) )
    2953             :         {
    2954           0 :             AddFormat( FORMAT_STRING );
    2955           0 :              AddFormat( SOT_FORMATSTR_ID_SOLK );
    2956           0 :              AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
    2957           0 :              AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
    2958           0 :              AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
    2959           0 :              AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
    2960           0 :             eBufferType = TRNSFR_INETFLD;
    2961           0 :         }
    2962             :     }
    2963             : 
    2964           0 :     if( pWrtShell->IsFrmSelected() )
    2965             :     {
    2966           0 :         SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_URL, RES_URL );
    2967           0 :         pWrtShell->GetFlyFrmAttr( aSet );
    2968           0 :         const SwFmtURL& rURL = (SwFmtURL&)aSet.Get( RES_URL );
    2969           0 :         if( rURL.GetMap() )
    2970             :         {
    2971           0 :             pImageMap = new ImageMap( *rURL.GetMap() );
    2972           0 :             AddFormat( SOT_FORMATSTR_ID_SVIM );
    2973             :         }
    2974           0 :         else if( rURL.GetURL().Len() )
    2975             :         {
    2976             :             pTargetURL = new INetImage( sGrfNm, rURL.GetURL(),
    2977             :                                         rURL.GetTargetFrameName(),
    2978           0 :                                         aEmptyStr, Size() );
    2979           0 :             AddFormat( SOT_FORMATSTR_ID_INET_IMAGE );
    2980           0 :         }
    2981           0 :     }
    2982             : }
    2983             : 
    2984           0 : void SwTransferable::StartDrag( Window* pWin, const Point& rPos )
    2985             : {
    2986           0 :     if(!pWrtShell)
    2987           0 :         return;
    2988           0 :     bOldIdle = pWrtShell->GetViewOptions()->IsIdle();
    2989           0 :     bCleanUp = sal_True;
    2990             : 
    2991           0 :     ((SwViewOption *)pWrtShell->GetViewOptions())->SetIdle( sal_False );
    2992             : 
    2993           0 :     if( pWrtShell->IsSelFrmMode() )
    2994           0 :         pWrtShell->ShowCrsr();
    2995             : 
    2996           0 :     SW_MOD()->pDragDrop = this;
    2997             : 
    2998           0 :     SetDataForDragAndDrop( rPos );
    2999             : 
    3000           0 :     sal_Int8 nDragOptions = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
    3001           0 :     SwDocShell* pDShell = pWrtShell->GetView().GetDocShell();
    3002           0 :     if( ( pDShell && pDShell->IsReadOnly() ) || pWrtShell->HasReadonlySel() )
    3003           0 :         nDragOptions &= ~DND_ACTION_MOVE;
    3004             : 
    3005           0 :     TransferableHelper::StartDrag( pWin, nDragOptions );
    3006             : }
    3007             : 
    3008           0 : void SwTransferable::DragFinished( sal_Int8 nAction )
    3009             : {
    3010             :     //And the last finishing work so that all statuses are right
    3011           0 :     if( DND_ACTION_MOVE == nAction  )
    3012             :     {
    3013           0 :         if( bCleanUp )
    3014             :         {
    3015             :             //It was dropped outside of Writer. We still have to
    3016             :             //delete.
    3017             : 
    3018           0 :             pWrtShell->StartAllAction();
    3019           0 :             pWrtShell->StartUndo( UNDO_UI_DRAG_AND_MOVE );
    3020           0 :             if ( pWrtShell->IsTableMode() )
    3021           0 :                 pWrtShell->DeleteTblSel();
    3022             :             else
    3023             :             {
    3024           0 :                 if ( !(pWrtShell->IsSelFrmMode() || pWrtShell->IsObjSelected()) )
    3025             :                     //SmartCut, take one of the blanks along
    3026           0 :                     pWrtShell->IntelligentCut( pWrtShell->GetSelectionType(), sal_True );
    3027           0 :                 pWrtShell->DelRight();
    3028             :             }
    3029           0 :             pWrtShell->EndUndo( UNDO_UI_DRAG_AND_MOVE );
    3030           0 :             pWrtShell->EndAllAction();
    3031             :         }
    3032             :         else
    3033             :         {
    3034           0 :             const int nSelection = pWrtShell->GetSelectionType();
    3035           0 :             if( ( nsSelectionType::SEL_FRM | nsSelectionType::SEL_GRF |
    3036             :                  nsSelectionType::SEL_OLE | nsSelectionType::SEL_DRW ) & nSelection )
    3037             :             {
    3038           0 :                 pWrtShell->EnterSelFrmMode();
    3039             :             }
    3040             :         }
    3041             :     }
    3042           0 :     pWrtShell->GetView().GetEditWin().DragFinished();
    3043             : 
    3044           0 :     if( pWrtShell->IsSelFrmMode() )
    3045           0 :         pWrtShell->HideCrsr();
    3046             :     else
    3047           0 :         pWrtShell->ShowCrsr();
    3048             : 
    3049           0 :     ((SwViewOption *)pWrtShell->GetViewOptions())->SetIdle( bOldIdle );
    3050           0 : }
    3051             : 
    3052           0 : int SwTransferable::PrivatePaste( SwWrtShell& rShell )
    3053             : {
    3054             :     // first, ask for the SelectionType, then action-bracketing !!!!
    3055             :     // (otherwise it's not pasted into a TableSelection!!!)
    3056             :     OSL_ENSURE( !rShell.ActionPend(), "Paste darf nie eine Actionklammerung haben" );
    3057           0 :     if ( !pClpDocFac )
    3058           0 :         return sal_False; // the return value of the SwFEShell::Paste also is sal_Bool!
    3059             : 
    3060           0 :     const int nSelection = rShell.GetSelectionType();
    3061             : 
    3062           0 :     SwRewriter aRewriter;
    3063             : 
    3064           0 :     SwTrnsfrActionAndUndo aAction( &rShell, UNDO_PASTE_CLIPBOARD);
    3065             : 
    3066           0 :     bool bKillPaMs = false;
    3067             : 
    3068             :     //Delete selected content, not at table-selection and table in Clipboard
    3069           0 :     if( rShell.HasSelection() && !( nSelection & nsSelectionType::SEL_TBL_CELLS))
    3070             :     {
    3071           0 :         bKillPaMs = true;
    3072           0 :         rShell.SetRetainSelection( true );
    3073           0 :         rShell.DelRight();
    3074             :         // when a Fly was selected, a valid cursor position has to be found now
    3075             :         // (parked Cursor!)
    3076           0 :         if( ( nsSelectionType::SEL_FRM | nsSelectionType::SEL_GRF |
    3077             :             nsSelectionType::SEL_OLE | nsSelectionType::SEL_DRW |
    3078             :             nsSelectionType::SEL_DRW_FORM ) & nSelection )
    3079             :         {
    3080             :             // position the cursor again
    3081           0 :             Point aPt( rShell.GetCharRect().Pos() );
    3082           0 :             rShell.SwCrsrShell::SetCrsr( aPt, sal_True );
    3083             :         }
    3084           0 :         rShell.SetRetainSelection( false );
    3085             :     }
    3086             : 
    3087           0 :     sal_Bool bInWrd = sal_False, bEndWrd = sal_False, bSttWrd = sal_False,
    3088           0 :          bSmart = 0 != (TRNSFR_DOCUMENT_WORD & eBufferType);
    3089           0 :     if( bSmart )
    3090             :     {
    3091             : // Why not for other Scripts? If TRNSFR_DOCUMENT_WORD is set, we have a word
    3092             : // in the buffer, word in this context means 'something with spaces at beginning
    3093             : // and end'. In this case we definitely want these spaces to be inserted here.
    3094           0 :             bInWrd = rShell.IsInWrd();
    3095           0 :              bEndWrd = rShell.IsEndWrd();
    3096           0 :             bSmart = bInWrd || bEndWrd;
    3097           0 :             if( bSmart )
    3098             :             {
    3099           0 :                  bSttWrd = rShell.IsSttWrd();
    3100           0 :                 if( bSmart && !bSttWrd && (bInWrd || bEndWrd) )
    3101           0 :                     rShell.SwEditShell::Insert(' ');
    3102             :             }
    3103             :     }
    3104             : 
    3105           0 :     int nRet = rShell.Paste( pClpDocFac->GetDoc() );
    3106             : 
    3107           0 :     if( bKillPaMs )
    3108           0 :         rShell.KillPams();
    3109             : 
    3110             :     // If Smart Paste then insert blank
    3111           0 :     if( nRet && bSmart && ((bInWrd && !bEndWrd )|| bSttWrd) )
    3112           0 :         rShell.SwEditShell::Insert(' ');
    3113             : 
    3114           0 :     return nRet;
    3115             : }
    3116             : 
    3117           0 : int SwTransferable::PrivateDrop( SwWrtShell& rSh, const Point& rDragPt,
    3118             :                                 sal_Bool bMove, sal_Bool bIsXSelection )
    3119             : {
    3120           0 :     int cWord    = 0;
    3121           0 :     sal_Bool bInWrd  = sal_False;
    3122           0 :     sal_Bool bEndWrd = sal_False;
    3123           0 :     sal_Bool bSttWrd = sal_False;
    3124           0 :     bool bSttPara = false;
    3125           0 :     sal_Bool bTblSel = sal_False;
    3126           0 :     sal_Bool bFrmSel = sal_False;
    3127             : 
    3128           0 :     SwWrtShell& rSrcSh = *GetShell();
    3129             : 
    3130           0 :     rSh.UnSetVisCrsr();
    3131             : 
    3132           0 :     if( TRNSFR_INETFLD == eBufferType )
    3133             :     {
    3134           0 :         if( rSh.GetFmtFromObj( rDragPt ) )
    3135             :         {
    3136           0 :             INetBookmark aTmp;
    3137           0 :             if( (TRNSFR_INETFLD & eBufferType) && pBkmk )
    3138           0 :                 aTmp = *pBkmk;
    3139             : 
    3140             :             // select target graphic
    3141           0 :             if( rSh.SelectObj( rDragPt ) )
    3142             :             {
    3143           0 :                 rSh.HideCrsr();
    3144           0 :                 rSh.EnterSelFrmMode( &rDragPt );
    3145           0 :                 bFrmDrag = sal_True;
    3146             :             }
    3147             : 
    3148           0 :             const int nSelection = rSh.GetSelectionType();
    3149             : 
    3150             :             // not yet consider Draw objects
    3151           0 :             if( nsSelectionType::SEL_GRF & nSelection )
    3152             :             {
    3153           0 :                 SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL );
    3154           0 :                 rSh.GetFlyFrmAttr( aSet );
    3155           0 :                 SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) );
    3156           0 :                 aURL.SetURL( aTmp.GetURL(), sal_False );
    3157           0 :                 aSet.Put( aURL );
    3158           0 :                 rSh.SetFlyFrmAttr( aSet );
    3159           0 :                 return 1;
    3160             :             }
    3161             : 
    3162           0 :             if( nsSelectionType::SEL_DRW & nSelection )
    3163             :             {
    3164           0 :                 rSh.LeaveSelFrmMode();
    3165           0 :                 rSh.UnSelectFrm();
    3166           0 :                 rSh.ShowCrsr();
    3167           0 :                 bFrmDrag = sal_False;
    3168           0 :             }
    3169             :         }
    3170             :     }
    3171             : 
    3172           0 :     if( &rSh != &rSrcSh && (nsSelectionType::SEL_GRF & rSh.GetSelectionType()) &&
    3173             :         TRNSFR_GRAPHIC == eBufferType )
    3174             :     {
    3175             :         // ReRead the graphic
    3176           0 :         String sGrfNm, sFltNm;
    3177           0 :         rSrcSh.GetGrfNms( &sGrfNm, &sFltNm );
    3178           0 :         rSh.ReRead( sGrfNm, sFltNm, rSrcSh.GetGraphic() );
    3179           0 :         return 1;
    3180             :     }
    3181             : 
    3182             :     //not in selections or selected frames
    3183           0 :     if( rSh.ChgCurrPam( rDragPt ) ||
    3184           0 :         ( rSh.IsSelFrmMode() && rSh.IsInsideSelectedObj( rDragPt )) )
    3185           0 :         return 0;
    3186             : 
    3187           0 :     if( rSrcSh.IsTableMode() )
    3188           0 :         bTblSel = sal_True;
    3189           0 :     else if( rSrcSh.IsSelFrmMode() || rSrcSh.IsObjSelected() )
    3190             :     {
    3191             :         // don't move position-protected objects!
    3192           0 :         if( bMove && rSrcSh.IsSelObjProtected( FLYPROTECT_POS ) )
    3193           0 :             return 0;
    3194             : 
    3195           0 :         bFrmSel = sal_True;
    3196             :     }
    3197             : 
    3198           0 :     const int nSel = rSrcSh.GetSelectionType();
    3199             : 
    3200           0 :     SwUndoId eUndoId = bMove ? UNDO_UI_DRAG_AND_MOVE : UNDO_UI_DRAG_AND_COPY;
    3201             : 
    3202           0 :     SwRewriter aRewriter;
    3203             : 
    3204           0 :     aRewriter.AddRule(UndoArg1, rSrcSh.GetSelDescr());
    3205             : 
    3206           0 :     if(rSrcSh.GetDoc() != rSh.GetDoc())
    3207           0 :         rSrcSh.StartUndo( eUndoId, &aRewriter );
    3208           0 :     rSh.StartUndo( eUndoId, &aRewriter );
    3209             : 
    3210           0 :     rSh.StartAction();
    3211           0 :     rSrcSh.StartAction();
    3212             : 
    3213           0 :     if( &rSrcSh != &rSh )
    3214             :     {
    3215           0 :         rSh.EnterStdMode();
    3216           0 :         rSh.SwCrsrShell::SetCrsr( rDragPt, sal_True );
    3217           0 :         cWord = rSrcSh.IntelligentCut( nSel, sal_False );
    3218             :     }
    3219           0 :     else if( !bTblSel && !bFrmSel )
    3220             :     {
    3221           0 :         if( !rSh.IsAddMode() )
    3222             :         {
    3223             :             // #i87233#
    3224           0 :             if ( rSh.IsBlockMode() )
    3225             :             {
    3226             :                 // preserve order of cursors for block mode
    3227           0 :                 rSh.GoPrevCrsr();
    3228             :             }
    3229             : 
    3230           0 :             rSh.SwCrsrShell::CreateCrsr();
    3231             :         }
    3232           0 :         rSh.SwCrsrShell::SetCrsr( rDragPt, sal_True, false );
    3233           0 :         rSh.GoPrevCrsr();
    3234           0 :         cWord = rSh.IntelligentCut( rSh.GetSelectionType(), sal_False );
    3235           0 :         rSh.GoNextCrsr();
    3236             :     }
    3237             : 
    3238           0 :     bInWrd  = rSh.IsInWrd();
    3239           0 :     bEndWrd = rSh.IsEndWrd();
    3240           0 :     bSttWrd = !bEndWrd && rSh.IsSttWrd();
    3241           0 :     bSttPara= rSh.IsSttPara();
    3242             : 
    3243           0 :     Point aSttPt( SwEditWin::GetDDStartPosX(), SwEditWin::GetDDStartPosY() );
    3244             : 
    3245             :     // at first, select INetFelder!
    3246           0 :     if( TRNSFR_INETFLD == eBufferType )
    3247             :     {
    3248           0 :         if( &rSrcSh == &rSh )
    3249             :         {
    3250           0 :             rSh.GoPrevCrsr();
    3251           0 :             rSh.SwCrsrShell::SetCrsr( aSttPt, sal_True );
    3252           0 :             rSh.SelectTxtAttr( RES_TXTATR_INETFMT );
    3253           0 :             if( rSh.ChgCurrPam( rDragPt ) )
    3254             :             {
    3255             :                 // don't copy/move inside of yourself
    3256           0 :                 rSh.DestroyCrsr();
    3257           0 :                 rSh.EndUndo();
    3258           0 :                 rSh.EndAction();
    3259           0 :                 rSh.EndAction();
    3260           0 :                 return 0;
    3261             :             }
    3262           0 :             rSh.GoNextCrsr();
    3263             :         }
    3264             :         else
    3265             :         {
    3266           0 :             rSrcSh.SwCrsrShell::SetCrsr( aSttPt, sal_True );
    3267           0 :             rSrcSh.SelectTxtAttr( RES_TXTATR_INETFMT );
    3268             :         }
    3269             : 
    3270             :         // is there an URL attribute at the insert point? Then replace that,
    3271             :         // so simply put up a selection?
    3272           0 :         rSh.DelINetAttrWithText();
    3273           0 :         bDDINetAttr = sal_True;
    3274             :     }
    3275             : 
    3276           0 :     if ( rSrcSh.IsSelFrmMode() )
    3277             :     {
    3278             :         //Hack: fool the special treatment
    3279           0 :         aSttPt -= aSttPt - rSrcSh.GetObjRect().Pos();
    3280             :     }
    3281             : 
    3282             :     sal_Bool bRet = rSrcSh.SwFEShell::Copy( &rSh, aSttPt, rDragPt, bMove,
    3283           0 :                                             !bIsXSelection );
    3284             : 
    3285           0 :     if( !bIsXSelection )
    3286             :     {
    3287           0 :         rSrcSh.Push();
    3288           0 :         if ( bRet && bMove && !bFrmSel )
    3289             :         {
    3290           0 :             if ( bTblSel )
    3291             :             {
    3292             :                 /* delete table contents not cells */
    3293           0 :                 rSrcSh.Delete();
    3294             :             }
    3295             :             else
    3296             :             {
    3297             :                 //SmartCut, take one of the blanks along.
    3298           0 :                 rSh.SwCrsrShell::DestroyCrsr();
    3299           0 :                 if ( cWord == SwWrtShell::WORD_SPACE_BEFORE )
    3300           0 :                     rSh.ExtendSelection( sal_False );
    3301           0 :                 else if ( cWord == SwWrtShell::WORD_SPACE_AFTER )
    3302           0 :                     rSh.ExtendSelection();
    3303           0 :                 rSrcSh.DelRight();
    3304             :             }
    3305             :         }
    3306           0 :         rSrcSh.KillPams();
    3307           0 :         rSrcSh.Pop( sal_False );
    3308             : 
    3309             :         /* after dragging a table selection inside one shell
    3310             :             set cursor to the drop position. */
    3311           0 :         if( &rSh == &rSrcSh && ( bTblSel || rSh.IsBlockMode() ) )
    3312             :         {
    3313           0 :             rSrcSh.SwCrsrShell::SetCrsr(rDragPt);
    3314           0 :             rSrcSh.GetSwCrsr()->SetMark();
    3315             :         }
    3316             :     }
    3317             : 
    3318           0 :     if( bRet && !bTblSel && !bFrmSel )
    3319             :     {
    3320           0 :         if( (bInWrd || bEndWrd) &&
    3321             :             (cWord == SwWrtShell::WORD_SPACE_AFTER ||
    3322             :                 cWord == SwWrtShell::WORD_SPACE_BEFORE) )
    3323             :         {
    3324           0 :             if ( bSttWrd || (bInWrd && !bEndWrd))
    3325           0 :                 rSh.SwEditShell::Insert(' ', bIsXSelection);
    3326           0 :             if ( !bSttWrd || (bInWrd && !bSttPara) )
    3327             :             {
    3328           0 :                 rSh.SwapPam();
    3329           0 :                 if ( !bSttWrd )
    3330           0 :                     rSh.SwEditShell::Insert(' ', bIsXSelection);
    3331           0 :                 rSh.SwapPam();
    3332             :             }
    3333             :         }
    3334             : 
    3335           0 :         if( bIsXSelection )
    3336             :         {
    3337           0 :             if( &rSrcSh == &rSh && !rSh.IsAddMode() )
    3338             :             {
    3339           0 :                 rSh.SwCrsrShell::DestroyCrsr();
    3340           0 :                 rSh.GoPrevCrsr();
    3341             :             }
    3342             :             else
    3343             :             {
    3344           0 :                 rSh.SwapPam();
    3345           0 :                 rSh.SwCrsrShell::ClearMark();
    3346             :             }
    3347             :         }
    3348             :         else
    3349             :         {
    3350           0 :             if( rSh.IsAddMode() )
    3351           0 :                 rSh.SwCrsrShell::CreateCrsr();
    3352             :             else
    3353             :             {
    3354             :                 // turn on selection mode
    3355           0 :                 rSh.SttSelect();
    3356           0 :                 rSh.EndSelect();
    3357             :             }
    3358             :         }
    3359             :     }
    3360             : 
    3361           0 :     if( bRet && bMove && bFrmSel )
    3362           0 :         rSrcSh.LeaveSelFrmMode();
    3363             : 
    3364           0 :     if( rSrcSh.GetDoc() != rSh.GetDoc() )
    3365           0 :         rSrcSh.EndUndo();
    3366           0 :     rSh.EndUndo();
    3367             : 
    3368             :         // put the shell in the right state
    3369           0 :     if( &rSrcSh != &rSh && ( rSh.IsFrmSelected() || rSh.IsObjSelected() ))
    3370           0 :         rSh.EnterSelFrmMode();
    3371             : 
    3372           0 :     rSrcSh.EndAction();
    3373           0 :     rSh.EndAction();
    3374           0 :     return 1;
    3375             : }
    3376             : 
    3377             : // Interfaces for Selection
    3378           0 : void SwTransferable::CreateSelection( SwWrtShell& rSh,
    3379             :                                       const ViewShell * _pCreatorView )
    3380             : {
    3381           0 :     SwModule *pMod = SW_MOD();
    3382           0 :     SwTransferable* pNew = new SwTransferable( rSh );
    3383             : 
    3384           0 :      pNew->pCreatorView = _pCreatorView;
    3385             : 
    3386             :     uno::Reference<
    3387           0 :             datatransfer::XTransferable > xRef( pNew );
    3388           0 :     pMod->pXSelection = pNew;
    3389           0 :     pNew->CopyToSelection( rSh.GetWin() );
    3390           0 : }
    3391             : 
    3392          85 : void SwTransferable::ClearSelection( SwWrtShell& rSh,
    3393             :                                      const ViewShell * _pCreatorView)
    3394             : {
    3395          85 :     SwModule *pMod = SW_MOD();
    3396          85 :     if( pMod->pXSelection &&
    3397           0 :         ((!pMod->pXSelection->pWrtShell) || (pMod->pXSelection->pWrtShell == &rSh)) &&
    3398             :         (!_pCreatorView || (pMod->pXSelection->pCreatorView == _pCreatorView)) )
    3399             :     {
    3400           0 :         TransferableHelper::ClearSelection( rSh.GetWin() );
    3401             :     }
    3402          85 : }
    3403             : 
    3404             : namespace
    3405             : {
    3406             :     class theSwTransferableUnoTunnelId : public rtl::Static< UnoTunnelIdInit, SwTransferable > {};
    3407             : }
    3408             : 
    3409           0 : const Sequence< sal_Int8 >& SwTransferable::getUnoTunnelId()
    3410             : {
    3411           0 :     return theSwTransferableUnoTunnelId::get().getSeq();
    3412             : }
    3413             : 
    3414           0 : sal_Int64 SwTransferable::getSomething( const Sequence< sal_Int8 >& rId ) throw( RuntimeException )
    3415             : {
    3416             :     sal_Int64 nRet;
    3417           0 :     if( ( rId.getLength() == 16 ) &&
    3418           0 :         ( 0 == memcmp( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
    3419             :     {
    3420           0 :         nRet = sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) );
    3421             :     }
    3422             :     else
    3423           0 :         nRet = TransferableHelper::getSomething(rId);
    3424           0 :     return nRet;
    3425             : }
    3426             : 
    3427           0 : SwTransferable* SwTransferable::GetSwTransferable( const TransferableDataHelper& rData )
    3428             : {
    3429           0 :     SwTransferable* pSwTransferable = NULL;
    3430             : 
    3431           0 :     uno::Reference<XUnoTunnel> xTunnel( rData.GetTransferable(), UNO_QUERY );
    3432           0 :     if ( xTunnel.is() )
    3433             :     {
    3434           0 :         sal_Int64 nHandle = xTunnel->getSomething( getUnoTunnelId() );
    3435           0 :         if ( nHandle )
    3436           0 :             pSwTransferable = (SwTransferable*) (sal_IntPtr) nHandle;
    3437             :     }
    3438             : 
    3439           0 :     return pSwTransferable;
    3440             : 
    3441             : }
    3442             : 
    3443           0 : SwTrnsfrDdeLink::SwTrnsfrDdeLink( SwTransferable& rTrans, SwWrtShell& rSh )
    3444             :     : rTrnsfr( rTrans ), pDocShell( 0 ),
    3445           0 :     bDelBookmrk( sal_False ), bInDisconnect( sal_False )
    3446             : {
    3447             :     // we only end up here with table- or text selection
    3448           0 :     if( nsSelectionType::SEL_TBL_CELLS & rSh.GetSelectionType() )
    3449             :     {
    3450           0 :         SwFrmFmt* pFmt = rSh.GetTableFmt();
    3451           0 :         if( pFmt )
    3452           0 :             sName = pFmt->GetName();
    3453             :     }
    3454             :     else
    3455             :     {
    3456             :         // creating a temp. bookmark without undo
    3457           0 :         sal_Bool bUndo = rSh.DoesUndo();
    3458           0 :         rSh.DoUndo( sal_False );
    3459           0 :         sal_Bool bIsModified = rSh.IsModified();
    3460             : 
    3461             :         ::sw::mark::IMark* pMark = rSh.SetBookmark(
    3462             :             KeyCode(),
    3463             :             ::rtl::OUString(),
    3464             :             ::rtl::OUString(),
    3465           0 :             IDocumentMarkAccess::DDE_BOOKMARK);
    3466           0 :         if(pMark)
    3467             :         {
    3468           0 :             sName = pMark->GetName();
    3469           0 :             bDelBookmrk = sal_True;
    3470           0 :             if( !bIsModified )
    3471           0 :                 rSh.ResetModified();
    3472             :         }
    3473             :         else
    3474           0 :             sName.Erase();
    3475           0 :         rSh.DoUndo( bUndo );
    3476             :     }
    3477             : 
    3478           0 :     if( sName.Len() &&
    3479           0 :         0 != ( pDocShell = rSh.GetDoc()->GetDocShell() ) )
    3480             :     {
    3481             :         // then we create our "server" and connect to it
    3482           0 :         refObj = pDocShell->DdeCreateLinkSource( sName );
    3483           0 :         if( refObj.Is() )
    3484             :         {
    3485           0 :             refObj->AddConnectAdvise( this );
    3486             :             refObj->AddDataAdvise( this,
    3487             :                             aEmptyStr,
    3488           0 :                             ADVISEMODE_NODATA | ADVISEMODE_ONLYONCE );
    3489           0 :             nOldTimeOut = refObj->GetUpdateTimeout();
    3490           0 :             refObj->SetUpdateTimeout( 0 );
    3491             :         }
    3492             :     }
    3493           0 : }
    3494             : 
    3495           0 : SwTrnsfrDdeLink::~SwTrnsfrDdeLink()
    3496             : {
    3497           0 :     if( refObj.Is() )
    3498           0 :         Disconnect( sal_True );
    3499           0 : }
    3500             : 
    3501           0 : ::sfx2::SvBaseLink::UpdateResult SwTrnsfrDdeLink::DataChanged( const String& ,
    3502             :                                     const uno::Any& )
    3503             : {
    3504             :     // well, that's it with the link
    3505           0 :     if( !bInDisconnect )
    3506             :     {
    3507           0 :         if( FindDocShell() && pDocShell->GetView() )
    3508           0 :             rTrnsfr.RemoveDDELinkFormat( pDocShell->GetView()->GetEditWin() );
    3509           0 :         Disconnect( sal_False );
    3510             :     }
    3511           0 :     return SUCCESS;
    3512             : }
    3513             : 
    3514           0 : sal_Bool SwTrnsfrDdeLink::WriteData( SvStream& rStrm )
    3515             : {
    3516           0 :     if( !refObj.Is() || !FindDocShell() )
    3517           0 :         return sal_False;
    3518             : 
    3519           0 :     rtl_TextEncoding eEncoding = DDE_TXT_ENCODING;
    3520             :     const rtl::OString aAppNm(rtl::OUStringToOString(
    3521           0 :         GetpApp()->GetAppName(), eEncoding));
    3522             :     const rtl::OString aTopic(rtl::OUStringToOString(
    3523           0 :         pDocShell->GetTitle(SFX_TITLE_FULLNAME), eEncoding));
    3524           0 :     const rtl::OString aName(rtl::OUStringToOString(sName, eEncoding));
    3525             : 
    3526           0 :     sal_Char* pMem = new sal_Char[ aAppNm.getLength() + aTopic.getLength() + aName.getLength() + 4 ];
    3527             : 
    3528           0 :     sal_Int32 nLen = aAppNm.getLength();
    3529           0 :     memcpy( pMem, aAppNm.getStr(), nLen );
    3530           0 :     pMem[ nLen++ ] = 0;
    3531           0 :     memcpy( pMem + nLen, aTopic.getStr(), aTopic.getLength() );
    3532           0 :     nLen = nLen + aTopic.getLength();
    3533           0 :     pMem[ nLen++ ] = 0;
    3534           0 :     memcpy( pMem + nLen, aName.getStr(), aName.getLength() );
    3535           0 :     nLen = nLen + aName.getLength();
    3536           0 :     pMem[ nLen++ ] = 0;
    3537           0 :     pMem[ nLen++ ] = 0;
    3538             : 
    3539           0 :     rStrm.Write( pMem, nLen );
    3540           0 :     delete[] pMem;
    3541             : 
    3542           0 :     IDocumentMarkAccess* const pMarkAccess = pDocShell->GetDoc()->getIDocumentMarkAccess();
    3543           0 :     IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->findMark(sName);
    3544           0 :     if(ppMark != pMarkAccess->getMarksEnd()
    3545           0 :         && IDocumentMarkAccess::GetType(**ppMark) != IDocumentMarkAccess::BOOKMARK)
    3546             :     {
    3547             :         // the mark is still a DdeBookmark
    3548             :         // we replace it with a Bookmark, so it will get saved etc.
    3549           0 :         ::sw::mark::IMark* const pMark = ppMark->get();
    3550           0 :         SwServerObject* const pServerObject = dynamic_cast<SwServerObject *>(&refObj);
    3551             : 
    3552             :         // collecting state of old mark
    3553           0 :         SwPaM aPaM(pMark->GetMarkStart());
    3554           0 :         *aPaM.GetPoint() = pMark->GetMarkStart();
    3555           0 :         if(pMark->IsExpanded())
    3556             :         {
    3557           0 :             aPaM.SetMark();
    3558           0 :             *aPaM.GetMark() = pMark->GetMarkEnd();
    3559             :         }
    3560           0 :         ::rtl::OUString sMarkName = pMark->GetName();
    3561             : 
    3562             :         // remove mark
    3563           0 :         pServerObject->SetNoServer(); // this removes the connection between SwServerObject and mark
    3564             :         // N.B. ppMark was not loaded from file and cannot have xml:id
    3565           0 :         pMarkAccess->deleteMark(ppMark);
    3566             : 
    3567             :         // recreate as Bookmark
    3568             :         ::sw::mark::IMark* const pNewMark = pMarkAccess->makeMark(
    3569             :             aPaM,
    3570             :             sMarkName,
    3571           0 :             IDocumentMarkAccess::BOOKMARK);
    3572           0 :         pServerObject->SetDdeBookmark(*pNewMark);
    3573             :     }
    3574             : 
    3575           0 :     bDelBookmrk = false;
    3576           0 :     return true;
    3577             : }
    3578             : 
    3579           0 : void SwTrnsfrDdeLink::Disconnect( sal_Bool bRemoveDataAdvise )
    3580             : {
    3581             :     //  don't accept DataChanged anymore, when already in Disconnect!
    3582             :     //  (DTOR from Bookmark sends a DataChanged!)
    3583           0 :     sal_Bool bOldDisconnect = bInDisconnect;
    3584           0 :     bInDisconnect = sal_True;
    3585             : 
    3586             :     // destroy the unused bookmark again (without Undo!)?
    3587           0 :     if( bDelBookmrk && refObj.Is() && FindDocShell() )
    3588             :     {
    3589           0 :         SwDoc* pDoc = pDocShell->GetDoc();
    3590           0 :         ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
    3591             : 
    3592             :         // #i58448#
    3593           0 :         Link aSavedOle2Link( pDoc->GetOle2Link() );
    3594           0 :         pDoc->SetOle2Link( Link() );
    3595             : 
    3596           0 :         sal_Bool bIsModified = pDoc->IsModified();
    3597             : 
    3598           0 :         IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
    3599           0 :         pMarkAccess->deleteMark(pMarkAccess->findMark(sName));
    3600             : 
    3601           0 :         if( !bIsModified )
    3602           0 :             pDoc->ResetModified();
    3603             :         // #i58448#
    3604           0 :         pDoc->SetOle2Link( aSavedOle2Link );
    3605             : 
    3606           0 :         bDelBookmrk = sal_False;
    3607             :     }
    3608             : 
    3609           0 :     if( refObj.Is() )
    3610             :     {
    3611           0 :         refObj->SetUpdateTimeout( nOldTimeOut );
    3612           0 :         refObj->RemoveConnectAdvise( this );
    3613           0 :         if( bRemoveDataAdvise )
    3614             :             // in a DataChanged the SelectionObject must NEVER be deleted
    3615             :             // is already handled by the base class
    3616             :             // (ADVISEMODE_ONLYONCE!!!!)
    3617             :             // but always in normal Disconnect!
    3618           0 :             refObj->RemoveAllDataAdvise( this );
    3619           0 :         refObj.Clear();
    3620             :     }
    3621           0 :     bInDisconnect = bOldDisconnect;
    3622           0 : }
    3623             : 
    3624           0 : sal_Bool SwTrnsfrDdeLink::FindDocShell()
    3625             : {
    3626           0 :     TypeId aType( TYPE( SwDocShell ) );
    3627           0 :     SfxObjectShell* pTmpSh = SfxObjectShell::GetFirst( &aType );
    3628           0 :     while( pTmpSh )
    3629             :     {
    3630           0 :         if( pTmpSh == pDocShell )       // that's what we want to have
    3631             :         {
    3632           0 :             if( pDocShell->GetDoc() )
    3633           0 :                 return sal_True;
    3634           0 :             break;      // the Doc is not there anymore, so leave!
    3635             :         }
    3636           0 :         pTmpSh = SfxObjectShell::GetNext( *pTmpSh, &aType );
    3637             :     }
    3638             : 
    3639           0 :     pDocShell = 0;
    3640           0 :     return sal_False;
    3641             : }
    3642             : 
    3643           0 : void SwTrnsfrDdeLink::Closed()
    3644             : {
    3645           0 :     if( !bInDisconnect && refObj.Is() )
    3646             :     {
    3647           0 :         refObj->RemoveAllDataAdvise( this );
    3648           0 :         refObj->RemoveConnectAdvise( this );
    3649           0 :         refObj.Clear();
    3650             :     }
    3651          30 : }
    3652             : 
    3653             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10