diff options
author | Gabor Kelemen <gabor.kelemen.extern@allotropia.de> | 2024-04-26 13:39:44 +0200 |
---|---|---|
committer | Gabor Kelemen <gabor.kelemen.extern@allotropia.de> | 2024-04-28 17:08:29 +0200 |
commit | 924d7b64f07a3bd1d9d3195eb3ce923b616bfb45 (patch) | |
tree | 4d9087f3f5971be969f378b720a7facce02c5474 | |
parent | 6a11bf9f7bd209a082254c861d5a04c7f5729d68 (diff) |
Drop CacheConfiguration in favor of officecfg
Also the key path was wrong in SlsCacheConfiguration.cxx:
MultiPaneGUI/SlideSorter/PreviewCache
but in Impress.xcs we have
MultiPaneGUI/SlideSorterBar/PreviewCache
hierarchy so this may actually now start to work :)
Change-Id: I4b552be713e6e157edb45692ba78101429aa1c85
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166755
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
-rw-r--r-- | compilerplugins/clang/unnecessarylocking.cxx | 2 | ||||
-rw-r--r-- | sd/Library_sd.mk | 1 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx | 7 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx | 17 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx | 144 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/cache/SlsCacheConfiguration.hxx | 68 | ||||
-rw-r--r-- | sd/source/ui/tools/SdGlobalResourceContainer.cxx | 4 | ||||
-rw-r--r-- | solenv/clang-format/excludelist | 1 |
8 files changed, 8 insertions, 236 deletions
diff --git a/compilerplugins/clang/unnecessarylocking.cxx b/compilerplugins/clang/unnecessarylocking.cxx index 40b15518571d..b578f8da229d 100644 --- a/compilerplugins/clang/unnecessarylocking.cxx +++ b/compilerplugins/clang/unnecessarylocking.cxx @@ -115,8 +115,6 @@ bool UnnecessaryLocking::VisitCompoundStmt(const CompoundStmt* compoundStmt) && !loplugin::isSamePathname(fn, SRCDIR "/desktop/source/deployment/gui/dp_gui_dialog2.cxx") && !loplugin::isSamePathname(fn, SRCDIR "/desktop/source/lib/init.cxx") - && !loplugin::isSamePathname( - fn, SRCDIR "/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx") // needs to lock around access to methods in vcl && !loplugin::isSamePathname(fn, SRCDIR "/basctl/source/basicide/unomodel.cxx") diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 12296242bedb..643cce60ff82 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -375,7 +375,6 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/ui/slidesorter/cache/SlsBitmapCompressor \ sd/source/ui/slidesorter/cache/SlsBitmapFactory \ sd/source/ui/slidesorter/cache/SlsCacheCompactor \ - sd/source/ui/slidesorter/cache/SlsCacheConfiguration \ sd/source/ui/slidesorter/cache/SlsGenericPageCache \ sd/source/ui/slidesorter/cache/SlsPageCache \ sd/source/ui/slidesorter/cache/SlsPageCacheManager \ diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx b/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx index 89acdc564bf5..ca0bd8cf4b8b 100644 --- a/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx +++ b/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx @@ -17,12 +17,13 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <officecfg/Office/Impress.hxx> + #include <memory> #include <unordered_map> #include "SlsBitmapCache.hxx" #include "SlsCacheCompactor.hxx" #include "SlsBitmapCompressor.hxx" -#include "SlsCacheConfiguration.hxx" #include <sal/log.hxx> @@ -126,9 +127,7 @@ BitmapCache::BitmapCache () mnMaximalNormalCacheSize(MAXIMAL_CACHE_SIZE), mbIsFull(false) { - Any aCacheSize (CacheConfiguration::Instance()->GetValue("CacheSize")); - if (aCacheSize.has<sal_Int32>()) - aCacheSize >>= mnMaximalNormalCacheSize; + mnMaximalNormalCacheSize = officecfg::Office::Impress::MultiPaneGUI::SlideSorterBar::PreviewCache::CacheSize::get(); mpCacheCompactor = CacheCompactor::Create(*this,mnMaximalNormalCacheSize); } diff --git a/sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx b/sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx index f5fa8690af20..74262f1f224c 100644 --- a/sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx +++ b/sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx @@ -22,11 +22,10 @@ #include "SlsBitmapCompressor.hxx" #include "SlsBitmapCache.hxx" -#include "SlsCacheConfiguration.hxx" #include <rtl/ustring.hxx> #include <sal/log.hxx> -#include <com/sun/star/uno/Any.hxx> +#include <officecfg/Office/Impress.hxx> #include <utility> using namespace ::com::sun::star::uno; @@ -86,27 +85,21 @@ namespace sd::slidesorter::cache { static const char sNone[] = "None"; std::shared_ptr<BitmapCompressor> pCompressor; - OUString sCompressionPolicy("PNGCompression"); - Any aCompressionPolicy (CacheConfiguration::Instance()->GetValue("CompressionPolicy")); - if (aCompressionPolicy.has<OUString>()) - aCompressionPolicy >>= sCompressionPolicy; + OUString sCompressionPolicy = officecfg::Office::Impress::MultiPaneGUI::SlideSorterBar::PreviewCache::CompressionPolicy::get(); if (sCompressionPolicy == sNone) pCompressor = std::make_shared<NoBitmapCompression>(); else if (sCompressionPolicy == "Erase") pCompressor = std::make_shared<CompressionByDeletion>(); else if (sCompressionPolicy == "ResolutionReduction") pCompressor = std::make_shared<ResolutionReduction>(); - else + else // default: "PNGCompression" pCompressor = std::make_shared<PngCompression>(); ::std::unique_ptr<CacheCompactor> pCompactor; - OUString sCompactionPolicy("Compress"); - Any aCompactionPolicy (CacheConfiguration::Instance()->GetValue("CompactionPolicy")); - if (aCompactionPolicy.has<OUString>()) - aCompactionPolicy >>= sCompactionPolicy; + OUString sCompactionPolicy = officecfg::Office::Impress::MultiPaneGUI::SlideSorterBar::PreviewCache::CompactionPolicy::get(); if (sCompactionPolicy == sNone) pCompactor.reset(new NoCacheCompaction(rCache,nMaximalCacheSize)); - else + else // default: "Compress" pCompactor.reset(new CacheCompactionByCompression(rCache,nMaximalCacheSize,pCompressor)); return pCompactor; diff --git a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx b/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx deleted file mode 100644 index fd08c76276c9..000000000000 --- a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "SlsCacheConfiguration.hxx" -#include <vcl/svapp.hxx> - -#include <comphelper/processfactory.hxx> -#include <comphelper/propertysequence.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/configuration/theDefaultProvider.hpp> - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; - -namespace sd::slidesorter::cache { - -namespace -{ - typedef std::shared_ptr<CacheConfiguration> CacheConfigSharedPtr; - CacheConfigSharedPtr& theInstance() - { - static CacheConfigSharedPtr SINGLETON; - return SINGLETON; - } -} - -std::weak_ptr<CacheConfiguration> CacheConfiguration::mpWeakInstance; - -std::shared_ptr<CacheConfiguration> CacheConfiguration::Instance() -{ - SolarMutexGuard aSolarGuard; - CacheConfigSharedPtr &rInstancePtr = theInstance(); - if (!rInstancePtr) - { - // Maybe somebody else kept a previously created instance alive. - if ( ! mpWeakInstance.expired()) - rInstancePtr = std::shared_ptr<CacheConfiguration>(mpWeakInstance); - if (!rInstancePtr) - { - // We have to create a new instance. - rInstancePtr.reset(new CacheConfiguration()); - mpWeakInstance = rInstancePtr; - // Prepare to release this instance in the near future. - rInstancePtr->m_ReleaseTimer.SetInvokeHandler( - LINK(rInstancePtr.get(),CacheConfiguration,TimerCallback)); - rInstancePtr->m_ReleaseTimer.SetTimeout(5000 /* 5s */); - rInstancePtr->m_ReleaseTimer.Start(); - } - } - return rInstancePtr; -} - -CacheConfiguration::CacheConfiguration() - : m_ReleaseTimer("sd::CacheConfiguration maReleaseTimer") -{ - // Get the cache size from configuration. - try - { - // Obtain access to the configuration. - Reference<lang::XMultiServiceFactory> xProvider = - configuration::theDefaultProvider::get( ::comphelper::getProcessComponentContext() ); - - // Obtain access to Impress configuration. - Sequence<Any> aCreationArguments(comphelper::InitAnyPropertySequence( - { - {"nodepath", Any(OUString("/org.openoffice.Office.Impress/"))}, - {"depth", Any(sal_Int32(-1))} - })); - - Reference<XInterface> xRoot (xProvider->createInstanceWithArguments( - "com.sun.star.configuration.ConfigurationAccess", - aCreationArguments)); - if ( ! xRoot.is()) - return; - Reference<container::XHierarchicalNameAccess> xHierarchy (xRoot, UNO_QUERY); - if ( ! xHierarchy.is()) - return; - - // Get the node for the slide sorter preview cache. - mxCacheNode.set( xHierarchy->getByHierarchicalName("MultiPaneGUI/SlideSorter/PreviewCache"), UNO_QUERY); - } - catch (RuntimeException &) - { - } - catch (Exception &) - { - } -} - -Any CacheConfiguration::GetValue (const OUString& rName) -{ - Any aResult; - - if (mxCacheNode != nullptr) - { - try - { - aResult = mxCacheNode->getByName(rName); - } - catch (Exception &) - { - } - } - - return aResult; -} - -IMPL_STATIC_LINK_NOARG(CacheConfiguration, TimerCallback, Timer *, void) -{ - CacheConfigSharedPtr &rInstancePtr = theInstance(); - // Release our reference to the instance. - rInstancePtr.reset(); - // note: if there are no other references to the instance, m_ReleaseTimer - // will be deleted now -} - -void CacheConfiguration::Shutdown() -{ - CacheConfigSharedPtr &rInstancePtr = theInstance(); - rInstancePtr.reset(); - assert(mpWeakInstance.expired()); // ensure m_ReleaseTimer is destroyed -} - -} // end of namespace ::sd::slidesorter::cache - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.hxx b/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.hxx deleted file mode 100644 index d53bcd713fb2..000000000000 --- a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.hxx +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#include <com/sun/star/uno/Any.hxx> -#include <vcl/timer.hxx> -#include <memory> - -namespace com::sun::star::container -{ -class XNameAccess; -} - -namespace sd::slidesorter::cache -{ -/** A very simple and easy-to-use access to configuration entries regarding - the slide sorter cache. -*/ -class CacheConfiguration -{ -public: - /** Return an instance to this class. The reference is released after 5 - seconds. Subsequent calls to this function will create a new - instance. - */ - static std::shared_ptr<CacheConfiguration> Instance(); - - static void Shutdown(); - - /** Look up the specified value in - MultiPaneGUI/SlideSorter/PreviewCache. When the specified value - does not exist then an empty Any is returned. - */ - css::uno::Any GetValue(const OUString& rName); - -private: - /** When a caller holds a reference after we have released ours we use - this weak pointer to avoid creating a new instance. - */ - static std::weak_ptr<CacheConfiguration> mpWeakInstance; - Timer m_ReleaseTimer; - css::uno::Reference<css::container::XNameAccess> mxCacheNode; - - CacheConfiguration(); - - DECL_STATIC_LINK(CacheConfiguration, TimerCallback, Timer*, void); -}; - -} // end of namespace ::sd::slidesorter::cache - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/tools/SdGlobalResourceContainer.cxx b/sd/source/ui/tools/SdGlobalResourceContainer.cxx index 7f692caa157c..16ea15dcb63e 100644 --- a/sd/source/ui/tools/SdGlobalResourceContainer.cxx +++ b/sd/source/ui/tools/SdGlobalResourceContainer.cxx @@ -19,8 +19,6 @@ #include <tools/SdGlobalResourceContainer.hxx> -#include <../cache/SlsCacheConfiguration.hxx> - #include <comphelper/processfactory.hxx> #include <comphelper/unique_disposing_ptr.hxx> @@ -189,8 +187,6 @@ SdGlobalResourceContainer::~SdGlobalResourceContainer() if (xComponent.is()) xComponent->dispose(); } - - sd::slidesorter::cache::CacheConfiguration::Shutdown(); } } // end of namespace sd diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index c1c2506ef286..8991519cf8db 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -9900,7 +9900,6 @@ sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx sd/source/ui/slidesorter/cache/SlsCacheCompactor.hxx -sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx sd/source/ui/slidesorter/cache/SlsPageCache.cxx |