xref: /AOO41X/main/dbaccess/source/core/recovery/storagestream.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * Copyright 2009 by Sun Microsystems, Inc.
5 *
6 * OpenOffice.org - a multi-platform office productivity suite
7 *
8 * This file is part of OpenOffice.org.
9 *
10 * OpenOffice.org is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License version 3
12 * only, as published by the Free Software Foundation.
13 *
14 * OpenOffice.org is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU Lesser General Public License version 3 for more details
18 * (a copy is included in the LICENSE file that accompanied this code).
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with OpenOffice.org.  If not, see
22 * <http://www.openoffice.org/license.html>
23 * for a copy of the LGPLv3 License.
24 ************************************************************************/
25 
26 #ifndef STORAGESTREAM_HXX
27 #define STORAGESTREAM_HXX
28 
29 #include "dbaccessdllapi.h"
30 
31 /** === begin UNO includes === **/
32 #include <com/sun/star/embed/XStorage.hpp>
33 /** === end UNO includes === **/
34 
35 namespace comphelper
36 {
37     class ComponentContext;
38 }
39 
40 //........................................................................
41 namespace dbaccess
42 {
43 //........................................................................
44 
45 	//====================================================================
46 	//= StorageOutputStream
47 	//====================================================================
48     /** convenience wrapper around a stream living in a storage
49     */
50 	class DBACCESS_DLLPRIVATE StorageOutputStream
51 	{
52     public:
53         StorageOutputStream(
54             const ::comphelper::ComponentContext& i_rContext,
55             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rParentStorage,
56             const ::rtl::OUString& i_rStreamName
57         );
58         virtual ~StorageOutputStream();
59 
60         /** simply calls closeOutput on our output stream, override to extend/modify this behavior
61         */
62         virtual void close();
63 
64     protected:
65         const ::comphelper::ComponentContext&   getContext() const { return m_rContext; }
66         const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >&
67                                                 getOutputStream() const { return m_xOutputStream; }
68 
69     private:
70         const ::comphelper::ComponentContext&   m_rContext;
71               ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
72                                                 m_xOutputStream;
73 	};
74 
75 	//====================================================================
76 	//= StorageInputStream
77 	//====================================================================
78     /** convenience wrapper around a stream living in a storage
79     */
80 	class DBACCESS_DLLPRIVATE StorageInputStream
81 	{
82     public:
83         StorageInputStream(
84             const ::comphelper::ComponentContext& i_rContext,
85             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rParentStorage,
86             const ::rtl::OUString& i_rStreamName
87         );
88         virtual ~StorageInputStream();
89 
90         /** simply calls closeInput on our input stream, override to extend/modify this behavior
91         */
92         virtual void close();
93 
94     protected:
95         const ::comphelper::ComponentContext&   getContext() const { return m_rContext; }
96         const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >&
97                                                 getInputStream() const { return m_xInputStream; }
98 
99     private:
100         const ::comphelper::ComponentContext&   m_rContext;
101               ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
102                                                 m_xInputStream;
103 	};
104 
105 //........................................................................
106 } // namespace dbaccess
107 //........................................................................
108 
109 #endif // STORAGESTREAM_HXX
110