*コマンドの無効化 [#n78c6e50] コマンドを無効にしてメニューなどから項目を実行できないようにします。コマンドの無効化は /org.openoffice.Office.Commands/Execute/Disabled 以下にコマンドを追加することで行います。一時的に行う場合でもこの設定を変更、元に戻す必要があります。無効化は dispatch の最初の判定のためコマンドのハンドラなどに処理が渡らなくなります。 コマンドは以下参照。コマンドに .uno: を付けるとコマンド URL になります。 -http://wiki.services.openoffice.org/wiki/Framework/Article/OpenOffice.org_2.x_Commands この項目でのコマンドの無効化はすべてのドキュメントに影響し、ドキュメントごとのコマンドの無効化には利用できません。 #contents **無効化 [#l330e245] 以下のようにして /org.openoffice.Office.Commands/Execute/Disabled に node を追加します。node ごとにコマンド一つしか設定できないため、無効化するコマンドごとに新しい node を追加します。最後に commitChanges で設定を反映させます。 Sub disablecommands_1 Dim oProvider As Object, oCfgWriter As Object Dim oNode(0) As New com.sun.star.beans.PropertyValue oProvider = CreateUnoService("com.sun.star.configuration.ConfigurationProvider") oNode(0).Name = "nodepath" oNode(0).Value = "/org.openoffice.Office.Commands/Execute/Disabled" oCfgWriter = oProvider.createInstanceWithArguments( _ "com.sun.star.configuration.ConfigurationUpdateAccess", oNode ) sCommands = Array("NewDoc","Open") For i = 0 To UBound(sCommands) oElem = oCfgWriter.createInstanceWithArguments(Array()) oElem.Command = sCommands(i) oCfgWriter.insertByName("Command_" & sCommands(i),oElem) Next i oCfgWriter.commitChanges() End Sub **無効化エントリの削除 [#z5d14889] 一度無効化したコマンドは有効にするまでずっと無効化されたままです。OOo を再起動しても元に戻ることはありません (設定ファイルを削除すれば有効化できますが)。コマンドを有効にするには次のようにして無効化コマンドのエントリを削除します。 Sub disablecommands_2 Dim oProvider As Object, oCfgWriter As Object Dim oNode(0) As New com.sun.star.beans.PropertyValue oProvider = CreateUnoService("com.sun.star.configuration.ConfigurationProvider") oNode(0).Name = "nodepath" oNode(0).Value = "/org.openoffice.Office.Commands/Execute/Disabled" oCfgWriter = oProvider.createInstanceWithArguments( _ "com.sun.star.configuration.ConfigurationUpdateAccess", oNode ) sCommands = oCfgWriter.ElementNames For i = 0 To UBound(sCommands) oCfgWriter.removeByName(sCommands(i)) Next i oCfgWriter.commitChanges() End Sub |