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

Generated by: LCOV version 1.10