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 .
21 #include "XMLAxisPositionPropertyHdl.hxx"
23 #include <rtl/ustrbuf.hxx>
25 #include <com/sun/star/uno/Any.hxx>
26 #include <com/sun/star/chart/ChartAxisPosition.hpp>
28 #include <sax/tools/converter.hxx>
30 #include <xmloff/xmltoken.hxx>
33 using namespace ::xmloff::token
;
35 using namespace com::sun::star
;
37 XMLAxisPositionPropertyHdl::XMLAxisPositionPropertyHdl( bool bCrossingValue
)
38 : m_bCrossingValue( bCrossingValue
)
41 XMLAxisPositionPropertyHdl::~XMLAxisPositionPropertyHdl()
44 bool XMLAxisPositionPropertyHdl::importXML( const OUString
& rStrImpValue
,
45 uno::Any
& rValue
, const SvXMLUnitConverter
& /*rUnitConverter*/ ) const
49 if( rStrImpValue
.equals( GetXMLToken(XML_START
) ) )
51 if( !m_bCrossingValue
)
53 rValue
<<= css::chart::ChartAxisPosition_START
;
57 else if( rStrImpValue
.equals( GetXMLToken(XML_END
) ) )
59 if( !m_bCrossingValue
)
61 rValue
<<= css::chart::ChartAxisPosition_END
;
65 else if( rStrImpValue
.equals( GetXMLToken(XML_0
) ) )
67 if( !m_bCrossingValue
)
69 rValue
<<= css::chart::ChartAxisPosition_ZERO
;
75 if( !m_bCrossingValue
)
77 rValue
<<= css::chart::ChartAxisPosition_VALUE
;
83 bResult
= ::sax::Converter::convertDouble(fDblValue
, rStrImpValue
);
91 bool XMLAxisPositionPropertyHdl::exportXML( OUString
& rStrExpValue
,
92 const uno::Any
& rValue
, const SvXMLUnitConverter
& /*rUnitConverter*/ ) const
96 OUStringBuffer sValueBuffer
;
97 if( m_bCrossingValue
)
99 if(rStrExpValue
.isEmpty())
103 ::sax::Converter::convertDouble( sValueBuffer
, fValue
);
104 rStrExpValue
= sValueBuffer
.makeStringAndClear();
110 css::chart::ChartAxisPosition
ePosition( css::chart::ChartAxisPosition_ZERO
);
111 rValue
>>= ePosition
;
114 case css::chart::ChartAxisPosition_START
:
115 rStrExpValue
= GetXMLToken( XML_START
);
118 case css::chart::ChartAxisPosition_END
:
119 rStrExpValue
= GetXMLToken( XML_END
);
122 case css::chart::ChartAxisPosition_ZERO
:
123 ::sax::Converter::convertDouble( sValueBuffer
, 0.0 );
124 rStrExpValue
= sValueBuffer
.makeStringAndClear();
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */