summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorGökay Şatır <gokaysatir@collabora.com>2024-10-03 12:12:27 +0300
committerMiklos Vajna <vmiklos@collabora.com>2024-11-20 11:56:45 +0100
commitcb610c0200152ea2d62152a3e6f5e003e246bd21 (patch)
treea96882889ff1d2e9bb910c88c434db2b5edcd08b /sc
parentb4bd177f841db980754e233f7996c1a855647ed4 (diff)
cool#7406: Refactor Calc->getPartInfo & use JsonWriter.
Indeed this seems unrelated to the task. But grid in Impress requires to add new properties to "getPartInfo (impress)". When i checked the code, i saw that we use getPartInfo's result (on server side) like it's a text instead of JSON. So we'll refactor that part. Touching that part requires also touching some other shared functions on COOL side. And those changes also required adding new props here. We have been fetching this data (without adding new properties) one by one. We now will be able to fetch the whole part's data at once. This commit also uses JsonWriter class. Change-Id: Icc26ae71c668c391218e2d517259e1ef32a0832f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176815 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/unoobj/docuno.cxx29
1 files changed, 19 insertions, 10 deletions
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index e1a4fdb9ec14..81e6e039e3f7 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -649,16 +649,25 @@ OUString ScModelObj::getPartInfo( int nPart )
const bool bIsSelected = false; //pViewData->GetDocument()->IsSelected(nPart);
const bool bIsRTLLayout = pViewData->GetDocument().IsLayoutRTL(nPart);
- OUString aPartInfo = "{ \"visible\": \"" +
- OUString::number(static_cast<unsigned int>(bIsVisible)) +
- "\", \"selected\": \"" +
- OUString::number(static_cast<unsigned int>(bIsSelected)) +
- "\", \"rtllayout\": \"" +
- OUString::number(static_cast<unsigned int>(bIsRTLLayout)) +
- "\", \"protected\": \"" +
- OUString::number(static_cast<unsigned int>(bIsProtected)) +
- "\" }";
- return aPartInfo;
+ ::tools::JsonWriter jsonWriter;
+ jsonWriter.put("visible", static_cast<unsigned int>(bIsVisible));
+ jsonWriter.put("rtllayout", static_cast<unsigned int>(bIsRTLLayout));
+ jsonWriter.put("protected", static_cast<unsigned int>(bIsProtected));
+ jsonWriter.put("selected", static_cast<unsigned int>(bIsSelected));
+
+ OUString tabName;
+ pViewData->GetDocument().GetName(nPart, tabName);
+ jsonWriter.put("name", tabName);
+
+ sal_Int64 hashCode;
+ pViewData->GetDocument().GetHashCode(nPart, hashCode);
+ jsonWriter.put("hash", hashCode);
+
+ Size lastColRow = getDataArea(nPart);
+ jsonWriter.put("lastcolumn", lastColRow.getWidth());
+ jsonWriter.put("lastrow", lastColRow.getHeight());
+
+ return OStringToOUString(jsonWriter.finishAndGetAsOString(), RTL_TEXTENCODING_UTF8);
}
OUString ScModelObj::getPartName( int nPart )