diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /sw/qa/core/text/text.cxx | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sw/qa/core/text/text.cxx')
-rw-r--r-- | sw/qa/core/text/text.cxx | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx new file mode 100644 index 000000000..3f7cfb527 --- /dev/null +++ b/sw/qa/core/text/text.cxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> + +#include <vcl/gdimtf.hxx> + +#include <wrtsh.hxx> + +static char const DATA_DIRECTORY[] = "/sw/qa/core/text/data/"; + +/// Covers sw/source/core/text/ fixes. +class SwCoreTextTest : public SwModelTestBase +{ +public: + SwDoc* createDoc(const char* pName = nullptr); +}; + +SwDoc* SwCoreTextTest::createDoc(const char* pName) +{ + load(DATA_DIRECTORY, pName); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + return pTextDoc->GetDocShell()->GetDoc(); +} + +CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testFootnoteConnect) +{ + SwDoc* pDoc = createDoc("footnote-connect.fodt"); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + // Jump to the start of the next page. + pWrtShell->SttNxtPg(); + // Remove the page break. + pWrtShell->DelLeft(); + // Split the multi-line text frame, containing an endnote. + pWrtShell->DelLeft(); + // Join the split text frame. + pWrtShell->DelLeft(); + // Turn the 3 page document into a 2 page one, so the endnote frame is moved. + // Without the accompanying fix in place, this test would have crashed due to a use-after-free + // in SwFootnoteFrame::GetRef(). + pWrtShell->DelLeft(); +} + +CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testSemiTransparentText) +{ + // Create an in-memory empty document. + loadURL("private:factory/swriter", nullptr); + + // Set text to half-transparent and type a character. + uno::Reference<beans::XPropertySet> xParagraph(getParagraph(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xParagraph.is()); + sal_Int16 nTransparence = 50; + xParagraph->setPropertyValue("CharTransparence", uno::makeAny(nTransparence)); + uno::Reference<text::XTextRange> xTextRange(xParagraph, uno::UNO_QUERY); + CPPUNIT_ASSERT(xTextRange.is()); + xTextRange->setString("x"); + + // Render the document to a metafile. + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDocShell* pDocShell = pTextDoc->GetDocShell(); + CPPUNIT_ASSERT(pDocShell); + std::shared_ptr<GDIMetaFile> xMetaFile = pDocShell->GetPreviewMetaFile(); + CPPUNIT_ASSERT(xMetaFile); + + // Make sure that DrawTransparent() was used during rendering. + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "//floattransparent"); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |