Bump for 3.6-28
[LibreOffice.git] / editeng / source / misc / acorrcfg.cxx
blobbdfcf4c8f98fe35ed385c4294f02b7115db9a516
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
30 #include <editeng/acorrcfg.hxx>
31 #include <tools/debug.hxx>
32 #include <tools/urlobj.hxx>
33 #include <unotools/pathoptions.hxx>
34 #include <svl/urihelper.hxx>
36 #include <editeng/svxacorr.hxx>
37 #include <com/sun/star/uno/Any.hxx>
38 #include <com/sun/star/uno/Sequence.hxx>
40 #include <rtl/instance.hxx>
42 using namespace utl;
43 using namespace com::sun::star::uno;
45 using ::rtl::OUString;
47 SvxAutoCorrCfg::SvxAutoCorrCfg() :
48 aBaseConfig(*this),
49 aSwConfig(*this),
50 bFileRel(sal_True),
51 bNetRel(sal_True),
52 bAutoTextTip(sal_True),
53 bAutoTextPreview(sal_False),
54 bAutoFmtByInput(sal_True),
55 bSearchInAllCategories(sal_False)
57 SvtPathOptions aPathOpt;
58 String sSharePath, sUserPath, sAutoPath( aPathOpt.GetAutoCorrectPath() );
60 String* pS = &sSharePath;
61 for( sal_uInt16 n = 0; n < 2; ++n, pS = &sUserPath )
63 *pS = sAutoPath.GetToken( n, ';' );
64 INetURLObject aPath( *pS );
65 aPath.insertName( String::CreateFromAscii("acor") );
66 *pS = aPath.GetMainURL(INetURLObject::DECODE_TO_IURI);
68 pAutoCorrect = new SvxAutoCorrect( sSharePath, sUserPath );
70 aBaseConfig.Load(sal_True);
71 aSwConfig.Load(sal_True);
74 SvxAutoCorrCfg::~SvxAutoCorrCfg()
76 delete pAutoCorrect;
79 void SvxAutoCorrCfg::SetAutoCorrect( SvxAutoCorrect* pNew )
81 if( pNew && pNew != pAutoCorrect )
83 if( pAutoCorrect->GetFlags() != pNew->GetFlags() )
85 aBaseConfig.SetModified();
86 aSwConfig.SetModified();
88 delete pAutoCorrect;
89 pAutoCorrect = pNew;
93 Sequence<OUString> SvxBaseAutoCorrCfg::GetPropertyNames()
95 static const char* aPropNames[] =
97 "Exceptions/TwoCapitalsAtStart", // 0
98 "Exceptions/CapitalAtStartSentence", // 1
99 "UseReplacementTable", // 2
100 "TwoCapitalsAtStart", // 3
101 "CapitalAtStartSentence", // 4
102 "ChangeUnderlineWeight", // 5
103 "SetInetAttribute", // 6
104 "ChangeOrdinalNumber", // 7
105 "AddNonBreakingSpace", // 8
106 "ChangeDash", // 9
107 "RemoveDoubleSpaces", // 10
108 "ReplaceSingleQuote", // 11
109 "SingleQuoteAtStart", // 12
110 "SingleQuoteAtEnd", // 13
111 "ReplaceDoubleQuote", // 14
112 "DoubleQuoteAtStart", // 15
113 "DoubleQuoteAtEnd", // 16
114 "CorrectAccidentalCapsLock" // 17
116 const int nCount = 18;
117 Sequence<OUString> aNames(nCount);
118 OUString* pNames = aNames.getArray();
119 for(int i = 0; i < nCount; i++)
120 pNames[i] = OUString::createFromAscii(aPropNames[i]);
121 return aNames;
124 void SvxBaseAutoCorrCfg::Load(sal_Bool bInit)
126 Sequence<OUString> aNames = GetPropertyNames();
127 Sequence<Any> aValues = GetProperties(aNames);
128 if(bInit)
129 EnableNotification(aNames);
130 const Any* pValues = aValues.getConstArray();
131 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
132 if(aValues.getLength() == aNames.getLength())
134 long nFlags = 0; // default all off
135 sal_Int32 nTemp = 0;
136 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
138 if(pValues[nProp].hasValue())
140 switch(nProp)
142 case 0:
143 if(*(sal_Bool*)pValues[nProp].getValue())
144 nFlags |= SaveWordCplSttLst;
145 break;//"Exceptions/TwoCapitalsAtStart",
146 case 1:
147 if(*(sal_Bool*)pValues[nProp].getValue())
148 nFlags |= SaveWordWrdSttLst;
149 break;//"Exceptions/CapitalAtStartSentence",
150 case 2:
151 if(*(sal_Bool*)pValues[nProp].getValue())
152 nFlags |= Autocorrect;
153 break;//"UseReplacementTable",
154 case 3:
155 if(*(sal_Bool*)pValues[nProp].getValue())
156 nFlags |= CptlSttWrd;
157 break;//"TwoCapitalsAtStart",
158 case 4:
159 if(*(sal_Bool*)pValues[nProp].getValue())
160 nFlags |= CptlSttSntnc;
161 break;//"CapitalAtStartSentence",
162 case 5:
163 if(*(sal_Bool*)pValues[nProp].getValue())
164 nFlags |= ChgWeightUnderl;
165 break;//"ChangeUnderlineWeight",
166 case 6:
167 if(*(sal_Bool*)pValues[nProp].getValue())
168 nFlags |= SetINetAttr;
169 break;//"SetInetAttribute",
170 case 7:
171 if(*(sal_Bool*)pValues[nProp].getValue())
172 nFlags |= ChgOrdinalNumber;
173 break;//"ChangeOrdinalNumber",
174 case 8:
175 if(*(sal_Bool*)pValues[nProp].getValue())
176 nFlags |= AddNonBrkSpace;
177 break;//"AddNonBreakingSpace"
178 case 9:
179 if(*(sal_Bool*)pValues[nProp].getValue())
180 nFlags |= ChgToEnEmDash;
181 break;//"ChangeDash",
182 case 10:
183 if(*(sal_Bool*)pValues[nProp].getValue())
184 nFlags |= IgnoreDoubleSpace;
185 break;//"RemoveDoubleSpaces",
186 case 11:
187 if(*(sal_Bool*)pValues[nProp].getValue())
188 nFlags |= ChgSglQuotes;
189 break;//"ReplaceSingleQuote",
190 case 12:
191 pValues[nProp] >>= nTemp;
192 rParent.pAutoCorrect->SetStartSingleQuote(
193 sal::static_int_cast< sal_Unicode >( nTemp ) );
194 break;//"SingleQuoteAtStart",
195 case 13:
196 pValues[nProp] >>= nTemp;
197 rParent.pAutoCorrect->SetEndSingleQuote(
198 sal::static_int_cast< sal_Unicode >( nTemp ) );
199 break;//"SingleQuoteAtEnd",
200 case 14:
201 if(*(sal_Bool*)pValues[nProp].getValue())
202 nFlags |= ChgQuotes;
203 break;//"ReplaceDoubleQuote",
204 case 15:
205 pValues[nProp] >>= nTemp;
206 rParent.pAutoCorrect->SetStartDoubleQuote(
207 sal::static_int_cast< sal_Unicode >( nTemp ) );
208 break;//"DoubleQuoteAtStart",
209 case 16:
210 pValues[nProp] >>= nTemp;
211 rParent.pAutoCorrect->SetEndDoubleQuote(
212 sal::static_int_cast< sal_Unicode >( nTemp ) );
213 break;//"DoubleQuoteAtEnd"
214 case 17:
215 if(*(sal_Bool*)pValues[nProp].getValue())
216 nFlags |= CorrectCapsLock;
217 break;//"CorrectAccidentalCapsLock"
221 if( nFlags )
222 rParent.pAutoCorrect->SetAutoCorrFlag( nFlags, sal_True );
223 rParent.pAutoCorrect->SetAutoCorrFlag( ( 0xffff & ~nFlags ), sal_False );
228 SvxBaseAutoCorrCfg::SvxBaseAutoCorrCfg(SvxAutoCorrCfg& rPar) :
229 utl::ConfigItem(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/AutoCorrect"))),
230 rParent(rPar)
234 SvxBaseAutoCorrCfg::~SvxBaseAutoCorrCfg()
238 void SvxBaseAutoCorrCfg::Commit()
240 Sequence<OUString> aNames( GetPropertyNames() );
242 Sequence<Any> aValues(aNames.getLength());
243 Any* pValues = aValues.getArray();
245 const Type& rType = ::getBooleanCppuType();
246 sal_Bool bVal;
247 const long nFlags = rParent.pAutoCorrect->GetFlags();
248 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
250 switch(nProp)
252 case 0:
253 bVal = 0 != (nFlags & SaveWordCplSttLst);
254 pValues[nProp].setValue(&bVal, rType);
255 break;//"Exceptions/TwoCapitalsAtStart",
256 case 1:
257 bVal = 0 != (nFlags & SaveWordWrdSttLst);
258 pValues[nProp].setValue(&bVal, rType);
259 break;//"Exceptions/CapitalAtStartSentence",
260 case 2:
261 bVal = 0 != (nFlags & Autocorrect);
262 pValues[nProp].setValue(&bVal, rType);
263 break;//"UseReplacementTable",
264 case 3:
265 bVal = 0 != (nFlags & CptlSttWrd);
266 pValues[nProp].setValue(&bVal, rType);
267 break;//"TwoCapitalsAtStart",
268 case 4:
269 bVal = 0 != (nFlags & CptlSttSntnc);
270 pValues[nProp].setValue(&bVal, rType);
271 break;//"CapitalAtStartSentence",
272 case 5:
273 bVal = 0 != (nFlags & ChgWeightUnderl);
274 pValues[nProp].setValue(&bVal, rType);
275 break;//"ChangeUnderlineWeight",
276 case 6:
277 bVal = 0 != (nFlags & SetINetAttr);
278 pValues[nProp].setValue(&bVal, rType);
279 break;//"SetInetAttribute",
280 case 7:
281 bVal = 0 != (nFlags & ChgOrdinalNumber);
282 pValues[nProp].setValue(&bVal, rType);
283 break;//"ChangeOrdinalNumber",
284 case 8:
285 bVal = 0 != (nFlags & AddNonBrkSpace);
286 pValues[nProp].setValue(&bVal, rType);
287 break;//"AddNonBreakingSpace"
288 case 9:
289 bVal = 0 != (nFlags & ChgToEnEmDash);
290 pValues[nProp].setValue(&bVal, rType);
291 break;//"ChangeDash",
292 case 10:
293 bVal = 0 != (nFlags & IgnoreDoubleSpace);
294 pValues[nProp].setValue(&bVal, rType);
295 break;//"RemoveDoubleSpaces",
296 case 11:
297 bVal = 0 != (nFlags & ChgSglQuotes);
298 pValues[nProp].setValue(&bVal, rType);
299 break;//"ReplaceSingleQuote",
300 case 12:
301 pValues[nProp] <<= (sal_Int32)rParent.pAutoCorrect->GetStartSingleQuote();
302 break;//"SingleQuoteAtStart",
303 case 13:
304 pValues[nProp] <<= (sal_Int32) rParent.pAutoCorrect->GetEndSingleQuote();
305 break;//"SingleQuoteAtEnd",
306 case 14:
307 bVal = 0 != (nFlags & ChgQuotes);
308 pValues[nProp].setValue(&bVal, rType);
309 break;//"ReplaceDoubleQuote",
310 case 15:
311 pValues[nProp] <<= (sal_Int32) rParent.pAutoCorrect->GetStartDoubleQuote();
312 break;//"DoubleQuoteAtStart",
313 case 16:
314 pValues[nProp] <<= (sal_Int32) rParent.pAutoCorrect->GetEndDoubleQuote();
315 break;//"DoubleQuoteAtEnd"
316 case 17:
317 bVal = 0 != (nFlags & CorrectCapsLock);
318 pValues[nProp].setValue(&bVal, rType);
319 break;//"CorrectAccidentalCapsLock"
322 PutProperties(aNames, aValues);
325 void SvxBaseAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */)
327 Load(sal_False);
330 Sequence<OUString> SvxSwAutoCorrCfg::GetPropertyNames()
332 static const char* aPropNames[] =
334 "Text/FileLinks", // 0
335 "Text/InternetLinks", // 1
336 "Text/ShowPreview", // 2
337 "Text/ShowToolTip", // 3
338 "Text/SearchInAllCategories", // 4
339 "Format/Option/UseReplacementTable", // 5
340 "Format/Option/TwoCapitalsAtStart", // 6
341 "Format/Option/CapitalAtStartSentence", // 7
342 "Format/Option/ChangeUnderlineWeight", // 8
343 "Format/Option/SetInetAttribute", // 9
344 "Format/Option/ChangeOrdinalNumber", //10
345 "Format/Option/AddNonBreakingSpace", //11
346 "Format/Option/ChangeDash", //12
347 "Format/Option/DelEmptyParagraphs", //13
348 "Format/Option/ReplaceUserStyle", //14
349 "Format/Option/ChangeToBullets/Enable", //15
350 "Format/Option/ChangeToBullets/SpecialCharacter/Char", //16
351 "Format/Option/ChangeToBullets/SpecialCharacter/Font", //17
352 "Format/Option/ChangeToBullets/SpecialCharacter/FontFamily", //18
353 "Format/Option/ChangeToBullets/SpecialCharacter/FontCharset", //19
354 "Format/Option/ChangeToBullets/SpecialCharacter/FontPitch", //20
355 "Format/Option/CombineParagraphs", //21
356 "Format/Option/CombineValue", //22
357 "Format/Option/DelSpacesAtStartEnd", //23
358 "Format/Option/DelSpacesBetween", //24
359 "Format/ByInput/Enable", //25
360 "Format/ByInput/ChangeDash", //26
361 "Format/ByInput/ApplyNumbering/Enable", //27
362 "Format/ByInput/ChangeToBorders", //28
363 "Format/ByInput/ChangeToTable", //29
364 "Format/ByInput/ReplaceStyle", //30
365 "Format/ByInput/DelSpacesAtStartEnd", //31
366 "Format/ByInput/DelSpacesBetween", //32
367 "Completion/Enable", //33
368 "Completion/MinWordLen", //34
369 "Completion/MaxListLen", //35
370 "Completion/CollectWords", //36
371 "Completion/EndlessList", //37
372 "Completion/AppendBlank", //38
373 "Completion/ShowAsTip", //39
374 "Completion/AcceptKey", //40
375 "Completion/KeepList", //41
376 "Format/ByInput/ApplyNumbering/SpecialCharacter/Char", //42
377 "Format/ByInput/ApplyNumbering/SpecialCharacter/Font", //43
378 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily", //44
379 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset", //45
380 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch" //46
382 const int nCount = 47;
383 Sequence<OUString> aNames(nCount);
384 OUString* pNames = aNames.getArray();
385 for(int i = 0; i < nCount; i++)
386 pNames[i] = OUString::createFromAscii(aPropNames[i]);
387 return aNames;
390 void SvxSwAutoCorrCfg::Load(sal_Bool bInit)
392 Sequence<OUString> aNames = GetPropertyNames();
393 Sequence<Any> aValues = GetProperties(aNames);
394 if(bInit)
395 EnableNotification(aNames);
396 const Any* pValues = aValues.getConstArray();
397 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
398 if(aValues.getLength() == aNames.getLength())
400 SvxSwAutoFmtFlags& rSwFlags = rParent.pAutoCorrect->GetSwFlags();
401 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
403 if(pValues[nProp].hasValue())
405 switch(nProp)
407 case 0: rParent.bFileRel = *(sal_Bool*)pValues[nProp].getValue(); break; // "Text/FileLinks",
408 case 1: rParent.bNetRel = *(sal_Bool*)pValues[nProp].getValue(); break; // "Text/InternetLinks",
409 case 2: rParent.bAutoTextPreview = *(sal_Bool*)pValues[nProp].getValue(); break; // "Text/ShowPreview",
410 case 3: rParent.bAutoTextTip = *(sal_Bool*)pValues[nProp].getValue(); break; // "Text/ShowToolTip",
411 case 4: rParent.bSearchInAllCategories = *(sal_Bool*)pValues[nProp].getValue(); break; //"Text/SearchInAllCategories"
412 case 5: rSwFlags.bAutoCorrect = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/UseReplacementTable",
413 case 6: rSwFlags.bCptlSttSntnc = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/TwoCapitalsAtStart",
414 case 7: rSwFlags.bCptlSttWrd = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/CapitalAtStartSentence",
415 case 8: rSwFlags.bChgWeightUnderl = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/ChangeUnderlineWeight",
416 case 9: rSwFlags.bSetINetAttr = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/SetInetAttribute",
417 case 10: rSwFlags.bChgOrdinalNumber = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/ChangeOrdinalNumber",
418 case 11: rSwFlags.bAddNonBrkSpace = *(sal_Bool*)pValues[nProp].getValue( ); break; // "Format/Option/AddNonBreakingSpace",
419 // it doesn't exist here - the common flags are used for that -> LM
420 // case 12: rSwFlags.bChgToEnEmDash = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/ChangeDash",
421 case 13: rSwFlags.bDelEmptyNode = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/DelEmptyParagraphs",
422 case 14: rSwFlags.bChgUserColl = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/ReplaceUserStyle",
423 case 15: rSwFlags.bChgEnumNum = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/ChangeToBullets/Enable",
424 case 16:
426 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
427 rSwFlags.cBullet =
428 sal::static_int_cast< sal_Unicode >(nVal);
430 break; // "Format/Option/ChangeToBullets/SpecialCharacter/Char",
431 case 17:
433 OUString sTemp; pValues[nProp] >>= sTemp;
434 rSwFlags.aBulletFont.SetName(sTemp);
436 break; // "Format/Option/ChangeToBullets/SpecialCharacter/Font",
437 case 18:
439 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
440 rSwFlags.aBulletFont.SetFamily(FontFamily(nVal));
442 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontFamily",
443 case 19:
445 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
446 rSwFlags.aBulletFont.SetCharSet(CharSet(nVal));
448 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontCharset",
449 case 20:
451 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
452 rSwFlags.aBulletFont.SetPitch(FontPitch(nVal));
454 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontPitch",
455 case 21: rSwFlags.bRightMargin = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/CombineParagraphs",
456 case 22:
458 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
459 rSwFlags.nRightMargin =
460 sal::static_int_cast< sal_uInt8 >(nVal);
462 break; // "Format/Option/CombineValue",
463 case 23: rSwFlags.bAFmtDelSpacesAtSttEnd = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/DelSpacesAtStartEnd",
464 case 24: rSwFlags.bAFmtDelSpacesBetweenLines = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/Option/DelSpacesBetween",
465 case 25: rParent.bAutoFmtByInput = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/ByInput/Enable",
466 case 26: rSwFlags.bChgToEnEmDash = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/ByInput/ChangeDash",
467 case 27: rSwFlags.bSetNumRule = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/ByInput/ApplyNumbering/Enable",
468 case 28: rSwFlags.bSetBorder = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/ByInput/ChangeToBorders",
469 case 29: rSwFlags.bCreateTable = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/ByInput/ChangeToTable",
470 case 30: rSwFlags.bReplaceStyles = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/ByInput/ReplaceStyle",
471 case 31: rSwFlags.bAFmtByInpDelSpacesAtSttEnd = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/ByInput/DelSpacesAtStartEnd",
472 case 32: rSwFlags.bAFmtByInpDelSpacesBetweenLines = *(sal_Bool*)pValues[nProp].getValue(); break; // "Format/ByInput/DelSpacesBetween",
473 case 33: rSwFlags.bAutoCompleteWords = *(sal_Bool*)pValues[nProp].getValue(); break; // "Completion/Enable",
474 case 34:
476 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
477 rSwFlags.nAutoCmpltWordLen =
478 sal::static_int_cast< sal_uInt16 >(nVal);
480 break; // "Completion/MinWordLen",
481 case 35:
483 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
484 rSwFlags.nAutoCmpltListLen =
485 sal::static_int_cast< sal_uInt16 >(nVal);
487 break; // "Completion/MaxListLen",
488 case 36: rSwFlags.bAutoCmpltCollectWords = *(sal_Bool*)pValues[nProp].getValue(); break; // "Completion/CollectWords",
489 case 37: rSwFlags.bAutoCmpltEndless = *(sal_Bool*)pValues[nProp].getValue(); break; // "Completion/EndlessList",
490 case 38: rSwFlags.bAutoCmpltAppendBlanc = *(sal_Bool*)pValues[nProp].getValue(); break; // "Completion/AppendBlank",
491 case 39: rSwFlags.bAutoCmpltShowAsTip = *(sal_Bool*)pValues[nProp].getValue(); break; // "Completion/ShowAsTip",
492 case 40:
494 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
495 rSwFlags.nAutoCmpltExpandKey =
496 sal::static_int_cast< sal_uInt16 >(nVal);
498 break; // "Completion/AcceptKey"
499 case 41 :rSwFlags.bAutoCmpltKeepList = *(sal_Bool*)pValues[nProp].getValue(); break;//"Completion/KeepList"
500 case 42 :
502 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
503 rSwFlags.cByInputBullet =
504 sal::static_int_cast< sal_Unicode >(nVal);
506 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/Char",
507 case 43 :
509 OUString sTemp; pValues[nProp] >>= sTemp;
510 rSwFlags.aByInputBulletFont.SetName(sTemp);
512 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/Font",
513 case 44 :
515 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
516 rSwFlags.aByInputBulletFont.SetFamily(FontFamily(nVal));
518 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily",
519 case 45 :
521 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
522 rSwFlags.aByInputBulletFont.SetCharSet(CharSet(nVal));
524 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset",
525 case 46 :
527 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
528 rSwFlags.aByInputBulletFont.SetPitch(FontPitch(nVal));
530 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch",
537 SvxSwAutoCorrCfg::SvxSwAutoCorrCfg(SvxAutoCorrCfg& rPar) :
538 utl::ConfigItem(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Writer/AutoFunction"))),
539 rParent(rPar)
543 SvxSwAutoCorrCfg::~SvxSwAutoCorrCfg()
547 void SvxSwAutoCorrCfg::Commit()
549 Sequence<OUString> aNames = GetPropertyNames();
551 Sequence<Any> aValues(aNames.getLength());
552 Any* pValues = aValues.getArray();
554 const Type& rType = ::getBooleanCppuType();
555 sal_Bool bVal;
556 SvxSwAutoFmtFlags& rSwFlags = rParent.pAutoCorrect->GetSwFlags();
557 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
559 switch(nProp)
561 case 0: pValues[nProp].setValue(&rParent.bFileRel, rType); break; // "Text/FileLinks",
562 case 1: pValues[nProp].setValue(&rParent.bNetRel, rType); break; // "Text/InternetLinks",
563 case 2: pValues[nProp].setValue(&rParent.bAutoTextPreview, rType); break; // "Text/ShowPreview",
564 case 3: pValues[nProp].setValue(&rParent.bAutoTextTip, rType); break; // "Text/ShowToolTip",
565 case 4: pValues[nProp].setValue(&rParent.bSearchInAllCategories, rType );break; //"Text/SearchInAllCategories"
566 case 5: bVal = rSwFlags.bAutoCorrect; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/UseReplacementTable",
567 case 6: bVal = rSwFlags.bCptlSttSntnc; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/TwoCapitalsAtStart",
568 case 7: bVal = rSwFlags.bCptlSttWrd; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/CapitalAtStartSentence",
569 case 8: bVal = rSwFlags.bChgWeightUnderl; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/ChangeUnderlineWeight",
570 case 9: bVal = rSwFlags.bSetINetAttr; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/SetInetAttribute",
571 case 10: bVal = rSwFlags.bChgOrdinalNumber; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/ChangeOrdinalNumber",
572 case 11: bVal = rSwFlags.bAddNonBrkSpace; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/AddNonBreakingSpace",
573 // it doesn't exist here - the common flags are used for that -> LM
574 case 12:
575 bVal = sal_True; pValues[nProp].setValue(&bVal, rType);
576 break; // "Format/Option/ChangeDash",
577 case 13: bVal = rSwFlags.bDelEmptyNode; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/DelEmptyParagraphs",
578 case 14: bVal = rSwFlags.bChgUserColl; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/ReplaceUserStyle",
579 case 15: bVal = rSwFlags.bChgEnumNum; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/ChangeToBullets/Enable",
580 case 16:
581 pValues[nProp] <<= (sal_Int32)rSwFlags.cBullet;
582 break; // "Format/Option/ChangeToBullets/SpecialCharacter/Char",
583 case 17:
584 pValues[nProp] <<= OUString(rSwFlags.aBulletFont.GetName());
585 break; // "Format/Option/ChangeToBullets/SpecialCharacter/Font",
586 case 18:
587 pValues[nProp] <<= (sal_Int32)rSwFlags.aBulletFont.GetFamily();
588 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontFamily",
589 case 19:
590 pValues[nProp] <<= (sal_Int32)rSwFlags.aBulletFont.GetCharSet();
591 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontCharset",
592 case 20:
593 pValues[nProp] <<= (sal_Int32)rSwFlags.aBulletFont.GetPitch();
594 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontPitch",
595 case 21: bVal = rSwFlags.bRightMargin; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/CombineParagraphs",
596 case 22:
597 pValues[nProp] <<= (sal_Int32)rSwFlags.nRightMargin;
598 break; // "Format/Option/CombineValue",
599 case 23: bVal = rSwFlags.bAFmtDelSpacesAtSttEnd; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/DelSpacesAtStartEnd",
600 case 24: bVal = rSwFlags.bAFmtDelSpacesBetweenLines; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/DelSpacesBetween",
601 case 25: bVal = rParent.bAutoFmtByInput; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/Enable",
602 case 26: bVal = rSwFlags.bChgToEnEmDash; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/ChangeDash",
603 case 27: bVal = rSwFlags.bSetNumRule; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/ApplyNumbering/Enable",
604 case 28: bVal = rSwFlags.bSetBorder; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/ChangeToBorders",
605 case 29: bVal = rSwFlags.bCreateTable; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/ChangeToTable",
606 case 30: bVal = rSwFlags.bReplaceStyles; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/ReplaceStyle",
607 case 31: bVal = rSwFlags.bAFmtByInpDelSpacesAtSttEnd; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/DelSpacesAtStartEnd",
608 case 32: bVal = rSwFlags.bAFmtByInpDelSpacesBetweenLines; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/DelSpacesBetween",
609 case 33: bVal = rSwFlags.bAutoCompleteWords; pValues[nProp].setValue(&bVal, rType); break; // "Completion/Enable",
610 case 34:
611 pValues[nProp] <<= (sal_Int32)rSwFlags.nAutoCmpltWordLen;
612 break; // "Completion/MinWordLen",
613 case 35:
614 pValues[nProp] <<= (sal_Int32)rSwFlags.nAutoCmpltListLen;
615 break; // "Completion/MaxListLen",
616 case 36: bVal = rSwFlags.bAutoCmpltCollectWords; pValues[nProp].setValue(&bVal, rType); break; // "Completion/CollectWords",
617 case 37: bVal = rSwFlags.bAutoCmpltEndless; pValues[nProp].setValue(&bVal, rType); break; // "Completion/EndlessList",
618 case 38: bVal = rSwFlags.bAutoCmpltAppendBlanc; pValues[nProp].setValue(&bVal, rType); break; // "Completion/AppendBlank",
619 case 39: bVal = rSwFlags.bAutoCmpltShowAsTip; pValues[nProp].setValue(&bVal, rType); break; // "Completion/ShowAsTip",
620 case 40:
621 pValues[nProp] <<= (sal_Int32)rSwFlags.nAutoCmpltExpandKey;
622 break; // "Completion/AcceptKey"
623 case 41 :bVal = rSwFlags.bAutoCmpltKeepList; pValues[nProp].setValue(&bVal, rType); break;// "Completion/KeepList"
624 case 42 :
625 pValues[nProp] <<= (sal_Int32)rSwFlags.cByInputBullet;
626 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/Char",
627 case 43 :
628 pValues[nProp] <<= OUString(rSwFlags.aByInputBulletFont.GetName());
629 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/Font",
630 case 44 :
631 pValues[nProp] <<= (sal_Int32)rSwFlags.aByInputBulletFont.GetFamily();
632 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily",
633 case 45 :
634 pValues[nProp] <<= (sal_Int32)rSwFlags.aByInputBulletFont.GetCharSet();
635 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset",
636 case 46 :
637 pValues[nProp] <<= (sal_Int32)rSwFlags.aByInputBulletFont.GetPitch();
638 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch",
641 PutProperties(aNames, aValues);
644 void SvxSwAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ )
646 Load(sal_False);
649 namespace
651 class theSvxAutoCorrCfg : public rtl::Static<SvxAutoCorrCfg, theSvxAutoCorrCfg>{};
654 SvxAutoCorrCfg& SvxAutoCorrCfg::Get()
656 return theSvxAutoCorrCfg::get();
659 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */