diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-03-12 19:27:11 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-03-13 16:30:28 +0100 |
commit | 9932cd89ae238b97090b8447ed50fd1ee8bf19cc (patch) | |
tree | d1d205c8ab2db1be9b8fdec26db4d989ee1743f5 /sfx2/source | |
parent | 23e07d6b0dac8bab47eb3cd0dafb3d6315af8f20 (diff) |
devtools: document classes and method, remove unneeded methods
This documents DevTools classes and methods. In addition it also
removes some methods that aren't needed anymore.
Change-Id: I550e2ce197d1565b4f770eb7dd59b2195f2230a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112379
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/devtools/DevelopmentToolDockingWindow.cxx | 40 | ||||
-rw-r--r-- | sfx2/source/devtools/DocumentModelTreeHandler.cxx | 60 | ||||
-rw-r--r-- | sfx2/source/devtools/ObjectInspectorTreeHandler.cxx | 50 | ||||
-rw-r--r-- | sfx2/source/devtools/SelectionChangeHandler.hxx | 5 |
4 files changed, 112 insertions, 43 deletions
diff --git a/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx b/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx index a6b34091fcca..120c5b0ed23b 100644 --- a/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx +++ b/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx @@ -60,26 +60,6 @@ DevelopmentToolDockingWindow::DevelopmentToolDockingWindow(SfxBindings* pInputBi maObjectInspectorTreeHandler.introspect(mxRoot); } -void DevelopmentToolDockingWindow::inspectSelectionOrRoot() -{ - if (mxSelectionSupplier.is()) - { - css::uno::Any aAny = mxSelectionSupplier->getSelection(); - if (aAny.hasValue()) - { - auto xInterface = aAny.get<css::uno::Reference<css::uno::XInterface>>(); - if (xInterface.is()) - { - maObjectInspectorTreeHandler.introspect(xInterface); - mpSelectionToggle->set_state(TRISTATE_TRUE); - return; - } - } - } - mpSelectionToggle->set_state(TRISTATE_FALSE); - maObjectInspectorTreeHandler.introspect(mxRoot); -} - IMPL_LINK(DevelopmentToolDockingWindow, DocumentModelTreeViewSelectionHandler, weld::TreeView&, rView, void) { @@ -155,6 +135,24 @@ void DevelopmentToolDockingWindow::selectionChanged( updateSelection(); } -void DevelopmentToolDockingWindow::changeToCurrentSelection() { inspectSelectionOrRoot(); } +void DevelopmentToolDockingWindow::changeToCurrentSelection() +{ + if (mxSelectionSupplier.is()) + { + css::uno::Any aAny = mxSelectionSupplier->getSelection(); + if (aAny.hasValue()) + { + auto xInterface = aAny.get<css::uno::Reference<css::uno::XInterface>>(); + if (xInterface.is()) + { + maObjectInspectorTreeHandler.introspect(xInterface); + mpSelectionToggle->set_state(TRISTATE_TRUE); + return; + } + } + } + mpSelectionToggle->set_state(TRISTATE_FALSE); + maObjectInspectorTreeHandler.introspect(mxRoot); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/devtools/DocumentModelTreeHandler.cxx b/sfx2/source/devtools/DocumentModelTreeHandler.cxx index 6d15c56f3a5a..47dcb980a2f3 100644 --- a/sfx2/source/devtools/DocumentModelTreeHandler.cxx +++ b/sfx2/source/devtools/DocumentModelTreeHandler.cxx @@ -57,6 +57,7 @@ OUString lclAppend(std::unique_ptr<weld::TreeView>& rTree, OUString const& rStri return sId; } +// returns a name of the object, if available OUString lclGetNamed(uno::Reference<uno::XInterface> const& xObject) { uno::Reference<container::XNamed> xNamed(xObject, uno::UNO_QUERY); @@ -65,11 +66,11 @@ OUString lclGetNamed(uno::Reference<uno::XInterface> const& xObject) return xNamed->getName(); } -/** - * DocumentModelTreeEntry represents an object that is "attached" to - * the tree view an is responsible to provide the UNO object associated - * with the current node and on demand create and fill the children of - * the said node. +/** DocumentModelTreeEntry is an object "attached" to a tree node. + * + * It represents an object that is "attached" to the tree view an is + * responsible to provide the UNO object associated with the current + * node and on demand create and fill the children of the said node. */ class DocumentModelTreeEntry { @@ -113,6 +114,7 @@ protected: } }; +/** Entry that represents the document root object */ class DocumentRootEntry : public DocumentModelTreeEntry { public: @@ -122,6 +124,7 @@ public: } }; +/** Represents a paragraph object (XParagraph) */ class ParagraphEntry : public DocumentModelTreeEntry { public: @@ -156,6 +159,7 @@ public: } }; +/** Represents a list of paragraphs */ class ParagraphsEntry : public DocumentModelTreeEntry { public: @@ -200,6 +204,7 @@ public: } }; +/** Represents a list of shapes */ class ShapesEntry : public DocumentModelTreeEntry { public: @@ -236,6 +241,7 @@ public: } }; +/** Represents a list of tables */ class TablesEntry : public DocumentModelTreeEntry { public: @@ -259,6 +265,7 @@ public: } }; +/** Represents a list of frames */ class FramesEntry : public DocumentModelTreeEntry { public: @@ -282,6 +289,7 @@ public: } }; +/** Represents a list of writer graphic objects */ class WriterGraphicObjectsEntry : public DocumentModelTreeEntry { public: @@ -305,6 +313,7 @@ public: } }; +/** Represents a list of writer embedded (OLE) objects */ class EmbeddedObjectsEntry : public DocumentModelTreeEntry { public: @@ -328,6 +337,7 @@ public: } }; +/** Represents a style family, whcih contains a list of styles */ class StylesFamilyEntry : public DocumentModelTreeEntry { public: @@ -343,6 +353,7 @@ public: } }; +/** Represents a list of style families */ class StylesFamiliesEntry : public DocumentModelTreeEntry { public: @@ -379,6 +390,7 @@ public: } }; +/** Represents a list of pages */ class PagesEntry : public DocumentModelTreeEntry { public: @@ -416,6 +428,7 @@ public: } }; +/** Represents a list of (Impress) slides */ class SlidesEntry : public DocumentModelTreeEntry { public: @@ -453,6 +466,7 @@ public: } }; +/** Represents a list of (Impress) master slides */ class MasterSlidesEntry : public DocumentModelTreeEntry { public: @@ -490,6 +504,7 @@ public: } }; +/** Represents a list of charts */ class ChartsEntry : public DocumentModelTreeEntry { public: @@ -516,6 +531,7 @@ public: } }; +/** Represents a list of pivot tables */ class PivotTablesEntry : public DocumentModelTreeEntry { public: @@ -542,6 +558,7 @@ public: } }; +/** Represents a (Calc) sheet */ class SheetEntry : public DocumentModelTreeEntry { public: @@ -565,6 +582,7 @@ public: } }; +/** Represents a list of (Calc) sheet */ class SheetsEntry : public DocumentModelTreeEntry { public: @@ -685,37 +703,37 @@ void DocumentModelTreeHandler::inspectDocument() { uno::Reference<lang::XServiceInfo> xDocumentServiceInfo(mxDocument, uno::UNO_QUERY_THROW); - lclAppend(mpDocumentModelTree, "Document", new DocumentRootEntry(mxDocument), false); + lclAppend(mpDocumentModelTree, u"Document", new DocumentRootEntry(mxDocument), false); if (xDocumentServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument")) { - lclAppend(mpDocumentModelTree, "Sheets", new SheetsEntry(mxDocument), true); - lclAppend(mpDocumentModelTree, "Styles", new StylesFamiliesEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Sheets", new SheetsEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Styles", new StylesFamiliesEntry(mxDocument), true); } else if (xDocumentServiceInfo->supportsService( "com.sun.star.presentation.PresentationDocument")) { - lclAppend(mpDocumentModelTree, "Slides", new SlidesEntry(mxDocument), true); - lclAppend(mpDocumentModelTree, "Master Slides", new MasterSlidesEntry(mxDocument), true); - lclAppend(mpDocumentModelTree, "Styles", new StylesFamiliesEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Slides", new SlidesEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Master Slides", new MasterSlidesEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Styles", new StylesFamiliesEntry(mxDocument), true); } else if (xDocumentServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument")) { - lclAppend(mpDocumentModelTree, "Pages", new PagesEntry(mxDocument), true); - lclAppend(mpDocumentModelTree, "Styles", new StylesFamiliesEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Pages", new PagesEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Styles", new StylesFamiliesEntry(mxDocument), true); } else if (xDocumentServiceInfo->supportsService("com.sun.star.text.TextDocument") || xDocumentServiceInfo->supportsService("com.sun.star.text.WebDocument")) { - lclAppend(mpDocumentModelTree, "Paragraphs", new ParagraphsEntry(mxDocument), true); - lclAppend(mpDocumentModelTree, "Shapes", new ShapesEntry(mxDocument), true); - lclAppend(mpDocumentModelTree, "Tables", new TablesEntry(mxDocument), true); - lclAppend(mpDocumentModelTree, "Frames", new FramesEntry(mxDocument), true); - lclAppend(mpDocumentModelTree, "Graphic Objects", new WriterGraphicObjectsEntry(mxDocument), - true); - lclAppend(mpDocumentModelTree, "Embedded Objects", new EmbeddedObjectsEntry(mxDocument), + lclAppend(mpDocumentModelTree, u"Paragraphs", new ParagraphsEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Shapes", new ShapesEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Tables", new TablesEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Frames", new FramesEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Graphic Objects", + new WriterGraphicObjectsEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Embedded Objects", new EmbeddedObjectsEntry(mxDocument), true); - lclAppend(mpDocumentModelTree, "Styles", new StylesFamiliesEntry(mxDocument), true); + lclAppend(mpDocumentModelTree, u"Styles", new StylesFamiliesEntry(mxDocument), true); } } diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx index 553e7616308b..28186da1c3c2 100644 --- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx +++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx @@ -49,6 +49,7 @@ namespace constexpr OUStringLiteral constTypeDescriptionManagerSingletonName = u"/singletons/com.sun.star.reflection.theTypeDescriptionManager"; +/** converts any value to a string */ OUString AnyToString(const uno::Any& aValue, const uno::Reference<uno::XComponentContext>& xContext) { OUString aRetStr; @@ -181,12 +182,14 @@ OUString AnyToString(const uno::Any& aValue, const uno::Reference<uno::XComponen return aRetStr; } +/** converts an any's type to a string (in a short form) */ OUString getAnyType(const uno::Any& aValue) { OUString aTypeName = aValue.getValueType().getTypeName(); return aTypeName.replaceAll("com.sun.star", "css"); } +/** converts a Type to a XIdlClass */ uno::Reference<reflection::XIdlClass> convertTypeToIdlClass(const uno::Type& rType, const uno::Reference<uno::XComponentContext>& xContext) @@ -197,6 +200,15 @@ convertTypeToIdlClass(const uno::Type& rType, // Object inspector nodes +/** Object inspector node's main interface + * + * The interface for the "attached" object to a tree view nodes that + * are added to the tree views of the object inspector part. The node + * can return the main value of the node (object name) and if present + * also the values for additional columns. It signals if a tree needs + * an expander and fills the children of the tree is any exists. + * + */ class ObjectInspectorNodeInterface { public: @@ -204,19 +216,24 @@ public: virtual ~ObjectInspectorNodeInterface() {} + // main value (object name) of the tree view node virtual OUString getObjectName() = 0; + // should show the expander for the tree view node virtual bool shouldShowExpander() { return false; } + // fill the children for the current tree view node virtual void fillChildren(std::unique_ptr<weld::TreeView>& rTree, const weld::TreeIter* pParent) = 0; + // fill any additional column values for the current tree view node virtual std::vector<std::pair<sal_Int32, OUString>> getColumnValues() { return std::vector<std::pair<sal_Int32, OUString>>(); } }; +// appends the node to the root of the tree view OUString lclAppendNode(std::unique_ptr<weld::TreeView>& pTree, ObjectInspectorNodeInterface* pEntry) { OUString sName = pEntry->getObjectName(); @@ -234,6 +251,7 @@ OUString lclAppendNode(std::unique_ptr<weld::TreeView>& pTree, ObjectInspectorNo return sId; } +// appends the node to the parent OUString lclAppendNodeToParent(std::unique_ptr<weld::TreeView>& pTree, const weld::TreeIter* pParent, ObjectInspectorNodeInterface* pEntry) { @@ -252,6 +270,7 @@ OUString lclAppendNodeToParent(std::unique_ptr<weld::TreeView>& pTree, return sId; } +/** Node that represent just a simple string with no children or columns */ class SimpleStringNode : public ObjectInspectorNodeInterface { protected: @@ -271,6 +290,7 @@ public: OUString getObjectName() override { return msName; } }; +/** Node represents a method of an object */ class MethodNode : public ObjectInspectorNodeInterface { private: @@ -351,6 +371,12 @@ public: } }; +/** Node represents a class (XIdlClass) of an object. + * + * Children are superclasses of the current class. XInterface superclass + * is ignored. + * + */ class ClassNode : public ObjectInspectorNodeInterface { private: @@ -376,6 +402,7 @@ public: OUString getObjectName() override { return mxClass->getName(); } + // Fill superclasses void fillChildren(std::unique_ptr<weld::TreeView>& rTree, const weld::TreeIter* pParent) override { @@ -388,6 +415,7 @@ public: } }; +/** Node represents a basic value, that can be any object, sequece, struct */ class BasicValueNode : public SimpleStringNode { protected: @@ -439,6 +467,7 @@ public: } }; +/** Node represents a property */ class GenericPropertiesNode : public BasicValueNode { public: @@ -452,6 +481,7 @@ public: const weld::TreeIter* pParent) override; }; +/** Node represents a struct */ class StructNode : public BasicValueNode { public: @@ -467,6 +497,7 @@ public: const weld::TreeIter* pParent) override; }; +/** Node represents a sequence */ class SequenceNode : public BasicValueNode { uno::Reference<reflection::XIdlArray> mxIdlArray; @@ -710,8 +741,11 @@ BasicValueNode::createNodeObjectForAny(OUString const& rName, uno::Any& rAny, OU return new BasicValueNode(rName, rAny, rInfo, mxContext); } -// helper functions +} // end anonymous namespace +// Object inspector tree view helper functions +namespace +{ ObjectInspectorNodeInterface* getSelectedNode(weld::TreeView const& rTreeView) { OUString sID = rTreeView.get_selected_id(); @@ -990,6 +1024,7 @@ void ObjectInspectorTreeHandler::clearObjectInspectorChildren( } while (bChild); } +/** Deletes all the node objects in a tree view */ void ObjectInspectorTreeHandler::clearAll(std::unique_ptr<weld::TreeView>& pTreeView) { // destroy all ObjectInspectorNodes from the tree @@ -1002,6 +1037,7 @@ void ObjectInspectorTreeHandler::clearAll(std::unique_ptr<weld::TreeView>& pTree pTreeView->clear(); } +/** Append interfaces to the "interfaces" tree view */ void ObjectInspectorTreeHandler::appendInterfaces(uno::Reference<uno::XInterface> const& xInterface) { if (!xInterface.is()) @@ -1019,6 +1055,7 @@ void ObjectInspectorTreeHandler::appendInterfaces(uno::Reference<uno::XInterface } } +/** Append services to the "services" tree view */ void ObjectInspectorTreeHandler::appendServices(uno::Reference<uno::XInterface> const& xInterface) { if (!xInterface.is()) @@ -1032,6 +1069,7 @@ void ObjectInspectorTreeHandler::appendServices(uno::Reference<uno::XInterface> } } +/** Append properties to the "properties" tree view */ void ObjectInspectorTreeHandler::appendProperties(uno::Reference<uno::XInterface> const& xInterface) { if (!xInterface.is()) @@ -1040,6 +1078,7 @@ void ObjectInspectorTreeHandler::appendProperties(uno::Reference<uno::XInterface aNode.fillChildren(mpPropertiesTreeView, nullptr); } +/** Append methods to the "methods" tree view */ void ObjectInspectorTreeHandler::appendMethods(uno::Reference<uno::XInterface> const& xInterface) { if (!xInterface.is()) @@ -1060,18 +1099,21 @@ void ObjectInspectorTreeHandler::updateBackButtonState() mpObjectInspectorToolbar->set_item_sensitive("back", maInspectionStack.size() > 1); } +// Clears all the objects from the stack void ObjectInspectorTreeHandler::clearStack() { maInspectionStack.clear(); updateBackButtonState(); } +// Adds an object to the stack void ObjectInspectorTreeHandler::addToStack(css::uno::Any const& rAny) { maInspectionStack.push_back(rAny); updateBackButtonState(); } +// Removes an object from the back of the stack and return it css::uno::Any ObjectInspectorTreeHandler::popFromStack() { maInspectionStack.pop_back(); @@ -1080,6 +1122,7 @@ css::uno::Any ObjectInspectorTreeHandler::popFromStack() return aAny; } +// Inspect the input object in the object inspector void ObjectInspectorTreeHandler::inspectObject(uno::Reference<uno::XInterface> const& xInterface) { if (!xInterface.is()) @@ -1090,10 +1133,14 @@ void ObjectInspectorTreeHandler::inspectObject(uno::Reference<uno::XInterface> c OUString aImplementationName = xServiceInfo->getImplementationName(); mpClassNameLabel->set_label(aImplementationName); + // Fire entering the current opened page manually auto rPageId = mpObjectInspectorNotebook->get_current_page_ident(); NotebookEnterPage(rPageId); } +// Inspect the input object in the object inspector. +// Make the input object the root of the stack (clear all other +// objects from the stack). void ObjectInspectorTreeHandler::introspect(uno::Reference<uno::XInterface> const& xInterface) { clearStack(); @@ -1103,6 +1150,7 @@ void ObjectInspectorTreeHandler::introspect(uno::Reference<uno::XInterface> cons void ObjectInspectorTreeHandler::dispose() { + // We need to clear all the nodes clearAll(mpInterfacesTreeView); clearAll(mpServicesTreeView); clearAll(mpPropertiesTreeView); diff --git a/sfx2/source/devtools/SelectionChangeHandler.hxx b/sfx2/source/devtools/SelectionChangeHandler.hxx index bfb7035e4d8a..523165f2f599 100644 --- a/sfx2/source/devtools/SelectionChangeHandler.hxx +++ b/sfx2/source/devtools/SelectionChangeHandler.hxx @@ -23,6 +23,11 @@ typedef cppu::WeakComponentImplHelper<css::view::XSelectionChangeListener> SelectionChangeHandlerInterfaceBase; +/** Selection change handler to listen to document selection changes. + * + * Listens to the changes and notifies the docking window with a new + * selected object, when a change happens. + */ class SelectionChangeHandler final : private ::cppu::BaseMutex, public SelectionChangeHandlerInterfaceBase { |