bump product version to 5.0.4.1
[LibreOffice.git] / editeng / source / misc / acorrcfg.cxx
blob325e787217dd8ae5a670a984b5fad29ae5f8db33
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <comphelper/processfactory.hxx>
21 #include <editeng/acorrcfg.hxx>
22 #include <tools/debug.hxx>
23 #include <tools/urlobj.hxx>
24 #include <ucbhelper/content.hxx>
25 #include <unotools/pathoptions.hxx>
26 #include <unotools/ucbhelper.hxx>
27 #include <svl/urihelper.hxx>
29 #include <editeng/svxacorr.hxx>
30 #include <com/sun/star/uno/Any.hxx>
31 #include <com/sun/star/uno/Sequence.hxx>
33 #include <rtl/instance.hxx>
35 using namespace utl;
36 using namespace com::sun::star;
37 using namespace com::sun::star::uno;
40 SvxAutoCorrCfg::SvxAutoCorrCfg() :
41 aBaseConfig(*this),
42 aSwConfig(*this),
43 bFileRel(true),
44 bNetRel(true),
45 bAutoTextTip(true),
46 bAutoTextPreview(false),
47 bAutoFmtByInput(true),
48 bSearchInAllCategories(false)
50 SvtPathOptions aPathOpt;
51 OUString sSharePath, sUserPath, sAutoPath( aPathOpt.GetAutoCorrectPath() );
53 sSharePath = sAutoPath.getToken(0, ';');
54 sUserPath = sAutoPath.getToken(1, ';');
56 //fdo#67743 ensure the userdir exists so that any later attempt to copy the
57 //shared autocorrect file into the user dir will succeed
58 ::ucbhelper::Content aContent;
59 Reference < ucb::XCommandEnvironment > xEnv;
60 ::utl::UCBContentHelper::ensureFolder(comphelper::getProcessComponentContext(), xEnv, sUserPath, aContent);
62 OUString* pS = &sSharePath;
63 for( sal_uInt16 n = 0; n < 2; ++n, pS = &sUserPath )
65 INetURLObject aPath( *pS );
66 aPath.insertName(OUString("acor"));
67 *pS = aPath.GetMainURL(INetURLObject::DECODE_TO_IURI);
69 pAutoCorrect = new SvxAutoCorrect( sSharePath, sUserPath );
71 aBaseConfig.Load(true);
72 aSwConfig.Load(true);
75 SvxAutoCorrCfg::~SvxAutoCorrCfg()
77 delete pAutoCorrect;
80 void SvxAutoCorrCfg::SetAutoCorrect(SvxAutoCorrect *const pNew)
82 if (pNew != pAutoCorrect)
84 if (pNew && (pAutoCorrect->GetFlags() != pNew->GetFlags()))
86 aBaseConfig.SetModified();
87 aSwConfig.SetModified();
89 delete pAutoCorrect;
90 pAutoCorrect = pNew;
94 Sequence<OUString> SvxBaseAutoCorrCfg::GetPropertyNames()
96 static const char* aPropNames[] =
98 "Exceptions/TwoCapitalsAtStart", // 0
99 "Exceptions/CapitalAtStartSentence", // 1
100 "UseReplacementTable", // 2
101 "TwoCapitalsAtStart", // 3
102 "CapitalAtStartSentence", // 4
103 "ChangeUnderlineWeight", // 5
104 "SetInetAttribute", // 6
105 "ChangeOrdinalNumber", // 7
106 "AddNonBreakingSpace", // 8
107 "ChangeDash", // 9
108 "RemoveDoubleSpaces", // 10
109 "ReplaceSingleQuote", // 11
110 "SingleQuoteAtStart", // 12
111 "SingleQuoteAtEnd", // 13
112 "ReplaceDoubleQuote", // 14
113 "DoubleQuoteAtStart", // 15
114 "DoubleQuoteAtEnd", // 16
115 "CorrectAccidentalCapsLock" // 17
117 const int nCount = 18;
118 Sequence<OUString> aNames(nCount);
119 OUString* pNames = aNames.getArray();
120 for(int i = 0; i < nCount; i++)
121 pNames[i] = OUString::createFromAscii(aPropNames[i]);
122 return aNames;
125 void SvxBaseAutoCorrCfg::Load(bool bInit)
127 Sequence<OUString> aNames = GetPropertyNames();
128 Sequence<Any> aValues = GetProperties(aNames);
129 if(bInit)
130 EnableNotification(aNames);
131 const Any* pValues = aValues.getConstArray();
132 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
133 if(aValues.getLength() == aNames.getLength())
135 long nFlags = 0; // default all off
136 sal_Int32 nTemp = 0;
137 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
139 if(pValues[nProp].hasValue())
141 switch(nProp)
143 case 0:
144 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
145 nFlags |= SaveWordCplSttLst;
146 break;//"Exceptions/TwoCapitalsAtStart",
147 case 1:
148 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
149 nFlags |= SaveWordWrdSttLst;
150 break;//"Exceptions/CapitalAtStartSentence",
151 case 2:
152 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
153 nFlags |= Autocorrect;
154 break;//"UseReplacementTable",
155 case 3:
156 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
157 nFlags |= CptlSttWrd;
158 break;//"TwoCapitalsAtStart",
159 case 4:
160 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
161 nFlags |= CptlSttSntnc;
162 break;//"CapitalAtStartSentence",
163 case 5:
164 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
165 nFlags |= ChgWeightUnderl;
166 break;//"ChangeUnderlineWeight",
167 case 6:
168 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
169 nFlags |= SetINetAttr;
170 break;//"SetInetAttribute",
171 case 7:
172 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
173 nFlags |= ChgOrdinalNumber;
174 break;//"ChangeOrdinalNumber",
175 case 8:
176 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
177 nFlags |= AddNonBrkSpace;
178 break;//"AddNonBreakingSpace"
179 case 9:
180 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
181 nFlags |= ChgToEnEmDash;
182 break;//"ChangeDash",
183 case 10:
184 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
185 nFlags |= IgnoreDoubleSpace;
186 break;//"RemoveDoubleSpaces",
187 case 11:
188 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
189 nFlags |= ChgSglQuotes;
190 break;//"ReplaceSingleQuote",
191 case 12:
192 pValues[nProp] >>= nTemp;
193 rParent.pAutoCorrect->SetStartSingleQuote(
194 sal::static_int_cast< sal_Unicode >( nTemp ) );
195 break;//"SingleQuoteAtStart",
196 case 13:
197 pValues[nProp] >>= nTemp;
198 rParent.pAutoCorrect->SetEndSingleQuote(
199 sal::static_int_cast< sal_Unicode >( nTemp ) );
200 break;//"SingleQuoteAtEnd",
201 case 14:
202 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
203 nFlags |= ChgQuotes;
204 break;//"ReplaceDoubleQuote",
205 case 15:
206 pValues[nProp] >>= nTemp;
207 rParent.pAutoCorrect->SetStartDoubleQuote(
208 sal::static_int_cast< sal_Unicode >( nTemp ) );
209 break;//"DoubleQuoteAtStart",
210 case 16:
211 pValues[nProp] >>= nTemp;
212 rParent.pAutoCorrect->SetEndDoubleQuote(
213 sal::static_int_cast< sal_Unicode >( nTemp ) );
214 break;//"DoubleQuoteAtEnd"
215 case 17:
216 if(*static_cast<sal_Bool const *>(pValues[nProp].getValue()))
217 nFlags |= CorrectCapsLock;
218 break;//"CorrectAccidentalCapsLock"
222 if( nFlags )
223 rParent.pAutoCorrect->SetAutoCorrFlag( nFlags, true );
224 rParent.pAutoCorrect->SetAutoCorrFlag( ( 0xffff & ~nFlags ), false );
229 SvxBaseAutoCorrCfg::SvxBaseAutoCorrCfg(SvxAutoCorrCfg& rPar) :
230 utl::ConfigItem(OUString("Office.Common/AutoCorrect")),
231 rParent(rPar)
235 SvxBaseAutoCorrCfg::~SvxBaseAutoCorrCfg()
239 void SvxBaseAutoCorrCfg::ImplCommit()
241 Sequence<OUString> aNames( GetPropertyNames() );
243 Sequence<Any> aValues(aNames.getLength());
244 Any* pValues = aValues.getArray();
246 const Type& rType = cppu::UnoType<bool>::get();
247 sal_Bool bVal;
248 const long nFlags = rParent.pAutoCorrect->GetFlags();
249 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
251 switch(nProp)
253 case 0:
254 bVal = 0 != (nFlags & SaveWordCplSttLst);
255 pValues[nProp].setValue(&bVal, rType);
256 break;//"Exceptions/TwoCapitalsAtStart",
257 case 1:
258 bVal = 0 != (nFlags & SaveWordWrdSttLst);
259 pValues[nProp].setValue(&bVal, rType);
260 break;//"Exceptions/CapitalAtStartSentence",
261 case 2:
262 bVal = 0 != (nFlags & Autocorrect);
263 pValues[nProp].setValue(&bVal, rType);
264 break;//"UseReplacementTable",
265 case 3:
266 bVal = 0 != (nFlags & CptlSttWrd);
267 pValues[nProp].setValue(&bVal, rType);
268 break;//"TwoCapitalsAtStart",
269 case 4:
270 bVal = 0 != (nFlags & CptlSttSntnc);
271 pValues[nProp].setValue(&bVal, rType);
272 break;//"CapitalAtStartSentence",
273 case 5:
274 bVal = 0 != (nFlags & ChgWeightUnderl);
275 pValues[nProp].setValue(&bVal, rType);
276 break;//"ChangeUnderlineWeight",
277 case 6:
278 bVal = 0 != (nFlags & SetINetAttr);
279 pValues[nProp].setValue(&bVal, rType);
280 break;//"SetInetAttribute",
281 case 7:
282 bVal = 0 != (nFlags & ChgOrdinalNumber);
283 pValues[nProp].setValue(&bVal, rType);
284 break;//"ChangeOrdinalNumber",
285 case 8:
286 bVal = 0 != (nFlags & AddNonBrkSpace);
287 pValues[nProp].setValue(&bVal, rType);
288 break;//"AddNonBreakingSpace"
289 case 9:
290 bVal = 0 != (nFlags & ChgToEnEmDash);
291 pValues[nProp].setValue(&bVal, rType);
292 break;//"ChangeDash",
293 case 10:
294 bVal = 0 != (nFlags & IgnoreDoubleSpace);
295 pValues[nProp].setValue(&bVal, rType);
296 break;//"RemoveDoubleSpaces",
297 case 11:
298 bVal = 0 != (nFlags & ChgSglQuotes);
299 pValues[nProp].setValue(&bVal, rType);
300 break;//"ReplaceSingleQuote",
301 case 12:
302 pValues[nProp] <<= (sal_Int32)rParent.pAutoCorrect->GetStartSingleQuote();
303 break;//"SingleQuoteAtStart",
304 case 13:
305 pValues[nProp] <<= (sal_Int32) rParent.pAutoCorrect->GetEndSingleQuote();
306 break;//"SingleQuoteAtEnd",
307 case 14:
308 bVal = 0 != (nFlags & ChgQuotes);
309 pValues[nProp].setValue(&bVal, rType);
310 break;//"ReplaceDoubleQuote",
311 case 15:
312 pValues[nProp] <<= (sal_Int32) rParent.pAutoCorrect->GetStartDoubleQuote();
313 break;//"DoubleQuoteAtStart",
314 case 16:
315 pValues[nProp] <<= (sal_Int32) rParent.pAutoCorrect->GetEndDoubleQuote();
316 break;//"DoubleQuoteAtEnd"
317 case 17:
318 bVal = 0 != (nFlags & CorrectCapsLock);
319 pValues[nProp].setValue(&bVal, rType);
320 break;//"CorrectAccidentalCapsLock"
323 PutProperties(aNames, aValues);
326 void SvxBaseAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */)
328 Load(false);
331 Sequence<OUString> SvxSwAutoCorrCfg::GetPropertyNames()
333 static const char* aPropNames[] =
335 "Text/FileLinks", // 0
336 "Text/InternetLinks", // 1
337 "Text/ShowPreview", // 2
338 "Text/ShowToolTip", // 3
339 "Text/SearchInAllCategories", // 4
340 "Format/Option/UseReplacementTable", // 5
341 "Format/Option/TwoCapitalsAtStart", // 6
342 "Format/Option/CapitalAtStartSentence", // 7
343 "Format/Option/ChangeUnderlineWeight", // 8
344 "Format/Option/SetInetAttribute", // 9
345 "Format/Option/ChangeOrdinalNumber", //10
346 "Format/Option/AddNonBreakingSpace", //11
347 "Format/Option/ChangeDash", //12
348 "Format/Option/DelEmptyParagraphs", //13
349 "Format/Option/ReplaceUserStyle", //14
350 "Format/Option/ChangeToBullets/Enable", //15
351 "Format/Option/ChangeToBullets/SpecialCharacter/Char", //16
352 "Format/Option/ChangeToBullets/SpecialCharacter/Font", //17
353 "Format/Option/ChangeToBullets/SpecialCharacter/FontFamily", //18
354 "Format/Option/ChangeToBullets/SpecialCharacter/FontCharset", //19
355 "Format/Option/ChangeToBullets/SpecialCharacter/FontPitch", //20
356 "Format/Option/CombineParagraphs", //21
357 "Format/Option/CombineValue", //22
358 "Format/Option/DelSpacesAtStartEnd", //23
359 "Format/Option/DelSpacesBetween", //24
360 "Format/ByInput/Enable", //25
361 "Format/ByInput/ChangeDash", //26
362 "Format/ByInput/ApplyNumbering/Enable", //27
363 "Format/ByInput/ChangeToBorders", //28
364 "Format/ByInput/ChangeToTable", //29
365 "Format/ByInput/ReplaceStyle", //30
366 "Format/ByInput/DelSpacesAtStartEnd", //31
367 "Format/ByInput/DelSpacesBetween", //32
368 "Completion/Enable", //33
369 "Completion/MinWordLen", //34
370 "Completion/MaxListLen", //35
371 "Completion/CollectWords", //36
372 "Completion/EndlessList", //37
373 "Completion/AppendBlank", //38
374 "Completion/ShowAsTip", //39
375 "Completion/AcceptKey", //40
376 "Completion/KeepList", //41
377 "Format/ByInput/ApplyNumbering/SpecialCharacter/Char", //42
378 "Format/ByInput/ApplyNumbering/SpecialCharacter/Font", //43
379 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily", //44
380 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset", //45
381 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch" //46
383 const int nCount = 47;
384 Sequence<OUString> aNames(nCount);
385 OUString* pNames = aNames.getArray();
386 for(int i = 0; i < nCount; i++)
387 pNames[i] = OUString::createFromAscii(aPropNames[i]);
388 return aNames;
391 void SvxSwAutoCorrCfg::Load(bool bInit)
393 Sequence<OUString> aNames = GetPropertyNames();
394 Sequence<Any> aValues = GetProperties(aNames);
395 if(bInit)
396 EnableNotification(aNames);
397 const Any* pValues = aValues.getConstArray();
398 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
399 if(aValues.getLength() == aNames.getLength())
401 SvxSwAutoFormatFlags& rSwFlags = rParent.pAutoCorrect->GetSwFlags();
402 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
404 if(pValues[nProp].hasValue())
406 switch(nProp)
408 case 0: rParent.bFileRel = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Text/FileLinks",
409 case 1: rParent.bNetRel = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Text/InternetLinks",
410 case 2: rParent.bAutoTextPreview = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Text/ShowPreview",
411 case 3: rParent.bAutoTextTip = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Text/ShowToolTip",
412 case 4: rParent.bSearchInAllCategories = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; //"Text/SearchInAllCategories"
413 case 5: rSwFlags.bAutoCorrect = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/UseReplacementTable",
414 case 6: rSwFlags.bCptlSttSntnc = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/TwoCapitalsAtStart",
415 case 7: rSwFlags.bCptlSttWrd = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/CapitalAtStartSentence",
416 case 8: rSwFlags.bChgWeightUnderl = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/ChangeUnderlineWeight",
417 case 9: rSwFlags.bSetINetAttr = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/SetInetAttribute",
418 case 10: rSwFlags.bChgOrdinalNumber = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/ChangeOrdinalNumber",
419 case 11: rSwFlags.bAddNonBrkSpace = *static_cast<sal_Bool const *>(pValues[nProp].getValue( )); break; // "Format/Option/AddNonBreakingSpace",
420 // it doesn't exist here - the common flags are used for that -> LM
421 // case 12: rSwFlags.bChgToEnEmDash = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/ChangeDash",
422 case 13: rSwFlags.bDelEmptyNode = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/DelEmptyParagraphs",
423 case 14: rSwFlags.bChgUserColl = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/ReplaceUserStyle",
424 case 15: rSwFlags.bChgEnumNum = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/ChangeToBullets/Enable",
425 case 16:
427 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
428 rSwFlags.cBullet =
429 sal::static_int_cast< sal_Unicode >(nVal);
431 break; // "Format/Option/ChangeToBullets/SpecialCharacter/Char",
432 case 17:
434 OUString sTemp; pValues[nProp] >>= sTemp;
435 rSwFlags.aBulletFont.SetName(sTemp);
437 break; // "Format/Option/ChangeToBullets/SpecialCharacter/Font",
438 case 18:
440 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
441 rSwFlags.aBulletFont.SetFamily(FontFamily(nVal));
443 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontFamily",
444 case 19:
446 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
447 rSwFlags.aBulletFont.SetCharSet(rtl_TextEncoding(nVal));
449 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontCharset",
450 case 20:
452 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
453 rSwFlags.aBulletFont.SetPitch(FontPitch(nVal));
455 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontPitch",
456 case 21: rSwFlags.bRightMargin = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/CombineParagraphs",
457 case 22:
459 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
460 rSwFlags.nRightMargin =
461 sal::static_int_cast< sal_uInt8 >(nVal);
463 break; // "Format/Option/CombineValue",
464 case 23: rSwFlags.bAFormatDelSpacesAtSttEnd = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/DelSpacesAtStartEnd",
465 case 24: rSwFlags.bAFormatDelSpacesBetweenLines = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/DelSpacesBetween",
466 case 25: rParent.bAutoFmtByInput = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/Enable",
467 case 26: rSwFlags.bChgToEnEmDash = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/ChangeDash",
468 case 27: rSwFlags.bSetNumRule = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/ApplyNumbering/Enable",
469 case 28: rSwFlags.bSetBorder = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/ChangeToBorders",
470 case 29: rSwFlags.bCreateTable = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/ChangeToTable",
471 case 30: rSwFlags.bReplaceStyles = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/ReplaceStyle",
472 case 31: rSwFlags.bAFormatByInpDelSpacesAtSttEnd = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/DelSpacesAtStartEnd",
473 case 32: rSwFlags.bAFormatByInpDelSpacesBetweenLines = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/DelSpacesBetween",
474 case 33: rSwFlags.bAutoCompleteWords = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Completion/Enable",
475 case 34:
477 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
478 rSwFlags.nAutoCmpltWordLen =
479 sal::static_int_cast< sal_uInt16 >(nVal);
481 break; // "Completion/MinWordLen",
482 case 35:
484 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
485 rSwFlags.nAutoCmpltListLen =
486 sal::static_int_cast< sal_uInt16 >(nVal);
488 break; // "Completion/MaxListLen",
489 case 36: rSwFlags.bAutoCmpltCollectWords = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Completion/CollectWords",
490 case 37: rSwFlags.bAutoCmpltEndless = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Completion/EndlessList",
491 case 38: rSwFlags.bAutoCmpltAppendBlanc = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Completion/AppendBlank",
492 case 39: rSwFlags.bAutoCmpltShowAsTip = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Completion/ShowAsTip",
493 case 40:
495 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
496 rSwFlags.nAutoCmpltExpandKey =
497 sal::static_int_cast< sal_uInt16 >(nVal);
499 break; // "Completion/AcceptKey"
500 case 41 :rSwFlags.bAutoCmpltKeepList = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break;//"Completion/KeepList"
501 case 42 :
503 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
504 rSwFlags.cByInputBullet =
505 sal::static_int_cast< sal_Unicode >(nVal);
507 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/Char",
508 case 43 :
510 OUString sTemp; pValues[nProp] >>= sTemp;
511 rSwFlags.aByInputBulletFont.SetName(sTemp);
513 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/Font",
514 case 44 :
516 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
517 rSwFlags.aByInputBulletFont.SetFamily(FontFamily(nVal));
519 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily",
520 case 45 :
522 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
523 rSwFlags.aByInputBulletFont.SetCharSet(rtl_TextEncoding(nVal));
525 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset",
526 case 46 :
528 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
529 rSwFlags.aByInputBulletFont.SetPitch(FontPitch(nVal));
531 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch",
538 SvxSwAutoCorrCfg::SvxSwAutoCorrCfg(SvxAutoCorrCfg& rPar) :
539 utl::ConfigItem(OUString("Office.Writer/AutoFunction")),
540 rParent(rPar)
544 SvxSwAutoCorrCfg::~SvxSwAutoCorrCfg()
548 void SvxSwAutoCorrCfg::ImplCommit()
550 Sequence<OUString> aNames = GetPropertyNames();
552 Sequence<Any> aValues(aNames.getLength());
553 Any* pValues = aValues.getArray();
555 const Type& rType = cppu::UnoType<bool>::get();
556 sal_Bool bVal;
557 SvxSwAutoFormatFlags& rSwFlags = rParent.pAutoCorrect->GetSwFlags();
558 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
560 switch(nProp)
562 case 0: pValues[nProp].setValue(&rParent.bFileRel, rType); break; // "Text/FileLinks",
563 case 1: pValues[nProp].setValue(&rParent.bNetRel, rType); break; // "Text/InternetLinks",
564 case 2: pValues[nProp].setValue(&rParent.bAutoTextPreview, rType); break; // "Text/ShowPreview",
565 case 3: pValues[nProp].setValue(&rParent.bAutoTextTip, rType); break; // "Text/ShowToolTip",
566 case 4: pValues[nProp].setValue(&rParent.bSearchInAllCategories, rType );break; //"Text/SearchInAllCategories"
567 case 5: bVal = rSwFlags.bAutoCorrect; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/UseReplacementTable",
568 case 6: bVal = rSwFlags.bCptlSttSntnc; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/TwoCapitalsAtStart",
569 case 7: bVal = rSwFlags.bCptlSttWrd; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/CapitalAtStartSentence",
570 case 8: bVal = rSwFlags.bChgWeightUnderl; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/ChangeUnderlineWeight",
571 case 9: bVal = rSwFlags.bSetINetAttr; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/SetInetAttribute",
572 case 10: bVal = rSwFlags.bChgOrdinalNumber; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/ChangeOrdinalNumber",
573 case 11: bVal = rSwFlags.bAddNonBrkSpace; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/AddNonBreakingSpace",
574 // it doesn't exist here - the common flags are used for that -> LM
575 case 12:
576 bVal = sal_True; pValues[nProp].setValue(&bVal, rType);
577 break; // "Format/Option/ChangeDash",
578 case 13: bVal = rSwFlags.bDelEmptyNode; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/DelEmptyParagraphs",
579 case 14: bVal = rSwFlags.bChgUserColl; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/ReplaceUserStyle",
580 case 15: bVal = rSwFlags.bChgEnumNum; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/ChangeToBullets/Enable",
581 case 16:
582 pValues[nProp] <<= (sal_Int32)rSwFlags.cBullet;
583 break; // "Format/Option/ChangeToBullets/SpecialCharacter/Char",
584 case 17:
585 pValues[nProp] <<= OUString(rSwFlags.aBulletFont.GetName());
586 break; // "Format/Option/ChangeToBullets/SpecialCharacter/Font",
587 case 18:
588 pValues[nProp] <<= (sal_Int32)rSwFlags.aBulletFont.GetFamily();
589 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontFamily",
590 case 19:
591 pValues[nProp] <<= (sal_Int32)rSwFlags.aBulletFont.GetCharSet();
592 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontCharset",
593 case 20:
594 pValues[nProp] <<= (sal_Int32)rSwFlags.aBulletFont.GetPitch();
595 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontPitch",
596 case 21: bVal = rSwFlags.bRightMargin; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/CombineParagraphs",
597 case 22:
598 pValues[nProp] <<= (sal_Int32)rSwFlags.nRightMargin;
599 break; // "Format/Option/CombineValue",
600 case 23: bVal = rSwFlags.bAFormatDelSpacesAtSttEnd; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/DelSpacesAtStartEnd",
601 case 24: bVal = rSwFlags.bAFormatDelSpacesBetweenLines; pValues[nProp].setValue(&bVal, rType); break; // "Format/Option/DelSpacesBetween",
602 case 25: bVal = rParent.bAutoFmtByInput; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/Enable",
603 case 26: bVal = rSwFlags.bChgToEnEmDash; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/ChangeDash",
604 case 27: bVal = rSwFlags.bSetNumRule; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/ApplyNumbering/Enable",
605 case 28: bVal = rSwFlags.bSetBorder; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/ChangeToBorders",
606 case 29: bVal = rSwFlags.bCreateTable; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/ChangeToTable",
607 case 30: bVal = rSwFlags.bReplaceStyles; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/ReplaceStyle",
608 case 31: bVal = rSwFlags.bAFormatByInpDelSpacesAtSttEnd; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/DelSpacesAtStartEnd",
609 case 32: bVal = rSwFlags.bAFormatByInpDelSpacesBetweenLines; pValues[nProp].setValue(&bVal, rType); break; // "Format/ByInput/DelSpacesBetween",
610 case 33: bVal = rSwFlags.bAutoCompleteWords; pValues[nProp].setValue(&bVal, rType); break; // "Completion/Enable",
611 case 34:
612 pValues[nProp] <<= (sal_Int32)rSwFlags.nAutoCmpltWordLen;
613 break; // "Completion/MinWordLen",
614 case 35:
615 pValues[nProp] <<= (sal_Int32)rSwFlags.nAutoCmpltListLen;
616 break; // "Completion/MaxListLen",
617 case 36: bVal = rSwFlags.bAutoCmpltCollectWords; pValues[nProp].setValue(&bVal, rType); break; // "Completion/CollectWords",
618 case 37: bVal = rSwFlags.bAutoCmpltEndless; pValues[nProp].setValue(&bVal, rType); break; // "Completion/EndlessList",
619 case 38: bVal = rSwFlags.bAutoCmpltAppendBlanc; pValues[nProp].setValue(&bVal, rType); break; // "Completion/AppendBlank",
620 case 39: bVal = rSwFlags.bAutoCmpltShowAsTip; pValues[nProp].setValue(&bVal, rType); break; // "Completion/ShowAsTip",
621 case 40:
622 pValues[nProp] <<= (sal_Int32)rSwFlags.nAutoCmpltExpandKey;
623 break; // "Completion/AcceptKey"
624 case 41 :bVal = rSwFlags.bAutoCmpltKeepList; pValues[nProp].setValue(&bVal, rType); break;// "Completion/KeepList"
625 case 42 :
626 pValues[nProp] <<= (sal_Int32)rSwFlags.cByInputBullet;
627 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/Char",
628 case 43 :
629 pValues[nProp] <<= OUString(rSwFlags.aByInputBulletFont.GetName());
630 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/Font",
631 case 44 :
632 pValues[nProp] <<= (sal_Int32)rSwFlags.aByInputBulletFont.GetFamily();
633 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily",
634 case 45 :
635 pValues[nProp] <<= (sal_Int32)rSwFlags.aByInputBulletFont.GetCharSet();
636 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset",
637 case 46 :
638 pValues[nProp] <<= (sal_Int32)rSwFlags.aByInputBulletFont.GetPitch();
639 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch",
642 PutProperties(aNames, aValues);
645 void SvxSwAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ )
647 Load(false);
650 namespace
652 class theSvxAutoCorrCfg : public rtl::Static<SvxAutoCorrCfg, theSvxAutoCorrCfg>{};
655 SvxAutoCorrCfg& SvxAutoCorrCfg::Get()
657 return theSvxAutoCorrCfg::get();
660 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */