xref: /aoo42x/main/xmloff/source/style/numehelp.cxx (revision cdf0e10c)
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 
31 #include "xmloff/numehelp.hxx"
32 
33 #include <xmloff/nmspmap.hxx>
34 #include "xmloff/xmlnmspe.hxx"
35 #include <xmloff/xmluconv.hxx>
36 #include <xmloff/xmltoken.hxx>
37 #include <xmloff/xmlexp.hxx>
38 #include <com/sun/star/uno/Reference.h>
39 #include <rtl/ustring.hxx>
40 #include <svl/zforlist.hxx>
41 #include <com/sun/star/util/NumberFormat.hpp>
42 #include <rtl/math.hxx>
43 #include <tools/debug.hxx>
44 #include <rtl/ustrbuf.hxx>
45 
46 using namespace com::sun::star;
47 using namespace xmloff::token;
48 
49 #define XML_TYPE "Type"
50 #define XML_CURRENCYSYMBOL "CurrencySymbol"
51 #define XML_CURRENCYABBREVIATION "CurrencyAbbreviation"
52 #define XML_STANDARDFORMAT "StandardFormat"
53 
54 XMLNumberFormatAttributesExportHelper::XMLNumberFormatAttributesExportHelper(
55 			::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xTempNumberFormatsSupplier)
56 	: xNumberFormats(xTempNumberFormatsSupplier.is() ? xTempNumberFormatsSupplier->getNumberFormats() : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats > ()),
57 	pExport(NULL),
58     sStandardFormat(RTL_CONSTASCII_USTRINGPARAM(XML_STANDARDFORMAT)),
59     sType(RTL_CONSTASCII_USTRINGPARAM(XML_TYPE)),
60     msCurrencySymbol(RTL_CONSTASCII_USTRINGPARAM(XML_CURRENCYSYMBOL)),
61     msCurrencyAbbreviation(RTL_CONSTASCII_USTRINGPARAM(XML_CURRENCYABBREVIATION)),
62 	aNumberFormats()
63 {
64 }
65 
66 XMLNumberFormatAttributesExportHelper::XMLNumberFormatAttributesExportHelper(
67             ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xTempNumberFormatsSupplier,
68             SvXMLExport& rTempExport )
69 :	xNumberFormats(xTempNumberFormatsSupplier.is() ? xTempNumberFormatsSupplier->getNumberFormats() : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats > ()),
70 	pExport(&rTempExport),
71     sStandardFormat(RTL_CONSTASCII_USTRINGPARAM(XML_STANDARDFORMAT)),
72     sType(RTL_CONSTASCII_USTRINGPARAM(XML_TYPE)),
73     sAttrValueType(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_VALUE_TYPE))),
74     sAttrValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_VALUE))),
75 	sAttrDateValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_DATE_VALUE))),
76     sAttrTimeValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_TIME_VALUE))),
77 	sAttrBooleanValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_BOOLEAN_VALUE))),
78     sAttrStringValue(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_STRING_VALUE))),
79 	sAttrCurrency(rTempExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OFFICE, GetXMLToken(XML_CURRENCY))),
80     msCurrencySymbol(RTL_CONSTASCII_USTRINGPARAM(XML_CURRENCYSYMBOL)),
81     msCurrencyAbbreviation(RTL_CONSTASCII_USTRINGPARAM(XML_CURRENCYABBREVIATION)),
82     aNumberFormats()
83 {
84 }
85 
86 XMLNumberFormatAttributesExportHelper::~XMLNumberFormatAttributesExportHelper()
87 {
88 }
89 
90 sal_Int16 XMLNumberFormatAttributesExportHelper::GetCellType(const sal_Int32 nNumberFormat, rtl::OUString& sCurrency, sal_Bool& bIsStandard)
91 {
92 	XMLNumberFormat aFormat(sEmpty, nNumberFormat, 0);
93 	XMLNumberFormatSet::iterator aItr(aNumberFormats.find(aFormat));
94     XMLNumberFormatSet::iterator aEndItr(aNumberFormats.end());
95 	if (aItr != aEndItr)
96 	{
97 		bIsStandard = aItr->bIsStandard;
98 		sCurrency = aItr->sCurrency;
99 		return aItr->nType;
100 	}
101 	else
102 	{
103 		aFormat.nType = GetCellType(nNumberFormat, bIsStandard);
104 		aFormat.bIsStandard = bIsStandard;
105         if ((aFormat.nType & ~util::NumberFormat::DEFINED) == util::NumberFormat::CURRENCY)
106 			if (GetCurrencySymbol(nNumberFormat, aFormat.sCurrency))
107 				sCurrency = aFormat.sCurrency;
108 		aNumberFormats.insert(aFormat);
109 		return aFormat.nType;
110 	}
111 }
112 
113 void XMLNumberFormatAttributesExportHelper::WriteAttributes(SvXMLExport& rXMLExport,
114 								const sal_Int16 nTypeKey,
115 								const double& rValue,
116 								const rtl::OUString& rCurrency,
117 								sal_Bool bExportValue)
118 {
119 	sal_Bool bWasSetTypeAttribute = sal_False;
120 	switch(nTypeKey & ~util::NumberFormat::DEFINED)
121 	{
122 	case 0:
123 	case util::NumberFormat::NUMBER:
124 	case util::NumberFormat::SCIENTIFIC:
125 	case util::NumberFormat::FRACTION:
126 		{
127 			if (!bWasSetTypeAttribute)
128 			{
129 				rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT);
130 				bWasSetTypeAttribute = sal_True;
131 			}
132 		}		// No Break
133 	case util::NumberFormat::PERCENT:
134 		{
135 			if (!bWasSetTypeAttribute)
136 			{
137 				rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_PERCENTAGE);
138 				bWasSetTypeAttribute = sal_True;
139 			}
140 		}		// No Break
141 	case util::NumberFormat::CURRENCY:
142 		{
143 			if (!bWasSetTypeAttribute)
144 			{
145 				rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_CURRENCY);
146 				if (rCurrency.getLength() > 0)
147 					rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CURRENCY, rCurrency);
148 				bWasSetTypeAttribute = sal_True;
149 			}
150 
151 			if (bExportValue)
152 			{
153                 rtl::OUString sValue( ::rtl::math::doubleToUString( rValue,
154                             rtl_math_StringFormat_Automatic,
155                             rtl_math_DecimalPlaces_Max, '.', sal_True));
156 				rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE, sValue);
157 			}
158 		}
159 		break;
160 	case util::NumberFormat::DATE:
161 	case util::NumberFormat::DATETIME:
162 		{
163 			if (!bWasSetTypeAttribute)
164 			{
165 				rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_DATE);
166 				bWasSetTypeAttribute = sal_True;
167 			}
168 			if (bExportValue)
169 			{
170                 if ( rXMLExport.SetNullDateOnUnitConverter() )
171 				{
172 					rtl::OUStringBuffer sBuffer;
173 					rXMLExport.GetMM100UnitConverter().convertDateTime(sBuffer, rValue);
174 					rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_DATE_VALUE, sBuffer.makeStringAndClear());
175 				}
176 			}
177 		}
178 		break;
179 	case util::NumberFormat::TIME:
180 		{
181 			if (!bWasSetTypeAttribute)
182 			{
183 				rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TIME);
184 				bWasSetTypeAttribute = sal_True;
185 			}
186 			if (bExportValue)
187 			{
188 				rtl::OUStringBuffer sBuffer;
189 				rXMLExport.GetMM100UnitConverter().convertTime(sBuffer, rValue);
190 				rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_TIME_VALUE, sBuffer.makeStringAndClear());
191 			}
192 		}
193 		break;
194 	case util::NumberFormat::LOGICAL:
195 		{
196 			if (!bWasSetTypeAttribute)
197 			{
198 				rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_BOOLEAN);
199 				bWasSetTypeAttribute = sal_True;
200 			}
201 			if (bExportValue)
202 			{
203 				double fTempValue = rValue;
204 				if (::rtl::math::approxEqual( fTempValue, 1.0 ))
205 				{
206 					rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, XML_TRUE);
207 				}
208 				else
209 				{
210 					if (::rtl::math::approxEqual( rValue, 0.0 ))
211 					{
212 						rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, XML_FALSE);
213 					}
214 					else
215 					{
216                         rtl::OUString sValue( ::rtl::math::doubleToUString(
217                                     fTempValue,
218                                     rtl_math_StringFormat_Automatic,
219                                     rtl_math_DecimalPlaces_Max, '.',
220                                     sal_True));
221 						rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, sValue);
222 					}
223 				}
224 			}
225 		}
226 		break;
227 	case util::NumberFormat::TEXT:
228 		{
229 			if (!bWasSetTypeAttribute)
230 			{
231 				rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT);
232 				bWasSetTypeAttribute = sal_True;
233 				if (bExportValue)
234 				{
235                     rtl::OUString sValue( ::rtl::math::doubleToUString( rValue,
236                                 rtl_math_StringFormat_Automatic,
237                                 rtl_math_DecimalPlaces_Max, '.', sal_True));
238 					rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE, sValue);
239 				}
240 			}
241 		}
242 		break;
243 	}
244 }
245 
246 sal_Bool XMLNumberFormatAttributesExportHelper::GetCurrencySymbol(const sal_Int32 nNumberFormat, rtl::OUString& sCurrencySymbol,
247 	uno::Reference <util::XNumberFormatsSupplier>& xNumberFormatsSupplier)
248 {
249 	if (xNumberFormatsSupplier.is())
250 	{
251 		uno::Reference <util::XNumberFormats> xNumberFormats(xNumberFormatsSupplier->getNumberFormats());
252 		if (xNumberFormats.is())
253 		{
254 			try
255 			{
256 				uno::Reference <beans::XPropertySet> xNumberPropertySet(xNumberFormats->getByKey(nNumberFormat));
257 				if ( xNumberPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_CURRENCYSYMBOL))) >>= sCurrencySymbol)
258 				{
259 					rtl::OUString sCurrencyAbbreviation;
260 					if ( xNumberPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_CURRENCYABBREVIATION))) >>= sCurrencyAbbreviation)
261 					{
262 						if ( sCurrencyAbbreviation.getLength() != 0 )
263 							sCurrencySymbol = sCurrencyAbbreviation;
264 						else
265 						{
266 							if ( sCurrencySymbol.getLength() == 1 && sCurrencySymbol.toChar() == NfCurrencyEntry::GetEuroSymbol() )
267 								sCurrencySymbol = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EUR"));
268 						}
269 					}
270 					return sal_True;
271 				}
272 			}
273 			catch ( uno::Exception& )
274 			{
275 				DBG_ERROR("Numberformat not found");
276 			}
277 		}
278 	}
279 	return sal_False;
280 }
281 
282 
283 sal_Int16 XMLNumberFormatAttributesExportHelper::GetCellType(const sal_Int32 nNumberFormat, sal_Bool& bIsStandard,
284 	uno::Reference <util::XNumberFormatsSupplier>& xNumberFormatsSupplier)
285 {
286 	if (xNumberFormatsSupplier.is())
287 	{
288 		uno::Reference <util::XNumberFormats> xNumberFormats(xNumberFormatsSupplier->getNumberFormats());
289 		if (xNumberFormats.is())
290 		{
291 			try
292 			{
293 				uno::Reference <beans::XPropertySet> xNumberPropertySet(xNumberFormats->getByKey(nNumberFormat));
294 				xNumberPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STANDARDFORMAT))) >>= bIsStandard;
295 				sal_Int16 nNumberType = sal_Int16();
296 				if ( xNumberPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(XML_TYPE))) >>= nNumberType )
297 				{
298 					return nNumberType;
299 				}
300 			}
301 			catch ( uno::Exception& )
302 			{
303 				DBG_ERROR("Numberformat not found");
304 			}
305 		}
306 	}
307 	return 0;
308 }
309 
310 void XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(SvXMLExport& rXMLExport,
311 	const sal_Int32 nNumberFormat, const double& rValue, sal_Bool bExportValue)
312 {
313 	sal_Bool bIsStandard;
314 	sal_Int16 nTypeKey = GetCellType(nNumberFormat, bIsStandard, rXMLExport.GetNumberFormatsSupplier());
315 	rtl::OUString sCurrency;
316     if ((nTypeKey & ~util::NumberFormat::DEFINED) == util::NumberFormat::CURRENCY)
317 		GetCurrencySymbol(nNumberFormat, sCurrency, rXMLExport.GetNumberFormatsSupplier());
318 	WriteAttributes(rXMLExport, nTypeKey, rValue, sCurrency, bExportValue);
319 }
320 
321 void XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(SvXMLExport& rXMLExport,
322 	const rtl::OUString& rValue, const rtl::OUString& rCharacters,
323 	sal_Bool bExportValue, sal_Bool bExportTypeAttribute)
324 {
325 	if (bExportTypeAttribute)
326 		rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING);
327 	if (bExportValue && rValue.getLength() && (rValue != rCharacters))
328 		rXMLExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_STRING_VALUE, rValue);
329 }
330 
331 sal_Bool XMLNumberFormatAttributesExportHelper::GetCurrencySymbol(const sal_Int32 nNumberFormat, rtl::OUString& rCurrencySymbol)
332 {
333     if (!xNumberFormats.is() && pExport && pExport->GetNumberFormatsSupplier().is())
334 		xNumberFormats.set(pExport->GetNumberFormatsSupplier()->getNumberFormats());
335 
336     if (xNumberFormats.is())
337 	{
338 		try
339 		{
340 			uno::Reference <beans::XPropertySet> xNumberPropertySet(xNumberFormats->getByKey(nNumberFormat));
341 			if ( xNumberPropertySet->getPropertyValue(msCurrencySymbol) >>= rCurrencySymbol)
342 			{
343 				rtl::OUString sCurrencyAbbreviation;
344 				if ( xNumberPropertySet->getPropertyValue(msCurrencyAbbreviation) >>= sCurrencyAbbreviation)
345 				{
346 					if ( sCurrencyAbbreviation.getLength() != 0 )
347 						rCurrencySymbol = sCurrencyAbbreviation;
348 					else
349 					{
350 						if ( rCurrencySymbol.getLength() == 1 && rCurrencySymbol.toChar() == NfCurrencyEntry::GetEuroSymbol() )
351 							rCurrencySymbol = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EUR"));
352 					}
353 				}
354 				return sal_True;
355 			}
356 		}
357 		catch ( uno::Exception& )
358 		{
359 			DBG_ERROR("Numberformat not found");
360 		}
361 	}
362 	return sal_False;
363 }
364 
365 sal_Int16 XMLNumberFormatAttributesExportHelper::GetCellType(const sal_Int32 nNumberFormat, sal_Bool& bIsStandard)
366 {
367     if (!xNumberFormats.is() && pExport && pExport->GetNumberFormatsSupplier().is())
368 		xNumberFormats.set(pExport->GetNumberFormatsSupplier()->getNumberFormats());
369 
370     if (xNumberFormats.is())
371 	{
372 		try
373 		{
374 			uno::Reference <beans::XPropertySet> xNumberPropertySet(xNumberFormats->getByKey(nNumberFormat));
375             if (xNumberPropertySet.is())
376             {
377 			    xNumberPropertySet->getPropertyValue(sStandardFormat) >>= bIsStandard;
378 			    sal_Int16 nNumberType = sal_Int16();
379 			    if ( xNumberPropertySet->getPropertyValue(sType) >>= nNumberType )
380 			    {
381 				    return nNumberType;
382 			    }
383             }
384 		}
385 		catch ( uno::Exception& )
386 		{
387 			DBG_ERROR("Numberformat not found");
388 		}
389 	}
390 	return 0;
391 }
392 
393 void XMLNumberFormatAttributesExportHelper::WriteAttributes(
394 								const sal_Int16 nTypeKey,
395 								const double& rValue,
396 								const rtl::OUString& rCurrency,
397 								sal_Bool bExportValue)
398 {
399     if (!pExport)
400         return;
401 
402 	sal_Bool bWasSetTypeAttribute = sal_False;
403 	switch(nTypeKey & ~util::NumberFormat::DEFINED)
404 	{
405 	case 0:
406 	case util::NumberFormat::NUMBER:
407 	case util::NumberFormat::SCIENTIFIC:
408 	case util::NumberFormat::FRACTION:
409 		{
410 			if (!bWasSetTypeAttribute)
411 			{
412 				pExport->AddAttribute(sAttrValueType, XML_FLOAT);
413 				bWasSetTypeAttribute = sal_True;
414 			}
415 		}		// No Break
416 	case util::NumberFormat::PERCENT:
417 		{
418 			if (!bWasSetTypeAttribute)
419 			{
420 				pExport->AddAttribute(sAttrValueType, XML_PERCENTAGE);
421 				bWasSetTypeAttribute = sal_True;
422 			}
423 		}		// No Break
424 	case util::NumberFormat::CURRENCY:
425 		{
426 			if (!bWasSetTypeAttribute)
427 			{
428 				pExport->AddAttribute(sAttrValueType, XML_CURRENCY);
429 				if (rCurrency.getLength() > 0)
430 					pExport->AddAttribute(sAttrCurrency, rCurrency);
431 				bWasSetTypeAttribute = sal_True;
432 			}
433 
434 			if (bExportValue)
435 			{
436                 rtl::OUString sValue( ::rtl::math::doubleToUString( rValue,
437                             rtl_math_StringFormat_Automatic,
438                             rtl_math_DecimalPlaces_Max, '.', sal_True));
439 				pExport->AddAttribute(sAttrValue, sValue);
440 			}
441 		}
442 		break;
443 	case util::NumberFormat::DATE:
444 	case util::NumberFormat::DATETIME:
445 		{
446 			if (!bWasSetTypeAttribute)
447 			{
448 				pExport->AddAttribute(sAttrValueType, XML_DATE);
449 				bWasSetTypeAttribute = sal_True;
450 			}
451 			if (bExportValue)
452 			{
453                 if ( pExport->SetNullDateOnUnitConverter() )
454 				{
455 					rtl::OUStringBuffer sBuffer;
456 					pExport->GetMM100UnitConverter().convertDateTime(sBuffer, rValue);
457 					pExport->AddAttribute(sAttrDateValue, sBuffer.makeStringAndClear());
458 				}
459 			}
460 		}
461 		break;
462 	case util::NumberFormat::TIME:
463 		{
464 			if (!bWasSetTypeAttribute)
465 			{
466 				pExport->AddAttribute(sAttrValueType, XML_TIME);
467 				bWasSetTypeAttribute = sal_True;
468 			}
469 			if (bExportValue)
470 			{
471 				rtl::OUStringBuffer sBuffer;
472 				pExport->GetMM100UnitConverter().convertTime(sBuffer, rValue);
473 				pExport->AddAttribute(sAttrTimeValue, sBuffer.makeStringAndClear());
474 			}
475 		}
476 		break;
477 	case util::NumberFormat::LOGICAL:
478 		{
479 			if (!bWasSetTypeAttribute)
480 			{
481 				pExport->AddAttribute(sAttrValueType, XML_BOOLEAN);
482 				bWasSetTypeAttribute = sal_True;
483 			}
484 			if (bExportValue)
485 			{
486 				double fTempValue = rValue;
487 				if (::rtl::math::approxEqual( fTempValue, 1.0 ))
488 				{
489 					pExport->AddAttribute(sAttrBooleanValue, XML_TRUE);
490 				}
491 				else
492 				{
493 					if (::rtl::math::approxEqual( rValue, 0.0 ))
494 					{
495 						pExport->AddAttribute(sAttrBooleanValue, XML_FALSE);
496 					}
497 					else
498 					{
499                         rtl::OUString sValue( ::rtl::math::doubleToUString(
500                                     fTempValue,
501                                     rtl_math_StringFormat_Automatic,
502                                     rtl_math_DecimalPlaces_Max, '.',
503                                     sal_True));
504 						pExport->AddAttribute(sAttrBooleanValue, sValue);
505 					}
506 				}
507 			}
508 		}
509 		break;
510 	case util::NumberFormat::TEXT:
511 		{
512 			if (!bWasSetTypeAttribute)
513 			{
514 				pExport->AddAttribute(sAttrValueType, XML_FLOAT);
515 				bWasSetTypeAttribute = sal_True;
516 				if (bExportValue)
517 				{
518                     rtl::OUString sValue( ::rtl::math::doubleToUString( rValue,
519                                 rtl_math_StringFormat_Automatic,
520                                 rtl_math_DecimalPlaces_Max, '.', sal_True));
521 					pExport->AddAttribute(sAttrValue, sValue);
522 				}
523 			}
524 		}
525 		break;
526 	}
527 }
528 
529 void XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
530 	const sal_Int32 nNumberFormat, const double& rValue, sal_Bool bExportValue)
531 {
532 	if (pExport)
533 	{
534 		sal_Bool bIsStandard;
535 		rtl::OUString sCurrency;
536 		sal_Int16 nTypeKey = GetCellType(nNumberFormat, sCurrency, bIsStandard);
537 	    WriteAttributes(nTypeKey, rValue, sCurrency, bExportValue);
538 	}
539 	else {
540 		DBG_ERROR("no SvXMLExport given");
541     }
542 }
543 
544 void XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
545 	const rtl::OUString& rValue, const rtl::OUString& rCharacters,
546 	sal_Bool bExportValue, sal_Bool bExportTypeAttribute)
547 {
548     if (pExport)
549     {
550 	    if (bExportTypeAttribute)
551 		    pExport->AddAttribute(sAttrValueType, XML_STRING);
552 	    if (bExportValue && rValue.getLength() && (rValue != rCharacters))
553 		    pExport->AddAttribute(sAttrStringValue, rValue);
554     }
555 	else {
556 		DBG_ERROR("no SvXMLExport given");
557     }
558 }
559