1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <test/unoapi_test.hxx>
11 #include <test/container/xenumerationaccess.hxx>
12 #include <test/container/xelementaccess.hxx>
13 #include <test/text/xsimpletext.hxx>
14 #include <test/text/xtextrange.hxx>
15 #include <test/text/xtext.hxx>
17 #include <com/sun/star/frame/Desktop.hpp>
19 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
21 #include <com/sun/star/text/XTextDocument.hpp>
22 #include <com/sun/star/text/XText.hpp>
23 #include <com/sun/star/table/XCell.hpp>
24 #include <com/sun/star/text/XTextTable.hpp>
25 #include <com/sun/star/text/XSimpleText.hpp>
28 using namespace css::uno
;
33 * Initial tests for SwXTableCellText.
35 class SwXTableCellText final
: public UnoApiTest
,
36 public apitest::XEnumerationAccess
,
37 public apitest::XElementAccess
,
38 public apitest::XSimpleText
,
39 public apitest::XTextRange
,
44 : UnoApiTest(u
""_ustr
)
45 , XElementAccess(cppu::UnoType
<text::XTextRange
>::get())
49 Reference
<XInterface
> init() override
51 loadFromURL(u
"private:factory/swriter"_ustr
);
52 Reference
<text::XTextDocument
> xTextDocument(mxComponent
, UNO_QUERY_THROW
);
53 Reference
<lang::XMultiServiceFactory
> xMSF(mxComponent
, UNO_QUERY_THROW
);
55 Reference
<text::XText
> xText
= xTextDocument
->getText();
56 Reference
<text::XTextCursor
> xCursor
= xText
->createTextCursor();
58 Reference
<text::XTextTable
> xTable(
59 xMSF
->createInstance(u
"com.sun.star.text.TextTable"_ustr
), UNO_QUERY_THROW
);
60 xText
->insertTextContent(xCursor
, xTable
, false);
62 Reference
<table::XCell
> xCell
= xTable
->getCellByName(u
"A1"_ustr
);
63 Reference
<text::XSimpleText
> xCellText(xCell
, UNO_QUERY_THROW
);
64 xCellText
->setString(u
"SwXTableCellText"_ustr
);
66 mxTextContent
= Reference
<text::XTextContent
>(
67 xMSF
->createInstance(u
"com.sun.star.text.TextTable"_ustr
), UNO_QUERY_THROW
);
69 return Reference
<XInterface
>(xCellText
->getText(), UNO_QUERY_THROW
);
72 Reference
<text::XTextContent
> getTextContent() override
{ return mxTextContent
; };
74 CPPUNIT_TEST_SUITE(SwXTableCellText
);
75 CPPUNIT_TEST(testCreateEnumeration
);
76 CPPUNIT_TEST(testGetElementType
);
77 CPPUNIT_TEST(testHasElements
);
78 CPPUNIT_TEST(testCreateTextCursor
);
79 CPPUNIT_TEST(testCreateTextCursorByRange
);
80 CPPUNIT_TEST(testInsertString
);
81 CPPUNIT_TEST(testInsertControlCharacter
);
82 CPPUNIT_TEST(testGetEnd
);
83 CPPUNIT_TEST(testGetSetString
);
84 CPPUNIT_TEST(testGetStart
);
85 CPPUNIT_TEST(testGetText
);
86 CPPUNIT_TEST(testInsertRemoveTextContent
);
87 CPPUNIT_TEST_SUITE_END();
90 Reference
<text::XTextContent
> mxTextContent
;
93 CPPUNIT_TEST_SUITE_REGISTRATION(SwXTableCellText
);
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */