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