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