diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-11-17 13:33:51 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-11-26 18:40:27 +0100 |
commit | 852b213b22eaaa7d4bae7cba596db12f90b41a24 (patch) | |
tree | 59b0478e46557ab7efaf26901390bf202802ca5a /sw | |
parent | c9c48701af9e133f682acaa8a5103f2eccd5be9e (diff) |
SpellingPopup: Remove m_aSuggestions member variable
We don't need it after the construction. The text is stored by the
menu item.
(cherry picked from commit dc842a4af87ae5f1edd6112ca4f2ff2ac25f5a50)
Reviewed-on: https://gerrit.libreoffice.org/83589
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit 4549de73090284f149ed6ba62818e27739bdaf19)
Change-Id: I54b0392b4564e76d405824bb297e6f993a24a5fb
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/inc/olmenu.hxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/lingu/olmenu.cxx | 34 |
2 files changed, 20 insertions, 15 deletions
diff --git a/sw/source/uibase/inc/olmenu.hxx b/sw/source/uibase/inc/olmenu.hxx index bda8b7ddb3d4..b98fb5ba88f9 100644 --- a/sw/source/uibase/inc/olmenu.hxx +++ b/sw/source/uibase/inc/olmenu.hxx @@ -95,7 +95,6 @@ class SW_DLLPUBLIC SwSpellPopup css::linguistic2::ProofreadingResult m_xGrammarResult; sal_Int32 m_nGrammarError; - css::uno::Sequence< OUString > m_aSuggestions; OUString m_sExplanationLink; LanguageType m_nCheckedLanguage; diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx index 5bafea9609e3..c9105fa27902 100644 --- a/sw/source/uibase/lingu/olmenu.cxx +++ b/sw/source/uibase/lingu/olmenu.cxx @@ -242,12 +242,13 @@ SwSpellPopup::SwSpellPopup( bool bUseImagesInMenus = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus(); m_nCheckedLanguage = LANGUAGE_NONE; + css::uno::Sequence< OUString > aSuggestions; if (m_xSpellAlt.is()) { m_nCheckedLanguage = LanguageTag( m_xSpellAlt->getLocale() ).getLanguageType(); - m_aSuggestions = m_xSpellAlt->getAlternatives(); + aSuggestions = m_xSpellAlt->getAlternatives(); } - sal_Int16 nStringCount = static_cast< sal_Int16 >( m_aSuggestions.getLength() ); + sal_Int16 nStringCount = static_cast< sal_Int16 >( aSuggestions.getLength() ); SvtLinguConfig aCfg; @@ -275,7 +276,7 @@ SwSpellPopup::SwSpellPopup( sal_uInt16 nItemId = MN_SUGGESTION_START; for (sal_uInt16 i = 0; i < nStringCount; ++i) { - const OUString aEntry = m_aSuggestions[ i ]; + const OUString aEntry = aSuggestions[ i ]; m_xPopupMenu->InsertItem(nItemId, aEntry, MenuItemBits::NONE, OString(), i); m_xPopupMenu->SetHelpId(nItemId, HID_LINGU_REPLACE); if (!aSuggestionImageUrl.isEmpty()) @@ -445,7 +446,6 @@ SwSpellPopup::SwSpellPopup( , m_nRedlinePrevId(m_xPopupMenu->GetItemId("prev")) , m_pSh(pWrtSh) , m_xGrammarResult(rResult) - , m_aSuggestions(rSuggestions) , m_sExplanationLink() , m_bGrammarResults(true) { @@ -483,7 +483,7 @@ SwSpellPopup::SwSpellPopup( m_xPopupMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics); m_xPopupMenu->InsertSeparator(OString(), nPos++); - sal_Int32 nStringCount = m_aSuggestions.getLength(); + sal_Int32 nStringCount = rSuggestions.getLength(); if ( nStringCount ) // suggestions available... { Image aImage; @@ -502,7 +502,7 @@ SwSpellPopup::SwSpellPopup( sal_uInt16 nItemId = MN_SUGGESTION_START; for (sal_Int32 i = 0; i < nStringCount; ++i) { - const OUString aEntry = m_aSuggestions[ i ]; + const OUString aEntry = rSuggestions[ i ]; m_xPopupMenu->InsertItem(nItemId, aEntry, MenuItemBits::NONE, OString(), nPos++); m_xPopupMenu->SetHelpId(nItemId, HID_LINGU_REPLACE); if (!aSuggestionImageUrl.isEmpty()) @@ -644,15 +644,22 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) if ((MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) || (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)) { - sal_Int32 nAltIdx = (MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ? - nId - MN_SUGGESTION_START : nId - MN_AUTOCORR_START; - OSL_ENSURE( 0 <= nAltIdx && nAltIdx < m_aSuggestions.getLength(), "index out of range" ); - if (0 <= nAltIdx && nAltIdx < m_aSuggestions.getLength() && (m_bGrammarResults || m_xSpellAlt.is())) + OUString sNewWord; + if (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END) + { + PopupMenu* pMenu = m_xPopupMenu->GetPopupMenu(m_nCorrectMenuId); + assert(pMenu); + sNewWord = pMenu->GetItemText(nId); + } + else + sNewWord = m_xPopupMenu->GetItemText(nId); + + if (m_bGrammarResults || m_xSpellAlt.is()) { bool bOldIns = m_pSh->IsInsMode(); m_pSh->SetInsMode(); - OUString aTmp( m_aSuggestions[ nAltIdx ] ); + OUString aTmp( sNewWord ); OUString aOrig( m_bGrammarResults ? OUString() : m_xSpellAlt->getWord() ); // if original word has a trailing . (likely the end of a sentence) @@ -688,11 +695,10 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect(); OUString aOrigWord( m_bGrammarResults ? OUString() : m_xSpellAlt->getWord() ) ; - OUString aNewWord( m_aSuggestions[ nAltIdx ] ); - SvxPrepareAutoCorrect( aOrigWord, aNewWord ); + SvxPrepareAutoCorrect( aOrigWord, sNewWord ); if (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END) - pACorr->PutText( aOrigWord, aNewWord, m_nCheckedLanguage ); + pACorr->PutText( aOrigWord, sNewWord, m_nCheckedLanguage ); /* #102505# EndAction/EndUndo moved down since insertion of temporary auto correction is now undoable two and |