sw/qa/extras/uiwriter/data/tdf152030.odt |binary sw/qa/extras/uiwriter/uiwriter6.cxx | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+)
New commits: commit 21c5f6984713077afbebbe36afb67449bbbf21f6 Author: madhura <[email protected]> AuthorDate: Mon Mar 2 10:08:56 2026 +0000 Commit: Xisco Fauli <[email protected]> CommitDate: Mon Mar 2 20:57:19 2026 +0100 tdf#152030 sw: add regression test for deletion of protected TOC Add CppUnit regression test to verify that selecting and deleting a protected table of contents is allowed when the selection fully contains the TOC. Change-Id: Icbc13a0279bd5b81ace5c8f05b84a9387c342312 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200789 Reviewed-by: Xisco Fauli <[email protected]> Tested-by: Jenkins diff --git a/sw/qa/extras/uiwriter/data/tdf152030.odt b/sw/qa/extras/uiwriter/data/tdf152030.odt new file mode 100644 index 000000000000..075824088c1e Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf152030.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx index 9be0d6812b3a..8d4aed361583 100644 --- a/sw/qa/extras/uiwriter/uiwriter6.cxx +++ b/sw/qa/extras/uiwriter/uiwriter6.cxx @@ -41,6 +41,8 @@ #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XDocumentIndexesSupplier.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> #include <o3tl/cppunittraitshelper.hxx> #include <swdtflvr.hxx> @@ -3323,6 +3325,25 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf158454) CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf152030) +{ + createSwDoc("tdf152030.odt"); + + // Ensure a TOC exists initially + uno::Reference<text::XDocumentIndexesSupplier> xIndexesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexes = xIndexesSupplier->getDocumentIndexes(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexes->getCount()); + + // Select entire document (ensures TOC is fully included) + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + // Delete Selection + dispatchCommand(mxComponent, u".uno:Delete"_ustr, {}); + + // After fix: TOC should be deleted + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexes->getCount()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
