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