[Libreoffice-commits] core.git: 7 commits - oox/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Apr 17 07:54:53 PDT 2014


 oox/source/drawingml/customshapepresetdata.cxx |  155 +++++++++++++++++++++----
 1 file changed, 131 insertions(+), 24 deletions(-)

New commits:
commit 06abff6caef5205178858796643ced0dff13ad95
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Apr 17 16:00:25 2014 +0200

    oox customshapepresetdata: parse SubViewSize
    
    Change-Id: I2feb7054ea2bd699384b01a1d83845cd3c2562b0

diff --git a/oox/source/drawingml/customshapepresetdata.cxx b/oox/source/drawingml/customshapepresetdata.cxx
index 97e9b74..6d3a281 100644
--- a/oox/source/drawingml/customshapepresetdata.cxx
+++ b/oox/source/drawingml/customshapepresetdata.cxx
@@ -161,6 +161,25 @@ awt::Rectangle lcl_parseRectangle(const OString& rValue)
     return aRectangle;
 }
 
+awt::Size lcl_parseSize(const OString& rValue)
+{
+    awt::Size aSize;
+    OString aToken = rValue;
+    // We expect the followings here: Width, Height
+    static const OString aExpectedWidthPrefix = "Width = (long) ";
+    assert(aToken.startsWith(aExpectedWidthPrefix));
+    sal_Int32 nIndex = aExpectedWidthPrefix.getLength();
+    aSize.Width = static_cast<sal_Int32>(aToken.getToken(0, ',', nIndex).toInt32());
+
+    static const OString aExpectedHeightPrefix = " Height = (long) ";
+    aToken = aToken.copy(nIndex);
+    assert(aToken.startsWith(aExpectedHeightPrefix));
+    nIndex = aExpectedHeightPrefix.getLength();
+    aSize.Width = static_cast<sal_Int32>(aToken.copy(nIndex).toInt32());
+
+    return aSize;
+}
+
 drawing::EnhancedCustomShapeTextFrame lcl_parseEnhancedCustomShapeTextFrame(const OString& rValue)
 {
     drawing::EnhancedCustomShapeTextFrame aTextFrame;
@@ -602,6 +621,68 @@ void lcl_parsePathTextFrames(comphelper::SequenceAsVector<beans::PropertyValue>&
     }
 }
 
