sw/source/uibase/lingu/olmenu.cxx |   21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

New commits:
commit 9c55d9be304f0f6eb88488c46031a17e1ccac1eb
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Dec 20 12:52:57 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Jan 24 13:46:52 2025 +0100

    expose Add to Dictionary menu entries to kit
    
    Change-Id: If9a072afef339110a4d44366b1f2e515e6feb55a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178917
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    (cherry picked from commit 2ce644117859138121869ff6146822c153ea60f0)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180692
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/source/uibase/lingu/olmenu.cxx 
b/sw/source/uibase/lingu/olmenu.cxx
index acf36d89a113..b501bd45fc14 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -361,6 +361,7 @@ SwSpellPopup::SwSpellPopup(
             }
         }
     }
+
     m_xPopupMenu->EnableItem(m_nAddMenuId, (nItemId - MN_DICTIONARIES_START) > 
1);
     m_xPopupMenu->EnableItem(m_nAddId, (nItemId - MN_DICTIONARIES_START) == 1);
 
@@ -595,9 +596,8 @@ void SwSpellPopup::InitItemCommands(const 
css::uno::Sequence< OUString >& aSugge
         m_xPopupMenu->SetItemCommand(nItemId, sCommandString);
     }
 
-    PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nLangSelectionMenuId);
     m_xPopupMenu->SetItemCommand(m_nLangSelectionMenuId, 
u".uno:SetSelectionLanguageMenu"_ustr);
-    if(pMenu)
+    if (PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nLangSelectionMenuId))
     {
         for (const auto& item : m_aLangTable_Text)
         {
@@ -610,9 +610,8 @@ void SwSpellPopup::InitItemCommands(const 
css::uno::Sequence< OUString >& aSugge
         pMenu->SetItemCommand(MN_SET_SELECTION_MORE, 
u".uno:FontDialog?Page:string=font"_ustr);
     }
 
-    pMenu = m_xPopupMenu->GetPopupMenu(m_nLangParaMenuId);
     m_xPopupMenu->SetItemCommand(m_nLangParaMenuId, 
u".uno:SetParagraphLanguageMenu"_ustr);
-    if(pMenu)
+    if (PopupMenu* pMenu = m_xPopupMenu->GetPopupMenu(m_nLangParaMenuId))
     {
         for (const auto& item : m_aLangTable_Paragraph)
         {
@@ -624,6 +623,20 @@ void SwSpellPopup::InitItemCommands(const 
css::uno::Sequence< OUString >& aSugge
         pMenu->SetItemCommand(MN_SET_PARA_RESET, 
u".uno:LanguageStatus?Language:string=Paragraph_RESET_LANGUAGES"_ustr);
         pMenu->SetItemCommand(MN_SET_PARA_MORE, 
u".uno:FontDialogForParagraph"_ustr);
     }
+
+    OUString sCommandString = ".uno:AddToWordbook?Wordbook:string=" + 
m_aDicNameSingle;
+    m_xPopupMenu->SetItemCommand(m_nAddId, sCommandString);
+    m_xPopupMenu->SetItemCommand(m_nAddMenuId, sCommandString);
+    if (PopupMenu *pMenu = m_xPopupMenu->GetPopupMenu(m_nAddMenuId))
+    {
+        for (sal_uInt16 i = 0, nItemCount = pMenu->GetItemCount(); i < 
nItemCount; ++i)
+        {
+            sal_uInt16 nItemId = pMenu->GetItemId(i);
+            OUString sDict = pMenu->GetItemText(nItemId);
+            sCommandString = ".uno:AddToWordbook?Wordbook:string=" + sDict;
+            pMenu->SetItemCommand(nItemId, sCommandString);
+        }
+    }
 }
 
 void SwSpellPopup::checkRedline()

Reply via email to