diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-02-25 11:04:01 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-02-25 19:17:24 +0100 |
commit | d37b9b2f9d6340a4f100f764b02e6f562072c004 (patch) | |
tree | 55b46cf1e32e7df6e6fb9e655be00665c5de6735 /sw/qa | |
parent | 27dd792d6db7012e3e819615e6ee937e2990beec (diff) |
sw: fix incorrect loop condition in SwTransferable::isComplex()
We're not consuming hints in that loop, so we want to end when the
iteration ended, not when the list of hints is empty.
Change-Id: I2cb735c03c3551f7b0be8b314183780eedff9ecf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111519
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/uibase/dochdl/dochdl.cxx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sw/qa/uibase/dochdl/dochdl.cxx b/sw/qa/uibase/dochdl/dochdl.cxx index cd555acc7a7b..2006022fc587 100644 --- a/sw/qa/uibase/dochdl/dochdl.cxx +++ b/sw/qa/uibase/dochdl/dochdl.cxx @@ -10,10 +10,14 @@ #include <swmodeltestbase.hxx> #include <vcl/transfer.hxx> +#include <editeng/wghtitem.hxx> +#include <editeng/postitem.hxx> +#include <editeng/udlnitem.hxx> #include <docsh.hxx> #include <swdtflvr.hxx> #include <wrtsh.hxx> +#include <view.hxx> /// Covers sw/source/uibase/dochdl/ fixes. class SwUibaseDochdlTest : public SwModelTestBase @@ -46,6 +50,30 @@ CPPUNIT_TEST_FIXTURE(SwUibaseDochdlTest, testSelectPasteFormat) CPPUNIT_ASSERT_EQUAL(SotClipboardFormatId::EMBED_SOURCE, nFormat); } +CPPUNIT_TEST_FIXTURE(SwUibaseDochdlTest, testComplexSelection) +{ + // Given a document where a text node has hints, but no as-char images. + SwDoc* pDoc = createSwDoc(); + SwDocShell* pDocShell = pDoc->GetDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + pWrtShell->Insert2("abc"); + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false); + SfxItemSet aSet(pWrtShell->GetView().GetPool(), + svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END - 1>{}); + // Bold, italic, underline. + aSet.Put(SvxWeightItem(WEIGHT_BOLD, RES_CHRATR_WEIGHT)); + aSet.Put(SvxPostureItem(ITALIC_NORMAL, RES_CHRATR_POSTURE)); + aSet.Put(SvxUnderlineItem(LINESTYLE_SINGLE, RES_CHRATR_UNDERLINE)); + pWrtShell->SetAttrSet(aSet); + uno::Reference<datatransfer::XTransferable2> xTransfer = new SwTransferable(*pWrtShell); + + // When checking if the selection is complex, then there should be no crash. + // Without the accompanying fix in place, this test would have crashed, because we read past the + // end of the hints array. + CPPUNIT_ASSERT(!xTransfer->isComplex()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |