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 CACHEDROWSET_HXX
25 #define CACHEDROWSET_HXX
26 
27 /** === begin UNO includes === **/
28 #include <com/sun/star/sdbc/XResultSet.hpp>
29 #include <com/sun/star/sdbc/XConnection.hpp>
30 /** === end UNO includes === **/
31 
32 #include <comphelper/componentcontext.hxx>
33 #include <unotools/sharedunocomponent.hxx>
34 
35 #include <memory>
36 
37 //........................................................................
38 namespace frm
39 {
40 //........................................................................
41 
42     struct CachedRowSet_Data;
43 	//====================================================================
44 	//= CachedRowSet
45 	//====================================================================
46     /** caches a result set obtained from a SQL statement
47     */
48 	class CachedRowSet
49 	{
50     public:
51         CachedRowSet( const ::comphelper::ComponentContext& _rContext );
52         ~CachedRowSet();
53 
54     public:
55         /** executes the statement
56 
57             @return
58                 the result set produced by the statement. The caller takes ownership of the
59                 given object.
60 
61             @throws ::com::sun::star::sdbc::SQLException
62                 if such an exception is thrown when executing the statement
63         */
64         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >
65                 execute();
66 
67         /// determines whether the row set properties are dirty, i.e. have changed since the last call to execute
68         bool    isDirty() const;
69 
70         /// disposes the instance and frees all associated resources
71         void    dispose();
72 
73         /** sets the command of a query as command to be executed
74 
75             A connection must have been set before.
76 
77             @throws Exception
78         */
79         void    setCommandFromQuery ( const ::rtl::OUString& _rQueryName );
80 
81         void    setCommand          ( const ::rtl::OUString& _rCommand );
82         void    setEscapeProcessing ( const sal_Bool _bEscapeProcessing );
83         void    setConnection       ( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection );
84 
85     private:
86         ::std::auto_ptr< CachedRowSet_Data >    m_pData;
87 	};
88 
89 //........................................................................
90 } // namespace frm
91 //........................................................................
92 
93 #endif // CACHEDROWSET_HXX
94