update credits
[LibreOffice.git] / ucb / source / ucp / hierarchy / hierarchyprovider.hxx
blob153651179de649a34757ae459ead4f5ce74b4dd3
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 #ifndef _HIERARCHYPROVIDER_HXX
21 #define _HIERARCHYPROVIDER_HXX
23 #include <boost/unordered_map.hpp>
24 #include <ucbhelper/providerhelper.hxx>
25 #include <com/sun/star/lang/XInitialization.hpp>
27 namespace com { namespace sun { namespace star {
28 namespace container {
29 class XHierarchicalNameAccess;
31 namespace util {
32 class XOfficeInstallationDirectories;
34 } } }
36 namespace hierarchy_ucp {
38 //=========================================================================
40 #define HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME \
41 "com.sun.star.ucb.HierarchyContentProvider"
42 #define HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME_LENGTH 41
44 #define HIERARCHY_URL_SCHEME \
45 "vnd.sun.star.hier"
46 #define HIERARCHY_URL_SCHEME_LENGTH 17
48 #define HIERARCHY_FOLDER_CONTENT_TYPE \
49 "application/" HIERARCHY_URL_SCHEME "-folder"
50 #define HIERARCHY_LINK_CONTENT_TYPE \
51 "application/" HIERARCHY_URL_SCHEME "-link"
53 //=========================================================================
55 struct ConfigProviderMapEntry
57 com::sun::star::uno::Reference<
58 com::sun::star::lang::XMultiServiceFactory > xConfigProvider;
59 com::sun::star::uno::Reference<
60 com::sun::star::container::XHierarchicalNameAccess > xRootReadAccess;
61 bool bTriedToGetRootReadAccess; // #82494#
63 ConfigProviderMapEntry() : bTriedToGetRootReadAccess( false ) {}
66 struct equalString
68 bool operator()(
69 const OUString& rKey1, const OUString& rKey2 ) const
71 return !!( rKey1 == rKey2 );
75 struct hashString
77 size_t operator()( const OUString & rName ) const
79 return rName.hashCode();
83 typedef boost::unordered_map
85 OUString, // servcie specifier
86 ConfigProviderMapEntry,
87 hashString,
88 equalString
90 ConfigProviderMap;
92 //=========================================================================
94 class HierarchyContentProvider : public ::ucbhelper::ContentProviderImplHelper,
95 public com::sun::star::lang::XInitialization
97 ConfigProviderMap m_aConfigProviderMap;
98 com::sun::star::uno::Reference<
99 com::sun::star::util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
101 public:
102 HierarchyContentProvider(
103 const com::sun::star::uno::Reference<
104 com::sun::star::uno::XComponentContext >& rxContext );
105 virtual ~HierarchyContentProvider();
107 // XInterface
108 XINTERFACE_DECL()
110 // XTypeProvider
111 XTYPEPROVIDER_DECL()
113 // XServiceInfo
114 XSERVICEINFO_DECL()
116 // XContentProvider
117 virtual com::sun::star::uno::Reference<
118 com::sun::star::ucb::XContent > SAL_CALL
119 queryContent( const com::sun::star::uno::Reference<
120 com::sun::star::ucb::XContentIdentifier >& Identifier )
121 throw( com::sun::star::ucb::IllegalIdentifierException,
122 com::sun::star::uno::RuntimeException );
124 // XInitialization
125 virtual void SAL_CALL
126 initialize( const ::com::sun::star::uno::Sequence<
127 ::com::sun::star::uno::Any >& aArguments )
128 throw( ::com::sun::star::uno::Exception,
129 ::com::sun::star::uno::RuntimeException );
131 // Non-Interface methods
132 com::sun::star::uno::Reference<
133 com::sun::star::lang::XMultiServiceFactory >
134 getConfigProvider( const OUString & rServiceSpecifier );
135 com::sun::star::uno::Reference<
136 com::sun::star::container::XHierarchicalNameAccess >
137 getRootConfigReadNameAccess( const OUString & rServiceSpecifier );
139 // Note: may retrun an empty reference.
140 com::sun::star::uno::Reference<
141 com::sun::star::util::XOfficeInstallationDirectories >
142 getOfficeInstallationDirectories();
145 } // namespace hierarchy_ucp
147 #endif /* !_HIERARCHYPROVIDER_HXX */
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */