Bug 36210 - disable "Insert" command impossible through dispatch framework
Summary: disable "Insert" command impossible through dispatch framework
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.3.2 release
Hardware: Other All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: needsDevEval
Depends on:
Blocks: Macro
  Show dependency treegraph
 
Reported: 2011-04-13 08:29 UTC by Laurent Godard
Modified: 2019-08-10 16:52 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
a file with a correct macro (10.82 KB, application/vnd.oasis.opendocument.spreadsheet)
2012-11-21 17:22 UTC, Laurent Godard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Godard 2011-04-13 08:29:51 UTC
the whole suite menus/action use dispatch framework

this is useful when one want to disable some UI commands

http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Disable_Commands

especially, it is said :
The dispatch framework works with the design pattern chain of responsibility 
...
The disable commands implementation is the first chain member and can therefore work as a wall for all disabled commands. They are not be sent to the next chain member, and disappear.

applying this to "Insert" command works for menu entries (insert > sheet or right click on a sheet tab) - see given macro code

but, the Insert is still available
- by clicking the green + button
- by clicking empty space near sheet tabs

--> these 2 functionality should respect the dispatch framework
Comment 1 Laurent Godard 2011-04-13 08:31:29 UTC
the macro to test this - answer yes/No wether you want to disable/enable the Insert sheet command

dim conf

sub testDisableInsert

conf = getConfigSetting("/org.openoffice.Office.Commands/Execute/Disabled" ,true)

	message = "do you want to DISABLE ""insert sheet"" command ?"
	response = msgBox(message, 32 + 4, "Question")
	value = (response = 6)

	setEnable(value,"Insert")

end sub


sub setEnable(state,url)

	if state then
		enable(url)
	else
		disable(url)
	endif
	conf.commitChanges()
end sub

sub disable(url)

	spliter = split(url,"?")
	nom = spliter(0)
	if not conf.hasByName(nom) then
		elem = conf.createInstanceWithArguments(array())
		elem.setPropertyValue("Command",url)
		conf.insertByName(nom,elem)
	endif

end sub 
sub enable(url)

	spliter = split(url,"?")
	nom = spliter(0)
	if conf.hasByName(nom) then
		conf.removeByName(nom)
	endif

end sub

function getConfigSetting(target as string, forUpdate as boolean)
' retourne le noeud de config demandé
' exemple: aSettings = getConfigSetting( "/org.openoffice.Office.Common/Path/Current", false)

	dim service as String ' nom du service d'acces à la configuration
	dim aSettings, aConfigProvider
	dim aParams(0) As new com.sun.star.beans.PropertyValue
	dim varEmpty

	if forUpdate then
		service = "com.sun.star.configuration.ConfigurationUpdateAccess"
	else
		service = "com.sun.star.configuration.ConfigurationAccess"
	endif
	
	aConfigProvider = createUnoService( "com.sun.star.configuration.ConfigurationProvider" )
	aParams(0).Name = "nodepath"
	aParams(0).Value = target
	
	aSettings = aConfigProvider.createInstanceWithArguments(service, aParams() )
	
	getConfigSetting = aSettings

end function
Comment 2 Björn Michaelsen 2011-12-23 12:05:31 UTC Comment hidden (obsolete)
Comment 3 Florian Reisinger 2012-08-14 14:03:28 UTC Comment hidden (obsolete)
Comment 4 Florian Reisinger 2012-08-14 14:04:23 UTC Comment hidden (obsolete)
Comment 5 Florian Reisinger 2012-08-14 14:08:55 UTC Comment hidden (obsolete)
Comment 6 Florian Reisinger 2012-08-14 14:10:56 UTC Comment hidden (obsolete)
Comment 7 sasha.libreoffice 2012-08-31 09:34:01 UTC
Nobody tested yet. Reopening
Comment 8 Joel Madero 2012-11-21 16:54:39 UTC
I can't get the macro to do anything for me. It asks if I want to disable the insert sheet command and I click yes, but I'm still able to insert sheet ANY method (insert - sheet, right click on sheet1 and do Insert Sheet..., Clicking Green +, or Empty Space)

Can you verify that your macro disables insert sheet in any way? I don't know the code so I can't verify that aspect but I want to confirm that we're on the same page before triaging the bug. Marking as NEEDINFO until you respond.

Thanks for your patience and apologies for the long delay.


Regards,
Joel
Comment 9 Laurent Godard 2012-11-21 17:16:05 UTC
i confirm the macro does do anythoing anymore
i'll have a look
i let you know
Comment 10 Laurent Godard 2012-11-21 17:22:11 UTC
Created attachment 70382 [details]
a file with a correct macro

Please find an ods document with the macro inside (enable macros in security)
click the button to DISABLE (answer Yes) or ENABLE (answer No)

when DISABLE
disapear in menu Insert
Right click on tab, the menu entry iss still there but inactive
the other described way are still available
Comment 11 Joel Madero 2012-11-21 17:34:45 UTC
Confirmed, quite strange :)

Marking as NEW and prioritizing:

Minor: Doesn't prevent high quality/professional work

Low: Very very few users would actually care about this - the number of users using macros is already low, one as specific as limiting the ability to make new sheets is probably less than 0.1% of users. 

Leaving PrposedEasyHack as I don't think it'd be that difficult to fix.

Thanks for your patience and the test document
Comment 12 Joel Madero 2014-02-27 22:55:13 UTC
In order to limit the confusion between ProposedEasyHack and EasyHack and to make queries much easier we are changing ProposedEasyHack to NeedsDevEval.

Thank you and apologies for the noise
Comment 13 Robinson Tryon (qubit) 2015-12-13 11:20:52 UTC Comment hidden (obsolete)
Comment 14 QA Administrators 2018-10-22 02:47:37 UTC Comment hidden (obsolete)
Comment 15 Buovjaga 2019-08-10 16:52:39 UTC
(In reply to Laurent Godard from comment #10)
> Created attachment 70382 [details]
> a file with a correct macro
> 
> Please find an ods document with the macro inside (enable macros in security)
> click the button to DISABLE (answer Yes) or ENABLE (answer No)
> 
> when DISABLE
> disapear in menu Insert
> Right click on tab, the menu entry iss still there but inactive
> the other described way are still available

Nothing is disabled, not even menu entries in Sheet menu.

Arch Linux 64-bit
Version: 6.4.0.0.alpha0+
Build ID: 37fc9f51a8de11d40632e8cda17ccf1fa4b1f503
CPU threads: 8; OS: Linux 5.2; UI render: default; VCL: gtk3; 
Locale: fi-FI (fi_FI.UTF-8); UI-Language: en-US
Calc: threaded
Built on 6 August 2019