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