LCOV - code coverage report
Current view: top level - libreoffice/sc/source/core/tool - viewopti.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 182 317 57.4 %
Date: 2012-12-27 Functions: 14 36 38.9 %
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             : 
      25             : #include "global.hxx"
      26             : #include "globstr.hrc"
      27             : #include "cfgids.hxx"
      28             : #include "viewopti.hxx"
      29             : #include "rechead.hxx"
      30             : #include "scresid.hxx"
      31             : #include "sc.hrc"
      32             : #include "miscuno.hxx"
      33             : 
      34             : using namespace utl;
      35             : using namespace com::sun::star::uno;
      36             : 
      37             : using ::rtl::OUString;
      38             : 
      39             : //------------------------------------------------------------------
      40             : 
      41           0 : TYPEINIT1(ScTpViewItem, SfxPoolItem);
      42             : 
      43             : #define SC_VERSION ((sal_uInt16)302)
      44             : 
      45             : 
      46             : //========================================================================
      47             : // class ScGridOptions
      48             : //========================================================================
      49             : 
      50             : 
      51         202 : void ScGridOptions::SetDefaults()
      52             : {
      53         202 :     *this = ScGridOptions();
      54             : 
      55             :     //  Raster-Defaults sind jetzt zwischen den Apps unterschiedlich
      56             :     //  darum hier selber eintragen (alles in 1/100mm)
      57             : 
      58         202 :     if ( ScOptionsUtil::IsMetricSystem() )
      59             :     {
      60           0 :         nFldDrawX = 1000;   // 1cm
      61           0 :         nFldDrawY = 1000;
      62           0 :         nFldSnapX = 1000;
      63           0 :         nFldSnapY = 1000;
      64             :     }
      65             :     else
      66             :     {
      67         202 :         nFldDrawX = 1270;   // 0,5"
      68         202 :         nFldDrawY = 1270;
      69         202 :         nFldSnapX = 1270;
      70         202 :         nFldSnapY = 1270;
      71             :     }
      72         202 :     nFldDivisionX = 1;
      73         202 :     nFldDivisionY = 1;
      74         202 : }
      75             : 
      76             : //------------------------------------------------------------------------
      77             : 
      78        1808 : const ScGridOptions& ScGridOptions::operator=( const ScGridOptions& rCpy )
      79             : {
      80        1808 :     nFldDrawX       = rCpy.nFldDrawX;       // UINT32
      81        1808 :     nFldDivisionX   = rCpy.nFldDivisionX;
      82        1808 :     nFldDrawY       = rCpy.nFldDrawY;
      83        1808 :     nFldDivisionY   = rCpy.nFldDivisionY;
      84        1808 :     nFldSnapX       = rCpy.nFldSnapX;
      85        1808 :     nFldSnapY       = rCpy.nFldSnapY;
      86        1808 :     bUseGridsnap    = rCpy.bUseGridsnap;    // BitBool
      87        1808 :     bSynchronize    = rCpy.bSynchronize;
      88        1808 :     bGridVisible    = rCpy.bGridVisible;
      89        1808 :     bEqualGrid      = rCpy.bEqualGrid;
      90             : 
      91        1808 :     return *this;
      92             : }
      93             : 
      94             : //------------------------------------------------------------------------
      95             : 
      96           0 : bool ScGridOptions::operator==( const ScGridOptions& rCpy ) const
      97             : {
      98             :     return (   nFldDrawX        == rCpy.nFldDrawX
      99             :             && nFldDivisionX    == rCpy.nFldDivisionX
     100             :             && nFldDrawY        == rCpy.nFldDrawY
     101             :             && nFldDivisionY    == rCpy.nFldDivisionY
     102             :             && nFldSnapX        == rCpy.nFldSnapX
     103             :             && nFldSnapY        == rCpy.nFldSnapY
     104             :             && bUseGridsnap     == rCpy.bUseGridsnap
     105             :             && bSynchronize     == rCpy.bSynchronize
     106             :             && bGridVisible     == rCpy.bGridVisible
     107           0 :             && bEqualGrid       == rCpy.bEqualGrid );
     108             : }
     109             : 
     110             : 
     111             : //========================================================================
     112             : // class ScViewOptions
     113             : //========================================================================
     114             : 
     115         202 : ScViewOptions::ScViewOptions()
     116             : {
     117         202 :     SetDefaults();
     118         202 : }
     119             : 
     120             : //------------------------------------------------------------------------
     121             : 
     122         722 : ScViewOptions::ScViewOptions( const ScViewOptions& rCpy )
     123             : {
     124         722 :     *this = rCpy;
     125         722 : }
     126             : 
     127             : //------------------------------------------------------------------------
     128             : 
     129         834 : ScViewOptions::~ScViewOptions()
     130             : {
     131         834 : }
     132             : 
     133             : //------------------------------------------------------------------------
     134             : 
     135         202 : void ScViewOptions::SetDefaults()
     136             : {
     137         202 :     aOptArr[ VOPT_FORMULAS    ] = false;
     138         202 :     aOptArr[ VOPT_SYNTAX      ] = false;
     139         202 :     aOptArr[ VOPT_HELPLINES   ] = false;
     140         202 :     aOptArr[ VOPT_GRID_ONTOP  ] = false;
     141         202 :     aOptArr[ VOPT_NOTES       ] = true;
     142         202 :     aOptArr[ VOPT_NULLVALS    ] = true;
     143         202 :     aOptArr[ VOPT_VSCROLL     ] = true;
     144         202 :     aOptArr[ VOPT_HSCROLL     ] = true;
     145         202 :     aOptArr[ VOPT_TABCONTROLS ] = true;
     146         202 :     aOptArr[ VOPT_OUTLINER    ] = true;
     147         202 :     aOptArr[ VOPT_HEADER      ] = true;
     148         202 :     aOptArr[ VOPT_GRID        ] = true;
     149         202 :     aOptArr[ VOPT_ANCHOR      ] = true;
     150         202 :     aOptArr[ VOPT_PAGEBREAKS  ] = true;
     151         202 :     aOptArr[ VOPT_CLIPMARKS   ] = true;
     152             : 
     153         202 :     aModeArr[VOBJ_TYPE_OLE ]  = VOBJ_MODE_SHOW;
     154         202 :     aModeArr[VOBJ_TYPE_CHART] = VOBJ_MODE_SHOW;
     155         202 :     aModeArr[VOBJ_TYPE_DRAW ] = VOBJ_MODE_SHOW;
     156             : 
     157         202 :     aGridCol     = Color( SC_STD_GRIDCOLOR );
     158         202 :     aGridColName = ScGlobal::GetRscString( STR_GRIDCOLOR );
     159             : 
     160         202 :     aGridOpt.SetDefaults();
     161         202 : }
     162             : 
     163             : //------------------------------------------------------------------------
     164             : 
     165           2 : Color ScViewOptions::GetGridColor( String* pStrName ) const
     166             : {
     167           2 :     if ( pStrName )
     168           2 :         *pStrName = aGridColName;
     169             : 
     170           2 :     return aGridCol;
     171             : }
     172             : 
     173             : //------------------------------------------------------------------------
     174             : 
     175        1448 : const ScViewOptions& ScViewOptions::operator=( const ScViewOptions& rCpy )
     176             : {
     177             :     sal_uInt16 i;
     178             : 
     179        1448 :     for ( i=0; i<MAX_OPT; i++ )  aOptArr [i] = rCpy.aOptArr[i];
     180        1448 :     for ( i=0; i<MAX_TYPE; i++ ) aModeArr[i] = rCpy.aModeArr[i];
     181             : 
     182        1448 :     aGridCol        = rCpy.aGridCol;
     183        1448 :     aGridColName    = rCpy.aGridColName;
     184        1448 :     aGridOpt        = rCpy.aGridOpt;
     185             : 
     186        1448 :     return *this;
     187             : }
     188             : 
     189             : //------------------------------------------------------------------------
     190             : 
     191           0 : int ScViewOptions::operator==( const ScViewOptions& rOpt ) const
     192             : {
     193           0 :     sal_Bool    bEqual = sal_True;
     194             :     sal_uInt16  i;
     195             : 
     196           0 :     for ( i=0; i<MAX_OPT && bEqual; i++ )  bEqual = (aOptArr [i] == rOpt.aOptArr[i]);
     197           0 :     for ( i=0; i<MAX_TYPE && bEqual; i++ ) bEqual = (aModeArr[i] == rOpt.aModeArr[i]);
     198             : 
     199           0 :     bEqual = bEqual && (aGridCol       == rOpt.aGridCol);
     200           0 :     bEqual = bEqual && (aGridColName   == rOpt.aGridColName);
     201           0 :     bEqual = bEqual && (aGridOpt       == rOpt.aGridOpt);
     202             : 
     203           0 :     return bEqual;
     204             : }
     205             : 
     206             : //------------------------------------------------------------------------
     207             : 
     208           0 : SvxGridItem* ScViewOptions::CreateGridItem( sal_uInt16 nId /* = SID_ATTR_GRID_OPTIONS */ ) const
     209             : {
     210           0 :     SvxGridItem* pItem = new SvxGridItem( nId );
     211             : 
     212           0 :     pItem->SetFldDrawX      ( aGridOpt.GetFldDrawX() );
     213           0 :     pItem->SetFldDivisionX  ( aGridOpt.GetFldDivisionX() );
     214           0 :     pItem->SetFldDrawY      ( aGridOpt.GetFldDrawY() );
     215           0 :     pItem->SetFldDivisionY  ( aGridOpt.GetFldDivisionY() );
     216           0 :     pItem->SetFldSnapX      ( aGridOpt.GetFldSnapX() );
     217           0 :     pItem->SetFldSnapY      ( aGridOpt.GetFldSnapY() );
     218           0 :     pItem->SetUseGridSnap   ( aGridOpt.GetUseGridSnap() );
     219           0 :     pItem->SetSynchronize   ( aGridOpt.GetSynchronize() );
     220           0 :     pItem->SetGridVisible   ( aGridOpt.GetGridVisible() );
     221           0 :     pItem->SetEqualGrid     ( aGridOpt.GetEqualGrid() );
     222             : 
     223           0 :     return pItem;
     224             : }
     225             : 
     226             : //========================================================================
     227             : //      ScTpViewItem - Daten fuer die ViewOptions-TabPage
     228             : //========================================================================
     229             : 
     230             : //------------------------------------------------------------------------
     231             : 
     232           0 : ScTpViewItem::ScTpViewItem( sal_uInt16 nWhichP, const ScViewOptions& rOpt )
     233             :     :   SfxPoolItem ( nWhichP ),
     234           0 :         theOptions  ( rOpt )
     235             : {
     236           0 : }
     237             : 
     238             : //------------------------------------------------------------------------
     239             : 
     240           0 : ScTpViewItem::ScTpViewItem( const ScTpViewItem& rItem )
     241             :     :   SfxPoolItem ( rItem ),
     242           0 :         theOptions  ( rItem.theOptions )
     243             : {
     244           0 : }
     245             : 
     246             : //------------------------------------------------------------------------
     247             : 
     248           0 : ScTpViewItem::~ScTpViewItem()
     249             : {
     250           0 : }
     251             : 
     252             : //------------------------------------------------------------------------
     253             : 
     254           0 : String ScTpViewItem::GetValueText() const
     255             : {
     256           0 :     return rtl::OUString("ScTpViewItem");
     257             : }
     258             : 
     259             : //------------------------------------------------------------------------
     260             : 
     261           0 : int ScTpViewItem::operator==( const SfxPoolItem& rItem ) const
     262             : {
     263             :     OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
     264             : 
     265           0 :     const ScTpViewItem& rPItem = (const ScTpViewItem&)rItem;
     266             : 
     267           0 :     return ( theOptions == rPItem.theOptions );
     268             : }
     269             : 
     270             : //------------------------------------------------------------------------
     271             : 
     272           0 : SfxPoolItem* ScTpViewItem::Clone( SfxItemPool * ) const
     273             : {
     274           0 :     return new ScTpViewItem( *this );
     275             : }
     276             : 
     277             : //==================================================================
     278             : //  Config Item containing view options
     279             : //==================================================================
     280             : 
     281             : #define CFGPATH_LAYOUT      "Office.Calc/Layout"
     282             : 
     283             : #define SCLAYOUTOPT_GRIDLINES       0
     284             : #define SCLAYOUTOPT_GRIDCOLOR       1
     285             : #define SCLAYOUTOPT_PAGEBREAK       2
     286             : #define SCLAYOUTOPT_GUIDE           3
     287             : #define SCLAYOUTOPT_COLROWHDR       4
     288             : #define SCLAYOUTOPT_HORISCROLL      5
     289             : #define SCLAYOUTOPT_VERTSCROLL      6
     290             : #define SCLAYOUTOPT_SHEETTAB        7
     291             : #define SCLAYOUTOPT_OUTLINE         8
     292             : #define SCLAYOUTOPT_GRID_ONCOLOR    9
     293             : #define SCLAYOUTOPT_COUNT           10
     294             : 
     295             : #define CFGPATH_DISPLAY     "Office.Calc/Content/Display"
     296             : 
     297             : #define SCDISPLAYOPT_FORMULA        0
     298             : #define SCDISPLAYOPT_ZEROVALUE      1
     299             : #define SCDISPLAYOPT_NOTETAG        2
     300             : #define SCDISPLAYOPT_VALUEHI        3
     301             : #define SCDISPLAYOPT_ANCHOR         4
     302             : #define SCDISPLAYOPT_TEXTOVER       5
     303             : #define SCDISPLAYOPT_OBJECTGRA      6
     304             : #define SCDISPLAYOPT_CHART          7
     305             : #define SCDISPLAYOPT_DRAWING        8
     306             : #define SCDISPLAYOPT_COUNT          9
     307             : 
     308             : #define CFGPATH_GRID        "Office.Calc/Grid"
     309             : 
     310             : #define SCGRIDOPT_RESOLU_X          0
     311             : #define SCGRIDOPT_RESOLU_Y          1
     312             : #define SCGRIDOPT_SUBDIV_X          2
     313             : #define SCGRIDOPT_SUBDIV_Y          3
     314             : #define SCGRIDOPT_OPTION_X          4
     315             : #define SCGRIDOPT_OPTION_Y          5
     316             : #define SCGRIDOPT_SNAPTOGRID        6
     317             : #define SCGRIDOPT_SYNCHRON          7
     318             : #define SCGRIDOPT_VISIBLE           8
     319             : #define SCGRIDOPT_SIZETOGRID        9
     320             : #define SCGRIDOPT_COUNT             10
     321             : 
     322             : 
     323           4 : Sequence<OUString> ScViewCfg::GetLayoutPropertyNames()
     324             : {
     325             :     static const char* aPropNames[] =
     326             :     {
     327             :         "Line/GridLine",            // SCLAYOUTOPT_GRIDLINES
     328             :         "Line/GridLineColor",       // SCLAYOUTOPT_GRIDCOLOR
     329             :         "Line/PageBreak",           // SCLAYOUTOPT_PAGEBREAK
     330             :         "Line/Guide",               // SCLAYOUTOPT_GUIDE
     331             :         "Window/ColumnRowHeader",   // SCLAYOUTOPT_COLROWHDR
     332             :         "Window/HorizontalScroll",  // SCLAYOUTOPT_HORISCROLL
     333             :         "Window/VerticalScroll",    // SCLAYOUTOPT_VERTSCROLL
     334             :         "Window/SheetTab",          // SCLAYOUTOPT_SHEETTAB
     335             :         "Window/OutlineSymbol",     // SCLAYOUTOPT_OUTLINE
     336             :         "Line/GridOnColoredCells"   // SCLAYOUTOPT_GRID_ONCOLOR
     337             :     };
     338           4 :     Sequence<OUString> aNames(SCLAYOUTOPT_COUNT);
     339           4 :     OUString* pNames = aNames.getArray();
     340          44 :     for(int i = 0; i < SCLAYOUTOPT_COUNT; i++)
     341          40 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     342             : 
     343           4 :     return aNames;
     344             : }
     345             : 
     346           4 : Sequence<OUString> ScViewCfg::GetDisplayPropertyNames()
     347             : {
     348             :     static const char* aPropNames[] =
     349             :     {
     350             :         "Formula",                  // SCDISPLAYOPT_FORMULA
     351             :         "ZeroValue",                // SCDISPLAYOPT_ZEROVALUE
     352             :         "NoteTag",                  // SCDISPLAYOPT_NOTETAG
     353             :         "ValueHighlighting",        // SCDISPLAYOPT_VALUEHI
     354             :         "Anchor",                   // SCDISPLAYOPT_ANCHOR
     355             :         "TextOverflow",             // SCDISPLAYOPT_TEXTOVER
     356             :         "ObjectGraphic",            // SCDISPLAYOPT_OBJECTGRA
     357             :         "Chart",                    // SCDISPLAYOPT_CHART
     358             :         "DrawingObject"             // SCDISPLAYOPT_DRAWING
     359             :     };
     360           4 :     Sequence<OUString> aNames(SCDISPLAYOPT_COUNT);
     361           4 :     OUString* pNames = aNames.getArray();
     362          40 :     for(int i = 0; i < SCDISPLAYOPT_COUNT; i++)
     363          36 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     364             : 
     365           4 :     return aNames;
     366             : }
     367             : 
     368           4 : Sequence<OUString> ScViewCfg::GetGridPropertyNames()
     369             : {
     370             :     static const char* aPropNames[] =
     371             :     {
     372             :         "Resolution/XAxis/NonMetric",   // SCGRIDOPT_RESOLU_X
     373             :         "Resolution/YAxis/NonMetric",   // SCGRIDOPT_RESOLU_Y
     374             :         "Subdivision/XAxis",            // SCGRIDOPT_SUBDIV_X
     375             :         "Subdivision/YAxis",            // SCGRIDOPT_SUBDIV_Y
     376             :         "Option/XAxis/NonMetric",       // SCGRIDOPT_OPTION_X
     377             :         "Option/YAxis/NonMetric",       // SCGRIDOPT_OPTION_Y
     378             :         "Option/SnapToGrid",            // SCGRIDOPT_SNAPTOGRID
     379             :         "Option/Synchronize",           // SCGRIDOPT_SYNCHRON
     380             :         "Option/VisibleGrid",           // SCGRIDOPT_VISIBLE
     381             :         "Option/SizeToGrid"             // SCGRIDOPT_SIZETOGRID
     382             :     };
     383           4 :     Sequence<OUString> aNames(SCGRIDOPT_COUNT);
     384           4 :     OUString* pNames = aNames.getArray();
     385          44 :     for(int i = 0; i < SCGRIDOPT_COUNT; i++)
     386          40 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     387             : 
     388             :     //  adjust for metric system
     389           4 :     if (ScOptionsUtil::IsMetricSystem())
     390             :     {
     391           0 :         pNames[SCGRIDOPT_RESOLU_X] = OUString(RTL_CONSTASCII_USTRINGPARAM( "Resolution/XAxis/Metric" ));
     392           0 :         pNames[SCGRIDOPT_RESOLU_Y] = OUString(RTL_CONSTASCII_USTRINGPARAM( "Resolution/YAxis/Metric" ));
     393           0 :         pNames[SCGRIDOPT_OPTION_X] = OUString(RTL_CONSTASCII_USTRINGPARAM( "Option/XAxis/Metric" ));
     394           0 :         pNames[SCGRIDOPT_OPTION_Y] = OUString(RTL_CONSTASCII_USTRINGPARAM( "Option/YAxis/Metric" ));
     395             :     }
     396             : 
     397           4 :     return aNames;
     398             : }
     399             : 
     400             : 
     401           4 : ScViewCfg::ScViewCfg() :
     402             :     aLayoutItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_LAYOUT )) ),
     403             :     aDisplayItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_DISPLAY )) ),
     404           4 :     aGridItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_GRID )) )
     405             : {
     406           4 :     sal_Int32 nIntVal = 0;
     407             : 
     408           4 :     Sequence<OUString> aNames = GetLayoutPropertyNames();
     409           4 :     Sequence<Any> aValues = aLayoutItem.GetProperties(aNames);
     410           4 :     aLayoutItem.EnableNotification(aNames);
     411           4 :     const Any* pValues = aValues.getConstArray();
     412             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     413           4 :     if(aValues.getLength() == aNames.getLength())
     414             :     {
     415          44 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     416             :         {
     417             :             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
     418          40 :             if(pValues[nProp].hasValue())
     419             :             {
     420          40 :                 switch(nProp)
     421             :                 {
     422             :                     case SCLAYOUTOPT_GRIDCOLOR:
     423           4 :                         if ( pValues[nProp] >>= nIntVal )
     424           4 :                             SetGridColor( Color(nIntVal), EMPTY_STRING );
     425           4 :                         break;
     426             :                     case SCLAYOUTOPT_GRIDLINES:
     427           4 :                         SetOption( VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     428           4 :                         break;
     429             :                     case SCLAYOUTOPT_GRID_ONCOLOR:
     430           4 :                         SetOption( VOPT_GRID_ONTOP, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     431           4 :                         break;
     432             :                     case SCLAYOUTOPT_PAGEBREAK:
     433           4 :                         SetOption( VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     434           4 :                         break;
     435             :                     case SCLAYOUTOPT_GUIDE:
     436           4 :                         SetOption( VOPT_HELPLINES, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     437           4 :                         break;
     438             :                     case SCLAYOUTOPT_COLROWHDR:
     439           4 :                         SetOption( VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     440           4 :                         break;
     441             :                     case SCLAYOUTOPT_HORISCROLL:
     442           4 :                         SetOption( VOPT_HSCROLL, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     443           4 :                         break;
     444             :                     case SCLAYOUTOPT_VERTSCROLL:
     445           4 :                         SetOption( VOPT_VSCROLL, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     446           4 :                         break;
     447             :                     case SCLAYOUTOPT_SHEETTAB:
     448           4 :                         SetOption( VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     449           4 :                         break;
     450             :                     case SCLAYOUTOPT_OUTLINE:
     451           4 :                         SetOption( VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     452           4 :                         break;
     453             :                 }
     454             :             }
     455             :         }
     456             :     }
     457           4 :     aLayoutItem.SetCommitLink( LINK( this, ScViewCfg, LayoutCommitHdl ) );
     458             : 
     459           4 :     aNames = GetDisplayPropertyNames();
     460           4 :     aValues = aDisplayItem.GetProperties(aNames);
     461           4 :     aDisplayItem.EnableNotification(aNames);
     462           4 :     pValues = aValues.getConstArray();
     463             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     464           4 :     if(aValues.getLength() == aNames.getLength())
     465             :     {
     466          40 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     467             :         {
     468             :             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
     469          36 :             if(pValues[nProp].hasValue())
     470             :             {
     471          36 :                 switch(nProp)
     472             :                 {
     473             :                     case SCDISPLAYOPT_FORMULA:
     474           4 :                         SetOption( VOPT_FORMULAS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     475           4 :                         break;
     476             :                     case SCDISPLAYOPT_ZEROVALUE:
     477           4 :                         SetOption( VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     478           4 :                         break;
     479             :                     case SCDISPLAYOPT_NOTETAG:
     480           4 :                         SetOption( VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     481           4 :                         break;
     482             :                     case SCDISPLAYOPT_VALUEHI:
     483           4 :                         SetOption( VOPT_SYNTAX, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     484           4 :                         break;
     485             :                     case SCDISPLAYOPT_ANCHOR:
     486           4 :                         SetOption( VOPT_ANCHOR, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     487           4 :                         break;
     488             :                     case SCDISPLAYOPT_TEXTOVER:
     489           4 :                         SetOption( VOPT_CLIPMARKS, ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     490           4 :                         break;
     491             :                     case SCDISPLAYOPT_OBJECTGRA:
     492           4 :                         if ( pValues[nProp] >>= nIntVal )
     493             :                         {
     494             :                             //#i80528# adapt to new range eventually
     495           4 :                             if((sal_Int32)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int32)VOBJ_MODE_SHOW;
     496             : 
     497           4 :                             SetObjMode( VOBJ_TYPE_OLE, (ScVObjMode)nIntVal);
     498             :                         }
     499           4 :                         break;
     500             :                     case SCDISPLAYOPT_CHART:
     501           4 :                         if ( pValues[nProp] >>= nIntVal )
     502             :                         {
     503             :                             //#i80528# adapt to new range eventually
     504           4 :                             if((sal_Int32)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int32)VOBJ_MODE_SHOW;
     505             : 
     506           4 :                             SetObjMode( VOBJ_TYPE_CHART, (ScVObjMode)nIntVal);
     507             :                         }
     508           4 :                         break;
     509             :                     case SCDISPLAYOPT_DRAWING:
     510           4 :                         if ( pValues[nProp] >>= nIntVal )
     511             :                         {
     512             :                             //#i80528# adapt to new range eventually
     513           4 :                             if((sal_Int32)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int32)VOBJ_MODE_SHOW;
     514             : 
     515           4 :                             SetObjMode( VOBJ_TYPE_DRAW, (ScVObjMode)nIntVal);
     516             :                         }
     517           4 :                         break;
     518             :                 }
     519             :             }
     520             :         }
     521             :     }
     522           4 :     aDisplayItem.SetCommitLink( LINK( this, ScViewCfg, DisplayCommitHdl ) );
     523             : 
     524           4 :     ScGridOptions aGrid = GetGridOptions();     //! initialization necessary?
     525           4 :     aNames = GetGridPropertyNames();
     526           4 :     aValues = aGridItem.GetProperties(aNames);
     527           4 :     aGridItem.EnableNotification(aNames);
     528           4 :     pValues = aValues.getConstArray();
     529             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     530           4 :     if(aValues.getLength() == aNames.getLength())
     531             :     {
     532          44 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     533             :         {
     534             :             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
     535          40 :             if(pValues[nProp].hasValue())
     536             :             {
     537          40 :                 switch(nProp)
     538             :                 {
     539             :                     case SCGRIDOPT_RESOLU_X:
     540           4 :                         if (pValues[nProp] >>= nIntVal) aGrid.SetFldDrawX( nIntVal );
     541           4 :                         break;
     542             :                     case SCGRIDOPT_RESOLU_Y:
     543           4 :                         if (pValues[nProp] >>= nIntVal) aGrid.SetFldDrawY( nIntVal );
     544           4 :                         break;
     545             :                     case SCGRIDOPT_SUBDIV_X:
     546           4 :                         if (pValues[nProp] >>= nIntVal) aGrid.SetFldDivisionX( nIntVal );
     547           4 :                         break;
     548             :                     case SCGRIDOPT_SUBDIV_Y:
     549           4 :                         if (pValues[nProp] >>= nIntVal) aGrid.SetFldDivisionY( nIntVal );
     550           4 :                         break;
     551             :                     case SCGRIDOPT_OPTION_X:
     552           4 :                         if (pValues[nProp] >>= nIntVal) aGrid.SetFldSnapX( nIntVal );
     553           4 :                         break;
     554             :                     case SCGRIDOPT_OPTION_Y:
     555           4 :                         if (pValues[nProp] >>= nIntVal) aGrid.SetFldSnapY( nIntVal );
     556           4 :                         break;
     557             :                     case SCGRIDOPT_SNAPTOGRID:
     558           4 :                         aGrid.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     559           4 :                         break;
     560             :                     case SCGRIDOPT_SYNCHRON:
     561           4 :                         aGrid.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     562           4 :                         break;
     563             :                     case SCGRIDOPT_VISIBLE:
     564           4 :                         aGrid.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     565           4 :                         break;
     566             :                     case SCGRIDOPT_SIZETOGRID:
     567           4 :                         aGrid.SetEqualGrid( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
     568           4 :                         break;
     569             :                 }
     570             :             }
     571             :         }
     572             :     }
     573           4 :     SetGridOptions( aGrid );
     574           4 :     aGridItem.SetCommitLink( LINK( this, ScViewCfg, GridCommitHdl ) );
     575           4 : }
     576             : 
     577           0 : IMPL_LINK_NOARG(ScViewCfg, LayoutCommitHdl)
     578             : {
     579           0 :     Sequence<OUString> aNames = GetLayoutPropertyNames();
     580           0 :     Sequence<Any> aValues(aNames.getLength());
     581           0 :     Any* pValues = aValues.getArray();
     582             : 
     583           0 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     584             :     {
     585           0 :         switch(nProp)
     586             :         {
     587             :             case SCLAYOUTOPT_GRIDCOLOR:
     588           0 :                 pValues[nProp] <<= (sal_Int32) GetGridColor().GetColor();
     589           0 :                 break;
     590             :             case SCLAYOUTOPT_GRIDLINES:
     591           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_GRID ) );
     592           0 :                 break;
     593             :             case SCLAYOUTOPT_GRID_ONCOLOR:
     594           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_GRID_ONTOP ) );
     595           0 :                 break;
     596             :             case SCLAYOUTOPT_PAGEBREAK:
     597           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_PAGEBREAKS ) );
     598           0 :                 break;
     599             :             case SCLAYOUTOPT_GUIDE:
     600           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_HELPLINES ) );
     601           0 :                 break;
     602             :             case SCLAYOUTOPT_COLROWHDR:
     603           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_HEADER ) );
     604           0 :                 break;
     605             :             case SCLAYOUTOPT_HORISCROLL:
     606           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_HSCROLL ) );
     607           0 :                 break;
     608             :             case SCLAYOUTOPT_VERTSCROLL:
     609           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_VSCROLL ) );
     610           0 :                 break;
     611             :             case SCLAYOUTOPT_SHEETTAB:
     612           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_TABCONTROLS ) );
     613           0 :                 break;
     614             :             case SCLAYOUTOPT_OUTLINE:
     615           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_OUTLINER ) );
     616           0 :                 break;
     617             :         }
     618             :     }
     619           0 :     aLayoutItem.PutProperties(aNames, aValues);
     620             : 
     621           0 :     return 0;
     622             : }
     623             : 
     624           0 : IMPL_LINK_NOARG(ScViewCfg, DisplayCommitHdl)
     625             : {
     626           0 :     Sequence<OUString> aNames = GetDisplayPropertyNames();
     627           0 :     Sequence<Any> aValues(aNames.getLength());
     628           0 :     Any* pValues = aValues.getArray();
     629             : 
     630           0 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     631             :     {
     632           0 :         switch(nProp)
     633             :         {
     634             :             case SCDISPLAYOPT_FORMULA:
     635           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_FORMULAS ) );
     636           0 :                 break;
     637             :             case SCDISPLAYOPT_ZEROVALUE:
     638           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_NULLVALS ) );
     639           0 :                 break;
     640             :             case SCDISPLAYOPT_NOTETAG:
     641           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_NOTES ) );
     642           0 :                 break;
     643             :             case SCDISPLAYOPT_VALUEHI:
     644           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_SYNTAX ) );
     645           0 :                 break;
     646             :             case SCDISPLAYOPT_ANCHOR:
     647           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_ANCHOR ) );
     648           0 :                 break;
     649             :             case SCDISPLAYOPT_TEXTOVER:
     650           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetOption( VOPT_CLIPMARKS ) );
     651           0 :                 break;
     652             :             case SCDISPLAYOPT_OBJECTGRA:
     653           0 :                 pValues[nProp] <<= (sal_Int32) GetObjMode( VOBJ_TYPE_OLE );
     654           0 :                 break;
     655             :             case SCDISPLAYOPT_CHART:
     656           0 :                 pValues[nProp] <<= (sal_Int32) GetObjMode( VOBJ_TYPE_CHART );
     657           0 :                 break;
     658             :             case SCDISPLAYOPT_DRAWING:
     659           0 :                 pValues[nProp] <<= (sal_Int32) GetObjMode( VOBJ_TYPE_DRAW );
     660           0 :                 break;
     661             :         }
     662             :     }
     663           0 :     aDisplayItem.PutProperties(aNames, aValues);
     664             : 
     665           0 :     return 0;
     666             : }
     667             : 
     668           0 : IMPL_LINK_NOARG(ScViewCfg, GridCommitHdl)
     669             : {
     670           0 :     const ScGridOptions& rGrid = GetGridOptions();
     671             : 
     672           0 :     Sequence<OUString> aNames = GetGridPropertyNames();
     673           0 :     Sequence<Any> aValues(aNames.getLength());
     674           0 :     Any* pValues = aValues.getArray();
     675             : 
     676           0 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     677             :     {
     678           0 :         switch(nProp)
     679             :         {
     680             :             case SCGRIDOPT_RESOLU_X:
     681           0 :                 pValues[nProp] <<= (sal_Int32) rGrid.GetFldDrawX();
     682           0 :                 break;
     683             :             case SCGRIDOPT_RESOLU_Y:
     684           0 :                 pValues[nProp] <<= (sal_Int32) rGrid.GetFldDrawY();
     685           0 :                 break;
     686             :             case SCGRIDOPT_SUBDIV_X:
     687           0 :                 pValues[nProp] <<= (sal_Int32) rGrid.GetFldDivisionX();
     688           0 :                 break;
     689             :             case SCGRIDOPT_SUBDIV_Y:
     690           0 :                 pValues[nProp] <<= (sal_Int32) rGrid.GetFldDivisionY();
     691           0 :                 break;
     692             :             case SCGRIDOPT_OPTION_X:
     693           0 :                 pValues[nProp] <<= (sal_Int32) rGrid.GetFldSnapX();
     694           0 :                 break;
     695             :             case SCGRIDOPT_OPTION_Y:
     696           0 :                 pValues[nProp] <<= (sal_Int32) rGrid.GetFldSnapY();
     697           0 :                 break;
     698             :             case SCGRIDOPT_SNAPTOGRID:
     699           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], rGrid.GetUseGridSnap() );
     700           0 :                 break;
     701             :             case SCGRIDOPT_SYNCHRON:
     702           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], rGrid.GetSynchronize() );
     703           0 :                 break;
     704             :             case SCGRIDOPT_VISIBLE:
     705           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], rGrid.GetGridVisible() );
     706           0 :                 break;
     707             :             case SCGRIDOPT_SIZETOGRID:
     708           0 :                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], rGrid.GetEqualGrid() );
     709           0 :                 break;
     710             :         }
     711             :     }
     712           0 :     aGridItem.PutProperties(aNames, aValues);
     713             : 
     714           0 :     return 0;
     715             : }
     716             : 
     717           0 : void ScViewCfg::SetOptions( const ScViewOptions& rNew )
     718             : {
     719           0 :     *(ScViewOptions*)this = rNew;
     720           0 :     aLayoutItem.SetModified();
     721           0 :     aDisplayItem.SetModified();
     722           0 :     aGridItem.SetModified();
     723          15 : }
     724             : 
     725             : 
     726             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10