Update ooo320-m1
[ooovba.git] / xmloff / source / style / chrhghdl.cxx
blob7ea4605e155067de6c1941b72c914721f2997246
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: chrhghdl.cxx,v $
10 * $Revision: 1.12 $
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"
35 #include <chrhghdl.hxx>
36 #include <xmloff/xmluconv.hxx>
37 #include "xmlehelp.hxx"
38 #include <rtl/ustrbuf.hxx>
39 #include <com/sun/star/uno/Any.hxx>
41 #ifndef _XMLOFF_XMLEMENT_HXX
42 #include <xmloff/xmlelement.hxx>
43 #endif
45 using ::rtl::OUString;
46 using ::rtl::OUStringBuffer;
48 using namespace ::com::sun::star;
50 // this is a copy of defines in svx/inc/escpitem.hxx
51 #define DFLT_ESC_PROP 58
52 #define DFLT_ESC_AUTO_SUPER 101
53 #define DFLT_ESC_AUTO_SUB -101
55 ///////////////////////////////////////////////////////////////////////////////
57 // class XMLEscapementPropHdl
60 XMLCharHeightHdl::~XMLCharHeightHdl()
62 // nothing to do
65 sal_Bool XMLCharHeightHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
67 double fSize;
69 if( rStrImpValue.indexOf( sal_Unicode('%') ) == -1 )
71 MapUnit eSrcUnit = SvXMLExportHelper::GetUnitFromString( rStrImpValue, MAP_POINT );
72 if( SvXMLUnitConverter::convertDouble( fSize, rStrImpValue, eSrcUnit, MAP_POINT ))
74 rValue <<= (float)fSize;
75 return sal_True;
79 return sal_False;
82 sal_Bool XMLCharHeightHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
84 OUStringBuffer aOut;
86 float fSize = 0;
87 if( rValue >>= fSize )
89 SvXMLUnitConverter::convertDouble( aOut, (double)fSize, TRUE, MAP_POINT, MAP_POINT );
90 aOut.append( sal_Unicode('p'));
91 aOut.append( sal_Unicode('t'));
94 rStrExpValue = aOut.makeStringAndClear();
95 return rStrExpValue.getLength() != 0;
98 ///////////////////////////////////////////////////////////////////////////////
100 // class XMLEscapementHeightPropHdl
103 XMLCharHeightPropHdl::~XMLCharHeightPropHdl()
105 // nothing to do
108 sal_Bool XMLCharHeightPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
110 sal_Int32 nPrc = 100;
112 if( rStrImpValue.indexOf( sal_Unicode('%') ) != -1 )
114 if( SvXMLUnitConverter::convertPercent( nPrc, rStrImpValue ) )
116 rValue <<= (sal_Int16)nPrc;
117 return sal_True;
121 return sal_False;
124 sal_Bool XMLCharHeightPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
126 OUStringBuffer aOut( rStrExpValue );
128 sal_Int16 nValue = sal_Int16();
129 if( rValue >>= nValue )
131 SvXMLUnitConverter::convertPercent( aOut, nValue );
134 rStrExpValue = aOut.makeStringAndClear();
135 return rStrExpValue.getLength() != 0;
138 ///////////////////////////////////////////////////////////////////////////////
140 // class XMLEscapementPropHdl
143 XMLCharHeightDiffHdl::~XMLCharHeightDiffHdl()
145 // nothing to do
148 sal_Bool XMLCharHeightDiffHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
150 sal_Int32 nRel = 0;
152 if( SvXMLUnitConverter::convertMeasure( nRel, rStrImpValue, MAP_POINT ) )
154 rValue <<= (float)nRel;
155 return sal_True;
158 return sal_False;
161 sal_Bool XMLCharHeightDiffHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
163 OUStringBuffer aOut;
165 float nRel = 0;
166 if( (rValue >>= nRel) && (nRel != 0) )
168 SvXMLUnitConverter::convertMeasure( aOut, (sal_Int32)nRel, MAP_POINT, MAP_POINT );
169 rStrExpValue = aOut.makeStringAndClear();
172 return rStrExpValue.getLength() != 0;