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