LCOV - code coverage report
Current view: top level - xmloff/source/chart - XMLSymbolTypePropertyHdl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 18 47 38.3 %
Date: 2012-08-25 Functions: 5 7 71.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 36 16.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 "XMLSymbolTypePropertyHdl.hxx"
      30                 :            : #include <xmloff/xmluconv.hxx>
      31                 :            : #include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
      32                 :            : #include <rtl/ustrbuf.hxx>
      33                 :            : 
      34                 :            : using namespace ::xmloff::token;
      35                 :            : using ::rtl::OUString;
      36                 :            : using ::rtl::OUStringBuffer;
      37                 :            : 
      38                 :            : namespace
      39                 :            : {
      40                 :            : struct SvXMLSignedEnumMapEntry
      41                 :            : {
      42                 :            :     ::xmloff::token::XMLTokenEnum   eToken;
      43                 :            :     sal_Int32                       nValue;
      44                 :            : };
      45                 :            : 
      46                 :            : SvXMLSignedEnumMapEntry aXMLChartSymbolTypeEnumMap[] =
      47                 :            : {
      48                 :            :     { XML_NONE,                -3 },
      49                 :            :     { XML_AUTOMATIC,           -2 },
      50                 :            :     { XML_IMAGE,               -1 },
      51                 :            :     { XML_TOKEN_INVALID,        0 }
      52                 :            : };
      53                 :            : 
      54                 :            : SvXMLSignedEnumMapEntry aXMLChartSymbolNameMap[] =
      55                 :            : {
      56                 :            :     { XML_GRADIENTSTYLE_SQUARE, 0 },  // "square"
      57                 :            :     { XML_DIAMOND,              1 },
      58                 :            :     { XML_ARROW_DOWN,           2 },
      59                 :            :     { XML_ARROW_UP,             3 },
      60                 :            :     { XML_ARROW_RIGHT,          4 },
      61                 :            :     { XML_ARROW_LEFT,           5 },
      62                 :            :     { XML_BOW_TIE,              6 },
      63                 :            :     { XML_HOURGLASS,            7 },
      64                 :            :     { XML_CIRCLE,               8 },
      65                 :            :     { XML_STAR,                 9 },
      66                 :            :     { XML_X,                   10 },
      67                 :            :     { XML_PLUS,                11 },
      68                 :            :     { XML_ASTERISK,            12 },
      69                 :            :     { XML_HORIZONTAL_BAR,      13 },
      70                 :            :     { XML_VERTICAL_BAR,        14 },
      71                 :            :     { XML_TOKEN_INVALID,        0 }
      72                 :            : };
      73                 :            : 
      74                 :          0 : sal_Bool lcl_convertEnum(
      75                 :            :     OUStringBuffer & rBuffer,
      76                 :            :     sal_Int32 nValue,
      77                 :            :     const SvXMLSignedEnumMapEntry *pMap )
      78                 :            : {
      79                 :          0 :     enum XMLTokenEnum eTok = XML_TOKEN_INVALID;
      80                 :            : 
      81         [ #  # ]:          0 :     while( pMap->eToken != XML_TOKEN_INVALID )
      82                 :            :     {
      83         [ #  # ]:          0 :         if( pMap->nValue == nValue )
      84                 :            :         {
      85                 :          0 :             eTok = pMap->eToken;
      86                 :          0 :             break;
      87                 :            :         }
      88                 :          0 :         pMap++;
      89                 :            :     }
      90                 :            : 
      91         [ #  # ]:          0 :     if( eTok != XML_TOKEN_INVALID )
      92                 :          0 :         rBuffer.append( GetXMLToken(eTok) );
      93                 :            : 
      94                 :          0 :     return (eTok != XML_TOKEN_INVALID);
      95                 :            : }
      96                 :            : 
      97                 :          6 : sal_Bool lcl_convertEnum(
      98                 :            :     sal_Int32 & rEnum,
      99                 :            :     const OUString & rValue,
     100                 :            :     const SvXMLSignedEnumMapEntry *pMap )
     101                 :            : {
     102         [ +  - ]:          6 :     while( pMap->eToken != XML_TOKEN_INVALID )
     103                 :            :     {
     104         [ +  - ]:          6 :         if( IsXMLToken( rValue, pMap->eToken ) )
     105                 :            :         {
     106                 :          6 :             rEnum = pMap->nValue;
     107                 :          6 :             return sal_True;
     108                 :            :         }
     109                 :          0 :         pMap++;
     110                 :            :     }
     111                 :          6 :     return sal_False;
     112                 :            : }
     113                 :            : 
     114                 :            : } // anonymous namespace
     115                 :            : 
     116                 :            : using namespace com::sun::star;
     117                 :            : 
     118                 :         66 : XMLSymbolTypePropertyHdl::XMLSymbolTypePropertyHdl( bool bIsNamedSymbol )
     119                 :         66 :         : m_bIsNamedSymbol( bIsNamedSymbol )
     120                 :         66 : {}
     121                 :            : 
     122                 :         66 : XMLSymbolTypePropertyHdl::~XMLSymbolTypePropertyHdl()
     123         [ -  + ]:        132 : {}
     124                 :            : 
     125                 :          6 : sal_Bool XMLSymbolTypePropertyHdl::importXML( const OUString& rStrImpValue,
     126                 :            :                                                   uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
     127                 :            : {
     128                 :          6 :     sal_Bool bResult = sal_False;
     129                 :            : 
     130         [ -  + ]:          6 :     if( m_bIsNamedSymbol )
     131                 :            :     {
     132                 :          0 :         sal_Int32 nValue = -3; // NONE
     133         [ #  # ]:          0 :         bResult = lcl_convertEnum( nValue, rStrImpValue, aXMLChartSymbolNameMap );
     134         [ #  # ]:          0 :         rValue <<= nValue;
     135                 :            :     }
     136                 :            :     else
     137                 :            :     {
     138                 :          6 :         sal_Int32 nValue = -3; // NONE
     139         [ +  - ]:          6 :         bResult = lcl_convertEnum( nValue, rStrImpValue, aXMLChartSymbolTypeEnumMap );
     140         [ +  - ]:          6 :         rValue <<= nValue;
     141                 :            :     }
     142                 :            : 
     143                 :          6 :     return bResult;
     144                 :            : }
     145                 :            : 
     146                 :          0 : sal_Bool XMLSymbolTypePropertyHdl::exportXML( OUString& rStrExpValue,
     147                 :            :                                               const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
     148                 :            : {
     149                 :          0 :     sal_Bool bResult = sal_False;
     150                 :            : 
     151                 :          0 :     sal_Int32 nType = -3; // NONE
     152                 :          0 :     rValue >>= nType;
     153                 :            : 
     154         [ #  # ]:          0 :     if( m_bIsNamedSymbol )
     155                 :            :     {
     156                 :          0 :         OUStringBuffer aBuf;
     157         [ #  # ]:          0 :         bResult = lcl_convertEnum( aBuf, nType, aXMLChartSymbolNameMap );
     158         [ #  # ]:          0 :         rStrExpValue = aBuf.makeStringAndClear();
     159                 :            :     }
     160                 :            :     else
     161                 :            :     {
     162         [ #  # ]:          0 :         if( nType < 0 )
     163                 :            :         {
     164                 :          0 :             OUStringBuffer aBuf;
     165         [ #  # ]:          0 :             bResult = lcl_convertEnum( aBuf, nType, aXMLChartSymbolTypeEnumMap );
     166         [ #  # ]:          0 :             rStrExpValue = aBuf.makeStringAndClear();
     167                 :            :         }
     168                 :            :         else
     169                 :            :         {
     170                 :          0 :             bResult = true;
     171         [ #  # ]:          0 :             rStrExpValue = GetXMLToken( XML_NAMED_SYMBOL );
     172                 :            :         }
     173                 :            :     }
     174                 :            : 
     175                 :          0 :     return bResult;
     176                 :            : }
     177                 :            : 
     178                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10