Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3093

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/93/3093/1

fdo#35791 Added cases for unsupported VML commands

Change-Id: Ia1abca37352b1feb20a41b4bac68ecb9e40ed8dc
---
M oox/source/vml/vmlformatting.cxx
1 file changed, 96 insertions(+), 11 deletions(-)



diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index 05940f9..b3cac88 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -273,8 +273,9 @@
     sal_Int32 nTokenStart = 0;
     sal_Int32 nTokenLen = 0;
     sal_Int32 nParamCount = 0;
+    bool bCommand = false;
     enum VML_State { START, MOVE_REL, MOVE_ABS, BEZIER_REL, BEZIER_ABS,
-                     LINE_REL, LINE_ABS, CLOSE, END };
+                     LINE_REL, LINE_ABS, CLOSE, END, UNSUPPORTED };
     VML_State state = START;
 
     rPointLists.push_back( ::std::vector< Point>() );
@@ -288,7 +289,7 @@
         else if ( rPath[ i ] != ' ' )
         {
             // Store coordinate from current token
-            if ( state != START )
+            if ( state != START && state != UNSUPPORTED )
             {
                 if ( nTokenLen > 0 )
                     aCoordList.push_back( rPath.copy( nTokenStart, nTokenLen ).toInt32() );
@@ -374,25 +375,109 @@
                     break;
 
                 case START:
+                case UNSUPPORTED:
                     break;
                 }
 
                 aCoordList.clear();
             }
 
-            // Move on to current command state
+            // Allow two-char commands to peek ahead to the next character
+            char nextChar = '\0';
+            if (i+1 < rPath.getLength())
+                nextChar = rPath[i+1];
+
+            // Move to relevant state upon finding a command
+            bCommand = true;
             switch ( rPath[ i ] )
             {
-            case 't': state = MOVE_REL; nTokenLen = 0; nParamCount = 2 * 2; break;
-            case 'm': state = MOVE_ABS; nTokenLen = 0; nParamCount = 2 * 2; break;
-            case 'v': state = BEZIER_REL; nTokenLen = 0; nParamCount = 2 * 6; break;
-            case 'c': state = BEZIER_ABS; nTokenLen = 0; nParamCount = 2 * 6; break;
-            case 'r': state = LINE_REL; nTokenLen = 0; nParamCount = 2 * 2; break;
-            case 'l': state = LINE_ABS; nTokenLen = 0; nParamCount = 2 * 2; break;
-            case 'x': state = CLOSE; nTokenLen = 0; break;
-            case 'e': state = END; break;
+            // Single-character commands
+            case 't': // rmoveto
+                state = MOVE_REL; nParamCount = 2 * 2; break;
+            case 'm': // moveto
+                state = MOVE_ABS; nParamCount = 2 * 2; break;
+            case 'v': // rcurveto
+                state = BEZIER_REL; nParamCount = 2 * 6; break;
+            case 'c': // curveto
+                state = BEZIER_ABS; nParamCount = 2 * 6; break;
+            case 'r': // rlineto
+                state = LINE_REL; nParamCount = 2 * 2; break;
+            case 'l': // lineto
+                state = LINE_ABS; nParamCount = 2 * 2; break;
+            case 'x': // close
+                state = CLOSE; break;
+            case 'e': // end
+                state = END; break;
+
+            // Two-character commands
+            case 'n':
+            {
+                switch ( nextChar )
+                {
+                case 'f': // nf - nofill
+                case 's': // ns - nostroke
+                    state = UNSUPPORTED; i++; break;
+                }
+                break;
+            }
+            case 'a': // Elliptical curves
+            {
+                switch ( nextChar )
+                {
+                case 'e': // ae - angleellipseto
+                case 'l': // al - angleellipse
+                    state = UNSUPPORTED; i++; break;
+                case 't': // at - arcto
+                case 'r': // ar - arc
+                    state = UNSUPPORTED; i++; break;
+                }
+                break;
+            }
+            case 'w': // Clockwise elliptical arcs
+            {
+                switch ( nextChar )
+                {
+                case 'a': // wa - clockwisearcto
+                case 'r': // wr - clockwisearc
+                    state = UNSUPPORTED; i++; break;
+                }
+                break;
+            }
+            case 'q':
+            {
+                switch ( nextChar )
+                {
+                case 'x': // qx - ellipticalquadrantx
+                case 'y': // qy - ellipticalquadranty
+                    state = UNSUPPORTED; i++; break;
+                case 'b': // qb - quadraticbezier
+                    state = UNSUPPORTED; i++; break;
+                }
+                break;
+            }
+            case 'h': // behaviour extensions
+            {
+                switch ( nextChar )
+                {
+                case 'a': // ha - AutoLine
+                case 'b': // hb - AutoCurve
+                case 'c': // hc - CornerLine
+                case 'd': // hd - CornerCurve
+                case 'e': // he - SmoothLine
+                case 'f': // hf - SmoothCurve
+                case 'g': // hg - SymmetricLine
+                case 'h': // hh - SymmetricCurve
+                case 'i': // hi - Freeform
+                    state = UNSUPPORTED; i++; break;
+                }
+                break;
+            }
+            default:
+                bCommand = false;
+                break;
             }
 
+            if (bCommand) nTokenLen = 0;
             nTokenStart = i+1;
         }
     }

-- 
To view, visit https://gerrit.libreoffice.org/3093
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia1abca37352b1feb20a41b4bac68ecb9e40ed8dc
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Eilidh McAdam <eilidh.mcadam@gmail.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.