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