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"
53 #include "uno/lbnames.h"
55 #include /*MSVC trouble: <cstdlib>*/ <stdlib.h>
61 class Service
: public cppu::WeakImplHelper1
< css::lang::XMain
> {
63 virtual sal_Int32 SAL_CALL
64 run(css::uno::Sequence
< rtl::OUString
> const & arguments
)
65 throw (css::uno::RuntimeException
);
67 static rtl::OUString
getImplementationName();
69 static css::uno::Sequence
< rtl::OUString
> getSupportedServiceNames();
71 static css::uno::Reference
< css::uno::XInterface
> SAL_CALL
createInstance(
72 css::uno::Reference
< css::uno::XComponentContext
> const & context
)
73 throw (css::uno::Exception
);
77 css::uno::Reference
< css::uno::XComponentContext
> const & context
):
81 css::uno::Reference
< css::uno::XComponentContext
> m_context
;
88 std::ostream
& operator <<(std::ostream
& out
, rtl::OUString
const & value
) {
89 return out
<< rtl::OUStringToOString(value
, RTL_TEXTENCODING_UTF8
).getStr();
92 void assertTrue(bool argument
) {
95 << "assertTrue(" << argument
<< ") failed" << std::endl
;
96 /*MSVC trouble: std::*/abort();
100 void assertFalse(bool argument
) {
103 << "assertFalse(" << argument
<< ") failed" << std::endl
;
104 /*MSVC trouble: std::*/abort();
108 template< typename T
> void assertEqual(T
const & value
, T
const & argument
) {
109 if (argument
!= value
) {
111 << "assertEqual(" << value
<< ", " << argument
<< ") failed"
113 /*MSVC trouble: std::*/abort();
119 sal_Int32
Service::run(css::uno::Sequence
< rtl::OUString
> const &)
120 throw (css::uno::RuntimeException
)
122 css::uno::Reference
< css::lang::XMultiComponentFactory
> factory(
123 m_context
->getServiceManager());
124 assertTrue(factory
.is());
125 css::uno::Sequence
< css::uno::Any
> args(1);
126 args
[0] = css::uno::Reference
< css::beans::XPropertySet
>(
127 factory
, css::uno::UNO_QUERY_THROW
)->getPropertyValue(
128 rtl::OUString("Registry"));
129 css::uno::Reference
< css::container::XHierarchicalNameAccess
> provider(
130 factory
->createInstanceWithArgumentsAndContext(
131 rtl::OUString( "com.sun.star.comp.stoc.RegistryTypeDescriptionProvider"),
133 css::uno::UNO_QUERY_THROW
);
135 // The following assumes that interface members are sorted by increasing
136 // values of XInterfaceMemberTypeDescription.getPosition, the exceptions
137 // of interface attributes and interface methods, the constructors of
138 // services, and the exceptions of service constructors are sorted as given
139 // in the UNOIDL source code:
143 provider
->hasByHierarchicalName(
144 rtl::OUString( "[][]boolean")));
147 provider
->hasByHierarchicalName(
148 rtl::OUString( "test.registrytdprovider.Struct3<boolean,boolean>")));
151 provider
->hasByHierarchicalName(
152 rtl::OUString( "com.sun.star.uno.XComponentContext::getValueByName")));
154 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> exception
;
156 = css::uno::Reference
< css::reflection::XCompoundTypeDescription
>(
157 provider
->getByHierarchicalName(
158 rtl::OUString( "com.sun.star.uno.Exception")),
159 css::uno::UNO_QUERY_THROW
);
160 assertEqual(css::uno::TypeClass_EXCEPTION
, exception
->getTypeClass());
161 assertEqual( rtl::OUString( "com.sun.star.uno.Exception"),
162 exception
->getName());
163 assertFalse(exception
->getBaseType().is());
165 = css::uno::Reference
< css::reflection::XCompoundTypeDescription
>(
166 provider
->getByHierarchicalName(
167 rtl::OUString( "com.sun.star.uno.RuntimeException")),
168 css::uno::UNO_QUERY_THROW
);
169 assertEqual(css::uno::TypeClass_EXCEPTION
, exception
->getTypeClass());
170 assertEqual( rtl::OUString( "com.sun.star.uno.RuntimeException"),
171 exception
->getName());
172 assertEqual( rtl::OUString( "com.sun.star.uno.Exception"),
173 exception
->getBaseType()->getName());
175 css::uno::Reference
< css::reflection::XStructTypeDescription
> structure
;
177 structure
= css::uno::Reference
< css::reflection::XStructTypeDescription
>(
178 provider
->getByHierarchicalName(
179 rtl::OUString( "test.registrytdprovider.Struct2")),
180 css::uno::UNO_QUERY_THROW
);
181 assertEqual(css::uno::TypeClass_STRUCT
, structure
->getTypeClass());
182 assertEqual( rtl::OUString( "test.registrytdprovider.Struct2"),
183 structure
->getName());
184 assertFalse(structure
->getBaseType().is());
185 assertEqual
< sal_Int32
>(1, structure
->getMemberTypes().getLength());
187 rtl::OUString( "test.registrytdprovider.Struct1"),
188 structure
->getMemberTypes()[0]->getName());
189 assertEqual
< sal_Int32
>(1, structure
->getMemberNames().getLength());
192 structure
->getMemberNames()[0]);
193 assertEqual
< sal_Int32
>(0, structure
->getTypeParameters().getLength());
194 assertEqual
< sal_Int32
>(0, structure
->getTypeArguments().getLength());
196 structure
= css::uno::Reference
< css::reflection::XStructTypeDescription
>(
197 provider
->getByHierarchicalName(
198 rtl::OUString( "test.registrytdprovider.Struct3")),
199 css::uno::UNO_QUERY_THROW
);
200 assertEqual(css::uno::TypeClass_STRUCT
, structure
->getTypeClass());
202 rtl::OUString( "test.registrytdprovider.Struct3"),
203 structure
->getName());
204 assertFalse(structure
->getBaseType().is());
205 assertEqual
< sal_Int32
>(1, structure
->getMemberTypes().getLength());
207 css::uno::TypeClass_UNKNOWN
,
208 structure
->getMemberTypes()[0]->getTypeClass());
211 structure
->getMemberTypes()[0]->getName());
212 assertEqual
< sal_Int32
>(1, structure
->getMemberNames().getLength());
215 structure
->getMemberNames()[0]);
216 assertEqual
< sal_Int32
>(2, structure
->getTypeParameters().getLength());
219 structure
->getTypeParameters()[0]);
222 structure
->getTypeParameters()[1]);
223 assertEqual
< sal_Int32
>(0, structure
->getTypeArguments().getLength());
225 structure
= css::uno::Reference
< css::reflection::XStructTypeDescription
>(
226 provider
->getByHierarchicalName(
227 rtl::OUString( "test.registrytdprovider.Struct4")),
228 css::uno::UNO_QUERY_THROW
);
229 assertEqual(css::uno::TypeClass_STRUCT
, structure
->getTypeClass());
231 rtl::OUString( "test.registrytdprovider.Struct4"),
232 structure
->getName());
234 rtl::OUString( "test.registrytdprovider.Struct2"),
235 structure
->getBaseType()->getName());
236 assertEqual
< sal_Int32
>(1, structure
->getMemberTypes().getLength());
238 rtl::OUString( "test.registrytdprovider.Struct3<"
239 "test.registrytdprovider.Struct2,"
240 "test.registrytdprovider.Struct3<boolean,any>>"),
241 structure
->getMemberTypes()[0]->getName());
242 assertEqual
< sal_Int32
>(1, structure
->getMemberNames().getLength());
245 structure
->getMemberNames()[0]);
246 assertEqual
< sal_Int32
>(0, structure
->getTypeParameters().getLength());
247 assertEqual
< sal_Int32
>(0, structure
->getTypeArguments().getLength());
249 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
253 = css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>(
254 provider
->getByHierarchicalName(
255 rtl::OUString( "test.registrytdprovider.XTest1")),
256 css::uno::UNO_QUERY_THROW
);
257 assertEqual(css::uno::TypeClass_INTERFACE
, interface
->getTypeClass());
259 rtl::OUString( "test.registrytdprovider.XTest1"),
260 interface
->getName());
262 css::uno::Reference
< css::reflection::XTypeDescription
> > bases(
263 interface
->getBaseTypes());
264 assertEqual
< sal_Int32
>(1, bases
.getLength());
266 rtl::OUString( "com.sun.star.uno.XInterface"),
267 bases
[0]->getName());
269 css::uno::Reference
< css::reflection::XTypeDescription
> >
270 optionalBases(interface
->getOptionalBaseTypes());
271 assertEqual
< sal_Int32
>(1, optionalBases
.getLength());
274 "test.registrytdprovider.XBase"),
275 optionalBases
[0]->getName());
278 css::reflection::XInterfaceMemberTypeDescription
> > members(
279 interface
->getMembers());
280 assertEqual
< sal_Int32
>(5, members
.getLength());
282 css::uno::Reference
< css::reflection::XInterfaceAttributeTypeDescription2
>
285 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
288 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
290 css::uno::Reference
< css::reflection::XInterfaceMethodTypeDescription
>
293 attribute
= css::uno::Reference
<
294 css::reflection::XInterfaceAttributeTypeDescription2
>(
295 members
[0], css::uno::UNO_QUERY_THROW
);
297 css::uno::TypeClass_INTERFACE_ATTRIBUTE
, attribute
->getTypeClass());
299 rtl::OUString( "test.registrytdprovider.XTest1::a1"),
300 attribute
->getName());
303 attribute
->getMemberName());
304 assertEqual
< sal_Int32
>(3, attribute
->getPosition());
305 assertEqual
< bool >(false, attribute
->isReadOnly());
307 rtl::OUString("short"),
308 attribute
->getType()->getName());
309 assertEqual
< bool >(true, attribute
->isBound());
310 getExceptions
= attribute
->getGetExceptions();
311 assertEqual
< sal_Int32
>(0, getExceptions
.getLength());
312 setExceptions
= attribute
->getSetExceptions();
313 assertEqual
< sal_Int32
>(0, setExceptions
.getLength());
315 attribute
= css::uno::Reference
<
316 css::reflection::XInterfaceAttributeTypeDescription2
>(
317 members
[1], css::uno::UNO_QUERY_THROW
);
319 css::uno::TypeClass_INTERFACE_ATTRIBUTE
, attribute
->getTypeClass());
321 rtl::OUString( "test.registrytdprovider.XTest1::a2"),
322 attribute
->getName());
325 attribute
->getMemberName());
326 assertEqual
< sal_Int32
>(4, attribute
->getPosition());
327 assertEqual
< bool >(false, attribute
->isReadOnly());
329 rtl::OUString("long"),
330 attribute
->getType()->getName());
331 assertEqual
< bool >(false, attribute
->isBound());
332 getExceptions
= attribute
->getGetExceptions();
333 assertEqual
< sal_Int32
>(2, getExceptions
.getLength());
335 rtl::OUString( "com.sun.star.lang.WrappedTargetException"),
336 getExceptions
[0]->getName());
338 rtl::OUString( "com.sun.star.uno.RuntimeException"),
339 getExceptions
[1]->getName());
340 setExceptions
= attribute
->getSetExceptions();
341 assertEqual
< sal_Int32
>(2, setExceptions
.getLength());
343 rtl::OUString( "com.sun.star.uno.Exception"),
344 setExceptions
[0]->getName());
346 rtl::OUString( "com.sun.star.lang.WrappedTargetException"),
347 setExceptions
[1]->getName());
349 attribute
= css::uno::Reference
<
350 css::reflection::XInterfaceAttributeTypeDescription2
>(
351 members
[2], css::uno::UNO_QUERY_THROW
);
353 css::uno::TypeClass_INTERFACE_ATTRIBUTE
, attribute
->getTypeClass());
356 "test.registrytdprovider.XTest1::a3"),
357 attribute
->getName());
360 attribute
->getMemberName());
361 assertEqual
< sal_Int32
>(5, attribute
->getPosition());
362 assertEqual
< bool >(true, attribute
->isReadOnly());
364 rtl::OUString("hyper"),
365 attribute
->getType()->getName());
366 assertEqual
< bool >(true, attribute
->isBound());
367 getExceptions
= attribute
->getGetExceptions();
368 assertEqual
< sal_Int32
>(1, getExceptions
.getLength());
370 rtl::OUString( "com.sun.star.lang.WrappedTargetException"),
371 getExceptions
[0]->getName());
372 setExceptions
= attribute
->getSetExceptions();
373 assertEqual
< sal_Int32
>(0, setExceptions
.getLength());
375 method
= css::uno::Reference
<
376 css::reflection::XInterfaceMethodTypeDescription
>(
377 members
[3], css::uno::UNO_QUERY_THROW
);
378 assertEqual(css::uno::TypeClass_INTERFACE_METHOD
, method
->getTypeClass());
380 rtl::OUString( "test.registrytdprovider.XTest1::f1"),
384 method
->getMemberName());
385 assertEqual
< sal_Int32
>(6, method
->getPosition());
386 assertEqual
< bool >(false, method
->isOneway());
387 assertEqual
< sal_Int32
>(1, method
->getParameters().getLength());
390 method
->getParameters()[0]->getName());
392 rtl::OUString("any"),
393 method
->getParameters()[0]->getType()->getName());
394 assertEqual
< bool >(false, method
->getParameters()[0]->isIn());
395 assertEqual
< bool >(true, method
->getParameters()[0]->isOut());
396 assertEqual
< sal_Int32
>(0, method
->getParameters()[0]->getPosition());
397 assertEqual
< sal_Int32
>(1, method
->getExceptions().getLength());
399 rtl::OUString( "com.sun.star.uno.RuntimeException"),
400 method
->getExceptions()[0]->getName());
402 method
= css::uno::Reference
<
403 css::reflection::XInterfaceMethodTypeDescription
>(
404 members
[4], css::uno::UNO_QUERY_THROW
);
405 assertEqual(css::uno::TypeClass_INTERFACE_METHOD
, method
->getTypeClass());
407 rtl::OUString( "test.registrytdprovider.XTest1::f2"),
411 method
->getMemberName());
412 assertEqual
< sal_Int32
>(7, method
->getPosition());
413 assertEqual
< bool >(true, method
->isOneway());
414 assertEqual
< sal_Int32
>(0, method
->getParameters().getLength());
415 assertEqual
< sal_Int32
>(0, method
->getExceptions().getLength());
418 = css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>(
419 provider
->getByHierarchicalName(
420 rtl::OUString( "test.registrytdprovider.XTest2")),
421 css::uno::UNO_QUERY_THROW
);
422 assertEqual(css::uno::TypeClass_INTERFACE
, interface
->getTypeClass());
424 rtl::OUString( "test.registrytdprovider.XTest2"),
425 interface
->getName());
426 assertEqual
< sal_Int32
>(1, interface
->getBaseTypes().getLength());
428 rtl::OUString( "test.registrytdprovider.Typedef2"),
429 interface
->getBaseTypes()[0]->getName());
430 assertEqual
< sal_Int32
>(0, interface
->getOptionalBaseTypes().getLength());
431 assertEqual
< sal_Int32
>(0, interface
->getMembers().getLength());
433 css::uno::Reference
< css::reflection::XServiceTypeDescription2
> service
;
435 service
= css::uno::Reference
< css::reflection::XServiceTypeDescription2
>(
436 provider
->getByHierarchicalName(
437 rtl::OUString( "test.registrytdprovider.Service1")),
438 css::uno::UNO_QUERY_THROW
);
439 assertEqual(css::uno::TypeClass_SERVICE
, service
->getTypeClass());
441 rtl::OUString( "test.registrytdprovider.Service1"),
443 assertEqual
< sal_Int32
>(0, service
->getMandatoryServices().getLength());
444 assertEqual
< sal_Int32
>(0, service
->getOptionalServices().getLength());
445 assertEqual
< sal_Int32
>(0, service
->getMandatoryInterfaces().getLength());
446 assertEqual
< sal_Int32
>(0, service
->getOptionalInterfaces().getLength());
447 assertEqual
< bool >(true, service
->isSingleInterfaceBased());
450 "test.registrytdprovider.XTest1"),
451 service
->getInterface()->getName());
452 assertEqual
< sal_Int32
>(2, service
->getConstructors().getLength());
455 service
->getConstructors()[0]->getName());
456 assertEqual
< sal_Int32
>(
457 0, service
->getConstructors()[0]->getParameters().getLength());
458 assertEqual
< sal_Int32
>(
459 0, service
->getConstructors()[0]->getExceptions().getLength());
462 service
->getConstructors()[1]->getName());
463 assertEqual
< sal_Int32
>(
464 1, service
->getConstructors()[1]->getParameters().getLength());
467 service
->getConstructors()[1]->getParameters()[0]->getName());
469 rtl::OUString("any"),
470 (service
->getConstructors()[1]->getParameters()[0]->getType()->
473 true, service
->getConstructors()[1]->getParameters()[0]->isIn());
475 false, service
->getConstructors()[1]->getParameters()[0]->isOut());
476 assertEqual
< sal_Int32
>(
477 0, service
->getConstructors()[1]->getParameters()[0]->getPosition());
480 service
->getConstructors()[1]->getParameters()[0]->isRestParameter());
481 assertEqual
< sal_Int32
>(
482 1, service
->getConstructors()[1]->getExceptions().getLength());
484 rtl::OUString( "com.sun.star.uno.RuntimeException"),
485 service
->getConstructors()[1]->getExceptions()[0]->getName());
487 service
= css::uno::Reference
< css::reflection::XServiceTypeDescription2
>(
488 provider
->getByHierarchicalName(
489 rtl::OUString( "test.registrytdprovider.Service2")),
490 css::uno::UNO_QUERY_THROW
);
491 assertEqual(css::uno::TypeClass_SERVICE
, service
->getTypeClass());
493 rtl::OUString( "test.registrytdprovider.Service2"),
495 assertEqual
< sal_Int32
>(0, service
->getMandatoryServices().getLength());
496 assertEqual
< sal_Int32
>(0, service
->getOptionalServices().getLength());
497 assertEqual
< sal_Int32
>(1, service
->getMandatoryInterfaces().getLength());
499 rtl::OUString( "test.registrytdprovider.XTest1"),
500 service
->getMandatoryInterfaces()[0]->getName());
501 assertEqual
< sal_Int32
>(1, service
->getOptionalInterfaces().getLength());
503 rtl::OUString( "test.registrytdprovider.XBase"),
504 service
->getOptionalInterfaces()[0]->getName());
505 assertEqual
< bool >(false, service
->isSingleInterfaceBased());
506 assertFalse(service
->getInterface().is());
507 assertEqual
< sal_Int32
>(0, service
->getConstructors().getLength());
509 service
= css::uno::Reference
< css::reflection::XServiceTypeDescription2
>(
510 provider
->getByHierarchicalName(
511 rtl::OUString( "test.registrytdprovider.Service3")),
512 css::uno::UNO_QUERY_THROW
);
513 assertEqual(css::uno::TypeClass_SERVICE
, service
->getTypeClass());
516 "test.registrytdprovider.Service3"),
518 assertEqual
< sal_Int32
>(0, service
->getMandatoryServices().getLength());
519 assertEqual
< sal_Int32
>(0, service
->getOptionalServices().getLength());
520 assertEqual
< sal_Int32
>(0, service
->getMandatoryInterfaces().getLength());
521 assertEqual
< sal_Int32
>(0, service
->getOptionalInterfaces().getLength());
522 assertEqual
< bool >(true, service
->isSingleInterfaceBased());
525 "test.registrytdprovider.Typedef2"),
526 service
->getInterface()->getName());
527 assertEqual
< sal_Int32
>(0, service
->getConstructors().getLength());
529 css::uno::Reference
< css::reflection::XSingletonTypeDescription2
>
532 singleton
= css::uno::Reference
<
533 css::reflection::XSingletonTypeDescription2
>(
534 provider
->getByHierarchicalName(
535 rtl::OUString( "test.registrytdprovider.Singleton1")),
536 css::uno::UNO_QUERY_THROW
);
537 assertEqual(css::uno::TypeClass_SINGLETON
, singleton
->getTypeClass());
540 "test.registrytdprovider.Singleton1"),
541 singleton
->getName());
542 assertFalse(singleton
->getService().is());
543 assertEqual
< bool >(true, singleton
->isInterfaceBased());
546 "test.registrytdprovider.XTest1"),
547 singleton
->getInterface()->getName());
549 singleton
= css::uno::Reference
<
550 css::reflection::XSingletonTypeDescription2
>(
551 provider
->getByHierarchicalName(
552 rtl::OUString( "test.registrytdprovider.Singleton2")),
553 css::uno::UNO_QUERY_THROW
);
554 assertEqual(css::uno::TypeClass_SINGLETON
, singleton
->getTypeClass());
557 "test.registrytdprovider.Singleton2"),
558 singleton
->getName());
561 "test.registrytdprovider.Service1"),
562 singleton
->getService()->getName());
563 assertEqual
< bool >(false, singleton
->isInterfaceBased());
564 assertFalse(singleton
->getInterface().is());
566 singleton
= css::uno::Reference
<
567 css::reflection::XSingletonTypeDescription2
>(
568 provider
->getByHierarchicalName(
569 rtl::OUString( "test.registrytdprovider.Singleton3")),
570 css::uno::UNO_QUERY_THROW
);
571 assertEqual(css::uno::TypeClass_SINGLETON
, singleton
->getTypeClass());
574 "test.registrytdprovider.Singleton3"),
575 singleton
->getName());
576 assertFalse(singleton
->getService().is());
577 assertEqual
< bool >(true, singleton
->isInterfaceBased());
580 "test.registrytdprovider.Typedef2"),
581 singleton
->getInterface()->getName());
583 css::uno::Reference
< css::reflection::XPublished
> published
;
584 published
= css::uno::Reference
< css::reflection::XPublished
>(
585 css::uno::Reference
< css::reflection::XTypeDescription
>(
586 provider
->getByHierarchicalName(
587 rtl::OUString( "test.registrytdprovider.Enum1")),
588 css::uno::UNO_QUERY_THROW
),
589 css::uno::UNO_QUERY
);
590 assertTrue(published
.is());
591 assertTrue(published
->isPublished());
592 published
= css::uno::Reference
< css::reflection::XPublished
>(
593 css::uno::Reference
< css::reflection::XTypeDescription
>(
594 provider
->getByHierarchicalName(
595 rtl::OUString( "test.registrytdprovider.Enum2")),
596 css::uno::UNO_QUERY_THROW
),
597 css::uno::UNO_QUERY
);
598 assertTrue(published
.is());
599 assertFalse(published
->isPublished());
600 published
= css::uno::Reference
< css::reflection::XPublished
>(
601 css::uno::Reference
< css::reflection::XTypeDescription
>(
602 provider
->getByHierarchicalName(
603 rtl::OUString( "test.registrytdprovider.Struct1")),
604 css::uno::UNO_QUERY_THROW
),
605 css::uno::UNO_QUERY
);
606 assertTrue(published
.is());
607 assertTrue(published
->isPublished());
608 published
= css::uno::Reference
< css::reflection::XPublished
>(
609 css::uno::Reference
< css::reflection::XTypeDescription
>(
610 provider
->getByHierarchicalName(
611 rtl::OUString( "test.registrytdprovider.Struct2")),
612 css::uno::UNO_QUERY_THROW
),
613 css::uno::UNO_QUERY
);
614 assertTrue(published
.is());
615 assertFalse(published
->isPublished());
616 published
= css::uno::Reference
< css::reflection::XPublished
>(
617 css::uno::Reference
< css::reflection::XTypeDescription
>(
618 provider
->getByHierarchicalName(
619 rtl::OUString( "test.registrytdprovider.Struct3")),
620 css::uno::UNO_QUERY_THROW
),
621 css::uno::UNO_QUERY
);
622 assertTrue(published
.is());
623 assertTrue(published
->isPublished());
624 published
= css::uno::Reference
< css::reflection::XPublished
>(
625 css::uno::Reference
< css::reflection::XStructTypeDescription
>(
626 provider
->getByHierarchicalName(
627 rtl::OUString( "test.registrytdprovider.Struct3")),
628 css::uno::UNO_QUERY_THROW
)->getMemberTypes()[0],
629 css::uno::UNO_QUERY
);
630 assertFalse(published
.is());
631 published
= css::uno::Reference
< css::reflection::XPublished
>(
632 css::uno::Reference
< css::reflection::XTypeDescription
>(
633 provider
->getByHierarchicalName(
634 rtl::OUString( "test.registrytdprovider.Struct3a")),
635 css::uno::UNO_QUERY_THROW
),
636 css::uno::UNO_QUERY
);
637 assertTrue(published
.is());
638 assertFalse(published
->isPublished());
639 published
= css::uno::Reference
< css::reflection::XPublished
>(
640 css::uno::Reference
< css::reflection::XTypeDescription
>(
641 provider
->getByHierarchicalName(
642 rtl::OUString( "test.registrytdprovider.Exception1")),
643 css::uno::UNO_QUERY_THROW
),
644 css::uno::UNO_QUERY
);
645 assertTrue(published
.is());
646 assertTrue(published
->isPublished());
647 published
= css::uno::Reference
< css::reflection::XPublished
>(
648 css::uno::Reference
< css::reflection::XTypeDescription
>(
649 provider
->getByHierarchicalName(
650 rtl::OUString( "test.registrytdprovider.Exception2")),
651 css::uno::UNO_QUERY_THROW
),
652 css::uno::UNO_QUERY
);
653 assertTrue(published
.is());
654 assertFalse(published
->isPublished());
655 published
= css::uno::Reference
< css::reflection::XPublished
>(
656 css::uno::Reference
< css::reflection::XTypeDescription
>(
657 provider
->getByHierarchicalName(
658 rtl::OUString( "test.registrytdprovider.XTest1")),
659 css::uno::UNO_QUERY_THROW
),
660 css::uno::UNO_QUERY
);
661 assertTrue(published
.is());
662 assertTrue(published
->isPublished());
663 published
= css::uno::Reference
< css::reflection::XPublished
>(
664 css::uno::Reference
< css::reflection::XTypeDescription
>(
665 provider
->getByHierarchicalName(
666 rtl::OUString( "test.registrytdprovider.XTest2")),
667 css::uno::UNO_QUERY_THROW
),
668 css::uno::UNO_QUERY
);
669 assertTrue(published
.is());
670 assertFalse(published
->isPublished());
671 published
= css::uno::Reference
< css::reflection::XPublished
>(
672 css::uno::Reference
< css::reflection::XTypeDescription
>(
673 provider
->getByHierarchicalName(
674 rtl::OUString( "test.registrytdprovider.Typedef1")),
675 css::uno::UNO_QUERY_THROW
),
676 css::uno::UNO_QUERY
);
677 assertTrue(published
.is());
678 assertTrue(published
->isPublished());
679 published
= css::uno::Reference
< css::reflection::XPublished
>(
680 css::uno::Reference
< css::reflection::XTypeDescription
>(
681 provider
->getByHierarchicalName(
682 rtl::OUString( "test.registrytdprovider.Typedef2")),
683 css::uno::UNO_QUERY_THROW
),
684 css::uno::UNO_QUERY
);
685 assertTrue(published
.is());
686 assertFalse(published
->isPublished());
687 //TODO: check constants test.registrytdprovider.Const1 (published),
688 // test.registrytdprovider.Const2 (unpublished), and
689 // test.registrytdprovider.Consts1.C (no XPublished), which are not
690 // accessible via provider->getByHierarchicalName (see #i31428)
691 published
= css::uno::Reference
< css::reflection::XPublished
>(
692 css::uno::Reference
< css::reflection::XTypeDescription
>(
693 provider
->getByHierarchicalName(
694 rtl::OUString( "test.registrytdprovider.Consts1")),
695 css::uno::UNO_QUERY_THROW
),
696 css::uno::UNO_QUERY
);
697 assertTrue(published
.is());
698 assertTrue(published
->isPublished());
699 published
= css::uno::Reference
< css::reflection::XPublished
>(
700 css::uno::Reference
< css::reflection::XTypeDescription
>(
701 provider
->getByHierarchicalName(
702 rtl::OUString( "test.registrytdprovider.Consts2")),
703 css::uno::UNO_QUERY_THROW
),
704 css::uno::UNO_QUERY
);
705 assertTrue(published
.is());
706 assertFalse(published
->isPublished());
707 published
= css::uno::Reference
< css::reflection::XPublished
>(
708 css::uno::Reference
< css::reflection::XTypeDescription
>(
709 provider
->getByHierarchicalName(
710 rtl::OUString( "test.registrytdprovider")),
711 css::uno::UNO_QUERY_THROW
),
712 css::uno::UNO_QUERY
);
713 assertFalse(published
.is());
714 published
= css::uno::Reference
< css::reflection::XPublished
>(
715 css::uno::Reference
< css::reflection::XTypeDescription
>(
716 provider
->getByHierarchicalName(
717 rtl::OUString( "test.registrytdprovider.Service1")),
718 css::uno::UNO_QUERY_THROW
),
719 css::uno::UNO_QUERY
);
720 assertTrue(published
.is());
721 assertTrue(published
->isPublished());
722 published
= css::uno::Reference
< css::reflection::XPublished
>(
723 css::uno::Reference
< css::reflection::XTypeDescription
>(
724 provider
->getByHierarchicalName(
725 rtl::OUString( "test.registrytdprovider.Service2")),
726 css::uno::UNO_QUERY_THROW
),
727 css::uno::UNO_QUERY
);
728 assertTrue(published
.is());
729 assertFalse(published
->isPublished());
730 published
= css::uno::Reference
< css::reflection::XPublished
>(
731 css::uno::Reference
< css::reflection::XTypeDescription
>(
732 provider
->getByHierarchicalName(
733 rtl::OUString( "test.registrytdprovider.Singleton2")),
734 css::uno::UNO_QUERY_THROW
),
735 css::uno::UNO_QUERY
);
736 assertTrue(published
.is());
737 assertTrue(published
->isPublished());
738 published
= css::uno::Reference
< css::reflection::XPublished
>(
739 css::uno::Reference
< css::reflection::XTypeDescription
>(
740 provider
->getByHierarchicalName(
741 rtl::OUString( "test.registrytdprovider.Singleton1")),
742 css::uno::UNO_QUERY_THROW
),
743 css::uno::UNO_QUERY
);
744 assertTrue(published
.is());
745 assertFalse(published
->isPublished());
750 rtl::OUString
Service::getImplementationName() {
751 return rtl::OUString("test.registrytdprovider.impl");
754 css::uno::Sequence
< rtl::OUString
> Service::getSupportedServiceNames() {
755 return css::uno::Sequence
< rtl::OUString
>();
758 css::uno::Reference
< css::uno::XInterface
> Service::createInstance(
759 css::uno::Reference
< css::uno::XComponentContext
> const & context
)
760 throw (css::uno::Exception
)
762 return static_cast< cppu::OWeakObject
* >(new Service(context
));
765 extern "C" SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
component_getFactory(char const * implName
,
766 void * serviceManager
, void *) {
768 if (serviceManager
!= 0) {
769 css::uno::Reference
< css::lang::XSingleComponentFactory
> f
;
770 if (Service::getImplementationName().equalsAscii(implName
)) {
771 f
= cppu::createSingleComponentFactory(
772 &Service::createInstance
, Service::getImplementationName(),
773 Service::getSupportedServiceNames());
785 bool writeInfo(void * registryKey
, rtl::OUString
const & implementationName
,
786 css::uno::Sequence
< rtl::OUString
> const & serviceNames
) {
787 rtl::OUString
keyName("/");
788 keyName
+= implementationName
;
789 keyName
+= rtl::OUString("/UNO/SERVICES");
790 css::uno::Reference
< css::registry::XRegistryKey
> key
;
792 key
= static_cast< css::registry::XRegistryKey
* >(registryKey
)->
794 } catch (css::registry::InvalidRegistryException
&) {}
799 for (sal_Int32 i
= 0; i
< serviceNames
.getLength(); ++i
) {
801 key
->createKey(serviceNames
[i
]);
802 } catch (css::registry::InvalidRegistryException
&) {
812 extern "C" sal_Bool SAL_CALL
component_writeInfo(void *, void * registryKey
) {
814 && writeInfo(registryKey
, Service::getImplementationName(),
815 Service::getSupportedServiceNames());
818 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */