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
32namespace 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
39namespace oox {
40
41
42class StorageBase;
43typedef std::shared_ptr< StorageBase > StorageRef;
44
52{
53public:
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
139protected:
141 explicit StorageBase( const StorageBase& rParentStorage, OUString aStorageName, bool bReadOnly );
142
143private:
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
174private:
177 css::uno::Reference< css::io::XInputStream >
179 css::uno::Reference< css::io::XStream >
181 OUString maParentPath;
182 OUString maStorageName;
185};
186
187
188} // namespace oox
189
190#endif
191
192/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Template for a map of ref-counted objects with additional accessor functions.
Definition: refmap.hxx:41
Base class for storage access implementations.
Definition: storagebase.hxx:52
virtual css::uno::Reference< css::embed::XStorage > implGetXStorage() const =0
Returns the com.sun.star.embed.XStorage interface of the current storage.
virtual bool implIsStorage() const =0
Returns true, if the object represents a valid storage.
StorageBase(const css::uno::Reference< css::io::XInputStream > &rxInStream, bool bBaseStreamAccess)
const OUString & getName() const
Returns the element name of this storage.
Definition: storagebase.hxx:79
StorageBase(const StorageBase &)=delete
bool mbReadOnly
True = storage opened read-only (based on input stream).
css::uno::Reference< css::io::XStream > mxOutStream
Cached base output stream (to keep it alive).
css::uno::Reference< css::io::XInputStream > mxInStream
Cached base input stream (to keep it alive).
bool mbBaseStreamAccess
True = access base streams with empty stream name.
StorageBase & operator=(const StorageBase &)=delete
OUString maStorageName
Name of this storage, if it is a substorage.
virtual void implCommit() const =0
Commits the current storage.
RefMap< OUString, StorageBase > maSubStorages
Map of direct sub storages.
virtual css::uno::Reference< css::io::XInputStream > implOpenInputStream(const OUString &rElementName)=0
Implementation of opening an input stream element.
virtual css::uno::Reference< css::io::XOutputStream > implOpenOutputStream(const OUString &rElementName)=0
Implementation of opening an output stream element.
StorageBase(const css::uno::Reference< css::io::XStream > &rxOutStream, bool bBaseStreamAccess)
bool isReadOnly() const
Returns true, if the storage operates in read-only mode (based on an input stream).
Definition: storagebase.hxx:72
virtual StorageRef implOpenSubStorage(const OUString &rElementName, bool bCreate)=0
Implementation of opening a storage element.
virtual void implGetElementNames(::std::vector< OUString > &orElementNames) const =0
Returns the names of all elements of this storage.
OUString maParentPath
Full path of parent storage.
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
std::shared_ptr< StorageBase > StorageRef
Definition: storagebase.hxx:42