sw/qa/core/doc/data/tdf160843.odt |binary
 sw/qa/core/doc/doc.cxx            |   23 +++++++++++++++++++++++
 sw/source/core/doc/fmtcol.cxx     |    7 ++++++-
 sw/source/core/txtnode/ndtxt.cxx  |    5 ++++-
 4 files changed, 33 insertions(+), 2 deletions(-)

New commits:
commit 65d6ff10cea3641509683e407695589b269ff1dd
Author:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
AuthorDate: Wed Jul 31 11:30:12 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Aug 2 11:13:18 2024 +0200

    tdf#160843: fix page count reset
    
    - SwTextFormatColl and SwTextNode: explicitly forward page count hint
    - add test
    
    Change-Id: Ic37bece92828f21632acff8f802d4847e820542f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171329
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 39fd178b86608ebb0717bf15992bdf6b16d6e92a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171362

diff --git a/sw/qa/core/doc/data/tdf160843.odt 
b/sw/qa/core/doc/data/tdf160843.odt
new file mode 100644
index 000000000000..97f0619a433b
Binary files /dev/null and b/sw/qa/core/doc/data/tdf160843.odt differ
diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx
index b207f9c0f9bb..0da481188cbe 100644
--- a/sw/qa/core/doc/doc.cxx
+++ b/sw/qa/core/doc/doc.cxx
@@ -609,6 +609,29 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testSplitFlyInsertUndo)
     CPPUNIT_ASSERT(!rFlyFormats.empty());
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testVirtPageNumReset)
+{
+    createSwDoc("tdf160843.odt");
+    auto pWrtShell = getSwDocShell()->GetWrtShell();
+    sal_uInt16 nPhys = 0;
+    sal_uInt16 nVirt = 0;
+
+    pWrtShell->GotoPage(1, false);
+    pWrtShell->GetPageNum(nPhys, nVirt, true, false);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), nPhys);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), nVirt);
+
+    pWrtShell->GotoPage(3, false);
+    pWrtShell->GetPageNum(nPhys, nVirt, true, false);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(3), nPhys);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), nVirt);
+
+    pWrtShell->GotoPage(5, false);
+    pWrtShell->GetPageNum(nPhys, nVirt, true, false);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(5), nPhys);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), nVirt);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx
index 96274bb5b5d3..f3523a544e97 100644
--- a/sw/source/core/doc/fmtcol.cxx
+++ b/sw/source/core/doc/fmtcol.cxx
@@ -133,7 +133,12 @@ void SwTextFormatColl::SwClientNotify(const SwModify& 
rModify, const SfxHint& rH
         CallSwClientNotify(rHint);
         return;
     }
-    if (rHint.GetId() != SfxHintId::SwLegacyModify)
+    else if (rHint.GetId() == SfxHintId::SwVirtPageNumHint)
+    {
+        CallSwClientNotify(rHint);
+        return;
+    }
+    else if (rHint.GetId() != SfxHintId::SwLegacyModify)
         return;
     auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
     if(GetDoc()->IsInDtor())
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 4cb8534ab205..ab3a57e44778 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -5545,13 +5545,16 @@ void SwTextNode::SwClientNotify( const SwModify& 
rModify, const SfxHint& rHint )
     if(rHint.GetId() == SfxHintId::SwAutoFormatUsedHint)
     {
         static_cast<const sw::AutoFormatUsedHint&>(rHint).CheckNode(this);
-        return;
     }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
         auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
         TriggerNodeUpdate(*pLegacyHint);
     }
+    else if (rHint.GetId() == SfxHintId::SwVirtPageNumHint)
+    {
+        CallSwClientNotify(rHint);
+    }
     else if (rHint.GetId() == SfxHintId::SwAttr)
     {
         if (&rModify == GetRegisteredIn())

Reply via email to