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 .
20 #ifndef INCLUDED_TDOC_STORAGE_HXX
21 #define INCLUDED_TDOC_STORAGE_HXX
25 #include "osl/mutex.hxx"
26 #include "rtl/ref.hxx"
27 #include "salhelper/simplereferenceobject.hxx"
29 #include "com/sun/star/embed/XStorage.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 com::sun::star::uno::Reference
<
48 com::sun::star::lang::XMultiServiceFactory
> & xSMgr
,
49 const rtl::Reference
< OfficeDocumentsManager
> & xDocsMgr
);
50 ~StorageElementFactory();
52 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>
53 createTemporaryStorage()
54 throw ( com::sun::star::uno::Exception
,
55 com::sun::star::uno::RuntimeException
);
57 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>
58 createStorage( const rtl::OUString
& rUri
, StorageAccessMode eMode
)
59 throw ( com::sun::star::embed::InvalidStorageException
,
60 com::sun::star::lang::IllegalArgumentException
,
61 com::sun::star::io::IOException
,
62 com::sun::star::embed::StorageWrappedTargetException
,
63 com::sun::star::uno::RuntimeException
);
65 com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
>
66 createInputStream( const rtl::OUString
& rUri
,
67 const rtl::OUString
& rPassword
)
68 throw ( com::sun::star::embed::InvalidStorageException
,
69 com::sun::star::lang::IllegalArgumentException
,
70 com::sun::star::io::IOException
,
71 com::sun::star::embed::StorageWrappedTargetException
,
72 com::sun::star::packages::WrongPasswordException
,
73 com::sun::star::uno::RuntimeException
);
75 com::sun::star::uno::Reference
< com::sun::star::io::XOutputStream
>
76 createOutputStream( const rtl::OUString
& rUri
,
77 const rtl::OUString
& rPassword
,
79 throw ( com::sun::star::embed::InvalidStorageException
,
80 com::sun::star::lang::IllegalArgumentException
,
81 com::sun::star::io::IOException
,
82 com::sun::star::embed::StorageWrappedTargetException
,
83 com::sun::star::packages::WrongPasswordException
,
84 com::sun::star::uno::RuntimeException
);
86 com::sun::star::uno::Reference
< com::sun::star::io::XStream
>
87 createStream( const rtl::OUString
& rUri
,
88 const rtl::OUString
& rPassword
,
90 throw ( com::sun::star::embed::InvalidStorageException
,
91 com::sun::star::lang::IllegalArgumentException
,
92 com::sun::star::io::IOException
,
93 com::sun::star::embed::StorageWrappedTargetException
,
94 com::sun::star::packages::WrongPasswordException
,
95 com::sun::star::uno::RuntimeException
);
100 void releaseElement( Storage
* pElement
) SAL_THROW(());
102 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>
103 queryParentStorage( const rtl::OUString
& rUri
,
104 StorageAccessMode eMode
)
105 throw ( com::sun::star::embed::InvalidStorageException
,
106 com::sun::star::lang::IllegalArgumentException
,
107 com::sun::star::io::IOException
,
108 com::sun::star::embed::StorageWrappedTargetException
,
109 com::sun::star::uno::RuntimeException
);
111 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>
112 queryStorage( const com::sun::star::uno::Reference
<
113 com::sun::star::embed::XStorage
> & xParentStorage
,
114 const rtl::OUString
& rUri
,
115 StorageAccessMode eMode
)
116 throw ( com::sun::star::embed::InvalidStorageException
,
117 com::sun::star::lang::IllegalArgumentException
,
118 com::sun::star::io::IOException
,
119 com::sun::star::embed::StorageWrappedTargetException
,
120 com::sun::star::uno::RuntimeException
);
122 com::sun::star::uno::Reference
< com::sun::star::io::XStream
>
123 queryStream( const com::sun::star::uno::Reference
<
124 com::sun::star::embed::XStorage
> & xParentStorage
,
125 const rtl::OUString
& rPassword
,
126 const rtl::OUString
& rUri
,
127 StorageAccessMode eMode
,
128 bool bTruncate
/* ignored for read-only streams */ )
129 throw ( com::sun::star::embed::InvalidStorageException
,
130 com::sun::star::lang::IllegalArgumentException
,
131 com::sun::star::io::IOException
,
132 com::sun::star::embed::StorageWrappedTargetException
,
133 com::sun::star::packages::WrongPasswordException
,
134 com::sun::star::uno::RuntimeException
);
139 const std::pair
< rtl::OUString
, bool > & s1
,
140 const std::pair
< rtl::OUString
, bool > & s2
) const
142 if ( s1
.first
< s2
.first
)
144 else if ( s1
.first
== s2
.first
)
145 return ( !s1
.second
&& s2
.second
);
151 // key: pair< storageuri, iswritable >
153 std::pair
< rtl::OUString
, bool >, Storage
*, ltstrbool
> StorageMap
;
157 rtl::Reference
< OfficeDocumentsManager
> m_xDocsMgr
;
158 com::sun::star::uno::Reference
<
159 com::sun::star::lang::XMultiServiceFactory
> m_xSMgr
;
162 } // namespace tdoc_ucp
164 #endif /* !INCLUDED_TDOC_STORAGE_HXX */
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */