Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * The Contents of this file are made available subject to the terms of
5 : * either of the following licenses
6 : *
7 : * - GNU Lesser General Public License Version 2.1
8 : * - Sun Industry Standards Source License Version 1.1
9 : *
10 : * Sun Microsystems Inc., October, 2000
11 : *
12 : * GNU Lesser General Public License Version 2.1
13 : * =============================================
14 : * Copyright 2000 by Sun Microsystems, Inc.
15 : * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 : *
17 : * This library is free software; you can redistribute it and/or
18 : * modify it under the terms of the GNU Lesser General Public
19 : * License version 2.1, as published by the Free Software Foundation.
20 : *
21 : * This library is distributed in the hope that it will be useful,
22 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 : * Lesser General Public License for more details.
25 : *
26 : * You should have received a copy of the GNU Lesser General Public
27 : * License along with this library; if not, write to the Free Software
28 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 : * MA 02111-1307 USA
30 : *
31 : *
32 : * Sun Industry Standards Source License Version 1.1
33 : * =================================================
34 : * The contents of this file are subject to the Sun Industry Standards
35 : * Source License Version 1.1 (the "License"); You may not use this file
36 : * except in compliance with the License. You may obtain a copy of the
37 : * License at http://www.openoffice.org/license.html.
38 : *
39 : * Software provided under this License is provided on an "AS IS" basis,
40 : * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 : * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 : * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 : * See the License for the specific provisions governing your rights and
44 : * obligations concerning the Software.
45 : *
46 : * The Initial Developer of the Original Code is: IBM Corporation
47 : *
48 : * Copyright: 2008 by IBM Corporation
49 : *
50 : * All Rights Reserved.
51 : *
52 : * Contributor(s): _______________________________________
53 : *
54 : *
55 : ************************************************************************/
56 : /*************************************************************************
57 : * @file
58 : * For LWP filter architecture prototype
59 : ************************************************************************/
60 : /*************************************************************************
61 : * Change History
62 : Jan 2005 Created
63 : ************************************************************************/
64 :
65 : #include "lwptools.hxx"
66 : #include <rtl/ustrbuf.hxx>
67 : #include <osl/process.h>
68 : #include <osl/thread.h>
69 : #include <osl/file.hxx>
70 : #include <vcl/svapp.hxx>
71 : #include <vcl/settings.hxx>
72 : #include <unicode/datefmt.h>
73 : #include <unicode/udat.h>
74 : #include <i18nlangtag/languagetagicu.hxx>
75 :
76 : #ifdef SAL_UNX
77 : #define SEPARATOR '/'
78 : #else
79 : #define SEPARATOR '\\'
80 : #endif
81 :
82 : using namespace icu;
83 : using namespace ::rtl;
84 : using namespace ::osl;
85 :
86 : /**
87 : * @descr read lwp unicode string from stream to OUString per aEncoding
88 : */
89 0 : sal_uInt16 LwpTools::QuickReadUnicode(LwpObjectStream* pObjStrm,
90 : OUString& str, sal_uInt16 strlen, rtl_TextEncoding aEncoding)
91 : //strlen: length of bytes
92 : {
93 :
94 0 : sal_uInt16 readLen = 0;
95 0 : OUStringBuffer strBuf(128);
96 :
97 0 : if( !IsUnicodePacked(pObjStrm, strlen) )
98 : {
99 0 : sal_uInt16 len = 0;
100 : sal_Char buf[1024];
101 :
102 0 : while(strlen)
103 : {
104 0 : strlen>1023?len=1023 :len=strlen;
105 0 : len = pObjStrm->QuickRead(buf, len);
106 0 : buf[len] = '\0';
107 0 : strBuf.append( OUString(buf, len, aEncoding) );
108 0 : strlen -= len;
109 0 : readLen += len;
110 0 : if(!len) break;
111 : }
112 0 : str = strBuf.makeStringAndClear();
113 0 : return readLen;
114 : }
115 : else
116 : {
117 : sal_Char buf[1024];
118 : sal_Unicode unibuf[1024];
119 : sal_uInt8 readbyte;
120 : sal_uInt16 readword;
121 :
122 0 : sal_Bool flag = sal_False; //switch if unicode part reached
123 0 : sal_uInt16 sublen = 0;
124 :
125 0 : while(readLen<strlen)
126 : {
127 0 : if(!flag) //Not unicode string
128 : {
129 : bool bFailure;
130 0 : readbyte = pObjStrm->QuickReaduInt8(&bFailure);
131 0 : if(bFailure) break;
132 0 : readLen+=sizeof(readbyte);
133 :
134 0 : if(readbyte == 0x00)
135 : {
136 0 : flag = sal_True;
137 0 : if(sublen>0) //add it to the strBuf
138 : {
139 0 : strBuf.append( OUString(buf, sublen, aEncoding) ); //try the aEncoding
140 0 : sublen = 0;
141 : }
142 : }
143 : else
144 : {
145 0 : buf[sublen++] = readbyte;
146 : }
147 0 : if(sublen>=1023 || readLen==strlen) //add it to the strBuf
148 : {
149 0 : strBuf.append( OUString(buf, sublen, aEncoding) ); //try the aEncoding
150 0 : sublen = 0;
151 : }
152 : }
153 : else //unicode string
154 : {
155 : bool bFailure;
156 0 : readword = pObjStrm->QuickReaduInt16(&bFailure);
157 0 : if(bFailure) break;
158 0 : readLen+=sizeof(readword);
159 :
160 0 : if(readword == 0x0000)
161 : {
162 0 : flag = sal_False;
163 0 : if(sublen)
164 : {
165 0 : unibuf[sublen] = '\0';
166 0 : strBuf.append( OUString(unibuf) );
167 0 : sublen = 0;
168 : }
169 : }
170 : else
171 : {
172 0 : unibuf[sublen++] = readword;
173 : }
174 0 : if(sublen>=1023 || readLen==strlen)
175 : {
176 0 : unibuf[sublen] = '\0';
177 0 : strBuf.append( OUString(unibuf) );
178 0 : sublen = 0;
179 : }
180 : }
181 : }
182 0 : str = strBuf.makeStringAndClear();
183 0 : return readLen;
184 0 : }
185 : }
186 :
187 : /**
188 : * @descr Judge if the data (len) in object stream is lwp unicode packed
189 : */
190 0 : sal_Bool LwpTools::IsUnicodePacked(LwpObjectStream* pObjStrm, sal_uInt16 len)
191 : {
192 : sal_uInt8 byte;
193 0 : sal_uInt16 oldpos = pObjStrm->GetPos();
194 :
195 0 : for (sal_uInt16 i = 0; i < len; i++)
196 : {
197 0 : byte = pObjStrm->QuickReaduInt8();
198 0 : if (byte == 0x00)
199 : {
200 0 : pObjStrm->Seek(oldpos);
201 0 : return sal_True;
202 : }
203 : }
204 0 : pObjStrm->Seek(oldpos);
205 0 : return sal_False;
206 : }
207 :
208 0 : sal_Bool LwpTools::isFileUrl(const OString &fileName)
209 : {
210 0 : if (fileName.startsWith("file://") )
211 0 : return sal_True;
212 0 : return sal_False;
213 : }
214 :
215 0 : OUString LwpTools::convertToFileUrl(const OString &fileName)
216 : {
217 0 : if ( isFileUrl(fileName) )
218 : {
219 0 : return OStringToOUString(fileName, osl_getThreadTextEncoding());
220 : }
221 :
222 0 : OUString uUrlFileName;
223 0 : OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding());
224 0 : if ( fileName.startsWith(".") || fileName.indexOf(SEPARATOR) < 0 )
225 : {
226 0 : OUString uWorkingDir;
227 0 : OSL_VERIFY( osl_getProcessWorkingDir(&uWorkingDir.pData) == osl_Process_E_None );
228 0 : OSL_VERIFY( FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uUrlFileName) == FileBase::E_None );
229 : } else
230 : {
231 0 : OSL_VERIFY( FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName) == FileBase::E_None );
232 : }
233 :
234 0 : return uUrlFileName;
235 : }
236 :
237 0 : OUString LwpTools::DateTimeToOUString(LtTm & dt)
238 : {
239 0 : OUString aResult = OUString::number(dt.tm_year) + "-" + OUString::number(dt.tm_mon) + "-" + OUString::number(dt.tm_mday) +
240 0 : "T" + OUString::number(dt.tm_hour) + ":" + OUString::number(dt.tm_min) + ":" + OUString::number(dt.tm_sec);
241 :
242 0 : return aResult;
243 : }
244 :
245 : /**
246 : * @descr get the system date format
247 : */
248 0 : XFDateStyle* LwpTools::GetSystemDateStyle(sal_Bool bLongFormat)
249 : {
250 : icu::DateFormat::EStyle style;
251 0 : if (bLongFormat)
252 0 : style = icu::DateFormat::FULL;//system full date format
253 : else
254 0 : style = icu::DateFormat::SHORT;//system short date format
255 :
256 : //1 get locale for system
257 0 : icu::Locale aLocale( LanguageTagIcu::getIcuLocale( Application::GetSettings().GetLanguageTag()));
258 : //2 get icu format pattern by locale
259 0 : icu::DateFormat* fmt = icu::DateFormat::createDateInstance(style,aLocale);
260 :
261 0 : int32_t nLength = 0;
262 : int32_t nLengthNeed;
263 0 : UErrorCode status = U_ZERO_ERROR;
264 0 : UChar* pattern = NULL;
265 :
266 0 : nLengthNeed = udat_toPattern((void *const *)fmt,sal_False,NULL,nLength,&status);
267 0 : if (status == U_BUFFER_OVERFLOW_ERROR)
268 : {
269 0 : status = U_ZERO_ERROR;
270 0 : nLength = nLengthNeed +1;
271 0 : pattern = (UChar*)malloc(sizeof(UChar)*nLength);
272 0 : udat_toPattern((void *const *)fmt,sal_False,pattern,nLength,&status);
273 : }
274 0 : if (pattern == NULL)
275 0 : return NULL;
276 : // 3 parse pattern string,per icu date/time format syntax, there are 20 letters reserved
277 : // as patter letter,each represent a element in date/time and its repeat numbers represent
278 : // different format: for exampel: M produces '1',MM produces '01', MMM produces 'Jan', MMMM produces 'Januaray'
279 : // letter other than these letters is regard as text in the format, for example ','in 'Jan,2005'
280 : // we parse pattern string letter by letter and get the time format.
281 : UChar cSymbol;
282 : UChar cTmp;
283 0 : XFDateStyle* pDateStyle = new XFDateStyle;
284 :
285 0 : for (int32_t i=0;i<nLengthNeed;)
286 : {
287 0 : cSymbol = pattern[i];
288 : int32_t j;
289 0 : switch(cSymbol)
290 : {
291 : case 'G':
292 : {
293 0 : for (j=1;;j++)
294 : {
295 0 : cTmp = pattern[i+j];
296 0 : if (cTmp != cSymbol)
297 : {
298 0 : i=i+j;
299 0 : break;
300 : }
301 : }
302 0 : pDateStyle->AddEra();
303 0 : break;
304 : }
305 : case 'y':
306 : {
307 0 : for (j=1;;j++)
308 : {
309 0 : cTmp = pattern[i+j];
310 0 : if (cTmp != cSymbol)
311 : {
312 0 : i=i+j;
313 0 : break;
314 : }
315 : }
316 0 : if (j <= 2)
317 0 : pDateStyle->AddYear(sal_False);
318 : else
319 0 : pDateStyle->AddYear();
320 0 : break;
321 : }
322 : case 'M':
323 : {
324 0 : for (j=1;;j++)
325 : {
326 0 : cTmp = pattern[i+j];
327 0 : if (cTmp != cSymbol)
328 : {
329 0 : i=i+j;
330 0 : break;
331 : }
332 : }
333 0 : if (j==1)
334 0 : pDateStyle->AddMonth(sal_False,sal_False);
335 0 : else if (j==2)
336 0 : pDateStyle->AddMonth(sal_True,sal_False);
337 0 : else if (j==3)
338 0 : pDateStyle->AddMonth(sal_False,sal_True);
339 : else
340 0 : pDateStyle->AddMonth(sal_True,sal_True);
341 0 : break;
342 : }
343 : case 'd':
344 : {
345 0 : for (j=1;;j++)
346 : {
347 0 : cTmp = pattern[i+j];
348 0 : if (cTmp != cSymbol)
349 : {
350 0 : i=i+j;
351 0 : break;
352 : }
353 : }
354 0 : if (j==1)
355 0 : pDateStyle->AddMonthDay(sal_False);
356 : else
357 0 : pDateStyle->AddMonthDay();
358 0 : break;
359 : }
360 : case 'h':
361 : {
362 0 : for (j=1;;j++)
363 : {
364 0 : cTmp = pattern[i+j];
365 0 : if (cTmp != cSymbol)
366 : {
367 0 : i=i+j;
368 0 : break;
369 : }
370 : }
371 0 : if (j==1)
372 0 : pDateStyle->AddHour(sal_False);
373 : else
374 0 : pDateStyle->AddHour();
375 0 : break;
376 : }
377 : case 'H':
378 : {
379 0 : for (j=1;;j++)
380 : {
381 0 : cTmp = pattern[i+j];
382 0 : if (cTmp != cSymbol)
383 : {
384 0 : i=i+j;
385 0 : break;
386 : }
387 : }
388 0 : if (j==1)
389 0 : pDateStyle->AddHour(sal_False);
390 : else
391 0 : pDateStyle->AddHour();
392 0 : break;
393 : }
394 : case 'm':
395 : {
396 0 : for (j=1;;j++)
397 : {
398 0 : cTmp = pattern[i+j];
399 0 : if (cTmp != cSymbol)
400 : {
401 0 : i=i+j;
402 0 : break;
403 : }
404 : }
405 0 : if (j==1)
406 0 : pDateStyle->AddMinute(sal_False);
407 : else
408 0 : pDateStyle->AddMinute();
409 0 : break;
410 : }
411 : case 's':
412 : {
413 0 : for (j=1;;j++)
414 : {
415 0 : cTmp = pattern[i+j];
416 0 : if (cTmp != cSymbol)
417 : {
418 0 : i=i+j;
419 0 : break;
420 : }
421 : }
422 0 : if (j==1)
423 0 : pDateStyle->AddSecond(sal_False,0);
424 : else
425 0 : pDateStyle->AddSecond(sal_True,0);
426 0 : break;
427 : }
428 : case 'S':
429 : {
430 0 : for (j=1;;j++)
431 : {
432 0 : cTmp = pattern[i+j];
433 0 : if (cTmp != cSymbol)
434 : {
435 0 : i=i+j;
436 0 : break;
437 : }
438 : }
439 : /*if (j==1)
440 : pDateStyle->AddSecond(sal_False);
441 : else
442 : pDateStyle->AddSecond();*/
443 0 : break;
444 : }
445 : case 'E':
446 : {
447 0 : for (j=1;;j++)
448 : {
449 0 : cTmp = pattern[i+j];
450 0 : if (cTmp != cSymbol)
451 : {
452 0 : i=i+j;
453 0 : break;
454 : }
455 : }
456 0 : if (j<=2)
457 0 : pDateStyle->AddWeekDay(sal_False);
458 : else
459 0 : pDateStyle->AddWeekDay();
460 0 : break;
461 : }
462 : case 'D':
463 : {
464 0 : for (j=1;;j++)
465 : {
466 0 : cTmp = pattern[i+j];
467 0 : if (cTmp != cSymbol)
468 : {
469 0 : i=i+j;
470 0 : break;
471 : }
472 : }
473 : /*if (j==1)
474 : pDateStyle->AddWeekDay(sal_False);
475 : else
476 : pDateStyle->AddWeekDay();*/
477 0 : break;
478 : }
479 : case 'F':
480 : {
481 0 : for (j=1;;j++)
482 : {
483 0 : cTmp = pattern[i+j];
484 0 : if (cTmp != cSymbol)
485 : {
486 0 : i=i+j;
487 0 : break;
488 : }
489 : }
490 : /*if (j==1)
491 : pDateStyle->AddWeekDay(sal_False);
492 : else
493 : pDateStyle->AddWeekDay();*/
494 0 : break;
495 : }
496 : case 'w':
497 : {
498 0 : for (j=1;;j++)
499 : {
500 0 : cTmp = pattern[i+j];
501 0 : if (cTmp != cSymbol)
502 : {
503 0 : i=i+j;
504 0 : break;
505 : }
506 : }
507 : /*if (j==1)
508 : pDateStyle->AddWeekDay(sal_False);
509 : else
510 : pDateStyle->AddWeekDay();*/
511 0 : break;
512 : }
513 : case 'W':
514 : {
515 0 : for (j=1;;j++)
516 : {
517 0 : cTmp = pattern[i+j];
518 0 : if (cTmp != cSymbol)
519 : {
520 0 : i=i+j;
521 0 : break;
522 : }
523 : }
524 : /*if (j==1)
525 : pDateStyle->AddWeekDay(sal_False);
526 : else
527 : pDateStyle->AddWeekDay();*/
528 0 : break;
529 : }
530 : case 'a':
531 : {
532 0 : for (j=1;;j++)
533 : {
534 0 : cTmp = pattern[i+j];
535 0 : if (cTmp != cSymbol)
536 : {
537 0 : i=i+j;
538 0 : break;
539 : }
540 : }
541 0 : pDateStyle->AddAmPm(sal_True);
542 0 : break;
543 : }
544 : case 'k':
545 : {
546 0 : for (j=1;;j++)
547 : {
548 0 : cTmp = pattern[i+j];
549 0 : if (cTmp != cSymbol)
550 : {
551 0 : i=i+j;
552 0 : break;
553 : }
554 : }
555 0 : break;
556 : }
557 : case 'K':
558 : {
559 0 : for (j=1;;j++)
560 : {
561 0 : cTmp = pattern[i+j];
562 0 : if (cTmp != cSymbol)
563 : {
564 0 : i=i+j;
565 0 : break;
566 : }
567 : }
568 0 : if (j==1)
569 0 : pDateStyle->AddHour(sal_False);
570 : else
571 0 : pDateStyle->AddHour();
572 0 : break;
573 : }
574 : case 'Z':
575 : {
576 0 : for (j=1;;j++)
577 : {
578 0 : cTmp = pattern[i+j];
579 0 : if (cTmp != cSymbol)
580 : {
581 0 : i=i+j;
582 0 : break;
583 : }
584 : }
585 0 : break;
586 : }
587 : case '\''://'
588 : {
589 0 : for (j=1;;j++)
590 : {
591 0 : cTmp = pattern[i+j];
592 0 : if (cTmp != cSymbol)
593 : {
594 0 : i=i+j;
595 0 : break;
596 : }
597 : }
598 0 : break;
599 : }
600 : case '"':
601 : {
602 0 : pDateStyle->AddText("'");
603 0 : break;
604 : }
605 : default:
606 : {
607 0 : if ((cSymbol>='A' && cSymbol<='Z') || (cSymbol>='a' && cSymbol<='z') )
608 0 : return NULL;
609 : else//TEXT
610 : {
611 : //UChar buffer[1024];
612 : sal_Unicode buffer[1024];
613 0 : buffer[0] = cSymbol;
614 0 : for (j=1;;j++)
615 : {
616 0 : cTmp = pattern[i+j];
617 0 : if ((cTmp>='A' && cTmp<='Z') || (cTmp>='a' && cTmp<='z') ||
618 0 : cTmp=='\'' || cTmp=='"' )
619 : {
620 0 : i=i+j;
621 0 : buffer[j]= '\0';
622 0 : break;
623 : }
624 : else
625 0 : buffer[j] = cTmp;
626 : }
627 :
628 0 : pDateStyle->AddText(OUString(buffer));//keep for all parsed
629 : }
630 0 : break;
631 0 : }
632 : }
633 : }
634 : // udat_close(fmt);
635 0 : return pDateStyle;
636 : }
637 : /**
638 : * @descr get the system time format
639 : */
640 0 : XFTimeStyle* LwpTools::GetSystemTimeStyle()
641 : {
642 : //1 get locale for system
643 0 : icu::Locale aLocale( LanguageTagIcu::getIcuLocale( Application::GetSettings().GetLanguageTag()));
644 : //2 get icu format pattern by locale
645 0 : icu::DateFormat* fmt = icu::DateFormat::createTimeInstance(icu::DateFormat::DEFAULT,aLocale);
646 :
647 0 : int32_t nLength = 0;
648 : int32_t nLengthNeed;
649 0 : UErrorCode status = U_ZERO_ERROR;
650 0 : UChar* pattern = NULL;
651 0 : nLengthNeed = udat_toPattern((void *const *)fmt,false,NULL,nLength,&status);
652 0 : if (status == U_BUFFER_OVERFLOW_ERROR)
653 : {
654 0 : status = U_ZERO_ERROR;
655 0 : nLength = nLengthNeed +1;
656 0 : pattern = (UChar*)malloc(sizeof(UChar)*nLength);
657 0 : udat_toPattern((void *const *)fmt,false,pattern,nLength,&status);
658 : }
659 :
660 0 : if (pattern == NULL)
661 0 : return NULL;
662 : // 3 parse pattern string,per icu date/time format syntax, there are 20 letters reserved
663 : // as patter letter,each represent a element in date/time and its repeat numbers represent
664 : // different format: for exampel: M produces '1',MM produces '01', MMM produces 'Jan', MMMM produces 'Januaray'
665 : // letter other than these letters is regard as text in the format, for example ','in 'Jan,2005'
666 : // we parse pattern string letter by letter and get the time format.
667 : // for time format ,for there is not date info,we can only parse the letter representing time.
668 : UChar cSymbol;
669 : UChar cTmp;
670 0 : XFTimeStyle* pTimeStyle = new XFTimeStyle;
671 :
672 0 : for (int32_t i=0;i<nLengthNeed;)
673 : {
674 0 : cSymbol = pattern[i];
675 : int32_t j;
676 0 : switch(cSymbol)
677 : {
678 : case 'h':
679 : {
680 0 : for (j=1;;j++)
681 : {
682 0 : cTmp = pattern[i+j];
683 0 : if (cTmp != cSymbol)
684 : {
685 0 : i=i+j;
686 0 : break;
687 : }
688 : }
689 0 : if (j==1)
690 0 : pTimeStyle->AddHour(sal_False);
691 : else
692 0 : pTimeStyle->AddHour();
693 0 : break;
694 : }
695 : case 'H':
696 : {
697 0 : for (j=1;;j++)
698 : {
699 0 : cTmp = pattern[i+j];
700 0 : if (cTmp != cSymbol)
701 : {
702 0 : i=i+j;
703 0 : break;
704 : }
705 : }
706 0 : if (j==1)
707 0 : pTimeStyle->AddHour(sal_False);
708 : else
709 0 : pTimeStyle->AddHour();
710 0 : break;
711 : }
712 : case 'm':
713 : {
714 0 : for (j=1;;j++)
715 : {
716 0 : cTmp = pattern[i+j];
717 0 : if (cTmp != cSymbol)
718 : {
719 0 : i=i+j;
720 0 : break;
721 : }
722 : }
723 0 : if (j==1)
724 0 : pTimeStyle->AddMinute(sal_False);
725 : else
726 0 : pTimeStyle->AddMinute();
727 0 : break;
728 : }
729 : case 's':
730 : {
731 0 : for (j=1;;j++)
732 : {
733 0 : cTmp = pattern[i+j];
734 0 : if (cTmp != cSymbol)
735 : {
736 0 : i=i+j;
737 0 : break;
738 : }
739 : }
740 0 : if (j==1)
741 0 : pTimeStyle->AddSecond(sal_False,0);
742 : else
743 0 : pTimeStyle->AddSecond(sal_True,0);
744 0 : break;
745 : }
746 : case 'S':
747 : {
748 0 : for (j=1;;j++)
749 : {
750 0 : cTmp = pattern[i+j];
751 0 : if (cTmp != cSymbol)
752 : {
753 0 : i=i+j;
754 0 : break;
755 : }
756 : }
757 : /*if (j==1)
758 : pDateStyle->AddSecond(sal_False);
759 : else
760 : pDateStyle->AddSecond();*/
761 0 : break;
762 : }
763 : case 'a':
764 : {
765 0 : for (j=1;;j++)
766 : {
767 0 : cTmp = pattern[i+j];
768 0 : if (cTmp != cSymbol)
769 : {
770 0 : i=i+j;
771 0 : break;
772 : }
773 : }
774 0 : pTimeStyle->SetAmPm(sal_True);
775 0 : break;
776 : }
777 : case 'k':
778 : {
779 0 : for (j=1;;j++)
780 : {
781 0 : cTmp = pattern[i+j];
782 0 : if (cTmp != cSymbol)
783 : {
784 0 : i=i+j;
785 0 : break;
786 : }
787 : }
788 0 : break;
789 : }
790 : case 'K':
791 : {
792 0 : for (j=1;;j++)
793 : {
794 0 : cTmp = pattern[i+j];
795 0 : if (cTmp != cSymbol)
796 : {
797 0 : i=i+j;
798 0 : break;
799 : }
800 : }
801 0 : if (j==1)
802 0 : pTimeStyle->AddHour(sal_False);
803 : else
804 0 : pTimeStyle->AddHour();
805 0 : break;
806 : }
807 : case '\''://'
808 : {
809 0 : for (j=1;;j++)
810 : {
811 0 : cTmp = pattern[i+j];
812 0 : if (cTmp != cSymbol)
813 : {
814 0 : i=i+j;
815 0 : break;
816 : }
817 : }
818 0 : break;
819 : }
820 : case '"':
821 : {
822 0 : pTimeStyle->AddText("'");
823 0 : break;
824 : }
825 : default:
826 : {
827 0 : if ((cSymbol>='A' && cSymbol<='Z') || (cSymbol>='a' && cSymbol<='z') )
828 0 : return NULL;
829 : else//TEXT
830 : {
831 : sal_Unicode buffer[1024];
832 0 : buffer[0] = cSymbol;
833 : //strBuffer.append(cSymbol);
834 0 : for (j=1;;j++)
835 : {
836 0 : cTmp = pattern[i+j];
837 0 : if ((cTmp>='A' && cTmp<='Z') || (cTmp>='a' && cTmp<='z') ||
838 0 : cTmp=='\'' || cTmp=='"' )
839 : {
840 0 : i=i+j;
841 0 : buffer[j]= '\0';
842 0 : break;
843 : }
844 : else
845 0 : buffer[j] = cTmp;
846 : }
847 0 : pTimeStyle->AddText(OUString(buffer));//keep for all parsed
848 : }
849 0 : break;
850 0 : }
851 : }
852 : }
853 : // udat_close(fmt);
854 0 : return pTimeStyle;
855 : }
856 :
857 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|