Avoid potential negative array index access to cached text.
[LibreOffice.git] / writerfilter / qa / cppunittests / dmapper / TableManager.cxx
blob0f27633dce7403ab889ec6dd3e8e551ba313182e
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/text/XTextFramesSupplier.hpp>
14 using namespace com::sun::star;
16 namespace
18 /// Tests for writerfilter/source/dmapper/TableManager.cxx.
19 class Test : public UnoApiTest
21 public:
22 Test()
23 : UnoApiTest("/writerfilter/qa/cppunittests/dmapper/data/")
28 CPPUNIT_TEST_FIXTURE(Test, testFloattableNestedCellStartDOCXImport)
30 // Given a document with a nested floating table at cell start and an other inner floating table:
31 // When importing that document:
32 loadFromFile(u"floattable-nested-cellstart.docx");
34 // Then make sure that both inner tables are floating:
35 uno::Reference<text::XTextFramesSupplier> xFramesSupplier(mxComponent, uno::UNO_QUERY);
36 uno::Reference<container::XIndexAccess> xFrames(xFramesSupplier->getTextFrames(),
37 uno::UNO_QUERY);
38 // Without the accompanying fix in place, this test would have failed with:
39 // - Expected: 2
40 // - Actual : 1
41 // i.e. the first inner table was not floating.
42 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xFrames->getCount());
46 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */