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

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