update ooo310-m15
[ooovba.git] / writerfilter / source / dmapper / ConversionHelper.cxx
bloba3bde533e2d478d01f30c1a7485ea6852dfee282
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: ConversionHelper.cxx,v $
11 * $Revision: 1.12 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
31 #include <ConversionHelper.hxx>
32 #include <com/sun/star/table/BorderLine.hpp>
33 #include <com/sun/star/lang/Locale.hpp>
34 #include <com/sun/star/text/HoriOrientation.hpp>
35 #include <com/sun/star/style/NumberingType.hpp>
36 #include <ooxml/resourceids.hxx>
37 #include <tools/color.hxx>
38 #include <rtl/ustrbuf.hxx>
39 # include <svx/paperinf.hxx> //lA0Width...
40 #include <algorithm>
41 #include <functional>
43 using namespace com::sun::star;
45 namespace writerfilter {
46 namespace dmapper{
47 namespace ConversionHelper{
49 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
51 //line definitions in 1/100 mm
52 #define LINE_WIDTH_0 2
53 #define LINE_WIDTH_1 36
54 #define LINE_WIDTH_2 89
55 #define LINE_WIDTH_3 142
56 #define LINE_WIDTH_4 177
57 #define LINE_WIDTH_5 18
59 #define DOUBLE_LINE0_OUT LINE_WIDTH_0
60 #define DOUBLE_LINE0_IN LINE_WIDTH_0
61 #define DOUBLE_LINE0_DIST LINE_WIDTH_1
63 #define DOUBLE_LINE1_OUT LINE_WIDTH_1
64 #define DOUBLE_LINE1_IN LINE_WIDTH_1
65 #define DOUBLE_LINE1_DIST LINE_WIDTH_1
67 #define DOUBLE_LINE2_OUT LINE_WIDTH_2
68 #define DOUBLE_LINE2_IN LINE_WIDTH_2
69 #define DOUBLE_LINE2_DIST LINE_WIDTH_2
71 #define DOUBLE_LINE3_OUT LINE_WIDTH_2
72 #define DOUBLE_LINE3_IN LINE_WIDTH_1
73 #define DOUBLE_LINE3_DIST LINE_WIDTH_2
75 #define DOUBLE_LINE4_OUT LINE_WIDTH_1
76 #define DOUBLE_LINE4_IN LINE_WIDTH_2
77 #define DOUBLE_LINE4_DIST LINE_WIDTH_1
79 #define DOUBLE_LINE5_OUT LINE_WIDTH_3
80 #define DOUBLE_LINE5_IN LINE_WIDTH_2
81 #define DOUBLE_LINE5_DIST LINE_WIDTH_2
83 #define DOUBLE_LINE6_OUT LINE_WIDTH_2
84 #define DOUBLE_LINE6_IN LINE_WIDTH_3
85 #define DOUBLE_LINE6_DIST LINE_WIDTH_2
87 #define DOUBLE_LINE7_OUT LINE_WIDTH_0
88 #define DOUBLE_LINE7_IN LINE_WIDTH_0
89 #define DOUBLE_LINE7_DIST LINE_WIDTH_2
91 #define DOUBLE_LINE8_OUT LINE_WIDTH_1
92 #define DOUBLE_LINE8_IN LINE_WIDTH_0
93 #define DOUBLE_LINE8_DIST LINE_WIDTH_2
95 #define DOUBLE_LINE9_OUT LINE_WIDTH_2
96 #define DOUBLE_LINE9_IN LINE_WIDTH_0
97 #define DOUBLE_LINE9_DIST LINE_WIDTH_2
99 #define DOUBLE_LINE10_OUT LINE_WIDTH_3
100 #define DOUBLE_LINE10_IN LINE_WIDTH_0
101 #define DOUBLE_LINE10_DIST LINE_WIDTH_2
103 sal_Int32 MakeBorderLine( sal_Int32 nSprmValue, table::BorderLine& rToFill )
105 //TODO: Lines are always solid
106 //Border
107 //borders are defined as:
108 // 0x XX XX XX XX
109 // || || || ||
110 // || || || ---- Line width in 1/8 pt
111 // || || ||
112 // || || ------- Line type: 0 - none 1 - single ... 25 - engrave 3D and 64 - 230 page borders
113 // || ||
114 // || ---------- Line color
115 // ||
116 // ------------- seven bits line space
117 // -------------- first bit: with shading
118 sal_Int16 nLineThicknessTwip = (sal_Int16)((nSprmValue & 0xff) * 20)/8L ;
119 sal_Int32 nLineType = ((nSprmValue & 0xff00) >> 8);
120 sal_Int32 nLineColor = (nSprmValue & 0xff0000)>>16;
121 sal_Int32 nLineDistance = (((nSprmValue & 0x3f000000)>>24) * 2540 + 36)/72L;
122 sal_Int32 nLineThickness = TWIP_TO_MM100(nLineThicknessTwip);
123 MakeBorderLine( nLineThickness, nLineType, nLineColor, rToFill, false);
124 return nLineDistance;
126 void MakeBorderLine( sal_Int32 nLineThickness, sal_Int32 nLineType,
127 sal_Int32 nLineColor,
128 table::BorderLine& rToFill, bool bIsOOXML )
130 static const sal_Int32 aBorderDefColor[] =
132 COL_AUTO, COL_BLACK, COL_LIGHTBLUE, COL_LIGHTCYAN, COL_LIGHTGREEN,
133 COL_LIGHTMAGENTA, COL_LIGHTRED, COL_YELLOW, COL_WHITE, COL_BLUE,
134 COL_CYAN, COL_GREEN, COL_MAGENTA, COL_RED, COL_BROWN, COL_GRAY,
135 COL_LIGHTGRAY
137 //no auto color for borders
138 if(!nLineColor)
139 ++nLineColor;
140 if(!bIsOOXML && sal::static_int_cast<sal_uInt32>(nLineColor) <
141 sizeof(aBorderDefColor) / sizeof(nLineColor))
142 nLineColor = aBorderDefColor[nLineColor];
144 enum eBorderCode
146 single0, single1, single2, single3, single4, single5,
147 double0, double1, double2, double3, double4, double5, double6,
148 double7, double8, double9, double10,
149 none
150 } eCodeIdx = none;
152 // Map to our border types, we should use of one equal line
153 // thickness, or one of smaller thickness. If too small we
154 // can make the defecit up in additional white space or
155 // object size
156 switch(nLineType)
158 // First the single lines
159 case 1: break;
160 case 2:
161 case 5:
162 // and the unsupported special cases which we map to a single line
163 case 6:
164 case 7:
165 case 8:
166 case 9:
167 case 22:
168 // or if in necessary by a double line
169 case 24:
170 case 25:
171 if( nLineThickness < 10)
172 eCodeIdx = single0;// 1 Twip for us
173 else if( nLineThickness < 20)
174 eCodeIdx = single5;// 10 Twips for us
175 else if (nLineThickness < 50)
176 eCodeIdx = single1;// 20 Twips
177 else if (nLineThickness < 80)
178 eCodeIdx = single2;// 50
179 else if (nLineThickness < 100)
180 eCodeIdx = single3;// 80
181 else if (nLineThickness < 150)
182 eCodeIdx = single4;// 100
183 // Hack: for the quite thick lines we must paint double lines,
184 // because our singles lines don't come thicker than 5 points.
185 else if (nLineThickness < 180)
186 eCodeIdx = double2;// 150
187 else
188 eCodeIdx = double5;// 180
189 break;
190 // then the shading beams which we represent by a double line
191 case 23:
192 eCodeIdx = double1;
193 break;
194 // then the double lines, for which we have good matches
195 case 3:
196 case 10: //Don't have tripple so use double
197 if (nLineThickness < 60)
198 eCodeIdx = double0;// 22 Twips for us
199 else if (nLineThickness < 135)
200 eCodeIdx = double7;// some more space
201 else if (nLineThickness < 180)
202 eCodeIdx = double1;// 60
203 else
204 eCodeIdx = double2;// 150
205 break;
206 case 11:
207 eCodeIdx = double4;// 90 Twips for us
208 break;
209 case 12:
210 case 13: //Don't have thin thick thin, so use thick thin
211 if (nLineThickness < 87)
212 eCodeIdx = double8;// 71 Twips for us
213 else if (nLineThickness < 117)
214 eCodeIdx = double9;// 101
215 else if (nLineThickness < 166)
216 eCodeIdx = double10;// 131
217 else
218 eCodeIdx = double5;// 180
219 break;
220 case 14:
221 if (nLineThickness < 46)
222 eCodeIdx = double0;// 22 Twips for us
223 else if (nLineThickness < 76)
224 eCodeIdx = double1;// 60
225 else if (nLineThickness < 121)
226 eCodeIdx = double4;// 90
227 else if (nLineThickness < 166)
228 eCodeIdx = double2;// 150
229 else
230 eCodeIdx = double6;// 180
231 break;
232 case 15:
233 case 16: //Don't have thin thick thin, so use thick thin
234 if (nLineThickness < 46)
235 eCodeIdx = double0;// 22 Twips for us
236 else if (nLineThickness < 76)
237 eCodeIdx = double1;// 60
238 else if (nLineThickness < 121)
239 eCodeIdx = double3;// 90
240 else if (nLineThickness < 166)
241 eCodeIdx = double2;// 150
242 else
243 eCodeIdx = double5;// 180
244 break;
245 case 17:
246 if (nLineThickness < 46)
247 eCodeIdx = double0;// 22 Twips for us
248 else if (nLineThickness < 72)
249 eCodeIdx = double7;// 52
250 else if (nLineThickness < 137)
251 eCodeIdx = double4;// 90
252 else
253 eCodeIdx = double6;// 180
254 break;
255 case 18:
256 case 19: //Don't have thin thick thin, so use thick thin
257 if (nLineThickness < 46)
258 eCodeIdx = double0;// 22 Twips for us
259 else if (nLineThickness < 62)
260 eCodeIdx = double7;// 52
261 else if (nLineThickness < 87)
262 eCodeIdx = double8;// 71
263 else if (nLineThickness < 117)
264 eCodeIdx = double9;// 101
265 else if (nLineThickness < 156)
266 eCodeIdx = double10;// 131
267 else
268 eCodeIdx = double5;// 180
269 break;
270 case 20:
271 if (nLineThickness < 46)
272 eCodeIdx = single1; // 20 Twips for us
273 else
274 eCodeIdx = double1;// 60
275 break;
276 case 21:
277 eCodeIdx = double1;// 60 Twips for us
278 break;
279 case 0:
280 case 255:
281 eCodeIdx = none;
282 break;
283 default:
284 eCodeIdx = single0;
285 break;
287 struct BorderDefinition
289 sal_Int16 nOut;
290 sal_Int16 nIn;
291 sal_Int16 nDist;
295 static const BorderDefinition aLineTab[] =
297 /* 0*/ { LINE_WIDTH_0, 0, 0 },
298 /* 1*/ { LINE_WIDTH_1, 0, 0 },
299 /* 2*/ { LINE_WIDTH_2, 0, 0 },
300 /* 3*/ { LINE_WIDTH_3, 0, 0 },
301 /* 4*/ { LINE_WIDTH_4, 0, 0 },
302 /* 5*/ { LINE_WIDTH_5, 0, 0 },
303 /* 6*/ { DOUBLE_LINE0_OUT, DOUBLE_LINE0_IN, DOUBLE_LINE0_DIST },
304 /* 7*/ { DOUBLE_LINE1_OUT, DOUBLE_LINE1_IN, DOUBLE_LINE1_DIST },
305 /* 8*/ { DOUBLE_LINE2_OUT, DOUBLE_LINE2_IN, DOUBLE_LINE2_DIST },
306 /* 9*/ { DOUBLE_LINE3_OUT, DOUBLE_LINE3_IN, DOUBLE_LINE3_DIST },
307 /*10*/ { DOUBLE_LINE4_OUT, DOUBLE_LINE4_IN, DOUBLE_LINE4_DIST },
308 /*11*/ { DOUBLE_LINE5_OUT, DOUBLE_LINE5_IN, DOUBLE_LINE5_DIST },
309 /*12*/ { DOUBLE_LINE6_OUT, DOUBLE_LINE6_IN, DOUBLE_LINE6_DIST },
310 /*13*/ { DOUBLE_LINE7_OUT, DOUBLE_LINE7_IN, DOUBLE_LINE7_DIST },
311 /*14*/ { DOUBLE_LINE8_OUT, DOUBLE_LINE8_IN, DOUBLE_LINE8_DIST },
312 /*15*/ { DOUBLE_LINE9_OUT, DOUBLE_LINE9_IN, DOUBLE_LINE9_DIST },
313 /*16*/ { DOUBLE_LINE10_OUT,DOUBLE_LINE10_IN,DOUBLE_LINE10_DIST},
314 /*17*/ { 0, 0, 0 }
317 rToFill.Color = nLineColor;
318 if( nLineType == 1)
320 rToFill.InnerLineWidth = 0;
321 rToFill.OuterLineWidth = sal_Int16(nLineThickness);
322 rToFill.LineDistance = 0;
325 else
327 rToFill.InnerLineWidth = aLineTab[eCodeIdx].nIn;
328 rToFill.OuterLineWidth = aLineTab[eCodeIdx].nOut;
329 rToFill.LineDistance = aLineTab[eCodeIdx].nDist;
333 void lcl_SwapQuotesInField(::rtl::OUString &rFmt)
335 //Swap unescaped " and ' with ' and "
336 sal_Int32 nLen = rFmt.getLength();
337 ::rtl::OUStringBuffer aBuffer( rFmt.getStr() );
338 const sal_Unicode* pFmt = rFmt.getStr();
339 for (sal_Int32 nI = 0; nI < nLen; ++nI)
341 if ((pFmt[nI] == '\"') && (!nI || pFmt[nI-1] != '\\'))
342 aBuffer.setCharAt(nI, '\'');
343 else if ((pFmt[nI] == '\'') && (!nI || pFmt[nI-1] != '\\'))
344 aBuffer.setCharAt(nI, '\"');
346 rFmt = aBuffer.makeStringAndClear();
348 bool lcl_IsNotAM(::rtl::OUString& rFmt, sal_Int32 nPos)
350 return (
351 (nPos == rFmt.getLength() - 1) ||
353 (rFmt.getStr()[nPos+1] != 'M') &&
354 (rFmt.getStr()[nPos+1] != 'm')
359 ::rtl::OUString ConvertMSFormatStringToSO(
360 const ::rtl::OUString& rFormat, lang::Locale& rLocale, bool bHijri)
362 ::rtl::OUString sFormat(rFormat);
363 lcl_SwapQuotesInField(sFormat);
365 //#102782#, #102815#, #108341# & #111944# have to work at the same time :-)
366 bool bForceJapanese(false);
367 bool bForceNatNum(false);
368 sal_Int32 nLen = sFormat.getLength();
369 sal_Int32 nI = 0;
370 // const sal_Unicode* pFormat = sFormat.getStr();
371 ::rtl::OUStringBuffer aNewFormat( sFormat.getStr() );
372 while (nI < nLen)
374 if (aNewFormat.charAt(nI) == '\\')
375 nI++;
376 else if (aNewFormat.charAt(nI) == '\"')
378 ++nI;
379 //While not at the end and not at an unescaped end quote
380 while ((nI < nLen) && (!(aNewFormat.charAt(nI) == '\"') && (aNewFormat.charAt(nI-1) != '\\')))
381 ++nI;
383 else //normal unquoted section
385 sal_Unicode nChar = aNewFormat.charAt(nI);
386 if (nChar == 'O')
388 aNewFormat.setCharAt(nI, 'M');
389 bForceNatNum = true;
391 else if (nChar == 'o')
393 aNewFormat.setCharAt(nI, 'm');
394 bForceNatNum = true;
396 else if ((nChar == 'A') && lcl_IsNotAM(sFormat, nI))
398 aNewFormat.setCharAt(nI, 'D');
399 bForceNatNum = true;
401 else if ((nChar == 'g') || (nChar == 'G'))
402 bForceJapanese = true;
403 else if ((nChar == 'a') && lcl_IsNotAM(sFormat, nI))
404 bForceJapanese = true;
405 else if (nChar == 'E')
407 if ((nI != nLen-1) && (aNewFormat.charAt(nI+1) == 'E'))
409 //todo: this cannot be the right way to replace a part of the string!
410 aNewFormat.setCharAt( nI, 'Y' );
411 aNewFormat.setCharAt( nI + 1, 'Y' );
412 aNewFormat.insert(nI + 2, ::rtl::OUString::createFromAscii("YY"));
413 nLen+=2;
414 nI+=3;
416 bForceJapanese = true;
418 else if (nChar == 'e')
420 if ((nI != nLen-1) && (aNewFormat.charAt(nI+1) == 'e'))
422 //todo: this cannot be the right way to replace a part of the string!
423 aNewFormat.setCharAt( nI, 'y' );
424 aNewFormat.setCharAt( nI + 1, 'y' );
425 aNewFormat.insert(nI + 2, ::rtl::OUString::createFromAscii("yy"));
426 nLen+=2;
427 nI+=3;
429 bForceJapanese = true;
431 else if (nChar == '/')
433 // MM We have to escape '/' in case it's used as a char
434 //todo: this cannot be the right way to replace a part of the string!
435 aNewFormat.setCharAt( nI, '\\' );
436 aNewFormat.insert(nI + 1, ::rtl::OUString::createFromAscii("/"));
437 nI++;
438 nLen++;
441 ++nI;
444 if (bForceNatNum)
445 bForceJapanese = true;
447 if (bForceJapanese)
449 rLocale.Language = ::rtl::OUString::createFromAscii("ja");
450 rLocale.Country = ::rtl::OUString::createFromAscii("JP");
453 if (bForceNatNum)
455 aNewFormat.insert( 0, ::rtl::OUString::createFromAscii("[NatNum1][$-411]"));
458 if (bHijri)
460 aNewFormat.insert( 0, ::rtl::OUString::createFromAscii("[~hijri]"));
462 return aNewFormat.makeStringAndClear();
465 /*-------------------------------------------------------------------------
467 -----------------------------------------------------------------------*/
468 sal_Int32 convertTwipToMM100(sal_Int32 _t)
470 return TWIP_TO_MM100( _t );
472 /*-- 09.08.2007 09:34:44---------------------------------------------------
474 -----------------------------------------------------------------------*/
475 sal_Int32 convertEMUToMM100(sal_Int32 _t)
477 return _t / 360;
480 /*-- 21.11.2006 08:47:12---------------------------------------------------
481 contains a color from 0xTTRRGGBB to 0xTTRRGGBB
482 -----------------------------------------------------------------------*/
483 sal_Int32 ConvertColor(sal_Int32 nWordColor)
485 sal_uInt8
486 r(static_cast<sal_uInt8>(nWordColor&0xFF)),
487 g(static_cast<sal_uInt8>(((nWordColor)>>8)&0xFF)),
488 b(static_cast<sal_uInt8>((nWordColor>>16)&0xFF)),
489 t(static_cast<sal_uInt8>((nWordColor>>24)&0xFF));
490 sal_Int32 nRet = (t<<24) + (r<<16) + (g<<8) + b;
491 return nRet;
493 /*-- 12.12.2006 08:59:42---------------------------------------------------
495 -----------------------------------------------------------------------*/
496 class closeenough : public std::unary_function<long, bool>
498 private:
499 long mnValue;
500 long mnWriggleRoom;
501 public:
502 closeenough(long nValue, long nWriggleRoom)
503 : mnValue(nValue), mnWriggleRoom(nWriggleRoom) {}
504 bool operator()(long nTest) const
506 return (
507 (mnValue - nTest < mnWriggleRoom) &&
508 (mnValue - nTest > -mnWriggleRoom)
512 /*-- 12.12.2006 08:59:42---------------------------------------------------
514 -----------------------------------------------------------------------*/
515 sal_Int32 SnapPageDimension( sal_Int32 nVal )
517 static const long aSizes[] =
519 lA0Width, lA0Height, lA1Width, lA2Width, lA3Width, lA4Width,
520 lA5Width, lB4Width, lB4Height, lB5Width, lB6Width, lC4Width,
521 lC4Height, lC5Width, lC6Width, lC65Width, lC65Height, lDLWidth,
522 lDLHeight, lJISB4Width, lJISB4Height, lJISB5Width, lJISB6Width,
523 lLetterWidth, lLetterHeight, lLegalHeight, lTabloidWidth,
524 lTabloidHeight, lDiaWidth, lDiaHeight, lScreenWidth,
525 lScreenHeight, lAWidth, lAHeight, lBHeight, lCHeight, lDHeight,
526 lEHeight, lExeWidth, lExeHeight, lLegal2Width, lLegal2Height,
527 lCom675Width, lCom675Height, lCom9Width, lCom9Height,
528 lCom10Width, lCom10Height, lCom11Width, lCom11Height,
529 lCom12Width, lMonarchHeight, lKai16Width, lKai16Height,
530 lKai32Width, lKai32BigWidth, lKai32BigHeight
533 const long nWriggleRoom = 5;
534 const long *pEnd = aSizes + sizeof(aSizes) / sizeof(aSizes[0]);
535 const long *pEntry =
536 std::find_if(aSizes, pEnd, closeenough(nVal, nWriggleRoom));
538 if (pEntry != pEnd)
539 nVal = *pEntry;
541 return nVal;
543 /*-- 27.06.2007 13:42:32---------------------------------------------------
545 -----------------------------------------------------------------------*/
546 sal_Int16 convertTableJustification( sal_Int32 nIntValue )
548 sal_Int16 nOrient = text::HoriOrientation::LEFT_AND_WIDTH;
549 switch( nIntValue )
551 case 1 : nOrient = text::HoriOrientation::CENTER; break;
552 case 2 : nOrient = text::HoriOrientation::RIGHT; break;
553 case 0 :
554 //no break
555 default:;
558 return nOrient;
560 /*-- 06.08.2007 15:27:30---------------------------------------------------
561 conversion form xsd::DateTime
562 [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]
563 -----------------------------------------------------------------------*/
564 com::sun::star::util::DateTime convertDateTime( const ::rtl::OUString& rDateTimeString )
566 util::DateTime aRet( 0, 0, 0, 0, 1, 1, 1901 );
568 sal_Int32 nIndex = 0;
569 ::rtl::OUString sDate( rDateTimeString.getToken( 0, 'T', nIndex ));
570 sal_Int32 nDateIndex = 0;
571 aRet.Year = (sal_uInt16)sDate.getToken( 0, '-', nDateIndex ).toInt32();
572 if( nDateIndex > 0)
573 aRet.Month = (sal_uInt16)sDate.getToken( 0, '-', nDateIndex ).toInt32();
574 if( nDateIndex > 0)
575 aRet.Day = (sal_uInt16)sDate.getToken( 0, '-', nDateIndex ).toInt32();
576 ::rtl::OUString sTime;
577 if(nIndex > 0)
579 sTime = ( rDateTimeString.getToken( 0, 'Z', nIndex ));
580 sal_Int32 nTimeIndex = 0;
581 aRet.Hours = (sal_uInt16)sTime.getToken( 0, ':', nTimeIndex ).toInt32();
582 if( nTimeIndex > 0)
583 aRet.Minutes = (sal_uInt16)sTime.getToken( 0, ':', nTimeIndex ).toInt32();
584 if( nTimeIndex > 0)
586 ::rtl::OUString sSeconds = sTime.getToken( 0, ':', nTimeIndex );
587 nTimeIndex = 0;
588 aRet.Seconds = (sal_uInt16)sSeconds.getToken( 0, '.', nTimeIndex ).toInt32();
589 aRet.HundredthSeconds = (sal_uInt16)sSeconds.getToken( 0, '.', nTimeIndex ).toInt32();
592 // todo: ignore time offset for a while - there's no time zone available
593 // nIndex = 0;
594 // ::rtl::OUString sOffset( rDateTimeString.getToken( 1, 'Z', nIndex ));
595 // if( sOffset.getLength() )
596 // {
597 // add hour and minute offset and increase/decrease date if necessary
598 // }
600 return aRet;
602 /*-- 05.03.2008 09:10:13---------------------------------------------------
604 -----------------------------------------------------------------------*/
605 sal_Int16 ConvertNumberingType(sal_Int32 nNFC)
607 sal_Int16 nRet;
608 switch(nNFC)
610 case NS_ooxml::LN_Value_ST_NumberFormat_decimal:
611 case 0: nRet = style::NumberingType::ARABIC; break;
612 case NS_ooxml::LN_Value_ST_NumberFormat_upperRoman:
613 case 1: nRet = style::NumberingType::ROMAN_UPPER; break;
614 case NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman:
615 case 2: nRet = style::NumberingType::ROMAN_LOWER; break;
616 case 3: nRet = style::NumberingType::CHARS_UPPER_LETTER_N; break;
617 case 4: nRet = style::NumberingType::CHARS_LOWER_LETTER_N; break;
618 case 5: nRet = style::NumberingType::ARABIC; break;//ORDINAL
619 case NS_ooxml::LN_Value_ST_NumberFormat_bullet:
620 case 23:
621 case 25:
622 nRet = style::NumberingType::CHAR_SPECIAL;
623 break;
624 case 255: nRet = style::NumberingType::NUMBER_NONE; break;
625 case NS_ooxml::LN_Value_ST_NumberFormat_upperLetter:
626 nRet = style::NumberingType::CHARS_UPPER_LETTER;
627 break;
628 case NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter:
629 nRet = style::NumberingType::CHARS_LOWER_LETTER;
630 break;
631 default: nRet = style::NumberingType::ARABIC;
633 /* TODO: Lots of additional values are available - some are supported in the I18 framework
634 NS_ooxml::LN_Value_ST_NumberFormat_ordinal = 91682;
635 NS_ooxml::LN_Value_ST_NumberFormat_cardinalText = 91683;
636 NS_ooxml::LN_Value_ST_NumberFormat_ordinalText = 91684;
637 NS_ooxml::LN_Value_ST_NumberFormat_hex = 91685;
638 NS_ooxml::LN_Value_ST_NumberFormat_chicago = 91686;
639 NS_ooxml::LN_Value_ST_NumberFormat_ideographDigital = 91687;
640 NS_ooxml::LN_Value_ST_NumberFormat_japaneseCounting = 91688;
641 NS_ooxml::LN_Value_ST_NumberFormat_aiueo = 91689;
642 NS_ooxml::LN_Value_ST_NumberFormat_iroha = 91690;
643 NS_ooxml::LN_Value_ST_NumberFormat_decimalFullWidth = 91691;
644 NS_ooxml::LN_Value_ST_NumberFormat_decimalHalfWidth = 91692;
645 NS_ooxml::LN_Value_ST_NumberFormat_japaneseLegal = 91693;
646 NS_ooxml::LN_Value_ST_NumberFormat_japaneseDigitalTenThousand = 91694;
647 NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedCircle = 91695;
648 NS_ooxml::LN_Value_ST_NumberFormat_decimalFullWidth2 = 91696;
649 NS_ooxml::LN_Value_ST_NumberFormat_aiueoFullWidth = 91697;
650 NS_ooxml::LN_Value_ST_NumberFormat_irohaFullWidth = 91698;
651 NS_ooxml::LN_Value_ST_NumberFormat_decimalZero = 91699;
652 NS_ooxml::LN_Value_ST_NumberFormat_ganada = 91701;
653 NS_ooxml::LN_Value_ST_NumberFormat_chosung = 91702;
654 NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedFullstop = 91703;
655 NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedParen = 91704;
656 NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedCircleChinese = 91705;
657 NS_ooxml::LN_Value_ST_NumberFormat_ideographEnclosedCircle = 91706;
658 NS_ooxml::LN_Value_ST_NumberFormat_ideographTraditional = 91707;
659 NS_ooxml::LN_Value_ST_NumberFormat_ideographZodiac = 91708;
660 NS_ooxml::LN_Value_ST_NumberFormat_ideographZodiacTraditional = 91709;
661 NS_ooxml::LN_Value_ST_NumberFormat_taiwaneseCounting = 91710;
662 NS_ooxml::LN_Value_ST_NumberFormat_ideographLegalTraditional = 91711;
663 NS_ooxml::LN_Value_ST_NumberFormat_taiwaneseCountingThousand = 91712;
664 NS_ooxml::LN_Value_ST_NumberFormat_taiwaneseDigital = 91713;
665 NS_ooxml::LN_Value_ST_NumberFormat_chineseCounting = 91714;
666 NS_ooxml::LN_Value_ST_NumberFormat_chineseLegalSimplified = 91715;
667 NS_ooxml::LN_Value_ST_NumberFormat_chineseCountingThousand = 91716;
668 NS_ooxml::LN_Value_ST_NumberFormat_koreanDigital = 91717;
669 NS_ooxml::LN_Value_ST_NumberFormat_koreanCounting = 91718;
670 NS_ooxml::LN_Value_ST_NumberFormat_koreanLegal = 91719;
671 NS_ooxml::LN_Value_ST_NumberFormat_koreanDigital2 = 91720;
672 NS_ooxml::LN_Value_ST_NumberFormat_vietnameseCounting = 91721;
673 NS_ooxml::LN_Value_ST_NumberFormat_russianLower = 91722;
674 NS_ooxml::LN_Value_ST_NumberFormat_russianUpper = 91723;
675 NS_ooxml::LN_Value_ST_NumberFormat_none = 91724;
676 NS_ooxml::LN_Value_ST_NumberFormat_numberInDash = 91725;
677 NS_ooxml::LN_Value_ST_NumberFormat_hebrew1 = 91726;
678 NS_ooxml::LN_Value_ST_NumberFormat_hebrew2 = 91727;
679 NS_ooxml::LN_Value_ST_NumberFormat_arabicAlpha = 91728;
680 NS_ooxml::LN_Value_ST_NumberFormat_arabicAbjad = 91729;
681 NS_ooxml::LN_Value_ST_NumberFormat_hindiVowels = 91730;
682 NS_ooxml::LN_Value_ST_NumberFormat_hindiConsonants = 91731;
683 NS_ooxml::LN_Value_ST_NumberFormat_hindiNumbers = 91732;
684 NS_ooxml::LN_Value_ST_NumberFormat_hindiCounting = 91733;
685 NS_ooxml::LN_Value_ST_NumberFormat_thaiLetters = 91734;
686 NS_ooxml::LN_Value_ST_NumberFormat_thaiNumbers = 91735;
687 NS_ooxml::LN_Value_ST_NumberFormat_thaiCounting = 91736;*/
688 return nRet;
692 } // namespace ConversionHelper
693 } //namespace dmapper
694 } //namespace writerfilter