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