LCOV - code coverage report
Current view: top level - sw/source/uibase/config - usrpref.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 217 307 70.7 %
Date: 2014-11-03 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           0 : void SwMasterUsrPref::SetUsrPref(const SwViewOption &rCopy)
      41             : {
      42           0 :     *((SwViewOption*)this) = rCopy;
      43           0 : }
      44             : 
      45          88 : SwMasterUsrPref::SwMasterUsrPref(bool bWeb) :
      46             :     eFldUpdateFlags(AUTOUPD_OFF),
      47             :     nLinkUpdateMode(0),
      48             :     bIsHScrollMetricSet(false),
      49             :     bIsVScrollMetricSet(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           2 :     pWebColorConfig(bWeb ? new SwWebColorConfig(*this) : 0),
      58          90 :     bApplyCharUnit(false)
      59             : {
      60          88 :     MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
      61          88 :     eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH;
      62          88 :     eHScrollMetric = eVScrollMetric = eUserMetric;
      63             : 
      64          88 :     aContentConfig.Load();
      65          88 :     aLayoutConfig.Load();
      66          88 :     aGridConfig.Load();
      67          88 :     aCursorConfig.Load();
      68          88 :     if(pWebColorConfig)
      69           2 :         pWebColorConfig->Load();
      70          88 : }
      71             : 
      72          76 : SwMasterUsrPref::~SwMasterUsrPref()
      73             : {
      74          38 :     delete pWebColorConfig;
      75          38 : }
      76             : 
      77         264 : 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         264 :     const int nCount = bWeb ? 12 : 19;
     103         264 :     Sequence<OUString> aNames(nCount);
     104         264 :     OUString* pNames = aNames.getArray();
     105        5238 :     for(int i = 0; i < nCount; i++)
     106             :     {
     107        4974 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     108             :     }
     109         264 :     return aNames;
     110             : }
     111             : 
     112          88 : SwContentViewConfig::SwContentViewConfig(bool bIsWeb, SwMasterUsrPref& rPar) :
     113             :     ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Content") :  OUString("Office.Writer/Content")),
     114             :     rParent(rPar),
     115          88 :     bWeb(bIsWeb)
     116             : {
     117          88 :     Load();
     118          88 :     EnableNotification( GetPropertyNames() );
     119          88 : }
     120             : 
     121          38 : SwContentViewConfig::~SwContentViewConfig()
     122             : {
     123          38 : }
     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(true); break;// "NonprintingCharacter/ParagraphEnd",
     150           0 :             case  8: bVal = rParent.IsSoftHyph(); break;// "NonprintingCharacter/OptionalHyphen",
     151           0 :             case  9: bVal = rParent.IsBlank(true);  break;// "NonprintingCharacter/Space",
     152           0 :             case 10: bVal = rParent.IsLineBreak(true);break;// "NonprintingCharacter/Break",
     153           0 :             case 11: bVal = rParent.IsHardBlank(); break;// "NonprintingCharacter/ProtectedSpace",
     154           0 :             case 12: bVal = rParent.IsTab(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(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         176 : void SwContentViewConfig::Load()
     169             : {
     170         176 :     Sequence<OUString> aNames = GetPropertyNames();
     171         352 :     Sequence<Any> aValues = GetProperties(aNames);
     172         176 :     const Any* pValues = aValues.getConstArray();
     173             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     174         176 :     if(aValues.getLength() == aNames.getLength())
     175             :     {
     176        3492 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     177             :         {
     178        3316 :             if(pValues[nProp].hasValue())
     179             :             {
     180        3312 :                 bool bSet = nProp != 16 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False;
     181        3312 :                 switch(nProp)
     182             :                 {
     183         176 :                     case  0: rParent.SetGraphic(bSet);  break;// "Display/GraphicObject",
     184         176 :                     case  1: rParent.SetTable(bSet);    break;// "Display/Table",
     185         176 :                     case  2: rParent.SetDraw(bSet);     break;// "Display/DrawingControl",
     186         176 :                     case  3: rParent.SetFldName(bSet);  break;// "Display/FieldCode",
     187         176 :                     case  4: rParent.SetPostIts(bSet);  break;// "Display/Note",
     188         172 :                     case  5: rParent.SetShowContentTips(bSet);  break;// "Display/ShowContentTips",
     189         176 :                     case  6: rParent.SetViewMetaChars(bSet); break; //"NonprintingCharacter/MetaCharacters"
     190         176 :                     case  7: rParent.SetParagraph(bSet); break;// "NonprintingCharacter/ParagraphEnd",
     191         176 :                     case  8: rParent.SetSoftHyph(bSet); break;// "NonprintingCharacter/OptionalHyphen",
     192         176 :                     case  9: rParent.SetBlank(bSet);    break;// "NonprintingCharacter/Space",
     193         176 :                     case 10: rParent.SetLineBreak(bSet);break;// "NonprintingCharacter/Break",
     194         176 :                     case 11: rParent.SetHardBlank(bSet); break;// "NonprintingCharacter/ProtectedSpace",
     195         172 :                     case 12: rParent.SetTab(bSet);      break;// "NonprintingCharacter/Tab",
     196         172 :                     case 13: rParent.SetShowHiddenField(bSet);   break;// "NonprintingCharacter/Fields: HiddenText",
     197         172 :                     case 14: rParent.SetShowHiddenPara(bSet); break;// "NonprintingCharacter/Fields: HiddenParagraph",
     198         172 :                     case 15: rParent.SetShowHiddenChar(bSet); break;// "NonprintingCharacter/HiddenCharacter",
     199             :                     case 16:
     200             :                     {
     201         172 :                         sal_Int32 nSet = 0;
     202         172 :                         pValues[nProp] >>= nSet;
     203         172 :                         rParent.SetUpdateLinkMode(nSet, true);
     204             :                     }
     205         172 :                     break;// "Update/Link",
     206         172 :                     case 17: rParent.SetUpdateFields(bSet, true); break;// "Update/Field",
     207         172 :                     case 18: rParent.SetUpdateCharts(bSet, true); break;// "Update/Chart"
     208             :                 }
     209             :             }
     210             :         }
     211         176 :     }
     212         176 : }
     213             : 
     214         174 : 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         174 :     const int nCount = bWeb ? 13 : 20;
     241         174 :     Sequence<OUString> aNames(nCount);
     242         174 :     OUString* pNames = aNames.getArray();
     243        3626 :     for(int i = 0; i < nCount; i++)
     244             :     {
     245        3452 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     246             :     }
     247         174 :     return aNames;
     248             : }
     249             : 
     250          88 : SwLayoutViewConfig::SwLayoutViewConfig(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          88 :     bWeb(bIsWeb)
     255             : {
     256          88 : }
     257             : 
     258          38 : SwLayoutViewConfig::~SwLayoutViewConfig()
     259             : {
     260          38 : }
     261             : 
     262          86 : void SwLayoutViewConfig::Commit()
     263             : {
     264          86 :     Sequence<OUString> aNames = GetPropertyNames();
     265             : 
     266         172 :     Sequence<Any> aValues(aNames.getLength());
     267          86 :     Any* pValues = aValues.getArray();
     268             : 
     269        1792 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     270             :     {
     271        1706 :         Any &rVal = pValues[nProp];
     272        1706 :         switch(nProp)
     273             :         {
     274          86 :             case  0: rVal <<= rParent.IsCrossHair(); break;              // "Line/Guide",
     275          86 :             case  1: rVal <<= rParent.IsViewHScrollBar(); break;         // "Window/HorizontalScroll",
     276          86 :             case  2: rVal <<= rParent.IsViewVScrollBar(); break;         // "Window/VerticalScroll",
     277          86 :             case  3: rVal <<= 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          86 :             case  4: rVal <<= rParent.IsViewHRuler(true); break;         // "Window/HorizontalRuler",
     281          86 :             case  5: rVal <<= rParent.IsViewVRuler(true); break;         // "Window/VerticalRuler",
     282             :             case  6:
     283          86 :                 if(rParent.bIsHScrollMetricSet)
     284           0 :                     rVal <<= (sal_Int32)rParent.eHScrollMetric;                     // "Window/HorizontalRulerUnit"
     285          86 :             break;
     286             :             case  7:
     287          86 :                 if(rParent.bIsVScrollMetricSet)
     288           0 :                     rVal <<= (sal_Int32)rParent.eVScrollMetric;                     // "Window/VerticalRulerUnit"
     289          86 :             break;
     290          86 :             case  8: rVal <<= rParent.IsSmoothScroll(); break;                      // "Window/SmoothScroll",
     291          86 :             case  9: rVal <<= (sal_Int32)rParent.GetZoom(); break;                  // "Zoom/Value",
     292          86 :             case 10: rVal <<= (sal_Int32)rParent.GetZoomType(); break;              // "Zoom/Type",
     293          86 :             case 11: rVal <<= rParent.IsAlignMathObjectsToBaseline(); break;        // "Other/IsAlignMathObjectsToBaseline"
     294          86 :             case 12: rVal <<= (sal_Int32)rParent.GetMetric(); break;                // "Other/MeasureUnit",
     295          84 :             case 13: rVal <<= static_cast<sal_Int32>(convertTwipToMm100(rParent.GetDefTab())); break;// "Other/TabStop",
     296          84 :             case 14: rVal <<= rParent.IsVRulerRight(); break;                       // "Window/IsVerticalRulerRight",
     297          84 :             case 15: rVal <<= (sal_Int32)rParent.GetViewLayoutColumns(); break;     // "ViewLayout/Columns",
     298          84 :             case 16: rVal <<= rParent.IsViewLayoutBookMode(); break;                // "ViewLayout/BookMode",
     299          84 :             case 17: rVal <<= rParent.IsSquaredPageMode(); break;                   // "Other/IsSquaredPageMode",
     300          84 :             case 18: rVal <<= rParent.IsApplyCharUnit(); break;                     // "Other/ApplyCharUnit",
     301          84 :             case 19: rVal <<= rParent.IsShowScrollBarTips(); break;                 // "Window/ShowScrollBarTips",
     302             :         }
     303             :     }
     304         172 :     PutProperties(aNames, aValues);
     305          86 : }
     306             : 
     307          88 : void SwLayoutViewConfig::Load()
     308             : {
     309          88 :     Sequence<OUString> aNames = GetPropertyNames();
     310         176 :     Sequence<Any> aValues = GetProperties(aNames);
     311          88 :     const Any* pValues = aValues.getConstArray();
     312             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     313          88 :     if(aValues.getLength() == aNames.getLength())
     314             :     {
     315        1834 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     316             :         {
     317        1746 :             if(pValues[nProp].hasValue())
     318             :             {
     319        1498 :                 sal_Int32   nInt32Val   = 0;
     320        1498 :                 bool    bSet        = false;
     321        1498 :                 pValues[nProp] >>= nInt32Val;
     322        1498 :                 pValues[nProp] >>= bSet;
     323             : 
     324        1498 :                 switch(nProp)
     325             :                 {
     326          88 :                     case  0: rParent.SetCrossHair(bSet); break;// "Line/Guide",
     327          88 :                     case  1: rParent.SetViewHScrollBar(bSet); break;// "Window/HorizontalScroll",
     328          88 :                     case  2: rParent.SetViewVScrollBar(bSet); break;// "Window/VerticalScroll",
     329          88 :                     case  3: rParent.SetViewAnyRuler(bSet);break; // "Window/ShowRulers"
     330          88 :                     case  4: rParent.SetViewHRuler(bSet); break;// "Window/HorizontalRuler",
     331          88 :                     case  5: rParent.SetViewVRuler(bSet); break;// "Window/VerticalRuler",
     332             :                     case  6:
     333             :                     {
     334           0 :                         rParent.bIsHScrollMetricSet = true;
     335           0 :                         rParent.eHScrollMetric = ((FieldUnit)nInt32Val);  // "Window/HorizontalRulerUnit"
     336             :                     }
     337           0 :                     break;
     338             :                     case  7:
     339             :                     {
     340           0 :                         rParent.bIsVScrollMetricSet = true;
     341           0 :                         rParent.eVScrollMetric = ((FieldUnit)nInt32Val); // "Window/VerticalRulerUnit"
     342             :                     }
     343           0 :                     break;
     344          88 :                     case  8: rParent.SetSmoothScroll(bSet); break;// "Window/SmoothScroll",
     345          88 :                     case  9: rParent.SetZoom( static_cast< sal_uInt16 >(nInt32Val) ); break;// "Zoom/Value",
     346          88 :                     case 10: rParent.SetZoomType( static_cast< SvxZoomType >(nInt32Val) ); break;// "Zoom/Type",
     347          88 :                     case 11: rParent.SetAlignMathObjectsToBaseline(bSet); break;// "Other/IsAlignMathObjectsToBaseline"
     348          16 :                     case 12: rParent.SetMetric((FieldUnit)nInt32Val, true); break;// "Other/MeasureUnit",
     349          86 :                     case 13: rParent.SetDefTab(convertMm100ToTwip(nInt32Val), true); break;// "Other/TabStop",
     350          86 :                     case 14: rParent.SetVRulerRight(bSet); break;// "Window/IsVerticalRulerRight",
     351          86 :                     case 15: rParent.SetViewLayoutColumns( static_cast<sal_uInt16>(nInt32Val) ); break;// "ViewLayout/Columns",
     352          86 :                     case 16: rParent.SetViewLayoutBookMode(bSet); break;// "ViewLayout/BookMode",
     353          86 :                     case 17: rParent.SetDefaultPageMode(bSet,true); break;// "Other/IsSquaredPageMode",
     354          86 :                     case 18: rParent.SetApplyCharUnit(bSet); break;// "Other/ApplyUserChar"
     355          86 :                     case 19: rParent.SetShowScrollBarTips(bSet); break;// "Window/ShowScrollBarTips",
     356             :                 }
     357             :             }
     358             :         }
     359          88 :     }
     360          88 : }
     361             : 
     362           0 : void SwLayoutViewConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
     363             : 
     364          88 : 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          88 :     const int nCount = 7;
     377          88 :     Sequence<OUString> aNames(nCount);
     378          88 :     OUString* pNames = aNames.getArray();
     379         704 :     for(int i = 0; i < nCount; i++)
     380             :     {
     381         616 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     382             :     }
     383          88 :     return aNames;
     384             : }
     385             : 
     386          88 : SwGridConfig::SwGridConfig(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          88 :     rParent(rPar)
     390             : {
     391          88 : }
     392             : 
     393          38 : SwGridConfig::~SwGridConfig()
     394             : {
     395          38 : }
     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)convertTwipToMm100(rParent.GetSnapSize().Width()); break;//      "Resolution/XAxis",
     413           0 :             case  4: pValues[nProp] <<= (sal_Int32)convertTwipToMm100(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          88 : void SwGridConfig::Load()
     424             : {
     425          88 :     Sequence<OUString> aNames = GetPropertyNames();
     426         176 :     Sequence<Any> aValues = GetProperties(aNames);
     427          88 :     const Any* pValues = aValues.getConstArray();
     428             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     429          88 :     if(aValues.getLength() == aNames.getLength())
     430             :     {
     431          88 :         Size aSnap(rParent.GetSnapSize());
     432         704 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     433             :         {
     434         616 :             if(pValues[nProp].hasValue())
     435             :             {
     436         616 :                 bool bSet = nProp < 3 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False;
     437         616 :                 sal_Int32 nSet = 0;
     438         616 :                 if(nProp >= 3)
     439         352 :                     pValues[nProp] >>= nSet;
     440         616 :                 switch(nProp)
     441             :                 {
     442          88 :                     case  0: rParent.SetSnap(bSet); break;//        "Option/SnapToGrid",
     443          88 :                     case  1: rParent.SetGridVisible(bSet); break;//"Option/VisibleGrid",
     444          88 :                     case  2: rParent.SetSynchronize(bSet); break;//  "Option/Synchronize",
     445          88 :                     case  3: aSnap.Width() = convertMm100ToTwip(nSet); break;//      "Resolution/XAxis",
     446          88 :                     case  4: aSnap.Height() = convertMm100ToTwip(nSet); break;//      "Resolution/YAxis",
     447          88 :                     case  5: rParent.SetDivisionX((short)nSet); break;//   "Subdivision/XAxis",
     448          88 :                     case  6: rParent.SetDivisionY((short)nSet); break;//   "Subdivision/YAxis"
     449             :                 }
     450             :             }
     451             :         }
     452          88 :         rParent.SetSnapSize(aSnap);
     453          88 :     }
     454          88 : }
     455             : 
     456           0 : void SwGridConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
     457             : 
     458          88 : 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          88 :     const int nCount = 3;
     467          88 :     Sequence<OUString> aNames(nCount);
     468          88 :     OUString* pNames = aNames.getArray();
     469         352 :     for(int i = 0; i < nCount; i++)
     470         264 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     471          88 :     return aNames;
     472             : }
     473             : 
     474          88 : SwCursorConfig::SwCursorConfig(SwMasterUsrPref& rPar) :
     475             :     ConfigItem("Office.Writer/Cursor",
     476             :         CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
     477          88 :     rParent(rPar)
     478             : {
     479          88 : }
     480             : 
     481          38 : SwCursorConfig::~SwCursorConfig()
     482             : {
     483          38 : }
     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          88 : void SwCursorConfig::Load()
     508             : {
     509          88 :     Sequence<OUString> aNames = GetPropertyNames();
     510         176 :     Sequence<Any> aValues = GetProperties(aNames);
     511          88 :     const Any* pValues = aValues.getConstArray();
     512             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     513          88 :     if(aValues.getLength() == aNames.getLength())
     514             :     {
     515             : 
     516         352 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     517             :         {
     518         264 :             if(pValues[nProp].hasValue())
     519             :             {
     520         264 :                 bool bSet = false;
     521         264 :                 sal_Int32 nSet = 0;
     522         264 :                 if(nProp != 1 )
     523         176 :                     bSet = *(sal_Bool*)pValues[nProp].getValue();
     524             :                 else
     525          88 :                     pValues[nProp] >>= nSet;
     526         264 :                 switch(nProp)
     527             :                 {
     528          88 :                     case  0: rParent.SetShadowCursor(bSet);         break;//  "DirectCursor/UseDirectCursor",
     529          88 :                     case  1: rParent.SetShdwCrsrFillMode((sal_uInt8)nSet); break;//  "DirectCursor/Insert",
     530          88 :                     case  2: rParent.SetCursorInProtectedArea(bSet); break;// "Option/ProtectedArea"
     531             :                 }
     532             :             }
     533             :         }
     534             : 
     535          88 :     }
     536          88 : }
     537             : 
     538           0 : void SwCursorConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
     539             : 
     540           2 : SwWebColorConfig::SwWebColorConfig(SwMasterUsrPref& rPar) :
     541             :     ConfigItem("Office.WriterWeb/Background",
     542             :         CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
     543             :     rParent(rPar),
     544           2 :     aPropNames(1)
     545             : {
     546           2 :     aPropNames.getArray()[0] = "Color";
     547           2 : }
     548             : 
     549           4 : SwWebColorConfig::~SwWebColorConfig()
     550             : {
     551           4 : }
     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           2 : void SwWebColorConfig::Load()
     570             : {
     571           2 :     Sequence<Any> aValues = GetProperties(aPropNames);
     572           2 :     const Any* pValues = aValues.getConstArray();
     573             :     OSL_ENSURE(aValues.getLength() == aPropNames.getLength(), "GetProperties failed");
     574           2 :     if(aValues.getLength() == aPropNames.getLength())
     575             :     {
     576           4 :         for(int nProp = 0; nProp < aPropNames.getLength(); nProp++)
     577             :         {
     578           2 :             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           2 :     }
     590         272 : }
     591             : 
     592             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10