1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_xmloff.hxx" 30 #include "XMLAxisPositionPropertyHdl.hxx" 31 #include <xmloff/xmluconv.hxx> 32 #include <com/sun/star/chart/ChartAxisPosition.hpp> 33 #include <rtl/ustrbuf.hxx> 34 35 using namespace ::xmloff::token; 36 using ::rtl::OUString; 37 using ::rtl::OUStringBuffer; 38 39 using namespace com::sun::star; 40 41 XMLAxisPositionPropertyHdl::XMLAxisPositionPropertyHdl( bool bCrossingValue ) 42 : m_bCrossingValue( bCrossingValue ) 43 {} 44 45 XMLAxisPositionPropertyHdl::~XMLAxisPositionPropertyHdl() 46 {} 47 48 sal_Bool XMLAxisPositionPropertyHdl::importXML( const OUString& rStrImpValue, 49 uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const 50 { 51 sal_Bool bResult = false; 52 53 if( rStrImpValue.equals( GetXMLToken(XML_START) ) ) 54 { 55 if( !m_bCrossingValue ) 56 { 57 rValue <<= ::com::sun::star::chart::ChartAxisPosition_START; 58 bResult = true; 59 } 60 } 61 else if( rStrImpValue.equals( GetXMLToken(XML_END) ) ) 62 { 63 if( !m_bCrossingValue ) 64 { 65 rValue <<= ::com::sun::star::chart::ChartAxisPosition_END; 66 bResult = true; 67 } 68 } 69 else 70 { 71 if( !m_bCrossingValue ) 72 { 73 rValue <<= ::com::sun::star::chart::ChartAxisPosition_VALUE; 74 bResult = true; 75 } 76 else 77 { 78 double fDblValue=0.0; 79 bResult = SvXMLUnitConverter::convertDouble( fDblValue, rStrImpValue ); 80 rValue <<= fDblValue; 81 } 82 } 83 84 return bResult; 85 } 86 87 sal_Bool XMLAxisPositionPropertyHdl::exportXML( OUString& rStrExpValue, 88 const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const 89 { 90 sal_Bool bResult = sal_False; 91 92 rtl::OUStringBuffer sValueBuffer; 93 if( m_bCrossingValue ) 94 { 95 if(rStrExpValue.getLength() == 0) 96 { 97 double fValue = 0.0; 98 rValue >>= fValue; 99 SvXMLUnitConverter::convertDouble( sValueBuffer, fValue ); 100 rStrExpValue = sValueBuffer.makeStringAndClear(); 101 bResult = true; 102 } 103 } 104 else 105 { 106 ::com::sun::star::chart::ChartAxisPosition ePosition( ::com::sun::star::chart::ChartAxisPosition_ZERO ); 107 rValue >>= ePosition; 108 switch(ePosition) 109 { 110 case ::com::sun::star::chart::ChartAxisPosition_START: 111 rStrExpValue = GetXMLToken( XML_START ); 112 bResult = true; 113 break; 114 case ::com::sun::star::chart::ChartAxisPosition_END: 115 rStrExpValue = GetXMLToken( XML_END ); 116 bResult = true; 117 break; 118 case ::com::sun::star::chart::ChartAxisPosition_ZERO: 119 SvXMLUnitConverter::convertDouble( sValueBuffer, 0.0 ); 120 rStrExpValue = sValueBuffer.makeStringAndClear(); 121 bResult = true; 122 break; 123 default: 124 break; 125 } 126 } 127 return bResult; 128 } 129