fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / xmlhelp / source / treeview / tvfactory.cxx
blob02b0a237f0053ef0a454047567e4e1f3378f35e8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/lang/XSingleServiceFactory.hpp>
22 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
23 #include <com/sun/star/beans/PropertyValue.hpp>
24 #include "tvfactory.hxx"
25 #include "tvread.hxx"
28 using namespace treeview;
29 using namespace com::sun::star;
30 using namespace com::sun::star::uno;
31 using namespace com::sun::star::lang;
32 using namespace com::sun::star::beans;
33 using namespace com::sun::star::container;
37 TVFactory::TVFactory( const uno::Reference< XMultiServiceFactory >& xMSF )
38 : m_xMSF( xMSF )
43 TVFactory::~TVFactory()
48 //////////////////////////////////////////////////////////////////////////
49 // XInterface
50 //////////////////////////////////////////////////////////////////////////
52 void SAL_CALL
53 TVFactory::acquire(
54 void )
55 throw()
57 OWeakObject::acquire();
61 void SAL_CALL
62 TVFactory::release(
63 void )
64 throw()
66 OWeakObject::release();
70 Any SAL_CALL
71 TVFactory::queryInterface(
72 const Type& rType )
73 throw( RuntimeException )
75 Any aRet = cppu::queryInterface( rType,
76 (static_cast< XServiceInfo* >(this)),
77 (static_cast< XTypeProvider* >(this)),
78 (static_cast< XMultiServiceFactory* >(this)) );
80 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
84 ////////////////////////////////////////////////////////////////////////////////
86 // XTypeProvider methods.
88 XTYPEPROVIDER_IMPL_3( TVFactory,
89 XServiceInfo,
90 XTypeProvider,
91 XMultiServiceFactory );
95 ////////////////////////////////////////////////////////////////////////////////
97 // XServiceInfo methods.
99 OUString SAL_CALL
100 TVFactory::getImplementationName()
101 throw( RuntimeException )
103 return TVFactory::getImplementationName_static();
107 sal_Bool SAL_CALL
108 TVFactory::supportsService(
109 const OUString& ServiceName )
110 throw( RuntimeException )
112 return
113 ServiceName.compareToAscii( "com.sun.star.help.TreeView" ) == 0 ||
114 ServiceName.compareToAscii( "com.sun.star.ucb.HiearchyDataSource" ) == 0;
118 Sequence< OUString > SAL_CALL
119 TVFactory::getSupportedServiceNames( void )
120 throw( RuntimeException )
122 return TVFactory::getSupportedServiceNames_static();
127 // XMultiServiceFactory
129 Reference< XInterface > SAL_CALL
130 TVFactory::createInstance(
131 const OUString& aServiceSpecifier )
132 throw( Exception,
133 RuntimeException )
135 Any aAny;
136 aAny <<= OUString();
137 Sequence< Any > seq( 1 );
138 seq[0] <<= PropertyValue(
139 OUString( "nodepath" ),
141 aAny,
142 PropertyState_DIRECT_VALUE );
144 return createInstanceWithArguments( aServiceSpecifier,
145 seq );
149 Reference< XInterface > SAL_CALL
150 TVFactory::createInstanceWithArguments(
151 const OUString& ServiceSpecifier,
152 const Sequence< Any >& Arguments )
153 throw( Exception,
154 RuntimeException )
156 (void)ServiceSpecifier;
158 if( ! m_xHDS.is() )
160 cppu::OWeakObject* p = new TVChildTarget( m_xMSF );
161 m_xHDS = Reference< XInterface >( p );
164 Reference< XInterface > ret = m_xHDS;
166 OUString hierview;
167 for( int i = 0; i < Arguments.getLength(); ++i )
169 PropertyValue pV;
170 if( ! ( Arguments[i] >>= pV ) )
171 continue;
173 if( pV.Name.compareToAscii( "nodepath" ) )
174 continue;
176 if( ! ( pV.Value >>= hierview ) )
177 continue;
179 break;
182 if( !hierview.isEmpty() )
184 Reference< XHierarchicalNameAccess > xhieraccess( m_xHDS,UNO_QUERY );
185 Any aAny = xhieraccess->getByHierarchicalName( hierview );
186 Reference< XInterface > xInterface;
187 aAny >>= xInterface;
188 return xInterface;
190 else
191 return m_xHDS;
195 Sequence< OUString > SAL_CALL
196 TVFactory::getAvailableServiceNames( )
197 throw( RuntimeException )
199 Sequence< OUString > seq( 1 );
200 seq[0] = OUString( "com.sun.star.ucb.HierarchyDataReadAccess" );
201 return seq;
206 // static
209 OUString SAL_CALL
210 TVFactory::getImplementationName_static()
212 return OUString( "com.sun.star.help.TreeViewImpl" );
216 Sequence< OUString > SAL_CALL
217 TVFactory::getSupportedServiceNames_static()
219 Sequence< OUString > seq( 2 );
220 seq[0] = OUString( "com.sun.star.help.TreeView" );
221 seq[1] = OUString( "com.sun.star.ucb.HiearchyDataSource" );
222 return seq;
226 Reference< XSingleServiceFactory > SAL_CALL
227 TVFactory::createServiceFactory(
228 const Reference< XMultiServiceFactory >& rxServiceMgr )
230 return Reference< XSingleServiceFactory > (
231 cppu::createSingleFactory(
232 rxServiceMgr,
233 TVFactory::getImplementationName_static(),
234 TVFactory::CreateInstance,
235 TVFactory::getSupportedServiceNames_static() ) );
240 Reference< XInterface > SAL_CALL
241 TVFactory::CreateInstance(
242 const Reference< XMultiServiceFactory >& xMultiServiceFactory )
244 XServiceInfo* xP = (XServiceInfo*) new TVFactory( xMultiServiceFactory );
245 return Reference< XInterface >::query( xP );
248 //=========================================================================
249 extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL treeview_component_getFactory(
250 const sal_Char * pImplName,void * pServiceManager,void * pRegistryKey )
252 (void)pRegistryKey;
254 void * pRet = 0;
256 Reference< XMultiServiceFactory > xSMgr(
257 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
259 Reference< XSingleServiceFactory > xFactory;
261 //////////////////////////////////////////////////////////////////////
262 // File Content Provider.
263 //////////////////////////////////////////////////////////////////////
265 if ( TVFactory::getImplementationName_static().compareToAscii( pImplName ) == 0 )
267 xFactory = TVFactory::createServiceFactory( xSMgr );
270 //////////////////////////////////////////////////////////////////////
272 if ( xFactory.is() )
274 xFactory->acquire();
275 pRet = xFactory.get();
278 return pRet;
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */