merged tag ooo/OOO330_m14
[LibreOffice.git] / framework / source / inc / accelerators / storageholder.hxx
blob291fc29675eb457a2988a256db0add6948bcc0fe
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef __FRAMEWORK_ACCELERATORS_STORAGEHOLDER_HXX_
29 #define __FRAMEWORK_ACCELERATORS_STORAGEHOLDER_HXX_
31 //===============================================
32 // own includes
34 #include <accelerators/istoragelistener.hxx>
35 #include <threadhelp/threadhelpbase.hxx>
36 #include <general.h>
37 #include <stdtypes.h>
39 //===============================================
40 // interface includes
42 #ifndef __COM_SUN_STAR_EMBED_XSTORAGE_HPP_
43 #include <com/sun/star/embed/XStorage.hpp>
44 #endif
46 #ifndef __COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
47 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48 #endif
50 //===============================================
51 // other includes
54 //===============================================
55 // namespace
57 namespace framework
60 #ifdef css
61 #error "Who defines css? I will use it as namespace alias inside header."
62 #else
63 #define css ::com::sun::star
64 #endif
66 //===============================================
67 // definitions
69 //-----------------------------------------------
70 /**
71 TODO document me
73 class StorageHolder : private ThreadHelpBase // attention! Must be the first base class to guarentee right initialize lock ...
75 //-------------------------------------------
76 // types
77 public:
79 /** @short TODO */
80 typedef ::std::vector< css::uno::Reference< css::embed::XStorage > > TStorageList;
82 typedef ::std::vector< IStorageListener* > TStorageListenerList;
84 struct TStorageInfo
86 public:
87 css::uno::Reference< css::embed::XStorage > Storage;
88 sal_Int32 UseCount;
89 TStorageListenerList Listener;
91 TStorageInfo()
92 : UseCount(0)
96 /** @short TODO */
97 typedef ::std::hash_map< ::rtl::OUString ,
98 TStorageInfo ,
99 ::rtl::OUStringHash ,
100 ::std::equal_to< ::rtl::OUString > > TPath2StorageInfo;
102 //-------------------------------------------
103 // member
104 private:
106 /** @short TODO */
107 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
109 /** @short TODO */
110 css::uno::Reference< css::embed::XStorage > m_xRoot;
112 /** @short TODO */
113 TPath2StorageInfo m_lStorages;
115 //-------------------------------------------
116 // interface
117 public:
119 //---------------------------------------
120 /** @short TODO
122 StorageHolder();
124 //---------------------------------------
125 /** @short TODO
127 StorageHolder(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
129 //---------------------------------------
130 /** @short TODO
132 virtual ~StorageHolder();
134 //---------------------------------------
135 /** @short TODO
137 virtual void forgetCachedStorages();
139 //---------------------------------------
140 /** @short TODO
142 virtual void setRootStorage(const css::uno::Reference< css::embed::XStorage >& xRoot);
144 //---------------------------------------
145 /** @short TODO
147 virtual css::uno::Reference< css::embed::XStorage > getRootStorage() const;
149 //---------------------------------------
150 /** @short TODO
151 open or get!
153 virtual css::uno::Reference< css::embed::XStorage > openPath(const ::rtl::OUString& sPath ,
154 sal_Int32 nOpenMode);
156 //---------------------------------------
157 /** @short TODO
159 virtual StorageHolder::TStorageList getAllPathStorages(const ::rtl::OUString& sPath);
161 //---------------------------------------
162 /** @short TODO
164 virtual void commitPath(const ::rtl::OUString& sPath);
166 //---------------------------------------
167 /** @short TODO
169 virtual void closePath(const ::rtl::OUString& sPath);
171 //---------------------------------------
172 /** @short TODO
174 virtual void notifyPath(const ::rtl::OUString& sPath);
176 //---------------------------------------
177 /** @short TODO
179 virtual void addStorageListener( IStorageListener* pListener,
180 const ::rtl::OUString& sPath );
182 //---------------------------------------
183 /** @short TODO
185 virtual void removeStorageListener( IStorageListener* pListener,
186 const ::rtl::OUString& sPath );
188 //---------------------------------------
189 /** @short TODO
191 virtual ::rtl::OUString getPathOfStorage(const css::uno::Reference< css::embed::XStorage >& xStorage);
193 //---------------------------------------
194 /** @short TODO
196 virtual css::uno::Reference< css::embed::XStorage > getParentStorage(const css::uno::Reference< css::embed::XStorage >& xChild);
198 //---------------------------------------
199 /** @short TODO
201 virtual css::uno::Reference< css::embed::XStorage > getParentStorage(const ::rtl::OUString& sChildPath);
203 //---------------------------------------
204 /** @short TODO
206 virtual void operator=(const StorageHolder& rCopy);
208 //---------------------------------------
209 /** @short opens a sub element of the specified base storage.
211 @descr First this method try to open the requested sub element
212 using the given open mode. If it failed there is second step,
213 which tries to do the same again ... but removing a might existing
214 WRITE flag from the open mode. The user can supress this fallback
215 handling by setting the parameter bAllowFallback to FALSE.
217 @param xBaseStorage
218 the storage, where the sub element should be searched.
220 @param sSubElement
221 the full name of the sub element.
222 e.g. "default.xml"
224 @param eOpenMode
225 a flag field, which set the open mode for this operation.
227 @param bAllowFallback
228 if eOpenMode contains an ELEMENT_WRITE flag this parameter
229 allow to remove it and try it with the rest of eOpenMode flags
230 again.
232 static css::uno::Reference< css::embed::XStorage > openSubStorageWithFallback(const css::uno::Reference< css::embed::XStorage >& xBaseStorage ,
233 const ::rtl::OUString& sSubStorage ,
234 sal_Int32 eOpenMode ,
235 sal_Bool bAllowFallback);
237 static css::uno::Reference< css::io::XStream > openSubStreamWithFallback(const css::uno::Reference< css::embed::XStorage >& xBaseStorage ,
238 const ::rtl::OUString& sSubStream ,
239 sal_Int32 eOpenMode ,
240 sal_Bool bAllowFallback);
242 //---------------------------------------
243 // helper
244 private:
246 //-----------------------------------
247 /** @short TODO
249 static ::rtl::OUString impl_st_normPath(const ::rtl::OUString& sPath);
251 //-----------------------------------
252 /** @short TODO
254 static OUStringList impl_st_parsePath(const ::rtl::OUString& sPath);
257 #undef css // dont let it out!
259 } // namespace framework
261 #endif // __FRAMEWORK_ACCELERATORS_STORAGEHOLDER_HXX_