summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2020-05-05 01:55:37 +0530
committerDennis Francis <dennis.francis@collabora.com>2020-05-25 00:39:51 +0530
commitcced75dfbb8d48e855e3c110807d3c95393e94b1 (patch)
treebbf7174e22bb8230f34cef055ee62a18ba6a85d7 /sc/source/ui
parent552db9165faaa8425f2b8cbf71bbef1438bb243a (diff)
Introduce ITiledRenderable::getSheetGeometryData()
ITiledRenderable::getSheetGeometryData(bool bColumns, bool bRows, bool bSizes, bool bHidden, bool bFiltered, bool bGroups) and implement it for the Calc derivation (ScModelObj). The aim is to use it actively in LOOL instead of the interface: ITiledRenderable::getRowColumnHeaders(const tools::Rectangle& /*rRectangle*/) This is used by the LOOL to fetch the sheet geometry data for just the current view-area in the clients, so LOOL queries this everytime some client's view-area changes. Like the existing interface, the new one will provide all 'kinds' of sheet geometry info [col/row sizes(twips), hidden/filtered and grouping]. But the difference is, it generates data for the whole sheet (not view-area specific). So the method need not be queried every time the view area changes in the LOOL clients, and more importantly it enables the clients to locate any cell at any zoom level without any further help from the core. This means core needn't send various client(zoom) specific positioning messages in pixel aligned twips. It just can send all positioning messages in print twips uniformly to all clients. Change-Id: Ib6aee9a0c92746b1576ed244e98cb54b572778c0
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/inc/tabview.hxx4
-rw-r--r--sc/source/ui/unoobj/docuno.cxx15
-rw-r--r--sc/source/ui/view/tabview.cxx77
3 files changed, 96 insertions, 0 deletions
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index a46c76666145..873d05047e46 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -592,6 +592,10 @@ public:
void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges );
/// @see ScModelObj::getRowColumnHeaders().
OUString getRowColumnHeaders(const tools::Rectangle& rRectangle);
+ /// @see ScModelObj::getSheetGeometryData()
+ OString getSheetGeometryData(bool bColumns, bool bRows, bool bSizes, bool bHidden,
+ bool bFiltered, bool bGroups);
+
static void OnLOKNoteStateChanged(const ScPostIt* pNote);
SCROW GetLOKStartHeaderRow() const { return mnLOKStartHeaderRow; }
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 2a4153756eb1..5d4fb17eb0fd 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -909,6 +909,21 @@ OUString ScModelObj::getRowColumnHeaders(const tools::Rectangle& rRectangle)
return pTabView->getRowColumnHeaders(rRectangle);
}
+OString ScModelObj::getSheetGeometryData(bool bColumns, bool bRows, bool bSizes, bool bHidden,
+ bool bFiltered, bool bGroups)
+{
+ ScViewData* pViewData = ScDocShell::GetViewData();
+
+ if (!pViewData)
+ return "";
+
+ ScTabView* pTabView = pViewData->GetView();
+ if (!pTabView)
+ return "";
+
+ return pTabView->getSheetGeometryData(bColumns, bRows, bSizes, bHidden, bFiltered, bGroups);
+}
+
OString ScModelObj::getCellCursor()
{
SolarMutexGuard aGuard;
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index d8bd7996f4ae..3e2f2fa3bdf5 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -49,6 +49,9 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <sfx2/lokhelper.hxx>
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/json_parser.hpp>
+
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
#include <algorithm>
@@ -2757,4 +2760,78 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
return sRet;
}
+OString ScTabView::getSheetGeometryData(bool bColumns, bool bRows, bool bSizes, bool bHidden,
+ bool bFiltered, bool bGroups)
+{
+ boost::property_tree::ptree aTree;
+ aTree.put("commandName", ".uno:SheetGeometryData");
+
+ auto getJSONString = [](const boost::property_tree::ptree& rTree) {
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, rTree);
+ return aStream.str();
+ };
+
+ ScDocument* pDoc = aViewData.GetDocument();
+ if (!pDoc)
+ return getJSONString(aTree).c_str();
+
+ if ((!bSizes && !bHidden && !bFiltered && !bGroups) ||
+ (!bColumns && !bRows))
+ {
+ return getJSONString(aTree).c_str();
+ }
+
+ struct GeomEntry
+ {
+ SheetGeomType eType;
+ const char* pKey;
+ bool bEnabled;
+ };
+
+ const GeomEntry aGeomEntries[] = {
+ { SheetGeomType::SIZES, "sizes", bSizes },
+ { SheetGeomType::HIDDEN, "hidden", bHidden },
+ { SheetGeomType::FILTERED, "filtered", bFiltered },
+ { SheetGeomType::GROUPS, "groups", bGroups }
+ };
+
+ struct DimensionEntry
+ {
+ const char* pKey;
+ bool bDimIsCol;
+ bool bEnabled;
+ };
+
+ const DimensionEntry aDimEntries[] = {
+ { "columns", true, bColumns },
+ { "rows", false, bRows }
+ };
+
+ SCTAB nTab = aViewData.GetTabNo();
+
+ for (const auto& rDimEntry : aDimEntries)
+ {
+ if (!rDimEntry.bEnabled)
+ continue;
+
+ bool bDimIsCol = rDimEntry.bDimIsCol;
+
+ boost::property_tree::ptree aDimTree;
+ for (const auto& rGeomEntry : aGeomEntries)
+ {
+ if (!rGeomEntry.bEnabled)
+ continue;
+
+ OString aGeomDataEncoding = pDoc->dumpSheetGeomData(nTab, bDimIsCol, rGeomEntry.eType);
+ // TODO: Investigate if we can avoid the copy of the 'value' string in put().
+ aDimTree.put(rGeomEntry.pKey, aGeomDataEncoding.getStr());
+ }
+
+ aTree.add_child(rDimEntry.pKey, aDimTree);
+ }
+
+ return getJSONString(aTree).c_str();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */