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