1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLSymbolTypePropertyHdl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "XMLSymbolTypePropertyHdl.hxx"
34 #include <xmloff/xmluconv.hxx>
35 #include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
36 #include <rtl/ustrbuf.hxx>
38 using namespace ::xmloff::token
;
39 using ::rtl::OUString
;
40 using ::rtl::OUStringBuffer
;
44 struct SvXMLSignedEnumMapEntry
46 ::xmloff::token::XMLTokenEnum eToken
;
50 SvXMLSignedEnumMapEntry aXMLChartSymbolTypeEnumMap
[] =
53 { XML_AUTOMATIC
, -2 },
55 { XML_TOKEN_INVALID
, 0 }
58 SvXMLSignedEnumMapEntry aXMLChartSymbolNameMap
[] =
60 { XML_GRADIENTSTYLE_SQUARE
, 0 }, // "square"
62 { XML_ARROW_DOWN
, 2 },
64 { XML_ARROW_RIGHT
, 4 },
65 { XML_ARROW_LEFT
, 5 },
68 { XML_TOKEN_INVALID
, 0 }
71 sal_Bool
lcl_convertEnum(
72 OUStringBuffer
& rBuffer
,
74 const SvXMLSignedEnumMapEntry
*pMap
)
76 enum XMLTokenEnum eTok
= XML_TOKEN_INVALID
;
78 while( pMap
->eToken
!= XML_TOKEN_INVALID
)
80 if( pMap
->nValue
== nValue
)
88 if( eTok
!= XML_TOKEN_INVALID
)
89 rBuffer
.append( GetXMLToken(eTok
) );
91 return (eTok
!= XML_TOKEN_INVALID
);
94 sal_Bool
lcl_convertEnum(
96 const OUString
& rValue
,
97 const SvXMLSignedEnumMapEntry
*pMap
)
99 while( pMap
->eToken
!= XML_TOKEN_INVALID
)
101 if( IsXMLToken( rValue
, pMap
->eToken
) )
103 rEnum
= pMap
->nValue
;
111 } // anonymous namespace
113 using namespace com::sun::star
;
115 XMLSymbolTypePropertyHdl::XMLSymbolTypePropertyHdl( bool bIsNamedSymbol
)
116 : m_bIsNamedSymbol( bIsNamedSymbol
)
119 XMLSymbolTypePropertyHdl::~XMLSymbolTypePropertyHdl()
122 sal_Bool
XMLSymbolTypePropertyHdl::importXML( const OUString
& rStrImpValue
,
123 uno::Any
& rValue
, const SvXMLUnitConverter
& /*rUnitConverter*/ ) const
125 sal_Bool bResult
= sal_False
;
127 if( m_bIsNamedSymbol
)
129 sal_Int32 nValue
= -3; // NONE
130 bResult
= lcl_convertEnum( nValue
, rStrImpValue
, aXMLChartSymbolNameMap
);
135 sal_Int32 nValue
= -3; // NONE
136 bResult
= lcl_convertEnum( nValue
, rStrImpValue
, aXMLChartSymbolTypeEnumMap
);
143 sal_Bool
XMLSymbolTypePropertyHdl::exportXML( OUString
& rStrExpValue
,
144 const uno::Any
& rValue
, const SvXMLUnitConverter
& /*rUnitConverter*/ ) const
146 sal_Bool bResult
= sal_False
;
148 sal_Int32 nType
= -3; // NONE
151 if( m_bIsNamedSymbol
)
154 bResult
= lcl_convertEnum( aBuf
, nType
, aXMLChartSymbolNameMap
);
155 rStrExpValue
= aBuf
.makeStringAndClear();
162 bResult
= lcl_convertEnum( aBuf
, nType
, aXMLChartSymbolTypeEnumMap
);
163 rStrExpValue
= aBuf
.makeStringAndClear();
168 rStrExpValue
= GetXMLToken( XML_NAMED_SYMBOL
);