Line data Source code
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 : #ifndef _HIERARCHYPROVIDER_HXX
21 : #define _HIERARCHYPROVIDER_HXX
22 :
23 : #include <boost/unordered_map.hpp>
24 : #include <ucbhelper/providerhelper.hxx>
25 : #include <com/sun/star/lang/XInitialization.hpp>
26 :
27 : namespace com { namespace sun { namespace star {
28 : namespace container {
29 : class XHierarchicalNameAccess;
30 : }
31 : namespace util {
32 : class XOfficeInstallationDirectories;
33 : }
34 : } } }
35 :
36 : namespace hierarchy_ucp {
37 :
38 : //=========================================================================
39 :
40 : #define HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME \
41 : "com.sun.star.ucb.HierarchyContentProvider"
42 : #define HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME_LENGTH 41
43 :
44 : #define HIERARCHY_URL_SCHEME \
45 : "vnd.sun.star.hier"
46 : #define HIERARCHY_URL_SCHEME_LENGTH 17
47 :
48 : #define HIERARCHY_FOLDER_CONTENT_TYPE \
49 : "application/" HIERARCHY_URL_SCHEME "-folder"
50 : #define HIERARCHY_LINK_CONTENT_TYPE \
51 : "application/" HIERARCHY_URL_SCHEME "-link"
52 :
53 : //=========================================================================
54 :
55 0 : struct ConfigProviderMapEntry
56 : {
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#
62 :
63 0 : ConfigProviderMapEntry() : bTriedToGetRootReadAccess( false ) {}
64 : };
65 :
66 : struct equalString
67 : {
68 0 : bool operator()(
69 : const rtl::OUString& rKey1, const rtl::OUString& rKey2 ) const
70 : {
71 0 : return !!( rKey1 == rKey2 );
72 : }
73 : };
74 :
75 : struct hashString
76 : {
77 0 : size_t operator()( const rtl::OUString & rName ) const
78 : {
79 0 : return rName.hashCode();
80 : }
81 : };
82 :
83 : typedef boost::unordered_map
84 : <
85 : rtl::OUString, // servcie specifier
86 : ConfigProviderMapEntry,
87 : hashString,
88 : equalString
89 : >
90 : ConfigProviderMap;
91 :
92 : //=========================================================================
93 :
94 : class HierarchyContentProvider : public ::ucbhelper::ContentProviderImplHelper,
95 : public com::sun::star::lang::XInitialization
96 : {
97 : ConfigProviderMap m_aConfigProviderMap;
98 : com::sun::star::uno::Reference<
99 : com::sun::star::util::XOfficeInstallationDirectories > m_xOfficeInstDirs;
100 :
101 : public:
102 : HierarchyContentProvider(
103 : const com::sun::star::uno::Reference<
104 : com::sun::star::uno::XComponentContext >& rxContext );
105 : virtual ~HierarchyContentProvider();
106 :
107 : // XInterface
108 : XINTERFACE_DECL()
109 :
110 : // XTypeProvider
111 : XTYPEPROVIDER_DECL()
112 :
113 : // XServiceInfo
114 : XSERVICEINFO_DECL()
115 :
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 );
123 :
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 );
130 :
131 : // Non-Interface methods
132 : com::sun::star::uno::Reference<
133 : com::sun::star::lang::XMultiServiceFactory >
134 : getConfigProvider( const rtl::OUString & rServiceSpecifier );
135 : com::sun::star::uno::Reference<
136 : com::sun::star::container::XHierarchicalNameAccess >
137 : getRootConfigReadNameAccess( const rtl::OUString & rServiceSpecifier );
138 :
139 : // Note: may retrun an empty reference.
140 : com::sun::star::uno::Reference<
141 : com::sun::star::util::XOfficeInstallationDirectories >
142 : getOfficeInstallationDirectories();
143 : };
144 :
145 : } // namespace hierarchy_ucp
146 :
147 : #endif /* !_HIERARCHYPROVIDER_HXX */
148 :
149 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|