merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / chart / XMLAxisPositionPropertyHdl.cxx
blob85687b6081c7f860887a31a01e4b1fc531d205df
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLAxisPositionPropertyHdl.cxx,v $
10 * $Revision: 1.1.2.1 $
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 "XMLAxisPositionPropertyHdl.hxx"
34 #include <xmloff/xmluconv.hxx>
35 #include <com/sun/star/chart/ChartAxisPosition.hpp>
36 #include <rtl/ustrbuf.hxx>
38 using namespace ::xmloff::token;
39 using ::rtl::OUString;
40 using ::rtl::OUStringBuffer;
42 using namespace com::sun::star;
44 XMLAxisPositionPropertyHdl::XMLAxisPositionPropertyHdl( bool bCrossingValue )
45 : m_bCrossingValue( bCrossingValue )
48 XMLAxisPositionPropertyHdl::~XMLAxisPositionPropertyHdl()
51 sal_Bool XMLAxisPositionPropertyHdl::importXML( const OUString& rStrImpValue,
52 uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
54 sal_Bool bResult = false;
56 if( rStrImpValue.equals( GetXMLToken(XML_START) ) )
58 if( !m_bCrossingValue )
60 rValue <<= ::com::sun::star::chart::ChartAxisPosition_START;
61 bResult = true;
64 else if( rStrImpValue.equals( GetXMLToken(XML_END) ) )
66 if( !m_bCrossingValue )
68 rValue <<= ::com::sun::star::chart::ChartAxisPosition_END;
69 bResult = true;
72 else
74 if( !m_bCrossingValue )
76 rValue <<= ::com::sun::star::chart::ChartAxisPosition_VALUE;
77 bResult = true;
79 else
81 double fDblValue=0.0;
82 bResult = SvXMLUnitConverter::convertDouble( fDblValue, rStrImpValue );
83 rValue <<= fDblValue;
87 return bResult;
90 sal_Bool XMLAxisPositionPropertyHdl::exportXML( OUString& rStrExpValue,
91 const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
93 sal_Bool bResult = sal_False;
95 rtl::OUStringBuffer sValueBuffer;
96 if( m_bCrossingValue )
98 if(rStrExpValue.getLength() == 0)
100 double fValue = 0.0;
101 rValue >>= fValue;
102 SvXMLUnitConverter::convertDouble( sValueBuffer, fValue );
103 rStrExpValue = sValueBuffer.makeStringAndClear();
104 bResult = true;
107 else
109 ::com::sun::star::chart::ChartAxisPosition ePosition( ::com::sun::star::chart::ChartAxisPosition_ZERO );
110 rValue >>= ePosition;
111 switch(ePosition)
113 case ::com::sun::star::chart::ChartAxisPosition_START:
114 rStrExpValue = GetXMLToken( XML_START );
115 bResult = true;
116 break;
117 case ::com::sun::star::chart::ChartAxisPosition_END:
118 rStrExpValue = GetXMLToken( XML_END );
119 bResult = true;
120 break;
121 case ::com::sun::star::chart::ChartAxisPosition_ZERO:
122 SvXMLUnitConverter::convertDouble( sValueBuffer, 0.0 );
123 rStrExpValue = sValueBuffer.makeStringAndClear();
124 bResult = true;
125 break;
126 default:
127 break;
130 return bResult;