use insert function instead of for loop
[LibreOffice.git] / sw / qa / api / SwXTextFrame.cxx
blob4b11138cba8ccdbfc63f37ed6b8224fab8fb0513
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>
11 #include <test/lang/xserviceinfo.hxx>
12 #include <test/lang/xcomponent.hxx>
14 #include <com/sun/star/frame/Desktop.hpp>
15 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
16 #include <com/sun/star/text/XTextDocument.hpp>
17 #include <com/sun/star/text/XText.hpp>
18 #include <com/sun/star/text/XTextCursor.hpp>
19 #include <com/sun/star/text/XTextFrame.hpp>
21 using namespace css;
23 namespace
25 /**
26 * Test for Java API test of file com.sun.star.comp.office.SwXTextFrame.csv
28 class SwXTextFrame final : public UnoApiTest,
29 public apitest::XServiceInfo,
30 public apitest::XComponent
32 public:
33 SwXTextFrame()
34 : UnoApiTest(u""_ustr)
35 , apitest::XServiceInfo(u"SwXTextFrame"_ustr, u"com.sun.star.text.TextFrame"_ustr)
39 uno::Reference<uno::XInterface> init() override
41 loadFromURL(u"private:factory/swriter"_ustr);
42 uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY_THROW);
43 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY_THROW);
44 uno::Reference<text::XTextFrame> xTextFrame(
45 xMSF->createInstance(u"com.sun.star.text.TextFrame"_ustr), uno::UNO_QUERY_THROW);
46 auto xText = xTextDocument->getText();
47 auto xTextCursor = xText->createTextCursor();
48 CPPUNIT_ASSERT(xTextCursor.is());
49 xText->insertTextContent(xTextCursor, xTextFrame, false);
50 xTextCursor->gotoEnd(false);
51 return xTextFrame;
54 void triggerDesktopTerminate() override { mxDesktop->terminate(); }
56 CPPUNIT_TEST_SUITE(SwXTextFrame);
57 CPPUNIT_TEST(testGetImplementationName);
58 CPPUNIT_TEST(testGetSupportedServiceNames);
59 CPPUNIT_TEST(testSupportsService);
60 CPPUNIT_TEST(testAddEventListener);
61 CPPUNIT_TEST(testRemoveEventListener);
62 CPPUNIT_TEST_SUITE_END();
65 CPPUNIT_TEST_SUITE_REGISTRATION(SwXTextFrame);
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */