tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / sw / qa / api / SwXBookmark.cxx
blobd2233c9b9aced5cb7075f987f9b7f5cd10e04a62
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/xcomponent.hxx>
12 #include <test/container/xnamed.hxx>
13 #include <test/text/xtextcontent.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>
22 using namespace css;
23 using namespace css::uno;
25 namespace
27 /**
28 * Initial tests for SwXBookmark.
30 class SwXBookmark final : public UnoApiTest,
31 public apitest::XComponent,
32 public apitest::XNamed,
33 public apitest::XTextContent
35 public:
36 SwXBookmark()
37 : UnoApiTest(u""_ustr)
38 , XNamed(u"Bookmark"_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 Reference<text::XTextContent> xBookmark(
52 xMSF->createInstance(u"com.sun.star.text.Bookmark"_ustr), UNO_QUERY_THROW);
54 xText->insertTextContent(xCursor, xBookmark, false);
55 mxTextRange = Reference<text::XTextRange>(xCursor, UNO_QUERY_THROW);
56 mxTextContent = Reference<text::XTextContent>(
57 xMSF->createInstance(u"com.sun.star.text.Bookmark"_ustr), UNO_QUERY_THROW);
59 return Reference<XInterface>(xBookmark, UNO_QUERY_THROW);
62 Reference<text::XTextRange> getTextRange() override { return mxTextRange; };
63 Reference<text::XTextContent> getTextContent() override { return mxTextContent; };
64 bool isAttachSupported() override { return true; }
65 void triggerDesktopTerminate() override { mxDesktop->terminate(); }
67 CPPUNIT_TEST_SUITE(SwXBookmark);
68 CPPUNIT_TEST(testDispose);
69 CPPUNIT_TEST(testAddEventListener);
70 CPPUNIT_TEST(testRemoveEventListener);
71 CPPUNIT_TEST(testGetName);
72 CPPUNIT_TEST(testSetName);
73 CPPUNIT_TEST(testAttach);
74 CPPUNIT_TEST(testGetAnchor);
75 CPPUNIT_TEST_SUITE_END();
77 private:
78 Reference<text::XTextRange> mxTextRange;
79 Reference<text::XTextContent> mxTextContent;
82 CPPUNIT_TEST_SUITE_REGISTRATION(SwXBookmark);
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */