sw/source/uibase/dochdl/swdtflvr.cxx |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 0750cacbb165b733ab76bb54a6c0116e8266a01f
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Feb 9 21:02:59 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Feb 12 12:14:07 2024 +0100

    tdf#158947 sw: Don't unrelatedly overwrite system clipboard on paste
    
    In `SwTransferable::RemoveDDELinkFormat`, only update the
    clipboard content with this `SwTransferable` after removing
    the `SotClipboardFormatId::LINK` from the supported formats
    if the `SwTransferable` was the clipboard content before
    already.
    
    Doing so always would unrelatedly overwrite what was previously
    copied from another application to the clipboard for the
    tdf#158947 scenario of pasting clipboard content of another
    application over a selection when using the Qt-based VCL plugins
    on Wayland (s. backtrace below that shows how the clipboard content
    was overwritten, frame #17 is the method changed in this
    commit).
    
    My assumption why the clipboard content is explicitly overwritten
    at all is to make sure that the system clipboard on some platforms
    gets notified about the change in supported formats/mime
    types after removing one. But that isn't necessary when the
    transfer data modified here aren't the current clipboard content
    in the first place.
    
    Backtrace for how clipboard content was previously overwritten
    for the tdf#158947 scenario with the qt6 VCL plugin on Wayland:
    
        ~"#0  QtClipboard::handleChanged(QClipboard::Mode) 
(this=0x557f90457770, aMode=QClipboard::Clipboard) at 
.../libreoffice/vcl/qt6/../qt5/QtClipboard.cxx:156
"
        ~"#1  0x00007f26f08844ff in 
QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, 
QtPrivate::List<QClipboard::Mode>, void, void 
(QtClipboard::*)(QClipboard::Mode)>::call(void 
(QtClipboard::*)(QClipboard::Mode), QtClipboard*, 
void**)::{lambda()#1}::operator()() const (__closure=0x7ffe889a2c20) at 
.../qt5/qtbase/src/corelib/kernel/qobjectdefs_impl.h:153
"
        ~"#2  0x00007f26f0884ffb in 
QtPrivate::FunctorCallBase::call_internal<void, 
QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, 
QtPrivate::List<QClipboard::Mode>, void, void 
(QtClipboard::*)(QClipboard::Mode)>::call(void 
(QtClipboard::*)(QClipboard::Mode), QtClipboard*, 
void**)::{lambda()#1}>(void**, 
QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, 
QtPrivate::List<QClipboard::Mode>, void, void 
(QtClipboard::*)(QClipboard::Mode)>::call(void 
(QtClipboard::*)(QClipboard::Mode), QtClipboard*, void**)::{lambda()#1}&&) 
(args=0x7ffe889a2ed0, fn=...) at 
.../qt5/qtbase/src/corelib/kernel/qobjectdefs_impl.h:72
"
        ~"#3  0x00007f26f088456f in 
QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, 
QtPrivate::List<QClipboard::Mode>, void, void 
(QtClipboard::*)(QClipboard::Mode)>::call(void 
(QtClipboard::*)(QClipboard::Mode), QtClipboard*, void**) (f=(void 
(QtClipboard::*)(QtClipboard * const, QClipboard::Mode)) 0x7f26f087a76e 
<QtClipboard::handleChanged(QClipboard::Mode)>, o=0x557f90457770, 
arg=0x7ffe889a2ed0) at .../qt5/qtbase/src/corelib/kernel/qobjectdefs_impl.h:152
"
        ~"#4  0x00007f26f08833de in QtPrivate::FunctionPointer<void 
(QtClipboard::*)(QClipboard::Mode)>::call<QtPrivate::List<QClipboard::Mode>, 
void>(void (QtClipboard::*)(QClipboard::Mode), QtClipboard*, void**) (f=(void 
(QtClipboard::*)(QtClipboard * const, QClipboard::Mode)) 0x7f26f087a76e 
<QtClipboard::handleChanged(QClipboard::Mode)>, o=0x557f90457770, 
arg=0x7ffe889a2ed0) at .../qt5/qtbase/src/corelib/kernel/qobjectdefs_impl.h:200
"
        ~"#5  0x00007f26f0881f71 in QtPrivate::QCallableObject<void 
(QtClipboard::*)(QClipboard::Mode), QtPrivate::List<QClipboard::Mode>, 
void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) 
(which=1, this_=0x557f904555f0, r=0x557f90457770, a=0x7ffe889a2ed0, ret=0x0) at 
.../qt5/qtbase/src/corelib/kernel/qobjectdefs_impl.h:571
"
        ~"#6  0x00007f26efdb863f in QtPrivate::QSlotObjectBase::call(QObject*, 
void**) (this=0x557f904555f0, r=0x557f90457770, a=0x7ffe889a2ed0) at 
.../qt5/qtbase/src/corelib/kernel/qobjectdefs_impl.h:487
"
        ~"#7  0x00007f26efe5772e in doActivate<false>(QObject*, int, void**) 
(sender=0x557f8d510fd0, signal_index=3, argv=0x7ffe889a2ed0) at 
.../qt5/qtbase/src/corelib/kernel/qobject.cpp:4116
"
        ~"#8  0x00007f26efe4cdef in QMetaObject::activate(QObject*, QMetaObject 
const*, int, void**) (sender=0x557f8d510fd0, m=0x7f26efa47cc0 
<QClipboard::staticMetaObject>, local_signal_index=0, argv=0x7ffe889a2ed0) at 
.../qt5/qtbase/src/corelib/kernel/qobject.cpp:4176
"
        ~"#9  0x00007f26eede9fcc in QClipboard::changed(QClipboard::Mode) 
(this=0x557f8d510fd0, _t1=QClipboard::Clipboard) at 
.../qt5/qtbase/src/gui/Gui_autogen/include/moc_qclipboard.cpp:182
"
        ~"#10 0x00007f26eede9bc1 in QClipboard::emitChanged(QClipboard::Mode) 
(this=0x557f8d510fd0, mode=QClipboard::Clipboard) at 
.../qt5/qtbase/src/gui/kernel/qclipboard.cpp:558
"
        ~"#11 0x00007f26eee4ed69 in 
QPlatformClipboard::emitChanged(QClipboard::Mode) (this=0x557f88019c20, 
mode=QClipboard::Clipboard) at 
.../qt5/qtbase/src/gui/kernel/qplatformclipboard.cpp:89
"
        ~"#12 0x00007f26ed78809e in 
QtWaylandClient::QWaylandClipboard::setMimeData(QMimeData*, QClipboard::Mode) 
(this=0x557f88019c20, data=0x557f8fb87930, mode=QClipboard::Clipboard) at 
.../qt5/qtwayland/src/client/qwaylandclipboard.cpp:89
"
        ~"#13 0x00007f26eede99de in QClipboard::setMimeData(QMimeData*, 
QClipboard::Mode) (this=0x557f8d510fd0, src=0x557f8fb87930, 
mode=QClipboard::Clipboard) at .../qt5/qtbase/src/gui/kernel/qclipboard.cpp:447
"
        ~"#14 0x00007f26f087a5b5 in 
QtClipboard::setContents(com::sun::star::uno::Reference<com::sun::star::datatransfer::XTransferable>
 const&, 
com::sun::star::uno::Reference<com::sun::star::datatransfer::clipboard::XClipboardOwner>
 const&) (this=0x557f8d50cbb0, xTrans=uno::Reference to (SwTransferable *) 
0x557f90440118, xClipboardOwner=uno::Reference to (SwTransferable *) 
0x557f90440120) at .../libreoffice/vcl/qt6/../qt5/QtClipboard.cxx:137
"
        ~"#15 0x00007f26fb05bacc in 
