xref: /trunk/main/sw/source/ui/lingu/olmenu.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "SwRewriter.hxx"
32*cdf0e10cSrcweir #include "chrdlg.hrc"
33*cdf0e10cSrcweir #include "cmdid.h"
34*cdf0e10cSrcweir #include "comcore.hrc"
35*cdf0e10cSrcweir #include "crsskip.hxx"
36*cdf0e10cSrcweir #include "doc.hxx"
37*cdf0e10cSrcweir #include "docsh.hxx"        //CheckSpellChanges
38*cdf0e10cSrcweir #include "edtwin.hxx"
39*cdf0e10cSrcweir #include "helpid.h"
40*cdf0e10cSrcweir #include "hintids.hxx"
41*cdf0e10cSrcweir #include "langhelper.hxx"
42*cdf0e10cSrcweir #include "ndtxt.hxx"
43*cdf0e10cSrcweir #include "olmenu.hrc"
44*cdf0e10cSrcweir #include "olmenu.hxx"
45*cdf0e10cSrcweir #include "swabstdlg.hxx"
46*cdf0e10cSrcweir #include "swmodule.hxx"
47*cdf0e10cSrcweir #include "swtypes.hxx"
48*cdf0e10cSrcweir #include "swundo.hxx"
49*cdf0e10cSrcweir #include "uitool.hxx"
50*cdf0e10cSrcweir #include "unomid.h"
51*cdf0e10cSrcweir #include "view.hxx"
52*cdf0e10cSrcweir #include "viewopt.hxx"
53*cdf0e10cSrcweir #include "wrtsh.hxx"
54*cdf0e10cSrcweir #include "wview.hxx"
55*cdf0e10cSrcweir #include "swabstdlg.hxx"
56*cdf0e10cSrcweir #include "chrdlg.hrc"
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir #ifndef _SVSTDARR_HXX
60*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
61*cdf0e10cSrcweir #include <svl/svstdarr.hxx>
62*cdf0e10cSrcweir #endif
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
65*cdf0e10cSrcweir #include <editeng/acorrcfg.hxx>
66*cdf0e10cSrcweir #include <editeng/svxacorr.hxx>
67*cdf0e10cSrcweir #include <editeng/langitem.hxx>
68*cdf0e10cSrcweir #include <editeng/splwrap.hxx>
69*cdf0e10cSrcweir #include <editeng/brshitem.hxx>
70*cdf0e10cSrcweir #include <editeng/unolingu.hxx>
71*cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
72*cdf0e10cSrcweir #include <linguistic/lngprops.hxx>
73*cdf0e10cSrcweir #include <linguistic/misc.hxx>
74*cdf0e10cSrcweir #include <osl/file.hxx>
75*cdf0e10cSrcweir #include <rtl/string.hxx>
76*cdf0e10cSrcweir #include <svtools/filter.hxx>
77*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
78*cdf0e10cSrcweir #include <sfx2/imagemgr.hxx>
79*cdf0e10cSrcweir #include <sfx2/request.hxx>
80*cdf0e10cSrcweir #include <sfx2/sfxdlg.hxx>
81*cdf0e10cSrcweir #include <svl/itemset.hxx>
82*cdf0e10cSrcweir #include <svl/languageoptions.hxx>
83*cdf0e10cSrcweir #include <svl/stritem.hxx>
84*cdf0e10cSrcweir #include <svtools/filter.hxx>
85*cdf0e10cSrcweir #include <svtools/langtab.hxx>
86*cdf0e10cSrcweir #include <svx/dlgutil.hxx>
87*cdf0e10cSrcweir #include <unotools/lingucfg.hxx>
88*cdf0e10cSrcweir #include <unotools/linguprops.hxx>
89*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
90*cdf0e10cSrcweir #include <vcl/settings.hxx>
91*cdf0e10cSrcweir #include <vcl/svapp.hxx>
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir #include <map>
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
96*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
97*cdf0e10cSrcweir #include <com/sun/star/document/XDocumentLanguages.hpp>
98*cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp>
99*cdf0e10cSrcweir #include <com/sun/star/frame/XStorable.hpp>
100*cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hpp>
101*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
102*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
103*cdf0e10cSrcweir #include <com/sun/star/linguistic2/SingleProofreadingError.hpp>
104*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
105*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
106*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir using namespace ::com::sun::star;
110*cdf0e10cSrcweir using ::rtl::OUString;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir extern void lcl_CharDialog( SwWrtShell &rWrtSh, sal_Bool bUseDialog, sal_uInt16 nSlot,const SfxItemSet *pArgs, SfxRequest *pReq );
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir /*--------------------------------------------------------------------------
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir ---------------------------------------------------------------------------*/
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir // tries to determine the language of 'rText'
120*cdf0e10cSrcweir //
121*cdf0e10cSrcweir LanguageType lcl_CheckLanguage(
122*cdf0e10cSrcweir     const OUString &rText,
123*cdf0e10cSrcweir     uno::Reference< linguistic2::XSpellChecker1 > xSpell,
124*cdf0e10cSrcweir     uno::Reference< linguistic2::XLanguageGuessing > xLangGuess,
125*cdf0e10cSrcweir     sal_Bool bIsParaText )
126*cdf0e10cSrcweir {
127*cdf0e10cSrcweir     LanguageType  nLang = LANGUAGE_NONE;
128*cdf0e10cSrcweir     if (bIsParaText)    // check longer texts with language-guessing...
129*cdf0e10cSrcweir     {
130*cdf0e10cSrcweir         if (!xLangGuess.is())
131*cdf0e10cSrcweir             return nLang;
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir         lang::Locale aLocale( xLangGuess->guessPrimaryLanguage( rText, 0, rText.getLength()) );
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir         // get language as from "Tools/Options - Language Settings - Languages: Locale setting"
136*cdf0e10cSrcweir         LanguageType nTmpLang = Application::GetSettings().GetLanguage();
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir         // if the result from language guessing does not provide a 'Country' part
139*cdf0e10cSrcweir         // try to get it by looking up the locale setting of the office.
140*cdf0e10cSrcweir         if (aLocale.Country.getLength() == 0)
141*cdf0e10cSrcweir         {
142*cdf0e10cSrcweir             lang::Locale aTmpLocale = SvxCreateLocale( nTmpLang );
143*cdf0e10cSrcweir             if (aTmpLocale.Language == aLocale.Language)
144*cdf0e10cSrcweir                 nLang = nTmpLang;
145*cdf0e10cSrcweir         }
146*cdf0e10cSrcweir         if (nLang == LANGUAGE_NONE) // language not found by looking up the system language...
147*cdf0e10cSrcweir             nLang = MsLangId::convertLocaleToLanguageWithFallback( aLocale );
148*cdf0e10cSrcweir         if (nLang == LANGUAGE_SYSTEM)
149*cdf0e10cSrcweir             nLang = nTmpLang;
150*cdf0e10cSrcweir         if (nLang == LANGUAGE_DONTKNOW)
151*cdf0e10cSrcweir             nLang = LANGUAGE_NONE;
152*cdf0e10cSrcweir     }
153*cdf0e10cSrcweir     else    // check single word
154*cdf0e10cSrcweir     {
155*cdf0e10cSrcweir             if (!xSpell.is())
156*cdf0e10cSrcweir             return nLang;
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir         //
159*cdf0e10cSrcweir         // build list of languages to check
160*cdf0e10cSrcweir         //
161*cdf0e10cSrcweir         LanguageType aLangList[4];
162*cdf0e10cSrcweir         const AllSettings& rSettings  = Application::GetSettings();
163*cdf0e10cSrcweir         SvtLinguOptions aLinguOpt;
164*cdf0e10cSrcweir         SvtLinguConfig().GetOptions( aLinguOpt );
165*cdf0e10cSrcweir         // The default document language from "Tools/Options - Language Settings - Languages: Western"
166*cdf0e10cSrcweir         aLangList[0] = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN);
167*cdf0e10cSrcweir         // The one from "Tools/Options - Language Settings - Languages: User interface"
168*cdf0e10cSrcweir         aLangList[1] = rSettings.GetUILanguage();
169*cdf0e10cSrcweir         // The one from "Tools/Options - Language Settings - Languages: Locale setting"
170*cdf0e10cSrcweir         aLangList[2] = rSettings.GetLanguage();
171*cdf0e10cSrcweir         // en-US
172*cdf0e10cSrcweir         aLangList[3] = LANGUAGE_ENGLISH_US;
173*cdf0e10cSrcweir #ifdef DEBUG
174*cdf0e10cSrcweir         lang::Locale a0( SvxCreateLocale( aLangList[0] ) );
175*cdf0e10cSrcweir         lang::Locale a1( SvxCreateLocale( aLangList[1] ) );
176*cdf0e10cSrcweir         lang::Locale a2( SvxCreateLocale( aLangList[2] ) );
177*cdf0e10cSrcweir         lang::Locale a3( SvxCreateLocale( aLangList[3] ) );
178*cdf0e10cSrcweir #endif
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir         sal_Int32   nCount = sizeof(aLangList) / sizeof(aLangList[0]);
181*cdf0e10cSrcweir         for (sal_Int32 i = 0;  i < nCount;  i++)
182*cdf0e10cSrcweir         {
183*cdf0e10cSrcweir             sal_Int16 nTmpLang = aLangList[i];
184*cdf0e10cSrcweir             if (nTmpLang != LANGUAGE_NONE  &&  nTmpLang != LANGUAGE_DONTKNOW)
185*cdf0e10cSrcweir             {
186*cdf0e10cSrcweir                 if (xSpell->hasLanguage( nTmpLang ) &&
187*cdf0e10cSrcweir                     xSpell->isValid( rText, nTmpLang, uno::Sequence< beans::PropertyValue >() ))
188*cdf0e10cSrcweir                 {
189*cdf0e10cSrcweir                     nLang = nTmpLang;
190*cdf0e10cSrcweir                     break;
191*cdf0e10cSrcweir                 }
192*cdf0e10cSrcweir             }
193*cdf0e10cSrcweir         }
194*cdf0e10cSrcweir     }
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     return nLang;
197*cdf0e10cSrcweir }
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir /// @returns : the language for the selected text that is set for the
201*cdf0e10cSrcweir ///     specified attribute (script type).
202*cdf0e10cSrcweir ///     If there are more than one languages used LANGUAGE_DONTKNOW will be returned.
203*cdf0e10cSrcweir /// @param nLangWhichId : one of
204*cdf0e10cSrcweir ///     RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
205*cdf0e10cSrcweir /// @returns: the language in use for the selected text.
206*cdf0e10cSrcweir ///     'In use' means the language(s) matching the script type(s) of the
207*cdf0e10cSrcweir ///     selected text. Or in other words, the language a spell checker would use.
208*cdf0e10cSrcweir ///     If there is more than one language LANGUAGE_DONTKNOW will be returned.
209*cdf0e10cSrcweir // check if nScriptType includes the script type associated to nLang
210*cdf0e10cSrcweir inline bool lcl_checkScriptType( sal_Int16 nScriptType, LanguageType nLang )
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir     return 0 != (nScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ));
213*cdf0e10cSrcweir }
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir void SwSpellPopup::fillLangPopupMenu(
216*cdf0e10cSrcweir     PopupMenu *pPopupMenu,
217*cdf0e10cSrcweir     sal_uInt16 nLangItemIdStart,
218*cdf0e10cSrcweir     uno::Sequence< OUString > aSeq,
219*cdf0e10cSrcweir     SwWrtShell* pWrtSh,
220*cdf0e10cSrcweir     std::map< sal_Int16, ::rtl::OUString > &rLangTable )
221*cdf0e10cSrcweir {
222*cdf0e10cSrcweir     if (!pPopupMenu)
223*cdf0e10cSrcweir         return;
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir     SvtLanguageTable    aLanguageTable;
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir     // set of languages to be displayed in the sub menus
228*cdf0e10cSrcweir     std::set< OUString > aLangItems;
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     OUString    aCurLang( aSeq[0] );
231*cdf0e10cSrcweir     sal_uInt16      nScriptType = static_cast< sal_Int16 >(aSeq[1].toInt32());
232*cdf0e10cSrcweir     OUString    aKeyboardLang( aSeq[2] );
233*cdf0e10cSrcweir     OUString    aGuessedTextLang( aSeq[3] );
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     if (aCurLang != OUString() &&
236*cdf0e10cSrcweir         LANGUAGE_DONTKNOW != aLanguageTable.GetType( aCurLang ))
237*cdf0e10cSrcweir         aLangItems.insert( aCurLang );
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir     //2--System
240*cdf0e10cSrcweir     const AllSettings& rAllSettings = Application::GetSettings();
241*cdf0e10cSrcweir     LanguageType rSystemLanguage = rAllSettings.GetLanguage();
242*cdf0e10cSrcweir     if (rSystemLanguage != LANGUAGE_DONTKNOW)
243*cdf0e10cSrcweir     {
244*cdf0e10cSrcweir         if (lcl_checkScriptType( nScriptType, rSystemLanguage ))
245*cdf0e10cSrcweir             aLangItems.insert( aLanguageTable.GetString(rSystemLanguage) );
246*cdf0e10cSrcweir     }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     //3--UI
249*cdf0e10cSrcweir     LanguageType rUILanguage = rAllSettings.GetUILanguage();
250*cdf0e10cSrcweir     if (rUILanguage != LANGUAGE_DONTKNOW)
251*cdf0e10cSrcweir     {
252*cdf0e10cSrcweir         if (lcl_checkScriptType(nScriptType, rUILanguage ))
253*cdf0e10cSrcweir             aLangItems.insert( aLanguageTable.GetString(rUILanguage) );
254*cdf0e10cSrcweir     }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     //4--guessed language
257*cdf0e10cSrcweir     if (aGuessedTextLang.getLength() > 0)
258*cdf0e10cSrcweir     {
259*cdf0e10cSrcweir         if (lcl_checkScriptType(nScriptType, aLanguageTable.GetType(aGuessedTextLang)))
260*cdf0e10cSrcweir             aLangItems.insert( aGuessedTextLang );
261*cdf0e10cSrcweir     }
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir     //5--keyboard language
264*cdf0e10cSrcweir     if (aKeyboardLang.getLength() > 0)
265*cdf0e10cSrcweir     {
266*cdf0e10cSrcweir         if (lcl_checkScriptType(nScriptType, aLanguageTable.GetType(aKeyboardLang)))
267*cdf0e10cSrcweir             aLangItems.insert( aKeyboardLang );
268*cdf0e10cSrcweir     }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir     //6--all languages used in current document
271*cdf0e10cSrcweir     uno::Reference< com::sun::star::frame::XModel > xModel;
272*cdf0e10cSrcweir     uno::Reference< com::sun::star::frame::XController > xController( pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface()->getController(), uno::UNO_QUERY );
273*cdf0e10cSrcweir     if ( xController.is() )
274*cdf0e10cSrcweir         xModel = xController->getModel();
275*cdf0e10cSrcweir     uno::Reference< document::XDocumentLanguages > xDocumentLanguages( xModel, uno::UNO_QUERY );
276*cdf0e10cSrcweir     /*the description of nScriptType flags
277*cdf0e10cSrcweir       LATIN :   0x0001
278*cdf0e10cSrcweir       ASIAN :   0x0002
279*cdf0e10cSrcweir       COMPLEX:  0x0004
280*cdf0e10cSrcweir     */
281*cdf0e10cSrcweir     const sal_Int16 nMaxCount = 7;
282*cdf0e10cSrcweir     if (xDocumentLanguages.is())
283*cdf0e10cSrcweir     {
284*cdf0e10cSrcweir         uno::Sequence< lang::Locale > rLocales( xDocumentLanguages->getDocumentLanguages( nScriptType, nMaxCount ) );
285*cdf0e10cSrcweir         if (rLocales.getLength() > 0)
286*cdf0e10cSrcweir         {
287*cdf0e10cSrcweir             for (sal_uInt16 i = 0; i < rLocales.getLength(); ++i)
288*cdf0e10cSrcweir             {
289*cdf0e10cSrcweir                 if (aLangItems.size() == (size_t)nMaxCount)
290*cdf0e10cSrcweir                     break;
291*cdf0e10cSrcweir                 const lang::Locale& rLocale = rLocales[i];
292*cdf0e10cSrcweir                 if (lcl_checkScriptType( nScriptType, aLanguageTable.GetType( rLocale.Language )))
293*cdf0e10cSrcweir                     aLangItems.insert( rLocale.Language );
294*cdf0e10cSrcweir             }
295*cdf0e10cSrcweir         }
296*cdf0e10cSrcweir     }
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir     sal_uInt16 nItemId = nLangItemIdStart;
300*cdf0e10cSrcweir     const OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*"));  // multiple languages in current selection
301*cdf0e10cSrcweir     const OUString sEmpty;  // 'no language found' from language guessing
302*cdf0e10cSrcweir     std::set< OUString >::const_iterator it;
303*cdf0e10cSrcweir     for (it = aLangItems.begin(); it != aLangItems.end(); ++it)
304*cdf0e10cSrcweir     {
305*cdf0e10cSrcweir         OUString aEntryTxt( *it );
306*cdf0e10cSrcweir         if (aEntryTxt != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) )&&
307*cdf0e10cSrcweir             aEntryTxt != sAsterix &&
308*cdf0e10cSrcweir             aEntryTxt != sEmpty)
309*cdf0e10cSrcweir         {
310*cdf0e10cSrcweir             DBG_ASSERT( nLangItemIdStart <= nItemId && nItemId <= nLangItemIdStart + MN_MAX_NUM_LANG,
311*cdf0e10cSrcweir                     "nItemId outside of expected range!" );
312*cdf0e10cSrcweir             pPopupMenu->InsertItem( nItemId, aEntryTxt, MIB_RADIOCHECK );
313*cdf0e10cSrcweir             if (aEntryTxt == aCurLang)
314*cdf0e10cSrcweir             {
315*cdf0e10cSrcweir                 //make a check mark for the current language
316*cdf0e10cSrcweir                 pPopupMenu->CheckItem( nItemId, sal_True );
317*cdf0e10cSrcweir             }
318*cdf0e10cSrcweir             rLangTable[ nItemId ] = aEntryTxt;
319*cdf0e10cSrcweir             ++nItemId;
320*cdf0e10cSrcweir         }
321*cdf0e10cSrcweir     }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir     pPopupMenu->InsertItem( nLangItemIdStart + MN_NONE_OFFSET,  String(SW_RES( STR_LANGSTATUS_NONE )), MIB_RADIOCHECK );
324*cdf0e10cSrcweir     pPopupMenu->InsertItem( nLangItemIdStart + MN_RESET_OFFSET, String(SW_RES( STR_RESET_TO_DEFAULT_LANGUAGE )), MIB_RADIOCHECK );
325*cdf0e10cSrcweir     pPopupMenu->InsertItem( nLangItemIdStart + MN_MORE_OFFSET,  String(SW_RES( STR_LANGSTATUS_MORE )), MIB_RADIOCHECK );
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir static Image lcl_GetImageFromPngUrl( const OUString &rFileUrl )
330*cdf0e10cSrcweir {
331*cdf0e10cSrcweir     Image aRes;
332*cdf0e10cSrcweir     OUString aTmp;
333*cdf0e10cSrcweir     osl::FileBase::getSystemPathFromFileURL( rFileUrl, aTmp );
334*cdf0e10cSrcweir //    ::rtl::OString aPath = OString( aTmp.getStr(), aTmp.getLength(), osl_getThreadTextEncoding() );
335*cdf0e10cSrcweir #if defined(WNT)
336*cdf0e10cSrcweir //    aTmp = lcl_Win_GetShortPathName( aTmp );
337*cdf0e10cSrcweir #endif
338*cdf0e10cSrcweir     Graphic aGraphic;
339*cdf0e10cSrcweir     const String aFilterName( RTL_CONSTASCII_USTRINGPARAM( IMP_PNG ) );
340*cdf0e10cSrcweir     if( GRFILTER_OK == GraphicFilter::LoadGraphic( aTmp, aFilterName, aGraphic ) )
341*cdf0e10cSrcweir     {
342*cdf0e10cSrcweir         aRes = Image( aGraphic.GetBitmapEx() );
343*cdf0e10cSrcweir     }
344*cdf0e10cSrcweir     return aRes;
345*cdf0e10cSrcweir }
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir OUString RetrieveLabelFromCommand( const OUString& aCmdURL )
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir     OUString aLabel;
351*cdf0e10cSrcweir     if ( aCmdURL.getLength() )
352*cdf0e10cSrcweir     {
353*cdf0e10cSrcweir         try
354*cdf0e10cSrcweir         {
355*cdf0e10cSrcweir             uno::Reference< container::XNameAccess > xNameAccess( ::comphelper::getProcessServiceFactory()->createInstance( OUString::createFromAscii("com.sun.star.frame.UICommandDescription") ), uno::UNO_QUERY );
356*cdf0e10cSrcweir             if ( xNameAccess.is() )
357*cdf0e10cSrcweir             {
358*cdf0e10cSrcweir                 uno::Reference< container::XNameAccess > xUICommandLabels;
359*cdf0e10cSrcweir                 const OUString aModule( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) );
360*cdf0e10cSrcweir                 uno::Any a = xNameAccess->getByName( aModule );
361*cdf0e10cSrcweir                 uno::Reference< container::XNameAccess > xUICommands;
362*cdf0e10cSrcweir                 a >>= xUICommandLabels;
363*cdf0e10cSrcweir                 OUString aStr;
364*cdf0e10cSrcweir                 uno::Sequence< beans::PropertyValue > aPropSeq;
365*cdf0e10cSrcweir                 a = xUICommandLabels->getByName( aCmdURL );
366*cdf0e10cSrcweir                 if ( a >>= aPropSeq )
367*cdf0e10cSrcweir                 {
368*cdf0e10cSrcweir                     for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
369*cdf0e10cSrcweir                     {
370*cdf0e10cSrcweir                         if ( aPropSeq[i].Name.equalsAscii( "Name" ))
371*cdf0e10cSrcweir                         {
372*cdf0e10cSrcweir                             aPropSeq[i].Value >>= aStr;
373*cdf0e10cSrcweir                             break;
374*cdf0e10cSrcweir                         }
375*cdf0e10cSrcweir                     }
376*cdf0e10cSrcweir                 }
377*cdf0e10cSrcweir                 aLabel = aStr;
378*cdf0e10cSrcweir             }
379*cdf0e10cSrcweir         }
380*cdf0e10cSrcweir         catch ( uno::Exception& )
381*cdf0e10cSrcweir         {
382*cdf0e10cSrcweir         }
383*cdf0e10cSrcweir     }
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir     return aLabel;
386*cdf0e10cSrcweir }
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir SwSpellPopup::SwSpellPopup(
390*cdf0e10cSrcweir         SwWrtShell* pWrtSh,
391*cdf0e10cSrcweir         const uno::Reference< linguistic2::XSpellAlternatives >  &xAlt,
392*cdf0e10cSrcweir         const String &rParaText ) :
393*cdf0e10cSrcweir PopupMenu( SW_RES(MN_SPELL_POPUP) ),
394*cdf0e10cSrcweir pSh( pWrtSh ),
395*cdf0e10cSrcweir xSpellAlt(xAlt),
396*cdf0e10cSrcweir bGrammarResults(false)
397*cdf0e10cSrcweir {
398*cdf0e10cSrcweir     DBG_ASSERT(xSpellAlt.is(), "no spelling alternatives available");
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir //    CreateAutoMnemonics();
401*cdf0e10cSrcweir     SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS);
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir     nCheckedLanguage = LANGUAGE_NONE;
404*cdf0e10cSrcweir     if (xSpellAlt.is())
405*cdf0e10cSrcweir     {
406*cdf0e10cSrcweir         nCheckedLanguage = SvxLocaleToLanguage( xSpellAlt->getLocale() );
407*cdf0e10cSrcweir         aSuggestions = xSpellAlt->getAlternatives();
408*cdf0e10cSrcweir     }
409*cdf0e10cSrcweir     sal_Int16 nStringCount = static_cast< sal_Int16 >( aSuggestions.getLength() );
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir     SvtLinguConfig aCfg;
412*cdf0e10cSrcweir     const bool bHC = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir     PopupMenu *pMenu = GetPopupMenu(MN_AUTOCORR);
415*cdf0e10cSrcweir     pMenu->SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS);
416*cdf0e10cSrcweir     sal_Bool bEnable = sal_False;
417*cdf0e10cSrcweir     if( nStringCount )
418*cdf0e10cSrcweir     {
419*cdf0e10cSrcweir         Image aImage;
420*cdf0e10cSrcweir         OUString aSuggestionImageUrl;
421*cdf0e10cSrcweir         uno::Reference< container::XNamed > xNamed( xSpellAlt, uno::UNO_QUERY );
422*cdf0e10cSrcweir         if (xNamed.is())
423*cdf0e10cSrcweir         {
424*cdf0e10cSrcweir             aSuggestionImageUrl = aCfg.GetSpellAndGrammarContextSuggestionImage( xNamed->getName(), bHC );
425*cdf0e10cSrcweir             aImage = Image( lcl_GetImageFromPngUrl( aSuggestionImageUrl ) );
426*cdf0e10cSrcweir         }
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir         InsertSeparator(0);
429*cdf0e10cSrcweir         bEnable = sal_True;
430*cdf0e10cSrcweir         sal_uInt16 nAutoCorrItemId  = MN_AUTOCORR_START;
431*cdf0e10cSrcweir         sal_uInt16 nItemId          = MN_SUGGESTION_START;
432*cdf0e10cSrcweir         for (sal_uInt16 i = 0; i < nStringCount; ++i)
433*cdf0e10cSrcweir         {
434*cdf0e10cSrcweir             const String aEntry = aSuggestions[ i ];
435*cdf0e10cSrcweir             InsertItem( nItemId, aEntry, 0, i );
436*cdf0e10cSrcweir             SetHelpId( nItemId, HID_LINGU_REPLACE);
437*cdf0e10cSrcweir             if (aSuggestionImageUrl.getLength() > 0)
438*cdf0e10cSrcweir                 SetItemImage( nItemId, aImage );
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir             pMenu->InsertItem( nAutoCorrItemId, aEntry );
441*cdf0e10cSrcweir             pMenu->SetHelpId( nAutoCorrItemId, HID_LINGU_AUTOCORR);
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir             ++nAutoCorrItemId;
444*cdf0e10cSrcweir             ++nItemId;
445*cdf0e10cSrcweir         }
446*cdf0e10cSrcweir     }
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir     OUString aIgnoreSelection( String( SW_RES( STR_IGNORE_SELECTION ) ) );
449*cdf0e10cSrcweir     OUString aSpellingAndGrammar = RetrieveLabelFromCommand( C2U(".uno:SpellingAndGrammarDialog") );
450*cdf0e10cSrcweir     SetItemText( MN_SPELLING_DLG, aSpellingAndGrammar );
451*cdf0e10cSrcweir     sal_uInt16 nItemPos = GetItemPos( MN_IGNORE_WORD );
452*cdf0e10cSrcweir     InsertItem( MN_IGNORE_SELECTION, aIgnoreSelection, 0, nItemPos );
453*cdf0e10cSrcweir     SetHelpId( MN_IGNORE_SELECTION, HID_LINGU_IGNORE_SELECTION);
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir     EnableItem( MN_AUTOCORR, bEnable );
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir     uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser();
458*cdf0e10cSrcweir     nGuessLangWord = LANGUAGE_NONE;
459*cdf0e10cSrcweir     nGuessLangPara = LANGUAGE_NONE;
460*cdf0e10cSrcweir     if (xSpellAlt.is() && xLG.is())
461*cdf0e10cSrcweir     {
462*cdf0e10cSrcweir         nGuessLangWord = lcl_CheckLanguage( xSpellAlt->getWord(), ::GetSpellChecker(), xLG, sal_False );
463*cdf0e10cSrcweir         nGuessLangPara = lcl_CheckLanguage( rParaText, ::GetSpellChecker(), xLG, sal_True );
464*cdf0e10cSrcweir     }
465*cdf0e10cSrcweir     if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
466*cdf0e10cSrcweir     {
467*cdf0e10cSrcweir         // make sure LANGUAGE_NONE gets not used as menu entry
468*cdf0e10cSrcweir         if (nGuessLangWord == LANGUAGE_NONE)
469*cdf0e10cSrcweir             nGuessLangWord = nGuessLangPara;
470*cdf0e10cSrcweir         if (nGuessLangPara == LANGUAGE_NONE)
471*cdf0e10cSrcweir             nGuessLangPara = nGuessLangWord;
472*cdf0e10cSrcweir     }
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir     pMenu = GetPopupMenu(MN_ADD_TO_DIC);
475*cdf0e10cSrcweir //    pMenu->CreateAutoMnemonics();
476*cdf0e10cSrcweir     pMenu->SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS);     //! necessary to retrieve the correct dictionary name in 'Execute' below
477*cdf0e10cSrcweir     bEnable = sal_False;    // enable MN_ADD_TO_DIC?
478*cdf0e10cSrcweir     uno::Reference< linguistic2::XDictionaryList >    xDicList( SvxGetDictionaryList() );
479*cdf0e10cSrcweir     if (xDicList.is())
480*cdf0e10cSrcweir     {
481*cdf0e10cSrcweir         // add the default positive dictionary to dic-list (if not already done).
482*cdf0e10cSrcweir         // This is to ensure that there is at least one dictionary to which
483*cdf0e10cSrcweir         // words could be added.
484*cdf0e10cSrcweir         uno::Reference< linguistic2::XDictionary >  xDic( SvxGetOrCreatePosDic( xDicList ) );
485*cdf0e10cSrcweir         if (xDic.is())
486*cdf0e10cSrcweir             xDic->setActive( sal_True );
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir         aDics = xDicList->getDictionaries();
489*cdf0e10cSrcweir         const uno::Reference< linguistic2::XDictionary >  *pDic = aDics.getConstArray();
490*cdf0e10cSrcweir         sal_uInt16 nDicCount = static_cast< sal_uInt16 >(aDics.getLength());
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir         sal_uInt16 nItemId = MN_DICTIONARIES_START;
493*cdf0e10cSrcweir         for( sal_uInt16 i = 0; i < nDicCount; i++ )
494*cdf0e10cSrcweir         {
495*cdf0e10cSrcweir             uno::Reference< linguistic2::XDictionary >  xDicTmp( pDic[i], uno::UNO_QUERY );
496*cdf0e10cSrcweir             if (!xDicTmp.is() || SvxGetIgnoreAllList() == xDicTmp)
497*cdf0e10cSrcweir                 continue;
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir             uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY );
500*cdf0e10cSrcweir             LanguageType nActLanguage = SvxLocaleToLanguage( xDicTmp->getLocale() );
501*cdf0e10cSrcweir             if( xDicTmp->isActive()
502*cdf0e10cSrcweir                 &&  xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
503*cdf0e10cSrcweir                 && (nCheckedLanguage == nActLanguage || LANGUAGE_NONE == nActLanguage )
504*cdf0e10cSrcweir                 && (!xStor.is() || !xStor->isReadonly()) )
505*cdf0e10cSrcweir             {
506*cdf0e10cSrcweir                 // the extra 1 is because of the (possible) external
507*cdf0e10cSrcweir                 // linguistic entry above
508*cdf0e10cSrcweir                 pMenu->InsertItem( nItemId, xDicTmp->getName() );
509*cdf0e10cSrcweir                 bEnable = sal_True;
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir                 uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
512*cdf0e10cSrcweir                 if (xSvcInfo.is())
513*cdf0e10cSrcweir                 {
514*cdf0e10cSrcweir                     OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage(
515*cdf0e10cSrcweir                             xSvcInfo->getImplementationName(), bHC) );
516*cdf0e10cSrcweir                     if (aDictionaryImageUrl.getLength() > 0)
517*cdf0e10cSrcweir                     {
518*cdf0e10cSrcweir                         Image aImage( lcl_GetImageFromPngUrl( aDictionaryImageUrl ) );
519*cdf0e10cSrcweir                         pMenu->SetItemImage( nItemId, aImage );
520*cdf0e10cSrcweir                     }
521*cdf0e10cSrcweir                 }
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir                 ++nItemId;
524*cdf0e10cSrcweir             }
525*cdf0e10cSrcweir         }
526*cdf0e10cSrcweir     }
527*cdf0e10cSrcweir     EnableItem( MN_ADD_TO_DIC, bEnable );
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir     //ADD NEW LANGUAGE MENU ITEM
530*cdf0e10cSrcweir     ///////////////////////////////////////////////////////////////////////////
531*cdf0e10cSrcweir     String aScriptTypesInUse( String::CreateFromInt32( pWrtSh->GetScriptType() ) );
532*cdf0e10cSrcweir     SvtLanguageTable aLanguageTable;
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir     // get keyboard language
535*cdf0e10cSrcweir     String aKeyboardLang;
536*cdf0e10cSrcweir     LanguageType nLang = LANGUAGE_DONTKNOW;
537*cdf0e10cSrcweir     SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
538*cdf0e10cSrcweir     nLang = rEditWin.GetInputLanguage();
539*cdf0e10cSrcweir     if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
540*cdf0e10cSrcweir         aKeyboardLang = aLanguageTable.GetString( nLang );
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir     // get the language that is in use
543*cdf0e10cSrcweir     const String aMultipleLanguages = String::CreateFromAscii("*");
544*cdf0e10cSrcweir     String aCurrentLang = aMultipleLanguages;
545*cdf0e10cSrcweir     nLang = SwLangHelper::GetCurrentLanguage( *pWrtSh );
546*cdf0e10cSrcweir     if (nLang != LANGUAGE_DONTKNOW)
547*cdf0e10cSrcweir         aCurrentLang = aLanguageTable.GetString( nLang );
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir     // build sequence for status value
550*cdf0e10cSrcweir     uno::Sequence< OUString > aSeq( 4 );
551*cdf0e10cSrcweir     aSeq[0] = aCurrentLang;
552*cdf0e10cSrcweir     aSeq[1] = aScriptTypesInUse;
553*cdf0e10cSrcweir     aSeq[2] = aKeyboardLang;
554*cdf0e10cSrcweir     aSeq[3] = aLanguageTable.GetString(nGuessLangWord);
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir     pMenu = GetPopupMenu(MN_SET_LANGUAGE_SELECTION);
557*cdf0e10cSrcweir     fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_SELECTION_START, aSeq, pWrtSh, aLangTable_Text );
558*cdf0e10cSrcweir     EnableItem( MN_SET_LANGUAGE_SELECTION, true );
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir     pMenu = GetPopupMenu(MN_SET_LANGUAGE_PARAGRAPH);
561*cdf0e10cSrcweir     fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_PARAGRAPH_START, aSeq, pWrtSh, aLangTable_Paragraph );
562*cdf0e10cSrcweir     EnableItem( MN_SET_LANGUAGE_PARAGRAPH, true );
563*cdf0e10cSrcweir /*
564*cdf0e10cSrcweir     pMenu = GetPopupMenu(MN_SET_LANGUAGE_ALL_TEXT);
565*cdf0e10cSrcweir     fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_ALL_TEXT_START, aSeq, pWrtSh, aLangTable_Document );
566*cdf0e10cSrcweir     EnableItem( MN_SET_LANGUAGE_ALL_TEXT, true );
567*cdf0e10cSrcweir */
568*cdf0e10cSrcweir     uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface();
569*cdf0e10cSrcweir     Image rImg = ::GetImage( xFrame,
570*cdf0e10cSrcweir             OUString::createFromAscii(".uno:SpellingAndGrammarDialog"), sal_False,
571*cdf0e10cSrcweir             Application::GetSettings().GetStyleSettings().GetHighContrastMode() );
572*cdf0e10cSrcweir     SetItemImage( MN_SPELLING_DLG, rImg );
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir     //////////////////////////////////////////////////////////////////////////////////
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir     RemoveDisabledEntries( sal_True, sal_True );
577*cdf0e10cSrcweir }
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir /*--------------------------------------------------------------------------
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir ---------------------------------------------------------------------------*/
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir SwSpellPopup::SwSpellPopup(
584*cdf0e10cSrcweir     SwWrtShell *pWrtSh,
585*cdf0e10cSrcweir     const linguistic2::ProofreadingResult &rResult,
586*cdf0e10cSrcweir     sal_Int32 nErrorInResult,
587*cdf0e10cSrcweir     const uno::Sequence< OUString > &rSuggestions,
588*cdf0e10cSrcweir     const String &rParaText ) :
589*cdf0e10cSrcweir PopupMenu( SW_RES(MN_SPELL_POPUP) ),
590*cdf0e10cSrcweir pSh( pWrtSh ),
591*cdf0e10cSrcweir aSuggestions( rSuggestions ),
592*cdf0e10cSrcweir bGrammarResults( true ),
593*cdf0e10cSrcweir aInfo16( SW_RES(IMG_INFO_16) )
594*cdf0e10cSrcweir {
595*cdf0e10cSrcweir     nCheckedLanguage = SvxLocaleToLanguage( rResult.aLocale );
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir     sal_uInt16 nPos = 0;
598*cdf0e10cSrcweir     OUString aMessageText( rResult.aErrors[ nErrorInResult ].aShortComment );
599*cdf0e10cSrcweir     InsertSeparator( nPos++ );
600*cdf0e10cSrcweir     InsertItem( MN_SHORT_COMMENT, aMessageText, MIB_NOSELECT, nPos++ );
601*cdf0e10cSrcweir     SetItemImage( MN_SHORT_COMMENT, aInfo16 );
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir //    CreateAutoMnemonics();
604*cdf0e10cSrcweir     SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS);
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir     InsertSeparator( nPos++ );
607*cdf0e10cSrcweir     sal_Int32 nStringCount = aSuggestions.getLength();
608*cdf0e10cSrcweir     if ( nStringCount )     // suggestions available...
609*cdf0e10cSrcweir     {
610*cdf0e10cSrcweir         Image aImage;
611*cdf0e10cSrcweir         OUString aSuggestionImageUrl;
612*cdf0e10cSrcweir         uno::Reference< lang::XServiceInfo > xInfo( rResult.xProofreader, uno::UNO_QUERY );
613*cdf0e10cSrcweir         if (xInfo.is())
614*cdf0e10cSrcweir         {
615*cdf0e10cSrcweir             aSuggestionImageUrl = SvtLinguConfig().GetSpellAndGrammarContextSuggestionImage( xInfo->getImplementationName() );
616*cdf0e10cSrcweir             aImage = Image( lcl_GetImageFromPngUrl( aSuggestionImageUrl ) );
617*cdf0e10cSrcweir         }
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir         sal_uInt16 nItemId = MN_SUGGESTION_START;
620*cdf0e10cSrcweir         for (sal_uInt16 i = 0;  i < nStringCount;  ++i)
621*cdf0e10cSrcweir         {
622*cdf0e10cSrcweir             const String aEntry = aSuggestions[ i ];
623*cdf0e10cSrcweir             InsertItem( nItemId, aEntry, 0, nPos++ );
624*cdf0e10cSrcweir             SetHelpId( nItemId, HID_LINGU_REPLACE );
625*cdf0e10cSrcweir             if (aSuggestionImageUrl.getLength() > 0)
626*cdf0e10cSrcweir                 SetItemImage( nItemId, aImage );
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir             ++nItemId;
629*cdf0e10cSrcweir         }
630*cdf0e10cSrcweir         InsertSeparator( nPos++ );
631*cdf0e10cSrcweir     }
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir     OUString aIgnoreSelection( String( SW_RES( STR_IGNORE_SELECTION ) ) );
634*cdf0e10cSrcweir     OUString aSpellingAndGrammar = RetrieveLabelFromCommand( C2U(".uno:SpellingAndGrammarDialog") );
635*cdf0e10cSrcweir     SetItemText( MN_SPELLING_DLG, aSpellingAndGrammar );
636*cdf0e10cSrcweir     sal_uInt16 nItemPos = GetItemPos( MN_IGNORE_WORD );
637*cdf0e10cSrcweir     InsertItem( MN_IGNORE_SELECTION, aIgnoreSelection, 0, nItemPos );
638*cdf0e10cSrcweir     SetHelpId( MN_IGNORE_SELECTION, HID_LINGU_IGNORE_SELECTION);
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir     EnableItem( MN_AUTOCORR, false );
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir     uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser();
643*cdf0e10cSrcweir     nGuessLangWord = LANGUAGE_NONE;
644*cdf0e10cSrcweir     nGuessLangPara = LANGUAGE_NONE;
645*cdf0e10cSrcweir     if (xLG.is())
646*cdf0e10cSrcweir     {
647*cdf0e10cSrcweir //        nGuessLangWord = lcl_CheckLanguage( xSpellAlt->getWord(), ::GetSpellChecker(), xLG, sal_False );
648*cdf0e10cSrcweir         nGuessLangPara = lcl_CheckLanguage( rParaText, ::GetSpellChecker(), xLG, sal_True );
649*cdf0e10cSrcweir     }
650*cdf0e10cSrcweir     if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
651*cdf0e10cSrcweir     {
652*cdf0e10cSrcweir         // make sure LANGUAGE_NONE gets not used as menu entry
653*cdf0e10cSrcweir         if (nGuessLangWord == LANGUAGE_NONE)
654*cdf0e10cSrcweir             nGuessLangWord = nGuessLangPara;
655*cdf0e10cSrcweir         if (nGuessLangPara == LANGUAGE_NONE)
656*cdf0e10cSrcweir             nGuessLangPara = nGuessLangWord;
657*cdf0e10cSrcweir     }
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir     EnableItem( MN_IGNORE_WORD, false );
660*cdf0e10cSrcweir     EnableItem( MN_ADD_TO_DIC, false );
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir     //ADD NEW LANGUAGE MENU ITEM
663*cdf0e10cSrcweir     ///////////////////////////////////////////////////////////////////////////
664*cdf0e10cSrcweir     String aScriptTypesInUse( String::CreateFromInt32( pWrtSh->GetScriptType() ) );
665*cdf0e10cSrcweir     SvtLanguageTable aLanguageTable;
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir     // get keyboard language
668*cdf0e10cSrcweir     String aKeyboardLang;
669*cdf0e10cSrcweir     LanguageType nLang = LANGUAGE_DONTKNOW;
670*cdf0e10cSrcweir     SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
671*cdf0e10cSrcweir     nLang = rEditWin.GetInputLanguage();
672*cdf0e10cSrcweir     if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
673*cdf0e10cSrcweir         aKeyboardLang = aLanguageTable.GetString( nLang );
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir     // get the language that is in use
676*cdf0e10cSrcweir     const String aMultipleLanguages = String::CreateFromAscii("*");
677*cdf0e10cSrcweir     String aCurrentLang = aMultipleLanguages;
678*cdf0e10cSrcweir     nLang = SwLangHelper::GetCurrentLanguage( *pWrtSh );
679*cdf0e10cSrcweir     if (nLang != LANGUAGE_DONTKNOW)
680*cdf0e10cSrcweir         aCurrentLang = aLanguageTable.GetString( nLang );
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir     // build sequence for status value
683*cdf0e10cSrcweir     uno::Sequence< OUString > aSeq( 4 );
684*cdf0e10cSrcweir     aSeq[0] = aCurrentLang;
685*cdf0e10cSrcweir     aSeq[1] = aScriptTypesInUse;
686*cdf0e10cSrcweir     aSeq[2] = aKeyboardLang;
687*cdf0e10cSrcweir     aSeq[3] = aLanguageTable.GetString(nGuessLangWord);
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir     PopupMenu *pMenu = GetPopupMenu(MN_SET_LANGUAGE_SELECTION);
690*cdf0e10cSrcweir     fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_SELECTION_START, aSeq, pWrtSh, aLangTable_Text );
691*cdf0e10cSrcweir     EnableItem( MN_SET_LANGUAGE_SELECTION, true );
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir     pMenu = GetPopupMenu(MN_SET_LANGUAGE_PARAGRAPH);
694*cdf0e10cSrcweir     fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_PARAGRAPH_START, aSeq, pWrtSh, aLangTable_Paragraph );
695*cdf0e10cSrcweir     EnableItem( MN_SET_LANGUAGE_PARAGRAPH, true );
696*cdf0e10cSrcweir /*
697*cdf0e10cSrcweir     pMenu = GetPopupMenu(MN_SET_LANGUAGE_ALL_TEXT);
698*cdf0e10cSrcweir     fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_ALL_TEXT_START, aSeq, pWrtSh, aLangTable_Document );
699*cdf0e10cSrcweir     EnableItem( MN_SET_LANGUAGE_ALL_TEXT, true );
700*cdf0e10cSrcweir */
701*cdf0e10cSrcweir     uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface();
702*cdf0e10cSrcweir     Image rImg = ::GetImage( xFrame,
703*cdf0e10cSrcweir             OUString::createFromAscii(".uno:SpellingAndGrammarDialog"), sal_False,
704*cdf0e10cSrcweir             Application::GetSettings().GetStyleSettings().GetHighContrastMode() );
705*cdf0e10cSrcweir     SetItemImage( MN_SPELLING_DLG, rImg );
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir     //////////////////////////////////////////////////////////////////////////////////
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir     RemoveDisabledEntries( sal_True, sal_True );
710*cdf0e10cSrcweir }
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir /*--------------------------------------------------------------------------
713*cdf0e10cSrcweir 
714*cdf0e10cSrcweir ---------------------------------------------------------------------------*/
715*cdf0e10cSrcweir sal_uInt16  SwSpellPopup::Execute( const Rectangle& rWordPos, Window* pWin )
716*cdf0e10cSrcweir {
717*cdf0e10cSrcweir //    SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS);
718*cdf0e10cSrcweir     sal_uInt16 nRet = PopupMenu::Execute(pWin, pWin->LogicToPixel(rWordPos));
719*cdf0e10cSrcweir     Execute( nRet );
720*cdf0e10cSrcweir     return nRet;
721*cdf0e10cSrcweir }
722*cdf0e10cSrcweir /*-- 19.01.2006 08:15:48---------------------------------------------------
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
725*cdf0e10cSrcweir void SwSpellPopup::Execute( sal_uInt16 nId )
726*cdf0e10cSrcweir {
727*cdf0e10cSrcweir     if (nId == USHRT_MAX)
728*cdf0e10cSrcweir         return;
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir     if (/*bGrammarResults && */nId == MN_SHORT_COMMENT)
731*cdf0e10cSrcweir         return;     // nothing to do since it is the error message (short comment)
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir     if ((MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ||
734*cdf0e10cSrcweir         (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END))
735*cdf0e10cSrcweir     {
736*cdf0e10cSrcweir         sal_Int32 nAltIdx = (MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ?
737*cdf0e10cSrcweir                 nId - MN_SUGGESTION_START : nId - MN_AUTOCORR_START;
738*cdf0e10cSrcweir         DBG_ASSERT( 0 <= nAltIdx && nAltIdx < aSuggestions.getLength(), "index out of range" );
739*cdf0e10cSrcweir         if (0 <= nAltIdx && nAltIdx < aSuggestions.getLength() && (bGrammarResults || xSpellAlt.is()))
740*cdf0e10cSrcweir         {
741*cdf0e10cSrcweir             sal_Bool bOldIns = pSh->IsInsMode();
742*cdf0e10cSrcweir             pSh->SetInsMode( sal_True );
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir             String aTmp( aSuggestions[ nAltIdx ] );
745*cdf0e10cSrcweir             String aOrig( bGrammarResults ? OUString() : xSpellAlt->getWord() );
746*cdf0e10cSrcweir 
747*cdf0e10cSrcweir             // if orginal word has a trailing . (likely the end of a sentence)
748*cdf0e10cSrcweir             // and the replacement text hasn't, then add it to the replacement
749*cdf0e10cSrcweir             if (aTmp.Len() && aOrig.Len() &&
750*cdf0e10cSrcweir                 '.' == aOrig.GetChar( aOrig.Len() - 1) && /* !IsAlphaNumeric ??*/
751*cdf0e10cSrcweir                 '.' != aTmp.GetChar( aTmp.Len() - 1))
752*cdf0e10cSrcweir             {
753*cdf0e10cSrcweir                 aTmp += '.';
754*cdf0e10cSrcweir             }
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir             // #111827#
757*cdf0e10cSrcweir             SwRewriter aRewriter;
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir             aRewriter.AddRule(UNDO_ARG1, pSh->GetCrsrDescr());
760*cdf0e10cSrcweir             aRewriter.AddRule(UNDO_ARG2, String(SW_RES(STR_YIELDS)));
761*cdf0e10cSrcweir 
762*cdf0e10cSrcweir             String aTmpStr( SW_RES(STR_START_QUOTE) );
763*cdf0e10cSrcweir             aTmpStr += aTmp;
764*cdf0e10cSrcweir             aTmpStr += String(SW_RES(STR_END_QUOTE));
765*cdf0e10cSrcweir             aRewriter.AddRule(UNDO_ARG3, aTmpStr);
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir             pSh->StartUndo(UNDO_UI_REPLACE, &aRewriter);
768*cdf0e10cSrcweir             pSh->StartAction();
769*cdf0e10cSrcweir             pSh->DelLeft();
770*cdf0e10cSrcweir 
771*cdf0e10cSrcweir             pSh->Insert( aTmp );
772*cdf0e10cSrcweir 
773*cdf0e10cSrcweir             /* #102505# EndAction/EndUndo moved down since insertion
774*cdf0e10cSrcweir                of temporary auto correction is now undoable two and
775*cdf0e10cSrcweir                must reside in the same undo group.*/
776*cdf0e10cSrcweir 
777*cdf0e10cSrcweir             // nur aufnehmen, wenn es NICHT schon in der Autokorrektur vorhanden ist
778*cdf0e10cSrcweir             SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get()->GetAutoCorrect();
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir             String aOrigWord( bGrammarResults ? OUString() : xSpellAlt->getWord() ) ;
781*cdf0e10cSrcweir             String aNewWord( aSuggestions[ nAltIdx ] );
782*cdf0e10cSrcweir             SvxPrepareAutoCorrect( aOrigWord, aNewWord );
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir             if (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)
785*cdf0e10cSrcweir                 pACorr->PutText( aOrigWord, aNewWord, nCheckedLanguage );
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir             /* #102505# EndAction/EndUndo moved down since insertion
788*cdf0e10cSrcweir                of temporary auto correction is now undoable two and
789*cdf0e10cSrcweir                must reside in the same undo group.*/
790*cdf0e10cSrcweir             pSh->EndAction();
791*cdf0e10cSrcweir             pSh->EndUndo();
792*cdf0e10cSrcweir 
793*cdf0e10cSrcweir             pSh->SetInsMode( bOldIns );
794*cdf0e10cSrcweir         }
795*cdf0e10cSrcweir     }
796*cdf0e10cSrcweir     else if (nId == MN_SPELLING_DLG)
797*cdf0e10cSrcweir     {
798*cdf0e10cSrcweir         if (bGrammarResults)
799*cdf0e10cSrcweir         {
800*cdf0e10cSrcweir             SvtLinguConfig().SetProperty( A2OU( UPN_IS_GRAMMAR_INTERACTIVE ), uno::makeAny( sal_True ));
801*cdf0e10cSrcweir         }
802*cdf0e10cSrcweir         pSh->Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
803*cdf0e10cSrcweir         {
804*cdf0e10cSrcweir             uno::Reference<linguistic2::XDictionaryList> xDictionaryList( SvxGetDictionaryList() );
805*cdf0e10cSrcweir             SvxDicListChgClamp aClamp( xDictionaryList );
806*cdf0e10cSrcweir             pSh->GetView().GetViewFrame()->GetDispatcher()->
807*cdf0e10cSrcweir                 Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON );
808*cdf0e10cSrcweir         }
809*cdf0e10cSrcweir     }
810*cdf0e10cSrcweir     else if (nId == MN_IGNORE_SELECTION)
811*cdf0e10cSrcweir     {
812*cdf0e10cSrcweir         SwPaM *pPaM = pSh->GetCrsr();
813*cdf0e10cSrcweir         if (pPaM)
814*cdf0e10cSrcweir             pSh->IgnoreGrammarErrorAt( *pPaM );
815*cdf0e10cSrcweir     }
816*cdf0e10cSrcweir     else if (nId == MN_IGNORE_WORD)
817*cdf0e10cSrcweir     {
818*cdf0e10cSrcweir         uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY );
819*cdf0e10cSrcweir         linguistic::AddEntryToDic( xDictionary,
820*cdf0e10cSrcweir                 xSpellAlt->getWord(), sal_False, aEmptyStr, LANGUAGE_NONE );
821*cdf0e10cSrcweir     }
822*cdf0e10cSrcweir     else if (MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END)
823*cdf0e10cSrcweir     {
824*cdf0e10cSrcweir             OUString aWord( xSpellAlt->getWord() );
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir             PopupMenu *pMenu = GetPopupMenu(MN_ADD_TO_DIC);
827*cdf0e10cSrcweir             String aDicName ( pMenu->GetItemText(nId) );
828*cdf0e10cSrcweir 
829*cdf0e10cSrcweir             uno::Reference< linguistic2::XDictionary >      xDic;
830*cdf0e10cSrcweir             uno::Reference< linguistic2::XDictionaryList >  xDicList( SvxGetDictionaryList() );
831*cdf0e10cSrcweir             if (xDicList.is())
832*cdf0e10cSrcweir                 xDic = xDicList->getDictionaryByName( aDicName );
833*cdf0e10cSrcweir 
834*cdf0e10cSrcweir             if (xDic.is())
835*cdf0e10cSrcweir             {
836*cdf0e10cSrcweir                 sal_Int16 nAddRes = linguistic::AddEntryToDic( xDic, aWord, sal_False, aEmptyStr, LANGUAGE_NONE );
837*cdf0e10cSrcweir                 // save modified user-dictionary if it is persistent
838*cdf0e10cSrcweir                 uno::Reference< frame::XStorable >  xSavDic( xDic, uno::UNO_QUERY );
839*cdf0e10cSrcweir                 if (xSavDic.is())
840*cdf0e10cSrcweir                     xSavDic->store();
841*cdf0e10cSrcweir 
842*cdf0e10cSrcweir                 if (DIC_ERR_NONE != nAddRes
843*cdf0e10cSrcweir                     && !xDic->getEntry( aWord ).is())
844*cdf0e10cSrcweir                 {
845*cdf0e10cSrcweir                     SvxDicError(
846*cdf0e10cSrcweir                         &pSh->GetView().GetViewFrame()->GetWindow(),
847*cdf0e10cSrcweir                         nAddRes );
848*cdf0e10cSrcweir                 }
849*cdf0e10cSrcweir             }
850*cdf0e10cSrcweir     }
851*cdf0e10cSrcweir     else
852*cdf0e10cSrcweir     {
853*cdf0e10cSrcweir         // Set language for selection or for paragraph...
854*cdf0e10cSrcweir 
855*cdf0e10cSrcweir         SfxItemSet aCoreSet( pSh->GetView().GetPool(),
856*cdf0e10cSrcweir                     RES_CHRATR_LANGUAGE,        RES_CHRATR_LANGUAGE,
857*cdf0e10cSrcweir                     RES_CHRATR_CJK_LANGUAGE,    RES_CHRATR_CJK_LANGUAGE,
858*cdf0e10cSrcweir                     RES_CHRATR_CTL_LANGUAGE,    RES_CHRATR_CTL_LANGUAGE,
859*cdf0e10cSrcweir                     0 );
860*cdf0e10cSrcweir         String aNewLangTxt;
861*cdf0e10cSrcweir 
862*cdf0e10cSrcweir         if (MN_SET_LANGUAGE_SELECTION_START <= nId && nId <= MN_SET_LANGUAGE_SELECTION_END)
863*cdf0e10cSrcweir         {
864*cdf0e10cSrcweir             //Set language for current selection
865*cdf0e10cSrcweir             aNewLangTxt = aLangTable_Text[nId];
866*cdf0e10cSrcweir             SwLangHelper::SetLanguage( *pSh, aNewLangTxt, true, aCoreSet );
867*cdf0e10cSrcweir         }
868*cdf0e10cSrcweir         else if (nId == MN_SET_SELECTION_NONE)
869*cdf0e10cSrcweir         {
870*cdf0e10cSrcweir             //Set Language_None for current selection
871*cdf0e10cSrcweir             SwLangHelper::SetLanguage_None( *pSh, true, aCoreSet );
872*cdf0e10cSrcweir         }
873*cdf0e10cSrcweir         else if (nId == MN_SET_SELECTION_RESET)
874*cdf0e10cSrcweir         {
875*cdf0e10cSrcweir             //reset languages for current selection
876*cdf0e10cSrcweir             SwLangHelper::ResetLanguages( *pSh, true );
877*cdf0e10cSrcweir         }
878*cdf0e10cSrcweir         else if (nId == MN_SET_SELECTION_MORE)
879*cdf0e10cSrcweir         {
880*cdf0e10cSrcweir             //Open Format/Character Dialog
881*cdf0e10cSrcweir             lcl_CharDialog( *pSh, true, nId, 0, 0 );
882*cdf0e10cSrcweir         }
883*cdf0e10cSrcweir         else if (MN_SET_LANGUAGE_PARAGRAPH_START <= nId && nId <= MN_SET_LANGUAGE_PARAGRAPH_END)
884*cdf0e10cSrcweir         {
885*cdf0e10cSrcweir             //Set language for current paragraph
886*cdf0e10cSrcweir             aNewLangTxt = aLangTable_Paragraph[nId];
887*cdf0e10cSrcweir             pSh->Push();        // save cursor
888*cdf0e10cSrcweir             SwLangHelper::SelectCurrentPara( *pSh );
889*cdf0e10cSrcweir             SwLangHelper::SetLanguage( *pSh, aNewLangTxt, true, aCoreSet );
890*cdf0e10cSrcweir             pSh->Pop( sal_False );  // restore cursor
891*cdf0e10cSrcweir         }
892*cdf0e10cSrcweir         else if (nId == MN_SET_PARA_NONE)
893*cdf0e10cSrcweir         {
894*cdf0e10cSrcweir             //Set Language_None for current paragraph
895*cdf0e10cSrcweir             pSh->Push();        // save cursor
896*cdf0e10cSrcweir             SwLangHelper::SelectCurrentPara( *pSh );
897*cdf0e10cSrcweir             SwLangHelper::SetLanguage_None( *pSh, true, aCoreSet );
898*cdf0e10cSrcweir             pSh->Pop( sal_False );  // restore cursor
899*cdf0e10cSrcweir         }
900*cdf0e10cSrcweir         else if (nId == MN_SET_PARA_RESET)
901*cdf0e10cSrcweir         {
902*cdf0e10cSrcweir             //reset languages for current paragraph
903*cdf0e10cSrcweir             pSh->Push();        // save cursor
904*cdf0e10cSrcweir             SwLangHelper::SelectCurrentPara( *pSh );
905*cdf0e10cSrcweir             SwLangHelper::ResetLanguages( *pSh, true );
906*cdf0e10cSrcweir             pSh->Pop( sal_False );  // restore cursor
907*cdf0e10cSrcweir         }
908*cdf0e10cSrcweir         else if (nId == MN_SET_PARA_MORE)
909*cdf0e10cSrcweir         {
910*cdf0e10cSrcweir             pSh->Push();        // save cursor
911*cdf0e10cSrcweir             SwLangHelper::SelectCurrentPara( *pSh );
912*cdf0e10cSrcweir             //Open Format/Character Dialog
913*cdf0e10cSrcweir             lcl_CharDialog( *pSh, true, nId, 0, 0 );
914*cdf0e10cSrcweir             pSh->Pop( sal_False );  // restore cursor
915*cdf0e10cSrcweir         }
916*cdf0e10cSrcweir #if 0
917*cdf0e10cSrcweir         else if (nId == MN_SET_LANGUAGE_ALL_TEXT_START + nNumLanguageDocEntries - 1)
918*cdf0e10cSrcweir         {
919*cdf0e10cSrcweir             //Set Language_None as the default language
920*cdf0e10cSrcweir             SwLangHelper::SetLanguage_None( *pSh, false, aCoreSet );
921*cdf0e10cSrcweir         }
922*cdf0e10cSrcweir         else if (nId == MN_SET_LANGUAGE_ALL_TEXT_START + nNumLanguageDocEntries)
923*cdf0e10cSrcweir         {
924*cdf0e10cSrcweir             // open the dialog "Tools/Options/Language Settings - Language"
925*cdf0e10cSrcweir             SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
926*cdf0e10cSrcweir             if (pFact)
927*cdf0e10cSrcweir             {
928*cdf0e10cSrcweir                 VclAbstractDialog* pDlg = pFact->CreateVclDialog( pSh->GetView().GetWindow(), SID_LANGUAGE_OPTIONS );
929*cdf0e10cSrcweir                 pDlg->Execute();
930*cdf0e10cSrcweir                 delete pDlg;
931*cdf0e10cSrcweir             }
932*cdf0e10cSrcweir         }
933*cdf0e10cSrcweir #endif
934*cdf0e10cSrcweir     }
935*cdf0e10cSrcweir 
936*cdf0e10cSrcweir     pSh->EnterStdMode();
937*cdf0e10cSrcweir }
938