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 ++++++++++++++
 vcl/source/treelist/imap.cxx                   |    9 ++++-----
 7 files changed, 57 insertions(+), 5 deletions(-)

New commits:
commit 373585ad0536922175a44dc75bbf5e64334237f1
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Feb 27 08:05:22 2026 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Feb 27 10:01:24 2026 +0100

    no need to allocate this on the heap
    
    Change-Id: I8302375dd3a4f94df287c0b7c59eb3e8d4319ad4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200557
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/vcl/source/treelist/imap.cxx b/vcl/source/treelist/imap.cxx
index a9b37df475c7..c8ded60dbce8 100644
--- a/vcl/source/treelist/imap.cxx
+++ b/vcl/source/treelist/imap.cxx
@@ -956,7 +956,6 @@ void ImageMap::Read( SvStream& rIStm )
 
     if ( !memcmp( cMagic, IMAPMAGIC, sizeof( cMagic ) ) )
     {
-        IMapCompat* pCompat;
         sal_uInt16  nCount;
 
         // delete old content
@@ -970,11 +969,11 @@ void ImageMap::Read( SvStream& rIStm )
         rIStm.ReadUInt16( nCount );
         read_uInt16_lenPrefixed_uInt8s_ToOString(rIStm); // Dummy
 
-        pCompat = new IMapCompat( rIStm, StreamMode::READ );
-
-        // here one can read in newer versions
+        {
+            IMapCompat aCompat( rIStm, StreamMode::READ );
+            // here one can read in newer versions
+        }
 
-        delete pCompat;
         ImpReadImageMap( rIStm, nCount );
 
     }
commit ec98972ddc1e9f0d9ec1e83ca1bce4bceec5ede7
Author:     Gökay Şatır <[email protected]>
AuthorDate: Wed Sep 3 20:31:56 2025 +0300
Commit:     Miklos Vajna <[email protected]>
CommitDate: Fri Feb 27 10:01:11 2026 +0100

    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 <[email protected]>
    Change-Id: Id7c1f37be435b2ac6e9f7bb6554376e1867bfbcb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190563
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200291
    Tested-by: Jenkins

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e5edb459933c..9219ca92acf3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -6768,6 +6768,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)
 {
@@ -6910,6 +6923,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 287b7227dc12..64e83f76f0ba 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -94,6 +94,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 2f6447303151..58d791061c2e 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -313,6 +313,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 b33312922109..4fb2829e7202 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -3725,6 +3725,20 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testValidationCellCrash)
     // Without the fix this will crash.
 }
 
+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 ccc8397575de..9162c5bd13cb 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -144,6 +144,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)
@@ -806,6 +808,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;

Reply via email to