lokdialog: Tunnel the spell-checking context menu with recommendations.
[LibreOffice.git] / sw / source / uibase / inc / olmenu.hxx
blobd37eb2edbfb5c50155ff452216cabda749050d3d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_OLMENU_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_OLMENU_HXX
22 #include <com/sun/star/linguistic2/XDictionary.hpp>
23 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
24 #include <com/sun/star/linguistic2/ProofreadingResult.hpp>
25 #include <com/sun/star/uno/Sequence.h>
27 #include <rtl/ustring.hxx>
28 #include <vcl/builder.hxx>
29 #include <vcl/image.hxx>
30 #include <vcl/menu.hxx>
32 #include <map>
33 #include <vector>
35 //! Don't change these values. You may break context menu modifying extensions!
36 #define MN_IGNORE_SELECTION 201
37 #define MN_SHORT_COMMENT 208
38 #define MN_EXPLANATION_LINK 209
40 // id range for dictionaries sub menu
41 #define MN_DICTIONARIES_START 300
42 #define MN_DICTIONARIES_END (MN_DICTIONARIES_START + 99)
44 // id range for suggestions from spell and grammar checker
45 #define MN_SUGGESTION_START 500
46 #define MN_SUGGESTION_END (MN_SUGGESTION_START + MN_MAX_NUM_LANG)
48 // id range for auto correction sub menu entries
49 #define MN_AUTOCORR_START 700
50 #define MN_AUTOCORR_END (MN_AUTOCORR_START + MN_MAX_NUM_LANG)
52 // max number of language entries sub menus
53 #define MN_MAX_NUM_LANG 99
55 #define MN_NONE_OFFSET (MN_MAX_NUM_LANG + 1)
56 #define MN_RESET_OFFSET (MN_MAX_NUM_LANG + 2)
57 #define MN_MORE_OFFSET (MN_MAX_NUM_LANG + 3)
59 // id range for 'set language for selection' sub menu entries
60 #define MN_SET_LANGUAGE_SELECTION_START 900
61 #define MN_SET_LANGUAGE_SELECTION_END (MN_SET_LANGUAGE_SELECTION_START + MN_MAX_NUM_LANG)
62 #define MN_SET_SELECTION_NONE (MN_SET_LANGUAGE_SELECTION_START + MN_NONE_OFFSET)
63 #define MN_SET_SELECTION_RESET (MN_SET_LANGUAGE_SELECTION_START + MN_RESET_OFFSET)
64 #define MN_SET_SELECTION_MORE (MN_SET_LANGUAGE_SELECTION_START + MN_MORE_OFFSET)
66 // id range for 'set language for paragraph' sub menu entries
67 #define MN_SET_LANGUAGE_PARAGRAPH_START 1100
68 #define MN_SET_LANGUAGE_PARAGRAPH_END (MN_SET_LANGUAGE_PARAGRAPH_START + MN_MAX_NUM_LANG)
69 #define MN_SET_PARA_NONE (MN_SET_LANGUAGE_PARAGRAPH_START + MN_NONE_OFFSET)
70 #define MN_SET_PARA_RESET (MN_SET_LANGUAGE_PARAGRAPH_START + MN_RESET_OFFSET)
71 #define MN_SET_PARA_MORE (MN_SET_LANGUAGE_PARAGRAPH_START + MN_MORE_OFFSET)
73 class SwWrtShell;
75 class SW_DLLPUBLIC SwSpellPopup
77 VclBuilder m_aBuilder;
78 VclPtr<PopupMenu> m_xPopupMenu;
79 sal_uInt16 m_nIgnoreWordId;
80 sal_uInt16 m_nAddMenuId;
81 sal_uInt16 m_nAddId;
82 sal_uInt16 m_nSpellDialogId;
83 sal_uInt16 m_nCorrectMenuId;
84 sal_uInt16 m_nCorrectDialogId;
85 sal_uInt16 m_nLangSelectionMenuId;
86 sal_uInt16 m_nLangParaMenuId;
87 sal_uInt16 m_nRedlineAcceptId;
88 sal_uInt16 m_nRedlineRejectId;
89 sal_uInt16 m_nRedlineNextId;
90 sal_uInt16 m_nRedlinePrevId;
91 SwWrtShell* m_pSh;
92 css::uno::Sequence< css::uno::Reference< css::linguistic2::XDictionary > > m_aDics;
93 css::uno::Reference< css::linguistic2::XSpellAlternatives > m_xSpellAlt;
95 css::linguistic2::ProofreadingResult m_xGrammarResult;
96 sal_Int32 m_nGrammarError;
98 css::uno::Sequence< OUString > m_aSuggestions;
99 OUString m_sExplanationLink;
101 LanguageType m_nCheckedLanguage;
102 LanguageType m_nGuessLangWord;
103 LanguageType m_nGuessLangPara;
105 std::map< sal_Int16, OUString > m_aLangTable_Text;
106 std::map< sal_Int16, OUString > m_aLangTable_Paragraph;
108 OUString m_aDicNameSingle;
109 bool m_bGrammarResults; // show grammar results? Or show spellcheck results?
111 static void fillLangPopupMenu( PopupMenu *pPopupMenu, sal_uInt16 nLangStart,
112 const css::uno::Sequence< OUString >& aSeq, SwWrtShell* pWrtSh,
113 std::map< sal_Int16, OUString > &rLangTable );
115 /// Checks if any of the redline menu items should be hidden.
116 void checkRedline();
118 public:
119 SwSpellPopup( SwWrtShell *pWrtSh,
120 const css::uno::Reference< css::linguistic2::XSpellAlternatives > &xAlt,
121 const OUString & rParaText );
123 SwSpellPopup( SwWrtShell *pWrtSh,
124 const css::linguistic2::ProofreadingResult &rResult,
125 sal_Int32 nErrorInResult,
126 const css::uno::Sequence< OUString > &rSuggestions,
127 const OUString & rParaText );
129 ~SwSpellPopup();
131 PopupMenu& GetMenu()
133 return *m_xPopupMenu.get();
136 void Execute( const tools::Rectangle& rPopupPos, vcl::Window* pWin );
137 void Execute( sal_uInt16 nId );
141 #endif
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */