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