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: 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
;
64 else if( rStrImpValue
.equals( GetXMLToken(XML_END
) ) )
66 if( !m_bCrossingValue
)
68 rValue
<<= ::com::sun::star::chart::ChartAxisPosition_END
;
74 if( !m_bCrossingValue
)
76 rValue
<<= ::com::sun::star::chart::ChartAxisPosition_VALUE
;
82 bResult
= SvXMLUnitConverter::convertDouble( fDblValue
, rStrImpValue
);
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)
102 SvXMLUnitConverter::convertDouble( sValueBuffer
, fValue
);
103 rStrExpValue
= sValueBuffer
.makeStringAndClear();
109 ::com::sun::star::chart::ChartAxisPosition
ePosition( ::com::sun::star::chart::ChartAxisPosition_ZERO
);
110 rValue
>>= ePosition
;
113 case ::com::sun::star::chart::ChartAxisPosition_START
:
114 rStrExpValue
= GetXMLToken( XML_START
);
117 case ::com::sun::star::chart::ChartAxisPosition_END
:
118 rStrExpValue
= GetXMLToken( XML_END
);
121 case ::com::sun::star::chart::ChartAxisPosition_ZERO
:
122 SvXMLUnitConverter::convertDouble( sValueBuffer
, 0.0 );
123 rStrExpValue
= sValueBuffer
.makeStringAndClear();