LCOV - code coverage report
Current view: top level - sc/source/core/tool - appoptio.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 361 370 97.6 %
Date: 2014-11-03 Functions: 36 36 100.0 %
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 <vcl/svapp.hxx>
      21             : 
      22             : #include <com/sun/star/uno/Any.hxx>
      23             : #include <com/sun/star/uno/Sequence.hxx>
      24             : #include "cfgids.hxx"
      25             : #include "appoptio.hxx"
      26             : #include "rechead.hxx"
      27             : #include "scresid.hxx"
      28             : #include "global.hxx"
      29             : #include "userlist.hxx"
      30             : #include "sc.hrc"
      31             : #include <formula/compiler.hrc>
      32             : #include "miscuno.hxx"
      33             : #include <boost/scoped_array.hpp>
      34             : 
      35             : using namespace utl;
      36             : using namespace com::sun::star::uno;
      37             : 
      38             : //      ScAppOptions - Applikations-Optionen
      39             : 
      40          76 : ScAppOptions::ScAppOptions() : pLRUList( NULL )
      41             : {
      42          76 :     SetDefaults();
      43          76 : }
      44             : 
      45         624 : ScAppOptions::ScAppOptions( const ScAppOptions& rCpy ) : pLRUList( NULL )
      46             : {
      47         624 :     *this = rCpy;
      48         624 : }
      49             : 
      50         644 : ScAppOptions::~ScAppOptions()
      51             : {
      52         644 :     delete [] pLRUList;
      53         644 : }
      54             : 
      55          76 : void ScAppOptions::SetDefaults()
      56             : {
      57          76 :     if ( ScOptionsUtil::IsMetricSystem() )
      58           0 :         eMetric     = FUNIT_CM;             // default for countries with metric system
      59             :     else
      60          76 :         eMetric     = FUNIT_INCH;           // default for others
      61             : 
      62          76 :     nZoom           = 100;
      63          76 :     eZoomType       = SVX_ZOOM_PERCENT;
      64          76 :     bSynchronizeZoom = true;
      65          76 :     nStatusFunc     = SUBTOTAL_FUNC_SUM;
      66          76 :     bAutoComplete   = true;
      67          76 :     bDetectiveAuto  = true;
      68             : 
      69          76 :     delete [] pLRUList;
      70          76 :     pLRUList = new sal_uInt16[5];               // sinnvoll vorbelegen
      71          76 :     pLRUList[0] = SC_OPCODE_SUM;
      72          76 :     pLRUList[1] = SC_OPCODE_AVERAGE;
      73          76 :     pLRUList[2] = SC_OPCODE_MIN;
      74          76 :     pLRUList[3] = SC_OPCODE_MAX;
      75          76 :     pLRUList[4] = SC_OPCODE_IF;
      76          76 :     nLRUFuncCount = 5;
      77             : 
      78          76 :     nTrackContentColor = COL_TRANSPARENT;
      79          76 :     nTrackInsertColor  = COL_TRANSPARENT;
      80          76 :     nTrackDeleteColor  = COL_TRANSPARENT;
      81          76 :     nTrackMoveColor    = COL_TRANSPARENT;
      82          76 :     eLinkMode          = LM_ON_DEMAND;
      83             : 
      84          76 :     nDefaultObjectSizeWidth = 8000;
      85          76 :     nDefaultObjectSizeHeight = 5000;
      86             : 
      87          76 :     mbShowSharedDocumentWarning = true;
      88             : 
      89          76 :     meKeyBindingType     = ScOptionsUtil::KEY_DEFAULT;
      90          76 : }
      91             : 
      92         664 : const ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
      93             : {
      94         664 :     eMetric         = rCpy.eMetric;
      95         664 :     eZoomType       = rCpy.eZoomType;
      96         664 :     bSynchronizeZoom = rCpy.bSynchronizeZoom;
      97         664 :     nZoom           = rCpy.nZoom;
      98         664 :     SetLRUFuncList( rCpy.pLRUList, rCpy.nLRUFuncCount );
      99         664 :     nStatusFunc     = rCpy.nStatusFunc;
     100         664 :     bAutoComplete   = rCpy.bAutoComplete;
     101         664 :     bDetectiveAuto  = rCpy.bDetectiveAuto;
     102         664 :     nTrackContentColor = rCpy.nTrackContentColor;
     103         664 :     nTrackInsertColor  = rCpy.nTrackInsertColor;
     104         664 :     nTrackDeleteColor  = rCpy.nTrackDeleteColor;
     105         664 :     nTrackMoveColor    = rCpy.nTrackMoveColor;
     106         664 :     eLinkMode       = rCpy.eLinkMode;
     107         664 :     nDefaultObjectSizeWidth = rCpy.nDefaultObjectSizeWidth;
     108         664 :     nDefaultObjectSizeHeight = rCpy.nDefaultObjectSizeHeight;
     109         664 :     mbShowSharedDocumentWarning = rCpy.mbShowSharedDocumentWarning;
     110         664 :     meKeyBindingType  = rCpy.meKeyBindingType;
     111         664 :      return *this;
     112             : }
     113             : 
     114         740 : void ScAppOptions::SetLRUFuncList( const sal_uInt16* pList, const sal_uInt16 nCount )
     115             : {
     116         740 :     delete [] pLRUList;
     117             : 
     118         740 :     nLRUFuncCount = nCount;
     119             : 
     120         740 :     if ( nLRUFuncCount > 0 )
     121             :     {
     122         740 :         pLRUList = new sal_uInt16[nLRUFuncCount];
     123             : 
     124        4440 :         for ( sal_uInt16 i=0; i<nLRUFuncCount; i++ )
     125        3700 :             pLRUList[i] = pList[i];
     126             :     }
     127             :     else
     128           0 :         pLRUList = NULL;
     129         740 : }
     130             : 
     131             : //  Config Item containing app options
     132             : 
     133          76 : static void lcl_SetLastFunctions( ScAppOptions& rOpt, const Any& rValue )
     134             : {
     135          76 :     Sequence<sal_Int32> aSeq;
     136          76 :     if ( rValue >>= aSeq )
     137             :     {
     138          76 :         long nCount = aSeq.getLength();
     139          76 :         if ( nCount < USHRT_MAX )
     140             :         {
     141          76 :             const sal_Int32* pArray = aSeq.getConstArray();
     142          76 :             boost::scoped_array<sal_uInt16> pUShorts(new sal_uInt16[nCount]);
     143         456 :             for (long i=0; i<nCount; i++)
     144         380 :                 pUShorts[i] = (sal_uInt16) pArray[i];
     145             : 
     146          76 :             rOpt.SetLRUFuncList( pUShorts.get(), sal::static_int_cast<sal_uInt16>(nCount) );
     147             :         }
     148          76 :     }
     149          76 : }
     150             : 
     151           2 : static void lcl_GetLastFunctions( Any& rDest, const ScAppOptions& rOpt )
     152             : {
     153           2 :     long nCount = rOpt.GetLRUFuncListCount();
     154           2 :     sal_uInt16* pUShorts = rOpt.GetLRUFuncList();
     155           2 :     if ( nCount && pUShorts )
     156             :     {
     157           2 :         Sequence<sal_Int32> aSeq( nCount );
     158           2 :         sal_Int32* pArray = aSeq.getArray();
     159          12 :         for (long i=0; i<nCount; i++)
     160          10 :             pArray[i] = pUShorts[i];
     161           2 :         rDest <<= aSeq;
     162             :     }
     163             :     else
     164           0 :         rDest <<= Sequence<sal_Int32>(0);   // empty
     165           2 : }
     166             : 
     167          76 : static void lcl_SetSortList( const Any& rValue )
     168             : {
     169          76 :     Sequence<OUString> aSeq;
     170          76 :     if ( rValue >>= aSeq )
     171             :     {
     172          76 :         long nCount = aSeq.getLength();
     173          76 :         const OUString* pArray = aSeq.getConstArray();
     174          76 :         ScUserList aList;
     175             : 
     176             :         //  if setting is "default", keep default values from ScUserList ctor
     177             :         //! mark "default" in a safe way
     178          76 :         bool bDefault = ( nCount == 1 && pArray[0] == "NULL" );
     179             : 
     180          76 :         if (!bDefault)
     181             :         {
     182           0 :             aList.clear();
     183             : 
     184           0 :             for (long i=0; i<nCount; i++)
     185             :             {
     186           0 :                 ScUserListData* pNew = new ScUserListData( pArray[i] );
     187           0 :                 aList.push_back(pNew);
     188             :             }
     189             :         }
     190             : 
     191          76 :         ScGlobal::SetUserList( &aList );
     192          76 :     }
     193          76 : }
     194             : 
     195           2 : static void lcl_GetSortList( Any& rDest )
     196             : {
     197           2 :     const ScUserList* pUserList = ScGlobal::GetUserList();
     198           2 :     if (pUserList)
     199             :     {
     200           2 :         size_t nCount = pUserList->size();
     201           2 :         Sequence<OUString> aSeq( nCount );
     202           2 :         OUString* pArray = aSeq.getArray();
     203          20 :         for (size_t i=0; i<nCount; ++i)
     204          18 :             pArray[i] = (*pUserList)[sal::static_int_cast<sal_uInt16>(i)]->GetString();
     205           2 :         rDest <<= aSeq;
     206             :     }
     207             :     else
     208           0 :         rDest <<= Sequence<OUString>(0);    // empty
     209           2 : }
     210             : 
     211             : #define CFGPATH_LAYOUT      "Office.Calc/Layout"
     212             : 
     213             : #define SCLAYOUTOPT_MEASURE         0
     214             : #define SCLAYOUTOPT_STATUSBAR       1
     215             : #define SCLAYOUTOPT_ZOOMVAL         2
     216             : #define SCLAYOUTOPT_ZOOMTYPE        3
     217             : #define SCLAYOUTOPT_SYNCZOOM        4
     218             : #define SCLAYOUTOPT_COUNT           5
     219             : 
     220             : #define CFGPATH_INPUT       "Office.Calc/Input"
     221             : 
     222             : #define SCINPUTOPT_LASTFUNCS        0
     223             : #define SCINPUTOPT_AUTOINPUT        1
     224             : #define SCINPUTOPT_DET_AUTO         2
     225             : #define SCINPUTOPT_COUNT            3
     226             : 
     227             : #define CFGPATH_REVISION    "Office.Calc/Revision/Color"
     228             : 
     229             : #define SCREVISOPT_CHANGE           0
     230             : #define SCREVISOPT_INSERTION        1
     231             : #define SCREVISOPT_DELETION         2
     232             : #define SCREVISOPT_MOVEDENTRY       3
     233             : #define SCREVISOPT_COUNT            4
     234             : 
     235             : #define CFGPATH_CONTENT     "Office.Calc/Content/Update"
     236             : 
     237             : #define SCCONTENTOPT_LINK           0
     238             : #define SCCONTENTOPT_COUNT          1
     239             : 
     240             : #define CFGPATH_SORTLIST    "Office.Calc/SortList"
     241             : 
     242             : #define SCSORTLISTOPT_LIST          0
     243             : #define SCSORTLISTOPT_COUNT         1
     244             : 
     245             : #define CFGPATH_MISC        "Office.Calc/Misc"
     246             : 
     247             : #define SCMISCOPT_DEFOBJWIDTH       0
     248             : #define SCMISCOPT_DEFOBJHEIGHT      1
     249             : #define SCMISCOPT_SHOWSHAREDDOCWARN 2
     250             : #define SCMISCOPT_COUNT             3
     251             : 
     252             : #define CFGPATH_COMPAT      "Office.Calc/Compatibility"
     253             : 
     254             : #define SCCOMPATOPT_KEY_BINDING     0
     255             : #define SCCOMPATOPT_COUNT           1
     256             : 
     257          78 : Sequence<OUString> ScAppCfg::GetLayoutPropertyNames()
     258             : {
     259             :     static const char* aPropNames[] =
     260             :     {
     261             :         "Other/MeasureUnit/NonMetric",  // SCLAYOUTOPT_MEASURE
     262             :         "Other/StatusbarFunction",      // SCLAYOUTOPT_STATUSBAR
     263             :         "Zoom/Value",                   // SCLAYOUTOPT_ZOOMVAL
     264             :         "Zoom/Type",                    // SCLAYOUTOPT_ZOOMTYPE
     265             :         "Zoom/Synchronize"              // SCLAYOUTOPT_SYNCZOOM
     266             :     };
     267          78 :     Sequence<OUString> aNames(SCLAYOUTOPT_COUNT);
     268          78 :     OUString* pNames = aNames.getArray();
     269         468 :     for(int i = 0; i < SCLAYOUTOPT_COUNT; i++)
     270         390 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     271             : 
     272             :     //  adjust for metric system
     273          78 :     if (ScOptionsUtil::IsMetricSystem())
     274           0 :         pNames[SCLAYOUTOPT_MEASURE] = "Other/MeasureUnit/Metric";
     275             : 
     276          78 :     return aNames;
     277             : }
     278             : 
     279          78 : Sequence<OUString> ScAppCfg::GetInputPropertyNames()
     280             : {
     281             :     static const char* aPropNames[] =
     282             :     {
     283             :         "LastFunctions",            // SCINPUTOPT_LASTFUNCS
     284             :         "AutoInput",                // SCINPUTOPT_AUTOINPUT
     285             :         "DetectiveAuto"             // SCINPUTOPT_DET_AUTO
     286             :     };
     287          78 :     Sequence<OUString> aNames(SCINPUTOPT_COUNT);
     288          78 :     OUString* pNames = aNames.getArray();
     289         312 :     for(int i = 0; i < SCINPUTOPT_COUNT; i++)
     290         234 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     291             : 
     292          78 :     return aNames;
     293             : }
     294             : 
     295          78 : Sequence<OUString> ScAppCfg::GetRevisionPropertyNames()
     296             : {
     297             :     static const char* aPropNames[] =
     298             :     {
     299             :         "Change",                   // SCREVISOPT_CHANGE
     300             :         "Insertion",                // SCREVISOPT_INSERTION
     301             :         "Deletion",                 // SCREVISOPT_DELETION
     302             :         "MovedEntry"                // SCREVISOPT_MOVEDENTRY
     303             :     };
     304          78 :     Sequence<OUString> aNames(SCREVISOPT_COUNT);
     305          78 :     OUString* pNames = aNames.getArray();
     306         390 :     for(int i = 0; i < SCREVISOPT_COUNT; i++)
     307         312 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     308             : 
     309          78 :     return aNames;
     310             : }
     311             : 
     312          78 : Sequence<OUString> ScAppCfg::GetContentPropertyNames()
     313             : {
     314             :     static const char* aPropNames[] =
     315             :     {
     316             :         "Link"                      // SCCONTENTOPT_LINK
     317             :     };
     318          78 :     Sequence<OUString> aNames(SCCONTENTOPT_COUNT);
     319          78 :     OUString* pNames = aNames.getArray();
     320         156 :     for(int i = 0; i < SCCONTENTOPT_COUNT; i++)
     321          78 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     322             : 
     323          78 :     return aNames;
     324             : }
     325             : 
     326          78 : Sequence<OUString> ScAppCfg::GetSortListPropertyNames()
     327             : {
     328             :     static const char* aPropNames[] =
     329             :     {
     330             :         "List"                      // SCSORTLISTOPT_LIST
     331             :     };
     332          78 :     Sequence<OUString> aNames(SCSORTLISTOPT_COUNT);
     333          78 :     OUString* pNames = aNames.getArray();
     334         156 :     for(int i = 0; i < SCSORTLISTOPT_COUNT; i++)
     335          78 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     336             : 
     337          78 :     return aNames;
     338             : }
     339             : 
     340          78 : Sequence<OUString> ScAppCfg::GetMiscPropertyNames()
     341             : {
     342             :     static const char* aPropNames[] =
     343             :     {
     344             :         "DefaultObjectSize/Width",      // SCMISCOPT_DEFOBJWIDTH
     345             :         "DefaultObjectSize/Height",     // SCMISCOPT_DEFOBJHEIGHT
     346             :         "SharedDocument/ShowWarning"    // SCMISCOPT_SHOWSHAREDDOCWARN
     347             :     };
     348          78 :     Sequence<OUString> aNames(SCMISCOPT_COUNT);
     349          78 :     OUString* pNames = aNames.getArray();
     350         312 :     for(int i = 0; i < SCMISCOPT_COUNT; i++)
     351         234 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     352             : 
     353          78 :     return aNames;
     354             : }
     355             : 
     356          78 : Sequence<OUString> ScAppCfg::GetCompatPropertyNames()
     357             : {
     358             :     static const char* aPropNames[] =
     359             :     {
     360             :         "KeyBindings/BaseGroup"         // SCCOMPATOPT_KEY_BINDING
     361             :     };
     362          78 :     Sequence<OUString> aNames(SCCOMPATOPT_COUNT);
     363          78 :     OUString* pNames = aNames.getArray();
     364         156 :     for (int i = 0; i < SCCOMPATOPT_COUNT; ++i)
     365          78 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     366             : 
     367          78 :     return aNames;
     368             : }
     369             : 
     370          76 : ScAppCfg::ScAppCfg() :
     371             :     aLayoutItem( OUString( CFGPATH_LAYOUT ) ),
     372             :     aInputItem( OUString( CFGPATH_INPUT ) ),
     373             :     aRevisionItem( OUString( CFGPATH_REVISION ) ),
     374             :     aContentItem( OUString( CFGPATH_CONTENT ) ),
     375             :     aSortListItem( OUString( CFGPATH_SORTLIST ) ),
     376             :     aMiscItem( OUString( CFGPATH_MISC ) ),
     377          76 :     aCompatItem( OUString(CFGPATH_COMPAT ) )
     378             : {
     379          76 :     sal_Int32 nIntVal = 0;
     380             : 
     381          76 :     Sequence<OUString> aNames;
     382         152 :     Sequence<Any> aValues;
     383          76 :     const Any* pValues = NULL;
     384             : 
     385          76 :     aNames = GetLayoutPropertyNames();
     386          76 :     aValues = aLayoutItem.GetProperties(aNames);
     387          76 :     aLayoutItem.EnableNotification(aNames);
     388          76 :     pValues = aValues.getConstArray();
     389             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     390          76 :     if(aValues.getLength() == aNames.getLength())
     391             :     {
     392         456 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     393             :         {
     394             :             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
     395         380 :             if(pValues[nProp].hasValue())
     396             :             {
     397         380 :                 switch(nProp)
     398             :                 {
     399             :                     case SCLAYOUTOPT_MEASURE:
     400          76 :                         if (pValues[nProp] >>= nIntVal) SetAppMetric( (FieldUnit) nIntVal );
     401          76 :                         break;
     402             :                     case SCLAYOUTOPT_STATUSBAR:
     403          76 :                         if (pValues[nProp] >>= nIntVal) SetStatusFunc( (sal_uInt16) nIntVal );
     404          76 :                         break;
     405             :                     case SCLAYOUTOPT_ZOOMVAL:
     406          76 :                         if (pValues[nProp] >>= nIntVal) SetZoom( (sal_uInt16) nIntVal );
     407          76 :                         break;
     408             :                     case SCLAYOUTOPT_ZOOMTYPE:
     409          76 :                         if (pValues[nProp] >>= nIntVal) SetZoomType( (SvxZoomType) nIntVal );
     410          76 :                         break;
     411             :                     case SCLAYOUTOPT_SYNCZOOM:
     412          76 :                         SetSynchronizeZoom( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     413          76 :                         break;
     414             :                 }
     415             :             }
     416             :         }
     417             :     }
     418          76 :     aLayoutItem.SetCommitLink( LINK( this, ScAppCfg, LayoutCommitHdl ) );
     419             : 
     420          76 :     aNames = GetInputPropertyNames();
     421          76 :     aValues = aInputItem.GetProperties(aNames);
     422          76 :     aInputItem.EnableNotification(aNames);
     423          76 :     pValues = aValues.getConstArray();
     424             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     425          76 :     if(aValues.getLength() == aNames.getLength())
     426             :     {
     427         304 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     428             :         {
     429             :             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
     430         228 :             if(pValues[nProp].hasValue())
     431             :             {
     432         228 :                 switch(nProp)
     433             :                 {
     434             :                     case SCINPUTOPT_LASTFUNCS:
     435          76 :                         lcl_SetLastFunctions( *this, pValues[nProp] );
     436          76 :                         break;
     437             :                     case SCINPUTOPT_AUTOINPUT:
     438          76 :                         SetAutoComplete( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     439          76 :                         break;
     440             :                     case SCINPUTOPT_DET_AUTO:
     441          76 :                         SetDetectiveAuto( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     442          76 :                         break;
     443             :                 }
     444             :             }
     445             :         }
     446             :     }
     447          76 :     aInputItem.SetCommitLink( LINK( this, ScAppCfg, InputCommitHdl ) );
     448             : 
     449          76 :     aNames = GetRevisionPropertyNames();
     450          76 :     aValues = aRevisionItem.GetProperties(aNames);
     451          76 :     aRevisionItem.EnableNotification(aNames);
     452          76 :     pValues = aValues.getConstArray();
     453             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     454          76 :     if(aValues.getLength() == aNames.getLength())
     455             :     {
     456         380 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     457             :         {
     458             :             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
     459         304 :             if(pValues[nProp].hasValue())
     460             :             {
     461         304 :                 switch(nProp)
     462             :                 {
     463             :                     case SCREVISOPT_CHANGE:
     464          76 :                         if (pValues[nProp] >>= nIntVal) SetTrackContentColor( (sal_uInt32) nIntVal );
     465          76 :                         break;
     466             :                     case SCREVISOPT_INSERTION:
     467          76 :                         if (pValues[nProp] >>= nIntVal) SetTrackInsertColor( (sal_uInt32) nIntVal );
     468          76 :                         break;
     469             :                     case SCREVISOPT_DELETION:
     470          76 :                         if (pValues[nProp] >>= nIntVal) SetTrackDeleteColor( (sal_uInt32) nIntVal );
     471          76 :                         break;
     472             :                     case SCREVISOPT_MOVEDENTRY:
     473          76 :                         if (pValues[nProp] >>= nIntVal) SetTrackMoveColor( (sal_uInt32) nIntVal );
     474          76 :                         break;
     475             :                 }
     476             :             }
     477             :         }
     478             :     }
     479          76 :     aRevisionItem.SetCommitLink( LINK( this, ScAppCfg, RevisionCommitHdl ) );
     480             : 
     481          76 :     aNames = GetContentPropertyNames();
     482          76 :     aValues = aContentItem.GetProperties(aNames);
     483          76 :     aContentItem.EnableNotification(aNames);
     484          76 :     pValues = aValues.getConstArray();
     485             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     486          76 :     if(aValues.getLength() == aNames.getLength())
     487             :     {
     488         152 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     489             :         {
     490             :             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
     491          76 :             if(pValues[nProp].hasValue())
     492             :             {
     493          76 :                 switch(nProp)
     494             :                 {
     495             :                     case SCCONTENTOPT_LINK:
     496          76 :                         if (pValues[nProp] >>= nIntVal) SetLinkMode( (ScLkUpdMode) nIntVal );
     497          76 :                         break;
     498             :                 }
     499             :             }
     500             :         }
     501             :     }
     502          76 :     aContentItem.SetCommitLink( LINK( this, ScAppCfg, ContentCommitHdl ) );
     503             : 
     504          76 :     aNames = GetSortListPropertyNames();
     505          76 :     aValues = aSortListItem.GetProperties(aNames);
     506          76 :     aSortListItem.EnableNotification(aNames);
     507          76 :     pValues = aValues.getConstArray();
     508             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     509          76 :     if(aValues.getLength() == aNames.getLength())
     510             :     {
     511         152 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     512             :         {
     513             :             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
     514          76 :             if(pValues[nProp].hasValue())
     515             :             {
     516          76 :                 switch(nProp)
     517             :                 {
     518             :                     case SCSORTLISTOPT_LIST:
     519          76 :                         lcl_SetSortList( pValues[nProp] );
     520          76 :                         break;
     521             :                 }
     522             :             }
     523             :         }
     524             :     }
     525          76 :     aSortListItem.SetCommitLink( LINK( this, ScAppCfg, SortListCommitHdl ) );
     526             : 
     527          76 :     aNames = GetMiscPropertyNames();
     528          76 :     aValues = aMiscItem.GetProperties(aNames);
     529          76 :     aMiscItem.EnableNotification(aNames);
     530          76 :     pValues = aValues.getConstArray();
     531             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     532          76 :     if(aValues.getLength() == aNames.getLength())
     533             :     {
     534         304 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     535             :         {
     536             :             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
     537         228 :             if(pValues[nProp].hasValue())
     538             :             {
     539         228 :                 switch(nProp)
     540             :                 {
     541             :                     case SCMISCOPT_DEFOBJWIDTH:
     542          76 :                         if (pValues[nProp] >>= nIntVal) SetDefaultObjectSizeWidth( nIntVal );
     543          76 :                         break;
     544             :                     case SCMISCOPT_DEFOBJHEIGHT:
     545          76 :                         if (pValues[nProp] >>= nIntVal) SetDefaultObjectSizeHeight( nIntVal );
     546          76 :                         break;
     547             :                     case SCMISCOPT_SHOWSHAREDDOCWARN:
     548          76 :                         SetShowSharedDocumentWarning( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     549          76 :                         break;
     550             :                 }
     551             :             }
     552             :         }
     553             :     }
     554          76 :     aMiscItem.SetCommitLink( LINK( this, ScAppCfg, MiscCommitHdl ) );
     555             : 
     556          76 :     aNames = GetCompatPropertyNames();
     557          76 :     aValues = aCompatItem.GetProperties(aNames);
     558          76 :     aCompatItem.EnableNotification(aNames);
     559          76 :     pValues = aValues.getConstArray();
     560          76 :     if (aValues.getLength() == aNames.getLength())
     561             :     {
     562         152 :         for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
     563             :         {
     564          76 :             switch (nProp)
     565             :             {
     566             :                 case SCCOMPATOPT_KEY_BINDING:
     567             :                 {
     568          76 :                     nIntVal = 0; // 0 = 'Default'
     569          76 :                     pValues[nProp] >>= nIntVal;
     570          76 :                     SetKeyBindingType(static_cast<ScOptionsUtil::KeyBindingType>(nIntVal));
     571             :                 }
     572          76 :                 break;
     573             :             }
     574             :         }
     575             :     }
     576         152 :     aCompatItem.SetCommitLink( LINK(this, ScAppCfg, CompatCommitHdl) );
     577          76 : }
     578           4 :  IMPL_LINK_NOARG(ScAppCfg, LayoutCommitHdl)
     579             : {
     580           2 :     Sequence<OUString> aNames = GetLayoutPropertyNames();
     581           4 :     Sequence<Any> aValues(aNames.getLength());
     582           2 :     Any* pValues = aValues.getArray();
     583             : 
     584          12 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     585             :     {
     586          10 :         switch(nProp)
     587             :         {
     588             :             case SCLAYOUTOPT_MEASURE:
     589           2 :                 pValues[nProp] <<= (sal_Int32) GetAppMetric();
     590           2 :                 break;
     591             :             case SCLAYOUTOPT_STATUSBAR:
     592           2 :                 pValues[nProp] <<= (sal_Int32) GetStatusFunc();
     593           2 :                 break;
     594             :             case SCLAYOUTOPT_ZOOMVAL:
     595           2 :                 pValues[nProp] <<= (sal_Int32) GetZoom();
     596           2 :                 break;
     597             :             case SCLAYOUTOPT_ZOOMTYPE:
     598           2 :                 pValues[nProp] <<= (sal_Int32) GetZoomType();
     599           2 :                 break;
     600             :             case SCLAYOUTOPT_SYNCZOOM:
     601           2 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetSynchronizeZoom() );
     602           2 :                 break;
     603             :         }
     604             :     }
     605           2 :     aLayoutItem.PutProperties(aNames, aValues);
     606             : 
     607           4 :     return 0;
     608             : }
     609             : 
     610           4 : IMPL_LINK_NOARG(ScAppCfg, InputCommitHdl)
     611             : {
     612           2 :     Sequence<OUString> aNames = GetInputPropertyNames();
     613           4 :     Sequence<Any> aValues(aNames.getLength());
     614           2 :     Any* pValues = aValues.getArray();
     615             : 
     616           8 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     617             :     {
     618           6 :         switch(nProp)
     619             :         {
     620             :             case SCINPUTOPT_LASTFUNCS:
     621           2 :                 lcl_GetLastFunctions( pValues[nProp], *this );
     622           2 :                 break;
     623             :             case SCINPUTOPT_AUTOINPUT:
     624           2 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetAutoComplete() );
     625           2 :                 break;
     626             :             case SCINPUTOPT_DET_AUTO:
     627           2 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetDetectiveAuto() );
     628           2 :                 break;
     629             :         }
     630             :     }
     631           2 :     aInputItem.PutProperties(aNames, aValues);
     632             : 
     633           4 :     return 0;
     634             : }
     635             : 
     636           4 : IMPL_LINK_NOARG(ScAppCfg, RevisionCommitHdl)
     637             : {
     638           2 :     Sequence<OUString> aNames = GetRevisionPropertyNames();
     639           4 :     Sequence<Any> aValues(aNames.getLength());
     640           2 :     Any* pValues = aValues.getArray();
     641             : 
     642          10 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     643             :     {
     644           8 :         switch(nProp)
     645             :         {
     646             :             case SCREVISOPT_CHANGE:
     647           2 :                 pValues[nProp] <<= (sal_Int32) GetTrackContentColor();
     648           2 :                 break;
     649             :             case SCREVISOPT_INSERTION:
     650           2 :                 pValues[nProp] <<= (sal_Int32) GetTrackInsertColor();
     651           2 :                 break;
     652             :             case SCREVISOPT_DELETION:
     653           2 :                 pValues[nProp] <<= (sal_Int32) GetTrackDeleteColor();
     654           2 :                 break;
     655             :             case SCREVISOPT_MOVEDENTRY:
     656           2 :                 pValues[nProp] <<= (sal_Int32) GetTrackMoveColor();
     657           2 :                 break;
     658             :         }
     659             :     }
     660           2 :     aRevisionItem.PutProperties(aNames, aValues);
     661             : 
     662           4 :     return 0;
     663             : }
     664             : 
     665           4 : IMPL_LINK_NOARG(ScAppCfg, ContentCommitHdl)
     666             : {
     667           2 :     Sequence<OUString> aNames = GetContentPropertyNames();
     668           4 :     Sequence<Any> aValues(aNames.getLength());
     669           2 :     Any* pValues = aValues.getArray();
     670             : 
     671           4 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     672             :     {
     673           2 :         switch(nProp)
     674             :         {
     675             :             case SCCONTENTOPT_LINK:
     676           2 :                 pValues[nProp] <<= (sal_Int32) GetLinkMode();
     677           2 :                 break;
     678             :         }
     679             :     }
     680           2 :     aContentItem.PutProperties(aNames, aValues);
     681             : 
     682           4 :     return 0;
     683             : }
     684             : 
     685           4 : IMPL_LINK_NOARG(ScAppCfg, SortListCommitHdl)
     686             : {
     687           2 :     Sequence<OUString> aNames = GetSortListPropertyNames();
     688           4 :     Sequence<Any> aValues(aNames.getLength());
     689           2 :     Any* pValues = aValues.getArray();
     690             : 
     691           4 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     692             :     {
     693           2 :         switch(nProp)
     694             :         {
     695             :             case SCSORTLISTOPT_LIST:
     696           2 :                 lcl_GetSortList( pValues[nProp] );
     697           2 :                 break;
     698             :         }
     699             :     }
     700           2 :     aSortListItem.PutProperties(aNames, aValues);
     701             : 
     702           4 :     return 0;
     703             : }
     704             : 
     705           4 : IMPL_LINK_NOARG(ScAppCfg, MiscCommitHdl)
     706             : {
     707           2 :     Sequence<OUString> aNames = GetMiscPropertyNames();
     708           4 :     Sequence<Any> aValues(aNames.getLength());
     709           2 :     Any* pValues = aValues.getArray();
     710             : 
     711           8 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     712             :     {
     713           6 :         switch(nProp)
     714             :         {
     715             :             case SCMISCOPT_DEFOBJWIDTH:
     716           2 :                 pValues[nProp] <<= (sal_Int32) GetDefaultObjectSizeWidth();
     717           2 :                 break;
     718             :             case SCMISCOPT_DEFOBJHEIGHT:
     719           2 :                 pValues[nProp] <<= (sal_Int32) GetDefaultObjectSizeHeight();
     720           2 :                 break;
     721             :             case SCMISCOPT_SHOWSHAREDDOCWARN:
     722           2 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetShowSharedDocumentWarning() );
     723           2 :                 break;
     724             :         }
     725             :     }
     726           2 :     aMiscItem.PutProperties(aNames, aValues);
     727             : 
     728           4 :     return 0;
     729             : }
     730             : 
     731           4 : IMPL_LINK_NOARG(ScAppCfg, CompatCommitHdl)
     732             : {
     733           2 :     Sequence<OUString> aNames = GetCompatPropertyNames();
     734           4 :     Sequence<Any> aValues(aNames.getLength());
     735           2 :     Any* pValues = aValues.getArray();
     736             : 
     737           4 :     for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
     738             :     {
     739           2 :         switch(nProp)
     740             :         {
     741             :             case SCCOMPATOPT_KEY_BINDING:
     742           2 :                 pValues[nProp] <<= static_cast<sal_Int32>(GetKeyBindingType());
     743           2 :             break;
     744             :         }
     745             :     }
     746           2 :     aCompatItem.PutProperties(aNames, aValues);
     747           4 :     return 0;
     748             : }
     749             : 
     750          40 : void ScAppCfg::SetOptions( const ScAppOptions& rNew )
     751             : {
     752          40 :     *(ScAppOptions*)this = rNew;
     753          40 :     OptionsChanged();
     754          40 : }
     755             : 
     756          40 : void ScAppCfg::OptionsChanged()
     757             : {
     758          40 :     aLayoutItem.SetModified();
     759          40 :     aInputItem.SetModified();
     760          40 :     aRevisionItem.SetModified();
     761          40 :     aContentItem.SetModified();
     762          40 :     aSortListItem.SetModified();
     763          40 :     aMiscItem.SetModified();
     764          40 :     aCompatItem.SetModified();
     765         268 : }
     766             : 
     767             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10