update dev300-m58
[ooovba.git] / framework / source / inc / accelerators / storageholder.hxx
blobdce603e7c5f1f035514e0864f6069d1f98b2c477
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: storageholder.hxx,v $
10 * $Revision: 1.5.82.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_ACCELERATORS_STORAGEHOLDER_HXX_
32 #define __FRAMEWORK_ACCELERATORS_STORAGEHOLDER_HXX_
34 //===============================================
35 // own includes
37 #include <accelerators/istoragelistener.hxx>
38 #include <threadhelp/threadhelpbase.hxx>
39 #include <general.h>
40 #include <stdtypes.h>
42 //===============================================
43 // interface includes
45 #ifndef __COM_SUN_STAR_EMBED_XSTORAGE_HPP_
46 #include <com/sun/star/embed/XStorage.hpp>
47 #endif
49 #ifndef __COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
50 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 #endif
53 //===============================================
54 // other includes
57 //===============================================
58 // namespace
60 namespace framework
63 #ifdef css
64 #error "Who defines css? I will use it as namespace alias inside header."
65 #else
66 #define css ::com::sun::star
67 #endif
69 //===============================================
70 // definitions
72 //-----------------------------------------------
73 /**
74 TODO document me
76 class StorageHolder : private ThreadHelpBase // attention! Must be the first base class to guarentee right initialize lock ...
78 //-------------------------------------------
79 // types
80 public:
82 /** @short TODO */
83 typedef ::std::vector< css::uno::Reference< css::embed::XStorage > > TStorageList;
85 typedef ::std::vector< IStorageListener* > TStorageListenerList;
87 struct TStorageInfo
89 public:
90 css::uno::Reference< css::embed::XStorage > Storage;
91 sal_Int32 UseCount;
92 TStorageListenerList Listener;
94 TStorageInfo()
95 : UseCount(0)
96 {}
99 /** @short TODO */
100 typedef ::std::hash_map< ::rtl::OUString ,
101 TStorageInfo ,
102 ::rtl::OUStringHash ,
103 ::std::equal_to< ::rtl::OUString > > TPath2StorageInfo;
105 //-------------------------------------------
106 // member
107 private:
109 /** @short TODO */
110 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
112 /** @short TODO */
113 css::uno::Reference< css::embed::XStorage > m_xRoot;
115 /** @short TODO */
116 TPath2StorageInfo m_lStorages;
118 //-------------------------------------------
119 // interface
120 public:
122 //---------------------------------------
123 /** @short TODO
125 StorageHolder();
127 //---------------------------------------
128 /** @short TODO
130 StorageHolder(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
132 //---------------------------------------
133 /** @short TODO
135 virtual ~StorageHolder();
137 //---------------------------------------
138 /** @short TODO
140 virtual void forgetCachedStorages();
142 //---------------------------------------
143 /** @short TODO
145 virtual void setRootStorage(const css::uno::Reference< css::embed::XStorage >& xRoot);
147 //---------------------------------------
148 /** @short TODO
150 virtual css::uno::Reference< css::embed::XStorage > getRootStorage() const;
152 //---------------------------------------
153 /** @short TODO
154 open or get!
156 virtual css::uno::Reference< css::embed::XStorage > openPath(const ::rtl::OUString& sPath ,
157 sal_Int32 nOpenMode);
159 //---------------------------------------
160 /** @short TODO
162 virtual StorageHolder::TStorageList getAllPathStorages(const ::rtl::OUString& sPath);
164 //---------------------------------------
165 /** @short TODO
167 virtual void commitPath(const ::rtl::OUString& sPath);
169 //---------------------------------------
170 /** @short TODO
172 virtual void closePath(const ::rtl::OUString& sPath);
174 //---------------------------------------
175 /** @short TODO
177 virtual void notifyPath(const ::rtl::OUString& sPath);
179 //---------------------------------------
180 /** @short TODO
182 virtual void addStorageListener( IStorageListener* pListener,
183 const ::rtl::OUString& sPath );
185 //---------------------------------------
186 /** @short TODO
188 virtual void removeStorageListener( IStorageListener* pListener,
189 const ::rtl::OUString& sPath );
191 //---------------------------------------
192 /** @short TODO
194 virtual ::rtl::OUString getPathOfStorage(const css::uno::Reference< css::embed::XStorage >& xStorage);
196 //---------------------------------------
197 /** @short TODO
199 virtual css::uno::Reference< css::embed::XStorage > getParentStorage(const css::uno::Reference< css::embed::XStorage >& xChild);
201 //---------------------------------------
202 /** @short TODO
204 virtual css::uno::Reference< css::embed::XStorage > getParentStorage(const ::rtl::OUString& sChildPath);
206 //---------------------------------------
207 /** @short TODO
209 virtual void operator=(const StorageHolder& rCopy);
211 //---------------------------------------
212 /** @short opens a sub element of the specified base storage.
214 @descr First this method try to open the requested sub element
215 using the given open mode. If it failed there is second step,
216 which tries to do the same again ... but removing a might existing
217 WRITE flag from the open mode. The user can supress this fallback
218 handling by setting the parameter bAllowFallback to FALSE.
220 @param xBaseStorage
221 the storage, where the sub element should be searched.
223 @param sSubElement
224 the full name of the sub element.
225 e.g. "default.xml"
227 @param eOpenMode
228 a flag field, which set the open mode for this operation.
230 @param bAllowFallback
231 if eOpenMode contains an ELEMENT_WRITE flag this parameter
232 allow to remove it and try it with the rest of eOpenMode flags
233 again.
235 static css::uno::Reference< css::embed::XStorage > openSubStorageWithFallback(const css::uno::Reference< css::embed::XStorage >& xBaseStorage ,
236 const ::rtl::OUString& sSubStorage ,
237 sal_Int32 eOpenMode ,
238 sal_Bool bAllowFallback);
240 static css::uno::Reference< css::io::XStream > openSubStreamWithFallback(const css::uno::Reference< css::embed::XStorage >& xBaseStorage ,
241 const ::rtl::OUString& sSubStream ,
242 sal_Int32 eOpenMode ,
243 sal_Bool bAllowFallback);
245 //---------------------------------------
246 // helper
247 private:
249 //-----------------------------------
250 /** @short TODO
252 static ::rtl::OUString impl_st_normPath(const ::rtl::OUString& sPath);
254 //-----------------------------------
255 /** @short TODO
257 static OUStringList impl_st_parsePath(const ::rtl::OUString& sPath);
260 #undef css // dont let it out!
262 } // namespace framework
264 #endif // __FRAMEWORK_ACCELERATORS_STORAGEHOLDER_HXX_