tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / sw / qa / api / SwXFrames.cxx
blob80cfe1840c96a916164a750f4c88bd74ae6400ff
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/container/xelementaccess.hxx>
12 #include <test/container/xindexaccess.hxx>
13 #include <test/container/xnameaccess.hxx>
15 #include <com/sun/star/frame/Desktop.hpp>
17 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
19 #include <com/sun/star/text/XTextDocument.hpp>
20 #include <com/sun/star/text/XText.hpp>
21 #include <com/sun/star/text/XTextFrame.hpp>
22 #include <com/sun/star/text/XTextFramesSupplier.hpp>
24 using namespace css;
25 using namespace css::uno;
27 namespace
29 /**
30 * Initial tests for SwXFramesText.
32 class SwXFramesText final : public UnoApiTest,
33 public apitest::XElementAccess,
34 public apitest::XIndexAccess,
35 public apitest::XNameAccess
37 public:
38 SwXFramesText()
39 : UnoApiTest(u""_ustr)
40 , XElementAccess(cppu::UnoType<text::XTextFrame>::get())
41 , XIndexAccess(1)
42 , XNameAccess(u"Frame1"_ustr)
46 Reference<XInterface> init() override
48 loadFromURL(u"private:factory/swriter"_ustr);
49 Reference<text::XTextDocument> xTextDocument(mxComponent, UNO_QUERY_THROW);
50 Reference<lang::XMultiServiceFactory> xMSF(mxComponent, UNO_QUERY_THROW);
52 Reference<text::XTextFrame> xTextFrame(
53 xMSF->createInstance(u"com.sun.star.text.TextFrame"_ustr), UNO_QUERY_THROW);
55 Reference<text::XText> xText = xTextDocument->getText();
56 Reference<text::XTextCursor> xCursor = xText->createTextCursor();
58 xText->insertTextContent(xCursor, xTextFrame, false);
60 Reference<text::XTextFramesSupplier> xSupplier(xTextDocument, UNO_QUERY_THROW);
62 // Reference<container::XNameAccess> xNA = xSupplier->getTextFrames();
63 // Sequence<OUString> aNames = xNA->getElementNames();
64 // std::cout << aNames[0] << std::endl;
66 return Reference<XInterface>(xSupplier->getTextFrames(), UNO_QUERY_THROW);
69 CPPUNIT_TEST_SUITE(SwXFramesText);
70 CPPUNIT_TEST(testGetByName);
71 CPPUNIT_TEST(testGetElementNames);
72 CPPUNIT_TEST(testHasByName);
73 CPPUNIT_TEST(testGetElementType);
74 CPPUNIT_TEST(testHasElements);
75 CPPUNIT_TEST(testGetCount);
76 CPPUNIT_TEST(testGetByIndex);
77 CPPUNIT_TEST_SUITE_END();
80 CPPUNIT_TEST_SUITE_REGISTRATION(SwXFramesText);
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */