[Libreoffice-commits] core.git: include/svx svx/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Sat Jan 16 08:10:12 UTC 2021


 include/svx/devtools/DevelopmentToolDockingWindow.hxx |    5 
 svx/source/devtools/DevelopmentToolDockingWindow.cxx  |  190 ++++++++++++++----
 2 files changed, 156 insertions(+), 39 deletions(-)

New commits:
commit a93d26fb1eaa185f5eec774f85a76deedd0205e6
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Jan 11 09:57:57 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat Jan 16 09:09:35 2021 +0100

    devtools: fill left-side document model view for all document types
    
    Change-Id: I19f1cfdbdde86b3fbeb2a0a7e3e4255ef0055cf5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109073
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/svx/devtools/DevelopmentToolDockingWindow.hxx b/include/svx/devtools/DevelopmentToolDockingWindow.hxx
index 2856bc3698df..19d286093cd3 100644
--- a/include/svx/devtools/DevelopmentToolDockingWindow.hxx
+++ b/include/svx/devtools/DevelopmentToolDockingWindow.hxx
@@ -46,6 +46,11 @@ public:
 
     void inspectDocument();
 
+    void inspectSpreadsheet();
+    void inspectPresentation();
+    void inspectDrawing();
+    void inspectText();
+
     void introspect(css::uno::Reference<css::uno::XInterface> const& xInterface);
 };
 
diff --git a/svx/source/devtools/DevelopmentToolDockingWindow.cxx b/svx/source/devtools/DevelopmentToolDockingWindow.cxx
index 0b3dbd06a9e5..69bf4682da77 100644
--- a/svx/source/devtools/DevelopmentToolDockingWindow.cxx
+++ b/svx/source/devtools/DevelopmentToolDockingWindow.cxx
@@ -43,7 +43,14 @@
 
 #include <com/sun/star/view/XSelectionSupplier.hpp>
 
-#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/drawing/XDrawPages.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
 
 using namespace css;
 
@@ -127,63 +134,168 @@ IMPL_LINK_NOARG(DevelopmentToolDockingWindow, LeftSideSelected, weld::TreeView&,
         introspect(rObject);
 }
 
-void DevelopmentToolDockingWindow::inspectDocument()
+void DevelopmentToolDockingWindow::inspectSpreadsheet()
 {
-    uno::Reference<lang::XServiceInfo> xDocument(mxRoot, uno::UNO_QUERY_THROW);
+    msDocumentType = "Spreadsheet Document";
 
-    if (xDocument->supportsService("com.sun.star.sheet.SpreadsheetDocument"))
+    std::unique_ptr<weld::TreeIter> pParent = mpLeftSideTreeView->make_iterator();
+    mpLeftSideTreeView->insert(nullptr, -1, &msDocumentType, nullptr, nullptr, nullptr, false,
+                               pParent.get());
+    maUnoObjectMap.emplace(msDocumentType, mxRoot);
+
+    uno::Reference<sheet::XSpreadsheetDocument> xSheetDoc(mxRoot, uno::UNO_QUERY);
+    uno::Reference<sheet::XSpreadsheets> xSheets = xSheetDoc->getSheets();
+    uno::Reference<container::XIndexAccess> xIndex(xSheets, uno::UNO_QUERY);
+    for (sal_Int32 i = 0; i < xIndex->getCount(); ++i)
     {
-        msDocumentType = "Spreadsheet Document";
+        uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(i), uno::UNO_QUERY);
+
+        std::unique_ptr<weld::TreeIter> pCurrentSheet = mpLeftSideTreeView->make_iterator();
+        OUString aSlideString = "Sheet " + OUString::number(i + 1);
+        maUnoObjectMap.emplace(aSlideString, xSheet);
+        mpLeftSideTreeView->insert(pParent.get(), -1, &aSlideString, nullptr, nullptr, nullptr,
+                                   false, pCurrentSheet.get());
     }
