[Libreoffice-commits] core.git: include/svx svx/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Feb 1 06:51:36 UTC 2021
include/svx/devtools/DevelopmentToolDockingWindow.hxx | 2 +
include/svx/devtools/DocumentModelTreeHandler.hxx | 2 +
svx/source/devtools/DevelopmentToolDockingWindow.cxx | 12 ++++++-
svx/source/devtools/DocumentModelTreeHandler.cxx | 29 ++++++++++++++++--
4 files changed, 41 insertions(+), 4 deletions(-)
New commits:
commit b58747e7dbfdb4ded3d774e850b4fcf6940c998e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed Jan 27 21:35:47 2021 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Feb 1 07:50:51 2021 +0100
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 at gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/svx/devtools/DevelopmentToolDockingWindow.hxx b/include/svx/devtools/DevelopmentToolDockingWindow.hxx
index 03ca8a387000..98a805a22716 100644
--- a/include/svx/devtools/DevelopmentToolDockingWindow.hxx
+++ b/include/svx/devtools/DevelopmentToolDockingWindow.hxx
@@ -50,6 +50,8 @@ public:
virtual void ToggleFloatingMode() override;
void introspect(css::uno::Reference<css::uno::XInterface> const& xInterface);
+
+ void selectionChanged(css::uno::Reference<css::uno::XInterface> const& xInterface);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/devtools/DocumentModelTreeHandler.hxx b/include/svx/devtools/DocumentModelTreeHandler.hxx
index ca7cab62b0b2..731c733015e0 100644
--- a/include/svx/devtools/DocumentModelTreeHandler.hxx
+++ b/include/svx/devtools/DocumentModelTreeHandler.hxx
@@ -23,6 +23,7 @@ class DocumentModelTreeHandler
private:
std::unique_ptr<weld::TreeView>& mpDocumentModelTree;
css::uno::Reference<css::uno::XInterface> mxDocument;
+ OUString msCurrentSelectionID;
void clearChildren(weld::TreeIter const& rParent);
@@ -39,6 +40,7 @@ public:
DECL_LINK(ExpandingHandler, const weld::TreeIter&, bool);
void inspectDocument();
+ void setCurrentSelectedObject(css::uno::Reference<css::uno::XInterface> xObject);
static css::uno::Reference<css::uno::XInterface> getObjectByID(OUString const& rID);
void dispose();
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: */
More information about the Libreoffice-commits
mailing list