TransferableHelper::CopyToClipboard(com::sun::star::uno::Reference<com::sun::star::datatransfer::clipboard::XClipboard>
 const&) const (this=0x557f904400f0, rClipboard=uno::Reference to (QtClipboard 
*) 0x557f8d50cc10) at .../libreoffice/vcl/source/treelist/transfer.cxx:942
"
        ~"#16 0x00007f26fb05bc77 in 
TransferableHelper::CopyToClipboard(vcl::Window*) const (this=0x557f904400f0, 
pWindow=0x557f8932d1f0) at .../libreoffice/vcl/source/treelist/transfer.cxx:957
"
        ~"#17 0x00007f26b5130940 in 
SwTransferable::RemoveDDELinkFormat(vcl::Window&) (this=0x557f904400f0, 
rWin=...) at .../libreoffice/sw/source/uibase/dochdl/swdtflvr.cxx:385
"
        ~"#18 0x00007f26b51440ab in 
SwTransferDdeLink::DataChanged(rtl::OUString const&, com::sun::star::uno::Any 
const&) (this=0x557f8fb864e0) at 
.../libreoffice/sw/source/uibase/dochdl/swdtflvr.cxx:4447
"
        ~"#19 0x00007f270120fa0e in sfx2::SvLinkSource::NotifyDataChanged() 
(this=0x557f8fb8bbe0) at .../libreoffice/sfx2/source/appl/linksrc.cxx:291
"
        ~"#20 0x00007f26b43210ba in SwServerObject::SendDataChanged(SwPaM 
const&) (this=0x557f8fb8bbe0, rRange=SwPaM = {...}) at 
.../libreoffice/sw/source/core/doc/swserv.cxx:177
"
        ~"#21 0x00007f26b43217c2 in SwDataChanged::~SwDataChanged() 
(this=0x7ffe889a3520, __in_chrg=<optimized out>) at 
.../libreoffice/sw/source/core/doc/swserv.cxx:308
"
        ~"#22 0x00007f26b4233c8b in 
sw::DocumentContentOperationsManager::DeleteRangeImplImpl(SwPaM&, 
SwDeleteFlags) (this=0x557f8d2b8000, rPam=SwPaM = {...}, 
flags=SwDeleteFlags::Default) at 
.../libreoffice/sw/source/core/doc/DocumentContentOperationsManager.cxx:4474
"
        ~"#23 0x00007f26b4233826 in 
sw::DocumentContentOperationsManager::DeleteRangeImpl(SwPaM&, SwDeleteFlags) 
(this=0x557f8d2b8000, rPam=SwPaM = {...}, flags=SwDeleteFlags::Default) at 
.../libreoffice/sw/source/core/doc/DocumentContentOperationsManager.cxx:4419
"
        ~"#24 0x00007f26b4233681 in 
sw::DocumentContentOperationsManager::DeleteAndJoinImpl(SwPaM&, SwDeleteFlags) 
(this=0x557f8d2b8000, rPam=SwPaM = {...}, flags=SwDeleteFlags::Default) at 
.../libreoffice/sw/source/core/doc/DocumentContentOperationsManager.cxx:4391
"
        ~"#25 0x00007f26b421edb7 in (anonymous 
namespace)::lcl_DoWithBreaks(sw::DocumentContentOperationsManager&, SwPaM&, 
SwDeleteFlags, bool 
(sw::DocumentContentOperationsManager::*)(sw::DocumentContentOperationsManager* 
const, SwPaM&, SwDeleteFlags)) (rDocumentContentOperations=..., rPam=SwPaM = 
{...}, flags=SwDeleteFlags::Default, pFunc=(bool 
(sw::DocumentContentOperationsManager::*)(sw::DocumentContentOperationsManager 
* const, SwPaM &, SwDeleteFlags)) 0x7f26b4233632 
<sw::DocumentContentOperationsManager::DeleteAndJoinImpl(SwPaM&, 
SwDeleteFlags)>) at 
.../libreoffice/sw/source/core/doc/DocumentContentOperationsManager.cxx:681
"
        ~"#26 0x00007f26b42279df in 
