LibreOffice Module oox (master)  1
storagebase.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_OOX_HELPER_STORAGEBASE_HXX
21 #define INCLUDED_OOX_HELPER_STORAGEBASE_HXX
22 
23 #include <functional>
24 #include <memory>
25 #include <vector>
26 
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <oox/dllapi.h>
29 #include <oox/helper/refmap.hxx>
30 #include <rtl/ustring.hxx>
31 
32 namespace com::sun::star {
33  namespace embed { class XStorage; }
34  namespace io { class XInputStream; }
35  namespace io { class XOutputStream; }
36  namespace io { class XStream; }
37 }
38 
39 namespace oox {
40 
41 
43 typedef std::shared_ptr< StorageBase > StorageRef;
44 
52 {
53 public:
54  explicit StorageBase(
55  const css::uno::Reference< css::io::XInputStream >& rxInStream,
56  bool bBaseStreamAccess );
57 
58  explicit StorageBase(
59  const css::uno::Reference< css::io::XStream >& rxOutStream,
60  bool bBaseStreamAccess );
61 
62  virtual ~StorageBase();
63 
65  bool isStorage() const;
66 
68  bool isRootStorage() const;
69 
72  bool isReadOnly() const { return mbReadOnly;}
73 
75  css::uno::Reference< css::embed::XStorage >
76  getXStorage() const;
77 
79  const OUString& getName() const { return maStorageName;}
80 
82  OUString getPath() const;
83 
86  void getElementNames( ::std::vector< OUString >& orElementNames ) const;
87 
97  StorageRef openSubStorage( const OUString& rStorageName, bool bCreateMissing );
98 
107  css::uno::Reference< css::io::XInputStream >
108  openInputStream( const OUString& rStreamName );
109 
118  css::uno::Reference< css::io::XOutputStream >
119  openOutputStream( const OUString& rStreamName );
120 
130  void copyToStorage( StorageBase& rDestStrg, const OUString& rElementName );
131 
134  void copyStorageToStorage( StorageBase& rDestStrg );
135 
137  void commit();
138 
139 protected:
141  explicit StorageBase( const StorageBase& rParentStorage, const OUString& rStorageName, bool bReadOnly );
142 
143 private:
144  StorageBase( const StorageBase& ) = delete;
145  StorageBase& operator=( const StorageBase& ) = delete;
146 
148  virtual bool implIsStorage() const = 0;
149 
151  virtual css::uno::Reference< css::embed::XStorage >
152  implGetXStorage() const = 0;
153 
155  virtual void implGetElementNames( ::std::vector< OUString >& orElementNames ) const = 0;
156 
158  virtual StorageRef implOpenSubStorage( const OUString& rElementName, bool bCreate ) = 0;
159 
161  virtual css::uno::Reference< css::io::XInputStream >
162  implOpenInputStream( const OUString& rElementName ) = 0;
163 
165  virtual css::uno::Reference< css::io::XOutputStream >
166  implOpenOutputStream( const OUString& rElementName ) = 0;
167 
169  virtual void implCommit() const = 0;
170 
172  StorageRef getSubStorage( const OUString& rElementName, bool bCreateMissing );
173 
174 private:
177  css::uno::Reference< css::io::XInputStream >
179  css::uno::Reference< css::io::XStream >
181  OUString maParentPath;
182  OUString maStorageName;
184  bool mbReadOnly;
185 };
186 
187 
188 } // namespace oox
189 
190 #endif
191 
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
exports com.sun.star. io
exports com.sun.star. embed
std::shared_ptr< StorageBase > StorageRef
Definition: storagebase.hxx:42
Template for a map of ref-counted objects with additional accessor functions.
Definition: refmap.hxx:39
bool mbReadOnly
True = storage opened read-only (based on input stream).
RefMap< OUString, StorageBase > maSubStorages
Map of direct sub storages.
OUString maParentPath
Full path of parent storage.
css::uno::Reference< css::io::XStream > mxOutStream
Cached base output stream (to keep it alive).
Base class for storage access implementations.
Definition: storagebase.hxx:51
OUString maStorageName
Name of this storage, if it is a substorage.
const OUString & getName() const
Returns the element name of this storage.
Definition: storagebase.hxx:79
bool isReadOnly() const
Returns true, if the storage operates in read-only mode (based on an input stream).
Definition: storagebase.hxx:72
bool mbBaseStreamAccess
True = access base streams with empty stream name.
css::uno::Reference< css::io::XInputStream > mxInStream
Cached base input stream (to keep it alive).
#define OOX_DLLPUBLIC
Definition: dllapi.h:28