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