diff options
author | Lei De Bin <leidb@apache.org> | 2012-08-16 01:30:17 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-03-10 18:59:06 +0000 |
commit | a2e964afc5187fc1e3b38720ec10ad9856b87020 (patch) | |
tree | 6881451a3745cf10f2b958c7b906474065f60c2e /sw | |
parent | b56e53f1358ab48173aa8f17acc6d40352320d9c (diff) |
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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/inc/msfilter.hxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/writerwordglue.cxx | 36 |
2 files changed, 40 insertions, 2 deletions
diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx index 1f807c028585..00a01725e345 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 c0149d536add..b4afcffff739 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 ( |