sw/source/filter/inc/msfilter.hxx | 6 +++++ sw/source/filter/ww8/writerwordglue.cxx | 36 ++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-)
New commits: commit a2e964afc5187fc1e3b38720ec10ad9856b87020 Author: Lei De Bin <le...@apache.org> Date: Thu Aug 16 01:30:17 2012 +0000 Resolves: #i120158# fix Time format is different than MS Office issue Reported by: Yan Ji Patch by: Chen Zuo Jun Review by: Lei De Bin (cherry picked from commit a535dd7eaa71a599b92c04eb9c6bab7678c30eb2) Conflicts: sw/source/filter/inc/msfilter.hxx sw/source/filter/ww8/writerwordglue.cxx Change-Id: Ie93d3755dfd230cea1914a67974e717c825c07a7 diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx index 1f807c02..00a0172 100644 --- a/sw/source/filter/inc/msfilter.hxx +++ b/sw/source/filter/inc/msfilter.hxx @@ -105,6 +105,12 @@ namespace sw */ sal_uLong MSDateTimeFormatToSwFormat(String& rParams, SvNumberFormatter *pFormatter, sal_uInt16 &rLang, bool bHijri, sal_uInt16 nDocLang); + /*Used to identify if the previous token is AM time field*/ + sal_Bool IsPreviousAM(String& rParams, xub_StrLen nPos); + + /*Used to identify if the next token is PM time field*/ + sal_Bool IsNextPM(String& rParams, xub_StrLen nPos); + /** Used by MSDateTimeFormatToSwFormat to identify AM time fields @author diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx index c0149d5..b4afcff 100644 --- a/sw/source/filter/ww8/writerwordglue.cxx +++ b/sw/source/filter/ww8/writerwordglue.cxx @@ -807,8 +807,12 @@ namespace sw } if (nChar == '/') { - // MM We have to escape '/' in case it's used as a char - rParams.Replace(nI, 1, rtl::OUString("\\/")); + // MM: We have to escape '/' in case it's used as a char. + // But not if it's a '/' inside AM/PM + if (!(IsPreviousAM(rParams, nI) && IsNextPM(rParams, nI))) + { + rParams.Replace(nI, 1, rtl::OUString("\\/")); + } nI++; nLen++; } @@ -950,6 +954,34 @@ namespace sw return nKey; } + sal_Bool IsPreviousAM(String& rParams, xub_StrLen nPos){ + xub_StrLen nPos1 = nPos - 1; + xub_StrLen nPos2 = nPos - 2; + + if(nPos1 > nPos || nPos2 > nPos){ + return sal_False; + }else{ + return ( + (rParams.GetChar(nPos1) == 'M'||rParams.GetChar(nPos1) == 'm')&& + (rParams.GetChar(nPos2) == 'A'||rParams.GetChar(nPos2) == 'a') + ); + } + } + sal_Bool IsNextPM(String& rParams, xub_StrLen nPos){ + xub_StrLen nPos1 = nPos + 1; + xub_StrLen nPos2 = nPos + 2; + + + if(nPos1 >= rParams.Len() - 1 || nPos2 > rParams.Len() - 1){ + return sal_False; + }else{ + return ( + (rParams.GetChar(nPos1) == 'P'||rParams.GetChar(nPos1) == 'p')&& + (rParams.GetChar(nPos2) == 'M'||rParams.GetChar(nPos2) == 'm') + ); + } + + } bool IsNotAM(String& rParams, xub_StrLen nPos) { return ( _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits