include/svx/fontworkgallery.hxx         |    5 ++++-
 sd/inc/strings.hrc                      |    1 +
 sd/source/ui/dlg/sdtreelb.cxx           |   27 +++++++++++++++++++++++++--
 svx/source/tbxctrls/fontworkgallery.cxx |   24 ++++++++++++++++++++++--
 svx/source/toolbars/fontworkbar.cxx     |    2 +-
 sw/qa/extras/accessibility/dialogs.cxx  |    2 +-
 sw/source/uibase/uiview/viewdraw.cxx    |    2 +-
 7 files changed, 55 insertions(+), 8 deletions(-)

New commits:
commit 1fd359790ed4a27902248d92ee343a4aeaf63c8e
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Fri Jun 2 08:08:18 2023 -0800
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Sun Mar 10 02:43:41 2024 +0100

    tdf#90242 Navigator: Improve custom shape naming
    
    This patch makes the Draw/Impress Navigator display the name retrieved
    by SdrCustomShapeGeometryItem::GetPropertyValueByName("Type") for
    custom shape objects when the custom shape is unnamed and the Navigator
    is set to show all objects. For Writer and Calc, this patch makes
    inserted fontwork custom shape objects be automatically named 'Fontwork
    N'.
    
    Change-Id: Ice34461fe7a4b26d01b2d93e871a956dc55392f4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152568
    Tested-by: Jenkins
    Reviewed-by: Stéphane Guillou <stephane.guil...@libreoffice.org>
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/include/svx/fontworkgallery.hxx b/include/svx/fontworkgallery.hxx
index 8e5eceb8f033..21c418584570 100644
--- a/include/svx/fontworkgallery.hxx
+++ b/include/svx/fontworkgallery.hxx
@@ -60,6 +60,8 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC FontWorkGalleryDialog 
final : public wel
     std::unique_ptr<weld::IconView> maCtlFavorites;
     std::unique_ptr<weld::Button> mxOKButton;
 
+    css::uno::Reference<css::frame::XFrame> mxFrame;
+
     void            initFavorites(sal_uInt16 nThemeId);
     void            insertSelectedFontwork();
     void            fillFavorites(sal_uInt16 nThemeId);
@@ -69,7 +71,8 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC FontWorkGalleryDialog 
final : public wel
     DECL_DLLPRIVATE_LINK(QueryTooltipHandler, const weld::TreeIter&, OUString);
 
 public:
-    FontWorkGalleryDialog(weld::Window* pParent, SdrView& rView);
+    FontWorkGalleryDialog(weld::Window* pParent, SdrView& rView,
+                          css::uno::Reference<css::frame::XFrame> xFrame);
     virtual ~FontWorkGalleryDialog() override;
 
     // SJ: if the SdrObject** is set, the SdrObject is not inserted into the 
page when executing the dialog
diff --git a/sd/inc/strings.hrc b/sd/inc/strings.hrc
index 5056a8030966..2522768a6a7b 100644
--- a/sd/inc/strings.hrc
+++ b/sd/inc/strings.hrc
@@ -245,6 +245,7 @@
 #define STR_GRAPHICS_STYLE_FAMILY                       
NC_("STR_GRAPHICS_STYLE_FAMILY", "Drawing Styles")
 #define STR_PRESENTATIONS_STYLE_FAMILY                  
NC_("STR_PRESENTATIONS_STYLE_FAMILY", "Presentation Styles")
 #define STR_CELL_STYLE_FAMILY                           
NC_("STR_CELL_STYLE_FAMILY", "Cell Styles")
+#define STR_NAVIGATOR_CUSTOMSHAPE                       
NC_("STR_NAVIGATOR_CUSTOMSHAPE", "Custom Shape")
 #define STR_NAVIGATOR_SHAPE_BASE_NAME                   
NC_("STR_NAVIGATOR_SHAPE_BASE_NAME", "Shape %1")
 #define STR_SET_BACKGROUND_PICTURE                      
NC_("STR_SET_BACKGROUND_PICTURE", "Set Background Image" )
 #define STR_RESET_LAYOUT                                
NC_("STR_RESET_LAYOUT", "Reset Slide Layout")
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index 63c26bc5635c..5bed03fa24db 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -58,6 +58,11 @@
 #include <svx/svdview.hxx>
 #include <DrawViewShell.hxx>
 
