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