sc/source/ui/unoobj/docuno.cxx |   29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

New commits:
commit cb610c0200152ea2d62152a3e6f5e003e246bd21
Author:     Gökay Şatır <gokaysa...@collabora.com>
AuthorDate: Thu Oct 3 12:12:27 2024 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Nov 20 11:56:45 2024 +0100

    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 <vmik...@collabora.com>
    Tested-by: Jenkins

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 )

Reply via email to