diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-08-11 18:11:18 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-12 08:40:30 +0200 |
commit | f9871d218bcae184a5845d63366175ea2df2086a (patch) | |
tree | d0e8a6b9bf885b68105b79b15da9081a6b27e30e | |
parent | 5351e837a11fb9d19759cd1b91ca4b5d43e2f75a (diff) |
flatten LngSvcMgr
Change-Id: I757cf9512fc3b87dd826eb39c2bbe456dc14d097
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120339
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | linguistic/source/lngsvcmgr.cxx | 30 | ||||
-rw-r--r-- | linguistic/source/lngsvcmgr.hxx | 11 |
2 files changed, 21 insertions, 20 deletions
diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx index 9e0100538809..898eeaf2256a 100644 --- a/linguistic/source/lngsvcmgr.cxx +++ b/linguistic/source/lngsvcmgr.cxx @@ -922,7 +922,7 @@ void LngSvcMgr::GetAvailableSpellSvcs_Impl() if (pAvailSpellSvcs) return; - pAvailSpellSvcs.reset(new SvcInfoArray); + pAvailSpellSvcs.emplace(); uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); @@ -960,7 +960,7 @@ void LngSvcMgr::GetAvailableSpellSvcs_Impl() uno::Sequence<lang::Locale> aLocaleSequence(xSvc->getLocales()); aLanguages = LocaleSeqToLangVec( aLocaleSequence ); - pAvailSpellSvcs->push_back( std::make_unique<SvcInfo>( aImplName, aLanguages ) ); + pAvailSpellSvcs->push_back( SvcInfo( aImplName, aLanguages ) ); } catch (const uno::Exception &) { @@ -976,7 +976,7 @@ void LngSvcMgr::GetAvailableGrammarSvcs_Impl() if (pAvailGrammarSvcs) return; - pAvailGrammarSvcs.reset(new SvcInfoArray); + pAvailGrammarSvcs.emplace(); uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); @@ -1018,7 +1018,7 @@ void LngSvcMgr::GetAvailableGrammarSvcs_Impl() uno::Sequence<lang::Locale> aLocaleSequence(xSvc->getLocales()); aLanguages = LocaleSeqToLangVec( aLocaleSequence ); - pAvailGrammarSvcs->push_back( std::make_unique<SvcInfo>( aImplName, aLanguages ) ); + pAvailGrammarSvcs->push_back( SvcInfo( aImplName, aLanguages ) ); } catch (const uno::Exception &) { @@ -1035,7 +1035,7 @@ void LngSvcMgr::GetAvailableHyphSvcs_Impl() if (pAvailHyphSvcs) return; - pAvailHyphSvcs.reset(new SvcInfoArray); + pAvailHyphSvcs.emplace(); uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xContext->getServiceManager(), uno::UNO_QUERY ); @@ -1070,7 +1070,7 @@ void LngSvcMgr::GetAvailableHyphSvcs_Impl() SAL_WARN_IF( aImplName.isEmpty(), "linguistic", "empty implementation name" ); uno::Sequence<lang::Locale> aLocaleSequence(xSvc->getLocales()); aLanguages = LocaleSeqToLangVec( aLocaleSequence ); - pAvailHyphSvcs->push_back( std::make_unique<SvcInfo>( aImplName, aLanguages ) ); + pAvailHyphSvcs->push_back( SvcInfo( aImplName, aLanguages ) ); } catch (const uno::Exception &) { @@ -1086,7 +1086,7 @@ void LngSvcMgr::GetAvailableThesSvcs_Impl() if (pAvailThesSvcs) return; - pAvailThesSvcs.reset(new SvcInfoArray); + pAvailThesSvcs.emplace(); uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); @@ -1124,7 +1124,7 @@ void LngSvcMgr::GetAvailableThesSvcs_Impl() uno::Sequence<lang::Locale> aLocaleSequence(xSvc->getLocales()); aLanguages = LocaleSeqToLangVec( aLocaleSequence ); - pAvailThesSvcs->push_back( std::make_unique<SvcInfo>( aImplName, aLanguages ) ); + pAvailThesSvcs->push_back( SvcInfo( aImplName, aLanguages ) ); } catch (const uno::Exception &) { @@ -1376,22 +1376,22 @@ uno::Sequence< OUString > SAL_CALL if (rServiceName == SN_SPELLCHECKER) { GetAvailableSpellSvcs_Impl(); - pInfoArray = pAvailSpellSvcs.get(); + pInfoArray = &*pAvailSpellSvcs; } else if (rServiceName == SN_GRAMMARCHECKER) { GetAvailableGrammarSvcs_Impl(); - pInfoArray = pAvailGrammarSvcs.get(); + pInfoArray = &*pAvailGrammarSvcs; } else if (rServiceName == SN_HYPHENATOR) { GetAvailableHyphSvcs_Impl(); - pInfoArray = pAvailHyphSvcs.get(); + pInfoArray = &*pAvailHyphSvcs; } else if (rServiceName == SN_THESAURUS) { GetAvailableThesSvcs_Impl(); - pInfoArray = pAvailThesSvcs.get(); + pInfoArray = &*pAvailThesSvcs; } if (pInfoArray) @@ -1400,12 +1400,12 @@ uno::Sequence< OUString > SAL_CALL aVec.reserve(pInfoArray->size()); LanguageType nLanguage = LinguLocaleToLanguage( rLocale ); - for (const auto& pInfo : *pInfoArray) + for (const auto& rInfo : *pInfoArray) { if (LinguIsUnspecified( nLanguage ) - || pInfo->HasLanguage( nLanguage )) + || rInfo.HasLanguage( nLanguage )) { - aVec.push_back(pInfo->aSvcImplName); + aVec.push_back(rInfo.aSvcImplName); } } diff --git a/linguistic/source/lngsvcmgr.hxx b/linguistic/source/lngsvcmgr.hxx index 5a56eaaaae21..0f37e041b1be 100644 --- a/linguistic/source/lngsvcmgr.hxx +++ b/linguistic/source/lngsvcmgr.hxx @@ -35,6 +35,7 @@ #include <vcl/idle.hxx> #include <vector> #include <memory> +#include <optional> class SpellCheckerDispatcher; class HyphenatorDispatcher; @@ -87,11 +88,11 @@ class LngSvcMgr : rtl::Reference<LngSvcMgrListenerHelper> mxListenerHelper; - typedef std::vector< std::unique_ptr<SvcInfo> > SvcInfoArray; - std::unique_ptr<SvcInfoArray> pAvailSpellSvcs; - std::unique_ptr<SvcInfoArray> pAvailGrammarSvcs; - std::unique_ptr<SvcInfoArray> pAvailHyphSvcs; - std::unique_ptr<SvcInfoArray> pAvailThesSvcs; + typedef std::vector< SvcInfo > SvcInfoArray; + std::optional<SvcInfoArray> pAvailSpellSvcs; + std::optional<SvcInfoArray> pAvailGrammarSvcs; + std::optional<SvcInfoArray> pAvailHyphSvcs; + std::optional<SvcInfoArray> pAvailThesSvcs; bool bDisposing; |