1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_STORAGEHOLDER_HXX
21 #define INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_STORAGEHOLDER_HXX
23 #include <accelerators/istoragelistener.hxx>
27 #include <com/sun/star/embed/XStorage.hpp>
42 typedef ::std::vector
< css::uno::Reference
< css::embed::XStorage
> > TStorageList
;
44 typedef ::std::vector
< IStorageListener
* > TStorageListenerList
;
49 css::uno::Reference
< css::embed::XStorage
> Storage
;
51 TStorageListenerList Listener
;
59 typedef std::unordered_map
< OUString
,
62 std::equal_to
< OUString
> > TPath2StorageInfo
;
66 mutable osl::Mutex m_mutex
;
69 css::uno::Reference
< css::embed::XStorage
> m_xRoot
;
72 TPath2StorageInfo m_lStorages
;
83 virtual ~StorageHolder();
87 void forgetCachedStorages();
91 void setRootStorage(const css::uno::Reference
< css::embed::XStorage
>& xRoot
);
95 css::uno::Reference
< css::embed::XStorage
> getRootStorage() const;
100 css::uno::Reference
< css::embed::XStorage
> openPath(const OUString
& sPath
,
101 sal_Int32 nOpenMode
);
105 StorageHolder::TStorageList
getAllPathStorages(const OUString
& sPath
);
109 void commitPath(const OUString
& sPath
);
113 void closePath(const OUString
& sPath
);
117 void notifyPath(const OUString
& sPath
);
121 void addStorageListener( IStorageListener
* pListener
,
122 const OUString
& sPath
);
126 void removeStorageListener( IStorageListener
* pListener
,
127 const OUString
& sPath
);
131 OUString
getPathOfStorage(const css::uno::Reference
< css::embed::XStorage
>& xStorage
);
135 css::uno::Reference
< css::embed::XStorage
> getParentStorage(const css::uno::Reference
< css::embed::XStorage
>& xChild
);
139 css::uno::Reference
< css::embed::XStorage
> getParentStorage(const OUString
& sChildPath
);
143 void operator=(const StorageHolder
& rCopy
);
145 /** @short opens a sub element of the specified base storage.
147 @descr First this method try to open the requested sub element
148 using the given open mode. If it failed there is second step,
149 which tries to do the same again ... but removing a might existing
150 WRITE flag from the open mode. The user can suppress this fallback
151 handling by setting the parameter bAllowFallback to sal_False.
154 the storage, where the sub element should be searched.
157 the full name of the sub element.
161 a flag field, which set the open mode for this operation.
163 @param bAllowFallback
164 if eOpenMode contains an ELEMENT_WRITE flag this parameter
165 allow to remove it and try it with the rest of eOpenMode flags
168 static css::uno::Reference
< css::embed::XStorage
> openSubStorageWithFallback(const css::uno::Reference
< css::embed::XStorage
>& xBaseStorage
,
169 const OUString
& sSubStorage
,
170 sal_Int32 eOpenMode
,
171 bool bAllowFallback
);
173 static css::uno::Reference
< css::io::XStream
> openSubStreamWithFallback(const css::uno::Reference
< css::embed::XStorage
>& xBaseStorage
,
174 const OUString
& sSubStream
,
175 sal_Int32 eOpenMode
,
176 bool bAllowFallback
);
183 static OUString
impl_st_normPath(const OUString
& sPath
);
187 static OUStringList
impl_st_parsePath(const OUString
& sPath
);
190 } // namespace framework
192 #endif // INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_STORAGEHOLDER_HXX
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */