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 .
24 #include <cppuhelper/bootstrap.hxx>
26 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/registry/XSimpleRegistry.hpp>
29 #include <com/sun/star/lang/XInitialization.hpp>
30 #include <com/sun/star/lang/DisposedException.hpp>
31 #include <com/sun/star/lang/XComponent.hpp>
32 #include <com/sun/star/uno/XComponentContext.hpp>
34 using namespace ::cppu
;
35 using namespace css::uno
;
36 using namespace css::lang
;
37 using namespace css::container
;
38 using namespace css::registry
;
45 Reference
< XSimpleRegistry
> r1
= createSimpleRegistry();
46 Reference
< XSimpleRegistry
> r2
= createSimpleRegistry();
47 r1
->open( OUString( "test1.rdb" ), sal_True
, sal_False
);
48 r2
->open( OUString( "test2.rdb" ), sal_True
, sal_False
);
49 Reference
< XSimpleRegistry
> r
= createNestedRegistry( );
50 Reference
< XInitialization
> rInit( r
, UNO_QUERY
);
51 Sequence
< Any
> seq( 2 );
54 rInit
->initialize( seq
);
56 Reference
< XComponentContext
> rComp
= bootstrap_InitialComponentContext( r
);
58 Reference
< XContentEnumerationAccess
> xCtAccess( rComp
->getServiceManager(), UNO_QUERY
);
60 Reference
< XEnumeration
> rEnum
=
61 xCtAccess
->createContentEnumeration( OUString( "com.sun.star.bridge.Bridge" ) );
64 while( rEnum
->hasMoreElements() )
66 Reference
< XServiceInfo
> r3
;
67 rEnum
->nextElement() >>= r3
;
68 OString o
= OUStringToOString( r3
->getImplementationName() , RTL_TEXTENCODING_ASCII_US
);
69 printf( "%s\n" , o
.getStr() );
70 Sequence
< OUString
> seq2
= r3
->getSupportedServiceNames();
71 for( int i
= 0 ;i
< seq2
.getLength() ; i
++ )
73 o
= OUStringToOString( seq2
[i
] , RTL_TEXTENCODING_ASCII_US
);
74 printf( " %s\n" , o
.getStr() );
78 // there are two services in two registries !
82 printf( "test passed\n" );
85 Reference
< XComponent
> xComp( rComp
, UNO_QUERY
);
89 xCtAccess
->createContentEnumeration(
90 OUString( "blabla" ) );
92 catch (DisposedException
&)
94 printf( "already disposed results in DisposedException: ok.\n" );
97 fprintf( stderr
, "missing DisposedException!\n" );
100 catch ( const Exception
& e
)
102 OString o
= OUStringToOString( e
.Message
, RTL_TEXTENCODING_ASCII_US
);
103 printf( "%s\n" , o
.getStr() );
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */