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/container/xnameaccess.hxx>
12 #include <test/container/xindexaccess.hxx>
13 #include <test/container/xelementaccess.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/beans/XPropertySet.hpp>
21 #include <com/sun/star/text/XText.hpp>
22 #include <com/sun/star/text/XTextContent.hpp>
23 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
24 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
25 #include <com/sun/star/text/XTextFrame.hpp>
27 #include <comphelper/processfactory.hxx>
30 using namespace css::uno
;
35 * Initial tests for SwXTextEmbeddedObjects.
37 class SwXTextEmbeddedObjects final
: public UnoApiTest
,
38 public apitest::XElementAccess
,
39 public apitest::XIndexAccess
,
40 public apitest::XNameAccess
43 SwXTextEmbeddedObjects()
44 : UnoApiTest(u
""_ustr
)
45 , XElementAccess(cppu::UnoType
<document::XEmbeddedObjectSupplier
>::get())
47 , XNameAccess(u
"Object1"_ustr
)
51 Reference
<XInterface
> init() override
53 loadFromURL(u
"private:factory/swriter"_ustr
);
54 Reference
<text::XTextDocument
> xTextDocument(mxComponent
, UNO_QUERY_THROW
);
55 Reference
<lang::XMultiServiceFactory
> xMSF(mxComponent
, UNO_QUERY_THROW
);
57 Reference
<text::XText
> xText
= xTextDocument
->getText();
58 Reference
<text::XTextCursor
> xCursor
= xText
->createTextCursor();
62 Reference
<text::XTextContent
> xTextContent(
63 xMSF
->createInstance(u
"com.sun.star.text.TextEmbeddedObject"_ustr
),
65 Reference
<beans::XPropertySet
> xPropertySet(xTextContent
, UNO_QUERY_THROW
);
66 xPropertySet
->setPropertyValue(u
"CLSID"_ustr
,
67 Any(u
"12dcae26-281f-416f-a234-c3086127382e"_ustr
));
69 xText
->insertTextContent(xCursor
, xTextContent
, false);
75 Reference
<text::XTextEmbeddedObjectsSupplier
> xTEOSupp(xTextDocument
, UNO_QUERY_THROW
);
77 return Reference
<XInterface
>(xTEOSupp
->getEmbeddedObjects(), UNO_QUERY_THROW
);
80 CPPUNIT_TEST_SUITE(SwXTextEmbeddedObjects
);
81 CPPUNIT_TEST(testGetByName
);
82 CPPUNIT_TEST(testGetElementNames
);
83 CPPUNIT_TEST(testHasByName
);
84 CPPUNIT_TEST(testGetCount
);
85 CPPUNIT_TEST(testGetByIndex
);
86 CPPUNIT_TEST(testGetElementType
);
87 CPPUNIT_TEST(testHasElements
);
88 CPPUNIT_TEST_SUITE_END();
91 CPPUNIT_TEST_SUITE_REGISTRATION(SwXTextEmbeddedObjects
);
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */