From 7f989417a1f16b6db6b9b0fbc6bb6ffd7a81bb1c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 17 May 2022 16:28:20 +0100 Subject: [PATCH] Resolves: tdf#145722 don't propose MOVE from AcceptDrop if not asked for MOVE announce to dnd that tree supports COPY and MOVE, but on accepting a drop return MOVE only if that's something the AcceptDrop has set as desirable. a) makes ctrl+dnd to select 'copy' work for gtk, including gtk on wayland b) makes gen correctly draw its copy dnd icon. git show -w Change-Id: Ie985f8c9201634afc5ae717fd2aef0dbc18a39e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134440 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos --- basctl/source/basicide/moduldlg.cxx | 48 ++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 582a08740d28..0471b2b2eefe 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -246,6 +246,10 @@ private: if (!pSource) return DND_ACTION_NONE; + // tdf#145722 only return a DND_ACTION_MOVE possibility if that + // is requested as an option + const bool bCheckForMove = rEvt.mnAction & DND_ACTION_MOVE; + sal_Int8 nMode = DND_ACTION_NONE; std::unique_ptr xEntry(pSource->make_iterator()); @@ -255,28 +259,31 @@ private: if (nDepth >= 2) { nMode = DND_ACTION_COPY; - EntryDescriptor aDesc = m_rTreeView.GetEntryDescriptor(xEntry.get()); - const ScriptDocument& aDocument( aDesc.GetDocument() ); - const OUString& aLibName( aDesc.GetLibName() ); - // allow MOVE mode only for libraries, which are not readonly - Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); - Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); - if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) || - ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) ) + if (bCheckForMove) { - // Only allow copy for localized libraries - bool bAllowMove = true; - if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) ) + EntryDescriptor aDesc = m_rTreeView.GetEntryDescriptor(xEntry.get()); + const ScriptDocument& aDocument( aDesc.GetDocument() ); + const OUString& aLibName( aDesc.GetLibName() ); + // allow MOVE mode only for libraries, which are not readonly + Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); + Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); + if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) || + ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) ) { - // Get StringResourceManager - Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, aLibName, true ) ); - Reference< XStringResourceManager > xSourceMgr = - LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib ); - if( xSourceMgr.is() ) - bAllowMove = ( xSourceMgr->getLocales().getLength() == 0 ); + // Only allow copy for localized libraries + bool bAllowMove = true; + if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) ) + { + // Get StringResourceManager + Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, aLibName, true ) ); + Reference< XStringResourceManager > xSourceMgr = + LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib ); + if( xSourceMgr.is() ) + bAllowMove = ( xSourceMgr->getLocales().getLength() == 0 ); + } + if( bAllowMove ) + nMode |= DND_ACTION_MOVE; } - if( bAllowMove ) - nMode |= DND_ACTION_MOVE; } } } @@ -569,6 +576,9 @@ ObjectPage::ObjectPage(weld::Container* pParent, const OString &rName, BrowseMod } m_xDropTarget.reset(new SbTreeListBoxDropTarget(*m_xBasicBox)); + // tdf#145722 explicitly claim COPY and MOVE are options + rtl::Reference xHelper(new TransferDataContainer); + m_xBasicBox->get_widget().enable_drag_source(xHelper, DND_ACTION_COPYMOVE); m_xBasicBox->connect_editing(LINK(this, ObjectPage, EditingEntryHdl), LINK(this, ObjectPage, EditedEntryHdl)); -- 2.11.4.GIT