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