summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-01-27 21:35:47 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-02-01 07:50:51 +0100
commitb58747e7dbfdb4ded3d774e850b4fcf6940c998e (patch)
treeb0287c409e6a7776fc1f6fa855410365de0d3b22 /svx
parentc81f3aec1ae17c6a1c6a5702cf5e42fbbad4e4b1 (diff)
devtools: add "Current Selection" to the left-side tree view
"Current Selection" shows in the object inspector the current selected object in the document. Change-Id: I944759b03b3b875e062de0d4555d93012eb48317 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110117 Tested-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/devtools/DevelopmentToolDockingWindow.cxx12
-rw-r--r--svx/source/devtools/DocumentModelTreeHandler.cxx29
2 files changed, 37 insertions, 4 deletions
diff --git a/svx/source/devtools/DevelopmentToolDockingWindow.cxx b/svx/source/devtools/DevelopmentToolDockingWindow.cxx
index 65e4d140cf0e..d5f5a1ca0be1 100644
--- a/svx/source/devtools/DevelopmentToolDockingWindow.cxx
+++ b/svx/source/devtools/DevelopmentToolDockingWindow.cxx
@@ -72,8 +72,8 @@ public:
if (xSupplier.is())
{
uno::Any aAny = xSupplier->getSelection();
- auto aRef = aAny.get<uno::Reference<uno::XInterface>>();
- mpDockingWindow->introspect(aRef);
+ auto xInterface = aAny.get<uno::Reference<uno::XInterface>>();
+ mpDockingWindow->selectionChanged(xInterface);
}
}
virtual void SAL_CALL disposing(const css::lang::EventObject& /*rEvent*/) override {}
@@ -148,6 +148,14 @@ void DevelopmentToolDockingWindow::ToggleFloatingMode()
Invalidate();
}
+void DevelopmentToolDockingWindow::selectionChanged(
+ uno::Reference<uno::XInterface> const& xInterface)
+{
+ maDocumentModelTreeHandler.setCurrentSelectedObject(xInterface);
+ // We need to update the introspection window
+ LeftSideSelected(*mpLeftSideTreeView);
+}
+
void DevelopmentToolDockingWindow::introspect(uno::Reference<uno::XInterface> const& xInterface)
{
if (!xInterface.is())
diff --git a/svx/source/devtools/DocumentModelTreeHandler.cxx b/svx/source/devtools/DocumentModelTreeHandler.cxx
index af446f923d0d..4d36077a74e7 100644
--- a/svx/source/devtools/DocumentModelTreeHandler.cxx
+++ b/svx/source/devtools/DocumentModelTreeHandler.cxx
@@ -49,11 +49,12 @@ void lclAppendToParentEntry(std::unique_ptr<weld::TreeView>& rTree, weld::TreeIt
rTree->insert(&rParent, -1, &rString, &sId, nullptr, nullptr, bChildrenOnDemand, nullptr);
}
-void lclAppend(std::unique_ptr<weld::TreeView>& rTree, OUString const& rString,
- DocumentModelTreeEntry* pEntry, bool bChildrenOnDemand = false)
+OUString lclAppend(std::unique_ptr<weld::TreeView>& rTree, OUString const& rString,
+ DocumentModelTreeEntry* pEntry, bool bChildrenOnDemand = false)
{
OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
rTree->insert(nullptr, -1, &rString, &sId, nullptr, nullptr, bChildrenOnDemand, nullptr);
+ return sId;
}
OUString lclGetNamed(uno::Reference<uno::XInterface> const& xObject)
@@ -121,6 +122,15 @@ public:
}
};
+class CurrentSelectionEntry : public DocumentModelTreeEntry
+{
+public:
+ CurrentSelectionEntry(css::uno::Reference<css::uno::XInterface> const& xObject)
+ : DocumentModelTreeEntry(xObject)
+ {
+ }
+};
+
class ParagraphsEntry : public DocumentModelTreeEntry
{
public:
@@ -623,6 +633,8 @@ void DocumentModelTreeHandler::inspectDocument()
{
uno::Reference<lang::XServiceInfo> xDocumentServiceInfo(mxDocument, uno::UNO_QUERY_THROW);
+ msCurrentSelectionID = lclAppend(mpDocumentModelTree, "Current Selection",
+ new CurrentSelectionEntry(mxDocument), false);
lclAppend(mpDocumentModelTree, "Document", new DocumentRootEntry(mxDocument), false);
if (xDocumentServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument"))
@@ -657,4 +669,17 @@ void DocumentModelTreeHandler::inspectDocument()
}
}
+void DocumentModelTreeHandler::setCurrentSelectedObject(
+ css::uno::Reference<css::uno::XInterface> xObject)
+{
+ if (msCurrentSelectionID.isEmpty())
+ return;
+
+ auto* pEntry = reinterpret_cast<DocumentModelTreeEntry*>(msCurrentSelectionID.toInt64());
+ if (!pEntry)
+ return;
+
+ pEntry->mxObject = xObject;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */