Don't link against private CoreUI framework when sandboxed
[LibreOffice.git] / xmlhelp / source / treeview / tvfactory.cxx
blobec2790032b6dfbf27bcc98b41440018e7b54c9fe
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 .
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>
28 #include <tvread.hxx>
30 using namespace treeview;
31 using namespace com::sun::star;
32 using namespace com::sun::star::uno;
33 using namespace com::sun::star::lang;
34 using namespace com::sun::star::beans;
35 using namespace com::sun::star::container;
37 TVFactory::TVFactory( const uno::Reference< XComponentContext >& xContext )
38 : m_xContext( xContext )
42 TVFactory::~TVFactory()
46 // XServiceInfo methods.
48 OUString SAL_CALL
49 TVFactory::getImplementationName()
51 return "com.sun.star.help.TreeViewImpl";
54 sal_Bool SAL_CALL TVFactory::supportsService( const OUString& ServiceName )
56 return cppu::supportsService( this, ServiceName );
59 Sequence< OUString > SAL_CALL
60 TVFactory::getSupportedServiceNames()
62 return { "com.sun.star.help.TreeView", "com.sun.star.ucb.HiearchyDataSource" };
65 // XMultiServiceFactory
67 Reference< XInterface > SAL_CALL
68 TVFactory::createInstance(
69 const OUString& aServiceSpecifier )
71 uno::Sequence<uno::Any> seq(comphelper::InitAnyPropertySequence(
73 {"nodepath", uno::Any(OUString())}
74 }));
76 return createInstanceWithArguments( aServiceSpecifier, seq );
79 Reference< XInterface > SAL_CALL
80 TVFactory::createInstanceWithArguments(
81 const OUString& /*ServiceSpecifier*/,
82 const Sequence< Any >& Arguments )
84 if( ! m_xHDS.is() )
86 m_xHDS = static_cast<cppu::OWeakObject*>(new TVChildTarget( m_xContext ));
89 OUString hierview;
90 for( const auto& rArgument : Arguments )
92 PropertyValue pV;
93 if( ! ( rArgument >>= pV ) )
94 continue;
96 if( pV.Name != "nodepath" )
97 continue;
99 if( ! ( pV.Value >>= hierview ) )
100 continue;
102 break;
105 if( !hierview.isEmpty() )
107 Reference< XHierarchicalNameAccess > xhieraccess( m_xHDS,UNO_QUERY );
108 Any aAny = xhieraccess->getByHierarchicalName( hierview );
109 Reference< XInterface > xInterface;
110 aAny >>= xInterface;
111 return xInterface;
113 else
114 return m_xHDS;
117 Sequence< OUString > SAL_CALL
118 TVFactory::getAvailableServiceNames( )
120 return { "com.sun.star.ucb.HierarchyDataReadAccess" };
123 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
124 com_sun_star_help_TreeViewImpl_get_implementation(
125 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
127 return cppu::acquire(new TVFactory(context));
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */