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 50e817ed03ccc201b8f6207801608a4414421cf0
Author:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
AuthorDate: Wed Jul 31 11:30:12 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Aug 21 10:01:49 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
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172110

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 b653a1cc2201..2fdd062f5c81 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 4d87241a03ba..c63d28e73af4 100644
--- a/sw/source/core/doc/fmtcol.cxx
+++ b/sw/source/core/doc/fmtcol.cxx
@@ -132,7 +132,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 77dbe2e0290f..c679afc618a6 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -5546,13 +5546,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 (dynamic_cast<const SwAttrHint*>(&rHint))
     {
         if (&rModify == GetRegisteredIn())

Reply via email to