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

Generated by: LCOV version 1.10