-    else if (xDocument->supportsService("com.sun.star.presentation.PresentationDocument"))
+}
+
+void DevelopmentToolDockingWindow::inspectPresentation()
+{
+    msDocumentType = "Presentation Document";
+
+    std::unique_ptr<weld::TreeIter> pParent = mpLeftSideTreeView->make_iterator();
+    mpLeftSideTreeView->insert(nullptr, -1, &msDocumentType, nullptr, nullptr, nullptr, false,
+                               pParent.get());
+    maUnoObjectMap.emplace(msDocumentType, mxRoot);
+
+    uno::Reference<drawing::XShape> xRet;
+
+    uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxRoot, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
+    for (sal_Int32 i = 0; i < xDrawPages->getCount(); ++i)
     {
-        msDocumentType = "Presentation Document";
+        uno::Reference<drawing::XDrawPage> xPage(xDrawPages->getByIndex(i), uno::UNO_QUERY);
+
+        std::unique_ptr<weld::TreeIter> pCurrentPage = mpLeftSideTreeView->make_iterator();
+        OUString aPageString = "Slide " + OUString::number(i + 1);
+        maUnoObjectMap.emplace(aPageString, xPage);
+        mpLeftSideTreeView->insert(pParent.get(), -1, &aPageString, nullptr, nullptr, nullptr,
+                                   false, pCurrentPage.get());
+
+        for (sal_Int32 j = 0; j < xPage->getCount(); ++j)
+        {
+            uno::Reference<container::XNamed> xShape(xPage->getByIndex(j), uno::UNO_QUERY);
+
+            OUString aShapeName = xShape->getName();
+            if (aShapeName.isEmpty())
+                aShapeName = "Shape " + OUString::number(j);
+
+            std::unique_ptr<weld::TreeIter> pCurrentShape = mpLeftSideTreeView->make_iterator();
+            mpLeftSideTreeView->insert(pCurrentPage.get(), -1, &aShapeName, nullptr, nullptr,
+                                       nullptr, false, pCurrentShape.get());
+            maUnoObjectMap.emplace(aShapeName, xShape);
+        }
     }
-    else if (xDocument->supportsService("com.sun.star.drawing.DrawingDocument"))
+}
+
+void DevelopmentToolDockingWindow::inspectDrawing()
+{
+    msDocumentType = "Drawing Document";
+
+    std::unique_ptr<weld::TreeIter> pParent = mpLeftSideTreeView->make_iterator();
+    mpLeftSideTreeView->insert(nullptr, -1, &msDocumentType, nullptr, nullptr, nullptr, false,
+                               pParent.get());
+    maUnoObjectMap.emplace(msDocumentType, mxRoot);
+
+    uno::Reference<drawing::XShape> xRet;
+
+    uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxRoot, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
+    for (sal_Int32 i = 0; i < xDrawPages->getCount(); ++i)
     {
-        msDocumentType = "Drawing Document";
+        uno::Reference<drawing::XDrawPage> xPage(xDrawPages->getByIndex(i), uno::UNO_QUERY);
+
+        std::unique_ptr<weld::TreeIter> pCurrentPage = mpLeftSideTreeView->make_iterator();
+        OUString aPageString = "Page " + OUString::number(i + 1);
+        maUnoObjectMap.emplace(aPageString, xPage);
+        mpLeftSideTreeView->insert(pParent.get(), -1, &aPageString, nullptr, nullptr, nullptr,
+                                   false, pCurrentPage.get());
+
+        for (sal_Int32 j = 0; j < xPage->getCount(); ++j)
+        {
+            uno::Reference<container::XNamed> xShape(xPage->getByIndex(j), uno::UNO_QUERY);
+
+            OUString aShapeName = xShape->getName();
+
+            std::unique_ptr<weld::TreeIter> pCurrentShape = mpLeftSideTreeView->make_iterator();
+            mpLeftSideTreeView->insert(pCurrentPage.get(), -1, &aShapeName, nullptr, nullptr,
+                                       nullptr, false, pCurrentShape.get());
+            maUnoObjectMap.emplace(aShapeName, xShape);
+        }
     }
-    else if (xDocument->supportsService("com.sun.star.text.TextDocument")
-             || xDocument->supportsService("com.sun.star.text.WebDocument"))
-    {
-        msDocumentType = "Text Document";
+}
+
+void DevelopmentToolDockingWindow::inspectText()
+{
+    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);
+    std::unique_ptr<weld::TreeIter> pParent = mpLeftSideTreeView->make_iterator();
+    mpLeftSideTreeView->insert(nullptr, -1, &msDocumentType, nullptr, nullptr, nullptr, false,
+                               pParent.get());
+    maUnoObjectMap.emplace(msDocumentType, mxRoot);
 
-        uno::Reference<text::XTextDocument> xTextDocument(xDocument, uno::UNO_QUERY);
-        if (xTextDocument.is())
+    uno::Reference<text::XTextDocument> xTextDocument(mxRoot, uno::UNO_QUERY);
+    if (xTextDocument.is())
+    {
+        uno::Reference<container::XEnumerationAccess> xParagraphEnumAccess(
+            xTextDocument->getText()->getText(), uno::UNO_QUERY);
+        if (xParagraphEnumAccess.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())
             {
-                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())
                 {
-                    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++;
-                    }
+                    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++;
                 }
             }
         }
     }
 }
 
+void DevelopmentToolDockingWindow::inspectDocument()
+{
+    uno::Reference<lang::XServiceInfo> xDocument(mxRoot, uno::UNO_QUERY_THROW);
+
+    if (xDocument->supportsService("com.sun.star.sheet.SpreadsheetDocument"))
+    {
+        inspectSpreadsheet();
+    }
+    else if (xDocument->supportsService("com.sun.star.presentation.PresentationDocument"))
+    {
+        inspectPresentation();
+    }
+    else if (xDocument->supportsService("com.sun.star.drawing.DrawingDocument"))
+    {
+        inspectDrawing();
+    }
+    else if (xDocument->supportsService("com.sun.star.text.TextDocument")
+             || xDocument->supportsService("com.sun.star.text.WebDocument"))
+    {
+        inspectText();
+    }
+}
+
 DevelopmentToolDockingWindow::~DevelopmentToolDockingWindow() { disposeOnce(); }
 
 void DevelopmentToolDockingWindow::dispose()


More information about the Libreoffice-commits mailing list