sw/qa/extras/ww8export/data/empty_group.docx |binary sw/qa/extras/ww8export/ww8export4.cxx | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+)
New commits: commit 2c2c155b37750618784cae410f50b75d503e506d Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Fri Apr 19 10:31:39 2024 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Fri Apr 19 08:59:17 2024 +0200 Add a unit test for commit 3f0220f18a66630e06e3c128980f21a5722f49ca (Handle empty range properly, 2024-04-18) Change-Id: Ifea60ace8ff864ef092e6a62177d5926ceb60de3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166278 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/qa/extras/ww8export/data/empty_group.docx b/sw/qa/extras/ww8export/data/empty_group.docx new file mode 100644 index 000000000000..a3454746c5e0 Binary files /dev/null and b/sw/qa/extras/ww8export/data/empty_group.docx differ diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx index 7ab6f76ec3a6..d3bc9c4071d9 100644 --- a/sw/qa/extras/ww8export/ww8export4.cxx +++ b/sw/qa/extras/ww8export/ww8export4.cxx @@ -20,8 +20,11 @@ #include <comphelper/sequenceashashmap.hxx> #include <o3tl/string_view.hxx> +#include <svx/svdpage.hxx> #include <docsh.hxx> +#include <drawdoc.hxx> +#include <IDocumentDrawModelAccess.hxx> #include <IDocumentMarkAccess.hxx> #include <IDocumentSettingAccess.hxx> #include <unotxdoc.hxx> @@ -294,6 +297,27 @@ DECLARE_WW8EXPORT_TEST(testTdf104704_mangledFooter, "tdf104704_mangledFooter.odt CPPUNIT_ASSERT_EQUAL(2, getPages()); } +CPPUNIT_TEST_FIXTURE(Test, testEmptyGroup) +{ + // Given a document with an empty group + createSwDoc("empty_group.docx"); + + CPPUNIT_ASSERT_EQUAL(1, getPages()); + CPPUNIT_ASSERT_EQUAL(1, getShapes()); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObject = pPage->GetObj(0); + + CPPUNIT_ASSERT_EQUAL(u"Empty group"_ustr, pObject->GetName()); + CPPUNIT_ASSERT(pObject->IsGroupObject()); + CPPUNIT_ASSERT_EQUAL(size_t(0), pObject->GetSubList()->GetObjCount()); + + // it must not assert/crash on save + saveAndReload(mpFilter); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT();