sc/source/ui/unoobj/docuno.cxx | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
New commits: commit 7ea2394e7b4370186c58001549a51acb58c7e49f Author: Gökay Şatır <gokaysa...@collabora.com> AuthorDate: Thu Oct 3 12:12:27 2024 +0300 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Oct 4 09:24:42 2024 +0200 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. Signed-off-by: Gökay Şatır <gokaysa...@collabora.com> Change-Id: Icc26ae71c668c391218e2d517259e1ef32a0832f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174433 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index eee0f203b73a..cc3ea8d9cab9 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -648,16 +648,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 )