canvas/Library_canvasfactory.mk                                       |    4 
 canvas/source/factory/cf_service.cxx                                  |   51 
++--------
 i18npool/Library_i18npool.mk                                          |    4 
 i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx |   20 
---
 4 files changed, 26 insertions(+), 53 deletions(-)

New commits:
commit 0cf10e8669c6f40a2187624469682c5bbc0bfb4d
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Tue May 14 19:42:37 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed May 15 08:02:10 2024 +0200

    use more officecfg in DefaultNumberingProvider
    
    Change-Id: I3b11bed579ec2ea86cac7fef57049a2279567a37
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167642
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/i18npool/Library_i18npool.mk b/i18npool/Library_i18npool.mk
index 0b72164bbf96..984137ebcf78 100644
--- a/i18npool/Library_i18npool.mk
+++ b/i18npool/Library_i18npool.mk
@@ -41,6 +41,10 @@ $(eval $(call gb_Library_use_externals,i18npool,\
        icu_headers \
 ))
 
+$(eval $(call gb_Library_use_custom_headers,i18npool,\
+       officecfg/registry \
+))
+
 ifeq ($(DISABLE_DYNLOADING),TRUE)
 $(eval $(call gb_Library_add_cxxflags,i18npool,\
        -DDICT_JA_ZH_IN_DATAFILE \
diff --git 
a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx 
b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index a1630a1cc2bd..1ba942ca3b51 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -32,6 +32,7 @@
 #include <string.h>
 #include <comphelper/propertysequence.hxx>
 #include <cppuhelper/supportsservice.hxx>
+#include <officecfg/Office/Common.hxx>
 
 // Cyrillic upper case
 #define C_CYR_A "\xD0\x90"
@@ -1201,23 +1202,8 @@ OUString 
DefaultNumberingProvider::makeNumberingIdentifier(sal_Int16 index)
 bool
 DefaultNumberingProvider::isScriptFlagEnabled(const OUString& aName)
 {
-    if (! xHierarchicalNameAccess.is()) {
-        Reference< XMultiServiceFactory > xConfigProvider =
-            configuration::theDefaultProvider::get(m_xContext);
-
-        if (! xConfigProvider.is())
-            throw RuntimeException();
-
-        uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence(
-        {
-            {"nodepath", uno::Any(u"/org.openoffice.Office.Common/I18N"_ustr)}
-        }));
-
-        Reference<XInterface> xInterface = 
xConfigProvider->createInstanceWithArguments(
-            u"com.sun.star.configuration.ConfigurationAccess"_ustr, aArgs);
-
-        xHierarchicalNameAccess.set(xInterface, UNO_QUERY_THROW);
-    }
+    if (! xHierarchicalNameAccess.is())
+        xHierarchicalNameAccess = officecfg::Office::Common::I18N::get();
 
     Any aEnabled = xHierarchicalNameAccess->getByHierarchicalName(aName);
 
commit 6555238fc62a08ef1e8c44e96dc18d38345dd419
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Tue May 14 19:17:28 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed May 15 08:01:56 2024 +0200

    use more officecfg in CanvasFactory
    
    Change-Id: I3d2b09a0e951a7901af85108537485fdea1dbc43
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167640
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/canvas/Library_canvasfactory.mk b/canvas/Library_canvasfactory.mk
index 0b0a9d988e15..0141cd1362cd 100644
--- a/canvas/Library_canvasfactory.mk
+++ b/canvas/Library_canvasfactory.mk
@@ -28,6 +28,10 @@ $(eval $(call 
gb_Library_set_componentfile,canvasfactory,canvas/source/factory/c
 
 $(eval $(call gb_Library_use_external,canvasfactory,boost_headers))
 
+$(eval $(call gb_Library_use_custom_headers,canvasfactory,\
+       officecfg/registry \
+))
+
 $(eval $(call gb_Library_use_sdk_api,canvasfactory))
 
 $(eval $(call gb_Library_use_libraries,canvasfactory,\
diff --git a/canvas/source/factory/cf_service.cxx 
b/canvas/source/factory/cf_service.cxx
index 88f07fc56f06..62d7ec3c0bd3 100644
--- a/canvas/source/factory/cf_service.cxx
+++ b/canvas/source/factory/cf_service.cxx
@@ -39,6 +39,7 @@
 #include <o3tl/string_view.hxx>
 #include <vcl/skia/SkiaHelper.hxx>
 #include <comphelper/configuration.hxx>
+#include <officecfg/Office/Canvas.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -60,7 +61,6 @@ class CanvasFactory
 
     mutable std::mutex                m_mutex;
     Reference<XComponentContext>      m_xContext;
-    Reference<container::XNameAccess> m_xCanvasConfigNameAccess;
     AvailVector                       m_aAvailableImplementations;
     AvailVector                       m_aAcceleratedImplementations;
     AvailVector                       m_aAAImplementations;
@@ -71,7 +71,7 @@ class CanvasFactory
 
     void checkConfigFlag( bool& r_bFlag,
                           bool& r_CacheFlag,
-                          const OUString& nodeName ) const;
+                          bool bCurrentConfigValue ) const;
     Reference<XInterface> use(
         OUString const & serviceName,
         Sequence<Any> const & args,
@@ -118,30 +118,12 @@ CanvasFactory::CanvasFactory( 
Reference<XComponentContext> const & xContext ) :
         try
         {
             // read out configuration for preferred services:
-            Reference<lang::XMultiServiceFactory> xConfigProvider(
-                configuration::theDefaultProvider::get( m_xContext ) );
 
-            uno::Sequence<uno::Any> aArgs(comphelper::InitAnyPropertySequence(
-            {
-                {"nodepath", uno::Any(u"/org.openoffice.Office.Canvas"_ustr)}
-            }));
-            m_xCanvasConfigNameAccess.set(
-                xConfigProvider->createInstanceWithArguments(
-                    u"com.sun.star.configuration.ConfigurationAccess"_ustr,
-                    aArgs ),
-                UNO_QUERY_THROW );
-
-            uno::Sequence<uno::Any> aArgs2(comphelper::InitAnyPropertySequence(
-            {
-                {"nodepath", 
uno::Any(u"/org.openoffice.Office.Canvas/CanvasServiceList"_ustr)}
-            }));
-            Reference<container::XNameAccess> xNameAccess(
-                xConfigProvider->createInstanceWithArguments(
-                    u"com.sun.star.configuration.ConfigurationAccess"_ustr,
-                    aArgs2 ), UNO_QUERY_THROW );
+            Reference<container::XNameAccess> xNameAccess = 
officecfg::Office::Canvas::CanvasServiceList::get();
             Reference<container::XHierarchicalNameAccess> 
xHierarchicalNameAccess(
                 xNameAccess, UNO_QUERY_THROW);
 
+
             for (auto& serviceName : xNameAccess->getElementNames())
             {
                 Reference<container::XNameAccess> xEntryNameAccess(
@@ -253,19 +235,16 @@ Reference<XInterface> CanvasFactory::use(
 
 void CanvasFactory::checkConfigFlag( bool& r_bFlag,
                                      bool& r_CacheFlag,
-                                     const OUString& nodeName ) const
+                                     bool bCurrentConfigValue ) const
 {
-    if( m_xCanvasConfigNameAccess.is() )
-    {
-        m_xCanvasConfigNameAccess->getByName( nodeName ) >>= r_bFlag;
+    r_bFlag = bCurrentConfigValue;
 
-        if( r_CacheFlag != r_bFlag )
-        {
-            // cache is invalid, because of different order of
-            // elements
-            r_CacheFlag = r_bFlag;
-            m_aCachedImplementations.clear();
-        }
+    if( r_CacheFlag != r_bFlag )
+    {
+        // cache is invalid, because of different order of
+        // elements
+        r_CacheFlag = r_bFlag;
+        m_aCachedImplementations.clear();
     }
 }
 
@@ -280,19 +259,19 @@ Reference<XInterface> CanvasFactory::lookupAndUse(
     bool bForceLastEntry(false);
     checkConfigFlag( bForceLastEntry,
                      m_bCacheHasForcedLastImpl,
-                     u"ForceSafeServiceImpl"_ustr );
+                     officecfg::Office::Canvas::ForceSafeServiceImpl::get() );
 
     // use anti-aliasing canvas, if config flag set (or not existing)
     bool bUseAAEntry(true);
     checkConfigFlag( bUseAAEntry,
                      m_bCacheHasUseAAEntry,
-                     u"UseAntialiasingCanvas"_ustr );
+                     officecfg::Office::Canvas::UseAntialiasingCanvas::get() );
 
     // use accelerated canvas, if config flag set (or not existing)
     bool bUseAcceleratedEntry(true);
     checkConfigFlag( bUseAcceleratedEntry,
                      m_bCacheHasUseAcceleratedEntry,
-                     u"UseAcceleratedCanvas"_ustr );
+                     officecfg::Office::Canvas::UseAcceleratedCanvas::get() );
 
     // try to reuse last working implementation for given service name
     const CacheVector::iterator aEnd(m_aCachedImplementations.end());

Reply via email to