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