diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-04-27 20:48:30 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-04-28 09:03:18 +0200 |
commit | 4ba1909f12b49f020195b5e767045340717ce6df (patch) | |
tree | 12ba92e913c321cc0ca0421c9dcf87879819177c /sw/qa/core/objectpositioning/objectpositioning.cxx | |
parent | 7cfc983f8f3f4d094cd01128043d5e2021cb80c6 (diff) |
tdf#131729 sw: handle no drawing objects when calculating overlap of objects
Regression from commit d37096f59e7e0286e55008153591a60bab92b9e8
(Related: tdf#124600 sw anchored object allow overlap: add layout,
2019-09-19), we assumed that the anchor frame always has draw objects,
but that may not be the case.
That happens when dragging a to-character anchored object around, before
the object is added to its anchor.
Change-Id: I1271a6e498553838c3851864b7965a1ba28de663
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92989
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa/core/objectpositioning/objectpositioning.cxx')
-rw-r--r-- | sw/qa/core/objectpositioning/objectpositioning.cxx | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/sw/qa/core/objectpositioning/objectpositioning.cxx b/sw/qa/core/objectpositioning/objectpositioning.cxx new file mode 100644 index 000000000000..c73e97567f20 --- /dev/null +++ b/sw/qa/core/objectpositioning/objectpositioning.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 <swmodeltestbase.hxx> + +#include <comphelper/classids.hxx> +#include <svtools/embedhlp.hxx> +#include <svx/svdpage.hxx> +#include <tools/globname.hxx> +#include <unotest/bootstrapfixturebase.hxx> +#include <vcl/gdimtf.hxx> + +#include <wrtsh.hxx> +#include <fmtanchr.hxx> +#include <IDocumentDrawModelAccess.hxx> +#include <drawdoc.hxx> +#include <dcontact.hxx> + +static char const DATA_DIRECTORY[] = "/sw/qa/core/objectpositioning/data/"; + +/// Covers sw/source/core/objectpositioning/ fixes. +class SwCoreObjectpositioningTest : public SwModelTestBase +{ +}; + +CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, testOverlapCrash) +{ + // Load a document with 2 images. + load(DATA_DIRECTORY, "overlap-crash.odt"); + + // Change their anchor type to to-char. + uno::Reference<beans::XPropertySet> xShape1(getShape(1), uno::UNO_QUERY); + xShape1->setPropertyValue("AnchorType", uno::makeAny(text::TextContentAnchorType_AT_CHARACTER)); + uno::Reference<beans::XPropertySet> xShape2(getShape(1), uno::UNO_QUERY); + xShape2->setPropertyValue("AnchorType", uno::makeAny(text::TextContentAnchorType_AT_CHARACTER)); + + // Insert a new paragraph at the start. + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwDocShell* pDocShell = pTextDoc->GetDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + // Without the accompanying fix in place, this test would have crashed. + pWrtShell->SplitNode(); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |