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