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

Generated by: LCOV version 1.10