sw::DocumentContentOperationsManager::DeleteAndJoin(SwPaM&, SwDeleteFlags) 
(this=0x557f8d2b8000, rPam=SwPaM = {...}, flags=SwDeleteFlags::Default) at 
.../libreoffice/sw/source/core/doc/DocumentContentOperationsManager.cxx:2367
"
        ~"#27 0x00007f26b44a71f6 in SwEditShell::DeleteSel(SwPaM&, bool, bool, 
bool*) (this=0x557f8d51b300, rPam=SwPaM = {...}, isArtificialSelection=false, 
goLeft=false, pUndo=0x7ffe889a3be6) at 
.../libreoffice/sw/source/core/edit/eddel.cxx:122
"
        ~"#28 0x00007f26b44a7671 in SwEditShell::Delete(bool, bool) 
(this=0x557f8d51b300, isArtificialSelection=false, goLeft=false) at 
.../libreoffice/sw/source/core/edit/eddel.cxx:164
"
        ~"#29 0x00007f26b5604933 in SwWrtShell::DelRight(bool) 
(this=0x557f8d51b300, isReplaceHeuristic=false) at 
.../libreoffice/sw/source/uibase/wrtsh/delete.cxx:312
"
        ~"#30 0x00007f26b512fe14 in (anonymous 
namespace)::SwTrnsfrActionAndUndo::SwTrnsfrActionAndUndo(SwWrtShell*, bool, 
SwPasteContext*) (this=0x557f9045b020, pS=0x557f8d51b300, bDelSel=true, 
pContext=0x7ffe889a4220) at 
.../libreoffice/sw/source/uibase/dochdl/swdtflvr.cxx:236
"
        ~"#31 0x00007f26b51377c1 in 
SwTransferable::PasteData(TransferableDataHelper const&, SwWrtShell&, unsigned 
char, SotExchangeActionFlags, SotClipboardFormatId, SotExchangeDest, bool, 
bool, Point const*, signed char, bool, RndStdIds, bool, SwPasteContext*, 
PasteTableType) (rData=..., rSh=..., nAction=36 '$', 
nActionFlags=(SotExchangeActionFlags::InsertImageMap | 
SotExchangeActionFlags::InsertTargetUrl), nFormat=SotClipboardFormatId::HTML, 
nDestination=SotExchangeDest::SWDOC_FREE_AREA, bIsPasteFormat=false, 
bIsDefault=false, pPt=0x0, nDropAction=0 '\000', bPasteSelection=false, 
nAnchorType=RndStdIds::FLY_AT_PARA, bIgnoreComments=false, 
pContext=0x7ffe889a4220, ePasteTable=PasteTableType::PASTE_DEFAULT) at 
.../libreoffice/sw/source/uibase/dochdl/swdtflvr.cxx:1768
"
        ~"#32 0x00007f26b5137333 in SwTransferable::Paste(SwWrtShell&, 
TransferableDataHelper&, RndStdIds, bool, PasteTableType) (rSh=..., rData=..., 
nAnchorType=RndStdIds::FLY_AT_PARA, bIgnoreComments=false, 
ePasteTable=PasteTableType::PASTE_DEFAULT) at 
.../libreoffice/sw/source/uibase/dochdl/swdtflvr.cxx:1687
"
        ~"#33 0x00007f26b52d29e9 in SwBaseShell::ExecClpbrd(SfxRequest&) 
(this=0x557f8db64330, rReq=...) at 
.../libreoffice/sw/source/uibase/shells/basesh.cxx:365
"
        ~"#34 0x00007f26b52d1681 in SfxStubSwBaseShellExecClpbrd(SfxShell*, 
SfxRequest&) (pShell=0x557f8db64330, rReq=...) at 
.../libreoffice/workdir/SdiTarget/sw/sdi/swslots.hxx:2219
"
        ~"#35 0x00007f27012d14dc in SfxDispatcher::Call_Impl(SfxShell&, SfxSlot 
