Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 :
10 : #include "test/text/xtextcontent.hxx"
11 : #include <com/sun/star/text/XTextContent.hpp>
12 : #include <com/sun/star/text/XTextRange.hpp>
13 : #include <com/sun/star/lang/IllegalArgumentException.hpp>
14 : #include "cppunit/extensions/HelperMacros.h"
15 :
16 : using namespace css;
17 : using namespace css::uno;
18 :
19 : namespace apitest {
20 :
21 2 : void XTextContent::testGetAnchor()
22 : {
23 2 : uno::Reference< text::XTextContent > xTextContent(init(), UNO_QUERY_THROW);
24 4 : uno::Reference< uno::XInterface > xAnchor(xTextContent->getAnchor());
25 4 : CPPUNIT_ASSERT(xAnchor.is());
26 2 : }
27 :
28 2 : void XTextContent::testAttach()
29 : {
30 2 : uno::Reference< text::XTextContent > xTextContent(init(), UNO_QUERY_THROW);
31 4 : uno::Reference< text::XTextRange > xAnchor = xTextContent->getAnchor();
32 :
33 4 : uno::Reference< text::XTextContent > xContent(getTextContent(), UNO_QUERY_THROW);
34 4 : uno::Reference< text::XTextRange > xRange(getTextRange(), UNO_QUERY_THROW);
35 :
36 : try
37 : {
38 2 : if (xContent.is())
39 2 : xContent->attach(xRange);
40 : else
41 0 : xTextContent->attach(xRange);
42 : }
43 2 : catch (const lang::IllegalArgumentException&)
44 : {
45 1 : bool bAttachSupported = isAttachSupported();
46 1 : if (bAttachSupported)
47 0 : CPPUNIT_ASSERT(false);
48 : }
49 0 : catch (const RuntimeException&)
50 : {
51 0 : bool bAttachSupported = isAttachSupported();
52 0 : if (bAttachSupported)
53 0 : CPPUNIT_ASSERT(false);
54 2 : }
55 2 : }
56 :
57 90 : }
58 :
59 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|