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 .
20 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
21 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
22 #include <com/sun/star/beans/PropertyValue.hpp>
23 #include <comphelper/processfactory.hxx>
24 #include <comphelper/propertysequence.hxx>
25 #include <cppuhelper/supportsservice.hxx>
26 #include <cppuhelper/factory.hxx>
27 #include <tvfactory.hxx>
31 using namespace treeview
;
32 using namespace com::sun::star
;
33 using namespace com::sun::star::uno
;
34 using namespace com::sun::star::lang
;
35 using namespace com::sun::star::beans
;
36 using namespace com::sun::star::container
;
38 TVFactory::TVFactory( uno::Reference
< XComponentContext
> xContext
)
39 : m_xContext(std::move( xContext
))
43 TVFactory::~TVFactory()
47 // XServiceInfo methods.
50 TVFactory::getImplementationName()
52 return "com.sun.star.help.TreeViewImpl";
55 sal_Bool SAL_CALL
TVFactory::supportsService( const OUString
& ServiceName
)
57 return cppu::supportsService( this, ServiceName
);
60 Sequence
< OUString
> SAL_CALL
61 TVFactory::getSupportedServiceNames()
63 return { "com.sun.star.help.TreeView", "com.sun.star.ucb.HiearchyDataSource" };
66 // XMultiServiceFactory
68 Reference
< XInterface
> SAL_CALL
69 TVFactory::createInstance(
70 const OUString
& aServiceSpecifier
)
72 uno::Sequence
<uno::Any
> seq(comphelper::InitAnyPropertySequence(
74 {"nodepath", uno::Any(OUString())}
77 return createInstanceWithArguments( aServiceSpecifier
, seq
);
80 Reference
< XInterface
> SAL_CALL
81 TVFactory::createInstanceWithArguments(
82 const OUString
& /*ServiceSpecifier*/,
83 const Sequence
< Any
>& Arguments
)
87 m_xHDS
= cppu::getXWeak(new TVChildTarget( m_xContext
));
91 for( const auto& rArgument
: Arguments
)
94 if( ! ( rArgument
>>= pV
) )
97 if( pV
.Name
!= "nodepath" )
100 if( ! ( pV
.Value
>>= hierview
) )
106 if( !hierview
.isEmpty() )
108 Reference
< XHierarchicalNameAccess
> xhieraccess( m_xHDS
,UNO_QUERY
);
109 Any aAny
= xhieraccess
->getByHierarchicalName( hierview
);
110 Reference
< XInterface
> xInterface
;
118 Sequence
< OUString
> SAL_CALL
119 TVFactory::getAvailableServiceNames( )
121 return { "com.sun.star.ucb.HierarchyDataReadAccess" };
124 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
125 com_sun_star_help_TreeViewImpl_get_implementation(
126 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const&)
128 return cppu::acquire(new TVFactory(context
));
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */