LibreOffice Module xmlhelp (master) 1
tvread.hxx
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#pragma once
21
22#include <mutex>
23#include <vector>
24#include <rtl/ref.hxx>
25#include <rtl/ustring.hxx>
26#include <com/sun/star/uno/Type.hxx>
27#include <com/sun/star/uno/XComponentContext.hpp>
28#include <com/sun/star/container/XNameAccess.hpp>
29#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
30#include <com/sun/star/util/XChangesNotifier.hpp>
31#include <com/sun/star/lang/XComponent.hpp>
32#include <com/sun/star/lang/XMultiServiceFactory.hpp>
33#include <com/sun/star/deployment/XPackage.hpp>
34#include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
36#include <memory>
37
38namespace treeview {
39
41 {
42 public:
43 enum {
46 ConfigData();
47 int m_vAdd[5] = {};
48 OUString m_vReplacement[5];
49
50 std::vector< sal_uInt64 > vFileLen;
51 std::vector< OUString > vFileURL;
52 OUString locale,system;
53 OUString appendix;
54
55 void replaceName( OUString& oustring ) const;
56 };
57
58 class TVDom;
59 class TVChildTarget;
60
61 class TVBase : public cppu::WeakImplHelper <
62 css::container::XNameAccess,
63 css::container::XHierarchicalNameAccess,
64 css::util::XChangesNotifier,
65 css::lang::XComponent >
66 {
67 friend class TVChildTarget;
68
69 public:
70
71 // XNameAccess
72
73 virtual css::uno::Type SAL_CALL
74 getElementType( ) override
75 {
77 }
78
79 virtual sal_Bool SAL_CALL hasElements() override
80 {
81 return true;
82 }
83
84 // XChangesNotifier
85
86 virtual void SAL_CALL
88 const css::uno::Reference< css::util::XChangesListener >& ) override
89 {
90 // read only
91 }
92
93 virtual void SAL_CALL
95 const css::uno::Reference< css::util::XChangesListener >& ) override
96 {
97 // read only
98 }
99
100 // XComponent
101
102 virtual void SAL_CALL dispose( ) override
103 {
104 }
105
106 virtual void SAL_CALL addEventListener(
107 const css::uno::Reference< css::lang::XEventListener >& ) override
108 {}
109
110 virtual void SAL_CALL
112 const css::uno::Reference< css::lang::XEventListener >& ) override
113 {}
114
115 // Abstract functions
116 // XNameAccess
117
118 virtual css::uno::Any SAL_CALL
119 getByName( const OUString& aName ) override = 0;
120
121 virtual css::uno::Sequence< OUString > SAL_CALL
122 getElementNames( ) override = 0;
123
124 virtual sal_Bool SAL_CALL
125 hasByName( const OUString& aName ) override = 0;
126
127 // XHierarchicalNameAccess
128
129 virtual css::uno::Any SAL_CALL
130 getByHierarchicalName( const OUString& aName ) override = 0;
131
132 virtual sal_Bool SAL_CALL
133 hasByHierarchicalName( const OUString& aName ) override = 0;
134
135 }; // end class TVBase
136
137 class TVRead final
138 : public TVBase
139 {
140 friend class TVChildTarget;
141
142 public:
143 TVRead( const ConfigData& configData, TVDom* tvDom );
144
145 virtual ~TVRead() override;
146
147 // XNameAccess
148
149 virtual css::uno::Any SAL_CALL
150 getByName( const OUString& aName ) override;
151
152 virtual css::uno::Sequence< OUString > SAL_CALL
153 getElementNames( ) override;
154
155 virtual sal_Bool SAL_CALL
156 hasByName( const OUString& aName ) override;
157
158 // XHierarchicalNameAccess
159
160 virtual css::uno::Any SAL_CALL
161 getByHierarchicalName( const OUString& aName ) override;
162
163 virtual sal_Bool SAL_CALL
164 hasByHierarchicalName( const OUString& aName ) override;
165
166 private:
167
168 OUString Title;
169 OUString TargetURL;
171
172 }; // end class TVRead
173
175 : public TVBase
176 {
177 public:
178
179 TVChildTarget( const ConfigData& configData,TVDom* tvDom );
180
181 TVChildTarget( const css::uno::Reference< css::uno::XComponentContext >& xContext );
182
183 virtual ~TVChildTarget() override;
184
185 virtual css::uno::Any SAL_CALL
186 getByName( const OUString& aName ) override;
187
188 virtual css::uno::Sequence< OUString > SAL_CALL
189 getElementNames( ) override;
190
191 virtual sal_Bool SAL_CALL
192 hasByName( const OUString& aName ) override;
193
194 // XHierarchicalNameAccess
195
196 virtual css::uno::Any SAL_CALL
197 getByHierarchicalName( const OUString& aName ) override;
198
199 virtual sal_Bool SAL_CALL
200 hasByHierarchicalName( const OUString& aName ) override;
201
202 private:
203 std::vector< rtl::Reference< TVRead > > Elements;
204
205 static ConfigData init(
206 const css::uno::Reference< css::uno::XComponentContext >& xContext );
207
208 static css::uno::Reference< css::lang::XMultiServiceFactory >
210 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
211
212 static css::uno::Reference< css::container::XHierarchicalNameAccess >
213 getHierAccess( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxProvider,
214 const char* file );
215
216 static OUString
217 getKey( const css::uno::Reference< css::container::XHierarchicalNameAccess >& xHierAccess,
218 const char* key );
219
220 static bool
222 const css::uno::Reference< css::container::XHierarchicalNameAccess >& xHierAccess,
223 const char* key);
224
225 static void subst( OUString& instpath );
226
227 std::unique_ptr<TVDom> SearchAndInsert(std::unique_ptr<TVDom> p, TVDom* tvDom);
228
229 void Check(TVDom* tvDom);
230
231 }; // end class TVChildTarget
232
233 enum class IteratorState
234 {
239 };
240
242 {
243 public:
244 TreeFileIterator( OUString aLanguage );
245 OUString nextTreeFile( sal_Int32& rnFileSize );
246
247 private:
248 static css::uno::Reference< css::deployment::XPackage > implGetHelpPackageFromPackage
249 ( const css::uno::Reference< css::deployment::XPackage >& xPackage,
250 css::uno::Reference< css::deployment::XPackage >& o_xParentPackageBundle );
251
252 css::uno::Reference< css::deployment::XPackage > implGetNextUserHelpPackage
253 ( css::uno::Reference< css::deployment::XPackage >& o_xParentPackageBundle );
254 css::uno::Reference< css::deployment::XPackage > implGetNextSharedHelpPackage
255 ( css::uno::Reference< css::deployment::XPackage >& o_xParentPackageBundle );
256 css::uno::Reference< css::deployment::XPackage > implGetNextBundledHelpPackage
257 ( css::uno::Reference< css::deployment::XPackage >& o_xParentPackageBundle );
258
259 void implGetLanguageVectorFromPackage( ::std::vector< OUString > &rv,
260 const css::uno::Reference< css::deployment::XPackage >& xPackage );
261
262 std::mutex m_aMutex;
263 css::uno::Reference< css::uno::XComponentContext > m_xContext;
264 css::uno::Reference< css::ucb::XSimpleFileAccess3 > m_xSFA;
265
267 OUString m_aLanguage;
268
269 css::uno::Sequence< css::uno::Reference
270 < css::deployment::XPackage > > m_aUserPackagesSeq;
272
273 css::uno::Sequence< css::uno::Reference
274 < css::deployment::XPackage > > m_aSharedPackagesSeq;
276
277 css::uno::Sequence< css::uno::Reference
278 < css::deployment::XPackage > > m_aBundledPackagesSeq;
280
284
285 OUString expandURL( const OUString& aURL );
286 OUString implGetTreeFileFromPackage( sal_Int32& rnFileSize,
287 const css::uno::Reference< css::deployment::XPackage >& xPackage );
288
289 }; // end class TreeFileIterator
290
291}
292
293/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Type const & get()
void replaceName(OUString &oustring) const
Definition: tvread.cxx:170
std::vector< OUString > vFileURL
Definition: tvread.hxx:51
OUString appendix
Definition: tvread.hxx:53
std::vector< sal_uInt64 > vFileLen
Definition: tvread.hxx:50
OUString m_vReplacement[5]
Definition: tvread.hxx:48
virtual void SAL_CALL dispose() override
Definition: tvread.hxx:102
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &) override
Definition: tvread.hxx:106
virtual css::uno::Type SAL_CALL getElementType() override
Definition: tvread.hxx:74
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override=0
virtual css::uno::Any SAL_CALL getByHierarchicalName(const OUString &aName) override=0
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override=0
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &) override
Definition: tvread.hxx:111
virtual void SAL_CALL removeChangesListener(const css::uno::Reference< css::util::XChangesListener > &) override
Definition: tvread.hxx:94
friend class TVChildTarget
Definition: tvread.hxx:67
virtual sal_Bool SAL_CALL hasElements() override
Definition: tvread.hxx:79
virtual void SAL_CALL addChangesListener(const css::uno::Reference< css::util::XChangesListener > &) override
Definition: tvread.hxx:87
virtual sal_Bool SAL_CALL hasByHierarchicalName(const OUString &aName) override=0
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override=0
static css::uno::Reference< css::container::XHierarchicalNameAccess > getHierAccess(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxProvider, const char *file)
Definition: tvread.cxx:755
static void subst(OUString &instpath)
Definition: tvread.cxx:821
virtual css::uno::Any SAL_CALL getByHierarchicalName(const OUString &aName) override
Definition: tvread.cxx:539
std::unique_ptr< TVDom > SearchAndInsert(std::unique_ptr< TVDom > p, TVDom *tvDom)
Definition: tvread.cxx:453
virtual ~TVChildTarget() override
Definition: tvread.cxx:415
void Check(TVDom *tvDom)
Definition: tvread.cxx:419
static OUString getKey(const css::uno::Reference< css::container::XHierarchicalNameAccess > &xHierAccess, const char *key)
Definition: tvread.cxx:778
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: tvread.cxx:503
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: tvread.cxx:515
static css::uno::Reference< css::lang::XMultiServiceFactory > getConfiguration(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Definition: tvread.cxx:736
static ConfigData init(const css::uno::Reference< css::uno::XComponentContext > &xContext)
Definition: tvread.cxx:575
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: tvread.cxx:526
virtual sal_Bool SAL_CALL hasByHierarchicalName(const OUString &aName) override
Definition: tvread.cxx:558
std::vector< rtl::Reference< TVRead > > Elements
Definition: tvread.hxx:203
static bool getBooleanKey(const css::uno::Reference< css::container::XHierarchicalNameAccess > &xHierAccess, const char *key)
Definition: tvread.cxx:799
TVChildTarget(const css::uno::Reference< css::uno::XComponentContext > &xContext)
TVRead(const ConfigData &configData, TVDom *tvDom)
Definition: tvread.cxx:215
virtual css::uno::Any SAL_CALL getByHierarchicalName(const OUString &aName) override
Definition: tvread.cxx:281
virtual ~TVRead() override
Definition: tvread.cxx:232
OUString TargetURL
Definition: tvread.hxx:169
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: tvread.cxx:239
rtl::Reference< TVChildTarget > Children
Definition: tvread.hxx:170
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: tvread.cxx:262
OUString Title
Definition: tvread.hxx:168
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: tvread.cxx:268
virtual sal_Bool SAL_CALL hasByHierarchicalName(const OUString &aName) override
Definition: tvread.cxx:291
TreeFileIterator(OUString aLanguage)
Definition: tvread.cxx:830
css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > m_aSharedPackagesSeq
Definition: tvread.hxx:274
OUString expandURL(const OUString &aURL)
Definition: tvread.cxx:1073
css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > m_aBundledPackagesSeq
Definition: tvread.hxx:278
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: tvread.hxx:263
OUString nextTreeFile(sal_Int32 &rnFileSize)
Definition: tvread.cxx:1024
css::uno::Reference< css::deployment::XPackage > implGetNextSharedHelpPackage(css::uno::Reference< css::deployment::XPackage > &o_xParentPackageBundle)
Definition: tvread.cxx:930
static css::uno::Reference< css::deployment::XPackage > implGetHelpPackageFromPackage(const css::uno::Reference< css::deployment::XPackage > &xPackage, css::uno::Reference< css::deployment::XPackage > &o_xParentPackageBundle)
Definition: tvread.cxx:851
css::uno::Reference< css::deployment::XPackage > implGetNextUserHelpPackage(css::uno::Reference< css::deployment::XPackage > &o_xParentPackageBundle)
Definition: tvread.cxx:900
void implGetLanguageVectorFromPackage(::std::vector< OUString > &rv, const css::uno::Reference< css::deployment::XPackage > &xPackage)
Definition: tvread.cxx:994
css::uno::Reference< css::deployment::XPackage > implGetNextBundledHelpPackage(css::uno::Reference< css::deployment::XPackage > &o_xParentPackageBundle)
Definition: tvread.cxx:960
css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > m_aUserPackagesSeq
Definition: tvread.hxx:270
IteratorState m_eState
Definition: tvread.hxx:266
css::uno::Reference< css::ucb::XSimpleFileAccess3 > m_xSFA
Definition: tvread.hxx:264
OUString implGetTreeFileFromPackage(sal_Int32 &rnFileSize, const css::uno::Reference< css::deployment::XPackage > &xPackage)
Definition: tvread.cxx:1105
IteratorState
Definition: tvread.hxx:234
unsigned char sal_Bool