From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../sfx2/devtools/DevelopmentToolChildWindow.hxx | 27 ++++++ .../sfx2/devtools/DevelopmentToolDockingWindow.hxx | 72 +++++++++++++++ include/sfx2/devtools/DocumentModelTreeHandler.hxx | 52 +++++++++++ .../sfx2/devtools/ObjectInspectorTreeHandler.hxx | 101 +++++++++++++++++++++ include/sfx2/devtools/ObjectInspectorWidgets.hxx | 55 +++++++++++ 5 files changed, 307 insertions(+) create mode 100644 include/sfx2/devtools/DevelopmentToolChildWindow.hxx create mode 100644 include/sfx2/devtools/DevelopmentToolDockingWindow.hxx create mode 100644 include/sfx2/devtools/DocumentModelTreeHandler.hxx create mode 100644 include/sfx2/devtools/ObjectInspectorTreeHandler.hxx create mode 100644 include/sfx2/devtools/ObjectInspectorWidgets.hxx (limited to 'include/sfx2/devtools') diff --git a/include/sfx2/devtools/DevelopmentToolChildWindow.hxx b/include/sfx2/devtools/DevelopmentToolChildWindow.hxx new file mode 100644 index 000000000..d78ac5c2e --- /dev/null +++ b/include/sfx2/devtools/DevelopmentToolChildWindow.hxx @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 +#include + +/** + * Necessary child window for the development tools docking window + */ +class SAL_WARN_UNUSED SFX2_DLLPUBLIC DevelopmentToolChildWindow final : public SfxChildWindow +{ + SFX_DECL_CHILDWINDOW_WITHID(DevelopmentToolChildWindow); + + DevelopmentToolChildWindow(vcl::Window* pParentWindow, sal_uInt16 nId, SfxBindings* pBindings, + SfxChildWinInfo* pInfo); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx b/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx new file mode 100644 index 000000000..4da9fccd9 --- /dev/null +++ b/include/sfx2/devtools/DevelopmentToolDockingWindow.hxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +/** Development tool main docking window + * + * Contains two sides. Left side contains the simplified DOM tree and + * the right side the object inspector tree. + */ +class SFX2_DLLPUBLIC DevelopmentToolDockingWindow final : public SfxDockingWindow +{ +private: + std::unique_ptr mpObjectInspectorWidgets; + std::unique_ptr mpDocumentModelTreeView; + std::unique_ptr mpDomToolbar; + + // Reference to the root object for the current document + css::uno::Reference mxRoot; + // Stores the current selected object in the document + css::uno::Reference mxCurrentSelection; + css::uno::Reference mxSelectionListener; + css::uno::Reference mxSelectionSupplier; + + // Handler for the DOM tree + DocumentModelTreeHandler maDocumentModelTreeHandler; + // Handler for the object inspector tree + ObjectInspectorTreeHandler maObjectInspectorTreeHandler; + + DECL_DLLPRIVATE_LINK(DocumentModelTreeViewSelectionHandler, weld::TreeView&, void); + DECL_DLLPRIVATE_LINK(DomToolbarButtonClicked, const OString&, void); + + void updateSelection(); + +public: + DevelopmentToolDockingWindow(SfxBindings* pBindings, SfxChildWindow* pChildWindow, + vcl::Window* pParent); + + virtual ~DevelopmentToolDockingWindow() override; + + void dispose() override; + + void ToggleFloatingMode() override; + + // Signals that the selected object in the document changes + void selectionChanged(css::uno::Reference const& xInterface); + + // Signals to change to the current selected object in the object inspector + void changeToCurrentSelection(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/DocumentModelTreeHandler.hxx b/include/sfx2/devtools/DocumentModelTreeHandler.hxx new file mode 100644 index 000000000..47294d527 --- /dev/null +++ b/include/sfx2/devtools/DocumentModelTreeHandler.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 + +#include +#include + +/** Document model tree handler + * + * Handles the DOM tree part of DevTools, which includes interaction with + * the DOM tree view UI elements and the DOM model. + */ +class DocumentModelTreeHandler +{ +private: + std::unique_ptr& mpDocumentModelTree; + css::uno::Reference mxDocument; + + // Clears all children of a tree node, where the parent is + // identified by the input tree iter. + void clearChildren(weld::TreeIter const& rParent); + + // Clear all tree view nodes. + void clearAll(); + +public: + DocumentModelTreeHandler(std::unique_ptr& pDocumentModelTree, + css::uno::Reference const& xDocument); + + DECL_LINK(ExpandingHandler, const weld::TreeIter&, bool); + + void inspectDocument(); + + static css::uno::Reference getObjectByID(OUString const& rID); + + void dispose(); + + // selects the input object if it exists in the DOM tree view + void selectObject(css::uno::Reference const& xInterface); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx b/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx new file mode 100644 index 000000000..b6fa678de --- /dev/null +++ b/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 +#include +#include + +#include +#include +#include + +#include + +#include +#include + +/** Object inspector tree handler + * + * Handles the object inspector part of DevTools - mainly interaction + * between UI objects that consist of the object inspector. + * + */ +class ObjectInspectorTreeHandler +{ +private: + std::unique_ptr& mpObjectInspectorWidgets; + + // object stack to remember previously inspected objects so it is + // possible to return back to them + std::deque maInspectionStack; + + // just the current context + css::uno::Reference mxContext; + + // treeview sort and compare + comphelper::string::NaturalStringSorter mxSorter; + void setSortFunction(std::unique_ptr& pTreeView); + sal_Int32 compare(std::unique_ptr& pTreeView, const weld::TreeIter& rLeft, + const weld::TreeIter& rRight); + + // treeview manipulation + static void clearObjectInspectorChildren(std::unique_ptr& pTreeView, + weld::TreeIter const& rParent); + static void handleExpanding(std::unique_ptr& pTreeView, + weld::TreeIter const& rParent); + static void clearAll(std::unique_ptr& pTreeView); + + void appendInterfaces(css::uno::Reference const& xInterface); + void appendServices(css::uno::Reference const& xInterface); + void appendProperties(css::uno::Reference const& xInterface); + void appendMethods(css::uno::Reference const& xInterface); + + void inspectObject(css::uno::Reference const& xInterface); + + // Object stack handling + void clearStack(); + void addToStack(css::uno::Any const& rAny); + css::uno::Any popFromStack(); + + void updateBackButtonState(); + +public: + ObjectInspectorTreeHandler(std::unique_ptr& pObjectInspectorWidgets); + + // callbacks when a node in the tree view is expanded + DECL_LINK(ExpandingHandlerInterfaces, const weld::TreeIter&, bool); + DECL_LINK(ExpandingHandlerServices, const weld::TreeIter&, bool); + DECL_LINK(ExpandingHandlerProperties, const weld::TreeIter&, bool); + DECL_LINK(ExpandingHandlerMethods, const weld::TreeIter&, bool); + + // callback when the tree view selection changed to a different node + DECL_LINK(SelectionChanged, weld::TreeView&, void); + + // callback when a pop-up is triggered on a tree view node + DECL_LINK(PopupMenuHandler, const CommandEvent&, bool); + + // callback when a button is clicked on a toolbar + DECL_LINK(ToolbarButtonClicked, const OString&, void); + + // callback when a page is entered or left on the notebook bar for + // different categories + DECL_LINK(NotebookEnterPage, const OString&, void); + DECL_LINK(NotebookLeavePage, const OString&, bool); + + DECL_LINK(HeaderBarClick, int, void); + + void introspect(css::uno::Reference const& xInterface); + + void dispose(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/devtools/ObjectInspectorWidgets.hxx b/include/sfx2/devtools/ObjectInspectorWidgets.hxx new file mode 100644 index 000000000..9c719d2aa --- /dev/null +++ b/include/sfx2/devtools/ObjectInspectorWidgets.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 + +struct ObjectInspectorWidgets +{ + ObjectInspectorWidgets(const std::unique_ptr& rxBuilder) + : mpClassNameLabel(rxBuilder->weld_label("class_name_value_id")) + , mpInterfacesTreeView(rxBuilder->weld_tree_view("interfaces_treeview_id")) + , mpServicesTreeView(rxBuilder->weld_tree_view("services_treeview_id")) + , mpPropertiesTreeView(rxBuilder->weld_tree_view("properties_treeview_id")) + , mpMethodsTreeView(rxBuilder->weld_tree_view("methods_treeview_id")) + , mpToolbar(rxBuilder->weld_toolbar("object_inspector_toolbar")) + , mpNotebook(rxBuilder->weld_notebook("object_inspector_notebookbar")) + , mpTextView(rxBuilder->weld_text_view("object_inspector_text_view")) + , mpPaned(rxBuilder->weld_paned("object_inspector_paned")) + { + } + + ~ObjectInspectorWidgets() + { + // dispose welded objects + mpClassNameLabel.reset(); + mpInterfacesTreeView.reset(); + mpServicesTreeView.reset(); + mpPropertiesTreeView.reset(); + mpMethodsTreeView.reset(); + mpToolbar.reset(); + mpNotebook.reset(); + mpTextView.reset(); + mpPaned.reset(); + } + + std::unique_ptr mpClassNameLabel; + std::unique_ptr mpInterfacesTreeView; + std::unique_ptr mpServicesTreeView; + std::unique_ptr mpPropertiesTreeView; + std::unique_ptr mpMethodsTreeView; + std::unique_ptr mpToolbar; + std::unique_ptr mpNotebook; + std::unique_ptr mpTextView; + std::unique_ptr mpPaned; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3