1f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e07b45SAndrew Rist  * distributed with this work for additional information
6f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f8e07b45SAndrew Rist  *
11f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f8e07b45SAndrew Rist  *
13f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18f8e07b45SAndrew Rist  * under the License.
19f8e07b45SAndrew Rist  *
20f8e07b45SAndrew Rist  *************************************************************/
21f8e07b45SAndrew Rist 
22f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_ACCELERATORS_PRESETHANDLER_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_ACCELERATORS_PRESETHANDLER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //__________________________________________
28cdf0e10cSrcweir // own includes
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <accelerators/storageholder.hxx>
31cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
32cdf0e10cSrcweir #include <general.h>
33cdf0e10cSrcweir #include <stdtypes.h>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //__________________________________________
36cdf0e10cSrcweir // interface includes
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #ifndef __COM_SUN_STAR_EMBED_XSTORAGE_HPP_
39cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #ifndef __COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
43cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir 
46cdf0e10cSrcweir //__________________________________________
47cdf0e10cSrcweir // other includes
48cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
49cdf0e10cSrcweir #include <salhelper/singletonref.hxx>
50cdf0e10cSrcweir #include <comphelper/locale.hxx>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir //__________________________________________
53cdf0e10cSrcweir // definition
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace framework
56cdf0e10cSrcweir {
57cdf0e10cSrcweir 
58cdf0e10cSrcweir //__________________________________________
59cdf0e10cSrcweir /**
60cdf0e10cSrcweir     TODO document me
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         <layer>/global/<resourcetype>/<preset>.xml
63cdf0e10cSrcweir         <layer>/modules/<moduleid>/<resourcetype>/<preset>.xml
64cdf0e10cSrcweir 
65cdf0e10cSrcweir         RESOURCETYPE        PRESET        TARGET
66cdf0e10cSrcweir                             (share)       (user)
67cdf0e10cSrcweir         "accelerator"       "default"     "current"
68cdf0e10cSrcweir                             "word"
69cdf0e10cSrcweir                             "excel"
70cdf0e10cSrcweir 
71cdf0e10cSrcweir         "menubar"           "default"     "menubar"
72cdf0e10cSrcweir 
73cdf0e10cSrcweir  */
7407a3d7f1SPedro Giffuni class PresetHandler : private ThreadHelpBase // attention! Must be the first base class to guarantee right initialize lock ...
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     //-------------------------------------------
77cdf0e10cSrcweir     // const
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     public:
80cdf0e10cSrcweir 
81cdf0e10cSrcweir         static ::rtl::OUString PRESET_DEFAULT();
82cdf0e10cSrcweir         static ::rtl::OUString TARGET_CURRENT();
83cdf0e10cSrcweir 
84cdf0e10cSrcweir         static ::rtl::OUString RESOURCETYPE_MENUBAR();
85cdf0e10cSrcweir         static ::rtl::OUString RESOURCETYPE_TOOLBAR();
86cdf0e10cSrcweir         static ::rtl::OUString RESOURCETYPE_ACCELERATOR();
87cdf0e10cSrcweir         static ::rtl::OUString RESOURCETYPE_STATUSBAR();
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     //-------------------------------------------
90cdf0e10cSrcweir     // types
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     public:
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         //---------------------------------------
95cdf0e10cSrcweir         /** @short  this handler can provide different
96cdf0e10cSrcweir                     types of configuration.
97cdf0e10cSrcweir 
98cdf0e10cSrcweir             @descr  Means: a global or a module dependend
99cdf0e10cSrcweir                     or ... configuration.
100cdf0e10cSrcweir          */
101cdf0e10cSrcweir         enum EConfigType
102cdf0e10cSrcweir         {
103cdf0e10cSrcweir             E_GLOBAL,
104cdf0e10cSrcweir             E_MODULES,
105cdf0e10cSrcweir             E_DOCUMENT
106cdf0e10cSrcweir         };
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     private:
109cdf0e10cSrcweir 
110cdf0e10cSrcweir         //---------------------------------------
111cdf0e10cSrcweir         /** @short  because a concurrent access to the same storage from different implementations
11207a3d7f1SPedro Giffuni                     isn't supported, we have to share it with others.
113cdf0e10cSrcweir 
114cdf0e10cSrcweir             @descr  This struct makes it possible to use any shared storage
115cdf0e10cSrcweir                     in combination with a SingletonRef<> template ...
116cdf0e10cSrcweir 
117cdf0e10cSrcweir                     Attention: Because these struct is shared it must be
118796b7e2aSmseidel                     used within a synchronized section. That's why this struct
119cdf0e10cSrcweir                     uses a base class ThreadHelpBase and can be locked
120cdf0e10cSrcweir                     from outside doing so!
121cdf0e10cSrcweir          */
122cdf0e10cSrcweir         struct TSharedStorages : public ThreadHelpBase
123cdf0e10cSrcweir         {
124cdf0e10cSrcweir             public:
125cdf0e10cSrcweir 
126cdf0e10cSrcweir                 StorageHolder m_lStoragesShare;
127cdf0e10cSrcweir                 StorageHolder m_lStoragesUser;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir                 TSharedStorages()
130cdf0e10cSrcweir                     : m_lStoragesShare(::comphelper::getProcessServiceFactory())
131cdf0e10cSrcweir                     , m_lStoragesUser (::comphelper::getProcessServiceFactory())
132cdf0e10cSrcweir                 {};
133cdf0e10cSrcweir 
134cdf0e10cSrcweir                 virtual ~TSharedStorages() {};
135cdf0e10cSrcweir         };
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     //-------------------------------------------
138cdf0e10cSrcweir     // member
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     private:
141cdf0e10cSrcweir 
142cdf0e10cSrcweir         //---------------------------------------
143cdf0e10cSrcweir         /** @short  can be used to create on needed uno resources. */
144cdf0e10cSrcweir         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
145cdf0e10cSrcweir 
146cdf0e10cSrcweir         //---------------------------------------
147cdf0e10cSrcweir         /** @short  knows the type of provided configuration.
148cdf0e10cSrcweir 
149cdf0e10cSrcweir             @descr  e.g. global, modules, ...
150cdf0e10cSrcweir          */
151cdf0e10cSrcweir         EConfigType m_eConfigType;
152cdf0e10cSrcweir 
153cdf0e10cSrcweir         //---------------------------------------
154cdf0e10cSrcweir         /** @short  specify the type of resource, which configuration sets
155cdf0e10cSrcweir                     must be provided here.
156cdf0e10cSrcweir 
157cdf0e10cSrcweir             @descr  e.g. menubars, toolbars, accelerators
158cdf0e10cSrcweir          */
159cdf0e10cSrcweir         ::rtl::OUString m_sResourceType;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir         //---------------------------------------
162cdf0e10cSrcweir         /** @short  specify the application module for a module
163cdf0e10cSrcweir                     dependend configuration.
164cdf0e10cSrcweir 
165cdf0e10cSrcweir             @descr  Will be used only, if m_sResourceType is set to
166cdf0e10cSrcweir                     "module". Further it must be a valid module identifier
167cdf0e10cSrcweir                     then ...
168cdf0e10cSrcweir          */
169cdf0e10cSrcweir         ::rtl::OUString m_sModule;
170cdf0e10cSrcweir 
171cdf0e10cSrcweir         //---------------------------------------
172cdf0e10cSrcweir         /** @short  provides access to the:
173cdf0e10cSrcweir                     a) shared root storages
174cdf0e10cSrcweir                     b) shared "inbetween" storages
175cdf0e10cSrcweir                     of the share and user layer. */
176cdf0e10cSrcweir         ::salhelper::SingletonRef< TSharedStorages > m_aSharedStorages;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir         //---------------------------------------
17907a3d7f1SPedro Giffuni         /** @short  if we run in document mode, we can't use the global root storages!
180cdf0e10cSrcweir                     We have to use a special document storage explicitly. */
181cdf0e10cSrcweir         StorageHolder m_lDocumentStorages;
182cdf0e10cSrcweir 
183cdf0e10cSrcweir         //---------------------------------------
184cdf0e10cSrcweir         /** @short  holds the folder storage of the share layer alive,
185cdf0e10cSrcweir                     where the current configuration set exists.
186cdf0e10cSrcweir 
187cdf0e10cSrcweir             @descr  Note: If this preset handler works in document mode
188cdf0e10cSrcweir                     this member is meaned relative to the document root ...
189cdf0e10cSrcweir                     not to the share layer root!
190cdf0e10cSrcweir 
191cdf0e10cSrcweir                     Further is defined, that m_xWorkingStorageUser
192cdf0e10cSrcweir                     is equals to m_xWorkingStorageShare then!
193cdf0e10cSrcweir          */
194cdf0e10cSrcweir         css::uno::Reference< css::embed::XStorage > m_xWorkingStorageShare;
195cdf0e10cSrcweir 
196cdf0e10cSrcweir         //---------------------------------------
197cdf0e10cSrcweir         /** @short  global language-independent storage
198cdf0e10cSrcweir          */
199cdf0e10cSrcweir         css::uno::Reference< css::embed::XStorage > m_xWorkingStorageNoLang;
200cdf0e10cSrcweir 
201cdf0e10cSrcweir         //---------------------------------------
202cdf0e10cSrcweir         /** @short  holds the folder storage of the user layer alive,
203cdf0e10cSrcweir                     where the current configuration set exists.
204cdf0e10cSrcweir 
205cdf0e10cSrcweir             @descr  Note: If this preset handler works in document mode
206cdf0e10cSrcweir                     this member is meaned relative to the document root ...
207cdf0e10cSrcweir                     not to the user layer root!
208cdf0e10cSrcweir 
209cdf0e10cSrcweir                     Further is defined, that m_xWorkingStorageUser
210cdf0e10cSrcweir                     is equals to m_xWorkingStorageShare then!
211cdf0e10cSrcweir          */
212cdf0e10cSrcweir         css::uno::Reference< css::embed::XStorage > m_xWorkingStorageUser;
213cdf0e10cSrcweir 
214cdf0e10cSrcweir         //---------------------------------------
215cdf0e10cSrcweir         /** @short  knows the names of all presets inside the current
216cdf0e10cSrcweir                     working storage of the share layer. */
217cdf0e10cSrcweir         OUStringList m_lPresets;
218cdf0e10cSrcweir 
219cdf0e10cSrcweir         //---------------------------------------
220cdf0e10cSrcweir         /** @short  knows the names of all targets inside the current
221cdf0e10cSrcweir                     working storage of the user layer. */
222cdf0e10cSrcweir         OUStringList m_lTargets;
223cdf0e10cSrcweir 
224cdf0e10cSrcweir         //---------------------------------------
225cdf0e10cSrcweir         /** @short  its the current office locale and will be used
226cdf0e10cSrcweir                     to handle localized presets.
227cdf0e10cSrcweir 
228cdf0e10cSrcweir             @descr  Default is "x-notranslate" which disable any
229cdf0e10cSrcweir                     localized handling inside this class! */
230cdf0e10cSrcweir         ::comphelper::Locale m_aLocale;
231cdf0e10cSrcweir 
232cdf0e10cSrcweir         //---------------------------------------
233cdf0e10cSrcweir         /** @short  knows the relative path from the root. */
234cdf0e10cSrcweir         ::rtl::OUString m_sRelPathShare;
235cdf0e10cSrcweir         ::rtl::OUString m_sRelPathNoLang;
236cdf0e10cSrcweir         ::rtl::OUString m_sRelPathUser;
237cdf0e10cSrcweir 
238cdf0e10cSrcweir     //-------------------------------------------
239cdf0e10cSrcweir     // native interface
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     public:
242cdf0e10cSrcweir 
243cdf0e10cSrcweir         //---------------------------------------
244cdf0e10cSrcweir         /** @short  does nothing real.
245cdf0e10cSrcweir 
246cdf0e10cSrcweir             @descr  Because this class should be useable in combination
247cdf0e10cSrcweir                     with ::salhelper::SingletonRef template this ctor
24807a3d7f1SPedro Giffuni                     can't have any special parameters!
249cdf0e10cSrcweir 
250cdf0e10cSrcweir             @param  xSMGR
251a49f1911Smseidel                     points to an uno service manager, which is used internally
252cdf0e10cSrcweir                     to create own needed uno resources.
253cdf0e10cSrcweir          */
254cdf0e10cSrcweir         PresetHandler(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
255cdf0e10cSrcweir 
256cdf0e10cSrcweir         //---------------------------------------
257cdf0e10cSrcweir         /** @short  copy ctor */
258cdf0e10cSrcweir         PresetHandler(const PresetHandler& rCopy);
259cdf0e10cSrcweir 
260cdf0e10cSrcweir         //---------------------------------------
261cdf0e10cSrcweir         /** @short  closes all open storages ... if user forgot that .-) */
262cdf0e10cSrcweir         virtual ~PresetHandler();
263cdf0e10cSrcweir 
264cdf0e10cSrcweir         //---------------------------------------
265cdf0e10cSrcweir         /** @short  free all currently cache(!) storages. */
266cdf0e10cSrcweir         void forgetCachedStorages();
267cdf0e10cSrcweir 
268cdf0e10cSrcweir         //---------------------------------------
269a49f1911Smseidel         /** @short  return access to the internally used and cached root storage.
270cdf0e10cSrcweir 
271cdf0e10cSrcweir             @descr  These root storages are the base of all further opened
272cdf0e10cSrcweir                     presets and targets. They are provided here only, to support
273cdf0e10cSrcweir                     older implementations, which base on them ...
274cdf0e10cSrcweir 
275cdf0e10cSrcweir                     getOrCreate...() - What does it mean?
276cdf0e10cSrcweir                     Such root storage will be created one times only and
277a49f1911Smseidel                     cached then internally till the last instance of such PresetHandler
278cdf0e10cSrcweir                     dies.
279cdf0e10cSrcweir 
280cdf0e10cSrcweir             @return com::sun::star::embed::XStorage
281cdf0e10cSrcweir                     which represent a root storage.
282cdf0e10cSrcweir          */
283cdf0e10cSrcweir         css::uno::Reference< css::embed::XStorage > getOrCreateRootStorageShare();
284cdf0e10cSrcweir         css::uno::Reference< css::embed::XStorage > getOrCreateRootStorageUser();
285cdf0e10cSrcweir 
286cdf0e10cSrcweir         //---------------------------------------
287cdf0e10cSrcweir         /** @short  provides access to the current working storages.
288cdf0e10cSrcweir 
289cdf0e10cSrcweir             @descr  Working storages are the "lowest" storages, where the
290cdf0e10cSrcweir                     preset and target files exists.
291cdf0e10cSrcweir 
292cdf0e10cSrcweir             @return com::sun::star::embed::XStorage
293cdf0e10cSrcweir                     which the current working storage.
294cdf0e10cSrcweir          */
295cdf0e10cSrcweir         css::uno::Reference< css::embed::XStorage > getWorkingStorageShare();
296cdf0e10cSrcweir         css::uno::Reference< css::embed::XStorage > getWorkingStorageUser();
297cdf0e10cSrcweir 
298cdf0e10cSrcweir         //---------------------------------------
299cdf0e10cSrcweir         /** @short  check if there is a parent storage well known for
300cdf0e10cSrcweir                     the specified child storage and return it.
301cdf0e10cSrcweir 
302cdf0e10cSrcweir             @param  xChild
303cdf0e10cSrcweir                     the child storage where a paranet storage should be searched for.
304cdf0e10cSrcweir 
305cdf0e10cSrcweir             @return com::sun::star::embed::XStorage
306cdf0e10cSrcweir                     A valid storage if a paranet exists. NULL otherwise.
307cdf0e10cSrcweir          */
308cdf0e10cSrcweir         css::uno::Reference< css::embed::XStorage > getParentStorageShare(const css::uno::Reference< css::embed::XStorage >& xChild);
309cdf0e10cSrcweir         css::uno::Reference< css::embed::XStorage > getParentStorageUser (const css::uno::Reference< css::embed::XStorage >& xChild);
310cdf0e10cSrcweir 
311cdf0e10cSrcweir         //---------------------------------------
312cdf0e10cSrcweir         /** @short  free all internal structures and let this handler
313cdf0e10cSrcweir                     work on a new type of configuration sets.
314cdf0e10cSrcweir 
315cdf0e10cSrcweir             @param  eConfigType
316cdf0e10cSrcweir                     differ between global or module dependend configuration.
317cdf0e10cSrcweir 
318cdf0e10cSrcweir             @param  sResourceType
319cdf0e10cSrcweir                     differ between menubar/toolbar/accelerator/... configuration.
320cdf0e10cSrcweir 
321cdf0e10cSrcweir             @param  sModule
322cdf0e10cSrcweir                     if sResourceType is set to a module dependend configuration,
323cdf0e10cSrcweir                     it address the current application module.
324cdf0e10cSrcweir 
325cdf0e10cSrcweir             @param  xDocumentRoot
326cdf0e10cSrcweir                     if sResourceType is set to E_DOCUMENT, this value points to the
327cdf0e10cSrcweir                     root storage inside the document, where we can save our
328796b7e2aSmseidel                     configuration files. Note: That's not the real root of the document ...
329796b7e2aSmseidel                     it's only a sub storage. But we interpret it as our root storage.
330cdf0e10cSrcweir 
331cdf0e10cSrcweir             @param  aLocale
332cdf0e10cSrcweir                     in case this configuration supports localized entries,
333cdf0e10cSrcweir                     the current locale must be set.
334cdf0e10cSrcweir 
335cdf0e10cSrcweir                     Localzation will be represented as directory structure
336cdf0e10cSrcweir                     of provided presets. Means: you call us with a preset name "default";
337a49f1911Smseidel                     and we use e.g. "/en-US/default.xml" internally.
338cdf0e10cSrcweir 
339cdf0e10cSrcweir                     If no localization exists for this preset set, this class
34007a3d7f1SPedro Giffuni                     will work in default mode - means "no locale" - automatically.
341cdf0e10cSrcweir                     e.g. "/default.xml"
342cdf0e10cSrcweir 
343cdf0e10cSrcweir             @throw  com::sun::star::uno::RuntimeException(!)
344cdf0e10cSrcweir                     if the specified resource couldn't be located.
345cdf0e10cSrcweir          */
346cdf0e10cSrcweir         void connectToResource(      EConfigType                                  eConfigType   ,
347cdf0e10cSrcweir                                const ::rtl::OUString&                             sResourceType ,
348cdf0e10cSrcweir                                const ::rtl::OUString&                             sModule       ,
349cdf0e10cSrcweir                                const css::uno::Reference< css::embed::XStorage >& xDocumentRoot ,
350cdf0e10cSrcweir                                const ::comphelper::Locale&                        aLocale       = ::comphelper::Locale(::comphelper::Locale::X_NOTRANSLATE()));
351cdf0e10cSrcweir 
352cdf0e10cSrcweir         //---------------------------------------
353cdf0e10cSrcweir         /** @short  try to copy the specified preset from the share
354cdf0e10cSrcweir                     layer to the user layer and establish it as the
355cdf0e10cSrcweir                     specified target.
356cdf0e10cSrcweir 
357cdf0e10cSrcweir             @descr  Means: copy share/.../<preset>.xml user/.../<target>.xml
358cdf0e10cSrcweir                     Note: The target will be overwritten completly or
359cdf0e10cSrcweir                     created as new by this operation!
360cdf0e10cSrcweir 
361cdf0e10cSrcweir             @param  sPreset
362cdf0e10cSrcweir                     the ALIAS name of an existing preset.
363cdf0e10cSrcweir 
364cdf0e10cSrcweir             @param  sTarget
365cdf0e10cSrcweir                     the ALIAS name of the target.
366cdf0e10cSrcweir 
367cdf0e10cSrcweir             @throw  com::sun::star::container::NoSuchElementException
368cdf0e10cSrcweir                     if the specified preset does not exists.
369cdf0e10cSrcweir 
370cdf0e10cSrcweir             @throw  com::sun::star::io::IOException
371cdf0e10cSrcweir                     if copying failed.
372cdf0e10cSrcweir          */
373cdf0e10cSrcweir         void copyPresetToTarget(const ::rtl::OUString& sPreset,
374cdf0e10cSrcweir                                 const ::rtl::OUString& sTarget);
375cdf0e10cSrcweir 
376cdf0e10cSrcweir         //---------------------------------------
377cdf0e10cSrcweir         /** @short  open the specified preset as stream object
378cdf0e10cSrcweir                     and return it.
379cdf0e10cSrcweir 
380cdf0e10cSrcweir             @descr  Note: Because presets resist inside the share
381cdf0e10cSrcweir                     layer, they will be opened readonly everytimes.
382cdf0e10cSrcweir 
383cdf0e10cSrcweir             @param  sPreset
384cdf0e10cSrcweir                     the ALIAS name of an existing preset.
385cdf0e10cSrcweir 
386cdf0e10cSrcweir             @param  bNoLangGlobal
387cdf0e10cSrcweir                     access the global language-independent storage instead of the preset storage
388cdf0e10cSrcweir 
389cdf0e10cSrcweir             @return The opened preset stream ... or NULL if the preset does not exists.
390cdf0e10cSrcweir          */
391cdf0e10cSrcweir         css::uno::Reference< css::io::XStream > openPreset(const ::rtl::OUString& sPreset,
392cdf0e10cSrcweir                                                            sal_Bool bUseNoLangGlobal = sal_False);
393cdf0e10cSrcweir 
394cdf0e10cSrcweir         //---------------------------------------
395cdf0e10cSrcweir         /** @short  open the specified target as stream object
396cdf0e10cSrcweir                     and return it.
397cdf0e10cSrcweir 
398cdf0e10cSrcweir             @descr  Note: Targets resist inside the user
399e9faf1d9Smseidel                     layer. Normally they are opened in read/write mode.
40007a3d7f1SPedro Giffuni                     But it will be opened readonly automatically if that isn't possible
401e9faf1d9Smseidel                     (maybe the file is write protected on the system ...).
402cdf0e10cSrcweir 
403cdf0e10cSrcweir             @param  sTarget
404cdf0e10cSrcweir                     the ALIAS name of the target.
405cdf0e10cSrcweir 
406cdf0e10cSrcweir             @param  bCreateIfMissing
407*7a164331Smseidel                     create target file, if it does not still exist.
408cdf0e10cSrcweir                     Note: That does not means reseting of an existing file!
409cdf0e10cSrcweir 
410cdf0e10cSrcweir             @return The opened target stream ... or NULL if the target does not exists
411*7a164331Smseidel                     or couldn't be created as new one.
412cdf0e10cSrcweir          */
413cdf0e10cSrcweir         css::uno::Reference< css::io::XStream > openTarget(const ::rtl::OUString& sTarget         ,
414cdf0e10cSrcweir                                                                  sal_Bool         bCreateIfMissing);
415cdf0e10cSrcweir 
416cdf0e10cSrcweir         //---------------------------------------
41707a3d7f1SPedro Giffuni         /** @short  do anything which is necessary to flush all changes
418cdf0e10cSrcweir                     back to disk.
419cdf0e10cSrcweir 
420cdf0e10cSrcweir             @descr  We have to call commit on all cached sub storages on the
421cdf0e10cSrcweir                     path from the root storage upside down to the working storage
42207a3d7f1SPedro Giffuni                     (which are not really used, but required to be holded alive!).
423cdf0e10cSrcweir          */
424cdf0e10cSrcweir         void commitUserChanges();
425cdf0e10cSrcweir 
426cdf0e10cSrcweir         //---------------------------------------
427cdf0e10cSrcweir         /** TODO */
428cdf0e10cSrcweir         void addStorageListener(IStorageListener* pListener);
429cdf0e10cSrcweir         void removeStorageListener(IStorageListener* pListener);
430cdf0e10cSrcweir 
431cdf0e10cSrcweir     //-------------------------------------------
432cdf0e10cSrcweir     // helper
433cdf0e10cSrcweir 
434cdf0e10cSrcweir     private:
435cdf0e10cSrcweir 
436cdf0e10cSrcweir         //---------------------------------------
437cdf0e10cSrcweir         /** @short  open a config path ignoring errors (catching exceptions).
438cdf0e10cSrcweir 
439cdf0e10cSrcweir             @descr  We catch only normal exceptions here - no runtime exceptions.
440cdf0e10cSrcweir 
441cdf0e10cSrcweir             @param  sPath
442cdf0e10cSrcweir                     the configuration path, which should be opened.
443cdf0e10cSrcweir 
444cdf0e10cSrcweir             @param  eMode
445cdf0e10cSrcweir                     the open mode (READ/READWRITE)
446cdf0e10cSrcweir 
447cdf0e10cSrcweir             @param  bShare
448cdf0e10cSrcweir                     force using of the share layer instead of the user layer.
449cdf0e10cSrcweir 
450cdf0e10cSrcweir             @return An opened storage in case method was successfully - null otherwise.
451cdf0e10cSrcweir          */
452cdf0e10cSrcweir         css::uno::Reference< css::embed::XStorage > impl_openPathIgnoringErrors(const ::rtl::OUString& sPath ,
453cdf0e10cSrcweir                                                                                       sal_Int32        eMode ,
454cdf0e10cSrcweir                                                                                       sal_Bool         bShare);
455cdf0e10cSrcweir 
456cdf0e10cSrcweir         //---------------------------------------
457cdf0e10cSrcweir         /** @short  try to find the specified locale inside list of possible ones.
458cdf0e10cSrcweir 
459e9faf1d9Smseidel             @descr  The list of possible locale values was e.g. retrieved from the system
460e9faf1d9Smseidel                     (configuration, directory listing etcpp). The locale normally represent
461cdf0e10cSrcweir                     the current office locale. This method search for a suitable item by using
462cdf0e10cSrcweir                     different algorithm.
463cdf0e10cSrcweir                     a) exact search
464cdf0e10cSrcweir                     b) search with using fallbacks
465cdf0e10cSrcweir 
466cdf0e10cSrcweir             @param  lLocalizedValues
467cdf0e10cSrcweir                     list of ISO locale codes
468cdf0e10cSrcweir 
469cdf0e10cSrcweir             @param  aLocale
470cdf0e10cSrcweir                     [IN ] the current office locale, which should be searched inside lLocalizedValues.
471cdf0e10cSrcweir                     [OUT] in case fallbacks was allowed, it contains afterwards the fallback locale.
472cdf0e10cSrcweir 
473cdf0e10cSrcweir             @param  bAllowFallbacks
474cdf0e10cSrcweir                     enable/disable using of fallbacks
475cdf0e10cSrcweir 
476cdf0e10cSrcweir             @return An iterator, which points directly into lLocalizedValue list.
477cdf0e10cSrcweir                     As a negative result the special iterator lLocalizedValues.end() will be returned.
478cdf0e10cSrcweir          */
479cdf0e10cSrcweir         ::std::vector< ::rtl::OUString >::const_iterator impl_findMatchingLocalizedValue(const ::std::vector< ::rtl::OUString >& lLocalizedValues,
480cdf0e10cSrcweir                                                                                                ::comphelper::Locale&             aLocale         ,
481cdf0e10cSrcweir                                                                                                sal_Bool                          bAllowFallbacks );
482cdf0e10cSrcweir 
483cdf0e10cSrcweir         //---------------------------------------
484cdf0e10cSrcweir         /** @short  open a config path ignoring errors (catching exceptions).
485cdf0e10cSrcweir 
486cdf0e10cSrcweir             @descr  We catch only normal exceptions here - no runtime exceptions.
487cdf0e10cSrcweir                     Further the path itself is tries in different versions (using locale
488cdf0e10cSrcweir                     specific attributes).
489cdf0e10cSrcweir                     e.g. "path/e-US" => "path/en" => "path/de"
490cdf0e10cSrcweir 
491cdf0e10cSrcweir             @param  sPath
492cdf0e10cSrcweir                     the configuration path, which should be opened.
493cdf0e10cSrcweir                     Its further used as out parameter too, so we can return the localized
494cdf0e10cSrcweir                     path to the calli!
495cdf0e10cSrcweir 
496cdf0e10cSrcweir             @param  eMode
497cdf0e10cSrcweir                     the open mode (READ/READWRITE)
498cdf0e10cSrcweir 
499cdf0e10cSrcweir             @param  bShare
500cdf0e10cSrcweir                     force using of the share layer instead of the user layer.
501cdf0e10cSrcweir 
502cdf0e10cSrcweir             @param  aLocale
503cdf0e10cSrcweir                     [IN ] contains the start locale for searching localized sub dirs.
504cdf0e10cSrcweir                     [OUT] contains the locale of a found localized sub dir
505cdf0e10cSrcweir 
506cdf0e10cSrcweir             @param  bAllowFallback
507cdf0e10cSrcweir                     enable/disable fallback handling for locales
508cdf0e10cSrcweir 
509cdf0e10cSrcweir             @return An opened storage in case method was successfully - null otherwise.
510cdf0e10cSrcweir          */
511cdf0e10cSrcweir         css::uno::Reference< css::embed::XStorage > impl_openLocalizedPathIgnoringErrors(::rtl::OUString&      sPath         ,
512cdf0e10cSrcweir                                                                                          sal_Int32             eMode         ,
513cdf0e10cSrcweir                                                                                          sal_Bool              bShare        ,
514cdf0e10cSrcweir                                                                                          ::comphelper::Locale& aLocale       ,
515cdf0e10cSrcweir                                                                                          sal_Bool              bAllowFallback);
516cdf0e10cSrcweir 
517cdf0e10cSrcweir         //---------------------------------------
518cdf0e10cSrcweir         /** @short  returns the names of all sub storages of specified storage.
519cdf0e10cSrcweir 
520cdf0e10cSrcweir             @param  xFolder
521cdf0e10cSrcweir                     the base storage for this operation.
522cdf0e10cSrcweir 
523cdf0e10cSrcweir             @return [vector< string >]
524cdf0e10cSrcweir                     a list of folder names.
525cdf0e10cSrcweir          */
526cdf0e10cSrcweir         ::std::vector< ::rtl::OUString > impl_getSubFolderNames(const css::uno::Reference< css::embed::XStorage >& xFolder);
527cdf0e10cSrcweir };
528cdf0e10cSrcweir 
529cdf0e10cSrcweir } // namespace framework
530cdf0e10cSrcweir 
531cdf0e10cSrcweir #endif // __FRAMEWORK_ACCELERATORS_PRESETHANDLER_HXX_
532