bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / chart / XMLAxisPositionPropertyHdl.cxx
blob89e62cfc8184683caa20f7a0fc327bd382481e37
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 sal_Bool XMLAxisPositionPropertyHdl::importXML( const OUString& rStrImpValue,
45 uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
47 sal_Bool bResult = false;
49 if( rStrImpValue.equals( GetXMLToken(XML_START) ) )
51 if( !m_bCrossingValue )
53 rValue <<= ::com::sun::star::chart::ChartAxisPosition_START;
54 bResult = true;
57 else if( rStrImpValue.equals( GetXMLToken(XML_END) ) )
59 if( !m_bCrossingValue )
61 rValue <<= ::com::sun::star::chart::ChartAxisPosition_END;
62 bResult = true;
65 else
67 if( !m_bCrossingValue )
69 rValue <<= ::com::sun::star::chart::ChartAxisPosition_VALUE;
70 bResult = true;
72 else
74 double fDblValue=0.0;
75 bResult = ::sax::Converter::convertDouble(fDblValue, rStrImpValue);
76 rValue <<= fDblValue;
80 return bResult;
83 sal_Bool XMLAxisPositionPropertyHdl::exportXML( OUString& rStrExpValue,
84 const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
86 sal_Bool bResult = sal_False;
88 OUStringBuffer sValueBuffer;
89 if( m_bCrossingValue )
91 if(rStrExpValue.isEmpty())
93 double fValue = 0.0;
94 rValue >>= fValue;
95 ::sax::Converter::convertDouble( sValueBuffer, fValue );
96 rStrExpValue = sValueBuffer.makeStringAndClear();
97 bResult = true;
100 else
102 ::com::sun::star::chart::ChartAxisPosition ePosition( ::com::sun::star::chart::ChartAxisPosition_ZERO );
103 rValue >>= ePosition;
104 switch(ePosition)
106 case ::com::sun::star::chart::ChartAxisPosition_START:
107 rStrExpValue = GetXMLToken( XML_START );
108 bResult = true;
109 break;
110 case ::com::sun::star::chart::ChartAxisPosition_END:
111 rStrExpValue = GetXMLToken( XML_END );
112 bResult = true;
113 break;
114 case ::com::sun::star::chart::ChartAxisPosition_ZERO:
115 ::sax::Converter::convertDouble( sValueBuffer, 0.0 );
116 rStrExpValue = sValueBuffer.makeStringAndClear();
117 bResult = true;
118 break;
119 default:
120 break;
123 return bResult;
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */