Disable Drag & Drop

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Penikufesin
Posts: 26
Joined: Sun Nov 02, 2014 7:03 pm

Disable Drag & Drop

Post by Penikufesin »

fabiusf wrote:

Code: Select all

Option VBASupport 1
...
Application.CellDragAndDrop = False
...
I'm desperately seeking this in OO/LO. Is there a undocumented feature or plans to implement this?
Last edited by Penikufesin on Tue Oct 31, 2023 8:04 pm, edited 2 times in total.
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: disable cut, copy, paste, paste special, drag & Drop

Post by JohnSUN-Pensioner »

I'm afraid to know the answer to the question - disable cut, copy, paste, etc. for the entire application? Not for a single document?
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
Penikufesin
Posts: 26
Joined: Sun Nov 02, 2014 7:03 pm

Re: Disable Drag & Drop

Post by Penikufesin »

It would be fine to disable Drag&Drop for a single document. (users sometimes move cells by accident)

BTW: I miss the original post, but it doesn't matter, subject edited.
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Disable Drag & Drop

Post by JohnSUN-Pensioner »

Ok. What about "protect sheet"?
If this variant is not suitable (why?), it is necessary to intercept mouse events and handle them independently (disconnect the mouse from the PC is simply, IMHO).
Another method - create dialog for users...
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
Penikufesin
Posts: 26
Joined: Sun Nov 02, 2014 7:03 pm

Re: Disable Drag & Drop

Post by Penikufesin »

The sheet is protected but a lot of cells are not, because they must be editable. For a lot of applications I prefer direct editing of the sheet instead of creating (possibly a huge number of) dialogs. Only the cell-moving-problem troubles...
Penikufesin
Posts: 26
Joined: Sun Nov 02, 2014 7:03 pm

Re: Disable Drag & Drop

Post by Penikufesin »

A few years later... are there news regarding this topic?
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Disable Drag & Drop

Post by JeJe »

Penikufesin wrote: Wed Mar 01, 2023 1:11 am A few years later... are there news regarding this topic?
Perhaps this page will help

viewtopic.php?f=25&t=29977
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Penikufesin
Posts: 26
Joined: Sun Nov 02, 2014 7:03 pm

Re: Disable Drag & Drop

Post by Penikufesin »

This looks very complicated. Ad hoc I couldn't get it to work. But thank you.
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Disable Drag & Drop

Post by JeJe »

Try running this code - then do a drag and drop. Testing for OpenOffice Calc I get windows(7) for the main window - that may differ for you.
This appears to stop the drag drop but you can use Mri to examine ev.context and look things up in the API to see how it all works for yourself.

Code: Select all


Sub StartDragDropListener()

w1 = thiscomponent.CurrentController.frame.componentwindow.accessiblecontext.getaccessiblechild(0).windows(7) '.windows(0
dt =thiscomponent.CurrentController.frame.containerwindow.gettoolkit.getdroptarget(w1) 
DDListener = CreateUnoListener("DDListener_","com.sun.star.datatransfer.dnd.XDropTargetListener")
dt.addDropTargetListener(DDListener)
end sub


function DDListener_drop(ev) ' 	The drag operation has terminated with a drop on this drop target.  
ev.context.dropcomplete false
end function
sub DDListener_dragEnter(ev) ' 	Called when a drag operation has encountered the drop target.  
end sub
sub DDListener_dragExit(ev) ' 	The drag operation has departed the drop target without dropping.  
end sub
sub DDListener_dragOver(ev) ' 	Called when a drag operation is ongoing on the drop target.  
end sub
sub DDListener_dropActionChanged(ev) '
end sub
sub DDListener_disposing(ev)
end sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Penikufesin
Posts: 26
Joined: Sun Nov 02, 2014 7:03 pm

Re: Disable Drag & Drop

Post by Penikufesin »

JeJe wrote: Thu Mar 02, 2023 3:31 am

Code: Select all

Sub StartDragDropListener()
...
It works, thank you very much!
But you're not sure, wether it is portable? And I'm wondering, why it has to be so complicated:

Code: Select all

w1 = thiscomponent.CurrentController.frame.componentwindow.accessiblecontext.getaccessiblechild(0).windows(7)
dt =thiscomponent.CurrentController.frame.containerwindow.gettoolkit.getdroptarget(w1) 
DDListener = CreateUnoListener("DDListener_","com.sun.star.datatransfer.dnd.XDropTargetListener")
dt.addDropTargetListener(DDListener)
I already use a keyboard handler in some documents, which looks much more simple:

Code: Select all

oKeyHandler = createUnoListener("KeyHdl_", "com.sun.star.awt.XKeyHandler")
ThisComponent.getCurrentController.addKeyHandler(oKeyHandler)
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Disable Drag & Drop

Post by JeJe »

Penikufesin wrote: Fri Mar 03, 2023 1:07 am But you're not sure, wether it is portable? And I'm wondering, why it has to be so complicated:
Unless you can find another way to identify the window I've just got the same suggestions I had in the other thread - to make it more rigorous loop though looking for an AccessibleRole of 40 and its also likely the biggest window (looking for which is how I got the 7)

There are a minuscule number of people wanting what you want here - so no OO developer has implemented an easy way to do it as they have done in Office - that would be my guess.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply