incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o..@apache.org
Subject svn commit: r1372411 - /incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par5.cxx
Date Mon, 13 Aug 2012 13:04:35 GMT
Author: orw
Date: Mon Aug 13 13:04:34 2012
New Revision: 1372411

URL: http://svn.apache.org/viewvc?rev=1372411&view=rev
Log:
#119440# - method <SwWW8ImplReader::Read_SubF_Combined(..)>
         -- add support for further field codes

         Found by: Yan Ji
         Patch by: zjcen
         Review by: orw

Modified:
    incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par5.cxx

Modified: incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par5.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par5.cxx?rev=1372411&r1=1372410&r2=1372411&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par5.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par5.cxx Mon Aug 13 13:04:34 2012
@@ -2506,7 +2506,7 @@ eF_ResT SwWW8ImplReader::Read_F_Equation
 {
     _ReadFieldParams 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);
@@ -2516,45 +2516,95 @@ eF_ResT SwWW8ImplReader::Read_F_Equation
 void SwWW8ImplReader::Read_SubF_Combined( _ReadFieldParams& rReadParam)
 {
     String sCombinedCharacters;
-    if ((-2 == rReadParam.SkipToNextToken()) &&
-            rReadParam.GetResult().EqualsIgnoreCaseAscii('(', 1, 0))
+    _ReadFieldParams 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('p', 1, 0))
-                || (('d' == cChar) && sF.EqualsIgnoreCaseAscii('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++)
+                        {
+                            const sal_Unicode cC = sPart.GetChar(nBegin+1);
+                            if ( (-1 < cC) && (cC < 32) )
+                            {
+                                nBegin++;
+                            }
+                            else
+                                break;
+                        }
+                        sCombinedCharacters = sPart.Copy( nBegin+1, nEnd-nBegin-1 );
+                        if ( sCombinedCharacters.Len() )
                         {
-                            sCombinedCharacters +=
-                                sPart.Copy(nBegin+1,nEnd-nBegin-1);
+                            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;
     }
 }
 



Mime
View raw message