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