From 6555238fc62a08ef1e8c44e96dc18d38345dd419 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 14 May 2024 19:17:28 +0200 Subject: [PATCH] use more officecfg in CanvasFactory Change-Id: I3d2b09a0e951a7901af85108537485fdea1dbc43 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167640 Tested-by: Jenkins Reviewed-by: Noel Grandin --- canvas/Library_canvasfactory.mk | 4 +++ canvas/source/factory/cf_service.cxx | 51 ++++++++-------------------- 2 files changed, 19 insertions(+), 36 deletions(-) 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 #include #include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -60,7 +61,6 @@ class CanvasFactory mutable std::mutex m_mutex; Reference m_xContext; - Reference 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 use( OUString const & serviceName, Sequence const & args, @@ -118,30 +118,12 @@ CanvasFactory::CanvasFactory( Reference const & xContext ) : try { // read out configuration for preferred services: - Reference xConfigProvider( - configuration::theDefaultProvider::get( m_xContext ) ); - uno::Sequence 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 aArgs2(comphelper::InitAnyPropertySequence( - { - {"nodepath", uno::Any(u"/org.openoffice.Office.Canvas/CanvasServiceList"_ustr)} - })); - Reference xNameAccess( - xConfigProvider->createInstanceWithArguments( - u"com.sun.star.configuration.ConfigurationAccess"_ustr, - aArgs2 ), UNO_QUERY_THROW ); + Reference xNameAccess = officecfg::Office::Canvas::CanvasServiceList::get(); Reference xHierarchicalNameAccess( xNameAccess, UNO_QUERY_THROW); + for (auto& serviceName : xNameAccess->getElementNames()) { Reference xEntryNameAccess( @@ -253,19 +235,16 @@ Reference 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 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());