LibreOffice Module test (master)  1
textcontent.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 
11 
12 #include <com/sun/star/text/TextContentAnchorType.hpp>
13 #include <com/sun/star/beans/XPropertySet.hpp>
14 
15 #include <com/sun/star/uno/Any.hxx>
16 #include <com/sun/star/uno/Reference.hxx>
17 #include <com/sun/star/uno/Sequence.hxx>
18 
19 #include <cppunit/TestAssert.h>
20 
21 using namespace css;
22 
23 namespace apitest
24 {
25 void TextContent::testTextContentProperties()
26 {
27  uno::Reference<beans::XPropertySet> xPS(init(), uno::UNO_QUERY_THROW);
28 
29  text::TextContentAnchorType aExpectedTCAT;
30  CPPUNIT_ASSERT(xPS->getPropertyValue("AnchorType") >>= aExpectedTCAT);
31  CPPUNIT_ASSERT_EQUAL(m_aExpectedTCAT, aExpectedTCAT);
32 
33  try
34  {
35  xPS->setPropertyValue("AnchorType", uno::makeAny(m_aNewTCAT));
36  text::TextContentAnchorType aNewTCAT;
37  CPPUNIT_ASSERT(xPS->getPropertyValue("AnchorType") >>= aNewTCAT);
38  CPPUNIT_ASSERT_EQUAL(m_aNewTCAT, aNewTCAT);
39  }
40  catch (const beans::UnknownPropertyException& /* ex */)
41  {
42  // ignore if property is optional
43  }
44 
45  uno::Sequence<text::TextContentAnchorType> aAnchorTypes;
46  CPPUNIT_ASSERT(xPS->getPropertyValue("AnchorTypes") >>= aAnchorTypes);
47  CPPUNIT_ASSERT(aAnchorTypes.hasElements());
48 
49  text::WrapTextMode aExpectedWTM;
50  CPPUNIT_ASSERT(xPS->getPropertyValue("TextWrap") >>= aExpectedWTM);
51  CPPUNIT_ASSERT_EQUAL(m_aExpectedWTM, aExpectedWTM);
52 
53  try
54  {
55  xPS->setPropertyValue("TextWrap", uno::makeAny(m_aNewWTM));
56  text::WrapTextMode aNewWTM;
57  CPPUNIT_ASSERT(xPS->getPropertyValue("TextWrap") >>= aNewWTM);
58  CPPUNIT_ASSERT_EQUAL(m_aNewWTM, aNewWTM);
59  }
60  catch (const beans::UnknownPropertyException& /* ex */)
61  {
62  // ignore if property is optional
63  }
64 }
65 
66 } // namespace apitest
67 
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
FILE * init(int, char **)