LCOV - code coverage report
Current view: top level - sw/source/uibase/utlui - navicfg.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 27 44 61.4 %
Date: 2014-11-03 Functions: 4 6 66.7 %
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 <swtypes.hxx>
      21             : #include <navicfg.hxx>
      22             : #include <swcont.hxx>
      23             : #include <osl/diagnose.h>
      24             : #include <com/sun/star/uno/Any.hxx>
      25             : #include <com/sun/star/uno/Sequence.hxx>
      26             : 
      27             : #include <unomid.h>
      28             : 
      29             : using namespace ::utl;
      30             : using namespace ::com::sun::star::uno;
      31             : 
      32           4 : Sequence<OUString> SwNavigationConfig::GetPropertyNames()
      33             : {
      34             :     static const char* aPropNames[] =
      35             :     {
      36             :         "RootType",             //0
      37             :         "SelectedPosition",     //1
      38             :         "OutlineLevel",         //2
      39             :         "InsertMode",           //3
      40             :         "ActiveBlock",          //4
      41             :         "ShowListBox",          //5
      42             :         "GlobalDocMode"         //6
      43             :     };
      44           4 :     const int nCount = 7;
      45           4 :     Sequence<OUString> aNames(nCount);
      46           4 :     OUString* pNames = aNames.getArray();
      47          32 :     for(int i = 0; i < nCount; i++)
      48             :     {
      49          28 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
      50             :     }
      51           4 :     return aNames;
      52             : }
      53             : 
      54           4 : SwNavigationConfig::SwNavigationConfig() :
      55             :     utl::ConfigItem("Office.Writer/Navigator"),
      56             :     nRootType(0xffff),
      57             :     nSelectedPos(0),
      58             :     nOutlineLevel(MAXLEVEL),
      59             :     nRegionMode(REGION_MODE_NONE),
      60             :     nActiveBlock(0),
      61             :     bIsSmall(false),
      62           4 :     bIsGlobalActive(true)
      63             : {
      64           4 :     Sequence<OUString> aNames = GetPropertyNames();
      65           8 :     Sequence<Any> aValues = GetProperties(aNames);
      66           4 :     const Any* pValues = aValues.getConstArray();
      67             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
      68           4 :     if(aValues.getLength() == aNames.getLength())
      69             :     {
      70          32 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
      71             :         {
      72          28 :             if(pValues[nProp].hasValue())
      73             :             {
      74          28 :                 switch(nProp)
      75             :                 {
      76           4 :                     case 0: pValues[nProp] >>= nRootType;      break;
      77           4 :                     case 1: pValues[nProp] >>= nSelectedPos;   break;
      78           4 :                     case 2: pValues[nProp] >>= nOutlineLevel;  break;
      79           4 :                     case 3: pValues[nProp] >>= nRegionMode;    break;
      80           4 :                     case 4: pValues[nProp] >>= nActiveBlock;    break;
      81           4 :                     case 5: bIsSmall        = *(sal_Bool*)pValues[nProp].getValue();  break;
      82           4 :                     case 6: bIsGlobalActive = *(sal_Bool*)pValues[nProp].getValue();  break;
      83             :                 }
      84             :             }
      85             :         }
      86           4 :     }
      87           4 : }
      88             : 
      89           8 : SwNavigationConfig::~SwNavigationConfig()
      90             : {
      91           8 : }
      92             : 
      93           0 : void SwNavigationConfig::Commit()
      94             : {
      95           0 :     Sequence<OUString> aNames = GetPropertyNames();
      96           0 :     Sequence<Any> aValues(aNames.getLength());
      97           0 :     Any* pValues = aValues.getArray();
      98           0 :     const Type& rType = ::getBooleanCppuType();
      99             : 
     100           0 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     101             :     {
     102           0 :         switch(nProp)
     103             :         {
     104           0 :             case 0: pValues[nProp] <<= nRootType;     break;
     105           0 :             case 1: pValues[nProp] <<= nSelectedPos;  break;
     106           0 :             case 2: pValues[nProp] <<= nOutlineLevel; break;
     107           0 :             case 3: pValues[nProp] <<= nRegionMode;   break;
     108           0 :             case 4: pValues[nProp] <<= nActiveBlock;    break;
     109           0 :             case 5: pValues[nProp].setValue(&bIsSmall, rType);          break;
     110           0 :             case 6: pValues[nProp].setValue(&bIsGlobalActive, rType);   break;
     111             :         }
     112             :     }
     113           0 :     PutProperties(aNames, aValues);
     114           0 : }
     115             : 
     116           0 : void SwNavigationConfig::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
     117             : 
     118             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10