Blame SOURCES/0280-sc-lok-update-parameter-syntax-for-.uno-CellCursor.patch

135360
From 01e6ce0c2286016e7a8459d1f0d865b49765f585 Mon Sep 17 00:00:00 2001
135360
From: Andrzej Hunt <andrzej@ahunt.org>
135360
Date: Thu, 5 Nov 2015 10:31:06 +0100
135360
Subject: [PATCH 280/398] sc lok: update parameter syntax for .uno:CellCursor
135360
135360
This follows the syntax for .uno:ViewRowColumnHeaders
135360
(which was implemented somewhat concurrentl with CellCursor)
135360
135360
Change-Id: I8ef03a969abc1716a0e95d95fb7043d75910c828
135360
(cherry picked from commit e7e0d46dba7b1016968a133330bca23a4bf668ec)
135360
---
135360
 desktop/source/lib/init.cxx | 57 +++++++++++++++++++++++++++------------------
135360
 1 file changed, 34 insertions(+), 23 deletions(-)
135360
135360
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
135360
index 3ca554d7e6f9..2e6e7e73df1a 100644
135360
--- a/desktop/source/lib/init.cxx
135360
+++ b/desktop/source/lib/init.cxx
135360
@@ -1273,7 +1273,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
135360
         strcpy(pMemory, aString.getStr());
135360
         return pMemory;
135360
     }
135360
-    else if (aCommand.startsWith(aCellCursor)
135360
+    else if (aCommand.startsWith(aCellCursor))
135360
     {
135360
         ITiledRenderable* pDoc = getTiledRenderable(pThis);
135360
         if (!pDoc)
135360
@@ -1282,29 +1282,40 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
135360
             return 0;
135360
         }
135360
 
135360
-        OString aString;
135360
-        OString aParams = aCommand.copy(OString(".uno:CellCursor:").getLength());
135360
-
135360
-        sal_Int32 nIndex = 0;
135360
-        OString aOutputWidth = aParams.getToken(0,  ',',  nIndex);
135360
-        OString aOutputHeight = aParams.getToken(0,  ',',  nIndex);
135360
-        OString aTileWidth = aParams.getToken(0,  ',',  nIndex);
135360
-        OString aTileHeight = aParams.getToken(0,  ',',  nIndex);
135360
-
135360
-        int nOutputWidth, nOutputHeight;
135360
-        long nTileWidth, nTileHeight;
135360
-        if (!(comphelper::string::getTokenCount(aParams, ',') == 4
135360
-              && !aOutputWidth.isEmpty()
135360
-              && (nOutputWidth = aOutputWidth.toInt32()) != 0
135360
-              && !aOutputHeight.isEmpty()
135360
-              && (nOutputHeight = aOutputHeight.toInt32()) != 0
135360
-              && !aTileWidth.isEmpty()
135360
-              && (nTileWidth = aTileWidth.toInt64()) != 0
135360
-              && !aTileHeight.isEmpty()
135360
-              && (nTileHeight = aTileHeight.toInt64()) != 0))
135360
+        // Command has parameters.
135360
+        int nOutputWidth = 0;
135360
+        int nOutputHeight = 0;
135360
+        long nTileWidth = 0;
135360
+        long nTileHeight = 0;
135360
+        if (aCommand.getLength() > aCellCursor.getLength())
135360
         {
135360
-            gImpl->maLastExceptionMsg = "Can't parse arguments for .uno:CellCursor, no cursor returned";
135360
-            return NULL;
135360
+            OString aArguments = aCommand.copy(aCellCursor.getLength() + 1);
135360
+            sal_Int32 nParamIndex = 0;
135360
+            do
135360
+            {
135360
+                OString aParamToken = aArguments.getToken(0, '&', nParamIndex);
135360
+                sal_Int32 nIndex = 0;
135360
+                OString aKey;
135360
+                OString aValue;
135360
+                do
135360
+                {
135360
+                    OString aToken = aParamToken.getToken(0, '=', nIndex);
135360
+                    if (!aKey.getLength())
135360
+                        aKey = aToken;
135360
+                    else
135360
+                        aValue = aToken;
135360
+                }
135360
+                while (nIndex >= 0);
135360
+                if (aKey == "outputWidth")
135360
+                    nOutputWidth = aValue.toInt32();
135360
+                else if (aKey == "outputHeight")
135360
+                    nOutputHeight = aValue.toInt32();
135360
+                else if (aKey == "tileWidth")
135360
+                    nTileWidth = aValue.toInt64();
135360
+                else if (aKey == "tileHeight")
135360
+                    nTileHeight = aValue.toInt64();
135360
+            }
135360
+            while (nParamIndex >= 0);
135360
         }
135360
 
135360
         OString aString = pDoc->getCellCursor(nOutputWidth, nOutputHeight, nTileWidth, nTileHeight);
135360
-- 
135360
2.12.0
135360