LibreOffice Module ucb (master) 1
tdoc_storage.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#pragma once
21
22#include <map>
23
24#include <osl/mutex.hxx>
25#include <rtl/ref.hxx>
27
28#include <com/sun/star/embed/XStorage.hpp>
29#include <com/sun/star/uno/XComponentContext.hpp>
30
31namespace tdoc_ucp {
32
34 {
35 READ, // Note: might be writable as well
38 };
39
40 class Storage;
41 class OfficeDocumentsManager;
42
44 {
45 public:
47 css::uno::Reference< css::uno::XComponentContext > xContext,
49 virtual ~StorageElementFactory() override;
50
53 css::uno::Reference< css::embed::XStorage >
55
61 css::uno::Reference< css::embed::XStorage >
62 createStorage( const OUString & rUri, StorageAccessMode eMode );
63
70 css::uno::Reference< css::io::XInputStream >
71 createInputStream( const OUString & rUri,
72 const OUString & rPassword );
73
80 css::uno::Reference< css::io::XOutputStream >
81 createOutputStream( const OUString & rUri,
82 const OUString & rPassword,
83 bool bTruncate );
84
91 css::uno::Reference< css::io::XStream >
92 createStream( const OUString & rUri,
93 const OUString & rPassword,
94 bool bTruncate );
95
96 private:
97 friend class Storage;
98
99 void releaseElement( Storage const * pElement );
100
106 css::uno::Reference< css::embed::XStorage >
107 queryParentStorage( const OUString & rUri,
108 StorageAccessMode eMode );
109
115 css::uno::Reference< css::embed::XStorage >
116 queryStorage( const css::uno::Reference<
117 css::embed::XStorage > & xParentStorage,
118 const OUString & rUri,
119 StorageAccessMode eMode );
120
127 css::uno::Reference< css::io::XStream >
128 queryStream( const css::uno::Reference<
129 css::embed::XStorage > & xParentStorage,
130 const OUString & rUri,
131 const OUString & rPassword,
132 StorageAccessMode eMode,
133 bool bTruncate /* ignored for read-only streams */ );
134
136 {
138 const std::pair< OUString, bool > & s1,
139 const std::pair< OUString, bool > & s2 ) const
140 {
141 if ( s1.first < s2.first )
142 return true;
143 else if ( s1.first == s2.first )
144 return ( !s1.second && s2.second );
145 else
146 return false;
147 }
148 };
149
150 // key: pair< storageuri, iswritable >
151 typedef std::map<
152 std::pair< OUString, bool >, Storage *, ltstrbool > StorageMap;
153
155 osl::Mutex m_aMutex;
157 css::uno::Reference< css::uno::XComponentContext > m_xContext;
158 };
159
160} // namespace tdoc_ucp
161
162/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::embed::XStorage > createStorage(const OUString &rUri, StorageAccessMode eMode)
rtl::Reference< OfficeDocumentsManager > m_xDocsMgr
css::uno::Reference< css::embed::XStorage > queryParentStorage(const OUString &rUri, StorageAccessMode eMode)
StorageElementFactory(css::uno::Reference< css::uno::XComponentContext > xContext, rtl::Reference< OfficeDocumentsManager > xDocsMgr)
css::uno::Reference< css::io::XInputStream > createInputStream(const OUString &rUri, const OUString &rPassword)
css::uno::Reference< css::io::XStream > queryStream(const css::uno::Reference< css::embed::XStorage > &xParentStorage, const OUString &rUri, const OUString &rPassword, StorageAccessMode eMode, bool bTruncate)
css::uno::Reference< css::io::XOutputStream > createOutputStream(const OUString &rUri, const OUString &rPassword, bool bTruncate)
css::uno::Reference< css::io::XStream > createStream(const OUString &rUri, const OUString &rPassword, bool bTruncate)
virtual ~StorageElementFactory() override
void releaseElement(Storage const *pElement)
std::map< std::pair< OUString, bool >, Storage *, ltstrbool > StorageMap
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Reference< css::embed::XStorage > queryStorage(const css::uno::Reference< css::embed::XStorage > &xParentStorage, const OUString &rUri, StorageAccessMode eMode)
css::uno::Reference< css::embed::XStorage > createTemporaryStorage()
Mode eMode
@ READ_WRITE_NOCREATE
@ READ_WRITE_CREATE
bool operator()(const std::pair< OUString, bool > &s1, const std::pair< OUString, bool > &s2) const