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