LibreOffice Module xmlhelp (master) 1
tvfactory.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <com/sun/star/lang/XSingleServiceFactory.hpp>
21#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
22#include <com/sun/star/beans/PropertyValue.hpp>
27#include <tvfactory.hxx>
28#include <tvread.hxx>
29#include <utility>
30
31using namespace treeview;
32using namespace com::sun::star;
33using namespace com::sun::star::uno;
34using namespace com::sun::star::lang;
35using namespace com::sun::star::beans;
36using namespace com::sun::star::container;
37
38TVFactory::TVFactory( uno::Reference< XComponentContext > xContext )
39 : m_xContext(std::move( xContext ))
40{
41}
42
44{
45}
46
47// XServiceInfo methods.
48
49OUString SAL_CALL
51{
52 return "com.sun.star.help.TreeViewImpl";
53}
54
55sal_Bool SAL_CALL TVFactory::supportsService( const OUString& ServiceName )
56{
57 return cppu::supportsService( this, ServiceName );
58}
59
62{
63 return { "com.sun.star.help.TreeView", "com.sun.star.ucb.HiearchyDataSource" };
64}
65
66// XMultiServiceFactory
67
70 const OUString& aServiceSpecifier )
71{
72 uno::Sequence<uno::Any> seq(comphelper::InitAnyPropertySequence(
73 {
74 {"nodepath", uno::Any(OUString())}
75 }));
76
77 return createInstanceWithArguments( aServiceSpecifier, seq );
78}
79
82 const OUString& /*ServiceSpecifier*/,
83 const Sequence< Any >& Arguments )
84{
85 if( ! m_xHDS.is() )
86 {
87 m_xHDS = cppu::getXWeak(new TVChildTarget( m_xContext ));
88 }
89
90 OUString hierview;
91 for( const auto& rArgument : Arguments )
92 {
93 PropertyValue pV;
94 if( ! ( rArgument >>= pV ) )
95 continue;
96
97 if( pV.Name != "nodepath" )
98 continue;
99
100 if( ! ( pV.Value >>= hierview ) )
101 continue;
102
103 break;
104 }
105
106 if( !hierview.isEmpty() )
107 {
108 Reference< XHierarchicalNameAccess > xhieraccess( m_xHDS,UNO_QUERY );
109 Any aAny = xhieraccess->getByHierarchicalName( hierview );
110 Reference< XInterface > xInterface;
111 aAny >>= xInterface;
112 return xInterface;
113 }
114 else
115 return m_xHDS;
116}
117
120{
121 return { "com.sun.star.ucb.HierarchyDataReadAccess" };
122}
123
124extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
126 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
127{
128 return cppu::acquire(new TVFactory(context));
129}
130
131
132/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XComponentContext > m_xContext
css::uno::Reference< css::uno::XInterface > m_xHDS
Definition: tvfactory.hxx:71
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: tvfactory.cxx:119
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: tvfactory.cxx:55
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: tvfactory.hxx:70
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(const OUString &aServiceSpecifier) override
Definition: tvfactory.cxx:69
virtual OUString SAL_CALL getImplementationName() override
Definition: tvfactory.cxx:50
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(const OUString &ServiceSpecifier, const css::uno::Sequence< css::uno::Any > &Arguments) override
Definition: tvfactory.cxx:81
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: tvfactory.cxx:61
virtual ~TVFactory() override
Definition: tvfactory.cxx:43
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_help_TreeViewImpl_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: tvfactory.cxx:125
unsigned char sal_Bool