summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-05-17 16:28:20 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-05-17 20:50:05 +0200
commit517a39c3201ff5a2a258402ca5de6ae9d9c41196 (patch)
tree609b70e514351b7905181b2c5533c3788d6fc576 /basctl
parentba257c8443e3b66f73737895f68e57b7cd1c7cb2 (diff)
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/+/134486 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/moduldlg.cxx48
1 files changed, 29 insertions, 19 deletions
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index 3d5ead6d0259..dc46c7db0677 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<weld::TreeIter> 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<TransferDataContainer> 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));