const&, SfxRequest&, bool) (this=0x557f8d4f46b0, rShell=..., rSlot=..., 
rReq=..., bRecord=true) at .../libreoffice/sfx2/source/control/dispatch.cxx:254
"
        ~"#36 0x00007f27012d4b34 in SfxDispatcher::Execute_(SfxShell&, SfxSlot 
const&, SfxRequest&, SfxCallMode) (this=0x557f8d4f46b0, rShell=..., rSlot=..., 
rReq=..., eCallMode=SfxCallMode::RECORD) at 
.../libreoffice/sfx2/source/control/dispatch.cxx:753
"
        ~"#37 0x00007f27012c05d4 in SfxBindings::Execute_Impl(SfxRequest&, 
SfxSlot const*, SfxShell*) (this=0x557f8d503240, aReq=..., pSlot=0x7f26b6cf5360 
<aSwBaseShellSlots_Impl+1440>, pShell=0x557f8db64330) at 
.../libreoffice/sfx2/source/control/bindings.cxx:1057
"
        ~"#38 0x00007f270139813d in 
SfxDispatchController_Impl::dispatch(com::sun::star::util::URL const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, 
com::sun::star::uno::Reference<com::sun::star::frame::XDispatchResultListener> 
const&) (this=0x557f8db682a0, aURL=..., aArgs=empty uno::Sequence, 
rListener=empty uno::Reference) at 
.../libreoffice/sfx2/source/control/unoctitm.cxx:688
"
        ~"#39 0x00007f2701395dbf in 
SfxOfficeDispatch::dispatch(com::sun::star::util::URL const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) 
(this=0x557f8db68200, aURL=..., aArgs=empty uno::Sequence) at 
.../libreoffice/sfx2/source/control/unoctitm.cxx:250
"
        ~"#40 0x00007f26fe03d948 in svt::(anonymous 
namespace)::AsyncAccelExec::impl_ts_asyncCallback(LinkParamNone*) 
(this=0x557f8fb8e070) at 
.../libreoffice/svtools/source/misc/acceleratorexecute.cxx:508
"
        ~"#41 0x00007f26fe03d869 in svt::(anonymous 
namespace)::AsyncAccelExec::LinkStubimpl_ts_asyncCallback(void*, 
LinkParamNone*) (instance=0x557f8fb8e070, data=0x0) at 
.../libreoffice/svtools/source/misc/acceleratorexecute.cxx:500
"
        ~"#42 0x00007f26fab0db3b in Link<LinkParamNone*, 
void>::Call(LinkParamNone*) const (this=0x557f8fb8e110, data=0x0) at 
.../libreoffice/include/tools/link.hxx:111
"
        ~"#43 0x00007f26fb469f3d in vcl::EventPoster::DoEvent_Impl(void*) 
(this=0x557f8fb8e108) at .../libreoffice/vcl/source/helper/evntpost.cxx:52
"
        ~"#44 0x00007f26fb469f05 in 
vcl::EventPoster::LinkStubDoEvent_Impl(void*, void*) (instance=0x557f8fb8e108, 
data=0x0) at .../libreoffice/vcl/source/helper/evntpost.cxx:48
"
        ~"#45 0x00007f26fadc2373 in Link<void*, void>::Call(void*) const 
(this=0x7f26e80153b8, data=0x0) at .../libreoffice/include/tools/link.hxx:111
"
        ~"#46 0x00007f26fadbf458 in ImplHandleUserEvent(ImplSVEvent*) 
(pSVEvent=0x7f26e80153b0) at .../libreoffice/vcl/source/window/winproc.cxx:2287
"
        ~"#47 0x00007f26fadc1385 in ImplWindowFrameProc(vcl::Window*, SalEvent, 
void const*) (_pWindow=0x557f897d0e90, nEvent=SalEvent::UserEvent, 
pEvent=0x7f26e80153b0) at .../libreoffice/vcl/source/window/winproc.cxx:2851
"
        ~"#48 0x00007f26f08b6bae in SalFrame::CallCallback(SalEvent, void 
