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