diff options
author | Oliver Bolte <obo@openoffice.org> | 2004-11-16 11:53:22 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2004-11-16 11:53:22 +0000 |
commit | 0150775fed3d2c1e1010bf76a390400f29af0ff6 (patch) | |
tree | 0ad320b33f0cc571ae71b431c44d33299c4d3dfd /sw/source/filter | |
parent | f693a25173ae0b895e138d387274b5a323a7ed97 (diff) |
INTEGRATION: CWS borderingfilterteam28 (1.11.54); FILE MERGED
2004/11/05 16:31:29 mmaher 1.11.54.3: RESYNC: (1.11-1.12); FILE MERGED
2004/11/02 17:53:40 mmaher 1.11.54.2: #i36447# Date time field missing format string, german mapping table changed to English and date/time import not skipping quoted text properly.
2004/10/26 15:02:09 mmaher 1.11.54.1: #117892# Put the word date and time field number formatter in a common area
Diffstat (limited to 'sw/source/filter')
-rw-r--r-- | sw/source/filter/ww8/writerwordglue.cxx | 134 |
1 files changed, 132 insertions, 2 deletions
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx index f7538cad8d09..a66e7bf8cee6 100644 --- a/sw/source/filter/ww8/writerwordglue.cxx +++ b/sw/source/filter/ww8/writerwordglue.cxx @@ -2,9 +2,9 @@ * * $RCSfile: writerwordglue.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: rt $ $Date: 2004-10-28 13:06:09 $ + * last change: $Author: obo $ $Date: 2004-11-16 12:53:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -926,7 +926,137 @@ namespace sw return aDateTime; } + ULONG MSDateTimeFormatToSwFormat(String& rParams, + SvNumberFormatter *pFormatter, USHORT &rLang, bool bHijri) + { + // tell the Formatter about the new entry + UINT16 nCheckPos = 0; + INT16 nType = NUMBERFORMAT_DEFINED; + ULONG nKey = 0; + + SwapQuotesInField(rParams); + + //#102782#, #102815#, #108341# & #111944# have to work at the same time :-) + bool bForceJapanese(false); + bool bForceNatNum(false); + xub_StrLen nLen = rParams.Len(); + xub_StrLen nI = 0; + while (nI < nLen) + { + if (rParams.GetChar(nI) == '\\') + nI++; + else if (rParams.GetChar(nI) == '\"') + { + ++nI; + //While not at the end and not at an unescaped end quote + while ((nI < nLen) && (!(rParams.GetChar(nI) == '\"') && (rParams.GetChar(nI-1) != '\\'))) + ++nI; + } + else //normal unquoted section + { + sal_Unicode nChar = rParams.GetChar(nI); + if (nChar == 'O') + { + rParams.SetChar(nI, 'M'); + bForceNatNum = true; + } + else if (nChar == 'o') + { + rParams.SetChar(nI, 'm'); + bForceNatNum = true; + } + else if ((nChar == 'A') && IsNotAM(rParams, nI)) + { + rParams.SetChar(nI, 'D'); + bForceNatNum = true; + } + else if ((nChar == 'g') || (nChar == 'G')) + bForceJapanese = true; + else if ((nChar == 'a') && IsNotAM(rParams, nI)) + bForceJapanese = true; + else if (nChar == 'E') + { + if ((nI != nLen-1) && (rParams.GetChar(nI+1) == 'E')) + { + rParams.Replace(nI, 2, CREATE_CONST_ASC("YYYY")); + nLen+=2; + nI+=3; + } + bForceJapanese = true; + } + else if (nChar == 'e') + { + if ((nI != nLen-1) && (rParams.GetChar(nI+1) == 'e')) + { + rParams.Replace(nI, 2, CREATE_CONST_ASC("yyyy")); + nLen+=2; + nI+=3; + } + bForceJapanese = true; + } + else if (nChar == '/') + { + // MM We have to escape '/' in case it's used as a char + rParams.Replace(nI, 1, CREATE_CONST_ASC("\\/")); + // rParams.Insert( nI, '\\' ); + nI++; + nLen++; + } + + if(rLang == LANGUAGE_GERMAN) + { + // MM German word documents understand yy and dd. + // We do not, we use jj and tt instead. + if(nChar == 'y' || nChar == 'Y') + rParams.SetChar(nI, 'J'); + else if(nChar == 'd' || nChar == 'D') + rParams.SetChar(nI, 'T'); + } + + } + ++nI; + } + + if (bForceNatNum) + bForceJapanese = true; + if (bForceJapanese) + rLang = LANGUAGE_JAPANESE; + + if (bForceNatNum) + rParams.Insert(CREATE_CONST_ASC("[NatNum1][$-411]"),0); + + if (bHijri) + rParams.Insert(CREATE_CONST_ASC("[~hijri]"), 0); + + pFormatter->PutEntry(rParams, nCheckPos, nType, nKey, rLang); + + return nKey; + } + + bool IsNotAM(String& rParams, xub_StrLen nPos) + { + return ( + (nPos == rParams.Len() - 1) || + ( + (rParams.GetChar(nPos+1) != 'M') && + (rParams.GetChar(nPos+1) != 'm') + ) + ); + } + + void SwapQuotesInField(String &rFmt) + { + //Swap unescaped " and ' with ' and " + xub_StrLen nLen = rFmt.Len(); + for (xub_StrLen nI = 0; nI < nLen; ++nI) + { + if ((rFmt.GetChar(nI) == '\"') && (!nI || rFmt.GetChar(nI-1) != '\\')) + rFmt.SetChar(nI, '\''); + else if ((rFmt.GetChar(nI) == '\'') && (!nI || rFmt.GetChar(nI-1) != '\\')) + rFmt.SetChar(nI, '\"'); + } + } } |