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 #ifndef CONNECTIVITY_HSQLDB_STORAGE_HXX
24 #define CONNECTIVITY_HSQLDB_STORAGE_HXX
25 
26 #include <cppuhelper/compbase6.hxx>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/io/XStream.hpp>
30 #include <com/sun/star/io/XInputStream.hpp>
31 #include <com/sun/star/io/XOutputStream.hpp>
32 #include <com/sun/star/io/XSeekable.hpp>
33 #include <com/sun/star/embed/XStorage.hpp>
34 #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
35 #include <com/sun/star/lang/XInitialization.hpp>
36 #include "connectivity/CommonTools.hxx"
37 #include <comphelper/broadcasthelper.hxx>
38 
39 
40 #define DECLARE_SERVICE_INFO_STATIC()	\
41 	DECLARE_SERVICE_INFO();	\
42 	static ::rtl::OUString SAL_CALL getImplementationName_Static(  ) throw (::com::sun::star::uno::RuntimeException);	\
43     static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static(  ) throw(::com::sun::star::uno::RuntimeException);	\
44 	static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >	\
45 		SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&)	\
46 
47 
48 namespace connectivity
49 {
50 	namespace hsqldb
51 	{
52 		typedef	::cppu::WeakComponentImplHelper6<	::com::sun::star::io::XStream
53 										,	::com::sun::star::io::XInputStream
54 										,	::com::sun::star::io::XOutputStream
55 										,	::com::sun::star::io::XSeekable
56 										,	::com::sun::star::lang::XInitialization
57 										,	::com::sun::star::lang::XServiceInfo>	OStorage_Base;
58 		class OStorage : public ::comphelper::OBaseMutex
59 						,public OStorage_Base
60 		{
61 			::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >			m_xServiceFactory;
62 			::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentSubStorageSupplier>	m_xDS;
63 
64 
65 			::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage>	m_xStorge;
66 			::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >		m_xStream;
67 			::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >	m_xIn;
68 			::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >	m_xOut;
69 			::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable >		m_xSeek;
70 
71 			OStorage();							// never implemented
72 			OStorage(const OStorage&);			// never implemented
73 			int operator= (const OStorage&);	// never implemented
74 
75 			OStorage(
76 				const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&	_rxFactory);
77 		protected:
78 			/** this function is called upon disposing the component
79 			*/
80 			virtual void SAL_CALL disposing();
81 		public:
82 			// ::com::sun::star::lang::XServiceInfo
83 			DECLARE_SERVICE_INFO_STATIC();
84 
85 			// XInitialization
86 			virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
87 
88 			// XStream
89 			virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(  ) throw (::com::sun::star::uno::RuntimeException);
90 			virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream(  ) throw (::com::sun::star::uno::RuntimeException);
91 
92 			// XInputStream
93 			virtual ::sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
94 			virtual ::sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
95 			virtual void SAL_CALL skipBytes( ::sal_Int32 nBytesToSkip ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
96 			virtual ::sal_Int32 SAL_CALL available(  ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
97 			virtual void SAL_CALL closeInput(  ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
98 
99 			// XOutputStream
100 			virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
101 			virtual void SAL_CALL flush(  ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
102 			virtual void SAL_CALL closeOutput(  ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
103 
104 			// XSeekable
105 			virtual void SAL_CALL seek( ::sal_Int64 location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
106 			virtual ::sal_Int64 SAL_CALL getPosition(  ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
107 			virtual ::sal_Int64 SAL_CALL getLength(  ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
108 		};
109 	}
110 // .......................................................................
111 } // connectivity
112 // .......................................................................
113 #endif // CONNECTIVITY_HSQLDB_STORAGE_HXX
114 
115