[Libreoffice-commits] core.git: sw/source

Oliver-Rainer Wittmann orw at apache.org
Sun Aug 18 06:46:20 PDT 2013


 sw/source/filter/ww8/ww8par5.cxx |  104 ++++++++++++++++++++++++++++-----------
 1 file changed, 77 insertions(+), 27 deletions(-)

New commits:
commit 611fd43dd2570bbffe84a3b0506f0c36d7972a38
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Mon Aug 13 12:04:34 2012 +0000

    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

diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 4bee4ef..cd3c7d9 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;
     }
 }
 


More information about the Libreoffice-commits mailing list