desktop/source/lib/init.cxx | 17 +++++++++++++++++ include/vcl/ITiledRenderable.hxx | 5 +++++ sc/inc/docuno.hxx | 3 +++ sc/qa/unit/tiledrendering/data/PrintRanges.ods |binary sc/qa/unit/tiledrendering/tiledrendering.cxx | 14 ++++++++++++++ sc/source/ui/unoobj/docuno.cxx | 14 ++++++++++++++ 6 files changed, 53 insertions(+)
New commits: commit e0fde66ad1e86cb1d6f9f1d0ea276a59a1c4cc0f Author: Gökay Şatır <gokaysa...@gmail.com> AuthorDate: Wed Sep 3 20:31:56 2025 +0300 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Sep 8 14:43:04 2025 +0200 cool#12762: Calc Online: Implement doc_getPrintRanges for document load. Issue: If a document has print ranges defined, Online side doesn't get it on document load and can't show the ranges. Fix: Add it to the document status message. There is also an Online side commit. Also a test added for the feature. Signed-off-by: Gökay Şatır <gokaysa...@gmail.com> Change-Id: Id7c1f37be435b2ac6e9f7bb6554376e1867bfbcb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190563 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 3bc592c01592..d62a258f45f7 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -6634,6 +6634,19 @@ static char* getUndoOrRedo(LibreOfficeKitDocument* pThis, UndoOrRedo eCommand) return pJson; } +/// Returns the JSON representation of print ranges in the document +static char* getPrintRanges(LibreOfficeKitDocument* pThis) +{ + ITiledRenderable* pDoc = getTiledRenderable(pThis); + if (!pDoc) + { + SetLastExceptionMsg(u"Document doesn't support tiled rendering"_ustr); + return nullptr; + } + + return convertOString(rtl::OUStringToOString(pDoc->getPrintRanges(), RTL_TEXTENCODING_UTF8)); +} + /// Returns only the number of the undo or redo elements static char* getUndoOrRedoCount(LibreOfficeKitDocument* pThis, UndoOrRedo eCommand) { @@ -6776,6 +6789,10 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo { return getUndoOrRedo(pThis, UndoOrRedo::REDO); } + else if (aCommand == ".uno:DefinePrintArea") + { + return getPrintRanges(pThis); + } else if (aCommand == ".uno:UndoCount") { return getUndoOrRedoCount(pThis, UndoOrRedo::UNDO); diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index fa42c077df5f..6bdb24d8b148 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -78,6 +78,11 @@ public: return Size(1, 1); } + virtual OUString getPrintRanges() + { + return OUString(); + } + /** * Set the document "part", i.e. slide for a slideshow, and * tab for a spreadsheet. diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index 898d96f5b140..3f47b0099fe0 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -315,6 +315,9 @@ public: /// @see vcl::ITiledRenderable::getDataArea(). virtual Size getDataArea(long nPart) override; + /// @see vcl::ITiledRenderable::getPrintRanges(). + virtual OUString getPrintRanges() override; + /// @see vcl::ITiledRenderable::setPart(). virtual void setPart(int nPart, bool bAllowChangeFocus = true) override; diff --git a/sc/qa/unit/tiledrendering/data/PrintRanges.ods b/sc/qa/unit/tiledrendering/data/PrintRanges.ods new file mode 100644 index 000000000000..a15824d94ad7 Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/PrintRanges.ods differ diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 95f01579deec..f4f0d15bcc6a 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -3636,6 +3636,20 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testPivotFilterPosition) CPPUNIT_ASSERT(it != aView.m_aStateChanges.end()); } +CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testPrintRanges) +{ + ScModelObj* pModelObj = createDoc("PrintRanges.ods"); + ScTestViewCallback aView; + pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + + /* + Expected output: { \"printranges\": [ { \"sheet\": 0, \"ranges\": [ [ 2, 6, 2, 6]]}]} + */ + OUString printRanges = pModelObj->getPrintRanges().replaceAll(" ", ""); + + CPPUNIT_ASSERT_EQUAL(u"{\"printranges\":[{\"sheet\":0,\"ranges\":[[2,6,2,6]]}]}"_ustr, printRanges); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 4edce1d6a496..770eb46f37ea 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -140,6 +140,8 @@ #include <strings.hrc> +#include <prnsave.hxx> + using namespace com::sun::star; // #i111553# provides the name of the VBA constant for this document type (e.g. 'ThisExcelDoc' for Calc) @@ -780,6 +782,18 @@ Size ScModelObj::getDataArea(long nPart) return aSize; } +OUString ScModelObj::getPrintRanges() +{ + const ScDocument& rDoc = pDocShell->GetDocument(); + + std::unique_ptr<ScPrintRangeSaver> pSaver = rDoc.CreatePrintRangeSaver(); + + tools::JsonWriter aJsonWriter; + pSaver->GetPrintRangesInfo(aJsonWriter); + + return OStringToOUString(aJsonWriter.finishAndGetAsOString(), RTL_TEXTENCODING_UTF8); +} + void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode) { SolarMutexGuard aGuard;