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