xref: /trunk/main/ucb/source/cacher/cachedcontentresultsetstub.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _CACHED_CONTENT_RESULTSET_STUB_HXX
29 #define _CACHED_CONTENT_RESULTSET_STUB_HXX
30 
31 #include <contentresultsetwrapper.hxx>
32 #include <com/sun/star/lang/XTypeProvider.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/ucb/XFetchProvider.hpp>
35 #include <com/sun/star/ucb/XFetchProviderForContentAccess.hpp>
36 #include <com/sun/star/ucb/XCachedContentResultSetStubFactory.hpp>
37 
38 #define CACHED_CRS_STUB_SERVICE_NAME "com.sun.star.ucb.CachedContentResultSetStub"
39 #define CACHED_CRS_STUB_FACTORY_NAME "com.sun.star.ucb.CachedContentResultSetStubFactory"
40 
41 //=========================================================================
42 
43 class CachedContentResultSetStub
44                 : public ContentResultSetWrapper
45                 , public com::sun::star::lang::XTypeProvider
46                 , public com::sun::star::lang::XServiceInfo
47                 , public com::sun::star::ucb::XFetchProvider
48                 , public com::sun::star::ucb::XFetchProviderForContentAccess
49 {
50 private:
51     sal_Int32       m_nColumnCount;
52     sal_Bool        m_bColumnCountCached;
53 
54     //members to propagate fetchsize and direction:
55     sal_Bool        m_bNeedToPropagateFetchSize;
56     sal_Bool        m_bFirstFetchSizePropagationDone;
57     sal_Int32       m_nLastFetchSize;
58     sal_Bool        m_bLastFetchDirection;
59     const rtl::OUString     m_aPropertyNameForFetchSize;
60     const rtl::OUString     m_aPropertyNameForFetchDirection;
61 
62 
63     void SAL_CALL
64     impl_getCurrentRowContent(
65         com::sun::star::uno::Any& rRowContent,
66         com::sun::star::uno::Reference<
67             com::sun::star::sdbc::XRow > xRow )
68         throw ( com::sun::star::sdbc::SQLException
69               , com::sun::star::uno::RuntimeException );
70 
71     sal_Int32 SAL_CALL
72     impl_getColumnCount();
73 
74     void SAL_CALL
75     impl_getCurrentContentIdentifierString(
76             com::sun::star::uno::Any& rAny
77             , com::sun::star::uno::Reference<
78                 com::sun::star::ucb::XContentAccess > xContentAccess )
79             throw ( com::sun::star::uno::RuntimeException );
80 
81     void SAL_CALL
82     impl_getCurrentContentIdentifier(
83             com::sun::star::uno::Any& rAny
84             , com::sun::star::uno::Reference<
85                 com::sun::star::ucb::XContentAccess > xContentAccess )
86             throw ( com::sun::star::uno::RuntimeException );
87 
88     void SAL_CALL
89     impl_getCurrentContent(
90             com::sun::star::uno::Any& rAny
91             , com::sun::star::uno::Reference<
92                 com::sun::star::ucb::XContentAccess > xContentAccess )
93             throw ( com::sun::star::uno::RuntimeException );
94 
95     void SAL_CALL
96     impl_propagateFetchSizeAndDirection( sal_Int32 nFetchSize, sal_Bool bFetchDirection )
97         throw ( com::sun::star::uno::RuntimeException );
98 
99 public:
100     CachedContentResultSetStub( com::sun::star::uno::Reference<
101                         com::sun::star::sdbc::XResultSet > xOrigin );
102 
103     virtual ~CachedContentResultSetStub();
104 
105 
106     //-----------------------------------------------------------------
107     // XInterface inherited
108     //-----------------------------------------------------------------
109     XINTERFACE_DECL()
110     //-----------------------------------------------------------------
111     // own inherited
112     //-----------------------------------------------------------------
113     virtual void SAL_CALL
114     impl_propertyChange( const com::sun::star::beans::PropertyChangeEvent& evt )
115         throw( com::sun::star::uno::RuntimeException );
116 
117     virtual void SAL_CALL
118     impl_vetoableChange( const com::sun::star::beans::PropertyChangeEvent& aEvent )
119         throw( com::sun::star::beans::PropertyVetoException,
120                com::sun::star::uno::RuntimeException );
121     //-----------------------------------------------------------------
122     // XTypeProvider
123     //-----------------------------------------------------------------
124     XTYPEPROVIDER_DECL()
125     //-----------------------------------------------------------------
126     // XServiceInfo
127     //-----------------------------------------------------------------
128     XSERVICEINFO_NOFACTORY_DECL()
129 
130     //-----------------------------------------------------------------
131     // XFetchProvider
132     //-----------------------------------------------------------------
133 
134     virtual com::sun::star::ucb::FetchResult SAL_CALL
135     fetch( sal_Int32 nRowStartPosition
136         , sal_Int32 nRowCount, sal_Bool bDirection )
137         throw( com::sun::star::uno::RuntimeException );
138 
139     //-----------------------------------------------------------------
140     // XFetchProviderForContentAccess
141     //-----------------------------------------------------------------
142     virtual com::sun::star::ucb::FetchResult SAL_CALL
143          fetchContentIdentifierStrings( sal_Int32 nRowStartPosition
144         , sal_Int32 nRowCount, sal_Bool bDirection )
145         throw( com::sun::star::uno::RuntimeException );
146 
147     virtual com::sun::star::ucb::FetchResult SAL_CALL
148          fetchContentIdentifiers( sal_Int32 nRowStartPosition
149         , sal_Int32 nRowCount, sal_Bool bDirection )
150         throw( com::sun::star::uno::RuntimeException );
151 
152     virtual com::sun::star::ucb::FetchResult SAL_CALL
153          fetchContents( sal_Int32 nRowStartPosition
154         , sal_Int32 nRowCount, sal_Bool bDirection )
155         throw( com::sun::star::uno::RuntimeException );
156 };
157 
158 //=========================================================================
159 
160 class CachedContentResultSetStubFactory
161                 : public cppu::OWeakObject
162                 , public com::sun::star::lang::XTypeProvider
163                 , public com::sun::star::lang::XServiceInfo
164                 , public com::sun::star::ucb::XCachedContentResultSetStubFactory
165 {
166 protected:
167     com::sun::star::uno::Reference<
168         com::sun::star::lang::XMultiServiceFactory >    m_xSMgr;
169 
170 public:
171 
172     CachedContentResultSetStubFactory(
173         const com::sun::star::uno::Reference<
174         com::sun::star::lang::XMultiServiceFactory > & rSMgr);
175 
176     virtual ~CachedContentResultSetStubFactory();
177 
178     //-----------------------------------------------------------------
179     // XInterface
180     XINTERFACE_DECL()
181 
182     //-----------------------------------------------------------------
183     // XTypeProvider
184     XTYPEPROVIDER_DECL()
185 
186     //-----------------------------------------------------------------
187     // XServiceInfo
188     XSERVICEINFO_DECL()
189 
190     //-----------------------------------------------------------------
191     // XCachedContentResultSetStubFactory
192 
193     virtual com::sun::star::uno::Reference<
194                 com::sun::star::sdbc::XResultSet > SAL_CALL
195     createCachedContentResultSetStub(
196                 const com::sun::star::uno::Reference<
197                     com::sun::star::sdbc::XResultSet > & xSource )
198             throw( com::sun::star::uno::RuntimeException );
199 };
200 
201 #endif
202 
203