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

Generated by: LCOV version 1.10