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/lang/xcomponent.hxx>
12 #include <test/text/xtextcontent.hxx>
13 #include <test/text/baseindexmark.hxx>
14 #include <test/text/documentindexmark.hxx>
16 #include <com/sun/star/frame/Desktop.hpp>
18 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
20 #include <com/sun/star/text/XTextDocument.hpp>
21 #include <com/sun/star/text/XText.hpp>
22 #include <com/sun/star/text/XDocumentIndexMark.hpp>
24 #include <comphelper/processfactory.hxx>
27 using namespace css::uno
;
32 * Initial tests for SwXDocumentIndexMark.
34 class SwXDocumentIndexMark final
: public UnoApiTest
,
35 public apitest::XComponent
,
36 public apitest::XTextContent
,
37 public apitest::BaseIndexMark
,
38 public apitest::DocumentIndexMark
41 SwXDocumentIndexMark();
43 Reference
<XInterface
> init() override
;
44 uno::Reference
<text::XTextRange
> getTextRange() override
;
45 uno::Reference
<text::XTextContent
> getTextContent() override
;
46 bool isAttachSupported() override
{ return true; }
47 void triggerDesktopTerminate() override
{ mxDesktop
->terminate(); }
49 CPPUNIT_TEST_SUITE(SwXDocumentIndexMark
);
50 CPPUNIT_TEST(testDispose
);
51 CPPUNIT_TEST(testAddEventListener
);
52 CPPUNIT_TEST(testRemoveEventListener
);
53 CPPUNIT_TEST(testAttach
);
54 CPPUNIT_TEST(testGetAnchor
);
55 CPPUNIT_TEST(testBaseIndexMarkProperties
);
56 CPPUNIT_TEST(testDocumentIndexMarkProperties
);
57 CPPUNIT_TEST_SUITE_END();
60 uno::Reference
<text::XTextRange
> mxTextRange
;
61 uno::Reference
<text::XTextContent
> mxTextContent
;
64 SwXDocumentIndexMark::SwXDocumentIndexMark()
65 : UnoApiTest(u
""_ustr
)
69 Reference
<XInterface
> SwXDocumentIndexMark::init()
71 loadFromURL(u
"private:factory/swriter"_ustr
);
72 Reference
<text::XTextDocument
> xTextDocument(mxComponent
, UNO_QUERY_THROW
);
73 Reference
<lang::XMultiServiceFactory
> xMSF(mxComponent
, UNO_QUERY_THROW
);
75 Reference
<text::XText
> xText
= xTextDocument
->getText();
76 Reference
<text::XTextCursor
> xCursor
= xText
->createTextCursor();
78 Reference
<text::XDocumentIndexMark
> xDIM(
79 xMSF
->createInstance(u
"com.sun.star.text.DocumentIndexMark"_ustr
), UNO_QUERY_THROW
);
81 mxTextRange
= uno::Reference
<text::XTextRange
>(xCursor
, uno::UNO_QUERY_THROW
);
82 mxTextContent
= uno::Reference
<text::XTextContent
>(
83 xMSF
->createInstance(u
"com.sun.star.text.DocumentIndex"_ustr
), uno::UNO_QUERY_THROW
);
84 xText
->insertTextContent(xCursor
, xDIM
, false);
86 return Reference
<XInterface
>(xDIM
, UNO_QUERY_THROW
);
89 uno::Reference
<text::XTextRange
> SwXDocumentIndexMark::getTextRange() { return mxTextRange
; }
91 uno::Reference
<text::XTextContent
> SwXDocumentIndexMark::getTextContent() { return mxTextContent
; }
93 CPPUNIT_TEST_SUITE_REGISTRATION(SwXDocumentIndexMark
);
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */