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 ::rtl::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 ::rtl::OUString Str1, const ::rtl::OUString Str2) const
67 : {
68 0 : return ( Str1 == Str2 );
69 : }
70 : };
71 :
72 : typedef boost::unordered_map
73 : <
74 : ::rtl::OUString,
75 : ::rtl::OUString,
76 : hashName_Impl,
77 : eqName_Impl
78 : >
79 : IdToStringMap;
80 :
81 : typedef boost::unordered_map
82 : <
83 : ::rtl::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 ::rtl::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 : ::rtl::OUString SAL_CALL implResolveString( const ::rtl::OUString& ResourceID, LocaleItem* pLocaleItem )
166 : throw (::com::sun::star::resource::MissingResourceException);
167 : ::sal_Bool implHasEntryForId( const ::rtl::OUString& ResourceID, LocaleItem* pLocaleItem );
168 : ::com::sun::star::uno::Sequence< ::rtl::OUString > implGetResourceIDs( LocaleItem* pLocaleItem );
169 : void implSetString( const ::rtl::OUString& ResourceID,
170 : const ::rtl::OUString& Str, LocaleItem* pLocaleItem );
171 : void implRemoveId( const ::rtl::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 ::rtl::OUString SAL_CALL getImplementationName( )
187 : throw (::com::sun::star::uno::RuntimeException);
188 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
189 : throw (::com::sun::star::uno::RuntimeException);
190 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
191 : throw (::com::sun::star::uno::RuntimeException);
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);
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);
198 :
199 : // XStringResourceResolver
200 : virtual ::rtl::OUString SAL_CALL resolveString( const ::rtl::OUString& ResourceID )
201 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException);
202 : virtual ::rtl::OUString SAL_CALL resolveStringForLocale( const ::rtl::OUString& ResourceID,
203 : const ::com::sun::star::lang::Locale& locale )
204 : throw ( ::com::sun::star::resource::MissingResourceException,
205 : ::com::sun::star::uno::RuntimeException);
206 : virtual ::sal_Bool SAL_CALL hasEntryForId( const ::rtl::OUString& ResourceID )
207 : throw (::com::sun::star::uno::RuntimeException);
208 : virtual ::sal_Bool SAL_CALL hasEntryForIdAndLocale( const ::rtl::OUString& ResourceID,
209 : const ::com::sun::star::lang::Locale& locale )
210 : throw (::com::sun::star::uno::RuntimeException);
211 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getResourceIDs( )
212 : throw (::com::sun::star::uno::RuntimeException);
213 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getResourceIDsForLocale
214 : ( const ::com::sun::star::lang::Locale& locale )
215 : throw (::com::sun::star::uno::RuntimeException);
216 : virtual ::com::sun::star::lang::Locale SAL_CALL getCurrentLocale( )
217 : throw (::com::sun::star::uno::RuntimeException);
218 : virtual ::com::sun::star::lang::Locale SAL_CALL getDefaultLocale( )
219 : throw (::com::sun::star::uno::RuntimeException);
220 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales( )
221 : throw (::com::sun::star::uno::RuntimeException);
222 :
223 : // XStringResourceManager
224 : virtual ::sal_Bool SAL_CALL isReadOnly()
225 : throw (::com::sun::star::uno::RuntimeException);
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);
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);
231 : virtual void SAL_CALL setString( const ::rtl::OUString& ResourceID, const ::rtl::OUString& Str )
232 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
233 : virtual void SAL_CALL setStringForLocale( const ::rtl::OUString& ResourceID, const ::rtl::OUString& Str,
234 : const ::com::sun::star::lang::Locale& locale )
235 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
236 : virtual void SAL_CALL removeId( const ::rtl::OUString& ResourceID )
237 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException,
238 : ::com::sun::star::lang::NoSupportException);
239 : virtual void SAL_CALL removeIdForLocale( const ::rtl::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);
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);
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);
249 : virtual ::sal_Int32 SAL_CALL getUniqueNumericId( )
250 : throw (::com::sun::star::lang::NoSupportException,
251 : ::com::sun::star::uno::RuntimeException);
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 : ::rtl::OUString m_aNameBase;
264 : ::rtl::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 );
275 :
276 : // does the actual loading
277 : virtual bool implLoadLocale( LocaleItem* pLocaleItem );
278 :
279 : virtual void implLoadAllLocales( void );
280 :
281 : void implScanLocaleNames( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aContentSeq );
282 : ::rtl::OUString implGetFileNameForLocaleItem( LocaleItem* pLocaleItem, const ::rtl::OUString& aNameBase );
283 : ::rtl::OUString implGetPathForLocaleItem( LocaleItem* pLocaleItem, const ::rtl::OUString& aNameBase,
284 : const ::rtl::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 ::rtl::OUString& aComment );
291 :
292 : void implWriteLocaleBinary( LocaleItem* pLocaleItem, BinaryOutput& rOut );
293 :
294 : void implStoreAtStorage
295 : (
296 : const ::rtl::OUString& aNameBase,
297 : const ::rtl::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 ::rtl::OUString& Location,
307 : const ::rtl::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 ::rtl::OUString& Location,
315 : const ::rtl::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 ::rtl::OUString& Location,
323 : const ::rtl::OUString& aNameBase,
324 : const ::rtl::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 ::rtl::OUString SAL_CALL getImplementationName( )
339 : throw (::com::sun::star::uno::RuntimeException);
340 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
341 : throw (::com::sun::star::uno::RuntimeException);
342 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
343 : throw (::com::sun::star::uno::RuntimeException);
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);
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);
350 :
351 : // XStringResourceResolver
352 : virtual ::rtl::OUString SAL_CALL resolveString( const ::rtl::OUString& ResourceID )
353 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException);
354 : virtual ::rtl::OUString SAL_CALL resolveStringForLocale( const ::rtl::OUString& ResourceID,
355 : const ::com::sun::star::lang::Locale& locale )
356 : throw ( ::com::sun::star::resource::MissingResourceException,
357 : ::com::sun::star::uno::RuntimeException);
358 : virtual ::sal_Bool SAL_CALL hasEntryForId( const ::rtl::OUString& ResourceID )
359 : throw (::com::sun::star::uno::RuntimeException);
360 : virtual ::sal_Bool SAL_CALL hasEntryForIdAndLocale( const ::rtl::OUString& ResourceID,
361 : const ::com::sun::star::lang::Locale& locale )
362 : throw (::com::sun::star::uno::RuntimeException);
363 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getResourceIDs( )
364 : throw (::com::sun::star::uno::RuntimeException);
365 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getResourceIDsForLocale
366 : ( const ::com::sun::star::lang::Locale& locale )
367 : throw (::com::sun::star::uno::RuntimeException);
368 : virtual ::com::sun::star::lang::Locale SAL_CALL getCurrentLocale( )
369 : throw (::com::sun::star::uno::RuntimeException);
370 : virtual ::com::sun::star::lang::Locale SAL_CALL getDefaultLocale( )
371 : throw (::com::sun::star::uno::RuntimeException);
372 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales( )
373 : throw (::com::sun::star::uno::RuntimeException);
374 :
375 : // XStringResourceManager
376 : virtual ::sal_Bool SAL_CALL isReadOnly()
377 : throw (::com::sun::star::uno::RuntimeException);
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);
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);
383 : virtual void SAL_CALL setString( const ::rtl::OUString& ResourceID, const ::rtl::OUString& Str )
384 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
385 : virtual void SAL_CALL setStringForLocale( const ::rtl::OUString& ResourceID, const ::rtl::OUString& Str,
386 : const ::com::sun::star::lang::Locale& locale )
387 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
388 : virtual void SAL_CALL removeId( const ::rtl::OUString& ResourceID )
389 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException,
390 : ::com::sun::star::lang::NoSupportException);
391 : virtual void SAL_CALL removeIdForLocale( const ::rtl::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);
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);
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);
401 : virtual ::sal_Int32 SAL_CALL getUniqueNumericId( )
402 : throw (::com::sun::star::lang::NoSupportException,
403 : ::com::sun::star::uno::RuntimeException);
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);
410 : virtual ::sal_Bool SAL_CALL isModified( )
411 : throw (::com::sun::star::uno::RuntimeException);
412 : virtual void SAL_CALL setComment( const ::rtl::OUString& Comment )
413 : throw (::com::sun::star::uno::RuntimeException);
414 : virtual void SAL_CALL storeToStorage
415 : ( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage,
416 : const ::rtl::OUString& NameBase, const ::rtl::OUString& Comment )
417 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
418 : virtual void SAL_CALL storeToURL( const ::rtl::OUString& URL, const ::rtl::OUString& NameBase,
419 : const ::rtl::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);
422 : virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL exportBinary( )
423 : throw (::com::sun::star::uno::RuntimeException);
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);
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 );
440 : virtual bool implLoadLocale( LocaleItem* pLocaleItem );
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 ::rtl::OUString SAL_CALL getImplementationName( )
449 : throw (::com::sun::star::uno::RuntimeException);
450 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
451 : throw (::com::sun::star::uno::RuntimeException);
452 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
453 : throw (::com::sun::star::uno::RuntimeException);
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);
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);
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);
464 :
465 : // XStringResourceResolver
466 : virtual ::rtl::OUString SAL_CALL resolveString( const ::rtl::OUString& ResourceID )
467 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException);
468 : virtual ::rtl::OUString SAL_CALL resolveStringForLocale( const ::rtl::OUString& ResourceID,
469 : const ::com::sun::star::lang::Locale& locale )
470 : throw ( ::com::sun::star::resource::MissingResourceException,
471 : ::com::sun::star::uno::RuntimeException);
472 : virtual ::sal_Bool SAL_CALL hasEntryForId( const ::rtl::OUString& ResourceID )
473 : throw (::com::sun::star::uno::RuntimeException);
474 : virtual ::sal_Bool SAL_CALL hasEntryForIdAndLocale( const ::rtl::OUString& ResourceID,
475 : const ::com::sun::star::lang::Locale& locale )
476 : throw (::com::sun::star::uno::RuntimeException);
477 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getResourceIDs( )
478 : throw (::com::sun::star::uno::RuntimeException);
479 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getResourceIDsForLocale
480 : ( const ::com::sun::star::lang::Locale& locale )
481 : throw (::com::sun::star::uno::RuntimeException);
482 : virtual ::com::sun::star::lang::Locale SAL_CALL getCurrentLocale( )
483 : throw (::com::sun::star::uno::RuntimeException);
484 : virtual ::com::sun::star::lang::Locale SAL_CALL getDefaultLocale( )
485 : throw (::com::sun::star::uno::RuntimeException);
486 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales( )
487 : throw (::com::sun::star::uno::RuntimeException);
488 :
489 : // XStringResourceManager
490 : virtual ::sal_Bool SAL_CALL isReadOnly()
491 : throw (::com::sun::star::uno::RuntimeException);
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);
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);
497 : virtual void SAL_CALL setString( const ::rtl::OUString& ResourceID, const ::rtl::OUString& Str )
498 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
499 : virtual void SAL_CALL setStringForLocale( const ::rtl::OUString& ResourceID, const ::rtl::OUString& Str,
500 : const ::com::sun::star::lang::Locale& locale )
501 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
502 : virtual void SAL_CALL removeId( const ::rtl::OUString& ResourceID )
503 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException,
504 : ::com::sun::star::lang::NoSupportException);
505 : virtual void SAL_CALL removeIdForLocale( const ::rtl::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);
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);
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);
515 : virtual ::sal_Int32 SAL_CALL getUniqueNumericId( )
516 : throw (::com::sun::star::lang::NoSupportException,
517 : ::com::sun::star::uno::RuntimeException);
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);
524 : virtual ::sal_Bool SAL_CALL isModified( )
525 : throw (::com::sun::star::uno::RuntimeException);
526 : virtual void SAL_CALL setComment( const ::rtl::OUString& Comment )
527 : throw (::com::sun::star::uno::RuntimeException);
528 : virtual void SAL_CALL storeToStorage
529 : ( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage,
530 : const ::rtl::OUString& NameBase, const ::rtl::OUString& Comment )
531 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
532 : virtual void SAL_CALL storeToURL( const ::rtl::OUString& URL, const ::rtl::OUString& NameBase,
533 : const ::rtl::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);
536 : virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL exportBinary( )
537 : throw (::com::sun::star::uno::RuntimeException);
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);
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);
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);
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 : ::rtl::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 );
566 : virtual bool implLoadLocale( LocaleItem* pLocaleItem );
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 ::rtl::OUString SAL_CALL getImplementationName( )
575 : throw (::com::sun::star::uno::RuntimeException);
576 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
577 : throw (::com::sun::star::uno::RuntimeException);
578 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
579 : throw (::com::sun::star::uno::RuntimeException);
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);
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);
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);
590 :
591 : // XStringResourceResolver
592 : virtual ::rtl::OUString SAL_CALL resolveString( const ::rtl::OUString& ResourceID )
593 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException);
594 : virtual ::rtl::OUString SAL_CALL resolveStringForLocale( const ::rtl::OUString& ResourceID,
595 : const ::com::sun::star::lang::Locale& locale )
596 : throw ( ::com::sun::star::resource::MissingResourceException,
597 : ::com::sun::star::uno::RuntimeException);
598 : virtual ::sal_Bool SAL_CALL hasEntryForId( const ::rtl::OUString& ResourceID )
599 : throw (::com::sun::star::uno::RuntimeException);
600 : virtual ::sal_Bool SAL_CALL hasEntryForIdAndLocale( const ::rtl::OUString& ResourceID,
601 : const ::com::sun::star::lang::Locale& locale )
602 : throw (::com::sun::star::uno::RuntimeException);
603 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getResourceIDs( )
604 : throw (::com::sun::star::uno::RuntimeException);
605 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getResourceIDsForLocale
606 : ( const ::com::sun::star::lang::Locale& locale )
607 : throw (::com::sun::star::uno::RuntimeException);
608 : virtual ::com::sun::star::lang::Locale SAL_CALL getCurrentLocale( )
609 : throw (::com::sun::star::uno::RuntimeException);
610 : virtual ::com::sun::star::lang::Locale SAL_CALL getDefaultLocale( )
611 : throw (::com::sun::star::uno::RuntimeException);
612 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales( )
613 : throw (::com::sun::star::uno::RuntimeException);
614 :
615 : // XStringResourceManager
616 : virtual ::sal_Bool SAL_CALL isReadOnly()
617 : throw (::com::sun::star::uno::RuntimeException);
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);
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);
623 : virtual void SAL_CALL setString( const ::rtl::OUString& ResourceID, const ::rtl::OUString& Str )
624 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
625 : virtual void SAL_CALL setStringForLocale( const ::rtl::OUString& ResourceID, const ::rtl::OUString& Str,
626 : const ::com::sun::star::lang::Locale& locale )
627 : throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
628 : virtual void SAL_CALL removeId( const ::rtl::OUString& ResourceID )
629 : throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException,
630 : ::com::sun::star::lang::NoSupportException);
631 : virtual void SAL_CALL removeIdForLocale( const ::rtl::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);
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);
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);
641 : virtual ::sal_Int32 SAL_CALL getUniqueNumericId( )
642 : throw (::com::sun::star::lang::NoSupportException,
643 : ::com::sun::star::uno::RuntimeException);
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);
650 : virtual ::sal_Bool SAL_CALL isModified( )
651 : throw (::com::sun::star::uno::RuntimeException);
652 : virtual void SAL_CALL setComment( const ::rtl::OUString& Comment )
653 : throw (::com::sun::star::uno::RuntimeException);
654 : virtual void SAL_CALL storeToStorage
655 : ( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage,
656 : const ::rtl::OUString& NameBase, const ::rtl::OUString& Comment )
657 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
658 : virtual void SAL_CALL storeToURL( const ::rtl::OUString& URL, const ::rtl::OUString& NameBase,
659 : const ::rtl::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);
662 : virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL exportBinary( )
663 : throw (::com::sun::star::uno::RuntimeException);
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);
666 :
667 : // XStringResourceWithLocation
668 : virtual void SAL_CALL storeAsURL( const ::rtl::OUString& URL )
669 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
670 : virtual void SAL_CALL setURL( const ::rtl::OUString& URL )
671 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
672 : };
673 :
674 : //.........................................................................
675 : } // namespace stringtable
676 : //.........................................................................
677 :
678 : #endif // SCRIPTING_DLGPROV_HXX
679 :
680 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|