+#include <svx/svdoashp.hxx>
+#include <svx/sdasitm.hxx>
+#include <svl/poolitem.hxx>
+#include <svl/stritem.hxx>
+
 using namespace com::sun::star;
 
 namespace {
@@ -918,7 +923,25 @@ OUString SdPageObjsTLV::GetObjectName(
         && aRet.isEmpty()
         && pObject!=nullptr)
     {
-        aRet = SdResId(STR_NAVIGATOR_SHAPE_BASE_NAME) + " (" + 
pObject->TakeObjNameSingul() +")";
+        OUString sObjName;
+        if (pObject->GetObjIdentifier() == SdrObjKind::CustomShape)
+        {
+            // taken from SdrObjCustomShape::GetCustomShapeName
+            OUString 
aEngine(pObject->GetMergedItem(SDRATTR_CUSTOMSHAPE_ENGINE).GetValue());
+            if (aEngine.isEmpty() || aEngine == 
"com.sun.star.drawing.EnhancedCustomShapeEngine")
+            {
+                OUString sShapeType;
+                const SdrCustomShapeGeometryItem& rGeometryItem
+                    = pObject->GetMergedItem(SDRATTR_CUSTOMSHAPE_GEOMETRY);
+                const uno::Any* pAny = 
rGeometryItem.GetPropertyValueByName("Type");
+                if (pAny && (*pAny >>= sShapeType))
+                    sObjName = SdResId(STR_NAVIGATOR_CUSTOMSHAPE) + u": " + 
sShapeType;
+            }
+        }
+        else
+            sObjName = pObject->TakeObjNameSingul();
+
+        aRet = SdResId(STR_NAVIGATOR_SHAPE_BASE_NAME) + " (" + sObjName +")";
         aRet = aRet.replaceFirst("%1", OUString::number(pObject->GetOrdNum() + 
1));
     }
 
@@ -1223,7 +1246,7 @@ void SdPageObjsTLV::AddShapeList (
             }
             else
             {
-                InsertEntry(xEntry.get(), sId, aStr, BMP_OBJECTS);
+                InsertEntry(xEntry.get(), sId, aStr, BMP_OBJECTS); // 
BMP_OBJECTS
             }
         }
     }
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx 
b/svx/source/tbxctrls/fontworkgallery.cxx
index 5a7a24f32d6a..9b3ea03868d9 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -22,6 +22,9 @@
 
 #include <comphelper/lok.hxx>
 #include <comphelper/propertyvalue.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/frame/ModuleManager.hpp>
 
 #include <vcl/toolbox.hxx>
 #include <vcl/virdev.hxx>
@@ -46,6 +49,9 @@
 #include <algorithm>
 #include <memory>
 
