LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/config - usrpref.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 216 306 70.6 %
Date: 2013-07-09 Functions: 25 39 64.1 %
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 <tools/stream.hxx>
      21             : #include <unotools/syslocale.hxx>
      22             : 
      23             : #include "swtypes.hxx"
      24             : #include "hintids.hxx"
      25             : #include "uitool.hxx"
      26             : #include "usrpref.hxx"
      27             : #include "crstate.hxx"
      28             : #include <linguistic/lngprops.hxx>
      29             : #include <com/sun/star/beans/XPropertySet.hpp>
      30             : #include <com/sun/star/uno/Any.hxx>
      31             : #include <com/sun/star/uno/Sequence.hxx>
      32             : #include <unotools/localedatawrapper.hxx>
      33             : 
      34             : #include <unomid.h>
      35             : 
      36             : using namespace utl;
      37             : using namespace ::com::sun::star;
      38             : using namespace ::com::sun::star::uno;
      39             : 
      40             : 
      41             : 
      42           0 : void SwMasterUsrPref::SetUsrPref(const SwViewOption &rCopy)
      43             : {
      44           0 :     *((SwViewOption*)this) = rCopy;
      45           0 : }
      46             : 
      47          34 : SwMasterUsrPref::SwMasterUsrPref(sal_Bool bWeb) :
      48             :     eFldUpdateFlags(AUTOUPD_OFF),
      49             :     nLinkUpdateMode(0),
      50             :     bIsHScrollMetricSet(sal_False),
      51             :     bIsVScrollMetricSet(sal_False),
      52             :     nDefTab( MM50 * 4 ),
      53             :     bIsSquaredPageMode(sal_False),
      54             :     aContentConfig(bWeb, *this),
      55             :     aLayoutConfig(bWeb, *this),
      56             :     aGridConfig(bWeb, *this),
      57             :     aCursorConfig(*this),
      58           1 :     pWebColorConfig(bWeb ? new SwWebColorConfig(*this) : 0),
      59          35 :     bApplyCharUnit(sal_False)
      60             : {
      61          34 :     MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
      62          34 :     eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH;
      63             : 
      64          34 :     aContentConfig.Load();
      65          34 :     aLayoutConfig.Load();
      66          34 :     aGridConfig.Load();
      67          34 :     aCursorConfig.Load();
      68          34 :     if(pWebColorConfig)
      69           1 :         pWebColorConfig->Load();
      70          34 : }
      71             : 
      72          42 : SwMasterUsrPref::~SwMasterUsrPref()
      73             : {
      74          21 :     delete pWebColorConfig;
      75          21 : }
      76             : 
      77         102 : Sequence<OUString> SwContentViewConfig::GetPropertyNames()
      78             : {
      79             :     static const char* aPropNames[] =
      80             :     {
      81             :         "Display/GraphicObject",                    //  0
      82             :         "Display/Table",                            //  1
      83             :         "Display/DrawingControl",                   //  2
      84             :         "Display/FieldCode",                        //  3
      85             :         "Display/Note",                             //  4
      86             :         "Display/ShowContentTips",                      //  5
      87             :         "NonprintingCharacter/MetaCharacters",     //   6
      88             :         "NonprintingCharacter/ParagraphEnd",        //  7
      89             :         "NonprintingCharacter/OptionalHyphen",      //  8
      90             :         "NonprintingCharacter/Space",               //  9
      91             :         "NonprintingCharacter/Break",               // 10
      92             :         "NonprintingCharacter/ProtectedSpace",      // 11
      93             :         "NonprintingCharacter/Tab",             // 12 //not in Writer/Web
      94             :         "NonprintingCharacter/HiddenText",      // 13
      95             :         "NonprintingCharacter/HiddenParagraph", // 14
      96             :         "NonprintingCharacter/HiddenCharacter",      // 15
      97             :         "Update/Link",                          // 16
      98             :         "Update/Field",                         // 17
      99             :         "Update/Chart"                          // 18
     100             : 
     101             : 
     102             :     };
     103         102 :     const int nCount = bWeb ? 12 : 19;
     104         102 :     Sequence<OUString> aNames(nCount);
     105         102 :     OUString* pNames = aNames.getArray();
     106        2019 :     for(int i = 0; i < nCount; i++)
     107             :     {
     108        1917 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     109             :     }
     110         102 :     return aNames;
     111             : }
     112             : 
     113          34 : SwContentViewConfig::SwContentViewConfig(sal_Bool bIsWeb, SwMasterUsrPref& rPar) :
     114             :     ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Content") :  OUString("Office.Writer/Content")),
     115             :     rParent(rPar),
     116          34 :     bWeb(bIsWeb)
     117             : {
     118          34 :     Load();
     119          34 :     EnableNotification( GetPropertyNames() );
     120          34 : }
     121             : 
     122          21 : SwContentViewConfig::~SwContentViewConfig()
     123             : {
     124          21 : }
     125             : 
     126           0 : void SwContentViewConfig::Notify( const Sequence< OUString > & /*rPropertyNames*/ )
     127             : {
     128           0 :     Load();
     129           0 : }
     130             : 
     131           0 : void SwContentViewConfig::Commit()
     132             : {
     133           0 :     Sequence<OUString> aNames = GetPropertyNames();
     134             : 
     135           0 :     Sequence<Any> aValues(aNames.getLength());
     136           0 :     Any* pValues = aValues.getArray();
     137             : 
     138           0 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     139             :     {
     140           0 :         sal_Bool bVal = sal_False;
     141           0 :         switch(nProp)
     142             :         {
     143           0 :             case  0: bVal = rParent.IsGraphic();    break;// "Display/GraphicObject",
     144           0 :             case  1: bVal = rParent.IsTable();  break;// "Display/Table",
     145           0 :             case  2: bVal = rParent.IsDraw();       break;// "Display/DrawingControl",
     146           0 :             case  3: bVal = rParent.IsFldName();    break;// "Display/FieldCode",
     147           0 :             case  4: bVal = rParent.IsPostIts();    break;// "Display/Note",
     148           0 :             case  5: bVal = rParent.IsShowContentTips(); break; // "Display/ShowContentTips"
     149           0 :             case  6: bVal = rParent.IsViewMetaChars(); break; //"NonprintingCharacter/MetaCharacters"
     150           0 :             case  7: bVal = rParent.IsParagraph(sal_True); break;// "NonprintingCharacter/ParagraphEnd",
     151           0 :             case  8: bVal = rParent.IsSoftHyph(); break;// "NonprintingCharacter/OptionalHyphen",
     152           0 :             case  9: bVal = rParent.IsBlank(sal_True);  break;// "NonprintingCharacter/Space",
     153           0 :             case 10: bVal = rParent.IsLineBreak(sal_True);break;// "NonprintingCharacter/Break",
     154           0 :             case 11: bVal = rParent.IsHardBlank(); break;// "NonprintingCharacter/ProtectedSpace",
     155           0 :             case 12: bVal = rParent.IsTab(sal_True);        break;// "NonprintingCharacter/Tab",
     156           0 :             case 13: bVal = rParent.IsShowHiddenField(); break;// "NonprintingCharacter/Fields: HiddenText",
     157           0 :             case 14: bVal = rParent.IsShowHiddenPara(); break;// "NonprintingCharacter/Fields: HiddenParagraph",
     158           0 :             case 15: bVal = rParent.IsShowHiddenChar(sal_True);    break;// "NonprintingCharacter/HiddenCharacter",
     159           0 :             case 16: pValues[nProp] <<= rParent.GetUpdateLinkMode();    break;// "Update/Link",
     160           0 :             case 17: bVal = rParent.IsUpdateFields(); break;// "Update/Field",
     161           0 :             case 18: bVal = rParent.IsUpdateCharts(); break;// "Update/Chart"
     162             :         }
     163           0 :         if(nProp != 16)
     164           0 :             pValues[nProp].setValue(&bVal, ::getBooleanCppuType());
     165             :     }
     166           0 :     PutProperties(aNames, aValues);
     167           0 : }
     168             : 
     169          68 : void SwContentViewConfig::Load()
     170             : {
     171          68 :     Sequence<OUString> aNames = GetPropertyNames();
     172         136 :     Sequence<Any> aValues = GetProperties(aNames);
     173          68 :     const Any* pValues = aValues.getConstArray();
     174             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     175          68 :     if(aValues.getLength() == aNames.getLength())
     176             :     {
     177        1346 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     178             :         {
     179        1278 :             if(pValues[nProp].hasValue())
     180             :             {
     181        1276 :                 sal_Bool bSet = nProp != 16 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False;
     182        1276 :                 switch(nProp)
     183             :                 {
     184          68 :                     case  0: rParent.SetGraphic(bSet);  break;// "Display/GraphicObject",
     185          68 :                     case  1: rParent.SetTable(bSet);    break;// "Display/Table",
     186          68 :                     case  2: rParent.SetDraw(bSet);     break;// "Display/DrawingControl",
     187          68 :                     case  3: rParent.SetFldName(bSet);  break;// "Display/FieldCode",
     188          68 :                     case  4: rParent.SetPostIts(bSet);  break;// "Display/Note",
     189          66 :                     case  5: rParent.SetShowContentTips(bSet);  break;// "Display/ShowContentTips",
     190          68 :                     case  6: rParent.SetViewMetaChars(bSet); break; //"NonprintingCharacter/MetaCharacters"
     191          68 :                     case  7: rParent.SetParagraph(bSet); break;// "NonprintingCharacter/ParagraphEnd",
     192          68 :                     case  8: rParent.SetSoftHyph(bSet); break;// "NonprintingCharacter/OptionalHyphen",
     193          68 :                     case  9: rParent.SetBlank(bSet);    break;// "NonprintingCharacter/Space",
     194          68 :                     case 10: rParent.SetLineBreak(bSet);break;// "NonprintingCharacter/Break",
     195          68 :                     case 11: rParent.SetHardBlank(bSet); break;// "NonprintingCharacter/ProtectedSpace",
     196          66 :                     case 12: rParent.SetTab(bSet);      break;// "NonprintingCharacter/Tab",
     197          66 :                     case 13: rParent.SetShowHiddenField(bSet);   break;// "NonprintingCharacter/Fields: HiddenText",
     198          66 :                     case 14: rParent.SetShowHiddenPara(bSet); break;// "NonprintingCharacter/Fields: HiddenParagraph",
     199          66 :                     case 15: rParent.SetShowHiddenChar(bSet); break;// "NonprintingCharacter/HiddenCharacter",
     200             :                     case 16:
     201             :                     {
     202          66 :                         sal_Int32 nSet = 0;
     203          66 :                         pValues[nProp] >>= nSet;
     204          66 :                         rParent.SetUpdateLinkMode(nSet, sal_True);
     205             :                     }
     206          66 :                     break;// "Update/Link",
     207          66 :                     case 17: rParent.SetUpdateFields(bSet, sal_True); break;// "Update/Field",
     208          66 :                     case 18: rParent.SetUpdateCharts(bSet, sal_True); break;// "Update/Chart"
     209             :                 }
     210             :             }
     211             :         }
     212          68 :     }
     213          68 : }
     214             : 
     215          55 : Sequence<OUString> SwLayoutViewConfig::GetPropertyNames()
     216             : {
     217             :     static const char* aPropNames[] =
     218             :     {
     219             :         "Line/Guide",                           // 0
     220             :         "Window/HorizontalScroll",              // 1
     221             :         "Window/VerticalScroll",                // 2
     222             :         "Window/ShowRulers",                    // 3
     223             :         "Window/HorizontalRuler",               // 4
     224             :         "Window/VerticalRuler",                 // 5
     225             :         "Window/HorizontalRulerUnit",           // 6
     226             :         "Window/VerticalRulerUnit",             // 7
     227             :         "Window/SmoothScroll",                  // 8
     228             :         "Zoom/Value",                           // 9
     229             :         "Zoom/Type",                            //10
     230             :         "Other/IsAlignMathObjectsToBaseline",   //11
     231             :         "Other/MeasureUnit",                    //12
     232             :         // below properties are not available in WriterWeb
     233             :         "Other/TabStop",                        //13
     234             :         "Window/IsVerticalRulerRight",          //14
     235             :         "ViewLayout/Columns",                   //15
     236             :         "ViewLayout/BookMode",                  //16
     237             :         "Other/IsSquaredPageMode",              //17
     238             :         "Other/ApplyCharUnit",                  //18
     239             :         "Window/ShowScrollBarTips"              //19
     240             :     };
     241          55 :     const int nCount = bWeb ? 13 : 20;
     242          55 :     Sequence<OUString> aNames(nCount);
     243          55 :     OUString* pNames = aNames.getArray();
     244        1141 :     for(int i = 0; i < nCount; i++)
     245             :     {
     246        1086 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     247             :     }
     248          55 :     return aNames;
     249             : }
     250             : 
     251          34 : SwLayoutViewConfig::SwLayoutViewConfig(sal_Bool bIsWeb, SwMasterUsrPref& rPar) :
     252             :     ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Layout") :  OUString("Office.Writer/Layout"),
     253             :         CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
     254             :     rParent(rPar),
     255          34 :     bWeb(bIsWeb)
     256             : {
     257          34 : }
     258             : 
     259          21 : SwLayoutViewConfig::~SwLayoutViewConfig()
     260             : {
     261          21 : }
     262             : 
     263          21 : void SwLayoutViewConfig::Commit()
     264             : {
     265          21 :     Sequence<OUString> aNames = GetPropertyNames();
     266             : 
     267          42 :     Sequence<Any> aValues(aNames.getLength());
     268          21 :     Any* pValues = aValues.getArray();
     269             : 
     270         434 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     271             :     {
     272         413 :         Any &rVal = pValues[nProp];
     273         413 :         switch(nProp)
     274             :         {
     275          21 :             case  0: rVal <<= (sal_Bool) rParent.IsCrossHair(); break;              // "Line/Guide",
     276          21 :             case  1: rVal <<= (sal_Bool) rParent.IsViewHScrollBar(); break;         // "Window/HorizontalScroll",
     277          21 :             case  2: rVal <<= (sal_Bool) rParent.IsViewVScrollBar(); break;         // "Window/VerticalScroll",
     278          21 :             case  3: rVal <<= (sal_Bool) rParent.IsViewAnyRuler(); break;           // "Window/ShowRulers"
     279             :             // #i14593# use IsView*Ruler(sal_True) instead of IsView*Ruler()
     280             :             // this preserves the single ruler states even if "Window/ShowRulers" is off
     281          21 :             case  4: rVal <<= (sal_Bool) rParent.IsViewHRuler(sal_True); break;         // "Window/HorizontalRuler",
     282          21 :             case  5: rVal <<= (sal_Bool) rParent.IsViewVRuler(sal_True); break;         // "Window/VerticalRuler",
     283             :             case  6:
     284          21 :                 if(rParent.bIsHScrollMetricSet)
     285           0 :                     rVal <<= (sal_Int32)rParent.eHScrollMetric;                     // "Window/HorizontalRulerUnit"
     286          21 :             break;
     287             :             case  7:
     288          21 :                 if(rParent.bIsVScrollMetricSet)
     289           0 :                     rVal <<= (sal_Int32)rParent.eVScrollMetric;                     // "Window/VerticalRulerUnit"
     290          21 :             break;
     291          21 :             case  8: rVal <<= (sal_Bool) rParent.IsSmoothScroll(); break;           // "Window/SmoothScroll",
     292          21 :             case  9: rVal <<= (sal_Int32)rParent.GetZoom(); break;                  // "Zoom/Value",
     293          21 :             case 10: rVal <<= (sal_Int32)rParent.GetZoomType(); break;              // "Zoom/Type",
     294          21 :             case 11: rVal <<= (sal_Bool) rParent.IsAlignMathObjectsToBaseline(); break;      // "Other/IsAlignMathObjectsToBaseline"
     295          21 :             case 12: rVal <<= (sal_Int32)rParent.GetMetric(); break;                // "Other/MeasureUnit",
     296          20 :             case 13: rVal <<= static_cast<sal_Int32>(TWIP_TO_MM100(rParent.GetDefTab())); break;// "Other/TabStop",
     297          20 :             case 14: rVal <<= (sal_Bool) rParent.IsVRulerRight(); break;            // "Window/IsVerticalRulerRight",
     298          20 :             case 15: rVal <<= (sal_Int32)rParent.GetViewLayoutColumns(); break;     // "ViewLayout/Columns",
     299          20 :             case 16: rVal <<= (sal_Bool) rParent.IsViewLayoutBookMode(); break;     // "ViewLayout/BookMode",
     300          20 :             case 17: rVal <<= (sal_Bool) rParent.IsSquaredPageMode(); break;        // "Other/IsSquaredPageMode",
     301          20 :             case 18: rVal <<= (sal_Bool) rParent.IsApplyCharUnit(); break;        // "Other/ApplyCharUnit",
     302          20 :             case 19: rVal <<= (sal_Bool) rParent.IsShowScrollBarTips(); break;      // "Window/ShowScrollBarTips",
     303             :         }
     304             :     }
     305          42 :     PutProperties(aNames, aValues);
     306          21 : }
     307             : 
     308          34 : void SwLayoutViewConfig::Load()
     309             : {
     310          34 :     Sequence<OUString> aNames = GetPropertyNames();
     311          68 :     Sequence<Any> aValues = GetProperties(aNames);
     312          34 :     const Any* pValues = aValues.getConstArray();
     313             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     314          34 :     if(aValues.getLength() == aNames.getLength())
     315             :     {
     316         707 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     317             :         {
     318         673 :             if(pValues[nProp].hasValue())
     319             :             {
     320         582 :                 sal_Int32   nInt32Val   = 0;
     321         582 :                 sal_Bool    bSet        = sal_False;
     322         582 :                 pValues[nProp] >>= nInt32Val;
     323         582 :                 pValues[nProp] >>= bSet;
     324             : 
     325         582 :                 switch(nProp)
     326             :                 {
     327          34 :                     case  0: rParent.SetCrossHair(bSet); break;// "Line/Guide",
     328          34 :                     case  1: rParent.SetViewHScrollBar(bSet); break;// "Window/HorizontalScroll",
     329          34 :                     case  2: rParent.SetViewVScrollBar(bSet); break;// "Window/VerticalScroll",
     330          34 :                     case  3: rParent.SetViewAnyRuler(bSet);break; // "Window/ShowRulers"
     331          34 :                     case  4: rParent.SetViewHRuler(bSet); break;// "Window/HorizontalRuler",
     332          34 :                     case  5: rParent.SetViewVRuler(bSet); break;// "Window/VerticalRuler",
     333             :                     case  6:
     334             :                     {
     335           0 :                         rParent.bIsHScrollMetricSet = sal_True;
     336           0 :                         rParent.eHScrollMetric = ((FieldUnit)nInt32Val);  // "Window/HorizontalRulerUnit"
     337             :                     }
     338           0 :                     break;
     339             :                     case  7:
     340             :                     {
     341           0 :                         rParent.bIsVScrollMetricSet = sal_True;
     342           0 :                         rParent.eVScrollMetric = ((FieldUnit)nInt32Val); // "Window/VerticalRulerUnit"
     343             :                     }
     344           0 :                     break;
     345          34 :                     case  8: rParent.SetSmoothScroll(bSet); break;// "Window/SmoothScroll",
     346          34 :                     case  9: rParent.SetZoom( static_cast< sal_uInt16 >(nInt32Val) ); break;// "Zoom/Value",
     347          34 :                     case 10: rParent.SetZoomType( static_cast< SvxZoomType >(nInt32Val) ); break;// "Zoom/Type",
     348          34 :                     case 11: rParent.SetAlignMathObjectsToBaseline(bSet); break;// "Other/IsAlignMathObjectsToBaseline"
     349          11 :                     case 12: rParent.SetMetric((FieldUnit)nInt32Val, sal_True); break;// "Other/MeasureUnit",
     350          33 :                     case 13: rParent.SetDefTab(MM100_TO_TWIP(nInt32Val), sal_True); break;// "Other/TabStop",
     351          33 :                     case 14: rParent.SetVRulerRight(bSet); break;// "Window/IsVerticalRulerRight",
     352          33 :                     case 15: rParent.SetViewLayoutColumns( static_cast<sal_uInt16>(nInt32Val) ); break;// "ViewLayout/Columns",
     353          33 :                     case 16: rParent.SetViewLayoutBookMode(bSet); break;// "ViewLayout/BookMode",
     354          33 :                     case 17: rParent.SetDefaultPageMode(bSet,sal_True); break;// "Other/IsSquaredPageMode",
     355          33 :                     case 18: rParent.SetApplyCharUnit(bSet); break;// "Other/ApplyUserChar"
     356          33 :                     case 19: rParent.SetShowScrollBarTips(bSet); break;// "Window/ShowScrollBarTips",
     357             :                 }
     358             :             }
     359             :         }
     360          34 :     }
     361          34 : }
     362             : 
     363           0 : void SwLayoutViewConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
     364             : 
     365          34 : Sequence<OUString> SwGridConfig::GetPropertyNames()
     366             : {
     367             :     static const char* aPropNames[] =
     368             :     {
     369             :         "Option/SnapToGrid",            // 0
     370             :         "Option/VisibleGrid",           // 1
     371             :         "Option/Synchronize",           // 2
     372             :         "Resolution/XAxis",             // 3
     373             :         "Resolution/YAxis",             // 4
     374             :         "Subdivision/XAxis",            // 5
     375             :         "Subdivision/YAxis"             // 6
     376             :     };
     377          34 :     const int nCount = 7;
     378          34 :     Sequence<OUString> aNames(nCount);
     379          34 :     OUString* pNames = aNames.getArray();
     380         272 :     for(int i = 0; i < nCount; i++)
     381             :     {
     382         238 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     383             :     }
     384          34 :     return aNames;
     385             : }
     386             : 
     387          34 : SwGridConfig::SwGridConfig(sal_Bool bIsWeb, SwMasterUsrPref& rPar) :
     388             :     ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Grid") :  OUString("Office.Writer/Grid"),
     389             :         CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
     390          34 :     rParent(rPar)
     391             : {
     392          34 : }
     393             : 
     394          21 : SwGridConfig::~SwGridConfig()
     395             : {
     396          21 : }
     397             : 
     398           0 : void SwGridConfig::Commit()
     399             : {
     400           0 :     Sequence<OUString> aNames = GetPropertyNames();
     401             : 
     402           0 :     Sequence<Any> aValues(aNames.getLength());
     403           0 :     Any* pValues = aValues.getArray();
     404             : 
     405           0 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     406             :     {
     407             :         sal_Bool bSet;
     408           0 :         switch(nProp)
     409             :         {
     410           0 :             case  0: bSet = rParent.IsSnap(); break;//      "Option/SnapToGrid",
     411           0 :             case  1: bSet = rParent.IsGridVisible(); break;//"Option/VisibleGrid",
     412           0 :             case  2: bSet = rParent.IsSynchronize(); break;//  "Option/Synchronize",
     413           0 :             case  3: pValues[nProp] <<= (sal_Int32)TWIP_TO_MM100(rParent.GetSnapSize().Width()); break;//      "Resolution/XAxis",
     414           0 :             case  4: pValues[nProp] <<= (sal_Int32)TWIP_TO_MM100(rParent.GetSnapSize().Height()); break;//      "Resolution/YAxis",
     415           0 :             case  5: pValues[nProp] <<= (sal_Int16)rParent.GetDivisionX(); break;//   "Subdivision/XAxis",
     416           0 :             case  6: pValues[nProp] <<= (sal_Int16)rParent.GetDivisionY(); break;//   "Subdivision/YAxis"
     417             :         }
     418           0 :         if(nProp < 3)
     419           0 :               pValues[nProp].setValue(&bSet, ::getBooleanCppuType());
     420             :     }
     421           0 :     PutProperties(aNames, aValues);
     422           0 : }
     423             : 
     424          34 : void SwGridConfig::Load()
     425             : {
     426          34 :     Sequence<OUString> aNames = GetPropertyNames();
     427          68 :     Sequence<Any> aValues = GetProperties(aNames);
     428          34 :     const Any* pValues = aValues.getConstArray();
     429             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     430          34 :     if(aValues.getLength() == aNames.getLength())
     431             :     {
     432          34 :         Size aSnap(rParent.GetSnapSize());
     433         272 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     434             :         {
     435         238 :             if(pValues[nProp].hasValue())
     436             :             {
     437         238 :                 sal_Bool bSet = nProp < 3 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False;
     438         238 :                 sal_Int32 nSet = 0;
     439         238 :                 if(nProp >= 3)
     440         136 :                     pValues[nProp] >>= nSet;
     441         238 :                 switch(nProp)
     442             :                 {
     443          34 :                     case  0: rParent.SetSnap(bSet); break;//        "Option/SnapToGrid",
     444          34 :                     case  1: rParent.SetGridVisible(bSet); break;//"Option/VisibleGrid",
     445          34 :                     case  2: rParent.SetSynchronize(bSet); break;//  "Option/Synchronize",
     446          34 :                     case  3: aSnap.Width() = MM100_TO_TWIP(nSet); break;//      "Resolution/XAxis",
     447          34 :                     case  4: aSnap.Height() = MM100_TO_TWIP(nSet); break;//      "Resolution/YAxis",
     448          34 :                     case  5: rParent.SetDivisionX((short)nSet); break;//   "Subdivision/XAxis",
     449          34 :                     case  6: rParent.SetDivisionY((short)nSet); break;//   "Subdivision/YAxis"
     450             :                 }
     451             :             }
     452             :         }
     453          34 :         rParent.SetSnapSize(aSnap);
     454          34 :     }
     455          34 : }
     456             : 
     457           0 : void SwGridConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
     458             : 
     459          34 : Sequence<OUString> SwCursorConfig::GetPropertyNames()
     460             : {
     461             :     static const char* aPropNames[] =
     462             :     {
     463             :         "DirectCursor/UseDirectCursor", // 0
     464             :         "DirectCursor/Insert",          // 1
     465             :         "Option/ProtectedArea"          // 2
     466             :     };
     467          34 :     const int nCount = 3;
     468          34 :     Sequence<OUString> aNames(nCount);
     469          34 :     OUString* pNames = aNames.getArray();
     470         136 :     for(int i = 0; i < nCount; i++)
     471         102 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     472          34 :     return aNames;
     473             : }
     474             : 
     475          34 : SwCursorConfig::SwCursorConfig(SwMasterUsrPref& rPar) :
     476             :     ConfigItem("Office.Writer/Cursor",
     477             :         CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
     478          34 :     rParent(rPar)
     479             : {
     480          34 : }
     481             : 
     482          21 : SwCursorConfig::~SwCursorConfig()
     483             : {
     484          21 : }
     485             : 
     486           0 : void SwCursorConfig::Commit()
     487             : {
     488           0 :     Sequence<OUString> aNames = GetPropertyNames();
     489             : 
     490           0 :     Sequence<Any> aValues(aNames.getLength());
     491           0 :     Any* pValues = aValues.getArray();
     492             : 
     493           0 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     494             :     {
     495             :         sal_Bool bSet;
     496           0 :         switch(nProp)
     497             :         {
     498           0 :             case  0: bSet = rParent.IsShadowCursor();       break;//  "DirectCursor/UseDirectCursor",
     499           0 :             case  1: pValues[nProp] <<= (sal_Int32)rParent.GetShdwCrsrFillMode();   break;//  "DirectCursor/Insert",
     500           0 :             case  2: bSet = rParent.IsCursorInProtectedArea(); break;// "Option/ProtectedArea"
     501             :         }
     502           0 :         if(nProp != 1 )
     503           0 :               pValues[nProp].setValue(&bSet, ::getBooleanCppuType());
     504             :     }
     505           0 :     PutProperties(aNames, aValues);
     506           0 : }
     507             : 
     508          34 : void SwCursorConfig::Load()
     509             : {
     510          34 :     Sequence<OUString> aNames = GetPropertyNames();
     511          68 :     Sequence<Any> aValues = GetProperties(aNames);
     512          34 :     const Any* pValues = aValues.getConstArray();
     513             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     514          34 :     if(aValues.getLength() == aNames.getLength())
     515             :     {
     516             : 
     517         136 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     518             :         {
     519         102 :             if(pValues[nProp].hasValue())
     520             :             {
     521         102 :                 sal_Bool bSet = sal_False;
     522         102 :                 sal_Int32 nSet = 0;
     523         102 :                 if(nProp != 1 )
     524          68 :                     bSet = *(sal_Bool*)pValues[nProp].getValue();
     525             :                 else
     526          34 :                     pValues[nProp] >>= nSet;
     527         102 :                 switch(nProp)
     528             :                 {
     529          34 :                     case  0: rParent.SetShadowCursor(bSet);         break;//  "DirectCursor/UseDirectCursor",
     530          34 :                     case  1: rParent.SetShdwCrsrFillMode((sal_uInt8)nSet); break;//  "DirectCursor/Insert",
     531          34 :                     case  2: rParent.SetCursorInProtectedArea(bSet); break;// "Option/ProtectedArea"
     532             :                 }
     533             :             }
     534             :         }
     535             : 
     536          34 :     }
     537          34 : }
     538             : 
     539           0 : void SwCursorConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
     540             : 
     541           1 : SwWebColorConfig::SwWebColorConfig(SwMasterUsrPref& rPar) :
     542             :     ConfigItem("Office.WriterWeb/Background",
     543             :         CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
     544             :     rParent(rPar),
     545           1 :     aPropNames(1)
     546             : {
     547           1 :     aPropNames.getArray()[0] = "Color";
     548           1 : }
     549             : 
     550           2 : SwWebColorConfig::~SwWebColorConfig()
     551             : {
     552           2 : }
     553             : 
     554           0 : void SwWebColorConfig::Commit()
     555             : {
     556           0 :     Sequence<Any> aValues(aPropNames.getLength());
     557           0 :     Any* pValues = aValues.getArray();
     558           0 :     for(int nProp = 0; nProp < aPropNames.getLength(); nProp++)
     559             :     {
     560           0 :         switch(nProp)
     561             :         {
     562           0 :             case  0: pValues[nProp] <<= (sal_Int32)rParent.GetRetoucheColor().GetColor();   break;// "Color",
     563             :         }
     564             :     }
     565           0 :     PutProperties(aPropNames, aValues);
     566           0 : }
     567             : 
     568           0 : void SwWebColorConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
     569             : 
     570           1 : void SwWebColorConfig::Load()
     571             : {
     572           1 :     Sequence<Any> aValues = GetProperties(aPropNames);
     573           1 :     const Any* pValues = aValues.getConstArray();
     574             :     OSL_ENSURE(aValues.getLength() == aPropNames.getLength(), "GetProperties failed");
     575           1 :     if(aValues.getLength() == aPropNames.getLength())
     576             :     {
     577           2 :         for(int nProp = 0; nProp < aPropNames.getLength(); nProp++)
     578             :         {
     579           1 :             if(pValues[nProp].hasValue())
     580             :             {
     581           0 :                 switch(nProp)
     582             :                 {
     583             :                     case  0:
     584           0 :                         sal_Int32 nSet = 0;
     585           0 :                         pValues[nProp] >>= nSet; rParent.SetRetoucheColor(nSet);
     586           0 :                     break;// "Color",
     587             :                 }
     588             :             }
     589             :         }
     590           1 :     }
     591         100 : }
     592             : 
     593             : 
     594             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10