| 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 |
#pragma once |
| 21 |
|
| 22 |
#include <ucbhelper/providerhelper.hxx> |
| 23 |
#include <com/sun/star/lang/XInitialization.hpp> |
| 24 |
#include <com/sun/star/lang/XMultiServiceFactory.hpp> |
| 25 |
#include <unordered_map> |
| 26 |
|
| 27 |
namespace com::sun::star { |
| 28 |
namespace container { |
| 29 |
class XHierarchicalNameAccess; |
| 30 |
} |
| 31 |
namespace util { |
| 32 |
class XOfficeInstallationDirectories; |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
namespace hierarchy_ucp { |
| 37 |
|
| 38 |
|
| 39 |
#define HIERARCHY_URL_SCHEME \ |
| 40 |
"vnd.sun.star.hier" |
| 41 |
#define HIERARCHY_URL_SCHEME_LENGTH 17 |
| 42 |
|
| 43 |
inline constexpr OUString HIERARCHY_FOLDER_CONTENT_TYPE = |
| 44 |
u"application/" HIERARCHY_URL_SCHEME "-folder"_ustr; |
| 45 |
inline constexpr OUString HIERARCHY_LINK_CONTENT_TYPE = |
| 46 |
u"application/" HIERARCHY_URL_SCHEME "-link"_ustr; |
| 47 |
|
| 48 |
struct ConfigProviderMapEntry |
| 49 |
{ |
| 50 |
css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider; |
| 51 |
css::uno::Reference< css::container::XHierarchicalNameAccess > xRootReadAccess; |
| 52 |
bool bTriedToGetRootReadAccess; |
| 53 |
|
| 54 |
ConfigProviderMapEntry() : bTriedToGetRootReadAccess( false ) {} |
| 55 |
}; |
| 56 |
|
| 57 |
typedef std::unordered_map |
| 58 |
< |
| 59 |
OUString, // service specifier |
| 60 |
ConfigProviderMapEntry |
| 61 |
> |
| 62 |
ConfigProviderMap; |
| 63 |
|
| 64 |
typedef cppu::ImplInheritanceHelper< ::ucbhelper::ContentProviderImplHelper, css::lang::XInitialization> HierarchyContentProvider_Base; |
| 65 |
class HierarchyContentProvider : public HierarchyContentProvider_Base |
| 66 |
{ |
| 67 |
ConfigProviderMap m_aConfigProviderMap; |
| 68 |
css::uno::Reference< css::util::XOfficeInstallationDirectories > m_xOfficeInstDirs; |
| 69 |
|
| 70 |
public: |
| 71 |
explicit HierarchyContentProvider( |
| 72 |
const css::uno::Reference< css::uno::XComponentContext >& rxContext ); |
| 73 |
virtual ~HierarchyContentProvider() override; |
| 74 |
|
| 75 |
// XServiceInfo |
| 76 |
virtual OUString SAL_CALL getImplementationName() override; |
| 77 |
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; |
| 78 |
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
| 79 |
|
| 80 |
// XContentProvider |
| 81 |
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL |
| 82 |
queryContent( const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier ) override; |
| 83 |
|
| 84 |
// XInitialization |
| 85 |
virtual void SAL_CALL |
| 86 |
initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; |
| 87 |
|
| 88 |
// Non-Interface methods |
| 89 |
css::uno::Reference< css::lang::XMultiServiceFactory > |
| 90 |
getConfigProvider( const OUString & rServiceSpecifier ); |
| 91 |
css::uno::Reference< css::container::XHierarchicalNameAccess > |
| 92 |
getRootConfigReadNameAccess( const OUString & rServiceSpecifier ); |
| 93 |
|
| 94 |
// Note: may return an empty reference. |
| 95 |
css::uno::Reference< css::util::XOfficeInstallationDirectories > |
| 96 |
getOfficeInstallationDirectories(); |
| 97 |
}; |
| 98 |
|
| 99 |
} // namespace hierarchy_ucp |
| 100 |
|
| 101 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |