diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-02-27 09:30:46 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-02-27 09:54:20 +0000 |
commit | 4805a1348bb3749d468656a4e648064dabe1fd04 (patch) | |
tree | 88411f0683c346da941ac6e10a59e99a03661e2a /cui | |
parent | 59bc90c9d60b5f425f29ce42d1db9381eb2c1f4d (diff) |
Optional may be avoided here, too
Change-Id: I6320f8b745ead030cb7ae304bdf85e0064a57380
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147751
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/autocdlg.hxx | 4 | ||||
-rw-r--r-- | cui/source/tabpages/autocdlg.cxx | 28 |
2 files changed, 15 insertions, 17 deletions
diff --git a/cui/source/inc/autocdlg.hxx b/cui/source/inc/autocdlg.hxx index 8e31011e7a33..7b4842314779 100644 --- a/cui/source/inc/autocdlg.hxx +++ b/cui/source/inc/autocdlg.hxx @@ -166,7 +166,7 @@ private: std::set<OUString> aFormatText; std::map<LanguageType, DoubleStringArray> aDoubleStringTable; - std::optional<CollatorWrapper> moCompareClass; + CollatorWrapper maCompareClass; std::unique_ptr<CharClass> pCharClass; LanguageType eLang; @@ -227,7 +227,7 @@ class OfaAutocorrExceptPage : public SfxTabPage { private: StringsTable aStringsTable; - std::optional<CollatorWrapper> moCompareClass; + CollatorWrapper maCompareClass; LanguageType eLang; std::unique_ptr<weld::Entry> m_xAbbrevED; diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index f8c4a16d0c6e..446775c6abad 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -667,6 +667,7 @@ IMPL_LINK_NOARG(OfaSwAutoFmtOptionsPage, EditHdl, weld::Button&, void) OfaAutocorrReplacePage::OfaAutocorrReplacePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/acorreplacepage.ui", "AcorReplacePage", &rSet) + , maCompareClass(comphelper::getProcessComponentContext()) , eLang(eLastDialogLanguage) , bHasSelectionText(false) , bFirstSelect(true) @@ -698,8 +699,7 @@ OfaAutocorrReplacePage::OfaAutocorrReplacePage(weld::Container* pPage, weld::Dia bSWriter = pMod == SfxModule::GetActiveModule(); LanguageTag aLanguageTag( eLastDialogLanguage ); - moCompareClass.emplace( comphelper::getProcessComponentContext() ); - moCompareClass->loadDefaultCollator( aLanguageTag.getLocale(), 0 ); + maCompareClass.loadDefaultCollator( aLanguageTag.getLocale(), 0 ); pCharClass.reset( new CharClass( std::move(aLanguageTag) ) ); auto nColWidth = m_xReplaceTLB->get_approximate_digit_width() * 32; @@ -722,7 +722,6 @@ OfaAutocorrReplacePage::~OfaAutocorrReplacePage() aDoubleStringTable.clear(); aChangesTable.clear(); - moCompareClass.reset(); pCharClass.reset(); } @@ -904,8 +903,8 @@ void OfaAutocorrReplacePage::SetLanguage(LanguageType eSet) eLastDialogLanguage = eSet; LanguageTag aLanguageTag( eLastDialogLanguage ); - moCompareClass.emplace( comphelper::getProcessComponentContext() ); - moCompareClass->loadDefaultCollator( aLanguageTag.getLocale(), 0 ); + maCompareClass = CollatorWrapper( comphelper::getProcessComponentContext() ); + maCompareClass.loadDefaultCollator( aLanguageTag.getLocale(), 0 ); pCharClass.reset( new CharClass( std::move(aLanguageTag) ) ); ModifyHdl(*m_xShortED); } @@ -919,7 +918,7 @@ IMPL_LINK(OfaAutocorrReplacePage, SelectHdl, weld::TreeView&, rBox, void) OUString sTmpShort(rBox.get_text(nEntry, 0)); // if the text is set via ModifyHdl, the cursor is always at the beginning // of a word, although you're editing here - bool bSameContent = 0 == moCompareClass->compareString(sTmpShort, m_xShortED->get_text()); + bool bSameContent = 0 == maCompareClass.compareString(sTmpShort, m_xShortED->get_text()); int nStartPos, nEndPos; m_xShortED->get_selection_bounds(nStartPos, nEndPos); if (m_xShortED->get_text() != sTmpShort) @@ -1057,7 +1056,7 @@ bool OfaAutocorrReplacePage::NewDelHdl(const weld::Widget* pBtn) int nCount = m_xReplaceTLB->n_children(); for (j = 0; j < nCount; ++j) { - if (0 >= moCompareClass->compareString(sEntry, m_xReplaceTLB->get_text(j, 0))) + if (0 >= maCompareClass.compareString(sEntry, m_xReplaceTLB->get_text(j, 0))) break; } nPos = j; @@ -1110,7 +1109,7 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void) &bTmpSelEntry, &bFirstSelIterSet, &xFirstSel, &aWordStr](weld::TreeIter& rIter){ OUString aTestStr = m_xReplaceTLB->get_text(rIter, 0); - if( moCompareClass->compareString(rEntry, aTestStr ) == 0 ) + if( maCompareClass.compareString(rEntry, aTestStr ) == 0 ) { if (!rRepString.isEmpty()) bFirstSelect = true; @@ -1191,6 +1190,7 @@ static bool lcl_FindInArray(std::vector<OUString>& rStrings, std::u16string_view OfaAutocorrExceptPage::OfaAutocorrExceptPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/acorexceptpage.ui", "AcorExceptPage", &rSet) + , maCompareClass(comphelper::getProcessComponentContext()) , eLang(eLastDialogLanguage) , m_xAbbrevED(m_xBuilder->weld_entry("abbrev")) , m_xAbbrevLB(m_xBuilder->weld_tree_view("abbrevlist")) @@ -1210,8 +1210,7 @@ OfaAutocorrExceptPage::OfaAutocorrExceptPage(weld::Container* pPage, weld::Dialo m_xDoubleCapsLB->set_size_request(-1, m_xDoubleCapsLB->get_height_rows(6)); css::lang::Locale aLcl( LanguageTag::convertToLocale(eLastDialogLanguage )); - moCompareClass.emplace( comphelper::getProcessComponentContext() ); - moCompareClass->loadDefaultCollator( aLcl, 0 ); + maCompareClass.loadDefaultCollator( aLcl, 0 ); m_xNewAbbrevPB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl)); m_xDelAbbrevPB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl)); @@ -1230,7 +1229,6 @@ OfaAutocorrExceptPage::OfaAutocorrExceptPage(weld::Container* pPage, weld::Dialo OfaAutocorrExceptPage::~OfaAutocorrExceptPage() { aStringsTable.clear(); - moCompareClass.reset(); } std::unique_ptr<SfxTabPage> OfaAutocorrExceptPage::Create(weld::Container* pPage, weld::DialogController* pController, @@ -1365,8 +1363,8 @@ void OfaAutocorrExceptPage::SetLanguage(LanguageType eSet) // save old settings and fill anew RefillReplaceBoxes(false, eLang, eSet); eLastDialogLanguage = eSet; - moCompareClass.emplace( comphelper::getProcessComponentContext() ); - moCompareClass->loadDefaultCollator( LanguageTag::convertToLocale( eLastDialogLanguage ), 0 ); + maCompareClass = CollatorWrapper( comphelper::getProcessComponentContext() ); + maCompareClass.loadDefaultCollator( LanguageTag::convertToLocale( eLastDialogLanguage ), 0 ); ModifyHdl(*m_xAbbrevED); ModifyHdl(*m_xDoubleCapsED); } @@ -1511,7 +1509,7 @@ IMPL_LINK(OfaAutocorrExceptPage, ModifyHdl, weld::Entry&, rEdt, void) bool bEntryLen = !sEntry.isEmpty(); if (&rEdt == m_xAbbrevED.get()) { - bool bSame = lcl_FindEntry(*m_xAbbrevLB, sEntry, *moCompareClass); + bool bSame = lcl_FindEntry(*m_xAbbrevLB, sEntry, maCompareClass); if(bSame && sEntry != m_xAbbrevLB->get_selected_text()) rEdt.set_text(m_xAbbrevLB->get_selected_text()); m_xNewAbbrevPB->set_sensitive(!bSame && bEntryLen); @@ -1519,7 +1517,7 @@ IMPL_LINK(OfaAutocorrExceptPage, ModifyHdl, weld::Entry&, rEdt, void) } else { - bool bSame = lcl_FindEntry(*m_xDoubleCapsLB, sEntry, *moCompareClass); + bool bSame = lcl_FindEntry(*m_xDoubleCapsLB, sEntry, maCompareClass); if(bSame && sEntry != m_xDoubleCapsLB->get_selected_text()) rEdt.set_text(m_xDoubleCapsLB->get_selected_text()); m_xNewDoublePB->set_sensitive(!bSame && bEntryLen); |