+#include <svx/strings.hrc>
+#include <svx/dialmgr.hxx>
+
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::beans;
@@ -53,7 +59,8 @@ using namespace ::com::sun::star::beans;
 namespace svx
 {
 
-FontWorkGalleryDialog::FontWorkGalleryDialog(weld::Window* pParent, SdrView& 
rSdrView)
+FontWorkGalleryDialog::FontWorkGalleryDialog(weld::Window* pParent, SdrView& 
rSdrView,
+                                             Reference<css::frame::XFrame> 
xFrame)
     : GenericDialogController(pParent, "svx/ui/fontworkgallerydialog.ui", 
"FontworkGalleryDialog")
     , mnThemeId(0xffff)
     , mrSdrView(rSdrView)
@@ -61,6 +68,7 @@ FontWorkGalleryDialog::FontWorkGalleryDialog(weld::Window* 
pParent, SdrView& rSd
     , mpDestModel(nullptr)
     , maCtlFavorites(m_xBuilder->weld_icon_view("ctlFavoriteswin"))
     , mxOKButton(m_xBuilder->weld_button("ok"))
+    , mxFrame(std::move(xFrame))
 {
     Size aSize(530, 400);
     maCtlFavorites->set_size_request(aSize.Width(), aSize.Height());
@@ -188,7 +196,19 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
         pPage->GetObj(0)->CloneSdrObject(
             bUseSpecialCalcMode ? *mpDestModel : 
mrSdrView.getSdrModelFromSdrView()));
 
-    pNewObject->MakeNameUnique();
+    Reference<XComponentContext> xContext = 
comphelper::getProcessComponentContext();
+    css::uno::Reference<css::frame::XModuleManager> xModuleManager =
+            css::frame::ModuleManager::create(xContext);
+    OUString aModuleIdentifier = xModuleManager->identify(mxFrame);
+
+    if (aModuleIdentifier != "com.sun.star.drawing.DrawingDocument"  &&
+        aModuleIdentifier != "com.sun.star.presentation.PresentationDocument" )
+    {
+        pNewObject->SetName(SvxResId(STR_ObjNameSingulFONTWORK) + u" 1");
+        pNewObject->MakeNameUnique();
+    }
+    else
+        pNewObject->SetName(OUString());
 
     // tdf#117629
     // Since the 'old' ::CloneSdrObject also copies the SdrPage* the
diff --git a/svx/source/toolbars/fontworkbar.cxx 
b/svx/source/toolbars/fontworkbar.cxx
index 8c81935b17f7..2a216183e955 100644
--- a/svx/source/toolbars/fontworkbar.cxx
+++ b/svx/source/toolbars/fontworkbar.cxx
@@ -416,7 +416,7 @@ void FontworkBar::execute( SdrView& rSdrView, SfxRequest 
const & rReq, SfxBindin
     {
         case SID_FONTWORK_GALLERY_FLOATER:
         {
-            std::shared_ptr<FontWorkGalleryDialog> pDlg = 
std::make_shared<FontWorkGalleryDialog>(rReq.GetFrameWeld(), rSdrView);
+            std::shared_ptr<FontWorkGalleryDialog> pDlg = 
std::make_shared<FontWorkGalleryDialog>(rReq.GetFrameWeld(), rSdrView, 
rBindings.GetActiveFrame());
             weld::DialogController::runAsync(pDlg, [](int){});
         }
         break;
diff --git a/sw/qa/extras/accessibility/dialogs.cxx 
b/sw/qa/extras/accessibility/dialogs.cxx
index a14eed6bdba3..2e047fdf9d72 100644
--- a/sw/qa/extras/accessibility/dialogs.cxx
+++ b/sw/qa/extras/accessibility/dialogs.cxx
@@ -171,7 +171,7 @@ CPPUNIT_TEST_FIXTURE(test::SwAccessibleTestBase, 
BasicTestFontworkDialog)
     CPPUNIT_ASSERT(dialogWaiter->waitEndDialog());
 
     CPPUNIT_ASSERT_EQUAL(
-        rtl::OUString("<PARAGRAPH/><SHAPE name=\"Simple\" description=\" 
\"><PARAGRAPH "
+        rtl::OUString("<PARAGRAPH/><SHAPE name=\"Fontwork 1\" description=\" 
\"><PARAGRAPH "
                       "description=\"Paragraph: 0 
Simple\">Simple</PARAGRAPH></SHAPE>"),
         collectText());
 }
diff --git a/sw/source/uibase/uiview/viewdraw.cxx 
b/sw/source/uibase/uiview/viewdraw.cxx
index e28ec7b1ebdf..a1d28225e51f 100644
--- a/sw/source/uibase/uiview/viewdraw.cxx
+++ b/sw/source/uibase/uiview/viewdraw.cxx
@@ -151,7 +151,7 @@ void SwView::ExecDraw(const SfxRequest& rReq)
         pSdrView = m_pWrtShell->GetDrawView();
         if (pSdrView)
         {
-            std::shared_ptr<svx::FontWorkGalleryDialog> pDlg = 
std::make_shared<svx::FontWorkGalleryDialog>(rWin.GetFrameWeld(), *pSdrView);
+            std::shared_ptr<svx::FontWorkGalleryDialog> pDlg = 
std::make_shared<svx::FontWorkGalleryDialog>(rWin.GetFrameWeld(), *pSdrView, 
GetFrame()->GetBindings().GetActiveFrame());
             pDlg->SetSdrObjectRef(&pSdrView->GetModel());
             weld::DialogController::runAsync(pDlg, [this, pDlg](int) {
                 vcl::Window& rWin2 = 
m_pWrtShell->GetView().GetViewFrame().GetWindow();

Reply via email to