Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <chrhghdl.hxx>
31 : :
32 : : #include <rtl/ustrbuf.hxx>
33 : :
34 : : #include <com/sun/star/uno/Any.hxx>
35 : :
36 : : #include <sax/tools/converter.hxx>
37 : :
38 : : #include <xmloff/xmluconv.hxx>
39 : :
40 : : using ::rtl::OUString;
41 : : using ::rtl::OUStringBuffer;
42 : :
43 : : using namespace ::com::sun::star;
44 : :
45 : : // this is a copy of defines in svx/inc/escpitem.hxx
46 : : #define DFLT_ESC_PROP 58
47 : : #define DFLT_ESC_AUTO_SUPER 101
48 : : #define DFLT_ESC_AUTO_SUB -101
49 : :
50 : : ///////////////////////////////////////////////////////////////////////////////
51 : : //
52 : : // class XMLEscapementPropHdl
53 : : //
54 : :
55 : 2328 : XMLCharHeightHdl::~XMLCharHeightHdl()
56 : : {
57 : : // nothing to do
58 [ - + ]: 4656 : }
59 : :
60 : 2699 : sal_Bool XMLCharHeightHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
61 : : {
62 [ + - ]: 2699 : if( rStrImpValue.indexOf( sal_Unicode('%') ) == -1 )
63 : : {
64 : : double fSize;
65 : : sal_Int16 const eSrcUnit = ::sax::Converter::GetUnitFromString(
66 [ + - ]: 2699 : rStrImpValue, util::MeasureUnit::POINT );
67 [ + - ][ + - ]: 2699 : if (::sax::Converter::convertDouble(fSize, rStrImpValue,
68 : 2699 : eSrcUnit, util::MeasureUnit::POINT))
69 : : {
70 [ + - ]: 2699 : rValue <<= (float)fSize;
71 : 2699 : return sal_True;
72 : : }
73 : : }
74 : :
75 : 2699 : return sal_False;
76 : : }
77 : :
78 : 903 : sal_Bool XMLCharHeightHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
79 : : {
80 : 903 : OUStringBuffer aOut;
81 : :
82 : 903 : float fSize = 0;
83 [ + - ]: 903 : if( rValue >>= fSize )
84 : : {
85 : : ::sax::Converter::convertDouble(aOut, (double)fSize, true,
86 [ + - ]: 903 : util::MeasureUnit::POINT, util::MeasureUnit::POINT);
87 [ + - ]: 903 : aOut.append( sal_Unicode('p'));
88 [ + - ]: 903 : aOut.append( sal_Unicode('t'));
89 : : }
90 : :
91 [ + - ]: 903 : rStrExpValue = aOut.makeStringAndClear();
92 : 903 : return !rStrExpValue.isEmpty();
93 : : }
94 : :
95 : : ///////////////////////////////////////////////////////////////////////////////
96 : : //
97 : : // class XMLEscapementHeightPropHdl
98 : : //
99 : :
100 : 2285 : XMLCharHeightPropHdl::~XMLCharHeightPropHdl()
101 : : {
102 : : // nothing to do
103 [ - + ]: 4570 : }
104 : :
105 : 2699 : sal_Bool XMLCharHeightPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
106 : : {
107 [ - + ]: 2699 : if( rStrImpValue.indexOf( sal_Unicode('%') ) != -1 )
108 : : {
109 : 0 : sal_Int32 nPrc = 100;
110 [ # # ][ # # ]: 0 : if (::sax::Converter::convertPercent( nPrc, rStrImpValue ))
111 : : {
112 [ # # ]: 0 : rValue <<= (sal_Int16)nPrc;
113 : 0 : return sal_True;
114 : : }
115 : : }
116 : :
117 : 2699 : return sal_False;
118 : : }
119 : :
120 : 0 : sal_Bool XMLCharHeightPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
121 : : {
122 [ # # ]: 0 : OUStringBuffer aOut( rStrExpValue );
123 : :
124 : 0 : sal_Int16 nValue = sal_Int16();
125 [ # # ]: 0 : if( rValue >>= nValue )
126 : : {
127 [ # # ]: 0 : ::sax::Converter::convertPercent( aOut, nValue );
128 : : }
129 : :
130 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
131 : 0 : return !rStrExpValue.isEmpty();
132 : : }
133 : :
134 : : ///////////////////////////////////////////////////////////////////////////////
135 : : //
136 : : // class XMLEscapementPropHdl
137 : : //
138 : :
139 : 2285 : XMLCharHeightDiffHdl::~XMLCharHeightDiffHdl()
140 : : {
141 : : // nothing to do
142 [ - + ]: 4570 : }
143 : :
144 : 0 : sal_Bool XMLCharHeightDiffHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
145 : : {
146 : 0 : sal_Int32 nRel = 0;
147 : :
148 [ # # ][ # # ]: 0 : if (::sax::Converter::convertMeasure( nRel, rStrImpValue,
149 : : util::MeasureUnit::POINT ))
150 : : {
151 [ # # ]: 0 : rValue <<= (float)nRel;
152 : 0 : return sal_True;
153 : : }
154 : :
155 : 0 : return sal_False;
156 : : }
157 : :
158 : 0 : sal_Bool XMLCharHeightDiffHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
159 : : {
160 : 0 : OUStringBuffer aOut;
161 : :
162 : 0 : float nRel = 0;
163 [ # # ][ # # ]: 0 : if( (rValue >>= nRel) && (nRel != 0) )
[ # # ]
164 : : {
165 : : ::sax::Converter::convertMeasure( aOut, static_cast<sal_Int32>(nRel),
166 [ # # ]: 0 : util::MeasureUnit::POINT, util::MeasureUnit::POINT );
167 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
168 : : }
169 : :
170 : 0 : return !rStrExpValue.isEmpty();
171 : : }
172 : :
173 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|