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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
23 #include <com/sun/star/lang/XMain.hpp>
24 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
25 #include <com/sun/star/reflection/XCompoundTypeDescription.hpp>
26 #include <com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp>
27 #include <com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp>
28 #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
29 #include <com/sun/star/reflection/XInterfaceTypeDescription2.hpp>
30 #include <com/sun/star/reflection/XPublished.hpp>
31 #include <com/sun/star/reflection/XServiceTypeDescription2.hpp>
32 #include <com/sun/star/reflection/XSingletonTypeDescription2.hpp>
33 #include <com/sun/star/reflection/XStructTypeDescription.hpp>
34 #include <com/sun/star/reflection/XTypeDescription.hpp>
35 #include <com/sun/star/registry/InvalidRegistryException.hpp>
36 #include <com/sun/star/registry/XRegistryKey.hpp>
37 #include <com/sun/star/uno/Any.hxx>
38 #include <com/sun/star/uno/Exception.hpp>
39 #include <com/sun/star/uno/Reference.hxx>
40 #include <com/sun/star/uno/RuntimeException.hpp>
41 #include <com/sun/star/uno/Sequence.hxx>
42 #include <com/sun/star/uno/TypeClass.hpp>
43 #include <com/sun/star/uno/XComponentContext.hpp>
44 #include <com/sun/star/uno/XInterface.hpp>
45 #include <cppuhelper/factory.hxx>
46 #include <cppuhelper/implbase1.hxx>
47 #include <cppuhelper/weak.hxx>
48 #include <rtl/textenc.h>
49 #include <rtl/ustring.h>
50 #include <rtl/ustring.hxx>
51 #include <sal/types.h>
52 #include <uno/environment.h>
54 #include /*MSVC trouble: <cstdlib>*/ <stdlib.h>
60 class Service
: public cppu::WeakImplHelper1
< css::lang::XMain
> {
62 virtual sal_Int32 SAL_CALL
63 run(css::uno::Sequence
< OUString
> const & arguments
)
64 throw (css::uno::RuntimeException
);
66 static OUString
getImplementationName();
68 static css::uno::Sequence
< OUString
> getSupportedServiceNames();
70 static css::uno::Reference
< css::uno::XInterface
> SAL_CALL
createInstance(
71 css::uno::Reference
< css::uno::XComponentContext
> const & context
)
72 throw (css::uno::Exception
);
76 css::uno::Reference
< css::uno::XComponentContext
> const & context
):
80 css::uno::Reference
< css::uno::XComponentContext
> m_context
;
87 std::ostream
& operator <<(std::ostream
& out
, OUString
const & value
) {
88 return out
<< OUStringToOString(value
, RTL_TEXTENCODING_UTF8
).getStr();
91 void assertTrue(bool argument
) {
94 << "assertTrue(" << argument
<< ") failed" << std::endl
;
95 /*MSVC trouble: std::*/abort();
99 void assertFalse(bool argument
) {
102 << "assertFalse(" << argument
<< ") failed" << std::endl
;
103 /*MSVC trouble: std::*/abort();
107 template< typename T
> void assertEqual(T
const & value
, T
const & argument
) {
108 if (argument
!= value
) {
110 << "assertEqual(" << value
<< ", " << argument
<< ") failed"
112 /*MSVC trouble: std::*/abort();
118 sal_Int32
Service::run(css::uno::Sequence
< OUString
> const &)
119 throw (css::uno::RuntimeException
)
121 css::uno::Reference
< css::lang::XMultiComponentFactory
> factory(
122 m_context
->getServiceManager());
123 assertTrue(factory
.is());
124 css::uno::Sequence
< css::uno::Any
> args(1);
125 args
[0] = css::uno::Reference
< css::beans::XPropertySet
>(
126 factory
, css::uno::UNO_QUERY_THROW
)->getPropertyValue(
127 OUString("Registry"));
128 css::uno::Reference
< css::container::XHierarchicalNameAccess
> provider(
129 factory
->createInstanceWithArgumentsAndContext(
130 OUString( "com.sun.star.comp.stoc.RegistryTypeDescriptionProvider"),
132 css::uno::UNO_QUERY_THROW
);
134 // The following assumes that interface members are sorted by increasing
135 // values of XInterfaceMemberTypeDescription.getPosition, the exceptions
136 // of interface attributes and interface methods, the constructors of
137 // services, and the exceptions of service constructors are sorted as given
138 // in the UNOIDL source code:
142 provider
->hasByHierarchicalName(
143 OUString( "[][]boolean")));
146 provider
->hasByHierarchicalName(
147 OUString( "test.registrytdprovider.Struct3<boolean,boolean>")));
150 provider
->hasByHierarchicalName(
151 OUString( "com.sun.star.uno.XComponentContext::getValueByName")));
153 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> exception
;
155 = css::uno::Reference
< css::reflection::XCompoundTypeDescription
>(
156 provider
->getByHierarchicalName(
157 OUString( "com.sun.star.uno.Exception")),
158 css::uno::UNO_QUERY_THROW
);
159 assertEqual(css::uno::TypeClass_EXCEPTION
, exception
->getTypeClass());
160 assertEqual( OUString( "com.sun.star.uno.Exception"),
161 exception
->getName());
162 assertFalse(exception
->getBaseType().is());
164 = css::uno::Reference
< css::reflection::XCompoundTypeDescription
>(
165 provider
->getByHierarchicalName(
166 OUString( "com.sun.star.uno.RuntimeException")),
167 css::uno::UNO_QUERY_THROW
);
168 assertEqual(css::uno::TypeClass_EXCEPTION
, exception
->getTypeClass());
169 assertEqual( OUString( "com.sun.star.uno.RuntimeException"),
170 exception
->getName());
171 assertEqual( OUString( "com.sun.star.uno.Exception"),
172 exception
->getBaseType()->getName());
174 css::uno::Reference
< css::reflection::XStructTypeDescription
> structure
;
176 structure
= css::uno::Reference
< css::reflection::XStructTypeDescription
>(
177 provider
->getByHierarchicalName(
178 OUString( "test.registrytdprovider.Struct2")),
179 css::uno::UNO_QUERY_THROW
);
180 assertEqual(css::uno::TypeClass_STRUCT
, structure
->getTypeClass());
181 assertEqual( OUString( "test.registrytdprovider.Struct2"),
182 structure
->getName());
183 assertFalse(structure
->getBaseType().is());
184 assertEqual
< sal_Int32
>(1, structure
->getMemberTypes().getLength());
186 OUString( "test.registrytdprovider.Struct1"),
187 structure
->getMemberTypes()[0]->getName());
188 assertEqual
< sal_Int32
>(1, structure
->getMemberNames().getLength());
191 structure
->getMemberNames()[0]);
192 assertEqual
< sal_Int32
>(0, structure
->getTypeParameters().getLength());
193 assertEqual
< sal_Int32
>(0, structure
->getTypeArguments().getLength());
195 structure
= css::uno::Reference
< css::reflection::XStructTypeDescription
>(
196 provider
->getByHierarchicalName(
197 OUString( "test.registrytdprovider.Struct3")),
198 css::uno::UNO_QUERY_THROW
);
199 assertEqual(css::uno::TypeClass_STRUCT
, structure
->getTypeClass());
201 OUString( "test.registrytdprovider.Struct3"),
202 structure
->getName());
203 assertFalse(structure
->getBaseType().is());
204 assertEqual
< sal_Int32
>(1, structure
->getMemberTypes().getLength());
206 css::uno::TypeClass_UNKNOWN
,
207 structure
->getMemberTypes()[0]->getTypeClass());
210 structure
->getMemberTypes()[0]->getName());
211 assertEqual
< sal_Int32
>(1, structure
->getMemberNames().getLength());
214 structure
->getMemberNames()[0]);
215 assertEqual
< sal_Int32
>(2, structure
->getTypeParameters().getLength());
218 structure
->getTypeParameters()[0]);
221 structure
->getTypeParameters()[1]);
222 assertEqual
< sal_Int32
>(0, structure
->getTypeArguments().getLength());
224 structure
= css::uno::Reference
< css::reflection::XStructTypeDescription
>(
225 provider
->getByHierarchicalName(
226 OUString( "test.registrytdprovider.Struct4")),
227 css::uno::UNO_QUERY_THROW
);
228 assertEqual(css::uno::TypeClass_STRUCT
, structure
->getTypeClass());
230 OUString( "test.registrytdprovider.Struct4"),
231 structure
->getName());
233 OUString( "test.registrytdprovider.Struct2"),
234 structure
->getBaseType()->getName());
235 assertEqual
< sal_Int32
>(1, structure
->getMemberTypes().getLength());
237 OUString( "test.registrytdprovider.Struct3<"
238 "test.registrytdprovider.Struct2,"
239 "test.registrytdprovider.Struct3<boolean,any>>"),
240 structure
->getMemberTypes()[0]->getName());
241 assertEqual
< sal_Int32
>(1, structure
->getMemberNames().getLength());
244 structure
->getMemberNames()[0]);
245 assertEqual
< sal_Int32
>(0, structure
->getTypeParameters().getLength());
246 assertEqual
< sal_Int32
>(0, structure
->getTypeArguments().getLength());
248 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
252 = css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>(
253 provider
->getByHierarchicalName(
254 OUString( "test.registrytdprovider.XTest1")),
255 css::uno::UNO_QUERY_THROW
);
256 assertEqual(css::uno::TypeClass_INTERFACE
, interface
->getTypeClass());
258 OUString( "test.registrytdprovider.XTest1"),
259 interface
->getName());
261 css::uno::Reference
< css::reflection::XTypeDescription
> > bases(
262 interface
->getBaseTypes());
263 assertEqual
< sal_Int32
>(1, bases
.getLength());
265 OUString( "com.sun.star.uno.XInterface"),
266 bases
[0]->getName());
268 css::uno::Reference
< css::reflection::XTypeDescription
> >
269 optionalBases(interface
->getOptionalBaseTypes());
270 assertEqual
< sal_Int32
>(1, optionalBases
.getLength());
273 "test.registrytdprovider.XBase"),
274 optionalBases
[0]->getName());
277 css::reflection::XInterfaceMemberTypeDescription
> > members(
278 interface
->getMembers());
279 assertEqual
< sal_Int32
>(5, members
.getLength());
281 css::uno::Reference
< css::reflection::XInterfaceAttributeTypeDescription2
>
284 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
287 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
289 css::uno::Reference
< css::reflection::XInterfaceMethodTypeDescription
>
292 attribute
= css::uno::Reference
<
293 css::reflection::XInterfaceAttributeTypeDescription2
>(
294 members
[0], css::uno::UNO_QUERY_THROW
);
296 css::uno::TypeClass_INTERFACE_ATTRIBUTE
, attribute
->getTypeClass());
298 OUString( "test.registrytdprovider.XTest1::a1"),
299 attribute
->getName());
302 attribute
->getMemberName());
303 assertEqual
< sal_Int32
>(3, attribute
->getPosition());
304 assertEqual
< bool >(false, attribute
->isReadOnly());
307 attribute
->getType()->getName());
308 assertEqual
< bool >(true, attribute
->isBound());
309 getExceptions
= attribute
->getGetExceptions();
310 assertEqual
< sal_Int32
>(0, getExceptions
.getLength());
311 setExceptions
= attribute
->getSetExceptions();
312 assertEqual
< sal_Int32
>(0, setExceptions
.getLength());
314 attribute
= css::uno::Reference
<
315 css::reflection::XInterfaceAttributeTypeDescription2
>(
316 members
[1], css::uno::UNO_QUERY_THROW
);
318 css::uno::TypeClass_INTERFACE_ATTRIBUTE
, attribute
->getTypeClass());
320 OUString( "test.registrytdprovider.XTest1::a2"),
321 attribute
->getName());
324 attribute
->getMemberName());
325 assertEqual
< sal_Int32
>(4, attribute
->getPosition());
326 assertEqual
< bool >(false, attribute
->isReadOnly());
329 attribute
->getType()->getName());
330 assertEqual
< bool >(false, attribute
->isBound());
331 getExceptions
= attribute
->getGetExceptions();
332 assertEqual
< sal_Int32
>(2, getExceptions
.getLength());
334 OUString( "com.sun.star.lang.WrappedTargetException"),
335 getExceptions
[0]->getName());
337 OUString( "com.sun.star.uno.RuntimeException"),
338 getExceptions
[1]->getName());
339 setExceptions
= attribute
->getSetExceptions();
340 assertEqual
< sal_Int32
>(2, setExceptions
.getLength());
342 OUString( "com.sun.star.uno.Exception"),
343 setExceptions
[0]->getName());
345 OUString( "com.sun.star.lang.WrappedTargetException"),
346 setExceptions
[1]->getName());
348 attribute
= css::uno::Reference
<
349 css::reflection::XInterfaceAttributeTypeDescription2
>(
350 members
[2], css::uno::UNO_QUERY_THROW
);
352 css::uno::TypeClass_INTERFACE_ATTRIBUTE
, attribute
->getTypeClass());
355 "test.registrytdprovider.XTest1::a3"),
356 attribute
->getName());
359 attribute
->getMemberName());
360 assertEqual
< sal_Int32
>(5, attribute
->getPosition());
361 assertEqual
< bool >(true, attribute
->isReadOnly());
364 attribute
->getType()->getName());
365 assertEqual
< bool >(true, attribute
->isBound());
366 getExceptions
= attribute
->getGetExceptions();
367 assertEqual
< sal_Int32
>(1, getExceptions
.getLength());
369 OUString( "com.sun.star.lang.WrappedTargetException"),
370 getExceptions
[0]->getName());
371 setExceptions
= attribute
->getSetExceptions();
372 assertEqual
< sal_Int32
>(0, setExceptions
.getLength());
374 method
= css::uno::Reference
<
375 css::reflection::XInterfaceMethodTypeDescription
>(
376 members
[3], css::uno::UNO_QUERY_THROW
);
377 assertEqual(css::uno::TypeClass_INTERFACE_METHOD
, method
->getTypeClass());
379 OUString( "test.registrytdprovider.XTest1::f1"),
383 method
->getMemberName());
384 assertEqual
< sal_Int32
>(6, method
->getPosition());
385 assertEqual
< bool >(false, method
->isOneway());
386 assertEqual
< sal_Int32
>(1, method
->getParameters().getLength());
389 method
->getParameters()[0]->getName());
392 method
->getParameters()[0]->getType()->getName());
393 assertEqual
< bool >(false, method
->getParameters()[0]->isIn());
394 assertEqual
< bool >(true, method
->getParameters()[0]->isOut());
395 assertEqual
< sal_Int32
>(0, method
->getParameters()[0]->getPosition());
396 assertEqual
< sal_Int32
>(1, method
->getExceptions().getLength());
398 OUString( "com.sun.star.uno.RuntimeException"),
399 method
->getExceptions()[0]->getName());
401 method
= css::uno::Reference
<
402 css::reflection::XInterfaceMethodTypeDescription
>(
403 members
[4], css::uno::UNO_QUERY_THROW
);
404 assertEqual(css::uno::TypeClass_INTERFACE_METHOD
, method
->getTypeClass());
406 OUString( "test.registrytdprovider.XTest1::f2"),
410 method
->getMemberName());
411 assertEqual
< sal_Int32
>(7, method
->getPosition());
412 assertEqual
< bool >(true, method
->isOneway());
413 assertEqual
< sal_Int32
>(0, method
->getParameters().getLength());
414 assertEqual
< sal_Int32
>(0, method
->getExceptions().getLength());
417 = css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>(
418 provider
->getByHierarchicalName(
419 OUString( "test.registrytdprovider.XTest2")),
420 css::uno::UNO_QUERY_THROW
);
421 assertEqual(css::uno::TypeClass_INTERFACE
, interface
->getTypeClass());
423 OUString( "test.registrytdprovider.XTest2"),
424 interface
->getName());
425 assertEqual
< sal_Int32
>(1, interface
->getBaseTypes().getLength());
427 OUString( "test.registrytdprovider.Typedef2"),
428 interface
->getBaseTypes()[0]->getName());
429 assertEqual
< sal_Int32
>(0, interface
->getOptionalBaseTypes().getLength());
430 assertEqual
< sal_Int32
>(0, interface
->getMembers().getLength());
432 css::uno::Reference
< css::reflection::XServiceTypeDescription2
> service
;
434 service
= css::uno::Reference
< css::reflection::XServiceTypeDescription2
>(
435 provider
->getByHierarchicalName(
436 OUString( "test.registrytdprovider.Service1")),
437 css::uno::UNO_QUERY_THROW
);
438 assertEqual(css::uno::TypeClass_SERVICE
, service
->getTypeClass());
440 OUString( "test.registrytdprovider.Service1"),
442 assertEqual
< sal_Int32
>(0, service
->getMandatoryServices().getLength());
443 assertEqual
< sal_Int32
>(0, service
->getOptionalServices().getLength());
444 assertEqual
< sal_Int32
>(0, service
->getMandatoryInterfaces().getLength());
445 assertEqual
< sal_Int32
>(0, service
->getOptionalInterfaces().getLength());
446 assertEqual
< bool >(true, service
->isSingleInterfaceBased());
449 "test.registrytdprovider.XTest1"),
450 service
->getInterface()->getName());
451 assertEqual
< sal_Int32
>(2, service
->getConstructors().getLength());
454 service
->getConstructors()[0]->getName());
455 assertEqual
< sal_Int32
>(
456 0, service
->getConstructors()[0]->getParameters().getLength());
457 assertEqual
< sal_Int32
>(
458 0, service
->getConstructors()[0]->getExceptions().getLength());
461 service
->getConstructors()[1]->getName());
462 assertEqual
< sal_Int32
>(
463 1, service
->getConstructors()[1]->getParameters().getLength());
466 service
->getConstructors()[1]->getParameters()[0]->getName());
469 (service
->getConstructors()[1]->getParameters()[0]->getType()->
472 true, service
->getConstructors()[1]->getParameters()[0]->isIn());
474 false, service
->getConstructors()[1]->getParameters()[0]->isOut());
475 assertEqual
< sal_Int32
>(
476 0, service
->getConstructors()[1]->getParameters()[0]->getPosition());
479 service
->getConstructors()[1]->getParameters()[0]->isRestParameter());
480 assertEqual
< sal_Int32
>(
481 1, service
->getConstructors()[1]->getExceptions().getLength());
483 OUString( "com.sun.star.uno.RuntimeException"),
484 service
->getConstructors()[1]->getExceptions()[0]->getName());
486 service
= css::uno::Reference
< css::reflection::XServiceTypeDescription2
>(
487 provider
->getByHierarchicalName(
488 OUString( "test.registrytdprovider.Service2")),
489 css::uno::UNO_QUERY_THROW
);
490 assertEqual(css::uno::TypeClass_SERVICE
, service
->getTypeClass());
492 OUString( "test.registrytdprovider.Service2"),
494 assertEqual
< sal_Int32
>(0, service
->getMandatoryServices().getLength());
495 assertEqual
< sal_Int32
>(0, service
->getOptionalServices().getLength());
496 assertEqual
< sal_Int32
>(1, service
->getMandatoryInterfaces().getLength());
498 OUString( "test.registrytdprovider.XTest1"),
499 service
->getMandatoryInterfaces()[0]->getName());
500 assertEqual
< sal_Int32
>(1, service
->getOptionalInterfaces().getLength());
502 OUString( "test.registrytdprovider.XBase"),
503 service
->getOptionalInterfaces()[0]->getName());
504 assertEqual
< bool >(false, service
->isSingleInterfaceBased());
505 assertFalse(service
->getInterface().is());
506 assertEqual
< sal_Int32
>(0, service
->getConstructors().getLength());
508 service
= css::uno::Reference
< css::reflection::XServiceTypeDescription2
>(
509 provider
->getByHierarchicalName(
510 OUString( "test.registrytdprovider.Service3")),
511 css::uno::UNO_QUERY_THROW
);
512 assertEqual(css::uno::TypeClass_SERVICE
, service
->getTypeClass());
515 "test.registrytdprovider.Service3"),
517 assertEqual
< sal_Int32
>(0, service
->getMandatoryServices().getLength());
518 assertEqual
< sal_Int32
>(0, service
->getOptionalServices().getLength());
519 assertEqual
< sal_Int32
>(0, service
->getMandatoryInterfaces().getLength());
520 assertEqual
< sal_Int32
>(0, service
->getOptionalInterfaces().getLength());
521 assertEqual
< bool >(true, service
->isSingleInterfaceBased());
524 "test.registrytdprovider.Typedef2"),
525 service
->getInterface()->getName());
526 assertEqual
< sal_Int32
>(0, service
->getConstructors().getLength());
528 css::uno::Reference
< css::reflection::XSingletonTypeDescription2
>
531 singleton
= css::uno::Reference
<
532 css::reflection::XSingletonTypeDescription2
>(
533 provider
->getByHierarchicalName(
534 OUString( "test.registrytdprovider.Singleton1")),
535 css::uno::UNO_QUERY_THROW
);
536 assertEqual(css::uno::TypeClass_SINGLETON
, singleton
->getTypeClass());
539 "test.registrytdprovider.Singleton1"),
540 singleton
->getName());
541 assertFalse(singleton
->getService().is());
542 assertEqual
< bool >(true, singleton
->isInterfaceBased());
545 "test.registrytdprovider.XTest1"),
546 singleton
->getInterface()->getName());
548 singleton
= css::uno::Reference
<
549 css::reflection::XSingletonTypeDescription2
>(
550 provider
->getByHierarchicalName(
551 OUString( "test.registrytdprovider.Singleton2")),
552 css::uno::UNO_QUERY_THROW
);
553 assertEqual(css::uno::TypeClass_SINGLETON
, singleton
->getTypeClass());
556 "test.registrytdprovider.Singleton2"),
557 singleton
->getName());
560 "test.registrytdprovider.Service1"),
561 singleton
->getService()->getName());
562 assertEqual
< bool >(false, singleton
->isInterfaceBased());
563 assertFalse(singleton
->getInterface().is());
565 singleton
= css::uno::Reference
<
566 css::reflection::XSingletonTypeDescription2
>(
567 provider
->getByHierarchicalName(
568 OUString( "test.registrytdprovider.Singleton3")),
569 css::uno::UNO_QUERY_THROW
);
570 assertEqual(css::uno::TypeClass_SINGLETON
, singleton
->getTypeClass());
573 "test.registrytdprovider.Singleton3"),
574 singleton
->getName());
575 assertFalse(singleton
->getService().is());
576 assertEqual
< bool >(true, singleton
->isInterfaceBased());
579 "test.registrytdprovider.Typedef2"),
580 singleton
->getInterface()->getName());
582 css::uno::Reference
< css::reflection::XPublished
> published
;
583 published
= css::uno::Reference
< css::reflection::XPublished
>(
584 css::uno::Reference
< css::reflection::XTypeDescription
>(
585 provider
->getByHierarchicalName(
586 OUString( "test.registrytdprovider.Enum1")),
587 css::uno::UNO_QUERY_THROW
),
588 css::uno::UNO_QUERY
);
589 assertTrue(published
.is());
590 assertTrue(published
->isPublished());
591 published
= css::uno::Reference
< css::reflection::XPublished
>(
592 css::uno::Reference
< css::reflection::XTypeDescription
>(
593 provider
->getByHierarchicalName(
594 OUString( "test.registrytdprovider.Enum2")),
595 css::uno::UNO_QUERY_THROW
),
596 css::uno::UNO_QUERY
);
597 assertTrue(published
.is());
598 assertFalse(published
->isPublished());
599 published
= css::uno::Reference
< css::reflection::XPublished
>(
600 css::uno::Reference
< css::reflection::XTypeDescription
>(
601 provider
->getByHierarchicalName(
602 OUString( "test.registrytdprovider.Struct1")),
603 css::uno::UNO_QUERY_THROW
),
604 css::uno::UNO_QUERY
);
605 assertTrue(published
.is());
606 assertTrue(published
->isPublished());
607 published
= css::uno::Reference
< css::reflection::XPublished
>(
608 css::uno::Reference
< css::reflection::XTypeDescription
>(
609 provider
->getByHierarchicalName(
610 OUString( "test.registrytdprovider.Struct2")),
611 css::uno::UNO_QUERY_THROW
),
612 css::uno::UNO_QUERY
);
613 assertTrue(published
.is());
614 assertFalse(published
->isPublished());
615 published
= css::uno::Reference
< css::reflection::XPublished
>(
616 css::uno::Reference
< css::reflection::XTypeDescription
>(
617 provider
->getByHierarchicalName(
618 OUString( "test.registrytdprovider.Struct3")),
619 css::uno::UNO_QUERY_THROW
),
620 css::uno::UNO_QUERY
);
621 assertTrue(published
.is());
622 assertTrue(published
->isPublished());
623 published
= css::uno::Reference
< css::reflection::XPublished
>(
624 css::uno::Reference
< css::reflection::XStructTypeDescription
>(
625 provider
->getByHierarchicalName(
626 OUString( "test.registrytdprovider.Struct3")),
627 css::uno::UNO_QUERY_THROW
)->getMemberTypes()[0],
628 css::uno::UNO_QUERY
);
629 assertFalse(published
.is());
630 published
= css::uno::Reference
< css::reflection::XPublished
>(
631 css::uno::Reference
< css::reflection::XTypeDescription
>(
632 provider
->getByHierarchicalName(
633 OUString( "test.registrytdprovider.Struct3a")),
634 css::uno::UNO_QUERY_THROW
),
635 css::uno::UNO_QUERY
);
636 assertTrue(published
.is());
637 assertFalse(published
->isPublished());
638 published
= css::uno::Reference
< css::reflection::XPublished
>(
639 css::uno::Reference
< css::reflection::XTypeDescription
>(
640 provider
->getByHierarchicalName(
641 OUString( "test.registrytdprovider.Exception1")),
642 css::uno::UNO_QUERY_THROW
),
643 css::uno::UNO_QUERY
);
644 assertTrue(published
.is());
645 assertTrue(published
->isPublished());
646 published
= css::uno::Reference
< css::reflection::XPublished
>(
647 css::uno::Reference
< css::reflection::XTypeDescription
>(
648 provider
->getByHierarchicalName(
649 OUString( "test.registrytdprovider.Exception2")),
650 css::uno::UNO_QUERY_THROW
),
651 css::uno::UNO_QUERY
);
652 assertTrue(published
.is());
653 assertFalse(published
->isPublished());
654 published
= css::uno::Reference
< css::reflection::XPublished
>(
655 css::uno::Reference
< css::reflection::XTypeDescription
>(
656 provider
->getByHierarchicalName(
657 OUString( "test.registrytdprovider.XTest1")),
658 css::uno::UNO_QUERY_THROW
),
659 css::uno::UNO_QUERY
);
660 assertTrue(published
.is());
661 assertTrue(published
->isPublished());
662 published
= css::uno::Reference
< css::reflection::XPublished
>(
663 css::uno::Reference
< css::reflection::XTypeDescription
>(
664 provider
->getByHierarchicalName(
665 OUString( "test.registrytdprovider.XTest2")),
666 css::uno::UNO_QUERY_THROW
),
667 css::uno::UNO_QUERY
);
668 assertTrue(published
.is());
669 assertFalse(published
->isPublished());
670 published
= css::uno::Reference
< css::reflection::XPublished
>(
671 css::uno::Reference
< css::reflection::XTypeDescription
>(
672 provider
->getByHierarchicalName(
673 OUString( "test.registrytdprovider.Typedef1")),
674 css::uno::UNO_QUERY_THROW
),
675 css::uno::UNO_QUERY
);
676 assertTrue(published
.is());
677 assertTrue(published
->isPublished());
678 published
= css::uno::Reference
< css::reflection::XPublished
>(
679 css::uno::Reference
< css::reflection::XTypeDescription
>(
680 provider
->getByHierarchicalName(
681 OUString( "test.registrytdprovider.Typedef2")),
682 css::uno::UNO_QUERY_THROW
),
683 css::uno::UNO_QUERY
);
684 assertTrue(published
.is());
685 assertFalse(published
->isPublished());
686 //TODO: check constants test.registrytdprovider.Const1 (published),
687 // test.registrytdprovider.Const2 (unpublished), and
688 // test.registrytdprovider.Consts1.C (no XPublished), which are not
689 // accessible via provider->getByHierarchicalName (see #i31428)
690 published
= css::uno::Reference
< css::reflection::XPublished
>(
691 css::uno::Reference
< css::reflection::XTypeDescription
>(
692 provider
->getByHierarchicalName(
693 OUString( "test.registrytdprovider.Consts1")),
694 css::uno::UNO_QUERY_THROW
),
695 css::uno::UNO_QUERY
);
696 assertTrue(published
.is());
697 assertTrue(published
->isPublished());
698 published
= css::uno::Reference
< css::reflection::XPublished
>(
699 css::uno::Reference
< css::reflection::XTypeDescription
>(
700 provider
->getByHierarchicalName(
701 OUString( "test.registrytdprovider.Consts2")),
702 css::uno::UNO_QUERY_THROW
),
703 css::uno::UNO_QUERY
);
704 assertTrue(published
.is());
705 assertFalse(published
->isPublished());
706 published
= css::uno::Reference
< css::reflection::XPublished
>(
707 css::uno::Reference
< css::reflection::XTypeDescription
>(
708 provider
->getByHierarchicalName(
709 OUString( "test.registrytdprovider")),
710 css::uno::UNO_QUERY_THROW
),
711 css::uno::UNO_QUERY
);
712 assertFalse(published
.is());
713 published
= css::uno::Reference
< css::reflection::XPublished
>(
714 css::uno::Reference
< css::reflection::XTypeDescription
>(
715 provider
->getByHierarchicalName(
716 OUString( "test.registrytdprovider.Service1")),
717 css::uno::UNO_QUERY_THROW
),
718 css::uno::UNO_QUERY
);
719 assertTrue(published
.is());
720 assertTrue(published
->isPublished());
721 published
= css::uno::Reference
< css::reflection::XPublished
>(
722 css::uno::Reference
< css::reflection::XTypeDescription
>(
723 provider
->getByHierarchicalName(
724 OUString( "test.registrytdprovider.Service2")),
725 css::uno::UNO_QUERY_THROW
),
726 css::uno::UNO_QUERY
);
727 assertTrue(published
.is());
728 assertFalse(published
->isPublished());
729 published
= css::uno::Reference
< css::reflection::XPublished
>(
730 css::uno::Reference
< css::reflection::XTypeDescription
>(
731 provider
->getByHierarchicalName(
732 OUString( "test.registrytdprovider.Singleton2")),
733 css::uno::UNO_QUERY_THROW
),
734 css::uno::UNO_QUERY
);
735 assertTrue(published
.is());
736 assertTrue(published
->isPublished());
737 published
= css::uno::Reference
< css::reflection::XPublished
>(
738 css::uno::Reference
< css::reflection::XTypeDescription
>(
739 provider
->getByHierarchicalName(
740 OUString( "test.registrytdprovider.Singleton1")),
741 css::uno::UNO_QUERY_THROW
),
742 css::uno::UNO_QUERY
);
743 assertTrue(published
.is());
744 assertFalse(published
->isPublished());
749 OUString
Service::getImplementationName() {
750 return OUString("test.registrytdprovider.impl");
753 css::uno::Sequence
< OUString
> Service::getSupportedServiceNames() {
754 return css::uno::Sequence
< OUString
>();
757 css::uno::Reference
< css::uno::XInterface
> Service::createInstance(
758 css::uno::Reference
< css::uno::XComponentContext
> const & context
)
759 throw (css::uno::Exception
)
761 return static_cast< cppu::OWeakObject
* >(new Service(context
));
764 extern "C" SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
component_getFactory(char const * implName
,
765 void * serviceManager
, void *) {
767 if (serviceManager
!= 0) {
768 css::uno::Reference
< css::lang::XSingleComponentFactory
> f
;
769 if (Service::getImplementationName().equalsAscii(implName
)) {
770 f
= cppu::createSingleComponentFactory(
771 &Service::createInstance
, Service::getImplementationName(),
772 Service::getSupportedServiceNames());
784 bool writeInfo(void * registryKey
, OUString
const & implementationName
,
785 css::uno::Sequence
< OUString
> const & serviceNames
) {
786 OUString keyName
= "/" + implementationName
+ "/UNO/SERVICES";
787 css::uno::Reference
< css::registry::XRegistryKey
> key
;
789 key
= static_cast< css::registry::XRegistryKey
* >(registryKey
)->
791 } catch (css::registry::InvalidRegistryException
&) {}
796 for (sal_Int32 i
= 0; i
< serviceNames
.getLength(); ++i
) {
798 key
->createKey(serviceNames
[i
]);
799 } catch (css::registry::InvalidRegistryException
&) {
809 extern "C" sal_Bool SAL_CALL
component_writeInfo(void *, void * registryKey
) {
811 && writeInfo(registryKey
, Service::getImplementationName(),
812 Service::getSupportedServiceNames());
815 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */