xref: /AOO41X/main/cui/source/options/optlingu.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_cui.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir // include ---------------------------------------------------------------
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
34*cdf0e10cSrcweir #include <vcl/field.hxx>
35*cdf0e10cSrcweir #include <vcl/fixed.hxx>
36*cdf0e10cSrcweir #include <tools/shl.hxx>
37*cdf0e10cSrcweir #include <tools/dynary.hxx>
38*cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
39*cdf0e10cSrcweir #include <unotools/lingucfg.hxx>
40*cdf0e10cSrcweir #include <editeng/unolingu.hxx>
41*cdf0e10cSrcweir #include <svx/dlgutil.hxx>
42*cdf0e10cSrcweir #include <linguistic/lngprops.hxx>
43*cdf0e10cSrcweir #include <linguistic/misc.hxx>
44*cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
45*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
46*cdf0e10cSrcweir #include <tools/urlobj.hxx>
47*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
49*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSpellChecker.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XProofreader.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XHyphenator.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XThesaurus.hpp>
53*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XAvailableLocales.hpp>
54*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceDisplayName.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/linguistic2/DictionaryListEventFlags.hpp>
56*cdf0e10cSrcweir #include <com/sun/star/linguistic2/DictionaryListEvent.hpp>
57*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XDictionaryListEventListener.hpp>
58*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XDictionaryList.hpp>
59*cdf0e10cSrcweir #include <com/sun/star/frame/XStorable.hpp>
60*cdf0e10cSrcweir #include <com/sun/star/ucb/CommandAbortedException.hpp>
61*cdf0e10cSrcweir #include <com/sun/star/system/XSystemShellExecute.hpp>
62*cdf0e10cSrcweir #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
63*cdf0e10cSrcweir #include <unotools/extendedsecurityoptions.hxx>
64*cdf0e10cSrcweir #include <svtools/svlbox.hxx>
65*cdf0e10cSrcweir #include <svl/eitem.hxx>
66*cdf0e10cSrcweir #include <svl/intitem.hxx>
67*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
68*cdf0e10cSrcweir #include <vcl/svapp.hxx>
69*cdf0e10cSrcweir #define _SVX_OPTLINGU_CXX
70*cdf0e10cSrcweir #include "optlingu.hrc"
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir #include <svx/svxdlg.hxx>
73*cdf0e10cSrcweir #include <editeng/optitems.hxx>
74*cdf0e10cSrcweir #include "optlingu.hxx"
75*cdf0e10cSrcweir #include <dialmgr.hxx>
76*cdf0e10cSrcweir #include <cuires.hrc>
77*cdf0e10cSrcweir #include "helpid.hrc"
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir #include <ucbhelper/content.hxx>
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir #include <vector>
82*cdf0e10cSrcweir #include <map>
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir using namespace ::ucbhelper;
86*cdf0e10cSrcweir using namespace ::rtl;
87*cdf0e10cSrcweir using namespace ::com::sun::star;
88*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
89*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
90*cdf0e10cSrcweir using namespace ::com::sun::star::linguistic2;
91*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
92*cdf0e10cSrcweir namespace css = com::sun::star;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir #define C2U(cChar) OUString::createFromAscii(cChar)
95*cdf0e10cSrcweir #define SVX_MAX_USERDICTS 20
96*cdf0e10cSrcweir #define CBCOL_FIRST		0
97*cdf0e10cSrcweir #define CBCOL_SECOND	1
98*cdf0e10cSrcweir #define CBCOL_BOTH		2
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir static const sal_Char cSpell[]   = SN_SPELLCHECKER;
101*cdf0e10cSrcweir static const sal_Char cGrammar[] = SN_GRAMMARCHECKER;
102*cdf0e10cSrcweir static const sal_Char cHyph[]    = SN_HYPHENATOR;
103*cdf0e10cSrcweir static const sal_Char cThes[]    = SN_THESAURUS;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir // static ----------------------------------------------------------------
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir static Sequence< sal_Int16 > lcl_LocaleSeqToLangSeq( const Sequence< Locale > &rSeq )
108*cdf0e10cSrcweir {
109*cdf0e10cSrcweir     sal_Int32 nLen = rSeq.getLength();
110*cdf0e10cSrcweir     Sequence< sal_Int16 > aRes( nLen );
111*cdf0e10cSrcweir     sal_Int16 *pRes = aRes.getArray();
112*cdf0e10cSrcweir     const Locale *pSeq = rSeq.getConstArray();
113*cdf0e10cSrcweir     for (sal_Int32 i = 0;  i < nLen;  ++i)
114*cdf0e10cSrcweir     {
115*cdf0e10cSrcweir         pRes[i] = SvxLocaleToLanguage( pSeq[i] );
116*cdf0e10cSrcweir     }
117*cdf0e10cSrcweir     return aRes;
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir static sal_Bool lcl_SeqHasLang( const Sequence< sal_Int16 > &rSeq, sal_Int16 nLang )
122*cdf0e10cSrcweir {
123*cdf0e10cSrcweir     sal_Int32 nLen = rSeq.getLength();
124*cdf0e10cSrcweir     const sal_Int16 *pLang = rSeq.getConstArray();
125*cdf0e10cSrcweir     sal_Int32 nPos = -1;
126*cdf0e10cSrcweir     for (sal_Int32 i = 0;  i < nLen  &&  nPos < 0;  ++i)
127*cdf0e10cSrcweir     {
128*cdf0e10cSrcweir         if (nLang == pLang[i])
129*cdf0e10cSrcweir             nPos = i;
130*cdf0e10cSrcweir     }
131*cdf0e10cSrcweir     return nPos < 0 ? sal_False : sal_True;
132*cdf0e10cSrcweir }
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir static sal_Int32 lcl_SeqGetEntryPos(
136*cdf0e10cSrcweir 	const Sequence< OUString > &rSeq, const OUString &rEntry )
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir 	sal_Int32 i;
139*cdf0e10cSrcweir 	sal_Int32 nLen = rSeq.getLength();
140*cdf0e10cSrcweir 	const OUString *pItem = rSeq.getConstArray();
141*cdf0e10cSrcweir 	for (i = 0;  i < nLen;  ++i)
142*cdf0e10cSrcweir 	{
143*cdf0e10cSrcweir 		if (rEntry == pItem[i])
144*cdf0e10cSrcweir 			break;
145*cdf0e10cSrcweir 	}
146*cdf0e10cSrcweir     return i < nLen ? i : -1;
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir static void lcl_OpenURL( const ::rtl::OUString& rURL )
150*cdf0e10cSrcweir {
151*cdf0e10cSrcweir     if ( rURL.getLength() > 0 )
152*cdf0e10cSrcweir     {
153*cdf0e10cSrcweir         try
154*cdf0e10cSrcweir         {
155*cdf0e10cSrcweir             uno::Reference< lang::XMultiServiceFactory > xSMGR =
156*cdf0e10cSrcweir                 ::comphelper::getProcessServiceFactory();
157*cdf0e10cSrcweir             uno::Reference< css::system::XSystemShellExecute > xSystemShell(
158*cdf0e10cSrcweir                 xSMGR->createInstance( ::rtl::OUString(
159*cdf0e10cSrcweir                     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.system.SystemShellExecute" ) ) ),
160*cdf0e10cSrcweir                 uno::UNO_QUERY_THROW );
161*cdf0e10cSrcweir             if ( xSystemShell.is() )
162*cdf0e10cSrcweir                 xSystemShell->execute( rURL, ::rtl::OUString(), css::system::SystemShellExecuteFlags::DEFAULTS );
163*cdf0e10cSrcweir         }
164*cdf0e10cSrcweir         catch( const uno::Exception& e )
165*cdf0e10cSrcweir         {
166*cdf0e10cSrcweir              OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
167*cdf0e10cSrcweir                 rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
168*cdf0e10cSrcweir         }
169*cdf0e10cSrcweir     }
170*cdf0e10cSrcweir }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir /*--------------------------------------------------
173*cdf0e10cSrcweir --------------------------------------------------*/
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir static const sal_uInt16 nNameLen = 8;
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir static sal_uInt16 pRanges[] =
178*cdf0e10cSrcweir {
179*cdf0e10cSrcweir 	SID_ATTR_SPELL,
180*cdf0e10cSrcweir 	SID_ATTR_SPELL,
181*cdf0e10cSrcweir 	0
182*cdf0e10cSrcweir };
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir sal_Bool KillFile_Impl( const String& rURL )
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
187*cdf0e10cSrcweir 	try
188*cdf0e10cSrcweir 	{
189*cdf0e10cSrcweir 		Content aCnt( rURL, uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
190*cdf0e10cSrcweir 		aCnt.executeCommand( OUString::createFromAscii( "delete" ), makeAny( sal_Bool( sal_True ) ) );
191*cdf0e10cSrcweir 	}
192*cdf0e10cSrcweir 	catch( ::com::sun::star::ucb::CommandAbortedException& )
193*cdf0e10cSrcweir 	{
194*cdf0e10cSrcweir 		DBG_ERRORFILE( "KillFile: CommandAbortedException" );
195*cdf0e10cSrcweir 		bRet = sal_False;
196*cdf0e10cSrcweir 	}
197*cdf0e10cSrcweir 	catch( ... )
198*cdf0e10cSrcweir 	{
199*cdf0e10cSrcweir 		DBG_ERRORFILE( "KillFile: Any other exception" );
200*cdf0e10cSrcweir 		bRet = sal_False;
201*cdf0e10cSrcweir 	}
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 	return bRet;
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir /* -----------------------------27.11.00 14:07--------------------------------
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
208*cdf0e10cSrcweir // 0x 0p 0t 0c nn
209*cdf0e10cSrcweir // p: 1 -> parent
210*cdf0e10cSrcweir // t: 1 -> spell, 2 -> hyph, 3 -> thes, 4 -> grammar
211*cdf0e10cSrcweir // c: 1 -> checked 0 -> unchecked
212*cdf0e10cSrcweir // n: index
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir #define TYPE_SPELL      (sal_uInt8)1
215*cdf0e10cSrcweir #define TYPE_GRAMMAR    (sal_uInt8)2
216*cdf0e10cSrcweir #define TYPE_HYPH       (sal_uInt8)3
217*cdf0e10cSrcweir #define TYPE_THES       (sal_uInt8)4
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir class ModuleUserData_Impl
220*cdf0e10cSrcweir {
221*cdf0e10cSrcweir 	sal_Bool bParent;
222*cdf0e10cSrcweir 	sal_Bool bIsChecked;
223*cdf0e10cSrcweir 	sal_uInt8 nType;
224*cdf0e10cSrcweir 	sal_uInt8 nIndex;
225*cdf0e10cSrcweir 	String	sImplName;
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir public:
228*cdf0e10cSrcweir 	ModuleUserData_Impl( String sImpName, sal_Bool bIsParent, sal_Bool bChecked, sal_uInt8 nSetType, sal_uInt8 nSetIndex ) :
229*cdf0e10cSrcweir 		bParent(bIsParent),
230*cdf0e10cSrcweir 		bIsChecked(bChecked),
231*cdf0e10cSrcweir 		nType(nSetType),
232*cdf0e10cSrcweir 		nIndex(nSetIndex),
233*cdf0e10cSrcweir 		sImplName(sImpName)
234*cdf0e10cSrcweir 		{
235*cdf0e10cSrcweir 		}
236*cdf0e10cSrcweir 	sal_Bool IsParent() const {return bParent;}
237*cdf0e10cSrcweir 	sal_uInt8 GetType() const {return nType;}
238*cdf0e10cSrcweir 	sal_Bool IsChecked() const {return bIsChecked;}
239*cdf0e10cSrcweir 	sal_uInt8 GetIndex() const {return nIndex;}
240*cdf0e10cSrcweir 	void SetIndex(sal_uInt8 nSet)  {nIndex = nSet;}
241*cdf0e10cSrcweir 	const String& GetImplName() const {return sImplName;}
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir };
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir /*--------------------------------------------------
246*cdf0e10cSrcweir --------------------------------------------------*/
247*cdf0e10cSrcweir //
248*cdf0e10cSrcweir // User for user-dictionaries (XDictionary interface)
249*cdf0e10cSrcweir //
250*cdf0e10cSrcweir class DicUserData
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir 	sal_uLong	nVal;
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir public:
255*cdf0e10cSrcweir 	DicUserData( sal_uLong nUserData ) : nVal( nUserData ) {}
256*cdf0e10cSrcweir 	DicUserData( sal_uInt16 nEID,
257*cdf0e10cSrcweir 				 sal_Bool bChecked, sal_Bool bEditable, sal_Bool bDeletable );
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 	sal_uLong	GetUserData() const			{ return nVal; }
260*cdf0e10cSrcweir 	sal_uInt16	GetEntryId() const			{ return (sal_uInt16)(nVal >> 16); }
261*cdf0e10cSrcweir 	sal_Bool	IsChecked() const			{ return (sal_Bool)(nVal >>  8) & 0x01; }
262*cdf0e10cSrcweir 	sal_Bool	IsEditable() const			{ return (sal_Bool)(nVal >>  9) & 0x01; }
263*cdf0e10cSrcweir 	sal_Bool	IsDeletable() const			{ return (sal_Bool)(nVal >> 10) & 0x01; }
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 	void	SetChecked( sal_Bool bVal );
266*cdf0e10cSrcweir };
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir DicUserData::DicUserData(
270*cdf0e10cSrcweir 		sal_uInt16 nEID,
271*cdf0e10cSrcweir 		sal_Bool bChecked, sal_Bool bEditable, sal_Bool bDeletable )
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir 	DBG_ASSERT( nEID < 65000, "Entry Id out of range" );
274*cdf0e10cSrcweir 	nVal =  ((sal_uLong)(0xFFFF & nEID)			<< 16) |
275*cdf0e10cSrcweir 			((sal_uLong)(bChecked ? 1 : 0)		<<  8) |
276*cdf0e10cSrcweir 			((sal_uLong)(bEditable ? 1 : 0)		<<  9) |
277*cdf0e10cSrcweir 			((sal_uLong)(bDeletable ? 1 : 0)	<< 10);
278*cdf0e10cSrcweir }
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir void DicUserData::SetChecked( sal_Bool bVal )
282*cdf0e10cSrcweir {
283*cdf0e10cSrcweir 	nVal &= ~(1UL << 8);
284*cdf0e10cSrcweir 	nVal |=  (sal_uLong)(bVal ? 1 : 0) << 8;
285*cdf0e10cSrcweir }
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir // class BrwString_Impl -------------------------------------------------
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir void lcl_SetCheckButton( SvLBoxEntry* pEntry, sal_Bool bCheck )
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir 	SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 	DBG_ASSERT(pItem,"SetCheckButton:Item not found");
295*cdf0e10cSrcweir 	if (((SvLBoxItem*)pItem)->IsA() == SV_ITEM_ID_LBOXBUTTON)
296*cdf0e10cSrcweir 	{
297*cdf0e10cSrcweir 		if (bCheck)
298*cdf0e10cSrcweir 			pItem->SetStateChecked();
299*cdf0e10cSrcweir 		else
300*cdf0e10cSrcweir 			pItem->SetStateUnchecked();
301*cdf0e10cSrcweir 		//InvalidateEntry( pEntry );
302*cdf0e10cSrcweir 	}
303*cdf0e10cSrcweir }
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir class BrwStringDic_Impl : public SvLBoxString
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir public:
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 	BrwStringDic_Impl( SvLBoxEntry* pEntry, sal_uInt16 nFlags,
311*cdf0e10cSrcweir 		const String& rStr ) : SvLBoxString( pEntry, nFlags, rStr ) {}
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 	virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
314*cdf0e10cSrcweir 											SvLBoxEntry* pEntry);
315*cdf0e10cSrcweir };
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir void BrwStringDic_Impl::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16,
318*cdf0e10cSrcweir 	SvLBoxEntry* pEntry )
319*cdf0e10cSrcweir {
320*cdf0e10cSrcweir 	ModuleUserData_Impl* pData = (ModuleUserData_Impl*)pEntry->GetUserData();
321*cdf0e10cSrcweir 	Point aPos(rPos);
322*cdf0e10cSrcweir 	Font aOldFont( rDev.GetFont());
323*cdf0e10cSrcweir 	if(pData->IsParent())
324*cdf0e10cSrcweir 	{
325*cdf0e10cSrcweir 		Font aFont( aOldFont );
326*cdf0e10cSrcweir 		aFont.SetWeight( WEIGHT_BOLD );
327*cdf0e10cSrcweir 		rDev.SetFont( aFont );
328*cdf0e10cSrcweir 		aPos.X() = 0;
329*cdf0e10cSrcweir 	}
330*cdf0e10cSrcweir 	else
331*cdf0e10cSrcweir 		aPos.X() += 5;
332*cdf0e10cSrcweir 	rDev.DrawText( aPos, GetText() );
333*cdf0e10cSrcweir 	rDev.SetFont( aOldFont );
334*cdf0e10cSrcweir }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir /*--------------------------------------------------
338*cdf0e10cSrcweir --------------------------------------------------*/
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir class OptionsBreakSet : public ModalDialog
341*cdf0e10cSrcweir {
342*cdf0e10cSrcweir 	OKButton 		aOKPB;
343*cdf0e10cSrcweir 	CancelButton	aCancelPB;
344*cdf0e10cSrcweir     FixedLine       aValFL;
345*cdf0e10cSrcweir 	NumericField	aValNF;
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir public:
348*cdf0e10cSrcweir 	OptionsBreakSet(Window* pParent, int nRID) :
349*cdf0e10cSrcweir 			ModalDialog(pParent, CUI_RES(RID_SVXDLG_LNG_ED_NUM_PREBREAK )),
350*cdf0e10cSrcweir 			aOKPB		(this, CUI_RES(BT_OK_PREBREAK)),
351*cdf0e10cSrcweir 			aCancelPB	(this, CUI_RES(BT_CANCEL_PREBREAK)),
352*cdf0e10cSrcweir             aValFL      (this, CUI_RES(FL_NUMVAL_PREBREAK)),
353*cdf0e10cSrcweir 			aValNF		(this, CUI_RES(ED_PREBREAK))
354*cdf0e10cSrcweir 	{
355*cdf0e10cSrcweir 		DBG_ASSERT( STR_NUM_PRE_BREAK_DLG   == nRID	||
356*cdf0e10cSrcweir 					STR_NUM_POST_BREAK_DLG  == nRID	||
357*cdf0e10cSrcweir 					STR_NUM_MIN_WORDLEN_DLG == nRID, "unexpected RID" );
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir 		if (nRID != -1)
360*cdf0e10cSrcweir             aValFL.SetText( String( CUI_RES(nRID) ) );
361*cdf0e10cSrcweir 		FreeResource();
362*cdf0e10cSrcweir 	}
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 	NumericField& 	GetNumericFld()	{ return aValNF; }
365*cdf0e10cSrcweir };
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir /*--------------------------------------------------
369*cdf0e10cSrcweir 	Entry IDs for options listbox of dialog
370*cdf0e10cSrcweir --------------------------------------------------*/
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir enum EID_OPTIONS
373*cdf0e10cSrcweir {
374*cdf0e10cSrcweir     EID_SPELL_AUTO,
375*cdf0e10cSrcweir     EID_GRAMMAR_AUTO,
376*cdf0e10cSrcweir 	EID_CAPITAL_WORDS,
377*cdf0e10cSrcweir 	EID_WORDS_WITH_DIGITS,
378*cdf0e10cSrcweir 	EID_CAPITALIZATION,
379*cdf0e10cSrcweir 	EID_SPELL_SPECIAL,
380*cdf0e10cSrcweir 	EID_NUM_MIN_WORDLEN,
381*cdf0e10cSrcweir 	EID_NUM_PRE_BREAK,
382*cdf0e10cSrcweir 	EID_NUM_POST_BREAK,
383*cdf0e10cSrcweir 	EID_HYPH_AUTO,
384*cdf0e10cSrcweir 	EID_HYPH_SPECIAL
385*cdf0e10cSrcweir };
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir //! this array must have an entry for every value of EID_OPTIONS.
388*cdf0e10cSrcweir //  It is used to get the respective property name.
389*cdf0e10cSrcweir static const char * aEidToPropName[] =
390*cdf0e10cSrcweir {
391*cdf0e10cSrcweir     UPN_IS_SPELL_AUTO,				// EID_SPELL_AUTO
392*cdf0e10cSrcweir     UPN_IS_GRAMMAR_AUTO,            // EID_GRAMMAR_AUTO
393*cdf0e10cSrcweir 	UPN_IS_SPELL_UPPER_CASE,		// EID_CAPITAL_WORDS
394*cdf0e10cSrcweir 	UPN_IS_SPELL_WITH_DIGITS,		// EID_WORDS_WITH_DIGITS
395*cdf0e10cSrcweir 	UPN_IS_SPELL_CAPITALIZATION,    // EID_CAPITALIZATION
396*cdf0e10cSrcweir 	UPN_IS_SPELL_SPECIAL,			// EID_SPELL_SPECIAL
397*cdf0e10cSrcweir 	UPN_HYPH_MIN_WORD_LENGTH,		// EID_NUM_MIN_WORDLEN,
398*cdf0e10cSrcweir 	UPN_HYPH_MIN_LEADING,			// EID_NUM_PRE_BREAK
399*cdf0e10cSrcweir 	UPN_HYPH_MIN_TRAILING,			// EID_NUM_POST_BREAK
400*cdf0e10cSrcweir 	UPN_IS_HYPH_AUTO,				// EID_HYPH_AUTO
401*cdf0e10cSrcweir 	UPN_IS_HYPH_SPECIAL				// EID_HYPH_SPECIAL
402*cdf0e10cSrcweir };
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir static inline String lcl_GetPropertyName( EID_OPTIONS eEntryId )
406*cdf0e10cSrcweir {
407*cdf0e10cSrcweir 	DBG_ASSERT( (unsigned int) eEntryId < sizeof(aEidToPropName) / sizeof(aEidToPropName[0]), "index out of range" );
408*cdf0e10cSrcweir 	return String::CreateFromAscii( aEidToPropName[ (int) eEntryId ] );
409*cdf0e10cSrcweir }
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir // class OptionsUserData -------------------------------------------------
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir class OptionsUserData
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir 	sal_uLong	nVal;
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir 	void	SetModified();
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir public:
420*cdf0e10cSrcweir 	OptionsUserData( sal_uLong nUserData ) : nVal( nUserData ) {}
421*cdf0e10cSrcweir 	OptionsUserData( sal_uInt16 nEID,
422*cdf0e10cSrcweir 					 sal_Bool bHasNV, sal_uInt16 nNumVal,
423*cdf0e10cSrcweir 					 sal_Bool bCheckable, sal_Bool bChecked );
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir 	sal_uLong	GetUserData() const			{ return nVal; }
426*cdf0e10cSrcweir 	sal_uInt16	GetEntryId() const			{ return (sal_uInt16)(nVal >> 16); }
427*cdf0e10cSrcweir 	sal_Bool	HasNumericValue() const		{ return (sal_Bool)(nVal >> 10) & 0x01; }
428*cdf0e10cSrcweir 	sal_uInt16	GetNumericValue() const		{ return (sal_uInt16)(nVal & 0xFF); }
429*cdf0e10cSrcweir 	sal_Bool	IsChecked() const			{ return (sal_Bool)(nVal >> 8) & 0x01; }
430*cdf0e10cSrcweir 	sal_Bool	IsCheckable() const			{ return (sal_Bool)(nVal >> 9) & 0x01; }
431*cdf0e10cSrcweir 	sal_Bool	IsModified() const			{ return (sal_Bool)(nVal >> 11) & 0x01; }
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir 	void	SetChecked( sal_Bool bVal );
434*cdf0e10cSrcweir 	void	SetNumericValue( sal_uInt8 nNumVal );
435*cdf0e10cSrcweir };
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir OptionsUserData::OptionsUserData( sal_uInt16 nEID,
438*cdf0e10cSrcweir 		sal_Bool bHasNV, sal_uInt16 nNumVal,
439*cdf0e10cSrcweir 		sal_Bool bCheckable, sal_Bool bChecked )
440*cdf0e10cSrcweir {
441*cdf0e10cSrcweir 	DBG_ASSERT( nEID < 65000, "Entry Id out of range" );
442*cdf0e10cSrcweir 	DBG_ASSERT( nNumVal < 256, "value out of range" );
443*cdf0e10cSrcweir 	nVal =  ((sal_uLong)(0xFFFF & nEID)			<< 16) |
444*cdf0e10cSrcweir 			((sal_uLong)(bHasNV ? 1 : 0)		<< 10) |
445*cdf0e10cSrcweir 			((sal_uLong)(bCheckable ? 1 : 0)	<<  9) |
446*cdf0e10cSrcweir 			((sal_uLong)(bChecked ? 1 : 0)		<<  8) |
447*cdf0e10cSrcweir 			((sal_uLong)(0xFF & nNumVal));
448*cdf0e10cSrcweir }
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir void OptionsUserData::SetChecked( sal_Bool bVal )
451*cdf0e10cSrcweir {
452*cdf0e10cSrcweir 	if (IsCheckable()  &&  (IsChecked() != bVal))
453*cdf0e10cSrcweir 	{
454*cdf0e10cSrcweir 		nVal &= ~(1UL << 8);
455*cdf0e10cSrcweir 		nVal |=  (sal_uLong)(bVal ? 1 : 0) << 8;
456*cdf0e10cSrcweir 		SetModified();
457*cdf0e10cSrcweir 	}
458*cdf0e10cSrcweir }
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir void OptionsUserData::SetNumericValue( sal_uInt8 nNumVal )
461*cdf0e10cSrcweir {
462*cdf0e10cSrcweir //	DBG_ASSERT( nNumVal < 256, "value out of range" );
463*cdf0e10cSrcweir 	if (HasNumericValue()  &&  (GetNumericValue() != nNumVal))
464*cdf0e10cSrcweir 	{
465*cdf0e10cSrcweir 		nVal &= 0xffffff00;
466*cdf0e10cSrcweir 		nVal |= (nNumVal);
467*cdf0e10cSrcweir 		SetModified();
468*cdf0e10cSrcweir 	}
469*cdf0e10cSrcweir }
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir void OptionsUserData::SetModified()
472*cdf0e10cSrcweir {
473*cdf0e10cSrcweir 	nVal |=  (sal_uLong)1 << 11;
474*cdf0e10cSrcweir }
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir // class BrwString_Impl -------------------------------------------------
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir class BrwString_Impl : public SvLBoxString
479*cdf0e10cSrcweir {
480*cdf0e10cSrcweir public:
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir 	BrwString_Impl( SvLBoxEntry* pEntry, sal_uInt16 nFlags,
483*cdf0e10cSrcweir 		const String& rStr ) : SvLBoxString( pEntry, nFlags, rStr ) {}
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir 	virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags,
486*cdf0e10cSrcweir 											SvLBoxEntry* pEntry);
487*cdf0e10cSrcweir };
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir void BrwString_Impl::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16,
490*cdf0e10cSrcweir 	SvLBoxEntry* pEntry )
491*cdf0e10cSrcweir {
492*cdf0e10cSrcweir 	Point aPos(rPos);
493*cdf0e10cSrcweir 	aPos.X() += 20;
494*cdf0e10cSrcweir 	rDev.DrawText( aPos, GetText() );
495*cdf0e10cSrcweir 	if(pEntry->GetUserData())
496*cdf0e10cSrcweir 	{
497*cdf0e10cSrcweir 		Point aNewPos(aPos);
498*cdf0e10cSrcweir 		aNewPos.X() += rDev.GetTextWidth(GetText());
499*cdf0e10cSrcweir 		Font aOldFont( rDev.GetFont());
500*cdf0e10cSrcweir 		Font aFont( aOldFont );
501*cdf0e10cSrcweir 		aFont.SetWeight( WEIGHT_BOLD );
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir //		sal_Bool bFett = sal_True;
504*cdf0e10cSrcweir //		sal_uInt16 nPos = 0;
505*cdf0e10cSrcweir 		//??? das untere byte aus dem user data in string wandeln
506*cdf0e10cSrcweir 		OptionsUserData aData( (sal_uLong) pEntry->GetUserData() );
507*cdf0e10cSrcweir 		if(aData.HasNumericValue())
508*cdf0e10cSrcweir 		{
509*cdf0e10cSrcweir 			String sTxt( ' ' );
510*cdf0e10cSrcweir 			sTxt +=  String::CreateFromInt32( aData.GetNumericValue() );
511*cdf0e10cSrcweir 			rDev.SetFont( aFont );
512*cdf0e10cSrcweir 			rDev.DrawText( aNewPos, sTxt );
513*cdf0e10cSrcweir 		}
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir //			if( STRING_NOTFOUND != nPos )
516*cdf0e10cSrcweir //				aNewPos.X() += rDev.GetTextWidth( sTxt );
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir 		rDev.SetFont( aOldFont );
519*cdf0e10cSrcweir 	}
520*cdf0e10cSrcweir }
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir // ServiceInfo_Impl ----------------------------------------------------
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir struct ServiceInfo_Impl
525*cdf0e10cSrcweir {
526*cdf0e10cSrcweir 	OUString					sDisplayName;
527*cdf0e10cSrcweir 	OUString					sSpellImplName;
528*cdf0e10cSrcweir 	OUString					sHyphImplName;
529*cdf0e10cSrcweir 	OUString					sThesImplName;
530*cdf0e10cSrcweir     OUString                    sGrammarImplName;
531*cdf0e10cSrcweir     uno::Reference< XSpellChecker >     xSpell;
532*cdf0e10cSrcweir     uno::Reference< XHyphenator >       xHyph;
533*cdf0e10cSrcweir     uno::Reference< XThesaurus >        xThes;
534*cdf0e10cSrcweir     uno::Reference< XProofreader >   	xGrammar;
535*cdf0e10cSrcweir 	sal_Bool						bConfigured;
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir     ServiceInfo_Impl() : bConfigured(sal_False) {}
538*cdf0e10cSrcweir };
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir typedef std::vector< ServiceInfo_Impl >                             ServiceInfoArr;
541*cdf0e10cSrcweir typedef std::map< sal_Int16 /*LanguageType*/, Sequence< OUString > >    LangImplNameTable;
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir // SvxLinguData_Impl ----------------------------------------------------
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir class SvxLinguData_Impl
547*cdf0e10cSrcweir {
548*cdf0e10cSrcweir     //contains services and implementation names sorted by implementation names
549*cdf0e10cSrcweir 	ServiceInfoArr			   			aDisplayServiceArr;
550*cdf0e10cSrcweir     sal_uLong                               nDisplayServices;
551*cdf0e10cSrcweir 
552*cdf0e10cSrcweir     Sequence< Locale >                  aAllServiceLocales;
553*cdf0e10cSrcweir     LangImplNameTable                   aCfgSpellTable;
554*cdf0e10cSrcweir     LangImplNameTable                   aCfgHyphTable;
555*cdf0e10cSrcweir     LangImplNameTable                   aCfgThesTable;
556*cdf0e10cSrcweir     LangImplNameTable                   aCfgGrammarTable;
557*cdf0e10cSrcweir     uno::Reference< XMultiServiceFactory >   xMSF;
558*cdf0e10cSrcweir     uno::Reference< XLinguServiceManager >   xLinguSrvcMgr;
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir     sal_Bool    AddRemove( Sequence< OUString > &rConfigured,
562*cdf0e10cSrcweir                            const OUString &rImplName, sal_Bool bAdd );
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir public:
565*cdf0e10cSrcweir 	SvxLinguData_Impl();
566*cdf0e10cSrcweir     SvxLinguData_Impl( const SvxLinguData_Impl &rData );
567*cdf0e10cSrcweir 	~SvxLinguData_Impl();
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir     SvxLinguData_Impl & operator = (const SvxLinguData_Impl &rData);
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir     uno::Reference<XLinguServiceManager> &   GetManager() { return xLinguSrvcMgr; }
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir     void SetChecked( const Sequence< OUString > &rConfiguredServices );
574*cdf0e10cSrcweir     void Reconfigure( const OUString &rDisplayName, sal_Bool bEnable );
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir     const Sequence<Locale> &    GetAllSupportedLocales() { return aAllServiceLocales; }
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir     const LangImplNameTable &   GetSpellTable() const   { return aCfgSpellTable; }
579*cdf0e10cSrcweir     LangImplNameTable &         GetSpellTable()         { return aCfgSpellTable; }
580*cdf0e10cSrcweir     const LangImplNameTable &   GetHyphTable() const    { return aCfgHyphTable; }
581*cdf0e10cSrcweir     LangImplNameTable &         GetHyphTable()          { return aCfgHyphTable; }
582*cdf0e10cSrcweir     const LangImplNameTable &   GetThesTable() const    { return aCfgThesTable; }
583*cdf0e10cSrcweir     LangImplNameTable &         GetThesTable()          { return aCfgThesTable; }
584*cdf0e10cSrcweir     const LangImplNameTable &   GetGrammarTable() const { return aCfgGrammarTable; }
585*cdf0e10cSrcweir     LangImplNameTable &         GetGrammarTable()       { return aCfgGrammarTable; }
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir     const ServiceInfoArr &      GetDisplayServiceArray() const  { return aDisplayServiceArr; }
588*cdf0e10cSrcweir     ServiceInfoArr &            GetDisplayServiceArray()        { return aDisplayServiceArr; }
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir     const sal_uLong &   GetDisplayServiceCount() const          { return nDisplayServices; }
591*cdf0e10cSrcweir     void            SetDisplayServiceCount( sal_uLong nVal )    { nDisplayServices = nVal; }
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir     // returns the list of service implementation names for the specified
594*cdf0e10cSrcweir     // language and service (TYPE_SPELL, TYPE_HYPH, TYPE_THES) sorted in
595*cdf0e10cSrcweir     // the proper order for the SvxEditModulesDlg (the ones from the
596*cdf0e10cSrcweir     // configuration (keeping that order!) first and then the other ones.
597*cdf0e10cSrcweir     // I.e. the ones available but not configured in arbitrary order).
598*cdf0e10cSrcweir     // They available ones may contain names that do not(!) support that
599*cdf0e10cSrcweir     // language.
600*cdf0e10cSrcweir     Sequence< OUString > GetSortedImplNames( sal_Int16 nLang, sal_uInt8 nType );
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir     ServiceInfo_Impl * GetInfoByImplName( const OUString &rSvcImplName );
603*cdf0e10cSrcweir };
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir sal_Int32 lcl_SeqGetIndex( const Sequence< OUString > &rSeq, const OUString &rTxt )
607*cdf0e10cSrcweir {
608*cdf0e10cSrcweir     sal_Int32 nRes = -1;
609*cdf0e10cSrcweir     sal_Int32 nLen = rSeq.getLength();
610*cdf0e10cSrcweir     const OUString *pString = rSeq.getConstArray();
611*cdf0e10cSrcweir     for (sal_Int32 i = 0;  i < nLen  &&  nRes == -1;  ++i)
612*cdf0e10cSrcweir     {
613*cdf0e10cSrcweir         if (pString[i] == rTxt)
614*cdf0e10cSrcweir             nRes = i;
615*cdf0e10cSrcweir     }
616*cdf0e10cSrcweir     return nRes;
617*cdf0e10cSrcweir }
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir Sequence< OUString > SvxLinguData_Impl::GetSortedImplNames( sal_Int16 nLang, sal_uInt8 nType )
621*cdf0e10cSrcweir {
622*cdf0e10cSrcweir     LangImplNameTable *pTable = 0;
623*cdf0e10cSrcweir     switch (nType)
624*cdf0e10cSrcweir     {
625*cdf0e10cSrcweir         case TYPE_SPELL     : pTable = &aCfgSpellTable; break;
626*cdf0e10cSrcweir         case TYPE_HYPH      : pTable = &aCfgHyphTable; break;
627*cdf0e10cSrcweir         case TYPE_THES      : pTable = &aCfgThesTable; break;
628*cdf0e10cSrcweir         case TYPE_GRAMMAR   : pTable = &aCfgGrammarTable; break;
629*cdf0e10cSrcweir     }
630*cdf0e10cSrcweir     Sequence< OUString > aRes;
631*cdf0e10cSrcweir     if (pTable->count( nLang ))
632*cdf0e10cSrcweir         aRes = (*pTable)[ nLang ];      // add configured services
633*cdf0e10cSrcweir     sal_Int32 nIdx = aRes.getLength();
634*cdf0e10cSrcweir     DBG_ASSERT( (sal_Int32) nDisplayServices >= nIdx, "size mismatch" );
635*cdf0e10cSrcweir     aRes.realloc( nDisplayServices );
636*cdf0e10cSrcweir     OUString *pRes = aRes.getArray();
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir     // add not configured services
639*cdf0e10cSrcweir     for (sal_Int32 i = 0;  i < (sal_Int32) nDisplayServices;  ++i)
640*cdf0e10cSrcweir     {
641*cdf0e10cSrcweir         const ServiceInfo_Impl &rInfo = aDisplayServiceArr[ i ];
642*cdf0e10cSrcweir         OUString aImplName;
643*cdf0e10cSrcweir         switch (nType)
644*cdf0e10cSrcweir         {
645*cdf0e10cSrcweir             case TYPE_SPELL     : aImplName = rInfo.sSpellImplName; break;
646*cdf0e10cSrcweir             case TYPE_HYPH      : aImplName = rInfo.sHyphImplName; break;
647*cdf0e10cSrcweir             case TYPE_THES      : aImplName = rInfo.sThesImplName; break;
648*cdf0e10cSrcweir             case TYPE_GRAMMAR   : aImplName = rInfo.sGrammarImplName; break;
649*cdf0e10cSrcweir         }
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir         if (aImplName.getLength()  &&  (lcl_SeqGetIndex( aRes, aImplName) == -1))    // name not yet added
652*cdf0e10cSrcweir         {
653*cdf0e10cSrcweir 			DBG_ASSERT( nIdx < aRes.getLength(), "index out of range" );
654*cdf0e10cSrcweir 			if (nIdx < aRes.getLength())
655*cdf0e10cSrcweir                 pRes[ nIdx++ ] = aImplName;
656*cdf0e10cSrcweir         }
657*cdf0e10cSrcweir     }
658*cdf0e10cSrcweir     // don't forget to put aRes back to its actual size just in case you allocated too much
659*cdf0e10cSrcweir     // since all of the names may have already been added
660*cdf0e10cSrcweir     // otherwise you get duplicate entries in the edit dialog
661*cdf0e10cSrcweir     aRes.realloc( nIdx );
662*cdf0e10cSrcweir     return aRes;
663*cdf0e10cSrcweir }
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir ServiceInfo_Impl * SvxLinguData_Impl::GetInfoByImplName( const OUString &rSvcImplName )
667*cdf0e10cSrcweir {
668*cdf0e10cSrcweir     ServiceInfo_Impl* pInfo = 0;
669*cdf0e10cSrcweir     for (sal_uLong i = 0;  i < nDisplayServices  &&  !pInfo;  ++i)
670*cdf0e10cSrcweir     {
671*cdf0e10cSrcweir         ServiceInfo_Impl &rTmp = aDisplayServiceArr[ i ];
672*cdf0e10cSrcweir         if (rTmp.sSpellImplName == rSvcImplName ||
673*cdf0e10cSrcweir             rTmp.sHyphImplName  == rSvcImplName ||
674*cdf0e10cSrcweir             rTmp.sThesImplName  == rSvcImplName ||
675*cdf0e10cSrcweir             rTmp.sGrammarImplName == rSvcImplName)
676*cdf0e10cSrcweir             pInfo = &rTmp;
677*cdf0e10cSrcweir     }
678*cdf0e10cSrcweir     return pInfo;
679*cdf0e10cSrcweir }
680*cdf0e10cSrcweir 
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir //-----------------------------------------------------------------------------
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir void lcl_MergeLocales(Sequence< Locale >& aAllLocales, const Sequence< Locale >& rAdd)
685*cdf0e10cSrcweir {
686*cdf0e10cSrcweir 	const Locale* pAdd = rAdd.getConstArray();
687*cdf0e10cSrcweir 	Sequence<Locale> aLocToAdd(rAdd.getLength());
688*cdf0e10cSrcweir 	const Locale* pAllLocales = aAllLocales.getConstArray();
689*cdf0e10cSrcweir 	Locale* pLocToAdd = aLocToAdd.getArray();
690*cdf0e10cSrcweir 	sal_Int32 nFound = 0;
691*cdf0e10cSrcweir 	sal_Int32 i;
692*cdf0e10cSrcweir 	for(i = 0; i < rAdd.getLength(); i++)
693*cdf0e10cSrcweir 	{
694*cdf0e10cSrcweir 		sal_Bool bFound = sal_False;
695*cdf0e10cSrcweir 		for(sal_Int32 j = 0; j < aAllLocales.getLength() && !bFound; j++)
696*cdf0e10cSrcweir 		{
697*cdf0e10cSrcweir 			bFound = pAdd[i].Language == pAllLocales[j].Language &&
698*cdf0e10cSrcweir 				pAdd[i].Country == pAllLocales[j].Country;
699*cdf0e10cSrcweir 		}
700*cdf0e10cSrcweir 		if(!bFound)
701*cdf0e10cSrcweir 		{
702*cdf0e10cSrcweir 			pLocToAdd[nFound++] = pAdd[i];
703*cdf0e10cSrcweir 		}
704*cdf0e10cSrcweir 	}
705*cdf0e10cSrcweir 	sal_Int32 nLength = aAllLocales.getLength();
706*cdf0e10cSrcweir 	aAllLocales.realloc( nLength + nFound);
707*cdf0e10cSrcweir 	Locale* pAllLocales2 = aAllLocales.getArray();
708*cdf0e10cSrcweir 	for(i = 0; i < nFound; i++)
709*cdf0e10cSrcweir 		pAllLocales2[nLength++] = pLocToAdd[i];
710*cdf0e10cSrcweir }
711*cdf0e10cSrcweir /* -----------------------------27.11.00 16:48--------------------------------
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
714*cdf0e10cSrcweir void lcl_MergeDisplayArray(
715*cdf0e10cSrcweir         SvxLinguData_Impl &rData,
716*cdf0e10cSrcweir         const ServiceInfo_Impl &rToAdd )
717*cdf0e10cSrcweir {
718*cdf0e10cSrcweir     sal_uLong nCnt = 0;
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir     ServiceInfoArr &rSvcInfoArr = rData.GetDisplayServiceArray();
721*cdf0e10cSrcweir     sal_uLong nEntries = rData.GetDisplayServiceCount();
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir     ServiceInfo_Impl* pEntry;
724*cdf0e10cSrcweir     for (sal_uLong i = 0;  i < nEntries;  ++i)
725*cdf0e10cSrcweir 	{
726*cdf0e10cSrcweir         pEntry = &rSvcInfoArr[i];
727*cdf0e10cSrcweir         if (pEntry  &&  pEntry->sDisplayName == rToAdd.sDisplayName)
728*cdf0e10cSrcweir 		{
729*cdf0e10cSrcweir             if(rToAdd.xSpell.is())
730*cdf0e10cSrcweir 			{
731*cdf0e10cSrcweir                 DBG_ASSERT( !pEntry->xSpell.is() &&
732*cdf0e10cSrcweir                             pEntry->sSpellImplName.getLength() == 0,
733*cdf0e10cSrcweir                             "merge conflict" );
734*cdf0e10cSrcweir                 pEntry->sSpellImplName = rToAdd.sSpellImplName;
735*cdf0e10cSrcweir                 pEntry->xSpell = rToAdd.xSpell;
736*cdf0e10cSrcweir 			}
737*cdf0e10cSrcweir             if(rToAdd.xGrammar.is())
738*cdf0e10cSrcweir             {
739*cdf0e10cSrcweir                 DBG_ASSERT( !pEntry->xGrammar.is() &&
740*cdf0e10cSrcweir                             pEntry->sGrammarImplName.getLength() == 0,
741*cdf0e10cSrcweir                             "merge conflict" );
742*cdf0e10cSrcweir                 pEntry->sGrammarImplName = rToAdd.sGrammarImplName;
743*cdf0e10cSrcweir                 pEntry->xGrammar = rToAdd.xGrammar;
744*cdf0e10cSrcweir             }
745*cdf0e10cSrcweir             if(rToAdd.xHyph.is())
746*cdf0e10cSrcweir 			{
747*cdf0e10cSrcweir                 DBG_ASSERT( !pEntry->xHyph.is() &&
748*cdf0e10cSrcweir                             pEntry->sHyphImplName.getLength() == 0,
749*cdf0e10cSrcweir                             "merge conflict" );
750*cdf0e10cSrcweir                 pEntry->sHyphImplName = rToAdd.sHyphImplName;
751*cdf0e10cSrcweir                 pEntry->xHyph = rToAdd.xHyph;
752*cdf0e10cSrcweir 			}
753*cdf0e10cSrcweir             if(rToAdd.xThes.is())
754*cdf0e10cSrcweir 			{
755*cdf0e10cSrcweir                 DBG_ASSERT( !pEntry->xThes.is() &&
756*cdf0e10cSrcweir                             pEntry->sThesImplName.getLength() == 0,
757*cdf0e10cSrcweir                             "merge conflict" );
758*cdf0e10cSrcweir                 pEntry->sThesImplName = rToAdd.sThesImplName;
759*cdf0e10cSrcweir                 pEntry->xThes = rToAdd.xThes;
760*cdf0e10cSrcweir 			}
761*cdf0e10cSrcweir 			return ;
762*cdf0e10cSrcweir 		}
763*cdf0e10cSrcweir         ++nCnt;
764*cdf0e10cSrcweir 	}
765*cdf0e10cSrcweir     rData.GetDisplayServiceArray().push_back( rToAdd );
766*cdf0e10cSrcweir     rData.SetDisplayServiceCount( nCnt + 1 );
767*cdf0e10cSrcweir }
768*cdf0e10cSrcweir /* -----------------------------26.11.00 18:07--------------------------------
769*cdf0e10cSrcweir 
770*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
771*cdf0e10cSrcweir SvxLinguData_Impl::SvxLinguData_Impl() :
772*cdf0e10cSrcweir     nDisplayServices    (0)
773*cdf0e10cSrcweir {
774*cdf0e10cSrcweir 	xMSF = ::comphelper::getProcessServiceFactory();
775*cdf0e10cSrcweir 	uno::Reference < XInterface > xI = xMSF->createInstance(
776*cdf0e10cSrcweir 		C2U( "com.sun.star.linguistic2.LinguServiceManager" ) );
777*cdf0e10cSrcweir 	xLinguSrvcMgr = uno::Reference<XLinguServiceManager>(xI, UNO_QUERY);
778*cdf0e10cSrcweir 	DBG_ASSERT(xLinguSrvcMgr.is(), "No linguistic service available!");
779*cdf0e10cSrcweir 	if(xLinguSrvcMgr.is())
780*cdf0e10cSrcweir 	{
781*cdf0e10cSrcweir 		Locale aCurrentLocale;
782*cdf0e10cSrcweir 	    LanguageType eLang = Application::GetSettings().GetLanguage();
783*cdf0e10cSrcweir 		SvxLanguageToLocale(aCurrentLocale, eLang);
784*cdf0e10cSrcweir 		Sequence<Any> aArgs(2);//second arguments has to be empty!
785*cdf0e10cSrcweir 		aArgs.getArray()[0] <<= SvxGetLinguPropertySet();
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir 		//read spell checker
788*cdf0e10cSrcweir 		Sequence< OUString > aSpellNames = xLinguSrvcMgr->getAvailableServices(
789*cdf0e10cSrcweir 						C2U(cSpell),	Locale() );
790*cdf0e10cSrcweir 		const OUString* pSpellNames = aSpellNames.getConstArray();
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir 		sal_Int32 nIdx;
793*cdf0e10cSrcweir 		for(nIdx = 0; nIdx < aSpellNames.getLength(); nIdx++)
794*cdf0e10cSrcweir 		{
795*cdf0e10cSrcweir             ServiceInfo_Impl aInfo;
796*cdf0e10cSrcweir             aInfo.sSpellImplName = pSpellNames[nIdx];
797*cdf0e10cSrcweir             aInfo.xSpell = uno::Reference<XSpellChecker>(
798*cdf0e10cSrcweir                             xMSF->createInstanceWithArguments(aInfo.sSpellImplName, aArgs), UNO_QUERY);
799*cdf0e10cSrcweir 
800*cdf0e10cSrcweir             uno::Reference<XServiceDisplayName> xDispName(aInfo.xSpell, UNO_QUERY);
801*cdf0e10cSrcweir             if(xDispName.is())
802*cdf0e10cSrcweir                 aInfo.sDisplayName = xDispName->getServiceDisplayName( aCurrentLocale );
803*cdf0e10cSrcweir 
804*cdf0e10cSrcweir             const Sequence< Locale > aLocales( aInfo.xSpell->getLocales() );
805*cdf0e10cSrcweir             //! suppress display of entries with no supported languages (see feature 110994)
806*cdf0e10cSrcweir             if (aLocales.getLength())
807*cdf0e10cSrcweir             {
808*cdf0e10cSrcweir                 lcl_MergeLocales( aAllServiceLocales, aLocales );
809*cdf0e10cSrcweir                 lcl_MergeDisplayArray( *this, aInfo );
810*cdf0e10cSrcweir             }
811*cdf0e10cSrcweir         }
812*cdf0e10cSrcweir 
813*cdf0e10cSrcweir         //read grammar checker
814*cdf0e10cSrcweir         Sequence< OUString > aGrammarNames = xLinguSrvcMgr->getAvailableServices(
815*cdf0e10cSrcweir                         C2U(cGrammar), Locale() );
816*cdf0e10cSrcweir         const OUString* pGrammarNames = aGrammarNames.getConstArray();
817*cdf0e10cSrcweir         for(nIdx = 0; nIdx < aGrammarNames.getLength(); nIdx++)
818*cdf0e10cSrcweir         {
819*cdf0e10cSrcweir             ServiceInfo_Impl aInfo;
820*cdf0e10cSrcweir             aInfo.sGrammarImplName = pGrammarNames[nIdx];
821*cdf0e10cSrcweir             aInfo.xGrammar = uno::Reference<XProofreader>(
822*cdf0e10cSrcweir                             xMSF->createInstanceWithArguments(aInfo.sGrammarImplName, aArgs), UNO_QUERY);
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir             uno::Reference<XServiceDisplayName> xDispName(aInfo.xGrammar, UNO_QUERY);
825*cdf0e10cSrcweir             if(xDispName.is())
826*cdf0e10cSrcweir                 aInfo.sDisplayName = xDispName->getServiceDisplayName( aCurrentLocale );
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir             const Sequence< Locale > aLocales( aInfo.xGrammar->getLocales() );
829*cdf0e10cSrcweir             //! suppress display of entries with no supported languages (see feature 110994)
830*cdf0e10cSrcweir             if (aLocales.getLength())
831*cdf0e10cSrcweir             {
832*cdf0e10cSrcweir                 lcl_MergeLocales( aAllServiceLocales, aLocales );
833*cdf0e10cSrcweir                 lcl_MergeDisplayArray( *this, aInfo );
834*cdf0e10cSrcweir             }
835*cdf0e10cSrcweir         }
836*cdf0e10cSrcweir 
837*cdf0e10cSrcweir 		//read hyphenator
838*cdf0e10cSrcweir 		Sequence< OUString > aHyphNames = xLinguSrvcMgr->getAvailableServices(
839*cdf0e10cSrcweir 						C2U(cHyph),	Locale() );
840*cdf0e10cSrcweir 		const OUString* pHyphNames = aHyphNames.getConstArray();
841*cdf0e10cSrcweir 		for(nIdx = 0; nIdx < aHyphNames.getLength(); nIdx++)
842*cdf0e10cSrcweir 		{
843*cdf0e10cSrcweir             ServiceInfo_Impl aInfo;
844*cdf0e10cSrcweir             aInfo.sHyphImplName = pHyphNames[nIdx];
845*cdf0e10cSrcweir             aInfo.xHyph = uno::Reference<XHyphenator>(
846*cdf0e10cSrcweir                             xMSF->createInstanceWithArguments(aInfo.sHyphImplName, aArgs), UNO_QUERY);
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir             uno::Reference<XServiceDisplayName> xDispName(aInfo.xHyph, UNO_QUERY);
849*cdf0e10cSrcweir             if(xDispName.is())
850*cdf0e10cSrcweir                 aInfo.sDisplayName = xDispName->getServiceDisplayName( aCurrentLocale );
851*cdf0e10cSrcweir 
852*cdf0e10cSrcweir             const Sequence< Locale > aLocales( aInfo.xHyph->getLocales() );
853*cdf0e10cSrcweir             //! suppress display of entries with no supported languages (see feature 110994)
854*cdf0e10cSrcweir             if (aLocales.getLength())
855*cdf0e10cSrcweir             {
856*cdf0e10cSrcweir                 lcl_MergeLocales( aAllServiceLocales, aLocales );
857*cdf0e10cSrcweir                 lcl_MergeDisplayArray( *this, aInfo );
858*cdf0e10cSrcweir             }
859*cdf0e10cSrcweir 		}
860*cdf0e10cSrcweir 
861*cdf0e10cSrcweir 		//read thesauri
862*cdf0e10cSrcweir 		Sequence< OUString > aThesNames = xLinguSrvcMgr->getAvailableServices(
863*cdf0e10cSrcweir 						C2U(cThes),		Locale() );
864*cdf0e10cSrcweir 		const OUString* pThesNames = aThesNames.getConstArray();
865*cdf0e10cSrcweir 		for(nIdx = 0; nIdx < aThesNames.getLength(); nIdx++)
866*cdf0e10cSrcweir 		{
867*cdf0e10cSrcweir             ServiceInfo_Impl aInfo;
868*cdf0e10cSrcweir             aInfo.sThesImplName = pThesNames[nIdx];
869*cdf0e10cSrcweir             aInfo.xThes = uno::Reference<XThesaurus>(
870*cdf0e10cSrcweir                             xMSF->createInstanceWithArguments(aInfo.sThesImplName, aArgs), UNO_QUERY);
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir             uno::Reference<XServiceDisplayName> xDispName(aInfo.xThes, UNO_QUERY);
873*cdf0e10cSrcweir             if(xDispName.is())
874*cdf0e10cSrcweir                 aInfo.sDisplayName = xDispName->getServiceDisplayName( aCurrentLocale );
875*cdf0e10cSrcweir 
876*cdf0e10cSrcweir             const Sequence< Locale > aLocales( aInfo.xThes->getLocales() );
877*cdf0e10cSrcweir             //! suppress display of entries with no supported languages (see feature 110994)
878*cdf0e10cSrcweir             if (aLocales.getLength())
879*cdf0e10cSrcweir             {
880*cdf0e10cSrcweir                 lcl_MergeLocales( aAllServiceLocales, aLocales );
881*cdf0e10cSrcweir                 lcl_MergeDisplayArray( *this, aInfo );
882*cdf0e10cSrcweir             }
883*cdf0e10cSrcweir 		}
884*cdf0e10cSrcweir 
885*cdf0e10cSrcweir         Sequence< OUString > aCfgSvcs;
886*cdf0e10cSrcweir 		const Locale* pAllLocales = aAllServiceLocales.getConstArray();
887*cdf0e10cSrcweir 		for(sal_Int32 nLocale = 0; nLocale < aAllServiceLocales.getLength(); nLocale++)
888*cdf0e10cSrcweir 		{
889*cdf0e10cSrcweir             sal_Int16 nLang = SvxLocaleToLanguage( pAllLocales[nLocale] );
890*cdf0e10cSrcweir 
891*cdf0e10cSrcweir             aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(C2U(cSpell), pAllLocales[nLocale]);
892*cdf0e10cSrcweir             SetChecked( aCfgSvcs );
893*cdf0e10cSrcweir             if (aCfgSvcs.getLength())
894*cdf0e10cSrcweir                 aCfgSpellTable[ nLang ] = aCfgSvcs;
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir             aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(C2U(cGrammar), pAllLocales[nLocale]);
897*cdf0e10cSrcweir             SetChecked( aCfgSvcs );
898*cdf0e10cSrcweir             if (aCfgSvcs.getLength())
899*cdf0e10cSrcweir                 aCfgGrammarTable[ nLang ] = aCfgSvcs;
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir             aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(C2U(cHyph), pAllLocales[nLocale]);
902*cdf0e10cSrcweir             SetChecked( aCfgSvcs );
903*cdf0e10cSrcweir             if (aCfgSvcs.getLength())
904*cdf0e10cSrcweir                 aCfgHyphTable[ nLang ] = aCfgSvcs;
905*cdf0e10cSrcweir 
906*cdf0e10cSrcweir             aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(C2U(cThes), pAllLocales[nLocale]);
907*cdf0e10cSrcweir             SetChecked( aCfgSvcs );
908*cdf0e10cSrcweir             if (aCfgSvcs.getLength())
909*cdf0e10cSrcweir                 aCfgThesTable[ nLang ] = aCfgSvcs;
910*cdf0e10cSrcweir 		}
911*cdf0e10cSrcweir 	}
912*cdf0e10cSrcweir }
913*cdf0e10cSrcweir /* -----------------------------22.05.01 10:43--------------------------------
914*cdf0e10cSrcweir 
915*cdf0e10cSrcweir ---------------------------------------------------------------------------*/
916*cdf0e10cSrcweir SvxLinguData_Impl::SvxLinguData_Impl( const SvxLinguData_Impl &rData ) :
917*cdf0e10cSrcweir     aDisplayServiceArr  (rData.aDisplayServiceArr),
918*cdf0e10cSrcweir     nDisplayServices    (rData.nDisplayServices),
919*cdf0e10cSrcweir     aAllServiceLocales  (rData.aAllServiceLocales),
920*cdf0e10cSrcweir     aCfgSpellTable      (rData.aCfgSpellTable),
921*cdf0e10cSrcweir     aCfgHyphTable       (rData.aCfgHyphTable),
922*cdf0e10cSrcweir     aCfgThesTable       (rData.aCfgThesTable),
923*cdf0e10cSrcweir     aCfgGrammarTable    (rData.aCfgGrammarTable),
924*cdf0e10cSrcweir     xMSF                (rData.xMSF),
925*cdf0e10cSrcweir     xLinguSrvcMgr       (rData.xLinguSrvcMgr)
926*cdf0e10cSrcweir {
927*cdf0e10cSrcweir }
928*cdf0e10cSrcweir /* -----------------------------22.05.01 10:43--------------------------------
929*cdf0e10cSrcweir 
930*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
931*cdf0e10cSrcweir SvxLinguData_Impl & SvxLinguData_Impl::operator = (const SvxLinguData_Impl &rData)
932*cdf0e10cSrcweir {
933*cdf0e10cSrcweir     xMSF                = rData.xMSF;
934*cdf0e10cSrcweir     xLinguSrvcMgr       = rData.xLinguSrvcMgr;
935*cdf0e10cSrcweir     aAllServiceLocales  = rData.aAllServiceLocales;
936*cdf0e10cSrcweir     aCfgSpellTable      = rData.aCfgSpellTable;
937*cdf0e10cSrcweir     aCfgHyphTable       = rData.aCfgHyphTable;
938*cdf0e10cSrcweir     aCfgThesTable       = rData.aCfgThesTable;
939*cdf0e10cSrcweir     aCfgGrammarTable    = rData.aCfgGrammarTable;
940*cdf0e10cSrcweir     aDisplayServiceArr  = rData.aDisplayServiceArr;
941*cdf0e10cSrcweir     nDisplayServices    = rData.nDisplayServices;
942*cdf0e10cSrcweir     return *this;
943*cdf0e10cSrcweir }
944*cdf0e10cSrcweir /* -----------------------------26.11.00 18:08--------------------------------
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
947*cdf0e10cSrcweir SvxLinguData_Impl::~SvxLinguData_Impl()
948*cdf0e10cSrcweir {
949*cdf0e10cSrcweir }
950*cdf0e10cSrcweir /* -----------------------------26.11.00 19:42--------------------------------
951*cdf0e10cSrcweir 
952*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
953*cdf0e10cSrcweir void SvxLinguData_Impl::SetChecked(const Sequence<OUString>& rConfiguredServices)
954*cdf0e10cSrcweir {
955*cdf0e10cSrcweir 	const OUString* pConfiguredServices = rConfiguredServices.getConstArray();
956*cdf0e10cSrcweir 	for(sal_Int32 n = 0; n < rConfiguredServices.getLength(); n++)
957*cdf0e10cSrcweir 	{
958*cdf0e10cSrcweir         ServiceInfo_Impl* pEntry;
959*cdf0e10cSrcweir         for (sal_uLong i = 0;  i < nDisplayServices;  ++i)
960*cdf0e10cSrcweir 		{
961*cdf0e10cSrcweir             pEntry = &aDisplayServiceArr[i];
962*cdf0e10cSrcweir             if (pEntry  &&  !pEntry->bConfigured)
963*cdf0e10cSrcweir             {
964*cdf0e10cSrcweir                 const OUString &rSrvcImplName = pConfiguredServices[n];
965*cdf0e10cSrcweir                 if (rSrvcImplName.getLength()  &&
966*cdf0e10cSrcweir                     (pEntry->sSpellImplName == rSrvcImplName  ||
967*cdf0e10cSrcweir                         pEntry->sGrammarImplName  == rSrvcImplName  ||
968*cdf0e10cSrcweir                         pEntry->sHyphImplName  == rSrvcImplName  ||
969*cdf0e10cSrcweir                         pEntry->sThesImplName  == rSrvcImplName))
970*cdf0e10cSrcweir                 {
971*cdf0e10cSrcweir                     pEntry->bConfigured = sal_True;
972*cdf0e10cSrcweir                     break;
973*cdf0e10cSrcweir                 }
974*cdf0e10cSrcweir             }
975*cdf0e10cSrcweir 		}
976*cdf0e10cSrcweir 	}
977*cdf0e10cSrcweir }
978*cdf0e10cSrcweir /* -----------------------------26.11.00 20:43--------------------------------
979*cdf0e10cSrcweir 
980*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
981*cdf0e10cSrcweir 
982*cdf0e10cSrcweir sal_Bool SvxLinguData_Impl::AddRemove(
983*cdf0e10cSrcweir             Sequence< OUString > &rConfigured,
984*cdf0e10cSrcweir             const OUString &rImplName, sal_Bool bAdd )
985*cdf0e10cSrcweir {
986*cdf0e10cSrcweir     sal_Bool bRet = sal_False;  // modified?
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir     sal_Int32 nEntries = rConfigured.getLength();
989*cdf0e10cSrcweir     sal_Int32 nPos = lcl_SeqGetEntryPos(rConfigured, rImplName);
990*cdf0e10cSrcweir     if (bAdd  &&  nPos < 0)         // add new entry
991*cdf0e10cSrcweir     {
992*cdf0e10cSrcweir         rConfigured.realloc( ++nEntries );
993*cdf0e10cSrcweir         OUString *pConfigured = rConfigured.getArray();
994*cdf0e10cSrcweir         pConfigured = rConfigured.getArray();
995*cdf0e10cSrcweir         pConfigured[nEntries - 1] = rImplName;
996*cdf0e10cSrcweir         bRet = sal_True;
997*cdf0e10cSrcweir     }
998*cdf0e10cSrcweir     else if (!bAdd  &&  nPos >= 0)  // remove existing entry
999*cdf0e10cSrcweir     {
1000*cdf0e10cSrcweir         OUString *pConfigured = rConfigured.getArray();
1001*cdf0e10cSrcweir         for (sal_Int32 i = nPos;  i < nEntries - 1;  ++i)
1002*cdf0e10cSrcweir             pConfigured[i] = pConfigured[i + 1];
1003*cdf0e10cSrcweir         rConfigured.realloc(--nEntries);
1004*cdf0e10cSrcweir         bRet = sal_True;
1005*cdf0e10cSrcweir     }
1006*cdf0e10cSrcweir 
1007*cdf0e10cSrcweir 	return bRet;
1008*cdf0e10cSrcweir }
1009*cdf0e10cSrcweir 
1010*cdf0e10cSrcweir 
1011*cdf0e10cSrcweir void SvxLinguData_Impl::Reconfigure( const OUString &rDisplayName, sal_Bool bEnable )
1012*cdf0e10cSrcweir {
1013*cdf0e10cSrcweir     DBG_ASSERT( rDisplayName.getLength(), "empty DisplayName" );
1014*cdf0e10cSrcweir 
1015*cdf0e10cSrcweir     ServiceInfo_Impl *pInfo = 0;
1016*cdf0e10cSrcweir     ServiceInfo_Impl *pTmp  = 0;
1017*cdf0e10cSrcweir     for (sal_uLong i = 0;  i < nDisplayServices;  ++i)
1018*cdf0e10cSrcweir     {
1019*cdf0e10cSrcweir         pTmp = &aDisplayServiceArr[i];
1020*cdf0e10cSrcweir         if (pTmp  &&  pTmp->sDisplayName == rDisplayName)
1021*cdf0e10cSrcweir         {
1022*cdf0e10cSrcweir             pInfo = pTmp;
1023*cdf0e10cSrcweir             break;
1024*cdf0e10cSrcweir         }
1025*cdf0e10cSrcweir     }
1026*cdf0e10cSrcweir     DBG_ASSERT( pInfo, "DisplayName entry not found" );
1027*cdf0e10cSrcweir     if (pInfo)
1028*cdf0e10cSrcweir     {
1029*cdf0e10cSrcweir         pInfo->bConfigured = bEnable;
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir         Sequence< Locale > aLocales;
1032*cdf0e10cSrcweir         const Locale *pLocale = 0;
1033*cdf0e10cSrcweir         sal_Int32 nLocales = 0;
1034*cdf0e10cSrcweir         sal_Int32 i;
1035*cdf0e10cSrcweir 
1036*cdf0e10cSrcweir         // update configured spellchecker entries
1037*cdf0e10cSrcweir         if (pInfo->xSpell.is())
1038*cdf0e10cSrcweir         {
1039*cdf0e10cSrcweir             aLocales = pInfo->xSpell->getLocales();
1040*cdf0e10cSrcweir             pLocale = aLocales.getConstArray();
1041*cdf0e10cSrcweir             nLocales = aLocales.getLength();
1042*cdf0e10cSrcweir             for (i = 0;  i < nLocales;  ++i)
1043*cdf0e10cSrcweir             {
1044*cdf0e10cSrcweir                 sal_Int16 nLang = SvxLocaleToLanguage( pLocale[i] );
1045*cdf0e10cSrcweir                 if (!aCfgSpellTable.count( nLang ) && bEnable)
1046*cdf0e10cSrcweir                     aCfgSpellTable[ nLang ] = Sequence< OUString >();
1047*cdf0e10cSrcweir                 if (aCfgSpellTable.count( nLang ))
1048*cdf0e10cSrcweir                     AddRemove( aCfgSpellTable[ nLang ], pInfo->sSpellImplName, bEnable );
1049*cdf0e10cSrcweir             }
1050*cdf0e10cSrcweir         }
1051*cdf0e10cSrcweir 
1052*cdf0e10cSrcweir         // update configured grammar checker entries
1053*cdf0e10cSrcweir         if (pInfo->xGrammar.is())
1054*cdf0e10cSrcweir         {
1055*cdf0e10cSrcweir             aLocales = pInfo->xGrammar->getLocales();
1056*cdf0e10cSrcweir             pLocale = aLocales.getConstArray();
1057*cdf0e10cSrcweir             nLocales = aLocales.getLength();
1058*cdf0e10cSrcweir             for (i = 0;  i < nLocales;  ++i)
1059*cdf0e10cSrcweir             {
1060*cdf0e10cSrcweir                 sal_Int16 nLang = SvxLocaleToLanguage( pLocale[i] );
1061*cdf0e10cSrcweir                 if (!aCfgGrammarTable.count( nLang ) && bEnable)
1062*cdf0e10cSrcweir                     aCfgGrammarTable[ nLang ] = Sequence< OUString >();
1063*cdf0e10cSrcweir                 if (aCfgGrammarTable.count( nLang ))
1064*cdf0e10cSrcweir                     AddRemove( aCfgGrammarTable[ nLang ], pInfo->sGrammarImplName, bEnable );
1065*cdf0e10cSrcweir             }
1066*cdf0e10cSrcweir         }
1067*cdf0e10cSrcweir 
1068*cdf0e10cSrcweir         // update configured hyphenator entries
1069*cdf0e10cSrcweir         if (pInfo->xHyph.is())
1070*cdf0e10cSrcweir         {
1071*cdf0e10cSrcweir             aLocales = pInfo->xHyph->getLocales();
1072*cdf0e10cSrcweir             pLocale = aLocales.getConstArray();
1073*cdf0e10cSrcweir             nLocales = aLocales.getLength();
1074*cdf0e10cSrcweir             for (i = 0;  i < nLocales;  ++i)
1075*cdf0e10cSrcweir             {
1076*cdf0e10cSrcweir                 sal_Int16 nLang = SvxLocaleToLanguage( pLocale[i] );
1077*cdf0e10cSrcweir                 if (!aCfgHyphTable.count( nLang ) && bEnable)
1078*cdf0e10cSrcweir                     aCfgHyphTable[ nLang ] = Sequence< OUString >();
1079*cdf0e10cSrcweir                 if (aCfgHyphTable.count( nLang ))
1080*cdf0e10cSrcweir                     AddRemove( aCfgHyphTable[ nLang ], pInfo->sHyphImplName, bEnable );
1081*cdf0e10cSrcweir             }
1082*cdf0e10cSrcweir         }
1083*cdf0e10cSrcweir 
1084*cdf0e10cSrcweir         // update configured spellchecker entries
1085*cdf0e10cSrcweir         if (pInfo->xThes.is())
1086*cdf0e10cSrcweir         {
1087*cdf0e10cSrcweir             aLocales = pInfo->xThes->getLocales();
1088*cdf0e10cSrcweir             pLocale = aLocales.getConstArray();
1089*cdf0e10cSrcweir             nLocales = aLocales.getLength();
1090*cdf0e10cSrcweir             for (i = 0;  i < nLocales;  ++i)
1091*cdf0e10cSrcweir             {
1092*cdf0e10cSrcweir                 sal_Int16 nLang = SvxLocaleToLanguage( pLocale[i] );
1093*cdf0e10cSrcweir                 if (!aCfgThesTable.count( nLang ) && bEnable)
1094*cdf0e10cSrcweir                     aCfgThesTable[ nLang ] = Sequence< OUString >();
1095*cdf0e10cSrcweir                 if (aCfgThesTable.count( nLang ))
1096*cdf0e10cSrcweir                     AddRemove( aCfgThesTable[ nLang ], pInfo->sThesImplName, bEnable );
1097*cdf0e10cSrcweir             }
1098*cdf0e10cSrcweir         }
1099*cdf0e10cSrcweir     }
1100*cdf0e10cSrcweir }
1101*cdf0e10cSrcweir 
1102*cdf0e10cSrcweir 
1103*cdf0e10cSrcweir // class SvxLinguTabPage -------------------------------------------------
1104*cdf0e10cSrcweir 
1105*cdf0e10cSrcweir #define CBCOL_FIRST		0
1106*cdf0e10cSrcweir #define CBCOL_SECOND	1
1107*cdf0e10cSrcweir #define CBCOL_BOTH		2
1108*cdf0e10cSrcweir 
1109*cdf0e10cSrcweir SvxLinguTabPage::SvxLinguTabPage( Window* pParent,
1110*cdf0e10cSrcweir 								  const SfxItemSet& rSet ):
1111*cdf0e10cSrcweir 
1112*cdf0e10cSrcweir 	SfxTabPage( pParent, CUI_RES( RID_SFXPAGE_LINGU ), rSet ),
1113*cdf0e10cSrcweir 
1114*cdf0e10cSrcweir     aLinguisticFL       ( this, CUI_RES( FL_LINGUISTIC ) ),
1115*cdf0e10cSrcweir 	aLinguModulesFT		( this, CUI_RES( FT_LINGU_MODULES ) ),
1116*cdf0e10cSrcweir 	aLinguModulesCLB	( this, CUI_RES( CLB_LINGU_MODULES ) ),
1117*cdf0e10cSrcweir 	aLinguModulesEditPB	( this, CUI_RES( PB_LINGU_MODULES_EDIT ) ),
1118*cdf0e10cSrcweir     aLinguDicsFT        ( this, CUI_RES( FT_LINGU_DICS ) ),
1119*cdf0e10cSrcweir     aLinguDicsCLB       ( this, CUI_RES( CLB_LINGU_DICS ) ),
1120*cdf0e10cSrcweir     aLinguDicsNewPB     ( this, CUI_RES( PB_LINGU_DICS_NEW_DIC ) ),
1121*cdf0e10cSrcweir     aLinguDicsEditPB    ( this, CUI_RES( PB_LINGU_DICS_EDIT_DIC ) ),
1122*cdf0e10cSrcweir     aLinguDicsDelPB     ( this, CUI_RES( PB_LINGU_DICS_DEL_DIC ) ),
1123*cdf0e10cSrcweir 	aLinguOptionsFT		( this, CUI_RES( FT_LINGU_OPTIONS ) ),
1124*cdf0e10cSrcweir 	aLinguOptionsCLB	( this, CUI_RES( CLB_LINGU_OPTIONS ) ),
1125*cdf0e10cSrcweir     aLinguOptionsEditPB ( this, CUI_RES( PB_LINGU_OPTIONS_EDIT ) ),
1126*cdf0e10cSrcweir     aMoreDictsLink      ( this, CUI_RES( FT_LINGU_OPTIONS_MOREDICTS ) ),
1127*cdf0e10cSrcweir 	sCapitalWords		( CUI_RES( STR_CAPITAL_WORDS ) ),
1128*cdf0e10cSrcweir 	sWordsWithDigits	( CUI_RES( STR_WORDS_WITH_DIGITS ) ),
1129*cdf0e10cSrcweir 	sCapitalization		( CUI_RES( STR_CAPITALIZATION ) ),
1130*cdf0e10cSrcweir 	sSpellSpecial		( CUI_RES( STR_SPELL_SPECIAL ) ),
1131*cdf0e10cSrcweir 	sSpellAuto			( CUI_RES( STR_SPELL_AUTO ) ),
1132*cdf0e10cSrcweir     sGrammarAuto        ( CUI_RES( STR_GRAMMAR_AUTO ) ),
1133*cdf0e10cSrcweir 	sNumMinWordlen  	( CUI_RES( STR_NUM_MIN_WORDLEN ) ),
1134*cdf0e10cSrcweir 	sNumPreBreak		( CUI_RES( STR_NUM_PRE_BREAK ) ),
1135*cdf0e10cSrcweir 	sNumPostBreak		( CUI_RES( STR_NUM_POST_BREAK ) ),
1136*cdf0e10cSrcweir 	sHyphAuto			( CUI_RES( STR_HYPH_AUTO ) ),
1137*cdf0e10cSrcweir 	sHyphSpecial		( CUI_RES( STR_HYPH_SPECIAL ) ),
1138*cdf0e10cSrcweir 
1139*cdf0e10cSrcweir 	pLinguData			( NULL )
1140*cdf0e10cSrcweir {
1141*cdf0e10cSrcweir 	pCheckButtonData = NULL;
1142*cdf0e10cSrcweir 
1143*cdf0e10cSrcweir     aLinguModulesCLB.SetStyle( aLinguModulesCLB.GetStyle()|WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
1144*cdf0e10cSrcweir 	aLinguModulesCLB.SetHelpId(HID_CLB_LINGU_MODULES );
1145*cdf0e10cSrcweir 	aLinguModulesCLB.SetHighlightRange();
1146*cdf0e10cSrcweir 	aLinguModulesCLB.SetSelectHdl( LINK( this, SvxLinguTabPage, SelectHdl_Impl ));
1147*cdf0e10cSrcweir     aLinguModulesCLB.SetDoubleClickHdl(LINK(this, SvxLinguTabPage, BoxDoubleClickHdl_Impl));
1148*cdf0e10cSrcweir     aLinguModulesCLB.SetCheckButtonHdl(LINK(this, SvxLinguTabPage, BoxCheckButtonHdl_Impl));
1149*cdf0e10cSrcweir 
1150*cdf0e10cSrcweir 	aLinguModulesEditPB.SetClickHdl( LINK( this, SvxLinguTabPage, ClickHdl_Impl ));
1151*cdf0e10cSrcweir 	aLinguOptionsEditPB.SetClickHdl( LINK( this, SvxLinguTabPage, ClickHdl_Impl ));
1152*cdf0e10cSrcweir 
1153*cdf0e10cSrcweir     aLinguDicsCLB.SetStyle( aLinguDicsCLB.GetStyle()|WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
1154*cdf0e10cSrcweir     aLinguDicsCLB.SetHelpId(HID_CLB_EDIT_MODULES_DICS );
1155*cdf0e10cSrcweir     aLinguDicsCLB.SetHighlightRange();
1156*cdf0e10cSrcweir     aLinguDicsCLB.SetSelectHdl( LINK( this, SvxLinguTabPage, SelectHdl_Impl ));
1157*cdf0e10cSrcweir     aLinguDicsCLB.SetCheckButtonHdl(LINK(this, SvxLinguTabPage, BoxCheckButtonHdl_Impl));
1158*cdf0e10cSrcweir 
1159*cdf0e10cSrcweir     aLinguDicsNewPB.SetClickHdl( LINK( this, SvxLinguTabPage, ClickHdl_Impl ));
1160*cdf0e10cSrcweir     aLinguDicsEditPB.SetClickHdl( LINK( this, SvxLinguTabPage, ClickHdl_Impl ));
1161*cdf0e10cSrcweir     aLinguDicsDelPB.SetClickHdl( LINK( this, SvxLinguTabPage, ClickHdl_Impl ));
1162*cdf0e10cSrcweir 
1163*cdf0e10cSrcweir     aLinguOptionsCLB.SetStyle( aLinguOptionsCLB.GetStyle()|WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
1164*cdf0e10cSrcweir 	aLinguOptionsCLB.SetHelpId(HID_CLB_LINGU_OPTIONS );
1165*cdf0e10cSrcweir 	aLinguOptionsCLB.SetHighlightRange();
1166*cdf0e10cSrcweir 	aLinguOptionsCLB.SetSelectHdl( LINK( this, SvxLinguTabPage, SelectHdl_Impl ));
1167*cdf0e10cSrcweir     aLinguOptionsCLB.SetDoubleClickHdl(LINK(this, SvxLinguTabPage, BoxDoubleClickHdl_Impl));
1168*cdf0e10cSrcweir 
1169*cdf0e10cSrcweir     if ( SvtExtendedSecurityOptions().GetOpenHyperlinkMode()
1170*cdf0e10cSrcweir             != SvtExtendedSecurityOptions::OPEN_NEVER )
1171*cdf0e10cSrcweir     {
1172*cdf0e10cSrcweir         aMoreDictsLink.SetURL( String(
1173*cdf0e10cSrcweir             RTL_CONSTASCII_STRINGPARAM( "http://extensions.services.openoffice.org/dictionary?cid=926386" ) ) );
1174*cdf0e10cSrcweir         aMoreDictsLink.SetClickHdl( LINK( this, SvxLinguTabPage, OpenURLHdl_Impl ) );
1175*cdf0e10cSrcweir     }
1176*cdf0e10cSrcweir     else
1177*cdf0e10cSrcweir         aMoreDictsLink.Hide();
1178*cdf0e10cSrcweir 
1179*cdf0e10cSrcweir 	String sAccessibleNameModuleEdit( CUI_RES( STR_LINGU_MODULES_EDIT ) );
1180*cdf0e10cSrcweir 	String sAccessibleNameDicsEdit	( CUI_RES( STR_LINGU_DICS_EDIT_DIC ) );
1181*cdf0e10cSrcweir 	String sAccessibleNameOptionEdit( CUI_RES( STR_LINGU_OPTIONS_EDIT ) );
1182*cdf0e10cSrcweir 
1183*cdf0e10cSrcweir 	aLinguModulesEditPB.SetAccessibleName(sAccessibleNameModuleEdit);
1184*cdf0e10cSrcweir 	aLinguDicsEditPB.SetAccessibleName(sAccessibleNameDicsEdit);
1185*cdf0e10cSrcweir 	aLinguOptionsEditPB.SetAccessibleName(sAccessibleNameOptionEdit);
1186*cdf0e10cSrcweir 
1187*cdf0e10cSrcweir     // force recalculation of hash value used for checking the need of updating
1188*cdf0e10cSrcweir     // because new dictionaries might be installed / downloaded.
1189*cdf0e10cSrcweir     //! Thus it needs to be called now since it may infuence the supported languages
1190*cdf0e10cSrcweir     //! to be reported AND the found user-dictionaries(!) as well.
1191*cdf0e10cSrcweir     SvxLinguConfigUpdate::UpdateAll( sal_True );
1192*cdf0e10cSrcweir 
1193*cdf0e10cSrcweir     xProp = uno::Reference< XPropertySet >( SvxGetLinguPropertySet(), UNO_QUERY );
1194*cdf0e10cSrcweir 	xDicList = uno::Reference< XDictionaryList >( SvxGetDictionaryList(), UNO_QUERY );
1195*cdf0e10cSrcweir 	if (xDicList.is())
1196*cdf0e10cSrcweir 	{
1197*cdf0e10cSrcweir         // keep references to all **currently** available dictionaries,
1198*cdf0e10cSrcweir         // since the diclist may get changed meanwhile (e.g. through the API).
1199*cdf0e10cSrcweir         // We want the dialog to operate on the same set of dictionaries it
1200*cdf0e10cSrcweir         // was started with.
1201*cdf0e10cSrcweir         // Also we have to take care to not loose the last reference when
1202*cdf0e10cSrcweir         // someone else removes a dictionary from the list.
1203*cdf0e10cSrcweir         // removed dics will be replaced by NULL new entries be added to the end
1204*cdf0e10cSrcweir         // Thus we may use indizes as consistent references.
1205*cdf0e10cSrcweir         aDics = xDicList->getDictionaries();
1206*cdf0e10cSrcweir 
1207*cdf0e10cSrcweir         UpdateDicBox_Impl();
1208*cdf0e10cSrcweir 	}
1209*cdf0e10cSrcweir 	else
1210*cdf0e10cSrcweir 	{
1211*cdf0e10cSrcweir         aLinguDicsFT.Disable();
1212*cdf0e10cSrcweir         aLinguDicsCLB.Disable();
1213*cdf0e10cSrcweir         aLinguDicsNewPB.Disable();
1214*cdf0e10cSrcweir         aLinguDicsEditPB.Disable();
1215*cdf0e10cSrcweir         aLinguDicsDelPB.Disable();
1216*cdf0e10cSrcweir 	}
1217*cdf0e10cSrcweir 
1218*cdf0e10cSrcweir 	const SfxSpellCheckItem* pItem = 0;
1219*cdf0e10cSrcweir 	SfxItemState eItemState = SFX_ITEM_UNKNOWN;
1220*cdf0e10cSrcweir 
1221*cdf0e10cSrcweir 	eItemState = rSet.GetItemState( GetWhich( SID_ATTR_SPELL ),
1222*cdf0e10cSrcweir 									sal_False, (const SfxPoolItem**)&pItem );
1223*cdf0e10cSrcweir 
1224*cdf0e10cSrcweir 	// handelt es sich um ein Default-Item?
1225*cdf0e10cSrcweir 	if ( eItemState == SFX_ITEM_DEFAULT )
1226*cdf0e10cSrcweir 		pItem = (const SfxSpellCheckItem*)&(rSet.Get( GetWhich( SID_ATTR_SPELL ) ) );
1227*cdf0e10cSrcweir 	else if ( eItemState == SFX_ITEM_DONTCARE )
1228*cdf0e10cSrcweir 		pItem = NULL;
1229*cdf0e10cSrcweir 
1230*cdf0e10cSrcweir 	FreeResource();
1231*cdf0e10cSrcweir }
1232*cdf0e10cSrcweir 
1233*cdf0e10cSrcweir // -----------------------------------------------------------------------
1234*cdf0e10cSrcweir 
1235*cdf0e10cSrcweir SvxLinguTabPage::~SvxLinguTabPage()
1236*cdf0e10cSrcweir {
1237*cdf0e10cSrcweir 	if (pLinguData)
1238*cdf0e10cSrcweir 		delete pLinguData;
1239*cdf0e10cSrcweir }
1240*cdf0e10cSrcweir 
1241*cdf0e10cSrcweir //------------------------------------------------------------------------
1242*cdf0e10cSrcweir 
1243*cdf0e10cSrcweir //nicht �berladen wegschmeissen
1244*cdf0e10cSrcweir sal_uInt16* SvxLinguTabPage::GetRanges()
1245*cdf0e10cSrcweir {
1246*cdf0e10cSrcweir 	//TL???
1247*cdf0e10cSrcweir 	return pRanges;
1248*cdf0e10cSrcweir }
1249*cdf0e10cSrcweir 
1250*cdf0e10cSrcweir //------------------------------------------------------------------------
1251*cdf0e10cSrcweir 
1252*cdf0e10cSrcweir SfxTabPage* SvxLinguTabPage::Create( Window* pParent,
1253*cdf0e10cSrcweir 									 const SfxItemSet& rAttrSet )
1254*cdf0e10cSrcweir {
1255*cdf0e10cSrcweir 	return ( new SvxLinguTabPage( pParent, rAttrSet ) );
1256*cdf0e10cSrcweir }
1257*cdf0e10cSrcweir 
1258*cdf0e10cSrcweir //------------------------------------------------------------------------
1259*cdf0e10cSrcweir 
1260*cdf0e10cSrcweir Any lcl_Bool2Any(sal_Bool bVal)
1261*cdf0e10cSrcweir {
1262*cdf0e10cSrcweir 	Any aRet(&bVal, ::getBooleanCppuType());
1263*cdf0e10cSrcweir 	return aRet;
1264*cdf0e10cSrcweir }
1265*cdf0e10cSrcweir 
1266*cdf0e10cSrcweir 
1267*cdf0e10cSrcweir sal_Bool lcl_Bool2Any(Any& rVal)
1268*cdf0e10cSrcweir {
1269*cdf0e10cSrcweir 	return *(sal_Bool*)rVal.getValue();
1270*cdf0e10cSrcweir }
1271*cdf0e10cSrcweir 
1272*cdf0e10cSrcweir 
1273*cdf0e10cSrcweir sal_Bool SvxLinguTabPage::FillItemSet( SfxItemSet& rCoreSet )
1274*cdf0e10cSrcweir {
1275*cdf0e10cSrcweir 	sal_Bool bModified = sal_True; // !!!!
1276*cdf0e10cSrcweir 
1277*cdf0e10cSrcweir 	// if not HideGroups was called with GROUP_MODULES...
1278*cdf0e10cSrcweir 	if (aLinguModulesCLB.IsVisible())
1279*cdf0e10cSrcweir 	{
1280*cdf0e10cSrcweir         DBG_ASSERT( pLinguData, "pLinguData not yet initialized" );
1281*cdf0e10cSrcweir         if (!pLinguData)
1282*cdf0e10cSrcweir             pLinguData = new SvxLinguData_Impl;
1283*cdf0e10cSrcweir 
1284*cdf0e10cSrcweir         LangImplNameTable::const_iterator aIt;
1285*cdf0e10cSrcweir 
1286*cdf0e10cSrcweir         // update spellchecker configuration entries
1287*cdf0e10cSrcweir         const LangImplNameTable *pTable = &pLinguData->GetSpellTable();
1288*cdf0e10cSrcweir         for (aIt = pTable->begin();  aIt != pTable->end();  ++aIt)
1289*cdf0e10cSrcweir         {
1290*cdf0e10cSrcweir             sal_Int16 nLang = aIt->first;
1291*cdf0e10cSrcweir             const Sequence< OUString > aImplNames( aIt->second );
1292*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1293*cdf0e10cSrcweir             const OUString *pTmpStr;
1294*cdf0e10cSrcweir             pTmpStr = aImplNames.getConstArray();
1295*cdf0e10cSrcweir #endif
1296*cdf0e10cSrcweir             uno::Reference< XLinguServiceManager > xMgr( pLinguData->GetManager() );
1297*cdf0e10cSrcweir             Locale aLocale( SvxCreateLocale(nLang) );
1298*cdf0e10cSrcweir             if (xMgr.is())
1299*cdf0e10cSrcweir                 xMgr->setConfiguredServices( C2U(cSpell), aLocale, aImplNames );
1300*cdf0e10cSrcweir         }
1301*cdf0e10cSrcweir 
1302*cdf0e10cSrcweir         // update grammar checker configuration entries
1303*cdf0e10cSrcweir         pTable = &pLinguData->GetGrammarTable();
1304*cdf0e10cSrcweir         for (aIt = pTable->begin();  aIt != pTable->end();  ++aIt)
1305*cdf0e10cSrcweir         {
1306*cdf0e10cSrcweir             sal_Int16 nLang = aIt->first;
1307*cdf0e10cSrcweir             const Sequence< OUString > aImplNames( aIt->second );
1308*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1309*cdf0e10cSrcweir             const OUString *pTmpStr;
1310*cdf0e10cSrcweir             pTmpStr = aImplNames.getConstArray();
1311*cdf0e10cSrcweir #endif
1312*cdf0e10cSrcweir             uno::Reference< XLinguServiceManager > xMgr( pLinguData->GetManager() );
1313*cdf0e10cSrcweir             Locale aLocale( SvxCreateLocale(nLang) );
1314*cdf0e10cSrcweir             if (xMgr.is())
1315*cdf0e10cSrcweir                 xMgr->setConfiguredServices( C2U(cGrammar), aLocale, aImplNames );
1316*cdf0e10cSrcweir         }
1317*cdf0e10cSrcweir 
1318*cdf0e10cSrcweir         // update hyphenator configuration entries
1319*cdf0e10cSrcweir         pTable = &pLinguData->GetHyphTable();
1320*cdf0e10cSrcweir         for (aIt = pTable->begin();  aIt != pTable->end();  ++aIt)
1321*cdf0e10cSrcweir         {
1322*cdf0e10cSrcweir             sal_Int16 nLang = aIt->first;
1323*cdf0e10cSrcweir             const Sequence< OUString > aImplNames( aIt->second );
1324*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1325*cdf0e10cSrcweir             const OUString *pTmpStr;
1326*cdf0e10cSrcweir             pTmpStr = aImplNames.getConstArray();
1327*cdf0e10cSrcweir #endif
1328*cdf0e10cSrcweir             uno::Reference< XLinguServiceManager > xMgr( pLinguData->GetManager() );
1329*cdf0e10cSrcweir             Locale aLocale( SvxCreateLocale(nLang) );
1330*cdf0e10cSrcweir             if (xMgr.is())
1331*cdf0e10cSrcweir                 xMgr->setConfiguredServices( C2U(cHyph), aLocale, aImplNames );
1332*cdf0e10cSrcweir         }
1333*cdf0e10cSrcweir 
1334*cdf0e10cSrcweir         // update thesaurus configuration entries
1335*cdf0e10cSrcweir         pTable = &pLinguData->GetThesTable();
1336*cdf0e10cSrcweir         for (aIt = pTable->begin();  aIt != pTable->end();  ++aIt)
1337*cdf0e10cSrcweir         {
1338*cdf0e10cSrcweir             sal_Int16 nLang = aIt->first;
1339*cdf0e10cSrcweir             const Sequence< OUString > aImplNames( aIt->second );
1340*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1341*cdf0e10cSrcweir             const OUString *pTmpStr;
1342*cdf0e10cSrcweir             pTmpStr = aImplNames.getConstArray();
1343*cdf0e10cSrcweir #endif
1344*cdf0e10cSrcweir             uno::Reference< XLinguServiceManager > xMgr( pLinguData->GetManager() );
1345*cdf0e10cSrcweir             Locale aLocale( SvxCreateLocale(nLang) );
1346*cdf0e10cSrcweir             if (xMgr.is())
1347*cdf0e10cSrcweir                 xMgr->setConfiguredServices( C2U(cThes), aLocale, aImplNames );
1348*cdf0e10cSrcweir         }
1349*cdf0e10cSrcweir 	}
1350*cdf0e10cSrcweir 
1351*cdf0e10cSrcweir 
1352*cdf0e10cSrcweir     //
1353*cdf0e10cSrcweir     // activate dictionaries according to checkbox state
1354*cdf0e10cSrcweir     //
1355*cdf0e10cSrcweir     Sequence< OUString > aActiveDics;
1356*cdf0e10cSrcweir     sal_Int32 nActiveDics = 0;
1357*cdf0e10cSrcweir     sal_uLong nEntries = aLinguDicsCLB.GetEntryCount();
1358*cdf0e10cSrcweir     for (sal_uLong i = 0;  i < nEntries;  ++i)
1359*cdf0e10cSrcweir     {
1360*cdf0e10cSrcweir         sal_Int32 nDics = aDics.getLength();
1361*cdf0e10cSrcweir //        const uno::Reference< XDictionary > *pDic = aDics.getConstArray();
1362*cdf0e10cSrcweir 
1363*cdf0e10cSrcweir         aActiveDics.realloc( nDics );
1364*cdf0e10cSrcweir         OUString *pActiveDic = aActiveDics.getArray();
1365*cdf0e10cSrcweir 
1366*cdf0e10cSrcweir         SvLBoxEntry *pEntry = aLinguDicsCLB.GetEntry( i );
1367*cdf0e10cSrcweir         if (pEntry)
1368*cdf0e10cSrcweir         {
1369*cdf0e10cSrcweir             DicUserData aData( (sal_uLong)pEntry->GetUserData() );
1370*cdf0e10cSrcweir             if (aData.GetEntryId() < nDics)
1371*cdf0e10cSrcweir             {
1372*cdf0e10cSrcweir                 sal_Bool bChecked = aLinguDicsCLB.IsChecked( (sal_uInt16) i );
1373*cdf0e10cSrcweir                 uno::Reference< XDictionary > xDic( aDics.getConstArray()[ i ] );
1374*cdf0e10cSrcweir                 if (xDic.is())
1375*cdf0e10cSrcweir                 {
1376*cdf0e10cSrcweir                     if (SvxGetIgnoreAllList() == xDic)
1377*cdf0e10cSrcweir                         bChecked = sal_True;
1378*cdf0e10cSrcweir                     xDic->setActive( bChecked );
1379*cdf0e10cSrcweir 
1380*cdf0e10cSrcweir                     if (bChecked)
1381*cdf0e10cSrcweir                     {
1382*cdf0e10cSrcweir                         String aDicName( xDic->getName() );
1383*cdf0e10cSrcweir                         pActiveDic[ nActiveDics++ ] = aDicName;
1384*cdf0e10cSrcweir                     }
1385*cdf0e10cSrcweir                 }
1386*cdf0e10cSrcweir             }
1387*cdf0e10cSrcweir         }
1388*cdf0e10cSrcweir     }
1389*cdf0e10cSrcweir     //
1390*cdf0e10cSrcweir     aActiveDics.realloc( nActiveDics );
1391*cdf0e10cSrcweir     Any aTmp;
1392*cdf0e10cSrcweir     aTmp <<= aActiveDics;
1393*cdf0e10cSrcweir     SvtLinguConfig aLngCfg;
1394*cdf0e10cSrcweir     aLngCfg.SetProperty( UPH_ACTIVE_DICTIONARIES, aTmp );
1395*cdf0e10cSrcweir 
1396*cdf0e10cSrcweir 
1397*cdf0e10cSrcweir     nEntries = aLinguOptionsCLB.GetEntryCount();
1398*cdf0e10cSrcweir     for (sal_uInt16 j = 0;  j < nEntries;  ++j)
1399*cdf0e10cSrcweir 	{
1400*cdf0e10cSrcweir 		SvLBoxEntry *pEntry = aLinguOptionsCLB.GetEntry( j );
1401*cdf0e10cSrcweir 
1402*cdf0e10cSrcweir 		OptionsUserData aData( (sal_uLong)pEntry->GetUserData() );
1403*cdf0e10cSrcweir 		String aPropName( lcl_GetPropertyName( (EID_OPTIONS) aData.GetEntryId() ) );
1404*cdf0e10cSrcweir 
1405*cdf0e10cSrcweir 		Any aAny;
1406*cdf0e10cSrcweir 		if (aData.IsCheckable())
1407*cdf0e10cSrcweir 		{
1408*cdf0e10cSrcweir 			sal_Bool bChecked = aLinguOptionsCLB.IsChecked( j );
1409*cdf0e10cSrcweir 			aAny <<= bChecked;
1410*cdf0e10cSrcweir 		}
1411*cdf0e10cSrcweir 		else if (aData.HasNumericValue())
1412*cdf0e10cSrcweir 		{
1413*cdf0e10cSrcweir 			sal_Int16 nVal = aData.GetNumericValue();
1414*cdf0e10cSrcweir 			aAny <<= nVal;
1415*cdf0e10cSrcweir 		}
1416*cdf0e10cSrcweir 
1417*cdf0e10cSrcweir 		if (xProp.is())
1418*cdf0e10cSrcweir 			xProp->setPropertyValue( aPropName, aAny );
1419*cdf0e10cSrcweir 		aLngCfg.SetProperty( aPropName, aAny );
1420*cdf0e10cSrcweir 	}
1421*cdf0e10cSrcweir 
1422*cdf0e10cSrcweir 	SvLBoxEntry *pPreBreakEntry  = aLinguOptionsCLB.GetEntry( (sal_uInt16) EID_NUM_PRE_BREAK );
1423*cdf0e10cSrcweir 	SvLBoxEntry *pPostBreakEntry = aLinguOptionsCLB.GetEntry( (sal_uInt16) EID_NUM_POST_BREAK );
1424*cdf0e10cSrcweir 	DBG_ASSERT( pPreBreakEntry, "NULL Pointer" );
1425*cdf0e10cSrcweir 	DBG_ASSERT( pPostBreakEntry, "NULL Pointer" );
1426*cdf0e10cSrcweir 	if (pPreBreakEntry && pPostBreakEntry)
1427*cdf0e10cSrcweir 	{
1428*cdf0e10cSrcweir 		OptionsUserData aPreBreakData( (sal_uLong)pPreBreakEntry->GetUserData() );
1429*cdf0e10cSrcweir 		OptionsUserData aPostBreakData( (sal_uLong)pPostBreakEntry->GetUserData() );
1430*cdf0e10cSrcweir 		if ( aPreBreakData.IsModified() || aPostBreakData.IsModified() )
1431*cdf0e10cSrcweir 		{
1432*cdf0e10cSrcweir 			SfxHyphenRegionItem aHyp( GetWhich( SID_ATTR_HYPHENREGION ) );
1433*cdf0e10cSrcweir 			aHyp.GetMinLead()  = (sal_uInt8) aPreBreakData.GetNumericValue();
1434*cdf0e10cSrcweir 			aHyp.GetMinTrail() = (sal_uInt8) aPostBreakData.GetNumericValue();
1435*cdf0e10cSrcweir 			rCoreSet.Put( aHyp );
1436*cdf0e10cSrcweir 		}
1437*cdf0e10cSrcweir 	}
1438*cdf0e10cSrcweir 
1439*cdf0e10cSrcweir 
1440*cdf0e10cSrcweir     // automatic spell checking
1441*cdf0e10cSrcweir 	sal_Bool bNewAutoCheck = aLinguOptionsCLB.IsChecked( (sal_uInt16) EID_SPELL_AUTO );
1442*cdf0e10cSrcweir 	const SfxPoolItem* pOld = GetOldItem( rCoreSet, SID_AUTOSPELL_CHECK );
1443*cdf0e10cSrcweir 	if ( !pOld || ( (SfxBoolItem*)pOld )->GetValue() != bNewAutoCheck )
1444*cdf0e10cSrcweir 	{
1445*cdf0e10cSrcweir 		rCoreSet.Put( SfxBoolItem( GetWhich( SID_AUTOSPELL_CHECK ),
1446*cdf0e10cSrcweir 								bNewAutoCheck ) );
1447*cdf0e10cSrcweir 		bModified |= sal_True;
1448*cdf0e10cSrcweir 	}
1449*cdf0e10cSrcweir 
1450*cdf0e10cSrcweir 	return bModified;
1451*cdf0e10cSrcweir }
1452*cdf0e10cSrcweir 
1453*cdf0e10cSrcweir // ----------------------------------------------------------------------
1454*cdf0e10cSrcweir 
1455*cdf0e10cSrcweir sal_uLong SvxLinguTabPage::GetDicUserData( const uno::Reference< XDictionary > &rxDic, sal_uInt16 nIdx )
1456*cdf0e10cSrcweir {
1457*cdf0e10cSrcweir     sal_uLong nRes = 0;
1458*cdf0e10cSrcweir     DBG_ASSERT( rxDic.is(), "dictionary not supplied" );
1459*cdf0e10cSrcweir     if (rxDic.is())
1460*cdf0e10cSrcweir     {
1461*cdf0e10cSrcweir         uno::Reference< frame::XStorable > xStor( rxDic, UNO_QUERY );
1462*cdf0e10cSrcweir 
1463*cdf0e10cSrcweir //        sal_uLong nUserData = 0;
1464*cdf0e10cSrcweir         sal_Bool bChecked = rxDic->isActive();
1465*cdf0e10cSrcweir         sal_Bool bEditable = !xStor.is() || !xStor->isReadonly();
1466*cdf0e10cSrcweir         sal_Bool bDeletable = bEditable;
1467*cdf0e10cSrcweir //        sal_Bool bNegativ = rxDic->getDictionaryType() == DictionaryType_NEGATIVE;
1468*cdf0e10cSrcweir 
1469*cdf0e10cSrcweir         nRes = DicUserData( nIdx,
1470*cdf0e10cSrcweir                 bChecked, bEditable, bDeletable ).GetUserData();
1471*cdf0e10cSrcweir     }
1472*cdf0e10cSrcweir     return nRes;
1473*cdf0e10cSrcweir }
1474*cdf0e10cSrcweir 
1475*cdf0e10cSrcweir 
1476*cdf0e10cSrcweir void SvxLinguTabPage::AddDicBoxEntry(
1477*cdf0e10cSrcweir         const uno::Reference< XDictionary > &rxDic,
1478*cdf0e10cSrcweir         sal_uInt16 nIdx )
1479*cdf0e10cSrcweir {
1480*cdf0e10cSrcweir     aLinguDicsCLB.SetUpdateMode(sal_False);
1481*cdf0e10cSrcweir 
1482*cdf0e10cSrcweir     String aTxt( ::GetDicInfoStr( rxDic->getName(),
1483*cdf0e10cSrcweir                         SvxLocaleToLanguage( rxDic->getLocale() ),
1484*cdf0e10cSrcweir                         DictionaryType_NEGATIVE == rxDic->getDictionaryType() ) );
1485*cdf0e10cSrcweir     aLinguDicsCLB.InsertEntry( aTxt, (sal_uInt16)LISTBOX_APPEND );  // append at end
1486*cdf0e10cSrcweir     SvLBoxEntry* pEntry = aLinguDicsCLB.GetEntry( aLinguDicsCLB.GetEntryCount() - 1 );
1487*cdf0e10cSrcweir     DBG_ASSERT( pEntry, "failed to add entry" );
1488*cdf0e10cSrcweir     if (pEntry)
1489*cdf0e10cSrcweir     {
1490*cdf0e10cSrcweir         DicUserData aData( GetDicUserData( rxDic, nIdx ) );
1491*cdf0e10cSrcweir         pEntry->SetUserData( (void *) aData.GetUserData() );
1492*cdf0e10cSrcweir         lcl_SetCheckButton( pEntry, aData.IsChecked() );
1493*cdf0e10cSrcweir     }
1494*cdf0e10cSrcweir 
1495*cdf0e10cSrcweir     aLinguDicsCLB.SetUpdateMode(sal_True);
1496*cdf0e10cSrcweir }
1497*cdf0e10cSrcweir 
1498*cdf0e10cSrcweir // ----------------------------------------------------------------------
1499*cdf0e10cSrcweir 
1500*cdf0e10cSrcweir void SvxLinguTabPage::UpdateDicBox_Impl()
1501*cdf0e10cSrcweir {
1502*cdf0e10cSrcweir     aLinguDicsCLB.SetUpdateMode(sal_False);
1503*cdf0e10cSrcweir     aLinguDicsCLB.Clear();
1504*cdf0e10cSrcweir 
1505*cdf0e10cSrcweir 	sal_Int32 nDics	 = aDics.getLength();
1506*cdf0e10cSrcweir 	const uno::Reference< XDictionary > *pDic = aDics.getConstArray();
1507*cdf0e10cSrcweir 	for (sal_Int32 i = 0;  i < nDics;  ++i)
1508*cdf0e10cSrcweir 	{
1509*cdf0e10cSrcweir 		const uno::Reference< XDictionary > &rDic = pDic[i];
1510*cdf0e10cSrcweir 		if (rDic.is())
1511*cdf0e10cSrcweir             AddDicBoxEntry( rDic, (sal_uInt16)i );
1512*cdf0e10cSrcweir 	}
1513*cdf0e10cSrcweir 
1514*cdf0e10cSrcweir     aLinguDicsCLB.SetUpdateMode(sal_True);
1515*cdf0e10cSrcweir }
1516*cdf0e10cSrcweir 
1517*cdf0e10cSrcweir // ----------------------------------------------------------------------
1518*cdf0e10cSrcweir 
1519*cdf0e10cSrcweir void SvxLinguTabPage::UpdateModulesBox_Impl()
1520*cdf0e10cSrcweir {
1521*cdf0e10cSrcweir     if (pLinguData)
1522*cdf0e10cSrcweir     {
1523*cdf0e10cSrcweir         const ServiceInfoArr &rAllDispSrvcArr = pLinguData->GetDisplayServiceArray();
1524*cdf0e10cSrcweir         const sal_uLong nDispSrvcCount = pLinguData->GetDisplayServiceCount();
1525*cdf0e10cSrcweir 
1526*cdf0e10cSrcweir         aLinguModulesCLB.Clear();
1527*cdf0e10cSrcweir 
1528*cdf0e10cSrcweir         for (sal_uInt16 i = 0;  i < nDispSrvcCount;  ++i)
1529*cdf0e10cSrcweir         {
1530*cdf0e10cSrcweir             const ServiceInfo_Impl &rInfo = rAllDispSrvcArr[i];
1531*cdf0e10cSrcweir             aLinguModulesCLB.InsertEntry( rInfo.sDisplayName, (sal_uInt16)LISTBOX_APPEND );
1532*cdf0e10cSrcweir             SvLBoxEntry* pEntry = aLinguModulesCLB.GetEntry(i);
1533*cdf0e10cSrcweir             pEntry->SetUserData( (void *) &rInfo );
1534*cdf0e10cSrcweir             aLinguModulesCLB.CheckEntryPos( i, rInfo.bConfigured );
1535*cdf0e10cSrcweir         }
1536*cdf0e10cSrcweir         aLinguModulesEditPB.Enable( nDispSrvcCount > 0 );
1537*cdf0e10cSrcweir     }
1538*cdf0e10cSrcweir }
1539*cdf0e10cSrcweir 
1540*cdf0e10cSrcweir //------------------------------------------------------------------------
1541*cdf0e10cSrcweir 
1542*cdf0e10cSrcweir void SvxLinguTabPage::Reset( const SfxItemSet& rSet )
1543*cdf0e10cSrcweir {
1544*cdf0e10cSrcweir 	// if not HideGroups was called with GROUP_MODULES...
1545*cdf0e10cSrcweir 	if (aLinguModulesCLB.IsVisible())
1546*cdf0e10cSrcweir 	{
1547*cdf0e10cSrcweir 		if (!pLinguData)
1548*cdf0e10cSrcweir 			pLinguData = new SvxLinguData_Impl;
1549*cdf0e10cSrcweir         UpdateModulesBox_Impl();
1550*cdf0e10cSrcweir 	}
1551*cdf0e10cSrcweir 
1552*cdf0e10cSrcweir 
1553*cdf0e10cSrcweir 	//
1554*cdf0e10cSrcweir 	//	get data from configuration
1555*cdf0e10cSrcweir 	//
1556*cdf0e10cSrcweir 
1557*cdf0e10cSrcweir 	SvtLinguConfig aLngCfg;
1558*cdf0e10cSrcweir 
1559*cdf0e10cSrcweir 	aLinguOptionsCLB.SetUpdateMode(sal_False);
1560*cdf0e10cSrcweir 	aLinguOptionsCLB.Clear();
1561*cdf0e10cSrcweir 
1562*cdf0e10cSrcweir 	SvLBoxTreeList *pModel = aLinguOptionsCLB.GetModel();
1563*cdf0e10cSrcweir 	SvLBoxEntry* pEntry = NULL;
1564*cdf0e10cSrcweir 
1565*cdf0e10cSrcweir 	sal_Int16 nVal = 0;
1566*cdf0e10cSrcweir 	sal_Bool  bVal  = sal_False;
1567*cdf0e10cSrcweir 	sal_uLong nUserData = 0;
1568*cdf0e10cSrcweir 
1569*cdf0e10cSrcweir     pEntry = CreateEntry( sSpellAuto,		CBCOL_FIRST );
1570*cdf0e10cSrcweir 	aLngCfg.GetProperty( C2U(UPN_IS_SPELL_AUTO) ) >>= bVal;
1571*cdf0e10cSrcweir 	const SfxPoolItem* pItem = GetItem( rSet, SID_AUTOSPELL_CHECK );
1572*cdf0e10cSrcweir 	if (pItem)
1573*cdf0e10cSrcweir 		bVal = ((SfxBoolItem *) pItem)->GetValue();
1574*cdf0e10cSrcweir 	nUserData = OptionsUserData( EID_SPELL_AUTO, sal_False, 0, sal_True, bVal).GetUserData();
1575*cdf0e10cSrcweir 	pEntry->SetUserData( (void *)nUserData );
1576*cdf0e10cSrcweir 	pModel->Insert( pEntry );
1577*cdf0e10cSrcweir 	lcl_SetCheckButton( pEntry, bVal );
1578*cdf0e10cSrcweir 
1579*cdf0e10cSrcweir     pEntry = CreateEntry( sGrammarAuto,       CBCOL_FIRST );
1580*cdf0e10cSrcweir     aLngCfg.GetProperty( C2U(UPN_IS_GRAMMAR_AUTO) ) >>= bVal;
1581*cdf0e10cSrcweir //    const SfxPoolItem* pItem = GetItem( rSet, SID_AUTOSPELL_CHECK );
1582*cdf0e10cSrcweir //    if (pItem)
1583*cdf0e10cSrcweir //        bVal = ((SfxBoolItem *) pItem)->GetValue();
1584*cdf0e10cSrcweir     nUserData = OptionsUserData( EID_GRAMMAR_AUTO, sal_False, 0, sal_True, bVal).GetUserData();
1585*cdf0e10cSrcweir     pEntry->SetUserData( (void *)nUserData );
1586*cdf0e10cSrcweir     pModel->Insert( pEntry );
1587*cdf0e10cSrcweir     lcl_SetCheckButton( pEntry, bVal );
1588*cdf0e10cSrcweir 
1589*cdf0e10cSrcweir 	pEntry = CreateEntry( sCapitalWords,	CBCOL_FIRST );
1590*cdf0e10cSrcweir 	aLngCfg.GetProperty( C2U(UPN_IS_SPELL_UPPER_CASE) ) >>= bVal;
1591*cdf0e10cSrcweir 	nUserData = OptionsUserData( EID_CAPITAL_WORDS, sal_False, 0, sal_True, bVal).GetUserData();
1592*cdf0e10cSrcweir 	pEntry->SetUserData( (void *)nUserData );
1593*cdf0e10cSrcweir 	pModel->Insert( pEntry );
1594*cdf0e10cSrcweir 	lcl_SetCheckButton( pEntry, bVal );
1595*cdf0e10cSrcweir 
1596*cdf0e10cSrcweir 	pEntry = CreateEntry( sWordsWithDigits,	CBCOL_FIRST );
1597*cdf0e10cSrcweir 	aLngCfg.GetProperty( C2U(UPN_IS_SPELL_WITH_DIGITS) ) >>= bVal;
1598*cdf0e10cSrcweir 	nUserData = OptionsUserData( EID_WORDS_WITH_DIGITS, sal_False, 0, sal_True, bVal).GetUserData();
1599*cdf0e10cSrcweir 	pEntry->SetUserData( (void *)nUserData );
1600*cdf0e10cSrcweir 	pModel->Insert( pEntry );
1601*cdf0e10cSrcweir 	lcl_SetCheckButton( pEntry, bVal );
1602*cdf0e10cSrcweir 
1603*cdf0e10cSrcweir 	pEntry = CreateEntry( sCapitalization,	CBCOL_FIRST );
1604*cdf0e10cSrcweir 	aLngCfg.GetProperty( C2U(UPN_IS_SPELL_CAPITALIZATION) ) >>= bVal;
1605*cdf0e10cSrcweir 	nUserData = OptionsUserData( EID_CAPITALIZATION, sal_False, 0, sal_True, bVal).GetUserData();
1606*cdf0e10cSrcweir 	pEntry->SetUserData( (void *)nUserData );
1607*cdf0e10cSrcweir 	pModel->Insert( pEntry );
1608*cdf0e10cSrcweir 	lcl_SetCheckButton( pEntry, bVal );
1609*cdf0e10cSrcweir 
1610*cdf0e10cSrcweir 	pEntry = CreateEntry( sSpellSpecial,	CBCOL_FIRST );
1611*cdf0e10cSrcweir 	aLngCfg.GetProperty( C2U(UPN_IS_SPELL_SPECIAL) ) >>= bVal;
1612*cdf0e10cSrcweir 	nUserData = OptionsUserData( EID_SPELL_SPECIAL, sal_False, 0, sal_True, bVal).GetUserData();
1613*cdf0e10cSrcweir 	pEntry->SetUserData( (void *)nUserData );
1614*cdf0e10cSrcweir 	pModel->Insert( pEntry );
1615*cdf0e10cSrcweir 	lcl_SetCheckButton( pEntry, bVal );
1616*cdf0e10cSrcweir 
1617*cdf0e10cSrcweir 	pEntry = CreateEntry( sNumMinWordlen,	CBCOL_SECOND );
1618*cdf0e10cSrcweir 	aLngCfg.GetProperty( C2U(UPN_HYPH_MIN_WORD_LENGTH) ) >>= nVal;
1619*cdf0e10cSrcweir 	nUserData = OptionsUserData( EID_NUM_MIN_WORDLEN, sal_True, (sal_uInt16)nVal, sal_False, sal_False).GetUserData();
1620*cdf0e10cSrcweir 	pEntry->SetUserData( (void *)nUserData );
1621*cdf0e10cSrcweir 	pModel->Insert( pEntry );
1622*cdf0e10cSrcweir 
1623*cdf0e10cSrcweir 	const SfxHyphenRegionItem *pHyp = NULL;
1624*cdf0e10cSrcweir 	sal_uInt16 nWhich = GetWhich( SID_ATTR_HYPHENREGION );
1625*cdf0e10cSrcweir     if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET )
1626*cdf0e10cSrcweir 		pHyp = &( (const SfxHyphenRegionItem &) rSet.Get( nWhich ) );
1627*cdf0e10cSrcweir 
1628*cdf0e10cSrcweir 	pEntry = CreateEntry( sNumPreBreak,		CBCOL_SECOND );
1629*cdf0e10cSrcweir 	aLngCfg.GetProperty( C2U(UPN_HYPH_MIN_LEADING) ) >>= nVal;
1630*cdf0e10cSrcweir 	if (pHyp)
1631*cdf0e10cSrcweir 		nVal = (sal_Int16) pHyp->GetMinLead();
1632*cdf0e10cSrcweir 	nUserData = OptionsUserData( EID_NUM_PRE_BREAK, sal_True, (sal_uInt16)nVal, sal_False, sal_False).GetUserData();
1633*cdf0e10cSrcweir 	pEntry->SetUserData( (void *)nUserData );
1634*cdf0e10cSrcweir 	pModel->Insert( pEntry );
1635*cdf0e10cSrcweir 
1636*cdf0e10cSrcweir 	pEntry = CreateEntry( sNumPostBreak,	CBCOL_SECOND );
1637*cdf0e10cSrcweir 	aLngCfg.GetProperty( C2U(UPN_HYPH_MIN_TRAILING) ) >>= nVal;
1638*cdf0e10cSrcweir 	if (pHyp)
1639*cdf0e10cSrcweir 		nVal = (sal_Int16) pHyp->GetMinTrail();
1640*cdf0e10cSrcweir 	nUserData = OptionsUserData( EID_NUM_POST_BREAK, sal_True, (sal_uInt16)nVal, sal_False, sal_False).GetUserData();
1641*cdf0e10cSrcweir 	pEntry->SetUserData( (void *)nUserData );
1642*cdf0e10cSrcweir 	pModel->Insert( pEntry );
1643*cdf0e10cSrcweir 
1644*cdf0e10cSrcweir 	pEntry = CreateEntry( sHyphAuto,		CBCOL_FIRST );
1645*cdf0e10cSrcweir 	aLngCfg.GetProperty( C2U(UPN_IS_HYPH_AUTO) ) >>= bVal;
1646*cdf0e10cSrcweir 	nUserData = OptionsUserData( EID_HYPH_AUTO, sal_False, 0, sal_True, bVal).GetUserData();
1647*cdf0e10cSrcweir 	pEntry->SetUserData( (void *)nUserData );
1648*cdf0e10cSrcweir 	pModel->Insert( pEntry );
1649*cdf0e10cSrcweir 	lcl_SetCheckButton( pEntry, bVal );
1650*cdf0e10cSrcweir 
1651*cdf0e10cSrcweir 	pEntry = CreateEntry( sHyphSpecial,		CBCOL_FIRST );
1652*cdf0e10cSrcweir 	aLngCfg.GetProperty( C2U(UPN_IS_HYPH_SPECIAL) ) >>= bVal;
1653*cdf0e10cSrcweir 	nUserData = OptionsUserData( EID_HYPH_SPECIAL, sal_False, 0, sal_True, bVal).GetUserData();
1654*cdf0e10cSrcweir 	pEntry->SetUserData( (void *)nUserData );
1655*cdf0e10cSrcweir 	pModel->Insert( pEntry );
1656*cdf0e10cSrcweir 	lcl_SetCheckButton( pEntry, bVal );
1657*cdf0e10cSrcweir 
1658*cdf0e10cSrcweir 	aLinguOptionsCLB.SetUpdateMode(sal_True);
1659*cdf0e10cSrcweir }
1660*cdf0e10cSrcweir 
1661*cdf0e10cSrcweir // -----------------------------------------------------------------------
1662*cdf0e10cSrcweir 
1663*cdf0e10cSrcweir IMPL_LINK( SvxLinguTabPage, BoxDoubleClickHdl_Impl, SvTreeListBox *, pBox )
1664*cdf0e10cSrcweir {
1665*cdf0e10cSrcweir     if (pBox == &aLinguModulesCLB)
1666*cdf0e10cSrcweir     {
1667*cdf0e10cSrcweir         //! in order to avoid a bug causing a GPF when double clicking
1668*cdf0e10cSrcweir         //! on a module entry and exiting the "Edit Modules" dialog
1669*cdf0e10cSrcweir         //! after that.
1670*cdf0e10cSrcweir         Application::PostUserEvent( LINK(
1671*cdf0e10cSrcweir                     this, SvxLinguTabPage, PostDblClickHdl_Impl ) );
1672*cdf0e10cSrcweir     }
1673*cdf0e10cSrcweir     else if (pBox == &aLinguOptionsCLB)
1674*cdf0e10cSrcweir     {
1675*cdf0e10cSrcweir         ClickHdl_Impl(&aLinguOptionsEditPB);
1676*cdf0e10cSrcweir     }
1677*cdf0e10cSrcweir     return 0;
1678*cdf0e10cSrcweir }
1679*cdf0e10cSrcweir 
1680*cdf0e10cSrcweir // -----------------------------------------------------------------------
1681*cdf0e10cSrcweir 
1682*cdf0e10cSrcweir IMPL_LINK( SvxLinguTabPage, PostDblClickHdl_Impl, SvTreeListBox *, EMPTYARG )
1683*cdf0e10cSrcweir {
1684*cdf0e10cSrcweir     ClickHdl_Impl(&aLinguModulesEditPB);
1685*cdf0e10cSrcweir 	return 0;
1686*cdf0e10cSrcweir }
1687*cdf0e10cSrcweir 
1688*cdf0e10cSrcweir // -----------------------------------------------------------------------
1689*cdf0e10cSrcweir 
1690*cdf0e10cSrcweir IMPL_LINK( SvxLinguTabPage, OpenURLHdl_Impl, svt::FixedHyperlink *, EMPTYARG )
1691*cdf0e10cSrcweir {
1692*cdf0e10cSrcweir     ::rtl::OUString sURL( aMoreDictsLink.GetURL() );
1693*cdf0e10cSrcweir     lcl_OpenURL( sURL );
1694*cdf0e10cSrcweir     return 0;
1695*cdf0e10cSrcweir }
1696*cdf0e10cSrcweir 
1697*cdf0e10cSrcweir // -----------------------------------------------------------------------
1698*cdf0e10cSrcweir 
1699*cdf0e10cSrcweir IMPL_LINK( SvxLinguTabPage, BoxCheckButtonHdl_Impl, SvTreeListBox *, pBox )
1700*cdf0e10cSrcweir {
1701*cdf0e10cSrcweir     if (pBox == &aLinguModulesCLB)
1702*cdf0e10cSrcweir     {
1703*cdf0e10cSrcweir         DBG_ASSERT( pLinguData, "NULL pointer, LinguData missing" );
1704*cdf0e10cSrcweir         sal_uInt16 nPos = aLinguModulesCLB.GetSelectEntryPos();
1705*cdf0e10cSrcweir         if (nPos != LISTBOX_ENTRY_NOTFOUND  &&  pLinguData)
1706*cdf0e10cSrcweir         {
1707*cdf0e10cSrcweir             pLinguData->Reconfigure( aLinguModulesCLB.GetText( nPos ),
1708*cdf0e10cSrcweir                                      aLinguModulesCLB.IsChecked( nPos ) );
1709*cdf0e10cSrcweir         }
1710*cdf0e10cSrcweir     }
1711*cdf0e10cSrcweir     else if (pBox == &aLinguDicsCLB)
1712*cdf0e10cSrcweir     {
1713*cdf0e10cSrcweir         sal_uInt16 nPos = aLinguDicsCLB.GetSelectEntryPos();
1714*cdf0e10cSrcweir         if (nPos != LISTBOX_ENTRY_NOTFOUND)
1715*cdf0e10cSrcweir         {
1716*cdf0e10cSrcweir             const uno::Reference< XDictionary > &rDic = aDics.getConstArray()[ nPos ];
1717*cdf0e10cSrcweir             if (SvxGetIgnoreAllList() == rDic)
1718*cdf0e10cSrcweir             {
1719*cdf0e10cSrcweir                 SvLBoxEntry* pEntry = aLinguDicsCLB.GetEntry( nPos );
1720*cdf0e10cSrcweir                 if (pEntry)
1721*cdf0e10cSrcweir                     lcl_SetCheckButton( pEntry, sal_True );
1722*cdf0e10cSrcweir             }
1723*cdf0e10cSrcweir         }
1724*cdf0e10cSrcweir     }
1725*cdf0e10cSrcweir 	return 0;
1726*cdf0e10cSrcweir }
1727*cdf0e10cSrcweir 
1728*cdf0e10cSrcweir // -----------------------------------------------------------------------
1729*cdf0e10cSrcweir 
1730*cdf0e10cSrcweir IMPL_LINK( SvxLinguTabPage, ClickHdl_Impl, PushButton *, pBtn )
1731*cdf0e10cSrcweir {
1732*cdf0e10cSrcweir 	if (&aLinguModulesEditPB == pBtn)
1733*cdf0e10cSrcweir 	{
1734*cdf0e10cSrcweir 		if (!pLinguData)
1735*cdf0e10cSrcweir 			pLinguData = new SvxLinguData_Impl;
1736*cdf0e10cSrcweir 
1737*cdf0e10cSrcweir         SvxLinguData_Impl   aOldLinguData( *pLinguData );
1738*cdf0e10cSrcweir         SvxEditModulesDlg   aDlg( this, *pLinguData );
1739*cdf0e10cSrcweir         if (aDlg.Execute() != RET_OK)
1740*cdf0e10cSrcweir             *pLinguData = aOldLinguData;
1741*cdf0e10cSrcweir 
1742*cdf0e10cSrcweir         // evaluate new status of 'bConfigured' flag
1743*cdf0e10cSrcweir         sal_uLong nLen = pLinguData->GetDisplayServiceCount();
1744*cdf0e10cSrcweir         for (sal_uLong i = 0;  i < nLen;  ++i)
1745*cdf0e10cSrcweir             pLinguData->GetDisplayServiceArray()[i].bConfigured = sal_False;
1746*cdf0e10cSrcweir         const Locale* pAllLocales = pLinguData->GetAllSupportedLocales().getConstArray();
1747*cdf0e10cSrcweir         sal_Int32 nLocales = pLinguData->GetAllSupportedLocales().getLength();
1748*cdf0e10cSrcweir         for (sal_Int32 k = 0;  k < nLocales;  ++k)
1749*cdf0e10cSrcweir 		{
1750*cdf0e10cSrcweir             sal_Int16 nLang = SvxLocaleToLanguage( pAllLocales[k] );
1751*cdf0e10cSrcweir             if (pLinguData->GetSpellTable().count( nLang ))
1752*cdf0e10cSrcweir                 pLinguData->SetChecked( pLinguData->GetSpellTable()[ nLang ] );
1753*cdf0e10cSrcweir             if (pLinguData->GetGrammarTable().count( nLang ))
1754*cdf0e10cSrcweir                 pLinguData->SetChecked( pLinguData->GetGrammarTable()[ nLang ] );
1755*cdf0e10cSrcweir             if (pLinguData->GetHyphTable().count( nLang ))
1756*cdf0e10cSrcweir                 pLinguData->SetChecked( pLinguData->GetHyphTable()[ nLang ] );
1757*cdf0e10cSrcweir             if (pLinguData->GetThesTable().count( nLang ))
1758*cdf0e10cSrcweir                 pLinguData->SetChecked( pLinguData->GetThesTable()[ nLang ] );
1759*cdf0e10cSrcweir 		}
1760*cdf0e10cSrcweir 
1761*cdf0e10cSrcweir         // show new status of modules
1762*cdf0e10cSrcweir         UpdateModulesBox_Impl();
1763*cdf0e10cSrcweir 	}
1764*cdf0e10cSrcweir     else if (&aLinguDicsNewPB == pBtn)
1765*cdf0e10cSrcweir 	{
1766*cdf0e10cSrcweir         uno::Reference< XSpellChecker1 > xSpellChecker1;
1767*cdf0e10cSrcweir 		SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1768*cdf0e10cSrcweir 		if(pFact)
1769*cdf0e10cSrcweir 		{
1770*cdf0e10cSrcweir 			AbstractSvxNewDictionaryDialog* aDlg = pFact->CreateSvxNewDictionaryDialog( this, xSpellChecker1, RID_SFXDLG_NEWDICT );
1771*cdf0e10cSrcweir             DBG_ASSERT(aDlg, "Dialogdiet fail!");
1772*cdf0e10cSrcweir 			uno::Reference< XDictionary >  xNewDic;
1773*cdf0e10cSrcweir             if ( aDlg->Execute() == RET_OK )
1774*cdf0e10cSrcweir                 xNewDic = uno::Reference< XDictionary >( aDlg->GetNewDictionary(), UNO_QUERY );
1775*cdf0e10cSrcweir 			if ( xNewDic.is() )
1776*cdf0e10cSrcweir 			{
1777*cdf0e10cSrcweir 				// add new dics to the end
1778*cdf0e10cSrcweir 				sal_Int32 nLen = aDics.getLength();
1779*cdf0e10cSrcweir 				aDics.realloc( nLen + 1 );
1780*cdf0e10cSrcweir 
1781*cdf0e10cSrcweir 				aDics.getArray()[ nLen ] = xNewDic;
1782*cdf0e10cSrcweir 
1783*cdf0e10cSrcweir 				AddDicBoxEntry( xNewDic, (sal_uInt16) nLen );
1784*cdf0e10cSrcweir 			}
1785*cdf0e10cSrcweir 			delete aDlg; //add by CHINA001
1786*cdf0e10cSrcweir 		}
1787*cdf0e10cSrcweir 	}
1788*cdf0e10cSrcweir     else if (&aLinguDicsEditPB == pBtn)
1789*cdf0e10cSrcweir 	{
1790*cdf0e10cSrcweir         SvLBoxEntry *pEntry = aLinguDicsCLB.GetCurEntry();
1791*cdf0e10cSrcweir 		if (pEntry)
1792*cdf0e10cSrcweir 		{
1793*cdf0e10cSrcweir 			DicUserData aData( (sal_uLong) pEntry->GetUserData() );
1794*cdf0e10cSrcweir 			sal_uInt16 nDicPos = aData.GetEntryId();
1795*cdf0e10cSrcweir 			sal_Int32 nDics = aDics.getLength();
1796*cdf0e10cSrcweir 			if (nDicPos < nDics)
1797*cdf0e10cSrcweir 			{
1798*cdf0e10cSrcweir 				uno::Reference< XDictionary > xDic;
1799*cdf0e10cSrcweir 				xDic = aDics.getConstArray()[ nDicPos ];
1800*cdf0e10cSrcweir 				if (xDic.is())
1801*cdf0e10cSrcweir 				{
1802*cdf0e10cSrcweir                     uno::Reference< XSpellChecker1 > xSpellChecker1;
1803*cdf0e10cSrcweir 					SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1804*cdf0e10cSrcweir 					if(pFact)
1805*cdf0e10cSrcweir 					{
1806*cdf0e10cSrcweir 						VclAbstractDialog* aDlg = pFact->CreateSvxEditDictionaryDialog( this, xDic->getName(), xSpellChecker1, RID_SFXDLG_EDITDICT );
1807*cdf0e10cSrcweir                         DBG_ASSERT(aDlg, "Dialogdiet fail!");
1808*cdf0e10cSrcweir                         aDlg->Execute();
1809*cdf0e10cSrcweir                         delete aDlg;
1810*cdf0e10cSrcweir 					}
1811*cdf0e10cSrcweir 				}
1812*cdf0e10cSrcweir 			}
1813*cdf0e10cSrcweir 		}
1814*cdf0e10cSrcweir 	}
1815*cdf0e10cSrcweir     else if (&aLinguDicsDelPB == pBtn)
1816*cdf0e10cSrcweir 	{
1817*cdf0e10cSrcweir 		if ( RET_NO ==
1818*cdf0e10cSrcweir 		 	QueryBox( this, CUI_RES( RID_SFXQB_DELDICT ) ).Execute() )
1819*cdf0e10cSrcweir 			return 0;
1820*cdf0e10cSrcweir 
1821*cdf0e10cSrcweir         SvLBoxEntry *pEntry = aLinguDicsCLB.GetCurEntry();
1822*cdf0e10cSrcweir 		if (pEntry)
1823*cdf0e10cSrcweir 		{
1824*cdf0e10cSrcweir 			DicUserData aData( (sal_uLong) pEntry->GetUserData() );
1825*cdf0e10cSrcweir 			sal_uInt16 nDicPos = aData.GetEntryId();
1826*cdf0e10cSrcweir 			sal_Int32 nDics = aDics.getLength();
1827*cdf0e10cSrcweir 			if (nDicPos < nDics)
1828*cdf0e10cSrcweir 			{
1829*cdf0e10cSrcweir 				uno::Reference< XDictionary > xDic;
1830*cdf0e10cSrcweir 				xDic = aDics.getConstArray()[ nDicPos ];
1831*cdf0e10cSrcweir 				if (xDic.is())
1832*cdf0e10cSrcweir 				{
1833*cdf0e10cSrcweir 					if (SvxGetIgnoreAllList() == xDic)
1834*cdf0e10cSrcweir 						xDic->clear();
1835*cdf0e10cSrcweir 					else
1836*cdf0e10cSrcweir 					{
1837*cdf0e10cSrcweir 						if (xDicList.is())
1838*cdf0e10cSrcweir 							xDicList->removeDictionary( xDic );
1839*cdf0e10cSrcweir 
1840*cdf0e10cSrcweir 						uno::Reference< frame::XStorable > xStor( xDic, UNO_QUERY );
1841*cdf0e10cSrcweir 						if ( xStor->hasLocation() && !xStor->isReadonly() )
1842*cdf0e10cSrcweir 						{
1843*cdf0e10cSrcweir 							String sURL = xStor->getLocation();
1844*cdf0e10cSrcweir 							INetURLObject aObj(sURL);
1845*cdf0e10cSrcweir 							DBG_ASSERT( aObj.GetProtocol() == INET_PROT_FILE,
1846*cdf0e10cSrcweir 									"non-file URLs cannot be deleted" );
1847*cdf0e10cSrcweir 							if ( aObj.GetProtocol() == INET_PROT_FILE )
1848*cdf0e10cSrcweir 							{
1849*cdf0e10cSrcweir 								KillFile_Impl( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
1850*cdf0e10cSrcweir 							}
1851*cdf0e10cSrcweir 						}
1852*cdf0e10cSrcweir 
1853*cdf0e10cSrcweir                         aDics.getArray()[ nDicPos ] = 0;
1854*cdf0e10cSrcweir 
1855*cdf0e10cSrcweir                         // remove entry from checklistbox
1856*cdf0e10cSrcweir                         sal_uLong nCnt = aLinguDicsCLB.GetEntryCount();
1857*cdf0e10cSrcweir                         for (sal_uLong i = 0;  i < nCnt;  ++i)
1858*cdf0e10cSrcweir                         {
1859*cdf0e10cSrcweir                             SvLBoxEntry *pDicEntry = aLinguDicsCLB.GetEntry( i );
1860*cdf0e10cSrcweir                             DBG_ASSERT( pDicEntry, "missing entry" );
1861*cdf0e10cSrcweir                             if (pDicEntry)
1862*cdf0e10cSrcweir                             {
1863*cdf0e10cSrcweir                                 DicUserData aDicData( (sal_uLong) pDicEntry->GetUserData() );
1864*cdf0e10cSrcweir                                 if (aDicData.GetEntryId() == nDicPos )
1865*cdf0e10cSrcweir                                 {
1866*cdf0e10cSrcweir                                     aLinguDicsCLB.RemoveEntry( (sal_uInt16) i );
1867*cdf0e10cSrcweir                                     break;
1868*cdf0e10cSrcweir                                 }
1869*cdf0e10cSrcweir                             }
1870*cdf0e10cSrcweir                         }
1871*cdf0e10cSrcweir                         DBG_ASSERT( nCnt > aLinguDicsCLB.GetEntryCount(),
1872*cdf0e10cSrcweir                                 "remove failed ?");
1873*cdf0e10cSrcweir 					}
1874*cdf0e10cSrcweir 				}
1875*cdf0e10cSrcweir 			}
1876*cdf0e10cSrcweir 		}
1877*cdf0e10cSrcweir 	}
1878*cdf0e10cSrcweir 	else if (&aLinguOptionsEditPB == pBtn)
1879*cdf0e10cSrcweir 	{
1880*cdf0e10cSrcweir 		SvLBoxEntry *pEntry = aLinguOptionsCLB.GetCurEntry();
1881*cdf0e10cSrcweir 		DBG_ASSERT( pEntry, "no entry selected" );
1882*cdf0e10cSrcweir 		if (pEntry)
1883*cdf0e10cSrcweir 		{
1884*cdf0e10cSrcweir 			long nVal = -1;
1885*cdf0e10cSrcweir 			OptionsUserData aData( (sal_uLong)pEntry->GetUserData() );
1886*cdf0e10cSrcweir 			if(aData.HasNumericValue())
1887*cdf0e10cSrcweir 			{
1888*cdf0e10cSrcweir 				int nRID = -1;
1889*cdf0e10cSrcweir 				switch (aData.GetEntryId())
1890*cdf0e10cSrcweir 				{
1891*cdf0e10cSrcweir 					case EID_NUM_PRE_BREAK	: nRID = STR_NUM_PRE_BREAK_DLG; break;
1892*cdf0e10cSrcweir 					case EID_NUM_POST_BREAK	: nRID = STR_NUM_POST_BREAK_DLG; break;
1893*cdf0e10cSrcweir 					case EID_NUM_MIN_WORDLEN: nRID = STR_NUM_MIN_WORDLEN_DLG; break;
1894*cdf0e10cSrcweir 					default:
1895*cdf0e10cSrcweir 						DBG_ERROR( "unexpected case" );
1896*cdf0e10cSrcweir 				}
1897*cdf0e10cSrcweir 
1898*cdf0e10cSrcweir 				OptionsBreakSet aDlg( this, nRID );
1899*cdf0e10cSrcweir                 aDlg.GetNumericFld().SetValue( aData.GetNumericValue() );
1900*cdf0e10cSrcweir 				if (RET_OK == aDlg.Execute() )
1901*cdf0e10cSrcweir 				{
1902*cdf0e10cSrcweir 					nVal = static_cast<long>(aDlg.GetNumericFld().GetValue());
1903*cdf0e10cSrcweir 					if (-1 != nVal && aData.GetNumericValue() != nVal)
1904*cdf0e10cSrcweir 					{
1905*cdf0e10cSrcweir 						aData.SetNumericValue( (sal_uInt8)nVal ); //! sets IsModified !
1906*cdf0e10cSrcweir 						pEntry->SetUserData( (void *) aData.GetUserData() );
1907*cdf0e10cSrcweir 						aLinguOptionsCLB.Invalidate();
1908*cdf0e10cSrcweir 					}
1909*cdf0e10cSrcweir 				}
1910*cdf0e10cSrcweir 			}
1911*cdf0e10cSrcweir 		}
1912*cdf0e10cSrcweir 	}
1913*cdf0e10cSrcweir 	else
1914*cdf0e10cSrcweir 	{
1915*cdf0e10cSrcweir 		DBG_ERROR( "pBtn unexpected value" );
1916*cdf0e10cSrcweir 	}
1917*cdf0e10cSrcweir 
1918*cdf0e10cSrcweir 	return 0;
1919*cdf0e10cSrcweir }
1920*cdf0e10cSrcweir 
1921*cdf0e10cSrcweir // -----------------------------------------------------------------------
1922*cdf0e10cSrcweir 
1923*cdf0e10cSrcweir IMPL_LINK( SvxLinguTabPage, SelectHdl_Impl, SvxCheckListBox *, pBox )
1924*cdf0e10cSrcweir {
1925*cdf0e10cSrcweir 	if (&aLinguModulesCLB == pBox)
1926*cdf0e10cSrcweir 	{
1927*cdf0e10cSrcweir 	}
1928*cdf0e10cSrcweir     else if (&aLinguDicsCLB == pBox)
1929*cdf0e10cSrcweir 	{
1930*cdf0e10cSrcweir 		SvLBoxEntry *pEntry = pBox->GetCurEntry();
1931*cdf0e10cSrcweir 		if (pEntry)
1932*cdf0e10cSrcweir 		{
1933*cdf0e10cSrcweir 			DicUserData aData( (sal_uLong) pEntry->GetUserData() );
1934*cdf0e10cSrcweir 
1935*cdf0e10cSrcweir 			// always allow to edit (i.e. at least view the content of the dictionary)
1936*cdf0e10cSrcweir             aLinguDicsEditPB.Enable( true/*aData.IsEditable()*/ );
1937*cdf0e10cSrcweir             aLinguDicsDelPB .Enable( aData.IsDeletable() );
1938*cdf0e10cSrcweir 		}
1939*cdf0e10cSrcweir 	}
1940*cdf0e10cSrcweir 	else if (&aLinguOptionsCLB == pBox)
1941*cdf0e10cSrcweir 	{
1942*cdf0e10cSrcweir 		SvLBoxEntry *pEntry = pBox->GetCurEntry();
1943*cdf0e10cSrcweir 		if (pEntry)
1944*cdf0e10cSrcweir 		{
1945*cdf0e10cSrcweir 			OptionsUserData aData( (sal_uLong) pEntry->GetUserData() );
1946*cdf0e10cSrcweir 			aLinguOptionsEditPB.Enable( aData.HasNumericValue() );
1947*cdf0e10cSrcweir 		}
1948*cdf0e10cSrcweir 	}
1949*cdf0e10cSrcweir 	else
1950*cdf0e10cSrcweir 	{
1951*cdf0e10cSrcweir 		DBG_ERROR( "pBox unexpected value" );
1952*cdf0e10cSrcweir 	}
1953*cdf0e10cSrcweir 
1954*cdf0e10cSrcweir 	return 0;
1955*cdf0e10cSrcweir }
1956*cdf0e10cSrcweir 
1957*cdf0e10cSrcweir // -----------------------------------------------------------------------
1958*cdf0e10cSrcweir 
1959*cdf0e10cSrcweir SvLBoxEntry* SvxLinguTabPage::CreateEntry( String& rTxt, sal_uInt16 nCol )
1960*cdf0e10cSrcweir {
1961*cdf0e10cSrcweir 	SvLBoxEntry* pEntry = new SvLBoxEntry;
1962*cdf0e10cSrcweir 
1963*cdf0e10cSrcweir 	if( !pCheckButtonData )
1964*cdf0e10cSrcweir 		pCheckButtonData = new SvLBoxButtonData( &aLinguOptionsCLB );
1965*cdf0e10cSrcweir 
1966*cdf0e10cSrcweir 	String sEmpty;
1967*cdf0e10cSrcweir 	if (CBCOL_FIRST == nCol)
1968*cdf0e10cSrcweir 		pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, pCheckButtonData ) );
1969*cdf0e10cSrcweir 	if (CBCOL_SECOND == nCol)
1970*cdf0e10cSrcweir 		pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty) );	// Leerspalte
1971*cdf0e10cSrcweir 	pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0));	// Sonst Puff!
1972*cdf0e10cSrcweir 	pEntry->AddItem( new BrwString_Impl( pEntry, 0, rTxt ) );
1973*cdf0e10cSrcweir 
1974*cdf0e10cSrcweir 	return pEntry;
1975*cdf0e10cSrcweir }
1976*cdf0e10cSrcweir 
1977*cdf0e10cSrcweir // -----------------------------------------------------------------------
1978*cdf0e10cSrcweir 
1979*cdf0e10cSrcweir void SvxLinguTabPage::HideGroups( sal_uInt16 nGrp )
1980*cdf0e10cSrcweir {
1981*cdf0e10cSrcweir 	if ( 0 != ( GROUP_MODULES & nGrp ) )
1982*cdf0e10cSrcweir 	{
1983*cdf0e10cSrcweir 		aLinguModulesFT.Hide();
1984*cdf0e10cSrcweir 		aLinguModulesCLB.Hide();
1985*cdf0e10cSrcweir 		aLinguModulesEditPB.Hide();
1986*cdf0e10cSrcweir 
1987*cdf0e10cSrcweir         // reposition / resize remaining controls
1988*cdf0e10cSrcweir         long nDeltaY = aLinguDicsFT.GetPosPixel().Y() -
1989*cdf0e10cSrcweir                        aLinguModulesFT.GetPosPixel().Y();
1990*cdf0e10cSrcweir         DBG_ASSERT( nDeltaY >= 0, "move/resize value is negative" );
1991*cdf0e10cSrcweir         Point   aPos;
1992*cdf0e10cSrcweir         //
1993*cdf0e10cSrcweir         aPos = aLinguDicsFT.GetPosPixel();
1994*cdf0e10cSrcweir         aPos.Y() -= nDeltaY;
1995*cdf0e10cSrcweir         aLinguDicsFT.SetPosPixel( aPos );
1996*cdf0e10cSrcweir         aPos = aLinguDicsCLB.GetPosPixel();
1997*cdf0e10cSrcweir         aPos.Y() -= nDeltaY;
1998*cdf0e10cSrcweir         aLinguDicsCLB.SetPosPixel( aPos );
1999*cdf0e10cSrcweir         aPos = aLinguDicsNewPB.GetPosPixel();
2000*cdf0e10cSrcweir         aPos.Y() -= nDeltaY;
2001*cdf0e10cSrcweir         aLinguDicsNewPB.SetPosPixel( aPos );
2002*cdf0e10cSrcweir         aPos = aLinguDicsEditPB.GetPosPixel();
2003*cdf0e10cSrcweir         aPos.Y() -= nDeltaY;
2004*cdf0e10cSrcweir         aLinguDicsEditPB.SetPosPixel( aPos );
2005*cdf0e10cSrcweir         aPos = aLinguDicsDelPB.GetPosPixel();
2006*cdf0e10cSrcweir         aPos.Y() -= nDeltaY;
2007*cdf0e10cSrcweir         aLinguDicsDelPB.SetPosPixel( aPos );
2008*cdf0e10cSrcweir         //
2009*cdf0e10cSrcweir         aPos = aLinguOptionsFT.GetPosPixel();
2010*cdf0e10cSrcweir         aPos.Y() -= nDeltaY;
2011*cdf0e10cSrcweir         aLinguOptionsFT.SetPosPixel( aPos );
2012*cdf0e10cSrcweir         aPos = aLinguOptionsCLB.GetPosPixel();
2013*cdf0e10cSrcweir         aPos.Y() -= nDeltaY;
2014*cdf0e10cSrcweir         aLinguOptionsCLB.SetPosPixel( aPos );
2015*cdf0e10cSrcweir         aPos = aLinguOptionsEditPB.GetPosPixel();
2016*cdf0e10cSrcweir         aPos.Y() -= nDeltaY;
2017*cdf0e10cSrcweir         aLinguOptionsEditPB.SetPosPixel( aPos );
2018*cdf0e10cSrcweir         //
2019*cdf0e10cSrcweir         Size aSize( aLinguOptionsCLB.GetSizePixel() );
2020*cdf0e10cSrcweir         aSize.Height() += nDeltaY;
2021*cdf0e10cSrcweir         aLinguOptionsCLB.SetSizePixel( aSize );
2022*cdf0e10cSrcweir 
2023*cdf0e10cSrcweir         if ( SvtExtendedSecurityOptions().GetOpenHyperlinkMode()
2024*cdf0e10cSrcweir                 != SvtExtendedSecurityOptions::OPEN_NEVER )
2025*cdf0e10cSrcweir         {
2026*cdf0e10cSrcweir             aSize = GetOutputSizePixel();
2027*cdf0e10cSrcweir             aSize.Height() += ( aMoreDictsLink.GetSizePixel().Height() * 11 / 8 );
2028*cdf0e10cSrcweir             SetSizePixel( aSize );
2029*cdf0e10cSrcweir             aMoreDictsLink.Show();
2030*cdf0e10cSrcweir         }
2031*cdf0e10cSrcweir 	}
2032*cdf0e10cSrcweir }
2033*cdf0e10cSrcweir /*--------------------------------------------------
2034*cdf0e10cSrcweir --------------------------------------------------*/
2035*cdf0e10cSrcweir 
2036*cdf0e10cSrcweir SvxEditModulesDlg::SvxEditModulesDlg(Window* pParent, SvxLinguData_Impl& rData) :
2037*cdf0e10cSrcweir     ModalDialog( pParent, CUI_RES(RID_SVXDLG_EDIT_MODULES ) ),
2038*cdf0e10cSrcweir     aModulesFL      ( this, CUI_RES( FL_EDIT_MODULES_OPTIONS ) ),
2039*cdf0e10cSrcweir     aLanguageFT     ( this, CUI_RES( FT_EDIT_MODULES_LANGUAGE ) ),
2040*cdf0e10cSrcweir     aLanguageLB     ( this, CUI_RES( LB_EDIT_MODULES_LANGUAGE ), sal_False ),
2041*cdf0e10cSrcweir     aModulesCLB     ( this, CUI_RES( CLB_EDIT_MODULES_MODULES ) ),
2042*cdf0e10cSrcweir     aPrioUpPB       ( this, CUI_RES( PB_EDIT_MODULES_PRIO_UP ) ),
2043*cdf0e10cSrcweir     aPrioDownPB     ( this, CUI_RES( PB_EDIT_MODULES_PRIO_DOWN ) ),
2044*cdf0e10cSrcweir     aBackPB         ( this, CUI_RES( PB_EDIT_MODULES_PRIO_BACK ) ),
2045*cdf0e10cSrcweir     aMoreDictsLink  ( this, CUI_RES( FT_EDIT_MODULES_NEWDICTSLINK ) ),
2046*cdf0e10cSrcweir     aButtonsFL      ( this, CUI_RES( FL_EDIT_MODULES_BUTTONS ) ),
2047*cdf0e10cSrcweir     aHelpPB         ( this, CUI_RES( PB_HELP ) ),
2048*cdf0e10cSrcweir     aClosePB        ( this, CUI_RES( PB_OK ) ),
2049*cdf0e10cSrcweir     sSpell          (       CUI_RES( ST_SPELL ) ),
2050*cdf0e10cSrcweir     sHyph           (       CUI_RES( ST_HYPH ) ),
2051*cdf0e10cSrcweir     sThes           (       CUI_RES( ST_THES ) ),
2052*cdf0e10cSrcweir     sGrammar        (       CUI_RES( ST_GRAMMAR ) ),
2053*cdf0e10cSrcweir     rLinguData      ( rData )
2054*cdf0e10cSrcweir {
2055*cdf0e10cSrcweir 	pCheckButtonData = NULL;
2056*cdf0e10cSrcweir 	FreeResource();
2057*cdf0e10cSrcweir 
2058*cdf0e10cSrcweir     pDefaultLinguData = new SvxLinguData_Impl( rLinguData );
2059*cdf0e10cSrcweir 
2060*cdf0e10cSrcweir 	aModulesCLB.SetStyle( aModulesCLB.GetStyle()|WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE );
2061*cdf0e10cSrcweir 	aModulesCLB.SetHighlightRange();
2062*cdf0e10cSrcweir 	aModulesCLB.SetHelpId(HID_CLB_EDIT_MODULES_MODULES );
2063*cdf0e10cSrcweir 	aModulesCLB.SetSelectHdl( LINK( this, SvxEditModulesDlg, SelectHdl_Impl ));
2064*cdf0e10cSrcweir     aModulesCLB.SetCheckButtonHdl( LINK( this, SvxEditModulesDlg, BoxCheckButtonHdl_Impl) );
2065*cdf0e10cSrcweir 
2066*cdf0e10cSrcweir     aClosePB   .SetClickHdl( LINK( this, SvxEditModulesDlg, ClickHdl_Impl ));
2067*cdf0e10cSrcweir     aPrioUpPB  .SetClickHdl( LINK( this, SvxEditModulesDlg, UpDownHdl_Impl ));
2068*cdf0e10cSrcweir 	aPrioDownPB.SetClickHdl( LINK( this, SvxEditModulesDlg, UpDownHdl_Impl ));
2069*cdf0e10cSrcweir     aBackPB    .SetClickHdl( LINK( this, SvxEditModulesDlg, BackHdl_Impl ));
2070*cdf0e10cSrcweir     // in case of not installed language modules
2071*cdf0e10cSrcweir     aPrioUpPB  .Enable( sal_False );
2072*cdf0e10cSrcweir     aPrioDownPB.Enable( sal_False );
2073*cdf0e10cSrcweir 
2074*cdf0e10cSrcweir     if ( SvtExtendedSecurityOptions().GetOpenHyperlinkMode()
2075*cdf0e10cSrcweir             != SvtExtendedSecurityOptions::OPEN_NEVER )
2076*cdf0e10cSrcweir     {
2077*cdf0e10cSrcweir         aMoreDictsLink.SetURL( String(
2078*cdf0e10cSrcweir             RTL_CONSTASCII_STRINGPARAM( "http://extensions.services.openoffice.org/dictionary?cid=926386" ) ) );
2079*cdf0e10cSrcweir         aMoreDictsLink.SetClickHdl( LINK( this, SvxEditModulesDlg, OpenURLHdl_Impl ) );
2080*cdf0e10cSrcweir     }
2081*cdf0e10cSrcweir     else
2082*cdf0e10cSrcweir     {
2083*cdf0e10cSrcweir         aMoreDictsLink.Hide();
2084*cdf0e10cSrcweir         long nPos = aMoreDictsLink.GetPosPixel().Y() + aMoreDictsLink.GetSizePixel().Height();
2085*cdf0e10cSrcweir         Size aSize = aModulesCLB.GetSizePixel();
2086*cdf0e10cSrcweir         aSize.Height() += ( nPos - ( aModulesCLB.GetPosPixel().Y() + aSize.Height() ) );
2087*cdf0e10cSrcweir         aModulesCLB.SetSizePixel( aSize );
2088*cdf0e10cSrcweir     }
2089*cdf0e10cSrcweir 
2090*cdf0e10cSrcweir     //
2091*cdf0e10cSrcweir     //fill language box
2092*cdf0e10cSrcweir     //
2093*cdf0e10cSrcweir     Sequence< sal_Int16 > aAvailLang;
2094*cdf0e10cSrcweir     uno::Reference< XAvailableLocales > xAvail( rLinguData.GetManager(), UNO_QUERY );
2095*cdf0e10cSrcweir     if (xAvail.is())
2096*cdf0e10cSrcweir     {
2097*cdf0e10cSrcweir         aAvailLang = lcl_LocaleSeqToLangSeq(
2098*cdf0e10cSrcweir                         xAvail->getAvailableLocales( C2U(cSpell) ) );
2099*cdf0e10cSrcweir     }
2100*cdf0e10cSrcweir     const Sequence< Locale >& rLoc = rLinguData.GetAllSupportedLocales();
2101*cdf0e10cSrcweir 	const Locale* pLocales = rLoc.getConstArray();
2102*cdf0e10cSrcweir 	aLanguageLB.Clear();
2103*cdf0e10cSrcweir 	for(long i = 0; i < rLoc.getLength(); i++)
2104*cdf0e10cSrcweir 	{
2105*cdf0e10cSrcweir         sal_Int16 nLang = SvxLocaleToLanguage( pLocales[i] );
2106*cdf0e10cSrcweir         aLanguageLB.InsertLanguage( nLang, lcl_SeqHasLang( aAvailLang, nLang ) );
2107*cdf0e10cSrcweir 	}
2108*cdf0e10cSrcweir 	LanguageType eSysLang = MsLangId::getSystemLanguage();
2109*cdf0e10cSrcweir 	aLanguageLB.SelectLanguage( eSysLang );
2110*cdf0e10cSrcweir 	if(!aLanguageLB.IsLanguageSelected( eSysLang ) )
2111*cdf0e10cSrcweir 		aLanguageLB.SelectEntryPos(0);
2112*cdf0e10cSrcweir 
2113*cdf0e10cSrcweir 	aLanguageLB.SetSelectHdl( LINK( this, SvxEditModulesDlg, LangSelectHdl_Impl ));
2114*cdf0e10cSrcweir 	LangSelectHdl_Impl(&aLanguageLB);
2115*cdf0e10cSrcweir }
2116*cdf0e10cSrcweir 
2117*cdf0e10cSrcweir 
2118*cdf0e10cSrcweir SvxEditModulesDlg::~SvxEditModulesDlg()
2119*cdf0e10cSrcweir {
2120*cdf0e10cSrcweir     delete pDefaultLinguData;
2121*cdf0e10cSrcweir }
2122*cdf0e10cSrcweir 
2123*cdf0e10cSrcweir 
2124*cdf0e10cSrcweir SvLBoxEntry* SvxEditModulesDlg::CreateEntry( String& rTxt, sal_uInt16 nCol )
2125*cdf0e10cSrcweir {
2126*cdf0e10cSrcweir 	SvLBoxEntry* pEntry = new SvLBoxEntry;
2127*cdf0e10cSrcweir 	if( !pCheckButtonData )
2128*cdf0e10cSrcweir 	{
2129*cdf0e10cSrcweir 		pCheckButtonData = new SvLBoxButtonData( &aModulesCLB );
2130*cdf0e10cSrcweir         pCheckButtonData->SetLink( aModulesCLB.GetCheckButtonHdl() );
2131*cdf0e10cSrcweir 	}
2132*cdf0e10cSrcweir 
2133*cdf0e10cSrcweir 	String sEmpty;
2134*cdf0e10cSrcweir 	if (CBCOL_FIRST == nCol)
2135*cdf0e10cSrcweir 		pEntry->AddItem( new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, pCheckButtonData ) );
2136*cdf0e10cSrcweir 	if (CBCOL_SECOND == nCol)
2137*cdf0e10cSrcweir 		pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty) );	// Leerspalte
2138*cdf0e10cSrcweir 	pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0));	// Sonst Puff!
2139*cdf0e10cSrcweir 	pEntry->AddItem( new BrwStringDic_Impl( pEntry, 0, rTxt ) );
2140*cdf0e10cSrcweir 
2141*cdf0e10cSrcweir 	return pEntry;
2142*cdf0e10cSrcweir }
2143*cdf0e10cSrcweir 
2144*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
2145*cdf0e10cSrcweir 
2146*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
2147*cdf0e10cSrcweir IMPL_LINK( SvxEditModulesDlg, SelectHdl_Impl, SvxCheckListBox *, pBox )
2148*cdf0e10cSrcweir {
2149*cdf0e10cSrcweir 	if (&aModulesCLB == pBox)
2150*cdf0e10cSrcweir 	{
2151*cdf0e10cSrcweir 		sal_Bool bDisableUp = sal_True;
2152*cdf0e10cSrcweir 		sal_Bool bDisableDown = sal_True;
2153*cdf0e10cSrcweir 		SvLBoxEntry *pEntry = pBox->GetCurEntry();
2154*cdf0e10cSrcweir 		if (pEntry)
2155*cdf0e10cSrcweir 		{
2156*cdf0e10cSrcweir 			ModuleUserData_Impl* pData = (ModuleUserData_Impl*)pEntry->GetUserData();
2157*cdf0e10cSrcweir 			if(!pData->IsParent() && pData->GetType() != TYPE_HYPH)
2158*cdf0e10cSrcweir 			{
2159*cdf0e10cSrcweir 				sal_uInt16	nCurPos = pBox->GetSelectEntryPos();
2160*cdf0e10cSrcweir 				if(nCurPos < pBox->GetEntryCount() - 1)
2161*cdf0e10cSrcweir 				{
2162*cdf0e10cSrcweir 					bDisableDown = ((ModuleUserData_Impl*)pBox->
2163*cdf0e10cSrcweir 							GetEntry(nCurPos + 1)->GetUserData())->IsParent();
2164*cdf0e10cSrcweir 				}
2165*cdf0e10cSrcweir 				if(nCurPos > 1)
2166*cdf0e10cSrcweir 				{
2167*cdf0e10cSrcweir             					bDisableUp = ((ModuleUserData_Impl*)pBox->
2168*cdf0e10cSrcweir 							GetEntry(nCurPos - 1)->GetUserData())->IsParent();
2169*cdf0e10cSrcweir 				}
2170*cdf0e10cSrcweir 			}
2171*cdf0e10cSrcweir 			aPrioUpPB.Enable(!bDisableUp);
2172*cdf0e10cSrcweir 			aPrioDownPB.Enable(!bDisableDown);
2173*cdf0e10cSrcweir 		}
2174*cdf0e10cSrcweir 	}
2175*cdf0e10cSrcweir 	else
2176*cdf0e10cSrcweir 	{
2177*cdf0e10cSrcweir 		DBG_ERROR( "pBox unexpected value" );
2178*cdf0e10cSrcweir 	}
2179*cdf0e10cSrcweir 
2180*cdf0e10cSrcweir 	return 0;
2181*cdf0e10cSrcweir }
2182*cdf0e10cSrcweir /* -----------------------------28.05.01 11:00--------------------------------
2183*cdf0e10cSrcweir 
2184*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
2185*cdf0e10cSrcweir IMPL_LINK( SvxEditModulesDlg, BoxCheckButtonHdl_Impl, SvTreeListBox *, pBox )
2186*cdf0e10cSrcweir {
2187*cdf0e10cSrcweir //    if (pBox == (SvTreeListBox *) &aModulesCLB)
2188*cdf0e10cSrcweir //    {
2189*cdf0e10cSrcweir         pBox = &aModulesCLB;
2190*cdf0e10cSrcweir 		SvLBoxEntry *pCurEntry = pBox->GetCurEntry();
2191*cdf0e10cSrcweir 		if (pCurEntry)
2192*cdf0e10cSrcweir 		{
2193*cdf0e10cSrcweir 			ModuleUserData_Impl* pData = (ModuleUserData_Impl *)
2194*cdf0e10cSrcweir 												pCurEntry->GetUserData();
2195*cdf0e10cSrcweir 			if (!pData->IsParent()  &&  pData->GetType() == TYPE_HYPH)
2196*cdf0e10cSrcweir 			{
2197*cdf0e10cSrcweir 				// make hyphenator checkboxes function as radio-buttons
2198*cdf0e10cSrcweir 				// (at most one box may be checked)
2199*cdf0e10cSrcweir 				SvLBoxEntry *pEntry = pBox->First();
2200*cdf0e10cSrcweir 				while (pEntry)
2201*cdf0e10cSrcweir 				{
2202*cdf0e10cSrcweir 					pData = (ModuleUserData_Impl *) pEntry->GetUserData();
2203*cdf0e10cSrcweir 					if (!pData->IsParent()  &&
2204*cdf0e10cSrcweir 						 pData->GetType() == TYPE_HYPH  &&
2205*cdf0e10cSrcweir 						 pEntry != pCurEntry)
2206*cdf0e10cSrcweir 					{
2207*cdf0e10cSrcweir 						lcl_SetCheckButton( pEntry, sal_False );
2208*cdf0e10cSrcweir 						pBox->InvalidateEntry( pEntry );
2209*cdf0e10cSrcweir 					}
2210*cdf0e10cSrcweir 					pEntry = pBox->Next( pEntry );
2211*cdf0e10cSrcweir 				}
2212*cdf0e10cSrcweir 			}
2213*cdf0e10cSrcweir 		}
2214*cdf0e10cSrcweir //    }
2215*cdf0e10cSrcweir 	return 0;
2216*cdf0e10cSrcweir }
2217*cdf0e10cSrcweir /* -----------------------------27.11.00 14:00--------------------------------
2218*cdf0e10cSrcweir 
2219*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
2220*cdf0e10cSrcweir OUString lcl_GetServiceName(sal_uInt8 nType)
2221*cdf0e10cSrcweir {
2222*cdf0e10cSrcweir 	switch(nType)
2223*cdf0e10cSrcweir 	{
2224*cdf0e10cSrcweir         case  TYPE_SPELL    : return C2U(cSpell);
2225*cdf0e10cSrcweir         case  TYPE_GRAMMAR  : return C2U(cGrammar);
2226*cdf0e10cSrcweir         case  TYPE_HYPH     : return C2U(cHyph);
2227*cdf0e10cSrcweir         case  TYPE_THES     : return C2U(cThes);
2228*cdf0e10cSrcweir 	}
2229*cdf0e10cSrcweir 	return OUString();
2230*cdf0e10cSrcweir }
2231*cdf0e10cSrcweir 
2232*cdf0e10cSrcweir 
2233*cdf0e10cSrcweir IMPL_LINK( SvxEditModulesDlg, LangSelectHdl_Impl, ListBox *, pBox )
2234*cdf0e10cSrcweir {
2235*cdf0e10cSrcweir 	LanguageType  eCurLanguage = aLanguageLB.GetSelectLanguage();
2236*cdf0e10cSrcweir 	static Locale aLastLocale;
2237*cdf0e10cSrcweir 	Locale aCurLocale;
2238*cdf0e10cSrcweir 	SvxLanguageToLocale(aCurLocale, eCurLanguage);
2239*cdf0e10cSrcweir 	SvLBoxTreeList *pModel = aModulesCLB.GetModel();
2240*cdf0e10cSrcweir //	uno::Reference<XLinguServiceManager>&   xMgr = rLinguData.GetManager();
2241*cdf0e10cSrcweir 
2242*cdf0e10cSrcweir     if (pBox)
2243*cdf0e10cSrcweir 	{
2244*cdf0e10cSrcweir         // save old probably changed settings
2245*cdf0e10cSrcweir         // before switching to new language entries
2246*cdf0e10cSrcweir 
2247*cdf0e10cSrcweir         sal_Int16 nLang = SvxLocaleToLanguage( aLastLocale );
2248*cdf0e10cSrcweir 
2249*cdf0e10cSrcweir 		sal_Int32 nStart = 0, nLocalIndex = 0;
2250*cdf0e10cSrcweir         Sequence< OUString > aChange;
2251*cdf0e10cSrcweir 		sal_Bool bChanged = sal_False;
2252*cdf0e10cSrcweir 		for(sal_uInt16 i = 0; i < aModulesCLB.GetEntryCount(); i++)
2253*cdf0e10cSrcweir 		{
2254*cdf0e10cSrcweir 			SvLBoxEntry *pEntry = aModulesCLB.GetEntry(i);
2255*cdf0e10cSrcweir 			ModuleUserData_Impl* pData = (ModuleUserData_Impl*)pEntry->GetUserData();
2256*cdf0e10cSrcweir 			if(pData->IsParent())
2257*cdf0e10cSrcweir 			{
2258*cdf0e10cSrcweir 				if(bChanged)
2259*cdf0e10cSrcweir 				{
2260*cdf0e10cSrcweir                     LangImplNameTable *pTable = 0;
2261*cdf0e10cSrcweir                     sal_uInt8 nType = pData->GetType();
2262*cdf0e10cSrcweir                     switch (nType - 1)
2263*cdf0e10cSrcweir                     {
2264*cdf0e10cSrcweir                         case  TYPE_SPELL    : pTable = &rLinguData.GetSpellTable(); break;
2265*cdf0e10cSrcweir                         case  TYPE_GRAMMAR  : pTable = &rLinguData.GetGrammarTable();  break;
2266*cdf0e10cSrcweir                         case  TYPE_HYPH     : pTable = &rLinguData.GetHyphTable();  break;
2267*cdf0e10cSrcweir                         case  TYPE_THES     : pTable = &rLinguData.GetThesTable();  break;
2268*cdf0e10cSrcweir                     }
2269*cdf0e10cSrcweir                     if (pTable)
2270*cdf0e10cSrcweir                     {
2271*cdf0e10cSrcweir                         aChange.realloc(nStart);
2272*cdf0e10cSrcweir                         (*pTable)[ nLang ] = aChange;
2273*cdf0e10cSrcweir                     }
2274*cdf0e10cSrcweir 				}
2275*cdf0e10cSrcweir 				nLocalIndex = nStart = 0;
2276*cdf0e10cSrcweir 				aChange.realloc(aModulesCLB.GetEntryCount());
2277*cdf0e10cSrcweir 				bChanged = sal_False;
2278*cdf0e10cSrcweir 			}
2279*cdf0e10cSrcweir 			else
2280*cdf0e10cSrcweir 			{
2281*cdf0e10cSrcweir 				OUString* pChange = aChange.getArray();
2282*cdf0e10cSrcweir 				pChange[nStart] = pData->GetImplName();
2283*cdf0e10cSrcweir 				bChanged |= pData->GetIndex() != nLocalIndex ||
2284*cdf0e10cSrcweir 					pData->IsChecked() != aModulesCLB.IsChecked(i);
2285*cdf0e10cSrcweir 				if(aModulesCLB.IsChecked(i))
2286*cdf0e10cSrcweir 					nStart++;
2287*cdf0e10cSrcweir 				++nLocalIndex;
2288*cdf0e10cSrcweir 			}
2289*cdf0e10cSrcweir 		}
2290*cdf0e10cSrcweir 		if(bChanged)
2291*cdf0e10cSrcweir 		{
2292*cdf0e10cSrcweir 			aChange.realloc(nStart);
2293*cdf0e10cSrcweir             rLinguData.GetThesTable()[ nLang ] = aChange;
2294*cdf0e10cSrcweir 		}
2295*cdf0e10cSrcweir 	}
2296*cdf0e10cSrcweir 
2297*cdf0e10cSrcweir 	for(sal_uLong i = 0; i < aModulesCLB.GetEntryCount(); i++)
2298*cdf0e10cSrcweir 		delete (ModuleUserData_Impl*)aModulesCLB.GetEntry(i)->GetUserData();
2299*cdf0e10cSrcweir 
2300*cdf0e10cSrcweir     //
2301*cdf0e10cSrcweir     // display entries for new selected language
2302*cdf0e10cSrcweir     //
2303*cdf0e10cSrcweir 	aModulesCLB.Clear();
2304*cdf0e10cSrcweir 	if(LANGUAGE_DONTKNOW != eCurLanguage)
2305*cdf0e10cSrcweir 	{
2306*cdf0e10cSrcweir //		sal_Int32 nEntryPos = 1;
2307*cdf0e10cSrcweir 
2308*cdf0e10cSrcweir         sal_uLong n;
2309*cdf0e10cSrcweir         ServiceInfo_Impl* pInfo;
2310*cdf0e10cSrcweir 
2311*cdf0e10cSrcweir         //
2312*cdf0e10cSrcweir         // spellchecker entries
2313*cdf0e10cSrcweir         //
2314*cdf0e10cSrcweir 		SvLBoxEntry* pEntry = CreateEntry( sSpell,	CBCOL_SECOND );
2315*cdf0e10cSrcweir         ModuleUserData_Impl* pUserData = new ModuleUserData_Impl(
2316*cdf0e10cSrcweir                                          String(), sal_True, sal_False, TYPE_SPELL, 0 );
2317*cdf0e10cSrcweir 		pEntry->SetUserData( (void *)pUserData );
2318*cdf0e10cSrcweir 		pModel->Insert( pEntry );
2319*cdf0e10cSrcweir         //
2320*cdf0e10cSrcweir         Sequence< OUString > aNames( rLinguData.GetSortedImplNames( eCurLanguage, TYPE_SPELL ) );
2321*cdf0e10cSrcweir         const OUString *pName = aNames.getConstArray();
2322*cdf0e10cSrcweir         sal_uLong nNames = (sal_uLong) aNames.getLength();
2323*cdf0e10cSrcweir 		sal_Int32 nLocalIndex = 0;	// index relative to parent
2324*cdf0e10cSrcweir         for (n = 0;  n < nNames;  ++n)
2325*cdf0e10cSrcweir 		{
2326*cdf0e10cSrcweir 			OUString aImplName;
2327*cdf0e10cSrcweir 			sal_Bool	 bIsSuppLang = sal_False;
2328*cdf0e10cSrcweir 
2329*cdf0e10cSrcweir             pInfo = rLinguData.GetInfoByImplName( pName[n] );
2330*cdf0e10cSrcweir 			if (pInfo)
2331*cdf0e10cSrcweir 			{
2332*cdf0e10cSrcweir 				bIsSuppLang = pInfo->xSpell.is()  &&
2333*cdf0e10cSrcweir 							  pInfo->xSpell->hasLocale( aCurLocale );
2334*cdf0e10cSrcweir 				aImplName = pInfo->sSpellImplName;
2335*cdf0e10cSrcweir 			}
2336*cdf0e10cSrcweir             if (aImplName.getLength() && bIsSuppLang)
2337*cdf0e10cSrcweir 			{
2338*cdf0e10cSrcweir                 String aTxt( pInfo->sDisplayName );
2339*cdf0e10cSrcweir                 SvLBoxEntry* pNewEntry = CreateEntry( aTxt, CBCOL_FIRST );
2340*cdf0e10cSrcweir 
2341*cdf0e10cSrcweir                 LangImplNameTable &rTable = rLinguData.GetSpellTable();
2342*cdf0e10cSrcweir                 const bool bHasLang = rTable.count( eCurLanguage );
2343*cdf0e10cSrcweir 				if (!bHasLang)
2344*cdf0e10cSrcweir 				{
2345*cdf0e10cSrcweir 					DBG_WARNING( "language entry missing" );	// only relevant if all languages found should be supported
2346*cdf0e10cSrcweir 				}
2347*cdf0e10cSrcweir                 const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0;
2348*cdf0e10cSrcweir                 lcl_SetCheckButton( pNewEntry, bCheck );
2349*cdf0e10cSrcweir                 pUserData = new ModuleUserData_Impl( aImplName, sal_False,
2350*cdf0e10cSrcweir                                         bCheck, TYPE_SPELL, (sal_uInt8)nLocalIndex++ );
2351*cdf0e10cSrcweir                 pNewEntry->SetUserData( (void *)pUserData );
2352*cdf0e10cSrcweir                 pModel->Insert( pNewEntry );
2353*cdf0e10cSrcweir 			}
2354*cdf0e10cSrcweir 		}
2355*cdf0e10cSrcweir 
2356*cdf0e10cSrcweir         //
2357*cdf0e10cSrcweir         // grammar checker entries
2358*cdf0e10cSrcweir         //
2359*cdf0e10cSrcweir         pEntry = CreateEntry( sGrammar,    CBCOL_SECOND );
2360*cdf0e10cSrcweir         pUserData = new ModuleUserData_Impl( String(), sal_True, sal_False, TYPE_GRAMMAR, 0 );
2361*cdf0e10cSrcweir         pEntry->SetUserData( (void *)pUserData );
2362*cdf0e10cSrcweir         pModel->Insert( pEntry );
2363*cdf0e10cSrcweir         //
2364*cdf0e10cSrcweir         aNames = rLinguData.GetSortedImplNames( eCurLanguage, TYPE_GRAMMAR );
2365*cdf0e10cSrcweir         pName = aNames.getConstArray();
2366*cdf0e10cSrcweir         nNames = (sal_uLong) aNames.getLength();
2367*cdf0e10cSrcweir         nLocalIndex = 0;
2368*cdf0e10cSrcweir         for (n = 0;  n < nNames;  ++n)
2369*cdf0e10cSrcweir         {
2370*cdf0e10cSrcweir             OUString aImplName;
2371*cdf0e10cSrcweir             sal_Bool     bIsSuppLang = sal_False;
2372*cdf0e10cSrcweir 
2373*cdf0e10cSrcweir             pInfo = rLinguData.GetInfoByImplName( pName[n] );
2374*cdf0e10cSrcweir             if (pInfo)
2375*cdf0e10cSrcweir             {
2376*cdf0e10cSrcweir                 bIsSuppLang = pInfo->xGrammar.is()  &&
2377*cdf0e10cSrcweir                               pInfo->xGrammar->hasLocale( aCurLocale );
2378*cdf0e10cSrcweir                 aImplName = pInfo->sGrammarImplName;
2379*cdf0e10cSrcweir             }
2380*cdf0e10cSrcweir             if (aImplName.getLength() && bIsSuppLang)
2381*cdf0e10cSrcweir             {
2382*cdf0e10cSrcweir                 String aTxt( pInfo->sDisplayName );
2383*cdf0e10cSrcweir                 SvLBoxEntry* pNewEntry = CreateEntry( aTxt, CBCOL_FIRST );
2384*cdf0e10cSrcweir 
2385*cdf0e10cSrcweir                 LangImplNameTable &rTable = rLinguData.GetGrammarTable();
2386*cdf0e10cSrcweir                 const bool bHasLang = rTable.count( eCurLanguage );
2387*cdf0e10cSrcweir                 if (!bHasLang)
2388*cdf0e10cSrcweir                 {
2389*cdf0e10cSrcweir                     DBG_WARNING( "language entry missing" );    // only relevant if all languages found should be supported
2390*cdf0e10cSrcweir                 }
2391*cdf0e10cSrcweir                 const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0;
2392*cdf0e10cSrcweir                 lcl_SetCheckButton( pNewEntry, bCheck );
2393*cdf0e10cSrcweir                 pUserData = new ModuleUserData_Impl( aImplName, sal_False,
2394*cdf0e10cSrcweir                                         bCheck, TYPE_GRAMMAR, (sal_uInt8)nLocalIndex++ );
2395*cdf0e10cSrcweir                 pNewEntry->SetUserData( (void *)pUserData );
2396*cdf0e10cSrcweir                 pModel->Insert( pNewEntry );
2397*cdf0e10cSrcweir             }
2398*cdf0e10cSrcweir         }
2399*cdf0e10cSrcweir 
2400*cdf0e10cSrcweir         //
2401*cdf0e10cSrcweir         // hyphenator entries
2402*cdf0e10cSrcweir         //
2403*cdf0e10cSrcweir 		pEntry = CreateEntry( sHyph,	CBCOL_SECOND );
2404*cdf0e10cSrcweir 		pUserData = new ModuleUserData_Impl( String(), sal_True, sal_False, TYPE_HYPH, 0 );
2405*cdf0e10cSrcweir 		pEntry->SetUserData( (void *)pUserData );
2406*cdf0e10cSrcweir 		pModel->Insert( pEntry );
2407*cdf0e10cSrcweir         //
2408*cdf0e10cSrcweir         aNames = rLinguData.GetSortedImplNames( eCurLanguage, TYPE_HYPH );
2409*cdf0e10cSrcweir         pName = aNames.getConstArray();
2410*cdf0e10cSrcweir         nNames = (sal_uLong) aNames.getLength();
2411*cdf0e10cSrcweir 		nLocalIndex = 0;
2412*cdf0e10cSrcweir         for (n = 0;  n < nNames;  ++n)
2413*cdf0e10cSrcweir 		{
2414*cdf0e10cSrcweir 			OUString aImplName;
2415*cdf0e10cSrcweir 			sal_Bool	 bIsSuppLang = sal_False;
2416*cdf0e10cSrcweir 
2417*cdf0e10cSrcweir             pInfo = rLinguData.GetInfoByImplName( pName[n] );
2418*cdf0e10cSrcweir 			if (pInfo)
2419*cdf0e10cSrcweir 			{
2420*cdf0e10cSrcweir 				bIsSuppLang = pInfo->xHyph.is()  &&
2421*cdf0e10cSrcweir 							  pInfo->xHyph->hasLocale( aCurLocale );
2422*cdf0e10cSrcweir 				aImplName = pInfo->sHyphImplName;
2423*cdf0e10cSrcweir 			}
2424*cdf0e10cSrcweir             if (aImplName.getLength() && bIsSuppLang)
2425*cdf0e10cSrcweir 			{
2426*cdf0e10cSrcweir                 String aTxt( pInfo->sDisplayName );
2427*cdf0e10cSrcweir                 SvLBoxEntry* pNewEntry = CreateEntry( aTxt, CBCOL_FIRST );
2428*cdf0e10cSrcweir 
2429*cdf0e10cSrcweir                 LangImplNameTable &rTable = rLinguData.GetHyphTable();
2430*cdf0e10cSrcweir                 const bool bHasLang = rTable.count( eCurLanguage );
2431*cdf0e10cSrcweir 				if (!bHasLang)
2432*cdf0e10cSrcweir 				{
2433*cdf0e10cSrcweir 					DBG_WARNING( "language entry missing" );	// only relevant if all languages found should be supported
2434*cdf0e10cSrcweir 				}
2435*cdf0e10cSrcweir                 const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0;
2436*cdf0e10cSrcweir                 lcl_SetCheckButton( pNewEntry, bCheck );
2437*cdf0e10cSrcweir                 pUserData = new ModuleUserData_Impl( aImplName, sal_False,
2438*cdf0e10cSrcweir                                         bCheck, TYPE_HYPH, (sal_uInt8)nLocalIndex++ );
2439*cdf0e10cSrcweir                 pNewEntry->SetUserData( (void *)pUserData );
2440*cdf0e10cSrcweir                 pModel->Insert( pNewEntry );
2441*cdf0e10cSrcweir 			}
2442*cdf0e10cSrcweir 		}
2443*cdf0e10cSrcweir 
2444*cdf0e10cSrcweir         //
2445*cdf0e10cSrcweir         // thesaurus entries
2446*cdf0e10cSrcweir         //
2447*cdf0e10cSrcweir 		pEntry = CreateEntry( sThes,	CBCOL_SECOND );
2448*cdf0e10cSrcweir 		pUserData = new ModuleUserData_Impl( String(), sal_True, sal_False, TYPE_THES, 0 );
2449*cdf0e10cSrcweir 		pEntry->SetUserData( (void *)pUserData );
2450*cdf0e10cSrcweir 		pModel->Insert( pEntry );
2451*cdf0e10cSrcweir         //
2452*cdf0e10cSrcweir         aNames = rLinguData.GetSortedImplNames( eCurLanguage, TYPE_THES );
2453*cdf0e10cSrcweir         pName = aNames.getConstArray();
2454*cdf0e10cSrcweir         nNames = (sal_uLong) aNames.getLength();
2455*cdf0e10cSrcweir 		nLocalIndex = 0;
2456*cdf0e10cSrcweir         for (n = 0;  n < nNames;  ++n)
2457*cdf0e10cSrcweir 		{
2458*cdf0e10cSrcweir 			OUString aImplName;
2459*cdf0e10cSrcweir 			sal_Bool	 bIsSuppLang = sal_False;
2460*cdf0e10cSrcweir 
2461*cdf0e10cSrcweir             pInfo = rLinguData.GetInfoByImplName( pName[n] );
2462*cdf0e10cSrcweir 			if (pInfo)
2463*cdf0e10cSrcweir 			{
2464*cdf0e10cSrcweir 				bIsSuppLang = pInfo->xThes.is()  &&
2465*cdf0e10cSrcweir 							  pInfo->xThes->hasLocale( aCurLocale );
2466*cdf0e10cSrcweir 				aImplName = pInfo->sThesImplName;
2467*cdf0e10cSrcweir 			}
2468*cdf0e10cSrcweir             if (aImplName.getLength() && bIsSuppLang)
2469*cdf0e10cSrcweir 			{
2470*cdf0e10cSrcweir                 String aTxt( pInfo->sDisplayName );
2471*cdf0e10cSrcweir                 SvLBoxEntry* pNewEntry = CreateEntry( aTxt, CBCOL_FIRST );
2472*cdf0e10cSrcweir 
2473*cdf0e10cSrcweir                 LangImplNameTable &rTable = rLinguData.GetThesTable();
2474*cdf0e10cSrcweir                 const bool bHasLang = rTable.count( eCurLanguage );
2475*cdf0e10cSrcweir 				if (!bHasLang)
2476*cdf0e10cSrcweir 				{
2477*cdf0e10cSrcweir 					DBG_WARNING( "language entry missing" );	// only relevant if all languages found should be supported
2478*cdf0e10cSrcweir 				}
2479*cdf0e10cSrcweir                 const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0;
2480*cdf0e10cSrcweir                 lcl_SetCheckButton( pNewEntry, bCheck );
2481*cdf0e10cSrcweir                 pUserData = new ModuleUserData_Impl( aImplName, sal_False,
2482*cdf0e10cSrcweir                                         bCheck, TYPE_THES, (sal_uInt8)nLocalIndex++ );
2483*cdf0e10cSrcweir                 pNewEntry->SetUserData( (void *)pUserData );
2484*cdf0e10cSrcweir                 pModel->Insert( pNewEntry );
2485*cdf0e10cSrcweir 			}
2486*cdf0e10cSrcweir 		}
2487*cdf0e10cSrcweir 	}
2488*cdf0e10cSrcweir 	aLastLocale.Language = aCurLocale.Language;
2489*cdf0e10cSrcweir 	aLastLocale.Country = aCurLocale.Country;
2490*cdf0e10cSrcweir 	return 0;
2491*cdf0e10cSrcweir }
2492*cdf0e10cSrcweir /* -----------------------------27.11.00 19:50--------------------------------
2493*cdf0e10cSrcweir 
2494*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
2495*cdf0e10cSrcweir IMPL_LINK( SvxEditModulesDlg, UpDownHdl_Impl, PushButton *, pBtn )
2496*cdf0e10cSrcweir {
2497*cdf0e10cSrcweir 	sal_Bool bUp = &aPrioUpPB == pBtn;
2498*cdf0e10cSrcweir 	sal_uInt16	nCurPos = aModulesCLB.GetSelectEntryPos();
2499*cdf0e10cSrcweir     SvLBoxEntry* pEntry;
2500*cdf0e10cSrcweir     if (nCurPos != LISTBOX_ENTRY_NOTFOUND  &&
2501*cdf0e10cSrcweir         0 != (pEntry = aModulesCLB.GetEntry(nCurPos)))
2502*cdf0e10cSrcweir     {
2503*cdf0e10cSrcweir         aModulesCLB.SetUpdateMode(sal_False);
2504*cdf0e10cSrcweir         SvLBoxTreeList *pModel = aModulesCLB.GetModel();
2505*cdf0e10cSrcweir 
2506*cdf0e10cSrcweir         ModuleUserData_Impl* pData = (ModuleUserData_Impl*)pEntry->GetUserData();
2507*cdf0e10cSrcweir         String aStr(aModulesCLB.GetEntryText(pEntry));
2508*cdf0e10cSrcweir         SvLBoxEntry* pToInsert = CreateEntry( aStr, CBCOL_FIRST );
2509*cdf0e10cSrcweir         pToInsert->SetUserData( (void *)pData);
2510*cdf0e10cSrcweir         sal_Bool bIsChecked = aModulesCLB.IsChecked(nCurPos);
2511*cdf0e10cSrcweir 
2512*cdf0e10cSrcweir         pModel->Remove(pEntry);
2513*cdf0e10cSrcweir 
2514*cdf0e10cSrcweir         sal_uInt16 nDestPos = bUp ? nCurPos - 1 : nCurPos + 1;
2515*cdf0e10cSrcweir         pModel->Insert(pToInsert, nDestPos);
2516*cdf0e10cSrcweir         aModulesCLB.CheckEntryPos(nDestPos, bIsChecked );
2517*cdf0e10cSrcweir         aModulesCLB.SelectEntryPos(nDestPos );
2518*cdf0e10cSrcweir         SelectHdl_Impl(&aModulesCLB);
2519*cdf0e10cSrcweir         aModulesCLB.SetUpdateMode(sal_True);
2520*cdf0e10cSrcweir     }
2521*cdf0e10cSrcweir 	return 0;
2522*cdf0e10cSrcweir }
2523*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
2524*cdf0e10cSrcweir 
2525*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
2526*cdf0e10cSrcweir IMPL_LINK( SvxEditModulesDlg, ClickHdl_Impl, PushButton *, pBtn )
2527*cdf0e10cSrcweir {
2528*cdf0e10cSrcweir 	if (&aClosePB == pBtn)
2529*cdf0e10cSrcweir 	{
2530*cdf0e10cSrcweir 		// store language config
2531*cdf0e10cSrcweir 		LangSelectHdl_Impl(&aLanguageLB);
2532*cdf0e10cSrcweir 		EndDialog( RET_OK );
2533*cdf0e10cSrcweir 	}
2534*cdf0e10cSrcweir 	else
2535*cdf0e10cSrcweir 	{
2536*cdf0e10cSrcweir 		DBG_ERROR( "pBtn unexpected value" );
2537*cdf0e10cSrcweir 	}
2538*cdf0e10cSrcweir 
2539*cdf0e10cSrcweir 	return 0;
2540*cdf0e10cSrcweir }
2541*cdf0e10cSrcweir /* -----------------------------27.11.00 20:31--------------------------------
2542*cdf0e10cSrcweir 
2543*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
2544*cdf0e10cSrcweir IMPL_LINK( SvxEditModulesDlg, BackHdl_Impl, PushButton *, EMPTYARG )
2545*cdf0e10cSrcweir {
2546*cdf0e10cSrcweir     rLinguData = *pDefaultLinguData;
2547*cdf0e10cSrcweir 	LangSelectHdl_Impl(0);
2548*cdf0e10cSrcweir 	return 0;
2549*cdf0e10cSrcweir }
2550*cdf0e10cSrcweir 
2551*cdf0e10cSrcweir // -----------------------------------------------------------------------
2552*cdf0e10cSrcweir 
2553*cdf0e10cSrcweir IMPL_LINK( SvxEditModulesDlg, OpenURLHdl_Impl, svt::FixedHyperlink *, EMPTYARG )
2554*cdf0e10cSrcweir {
2555*cdf0e10cSrcweir     ::rtl::OUString sURL( aMoreDictsLink.GetURL() );
2556*cdf0e10cSrcweir     lcl_OpenURL( sURL );
2557*cdf0e10cSrcweir     return 0;
2558*cdf0e10cSrcweir }
2559*cdf0e10cSrcweir 
2560