comphelper: Add helpers for accessing duck-typed methods of XBrowseNode
Implementations of XBrowseNode have a bunch of extra methods which are accessed by using XPropertySet::getPropertyValue to determine if the action is possible and then XInvocation::invoke to invoke it. This patch adds wrappers around checking and invoking these methods. The idea is to abstract away the actual implementation so that the approach can be changed in a later patch. Change-Id: I117ab848391dbb1277f9331d6a93f71c2cb556ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207343 Reviewed-by: Neil Roberts <nroberts@libreoffice.org> Tested-by: Jenkins
This commit is contained in:
@@ -127,6 +127,7 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\
|
||||
comphelper/source/misc/traceevent \
|
||||
comphelper/source/misc/random \
|
||||
comphelper/source/misc/SelectionMultiplex \
|
||||
comphelper/source/misc/scriptbrowse \
|
||||
comphelper/source/misc/sequenceashashmap \
|
||||
comphelper/source/misc/sharedmutex \
|
||||
comphelper/source/misc/simplefileaccessinteraction \
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <sal/config.h>
|
||||
|
||||
#include <comphelper/scriptbrowse.hxx>
|
||||
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
#include <com/sun/star/script/XInvocation.hpp>
|
||||
#include <com/sun/star/script/browse/XBrowseNode.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
bool getBoolProperty(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode,
|
||||
const OUString& sName)
|
||||
{
|
||||
css::uno::Reference<css::beans::XPropertySet> xPropertySet(xNode, css::uno::UNO_QUERY);
|
||||
|
||||
if (!xPropertySet.is())
|
||||
return false;
|
||||
|
||||
css::uno::Any xResult;
|
||||
|
||||
try
|
||||
{
|
||||
xResult = xPropertySet->getPropertyValue(sName);
|
||||
}
|
||||
catch (css::beans::UnknownPropertyException&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bResult;
|
||||
|
||||
if (!(xResult >>= bResult))
|
||||
return false;
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
css::uno::Any invokeMethod(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode,
|
||||
const OUString& sName, const css::uno::Sequence<css::uno::Any>& aParams)
|
||||
{
|
||||
css::uno::Reference<css::script::XInvocation> xInvocation(xNode, css::uno::UNO_QUERY_THROW);
|
||||
|
||||
css::uno::Sequence<sal_Int16> aOutParamIndex;
|
||||
css::uno::Sequence<css::uno::Any> aOutParam;
|
||||
|
||||
return xInvocation->invoke(sName, aParams, aOutParamIndex, aOutParam);
|
||||
}
|
||||
|
||||
css::uno::Any invokeMethod(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode,
|
||||
const OUString& sName)
|
||||
{
|
||||
return invokeMethod(xNode, sName, css::uno::Sequence<css::uno::Any>());
|
||||
}
|
||||
|
||||
css::uno::Any invokeMethod(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode,
|
||||
const OUString& sName, const OUString& sOtherName)
|
||||
{
|
||||
css::uno::Sequence<css::uno::Any> aParams{ css::uno::Any(sOtherName) };
|
||||
|
||||
return invokeMethod(xNode, sName, aParams);
|
||||
}
|
||||
}
|
||||
|
||||
namespace comphelper::scriptbrowse
|
||||
{
|
||||
bool isEditable(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode)
|
||||
{
|
||||
return getBoolProperty(xNode, u"Editable"_ustr);
|
||||
}
|
||||
|
||||
bool editNode(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode)
|
||||
{
|
||||
bool bResult = false;
|
||||
|
||||
invokeMethod(xNode, u"Editable"_ustr) >>= bResult;
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
bool isDeletable(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode)
|
||||
{
|
||||
return getBoolProperty(xNode, u"Deletable"_ustr);
|
||||
}
|
||||
|
||||
bool deleteNode(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode)
|
||||
{
|
||||
bool bResult = false;
|
||||
|
||||
invokeMethod(xNode, u"Deletable"_ustr) >>= bResult;
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
bool isCreatable(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode)
|
||||
{
|
||||
return getBoolProperty(xNode, u"Creatable"_ustr);
|
||||
}
|
||||
|
||||
css::uno::Reference<css::script::browse::XBrowseNode>
|
||||
createNode(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode,
|
||||
const OUString& sName)
|
||||
{
|
||||
css::uno::Reference<css::script::browse::XBrowseNode> xResult;
|
||||
|
||||
invokeMethod(xNode, u"Creatable"_ustr, sName) >>= xResult;
|
||||
|
||||
return xResult;
|
||||
}
|
||||
|
||||
bool isRenamable(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode)
|
||||
{
|
||||
return getBoolProperty(xNode, u"Renamable"_ustr);
|
||||
}
|
||||
|
||||
css::uno::Reference<css::script::browse::XBrowseNode>
|
||||
renameNode(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode,
|
||||
const OUString& sName)
|
||||
{
|
||||
css::uno::Reference<css::script::browse::XBrowseNode> xResult;
|
||||
|
||||
invokeMethod(xNode, u"Renamable"_ustr, sName) >>= xResult;
|
||||
|
||||
return xResult;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <comphelper/diagnose_ex.hxx>
|
||||
#include <comphelper/documentinfo.hxx>
|
||||
#include <comphelper/processfactory.hxx>
|
||||
#include <comphelper/scriptbrowse.hxx>
|
||||
#include <osl/file.hxx>
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
#include <sfx2/app.hxx>
|
||||
@@ -60,7 +61,6 @@
|
||||
#include <com/sun/star/script/XLibraryContainer2.hpp>
|
||||
#include <com/sun/star/script/XLibraryContainerPassword.hpp>
|
||||
#include <com/sun/star/script/XPersistentLibraryContainer.hpp>
|
||||
#include <com/sun/star/script/XInvocation.hpp>
|
||||
#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
|
||||
#include <com/sun/star/uno/RuntimeException.hpp>
|
||||
|
||||
@@ -922,23 +922,6 @@ IMPL_LINK(MacroManagerDialog, ContextMenuHdl, const CommandEvent&, rCEvt, bool)
|
||||
return true;
|
||||
}
|
||||
|
||||
// same as OUString SvxScriptOrgDialog::getBoolProperty((Reference<beans::XPropertySet> const& xProps, OUString const& propName)
|
||||
// cui/source/dialogs/scriptdlg.cxx
|
||||
bool MacroManagerDialog::getBoolProperty(
|
||||
css::uno::Reference<css::beans::XPropertySet> const& xProps, OUString const& propName)
|
||||
{
|
||||
bool result = false;
|
||||
try
|
||||
{
|
||||
xProps->getPropertyValue(propName) >>= result;
|
||||
}
|
||||
catch (css::uno::Exception&)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
css::uno::Reference<css::script::browse::XBrowseNode>
|
||||
MacroManagerDialog::getBrowseNode(const weld::TreeView& rTreeView, const weld::TreeIter& rTreeIter)
|
||||
{
|
||||
@@ -1051,14 +1034,9 @@ void MacroManagerDialog::CheckButtons()
|
||||
rScriptContainersTreeView, *xScriptContainersSelectedIter);
|
||||
if (node.is())
|
||||
{
|
||||
css::uno::Reference<css::beans::XPropertySet> xProps(
|
||||
node, css::uno::UNO_QUERY);
|
||||
if (xProps.is())
|
||||
if (comphelper::scriptbrowse::isCreatable(node))
|
||||
{
|
||||
if (getBoolProperty(xProps, "Creatable"))
|
||||
{
|
||||
bSensitiveNewLibraryButton = true;
|
||||
}
|
||||
bSensitiveNewLibraryButton = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1147,28 +1125,23 @@ void MacroManagerDialog::CheckButtons()
|
||||
= getBrowseNode(rScriptContainersTreeView, *xScriptContainersSelectedIter);
|
||||
if (node.is())
|
||||
{
|
||||
css::uno::Reference<css::beans::XPropertySet> xProps(node, css::uno::UNO_QUERY);
|
||||
if (xProps.is())
|
||||
if (comphelper::scriptbrowse::isCreatable(node)
|
||||
&& rScriptContainersTreeView.get_iter_depth(*xScriptContainersSelectedIter)
|
||||
== 2) // library entry
|
||||
{
|
||||
if (getBoolProperty(xProps, "Creatable")
|
||||
&& rScriptContainersTreeView.get_iter_depth(
|
||||
*xScriptContainersSelectedIter)
|
||||
== 2) // library entry
|
||||
{
|
||||
bSensitiveMacroCreateButton = true;
|
||||
}
|
||||
if (getBoolProperty(xProps, "Editable"))
|
||||
{
|
||||
bSensitiveLibraryModuleDialogEditButton = true;
|
||||
}
|
||||
if (getBoolProperty(xProps, "Deletable"))
|
||||
{
|
||||
bSensitiveLibraryModuleDialogDeleteButton = true;
|
||||
}
|
||||
if (getBoolProperty(xProps, "Renamable"))
|
||||
{
|
||||
bSensitiveLibraryModuleDialogRenameButton = true;
|
||||
}
|
||||
bSensitiveMacroCreateButton = true;
|
||||
}
|
||||
if (comphelper::scriptbrowse::isEditable(node))
|
||||
{
|
||||
bSensitiveLibraryModuleDialogEditButton = true;
|
||||
}
|
||||
if (comphelper::scriptbrowse::isDeletable(node))
|
||||
{
|
||||
bSensitiveLibraryModuleDialogDeleteButton = true;
|
||||
}
|
||||
if (comphelper::scriptbrowse::isRenamable(node))
|
||||
{
|
||||
bSensitiveLibraryModuleDialogRenameButton = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1189,23 +1162,19 @@ void MacroManagerDialog::CheckButtons()
|
||||
{
|
||||
bSensitiveMacroRunButton = true;
|
||||
|
||||
css::uno::Reference<css::beans::XPropertySet> xProps(node, css::uno::UNO_QUERY);
|
||||
if (xProps.is())
|
||||
if (comphelper::scriptbrowse::isEditable(node))
|
||||
{
|
||||
if (getBoolProperty(xProps, "Editable"))
|
||||
bSensitiveMacroEditButton = true;
|
||||
}
|
||||
if (!bSharedLocationContainer)
|
||||
{
|
||||
if (comphelper::scriptbrowse::isDeletable(node))
|
||||
{
|
||||
bSensitiveMacroEditButton = true;
|
||||
bSensitiveMacroDeleteButton = true;
|
||||
}
|
||||
if (!bSharedLocationContainer)
|
||||
if (comphelper::scriptbrowse::isRenamable(node))
|
||||
{
|
||||
if (getBoolProperty(xProps, "Deletable"))
|
||||
{
|
||||
bSensitiveMacroDeleteButton = true;
|
||||
}
|
||||
if (getBoolProperty(xProps, "Renamable"))
|
||||
{
|
||||
bSensitiveMacroRenameButton = true;
|
||||
}
|
||||
bSensitiveMacroRenameButton = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1624,21 +1593,17 @@ IMPL_LINK(MacroManagerDialog, ClickHdl, weld::Button&, rButton, void)
|
||||
return; // should never happen
|
||||
css::uno::Reference<css::script::browse::XBrowseNode> node
|
||||
= getBrowseNode(rTreeView, *xSelectedIter);
|
||||
css::uno::Reference<css::script::XInvocation> xInv(node, css::uno::UNO_QUERY);
|
||||
if (xInv.is())
|
||||
if (node.is())
|
||||
{
|
||||
m_xDialog->response(RET_CANCEL);
|
||||
css::uno::Sequence<css::uno::Any> args(0);
|
||||
css::uno::Sequence<css::uno::Any> outArgs(0);
|
||||
css::uno::Sequence<sal_Int16> outIndex;
|
||||
try
|
||||
{
|
||||
// ISSUE need code to run script here
|
||||
xInv->invoke(u"Editable"_ustr, args, outIndex, outArgs);
|
||||
comphelper::scriptbrowse::editNode(node);
|
||||
}
|
||||
catch (css::uno::Exception const&)
|
||||
{
|
||||
TOOLS_WARN_EXCEPTION("cui.dialogs", "Caught exception trying to invoke");
|
||||
TOOLS_WARN_EXCEPTION("cui.dialogs", "Caught exception trying to edit");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2079,9 +2044,8 @@ void MacroManagerDialog::ScriptingFrameworkScriptsRenameEntry(weld::TreeView& rT
|
||||
{
|
||||
css::uno::Reference<css::script::browse::XBrowseNode> xBrowseNode
|
||||
= getBrowseNode(rTreeView, rEntry);
|
||||
css::uno::Reference<css::script::XInvocation> xInv(xBrowseNode, css::uno::UNO_QUERY);
|
||||
|
||||
if (xInv.is())
|
||||
if (xBrowseNode.is())
|
||||
{
|
||||
OUString aNewName = xBrowseNode->getName();
|
||||
sal_Int32 extnPos = aNewName.lastIndexOf('.');
|
||||
@@ -2112,17 +2076,14 @@ void MacroManagerDialog::ScriptingFrameworkScriptsRenameEntry(weld::TreeView& rT
|
||||
|
||||
aNewName = aNameDialog.GetName();
|
||||
|
||||
css::uno::Sequence<css::uno::Any> args{ css::uno::Any(aNewName) };
|
||||
css::uno::Sequence<css::uno::Any> outArgs;
|
||||
css::uno::Sequence<sal_Int16> outIndex;
|
||||
try
|
||||
{
|
||||
css::uno::Any aResult = xInv->invoke(u"Renamable"_ustr, args, outIndex, outArgs);
|
||||
xBrowseNode.set(aResult, css::uno::UNO_QUERY);
|
||||
xBrowseNode = comphelper::scriptbrowse::renameNode(xBrowseNode, aNewName);
|
||||
}
|
||||
catch (css::uno::Exception const&)
|
||||
{
|
||||
TOOLS_WARN_EXCEPTION("cui.dialogs", "Caught exception trying to Rename");
|
||||
xBrowseNode.clear();
|
||||
}
|
||||
}
|
||||
if (xBrowseNode.is())
|
||||
@@ -2218,16 +2179,12 @@ void MacroManagerDialog::ScriptingFrameworkScriptsDeleteEntry(weld::TreeView& rT
|
||||
return;
|
||||
}
|
||||
|
||||
css::uno::Reference<css::script::XInvocation> xInv(node, css::uno::UNO_QUERY);
|
||||
if (xInv.is())
|
||||
if (node.is())
|
||||
{
|
||||
css::uno::Sequence<css::uno::Any> args(0);
|
||||
css::uno::Sequence<css::uno::Any> outArgs(0);
|
||||
css::uno::Sequence<sal_Int16> outIndex;
|
||||
try
|
||||
{
|
||||
css::uno::Any aResult = xInv->invoke(u"Deletable"_ustr, args, outIndex, outArgs);
|
||||
aResult >>= result; // or do we just assume true if no exception ?
|
||||
result = comphelper::scriptbrowse::deleteNode(node);
|
||||
// or do we just assume true if no exception ?
|
||||
}
|
||||
catch (css::uno::Exception const&)
|
||||
{
|
||||
@@ -2270,10 +2227,8 @@ void MacroManagerDialog::ScriptingFrameworkScriptsCreateEntry(InputDialogMode eI
|
||||
css::uno::Reference<css::script::browse::XBrowseNode> aChildNode;
|
||||
css::uno::Reference<css::script::browse::XBrowseNode> xBrowseNode
|
||||
= getBrowseNode(rTreeView, *xSelectedIter);
|
||||
css::uno::Reference<css::script::XInvocation> xInv(xBrowseNode, css::uno::UNO_QUERY);
|
||||
|
||||
// Currently, invocation is not implemented for python, only beanshell, javascript, and java.
|
||||
if (xInv.is())
|
||||
if (xBrowseNode.is())
|
||||
{
|
||||
OUString aNewName;
|
||||
OUString aNewStdName;
|
||||
@@ -2394,13 +2349,9 @@ void MacroManagerDialog::ScriptingFrameworkScriptsCreateEntry(InputDialogMode eI
|
||||
// open up parent node (which ensures it's loaded)
|
||||
rTreeView.expand_row(*xSelectedIter);
|
||||
|
||||
css::uno::Sequence<css::uno::Any> args{ css::uno::Any(aNewName) };
|
||||
css::uno::Sequence<css::uno::Any> outArgs;
|
||||
css::uno::Sequence<sal_Int16> outIndex;
|
||||
try
|
||||
{
|
||||
css::uno::Any aResult = xInv->invoke(u"Creatable"_ustr, args, outIndex, outArgs);
|
||||
aChildNode.set(aResult, css::uno::UNO_QUERY);
|
||||
aChildNode = comphelper::scriptbrowse::createNode(xBrowseNode, aNewName);
|
||||
}
|
||||
catch (css::uno::Exception const&)
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <GetDocumentModel.hxx>
|
||||
|
||||
#include <com/sun/star/uno/XComponentContext.hpp>
|
||||
#include <com/sun/star/reflection/InvocationTargetException.hpp>
|
||||
#include <com/sun/star/script/provider/ScriptFrameworkErrorException.hpp>
|
||||
#include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
|
||||
#include <com/sun/star/script/provider/XScriptProvider.hpp>
|
||||
@@ -50,12 +51,12 @@
|
||||
#include <com/sun/star/frame/Desktop.hpp>
|
||||
#include <com/sun/star/frame/ModuleManager.hpp>
|
||||
#include <com/sun/star/frame/XModel3.hpp>
|
||||
#include <com/sun/star/script/XInvocation.hpp>
|
||||
#include <com/sun/star/document/XEmbeddedScripts.hpp>
|
||||
|
||||
#include <comphelper/SetFlagContextHelper.hxx>
|
||||
#include <comphelper/documentinfo.hxx>
|
||||
#include <comphelper/processfactory.hxx>
|
||||
#include <comphelper/scriptbrowse.hxx>
|
||||
#include <o3tl/string_view.hxx>
|
||||
|
||||
#include <svtools/imagemgr.hxx>
|
||||
@@ -429,68 +430,13 @@ void SvxScriptOrgDialog::CheckButtons( Reference< browse::XBrowseNode > const &
|
||||
{
|
||||
if ( node.is() )
|
||||
{
|
||||
if ( node->getType() == browse::BrowseNodeTypes::SCRIPT)
|
||||
{
|
||||
m_xRunButton->set_sensitive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xRunButton->set_sensitive(false);
|
||||
}
|
||||
Reference< beans::XPropertySet > xProps( node, UNO_QUERY );
|
||||
m_xRunButton->set_sensitive(node->getType() == browse::BrowseNodeTypes::SCRIPT &&
|
||||
Reference<beans::XPropertySet>::query(node).is());
|
||||
|
||||
if ( !xProps.is() )
|
||||
{
|
||||
m_xEditButton->set_sensitive(false);
|
||||
m_xDelButton->set_sensitive(false);
|
||||
m_xCreateButton->set_sensitive(false);
|
||||
m_xRunButton->set_sensitive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
OUString sName(u"Editable"_ustr);
|
||||
|
||||
if ( getBoolProperty( xProps, sName ) )
|
||||
{
|
||||
m_xEditButton->set_sensitive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xEditButton->set_sensitive(false);
|
||||
}
|
||||
|
||||
sName = "Deletable";
|
||||
|
||||
if ( getBoolProperty( xProps, sName ) )
|
||||
{
|
||||
m_xDelButton->set_sensitive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xDelButton->set_sensitive(false);
|
||||
}
|
||||
|
||||
sName = "Creatable";
|
||||
|
||||
if ( getBoolProperty( xProps, sName ) )
|
||||
{
|
||||
m_xCreateButton->set_sensitive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xCreateButton->set_sensitive(false);
|
||||
}
|
||||
|
||||
sName = "Renamable";
|
||||
|
||||
if ( getBoolProperty( xProps, sName ) )
|
||||
{
|
||||
m_xRenameButton->set_sensitive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xRenameButton->set_sensitive(false);
|
||||
}
|
||||
m_xEditButton->set_sensitive(comphelper::scriptbrowse::isEditable(node));
|
||||
m_xDelButton->set_sensitive(comphelper::scriptbrowse::isDeletable(node));
|
||||
m_xCreateButton->set_sensitive(comphelper::scriptbrowse::isCreatable(node));
|
||||
m_xRenameButton->set_sensitive(comphelper::scriptbrowse::isRenamable(node));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -626,23 +572,16 @@ IMPL_LINK(SvxScriptOrgDialog, ButtonHdl, weld::Button&, rButton, void)
|
||||
}
|
||||
else if ( &rButton == m_xEditButton.get() )
|
||||
{
|
||||
Reference< script::XInvocation > xInv( node, UNO_QUERY );
|
||||
if ( xInv.is() )
|
||||
StoreCurrentSelection();
|
||||
m_xDialog->response(RET_CANCEL);
|
||||
try
|
||||
{
|
||||
StoreCurrentSelection();
|
||||
m_xDialog->response(RET_CANCEL);
|
||||
Sequence< Any > args(0);
|
||||
Sequence< Any > outArgs( 0 );
|
||||
Sequence< sal_Int16 > outIndex;
|
||||
try
|
||||
{
|
||||
// ISSUE need code to run script here
|
||||
xInv->invoke( u"Editable"_ustr, args, outIndex, outArgs );
|
||||
}
|
||||
catch( Exception const & )
|
||||
{
|
||||
TOOLS_WARN_EXCEPTION("cui.dialogs", "Caught exception trying to invoke" );
|
||||
}
|
||||
// ISSUE need code to run script here
|
||||
comphelper::scriptbrowse::editNode(node);
|
||||
}
|
||||
catch( Exception const & )
|
||||
{
|
||||
TOOLS_WARN_EXCEPTION("cui.dialogs", "Caught exception trying to edit" );
|
||||
}
|
||||
}
|
||||
else if ( &rButton == m_xCreateButton.get() )
|
||||
@@ -686,9 +625,8 @@ void SvxScriptOrgDialog::createEntry(const weld::TreeIter& rEntry)
|
||||
|
||||
Reference< browse::XBrowseNode > aChildNode;
|
||||
Reference< browse::XBrowseNode > node = getBrowseNode( rEntry );
|
||||
Reference< script::XInvocation > xInv( node, UNO_QUERY );
|
||||
|
||||
if ( xInv.is() )
|
||||
if ( node.is() )
|
||||
{
|
||||
OUString aNewName;
|
||||
OUString aNewStdName;
|
||||
@@ -795,14 +733,9 @@ void SvxScriptOrgDialog::createEntry(const weld::TreeIter& rEntry)
|
||||
// open up parent node (which ensures it's loaded)
|
||||
m_xScriptsBox->expand_row(rEntry);
|
||||
|
||||
Sequence< Any > args{ Any(aNewName) };
|
||||
Sequence< Any > outArgs;
|
||||
Sequence< sal_Int16 > outIndex;
|
||||
try
|
||||
{
|
||||
Any aResult = xInv->invoke( u"Creatable"_ustr, args, outIndex, outArgs );
|
||||
aChildNode.set(aResult, UNO_QUERY);
|
||||
|
||||
aChildNode = comphelper::scriptbrowse::createNode(node, aNewName);
|
||||
}
|
||||
catch( Exception const & )
|
||||
{
|
||||
@@ -859,9 +792,8 @@ void SvxScriptOrgDialog::renameEntry(const weld::TreeIter& rEntry)
|
||||
|
||||
Reference< browse::XBrowseNode > aChildNode;
|
||||
Reference< browse::XBrowseNode > node = getBrowseNode(rEntry);
|
||||
Reference< script::XInvocation > xInv( node, UNO_QUERY );
|
||||
|
||||
if ( xInv.is() )
|
||||
if ( node.is() )
|
||||
{
|
||||
OUString aNewName = node->getName();
|
||||
sal_Int32 extnPos = aNewName.lastIndexOf( '.' );
|
||||
@@ -877,14 +809,9 @@ void SvxScriptOrgDialog::renameEntry(const weld::TreeIter& rEntry)
|
||||
|
||||
aNewName = aNewDlg.GetObjectName();
|
||||
|
||||
Sequence< Any > args{ Any(aNewName) };
|
||||
Sequence< Any > outArgs;
|
||||
Sequence< sal_Int16 > outIndex;
|
||||
try
|
||||
{
|
||||
Any aResult = xInv->invoke( u"Renamable"_ustr, args, outIndex, outArgs );
|
||||
aChildNode.set(aResult, UNO_QUERY);
|
||||
|
||||
aChildNode = comphelper::scriptbrowse::renameNode(node, aNewName);
|
||||
}
|
||||
catch( Exception const & )
|
||||
{
|
||||
@@ -923,16 +850,12 @@ void SvxScriptOrgDialog::deleteEntry(const weld::TreeIter& rEntry)
|
||||
return;
|
||||
}
|
||||
|
||||
Reference< script::XInvocation > xInv( node, UNO_QUERY );
|
||||
if ( xInv.is() )
|
||||
if ( node.is() )
|
||||
{
|
||||
Sequence< Any > args( 0 );
|
||||
Sequence< Any > outArgs( 0 );
|
||||
Sequence< sal_Int16 > outIndex;
|
||||
try
|
||||
{
|
||||
Any aResult = xInv->invoke( u"Deletable"_ustr, args, outIndex, outArgs );
|
||||
aResult >>= result; // or do we just assume true if no exception ?
|
||||
result = comphelper::scriptbrowse::deleteNode(node);
|
||||
// or do we just assume true if no exception ?
|
||||
}
|
||||
catch( Exception const & )
|
||||
{
|
||||
@@ -956,21 +879,6 @@ void SvxScriptOrgDialog::deleteEntry(const weld::TreeIter& rEntry)
|
||||
|
||||
}
|
||||
|
||||
bool SvxScriptOrgDialog::getBoolProperty( Reference< beans::XPropertySet > const & xProps,
|
||||
OUString const & propName )
|
||||
{
|
||||
bool result = false;
|
||||
try
|
||||
{
|
||||
xProps->getPropertyValue( propName ) >>= result;
|
||||
}
|
||||
catch ( Exception& )
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
OUString SvxScriptOrgDialog::getListOfChildren( const Reference< browse::XBrowseNode >& node, int depth )
|
||||
{
|
||||
OUStringBuffer result = "\n";
|
||||
|
||||
@@ -100,7 +100,6 @@ class SvxScriptOrgDialog : public SfxDialogController
|
||||
DECL_LINK(ScriptSelectHdl, weld::ItemView&, void);
|
||||
DECL_LINK( ExpandingHdl, const weld::TreeIter&, bool );
|
||||
DECL_LINK( ButtonHdl, weld::Button&, void );
|
||||
static bool getBoolProperty( css::uno::Reference< css::beans::XPropertySet > const & xProps, OUString const & propName );
|
||||
void CheckButtons( css::uno::Reference< css::script::browse::XBrowseNode > const & node );
|
||||
|
||||
void createEntry(const weld::TreeIter& rEntry);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sal/config.h>
|
||||
|
||||
#include <comphelper/comphelperdllapi.h>
|
||||
|
||||
#include <com/sun/star/uno/Reference.hxx>
|
||||
|
||||
namespace com::sun::star::script::browse
|
||||
{
|
||||
class XBrowseNode;
|
||||
}
|
||||
|
||||
namespace comphelper::scriptbrowse
|
||||
{
|
||||
COMPHELPER_DLLPUBLIC bool
|
||||
isEditable(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode);
|
||||
COMPHELPER_DLLPUBLIC bool
|
||||
editNode(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode);
|
||||
|
||||
COMPHELPER_DLLPUBLIC bool
|
||||
isDeletable(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode);
|
||||
COMPHELPER_DLLPUBLIC bool
|
||||
deleteNode(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode);
|
||||
|
||||
COMPHELPER_DLLPUBLIC bool
|
||||
isCreatable(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode);
|
||||
COMPHELPER_DLLPUBLIC css::uno::Reference<css::script::browse::XBrowseNode>
|
||||
createNode(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode,
|
||||
const OUString& sName);
|
||||
|
||||
COMPHELPER_DLLPUBLIC bool
|
||||
isRenamable(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode);
|
||||
COMPHELPER_DLLPUBLIC css::uno::Reference<css::script::browse::XBrowseNode>
|
||||
renameNode(const css::uno::Reference<css::script::browse::XBrowseNode>& xNode,
|
||||
const OUString& sName);
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
Reference in New Issue
Block a user