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: chrhghdl.cxx,v $
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>
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()
65 sal_Bool
XMLCharHeightHdl::importXML( const OUString
& rStrImpValue
, uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
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
;
82 sal_Bool
XMLCharHeightHdl::exportXML( OUString
& rStrExpValue
, const uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
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()
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
;
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()
148 sal_Bool
XMLCharHeightDiffHdl::importXML( const OUString
& rStrImpValue
, uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
152 if( SvXMLUnitConverter::convertMeasure( nRel
, rStrImpValue
, MAP_POINT
) )
154 rValue
<<= (float)nRel
;
161 sal_Bool
XMLCharHeightDiffHdl::exportXML( OUString
& rStrExpValue
, const uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
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;