const*) const (this=0x557f8800cf80, nEvent=SalEvent::UserEvent, 
pEvent=0x7f26e80153b0) at .../libreoffice/vcl/inc/salframe.hxx:310
"
        ~"#49 0x00007f26f08d9dbf in 
QtInstance::ProcessEvent(SalUserEventList::SalUserEvent) (this=0x557f88020780, 
aEvent=...) at .../libreoffice/vcl/qt6/../qt5/QtInstance.cxx:516
"
        ~"#50 0x00007f26fb47b97f in operator()() const 
(__closure=0x7ffe889a50e0) at 
.../libreoffice/vcl/source/app/salusereventlist.cxx:119
"
        ~"#51 0x00007f26fb47bc53 in SalUserEventList::DispatchUserEvents(bool) 
(this=0x557f880207b8, bHandleAllCurrentEvents=false) at 
.../libreoffice/vcl/source/app/salusereventlist.cxx:120
"
        ~"#52 0x00007f26f08d98a4 in QtInstance::ImplYield(bool, bool) 
(this=0x557f88020780, bWait=true, bHandleAllCurrentEvents=false) at 
.../libreoffice/vcl/qt6/../qt5/QtInstance.cxx:442
"
        ~"#53 0x00007f26f08d9a4f in QtInstance::DoYield(bool, bool) 
(this=0x557f88020780, bWait=true, bHandleAllCurrentEvents=false) at 
.../libreoffice/vcl/qt6/../qt5/QtInstance.cxx:464
"
        ~"#54 0x00007f26fb5390d0 in ImplYield(bool, bool) (i_bWait=true, 
i_bAllEvents=false) at .../libreoffice/vcl/source/app/svapp.cxx:390
"
        ~"#55 0x00007f26fb539e6e in Application::Yield() () at 
.../libreoffice/vcl/source/app/svapp.cxx:474
"
        ~"#56 0x00007f26fb538dc3 in Application::Execute() () at 
.../libreoffice/vcl/source/app/svapp.cxx:368
"
        ~"#57 0x00007f2704e371b6 in desktop::Desktop::Main() 
(this=0x7ffe889a5c10) at .../libreoffice/desktop/source/app/app.cxx:1614
"
        ~"#58 0x00007f26fb558292 in ImplSVMain() () at 
.../libreoffice/vcl/source/app/svmain.cxx:229
"
        ~"#59 0x00007f26fb5585a7 in SVMain() () at 
.../libreoffice/vcl/source/app/svmain.cxx:261
"
        ~"#60 0x00007f2704ea4307 in soffice_main() () at 
.../libreoffice/desktop/source/app/sofficemain.cxx:94
"
        ~"#61 0x0000557f862d19d4 in sal_main () at 
.../libreoffice/desktop/source/app/main.c:51
"
        ~"#62 0x0000557f862d19ba in main (argc=3, argv=0x7ffe889a5e38) at 
.../libreoffice/desktop/source/app/main.c:49
"
        2906^done
        (gdb)
    
    Change-Id: I1f517d441eeb3e77e969062b884d9a425038b22a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163202
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    (cherry picked from commit cb9513c74502144a480494e0c6a32ac6173ae0a3)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163179
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx 
b/sw/source/uibase/dochdl/swdtflvr.cxx
index cb96c08527c6..ea419d2326f7 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -382,7 +382,8 @@ const Graphic* SwTransferable::FindOLEReplacementGraphic() 
const
 void SwTransferable::RemoveDDELinkFormat(vcl::Window& rWin)
 {
     RemoveFormat( SotClipboardFormatId::LINK );
-    CopyToClipboard(&rWin);
+    if (rWin.GetClipboard()->getContents().get() == this)
+        CopyToClipboard(&rWin);
 }
 
 void SwTransferable::DisconnectDDE()

Reply via email to