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/lang/XSingleServiceFactory.hpp>
22 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
23 #include <com/sun/star/beans/PropertyValue.hpp>
24 #include "tvfactory.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
)
43 TVFactory::~TVFactory()
48 //////////////////////////////////////////////////////////////////////////
50 //////////////////////////////////////////////////////////////////////////
57 OWeakObject::acquire();
66 OWeakObject::release();
71 TVFactory::queryInterface(
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
,
91 XMultiServiceFactory
);
95 ////////////////////////////////////////////////////////////////////////////////
97 // XServiceInfo methods.
100 TVFactory::getImplementationName()
101 throw( RuntimeException
)
103 return TVFactory::getImplementationName_static();
108 TVFactory::supportsService(
109 const OUString
& ServiceName
)
110 throw( RuntimeException
)
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
)
137 Sequence
< Any
> seq( 1 );
138 seq
[0] <<= PropertyValue(
139 OUString( "nodepath" ),
142 PropertyState_DIRECT_VALUE
);
144 return createInstanceWithArguments( aServiceSpecifier
,
149 Reference
< XInterface
> SAL_CALL
150 TVFactory::createInstanceWithArguments(
151 const OUString
& ServiceSpecifier
,
152 const Sequence
< Any
>& Arguments
)
156 (void)ServiceSpecifier
;
160 cppu::OWeakObject
* p
= new TVChildTarget( m_xMSF
);
161 m_xHDS
= Reference
< XInterface
>( p
);
164 Reference
< XInterface
> ret
= m_xHDS
;
167 for( int i
= 0; i
< Arguments
.getLength(); ++i
)
170 if( ! ( Arguments
[i
] >>= pV
) )
173 if( pV
.Name
.compareToAscii( "nodepath" ) )
176 if( ! ( pV
.Value
>>= hierview
) )
182 if( !hierview
.isEmpty() )
184 Reference
< XHierarchicalNameAccess
> xhieraccess( m_xHDS
,UNO_QUERY
);
185 Any aAny
= xhieraccess
->getByHierarchicalName( hierview
);
186 Reference
< XInterface
> xInterface
;
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" );
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" );
226 Reference
< XSingleServiceFactory
> SAL_CALL
227 TVFactory::createServiceFactory(
228 const Reference
< XMultiServiceFactory
>& rxServiceMgr
)
230 return Reference
< XSingleServiceFactory
> (
231 cppu::createSingleFactory(
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
)
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 //////////////////////////////////////////////////////////////////////
275 pRet
= xFactory
.get();
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */