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 .
24 #include <osl/mutex.hxx>
25 #include <rtl/ref.hxx>
26 #include <salhelper/simplereferenceobject.hxx>
28 #include <com/sun/star/embed/XStorage.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
33 enum StorageAccessMode
35 READ
, // Note: might be writable as well
41 class OfficeDocumentsManager
;
43 class StorageElementFactory
: public salhelper::SimpleReferenceObject
46 StorageElementFactory(
47 const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
,
48 const rtl::Reference
< OfficeDocumentsManager
> & xDocsMgr
);
49 virtual ~StorageElementFactory() override
;
51 /// @throws css::uno::Exception
52 /// @throws css::uno::RuntimeException
53 css::uno::Reference
< css::embed::XStorage
>
54 createTemporaryStorage();
56 /// @throws css::embed::InvalidStorageException
57 /// @throws css::lang::IllegalArgumentException
58 /// @throws css::io::IOException
59 /// @throws css::embed::StorageWrappedTargetException
60 /// @throws css::uno::RuntimeException
61 css::uno::Reference
< css::embed::XStorage
>
62 createStorage( const OUString
& rUri
, StorageAccessMode eMode
);
64 /// @throws css::embed::InvalidStorageException
65 /// @throws css::lang::IllegalArgumentException
66 /// @throws css::io::IOException
67 /// @throws css::embed::StorageWrappedTargetException
68 /// @throws css::packages::WrongPasswordException
69 /// @throws css::uno::RuntimeException
70 css::uno::Reference
< css::io::XInputStream
>
71 createInputStream( const OUString
& rUri
,
72 const OUString
& rPassword
);
74 /// @throws css::embed::InvalidStorageException
75 /// @throws css::lang::IllegalArgumentException
76 /// @throws css::io::IOException
77 /// @throws css::embed::StorageWrappedTargetException
78 /// @throws css::packages::WrongPasswordException
79 /// @throws css::uno::RuntimeException
80 css::uno::Reference
< css::io::XOutputStream
>
81 createOutputStream( const OUString
& rUri
,
82 const OUString
& rPassword
,
85 /// @throws css::embed::InvalidStorageException
86 /// @throws css::lang::IllegalArgumentException
87 /// @throws css::io::IOException
88 /// @throws css::embed::StorageWrappedTargetException
89 /// @throws css::packages::WrongPasswordException
90 /// @throws css::uno::RuntimeException
91 css::uno::Reference
< css::io::XStream
>
92 createStream( const OUString
& rUri
,
93 const OUString
& rPassword
,
99 void releaseElement( Storage
const * pElement
);
101 /// @throws css::embed::InvalidStorageException
102 /// @throws css::lang::IllegalArgumentException
103 /// @throws css::io::IOException
104 /// @throws css::embed::StorageWrappedTargetException
105 /// @throws css::uno::RuntimeException
106 css::uno::Reference
< css::embed::XStorage
>
107 queryParentStorage( const OUString
& rUri
,
108 StorageAccessMode eMode
);
110 /// @throws css::embed::InvalidStorageException
111 /// @throws css::lang::IllegalArgumentException
112 /// @throws css::io::IOException
113 /// @throws css::embed::StorageWrappedTargetException
114 /// @throws css::uno::RuntimeException
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
);
121 /// @throws css::embed::InvalidStorageException
122 /// @throws css::lang::IllegalArgumentException
123 /// @throws css::io::IOException
124 /// @throws css::embed::StorageWrappedTargetException
125 /// @throws css::packages::WrongPasswordException
126 /// @throws css::uno::RuntimeException
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 */ );
138 const std::pair
< OUString
, bool > & s1
,
139 const std::pair
< OUString
, bool > & s2
) const
141 if ( s1
.first
< s2
.first
)
143 else if ( s1
.first
== s2
.first
)
144 return ( !s1
.second
&& s2
.second
);
150 // key: pair< storageuri, iswritable >
152 std::pair
< OUString
, bool >, Storage
*, ltstrbool
> StorageMap
;
156 rtl::Reference
< OfficeDocumentsManager
> m_xDocsMgr
;
157 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
160 } // namespace tdoc_ucp
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */