Avoid potential negative array index access to cached text.
[LibreOffice.git] / writerfilter / qa / cppunittests / dmapper / DomainMapperTableManager.cxx
blob3743ece63f7b2e7891e2bfda1b5f63dfa3015c18
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <test/unoapi_test.hxx>
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/text/XTextFramesSupplier.hpp>
15 using namespace ::com::sun::star;
17 namespace
19 /// Tests for writerfilter/source/dmapper/DomainMapperTableManager.cxx.
20 class Test : public UnoApiTest
22 public:
23 Test()
24 : UnoApiTest("/writerfilter/qa/cppunittests/dmapper/data/")
29 CPPUNIT_TEST_FIXTURE(Test, testTblOverlap)
31 // Given a document with 2 floating tables, the second is not allowed to overlap:
32 // When importing that document:
33 loadFromFile(u"floattable-tbl-overlap.docx");
35 // Then make sure the second table is marked as "can't overlap":
36 uno::Reference<text::XTextFramesSupplier> xTextDocument(mxComponent, uno::UNO_QUERY);
37 uno::Reference<container::XIndexAccess> xFrames(xTextDocument->getTextFrames(), uno::UNO_QUERY);
38 uno::Reference<beans::XPropertySet> xFrame(xFrames->getByIndex(1), uno::UNO_QUERY);
39 bool bAllowOverlap{};
40 CPPUNIT_ASSERT(xFrame->getPropertyValue("AllowOverlap") >>= bAllowOverlap);
41 // Without the accompanying fix in place, this test would have failed, the tables were marked as
42 // "can overlap".
43 CPPUNIT_ASSERT(!bAllowOverlap);
47 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */