LCOV - code coverage report
Current view: top level - sw/source/ui/config - barcfg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 35 52 67.3 %
Date: 2012-08-25 Functions: 6 8 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 22 54 40.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <osl/diagnose.h>
      30                 :            : #include <com/sun/star/uno/Any.hxx>
      31                 :            : #include <com/sun/star/uno/Sequence.hxx>
      32                 :            : #include <wrtsh.hxx>
      33                 :            : #include "barcfg.hxx"
      34                 :            : 
      35                 :            : #include <unomid.h>
      36                 :            : 
      37                 :            : using namespace utl;
      38                 :            : using rtl::OUString;
      39                 :            : using namespace com::sun::star::uno;
      40                 :            : 
      41                 :            : #define SEL_TYPE_TABLE_TEXT     0
      42                 :            : #define SEL_TYPE_LIST_TEXT      1
      43                 :            : #define SEL_TYPE_TABLE_LIST     2
      44                 :            : #define SEL_TYPE_BEZIER         3
      45                 :            : #define SEL_TYPE_GRAPHIC        4
      46                 :            : 
      47                 :        146 : SwToolbarConfigItem::SwToolbarConfigItem( sal_Bool bWeb ) :
      48                 :            :     ConfigItem(bWeb ? C2U("Office.WriterWeb/ObjectBar") :  C2U("Office.Writer/ObjectBar"),
      49 [ +  + ][ +  - ]:        146 :         CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE)
      50                 :            : {
      51         [ +  + ]:        876 :     for(sal_uInt16 i = 0; i <= SEL_TYPE_GRAPHIC; i++ )
      52                 :        730 :         aTbxIdArray[i] = -1;
      53                 :            : 
      54         [ +  - ]:        146 :     Sequence<OUString> aNames = GetPropertyNames();
      55         [ +  - ]:        146 :     Sequence<Any> aValues = GetProperties(aNames);
      56                 :        146 :     const Any* pValues = aValues.getConstArray();
      57                 :            :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
      58         [ +  - ]:        146 :     if(aValues.getLength() == aNames.getLength())
      59                 :            :     {
      60         [ +  + ]:        876 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
      61                 :            :         {
      62         [ +  - ]:        730 :             if(pValues[nProp].hasValue())
      63                 :            :             {
      64                 :        730 :                 sal_Int32 nVal = 0;
      65                 :        730 :                 pValues[nProp] >>= nVal;
      66                 :        730 :                 aTbxIdArray[nProp] = nVal;
      67                 :            :             }
      68                 :            :         }
      69 [ +  - ][ +  - ]:        146 :     }
      70                 :        146 : }
      71                 :            : 
      72                 :         80 : SwToolbarConfigItem::~SwToolbarConfigItem()
      73                 :            : {
      74         [ -  + ]:        160 : }
      75                 :            : 
      76                 :          4 : sal_Int32 lcl_getArrayIndex(int nSelType)
      77                 :            : {
      78                 :          4 :     sal_Int32 nRet = -1;
      79         [ -  + ]:          4 :     if(nSelType & nsSelectionType::SEL_NUM)
      80                 :            :     {
      81         [ #  # ]:          0 :         if(nSelType & nsSelectionType::SEL_TBL)
      82                 :          0 :             nRet = SEL_TYPE_TABLE_LIST;
      83                 :            :         else
      84                 :          0 :             nRet = SEL_TYPE_LIST_TEXT;
      85                 :            :     }
      86         [ -  + ]:          4 :     else if(nSelType & nsSelectionType::SEL_TBL)
      87                 :          0 :         nRet = SEL_TYPE_TABLE_TEXT;
      88         [ -  + ]:          4 :     else if(nSelType & nsSelectionType::SEL_BEZ)
      89                 :          0 :         nRet = SEL_TYPE_BEZIER;
      90         [ -  + ]:          4 :     else if(nSelType & nsSelectionType::SEL_GRF)
      91                 :          0 :         nRet = SEL_TYPE_GRAPHIC;
      92                 :          4 :     return nRet;
      93                 :            : }
      94                 :            : 
      95                 :          4 : void SwToolbarConfigItem::SetTopToolbar( sal_Int32 nSelType, sal_Int32 nBarId )
      96                 :            : {
      97                 :          4 :     sal_Int32 nProp = lcl_getArrayIndex(nSelType);
      98         [ -  + ]:          4 :     if(nProp >= 0)
      99                 :            :     {
     100                 :          0 :         aTbxIdArray[nProp] = nBarId;
     101                 :          0 :         SetModified();
     102                 :            :     }
     103                 :          4 : }
     104                 :            : 
     105                 :        146 : Sequence<OUString> SwToolbarConfigItem::GetPropertyNames()
     106                 :            : {
     107                 :            :     static const char* aPropNames[] =
     108                 :            :     {
     109                 :            :         "Selection/Table",                   //  SEL_TYPE_TABLE_TEXT
     110                 :            :         "Selection/NumberedList",            //  SEL_TYPE_LIST_TEXT
     111                 :            :         "Selection/NumberedList_InTable",     //  SEL_TYPE_TABLE_LIST
     112                 :            :         "Selection/BezierObject",           //  SEL_TYPE_BEZIER
     113                 :            :         "Selection/Graphic"                 //SEL_TYPE_GRAPHIC
     114                 :            :     };
     115                 :        146 :     const int nCount = 5;
     116                 :        146 :     Sequence<OUString> aNames(nCount);
     117         [ +  - ]:        146 :     OUString* pNames = aNames.getArray();
     118         [ +  + ]:        876 :     for(int i = 0; i < nCount; i++)
     119                 :        730 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     120                 :        146 :     return aNames;
     121                 :            : }
     122                 :            : 
     123                 :          0 : void SwToolbarConfigItem::Commit()
     124                 :            : {
     125         [ #  # ]:          0 :     Sequence<OUString> aNames = GetPropertyNames();
     126                 :            : 
     127         [ #  # ]:          0 :     Sequence<Any> aValues(aNames.getLength());
     128         [ #  # ]:          0 :     Any* pValues = aValues.getArray();
     129                 :            : 
     130         [ #  # ]:          0 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     131         [ #  # ]:          0 :         pValues[nProp] <<= aTbxIdArray[nProp];
     132 [ #  # ][ #  # ]:          0 :     PutProperties(aNames, aValues);
                 [ #  # ]
     133                 :          0 : }
     134                 :            : 
     135                 :          0 : void SwToolbarConfigItem::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
     136                 :            : 
     137                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10