1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "XMLSymbolTypePropertyHdl.hxx"
21 #include <xmloff/xmluconv.hxx>
22 #include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
23 #include <rtl/ustrbuf.hxx>
25 using namespace ::xmloff::token
;
29 struct SvXMLSignedEnumMapEntry
31 ::xmloff::token::XMLTokenEnum eToken
;
35 const SvXMLSignedEnumMapEntry aXMLChartSymbolTypeEnumMap
[] =
38 { XML_AUTOMATIC
, -2 },
40 { XML_TOKEN_INVALID
, 0 }
43 const SvXMLSignedEnumMapEntry aXMLChartSymbolNameMap
[] =
45 { XML_GRADIENTSTYLE_SQUARE
, 0 }, // "square"
47 { XML_ARROW_DOWN
, 2 },
49 { XML_ARROW_RIGHT
, 4 },
50 { XML_ARROW_LEFT
, 5 },
58 { XML_HORIZONTAL_BAR
, 13 },
59 { XML_VERTICAL_BAR
, 14 },
60 { XML_TOKEN_INVALID
, 0 }
64 OUStringBuffer
& rBuffer
,
66 const SvXMLSignedEnumMapEntry
*pMap
)
68 enum XMLTokenEnum eTok
= XML_TOKEN_INVALID
;
70 while( pMap
->eToken
!= XML_TOKEN_INVALID
)
72 if( pMap
->nValue
== nValue
)
80 if( eTok
!= XML_TOKEN_INVALID
)
81 rBuffer
.append( GetXMLToken(eTok
) );
83 return (eTok
!= XML_TOKEN_INVALID
);
88 const OUString
& rValue
,
89 const SvXMLSignedEnumMapEntry
*pMap
)
91 while( pMap
->eToken
!= XML_TOKEN_INVALID
)
93 if( IsXMLToken( rValue
, pMap
->eToken
) )
103 } // anonymous namespace
105 using namespace com::sun::star
;
107 XMLSymbolTypePropertyHdl::XMLSymbolTypePropertyHdl( bool bIsNamedSymbol
)
108 : m_bIsNamedSymbol( bIsNamedSymbol
)
111 XMLSymbolTypePropertyHdl::~XMLSymbolTypePropertyHdl()
114 bool XMLSymbolTypePropertyHdl::importXML( const OUString
& rStrImpValue
,
115 uno::Any
& rValue
, const SvXMLUnitConverter
& /*rUnitConverter*/ ) const
117 bool bResult
= false;
119 if( m_bIsNamedSymbol
)
121 sal_Int32 nValue
= -3; // NONE
122 bResult
= lcl_convertEnum( nValue
, rStrImpValue
, aXMLChartSymbolNameMap
);
127 sal_Int32 nValue
= -3; // NONE
128 bResult
= lcl_convertEnum( nValue
, rStrImpValue
, aXMLChartSymbolTypeEnumMap
);
135 bool XMLSymbolTypePropertyHdl::exportXML( OUString
& rStrExpValue
,
136 const uno::Any
& rValue
, const SvXMLUnitConverter
& /*rUnitConverter*/ ) const
138 bool bResult
= false;
140 sal_Int32 nType
= -3; // NONE
143 if( m_bIsNamedSymbol
)
146 bResult
= lcl_convertEnum( aBuf
, nType
, aXMLChartSymbolNameMap
);
147 rStrExpValue
= aBuf
.makeStringAndClear();
154 bResult
= lcl_convertEnum( aBuf
, nType
, aXMLChartSymbolTypeEnumMap
);
155 rStrExpValue
= aBuf
.makeStringAndClear();
160 rStrExpValue
= GetXMLToken( XML_NAMED_SYMBOL
);
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */