From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- sw/qa/core/attr/attr.cxx | 53 +++++++++++++++++++++++++++++++++++++ sw/qa/core/attr/data/attr-set.docx | Bin 0 -> 11582 bytes 2 files changed, 53 insertions(+) create mode 100644 sw/qa/core/attr/attr.cxx create mode 100644 sw/qa/core/attr/data/attr-set.docx (limited to 'sw/qa/core/attr') diff --git a/sw/qa/core/attr/attr.cxx b/sw/qa/core/attr/attr.cxx new file mode 100644 index 000000000..0df9d9ef0 --- /dev/null +++ b/sw/qa/core/attr/attr.cxx @@ -0,0 +1,53 @@ +/* -*- 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 + +#include +#include +#include + +namespace +{ +constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/core/attr/data/"; + +/// Covers sw/source/core/attr/ fixes. +class Test : public SwModelTestBase +{ +}; + +CPPUNIT_TEST_FIXTURE(Test, testSwAttrSet) +{ + // Given a document with track changes and the whole document is selected: + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "attr-set.docx"); + SwDocShell* pDocShell = pDoc->GetDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Cut", {}); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + rtl::Reference xTransferable(new SwTransferable(*pWrtShell)); + SwModule* pMod = SW_MOD(); + SwTransferable* pOldTransferable = pMod->m_pXSelection; + pMod->m_pXSelection = xTransferable.get(); + + // When getting the plain text version of the selection: + datatransfer::DataFlavor aFlavor; + aFlavor.MimeType = "text/plain;charset=utf-16"; + aFlavor.DataType = cppu::UnoType::get(); + uno::Any aData = xTransferable->getTransferData(aFlavor); + + // Then make sure we get data without crashing: + CPPUNIT_ASSERT(aData.hasValue()); + pMod->m_pXSelection = pOldTransferable; +} +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/attr/data/attr-set.docx b/sw/qa/core/attr/data/attr-set.docx new file mode 100644 index 000000000..0cb8508aa Binary files /dev/null and b/sw/qa/core/attr/data/attr-set.docx differ -- cgit v1.2.3