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