tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / sw / qa / api / SwXParagraphEnumeration.cxx
blobf579ae414daf127e00a426040473a962a05e689c
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/xenumeration.hxx>
13 #include <com/sun/star/frame/Desktop.hpp>
15 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
17 #include <com/sun/star/text/XTextDocument.hpp>
18 #include <com/sun/star/text/XText.hpp>
19 #include <com/sun/star/container/XEnumeration.hpp>
20 #include <com/sun/star/container/XEnumerationAccess.hpp>
21 #include <com/sun/star/text/ControlCharacter.hpp>
22 #include <com/sun/star/lang/IllegalArgumentException.hpp>
24 #include <comphelper/processfactory.hxx>
26 using namespace css;
27 using namespace css::uno;
29 namespace
31 /**
32 * Initial tests for SwXParagraphEnumeration.
34 class SwXParagraphEnumeration final : public UnoApiTest, public apitest::XEnumeration
36 public:
37 SwXParagraphEnumeration()
38 : UnoApiTest(u""_ustr)
42 Reference<XInterface> init() override
44 loadFromURL(u"private:factory/swriter"_ustr);
45 Reference<text::XTextDocument> xTextDocument(mxComponent, UNO_QUERY_THROW);
46 Reference<lang::XMultiServiceFactory> xMSF(mxComponent, UNO_QUERY_THROW);
48 Reference<text::XText> xText = xTextDocument->getText();
49 Reference<text::XTextCursor> xCursor = xText->createTextCursor();
51 for (int i = 0; i < 5; i++)
53 try
55 xText->insertString(xCursor, u"The quick brown fox jumps over the lazy dog"_ustr,
56 false);
57 xText->insertControlCharacter(xCursor, text::ControlCharacter::LINE_BREAK, false);
58 xText->insertString(xCursor, u"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"_ustr,
59 false);
60 xText->insertControlCharacter(xCursor, text::ControlCharacter::LINE_BREAK, false);
62 catch (lang::IllegalArgumentException&)
66 try
68 xText->insertControlCharacter(xCursor, text::ControlCharacter::PARAGRAPH_BREAK,
69 false);
71 catch (lang::IllegalArgumentException&)
76 Reference<container::XEnumerationAccess> xEnumAccess(xText, UNO_QUERY_THROW);
77 Reference<container::XEnumeration> xEnum = xEnumAccess->createEnumeration();
79 return Reference<XInterface>(xEnum, UNO_QUERY_THROW);
82 CPPUNIT_TEST_SUITE(SwXParagraphEnumeration);
83 CPPUNIT_TEST(testHasMoreElements);
84 CPPUNIT_TEST(testNextElement);
85 CPPUNIT_TEST_SUITE_END();
88 CPPUNIT_TEST_SUITE_REGISTRATION(SwXParagraphEnumeration);
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */