summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-09-02 11:35:42 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2022-11-07 16:45:24 +0100
commit83955c0ca0cdd816a2aeac202a2f3b14ea11bdf5 (patch)
treec66b7a8b2cd995c49fcc9f7ea77ca3260a622d09
parentccb0ad61d3ccd3eed3c422dcd4b87486abcf83fc (diff)
lok: Introudce getDataArea for Calc
It will share information about real size of a data inside spreadsheet so we can easily check where data ends in online side. Change-Id: I376187a33c5c82d409f559d5cc826a4f36d4252e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139472 Reviewed-by: Gökay ŞATIR <gokaysatir@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx3
-rw-r--r--desktop/source/lib/init.cxx28
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h6
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx6
-rw-r--r--include/vcl/ITiledRenderable.hxx8
-rw-r--r--sc/inc/docuno.hxx3
-rw-r--r--sc/source/ui/unoobj/docuno.cxx22
7 files changed, 75 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d14030c2f376..2855e7b06162 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3658,10 +3658,11 @@ void DesktopLOKTest::testABI()
CPPUNIT_ASSERT_EQUAL(documentClassOffset(64),
offsetof(struct _LibreOfficeKitDocumentClass, sendContentControlEvent));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(65), offsetof(struct _LibreOfficeKitDocumentClass, getSelectionTypeAndText));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(66), offsetof(struct _LibreOfficeKitDocumentClass, getDataArea));
// Extending is fine, update this, and add new assert for the offsetof the
// new method
- CPPUNIT_ASSERT_EQUAL(documentClassOffset(66), sizeof(struct _LibreOfficeKitDocumentClass));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(67), sizeof(struct _LibreOfficeKitDocumentClass));
}
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 86e12adf0878..13fef313aec4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1028,6 +1028,10 @@ static int doc_getTileMode(LibreOfficeKitDocument* pThis);
static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
long* pWidth,
long* pHeight);
+static void doc_getDataArea(LibreOfficeKitDocument* pThis,
+ long nTab,
+ long* pCol,
+ long* pRow);
static void doc_initializeForRendering(LibreOfficeKitDocument* pThis,
const char* pArguments);
@@ -1280,6 +1284,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->paintPartTile = doc_paintPartTile;
m_pDocumentClass->getTileMode = doc_getTileMode;
m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
+ m_pDocumentClass->getDataArea = doc_getDataArea;
m_pDocumentClass->initializeForRendering = doc_initializeForRendering;
m_pDocumentClass->registerCallback = doc_registerCallback;
m_pDocumentClass->postKeyEvent = doc_postKeyEvent;
@@ -3928,6 +3933,29 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
}
}
+static void doc_getDataArea(LibreOfficeKitDocument* pThis,
+ long nTab,
+ long* pCol,
+ long* pRow)
+{
+ comphelper::ProfileZone aZone("doc_getDataArea");
+
+ SolarMutexGuard aGuard;
+ SetLastExceptionMsg();
+
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (pDoc)
+ {
+ Size aDocumentSize = pDoc->getDataArea(nTab);
+ *pCol = aDocumentSize.Width();
+ *pRow = aDocumentSize.Height();
+ }
+ else
+ {
+ SetLastExceptionMsg("Document doesn't support tiled rendering");
+ }
+}
+
static void doc_initializeForRendering(LibreOfficeKitDocument* pThis,
const char* pArguments)
{
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 3a706ba47091..2f57f744e1d4 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -483,6 +483,12 @@ struct _LibreOfficeKitDocumentClass
char** pText,
char** pUsedMimeType);
+ /// @see lok::Document::getDataArea().
+ void (*getDataArea) (LibreOfficeKitDocument* pThis,
+ long nPart,
+ long* pCol,
+ long* pRow);
+
#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 4aafaa830626..87ff25dcb445 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -208,6 +208,12 @@ public:
mpDoc->pClass->getDocumentSize(mpDoc, pWidth, pHeight);
}
+ /// Get the data area (in Calc last row and column).
+ void getDataArea(long nPart, long* pCol, long* pRow)
+ {
+ mpDoc->pClass->getDataArea(mpDoc, nPart, pCol, pRow);
+ }
+
/**
* Initialize document for rendering.
*
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index a26c1e6675ea..618c61060063 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -71,6 +71,14 @@ public:
virtual Size getDocumentSize() = 0;
/**
+ * Get the data area size (in Calc last column and row).
+ */
+ virtual Size getDataArea(long /*nPart*/)
+ {
+ return Size(1, 1);
+ }
+
+ /**
* Set the document "part", i.e. slide for a slideshow, and
* tab for a spreadsheet.
* bool bAllowChangeFocus - used to not disturb other users while editing when
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index dd3f10e285e9..f963bee00e17 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -310,6 +310,9 @@ public:
/// @see vcl::ITiledRenderable::getDocumentSize().
virtual Size getDocumentSize() override;
+ /// @see vcl::ITiledRenderable::getDataArea().
+ virtual Size getDataArea(long nPart) override;
+
/// @see vcl::ITiledRenderable::setPart().
virtual void setPart(int nPart, bool bAllowChangeFocus = true) override;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 37afe568e5d2..4e102f159d14 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -698,6 +698,28 @@ Size ScModelObj::getDocumentSize()
return aSize;
}
+Size ScModelObj::getDataArea(long nPart)
+{
+ Size aSize(1, 1);
+
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ if (!pViewData || !pDocShell)
+ return aSize;
+
+ SCTAB nTab = nPart;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ const ScDocument& rDoc = pDocShell->GetDocument();
+
+ const ScTable* pTab = rDoc.FetchTable(nTab);
+ if (!pTab)
+ return aSize;
+
+ pTab->GetCellArea(nEndCol, nEndRow);
+ aSize = Size(nEndCol, nEndRow);
+
+ return aSize;
+}
void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode)
{