summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-01-08 20:09:01 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-01-13 11:59:29 +0100
commite4a454f8a6e757739145689a445a9516f794b972 (patch)
tree596285c73f785dd8efc4c5a57af6240fc16ea89b /svx/source
parent9bbf7a1a1029f780e569b5e8df79e86ba5b8c88e (diff)
devtools: Add left-side tree of the document model
This adds the graoundwork for displaying the DOM of the current document as a left-side tree and implements filling in the paragraphs for Writer. The content of the DOM tree is of course a WIP. Change-Id: I99c75b0c46d9a6a4ca398c46de0af759d459b7f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108976 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/devtools/DevelopmentToolDockingWindow.cxx87
1 files changed, 86 insertions, 1 deletions
diff --git a/svx/source/devtools/DevelopmentToolDockingWindow.cxx b/svx/source/devtools/DevelopmentToolDockingWindow.cxx
index b1f66a3037e5..ac97e9134b17 100644
--- a/svx/source/devtools/DevelopmentToolDockingWindow.cxx
+++ b/svx/source/devtools/DevelopmentToolDockingWindow.cxx
@@ -22,6 +22,8 @@
#include <com/sun/star/beans/MethodConcept.hpp>
#include <com/sun/star/reflection/XIdlMethod.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <comphelper/processfactory.hxx>
@@ -41,6 +43,8 @@
#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+
using namespace css;
namespace
@@ -107,23 +111,104 @@ DevelopmentToolDockingWindow::DevelopmentToolDockingWindow(SfxBindings* pInputBi
"svx/ui/developmenttool.ui")
, mpClassNameLabel(m_xBuilder->weld_label("class_name_value_id"))
, mpClassListBox(m_xBuilder->weld_tree_view("class_listbox_id"))
+ , mpLeftSideTreeView(m_xBuilder->weld_tree_view("leftside_treeview_id"))
{
+ mpLeftSideTreeView->connect_changed(LINK(this, DevelopmentToolDockingWindow, LeftSideSelected));
+
auto* pViewFrame = pInputBindings->GetDispatcher()->GetFrame();
uno::Reference<frame::XController> xController = pViewFrame->GetFrame().GetController();
+ mxRoot = pInputBindings->GetDispatcher()->GetFrame()->GetObjectShell()->GetBaseModel();
+
+ introspect(mxRoot);
+ inspectDocument();
+
uno::Reference<view::XSelectionSupplier> xSupplier(xController, uno::UNO_QUERY);
if (xSupplier.is())
{
uno::Reference<view::XSelectionChangeListener> xChangeListener(
new SelectionChangeHandler(xController, this));
xSupplier->addSelectionChangeListener(xChangeListener);
- introspect(pInputBindings->GetDispatcher()->GetFrame()->GetObjectShell()->GetBaseModel());
+ }
+}
+
+IMPL_LINK_NOARG(DevelopmentToolDockingWindow, LeftSideSelected, weld::TreeView&, void)
+{
+ OUString sID = mpLeftSideTreeView->get_selected_text();
+ auto& rObject = maUnoObjectMap.at(sID);
+ if (rObject.is())
+ introspect(rObject);
+}
+
+void DevelopmentToolDockingWindow::inspectDocument()
+{
+ uno::Reference<lang::XServiceInfo> xDocument(mxRoot, uno::UNO_QUERY_THROW);
+
+ if (xDocument->supportsService("com.sun.star.sheet.SpreadsheetDocument"))
+ {
+ msDocumentType = "Spreadsheet Document";
+ }
+ else if (xDocument->supportsService("com.sun.star.presentation.PresentationDocument"))
+ {
+ msDocumentType = "Presentation Document";
+ }
+ else if (xDocument->supportsService("com.sun.star.drawing.DrawingDocument"))
+ {
+ msDocumentType = "Drawing Document";
+ }
+ else if (xDocument->supportsService("com.sun.star.text.TextDocument")
+ || xDocument->supportsService("com.sun.star.text.WebDocument"))
+ {
+ msDocumentType = "Text Document";
+
+ std::unique_ptr<weld::TreeIter> pParent = mpLeftSideTreeView->make_iterator();
+ mpLeftSideTreeView->insert(nullptr, -1, &msDocumentType, nullptr, nullptr, nullptr, false,
+ pParent.get());
+ maUnoObjectMap.emplace(msDocumentType, xDocument);
+
+ uno::Reference<text::XTextDocument> xTextDocument(xDocument, uno::UNO_QUERY);
+ if (xTextDocument.is())
+ {
+ uno::Reference<container::XEnumerationAccess> xParagraphEnumAccess(
+ xTextDocument->getText()->getText(), uno::UNO_QUERY);
+ if (xParagraphEnumAccess.is())
+ {
+ uno::Reference<container::XEnumeration> xParagraphEnum
+ = xParagraphEnumAccess->createEnumeration();
+ if (xParagraphEnum.is())
+ {
+ sal_Int32 i = 0;
+ std::unique_ptr<weld::TreeIter> pCurrent = mpLeftSideTreeView->make_iterator();
+ while (xParagraphEnum->hasMoreElements())
+ {
+ OUString aString = "Paragraph " + OUString::number(i + 1);
+ mpLeftSideTreeView->insert(pParent.get(), -1, &aString, nullptr, nullptr,
+ nullptr, false, pCurrent.get());
+
+ uno::Reference<text::XTextContent> const xElem(
+ xParagraphEnum->nextElement(), uno::UNO_QUERY);
+ maUnoObjectMap.emplace(aString, xElem);
+
+ i++;
+ }
+ }
+ }
+ }
}
}
DevelopmentToolDockingWindow::~DevelopmentToolDockingWindow() { disposeOnce(); }
+void DevelopmentToolDockingWindow::dispose()
+{
+ mpClassNameLabel.reset();
+ mpClassListBox.reset();
+ mpLeftSideTreeView.reset();
+
+ SfxDockingWindow::dispose();
+}
+
void DevelopmentToolDockingWindow::ToggleFloatingMode()
{
SfxDockingWindow::ToggleFloatingMode();