Update git submodules
[LibreOffice.git] / framework / source / inc / accelerators / storageholder.hxx
blob355bedeaa6626c808c16ee1f9225dbc15e7d6e82
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <com/sun/star/embed/XStorage.hpp>
24 #include <mutex>
25 #include <unordered_map>
26 #include <vector>
28 namespace framework
31 class XMLBasedAcceleratorConfiguration;
32 /**
33 TODO document me
35 class StorageHolder final
38 // types
39 public:
41 /** @short TODO */
42 typedef ::std::vector< css::uno::Reference< css::embed::XStorage > > TStorageList;
44 typedef ::std::vector< XMLBasedAcceleratorConfiguration* > TStorageListenerList;
46 struct TStorageInfo
48 public:
49 css::uno::Reference< css::embed::XStorage > Storage;
50 sal_Int32 UseCount;
51 TStorageListenerList Listener;
53 TStorageInfo()
54 : UseCount(0)
58 /** @short TODO */
59 typedef std::unordered_map< OUString,
60 TStorageInfo > TPath2StorageInfo;
62 // member
63 private:
64 mutable std::mutex m_mutex;
66 /** @short TODO */
67 css::uno::Reference< css::embed::XStorage > m_xRoot;
69 /** @short TODO */
70 TPath2StorageInfo m_lStorages;
72 // interface
73 public:
75 /** @short TODO
77 StorageHolder();
79 /** @short TODO
81 ~StorageHolder();
83 /** @short TODO
85 void forgetCachedStorages();
87 /** @short TODO
89 void setRootStorage(const css::uno::Reference< css::embed::XStorage >& xRoot);
91 /** @short TODO
93 css::uno::Reference< css::embed::XStorage > getRootStorage() const;
95 /** @short TODO
96 open or get!
98 css::uno::Reference< css::embed::XStorage > openPath(const OUString& sPath ,
99 sal_Int32 nOpenMode);
101 /** @short TODO
103 StorageHolder::TStorageList getAllPathStorages(const OUString& sPath);
105 /** @short TODO
107 void commitPath(const OUString& sPath);
109 /** @short TODO
111 void closePath(const OUString& sPath);
113 /** @short TODO
115 void notifyPath(const OUString& sPath);
117 /** @short TODO
119 void addStorageListener( XMLBasedAcceleratorConfiguration* pListener,
120 const OUString& sPath );
122 /** @short TODO
124 void removeStorageListener( XMLBasedAcceleratorConfiguration* pListener,
125 const OUString& sPath );
127 /** @short TODO
129 OUString getPathOfStorage(const css::uno::Reference< css::embed::XStorage >& xStorage);
131 /** @short TODO
133 css::uno::Reference< css::embed::XStorage > getParentStorage(const css::uno::Reference< css::embed::XStorage >& xChild);
135 /** @short TODO
137 css::uno::Reference< css::embed::XStorage > getParentStorage(const OUString& sChildPath);
139 /** @short TODO
141 StorageHolder& operator=(const StorageHolder& rCopy);
143 /** @short opens a sub element of the specified base storage.
144 If eOpenMode contains an ELEMENT_WRITE flag remove it and try it with the rest of eOpenMode flags
145 again.
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.
153 @param xBaseStorage
154 the storage, where the sub element should be searched.
156 @param sSubElement
157 the full name of the sub element.
158 e.g. "default.xml"
160 @param eOpenMode
161 a flag field, which set the open mode for this operation.
164 static css::uno::Reference< css::embed::XStorage > openSubStorageWithFallback(const css::uno::Reference< css::embed::XStorage >& xBaseStorage ,
165 const OUString& sSubStorage ,
166 sal_Int32 eOpenMode);
168 // helper
169 private:
171 /** @short TODO
173 static OUString impl_st_normPath(const OUString& sPath);
175 /** @short TODO
177 static std::vector<OUString> impl_st_parsePath(std::u16string_view sPath);
180 } // namespace framework
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */