1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef STORAGESTREAM_HXX
25 #define STORAGESTREAM_HXX
26 
27 #include "dbaccessdllapi.h"
28 
29 /** === begin UNO includes === **/
30 #include <com/sun/star/embed/XStorage.hpp>
31 /** === end UNO includes === **/
32 
33 namespace comphelper
34 {
35     class ComponentContext;
36 }
37 
38 //........................................................................
39 namespace dbaccess
40 {
41 //........................................................................
42 
43 	//====================================================================
44 	//= StorageOutputStream
45 	//====================================================================
46     /** convenience wrapper around a stream living in a storage
47     */
48 	class DBACCESS_DLLPRIVATE StorageOutputStream
49 	{
50     public:
51         StorageOutputStream(
52             const ::comphelper::ComponentContext& i_rContext,
53             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rParentStorage,
54             const ::rtl::OUString& i_rStreamName
55         );
56         virtual ~StorageOutputStream();
57 
58         /** simply calls closeOutput on our output stream, override to extend/modify this behavior
59         */
60         virtual void close();
61 
62     protected:
getContext() const63         const ::comphelper::ComponentContext&   getContext() const { return m_rContext; }
64         const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >&
getOutputStream() const65                                                 getOutputStream() const { return m_xOutputStream; }
66 
67     private:
68         const ::comphelper::ComponentContext&   m_rContext;
69               ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
70                                                 m_xOutputStream;
71 	};
72 
73 	//====================================================================
74 	//= StorageInputStream
75 	//====================================================================
76     /** convenience wrapper around a stream living in a storage
77     */
78 	class DBACCESS_DLLPRIVATE StorageInputStream
79 	{
80     public:
81         StorageInputStream(
82             const ::comphelper::ComponentContext& i_rContext,
83             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rParentStorage,
84             const ::rtl::OUString& i_rStreamName
85         );
86         virtual ~StorageInputStream();
87 
88         /** simply calls closeInput on our input stream, override to extend/modify this behavior
89         */
90         virtual void close();
91 
92     protected:
getContext() const93         const ::comphelper::ComponentContext&   getContext() const { return m_rContext; }
94         const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >&
getInputStream() const95                                                 getInputStream() const { return m_xInputStream; }
96 
97     private:
98         const ::comphelper::ComponentContext&   m_rContext;
99               ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
100                                                 m_xInputStream;
101 	};
102 
103 //........................................................................
104 } // namespace dbaccess
105 //........................................................................
106 
107 #endif // STORAGESTREAM_HXX
108