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/implbase.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::WeakImplHelper
< 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 "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 provider
->getByHierarchicalName(
156 OUString( "com.sun.star.uno.Exception")),
157 css::uno::UNO_QUERY_THROW
);
158 assertEqual(css::uno::TypeClass_EXCEPTION
, exception
->getTypeClass());
159 assertEqual( OUString( "com.sun.star.uno.Exception"),
160 exception
->getName());
161 assertFalse(exception
->getBaseType().is());
163 provider
->getByHierarchicalName(
164 OUString( "com.sun.star.uno.RuntimeException")),
165 css::uno::UNO_QUERY_THROW
);
166 assertEqual(css::uno::TypeClass_EXCEPTION
, exception
->getTypeClass());
167 assertEqual( OUString( "com.sun.star.uno.RuntimeException"),
168 exception
->getName());
169 assertEqual( OUString( "com.sun.star.uno.Exception"),
170 exception
->getBaseType()->getName());
172 css::uno::Reference
< css::reflection::XStructTypeDescription
> structure
;
175 provider
->getByHierarchicalName(
176 OUString( "test.registrytdprovider.Struct2")),
177 css::uno::UNO_QUERY_THROW
);
178 assertEqual(css::uno::TypeClass_STRUCT
, structure
->getTypeClass());
179 assertEqual( OUString( "test.registrytdprovider.Struct2"),
180 structure
->getName());
181 assertFalse(structure
->getBaseType().is());
182 assertEqual
< sal_Int32
>(1, structure
->getMemberTypes().getLength());
184 OUString( "test.registrytdprovider.Struct1"),
185 structure
->getMemberTypes()[0]->getName());
186 assertEqual
< sal_Int32
>(1, structure
->getMemberNames().getLength());
189 structure
->getMemberNames()[0]);
190 assertEqual
< sal_Int32
>(0, structure
->getTypeParameters().getLength());
191 assertEqual
< sal_Int32
>(0, structure
->getTypeArguments().getLength());
194 provider
->getByHierarchicalName(
195 OUString( "test.registrytdprovider.Struct3")),
196 css::uno::UNO_QUERY_THROW
);
197 assertEqual(css::uno::TypeClass_STRUCT
, structure
->getTypeClass());
199 OUString( "test.registrytdprovider.Struct3"),
200 structure
->getName());
201 assertFalse(structure
->getBaseType().is());
202 assertEqual
< sal_Int32
>(1, structure
->getMemberTypes().getLength());
204 css::uno::TypeClass_UNKNOWN
,
205 structure
->getMemberTypes()[0]->getTypeClass());
208 structure
->getMemberTypes()[0]->getName());
209 assertEqual
< sal_Int32
>(1, structure
->getMemberNames().getLength());
212 structure
->getMemberNames()[0]);
213 assertEqual
< sal_Int32
>(2, structure
->getTypeParameters().getLength());
216 structure
->getTypeParameters()[0]);
219 structure
->getTypeParameters()[1]);
220 assertEqual
< sal_Int32
>(0, structure
->getTypeArguments().getLength());
223 provider
->getByHierarchicalName(
224 OUString( "test.registrytdprovider.Struct4")),
225 css::uno::UNO_QUERY_THROW
);
226 assertEqual(css::uno::TypeClass_STRUCT
, structure
->getTypeClass());
228 OUString( "test.registrytdprovider.Struct4"),
229 structure
->getName());
231 OUString( "test.registrytdprovider.Struct2"),
232 structure
->getBaseType()->getName());
233 assertEqual
< sal_Int32
>(1, structure
->getMemberTypes().getLength());
235 OUString( "test.registrytdprovider.Struct3<"
236 "test.registrytdprovider.Struct2,"
237 "test.registrytdprovider.Struct3<boolean,any>>"),
238 structure
->getMemberTypes()[0]->getName());
239 assertEqual
< sal_Int32
>(1, structure
->getMemberNames().getLength());
242 structure
->getMemberNames()[0]);
243 assertEqual
< sal_Int32
>(0, structure
->getTypeParameters().getLength());
244 assertEqual
< sal_Int32
>(0, structure
->getTypeArguments().getLength());
246 css::uno::Reference
< css::reflection::XInterfaceTypeDescription2
>
250 provider
->getByHierarchicalName(
251 OUString( "test.registrytdprovider.XTest1")),
252 css::uno::UNO_QUERY_THROW
);
253 assertEqual(css::uno::TypeClass_INTERFACE
, interface
->getTypeClass());
255 OUString( "test.registrytdprovider.XTest1"),
256 interface
->getName());
258 css::uno::Reference
< css::reflection::XTypeDescription
> > bases(
259 interface
->getBaseTypes());
260 assertEqual
< sal_Int32
>(1, bases
.getLength());
262 OUString( "com.sun.star.uno.XInterface"),
263 bases
[0]->getName());
265 css::uno::Reference
< css::reflection::XTypeDescription
> >
266 optionalBases(interface
->getOptionalBaseTypes());
267 assertEqual
< sal_Int32
>(1, optionalBases
.getLength());
270 "test.registrytdprovider.XBase"),
271 optionalBases
[0]->getName());
274 css::reflection::XInterfaceMemberTypeDescription
> > members(
275 interface
->getMembers());
276 assertEqual
< sal_Int32
>(5, members
.getLength());
278 css::uno::Reference
< css::reflection::XInterfaceAttributeTypeDescription2
>
281 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
284 css::uno::Reference
< css::reflection::XCompoundTypeDescription
> >
286 css::uno::Reference
< css::reflection::XInterfaceMethodTypeDescription
>
289 attribute
.set( members
[0], css::uno::UNO_QUERY_THROW
);
291 css::uno::TypeClass_INTERFACE_ATTRIBUTE
, attribute
->getTypeClass());
293 OUString( "test.registrytdprovider.XTest1::a1"),
294 attribute
->getName());
297 attribute
->getMemberName());
298 assertEqual
< sal_Int32
>(3, attribute
->getPosition());
299 assertEqual
< bool >(false, attribute
->isReadOnly());
302 attribute
->getType()->getName());
303 assertEqual
< bool >(true, attribute
->isBound());
304 getExceptions
= attribute
->getGetExceptions();
305 assertEqual
< sal_Int32
>(0, getExceptions
.getLength());
306 setExceptions
= attribute
->getSetExceptions();
307 assertEqual
< sal_Int32
>(0, setExceptions
.getLength());
309 attribute
.set( members
[1], css::uno::UNO_QUERY_THROW
);
311 css::uno::TypeClass_INTERFACE_ATTRIBUTE
, attribute
->getTypeClass());
313 OUString( "test.registrytdprovider.XTest1::a2"),
314 attribute
->getName());
317 attribute
->getMemberName());
318 assertEqual
< sal_Int32
>(4, attribute
->getPosition());
319 assertEqual
< bool >(false, attribute
->isReadOnly());
322 attribute
->getType()->getName());
323 assertEqual
< bool >(false, attribute
->isBound());
324 getExceptions
= attribute
->getGetExceptions();
325 assertEqual
< sal_Int32
>(2, getExceptions
.getLength());
327 OUString( "com.sun.star.lang.WrappedTargetException"),
328 getExceptions
[0]->getName());
330 OUString( "com.sun.star.uno.RuntimeException"),
331 getExceptions
[1]->getName());
332 setExceptions
= attribute
->getSetExceptions();
333 assertEqual
< sal_Int32
>(2, setExceptions
.getLength());
335 OUString( "com.sun.star.uno.Exception"),
336 setExceptions
[0]->getName());
338 OUString( "com.sun.star.lang.WrappedTargetException"),
339 setExceptions
[1]->getName());
341 attribute
.set( members
[2], css::uno::UNO_QUERY_THROW
);
343 css::uno::TypeClass_INTERFACE_ATTRIBUTE
, attribute
->getTypeClass());
346 "test.registrytdprovider.XTest1::a3"),
347 attribute
->getName());
350 attribute
->getMemberName());
351 assertEqual
< sal_Int32
>(5, attribute
->getPosition());
352 assertEqual
< bool >(true, attribute
->isReadOnly());
355 attribute
->getType()->getName());
356 assertEqual
< bool >(true, attribute
->isBound());
357 getExceptions
= attribute
->getGetExceptions();
358 assertEqual
< sal_Int32
>(1, getExceptions
.getLength());
360 OUString( "com.sun.star.lang.WrappedTargetException"),
361 getExceptions
[0]->getName());
362 setExceptions
= attribute
->getSetExceptions();
363 assertEqual
< sal_Int32
>(0, setExceptions
.getLength());
365 method
.set( members
[3], css::uno::UNO_QUERY_THROW
);
366 assertEqual(css::uno::TypeClass_INTERFACE_METHOD
, method
->getTypeClass());
368 OUString( "test.registrytdprovider.XTest1::f1"),
372 method
->getMemberName());
373 assertEqual
< sal_Int32
>(6, method
->getPosition());
374 assertEqual
< bool >(false, method
->isOneway());
375 assertEqual
< sal_Int32
>(1, method
->getParameters().getLength());
378 method
->getParameters()[0]->getName());
381 method
->getParameters()[0]->getType()->getName());
382 assertEqual
< bool >(false, method
->getParameters()[0]->isIn());
383 assertEqual
< bool >(true, method
->getParameters()[0]->isOut());
384 assertEqual
< sal_Int32
>(0, method
->getParameters()[0]->getPosition());
385 assertEqual
< sal_Int32
>(1, method
->getExceptions().getLength());
387 OUString( "com.sun.star.uno.RuntimeException"),
388 method
->getExceptions()[0]->getName());
390 method
.set( members
[4], css::uno::UNO_QUERY_THROW
);
391 assertEqual(css::uno::TypeClass_INTERFACE_METHOD
, method
->getTypeClass());
393 OUString( "test.registrytdprovider.XTest1::f2"),
397 method
->getMemberName());
398 assertEqual
< sal_Int32
>(7, method
->getPosition());
399 assertEqual
< bool >(true, method
->isOneway());
400 assertEqual
< sal_Int32
>(0, method
->getParameters().getLength());
401 assertEqual
< sal_Int32
>(0, method
->getExceptions().getLength());
404 provider
->getByHierarchicalName(
405 OUString( "test.registrytdprovider.XTest2")),
406 css::uno::UNO_QUERY_THROW
);
407 assertEqual(css::uno::TypeClass_INTERFACE
, interface
->getTypeClass());
409 OUString( "test.registrytdprovider.XTest2"),
410 interface
->getName());
411 assertEqual
< sal_Int32
>(1, interface
->getBaseTypes().getLength());
413 OUString( "test.registrytdprovider.Typedef2"),
414 interface
->getBaseTypes()[0]->getName());
415 assertEqual
< sal_Int32
>(0, interface
->getOptionalBaseTypes().getLength());
416 assertEqual
< sal_Int32
>(0, interface
->getMembers().getLength());
418 css::uno::Reference
< css::reflection::XServiceTypeDescription2
> service
;
421 provider
->getByHierarchicalName(
422 OUString( "test.registrytdprovider.Service1")),
423 css::uno::UNO_QUERY_THROW
);
424 assertEqual(css::uno::TypeClass_SERVICE
, service
->getTypeClass());
426 OUString( "test.registrytdprovider.Service1"),
428 assertEqual
< sal_Int32
>(0, service
->getMandatoryServices().getLength());
429 assertEqual
< sal_Int32
>(0, service
->getOptionalServices().getLength());
430 assertEqual
< sal_Int32
>(0, service
->getMandatoryInterfaces().getLength());
431 assertEqual
< sal_Int32
>(0, service
->getOptionalInterfaces().getLength());
432 assertEqual
< bool >(true, service
->isSingleInterfaceBased());
435 "test.registrytdprovider.XTest1"),
436 service
->getInterface()->getName());
437 assertEqual
< sal_Int32
>(2, service
->getConstructors().getLength());
440 service
->getConstructors()[0]->getName());
441 assertEqual
< sal_Int32
>(
442 0, service
->getConstructors()[0]->getParameters().getLength());
443 assertEqual
< sal_Int32
>(
444 0, service
->getConstructors()[0]->getExceptions().getLength());
447 service
->getConstructors()[1]->getName());
448 assertEqual
< sal_Int32
>(
449 1, service
->getConstructors()[1]->getParameters().getLength());
452 service
->getConstructors()[1]->getParameters()[0]->getName());
455 (service
->getConstructors()[1]->getParameters()[0]->getType()->
458 true, service
->getConstructors()[1]->getParameters()[0]->isIn());
460 false, service
->getConstructors()[1]->getParameters()[0]->isOut());
461 assertEqual
< sal_Int32
>(
462 0, service
->getConstructors()[1]->getParameters()[0]->getPosition());
465 service
->getConstructors()[1]->getParameters()[0]->isRestParameter());
466 assertEqual
< sal_Int32
>(
467 1, service
->getConstructors()[1]->getExceptions().getLength());
469 OUString( "com.sun.star.uno.RuntimeException"),
470 service
->getConstructors()[1]->getExceptions()[0]->getName());
473 provider
->getByHierarchicalName(
474 OUString( "test.registrytdprovider.Service2")),
475 css::uno::UNO_QUERY_THROW
);
476 assertEqual(css::uno::TypeClass_SERVICE
, service
->getTypeClass());
478 OUString( "test.registrytdprovider.Service2"),
480 assertEqual
< sal_Int32
>(0, service
->getMandatoryServices().getLength());
481 assertEqual
< sal_Int32
>(0, service
->getOptionalServices().getLength());
482 assertEqual
< sal_Int32
>(1, service
->getMandatoryInterfaces().getLength());
484 OUString( "test.registrytdprovider.XTest1"),
485 service
->getMandatoryInterfaces()[0]->getName());
486 assertEqual
< sal_Int32
>(1, service
->getOptionalInterfaces().getLength());
488 OUString( "test.registrytdprovider.XBase"),
489 service
->getOptionalInterfaces()[0]->getName());
490 assertEqual
< bool >(false, service
->isSingleInterfaceBased());
491 assertFalse(service
->getInterface().is());
492 assertEqual
< sal_Int32
>(0, service
->getConstructors().getLength());
495 provider
->getByHierarchicalName(
496 OUString( "test.registrytdprovider.Service3")),
497 css::uno::UNO_QUERY_THROW
);
498 assertEqual(css::uno::TypeClass_SERVICE
, service
->getTypeClass());
501 "test.registrytdprovider.Service3"),
503 assertEqual
< sal_Int32
>(0, service
->getMandatoryServices().getLength());
504 assertEqual
< sal_Int32
>(0, service
->getOptionalServices().getLength());
505 assertEqual
< sal_Int32
>(0, service
->getMandatoryInterfaces().getLength());
506 assertEqual
< sal_Int32
>(0, service
->getOptionalInterfaces().getLength());
507 assertEqual
< bool >(true, service
->isSingleInterfaceBased());
510 "test.registrytdprovider.Typedef2"),
511 service
->getInterface()->getName());
512 assertEqual
< sal_Int32
>(0, service
->getConstructors().getLength());
514 css::uno::Reference
< css::reflection::XSingletonTypeDescription2
>
518 provider
->getByHierarchicalName(
519 OUString( "test.registrytdprovider.Singleton1")),
520 css::uno::UNO_QUERY_THROW
);
521 assertEqual(css::uno::TypeClass_SINGLETON
, singleton
->getTypeClass());
524 "test.registrytdprovider.Singleton1"),
525 singleton
->getName());
526 assertFalse(singleton
->getService().is());
527 assertEqual
< bool >(true, singleton
->isInterfaceBased());
530 "test.registrytdprovider.XTest1"),
531 singleton
->getInterface()->getName());
534 provider
->getByHierarchicalName(
535 OUString( "test.registrytdprovider.Singleton2")),
536 css::uno::UNO_QUERY_THROW
);
537 assertEqual(css::uno::TypeClass_SINGLETON
, singleton
->getTypeClass());
540 "test.registrytdprovider.Singleton2"),
541 singleton
->getName());
544 "test.registrytdprovider.Service1"),
545 singleton
->getService()->getName());
546 assertEqual
< bool >(false, singleton
->isInterfaceBased());
547 assertFalse(singleton
->getInterface().is());
550 provider
->getByHierarchicalName(
551 OUString( "test.registrytdprovider.Singleton3")),
552 css::uno::UNO_QUERY_THROW
);
553 assertEqual(css::uno::TypeClass_SINGLETON
, singleton
->getTypeClass());
556 "test.registrytdprovider.Singleton3"),
557 singleton
->getName());
558 assertFalse(singleton
->getService().is());
559 assertEqual
< bool >(true, singleton
->isInterfaceBased());
562 "test.registrytdprovider.Typedef2"),
563 singleton
->getInterface()->getName());
565 css::uno::Reference
< css::reflection::XPublished
> published
;
567 css::uno::Reference
< css::reflection::XTypeDescription
>(
568 provider
->getByHierarchicalName(
569 OUString( "test.registrytdprovider.Enum1")),
570 css::uno::UNO_QUERY_THROW
),
571 css::uno::UNO_QUERY
);
572 assertTrue(published
.is());
573 assertTrue(published
->isPublished());
575 css::uno::Reference
< css::reflection::XTypeDescription
>(
576 provider
->getByHierarchicalName(
577 OUString( "test.registrytdprovider.Enum2")),
578 css::uno::UNO_QUERY_THROW
),
579 css::uno::UNO_QUERY
);
580 assertTrue(published
.is());
581 assertFalse(published
->isPublished());
583 css::uno::Reference
< css::reflection::XTypeDescription
>(
584 provider
->getByHierarchicalName(
585 OUString( "test.registrytdprovider.Struct1")),
586 css::uno::UNO_QUERY_THROW
),
587 css::uno::UNO_QUERY
);
588 assertTrue(published
.is());
589 assertTrue(published
->isPublished());
591 css::uno::Reference
< css::reflection::XTypeDescription
>(
592 provider
->getByHierarchicalName(
593 OUString( "test.registrytdprovider.Struct2")),
594 css::uno::UNO_QUERY_THROW
),
595 css::uno::UNO_QUERY
);
596 assertTrue(published
.is());
597 assertFalse(published
->isPublished());
599 css::uno::Reference
< css::reflection::XTypeDescription
>(
600 provider
->getByHierarchicalName(
601 OUString( "test.registrytdprovider.Struct3")),
602 css::uno::UNO_QUERY_THROW
),
603 css::uno::UNO_QUERY
);
604 assertTrue(published
.is());
605 assertTrue(published
->isPublished());
607 css::uno::Reference
< css::reflection::XStructTypeDescription
>(
608 provider
->getByHierarchicalName(
609 OUString( "test.registrytdprovider.Struct3")),
610 css::uno::UNO_QUERY_THROW
)->getMemberTypes()[0],
611 css::uno::UNO_QUERY
);
612 assertFalse(published
.is());
614 css::uno::Reference
< css::reflection::XTypeDescription
>(
615 provider
->getByHierarchicalName(
616 OUString( "test.registrytdprovider.Struct3a")),
617 css::uno::UNO_QUERY_THROW
),
618 css::uno::UNO_QUERY
);
619 assertTrue(published
.is());
620 assertFalse(published
->isPublished());
622 css::uno::Reference
< css::reflection::XTypeDescription
>(
623 provider
->getByHierarchicalName(
624 OUString( "test.registrytdprovider.Exception1")),
625 css::uno::UNO_QUERY_THROW
),
626 css::uno::UNO_QUERY
);
627 assertTrue(published
.is());
628 assertTrue(published
->isPublished());
630 css::uno::Reference
< css::reflection::XTypeDescription
>(
631 provider
->getByHierarchicalName(
632 OUString( "test.registrytdprovider.Exception2")),
633 css::uno::UNO_QUERY_THROW
),
634 css::uno::UNO_QUERY
);
635 assertTrue(published
.is());
636 assertFalse(published
->isPublished());
638 css::uno::Reference
< css::reflection::XTypeDescription
>(
639 provider
->getByHierarchicalName(
640 OUString( "test.registrytdprovider.XTest1")),
641 css::uno::UNO_QUERY_THROW
),
642 css::uno::UNO_QUERY
);
643 assertTrue(published
.is());
644 assertTrue(published
->isPublished());
646 css::uno::Reference
< css::reflection::XTypeDescription
>(
647 provider
->getByHierarchicalName(
648 OUString( "test.registrytdprovider.XTest2")),
649 css::uno::UNO_QUERY_THROW
),
650 css::uno::UNO_QUERY
);
651 assertTrue(published
.is());
652 assertFalse(published
->isPublished());
654 css::uno::Reference
< css::reflection::XTypeDescription
>(
655 provider
->getByHierarchicalName(
656 OUString( "test.registrytdprovider.Typedef1")),
657 css::uno::UNO_QUERY_THROW
),
658 css::uno::UNO_QUERY
);
659 assertTrue(published
.is());
660 assertTrue(published
->isPublished());
662 css::uno::Reference
< css::reflection::XTypeDescription
>(
663 provider
->getByHierarchicalName(
664 OUString( "test.registrytdprovider.Typedef2")),
665 css::uno::UNO_QUERY_THROW
),
666 css::uno::UNO_QUERY
);
667 assertTrue(published
.is());
668 assertFalse(published
->isPublished());
669 //TODO: check constants test.registrytdprovider.Const1 (published),
670 // test.registrytdprovider.Const2 (unpublished), and
671 // test.registrytdprovider.Consts1.C (no XPublished), which are not
672 // accessible via provider->getByHierarchicalName (see #i31428)
674 css::uno::Reference
< css::reflection::XTypeDescription
>(
675 provider
->getByHierarchicalName(
676 OUString( "test.registrytdprovider.Consts1")),
677 css::uno::UNO_QUERY_THROW
),
678 css::uno::UNO_QUERY
);
679 assertTrue(published
.is());
680 assertTrue(published
->isPublished());
682 css::uno::Reference
< css::reflection::XTypeDescription
>(
683 provider
->getByHierarchicalName(
684 OUString( "test.registrytdprovider.Consts2")),
685 css::uno::UNO_QUERY_THROW
),
686 css::uno::UNO_QUERY
);
687 assertTrue(published
.is());
688 assertFalse(published
->isPublished());
690 css::uno::Reference
< css::reflection::XTypeDescription
>(
691 provider
->getByHierarchicalName(
692 OUString( "test.registrytdprovider")),
693 css::uno::UNO_QUERY_THROW
),
694 css::uno::UNO_QUERY
);
695 assertFalse(published
.is());
697 css::uno::Reference
< css::reflection::XTypeDescription
>(
698 provider
->getByHierarchicalName(
699 OUString( "test.registrytdprovider.Service1")),
700 css::uno::UNO_QUERY_THROW
),
701 css::uno::UNO_QUERY
);
702 assertTrue(published
.is());
703 assertTrue(published
->isPublished());
705 css::uno::Reference
< css::reflection::XTypeDescription
>(
706 provider
->getByHierarchicalName(
707 OUString( "test.registrytdprovider.Service2")),
708 css::uno::UNO_QUERY_THROW
),
709 css::uno::UNO_QUERY
);
710 assertTrue(published
.is());
711 assertFalse(published
->isPublished());
713 css::uno::Reference
< css::reflection::XTypeDescription
>(
714 provider
->getByHierarchicalName(
715 OUString( "test.registrytdprovider.Singleton2")),
716 css::uno::UNO_QUERY_THROW
),
717 css::uno::UNO_QUERY
);
718 assertTrue(published
.is());
719 assertTrue(published
->isPublished());
721 css::uno::Reference
< css::reflection::XTypeDescription
>(
722 provider
->getByHierarchicalName(
723 OUString( "test.registrytdprovider.Singleton1")),
724 css::uno::UNO_QUERY_THROW
),
725 css::uno::UNO_QUERY
);
726 assertTrue(published
.is());
727 assertFalse(published
->isPublished());
732 OUString
Service::getImplementationName() {
733 return OUString("test.registrytdprovider.impl");
736 css::uno::Sequence
< OUString
> Service::getSupportedServiceNames() {
737 return css::uno::Sequence
< OUString
>();
740 css::uno::Reference
< css::uno::XInterface
> Service::createInstance(
741 css::uno::Reference
< css::uno::XComponentContext
> const & context
)
742 throw (css::uno::Exception
)
744 return static_cast< cppu::OWeakObject
* >(new Service(context
));
747 extern "C" SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
component_getFactory(char const * implName
,
748 void * serviceManager
, void *) {
750 if (serviceManager
!= 0) {
751 css::uno::Reference
< css::lang::XSingleComponentFactory
> f
;
752 if (Service::getImplementationName().equalsAscii(implName
)) {
753 f
= cppu::createSingleComponentFactory(
754 &Service::createInstance
, Service::getImplementationName(),
755 Service::getSupportedServiceNames());
767 bool writeInfo(void * registryKey
, OUString
const & implementationName
,
768 css::uno::Sequence
< OUString
> const & serviceNames
) {
769 OUString keyName
= "/" + implementationName
+ "/UNO/SERVICES";
770 css::uno::Reference
< css::registry::XRegistryKey
> key
;
772 key
= static_cast< css::registry::XRegistryKey
* >(registryKey
)->
774 } catch (css::registry::InvalidRegistryException
&) {}
779 for (sal_Int32 i
= 0; i
< serviceNames
.getLength(); ++i
) {
781 key
->createKey(serviceNames
[i
]);
782 } catch (css::registry::InvalidRegistryException
&) {
792 extern "C" sal_Bool SAL_CALL
component_writeInfo(void *, void * registryKey
) {
794 && writeInfo(registryKey
, Service::getImplementationName(),
795 Service::getSupportedServiceNames());
798 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */