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 : : #include <rtl/ustrbuf.hxx>
30 : : #include "propimp0.hxx"
31 : : #include <com/sun/star/drawing/LineDash.hpp>
32 : : #include <com/sun/star/util/Duration.hpp>
33 : : #include <com/sun/star/uno/Any.hxx>
34 : :
35 : : #include <sax/tools/converter.hxx>
36 : :
37 : : #include <xmloff/xmluconv.hxx>
38 : : #include <xmloff/xmlimp.hxx>
39 : :
40 : : using ::rtl::OUString;
41 : : using ::rtl::OUStringBuffer;
42 : :
43 : : using namespace ::com::sun::star;
44 : :
45 : : //////////////////////////////////////////////////////////////////////////////
46 : : // implementation of graphic property Stroke
47 : :
48 : :
49 : : //////////////////////////////////////////////////////////////////////////////
50 : : // implementation of presentation page property Change
51 : :
52 : : //////////////////////////////////////////////////////////////////////////////
53 : : // implementation of an effect duration property handler
54 : :
55 : :
56 : 436 : XMLDurationPropertyHdl::~XMLDurationPropertyHdl()
57 : : {
58 [ - + ]: 872 : }
59 : :
60 : 0 : sal_Bool XMLDurationPropertyHdl::importXML(
61 : : const OUString& rStrImpValue,
62 : : ::com::sun::star::uno::Any& rValue,
63 : : const SvXMLUnitConverter& ) const
64 : : {
65 : 0 : util::Duration aDuration;
66 [ # # ]: 0 : ::sax::Converter::convertDuration(aDuration, rStrImpValue);
67 : :
68 : : const sal_Int32 nSeconds = ((aDuration.Days * 24 + aDuration.Hours) * 60
69 : 0 : + aDuration.Minutes) * 60 + aDuration.Seconds;
70 [ # # ]: 0 : rValue <<= nSeconds;
71 : :
72 : 0 : return sal_True;
73 : : }
74 : :
75 : 0 : sal_Bool XMLDurationPropertyHdl::exportXML(
76 : : OUString& rStrExpValue,
77 : : const ::com::sun::star::uno::Any& rValue,
78 : : const SvXMLUnitConverter& ) const
79 : : {
80 : 0 : sal_Int32 nVal = 0;
81 : :
82 [ # # ]: 0 : if(rValue >>= nVal)
83 : : {
84 : 0 : util::Duration aDuration;
85 : 0 : aDuration.Seconds = static_cast<sal_uInt16>(nVal);
86 : :
87 : 0 : OUStringBuffer aOut;
88 [ # # ]: 0 : ::sax::Converter::convertDuration(aOut, aDuration);
89 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
90 : 0 : return sal_True;
91 : : }
92 : :
93 : 0 : return sal_False;
94 : : }
95 : :
96 : : //////////////////////////////////////////////////////////////////////////////
97 : : // implementation of an opacity property handler
98 : :
99 : :
100 : 744 : XMLOpacityPropertyHdl::XMLOpacityPropertyHdl( SvXMLImport* pImport )
101 : 744 : : mpImport( pImport )
102 : : {
103 : 744 : }
104 : :
105 : 734 : XMLOpacityPropertyHdl::~XMLOpacityPropertyHdl()
106 : : {
107 [ - + ]: 1468 : }
108 : :
109 : 0 : sal_Bool XMLOpacityPropertyHdl::importXML(
110 : : const OUString& rStrImpValue,
111 : : ::com::sun::star::uno::Any& rValue,
112 : : const SvXMLUnitConverter& ) const
113 : : {
114 : 0 : sal_Bool bRet = sal_False;
115 : 0 : sal_Int32 nValue = 0;
116 : :
117 [ # # ]: 0 : if( rStrImpValue.indexOf( sal_Unicode('%') ) != -1 )
118 : : {
119 [ # # ][ # # ]: 0 : if (::sax::Converter::convertPercent( nValue, rStrImpValue ))
120 : 0 : bRet = sal_True;
121 : : }
122 : : else
123 : : {
124 : 0 : nValue = sal_Int32( rStrImpValue.toDouble() * 100.0 );
125 : 0 : bRet = sal_True;
126 : : }
127 : :
128 [ # # ]: 0 : if( bRet )
129 : : {
130 : : // check ranges
131 [ # # ]: 0 : if( nValue < 0 )
132 : 0 : nValue = 0;
133 [ # # ]: 0 : if( nValue > 100 )
134 : 0 : nValue = 100;
135 : :
136 : : // convert xml opacity to api transparency
137 : 0 : nValue = 100 - nValue;
138 : :
139 : : // #i42959#
140 [ # # ]: 0 : if( mpImport )
141 : : {
142 : : sal_Int32 nUPD, nBuild;
143 [ # # ][ # # ]: 0 : if( mpImport->getBuildIds( nUPD, nBuild ) )
144 : : {
145 : : // correct import of documents written prior to StarOffice 8/OOO 2.0 final
146 [ # # ][ # # ]: 0 : if( (nUPD == 680) && (nBuild < 8951) )
147 : 0 : nValue = 100 - nValue;
148 : : }
149 : : }
150 : :
151 [ # # ]: 0 : rValue <<= sal_uInt16(nValue);
152 : : }
153 : :
154 : 0 : return bRet;
155 : : }
156 : :
157 : 0 : sal_Bool XMLOpacityPropertyHdl::exportXML(
158 : : OUString& rStrExpValue,
159 : : const ::com::sun::star::uno::Any& rValue,
160 : : const SvXMLUnitConverter& ) const
161 : : {
162 : 0 : sal_Bool bRet = sal_False;
163 : 0 : sal_uInt16 nVal = sal_uInt16();
164 : :
165 [ # # ]: 0 : if( rValue >>= nVal )
166 : : {
167 : 0 : OUStringBuffer aOut;
168 : :
169 : 0 : nVal = 100 - nVal;
170 [ # # ]: 0 : ::sax::Converter::convertPercent( aOut, nVal );
171 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
172 : 0 : bRet = sal_True;
173 : : }
174 : :
175 : 0 : return bRet;
176 : : }
177 : :
178 : : //////////////////////////////////////////////////////////////////////////////
179 : : // implementation of an text animation step amount
180 : :
181 : 734 : XMLTextAnimationStepPropertyHdl::~XMLTextAnimationStepPropertyHdl()
182 : : {
183 [ - + ]: 1468 : }
184 : :
185 : 0 : sal_Bool XMLTextAnimationStepPropertyHdl::importXML(
186 : : const OUString& rStrImpValue,
187 : : ::com::sun::star::uno::Any& rValue,
188 : : const SvXMLUnitConverter& rUnitConverter ) const
189 : : {
190 : 0 : sal_Bool bRet = sal_False;
191 : 0 : sal_Int32 nValue = 0;
192 : :
193 [ # # ]: 0 : const OUString aPX( RTL_CONSTASCII_USTRINGPARAM( "px" ) );
194 : 0 : sal_Int32 nPos = rStrImpValue.indexOf( aPX );
195 [ # # ]: 0 : if( nPos != -1 )
196 : : {
197 [ # # ][ # # ]: 0 : if (::sax::Converter::convertNumber(nValue, rStrImpValue.copy(0, nPos)))
198 : : {
199 [ # # ]: 0 : rValue <<= sal_Int16( -nValue );
200 : 0 : bRet = sal_True;
201 : : }
202 : : }
203 : : else
204 : : {
205 [ # # ][ # # ]: 0 : if (rUnitConverter.convertMeasureToCore( nValue, rStrImpValue ))
206 : : {
207 [ # # ]: 0 : rValue <<= sal_Int16( nValue );
208 : 0 : bRet = sal_True;
209 : : }
210 : : }
211 : :
212 : 0 : return bRet;
213 : : }
214 : :
215 : 0 : sal_Bool XMLTextAnimationStepPropertyHdl::exportXML(
216 : : OUString& rStrExpValue,
217 : : const ::com::sun::star::uno::Any& rValue,
218 : : const SvXMLUnitConverter& rUnitConverter ) const
219 : : {
220 : 0 : sal_Bool bRet = sal_False;
221 : 0 : sal_Int16 nVal = sal_Int16();
222 : :
223 [ # # ]: 0 : if( rValue >>= nVal )
224 : : {
225 : 0 : OUStringBuffer aOut;
226 : :
227 [ # # ]: 0 : if( nVal < 0 )
228 : : {
229 [ # # ]: 0 : const OUString aPX( RTL_CONSTASCII_USTRINGPARAM( "px" ) );
230 [ # # ]: 0 : ::sax::Converter::convertNumber( aOut, (sal_Int32)-nVal );
231 [ # # ]: 0 : aOut.append( aPX );
232 : : }
233 : : else
234 : : {
235 [ # # ]: 0 : rUnitConverter.convertMeasureToXML( aOut, nVal );
236 : : }
237 : :
238 [ # # ]: 0 : rStrExpValue = aOut.makeStringAndClear();
239 : 0 : bRet = sal_True;
240 : : }
241 : :
242 : 0 : return bRet;
243 : : }
244 : :
245 : : //////////////////////////////////////////////////////////////////////////////
246 : :
247 : : #include "sdxmlexp_impl.hxx"
248 : :
249 : 0 : XMLDateTimeFormatHdl::XMLDateTimeFormatHdl( SvXMLExport* pExport )
250 : 0 : : mpExport( pExport )
251 : : {
252 : 0 : }
253 : :
254 : 0 : XMLDateTimeFormatHdl::~XMLDateTimeFormatHdl()
255 : : {
256 [ # # ]: 0 : }
257 : :
258 : 0 : sal_Bool XMLDateTimeFormatHdl::importXML( const rtl::OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& ) const
259 : : {
260 : 0 : rValue <<= rStrImpValue;
261 : 0 : return true;
262 : : }
263 : :
264 : 0 : sal_Bool XMLDateTimeFormatHdl::exportXML( rtl::OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& ) const
265 : : {
266 : 0 : sal_Int32 nNumberFormat = 0;
267 [ # # ][ # # ]: 0 : if( mpExport && (rValue >>= nNumberFormat) )
[ # # ]
268 : : {
269 [ # # ]: 0 : mpExport->addDataStyle( nNumberFormat );
270 [ # # ]: 0 : rStrExpValue = mpExport->getDataStyleName( nNumberFormat );
271 : 0 : return sal_True;
272 : : }
273 : :
274 : 0 : return sal_False;
275 : : }
276 : :
277 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|