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 <rtl/ustrbuf.hxx>
24 using namespace ::xmloff::token
;
28 struct SvXMLSignedEnumMapEntry
30 ::xmloff::token::XMLTokenEnum eToken
;
34 const SvXMLSignedEnumMapEntry aXMLChartSymbolTypeEnumMap
[] =
37 { XML_AUTOMATIC
, -2 },
39 { XML_TOKEN_INVALID
, 0 }
42 const SvXMLSignedEnumMapEntry aXMLChartSymbolNameMap
[] =
44 { XML_GRADIENTSTYLE_SQUARE
, 0 }, // "square"
46 { XML_ARROW_DOWN
, 2 },
48 { XML_ARROW_RIGHT
, 4 },
49 { XML_ARROW_LEFT
, 5 },
57 { XML_HORIZONTAL_BAR
, 13 },
58 { XML_VERTICAL_BAR
, 14 },
59 { XML_TOKEN_INVALID
, 0 }
63 OUStringBuffer
& rBuffer
,
65 const SvXMLSignedEnumMapEntry
*pMap
)
67 enum XMLTokenEnum eTok
= XML_TOKEN_INVALID
;
69 while( pMap
->eToken
!= XML_TOKEN_INVALID
)
71 if( pMap
->nValue
== nValue
)
79 if( eTok
!= XML_TOKEN_INVALID
)
80 rBuffer
.append( GetXMLToken(eTok
) );
82 return (eTok
!= XML_TOKEN_INVALID
);
87 std::u16string_view rValue
,
88 const SvXMLSignedEnumMapEntry
*pMap
)
90 while( pMap
->eToken
!= XML_TOKEN_INVALID
)
92 if( IsXMLToken( rValue
, pMap
->eToken
) )
102 } // anonymous namespace
104 using namespace com::sun::star
;
106 XMLSymbolTypePropertyHdl::XMLSymbolTypePropertyHdl( bool bIsNamedSymbol
)
107 : m_bIsNamedSymbol( bIsNamedSymbol
)
110 XMLSymbolTypePropertyHdl::~XMLSymbolTypePropertyHdl()
113 bool XMLSymbolTypePropertyHdl::importXML( const OUString
& rStrImpValue
,
114 uno::Any
& rValue
, const SvXMLUnitConverter
& /*rUnitConverter*/ ) const
116 bool bResult
= false;
118 if( m_bIsNamedSymbol
)
120 sal_Int32 nValue
= -3; // NONE
121 bResult
= lcl_convertEnum( nValue
, rStrImpValue
, aXMLChartSymbolNameMap
);
126 sal_Int32 nValue
= -3; // NONE
127 bResult
= lcl_convertEnum( nValue
, rStrImpValue
, aXMLChartSymbolTypeEnumMap
);
134 bool XMLSymbolTypePropertyHdl::exportXML( OUString
& rStrExpValue
,
135 const uno::Any
& rValue
, const SvXMLUnitConverter
& /*rUnitConverter*/ ) const
137 bool bResult
= false;
139 sal_Int32 nType
= -3; // NONE
142 if( m_bIsNamedSymbol
)
145 bResult
= lcl_convertEnum( aBuf
, nType
, aXMLChartSymbolNameMap
);
146 rStrExpValue
= aBuf
.makeStringAndClear();
153 bResult
= lcl_convertEnum( aBuf
, nType
, aXMLChartSymbolTypeEnumMap
);
154 rStrExpValue
= aBuf
.makeStringAndClear();
159 rStrExpValue
= GetXMLToken( XML_NAMED_SYMBOL
);
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */