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.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2024-05-14 19:17:28 +02:00 committed by Noel Grandin
parent 658a212585
commit 6555238fc6
2 changed files with 19 additions and 36 deletions

View file

@ -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,\

View file

@ -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());