diff options
author | Oliver-Rainer Wittmann <orw@apache.org> | 2012-08-13 12:04:34 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-08-18 14:33:18 +0100 |
commit | 611fd43dd2570bbffe84a3b0506f0c36d7972a38 (patch) | |
tree | d92a96f3a7b5f1d889c2872a25658ae65de0b09f /sw | |
parent | 30ba8fa46aafb0868ada3b0092cd33524c145989 (diff) |
Resolves: #i119440# add support for further field codes to Read_SubF_Combined
Found by: Yan Ji
Patch by: zjcen
Review by: orw
(cherry picked from commit 3c7cfb25492dafb231b74d824570fb943a599981)
Conflicts:
sw/source/filter/ww8/ww8par5.cxx
Change-Id: I458d556dccab7ddbfec4889cab2bfdc76fef15c9
Related: #i119440# correction to be warning-free
sal_Unicode is unsigned on all platforms;
Found by: Pavel Janik
(cherry picked from commit 0d2bf1c7dcc7adfd0b4e8c899501eacd06ff50d4)
Change-Id: I9df9ccc770eedc2fa51a080ad47576b06befb6b0
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/ww8par5.cxx | 104 |
1 files changed, 77 insertions, 27 deletions
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 4bee4ef1ccb5..cd3c7d901da3 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -2598,7 +2598,7 @@ eF_ResT SwWW8ImplReader::Read_F_Equation( WW8FieldDesc*, String& rStr ) { WW8ReadFieldParams aReadParam( rStr ); long cChar = aReadParam.SkipToNextToken(); - if ('o' == cChar) + if ('o' == cChar || 'O' == cChar) Read_SubF_Combined(aReadParam); else if ('*' == cChar) Read_SubF_Ruby(aReadParam); @@ -2608,45 +2608,95 @@ eF_ResT SwWW8ImplReader::Read_F_Equation( WW8FieldDesc*, String& rStr ) void SwWW8ImplReader::Read_SubF_Combined( WW8ReadFieldParams& rReadParam) { String sCombinedCharacters; - if ((-2 == rReadParam.SkipToNextToken()) && - rReadParam.GetResult().EqualsIgnoreCaseAscii(OUString('('), 1, 0)) + WW8ReadFieldParams aOriFldParam = rReadParam; + long cGetChar = rReadParam.SkipToNextToken(); + switch( cGetChar ) { - for (int i=0;i<2;i++) + case 'a': + case 'A': { - if ('s' == rReadParam.SkipToNextToken()) + String sTemp = rReadParam.GetResult(); + if ( !sTemp.EqualsIgnoreCaseAscii("d", 1, 0) ) { - long cChar = rReadParam.SkipToNextToken(); - if (-2 != rReadParam.SkipToNextToken()) - break; - String sF = rReadParam.GetResult(); - if ((('u' == cChar) && sF.EqualsIgnoreCaseAscii(OUString('p'), 1, 0)) - || (('d' == cChar) && sF.EqualsIgnoreCaseAscii(OUString('o'), 1, 0))) + break; + } + rReadParam.SkipToNextToken(); + } + case -2: + { + if ( rReadParam.GetResult().EqualsIgnoreCaseAscii('(', 1, 0) ) + { + for (int i=0;i<2;i++) { - if (-2 == rReadParam.SkipToNextToken()) + if ('s' == rReadParam.SkipToNextToken()) { - String sPart = rReadParam.GetResult(); - xub_StrLen nBegin = sPart.Search('('); + long cChar = rReadParam.SkipToNextToken(); + if (-2 != rReadParam.SkipToNextToken()) + break; + String sF = rReadParam.GetResult(); + if ((('u' == cChar) && sF.EqualsIgnoreCaseAscii('p', 1, 0)) + || (('d' == cChar) && sF.EqualsIgnoreCaseAscii('o', 1, 0))) + { + if (-2 == rReadParam.SkipToNextToken()) + { + String sPart = rReadParam.GetResult(); + xub_StrLen nBegin = sPart.Search('('); - //Word disallows brackets in this field, which - //aids figuring out the case of an end of )) vs ) - xub_StrLen nEnd = sPart.Search(')'); + //Word disallows brackets in this field, which + //aids figuring out the case of an end of )) vs ) + xub_StrLen nEnd = sPart.Search(')'); - if ((nBegin != STRING_NOTFOUND) && - (nEnd != STRING_NOTFOUND)) + if ((nBegin != STRING_NOTFOUND) && + (nEnd != STRING_NOTFOUND)) + { + sCombinedCharacters += + sPart.Copy(nBegin+1,nEnd-nBegin-1); + } + } + } + } + } + if (sCombinedCharacters.Len()) + { + SwCombinedCharField aFld((SwCombinedCharFieldType*) + rDoc.GetSysFldType(RES_COMBINED_CHARS),sCombinedCharacters); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); + } + else + { + const String sPart = aOriFldParam.GetResult(); + xub_StrLen nBegin = sPart.Search('('); + xub_StrLen nEnd = sPart.Search(','); + if ( nEnd == STRING_NOTFOUND ) + { + nEnd = sPart.Search(')'); + } + if ( (nBegin != STRING_NOTFOUND) && (nEnd != STRING_NOTFOUND) ) + { + // skip certain leading characters + for (int i = nBegin;i < nEnd-1;i++) { - sCombinedCharacters += - sPart.Copy(nBegin+1,nEnd-nBegin-1); + const sal_Unicode cC = sPart.GetChar(nBegin+1); + if ( cC < 32 ) + { + nBegin++; + } + else + break; + } + sCombinedCharacters = sPart.Copy( nBegin+1, nEnd-nBegin-1 ); + if ( sCombinedCharacters.Len() ) + { + SwInputField aFld( (SwInputFieldType*)rDoc.GetSysFldType( RES_INPUTFLD ), + sCombinedCharacters, sCombinedCharacters, INP_TXT, 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); // insert input field } } } } } - } - if (sCombinedCharacters.Len()) - { - SwCombinedCharField aFld((SwCombinedCharFieldType*) - rDoc.GetSysFldType(RES_COMBINED_CHARS),sCombinedCharacters); - rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); + default: + break; } } |