+void lcl_parsePathSubViewSizeValues(comphelper::SequenceAsVector<beans::PropertyValue>& rPath, const OString& rValue)
+{
+    comphelper::SequenceAsVector<awt::Size> aSizes;
+    sal_Int32 nLevel = 0;
+    sal_Int32 nStart = 0;
+    for (sal_Int32 i = 0; i < rValue.getLength(); ++i)
+    {
+        if (rValue[i] == '{')
+        {
+            if (!nLevel)
+                nStart = i;
+            nLevel++;
+        }
+        else if (rValue[i] == '}')
+        {
+            nLevel--;
+            if (!nLevel)
+                aSizes.push_back(lcl_parseSize(rValue.copy(nStart + strlen("{ "), i - nStart - strlen(" },"))));
+        }
+    }
+
+    beans::PropertyValue aPropertyValue;
+    aPropertyValue.Name = "SubViewSize";
+    aPropertyValue.Value = uno::makeAny(aSizes.getAsConstList());
+    rPath.push_back(aPropertyValue);
+}
+
+void lcl_parsePathSubViewSize(comphelper::SequenceAsVector<beans::PropertyValue>& rPath, const OString& rValue)
+{
+    sal_Int32 nLevel = 0;
+    bool bIgnore = false;
+    sal_Int32 nStart = 0;
+    for (sal_Int32 i = 0; i < rValue.getLength(); ++i)
+    {
+        if (rValue[i] == '{')
+        {
+            if (!nLevel)
+                bIgnore = true;
+            nLevel++;
+        }
+        else if (rValue[i] == '}')
+        {
+            nLevel--;
+            if (!nLevel)
+                bIgnore = false;
+        }
+        else if (rValue[i] == ',' && !bIgnore)
+        {
+            OString aToken = rValue.copy(nStart, i - nStart);
+            static const OString aExpectedPrefix("Value = (any) { ([]com.sun.star.awt.Size) { ");
+            if (aToken.startsWith(aExpectedPrefix))
+            {
+                aToken = aToken.copy(aExpectedPrefix.getLength(), aToken.getLength() - aExpectedPrefix.getLength() - strlen(" } }"));
+                lcl_parsePathSubViewSizeValues(rPath, aToken);
+            }
+            else if (!aToken.startsWith("Name =") && !aToken.startsWith("Handle ="))
+                SAL_WARN("oox", "lcl_parsePathSubViewSize: unexpected token: " << aToken);
+            nStart = i + strlen(", ");
+        }
+    }
+}
+
 void lcl_parsePath(comphelper::SequenceAsVector<beans::PropertyValue>& rPath, const OString& rValue)
 {
     sal_Int32 nLevel = 0;
@@ -626,6 +707,8 @@ void lcl_parsePath(comphelper::SequenceAsVector<beans::PropertyValue>& rPath, co
                     lcl_parsePathSegments(rPath, aToken);
                 else if (aToken.startsWith("Name = \"TextFrames\""))
                     lcl_parsePathTextFrames(rPath, aToken);
+                else if (aToken.startsWith("Name = \"SubViewSize\""))
+                    lcl_parsePathSubViewSize(rPath, aToken);
                 else
                     SAL_WARN("oox", "lcl_parsePath: unexpected token: " << aToken);
             }
commit ea06c516a8b8b2d8dbf0dadba1e8c2196cb89449
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Apr 17 15:48:11 2014 +0200

    oox customshapepresetdata: allow empty equation list
    
    Change-Id: Ie18c3e631c266d4281df8b92d08ddeaaef20e8d7

diff --git a/oox/source/drawingml/customshapepresetdata.cxx b/oox/source/drawingml/customshapepresetdata.cxx
index 71add4f..97e9b74 100644
--- a/oox/source/drawingml/customshapepresetdata.cxx
+++ b/oox/source/drawingml/customshapepresetdata.cxx
@@ -682,12 +682,15 @@ void CustomShapeProperties::initializePresetDataMap()
             else if (aLine == "Equations")
             {
                 aStream.ReadLine(aLine);
-                OString aExpectedPrefix("([]string) { ");
-                assert(aLine.startsWith(aExpectedPrefix));
-
                 comphelper::SequenceAsVector<OUString> aEquations;
-                OString aValue = aLine.copy(aExpectedPrefix.getLength(), aLine.getLength() - aExpectedPrefix.getLength() - strlen(" }"));
-                lcl_parseEquations(aEquations, aValue);
+                if (aLine != "([]string) {}")
+                {
+                    OString aExpectedPrefix("([]string) { ");
+                    assert(aLine.startsWith(aExpectedPrefix));
+
+                    OString aValue = aLine.copy(aExpectedPrefix.getLength(), aLine.getLength() - aExpectedPrefix.getLength() - strlen(" }"));
+                    lcl_parseEquations(aEquations, aValue);
+                }
                 aPropertyMap.setProperty(PROP_Equations, aEquations.getAsConstList());
             }
             else if (aLine == "Handles")
commit 0e44c6592b558ac70f87031a9ddb1d131fb802b2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Apr 17 15:45:51 2014 +0200

    oox customshapepresetdata: handle RadiusRangeMaximum/RadiusRangeMinimum
    
    Change-Id: Icc6e96f4cfbf8304933246d43621bf8d2824daf3

diff --git a/oox/source/drawingml/customshapepresetdata.cxx b/oox/source/drawingml/customshapepresetdata.cxx
index f865cd3..71add4f 100644
--- a/oox/source/drawingml/customshapepresetdata.cxx
+++ b/oox/source/drawingml/customshapepresetdata.cxx
@@ -351,6 +351,10 @@ uno::Sequence<beans::PropertyValue> lcl_parseHandle(const OString& rValue)
                     lcl_parseHandleRange(aRet, aToken, "RangeYMaximum");
                 else if (aToken.startsWith("Name = \"RangeYMinimum\""))
                     lcl_parseHandleRange(aRet, aToken, "RangeYMinimum");
+                else if (aToken.startsWith("Name = \"RadiusRangeMaximum\""))
+                    lcl_parseHandleRange(aRet, aToken, "RadiusRangeMaximum");
+                else if (aToken.startsWith("Name = \"RadiusRangeMinimum\""))
+                    lcl_parseHandleRange(aRet, aToken, "RadiusRangeMinimum");
                 else if (aToken.startsWith("Name = \"RefX\""))
                     lcl_parseHandleRef(aRet, aToken, "RefX");
                 else if (aToken.startsWith("Name = \"RefY\""))
commit 3e0bf64f58b72a13840b7136ac89f58b0484170e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Apr 17 15:39:18 2014 +0200

    oox customshapepresetdata: allow empty handle list
    
    Change-Id: I35d1c6aaf94853df844bd226c57003742d3c48be

diff --git a/oox/source/drawingml/customshapepresetdata.cxx b/oox/source/drawingml/customshapepresetdata.cxx
index 8875f77..f865cd3 100644
--- a/oox/source/drawingml/customshapepresetdata.cxx
+++ b/oox/source/drawingml/customshapepresetdata.cxx
@@ -689,12 +689,15 @@ void CustomShapeProperties::initializePresetDataMap()
             else if (aLine == "Handles")
             {
                 aStream.ReadLine(aLine);
-                OString aExpectedPrefix("([][]com.sun.star.beans.PropertyValue) { ");
-                assert(aLine.startsWith(aExpectedPrefix));
-
                 comphelper::SequenceAsVector< uno::Sequence<beans::PropertyValue> > aHandles;
-                OString aValue = aLine.copy(aExpectedPrefix.getLength(), aLine.getLength() - aExpectedPrefix.getLength() - strlen(" }"));
-                lcl_parseHandles(aHandles, aValue);
+                if (aLine != "([][]com.sun.star.beans.PropertyValue) {}")
+                {
+                    OString aExpectedPrefix("([][]com.sun.star.beans.PropertyValue) { ");
+                    assert(aLine.startsWith(aExpectedPrefix));
+
+                    OString aValue = aLine.copy(aExpectedPrefix.getLength(), aLine.getLength() - aExpectedPrefix.getLength() - strlen(" }"));
+                    lcl_parseHandles(aHandles, aValue);
+                }
                 aPropertyMap.setProperty(PROP_Handles, aHandles.getAsConstList());
             }
             else if (aLine == "MirroredX")
commit 79940e2da54c320d3dda0149bc9ac21ad45dccd5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Apr 17 15:37:24 2014 +0200

    oox customshapepresetdata: allow empty adjustment list
    
    Change-Id: I842a464ddc0403d63698b2f9b52d4362af1e46c3

diff --git a/oox/source/drawingml/customshapepresetdata.cxx b/oox/source/drawingml/customshapepresetdata.cxx
index a3740a9..8875f77 100644
--- a/oox/source/drawingml/customshapepresetdata.cxx
+++ b/oox/source/drawingml/customshapepresetdata.cxx
@@ -664,12 +664,15 @@ void CustomShapeProperties::initializePresetDataMap()
             if (aLine == "AdjustmentValues")
             {
                 aStream.ReadLine(aLine);
-                OString aExpectedPrefix("([]com.sun.star.drawing.EnhancedCustomShapeAdjustmentValue) { ");
-                assert(aLine.startsWith(aExpectedPrefix));
-
                 comphelper::SequenceAsVector<drawing::EnhancedCustomShapeAdjustmentValue> aAdjustmentValues;
-                OString aValue = aLine.copy(aExpectedPrefix.getLength(), aLine.getLength() - aExpectedPrefix.getLength() - strlen(" }"));
-                lcl_parseAdjustmentValues(aAdjustmentValues, aValue);
+                if (aLine != "([]com.sun.star.drawing.EnhancedCustomShapeAdjustmentValue) {}")
+                {
+                    OString aExpectedPrefix("([]com.sun.star.drawing.EnhancedCustomShapeAdjustmentValue) { ");
+                    assert(aLine.startsWith(aExpectedPrefix));
+
+                    OString aValue = aLine.copy(aExpectedPrefix.getLength(), aLine.getLength() - aExpectedPrefix.getLength() - strlen(" }"));
+                    lcl_parseAdjustmentValues(aAdjustmentValues, aValue);
+                }
                 aPropertyMap.setProperty(PROP_AdjustmentValues, aAdjustmentValues.getAsConstList());
             }
             else if (aLine == "Equations")
commit b7feee55782f83e356611a90c8a22e3509880ac2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Apr 17 15:28:18 2014 +0200

    oox customshapepresetdata: handle multiple definitions
    
    Change-Id: I41b1ff9fa030267ef05fadeb6f77d33a183af8f1

diff --git a/oox/source/drawingml/customshapepresetdata.cxx b/oox/source/drawingml/customshapepresetdata.cxx
index 49cb2c2..a3740a9 100644
--- a/oox/source/drawingml/customshapepresetdata.cxx
+++ b/oox/source/drawingml/customshapepresetdata.cxx
@@ -647,11 +647,16 @@ void CustomShapeProperties::initializePresetDataMap()
     OUString aName;
     bool bNotDone = aStream.ReadLine(aLine);
     PropertyMap aPropertyMap;
+    bool bFirst = true;
     while (bNotDone)
     {
         static const OString aCommentPrefix("/* ");
         if (aLine.startsWith(aCommentPrefix))
         {
+            if (bFirst)
+                bFirst = false;
+            else
+                maPresetDataMap[StaticTokenMap::get().getTokenFromUnicode(aName)] = aPropertyMap;
             aName = OStringToOUString(aLine.copy(aCommentPrefix.getLength(), aLine.getLength() - aCommentPrefix.getLength() - strlen(" */")), RTL_TEXTENCODING_UTF8);
         }
         else
commit d66140be01a2a0b4566988ef090287f08fd8e8f3
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Apr 17 15:24:06 2014 +0200

    oox customshapepresetdata: handle RangeXMaximum and a few more properties
    
    Change-Id: I8649866c338055ed7fe7c14f366c69670b538d93

diff --git a/oox/source/drawingml/customshapepresetdata.cxx b/oox/source/drawingml/customshapepresetdata.cxx
index 4522c3c..49cb2c2 100644
--- a/oox/source/drawingml/customshapepresetdata.cxx
+++ b/oox/source/drawingml/customshapepresetdata.cxx
@@ -305,21 +305,21 @@ void lcl_parseHandleRange(comphelper::SequenceAsVector<beans::PropertyValue>& rH
 }
 
 // Parses a string like: Name = "RefY", Handle = (long) 0, Value = (any) { (long) 0 }, State = (com.sun.star.beans.PropertyState) DIRECT_VALUE
-void lcl_parseHandleRefY(comphelper::SequenceAsVector<beans::PropertyValue>& rHandle, const OString& rValue)
+void lcl_parseHandleRef(comphelper::SequenceAsVector<beans::PropertyValue>& rHandle, const OString& rValue, const OUString& rName)
 {
-    static const OString aExpectedPrefix("Name = \"RefY\", Handle = (long) 0, Value = (any) { (long) ");
-    if (rValue.startsWith(aExpectedPrefix))
+    static const OString aExpectedXPrefix("Name = \"RefX\", Handle = (long) 0, Value = (any) { (long) ");
+    static const OString aExpectedYPrefix("Name = \"RefY\", Handle = (long) 0, Value = (any) { (long) ");
+    if (rValue.startsWith(aExpectedXPrefix) || rValue.startsWith(aExpectedYPrefix))
     {
-        sal_Int32 nIndex = aExpectedPrefix.getLength();
+        sal_Int32 nIndex = aExpectedXPrefix.getLength();
         beans::PropertyValue aPropertyValue;
-        aPropertyValue.Name = "RefY";
+        aPropertyValue.Name = rName;
         // We only expect a Value here
         aPropertyValue.Value = uno::makeAny(rValue.getToken(0, '}', nIndex).toInt32());
         rHandle.push_back(aPropertyValue);
-
     }
     else
-        SAL_WARN("oox", "lcl_parseHandleRefY: unexpected value: " << rValue);
+        SAL_WARN("oox", "lcl_parseHandleRef: unexpected value: " << rValue);
 }
 
 uno::Sequence<beans::PropertyValue> lcl_parseHandle(const OString& rValue)
@@ -343,14 +343,20 @@ uno::Sequence<beans::PropertyValue> lcl_parseHandle(const OString& rValue)
                 OString aToken = rValue.copy(nStart + strlen("{ "), i - nStart - strlen(" },"));
                 if (aToken.startsWith("Name = \"Position\""))
                     lcl_parseHandlePosition(aRet, aToken);
+                else if (aToken.startsWith("Name = \"RangeXMaximum\""))
+                    lcl_parseHandleRange(aRet, aToken, "RangeXMaximum");
+                else if (aToken.startsWith("Name = \"RangeXMinimum\""))
+                    lcl_parseHandleRange(aRet, aToken, "RangeXMinimum");
                 else if (aToken.startsWith("Name = \"RangeYMaximum\""))
                     lcl_parseHandleRange(aRet, aToken, "RangeYMaximum");
                 else if (aToken.startsWith("Name = \"RangeYMinimum\""))
                     lcl_parseHandleRange(aRet, aToken, "RangeYMinimum");
+                else if (aToken.startsWith("Name = \"RefX\""))
+                    lcl_parseHandleRef(aRet, aToken, "RefX");
                 else if (aToken.startsWith("Name = \"RefY\""))
-                    lcl_parseHandleRefY(aRet, aToken);
+                    lcl_parseHandleRef(aRet, aToken, "RefY");
                 else
-                    SAL_WARN("oox", "lcl_parseHandle: unexpected value: " << rValue);
+                    SAL_WARN("oox", "lcl_parseHandle: unexpected token: " << aToken);
             }
         }
     }


More information about the Libreoffice-commits mailing list