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 SCRIPTING_DLGPROV_HXX
21 : #define SCRIPTING_DLGPROV_HXX
22 :
23 : #include <com/sun/star/resource/XStringResourceWithStorage.hpp>
24 : #include <com/sun/star/resource/XStringResourceWithLocation.hpp>
25 : #include <com/sun/star/lang/XServiceInfo.hpp>
26 : #include <com/sun/star/lang/XInitialization.hpp>
27 : #include <com/sun/star/uno/XComponentContext.hpp>
28 : #include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
29 : #include <com/sun/star/io/XInputStream.hpp>
30 : #include <com/sun/star/io/XOutputStream.hpp>
31 : #include <cppuhelper/implbase1.hxx>
32 : #include <cppuhelper/implbase2.hxx>
33 : #include <cppuhelper/interfacecontainer.hxx>
34 : #include <osl/mutex.hxx>
35 :
36 : #include <vector>
37 : #include <boost/unordered_map.hpp>
38 :
39 :
40 : namespace stringresource
41 : {
42 :
43 :
44 :
45 : // mutex
46 :
47 :
48 : ::osl::Mutex& getMutex();
49 :
50 :
51 :
52 : // class stringresourceImpl
53 :
54 :
55 : // Hashtable to map string ids to string
56 : struct hashName_Impl
57 : {
58 0 : size_t operator()(const OUString& Str) const
59 : {
60 0 : return (size_t)Str.hashCode();
61 : }
62 : };
63 :
64 : struct eqName_Impl
65 : {
66 0 : sal_Bool operator()(const OUString& Str1, const OUString& Str2) const
67 : {
68 0 : return ( Str1 == Str2 );
69 : }
70 : };
71 :
72 : typedef boost::unordered_map
73 : <
74 : OUString,
75 : OUString,
76 : hashName_Impl,
77 : eqName_Impl
78 : >
79 : IdToStringMap;
80 :
81 : typedef boost::unordered_map
82 : <
83 : OUString,
84 : sal_Int32,
85 : hashName_Impl,
86 : eqName_Impl
87 : >
88 : IdToIndexMap;
89 :
90 :
91 0 : struct LocaleItem
92 : {
93 : ::com::sun::star::lang::Locale m_locale;
94 : IdToStringMap m_aIdToStringMap;
95 : IdToIndexMap m_aIdToIndexMap;
96 : sal_Int32 m_nNextIndex;
97 : bool m_bLoaded;
98 : bool m_bModified;
99 :
100 0 : LocaleItem( ::com::sun::star::lang::Locale locale, bool bLoaded=true )
101 : : m_locale( locale )
102 : , m_nNextIndex( 0 )
103 : , m_bLoaded( bLoaded )
104 0 : , m_bModified( false )
105 0 : {}
106 : };
107 :
108 : typedef std::vector< LocaleItem* > LocaleItemVector;
109 : typedef std::vector< LocaleItem* >::iterator LocaleItemVectorIt;
110 : typedef std::vector< LocaleItem* >::const_iterator LocaleItemVectorConstIt;
111 :
112 : typedef ::cppu::WeakImplHelper2<
113 : ::com::sun::star::lang::XServiceInfo,
114 : ::com::sun::star::resource::XStringResourceManager > StringResourceImpl_BASE;
115 :
116 : class StringResourceImpl : public StringResourceImpl_BASE
117 : {
118 : protected:
119 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
120 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > m_xMCF;
121 :
122 : LocaleItem* m_pCurrentLocaleItem;
123 : LocaleItem* m_pDefaultLocaleItem;
124 : bool m_bDefaultModified;
125 :
126 : ::cppu::OInterfaceContainerHelper m_aListenerContainer;
127 :
128 : LocaleItemVector m_aLocaleItemVector;
129 : LocaleItemVector m_aDeletedLocaleItemVector;
130 : LocaleItemVector m_aChangedDefaultLocaleVector;
131 :
132 : bool m_bModified;
133 : bool m_bReadOnly;
134 :
135 : sal_Int32 m_nNextUniqueNumericId;
136 :
137 : // Scans ResourceID to start with number and adapt m_nNextUniqueNumericId
138 : void implScanIdForNumber( const OUString& ResourceID );
139 : const static sal_Int32 UNIQUE_NUMBER_NEEDS_INITIALISATION = -1;
140 :
141 : // Checks read only status and throws exception if it's true
142 : void implCheckReadOnly( const sal_Char* pExceptionMsg )
143 : throw (::com::sun::star::lang::NoSupportException);
144 :
145 : // Return the context's MultiComponentFactory
146 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory >
147 : getMultiComponentFactory( void );
148 :
149 : // Returns the LocalItem for a given locale, if it exists, otherwise NULL
150 : // This method compares the locales exactly, no closest match search is performed
151 : LocaleItem* getItemForLocale( const ::com::sun::star::lang::Locale& locale, sal_Bool bException )
152 : throw (::com::sun::star::lang::IllegalArgumentException);
153 :
154 : // Returns the LocalItem for a given locale, if it exists, otherwise NULL
155 : // This method performes a closest match search, at least the language must match
156 : LocaleItem* getClosestMatchItemForLocale( const ::com::sun::star::lang::Locale& locale );
157 : void implSetCurrentLocale( const ::com::sun::star::lang::Locale& locale,
158 : sal_Bool FindClosestMatch, sal_Bool bUseDefaultIfNoMatch )
159 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
160 :
161 : void implModified( void );
162 : void implNotifyListeners( void );
163 :
164 : //=== Impl methods for ...ForLocale methods ===
165 : OUString SAL_CALL implResolveString( const OUString& ResourceID, LocaleItem* pLocaleItem )
166 : throw (::com::sun::star::resource::MissingResourceException);
167 : sal_Bool implHasEntryForId( const OUString& ResourceID, LocaleItem* pLocaleItem );
168 : ::com::sun::star::uno::Sequence< OUString > implGetResourceIDs( LocaleItem* pLocaleItem );
169 : void implSetString( const OUString& ResourceID,
170 : const OUString& Str, LocaleItem* pLocaleItem );
171 : void implRemoveId( const OUString& ResourceID, LocaleItem* pLocaleItem )
172 : throw (::com::sun::star::resource::MissingResourceException);
173 :
174 : // Method to load a locale if necessary, returns true if loading was
175 : // successful. Default implementation in base class just returns true.
176 : virtual bool loadLocale( LocaleItem* pLocaleItem );
177 :
178 : virtual void implLoadAllLocales( void );
179 :
180 : public:
181 : StringResourceImpl(
182 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
183 : virtual ~StringResourceImpl();
184 :
185 : // XServiceInfo
186 : virtual OUString SAL_CALL getImplementationName( )
187 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
188 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
189 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
190 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
191 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
192 :
193 : // XModifyBroadcaster
194 : virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
195 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
196 : virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
197 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
198 :
199 : // XStringResourceResolver
200 : virtual OUString SAL_CALL resolveString( const OUString& ResourceID )
201 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
202 : virtual OUString SAL_CALL resolveStringForLocale( const OUString& ResourceID,
203 : const ::com::sun::star::lang::Locale& locale )
204 : throw ( ::com::sun::star::resource::MissingResourceException,
205 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
206 : virtual sal_Bool SAL_CALL hasEntryForId( const OUString& ResourceID )
207 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
208 : virtual sal_Bool SAL_CALL hasEntryForIdAndLocale( const OUString& ResourceID,
209 : const ::com::sun::star::lang::Locale& locale )
210 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
211 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getResourceIDs( )
212 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
213 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getResourceIDsForLocale
214 : ( const ::com::sun::star::lang::Locale& locale )
215 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
216 : virtual ::com::sun::star::lang::Locale SAL_CALL getCurrentLocale( )
217 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
218 : virtual ::com::sun::star::lang::Locale SAL_CALL getDefaultLocale( )
219 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
220 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales( )
221 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
222 :
223 : // XStringResourceManager
224 : virtual sal_Bool SAL_CALL isReadOnly()
225 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
226 : virtual void SAL_CALL setCurrentLocale( const ::com::sun::star::lang::Locale& locale, sal_Bool FindClosestMatch )
227 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
228 : virtual void SAL_CALL setDefaultLocale( const ::com::sun::star::lang::Locale& locale )
229 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException,
230 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
231 : virtual void SAL_CALL setString( const OUString& ResourceID, const OUString& Str )
232 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
233 : virtual void SAL_CALL setStringForLocale( const OUString& ResourceID, const OUString& Str,
234 : const ::com::sun::star::lang::Locale& locale )
235 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
236 : virtual void SAL_CALL removeId( const OUString& ResourceID )
237 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException,
238 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
239 : virtual void SAL_CALL removeIdForLocale( const OUString& ResourceID,
240 : const ::com::sun::star::lang::Locale& locale )
241 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException,
242 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
243 : virtual void SAL_CALL newLocale( const ::com::sun::star::lang::Locale& locale )
244 : throw (::com::sun::star::container::ElementExistException, ::com::sun::star::lang::IllegalArgumentException,
245 : ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
246 : virtual void SAL_CALL removeLocale( const ::com::sun::star::lang::Locale& locale )
247 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException,
248 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
249 : virtual ::sal_Int32 SAL_CALL getUniqueNumericId( )
250 : throw (::com::sun::star::lang::NoSupportException,
251 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
252 : };
253 :
254 : typedef ::cppu::ImplInheritanceHelper1<
255 : StringResourceImpl,
256 : ::com::sun::star::resource::XStringResourcePersistence > StringResourcePersistenceImpl_BASE;
257 :
258 : class BinaryOutput;
259 :
260 : class StringResourcePersistenceImpl : public StringResourcePersistenceImpl_BASE
261 : {
262 : protected:
263 : OUString m_aNameBase;
264 : OUString m_aComment;
265 :
266 : void SAL_CALL implInitializeCommonParameters
267 : ( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
268 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
269 :
270 : // Scan locale properties files
271 : virtual void implScanLocales( void );
272 :
273 : // Method to load a locale if necessary, returns true if loading was successful
274 : virtual bool loadLocale( LocaleItem* pLocaleItem ) SAL_OVERRIDE;
275 :
276 : // does the actual loading
277 : virtual bool implLoadLocale( LocaleItem* pLocaleItem );
278 :
279 : virtual void implLoadAllLocales( void ) SAL_OVERRIDE;
280 :
281 : void implScanLocaleNames( const ::com::sun::star::uno::Sequence< OUString >& aContentSeq );
282 : OUString implGetFileNameForLocaleItem( LocaleItem* pLocaleItem, const OUString& aNameBase );
283 : OUString implGetPathForLocaleItem( LocaleItem* pLocaleItem, const OUString& aNameBase,
284 : const OUString& aLocation, bool bDefaultFile=false );
285 :
286 : bool implReadPropertiesFile( LocaleItem* pLocaleItem,
287 : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput );
288 :
289 : bool implWritePropertiesFile( LocaleItem* pLocaleItem, const ::com::sun::star::uno::Reference
290 : < ::com::sun::star::io::XOutputStream >& xOutputStream, const OUString& aComment );
291 :
292 : void implWriteLocaleBinary( LocaleItem* pLocaleItem, BinaryOutput& rOut );
293 :
294 : void implStoreAtStorage
295 : (
296 : const OUString& aNameBase,
297 : const OUString& aComment,
298 : const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage,
299 : bool bUsedForStore,
300 : bool bStoreAll
301 : )
302 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
303 :
304 : void implKillRemovedLocaleFiles
305 : (
306 : const OUString& Location,
307 : const OUString& aNameBase,
308 : const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& xFileAccess
309 : )
310 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
311 :
312 : void implKillChangedDefaultFiles
313 : (
314 : const OUString& Location,
315 : const OUString& aNameBase,
316 : const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& xFileAccess
317 : )
318 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
319 :
320 : void implStoreAtLocation
321 : (
322 : const OUString& Location,
323 : const OUString& aNameBase,
324 : const OUString& aComment,
325 : const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 >& xFileAccess,
326 : bool bUsedForStore,
327 : bool bStoreAll,
328 : bool bKillAll = false
329 : )
330 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
331 :
332 : public:
333 : StringResourcePersistenceImpl(
334 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
335 : virtual ~StringResourcePersistenceImpl();
336 :
337 : // XServiceInfo
338 : virtual OUString SAL_CALL getImplementationName( )
339 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
340 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
341 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
342 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
343 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
344 :
345 : // XModifyBroadcaster
346 : virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
347 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
348 : virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
349 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
350 :
351 : // XStringResourceResolver
352 : virtual OUString SAL_CALL resolveString( const OUString& ResourceID )
353 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
354 : virtual OUString SAL_CALL resolveStringForLocale( const OUString& ResourceID,
355 : const ::com::sun::star::lang::Locale& locale )
356 : throw ( ::com::sun::star::resource::MissingResourceException,
357 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
358 : virtual sal_Bool SAL_CALL hasEntryForId( const OUString& ResourceID )
359 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
360 : virtual sal_Bool SAL_CALL hasEntryForIdAndLocale( const OUString& ResourceID,
361 : const ::com::sun::star::lang::Locale& locale )
362 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
363 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getResourceIDs( )
364 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
365 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getResourceIDsForLocale
366 : ( const ::com::sun::star::lang::Locale& locale )
367 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
368 : virtual ::com::sun::star::lang::Locale SAL_CALL getCurrentLocale( )
369 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
370 : virtual ::com::sun::star::lang::Locale SAL_CALL getDefaultLocale( )
371 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
372 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales( )
373 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
374 :
375 : // XStringResourceManager
376 : virtual sal_Bool SAL_CALL isReadOnly()
377 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
378 : virtual void SAL_CALL setCurrentLocale( const ::com::sun::star::lang::Locale& locale, sal_Bool FindClosestMatch )
379 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
380 : virtual void SAL_CALL setDefaultLocale( const ::com::sun::star::lang::Locale& locale )
381 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException,
382 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
383 : virtual void SAL_CALL setString( const OUString& ResourceID, const OUString& Str )
384 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
385 : virtual void SAL_CALL setStringForLocale( const OUString& ResourceID, const OUString& Str,
386 : const ::com::sun::star::lang::Locale& locale )
387 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
388 : virtual void SAL_CALL removeId( const OUString& ResourceID )
389 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException,
390 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
391 : virtual void SAL_CALL removeIdForLocale( const OUString& ResourceID,
392 : const ::com::sun::star::lang::Locale& locale )
393 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException,
394 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
395 : virtual void SAL_CALL newLocale( const ::com::sun::star::lang::Locale& locale )
396 : throw (::com::sun::star::container::ElementExistException, ::com::sun::star::lang::IllegalArgumentException,
397 : ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
398 : virtual void SAL_CALL removeLocale( const ::com::sun::star::lang::Locale& locale )
399 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException,
400 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
401 : virtual ::sal_Int32 SAL_CALL getUniqueNumericId( )
402 : throw (::com::sun::star::lang::NoSupportException,
403 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
404 :
405 : // XStringResourcePersistence
406 : virtual void SAL_CALL store( )
407 : throw (::com::sun::star::lang::NoSupportException,
408 : ::com::sun::star::uno::Exception,
409 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
410 : virtual sal_Bool SAL_CALL isModified( )
411 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
412 : virtual void SAL_CALL setComment( const OUString& Comment )
413 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
414 : virtual void SAL_CALL storeToStorage
415 : ( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage,
416 : const OUString& NameBase, const OUString& Comment )
417 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
418 : virtual void SAL_CALL storeToURL( const OUString& URL, const OUString& NameBase,
419 : const OUString& Comment, const ::com::sun::star::uno::Reference
420 : < ::com::sun::star::task::XInteractionHandler >& Handler )
421 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
422 : virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL exportBinary( )
423 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
424 : virtual void SAL_CALL importBinary( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& Data )
425 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
426 : };
427 :
428 :
429 : typedef ::cppu::ImplInheritanceHelper2<
430 : StringResourcePersistenceImpl,
431 : ::com::sun::star::lang::XInitialization,
432 : ::com::sun::star::resource::XStringResourceWithStorage > StringResourceWithStorageImpl_BASE;
433 :
434 : class StringResourceWithStorageImpl : public StringResourceWithStorageImpl_BASE
435 : {
436 : ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > m_xStorage;
437 : bool m_bStorageChanged;
438 :
439 : virtual void implScanLocales( void ) SAL_OVERRIDE;
440 : virtual bool implLoadLocale( LocaleItem* pLocaleItem ) SAL_OVERRIDE;
441 :
442 : public:
443 : StringResourceWithStorageImpl(
444 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
445 : virtual ~StringResourceWithStorageImpl();
446 :
447 : // XServiceInfo
448 : virtual OUString SAL_CALL getImplementationName( )
449 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
450 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
451 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
452 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
453 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
454 :
455 : // XInitialization
456 : virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
457 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
458 :
459 : // XModifyBroadcaster
460 : virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
461 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
462 : virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
463 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
464 :
465 : // XStringResourceResolver
466 : virtual OUString SAL_CALL resolveString( const OUString& ResourceID )
467 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
468 : virtual OUString SAL_CALL resolveStringForLocale( const OUString& ResourceID,
469 : const ::com::sun::star::lang::Locale& locale )
470 : throw ( ::com::sun::star::resource::MissingResourceException,
471 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
472 : virtual sal_Bool SAL_CALL hasEntryForId( const OUString& ResourceID )
473 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
474 : virtual sal_Bool SAL_CALL hasEntryForIdAndLocale( const OUString& ResourceID,
475 : const ::com::sun::star::lang::Locale& locale )
476 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
477 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getResourceIDs( )
478 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
479 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getResourceIDsForLocale
480 : ( const ::com::sun::star::lang::Locale& locale )
481 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
482 : virtual ::com::sun::star::lang::Locale SAL_CALL getCurrentLocale( )
483 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
484 : virtual ::com::sun::star::lang::Locale SAL_CALL getDefaultLocale( )
485 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
486 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales( )
487 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
488 :
489 : // XStringResourceManager
490 : virtual sal_Bool SAL_CALL isReadOnly()
491 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
492 : virtual void SAL_CALL setCurrentLocale( const ::com::sun::star::lang::Locale& locale, sal_Bool FindClosestMatch )
493 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
494 : virtual void SAL_CALL setDefaultLocale( const ::com::sun::star::lang::Locale& locale )
495 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException,
496 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
497 : virtual void SAL_CALL setString( const OUString& ResourceID, const OUString& Str )
498 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
499 : virtual void SAL_CALL setStringForLocale( const OUString& ResourceID, const OUString& Str,
500 : const ::com::sun::star::lang::Locale& locale )
501 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
502 : virtual void SAL_CALL removeId( const OUString& ResourceID )
503 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException,
504 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
505 : virtual void SAL_CALL removeIdForLocale( const OUString& ResourceID,
506 : const ::com::sun::star::lang::Locale& locale )
507 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException,
508 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
509 : virtual void SAL_CALL newLocale( const ::com::sun::star::lang::Locale& locale )
510 : throw (::com::sun::star::container::ElementExistException, ::com::sun::star::lang::IllegalArgumentException,
511 : ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
512 : virtual void SAL_CALL removeLocale( const ::com::sun::star::lang::Locale& locale )
513 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException,
514 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
515 : virtual ::sal_Int32 SAL_CALL getUniqueNumericId( )
516 : throw (::com::sun::star::lang::NoSupportException,
517 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
518 :
519 : // XStringResourcePersistence
520 : virtual void SAL_CALL store( )
521 : throw (::com::sun::star::lang::NoSupportException,
522 : ::com::sun::star::uno::Exception,
523 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
524 : virtual sal_Bool SAL_CALL isModified( )
525 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
526 : virtual void SAL_CALL setComment( const OUString& Comment )
527 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
528 : virtual void SAL_CALL storeToStorage
529 : ( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage,
530 : const OUString& NameBase, const OUString& Comment )
531 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
532 : virtual void SAL_CALL storeToURL( const OUString& URL, const OUString& NameBase,
533 : const OUString& Comment, const ::com::sun::star::uno::Reference
534 : < ::com::sun::star::task::XInteractionHandler >& Handler )
535 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
536 : virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL exportBinary( )
537 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
538 : virtual void SAL_CALL importBinary( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& Data )
539 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
540 :
541 : // XStringResourceWithStorage
542 : virtual void SAL_CALL storeAsStorage
543 : ( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage )
544 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
545 : virtual void SAL_CALL setStorage
546 : ( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage )
547 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
548 : };
549 :
550 :
551 : typedef ::cppu::ImplInheritanceHelper2<
552 : StringResourcePersistenceImpl,
553 : ::com::sun::star::lang::XInitialization,
554 : ::com::sun::star::resource::XStringResourceWithLocation > StringResourceWithLocationImpl_BASE;
555 :
556 : class StringResourceWithLocationImpl : public StringResourceWithLocationImpl_BASE
557 : {
558 : OUString m_aLocation;
559 : bool m_bLocationChanged;
560 : com::sun::star::uno::Reference< com::sun::star::ucb::XSimpleFileAccess3 > m_xSFI;
561 : com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > m_xInteractionHandler;
562 :
563 : const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess3 > getFileAccess( void );
564 :
565 : virtual void implScanLocales( void ) SAL_OVERRIDE;
566 : virtual bool implLoadLocale( LocaleItem* pLocaleItem ) SAL_OVERRIDE;
567 :
568 : public:
569 : StringResourceWithLocationImpl(
570 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
571 : virtual ~StringResourceWithLocationImpl();
572 :
573 : // XServiceInfo
574 : virtual OUString SAL_CALL getImplementationName( )
575 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
576 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
577 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
578 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
579 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
580 :
581 : // XInitialization
582 : virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
583 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
584 :
585 : // XModifyBroadcaster
586 : virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
587 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
588 : virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
589 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
590 :
591 : // XStringResourceResolver
592 : virtual OUString SAL_CALL resolveString( const OUString& ResourceID )
593 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
594 : virtual OUString SAL_CALL resolveStringForLocale( const OUString& ResourceID,
595 : const ::com::sun::star::lang::Locale& locale )
596 : throw ( ::com::sun::star::resource::MissingResourceException,
597 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
598 : virtual sal_Bool SAL_CALL hasEntryForId( const OUString& ResourceID )
599 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
600 : virtual sal_Bool SAL_CALL hasEntryForIdAndLocale( const OUString& ResourceID,
601 : const ::com::sun::star::lang::Locale& locale )
602 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
603 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getResourceIDs( )
604 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
605 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getResourceIDsForLocale
606 : ( const ::com::sun::star::lang::Locale& locale )
607 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
608 : virtual ::com::sun::star::lang::Locale SAL_CALL getCurrentLocale( )
609 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
610 : virtual ::com::sun::star::lang::Locale SAL_CALL getDefaultLocale( )
611 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
612 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales( )
613 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
614 :
615 : // XStringResourceManager
616 : virtual sal_Bool SAL_CALL isReadOnly()
617 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
618 : virtual void SAL_CALL setCurrentLocale( const ::com::sun::star::lang::Locale& locale, sal_Bool FindClosestMatch )
619 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
620 : virtual void SAL_CALL setDefaultLocale( const ::com::sun::star::lang::Locale& locale )
621 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException,
622 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
623 : virtual void SAL_CALL setString( const OUString& ResourceID, const OUString& Str )
624 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
625 : virtual void SAL_CALL setStringForLocale( const OUString& ResourceID, const OUString& Str,
626 : const ::com::sun::star::lang::Locale& locale )
627 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
628 : virtual void SAL_CALL removeId( const OUString& ResourceID )
629 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException,
630 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
631 : virtual void SAL_CALL removeIdForLocale( const OUString& ResourceID,
632 : const ::com::sun::star::lang::Locale& locale )
633 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException,
634 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
635 : virtual void SAL_CALL newLocale( const ::com::sun::star::lang::Locale& locale )
636 : throw (::com::sun::star::container::ElementExistException, ::com::sun::star::lang::IllegalArgumentException,
637 : ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
638 : virtual void SAL_CALL removeLocale( const ::com::sun::star::lang::Locale& locale )
639 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException,
640 : ::com::sun::star::lang::NoSupportException, std::exception) SAL_OVERRIDE;
641 : virtual ::sal_Int32 SAL_CALL getUniqueNumericId( )
642 : throw (::com::sun::star::lang::NoSupportException,
643 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
644 :
645 : // XStringResourcePersistence
646 : virtual void SAL_CALL store( )
647 : throw (::com::sun::star::lang::NoSupportException,
648 : ::com::sun::star::uno::Exception,
649 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
650 : virtual sal_Bool SAL_CALL isModified( )
651 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
652 : virtual void SAL_CALL setComment( const OUString& Comment )
653 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
654 : virtual void SAL_CALL storeToStorage
655 : ( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage,
656 : const OUString& NameBase, const OUString& Comment )
657 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
658 : virtual void SAL_CALL storeToURL( const OUString& URL, const OUString& NameBase,
659 : const OUString& Comment, const ::com::sun::star::uno::Reference
660 : < ::com::sun::star::task::XInteractionHandler >& Handler )
661 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
662 : virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL exportBinary( )
663 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
664 : virtual void SAL_CALL importBinary( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& Data )
665 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
666 :
667 : // XStringResourceWithLocation
668 : virtual void SAL_CALL storeAsURL( const OUString& URL )
669 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
670 : virtual void SAL_CALL setURL( const OUString& URL )
671 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
672 : };
673 :
674 :
675 : } // namespace stringtable
676 :
677 :
678 : #endif // SCRIPTING_DLGPROV_HXX
679 :
680 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|