diff options
-rw-r--r-- | sw/CppunitTest_sw_core_layout.mk | 1 | ||||
-rw-r--r-- | sw/qa/core/layout/data/sorted-objs-insert.docx | bin | 0 -> 27084 bytes | |||
-rw-r--r-- | sw/qa/core/layout/sortedobjs.cxx | 35 | ||||
-rw-r--r-- | sw/source/core/layout/sortedobjs.cxx | 6 |
4 files changed, 42 insertions, 0 deletions
diff --git a/sw/CppunitTest_sw_core_layout.mk b/sw/CppunitTest_sw_core_layout.mk index 82f7dc87e695..8cc670abf64d 100644 --- a/sw/CppunitTest_sw_core_layout.mk +++ b/sw/CppunitTest_sw_core_layout.mk @@ -19,6 +19,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sw_core_layout, \ sw/qa/core/layout/layact \ sw/qa/core/layout/layout \ sw/qa/core/layout/paintfrm \ + sw/qa/core/layout/sortedobjs \ sw/qa/core/layout/tabfrm \ )) diff --git a/sw/qa/core/layout/data/sorted-objs-insert.docx b/sw/qa/core/layout/data/sorted-objs-insert.docx Binary files differnew file mode 100644 index 000000000000..4041ab986891 --- /dev/null +++ b/sw/qa/core/layout/data/sorted-objs-insert.docx diff --git a/sw/qa/core/layout/sortedobjs.cxx b/sw/qa/core/layout/sortedobjs.cxx new file mode 100644 index 000000000000..471dd48a8b0c --- /dev/null +++ b/sw/qa/core/layout/sortedobjs.cxx @@ -0,0 +1,35 @@ +/* -*- 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> + +namespace +{ +/// Covers sw/source/core/layout/sortedobjs.cxx fixes. +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/core/layout/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testSortedObjsInsert) +{ + // Given a document with two anchored objects, one is a fly frame in the header and the other is + // a group shape where one inner shape has an associated fly frame: + // When importing that document: + // Then make sure that we don't try to do binary search on an unsorted container that leads to a + // crash in debug builds: + createSwDoc("sorted-objs-insert.docx"); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/sortedobjs.cxx b/sw/source/core/layout/sortedobjs.cxx index da388bd3cbc9..ce581bb663ef 100644 --- a/sw/source/core/layout/sortedobjs.cxx +++ b/sw/source/core/layout/sortedobjs.cxx @@ -207,6 +207,12 @@ bool SwSortedObjs::is_sorted() const bool SwSortedObjs::Insert( SwAnchoredObject& _rAnchoredObj ) { + if (!is_sorted()) + { + SAL_WARN("sw.core", "SwSortedObjs::Insert: object list is not sorted"); + UpdateAll(); + } + // #i51941# if ( Contains( _rAnchoredObj ) ) { |