LibreOffice Module test (master)  1
tablecolumn.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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  */
9 
12 #include <comphelper/types.hxx>
13 #include <rtl/ustring.hxx>
14 
15 #include <com/sun/star/beans/XPropertySet.hpp>
16 #include <com/sun/star/table/XCellRange.hpp>
17 
18 #include <com/sun/star/uno/Any.hxx>
19 #include <com/sun/star/uno/Reference.hxx>
20 
21 #include <cppunit/TestAssert.h>
22 
23 using namespace css;
24 
25 namespace apitest
26 {
27 void TableColumn::testTableColumnProperties()
28 {
29  uno::Reference<beans::XPropertySet> xPS(init(), uno::UNO_QUERY_THROW);
30 
31  OUString aPropName = "Width";
32  testLongProperty(xPS, aPropName);
33 
34  // currently changing the value to false has no effect
35  aPropName = "OptimalWidth";
36  uno::Reference<table::XCellRange> xCR(m_xSheet, uno::UNO_QUERY_THROW);
37  xCR->getCellByPosition(0, 0)->setFormula("That's a pretty long text.");
38  const sal_Int64 nWidthBefore = ::comphelper::getINT64(xPS->getPropertyValue("Width"));
39  xPS->setPropertyValue(aPropName, uno::makeAny(true));
40  CPPUNIT_ASSERT(::comphelper::getBOOL(xPS->getPropertyValue(aPropName)));
41  const sal_Int64 nWidthAfter = ::comphelper::getINT64(xPS->getPropertyValue("Width"));
42  CPPUNIT_ASSERT(nWidthBefore != nWidthAfter);
43 
44  aPropName = "IsVisible";
45  testBooleanProperty(xPS, aPropName);
46 
47  aPropName = "IsStartOfNewPage";
48  testBooleanProperty(xPS, aPropName);
49 }
50 
51 } // namespace apitest
52 
53 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
bool getBOOL(const Any &_rAny)
void testBooleanProperty(uno::Reference< beans::XPropertySet > const &xPropertySet, const OUString &name)
FILE * init(int, char **)
void testLongProperty(uno::Reference< beans::XPropertySet > const &xPropertySet, const OUString &name, const sal_Int32 &nValue)