summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-02-10 20:56:32 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-02-12 06:39:06 +0100
commitece24a14fd3a7230e47bbe13e9b244b383aab2ee (patch)
tree9570c9fe609ed04304e36f94a0964a267eb3f982 /sfx2/source
parentb0d9e36d31d5bfa6c5797f5285bf1bf74777c5ed (diff)
devtools: handle nested sequences correctly
Change-Id: I64d7eabf8437b309a1c57e3b3dbb6abadfd507fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110742 Tested-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/devtools/ObjectInspectorTreeHandler.cxx118
1 files changed, 76 insertions, 42 deletions
diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
index 87e92573fe36..5e516868bc2e 100644
--- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
+++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
@@ -235,8 +235,14 @@ public:
{
if (maAny.hasValue())
{
- auto xInterface = uno::Reference<uno::XInterface>(maAny, uno::UNO_QUERY);
- return xInterface.is();
+ switch (maAny.getValueType().getTypeClass())
+ {
+ case uno::TypeClass_INTERFACE:
+ case uno::TypeClass_SEQUENCE:
+ return true;
+ default:
+ break;
+ }
}
return false;
}
@@ -405,14 +411,38 @@ public:
uno::Reference<uno::XInterface> xCurrent;
if (aCurrentAny.hasValue())
{
- auto xInterface = uno::Reference<uno::XInterface>(aCurrentAny, uno::UNO_QUERY);
- if (xInterface.is())
- xCurrent = xInterface;
+ switch (aCurrentAny.getValueType().getTypeClass())
+ {
+ case uno::TypeClass_INTERFACE:
+ {
+ auto xInterface
+ = uno::Reference<uno::XInterface>(aCurrentAny, uno::UNO_QUERY);
+ lclAppendNodeToParent(pTree, rParent,
+ new GenericPropertiesNode(OUString::number(i),
+ xInterface, aCurrentAny,
+ mxContext));
+ }
+ break;
+
+ case uno::TypeClass_SEQUENCE:
+ {
+ lclAppendNodeToParent(
+ pTree, rParent,
+ new SequenceNode(OUString::number(i), aCurrentAny, mxContext));
+ }
+ break;
+
+ default:
+ {
+ lclAppendNodeToParent(
+ pTree, rParent,
+ new ObjectInspectorNamedNode(OUString::number(i),
+ uno::Reference<uno::XInterface>(),
+ aCurrentAny, mxContext));
+ }
+ break;
+ }
}
-
- lclAppendNodeToParent(
- pTree, rParent,
- new GenericPropertiesNode(OUString::number(i), xCurrent, aCurrentAny, mxContext));
}
}
@@ -438,13 +468,16 @@ public:
void GenericPropertiesNode::fillChildren(std::unique_ptr<weld::TreeView>& pTree,
weld::TreeIter const& rParent)
{
- if (!mxObject.is())
- return;
+ uno::Any aAny = maAny;
+ if (!maAny.hasValue())
+ {
+ aAny = uno::makeAny(mxObject);
+ }
uno::Reference<beans::XIntrospection> xIntrospection = beans::theIntrospection::get(mxContext);
- auto xIntrospectionAccess = xIntrospection->inspect(uno::makeAny(mxObject));
+ auto xIntrospectionAccess = xIntrospection->inspect(aAny);
auto xInvocationFactory = css::script::Invocation::create(mxContext);
- uno::Sequence<uno::Any> aParameters = { uno::Any(mxObject) };
+ uno::Sequence<uno::Any> aParameters = { aAny };
auto xInvocationInterface = xInvocationFactory->createInstanceWithArguments(aParameters);
uno::Reference<script::XInvocation> xInvocation(xInvocationInterface, uno::UNO_QUERY);
@@ -453,50 +486,51 @@ void GenericPropertiesNode::fillChildren(std::unique_ptr<weld::TreeView>& pTree,
for (auto const& xProperty : xProperties)
{
- uno::Any aAny;
- uno::Reference<uno::XInterface> xCurrent = mxObject;
+ uno::Any aCurrentAny;
try
{
if (xInvocation->hasProperty(xProperty.Name))
{
- aAny = xInvocation->getValue(xProperty.Name);
+ aCurrentAny = xInvocation->getValue(xProperty.Name);
}
}
catch (...)
{
}
- bool bComplex = false;
- if (aAny.hasValue())
+ if (aCurrentAny.hasValue())
{
- auto xInterface = uno::Reference<uno::XInterface>(aAny, uno::UNO_QUERY);
- if (xInterface.is())
+ switch (aCurrentAny.getValueType().getTypeClass())
{
- xCurrent = xInterface;
- bComplex = true;
+ case uno::TypeClass_INTERFACE:
+ {
+ auto xInterface = uno::Reference<uno::XInterface>(aCurrentAny, uno::UNO_QUERY);
+ if (xInterface.is())
+ {
+ lclAppendNodeToParent(pTree, rParent,
+ new GenericPropertiesNode(xProperty.Name, xInterface,
+ aCurrentAny, mxContext));
+ }
+ }
+ break;
+
+ case uno::TypeClass_SEQUENCE:
+ {
+ lclAppendNodeToParent(pTree, rParent,
+ new SequenceNode(xProperty.Name, aCurrentAny, mxContext));
+ }
+ break;
+
+ default:
+ {
+ lclAppendNodeToParent(pTree, rParent,
+ new ObjectInspectorNamedNode(xProperty.Name, mxObject,
+ aCurrentAny, mxContext));
+ }
+ break;
}
}
-
- uno::TypeClass eTypeClass = aAny.getValueType().getTypeClass();
-
- if (bComplex)
- {
- lclAppendNodeToParent(
- pTree, rParent,
- new GenericPropertiesNode(xProperty.Name, xCurrent, aAny, mxContext));
- }
- else if (eTypeClass == uno::TypeClass_SEQUENCE)
- {
- lclAppendNodeToParent(pTree, rParent,
- new SequenceNode(xProperty.Name, aAny, mxContext));
- }
- else
- {
- lclAppendNodeToParent(
- pTree, rParent,
- new ObjectInspectorNamedNode(xProperty.Name, xCurrent, aAny, mxContext));
- }
}
}