update dev300-m58
[ooovba.git] / ucb / source / ucp / tdoc / tdoc_storage.hxx
blob0c858d5bd4e8ca8a0340545dce639f10529b014b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tdoc_storage.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_TDOC_STORAGE_HXX
32 #define INCLUDED_TDOC_STORAGE_HXX
34 #include <map>
36 #include "osl/mutex.hxx"
37 #include "rtl/ref.hxx"
38 #include "salhelper/simplereferenceobject.hxx"
40 #include "com/sun/star/embed/XStorage.hpp"
42 namespace tdoc_ucp {
44 enum StorageAccessMode
46 READ, // Note: might be writable as well
47 READ_WRITE_NOCREATE,
48 READ_WRITE_CREATE
51 class Storage;
52 class OfficeDocumentsManager;
54 class StorageElementFactory : public salhelper::SimpleReferenceObject
56 public:
57 StorageElementFactory(
58 const com::sun::star::uno::Reference<
59 com::sun::star::lang::XMultiServiceFactory > & xSMgr,
60 const rtl::Reference< OfficeDocumentsManager > & xDocsMgr );
61 ~StorageElementFactory();
63 com::sun::star::uno::Reference< com::sun::star::embed::XStorage >
64 createTemporaryStorage()
65 throw ( com::sun::star::uno::Exception,
66 com::sun::star::uno::RuntimeException );
68 com::sun::star::uno::Reference< com::sun::star::embed::XStorage >
69 createStorage( const rtl::OUString & rUri, StorageAccessMode eMode )
70 throw ( com::sun::star::embed::InvalidStorageException,
71 com::sun::star::lang::IllegalArgumentException,
72 com::sun::star::io::IOException,
73 com::sun::star::embed::StorageWrappedTargetException,
74 com::sun::star::uno::RuntimeException );
76 com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
77 createInputStream( const rtl::OUString & rUri,
78 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::XOutputStream >
87 createOutputStream( const rtl::OUString & rUri,
88 const rtl::OUString & rPassword,
89 bool bTruncate )
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 );
97 com::sun::star::uno::Reference< com::sun::star::io::XStream >
98 createStream( const rtl::OUString & rUri,
99 const rtl::OUString & rPassword,
100 bool bTruncate )
101 throw ( com::sun::star::embed::InvalidStorageException,
102 com::sun::star::lang::IllegalArgumentException,
103 com::sun::star::io::IOException,
104 com::sun::star::embed::StorageWrappedTargetException,
105 com::sun::star::packages::WrongPasswordException,
106 com::sun::star::uno::RuntimeException );
108 private:
109 friend class Storage;
111 void releaseElement( Storage * pElement ) SAL_THROW(());
113 com::sun::star::uno::Reference< com::sun::star::embed::XStorage >
114 queryParentStorage( 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::embed::XStorage >
123 queryStorage( const com::sun::star::uno::Reference<
124 com::sun::star::embed::XStorage > & xParentStorage,
125 const rtl::OUString & rUri,
126 StorageAccessMode eMode )
127 throw ( com::sun::star::embed::InvalidStorageException,
128 com::sun::star::lang::IllegalArgumentException,
129 com::sun::star::io::IOException,
130 com::sun::star::embed::StorageWrappedTargetException,
131 com::sun::star::uno::RuntimeException );
133 com::sun::star::uno::Reference< com::sun::star::io::XStream >
134 queryStream( const com::sun::star::uno::Reference<
135 com::sun::star::embed::XStorage > & xParentStorage,
136 const rtl::OUString & rPassword,
137 const rtl::OUString & rUri,
138 StorageAccessMode eMode,
139 bool bTruncate /* ignored for read-only streams */ )
140 throw ( com::sun::star::embed::InvalidStorageException,
141 com::sun::star::lang::IllegalArgumentException,
142 com::sun::star::io::IOException,
143 com::sun::star::embed::StorageWrappedTargetException,
144 com::sun::star::packages::WrongPasswordException,
145 com::sun::star::uno::RuntimeException );
147 struct ltstrbool
149 bool operator()(
150 const std::pair< rtl::OUString, bool > & s1,
151 const std::pair< rtl::OUString, bool > & s2 ) const
153 if ( s1.first < s2.first )
154 return true;
155 else if ( s1.first == s2.first )
156 return ( !s1.second && s2.second );
157 else
158 return false;
162 // key: pair< storageuri, iswritable >
163 typedef std::map<
164 std::pair< rtl::OUString, bool >, Storage *, ltstrbool > StorageMap;
166 StorageMap m_aMap;
167 osl::Mutex m_aMutex;
168 rtl::Reference< OfficeDocumentsManager > m_xDocsMgr;
169 com::sun::star::uno::Reference<
170 com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
173 } // namespace tdoc_ucp
175 #endif /* !INCLUDED_TDOC_STORAGE_HXX */