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

Generated by: LCOV version 1.10