LibreOffice Module sw (master)  1
swdtflvr.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <config_features.h>
21 
22 #include <com/sun/star/embed/XTransactedObject.hpp>
23 #include <com/sun/star/embed/Aspects.hpp>
24 #include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
25 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
26 #include <com/sun/star/embed/MSOLEObjectSystemCreator.hpp>
27 #include <com/sun/star/text/XPasteListener.hpp>
28 
30 #include <svtools/insdlg.hxx>
31 #include <unotools/tempfile.hxx>
32 #include <comphelper/fileformat.h>
36 #include <comphelper/string.hxx>
37 #include <o3tl/deleter.hxx>
39 #include <sot/filelist.hxx>
40 #include <svx/svxdlg.hxx>
42 #include <osl/endian.h>
43 #include <sfx2/linkmgr.hxx>
44 #include <tools/urlobj.hxx>
45 #include <vcl/weld.hxx>
46 #include <sfx2/dispatch.hxx>
47 #include <sfx2/viewfrm.hxx>
48 #include <svl/stritem.hxx>
49 #include <vcl/imap.hxx>
50 #include <sot/storage.hxx>
51 #include <vcl/graph.hxx>
52 #include <svl/urihelper.hxx>
53 #include <svx/svdmodel.hxx>
54 #include <svx/xmlexchg.hxx>
55 #include <svx/dbaexchange.hxx>
56 #include <svx/clipfmtitem.hxx>
57 #include <sfx2/mieclip.hxx>
58 #include <svl/urlbmk.hxx>
59 #include <vcl/inetimg.hxx>
60 #include <svx/fmview.hxx>
61 #include <sfx2/docfilt.hxx>
62 #include <vcl/imapobj.hxx>
63 #include <sfx2/docfile.hxx>
65 #include <unotools/streamwrap.hxx>
66 #include <vcl/graphicfilter.hxx>
67 
68 #ifdef _WIN32
69 #include <prewin.h>
70 #include <postwin.h>
72 #include <osl/file.hxx>
73 #endif
74 
75 #include <svx/unomodel.hxx>
76 #include <fmturl.hxx>
77 #include <fmtinfmt.hxx>
78 #include <swdtflvr.hxx>
79 #include <shellio.hxx>
80 #include <ddefld.hxx>
81 #include <doc.hxx>
82 #include <IDocumentUndoRedo.hxx>
86 #include <IDocumentState.hxx>
87 #include <IMark.hxx>
88 #include <section.hxx>
89 #include <ndtxt.hxx>
90 #include <edtdd.hxx>
91 #include <edtwin.hxx>
92 #include <navicont.hxx>
93 #include <swcont.hxx>
94 #include <wrtsh.hxx>
95 #include <swmodule.hxx>
96 #include <view.hxx>
97 #include <docsh.hxx>
98 #include <wdocsh.hxx>
99 #include <fldbas.hxx>
100 #include <swundo.hxx>
101 #include <pam.hxx>
102 #include <ndole.hxx>
103 #include <swwait.hxx>
104 #include <viewopt.hxx>
105 #include <SwCapObjType.hxx>
106 #include <cmdid.h>
107 #include <strings.hrc>
108 #include <svx/svditer.hxx>
109 #include <editeng/eeitem.hxx>
110 #include <editeng/fhgtitem.hxx>
111 #include <svx/svdpage.hxx>
112 #include <avmedia/mediawindow.hxx>
113 #include <swcrsr.hxx>
114 #include <SwRewriter.hxx>
115 #include <vcl/svapp.hxx>
116 #include <swserv.hxx>
117 #include <fmtmeta.hxx>
118 #include <itabenum.hxx>
119 #include <iodetect.hxx>
120 #include <unotextrange.hxx>
121 #include <unoframe.hxx>
122 #include <txatbase.hxx>
123 #include <vcl/uitest/logger.hxx>
125 
128 #include <vcl/TypeSerializer.hxx>
129 #include <comphelper/lok.hxx>
131 #include <sfx2/sfxdlg.hxx>
132 #include <comphelper/classids.hxx>
133 
134 #include <memory>
135 
136 #define OLESIZE 11905 - 2 * lMinBorder, 6 * MM50
137 
138 constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_DRAWMODEL = 0x00000001;
139 constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_HTML = 0x00000002;
140 constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_RTF = 0x00000004;
141 constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_STRING = 0x00000008;
142 constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_SWOLE = 0x00000010;
143 constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_DDE = 0x00000020;
144 constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_RICHTEXT = 0x00000040;
145 
146 using namespace ::svx;
147 using namespace ::com::sun::star;
148 using namespace ::com::sun::star::uno;
149 using namespace ::com::sun::star::datatransfer;
150 namespace {
151 
152 void collectUIInformation(const OUString& rAction, const OUString& aParameters)
153 {
154  EventDescription aDescription;
155  aDescription.aAction = rAction;
156  aDescription.aParameters = {{"parameters", aParameters}};
157  aDescription.aID = "writer_edit";
158  aDescription.aKeyWord = "SwEditWinUIObject";
159  aDescription.aParent = "MainWindow";
160  UITestLogger::getInstance().logEvent(aDescription);
161 }
162 
163 }
164 
165 namespace {
166 
167 class SwTransferDdeLink : public ::sfx2::SvBaseLink
168 {
169  OUString sName;
171  SwTransferable& rTrnsfr;
172  SwDocShell* pDocShell;
173  sal_uLong nOldTimeOut;
174  bool bDelBookmrk : 1;
175  bool bInDisconnect : 1;
176 
177  bool FindDocShell();
178 
180 
181 protected:
182  virtual ~SwTransferDdeLink() override;
183 
184 public:
185  SwTransferDdeLink( SwTransferable& rTrans, SwWrtShell& rSh );
186 
187  virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
188  const OUString& rMimeType, const css::uno::Any & rValue ) override;
189  virtual void Closed() override;
190 
191  bool WriteData( SvStream& rStrm );
192 
193  void Disconnect( bool bRemoveDataAdvise );
194 };
195 
196 }
197 
200 {
201 public:
202  SwPasteContext(SwWrtShell& rWrtShell);
203  ~SwPasteContext();
204 
205  void remember();
206  void forget();
207 
208 private:
210  std::unique_ptr<SwPaM> m_pPaM;
211  sal_Int32 m_nStartContent = 0;
212 };
213 
214 namespace {
215 
216 // helper class for Action and Undo enclosing
217 class SwTrnsfrActionAndUndo
218 {
219  SwWrtShell *pSh;
220 public:
221  SwTrnsfrActionAndUndo( SwWrtShell *pS, bool bDelSel = false, SwPasteContext* pContext = nullptr)
222  : pSh( pS )
223  {
225  if( bDelSel )
226  {
227  if (pContext)
228  pContext->forget();
229  pSh->DelRight();
230  if (pContext)
231  pContext->remember();
232  }
233  pSh->StartAllAction();
234  }
235  ~SwTrnsfrActionAndUndo() COVERITY_NOEXCEPT_FALSE
236  {
237  pSh->EndUndo();
238  pSh->EndAllAction();
239  }
240 };
241 
242 }
243 
245  : m_pWrtShell( &rSh ),
246  m_pCreatorView( nullptr ),
247  m_pOrigGraphic( nullptr ),
248  m_eBufferType( TransferBufferType::NONE ),
249  m_bOldIdle(false),
250  m_bCleanUp(false)
251 {
252  rSh.GetView().AddTransferable(*this);
253  SwDocShell* pDShell = rSh.GetDoc()->GetDocShell();
254  if( !pDShell )
255  return;
256 
258  if( pDShell->GetMedium() )
259  {
260  const INetURLObject& rURLObj = pDShell->GetMedium()->GetURLObject();
265  }
266 
268 }
269 
271 {
272  SolarMutexGuard aSolarGuard;
273 
274  // the DDELink still needs the WrtShell!
275  if( m_xDdeLink.is() )
276  {
277  static_cast<SwTransferDdeLink*>( m_xDdeLink.get() )->Disconnect( true );
278  m_xDdeLink.clear();
279  }
280 
281  m_pWrtShell = nullptr;
282 
283  // release reference to the document so that aDocShellRef will delete
284  // it (if aDocShellRef is set). Otherwise, the OLE nodes keep references
285  // to their sub-storage when the storage is already dead.
286  m_pClpDocFac.reset();
287 
288  // first close, then the Ref. can be cleared as well, so that
289  // the DocShell really gets deleted!
290  if( m_aDocShellRef.Is() )
291  {
293  SwDocShell* pDocSh = static_cast<SwDocShell*>(pObj);
294  pDocSh->DoClose();
295  }
297 
298  SwModule* pMod = SW_MOD();
299  if(pMod)
300  {
301  if ( pMod->m_pDragDrop == this )
302  pMod->m_pDragDrop = nullptr;
303  else if ( pMod->m_pXSelection == this )
304  pMod->m_pXSelection = nullptr;
305  }
306 
308 }
309 
310 static SwDoc& lcl_GetDoc(SwDocFac & rDocFac)
311 {
312  SwDoc& rDoc = rDocFac.GetDoc();
313  rDoc.SetClipBoard( true );
314  return rDoc;
315 }
316 
318 {
319  SwModule *pMod = SW_MOD();
320  if (!pMod)
321  return;
322  if( this == pMod->m_pDragDrop )
323  pMod->m_pDragDrop = nullptr;
324  else if( this == pMod->m_pXSelection )
325  pMod->m_pXSelection = nullptr;
326 }
327 
329 {
330  // only need if we are the current XSelection Object
331  SwModule *pMod = SW_MOD();
333  {
334  SetDataForDragAndDrop( Point( 0,0) );
335  }
336 }
337 
339 {
340  //set OleVisArea. Upper left corner of the page and size of
341  //RealSize in Twips.
342  const Size aSz( OLESIZE );
343  SwRect aVis( Point( DOCUMENTBORDER, DOCUMENTBORDER ), aSz );
344  pDoc->SetVisArea( aVis.SVRect() );
345 }
346 
347 uno::Reference < embed::XEmbeddedObject > SwTransferable::FindOLEObj( sal_Int64& nAspect ) const
348 {
349  uno::Reference < embed::XEmbeddedObject > xObj;
350  if( m_pClpDocFac )
351  {
352  SwIterator<SwContentNode,SwFormatColl> aIter( *m_pClpDocFac->GetDoc().GetDfltGrfFormatColl() );
353  for( SwContentNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
354  if( SwNodeType::Ole == pNd->GetNodeType() )
355  {
356  xObj = static_cast<SwOLENode*>(pNd)->GetOLEObj().GetOleRef();
357  nAspect = static_cast<SwOLENode*>(pNd)->GetAspect();
358  break;
359  }
360  }
361  return xObj;
362 }
363 
365 {
366  if( m_pClpDocFac )
367  {
368  SwIterator<SwContentNode,SwFormatColl> aIter( *m_pClpDocFac->GetDoc().GetDfltGrfFormatColl() );
369  for( SwContentNode* pNd = aIter.First(); pNd; pNd = aIter.Next() )
370  if( SwNodeType::Ole == pNd->GetNodeType() )
371  {
372  return static_cast<SwOLENode*>(pNd)->GetGraphic();
373  }
374  }
375 
376  return nullptr;
377 }
378 
380 {
381  RemoveFormat( SotClipboardFormatId::LINK );
382  CopyToClipboard( const_cast<vcl::Window*>(&rWin) );
383 }
384 
385 namespace
386 {
387  //Resolves: fdo#40717 surely when we create a clipboard document we should
388  //overwrite the clipboard documents styles and settings with that of the
389  //source, so that we can WYSIWYG paste. If we want that the destinations
390  //styles are used over the source styles, that's a matter of the
391  //destination paste code to handle, not the source paste code.
392  void lclOverWriteDoc(SwWrtShell &rSrcWrtShell, SwDoc &rDest)
393  {
394  const SwDoc &rSrc = *rSrcWrtShell.GetDoc();
395 
396  rDest.ReplaceCompatibilityOptions(rSrc);
397  rDest.ReplaceDefaults(rSrc);
398 
399  //It would probably make most sense here to only insert the styles used
400  //by the selection, e.g. apply SwDoc::IsUsed on styles ?
401  rDest.ReplaceStyles(rSrc, false);
402 
403  rSrcWrtShell.Copy(rDest);
404 
406  }
407 
408  void lclCheckAndPerformRotation(Graphic& aGraphic)
409  {
410  GraphicNativeMetadata aMetadata;
411  if ( !aMetadata.read(aGraphic) )
412  return;
413 
414  Degree10 aRotation = aMetadata.getRotation();
415  if (aRotation)
416  {
417  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/swriter/ui/queryrotateintostandarddialog.ui"));
418  std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("QueryRotateIntoStandardOrientationDialog"));
419  if (xQueryBox->run() == RET_YES)
420  {
421  GraphicNativeTransform aTransform( aGraphic );
422  aTransform.rotate( aRotation );
423  }
424  }
425  }
426 }
427 
429 {
430  sal_Int32 nTextLength = 0;
431  SwNodes& aNodes = m_pWrtShell->GetDoc()->GetNodes();
432  for (SwPaM& rPaM : m_pWrtShell->GetCursor()->GetRingContainer())
433  {
434  for (sal_uLong nIndex = rPaM.GetMark()->nNode.GetIndex();
435  nIndex <= rPaM.GetPoint()->nNode.GetIndex(); ++nIndex)
436  {
437  SwNode& rNd = *aNodes[nIndex];
438 
439  SwTextNode* pTextNode = rNd.GetTextNode();
440  if (pTextNode)
441  {
442  if (pTextNode->HasHints())
443  {
444  for (size_t nHint = 0; nHint < pTextNode->GetSwpHints().Count(); ++nHint)
445  {
446  SwTextAttr* pHint = pTextNode->GetSwpHints().Get(nHint);
447  if (pHint->Which() == RES_TXTATR_FLYCNT)
448  {
449  return true; // Complex
450  }
451  }
452  }
453 
454  nTextLength += pTextNode->GetText().getLength();
455  if (nTextLength >= 1024 * 512)
456  return true; // Complex
457  }
458  }
459  }
460 
462  return true; // Complex
463 
464  // Simple
465  return false;
466 }
467 
468 bool SwTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDoc )
469 {
470  SotClipboardFormatId nFormat = SotExchange::GetFormat( rFlavor );
471 
472  // we can only fulfil the request if
473  // 1) we have data for this format
474  // 2) we have either a clipboard document (pClpDocFac), or
475  // we have a SwWrtShell (so we can generate a new clipboard document)
476  if( !HasFormat( nFormat ) || ( m_pClpDocFac == nullptr && m_pWrtShell == nullptr ) )
477  return false;
478 
479  if( !m_pClpDocFac )
480  {
481  SelectionType nSelectionType = m_pWrtShell->GetSelectionType();
482 
483  // when pending we will not get the correct type, but SelectionType::Text
484  // as fallback. This *happens* during D&D, so we need to check if we are in
485  // the fallback and just try to get a graphic
486  const bool bPending(m_pWrtShell->ActionPend());
487 
488  // SEL_GRF is from ContentType of editsh
489  if(bPending || ((SelectionType::Graphic | SelectionType::DbForm) & nSelectionType))
490  {
491  m_pClpGraphic.reset(new Graphic);
492  if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::GDIMETAFILE, *m_pClpGraphic ))
494  m_pClpBitmap.reset(new Graphic);
495  if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::BITMAP, *m_pClpBitmap ))
497 
498  // is it a URL-Button ?
499  OUString sURL;
500  OUString sDesc;
501  if( m_pWrtShell->GetURLFromButton( sURL, sDesc ) )
502  {
503  m_pBookmark.reset(new INetBookmark( sURL, sDesc ));
505  }
506  }
507 
508  m_pClpDocFac.reset(new SwDocFac);
509  SwDoc& rTmpDoc = lcl_GetDoc(*m_pClpDocFac);
510 
511  rTmpDoc.getIDocumentFieldsAccess().LockExpFields(); // never update fields - leave text as it is
512  lclOverWriteDoc(*m_pWrtShell, rTmpDoc);
513 
514  // in CORE a new one was created (OLE-objects copied!)
515  m_aDocShellRef = rTmpDoc.GetTmpDocShell();
516  if( m_aDocShellRef.Is() )
518  rTmpDoc.SetTmpDocShell( nullptr );
519 
520  if( nSelectionType & SelectionType::Text && !m_pWrtShell->HasMark() )
521  {
522  SwContentAtPos aContentAtPos( IsAttrAtPos::InetAttr );
523 
525 
526  bool bSelect = g_bExecuteDrag &&
529  if( m_pWrtShell->GetContentAtPos( aPos, aContentAtPos, bSelect ) )
530  {
531  m_pBookmark.reset(new INetBookmark(
532  static_cast<const SwFormatINetFormat*>(aContentAtPos.aFnd.pAttr)->GetValue(),
533  aContentAtPos.sStr ));
535  if( bSelect )
537  }
538  }
540  {
542  m_pWrtShell->GetFlyFrameAttr( aSet );
543  const SwFormatURL& rURL = aSet.Get( RES_URL );
544  if( rURL.GetMap() )
545  m_pImageMap.reset(new ImageMap( *rURL.GetMap() ));
546  else if( !rURL.GetURL().isEmpty() )
547  m_pTargetURL.reset(new INetImage(OUString(), rURL.GetURL(),
548  rURL.GetTargetFrameName() ));
549  }
550  }
551 
552  bool bOK = false;
554  {
555  //TODO/MBA: testing - is this the "single OLE object" case?!
556  // get OLE-Object from ClipDoc and get the data from that.
557  sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; // will be set in the next statement
558  uno::Reference < embed::XEmbeddedObject > xObj = FindOLEObj( nAspect );
559  const Graphic* pOLEGraph = FindOLEReplacementGraphic();
560  if( xObj.is() )
561  {
562  TransferableDataHelper aD( new SvEmbedTransferHelper( xObj, pOLEGraph, nAspect ) );
563  uno::Any aAny = aD.GetAny(rFlavor, rDestDoc);
564  if( aAny.hasValue() )
565  bOK = SetAny( aAny );
566  }
567 
568  // the following solution will be used in the case when the object can not generate the image
569  // TODO/LATER: in future the transferhelper must probably be created based on object and the replacement stream
570  // TODO: Block not required now, SvEmbedTransferHelper should be able to handle GDIMetaFile format
571  if ( nFormat == SotClipboardFormatId::GDIMETAFILE )
572  {
573  pOLEGraph = FindOLEReplacementGraphic();
574  if ( pOLEGraph )
575  bOK = SetGDIMetaFile( pOLEGraph->GetGDIMetaFile() );
576  }
577  }
578  else
579  {
580  switch( nFormat )
581  {
582  case SotClipboardFormatId::LINK:
583  if( m_xDdeLink.is() )
584  bOK = SetObject( m_xDdeLink.get(), SWTRANSFER_OBJECTTYPE_DDE, rFlavor );
585  break;
586 
587  case SotClipboardFormatId::OBJECTDESCRIPTOR:
588  case SotClipboardFormatId::LINKSRCDESCRIPTOR:
590  break;
591 
592  case SotClipboardFormatId::DRAWING:
593  {
594  SwDoc& rDoc = lcl_GetDoc(*m_pClpDocFac);
597  }
598  break;
599 
600  case SotClipboardFormatId::STRING:
601  {
602  SwDoc& rDoc = lcl_GetDoc(*m_pClpDocFac);
603  bOK = SetObject( &rDoc, SWTRANSFER_OBJECTTYPE_STRING, rFlavor );
604  }
605  break;
606  case SotClipboardFormatId::RTF:
607  {
608  SwDoc& rDoc = lcl_GetDoc(*m_pClpDocFac);
609  bOK = SetObject( &rDoc, SWTRANSFER_OBJECTTYPE_RTF, rFlavor );
610  }
611  break;
612  case SotClipboardFormatId::RICHTEXT:
613  {
614  SwDoc& rDoc = lcl_GetDoc(*m_pClpDocFac);
615  bOK = SetObject( &rDoc, SWTRANSFER_OBJECTTYPE_RICHTEXT, rFlavor );
616  }
617  break;
618 
619  case SotClipboardFormatId::HTML:
620  {
621  SwDoc& rDoc = lcl_GetDoc(*m_pClpDocFac);
622  bOK = SetObject( &rDoc, SWTRANSFER_OBJECTTYPE_HTML, rFlavor );
623  }
624  break;
625 
626  case SotClipboardFormatId::SVXB:
628  bOK = SetGraphic( *m_pOrigGraphic );
629  break;
630 
631  case SotClipboardFormatId::GDIMETAFILE:
633  bOK = SetGDIMetaFile( m_pClpGraphic->GetGDIMetaFile() );
634  break;
635  case SotClipboardFormatId::BITMAP:
636  case SotClipboardFormatId::PNG:
637  // Neither pClpBitmap nor pClpGraphic are necessarily set
638  if( (m_eBufferType & TransferBufferType::Graphic) && (m_pClpBitmap != nullptr || m_pClpGraphic != nullptr))
639  bOK = SetBitmapEx( (m_pClpBitmap ? m_pClpBitmap : m_pClpGraphic)->GetBitmapEx(), rFlavor );
640  break;
641 
642  case SotClipboardFormatId::SVIM:
643  if( m_pImageMap )
644  bOK = SetImageMap( *m_pImageMap );
645  break;
646 
647  case SotClipboardFormatId::INET_IMAGE:
648  if( m_pTargetURL )
649  bOK = SetINetImage( *m_pTargetURL, rFlavor );
650  break;
651 
652  case SotClipboardFormatId::SOLK:
653  case SotClipboardFormatId::NETSCAPE_BOOKMARK:
654  case SotClipboardFormatId::FILEGRPDESCRIPTOR:
655  case SotClipboardFormatId::FILECONTENT:
656  case SotClipboardFormatId::UNIFORMRESOURCELOCATOR:
657  case SotClipboardFormatId::SIMPLE_FILE:
659  bOK = SetINetBookmark( *m_pBookmark, rFlavor );
660  break;
661 
662  case SotClipboardFormatId::EMBED_SOURCE:
663  if( !m_aDocShellRef.Is() )
664  {
665  SwDoc& rDoc = lcl_GetDoc(*m_pClpDocFac);
666  SwDocShell* pNewDocSh = new SwDocShell( rDoc,
667  SfxObjectCreateMode::EMBEDDED );
668  m_aDocShellRef = pNewDocSh;
671  }
673  rFlavor );
674  break;
675  default: break;
676  }
677  }
678  return bOK;
679 }
680 
682  void* pObject, sal_uInt32 nObjectType,
683  const DataFlavor& /*rFlavor*/ )
684 {
685  bool bRet = false;
686  WriterRef xWrt;
687 
688  switch( nObjectType )
689  {
691  {
692  // don't change the sequence of commands
693  SdrModel *pModel = static_cast<SdrModel*>(pObject);
694  xStream->SetBufferSize( 16348 );
695 
696  // for the changed pool defaults from drawing layer pool set those
697  // attributes as hard attributes to preserve them for saving
698  const SfxItemPool& rItemPool = pModel->GetItemPool();
699  const SvxFontHeightItem& rDefaultFontHeight = rItemPool.GetDefaultItem(EE_CHAR_FONTHEIGHT);
700 
701  // SW should have no MasterPages
702  OSL_ENSURE(0 == pModel->GetMasterPageCount(), "SW with MasterPages (!)");
703 
704  for(sal_uInt16 a(0); a < pModel->GetPageCount(); a++)
705  {
706  const SdrPage* pPage = pModel->GetPage(a);
707  SdrObjListIter aIter(pPage, SdrIterMode::DeepNoGroups);
708 
709  while(aIter.IsMore())
710  {
711  SdrObject* pObj = aIter.Next();
712  const SvxFontHeightItem& rItem = pObj->GetMergedItem(EE_CHAR_FONTHEIGHT);
713 
714  if(rItem.GetHeight() == rDefaultFontHeight.GetHeight())
715  {
716  pObj->SetMergedItem(rDefaultFontHeight);
717  }
718  }
719  }
720 
721  {
722  uno::Reference<io::XOutputStream> xDocOut( new utl::OOutputStreamWrapper( *xStream ) );
723  SvxDrawingLayerExport( pModel, xDocOut );
724  }
725 
726  bRet = ERRCODE_NONE == xStream->GetError();
727  }
728  break;
729 
731  {
732  SfxObjectShell* pEmbObj = static_cast<SfxObjectShell*>(pObject);
733  try
734  {
735  ::utl::TempFile aTempFile;
736  aTempFile.EnableKillingFile();
737  uno::Reference< embed::XStorage > xWorkStore =
738  ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
739 
740  // write document storage
741  pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, false );
742  // mba: no BaseURL for clipboard
743  SfxMedium aMedium( xWorkStore, OUString() );
744  pEmbObj->DoSaveObjectAs( aMedium, false );
745  pEmbObj->DoSaveCompleted();
746 
747  uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
748  if ( xTransact.is() )
749  xTransact->commit();
750 
751  std::unique_ptr<SvStream> pSrcStm(::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), StreamMode::READ ));
752  if( pSrcStm )
753  {
754  xStream->SetBufferSize( 0xff00 );
755  xStream->WriteStream( *pSrcStm );
756  pSrcStm.reset();
757  }
758 
759  xWorkStore->dispose();
760  xWorkStore.clear();
761  }
762  catch (const uno::Exception&)
763  {
764  }
765 
766  bRet = ( xStream->GetError() == ERRCODE_NONE );
767  }
768  break;
769 
771  {
772  xStream->SetBufferSize( 1024 );
773  SwTransferDdeLink* pDdeLnk = static_cast<SwTransferDdeLink*>(pObject);
774  if( pDdeLnk->WriteData( *xStream ) )
775  {
776  bRet = ERRCODE_NONE == xStream->GetError();
777  }
778  }
779  break;
780 
782  {
783  // LOK is interested in getting images embedded for copy/paste support.
784  GetHTMLWriter( comphelper::LibreOfficeKit::isActive() ? OUString("EmbedImages") : OUString(), OUString(), xWrt );
785  break;
786  }
787 
790  GetRTFWriter(OUString(), OUString(), xWrt);
791  break;
792 
794  GetASCWriter(OUString(), OUString(), xWrt);
795  if( xWrt.is() )
796  {
797  SwAsciiOptions aAOpt;
798  aAOpt.SetCharSet( RTL_TEXTENCODING_UTF8 );
799  xWrt->SetAsciiOptions( aAOpt );
800 
801  // no start char for clipboard
802  xWrt->m_bUCS2_WithStartChar = false;
803  }
804  break;
805  default: break;
806  }
807 
808  if( xWrt.is() )
809  {
810  SwDoc* pDoc = static_cast<SwDoc*>(pObject);
811  xWrt->m_bWriteClipboardDoc = true;
812  xWrt->m_bWriteOnlyFirstTable = bool(TransferBufferType::Table & m_eBufferType);
813  xWrt->SetShowProgress(false);
814 
815 #if defined(DEBUGPASTE)
816  SvFileStream aPasteDebug(OUString(
817  "PASTEBUFFER.debug"), StreamMode::WRITE|StreamMode::TRUNC);
818  SwWriter aDbgWrt( aPasteDebug, *pDoc );
819  aDbgWrt.Write( xWrt );
820 #endif
821 
822  SwWriter aWrt( *xStream, *pDoc );
823  if( ! aWrt.Write( xWrt ).IsError() )
824  {
825  xStream->WriteChar( '\0' ); // terminate with a zero
826  bRet = true;
827  }
828  }
829 
830  return bRet;
831 }
832 
834 {
835  int nRet = Copy( true );
836  if( nRet )
837  DeleteSelection();
838  collectUIInformation("CUT", "parameter");
839  return nRet;
840 }
841 
843 {
844  if(!m_pWrtShell)
845  return;
846  // ask for type of selection before action-bracketing
847  const SelectionType nSelection = m_pWrtShell->GetSelectionType();
848  // cut rows or columns selected by enhanced table selection and wholly selected tables
849  bool bCutMode = ( SelectionType::TableCell & nSelection ) && ( (SelectionType::TableRow | SelectionType::TableCol) & nSelection ||
851 
853  if( bCutMode )
854  {
855  if( !(SelectionType::TableCol & nSelection) )
857  else
858  {
860  pDispatch->Execute(FN_TABLE_DELETE_COL, SfxCallMode::SYNCHRON);
861  }
862  }
863  else
864  {
865  if( ( SelectionType::Text | SelectionType::Table ) & nSelection )
866  m_pWrtShell->IntelligentCut( nSelection );
868  }
870 }
871 
872 static void DeleteDDEMarks(SwDoc & rDest)
873 {
874  IDocumentMarkAccess *const pMarkAccess = rDest.getIDocumentMarkAccess();
875  std::vector< ::sw::mark::IMark* > vDdeMarks;
876  // find all DDE-Bookmarks
877  for (IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAllMarksBegin();
878  ppMark != pMarkAccess->getAllMarksEnd();
879  ++ppMark)
880  {
882  {
883  vDdeMarks.push_back(*ppMark);
884  }
885  }
886  // remove all DDE-Bookmarks, they are invalid inside the clipdoc!
887  for (const auto& rpMark : vDdeMarks)
888  {
889  pMarkAccess->deleteMark(rpMark);
890  }
891 }
892 
894 {
895  std::unique_ptr<SwWait> pWait;
896  if (m_pWrtShell->ShouldWait())
897  {
898  pWait.reset(new SwWait( *m_pWrtShell->GetView().GetDocShell(), true ));
899  }
900 
901  m_pClpDocFac.reset(new SwDocFac);
902 
903  SwDoc& rDest(lcl_GetDoc(*m_pClpDocFac));
904  rDest.getIDocumentFieldsAccess().LockExpFields(); // Never update fields - leave text as is
905  {
906  SwDoc const& rSrc(*m_pWrtShell->GetDoc());
907  assert(&rSrc == &rPaM.GetDoc());
908 
909  rDest.ReplaceCompatibilityOptions(rSrc);
910  rDest.ReplaceDefaults(rSrc);
911 
912  //It would probably make most sense here to only insert the styles used
913  //by the selection, e.g. apply SwDoc::IsUsed on styles ?
914  rDest.ReplaceStyles(rSrc, false);
915 
916  // relevant bits of rSrcWrtShell.Copy(rDest);
917  rDest.GetIDocumentUndoRedo().DoUndo(false); // always false!
919 
920  SwNodeIndex const aIdx(rDest.GetNodes().GetEndOfContent(), -1);
921  SwContentNode *const pContentNode(aIdx.GetNode().GetContentNode());
922  SwPosition aPos(aIdx,
923  SwIndex(pContentNode, pContentNode ? pContentNode->Len() : 0));
924 
926 
928 
930  }
931 
932  DeleteDDEMarks(rDest);
933 
934  // a new one was created in core (OLE objects copied!)
935  m_aDocShellRef = rDest.GetTmpDocShell();
936  if (m_aDocShellRef.Is())
938  rDest.SetTmpDocShell( nullptr );
939 
940  // let's add some formats
941  AddFormat( SotClipboardFormatId::EMBED_SOURCE );
942  AddFormat( SotClipboardFormatId::RTF );
943 #if HAVE_FEATURE_DESKTOP
944  AddFormat( SotClipboardFormatId::RICHTEXT );
945  AddFormat( SotClipboardFormatId::HTML );
946 #endif
947  AddFormat( SotClipboardFormatId::STRING );
948 }
949 
951 {
952  int nRet = 1;
953  if(!m_pWrtShell)
954  return 0;
955 
958 
959  if ( m_pWrtShell->GetTableCopied() )
960  m_pWrtShell->SetTableCopied( false );
961 
962  OUString sGrfNm;
963  const SelectionType nSelection = m_pWrtShell->GetSelectionType();
964  if( nSelection == SelectionType::Graphic )
965  {
966  m_pClpGraphic.reset(new Graphic);
967  if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::GDIMETAFILE, *m_pClpGraphic ))
969  m_pClpBitmap.reset(new Graphic);
970  if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::BITMAP, *m_pClpBitmap ))
972 
973  m_pClpDocFac.reset(new SwDocFac);
974  SwDoc& rDoc = lcl_GetDoc(*m_pClpDocFac);
975  m_pWrtShell->Copy(rDoc);
976 
977 #if HAVE_FEATURE_DESKTOP
979  AddFormat( SotClipboardFormatId::SVXB );
980 #endif
981 
983  AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
984 
985  const Graphic* pGrf = m_pWrtShell->GetGraphic();
986  if( pGrf && pGrf->IsSupportedGraphic() )
987  {
988  AddFormat( SotClipboardFormatId::PNG );
989 #if HAVE_FEATURE_DESKTOP
990  AddFormat( SotClipboardFormatId::GDIMETAFILE );
991  AddFormat( SotClipboardFormatId::BITMAP );
992 #endif
993  }
995  m_pWrtShell->GetGrfNms( &sGrfNm, nullptr );
996  }
997  else if ( nSelection == SelectionType::Ole )
998  {
999  m_pClpDocFac.reset(new SwDocFac);
1000  SwDoc& rDoc = lcl_GetDoc(*m_pClpDocFac);
1001  m_aDocShellRef = new SwDocShell(rDoc, SfxObjectCreateMode::EMBEDDED);
1003  m_pWrtShell->Copy(rDoc);
1004 
1005  AddFormat( SotClipboardFormatId::EMBED_SOURCE );
1006 
1007  // --> OD #i98753#
1008  // set size of embedded object at the object description structure
1009  m_aObjDesc.maSize = OutputDevice::LogicToLogic(m_pWrtShell->GetObjSize(), MapMode(MapUnit::MapTwip), MapMode(MapUnit::Map100thMM));
1010  // <--
1012 
1013 #if HAVE_FEATURE_DESKTOP
1014  AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
1015  AddFormat( SotClipboardFormatId::GDIMETAFILE );
1016 
1017  // Fetch the formats supported via embedtransferhelper as well
1018  sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
1019  uno::Reference < embed::XEmbeddedObject > xObj = FindOLEObj( nAspect );
1020  const Graphic* pOLEGraph = FindOLEReplacementGraphic();
1021  if( xObj.is() )
1022  {
1023  TransferableDataHelper aD( new SvEmbedTransferHelper( xObj, pOLEGraph, nAspect ) );
1024  if ( aD.GetTransferable().is() )
1025  {
1026  DataFlavorExVector aVector( aD.GetDataFlavorExVector() );
1027 
1028  for( const auto& rItem : aVector )
1029  AddFormat( rItem );
1030  }
1031  }
1032 #endif
1034  }
1035  // Is there anything to provide anyway?
1036  else if ( m_pWrtShell->IsSelection() || m_pWrtShell->IsFrameSelected() ||
1038  {
1039  std::unique_ptr<SwWait> pWait;
1040  if( m_pWrtShell->ShouldWait() )
1041  pWait.reset(new SwWait( *m_pWrtShell->GetView().GetDocShell(), true ));
1042 
1043  m_pClpDocFac.reset(new SwDocFac);
1044 
1045  // create additional cursor so that equal treatment of keyboard
1046  // and mouse selection is possible.
1047  // In AddMode with keyboard selection, the new cursor is not created
1048  // before the cursor is moved after end of selection.
1049  if( m_pWrtShell->IsAddMode() && m_pWrtShell->SwCursorShell::HasSelection() )
1051 
1052  SwDoc& rTmpDoc = lcl_GetDoc(*m_pClpDocFac);
1053 
1054  rTmpDoc.getIDocumentFieldsAccess().LockExpFields(); // Never update fields - leave text as is
1055  lclOverWriteDoc(*m_pWrtShell, rTmpDoc);
1056 
1057  DeleteDDEMarks(rTmpDoc);
1058 
1059  // a new one was created in CORE (OLE objects copied!)
1060  m_aDocShellRef = rTmpDoc.GetTmpDocShell();
1061  if( m_aDocShellRef.Is() )
1063  rTmpDoc.SetTmpDocShell( nullptr );
1064 
1065  if( m_pWrtShell->IsObjSelected() )
1067  else
1068  {
1070  if (m_pWrtShell->IntelligentCut(nSelection, false) != SwWrtShell::NO_WORD)
1072  }
1073 
1074  bool bDDELink = m_pWrtShell->IsSelection();
1075  if( nSelection & SelectionType::TableCell )
1076  {
1078  bDDELink = m_pWrtShell->HasWholeTabSelection();
1079 
1080  m_pWrtShell->SetTableCopied(true);
1081 
1082  if ( bIsCut && (SelectionType::TableRow | SelectionType::TableCol) & nSelection )
1084  }
1085 
1086 #if HAVE_FEATURE_DESKTOP
1087  //When someone needs it, we 'OLE' him something
1088  AddFormat( SotClipboardFormatId::EMBED_SOURCE );
1089 #endif
1090 
1091  //put RTF ahead of the OLE's Metafile to have less loss
1092  if( !m_pWrtShell->IsObjSelected() )
1093  {
1094  AddFormat( SotClipboardFormatId::RTF );
1095 #if HAVE_FEATURE_DESKTOP
1096  AddFormat( SotClipboardFormatId::RICHTEXT );
1097  AddFormat( SotClipboardFormatId::HTML );
1098 #endif
1099  }
1100  if( m_pWrtShell->IsSelection() )
1101  AddFormat( SotClipboardFormatId::STRING );
1102 
1103  if( nSelection & ( SelectionType::DrawObject | SelectionType::DbForm ))
1104  {
1105  AddFormat( SotClipboardFormatId::DRAWING );
1106  if ( nSelection & SelectionType::DrawObject )
1107  {
1108 #if HAVE_FEATURE_DESKTOP
1109  AddFormat( SotClipboardFormatId::GDIMETAFILE );
1110  AddFormat( SotClipboardFormatId::BITMAP );
1111 #endif
1112  AddFormat( SotClipboardFormatId::PNG );
1113  }
1115 
1116  m_pClpGraphic.reset(new Graphic);
1117  if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::GDIMETAFILE, *m_pClpGraphic ))
1118  m_pOrigGraphic = m_pClpGraphic.get();
1119  m_pClpBitmap.reset(new Graphic);
1120  if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::BITMAP, *m_pClpBitmap ))
1121  m_pOrigGraphic = m_pClpBitmap.get();
1122 
1123  // is it a URL-Button ?
1124  OUString sURL;
1125  OUString sDesc;
1126  if( m_pWrtShell->GetURLFromButton( sURL, sDesc ) )
1127  {
1128  AddFormat( SotClipboardFormatId::STRING );
1129 #if HAVE_FEATURE_DESKTOP
1130  AddFormat( SotClipboardFormatId::SOLK );
1131  AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
1132  AddFormat( SotClipboardFormatId::FILECONTENT );
1133  AddFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR );
1134 #endif
1135  AddFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR );
1137  nRet = 1;
1138  }
1139  }
1140 
1141  // at Cut, DDE-Link doesn't make sense!!
1142  SwDocShell* pDShell;
1143  if( !bIsCut && bDDELink &&
1144  nullptr != ( pDShell = m_pWrtShell->GetDoc()->GetDocShell()) &&
1145  SfxObjectCreateMode::STANDARD == pDShell->GetCreateMode() )
1146  {
1147 #if HAVE_FEATURE_DESKTOP
1148  AddFormat( SotClipboardFormatId::LINK );
1149 #endif
1150  m_xDdeLink = new SwTransferDdeLink( *this, *m_pWrtShell );
1151  }
1152 
1153  //ObjectDescriptor was already filly from the old DocShell.
1154  //Now adjust it. Thus in GetData the first query can still
1155  //be answered with delayed rendering.
1156  Size aSz( OLESIZE );
1157  m_aObjDesc.maSize = OutputDevice::LogicToLogic(aSz, MapMode(MapUnit::MapTwip), MapMode(MapUnit::Map100thMM));
1158 
1160 #if HAVE_FEATURE_DESKTOP
1161  AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
1162 #endif
1163  }
1164  else
1165  nRet = 0;
1166 
1167  if( m_pWrtShell->IsFrameSelected() )
1168  {
1170  m_pWrtShell->GetFlyFrameAttr( aSet );
1171  const SwFormatURL& rURL = aSet.Get( RES_URL );
1172  if( rURL.GetMap() )
1173  {
1174  m_pImageMap.reset( new ImageMap( *rURL.GetMap() ) );
1175  AddFormat( SotClipboardFormatId::SVIM );
1176  }
1177  else if( !rURL.GetURL().isEmpty() )
1178  {
1179  m_pTargetURL.reset(new INetImage( sGrfNm, rURL.GetURL(),
1180  rURL.GetTargetFrameName() ));
1181  AddFormat( SotClipboardFormatId::INET_IMAGE );
1182  }
1183  }
1184 
1185  return nRet;
1186 }
1187 
1188 int SwTransferable::Copy( bool bIsCut )
1189 {
1191  return 0;
1192 
1193  int nRet = PrepareForCopy( bIsCut );
1194  if ( nRet )
1195  {
1197  }
1198 
1199  if( !bIsCut ){
1200  collectUIInformation("COPY", "parameter");
1201  }
1202 
1203  return nRet;
1204 }
1205 
1207 {
1208  if(!m_pWrtShell)
1209  return;
1210  SwWait aWait( *m_pWrtShell->GetView().GetDocShell(), true );
1211 
1212  OUString aStr( m_pWrtShell->Calculate() );
1213 
1214  m_pClpDocFac.reset(new SwDocFac);
1215  SwDoc& rDoc = lcl_GetDoc(*m_pClpDocFac);
1216  m_pWrtShell->Copy(rDoc, &aStr);
1218  AddFormat( SotClipboardFormatId::STRING );
1219 
1221 }
1222 
1223 bool SwTransferable::CopyGlossary( SwTextBlocks& rGlossary, const OUString& rStr )
1224 {
1225  if(!m_pWrtShell)
1226  return false;
1227  SwWait aWait( *m_pWrtShell->GetView().GetDocShell(), true );
1228 
1229  m_pClpDocFac.reset(new SwDocFac);
1230  SwDoc& rCDoc = lcl_GetDoc(*m_pClpDocFac);
1231 
1232  SwNodes& rNds = rCDoc.GetNodes();
1233  SwNodeIndex aNodeIdx( *rNds.GetEndOfContent().StartOfSectionNode() );
1234  SwContentNode* pCNd = rNds.GoNext( &aNodeIdx ); // go to 1st ContentNode
1235  SwPaM aPam( *pCNd );
1236 
1237  rCDoc.getIDocumentFieldsAccess().LockExpFields(); // never update fields - leave text as it is
1238 
1239  rCDoc.InsertGlossary( rGlossary, rStr, aPam );
1240 
1241  // a new one was created in CORE (OLE-Objects copied!)
1242  m_aDocShellRef = rCDoc.GetTmpDocShell();
1243  if( m_aDocShellRef.Is() )
1245  rCDoc.SetTmpDocShell( nullptr );
1246 
1248 
1249  //When someone needs it, we 'OLE' her something.
1250  AddFormat( SotClipboardFormatId::EMBED_SOURCE );
1251  AddFormat( SotClipboardFormatId::RTF );
1252  AddFormat( SotClipboardFormatId::RICHTEXT );
1253  AddFormat( SotClipboardFormatId::HTML );
1254  AddFormat( SotClipboardFormatId::STRING );
1255 
1256  //ObjectDescriptor was already filled from the old DocShell.
1257  //Now adjust it. Thus in GetData the first query can still
1258  //be answered with delayed rendering.
1259  Size aSz( OLESIZE );
1260  m_aObjDesc.maSize = OutputDevice::LogicToLogic(aSz, MapMode(MapUnit::MapTwip), MapMode(MapUnit::Map100thMM));
1261 
1263  AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
1264 
1266 
1267  return true;
1268 }
1269 
1270 static uno::Reference < XTransferable > * lcl_getTransferPointer ( uno::Reference < XTransferable > &xRef )
1271 {
1272  return &xRef;
1273 }
1274 
1276  : m_rWrtShell(rWrtShell)
1277 {
1278  remember();
1279 }
1280 
1282 {
1284  return;
1285 
1286  SwPaM* pCursor = m_rWrtShell.GetCursor();
1287  if (!pCursor)
1288  return;
1289 
1290  // Set point to the previous node, so it is not moved.
1291  const SwNodeIndex& rNodeIndex = pCursor->GetPoint()->nNode;
1292  m_pPaM.reset(new SwPaM(rNodeIndex, rNodeIndex, 0, -1));
1293  m_nStartContent = pCursor->GetPoint()->nContent.GetIndex();
1294 }
1295 
1296 void SwPasteContext::forget() { m_pPaM.reset(); }
1297 
1299 {
1300  try
1301  {
1303  return;
1304 
1305  beans::PropertyValue aPropertyValue;
1306 
1307  switch (m_rWrtShell.GetView().GetShellMode())
1308  {
1309  case ShellMode::Graphic:
1310  {
1312  if (!pFormat)
1313  return;
1314 
1315  aPropertyValue.Name = "TextGraphicObject";
1316  aPropertyValue.Value
1317  <<= SwXTextGraphicObject::CreateXTextGraphicObject(*pFormat->GetDoc(), pFormat);
1318  break;
1319  }
1320 
1321  default:
1322  {
1323  if (!m_pPaM)
1324  return;
1325 
1326  SwPaM* pCursor = m_rWrtShell.GetCursor();
1327  if (!pCursor)
1328  return;
1329 
1330  if (!pCursor->GetPoint()->nNode.GetNode().IsTextNode())
1331  // Non-text was pasted.
1332  return;
1333 
1334  // Update mark after paste.
1335  *m_pPaM->GetMark() = *pCursor->GetPoint();
1336 
1337  // Restore point.
1338  ++m_pPaM->GetPoint()->nNode;
1339  SwNode& rNode = m_pPaM->GetNode();
1340  if (!rNode.IsTextNode())
1341  // Starting point is no longer text.
1342  return;
1343 
1344  m_pPaM->GetPoint()->nContent.Assign(static_cast<SwContentNode*>(&rNode),
1345  m_nStartContent);
1346 
1347  aPropertyValue.Name = "TextRange";
1348  const uno::Reference<text::XTextRange> xTextRange = SwXTextRange::CreateXTextRange(
1349  m_pPaM->GetDoc(), *m_pPaM->GetPoint(), m_pPaM->GetMark());
1350  aPropertyValue.Value <<= xTextRange;
1351  break;
1352  }
1353  }
1354 
1355  if (aPropertyValue.Name.isEmpty())
1356  return;
1357 
1358  // Invoke the listeners.
1359  uno::Sequence<beans::PropertyValue> aEvent{ aPropertyValue };
1360 
1362  while (it.hasMoreElements())
1363  {
1364  uno::Reference<text::XPasteListener> xListener(it.next(), UNO_QUERY);
1365  if (xListener.is())
1366  xListener->notifyPasteEvent(aEvent);
1367  }
1368  }
1369  catch (const uno::Exception& rException)
1370  {
1371  SAL_WARN("sw",
1372  "SwPasteContext::~SwPasteContext: uncaught exception: " << rException.Message);
1373  }
1374 }
1375 
1377  const TransferableDataHelper& rData )
1378 {
1379  // Check the common case first: We can always paste our own data!
1380  // If _only_ the internal format can be pasted, this check will
1381  // yield 'true', while the one below would give a (wrong) result 'false'.
1382 
1383  bool bIsPaste = ( GetSwTransferable( rData ) != nullptr );
1384 
1385  // if it's not our own data, we need to have a closer look:
1386  if( ! bIsPaste )
1387  {
1388  // determine the proper paste action, and return true if we find one
1389  uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
1390 
1391  SotExchangeDest nDestination = SwTransferable::GetSotDestination( rSh );
1392  sal_uInt16 nSourceOptions =
1393  (( SotExchangeDest::DOC_TEXTFRAME == nDestination ||
1394  SotExchangeDest::SWDOC_FREE_AREA == nDestination ||
1395  SotExchangeDest::DOC_TEXTFRAME_WEB == nDestination ||
1396  SotExchangeDest::SWDOC_FREE_AREA_WEB == nDestination )
1399 
1400  SotClipboardFormatId nFormat; // output param for GetExchangeAction
1401  sal_uInt8 nEventAction; // output param for GetExchangeAction
1403  rData.GetDataFlavorExVector(),
1404  nDestination,
1405  nSourceOptions, /* ?? */
1406  EXCHG_IN_ACTION_DEFAULT, /* ?? */
1407  nFormat, nEventAction, SotClipboardFormatId::NONE,
1408  lcl_getTransferPointer ( xTransferable ) );
1409 
1410  // if we find a suitable action, we can paste!
1411  bIsPaste = (EXCHG_INOUT_ACTION_NONE != nAction);
1412  }
1413 
1414  return bIsPaste;
1415 }
1416 
1418  SotClipboardFormatId& nFormat)
1419 {
1420  if (nFormat != SotClipboardFormatId::RICHTEXT)
1421  {
1422  return;
1423  }
1424 
1425  if (!rData.HasFormat(SotClipboardFormatId::EMBED_SOURCE))
1426  {
1427  return;
1428  }
1429 
1430  if (!rData.HasFormat(SotClipboardFormatId::OBJECTDESCRIPTOR))
1431  {
1432  return;
1433  }
1434 
1436  if (!rData.GetTransferableObjectDescriptor(SotClipboardFormatId::OBJECTDESCRIPTOR, aObjDesc))
1437  {
1438  return;
1439  }
1440 
1441  if (aObjDesc.maClassName != SvGlobalName(SO3_SW_CLASSID))
1442  {
1443  return;
1444  }
1445 
1446  // At this point we know that we paste from Writer to Writer and the clipboard has the content
1447  // in both RTF and ODF formats. Prefer ODF in this case.
1448  nAction = EXCHG_OUT_ACTION_INSERT_OLE;
1449  nFormat = SotClipboardFormatId::EMBED_SOURCE;
1450 }
1451 
1452 bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndStdIds nAnchorType, bool bIgnoreComments, PasteTableType ePasteTable)
1453 {
1454  SwPasteContext aPasteContext(rSh);
1455 
1456  sal_uInt8 nAction=0;
1457  SotExchangeDest nDestination = SwTransferable::GetSotDestination( rSh );
1458  SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
1459  SotExchangeActionFlags nActionFlags = SotExchangeActionFlags::NONE;
1460  bool bSingleCellTable = false;
1461 
1462  if( GetSwTransferable( rData ) )
1463  {
1465  }
1466  else
1467  {
1468  sal_uInt16 nSourceOptions =
1469  (( SotExchangeDest::DOC_TEXTFRAME == nDestination ||
1470  SotExchangeDest::SWDOC_FREE_AREA == nDestination ||
1471  SotExchangeDest::DOC_TEXTFRAME_WEB == nDestination ||
1472  SotExchangeDest::SWDOC_FREE_AREA_WEB == nDestination )
1475  uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
1476  sal_uInt8 nEventAction;
1478  rData.GetDataFlavorExVector(),
1479  nDestination,
1480  nSourceOptions, /* ?? */
1481  EXCHG_IN_ACTION_DEFAULT, /* ?? */
1482  nFormat, nEventAction, SotClipboardFormatId::NONE,
1483  lcl_getTransferPointer ( xTransferable ),
1484  &nActionFlags );
1485  }
1486 
1487  // tdf#37223 avoid non-native insertion of Calc worksheets in the following cases:
1488  // content of 1-cell worksheets are inserted as simple text using RTF format,
1489  // bigger worksheets within native (Writer) table cells are inserted as native tables,
1490  // ie. cell by cell instead of embedding the worksheet in a single cell of the Writer table
1491  if ( EXCHG_IN_ACTION_COPY == nAction && ( rData.HasFormat( SotClipboardFormatId::SYLK ) ||
1492  rData.HasFormat( SotClipboardFormatId::SYLK_BIGCAPS ) ) )
1493  {
1494  // is it a 1-cell worksheet?
1495  OUString aExpand;
1496  if( rData.GetString( SotClipboardFormatId::STRING, aExpand ))
1497  {
1498  const sal_Int32 nNewlines{comphelper::string::getTokenCount(aExpand, '\n')};
1499  const sal_Int32 nRows = nNewlines ? nNewlines-1 : 0;
1500  if ( nRows == 1 )
1501  {
1502  const sal_Int32 nCols = comphelper::string::getTokenCount(aExpand.getToken(0, '\n'), '\t');
1503  if (nCols == 1)
1504  bSingleCellTable = true;
1505  }
1506  }
1507 
1508  // convert the worksheet to a temporary native table using HTML format, and copy that into the original native table
1509  if (!bSingleCellTable && rData.HasFormat( SotClipboardFormatId::HTML ) &&
1510  rSh.GetDoc()->IsIdxInTable(rSh.GetCursor()->GetNode()) != nullptr && rSh.DoesUndo())
1511  {
1512  SfxDispatcher* pDispatch = rSh.GetView().GetViewFrame()->GetDispatcher();
1513  sal_uInt32 nLevel = 0;
1514  // within Writer table cells, inserting worksheets using HTML format results only plain text, not a native table,
1515  // so remove all outer nested tables temporary to get a working insertion point
1516  // (RTF format has no such problem, but that inserts the hidden rows of the original Calc worksheet, too)
1517  do
1518  {
1519  // insert a random character to redo the place of the insertion at the end
1520  pDispatch->Execute(FN_INSERT_NNBSP, SfxCallMode::SYNCHRON);
1521  pDispatch->Execute(FN_TABLE_DELETE_TABLE, SfxCallMode::SYNCHRON);
1522  nLevel++;
1523  } while (rSh.GetDoc()->IsIdxInTable(rSh.GetCursor()->GetNode()) != nullptr);
1524  if ( SwTransferable::PasteData( rData, rSh, EXCHG_OUT_ACTION_INSERT_STRING, nActionFlags, SotClipboardFormatId::HTML,
1525  nDestination, false, false, nullptr, 0, false, nAnchorType, bIgnoreComments, &aPasteContext, ePasteTable) )
1526  {
1527  bool bFoundTemporaryTable = false;
1528  pDispatch->Execute(FN_LINE_UP, SfxCallMode::SYNCHRON);
1529  if (rSh.GetDoc()->IsIdxInTable(rSh.GetCursor()->GetNode()) != nullptr)
1530  {
1531  bFoundTemporaryTable = true;
1532  pDispatch->Execute(FN_TABLE_SELECT_ALL, SfxCallMode::SYNCHRON);
1533  pDispatch->Execute(SID_COPY, SfxCallMode::SYNCHRON);
1534  }
1535  for(sal_uInt32 a = 0; a < 1 + (nLevel * 2); a++)
1536  pDispatch->Execute(SID_UNDO, SfxCallMode::SYNCHRON);
1537  // clipboard content hasn't changed (limit potential infinite
1538  // recursion with the same non-native table, as was in tdf#138688)
1539  if (!bFoundTemporaryTable)
1540  return false;
1541  if (ePasteTable == PasteTableType::PASTE_TABLE)
1542  pDispatch->Execute(FN_PASTE_NESTED_TABLE, SfxCallMode::SYNCHRON);
1543  else if (ePasteTable == PasteTableType::PASTE_ROW)
1544  pDispatch->Execute(FN_TABLE_PASTE_ROW_BEFORE, SfxCallMode::SYNCHRON);
1545  else if (ePasteTable == PasteTableType::PASTE_COLUMN)
1546  pDispatch->Execute(FN_TABLE_PASTE_COL_BEFORE, SfxCallMode::SYNCHRON);
1547  else
1548  pDispatch->Execute(SID_PASTE, SfxCallMode::SYNCHRON);
1549  return true;
1550  } else {
1551  for(sal_uInt32 a = 0; a < (nLevel * 2); a++)
1552  pDispatch->Execute(SID_UNDO, SfxCallMode::SYNCHRON);
1553  }
1554  }
1555  }
1556  // insert clipboard content as new table rows/columns before the actual row/column instead of overwriting it
1557  else if ( (rSh.GetTableInsertMode() != SwTable::SEARCH_NONE || ePasteTable == PasteTableType::PASTE_ROW || ePasteTable == PasteTableType::PASTE_COLUMN) &&
1558  rData.HasFormat( SotClipboardFormatId::HTML ) &&
1559  rSh.GetDoc()->IsIdxInTable(rSh.GetCursor()->GetNode()) != nullptr )
1560  {
1561  OUString aExpand;
1562  sal_Int32 nIdx;
1563  bool bRowMode = rSh.GetTableInsertMode() == SwTable::SEARCH_ROW || ePasteTable == PasteTableType::PASTE_ROW;
1564  if( rData.GetString( SotClipboardFormatId::HTML, aExpand ) && (nIdx = aExpand.indexOf("<table")) > -1 )
1565  {
1566  // table rows with span use also tbody
1567  bool bShifted = aExpand.indexOf("<tbody>") > -1;
1568  // calculate count of selected rows or columns
1569  sal_Int32 nSelectedRowsOrCols = 0;
1570  const OUString sSearchRowOrCol = bRowMode ? OUString("</tr>") : OUString("<col ");
1571  while((nIdx = aExpand.indexOf(sSearchRowOrCol, nIdx)) > -1)
1572  {
1573  // skip rows/columns of nested tables, based on HTML indentation
1574  if (nIdx > 2 && (aExpand[nIdx-1] != '\t' || aExpand[nIdx-2] != '\t' || (bShifted && aExpand[nIdx-3] != '\t')))
1575  ++nSelectedRowsOrCols;
1576  ++nIdx;
1577  }
1578  // are we at the beginning of the cell?
1579  bool bStartTableBoxNode =
1580  // first paragraph of the cell?
1581  rSh.GetCursor()->GetNode().GetIndex() == rSh.GetCursor()->GetNode().FindTableBoxStartNode()->GetIndex()+1 &&
1582  // beginning of the paragraph?
1583  !rSh.GetCursor()->GetPoint()->nContent.GetIndex();
1584  SfxDispatcher* pDispatch = rSh.GetView().GetViewFrame()->GetDispatcher();
1585 
1586  // go start of the cell
1587  if (!bStartTableBoxNode)
1588  pDispatch->Execute(FN_START_OF_DOCUMENT, SfxCallMode::SYNCHRON);
1589 
1590  // store cursor position in row mode
1591  ::sw::mark::IMark* pMark = (!bRowMode || nSelectedRowsOrCols == 0) ? nullptr : rSh.SetBookmark(
1592  vcl::KeyCode(),
1593  OUString(),
1595 
1596  // add a new empty row/column before the actual table row/column and go there
1597  const sal_uInt16 nDispatchSlot = bRowMode ? FN_TABLE_INSERT_ROW_BEFORE : FN_TABLE_INSERT_COL_BEFORE;
1598  pDispatch->Execute(nDispatchSlot, SfxCallMode::SYNCHRON);
1599  pDispatch->Execute(bRowMode ? FN_LINE_UP : FN_CHAR_LEFT, SfxCallMode::SYNCHRON);
1600 
1601  // add the other new empty rows/columns after the actual table row/column
1602  if ( nSelectedRowsOrCols > 1 )
1603  {
1604  SfxUInt16Item aCountItem( nDispatchSlot, nSelectedRowsOrCols-1 );
1605  SfxBoolItem aAfter( FN_PARAM_INSERT_AFTER, true );
1606  pDispatch->ExecuteList(nDispatchSlot,
1607  SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
1608  { &aCountItem, &aAfter });
1609  }
1610 
1611  // paste rows
1612  bool bResult = SwTransferable::PasteData( rData, rSh, nAction, nActionFlags, nFormat,
1613  nDestination, false, false, nullptr, 0, false, nAnchorType, bIgnoreComments, &aPasteContext );
1614 
1615  // restore cursor position
1616  if (pMark != nullptr)
1617  {
1618  rSh.GotoMark( pMark );
1619  rSh.getIDocumentMarkAccess()->deleteMark( pMark );
1620  }
1621 
1622  return bResult;
1623  }
1624  }
1625 
1626  // special case for tables from draw application or 1-cell tables
1627  if( EXCHG_OUT_ACTION_INSERT_DRAWOBJ == nAction || bSingleCellTable )
1628  {
1629  if( rData.HasFormat( SotClipboardFormatId::RTF ) )
1630  {
1632  nFormat = SotClipboardFormatId::RTF;
1633  }
1634  else if( rData.HasFormat( SotClipboardFormatId::RICHTEXT ) )
1635  {
1637  nFormat = SotClipboardFormatId::RICHTEXT;
1638  }
1639  }
1640 
1641  // Tweak the format if necessary: the source application can be considered in this context,
1642  // while not in sot/ code.
1643  SwTransferable::SelectPasteFormat(rData, nAction, nFormat);
1644 
1645  collectUIInformation("PASTE", "parameter");
1646 
1647  return EXCHG_INOUT_ACTION_NONE != nAction &&
1648  SwTransferable::PasteData( rData, rSh, nAction, nActionFlags, nFormat,
1649  nDestination, false, false, nullptr, 0, false, nAnchorType, bIgnoreComments, &aPasteContext, ePasteTable);
1650 }
1651 
1653  SwWrtShell& rSh, sal_uInt8 nAction, SotExchangeActionFlags nActionFlags,
1654  SotClipboardFormatId nFormat,
1655  SotExchangeDest nDestination, bool bIsPasteFormat,
1656  bool bIsDefault,
1657  const Point* pPt, sal_Int8 nDropAction,
1658  bool bPasteSelection, RndStdIds nAnchorType,
1659  bool bIgnoreComments,
1660  SwPasteContext* pContext,
1661  PasteTableType ePasteTable )
1662 {
1663  SwWait aWait( *rSh.GetView().GetDocShell(), false );
1664  std::unique_ptr<SwTrnsfrActionAndUndo, o3tl::default_delete<SwTrnsfrActionAndUndo>> pAction;
1665  SwModule* pMod = SW_MOD();
1666 
1667  bool bRet = false;
1668  bool bCallAutoCaption = false;
1669 
1670  if( pPt )
1671  {
1672  // external Drop
1673  if( bPasteSelection ? !pMod->m_pXSelection : !pMod->m_pDragDrop )
1674  {
1675  switch( nDestination )
1676  {
1677  case SotExchangeDest::DOC_LNKD_GRAPH_W_IMAP:
1678  case SotExchangeDest::DOC_LNKD_GRAPHOBJ:
1679  case SotExchangeDest::DOC_GRAPH_W_IMAP:
1680  case SotExchangeDest::DOC_GRAPHOBJ:
1681  case SotExchangeDest::DOC_OLEOBJ:
1682  case SotExchangeDest::DOC_DRAWOBJ:
1683  case SotExchangeDest::DOC_URLBUTTON:
1684  case SotExchangeDest::DOC_GROUPOBJ:
1685  // select frames/objects
1686  SwTransferable::SetSelInShell( rSh, true, pPt );
1687  break;
1688 
1689  default:
1690  SwTransferable::SetSelInShell( rSh, false, pPt );
1691  break;
1692  }
1693  }
1694  }
1695  else if( ( !GetSwTransferable( rData ) || bIsPasteFormat ) &&
1696  !rSh.IsTableMode() && rSh.HasSelection() )
1697  {
1698  // then delete the selections
1699 
1700  //don't delete selected content
1701  // - at table-selection
1702  // - at ReRead of a graphic/DDEData
1703  // - at D&D, for the right selection was taken care of
1704  // in Drop-Handler
1705  bool bDelSel = false;
1706  switch( nDestination )
1707  {
1708  case SotExchangeDest::DOC_TEXTFRAME:
1709  case SotExchangeDest::SWDOC_FREE_AREA:
1710  case SotExchangeDest::DOC_TEXTFRAME_WEB:
1711  case SotExchangeDest::SWDOC_FREE_AREA_WEB:
1712  bDelSel = true;
1713  break;
1714  default:
1715  break;
1716  }
1717 
1718  if( bDelSel )
1719  // #i34830#
1720  pAction.reset(new SwTrnsfrActionAndUndo(&rSh, true, pContext));
1721  }
1722 
1723  SwTransferable *pTrans=nullptr, *pTunneledTrans=GetSwTransferable( rData );
1724 
1725  // check for private drop
1726  bool bPrivateDrop(pPt);
1727  if (bPrivateDrop)
1728  {
1729  if (bPasteSelection)
1730  pTrans = pMod->m_pXSelection;
1731  else
1732  pTrans = pMod->m_pDragDrop;
1733  bPrivateDrop = nullptr != pTrans;
1734  }
1735  bool bNeedToSelectBeforePaste(false);
1736 
1737  if(bPrivateDrop && DND_ACTION_LINK == nDropAction)
1738  {
1739  // internal drop on object, suppress bPrivateDrop to change internal fill
1740  bPrivateDrop = false;
1741  bNeedToSelectBeforePaste = true;
1742  }
1743 
1744  if(bPrivateDrop && pPt && DND_ACTION_MOVE == nDropAction)
1745  {
1746  // check if dragged over a useful target. If yes, use as content exchange
1747  // drop as if from external
1748  const SwFrameFormat* pSwFrameFormat = rSh.GetFormatFromObj(*pPt);
1749 
1750  if(dynamic_cast< const SwDrawFrameFormat* >(pSwFrameFormat))
1751  {
1752  bPrivateDrop = false;
1753  bNeedToSelectBeforePaste = true;
1754  }
1755  }
1756 
1757  if(bPrivateDrop)
1758  {
1759  // then internal Drag & Drop or XSelection
1760  bRet = pTrans->PrivateDrop( rSh, *pPt, DND_ACTION_MOVE == nDropAction,
1761  bPasteSelection );
1762  }
1763  else if( !pPt && pTunneledTrans &&
1764  EXCHG_OUT_ACTION_INSERT_PRIVATE == nAction )
1765  {
1766  // then internal paste
1767  bRet = pTunneledTrans->PrivatePaste(rSh, pContext, ePasteTable);
1768  }
1769  else if( EXCHG_INOUT_ACTION_NONE != nAction )
1770  {
1771  if( !pAction )
1772  {
1773  pAction.reset(new SwTrnsfrActionAndUndo( &rSh ));
1774  }
1775 
1776  // in Drag&Drop MessageBoxes must not be showed
1777  bool bMsg = nullptr == pPt;
1778 
1779  // delete selections
1780 
1781  switch( nAction )
1782  {
1784  OSL_ENSURE( pPt, "EXCHG_OUT_ACTION_INSERT_PRIVATE: what should happen here?" );
1785  break;
1786 
1788  OSL_ENSURE( pPt, "EXCHG_OUT_ACTION_MOVE_PRIVATE: what should happen here?" );
1789  break;
1790 
1791  case EXCHG_IN_ACTION_MOVE:
1792  case EXCHG_IN_ACTION_COPY:
1793  case EXCHG_IN_ACTION_LINK:
1798 
1799  // then we have to use the format
1800  switch( nFormat )
1801  {
1802  case SotClipboardFormatId::DRAWING:
1803  bRet = SwTransferable::PasteSdrFormat( rData, rSh,
1804  SwPasteSdr::Insert, pPt,
1805  nActionFlags, bNeedToSelectBeforePaste);
1806  break;
1807 
1808  case SotClipboardFormatId::HTML:
1809  case SotClipboardFormatId::HTML_SIMPLE:
1810  case SotClipboardFormatId::HTML_NO_COMMENT:
1811  case SotClipboardFormatId::RTF:
1812  case SotClipboardFormatId::RICHTEXT:
1813  case SotClipboardFormatId::STRING:
1814  bRet = SwTransferable::PasteFileContent( rData, rSh,
1815  nFormat, bMsg, bIgnoreComments );
1816  break;
1817 
1818  case SotClipboardFormatId::NETSCAPE_BOOKMARK:
1819  {
1820  INetBookmark aBkmk;
1821  if( rData.GetINetBookmark( nFormat, aBkmk ) )
1822  {
1823  SwFormatINetFormat aFormat( aBkmk.GetURL(), OUString() );
1824  rSh.InsertURL( aFormat, aBkmk.GetDescription() );
1825  bRet = true;
1826  }
1827  }
1828  break;
1829 
1830  case SotClipboardFormatId::SD_OLE:
1831  bRet = SwTransferable::PasteOLE( rData, rSh, nFormat,
1832  nActionFlags, bMsg );
1833  break;
1834 
1835  case SotClipboardFormatId::SVIM:
1836  bRet = SwTransferable::PasteImageMap( rData, rSh );
1837  break;
1838 
1839  case SotClipboardFormatId::SVXB:
1840  case SotClipboardFormatId::BITMAP:
1841  case SotClipboardFormatId::PNG:
1842  case SotClipboardFormatId::GDIMETAFILE:
1843  bRet = SwTransferable::PasteGrf( rData, rSh, nFormat,
1844  SwPasteSdr::Insert,pPt,
1845  nActionFlags, nDropAction, bNeedToSelectBeforePaste);
1846  break;
1847 
1848  case SotClipboardFormatId::XFORMS:
1849  case SotClipboardFormatId::SBA_FIELDDATAEXCHANGE:
1850  case SotClipboardFormatId::SBA_DATAEXCHANGE:
1851  case SotClipboardFormatId::SBA_CTRLDATAEXCHANGE:
1852  bRet = SwTransferable::PasteDBData( rData, rSh, nFormat,
1853  EXCHG_IN_ACTION_LINK == nAction,
1854  pPt, bMsg );
1855  break;
1856 
1857  case SotClipboardFormatId::SIMPLE_FILE:
1858  bRet = SwTransferable::PasteFileName( rData, rSh, nFormat,
1859  ( EXCHG_IN_ACTION_MOVE == nAction
1861  : EXCHG_IN_ACTION_LINK == nAction
1863  : SwPasteSdr::Insert),
1864  pPt, nActionFlags, nullptr );
1865  break;
1866 
1867  case SotClipboardFormatId::FILE_LIST:
1868  // then insert as graphics only
1869  bRet = SwTransferable::PasteFileList( rData, rSh,
1870  EXCHG_IN_ACTION_LINK == nAction,
1871  pPt, bMsg );
1872  break;
1873 
1874  case SotClipboardFormatId::SONLK:
1875  if( pPt )
1876  {
1877  NaviContentBookmark aBkmk;
1878  if( aBkmk.Paste( rData ) )
1879  {
1880  if(bIsDefault)
1881  {
1882  switch(aBkmk.GetDefaultDragType())
1883  {
1884  case RegionMode::NONE: nAction = EXCHG_IN_ACTION_COPY; break;
1885  case RegionMode::EMBEDDED: nAction = EXCHG_IN_ACTION_MOVE; break;
1886  case RegionMode::LINK: nAction = EXCHG_IN_ACTION_LINK; break;
1887  }
1888  }
1889  rSh.NavigatorPaste( aBkmk, nAction );
1890  bRet = true;
1891  }
1892  }
1893  break;
1894 
1895  case SotClipboardFormatId::INET_IMAGE:
1896  case SotClipboardFormatId::NETSCAPE_IMAGE:
1897  bRet = SwTransferable::PasteTargetURL( rData, rSh,
1898  SwPasteSdr::Insert,
1899  pPt, true );
1900  break;
1901 
1902  default:
1903  OSL_ENSURE( pPt, "unknown format" );
1904  }
1905  break;
1906 
1908  {
1909  bool graphicInserted;
1910  bRet = SwTransferable::PasteFileName( rData, rSh, nFormat,
1911  SwPasteSdr::Insert, pPt,
1912  nActionFlags,
1913  &graphicInserted );
1914  if( graphicInserted )
1915  bCallAutoCaption = true;
1916  }
1917  break;
1918 
1920  bRet = SwTransferable::PasteOLE( rData, rSh, nFormat,
1921  nActionFlags,bMsg );
1922  break;
1923 
1925  {
1926  bool bReRead = 0 != CNT_HasGrf( rSh.GetCntType() );
1927  bRet = SwTransferable::PasteDDE( rData, rSh, bReRead, bMsg );
1928  }
1929  break;
1930 
1932  {
1933  OUString sURL, sDesc;
1934  if( SotClipboardFormatId::SIMPLE_FILE == nFormat )
1935  {
1936  if( rData.GetString( nFormat, sURL ) && !sURL.isEmpty() )
1937  {
1938  SwTransferable::CheckForURLOrLNKFile( rData, sURL, &sDesc );
1939  if( sDesc.isEmpty() )
1940  sDesc = sURL;
1941  bRet = true;
1942  }
1943  }
1944  else
1945  {
1946  INetBookmark aBkmk;
1947  if( rData.GetINetBookmark( nFormat, aBkmk ) )
1948  {
1949  sURL = aBkmk.GetURL();
1950  sDesc = aBkmk.GetDescription();
1951  bRet = true;
1952  }
1953  }
1954 
1955  if( bRet )
1956  {
1957  SwFormatINetFormat aFormat( sURL, OUString() );
1958  rSh.InsertURL( aFormat, sDesc );
1959  }
1960  }
1961  break;
1962 
1964  switch( nFormat )
1965  {
1966  case SotClipboardFormatId::DRAWING:
1967  bRet = SwTransferable::PasteSdrFormat( rData, rSh,
1968  SwPasteSdr::SetAttr, pPt,
1969  nActionFlags, bNeedToSelectBeforePaste);
1970  break;
1971  case SotClipboardFormatId::SVXB:
1972  case SotClipboardFormatId::GDIMETAFILE:
1973  case SotClipboardFormatId::BITMAP:
1974  case SotClipboardFormatId::PNG:
1975  case SotClipboardFormatId::NETSCAPE_BOOKMARK:
1976  case SotClipboardFormatId::SIMPLE_FILE:
1977  case SotClipboardFormatId::FILEGRPDESCRIPTOR:
1978  case SotClipboardFormatId::UNIFORMRESOURCELOCATOR:
1979  bRet = SwTransferable::PasteGrf( rData, rSh, nFormat,
1980  SwPasteSdr::SetAttr, pPt,
1981  nActionFlags, nDropAction, bNeedToSelectBeforePaste);
1982  break;
1983  default:
1984  OSL_FAIL( "unknown format" );
1985  }
1986 
1987  break;
1988 
1990  bRet = SwTransferable::PasteSdrFormat( rData, rSh,
1991  SwPasteSdr::Insert, pPt,
1992  nActionFlags, bNeedToSelectBeforePaste);
1993  break;
1998  bRet = SwTransferable::PasteGrf( rData, rSh, nFormat,
1999  SwPasteSdr::Insert, pPt,
2000  nActionFlags, nDropAction, bNeedToSelectBeforePaste, nAnchorType );
2001  break;
2002 
2004  bRet = SwTransferable::PasteSdrFormat( rData, rSh,
2005  SwPasteSdr::Replace, pPt,
2006  nActionFlags, bNeedToSelectBeforePaste);
2007  break;
2008 
2013  bRet = SwTransferable::PasteGrf( rData, rSh, nFormat,
2014  SwPasteSdr::Replace,pPt,
2015  nActionFlags, nDropAction, bNeedToSelectBeforePaste);
2016  break;
2017 
2019  bRet = SwTransferable::PasteAsHyperlink( rData, rSh, nFormat );
2020  break;
2021 
2022  default:
2023  OSL_FAIL("unknown action" );
2024  }
2025  }
2026 
2027  if( !bPasteSelection && rSh.IsFrameSelected() )
2028  {
2029  rSh.EnterSelFrameMode();
2030  //force ::SelectShell
2031  rSh.GetView().StopShellTimer();
2032  }
2033 
2034  pAction.reset();
2035  if( bCallAutoCaption )
2036  rSh.GetView().AutoCaption( GRAPHIC_CAP );
2037 
2038  return bRet;
2039 }
2040 
2042 {
2043  SotExchangeDest nRet = SotExchangeDest::NONE;
2044 
2045  ObjCntType eOType = rSh.GetObjCntTypeOfSelection();
2046 
2047  switch( eOType )
2048  {
2049  case OBJCNT_GRF:
2050  {
2051  bool bIMap, bLink;
2052  bIMap = nullptr != rSh.GetFlyFrameFormat()->GetURL().GetMap();
2053  OUString aDummy;
2054  rSh.GetGrfNms( &aDummy, nullptr );
2055  bLink = !aDummy.isEmpty();
2056 
2057  if( bLink && bIMap )
2058  nRet = SotExchangeDest::DOC_LNKD_GRAPH_W_IMAP;
2059  else if( bLink )
2060  nRet = SotExchangeDest::DOC_LNKD_GRAPHOBJ;
2061  else if( bIMap )
2062  nRet = SotExchangeDest::DOC_GRAPH_W_IMAP;
2063  else
2064  nRet = SotExchangeDest::DOC_GRAPHOBJ;
2065  }
2066  break;
2067 
2068  case OBJCNT_FLY:
2069  if( dynamic_cast< const SwWebDocShell *>( rSh.GetView().GetDocShell() ) != nullptr )
2070  nRet = SotExchangeDest::DOC_TEXTFRAME_WEB;
2071  else
2072  nRet = SotExchangeDest::DOC_TEXTFRAME;
2073  break;
2074  case OBJCNT_OLE: nRet = SotExchangeDest::DOC_OLEOBJ; break;
2075 
2076  case OBJCNT_CONTROL: /* no Action avail */
2077  case OBJCNT_SIMPLE: nRet = SotExchangeDest::DOC_DRAWOBJ; break;
2078  case OBJCNT_URLBUTTON: nRet = SotExchangeDest::DOC_URLBUTTON; break;
2079  case OBJCNT_GROUPOBJ: nRet = SotExchangeDest::DOC_GROUPOBJ; break;
2080 
2081  // what do we do at multiple selections???
2082  default:
2083  {
2084  if( dynamic_cast< const SwWebDocShell *>( rSh.GetView().GetDocShell() ) != nullptr )
2085  nRet = SotExchangeDest::SWDOC_FREE_AREA_WEB;
2086  else
2087  nRet = SotExchangeDest::SWDOC_FREE_AREA;
2088  }
2089  }
2090 
2091  return nRet;
2092 }
2093 
2095  SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments )
2096 {
2097  const char* pResId = STR_CLPBRD_FORMAT_ERROR;
2098  bool bRet = false;
2099 
2100  MSE40HTMLClipFormatObj aMSE40ClpObj;
2101 
2103  SvStream* pStream = nullptr;
2104  Reader* pRead = nullptr;
2105  OUString sData;
2106  switch( nFormat )
2107  {
2108  case SotClipboardFormatId::STRING:
2109  {
2110  pRead = ReadAscii;
2111  if( rData.GetString( nFormat, sData ) )
2112  {
2113  pStream = new SvMemoryStream( const_cast<sal_Unicode *>(sData.getStr()),
2114  sData.getLength() * sizeof( sal_Unicode ),
2115  StreamMode::READ );
2116 #ifdef OSL_BIGENDIAN
2117  pStream->SetEndian( SvStreamEndian::BIG );
2118 #else
2119  pStream->SetEndian( SvStreamEndian::LITTLE );
2120 #endif
2121 
2122  SwAsciiOptions aAOpt;
2123  aAOpt.SetCharSet( RTL_TEXTENCODING_UCS2 );
2124  pRead->GetReaderOpt().SetASCIIOpts( aAOpt );
2125  break;
2126  }
2127  }
2128  [[fallthrough]]; // because then test if we get a stream
2129 
2130  default:
2131  if( rData.GetSotStorageStream( nFormat, xStrm ) )
2132  {
2133  if( ( SotClipboardFormatId::HTML_SIMPLE == nFormat ) ||
2134  ( SotClipboardFormatId::HTML_NO_COMMENT == nFormat ) )
2135  {
2136  pStream = aMSE40ClpObj.IsValid( *xStrm );
2137  pRead = ReadHTML;
2138  pRead->SetReadUTF8( true );
2139 
2140  bool bNoComments =
2141  ( nFormat == SotClipboardFormatId::HTML_NO_COMMENT );
2142  pRead->SetIgnoreHTMLComments( bNoComments );
2143  }
2144  else
2145  {
2146  pStream = xStrm.get();
2147  if( SotClipboardFormatId::RTF == nFormat || SotClipboardFormatId::RICHTEXT == nFormat)
2148  pRead = SwReaderWriter::GetRtfReader();
2149  else if( !pRead )
2150  {
2151  pRead = ReadHTML;
2152  pRead->SetReadUTF8( true );
2153  }
2154  }
2155  }
2156  break;
2157  }
2158 
2159  if( pStream && pRead )
2160  {
2161  Link<LinkParamNone*,void> aOldLink( rSh.GetChgLnk() );
2163 
2164  const SwPosition& rInsPos = *rSh.GetCursor()->Start();
2165  SwReader aReader(*pStream, OUString(), OUString(), *rSh.GetCursor());
2166  rSh.SaveTableBoxContent( &rInsPos );
2167 
2168  if (bIgnoreComments)
2169  pRead->SetIgnoreHTMLComments(true);
2170 
2171  if( aReader.Read( *pRead ).IsError() )
2172  pResId = STR_ERROR_CLPBRD_READ;
2173  else
2174  {
2175  pResId = nullptr;
2176  bRet = true;
2177  }
2178 
2179  rSh.SetChgLnk( aOldLink );
2180  if( bRet )
2181  rSh.CallChgLnk();
2182  }
2183  else
2184  pResId = STR_CLPBRD_FORMAT_ERROR;
2185 
2186  // Exist a SvMemoryStream? (data in the OUString and xStrm is empty)
2187  if( pStream && !xStrm.is() )
2188  delete pStream;
2189 
2190  if (bMsg && pResId)
2191  {
2192  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
2193  VclMessageType::Info, VclButtonsType::Ok,
2194  SwResId(pResId)));
2195  xBox->run();
2196  }
2197  return bRet;
2198 }
2199 
2201  SotClipboardFormatId nFormat, SotExchangeActionFlags nActionFlags, bool bMsg )
2202 {
2203  bool bRet = false;
2205  uno::Reference < io::XInputStream > xStrm;
2206  uno::Reference < embed::XStorage > xStore;
2207  Reader* pRead = nullptr;
2208 
2209  // Get the preferred format
2211  if( rData.HasFormat( SotClipboardFormatId::EMBEDDED_OBJ ) )
2212  nId = SotClipboardFormatId::EMBEDDED_OBJ;
2213  else if( rData.HasFormat( SotClipboardFormatId::EMBED_SOURCE ) &&
2214  rData.HasFormat( SotClipboardFormatId::OBJECTDESCRIPTOR ))
2215  nId = SotClipboardFormatId::EMBED_SOURCE;
2216  else
2217  nId = SotClipboardFormatId::NONE;
2218 
2219  if (nId != SotClipboardFormatId::NONE)
2220  {
2221  SwDocShell* pDocSh = rSh.GetDoc()->GetDocShell();
2222  xStrm = rData.GetInputStream(nId, SfxObjectShell::CreateShellID(pDocSh));
2223  }
2224 
2225  if (xStrm.is())
2226  {
2227  // if there is an embedded object, first try if it's a writer object
2228  // this will be inserted into the document by using a Reader
2229  try
2230  {
2232  switch( SotStorage::GetFormatID( xStore ) )
2233  {
2234  case SotClipboardFormatId::STARWRITER_60:
2235  case SotClipboardFormatId::STARWRITERWEB_60:
2236  case SotClipboardFormatId::STARWRITERGLOB_60:
2237  case SotClipboardFormatId::STARWRITER_8:
2238  case SotClipboardFormatId::STARWRITERWEB_8:
2239  case SotClipboardFormatId::STARWRITERGLOB_8:
2240  pRead = ReadXML;
2241  break;
2242  default:
2243  try
2244  {
2245  xStore->dispose();
2246  xStore = nullptr;
2247  }
2248  catch (const uno::Exception&)
2249  {
2250  }
2251 
2252  break;
2253  }
2254  }
2255  catch (const uno::Exception&)
2256  {
2257  // it wasn't a storage, but maybe it's a useful stream
2258  }
2259  }
2260 
2261  if( pRead )
2262  {
2263  SwPaM &rPAM = *rSh.GetCursor();
2264  SwReader aReader(xStore, OUString(), rPAM);
2265  if( ! aReader.Read( *pRead ).IsError() )
2266  bRet = true;
2267  else if( bMsg )
2268  {
2269  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
2270  VclMessageType::Info, VclButtonsType::Ok,
2271  SwResId(STR_ERROR_CLPBRD_READ)));
2272  xBox->run();
2273  }
2274  }
2275  else
2276  {
2277  // temporary storage until the object is inserted
2278  uno::Reference< embed::XStorage > xTmpStor;
2279  uno::Reference < embed::XEmbeddedObject > xObj;
2280  OUString aName;
2282 
2283  if ( xStrm.is() )
2284  {
2285  if ( !rData.GetTransferableObjectDescriptor( SotClipboardFormatId::OBJECTDESCRIPTOR, aObjDesc ) )
2286  {
2287  OSL_ENSURE( !xStrm.is(), "An object without descriptor in clipboard!");
2288  }
2289  }
2290  else
2291  {
2292  if( rData.HasFormat( SotClipboardFormatId::OBJECTDESCRIPTOR_OLE ) && rData.GetTransferableObjectDescriptor( nFormat, aObjDesc ) )
2293  {
2294  xStrm = rData.GetInputStream(SotClipboardFormatId::EMBED_SOURCE_OLE, OUString());
2295  if (!xStrm.is())
2296  xStrm = rData.GetInputStream(SotClipboardFormatId::EMBEDDED_OBJ_OLE, OUString());
2297 
2298  if ( !xStrm.is() )
2299  {
2300  // This is MSOLE object that should be created by direct using of system clipboard
2301  try
2302  {
2304  uno::Reference < embed::XEmbedObjectClipboardCreator > xClipboardCreator =
2305  embed::MSOLEObjectSystemCreator::create( ::comphelper::getProcessComponentContext() );
2306 
2307  embed::InsertedObjectInfo aInfo = xClipboardCreator->createInstanceInitFromClipboard(
2308  xTmpStor,
2309  "DummyName",
2310  uno::Sequence< beans::PropertyValue >() );
2311 
2312  // TODO/LATER: in future InsertedObjectInfo will be used to get container related information
2313  // for example whether the object should be an iconified one
2314  xObj = aInfo.Object;
2315  }
2316  catch (const uno::Exception&)
2317  {
2318  }
2319  }
2320  }
2321  else if (rData.HasFormat(SotClipboardFormatId::SIMPLE_FILE))
2322  {
2323  OUString sFile;
2324  if (rData.GetString(nFormat, sFile) && !sFile.isEmpty())
2325  {
2326  // Copied from sd::View::DropInsertFileHdl
2327  uno::Sequence< beans::PropertyValue > aMedium(1);
2328  aMedium[0].Name = "URL";
2329  aMedium[0].Value <<= sFile;
2330  SwDocShell* pDocSh = rSh.GetDoc()->GetDocShell();
2331  xObj = pDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject(aMedium, aName);
2332  }
2333  }
2334  }
2335 
2336  if ( xStrm.is() && !xObj.is() )
2337  xObj = aCnt.InsertEmbeddedObject( xStrm, aName );
2338 
2339  if( xObj.is() )
2340  {
2341  svt::EmbeddedObjectRef xObjRef( xObj, aObjDesc.mnViewAspect );
2342 
2343  // try to get the replacement image from the clipboard
2344  Graphic aGraphic;
2345  SotClipboardFormatId nGrFormat = SotClipboardFormatId::NONE;
2346 
2347  // limit the size of the preview metafile to 100000 actions
2348  GDIMetaFile aMetafile;
2349  if (rData.GetGDIMetaFile(SotClipboardFormatId::GDIMETAFILE, aMetafile, 100000))
2350  {
2351  nGrFormat = SotClipboardFormatId::GDIMETAFILE;
2352  aGraphic = aMetafile;
2353  }
2354 
2355  // insert replacement image ( if there is one ) into the object helper
2356  if ( nGrFormat != SotClipboardFormatId::NONE )
2357  {
2358  DataFlavor aDataFlavor;
2359  SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
2360  xObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
2361  }
2362  else if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
2363  {
2364  // it is important to have an icon, let an empty graphic be used
2365  // if no other graphic is provided
2366  // TODO/LATER: in future a default bitmap could be used
2367  MapMode aMapMode( MapUnit::Map100thMM );
2368  aGraphic.SetPrefSize( Size( 2500, 2500 ) );
2369  aGraphic.SetPrefMapMode( aMapMode );
2370  xObjRef.SetGraphic( aGraphic, OUString() );
2371  }
2372 
2373  //set size. This is a hack because of handing over, size should be
2374  //passed to the InsertOle!!!!!!!!!!
2375  Size aSize;
2376  if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
2377  {
2378  if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
2379  aSize = aObjDesc.maSize;
2380  else
2381  {
2382  MapMode aMapMode( MapUnit::Map100thMM );
2383  aSize = xObjRef.GetSize( &aMapMode );
2384  }
2385  }
2386  else if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
2387  {
2388  aSize = aObjDesc.maSize; //always 100TH_MM
2389  MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
2390  aSize = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(aUnit));
2391  awt::Size aSz;
2392  try
2393  {
2394  aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
2395  }
2396  catch (const embed::NoVisualAreaSizeException&)
2397  {
2398  // in this case the provided size is used
2399  }
2400 
2401  if ( aSz.Width != aSize.Width() || aSz.Height != aSize.Height() )
2402  {
2403  aSz.Width = aSize.Width();
2404  aSz.Height = aSize.Height();
2405  xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
2406  }
2407  }
2408  else
2409  {
2410  // the descriptor contains the wrong object size
2411  // the following call will let the MSOLE objects cache the size if it is possible
2412  // it should be done while the object is running
2413  try
2414  {
2415  xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
2416  }
2417  catch (const uno::Exception&)
2418  {
2419  }
2420  }
2421  //End of Hack!
2422 
2423  rSh.InsertOleObject( xObjRef );
2424  bRet = true;
2425 
2426  if( bRet && ( nActionFlags & SotExchangeActionFlags::InsertTargetUrl) )
2427  SwTransferable::PasteTargetURL( rData, rSh, SwPasteSdr::NONE, nullptr, false );
2428 
2429  // let the object be unloaded if possible
2430  SwOLEObj::UnloadObject( xObj, rSh.GetDoc(), embed::Aspects::MSOLE_CONTENT );
2431  }
2432  }
2433  return bRet;
2434 }
2435 
2437  SwWrtShell& rSh, SwPasteSdr nAction,
2438  const Point* pPt, bool bInsertGRF )
2439 {
2440  bool bRet = false;
2441  INetImage aINetImg;
2442  if( ( rData.HasFormat( SotClipboardFormatId::INET_IMAGE ) &&
2443  rData.GetINetImage( SotClipboardFormatId::INET_IMAGE, aINetImg )) ||
2444  ( rData.HasFormat( SotClipboardFormatId::NETSCAPE_IMAGE ) &&
2445  rData.GetINetImage( SotClipboardFormatId::NETSCAPE_IMAGE, aINetImg )) )
2446  {
2447  if( !aINetImg.GetImageURL().isEmpty() && bInsertGRF )
2448  {
2449  OUString sURL( aINetImg.GetImageURL() );
2450  SwTransferable::CheckForURLOrLNKFile( rData, sURL );
2451 
2453  Graphic aGraphic;
2455  bRet = ERRCODE_NONE == GraphicFilter::LoadGraphic(sURL, OUString(), aGraphic, &rFlt);
2456 
2457  if( bRet )
2458  {
2459  //Check and Perform rotation if needed
2460  lclCheckAndPerformRotation(aGraphic);
2461 
2462  switch( nAction )
2463  {
2464  case SwPasteSdr::Insert:
2465  SwTransferable::SetSelInShell( rSh, false, pPt );
2466  rSh.Insert(sURL, OUString(), aGraphic);
2467  break;
2468 
2469  case SwPasteSdr::Replace:
2470  if( rSh.IsObjSelected() )
2471  {
2472  rSh.ReplaceSdrObj( sURL, &aGraphic );
2473  Point aPt( pPt ? *pPt : rSh.GetCursorDocPos() );
2474  SwTransferable::SetSelInShell( rSh, true, &aPt );
2475  }
2476  else
2477  rSh.ReRead(sURL, OUString(), &aGraphic);
2478  break;
2479 
2480  case SwPasteSdr::SetAttr:
2481  if( rSh.IsObjSelected() )
2482  rSh.Paste( aGraphic, OUString() );
2483  else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() )
2484  rSh.ReRead(sURL, OUString(), &aGraphic);
2485  else
2486  {
2487  SwTransferable::SetSelInShell( rSh, false, pPt );
2488  rSh.Insert(sURL, OUString(), aGraphic);
2489  }
2490  break;
2491  default:
2492  bRet = false;
2493  }
2494  }
2495  }
2496  else
2497  bRet = true;
2498  }
2499 
2500  if( bRet )
2501  {
2503  rSh.GetFlyFrameAttr( aSet );
2504  SwFormatURL aURL( aSet.Get( RES_URL ) );
2505 
2506  if( aURL.GetURL() != aINetImg.GetTargetURL() ||
2507  aURL.GetTargetFrameName() != aINetImg.GetTargetFrame() )
2508  {
2509  aURL.SetURL( aINetImg.GetTargetURL(), false );
2510  aURL.SetTargetFrameName( aINetImg.GetTargetFrame() );
2511  aSet.Put( aURL );
2512  rSh.SetFlyFrameAttr( aSet );
2513  }
2514  }
2515  return bRet;
2516 }
2517 
2518 void SwTransferable::SetSelInShell( SwWrtShell& rSh, bool bSelectFrame,
2519  const Point* pPt )
2520 {
2521  if( bSelectFrame )
2522  {
2523  // select frames/objects
2524  if( pPt && !rSh.GetView().GetViewFrame()->GetDispatcher()->IsLocked() )
2525  {
2526  rSh.GetView().NoRotate();
2527  if( rSh.SelectObj( *pPt ))
2528  {
2529  rSh.HideCursor();
2530  rSh.EnterSelFrameMode( pPt );
2531  g_bFrameDrag = true;
2532  }
2533  }
2534  }
2535  else
2536  {
2537  if( rSh.IsFrameSelected() || rSh.IsObjSelected() )
2538  {
2539  rSh.UnSelectFrame();
2540  rSh.LeaveSelFrameMode();
2541  rSh.GetView().GetEditWin().StopInsFrame();
2542  g_bFrameDrag = false;
2543  }
2544  else if( rSh.GetView().GetDrawFuncPtr() )
2545  rSh.GetView().GetEditWin().StopInsFrame();
2546 
2547  rSh.EnterStdMode();
2548  if( pPt )
2549  rSh.SwCursorShell::SetCursor( *pPt, true );
2550  }
2551 }
2552 
2554  SwWrtShell& rWrtShell, bool bReReadGrf,
2555  bool bMsg )
2556 {
2557  // data from Clipboardformat
2558  OUString aApp, aTopic, aItem;
2559 
2560  {
2562  if( !rData.GetSotStorageStream( SotClipboardFormatId::LINK, xStrm ))
2563  {
2564  OSL_ENSURE( false, "DDE Data not found." );
2565  return false;
2566  } // report useful error!!
2567 
2568  rtl_TextEncoding eEncoding = osl_getThreadTextEncoding();
2569  aApp = read_zeroTerminated_uInt8s_ToOUString(*xStrm, eEncoding);
2570  aTopic = read_zeroTerminated_uInt8s_ToOUString(*xStrm, eEncoding);
2571  aItem = read_zeroTerminated_uInt8s_ToOUString(*xStrm, eEncoding);
2572  }
2573 
2574  OUString aCmd;
2575  sfx2::MakeLnkName( aCmd, &aApp, aTopic, aItem );
2576 
2577  // do we want to read in a graphic now?
2578  SotClipboardFormatId nFormat;
2579  if( !rData.HasFormat( SotClipboardFormatId::RTF ) &&
2580  !rData.HasFormat( SotClipboardFormatId::RICHTEXT ) &&
2581  !rData.HasFormat( SotClipboardFormatId::HTML ) &&
2582  !rData.HasFormat( SotClipboardFormatId::STRING ) &&
2583  (rData.HasFormat( nFormat = SotClipboardFormatId::GDIMETAFILE ) ||
2584  rData.HasFormat( nFormat = SotClipboardFormatId::BITMAP )) )
2585  {
2586  Graphic aGrf;
2587  bool bRet = rData.GetGraphic( nFormat, aGrf );
2588  if( bRet )
2589  {
2590  OUString sLnkTyp("DDE");
2591  if ( bReReadGrf )
2592  rWrtShell.ReRead( aCmd, sLnkTyp, &aGrf );
2593  else
2594  rWrtShell.Insert( aCmd, sLnkTyp, aGrf );
2595  }
2596  return bRet;
2597  }
2598 
2599  SwFieldType* pTyp = nullptr;
2600  size_t i = 1;
2601  size_t j;
2602  OUString aName;
2603  bool bDoublePaste = false;
2604  const size_t nSize = rWrtShell.GetFieldTypeCount();
2605  const ::utl::TransliterationWrapper& rColl = ::GetAppCmpStrIgnore();
2606 
2607  do {
2608  aName = aApp + OUString::number( i );
2609  for( j = INIT_FLDTYPES; j < nSize; j++ )
2610  {
2611  pTyp = rWrtShell.GetFieldType( j );
2612  if( SwFieldIds::Dde == pTyp->Which() )
2613  {
2614  if( rColl.isEqual( static_cast<SwDDEFieldType*>(pTyp)->GetCmd(), aCmd ) &&
2615  SfxLinkUpdateMode::ALWAYS == static_cast<SwDDEFieldType*>(pTyp)->GetType() )
2616  {
2617  aName = pTyp->GetName();
2618  bDoublePaste = true;
2619  break;
2620  }
2621  else if( rColl.isEqual( aName, pTyp->GetName() ) )
2622  break;
2623  }
2624  }
2625  if( j == nSize )
2626  break;
2627  ++i;
2628  }
2629  while( !bDoublePaste );
2630 
2631  if( !bDoublePaste )
2632  {
2633  SwDDEFieldType aType( aName, aCmd, SfxLinkUpdateMode::ALWAYS );
2634  pTyp = rWrtShell.InsertFieldType( aType );
2635  }
2636 
2637  SwDDEFieldType* pDDETyp = static_cast<SwDDEFieldType*>(pTyp);
2638 
2639  OUString aExpand;
2640  if( rData.GetString( SotClipboardFormatId::STRING, aExpand ))
2641  {
2642  do { // middle checked loop
2643 
2644  const sal_Int32 nNewlines{comphelper::string::getTokenCount(aExpand, '\n')};
2645  // When data comes from a spreadsheet, we add a DDE-table
2646  if( !aExpand.isEmpty() &&
2647  ( rData.HasFormat( SotClipboardFormatId::SYLK ) ||
2648  rData.HasFormat( SotClipboardFormatId::SYLK_BIGCAPS ) ) )
2649  {
2650  const sal_Int32 nRows = nNewlines ? nNewlines-1 : 0;
2651  const sal_Int32 nCols = comphelper::string::getTokenCount(aExpand.getToken(0, '\n'), '\t');
2652 
2653  // don't try to insert tables that are too large for writer
2654  if (nRows > SAL_MAX_UINT16 || nCols > SAL_MAX_UINT16)
2655  {
2656  if( bMsg )
2657  {
2658  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
2659  VclMessageType::Info, VclButtonsType::Ok,
2660  SwResId(STR_TABLE_TOO_LARGE)));
2661  xBox->run();
2662  }
2663  pDDETyp = nullptr;
2664  break;
2665  }
2666 
2667  // at least one column & row must be there
2668  if( !nRows || !nCols )
2669  {
2670  if( bMsg )
2671  {
2672  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
2673  VclMessageType::Info, VclButtonsType::Ok,
2674  SwResId(STR_NO_TABLE)));
2675  xBox->run();
2676  }
2677  pDDETyp = nullptr;
2678  break;
2679  }
2680 
2681  rWrtShell.InsertDDETable(
2682  SwInsertTableOptions( SwInsertTableFlags::SplitLayout, 1 ), // TODO MULTIHEADER
2683  pDDETyp, nRows, nCols );
2684  }
2685  else if( nNewlines > 1 )
2686  {
2687  // multiple paragraphs -> insert a protected section
2688  if( rWrtShell.HasSelection() )
2689  rWrtShell.DelRight();
2690 
2691  SwSectionData aSect( SectionType::DdeLink, aName );
2692  aSect.SetLinkFileName( aCmd );
2693  aSect.SetProtectFlag(true);
2694  rWrtShell.InsertSection( aSect );
2695 
2696  pDDETyp = nullptr; // remove FieldTypes again
2697  }
2698  else
2699  {
2700  // insert
2701  SwDDEField aSwDDEField( pDDETyp );
2702  rWrtShell.Insert( aSwDDEField );
2703  }
2704 
2705  } while( false );
2706  }
2707  else
2708  pDDETyp = nullptr; // remove FieldTypes again
2709 
2710  if( !pDDETyp && !bDoublePaste )
2711  {
2712  // remove FieldType again - error occurred!
2713  for( j = nSize; j >= INIT_FLDTYPES; --j )
2714  if( pTyp == rWrtShell.GetFieldType( j ) )
2715  {
2716  rWrtShell.RemoveFieldType( j );
2717  break;
2718  }
2719  }
2720 
2721  return true;
2722 }
2723 
2725  SwWrtShell& rSh, SwPasteSdr nAction,
2726  const Point* pPt, SotExchangeActionFlags nActionFlags, bool bNeedToSelectBeforePaste)
2727 {
2728  bool bRet = false;
2730  if( rData.GetSotStorageStream( SotClipboardFormatId::DRAWING, xStrm ))
2731  {
2732  xStrm->SetVersion( SOFFICE_FILEFORMAT_50 );
2733 
2734  if(bNeedToSelectBeforePaste && pPt)
2735  {
2736  // if this is an internal drag, need to set the target right (select it), else
2737  // still the source will be selected
2738  SwTransferable::SetSelInShell( rSh, true, pPt );
2739  }
2740 
2741  rSh.Paste( *xStrm, nAction, pPt );
2742  bRet = true;
2743 
2744  if( bRet && ( nActionFlags & SotExchangeActionFlags::InsertTargetUrl ))
2745  SwTransferable::PasteTargetURL( rData, rSh, SwPasteSdr::NONE, nullptr, false );
2746  }
2747  return bRet;
2748 }
2749 
2751  SotClipboardFormatId nFormat, SwPasteSdr nAction, const Point* pPt,
2752  SotExchangeActionFlags nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste, RndStdIds nAnchorType )
2753 {
2754  bool bRet = false;
2755 
2756  Graphic aGraphic;
2757  INetBookmark aBkmk;
2758  bool bCheckForGrf = false, bCheckForImageMap = false;
2759 
2760  switch( nFormat )
2761  {
2762  case SotClipboardFormatId::BITMAP:
2763  case SotClipboardFormatId::PNG:
2764  case SotClipboardFormatId::GDIMETAFILE:
2765  bRet = rData.GetGraphic( nFormat, aGraphic );
2766  break;
2767 
2768  case SotClipboardFormatId::SVXB:
2769  {
2771 
2772  if(rData.GetSotStorageStream(SotClipboardFormatId::SVXB, xStm))
2773  {
2774  TypeSerializer aSerializer(*xStm);
2775  aSerializer.readGraphic(aGraphic);
2776  bRet = (GraphicType::NONE != aGraphic.GetType() && GraphicType::Default != aGraphic.GetType());
2777  }
2778 
2779  break;
2780  }
2781 
2782  case SotClipboardFormatId::NETSCAPE_BOOKMARK:
2783  case SotClipboardFormatId::FILEGRPDESCRIPTOR:
2784  case SotClipboardFormatId::UNIFORMRESOURCELOCATOR:
2785  bRet = rData.GetINetBookmark( nFormat, aBkmk );
2786  if( bRet )
2787  {
2788  if( SwPasteSdr::SetAttr == nAction )
2789  nFormat = SotClipboardFormatId::NETSCAPE_BOOKMARK;
2790  else
2791  bCheckForGrf = true;
2792  }
2793  break;
2794 
2795  case SotClipboardFormatId::SIMPLE_FILE:
2796  {
2797  OUString sText;
2798  bRet = rData.GetString( nFormat, sText );
2799  if( bRet )
2800  {
2801  OUString sDesc;
2802  SwTransferable::CheckForURLOrLNKFile( rData, sText, &sDesc );
2803 
2805  false);
2806 
2807 #ifdef _WIN32
2808  // Now that the path could be modified after SwTransferable::CheckForURLOrLNKFile,
2809  // where it could have been converted to URL, and made sure it's actually converted
2810  // to URL in URIHelper::SmartRel2Abs, we can finally convert file: URL back to
2811  // system path to make sure we don't use short path.
2812  // It looks not optimal, when we could apply GetLongPathNameW right to the original
2813  // pasted filename. But I don't know if (1) all arriving strings are system paths;
2814  // and (2) if SwTransferable::CheckForURLOrLNKFile could result in a different short
2815  // path, so taking a safe route.
2816  if (sText.startsWithIgnoreAsciiCase("file:"))
2817  {
2818  // tdf#124500: Convert short path to long path which should be used in links
2819  OUString sSysPath;
2820  osl::FileBase::getSystemPathFromFileURL(sText, sSysPath);
2821  std::unique_ptr<sal_Unicode[]> aBuf(new sal_Unicode[32767]);
2822  DWORD nCopied = GetLongPathNameW(o3tl::toW(sSysPath.getStr()),
2823  o3tl::toW(aBuf.get()), 32767);
2824  if (nCopied && nCopied < 32767)
2825  sText = URIHelper::SmartRel2Abs(INetURLObject(), OUString(aBuf.get()),
2826  Link<OUString*, bool>(), false);
2827  }
2828 #endif
2829 
2830  aBkmk = INetBookmark(sText, sDesc);
2831  bCheckForGrf = true;
2832  bCheckForImageMap = SwPasteSdr::Replace == nAction;
2833  }
2834  }
2835  break;
2836 
2837  default:
2838  bRet = rData.GetGraphic( nFormat, aGraphic );
2839  break;
2840  }
2841 
2842  if( bCheckForGrf )
2843  {
2846  bRet = ERRCODE_NONE == GraphicFilter::LoadGraphic(aBkmk.GetURL(), OUString(),
2847  aGraphic, &rFlt );
2848 
2849  if( !bRet && SwPasteSdr::SetAttr == nAction &&
2850  SotClipboardFormatId::SIMPLE_FILE == nFormat &&
2851  // only at frame selection
2852  rSh.IsFrameSelected() )
2853  {
2854  // then set as hyperlink after the graphic
2855  nFormat = SotClipboardFormatId::NETSCAPE_BOOKMARK;
2856  bRet = true;
2857  }
2858  }
2859 
2860  if(pPt && bNeedToSelectBeforePaste)
2861  {
2862  // when using internal D&Ds, still the source object is selected and
2863  // this is necessary to get the correct source data which is also
2864  // dependent from selection. After receiving the drag data it is
2865  // now time to select the correct target object
2866  SwTransferable::SetSelInShell( rSh, true, pPt );
2867  }
2868 
2869  if( bRet )
2870  {
2871  //Check and Perform rotation if needed
2872  lclCheckAndPerformRotation(aGraphic);
2873 
2874  OUString sURL;
2875  if( dynamic_cast< const SwWebDocShell *>( rSh.GetView().GetDocShell() ) != nullptr
2876  // #i123922# if link action is noted, also take URL
2877  || DND_ACTION_LINK == nDropAction)
2878  {
2879  sURL = aBkmk.GetURL();
2880  }
2881 
2882  switch( nAction )
2883  {
2884  case SwPasteSdr::Insert:
2885  {
2886  SwTransferable::SetSelInShell( rSh, false, pPt );
2887  rSh.Insert(sURL, OUString(), aGraphic, nullptr, nAnchorType);
2888  break;
2889  }
2890 
2891  case SwPasteSdr::Replace:
2892  {
2893  if( rSh.IsObjSelected() )
2894  {
2895  // #i123922# for D&D on draw objects, do for now the same for
2896  // SwPasteSdr::Replace (D&D) as for SwPasteSdr::SetAttr (D&D and
2897  // CTRL+SHIFT). The code below replaces the draw object with
2898  // a writer graphic; maybe this is an option later again if wanted
2899  rSh.Paste( aGraphic, sURL );
2900 
2901  // rSh.ReplaceSdrObj(sURL, OUString(), &aGraphic);
2902  // Point aPt( pPt ? *pPt : rSh.GetCursorDocPos() );
2903  // SwTransferable::SetSelInShell( rSh, true, &aPt );
2904  }
2905  else
2906  {
2907  // set graphic at writer graphic without link
2908  rSh.ReRead(sURL, OUString(), &aGraphic);
2909  }
2910 
2911  break;
2912  }
2913 
2914  case SwPasteSdr::SetAttr:
2915  {
2916  if( SotClipboardFormatId::NETSCAPE_BOOKMARK == nFormat )
2917  {
2918  if( rSh.IsFrameSelected() )
2919  {
2921  rSh.GetFlyFrameAttr( aSet );
2922  SwFormatURL aURL( aSet.Get( RES_URL ) );
2923  aURL.SetURL( aBkmk.GetURL(), false );
2924  aSet.Put( aURL );
2925  rSh.SetFlyFrameAttr( aSet );
2926  }
2927  }
2928  else if( rSh.IsObjSelected() )
2929  {
2930  // set as attribute at DrawObject
2931  rSh.Paste( aGraphic, sURL );
2932  }
2933  else if( OBJCNT_GRF == rSh.GetObjCntTypeOfSelection() )
2934  {
2935  // set as linked graphic at writer graphic frame
2936  rSh.ReRead(sURL, OUString(), &aGraphic);
2937  }
2938  else
2939  {
2940  SwTransferable::SetSelInShell( rSh, false, pPt );
2941  rSh.Insert(aBkmk.GetURL(), OUString(), aGraphic);
2942  }
2943  break;
2944  }
2945  default:
2946  {
2947  bRet = false;
2948  break;
2949  }
2950  }
2951  }
2952 
2953  if( bRet )
2954  {
2955 
2956  if( nActionFlags &
2957  ( SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::ReplaceImageMap ) )
2958  SwTransferable::PasteImageMap( rData, rSh );
2959 
2960  if( nActionFlags & SotExchangeActionFlags::InsertTargetUrl )
2961  SwTransferable::PasteTargetURL( rData, rSh, SwPasteSdr::NONE, nullptr, false );
2962  }
2963  else if( bCheckForImageMap )
2964  {
2965  // or should the file be an ImageMap-File?
2966  ImageMap aMap;
2967  SfxMedium aMed( INetURLObject(aBkmk.GetURL()).GetFull(),
2968  StreamMode::STD_READ );
2969  SvStream* pStream = aMed.GetInStream();
2970  if( pStream != nullptr &&
2971  !pStream->GetError() &&
2972  // mba: no BaseURL for clipboard functionality
2973  aMap.Read( *pStream, IMapFormat::Detect ) == IMAP_ERR_OK &&
2974  aMap.GetIMapObjectCount() )
2975  {
2977  rSh.GetFlyFrameAttr( aSet );
2978  SwFormatURL aURL( aSet.Get( RES_URL ) );
2979  aURL.SetMap( &aMap );
2980  aSet.Put( aURL );
2981  rSh.SetFlyFrameAttr( aSet );
2982  bRet = true;
2983  }
2984  }
2985 
2986  return bRet;
2987 }
2988 
2990  SwWrtShell& rSh )
2991 {
2992  bool bRet = false;
2993  if( rData.HasFormat( SotClipboardFormatId::SVIM ))
2994  {
2996  rSh.GetFlyFrameAttr( aSet );
2997  SwFormatURL aURL( aSet.Get( RES_URL ) );
2998  const ImageMap* pOld = aURL.GetMap();
2999 
3000  // set or replace, that is the question
3001  ImageMap aImageMap;
3002  if( rData.GetImageMap( SotClipboardFormatId::SVIM, aImageMap ) &&
3003  ( !pOld || aImageMap != *pOld ))
3004  {
3005  aURL.SetMap( &aImageMap );
3006  aSet.Put( aURL );
3007  rSh.SetFlyFrameAttr( aSet );
3008  }
3009  bRet = true;
3010  }
3011  return bRet;
3012 }
3013 
3015  SwWrtShell& rSh, SotClipboardFormatId nFormat )
3016 {
3017  bool bRet = false;
3018  OUString sFile;
3019  if( rData.GetString( nFormat, sFile ) && !sFile.isEmpty() )
3020  {
3021  OUString sDesc;
3022  SwTransferable::CheckForURLOrLNKFile( rData, sFile, &sDesc );
3023 
3024  // first, make the URL absolute
3026  aURL.SetSmartProtocol( INetProtocol::File );
3027  aURL.SetSmartURL( sFile );
3029 
3030  switch( rSh.GetObjCntTypeOfSelection() )
3031  {
3032  case OBJCNT_FLY:
3033  case OBJCNT_GRF:
3034  case OBJCNT_OLE:
3035  {
3037  rSh.GetFlyFrameAttr( aSet );
3038  SwFormatURL aURL2( aSet.Get( RES_URL ) );
3039  aURL2.SetURL( sFile, false );
3040  if( aURL2.GetName().isEmpty() )
3041  aURL2.SetName( sFile );
3042  aSet.Put( aURL2 );
3043  rSh.SetFlyFrameAttr( aSet );
3044  }
3045  break;
3046 
3047  default:
3048  {
3049  rSh.InsertURL( SwFormatINetFormat( sFile, OUString() ),
3050  sDesc.isEmpty() ? sFile : sDesc);
3051  }
3052  }
3053  bRet = true;
3054  }
3055  return bRet;
3056 }
3057 
3059  SwWrtShell& rSh, SotClipboardFormatId nFormat,
3060  SwPasteSdr nAction, const Point* pPt,
3061  SotExchangeActionFlags nActionFlags,
3062  bool * graphicInserted)
3063 {
3064  bool bRet = SwTransferable::PasteGrf( rData, rSh, nFormat, nAction,
3065  pPt, nActionFlags, 0, false);
3066  if (graphicInserted != nullptr) {
3067  *graphicInserted = bRet;
3068  }
3069  if( !bRet )
3070  {
3071  OUString sFile, sDesc;
3072  if( rData.GetString( nFormat, sFile ) && !sFile.isEmpty() )
3073  {
3074 #if HAVE_FEATURE_AVMEDIA
3075  INetURLObject aMediaURL;
3076 
3077  aMediaURL.SetSmartURL( sFile );
3078  const OUString aMediaURLStr( aMediaURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
3079 
3080  if( ::avmedia::MediaWindow::isMediaURL( aMediaURLStr, ""/*TODO?*/ ) )
3081  {
3082  const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, aMediaURLStr );
3084  SID_INSERT_AVMEDIA, SfxCallMode::SYNCHRON,
3085  { &aMediaURLItem });
3086  }
3087 #else
3088  if (false)
3089  {
3090  }
3091 #endif
3092  else
3093  {
3094  bool bIsURLFile = SwTransferable::CheckForURLOrLNKFile( rData, sFile, &sDesc );
3095 
3096  //Own FileFormat? --> insert, not for StarWriter/Web
3097  OUString sFileURL = URIHelper::SmartRel2Abs(INetURLObject(), sFile, Link<OUString *, bool>(), false );
3098  std::shared_ptr<const SfxFilter> pFlt = SwPasteSdr::SetAttr == nAction
3099  ? nullptr : SwIoSystem::GetFileFilter(sFileURL);
3100  if( pFlt && dynamic_cast< const SwWebDocShell *>( rSh.GetView().GetDocShell() ) == nullptr )
3101  {
3102  // and then pull up the insert-region-dialog
3103  SwSectionData aSect(
3105  rSh.GetDoc()->GetUniqueSectionName() );
3106  aSect.SetLinkFileName( sFileURL );
3107  aSect.SetProtectFlag( true );
3108 
3109  rSh.StartInsertRegionDialog( aSect ); // starts dialog asynchronously
3110  bRet = true;
3111  }
3112  else if (SwPasteSdr::Insert == nAction && rData.HasFormat(SotClipboardFormatId::SIMPLE_FILE))
3113  {
3114  // insert file as OLE
3115  PasteOLE(rData, rSh, nFormat, nActionFlags, nullptr == pPt);
3116  }
3117  else if( SwPasteSdr::SetAttr == nAction ||
3118  ( bIsURLFile && SwPasteSdr::Insert == nAction ))
3119  {
3120  //we can insert foreign files as links after all
3121 
3122  // first, make the URL absolute
3124  aURL.SetSmartProtocol( INetProtocol::File );
3125  aURL.SetSmartURL( sFile );
3127 
3128  switch( rSh.GetObjCntTypeOfSelection() )
3129  {
3130  case OBJCNT_FLY:
3131  case OBJCNT_GRF:
3132  case OBJCNT_OLE:
3133  {
3135  rSh.GetFlyFrameAttr( aSet );
3136  SwFormatURL aURL2( aSet.Get( RES_URL ) );
3137  aURL2.SetURL( sFile, false );
3138  if( aURL2.GetName().isEmpty() )
3139  aURL2.SetName( sFile );
3140  aSet.Put( aURL2 );
3141  rSh.SetFlyFrameAttr( aSet );
3142  }
3143  break;
3144 
3145  default:
3146  {
3147  rSh.InsertURL( SwFormatINetFormat( sFile, OUString() ),
3148  sDesc.isEmpty() ? sFile : sDesc );
3149  }
3150  }
3151  bRet = true;
3152  }
3153  }
3154  }
3155  }
3156  return bRet;
3157 }
3158 
3160  SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bLink,
3161  const Point* pDragPt, bool bMsg )
3162 {
3163  bool bRet = false;
3164  OUString sText;
3165  if( rData.GetString( nFormat, sText ) && !sText.isEmpty() )
3166  {
3167  sal_uInt16 nWh = SotClipboardFormatId::SBA_CTRLDATAEXCHANGE == nFormat
3168  ? 0
3169  : SotClipboardFormatId::SBA_DATAEXCHANGE == nFormat
3170  ? (bLink
3172  : FN_QRY_INSERT)
3173  : (bLink
3174  ? 0
3175  : FN_QRY_INSERT_FIELD );
3176  const DataFlavorExVector& rVector = rData.GetDataFlavorExVector();
3177  bool bHaveColumnDescriptor = OColumnTransferable::canExtractColumnDescriptor(rVector, ColumnTransferFormatFlags::COLUMN_DESCRIPTOR | ColumnTransferFormatFlags::CONTROL_EXCHANGE);
3178  if ( SotClipboardFormatId::XFORMS == nFormat )
3179  {
3180  rSh.MakeDrawView();
3181  FmFormView* pFmView = dynamic_cast<FmFormView*>( rSh.GetDrawView() );
3182  if (pFmView && pDragPt)
3183  {
3184  const OXFormsDescriptor &rDesc = OXFormsTransferable::extractDescriptor(rData);
3185  SdrObjectUniquePtr pObj = pFmView->CreateXFormsControl(rDesc);
3186  if(pObj)
3187  {
3188  rSh.SwFEShell::InsertDrawObj( *(pObj.release()), *pDragPt );
3189  }
3190  }
3191  }
3192  else if( nWh )
3193  {
3194  std::unique_ptr<SfxUnoAnyItem> pConnectionItem;
3195  std::unique_ptr<SfxUnoAnyItem> pCursorItem;
3196  std::unique_ptr<SfxUnoAnyItem> pColumnItem;
3197  std::unique_ptr<SfxUnoAnyItem> pSourceItem;
3198  std::unique_ptr<SfxUnoAnyItem> pCommandItem;
3199  std::unique_ptr<SfxUnoAnyItem> pCommandTypeItem;
3200  std::unique_ptr<SfxUnoAnyItem> pColumnNameItem;
3201  std::unique_ptr<SfxUnoAnyItem> pSelectionItem;
3202 
3203  bool bDataAvailable = true;
3204  ODataAccessDescriptor aDesc;
3205  if(bHaveColumnDescriptor)
3206  aDesc = OColumnTransferable::extractColumnDescriptor(rData);
3207  else if(ODataAccessObjectTransferable::canExtractObjectDescriptor(rVector) )
3208  aDesc = ODataAccessObjectTransferable::extractObjectDescriptor(rData);
3209  else
3210  bDataAvailable = false;
3211 
3212  if ( bDataAvailable )
3213  {
3214  pConnectionItem.reset(new SfxUnoAnyItem(FN_DB_CONNECTION_ANY, aDesc[DataAccessDescriptorProperty::Connection]));
3215  pColumnItem.reset(new SfxUnoAnyItem(FN_DB_COLUMN_ANY, aDesc[DataAccessDescriptorProperty::ColumnObject]));
3216  pSourceItem.reset(new SfxUnoAnyItem(FN_DB_DATA_SOURCE_ANY, makeAny(aDesc.getDataSource())));
3217  pCommandItem.reset(new SfxUnoAnyItem(FN_DB_DATA_COMMAND_ANY, aDesc[DataAccessDescriptorProperty::Command]));
3218  pCommandTypeItem.reset(new SfxUnoAnyItem(FN_DB_DATA_COMMAND_TYPE_ANY, aDesc[DataAccessDescriptorProperty::CommandType]));
3219  pColumnNameItem.reset(new SfxUnoAnyItem(FN_DB_DATA_COLUMN_NAME_ANY, aDesc[DataAccessDescriptorProperty::ColumnName]));
3220  pSelectionItem.reset(new SfxUnoAnyItem(FN_DB_DATA_SELECTION_ANY, aDesc[DataAccessDescriptorProperty::Selection]));
3221  pCursorItem.reset(new SfxUnoAnyItem(FN_DB_DATA_CURSOR_ANY, aDesc[DataAccessDescriptorProperty::Cursor]));
3222  }
3223 
3224  SwView& rView = rSh.GetView();
3225  //force ::SelectShell
3226  rView.StopShellTimer();
3227 
3228  SfxStringItem aDataDesc( nWh, sText );
3230  nWh, SfxCallMode::ASYNCHRON,
3231  { &aDataDesc, pConnectionItem.get(), pColumnItem.get(),
3232  pSourceItem.get(), pCommandItem.get(), pCommandTypeItem.get(),
3233  pColumnNameItem.get(), pSelectionItem.get(),
3234  pCursorItem.get() });
3235  }
3236  else
3237  {
3238  rSh.MakeDrawView();
3239  FmFormView* pFmView = dynamic_cast<FmFormView*>( rSh.GetDrawView() );
3240  if (pFmView && bHaveColumnDescriptor && pDragPt)
3241  {
3242  SdrObjectUniquePtr pObj = pFmView->CreateFieldControl( OColumnTransferable::extractColumnDescriptor(rData) );
3243  if (pObj)
3244  rSh.SwFEShell::InsertDrawObj( *(pObj.release()), *pDragPt );
3245  }
3246  }
3247  bRet = true;
3248  }
3249  else if( bMsg )
3250  {
3251  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
3252  VclMessageType::Info, VclButtonsType::Ok,
3253  SwResId(STR_CLPBRD_FORMAT_ERROR)));
3254  xBox->run();
3255  }
3256  return bRet;
3257 }
3258 
3260  SwWrtShell& rSh, bool bLink,
3261  const Point* pPt, bool bMsg )
3262 {
3263  bool bRet = false;
3264  FileList aFileList;
3265  if( rData.GetFileList( SotClipboardFormatId::FILE_LIST, aFileList ) &&
3266  aFileList.Count() )
3267  {
3269  OUString sFlyNm;
3270  // iterate over the filelist
3271  for( sal_uLong n = 0, nEnd = aFileList.Count(); n < nEnd; ++n )
3272  {
3274  pHlp->CopyString( SotClipboardFormatId::SIMPLE_FILE, aFileList.GetFile( n ));
3275  TransferableDataHelper aData( pHlp );
3276 
3277  if( SwTransferable::PasteFileName( aData, rSh, SotClipboardFormatId::SIMPLE_FILE, nAct,
3278  pPt, SotExchangeActionFlags::NONE, nullptr ))
3279  {
3280  if( bLink )
3281  {
3282  sFlyNm = rSh.GetFlyName();
3283  SwTransferable::SetSelInShell( rSh, false, pPt );
3284  }
3285  bRet = true;
3286  }
3287  }
3288  if( !sFlyNm.isEmpty() )
3289  rSh.GotoFly( sFlyNm );
3290  }
3291  else if( bMsg )
3292  {
3293  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
3294  VclMessageType::Info, VclButtonsType::Ok,
3295  SwResId(STR_CLPBRD_FORMAT_ERROR)));
3296  xBox->run();
3297  }
3298  return bRet;
3299 }
3300 
3302  OUString& rFileName, OUString* pTitle )
3303 {
3304  bool bIsURLFile = false;
3305  INetBookmark aBkmk;
3306  if( rData.GetINetBookmark( SotClipboardFormatId::SOLK, aBkmk ) )
3307  {
3308  rFileName = aBkmk.GetURL();
3309  if( pTitle )
3310  *pTitle = aBkmk.GetDescription();
3311  bIsURLFile = true;
3312  }
3313  else
3314  {
3315  if( rFileName.getLength()>4 && rFileName.endsWithIgnoreAsciiCase(".url") )
3316  {
3317  OSL_ENSURE( false, "how do we read today .URL - Files?" );
3318  }
3319  }
3320  return bIsURLFile;
3321 }
3322 
3324  const TransferableDataHelper& rData )
3325 {
3326  // we can paste-special if there's an entry in the paste-special-format list
3327  SvxClipboardFormatItem aClipboardFormatItem(0);
3328  FillClipFormatItem( rWrtShell, rData, aClipboardFormatItem);
3329  return aClipboardFormatItem.Count() > 0;
3330 }
3331 
3333 {
3334  return ( GetSwTransferable( rData ) != nullptr );
3335 }
3336 
3338  TransferableDataHelper& rData,
3339  SotClipboardFormatId nFormat )
3340 {
3341  SwWait aWait( *rSh.GetView().GetDocShell(), false );
3342  bool bRet = false;
3343 
3344  SotClipboardFormatId nPrivateFormat = SotClipboardFormatId::PRIVATE;
3345  SwTransferable *pClipboard = GetSwTransferable( rData );
3346  if( pClipboard &&
3348  nPrivateFormat = SotClipboardFormatId::EMBED_SOURCE;
3349 
3350  if( pClipboard && nPrivateFormat == nFormat )
3351  bRet = pClipboard->PrivatePaste( rSh );
3352  else if( rData.HasFormat( nFormat ) )
3353  {
3354  uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
3355  sal_uInt8 nEventAction;
3356  SotExchangeDest nDestination = SwTransferable::GetSotDestination( rSh );
3357  sal_uInt16 nSourceOptions =
3358  (( SotExchangeDest::DOC_TEXTFRAME == nDestination ||
3359  SotExchangeDest::SWDOC_FREE_AREA == nDestination ||
3360  SotExchangeDest::DOC_TEXTFRAME_WEB == nDestination ||
3361  SotExchangeDest::SWDOC_FREE_AREA_WEB == nDestination )
3364  SotExchangeActionFlags nActionFlags;
3366  rData.GetDataFlavorExVector(),
3367  nDestination,
3368  nSourceOptions, /* ?? */
3369  EXCHG_IN_ACTION_DEFAULT, /* ?? */
3370  nFormat, nEventAction, nFormat,
3371  lcl_getTransferPointer ( xTransferable ),
3372  &nActionFlags );
3373 
3374  if( EXCHG_INOUT_ACTION_NONE != nAction )
3375  bRet = SwTransferable::PasteData( rData, rSh, nAction, nActionFlags, nFormat,
3376  nDestination, true, false );
3377  }
3378  return bRet;
3379 }
3380 
3382  SotClipboardFormatId nFormat, SotExchangeDest nDestination )
3383 {
3385  if( rData.HasFormat( nFormat )) {
3386  uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() );
3387  sal_uInt8 nEventAction;
3389  rData.GetDataFlavorExVector(),
3390  nDestination, EXCHG_IN_ACTION_COPY,
3391  EXCHG_IN_ACTION_COPY, nFormat,
3392  nEventAction, nFormat,
3393  lcl_getTransferPointer ( xTransferable ) );
3394  }
3395  return EXCHG_INOUT_ACTION_NONE != nAction;
3396 }
3397 
3403 {
3404  SotClipboardFormatId::HTML,
3405  SotClipboardFormatId::HTML_SIMPLE,
3406  SotClipboardFormatId::HTML_NO_COMMENT,
3407  SotClipboardFormatId::RTF,
3408  SotClipboardFormatId::RICHTEXT,
3409  SotClipboardFormatId::STRING,
3410  SotClipboardFormatId::SONLK,
3411  SotClipboardFormatId::NETSCAPE_BOOKMARK,
3412  SotClipboardFormatId::DRAWING,
3413  SotClipboardFormatId::SVXB,
3414  SotClipboardFormatId::GDIMETAFILE,
3415  SotClipboardFormatId::BITMAP,
3416  SotClipboardFormatId::SVIM,
3417  SotClipboardFormatId::FILEGRPDESCRIPTOR,
3418  SotClipboardFormatId::NONE
3419 };
3420 
3422 {
3423  // Plain text == unformatted
3424  return SwTransferable::PasteFormat( rSh, rData, SotClipboardFormatId::STRING );
3425 }
3426 
3428 {
3429  DataFlavorExVector aFormats( rData.GetDataFlavorExVector() );
3431 
3433 
3434  SwTransferable *pClipboard = GetSwTransferable( rData );
3435  if( pClipboard )
3436  {
3437  aDesc = pClipboard->m_aObjDesc;
3438  const char* pResId;
3439  if( pClipboard->m_eBufferType & TransferBufferType::Document )
3440  pResId = STR_PRIVATETEXT;
3441  else if( pClipboard->m_eBufferType & TransferBufferType::Graphic )
3442  pResId = STR_PRIVATEGRAPHIC;
3443  else if( pClipboard->m_eBufferType == TransferBufferType::Ole )
3444  pResId = STR_PRIVATEOLE;
3445  else
3446  pResId = nullptr;
3447 
3448  if (pResId)
3449  {
3450  if (strcmp(STR_PRIVATEOLE, pResId) == 0 || strcmp(STR_PRIVATEGRAPHIC, pResId) == 0)
3451  {
3452  // add SotClipboardFormatId::EMBED_SOURCE to the formats. This
3453  // format display then the private format name.
3454  DataFlavorEx aFlavorEx;
3455  aFlavorEx.mnSotId = SotClipboardFormatId::EMBED_SOURCE;
3456  aFormats.insert( aFormats.begin(), aFlavorEx );
3457  }
3458  pDlg->SetObjName( pClipboard->m_aObjDesc.maClassName,
3459  SwResId(pResId) );
3460  pDlg->Insert( SotClipboardFormatId::EMBED_SOURCE, OUString() );
3461  }
3462  }
3463  else
3464  {
3465  if( rData.HasFormat( SotClipboardFormatId::OBJECTDESCRIPTOR ) )
3466  {
3468  SotClipboardFormatId::OBJECTDESCRIPTOR, aDesc );
3469  }
3470 
3471  if( SwTransferable::TestAllowedFormat( rData, SotClipboardFormatId::EMBED_SOURCE, nDest ))
3472  pDlg->Insert( SotClipboardFormatId::EMBED_SOURCE, OUString() );
3473  if( SwTransferable::TestAllowedFormat( rData, SotClipboardFormatId::LINK_SOURCE, nDest ))
3474  pDlg->Insert( SotClipboardFormatId::LINK_SOURCE, OUString() );
3475  }
3476 
3477  if( SwTransferable::TestAllowedFormat( rData, SotClipboardFormatId::LINK, nDest ))
3478  pDlg->Insert( SotClipboardFormatId::LINK, SwResId(STR_DDEFORMAT) );
3479 
3480  for( SotClipboardFormatId* pIds = aPasteSpecialIds; *pIds != SotClipboardFormatId::NONE; ++pIds )
3481  if( SwTransferable::TestAllowedFormat( rData, *pIds, nDest ))
3482  pDlg->Insert( *pIds, OUString() );
3483 }
3484 
3486  const TransferableDataHelper& rData,
3487  SvxClipboardFormatItem & rToFill )
3488 {
3490 
3491  SwTransferable *pClipboard = GetSwTransferable( rData );
3492  if( pClipboard )
3493  {
3494  const char* pResId;
3495  if( pClipboard->m_eBufferType & TransferBufferType::Document )
3496  pResId = STR_PRIVATETEXT;
3497  else if( pClipboard->m_eBufferType & TransferBufferType::Graphic )
3498  pResId = STR_PRIVATEGRAPHIC;
3499  else if( pClipboard->m_eBufferType == TransferBufferType::Ole )
3500  pResId = STR_PRIVATEOLE;
3501  else
3502  pResId = nullptr;
3503 
3504  if (pResId)
3505  rToFill.AddClipbrdFormat(SotClipboardFormatId::EMBED_SOURCE,
3506  SwResId(pResId));
3507  }
3508  else
3509  {
3511  if (rData.HasFormat(SotClipboardFormatId::OBJECTDESCRIPTOR))
3512  {
3513  (void)const_cast<TransferableDataHelper&>(rData).GetTransferableObjectDescriptor(
3514  SotClipboardFormatId::OBJECTDESCRIPTOR, aDesc);
3515  }
3516 
3517  if( SwTransferable::TestAllowedFormat( rData, SotClipboardFormatId::EMBED_SOURCE, nDest ))
3518  rToFill.AddClipbrdFormat( SotClipboardFormatId::EMBED_SOURCE,
3519  aDesc.maTypeName );
3520  if( SwTransferable::TestAllowedFormat( rData, SotClipboardFormatId::LINK_SOURCE, nDest ))
3521  rToFill.AddClipbrdFormat( SotClipboardFormatId::LINK_SOURCE );
3522 
3523  SotClipboardFormatId nFormat;
3524  if ( rData.HasFormat(nFormat = SotClipboardFormatId::EMBED_SOURCE_OLE) || rData.HasFormat(nFormat = SotClipboardFormatId::EMBEDDED_OBJ_OLE) )
3525  {
3526  OUString sName,sSource;
3527  if ( SvPasteObjectHelper::GetEmbeddedName(rData,sName,sSource,nFormat) )
3528  rToFill.AddClipbrdFormat( nFormat, sName );
3529  }
3530  }
3531 
3532  if( SwTransferable::TestAllowedFormat( rData, SotClipboardFormatId::LINK, nDest ))
3533  rToFill.AddClipbrdFormat( SotClipboardFormatId::LINK, SwResId(STR_DDEFORMAT) );
3534 
3535  for( SotClipboardFormatId* pIds = aPasteSpecialIds; *pIds != SotClipboardFormatId::NONE; ++pIds )
3536  if( SwTransferable::TestAllowedFormat( rData, *pIds, nDest ))
3537  rToFill.AddClipbrdFormat(*pIds, OUString());
3538 }
3539 
3540 void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
3541 {
3542  if(!m_pWrtShell)
3543  return;
3544  OUString sGrfNm;
3545  const SelectionType nSelection = m_pWrtShell->GetSelectionType();
3546  if( SelectionType::Graphic == nSelection)
3547  {
3548  AddFormat( SotClipboardFormatId::SVXB );
3549  const Graphic* pGrf = m_pWrtShell->GetGraphic();
3550  if ( pGrf && pGrf->IsSupportedGraphic() )
3551  {
3552  AddFormat( SotClipboardFormatId::GDIMETAFILE );
3553  AddFormat( SotClipboardFormatId::PNG );
3554  AddFormat( SotClipboardFormatId::BITMAP );
3555  }
3557  m_pWrtShell->GetGrfNms( &sGrfNm, nullptr );
3558  }
3559  else if( SelectionType::Ole == nSelection )
3560  {
3561  AddFormat( SotClipboardFormatId::EMBED_SOURCE );
3563  AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
3564  AddFormat( SotClipboardFormatId::GDIMETAFILE );
3566  }
3567  //Is there anything to provide anyway?
3568  else if ( m_pWrtShell->IsSelection() || m_pWrtShell->IsFrameSelected() ||
3570  {
3571  if( m_pWrtShell->IsObjSelected() )
3573  else
3574  {
3576  if( SwWrtShell::NO_WORD !=
3577  m_pWrtShell->IntelligentCut( nSelection, false ))
3579  }
3580 
3581  if( nSelection & SelectionType::TableCell )
3583 
3584  AddFormat( SotClipboardFormatId::EMBED_SOURCE );
3585 
3586  //put RTF ahead of the OLE's Metafile for less loss
3587  if( !m_pWrtShell->IsObjSelected() )
3588  {
3589  AddFormat( SotClipboardFormatId::RTF );
3590  AddFormat( SotClipboardFormatId::RICHTEXT );
3591  AddFormat( SotClipboardFormatId::HTML );
3592  }
3593  if( m_pWrtShell->IsSelection() )
3594  AddFormat( SotClipboardFormatId::STRING );
3595 
3596  if( nSelection & ( SelectionType::DrawObject | SelectionType::DbForm ))
3597  {
3598  AddFormat( SotClipboardFormatId::DRAWING );
3599  if ( nSelection & SelectionType::DrawObject )
3600  {
3601  AddFormat( SotClipboardFormatId::GDIMETAFILE );
3602  AddFormat( SotClipboardFormatId::PNG );
3603  AddFormat( SotClipboardFormatId::BITMAP );
3604  }
3606 
3607  m_pClpGraphic.reset(new Graphic);
3608  if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::GDIMETAFILE, *m_pClpGraphic ))
3609  m_pOrigGraphic = m_pClpGraphic.get();
3610  m_pClpBitmap.reset(new Graphic);
3611  if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::BITMAP, *m_pClpBitmap ))
3612  m_pOrigGraphic = m_pClpBitmap.get();
3613 
3614  // is it a URL-Button ?
3615  OUString sURL;
3616  OUString sDesc;
3617  if( m_pWrtShell->GetURLFromButton( sURL, sDesc ) )
3618  {
3619  AddFormat( SotClipboardFormatId::STRING );
3620  AddFormat( SotClipboardFormatId::SOLK );
3621  AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
3622  AddFormat( SotClipboardFormatId::FILECONTENT );
3623  AddFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR );
3624  AddFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR );
3626  }
3627  }
3628 
3629  //ObjectDescriptor was already filled from the old DocShell.
3630  //Now adjust it. Thus in GetData the first query can still
3631  //be answered with delayed rendering.
3632  m_aObjDesc.maDragStartPos = rSttPos;
3634  MapMode(MapUnit::MapTwip), MapMode(MapUnit::Map100thMM));
3636  AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
3637  }
3638  else if( nSelection & SelectionType::Text && !m_pWrtShell->HasMark() )
3639  {
3640  // is only one field - selected?
3641  SwContentAtPos aContentAtPos( IsAttrAtPos::InetAttr );
3643 
3644  if( m_pWrtShell->GetContentAtPos( aPos, aContentAtPos ) )
3645  {
3646  AddFormat( SotClipboardFormatId::STRING );
3647  AddFormat( SotClipboardFormatId::SOLK );
3648  AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
3649  AddFormat( SotClipboardFormatId::FILECONTENT );
3650  AddFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR );
3651  AddFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR );
3653  }
3654  }
3655 
3656  if( !m_pWrtShell->IsFrameSelected() )
3657  return;
3658 
3660  m_pWrtShell->GetFlyFrameAttr( aSet );
3661  const SwFormatURL& rURL = aSet.Get( RES_URL );
3662  if( rURL.GetMap() )
3663  {
3664  m_pImageMap.reset( new ImageMap( *rURL.GetMap() ) );
3665  AddFormat( SotClipboardFormatId::SVIM );
3666  }
3667  else if( !rURL.GetURL().isEmpty() )
3668  {
3669  m_pTargetURL.reset(new INetImage( sGrfNm, rURL.GetURL(),
3670  rURL.GetTargetFrameName() ));
3671  AddFormat( SotClipboardFormatId::INET_IMAGE );
3672  }
3673 }
3674 
3675 void SwTransferable::StartDrag( vcl::Window* pWin, const Point& rPos )
3676 {
3677  if(!m_pWrtShell)
3678  return;
3680  m_bCleanUp = true;
3681 
3682  m_pWrtShell->GetViewOptions()->SetIdle( false );
3683 
3684  if( m_pWrtShell->IsSelFrameMode() )
3686 
3687  SW_MOD()->m_pDragDrop = this;
3688 
3689  SetDataForDragAndDrop( rPos );
3690 
3691  sal_Int8 nDragOptions = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
3692  SwDocShell* pDShell = m_pWrtShell->GetView().GetDocShell();
3693  if( ( pDShell && pDShell->IsReadOnly() ) || m_pWrtShell->HasReadonlySel() )
3694  nDragOptions &= ~DND_ACTION_MOVE;
3695 
3696  TransferableHelper::StartDrag( pWin, nDragOptions );
3697 }
3698 
3700 {
3701  //And the last finishing work so that all statuses are right
3702  if( DND_ACTION_MOVE == nAction )
3703  {
3704  if( m_bCleanUp )
3705  {
3706  //It was dropped outside of Writer. We still have to
3707  //delete.
3708 
3711  if ( m_pWrtShell->IsTableMode() )
3713  else
3714  {
3716  //SmartCut, take one of the blanks along
3718  m_pWrtShell->DelRight();
3719  }
3722  }
3723  else
3724  {
3725  const SelectionType nSelection = m_pWrtShell->GetSelectionType();
3728  {
3730  }
3731  }
3732  }
3734 
3735  if( m_pWrtShell->IsSelFrameMode() )
3737  else
3739 
3741 }
3742 
3743 namespace
3744 {
3745 
3746 bool lcl_checkClassification(SwDoc* pSourceDoc, SwDoc* pDestinationDoc)
3747 {
3748  if (!pSourceDoc || !pDestinationDoc)
3749  return true;
3750 
3751  SwDocShell* pSourceShell = pSourceDoc->GetDocShell();
3752  SwDocShell* pDestinationShell = pDestinationDoc->GetDocShell();
3753  if (!pSourceShell || !pDestinationShell)
3754  return true;
3755 
3758 }
3759 
3760 }
3761 
3763 {
3764  // first, ask for the SelectionType, then action-bracketing !!!!
3765  // (otherwise it's not pasted into a TableSelection!!!)
3766  OSL_ENSURE( !rShell.ActionPend(), "Paste must never have an ActionPend" );
3767  if ( !m_pClpDocFac )
3768  return false; // the return value of the SwFEShell::Paste also is bool!
3769 
3770  const SelectionType nSelection = rShell.GetSelectionType();
3771 
3772  SwTrnsfrActionAndUndo aAction( &rShell );
3773 
3774  bool bKillPaMs = false;
3775 
3776  //Delete selected content, not at table-selection and table in Clipboard, and don't delete hovering graphics.
3777  if( rShell.HasSelection() && !( nSelection & SelectionType::TableCell) && !( nSelection & SelectionType::DrawObject))
3778  {
3779  if (!(nSelection & SelectionType::NumberList))
3780  {
3781  bKillPaMs = true;
3782  rShell.SetRetainSelection( true );
3783  }
3784  if (pContext)
3785  pContext->forget();
3786  rShell.DelRight();
3787  if (pContext)
3788  pContext->remember();
3789  // when a Fly was selected, a valid cursor position has to be found now
3790  // (parked Cursor!)
3792  SelectionType::Ole | SelectionType::DrawObject |
3793  SelectionType::DbForm ) & nSelection )
3794  {
3795  // position the cursor again
3796  Point aPt( rShell.GetCharRect().Pos() );
3797  rShell.SwCursorShell::SetCursor( aPt, true );
3798  }
3799  if (!(nSelection & SelectionType::NumberList))
3800  {
3801  rShell.SetRetainSelection( false );
3802  }
3803  }
3804  if ( nSelection & SelectionType::DrawObject) //unselect hovering graphics
3805  {
3806  rShell.ResetSelect(nullptr,false);
3807  }
3808 
3809  bool bInWrd = false, bEndWrd = false, bSttWrd = false,
3811  if( bSmart )
3812  {
3813  // Why not for other Scripts? If TransferBufferType::DocumentWord is set, we have a word
3814  // in the buffer, word in this context means 'something with spaces at beginning
3815  // and end'. In this case we definitely want these spaces to be inserted here.
3816  bInWrd = rShell.IsInWord();
3817  bEndWrd = rShell.IsEndWrd();
3818  bSmart = bInWrd || bEndWrd;
3819  if( bSmart )
3820  {
3821  bSttWrd = rShell.IsStartWord();
3822  if (!bSttWrd && (bInWrd || bEndWrd))
3823  rShell.SwEditShell::Insert(' ');
3824  }
3825  }
3826 
3827  bool bRet = true;
3828  // m_pWrtShell is nullptr when the source document is closed already.
3829  if (!m_pWrtShell || lcl_checkClassification(m_pWrtShell->GetDoc(), rShell.GetDoc()))
3830  bRet = rShell.Paste(m_pClpDocFac->GetDoc(), ePasteTable == PasteTableType::PASTE_TABLE);
3831 
3832  if( bKillPaMs )
3833  rShell.KillPams();
3834 
3835  // If Smart Paste then insert blank
3836  if( bRet && bSmart && ((bInWrd && !bEndWrd )|| bSttWrd) )
3837  rShell.SwEditShell::Insert(' ');
3838 
3839  return bRet;
3840 }
3841 
3842 bool SwTransferable::PrivateDrop( SwWrtShell& rSh, const Point& rDragPt,
3843  bool bMove, bool bIsXSelection )
3844 {
3845  int cWord = 0;
3846  bool bInWrd = false;
3847  bool bEndWrd = false;
3848  bool bSttWrd = false;
3849  bool bSttPara = false;
3850  bool bTableSel = false;
3851  bool bTableMove = false;
3852  bool bFrameSel = false;
3853 
3854  SwWrtShell& rSrcSh = *GetShell();
3855 
3856  rSh.UnSetVisibleCursor();
3857 
3859  {
3860  if( rSh.GetFormatFromObj( rDragPt ) )
3861  {
3862  INetBookmark aTmp;
3864  aTmp = *m_pBookmark;
3865 
3866  // select target graphic
3867  if( rSh.SelectObj( rDragPt ) )
3868  {
3869  rSh.HideCursor();
3870  rSh.EnterSelFrameMode( &rDragPt );
3871  g_bFrameDrag = true;
3872  }
3873 
3874  const SelectionType nSelection = rSh.GetSelectionType();
3875 
3876  // not yet consider Draw objects
3877  if( SelectionType::Graphic & nSelection )
3878  {
3880  rSh.GetFlyFrameAttr( aSet );
3881  SwFormatURL aURL( aSet.Get( RES_URL ) );
3882  aURL.SetURL( aTmp.GetURL(), false );
3883  aSet.Put( aURL );
3884  rSh.SetFlyFrameAttr( aSet );
3885  return true;
3886  }
3887 
3888  if( SelectionType::DrawObject & nSelection )
3889  {
3890  rSh.LeaveSelFrameMode();
3891  rSh.UnSelectFrame();
3892  rSh.ShowCursor();
3893  g_bFrameDrag = false;
3894  }
3895  }
3896  }
3897 
3898  if( &rSh != &rSrcSh && (SelectionType::Graphic & rSh.GetSelectionType()) &&
3900  {
3901  // ReRead the graphic
3902  OUString sGrfNm;
3903  OUString sFltNm;
3904  rSrcSh.GetGrfNms( &sGrfNm, &sFltNm );
3905  rSh.ReRead( sGrfNm, sFltNm, rSrcSh.GetGraphic() );
3906  return true;
3907  }
3908 
3909  //not in selections or selected frames
3910  if( rSh.TestCurrPam( rDragPt ) ||
3911  ( rSh.IsSelFrameMode() && rSh.IsInsideSelectedObj( rDragPt )) )
3912  return false;
3913 
3914  if( rSrcSh.IsTableMode() )
3915  {
3916  bTableSel = true;
3917  const SelectionType nSelection = rSrcSh.GetSelectionType();
3918  // at enhanced table row/column selection or wholly selected tables,
3919  // paste rows above or columns before, and in the case of moving, remove the selection
3920  // (limit only to the single document case temporarily)
3921  if( rSrcSh.GetDoc() == rSh.GetDoc() &&
3922  ( (( SelectionType::TableRow | SelectionType::TableCol) & nSelection ) || rSrcSh.HasWholeTabSelection() ) )
3923  {
3924  bool bTableCol(SelectionType::TableCol & nSelection);
3925 
3927 
3928  SwRewriter aRewriter;
3929 
3930  aRewriter.AddRule(UndoArg1, rSrcSh.GetSelDescr());
3931 
3932  if(rSrcSh.GetDoc() != rSh.GetDoc())
3933  rSrcSh.StartUndo( eUndoId, &aRewriter );
3934  rSh.StartUndo( eUndoId, &aRewriter );
3935 
3936  rSh.StartAction();
3937  rSrcSh.StartAction();
3938 
3939  SfxDispatcher* pDispatch = rSrcSh.GetView().GetViewFrame()->GetDispatcher();
3940  pDispatch->Execute(SID_COPY, SfxCallMode::SYNCHRON);
3941 
3942  rSrcSh.Push(); // save selection for later restoration
3943  rSh.EnterStdMode();
3944  rSh.SwCursorShell::SetCursor(rDragPt, false);
3945 
3946  // store cursor
3947  ::sw::mark::IMark* pMark = rSh.SetBookmark(
3948  vcl::KeyCode(),
3949  OUString(),
3951 
3952  rSrcSh.Pop(SwCursorShell::PopMode::DeleteCurrent); // restore selection...
3953 
3954  // delete source rows/columns
3955  if (bMove)
3956  pDispatch->Execute(bTableCol ? FN_TABLE_DELETE_COL : FN_TABLE_DELETE_ROW, SfxCallMode::SYNCHRON);
3957 
3958  // restore cursor position
3959  if (pMark != nullptr)
3960  {
3961  rSh.GotoMark( pMark );
3962  rSh.getIDocumentMarkAccess()->deleteMark( pMark );
3963  }
3964 
3965  // paste rows above/columns before
3966  pDispatch->Execute(bTableCol ? FN_TABLE_PASTE_COL_BEFORE : FN_TABLE_PASTE_ROW_BEFORE, SfxCallMode::SYNCHRON);
3967 
3968  if( rSrcSh.GetDoc() != rSh.GetDoc() )
3969  rSrcSh.EndUndo();
3970 
3971  rSh.DestroyCursor();
3972  rSh.EndUndo();
3973  rSh.EndAction();
3974  rSh.EndAction();
3975  return true;
3976  }
3977 
3978  if ( bMove && rSrcSh.HasWholeTabSelection() )
3979  bTableMove = true;
3980  }
3981  else if( rSrcSh.IsSelFrameMode() || rSrcSh.IsObjSelected() )
3982  {
3983  // don't move position-protected objects!
3985  return false;
3986 
3987  bFrameSel = true;
3988  }
3989 
3990  const SelectionType nSel = rSrcSh.GetSelectionType();
3991 
3993 
3994  SwRewriter aRewriter;
3995 
3996  aRewriter.AddRule(UndoArg1, rSrcSh.GetSelDescr());
3997 
3998  if(rSrcSh.GetDoc() != rSh.GetDoc())
3999  rSrcSh.StartUndo( eUndoId, &aRewriter );
4000  rSh.StartUndo( eUndoId, &aRewriter );
4001 
4002  rSh.StartAction();
4003  rSrcSh.StartAction();
4004 
4005  if( &rSrcSh != &rSh )
4006  {
4007  rSh.EnterStdMode();
4008  rSh.SwCursorShell::SetCursor( rDragPt, true );
4009  cWord = rSrcSh.IntelligentCut( nSel, false );
4010  }
4011  else if( !bTableSel && !bFrameSel )
4012  {
4013  if( !rSh.IsAddMode() )
4014  {
4015  // #i87233#
4016  if ( rSh.IsBlockMode() )
4017  {
4018  // preserve order of cursors for block mode
4019  rSh.GoPrevCursor();
4020  }
4021 
4022  rSh.SwCursorShell::CreateCursor();
4023  }
4024  rSh.SwCursorShell::SetCursor( rDragPt, true, false );
4025  rSh.GoPrevCursor();
4026  cWord = rSh.IntelligentCut( rSh.GetSelectionType(), false );
4027  rSh.GoNextCursor();
4028  }
4029 
4030  bInWrd = rSh.IsInWord();
4031  bEndWrd = rSh.IsEndWrd();
4032  bSttWrd = !bEndWrd && rSh.IsStartWord();
4033  bSttPara= rSh.IsSttPara();
4034 
4036 
4037  // at first, select InetFields!
4039  {
4040  if( &rSrcSh == &rSh )
4041  {
4042  rSh.GoPrevCursor();
4043  rSh.SwCursorShell::SetCursor( aSttPt, true );
4045  if( rSh.TestCurrPam( rDragPt ) )
4046  {
4047  // don't copy/move inside of yourself
4048  rSh.DestroyCursor();
4049  rSh.EndUndo();
4050  rSh.EndAction();
4051  rSh.EndAction();
4052  return false;
4053  }
4054  rSh.GoNextCursor();
4055  }
4056  else
4057  {
4058  rSrcSh.SwCursorShell::SetCursor( aSttPt, true );
4060  }
4061 
4062  // is there a URL attribute at the insert point? Then replace that,
4063  // so simply put up a selection?
4064  rSh.DelINetAttrWithText();
4065  g_bDDINetAttr = true;
4066  }
4067 
4068  if ( rSrcSh.IsSelFrameMode() )
4069  {
4070  //Hack: fool the special treatment
4071  aSttPt = rSrcSh.GetObjRect().Pos();
4072  }
4073 
4074  bool bRet = rSrcSh.SwFEShell::Copy(rSh, aSttPt, rDragPt, bMove,
4075  !bIsXSelection);
4076 
4077  if( !bIsXSelection )
4078  {
4079  rSrcSh.Push();
4080  if ( bRet && bMove && !bFrameSel )
4081  {
4082  if ( bTableSel )
4083  {
4084  /* delete table contents not cells */
4085  rSrcSh.Delete();
4086  }
4087  else
4088  {
4089  //SmartCut, take one of the blanks along.
4090  rSh.SwCursorShell::DestroyCursor();
4091  if ( cWord == SwWrtShell::WORD_SPACE_BEFORE )
4092  rSh.ExtendSelection( false );
4093  else if ( cWord == SwWrtShell::WORD_SPACE_AFTER )
4094  rSh.ExtendSelection();
4095  rSrcSh.DelRight();
4096  }
4097  }
4098  rSrcSh.KillPams();
4100 
4101  /* after dragging a table selection inside one shell
4102  set cursor to the drop position. */
4103  if( &rSh == &rSrcSh && ( bTableSel || rSh.IsBlockMode() ) )
4104  {
4105  rSrcSh.CalcLayout();
4106  rSrcSh.SwCursorShell::SetCursor(rDragPt);
4107  rSrcSh.GetSwCursor()->SetMark();
4108  }
4109  }
4110 
4111  if( bRet && !bTableSel && !bFrameSel )
4112  {
4113  if( (bInWrd || bEndWrd) &&
4114  (cWord == SwWrtShell::WORD_SPACE_AFTER ||
4115  cWord == SwWrtShell::WORD_SPACE_BEFORE) )
4116  {
4117  if ( bSttWrd || (bInWrd && !bEndWrd))
4118  rSh.SwEditShell::Insert(' ', bIsXSelection);
4119  if ( !bSttWrd || (bInWrd && !bSttPara) )
4120  {
4121  rSh.SwapPam();
4122  if ( !bSttWrd )
4123  rSh.SwEditShell::Insert(' ', bIsXSelection);
4124  rSh.SwapPam();
4125  }
4126  }
4127 
4128  if( bIsXSelection )
4129  {
4130  if( &rSrcSh == &rSh && !rSh.IsAddMode() )
4131  {
4132  rSh.SwCursorShell::DestroyCursor();
4133  rSh.GoPrevCursor();
4134  }
4135  else
4136  {
4137  rSh.SwapPam();
4138  rSh.SwCursorShell::ClearMark();
4139  }
4140  }
4141  else
4142  {
4143  if( rSh.IsAddMode() )
4144  rSh.SwCursorShell::CreateCursor();
4145  else
4146  {
4147  // turn on selection mode
4148  rSh.SttSelect();
4149  rSh.EndSelect();
4150  }
4151  }
4152  }
4153  else if ( bRet && bTableMove )
4154  {
4155  SfxDispatcher* pDispatch = rSrcSh.GetView().GetViewFrame()->GetDispatcher();
4156  pDispatch->Execute(FN_TABLE_DELETE_TABLE, SfxCallMode::SYNCHRON);
4157  }
4158 
4159  if( bRet && bMove && bFrameSel )
4160  rSrcSh.LeaveSelFrameMode();
4161 
4162  if( rSrcSh.GetDoc() != rSh.GetDoc() )
4163  rSrcSh.EndUndo();
4164  rSh.EndUndo();
4165 
4166  // put the shell in the right state
4167  if( &rSrcSh != &rSh && ( rSh.IsFrameSelected() || rSh.IsObjSelected() ))
4168  rSh.EnterSelFrameMode();
4169 
4170  rSrcSh.EndAction();
4171  rSh.EndAction();
4172  return true;
4173 }
4174 
4175 // Interfaces for Selection
4177  const SwFrameShell * _pCreatorView )
4178 {
4179  SwModule *pMod = SW_MOD();
4181 
4182  pNew->m_pCreatorView = _pCreatorView;
4183 
4184  pMod->m_pXSelection = pNew.get();
4185  pNew->CopyToSelection( rSh.GetWin() );
4186 }
4187 
4189  const SwFrameShell * _pCreatorView)
4190 {
4191  SwModule *pMod = SW_MOD();
4192  if( pMod->m_pXSelection &&
4193  ((!pMod->m_pXSelection->m_pWrtShell) || (pMod->m_pXSelection->m_pWrtShell == &rSh)) &&
4194  (!_pCreatorView || (pMod->m_pXSelection->m_pCreatorView == _pCreatorView)) )
4195  {
4197  }
4198 }
4199 
4200 namespace
4201 {
4202  class theSwTransferableUnoTunnelId : public rtl::Static< UnoTunnelIdInit, SwTransferable > {};
4203 }
4204 
4205 const Sequence< sal_Int8 >& SwTransferable::getUnoTunnelId()
4206 {
4207  return theSwTransferableUnoTunnelId::get().getSeq();
4208 }
4209 
4210 sal_Int64 SwTransferable::getSomething( const Sequence< sal_Int8 >& rId )
4211 {
4212  sal_Int64 nRet;
4213  if( isUnoTunnelId<SwTransferable>(rId) )
4214  {
4215  nRet = sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) );
4216  }
4217  else
4219  return nRet;
4220 }
4221 
4223 {
4224  return comphelper::getUnoTunnelImplementation<SwTransferable>(rData.GetTransferable());
4225 }
4226 
4227 SwTransferDdeLink::SwTransferDdeLink( SwTransferable& rTrans, SwWrtShell& rSh )
4228  : rTrnsfr(rTrans)
4229  , pDocShell(nullptr)
4230  , nOldTimeOut(0)
4231  , bDelBookmrk(false)
4232  , bInDisconnect(false)
4233 {
4234  // we only end up here with table- or text selection
4236  {
4237  SwFrameFormat* pFormat = rSh.GetTableFormat();
4238  if( pFormat )
4239  sName = pFormat->GetName();
4240  }
4241  else
4242  {
4243  // creating a temp. bookmark without undo
4244  bool bUndo = rSh.DoesUndo();
4245  rSh.DoUndo( false );
4246  bool bIsModified = rSh.IsModified();
4247 
4248  ::sw::mark::IMark* pMark = rSh.SetBookmark(
4249  vcl::KeyCode(),
4250  OUString(),
4252  if(pMark)
4253  {
4254  sName = pMark->GetName();
4255  bDelBookmrk = true;
4256  if( !bIsModified )
4257  rSh.ResetModified();
4258  }
4259  else
4260  sName.clear();
4261  rSh.DoUndo( bUndo );
4262  }
4263 
4264  if( sName.isEmpty() ||
4265  nullptr == ( pDocShell = rSh.GetDoc()->GetDocShell() ))
4266  return;
4267 
4268  // then we create our "server" and connect to it
4269  refObj = pDocShell->DdeCreateLinkSource( sName );
4270  if( refObj.is() )
4271  {
4272  refObj->AddConnectAdvise( this );
4273  refObj->AddDataAdvise( this,
4274  OUString(),
4275  ADVISEMODE_NODATA | ADVISEMODE_ONLYONCE );
4276  nOldTimeOut = refObj->GetUpdateTimeout();
4277  refObj->SetUpdateTimeout( 0 );
4278  }
4279 }
4280 
4281 SwTransferDdeLink::~SwTransferDdeLink()
4282 {
4283  if( refObj.is() )
4284  Disconnect( true );
4285 }
4286 
4287 ::sfx2::SvBaseLink::UpdateResult SwTransferDdeLink::DataChanged( const OUString& ,
4288  const uno::Any& )
4289 {
4290  // well, that's it with the link
4291  if( !bInDisconnect )
4292  {
4293  if( FindDocShell() && pDocShell->GetView() )
4294  rTrnsfr.RemoveDDELinkFormat( pDocShell->GetView()->GetEditWin() );
4295  Disconnect( false );
4296  }
4297  return SUCCESS;
4298 }
4299 
4300 bool SwTransferDdeLink::WriteData( SvStream& rStrm )
4301 {
4302  if( !refObj.is() || !FindDocShell() )
4303  return false;
4304 
4305  rtl_TextEncoding eEncoding = osl_getThreadTextEncoding();
4306  const OString aAppNm(OUStringToOString(
4307  Application::GetAppName(), eEncoding));
4308  const OString aTopic(OUStringToOString(
4309  pDocShell->GetTitle(SFX_TITLE_FULLNAME), eEncoding));
4310  const OString aName(OUStringToOString(sName, eEncoding));
4311 
4312  std::unique_ptr<char[]> pMem(new char[ aAppNm.getLength() + aTopic.getLength() + aName.getLength() + 4 ]);
4313 
4314  sal_Int32 nLen = aAppNm.getLength();
4315  memcpy( pMem.get(), aAppNm.getStr(), nLen );
4316  pMem[ nLen++ ] = 0;
4317  memcpy( pMem.get() + nLen, aTopic.getStr(), aTopic.getLength() );
4318  nLen = nLen + aTopic.getLength();
4319  pMem[ nLen++ ] = 0;
4320  memcpy( pMem.get() + nLen, aName.getStr(), aName.getLength() );
4321  nLen = nLen + aName.getLength();
4322  pMem[ nLen++ ] = 0;
4323  pMem[ nLen++ ] = 0;
4324 
4325  rStrm.WriteBytes( pMem.get(), nLen );
4326  pMem.reset();
4327 
4328  IDocumentMarkAccess* const pMarkAccess = pDocShell->GetDoc()->getIDocumentMarkAccess();
4329  IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->findMark(sName);
4330  if(ppMark != pMarkAccess->getAllMarksEnd()
4332  {
4333  // the mark is still a DdeBookmark
4334  // we replace it with a Bookmark, so it will get saved etc.
4335  ::sw::mark::IMark* const pMark = *ppMark;
4336  ::sfx2::SvLinkSource* p = refObj.get();
4337  SwServerObject& rServerObject = dynamic_cast<SwServerObject&>(*p);
4338 
4339  // collecting state of old mark
4340  SwPaM aPaM(pMark->GetMarkStart());
4341  *aPaM.GetPoint() = pMark->GetMarkStart();
4342  if(pMark->IsExpanded())
4343  {
4344  aPaM.SetMark();
4345  *aPaM.GetMark() = pMark->GetMarkEnd();
4346  }
4347  OUString sMarkName = pMark->GetName();
4348 
4349  // remove mark
4350  rServerObject.SetNoServer(); // this removes the connection between SwServerObject and mark
4351  // N.B. ppMark was not loaded from file and cannot have xml:id
4352  pMarkAccess->deleteMark(ppMark);
4353 
4354  // recreate as Bookmark
4355  ::sw::mark::IMark* const pNewMark = pMarkAccess->makeMark(
4356  aPaM,
4357  sMarkName,
4360  rServerObject.SetDdeBookmark(*pNewMark);
4361  }
4362 
4363  bDelBookmrk = false;
4364  return true;
4365 }
4366 
4367 void SwTransferDdeLink::Disconnect( bool bRemoveDataAdvise )
4368 {
4369  // don't accept DataChanged anymore, when already in Disconnect!
4370  // (DTOR from Bookmark sends a DataChanged!)
4371  bool bOldDisconnect = bInDisconnect;
4372  bInDisconnect = true;
4373 
4374  // destroy the unused bookmark again (without Undo!)?
4375  if( bDelBookmrk && refObj.is() && FindDocShell() )
4376  {
4377  SwDoc* pDoc = pDocShell->GetDoc();
4378  ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
4379 
4380  // #i58448#
4381  Link<bool,void> aSavedOle2Link( pDoc->GetOle2Link() );
4382  pDoc->SetOle2Link( Link<bool,void>() );
4383 
4384  bool bIsModified = pDoc->getIDocumentState().IsModified();
4385 
4386  IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
4387  pMarkAccess->deleteMark(pMarkAccess->findMark(sName));
4388 
4389  if( !bIsModified )
4390  pDoc->getIDocumentState().ResetModified();
4391  // #i58448#
4392  pDoc->SetOle2Link( aSavedOle2Link );
4393 
4394  bDelBookmrk = false;
4395  }
4396 
4397  if( refObj.is() )
4398  {
4399  refObj->SetUpdateTimeout( nOldTimeOut );
4400  refObj->RemoveConnectAdvise( this );
4401  if( bRemoveDataAdvise )
4402  // in a DataChanged the SelectionObject must NEVER be deleted
4403  // is already handled by the base class
4404  // (ADVISEMODE_ONLYONCE!!!!)
4405  // but always in normal Disconnect!
4406  refObj->RemoveAllDataAdvise( this );
4407  refObj.clear();
4408  }
4409  bInDisconnect = bOldDisconnect;
4410 }
4411 
4412 bool SwTransferDdeLink::FindDocShell()
4413 {
4414  SfxObjectShell* pTmpSh = SfxObjectShell::GetFirst( checkSfxObjectShell<SwDocShell> );
4415  while( pTmpSh )
4416  {
4417  if( pTmpSh == pDocShell ) // that's what we want to have
4418  {
4419  if( pDocShell->GetDoc() )
4420  return true;
4421  break; // the Doc is not there anymore, so leave!
4422  }
4423  pTmpSh = SfxObjectShell::GetNext( *pTmpSh, checkSfxObjectShell<SwDocShell> );
4424  }
4425 
4426  pDocShell = nullptr;
4427  return false;
4428 }
4429 
4430 void SwTransferDdeLink::Closed()
4431 {
4432  if( !bInDisconnect && refObj.is() )
4433  {
4434  refObj->RemoveAllDataAdvise( this );
4435  refObj->RemoveConnectAdvise( this );
4436  refObj.clear();
4437  }
4438 }
4439 
4440 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwFieldType * GetFieldType(size_t nField, SwFieldIds nResId=SwFieldIds::Unknown) const
get field types with a ResId, if 0 get all
Definition: edfld.cxx:64
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SfxViewFrame * GetViewFrame() const
bool UnloadObject()
Definition: ndole.cxx:973
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:240
bool is() const
void StopShellTimer()
Definition: view.cxx:1752
static bool IsPasteOwnFormat(const TransferableDataHelper &)
Definition: swdtflvr.cxx:3332
SwWrtShell * GetShell()
Definition: swdtflvr.hxx:227
#define EXCHG_IN_ACTION_COPY
#define FN_DB_CONNECTION_ANY
Definition: cmdid.h:736
bool Paste(SwDoc &rClpDoc, bool bNestedTable=false)
Definition: fecopy.cxx:710
#define FN_DB_DATA_SOURCE_ANY
Definition: cmdid.h:738
bool GetGraphic(SotClipboardFormatId nFormat, Graphic &rGraphic)
virtual void SetVisArea(const tools::Rectangle &rVisArea)
const ::utl::TransliterationWrapper & GetAppCmpStrIgnore()
Definition: init.cxx:791
bool SetINetImage(const INetImage &rINtImg, const css::datatransfer::DataFlavor &rFlavor)
static OUString GetAppName()
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
#define EXCHG_IN_ACTION_MOVE
void KillPams()
Definition: crsrsh.cxx:1025
URL aURL
void SetDataForDragAndDrop(const Point &rSttPos)
Definition: swdtflvr.cxx:3540
sal_uLong GetIndex() const
Definition: node.hxx:291
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
static SwTransferable * GetSwTransferable(const TransferableDataHelper &rData)
Definition: swdtflvr.cxx:4222
#define FN_TABLE_INSERT_COL_BEFORE
Definition: cmdid.h:358
bool hasValue()
sal_Int32 nIndex
SwTransferable(const SwTransferable &)=delete
static tools::Long GetDDStartPosX()
Definition: edtwin.hxx:249
static bool PasteAsHyperlink(TransferableDataHelper &rData, SwWrtShell &rSh, SotClipboardFormatId nFormat)
Definition: swdtflvr.cxx:3014
#define EXCHG_OUT_ACTION_INSERT_STRING
bool GetSotStorageStream(SotClipboardFormatId nFormat, tools::SvRef< SotTempStream > &rStreamRef)
virtual const OUString & GetName() const =0
Marks a position in the document model.
Definition: pam.hxx:35
SwTransferable * m_pXSelection
Definition: swmodule.hxx:128
TransferableObjectDescriptor m_aObjDesc
Definition: swdtflvr.hxx:79
css::uno::Any GetAny(SotClipboardFormatId nFormat, const OUString &rDestDoc) const
bool SetBitmapEx(const BitmapEx &rBitmap, const css::datatransfer::DataFlavor &rFlavor)
bool isContentExtractionLocked() const
SdrView * GetDrawView()
Definition: vnew.cxx:375
void AutoCaption(const sal_uInt16 nType, const SvGlobalName *pOleId=nullptr)
Definition: viewdlg2.cxx:179
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:194
const OUString & GetImageURL() const
void readGraphic(Graphic &rGraphic)
void SaveTableBoxContent(const SwPosition *pPos=nullptr)
Definition: trvltbl.cxx:870
void InsertDDETable(const SwInsertTableOptions &rInsTableOpts, SwDDEFieldType *pDDEType, sal_uInt16 nRows, sal_uInt16 nCols)
Definition: edtab.cxx:226
tools::SvRef< sfx2::SvBaseLink > m_xDdeLink
Definition: swdtflvr.hxx:80
SAL_DLLPRIVATE void SetProtectFlag(bool const bFlag)
Definition: section.hxx:105
SwTable::SearchType GetTableInsertMode() const
Definition: fesh.hxx:646
void SetLinkFileName(OUString const &rNew)
Definition: section.hxx:117
static css::uno::Reference< css::embed::XStorage > GetStorageFromInputStream(const css::uno::Reference< css::io::XInputStream > &xStream, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
void ReRead(const OUString &rGrfName, const OUString &rFltName, const Graphic *pGraphic=nullptr)
Re-read if graphic is not ok. Current graphic is replaced by the new one.
Definition: editsh.cxx:295
const OUString & GetText() const
Definition: ndtxt.hxx:211
std::unique_ptr< SwPaM > m_pPaM
Definition: swdtflvr.cxx:210
bool GoNextCursor()
go to the next SSelection
Definition: crsrsh.cxx:1360
SwUndoId
Definition: swundo.hxx:29
SwDocShell * GetDocShell()
Definition: doc.hxx:1354
bool g_bExecuteDrag
Definition: edtdd.cxx:45
bool GetURLFromButton(OUString &rURL, OUString &rDescr) const
Definition: wrtsh3.cxx:197
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
const OUString & GetTargetURL() const
void AddTransferable(SwTransferable &rTransferable)
Definition: view.cxx:1860
constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_DRAWMODEL
Definition: swdtflvr.cxx:138
signed char sal_Int8
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
SwNodeIndex nNode
Definition: pam.hxx:37
bool IsTableMode() const
Definition: crsrsh.hxx:643
bool IsSttPara() const
Definition: crsrsh.cxx:1098
bool Is() const
#define FN_TABLE_DELETE_TABLE
Definition: cmdid.h:372
static sal_uInt8 GetExchangeAction(const DataFlavorExVector &rDataFlavorExVector, SotExchangeDest nDestination, sal_uInt16 nSourceOptions, sal_uInt8 nUserAction, SotClipboardFormatId &rFormat, sal_uInt8 &rDefaultAction, SotClipboardFormatId nOnlyTestFormat=SotClipboardFormatId::NONE, const css::uno::Reference< css::datatransfer::XTransferable > *pxTransferable=nullptr, SotExchangeActionFlags *pActionFlags=nullptr)
SfxDispatcher * GetDispatcher()
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
int PrepareForCopy(bool bIsCut=false)
Definition: swdtflvr.cxx:950
static bool IsPaste(const SwWrtShell &, const TransferableDataHelper &)
Definition: swdtflvr.cxx:1376
::std::vector< DataFlavorEx > DataFlavorExVector
sal_uIntPtr sal_uLong
constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_RICHTEXT
Definition: swdtflvr.cxx:144
void SetPrefMapMode(const MapMode &rPrefMapMode)
Size GetObjSize() const
Definition: feshview.cxx:2293
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:476
bool PrivateDrop(SwWrtShell &rSh, const Point &rDragPt, bool bMove, bool bIsXSelection)
Definition: swdtflvr.cxx:3842
const SfxPoolItem * pAttr
Definition: crsrsh.hxx:96
void DeleteTable()
Definition: fetab.cxx:307
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1714
bool SetTransferableObjectDescriptor(const TransferableObjectDescriptor &rDesc)
#define EXCHG_OUT_ACTION_INSERT_DDE
#define CNT_HasGrf(USH)
Definition: editsh.hxx:135
bool IsModified() const
Changes in document?
Definition: edws.cxx:65
#define SOFFICE_FILEFORMAT_CURRENT
sal_Int64 n
Provides access to the marks of a document.
static bool PasteFileList(TransferableDataHelper &rData, SwWrtShell &rSh, bool bLink, const Point *pPt, bool bMsg)
Definition: swdtflvr.cxx:3259
static bool PasteFormat(SwWrtShell &rSh, TransferableDataHelper &rData, SotClipboardFormatId nFormat)
Definition: swdtflvr.cxx:3337
SwSection const * InsertSection(SwSectionData &rNewData, SfxItemSet const *const =nullptr)
Definition: edsect.cxx:35
bool IsSupportedGraphic() const
SwCursor * GetSwCursor() const
Definition: crsrsh.hxx:868
Definition: doc.hxx:187
bool HasFormat(SotClipboardFormatId nFormat)
void SetOle2Link(const Link< bool, void > &rLink)
Definition: doc.hxx:1330
SVL_DLLPUBLIC OUString removePassword(OUString const &rURI, INetURLObject::EncodeMechanism eEncodeMechanism, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
OUString GetUniqueSectionName(const OUString *pChkStr=nullptr) const
Definition: ndsect.cxx:1382
static bool CheckForURLOrLNKFile(TransferableDataHelper &rData, OUString &rFileName, OUString *pTitle=nullptr)
Definition: swdtflvr.cxx:3301
aBuf
#define EXCHG_OUT_ACTION_REPLACE_SVXB
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
comphelper::OInterfaceContainerHelper2 & GetPasteListeners()
Definition: fecopy.cxx:1207
sal_Int16 nId
bool IsInsideSelectedObj(const Point &rPt)
returns enum values
Definition: feshview.cxx:1267
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(57)
ObjCntType
Definition: fesh.hxx:120
SvStream * IsValid(SvStream &)
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:234
#define DND_ACTION_COPYMOVE
#define FN_DB_DATA_COMMAND_ANY
Definition: cmdid.h:739
void RemoveDDELinkFormat(const vcl::Window &rWin)
Definition: swdtflvr.cxx:379
#define SO3_SW_CLASSID
OUString GetSelDescr() const
Definition: wrtsh1.cxx:1757
SwNode & GetNode() const
Definition: ndindex.hxx:119
void SetTmpDocShell(SfxObjectShellLock rLock)
in case during copying of embedded object a new shell is created, it should be set here and cleaned l...
Definition: doc.hxx:1360
void EnterStdMode()
Definition: select.cxx:550
SwEditWin & GetEditWin()
Definition: view.hxx:403
void DestroyCursor()
transform TableCursor to normal cursor, nullify Tablemode
Definition: crsrsh.cxx:151
void Pos(const Point &rNew)
Definition: swrect.hxx:169
ErrCode Write(WriterRef const &rxWriter, const OUString *=nullptr)
Definition: shellio.cxx:731
void DoUndo(bool bOn=true)
Undo.
Definition: edws.cxx:200
void ReplaceCompatibilityOptions(const SwDoc &rSource)
Definition: docnew.cxx:875
SotExchangeDest
void SetReadUTF8(bool bSet)
Definition: shellio.hxx:254
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1769
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
size_t GetIMapObjectCount() const
void NavigatorPaste(const NaviContentBookmark &rBkmk, const sal_uInt16 nAction)
Definition: wrtsh2.cxx:542
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
sal_uInt16 Which() const
Definition: txatbase.hxx:114
sal_uInt16 Count() const
void SetClipBoard(bool bNew)
Definition: doc.hxx:967
#define EXCHG_OUT_ACTION_MOVE_PRIVATE
bool GetINetBookmark(SotClipboardFormatId nFormat, INetBookmark &rBmk)
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:315
bool InsertOleObject(const svt::EmbeddedObjectRef &xObj, SwFlyFrameFormat **pFlyFrameFormat=nullptr)
Definition: wrtsh1.cxx:465
void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc) const
bool HasFormat(SotClipboardFormatId nFormat) const
void EndAllAction()
Definition: edws.cxx:97
#define FN_PASTE_NESTED_TABLE
Definition: cmdid.h:298
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
sal_Int32 getTokenCount(const OString &rIn, char cTok)
void ReplaceStyles(const SwDoc &rSource, bool bIncludePageStyles=true)
Definition: docfmt.cxx:1528
bool SetINetBookmark(const INetBookmark &rBmk, const css::datatransfer::DataFlavor &rFlavor)
bool SetObject(void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor)
void StartInsertRegionDialog(const SwSectionData &)
Definition: regionsw.cxx:155
css::uno::Reference< css::document::XDocumentProperties > getDocProperties() const
bool DelRight()
Definition: delete.cxx:291
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:155
Degree10 getRotation() const
virtual void LockExpFields()=0
#define DND_ACTION_MOVE
void SwapPam()
Definition: crsrsh.cxx:979
#define EXCHG_IN_ACTION_DEFAULT
Used by the UI to modify the document model.
Definition: wrtsh.hxx:91
bool CopyGlossary(SwTextBlocks &rGlossary, const OUString &rStr)
Definition: swdtflvr.cxx:1223
void AddFormat(SotClipboardFormatId nFormat)
static void SelectPasteFormat(TransferableDataHelper &rData, sal_uInt8 &nAction, SotClipboardFormatId &nFormat)
Definition: swdtflvr.cxx:1417
HashMap_OWString_Interface aMap
static UITestLogger & getInstance()
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
SdrObjectUniquePtr CreateXFormsControl(const svx::OXFormsDescriptor &_rDesc)
void logEvent(const EventDescription &rDescription)
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: swdtflvr.cxx:4205
#define EXCHG_OUT_ACTION_INSERT_IMAGEMAP
sal_uInt16 sal_Unicode
Reader * ReadXML
Definition: fltini.cxx:46
tools::Long ResetSelect(const Point *, bool)
Definition: select.cxx:332
bool GotoFly(const OUString &rName, FlyCntType eType=FLYCNTTYPE_ALL, bool bSelFrame=true)
Definition: move.cxx:599
const SwView & GetView() const
Definition: wrtsh.hxx:429
RET_YES
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
#define FN_TABLE_SELECT_ALL
Definition: cmdid.h:361
bool IsMore() const
SwIndex nContent
Definition: pam.hxx:38
void ReplaceDefaults(const SwDoc &rSource)
Definition: docnew.cxx:843
#define SAL_MAX_UINT16
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
static void CreateSelection(SwWrtShell &rSh, const SwFrameShell *pCreator=nullptr)
Definition: swdtflvr.cxx:4176
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
#define EXCHG_INOUT_ACTION_NONE
static void DeleteDDEMarks(SwDoc &rDest)
Definition: swdtflvr.cxx:872
const Link< bool, void > & GetOle2Link() const
Definition: doc.hxx:1331
static tools::Long GetDDStartPosY()
Definition: edtwin.hxx:250
check if target position is in fly anchored at source range
#define FN_PARAM_INSERT_AFTER
Definition: cmdid.h:778
const OUString & GetName() const
Definition: format.hxx:115
virtual ::sw::mark::IMark * makeMark(const SwPaM &rPaM, const OUString &rProposedName, MarkType eMark,::sw::mark::InsertMode eMode, SwPosition const *pSepPos=nullptr)=0
Generates a new mark in the document for a certain selection.
bool Paste(TransferableDataHelper &rData)
Definition: content.cxx:4492
Graphic * m_pOrigGraphic
Definition: swdtflvr.hxx:89
static bool PasteData(TransferableDataHelper &rData, SwWrtShell &rSh, sal_uInt8 nAction, SotExchangeActionFlags nActionFlags, SotClipboardFormatId nFormat, SotExchangeDest nDestination, bool bIsPasteFormat, bool bIsDefault, const Point *pDDPos=nullptr, sal_Int8 nDropAction=0, bool bPasteSelection=false, RndStdIds nAnchorType=RndStdIds::FLY_AT_PARA, bool bIgnoreComments=false, SwPasteContext *pContext=nullptr, PasteTableType nPaste=PasteTableType::PASTE_DEFAULT)
Definition: swdtflvr.cxx:1652
virtual void DoUndo(bool const bDoUndo)=0
Enable/Disable Undo.
#define FN_QRY_MERGE_FIELD
Definition: cmdid.h:250
Reader * ReadHTML
Definition: fltini.cxx:46
bool InsertGlossary(SwTextBlocks &rBlock, const OUString &rEntry, SwPaM &rPaM, SwCursorShell *pShell=nullptr)
inserts an AutoText block
Definition: docglos.cxx:131
bool g_bDDINetAttr
Definition: edtwin.cxx:167
const GDIMetaFile & GetGDIMetaFile() const
OUString sStr
Definition: crsrsh.hxx:103
TransferBufferType m_eBufferType
Definition: swdtflvr.hxx:94
SwPasteSdr
Definition: fesh.hxx:157
static bool ShowPasteInfo(SfxClassificationCheckPasteResult eResult)
bool IsBlockMode() const
Definition: wrtsh.hxx:162
static bool Paste(SwWrtShell &, TransferableDataHelper &, RndStdIds nAnchorType=RndStdIds::FLY_AT_PARA, bool bIgnoreComments=false, PasteTableType ePasteTable=PasteTableType::PASTE_DEFAULT)
Definition: swdtflvr.cxx:1452
union SwContentAtPos::@24 aFnd
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
void GetGrfNms(OUString *pGrfName, OUString *pFltName, const SwFlyFrameFormat *=nullptr) const
Returns the name and the filter name of a graphic if the pointer is on a graphic. ...
Definition: editsh.cxx:305
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
Definition: viewsh.cxx:2671
#define EXCHG_OUT_ACTION_INSERT_GRAPH
SotClipboardFormatId
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
virtual bool WriteObject(tools::SvRef< SotTempStream > &rxOStm, void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor) override
Definition: swdtflvr.cxx:681
SfxObjectCreateMode GetCreateMode() const
static SotExchangeDest GetSotDestination(const SwWrtShell &rSh)
Definition: swdtflvr.cxx:2041
static SfxClassificationCheckPasteResult CheckPaste(const css::uno::Reference< css::document::XDocumentProperties > &xSource, const css::uno::Reference< css::document::XDocumentProperties > &xDestination)
void Insert(SwField const &, SwPaM *pAnnotationRange=nullptr)
Definition: wrtsh2.cxx:60
const char * sName
static SotClipboardFormatId GetFormatID(css::uno::Reference< css::embed::XStorage > const &xStorage)
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
#define FN_LINE_UP
Definition: cmdid.h:641
static SotClipboardFormatId aPasteSpecialIds[]
the list of formats which will be offered to the user in the 'Paste Special...' dialog and the paste ...
Definition: swdtflvr.cxx:3402
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:47
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
std::unique_ptr< SwDocFac, o3tl::default_delete< SwDocFac > > m_pClpDocFac
Definition: swdtflvr.hxx:86
static ErrCode LoadGraphic(const OUString &rPath, const OUString &rFilter, Graphic &rGraphic, GraphicFilter *pFilter=nullptr, sal_uInt16 *pDeterminedFormat=nullptr)
virtual std::unique_ptr< ILazyDeleter > deleteMark(const IDocumentMarkAccess::const_iterator_t &ppMark)=0
Deletes a mark.
void StopInsFrame()
Definition: edtwin.cxx:743
bool GetFlyFrameAttr(SfxItemSet &rSet) const
Definition: fefly1.cxx:1037
void SetChgLnk(const Link< LinkParamNone *, void > &rLnk)
Definition: crsrsh.hxx:483
virtual const_iterator_t getAllMarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence of marks.
#define FN_TABLE_PASTE_ROW_BEFORE
Definition: cmdid.h:299
void SetCharSet(rtl_TextEncoding nVal)
Definition: shellio.hxx:72
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
bool SetGraphic(const Graphic &rGraphic)
bool IsEmpty() const
void EndSelect()
Definition: select.cxx:424
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:612
bool ShouldWait() const
Should WaitPtr be switched on for the clipboard?
Definition: crsrsh.cxx:3055
OUString read_zeroTerminated_uInt8s_ToOUString(SvStream &rStream, rtl_TextEncoding eEnc)
bool IsSelection() const
Definition: crsrsh.hxx:879
static bool PasteDBData(TransferableDataHelper &rData, SwWrtShell &rSh, SotClipboardFormatId nFormat, bool bLink, const Point *pDragPt, bool bMsg)
Definition: swdtflvr.cxx:3159
bool GetINetImage(SotClipboardFormatId nFormat, INetImage &rINtImg)
T * get() const
SwgReaderOption & GetReaderOpt()
Definition: shellio.hxx:235
static css::uno::Reference< css::embed::XStorage > GetTemporaryStorage(const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
void RemoveFormat(SotClipboardFormatId nFormat)
#define FN_CHAR_LEFT
Definiti