LCOV - code coverage report
Current view: top level - editeng/source/misc - acorrcfg.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 199 352 56.5 %
Date: 2014-04-11 Functions: 12 19 63.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10