sfx2/source/devtools/DevToolsStrings.hrc          |   37 +++++++++++
 sfx2/source/devtools/DocumentModelTreeHandler.cxx |   74 ++++++++++++++--------
 2 files changed, 85 insertions(+), 26 deletions(-)

New commits:
commit 5b84eae0c10aa33bb8ef3a9a0d1336bcc9e9163c
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Mar 15 12:02:15 2021 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Tue Mar 16 03:40:53 2021 +0100

    devtools: add strings for translation in DocumentModelTreeHandler
    
    Change-Id: If2a09e969a5b27a67f977ec931d6eeef1712ce5a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112546
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sfx2/source/devtools/DevToolsStrings.hrc 
b/sfx2/source/devtools/DevToolsStrings.hrc
new file mode 100644
index 000000000000..b64433efe0bb
--- /dev/null
+++ b/sfx2/source/devtools/DevToolsStrings.hrc
@@ -0,0 +1,37 @@
+/* -*- 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
+#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" 
u8##String)
+
+#define STR_TEXT_PORTION NC_("STR_TEXT_PORTION", "Text Portion %1")
+#define STR_PARAGRAPH NC_("STR_PARAGRAPH", "Paragraph %1")
+#define STR_SHAPE NC_("STR_SHAPE", "Shape %1")
+#define STR_PAGE NC_("STR_PAGE", "Page %1")
+#define STR_SLIDE NC_("STR_SLIDE", "Slide %1")
+#define STR_MASTER_SLIDE NC_("STR_MASTER_SLIDE", "Master Slide %1")
+#define STR_SHEETS NC_("STR_SHEETS", "Sheets %1")
+
+#define STR_SHAPES_ENTRY NC_("STR_SHAPES_NODE", "Shapes")
+#define STR_CHARTS_ENTRY NC_("STR_CHARTS_ENTRY", "Charts")
+#define STR_PIVOT_TABLES_ENTRY NC_("STR_PIVOT_TABLES_ENTRY", "Pivot Tables")
+#define STR_DOCUMENT_ENTRY NC_("STR_DOCUMENT_ENTRY", "Document")
+#define STR_SHEETS_ENTRY NC_("STR_SHEETS_ENTRY", "Sheets")
+#define STR_STYLES_ENTRY NC_("STR_STYLES_ENTRY", "Styles")
+#define STR_SLIDES_ENTRY NC_("STR_SLIDES_ENTRY", "Slides")
+#define STR_MASTER_SLIDES_ENTRY NC_("STR_MASTER_SLIDES_ENTRY", "Master Slides")
+#define STR_PAGES_ENTRY NC_("STR_PAGES_ENTRY", "Pages")
+#define STR_PARAGRAPHS_ENTRY NC_("STR_PARAGRAPHS_ENTRY", "Paragraphs")
+#define STR_TABLES_ENTRY NC_("STR_TABLES_ENTRY", "Tables")
+#define STR_FRAMES_ENTRY NC_("STR_FRAMES_ENTRY", "Frames")
+#define STR_GRAPHIC_OBJECTS_ENTRY NC_("STR_GRAPHIC_OBJECTS_ENTRY", "Graphic 
Objects")
+#define STR_EMBEDDED_OBJECTS_ENTRY NC_("STR_EMBEDDED_OBJECTS_ENTRY", "Embedded 
Objects")
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/devtools/DocumentModelTreeHandler.cxx 
b/sfx2/source/devtools/DocumentModelTreeHandler.cxx
index 8494f93fa289..6216feb34ec1 100644
--- a/sfx2/source/devtools/DocumentModelTreeHandler.cxx
+++ b/sfx2/source/devtools/DocumentModelTreeHandler.cxx
@@ -12,6 +12,9 @@
 
 #include <sfx2/devtools/DocumentModelTreeHandler.hxx>
 
+#include <sfx2/sfxresid.hxx>
+#include "DevToolsStrings.hrc"
+
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/container/XNamed.hpp>
 #include <com/sun/star/container/XEnumerationAccess.hpp>
@@ -150,7 +153,8 @@ public:
                                                                     
uno::UNO_QUERY);
                 OUString aString = lclGetNamed(xTextPortion);
                 if (aString.isEmpty())
-                    aString = "Text Portion " + OUString::number(i + 1);
+                    aString
+                        = SfxResId(STR_TEXT_PORTION).replaceFirst("%1", 
OUString::number(i + 1));
 
                 auto pEntry = 
std::make_unique<DocumentModelTreeEntry>(xTextPortion);
                 lclAppendToParentEntry(pDocumentModelTree, rParent, aString, 
pEntry.release());
@@ -194,7 +198,9 @@ public:
                                                                     
uno::UNO_QUERY);
                 OUString aString = lclGetNamed(xParagraph);
                 if (aString.isEmpty())
-                    aString = "Paragraph " + OUString::number(i + 1);
+                {
+                    aString = SfxResId(STR_PARAGRAPH).replaceFirst("%1", 
OUString::number(i + 1));
+                }
 
                 auto pEntry = std::make_unique<ParagraphEntry>(xParagraph);
                 lclAppendToParentEntry(pDocumentModelTree, rParent, aString, 
pEntry.release(),
@@ -233,7 +239,8 @@ public:
                                                    uno::UNO_QUERY);
             OUString aShapeName = lclGetNamed(xShape);
             if (aShapeName.isEmpty())
-                aShapeName = "Shape " + OUString::number(nIndexShapes + 1);
+                aShapeName
+                    = SfxResId(STR_SHAPE).replaceFirst("%1", 
OUString::number(nIndexShapes + 1));
 
             auto pEntry = std::make_unique<DocumentModelTreeEntry>(xShape);
             lclAppendToParentEntry(pDocumentModelTree, rParent, aShapeName, 
pEntry.release());
@@ -419,7 +426,7 @@ public:
 
             OUString aPageString = lclGetNamed(xPage);
             if (aPageString.isEmpty())
-                aPageString = "Page " + OUString::number(i + 1);
+                aPageString = SfxResId(STR_PAGE).replaceFirst("%1", 
OUString::number(i + 1));
 
             auto pShapesEntry = std::make_unique<ShapesEntry>(xPage);
             lclAppendToParentEntry(pDocumentModelTree, rParent, aPageString, 
pShapesEntry.release(),
@@ -457,7 +464,7 @@ public:
 
             OUString aPageString = lclGetNamed(xPage);
             if (aPageString.isEmpty())
-                aPageString = "Slide " + OUString::number(i + 1);
+                aPageString = SfxResId(STR_SLIDE).replaceFirst("%1", 
OUString::number(i + 1));
 
             auto pShapesEntry = std::make_unique<ShapesEntry>(xPage);
             lclAppendToParentEntry(pDocumentModelTree, rParent, aPageString, 
pShapesEntry.release(),
@@ -495,7 +502,8 @@ public:
 
             OUString aPageString = lclGetNamed(xPage);
             if (aPageString.isEmpty())
-                aPageString = "Master Slide " + OUString::number(i + 1);
+                aPageString
+                    = SfxResId(STR_MASTER_SLIDE).replaceFirst("%1", 
OUString::number(i + 1));
 
             auto pShapesEntry = std::make_unique<ShapesEntry>(xPage);
             lclAppendToParentEntry(pDocumentModelTree, rParent, aPageString, 
pShapesEntry.release(),
@@ -571,13 +579,15 @@ public:
               weld::TreeIter const& rParent) override
     {
         auto pShapesEntry = std::make_unique<ShapesEntry>(getMainObject());
-        lclAppendToParentEntry(pDocumentModelTree, rParent, "Shapes", 
pShapesEntry.release(), true);
+        lclAppendToParentEntry(pDocumentModelTree, rParent, 
SfxResId(STR_SHAPES_ENTRY),
+                               pShapesEntry.release(), true);
 
         auto pChartsEntry = std::make_unique<ChartsEntry>(getMainObject());
-        lclAppendToParentEntry(pDocumentModelTree, rParent, "Charts", 
pChartsEntry.release(), true);
+        lclAppendToParentEntry(pDocumentModelTree, rParent, 
SfxResId(STR_CHARTS_ENTRY),
+                               pChartsEntry.release(), true);
 
         auto pPivotTablesEntry = 
std::make_unique<PivotTablesEntry>(getMainObject());
-        lclAppendToParentEntry(pDocumentModelTree, rParent, "Pivot Tables",
+        lclAppendToParentEntry(pDocumentModelTree, rParent, 
SfxResId(STR_PIVOT_TABLES_ENTRY),
                                pPivotTablesEntry.release(), true);
     }
 };
@@ -610,7 +620,7 @@ public:
             uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(i), 
uno::UNO_QUERY);
             OUString aString = lclGetNamed(xSheet);
             if (aString.isEmpty())
-                aString = "Sheet " + OUString::number(i + 1);
+                aString = SfxResId(STR_SHEETS).replaceFirst("%1", 
OUString::number(i + 1));
             auto pEntry = std::make_unique<SheetEntry>(xSheet);
             lclAppendToParentEntry(pDocumentModelTree, rParent, aString, 
pEntry.release(), true);
         }
@@ -703,37 +713,49 @@ void DocumentModelTreeHandler::inspectDocument()
 {
     uno::Reference<lang::XServiceInfo> xDocumentServiceInfo(mxDocument, 
uno::UNO_QUERY_THROW);
 
-    lclAppend(mpDocumentModelTree, u"Document", new 
DocumentRootEntry(mxDocument), false);
+    lclAppend(mpDocumentModelTree, SfxResId(STR_DOCUMENT_ENTRY), new 
DocumentRootEntry(mxDocument),
+              false);
 
     if 
(xDocumentServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument"))
     {
-        lclAppend(mpDocumentModelTree, u"Sheets", new SheetsEntry(mxDocument), 
true);
-        lclAppend(mpDocumentModelTree, u"Styles", new 
StylesFamiliesEntry(mxDocument), true);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_SHEETS_ENTRY), new 
SheetsEntry(mxDocument),
+                  true);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_STYLES_ENTRY),
+                  new StylesFamiliesEntry(mxDocument), true);
     }
     else if (xDocumentServiceInfo->supportsService(
                  "com.sun.star.presentation.PresentationDocument"))
     {
-        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);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_SLIDES_ENTRY), new 
SlidesEntry(mxDocument),
+                  true);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_MASTER_SLIDES_ENTRY),
+                  new MasterSlidesEntry(mxDocument), true);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_STYLES_ENTRY),
+                  new StylesFamiliesEntry(mxDocument), true);
     }
     else if 
(xDocumentServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument"))
     {
-        lclAppend(mpDocumentModelTree, u"Pages", new PagesEntry(mxDocument), 
true);
-        lclAppend(mpDocumentModelTree, u"Styles", new 
StylesFamiliesEntry(mxDocument), true);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_PAGES_ENTRY), new 
PagesEntry(mxDocument), true);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_STYLES_ENTRY),
+                  new StylesFamiliesEntry(mxDocument), true);
     }
     else if 
(xDocumentServiceInfo->supportsService("com.sun.star.text.TextDocument")
              || 
xDocumentServiceInfo->supportsService("com.sun.star.text.WebDocument"))
     {
-        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),
+        lclAppend(mpDocumentModelTree, SfxResId(STR_PARAGRAPHS_ENTRY),
+                  new ParagraphsEntry(mxDocument), true);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_SHAPES_ENTRY), new 
ShapesEntry(mxDocument),
                   true);
-        lclAppend(mpDocumentModelTree, u"Styles", new 
StylesFamiliesEntry(mxDocument), true);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_TABLES_ENTRY), new 
TablesEntry(mxDocument),
+                  true);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_FRAMES_ENTRY), new 
FramesEntry(mxDocument),
+                  true);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_GRAPHIC_OBJECTS_ENTRY),
+                  new WriterGraphicObjectsEntry(mxDocument), true);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_EMBEDDED_OBJECTS_ENTRY),
+                  new EmbeddedObjectsEntry(mxDocument), true);
+        lclAppend(mpDocumentModelTree, SfxResId(STR_STYLES_ENTRY),
+                  new StylesFamiliesEntry(mxDocument), true);
     }
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to