[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - desktop/qa sw/source tools/qa tools/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 11 11:23:03 UTC 2021
desktop/qa/desktop_lib/test_desktop_lib.cxx | 2
sw/source/core/crsr/crsrsh.cxx | 69 +++++++++++++---------------
tools/qa/cppunit/test_json_writer.cxx | 2
tools/source/misc/json_writer.cxx | 2
4 files changed, 36 insertions(+), 39 deletions(-)
New commits:
commit d46c7bd597e51453ac420db97fd898ed2f3b26bf
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Aug 3 14:42:13 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 11 13:22:30 2021 +0200
use tools::Json for cursor messages
and tweak the JsonWriter to produce output more like the boost propertytree,
to make the cypress tests happier.
Change-Id: Ia2062508ae9f14a5f89306042c33884ff300f478
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119936
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d41777c5e77b..9d454752239c 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2027,7 +2027,7 @@ public:
break;
case LOK_CALLBACK_TABLE_SELECTED:
{
- m_bEmptyTableSelection = (std::string(pPayload).compare("{\n}\n") == 0);
+ m_bEmptyTableSelection = (std::string(pPayload).compare("{ }") == 0);
++m_nTableSelectionCount;
}
break;
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index fd0e4aef29a8..dd0ca592aabe 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -73,7 +73,7 @@
#include <wrtsh.hxx>
#include <undobj.hxx>
#include <view.hxx>
-#include <boost/property_tree/json_parser.hpp>
+#include <tools/json_writer.hxx>
using namespace com::sun::star;
using namespace util;
@@ -2044,69 +2044,66 @@ void SwCursorShell::sendLOKCursorUpdates()
SwFrame* pCurrentFrame = GetCurrFrame();
SelectionType eType = pShell->GetSelectionType();
- boost::property_tree::ptree aRootTree;
+ tools::JsonWriter aJsonWriter;
if (pCurrentFrame && (eType & SelectionType::Table) && pCurrentFrame->IsInTab())
{
const SwRect& rPageRect = pShell->GetAnyCurRect(CurRectType::Page, nullptr);
- boost::property_tree::ptree aTableColumns;
{
+ auto columnsNode = aJsonWriter.startNode("columns");
SwTabCols aTabCols;
pShell->GetTabCols(aTabCols);
const int nColumnOffset = aTabCols.GetLeftMin() + rPageRect.Left();
- aTableColumns.put("left", aTabCols.GetLeft());
- aTableColumns.put("right", aTabCols.GetRight());
- aTableColumns.put("tableOffset", nColumnOffset);
+ aJsonWriter.put("left", aTabCols.GetLeft());
+ aJsonWriter.put("right", aTabCols.GetRight());
+ aJsonWriter.put("tableOffset", nColumnOffset);
- boost::property_tree::ptree aEntries;
- for (size_t i = 0; i < aTabCols.Count(); ++i)
{
- auto const & rEntry = aTabCols.GetEntry(i);
- boost::property_tree::ptree aTableColumnEntry;
- aTableColumnEntry.put("position", rEntry.nPos);
- aTableColumnEntry.put("min", rEntry.nMin);
- aTableColumnEntry.put("max", rEntry.nMax);
- aTableColumnEntry.put("hidden", rEntry.bHidden);
- aEntries.push_back(std::make_pair("", aTableColumnEntry));
+ auto entriesNode = aJsonWriter.startArray("entries");
+ for (size_t i = 0; i < aTabCols.Count(); ++i)
+ {
+ auto entryNode = aJsonWriter.startStruct();
+ auto const & rEntry = aTabCols.GetEntry(i);
+ aJsonWriter.put("position", rEntry.nPos);
+ aJsonWriter.put("min", rEntry.nMin);
+ aJsonWriter.put("max", rEntry.nMax);
+ aJsonWriter.put("hidden", rEntry.bHidden);
+ }
}
- aTableColumns.push_back(std::make_pair("entries", aEntries));
}
- boost::property_tree::ptree aTableRows;
{
+ auto rowsNode = aJsonWriter.startNode("rows");
SwTabCols aTabRows;
pShell->GetTabRows(aTabRows);
const int nRowOffset = aTabRows.GetLeftMin() + rPageRect.Top();
- aTableRows.put("left", aTabRows.GetLeft());
- aTableRows.put("right", aTabRows.GetRight());
- aTableRows.put("tableOffset", nRowOffset);
+ aJsonWriter.put("left", aTabRows.GetLeft());
+ aJsonWriter.put("right", aTabRows.GetRight());
+ aJsonWriter.put("tableOffset", nRowOffset);
- boost::property_tree::ptree aEntries;
- for (size_t i = 0; i < aTabRows.Count(); ++i)
{
- auto const & rEntry = aTabRows.GetEntry(i);
- boost::property_tree::ptree aTableRowEntry;
- aTableRowEntry.put("position", rEntry.nPos);
- aTableRowEntry.put("min", rEntry.nMin);
- aTableRowEntry.put("max", rEntry.nMax);
- aTableRowEntry.put("hidden", rEntry.bHidden);
- aEntries.push_back(std::make_pair("", aTableRowEntry));
+ auto entriesNode = aJsonWriter.startArray("entries");
+ for (size_t i = 0; i < aTabRows.Count(); ++i)
+ {
+ auto entryNode = aJsonWriter.startStruct();
+ auto const & rEntry = aTabRows.GetEntry(i);
+ aJsonWriter.put("position", rEntry.nPos);
+ aJsonWriter.put("min", rEntry.nMin);
+ aJsonWriter.put("max", rEntry.nMax);
+ aJsonWriter.put("hidden", rEntry.bHidden);
+ }
}
- aTableRows.push_back(std::make_pair("entries", aEntries));
}
-
- aRootTree.add_child("columns", aTableColumns);
- aRootTree.add_child("rows", aTableRows);
}
- std::stringstream aStream;
- boost::property_tree::write_json(aStream, aRootTree);
- GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TABLE_SELECTED, aStream.str().c_str());
+ char* pChar = aJsonWriter.extractData();
+ GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TABLE_SELECTED, pChar);
+ free(pChar);
}
void SwCursorShell::RefreshBlockCursor()
diff --git a/tools/qa/cppunit/test_json_writer.cxx b/tools/qa/cppunit/test_json_writer.cxx
index 6a2cc7813574..6ff2810d79d4 100644
--- a/tools/qa/cppunit/test_json_writer.cxx
+++ b/tools/qa/cppunit/test_json_writer.cxx
@@ -58,7 +58,7 @@ void JsonWriterTest::test1()
std::unique_ptr<char, Free> result(aJson.extractData());
CPPUNIT_ASSERT_EQUAL(std::string("{ \"node\": { \"oustring\": \"val1\", \"ostring\": \"val2\", "
- "\"charptr\": \"val3\", \"int\": 12}}"),
+ "\"charptr\": \"val3\", \"int\": \"12\"}}"),
std::string(result.get()));
}
diff --git a/tools/source/misc/json_writer.cxx b/tools/source/misc/json_writer.cxx
index 9319db2799bc..839fbfd2eb47 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -318,7 +318,7 @@ void JsonWriter::put(const char* pPropName, int nPropVal)
memcpy(mPos, "\": ", 3);
mPos += 3;
- mPos += sprintf(mPos, "%d", nPropVal);
+ mPos += sprintf(mPos, "\"%d\"", nPropVal);
}
void JsonWriter::putRaw(const rtl::OStringBuffer& rRawBuf)
More information about the Libreoffice-commits
mailing list