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