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 GIO_DATASUPPLIER_HXX
25 #define GIO_DATASUPPLIER_HXX
26 
27 #include <ucbhelper/resultset.hxx>
28 #include "gio_content.hxx"
29 #include <vector>
30 
31 namespace gio
32 {
33 
34 class Content;
35 
36 struct ResultListEntry
37 {
38     ::rtl::OUString aId;
39     com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > xId;
40     com::sun::star::uno::Reference< com::sun::star::ucb::XContent > xContent;
41     com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > xRow;
42     GFileInfo *pInfo;
43 
ResultListEntrygio::ResultListEntry44     ResultListEntry( GFileInfo *pInInfo ) : pInfo(pInInfo)
45     {
46         g_object_ref( pInfo );
47     }
48 
~ResultListEntrygio::ResultListEntry49     ~ResultListEntry()
50     {
51         g_object_unref( pInfo );
52     }
53 };
54 
55 typedef std::vector< ResultListEntry* > ResultList;
56 
57 class DataSupplier : public ucbhelper::ResultSetDataSupplier
58 {
59 private:
60     com::sun::star::uno::Reference< ::gio::Content > mxContent;
61     com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
62     sal_Int32 mnOpenMode;
63     bool mbCountFinal;
64     bool getData();
65     ResultList maResults;
66 public:
67     DataSupplier( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
68         const com::sun::star::uno::Reference< Content >& rContent, sal_Int32 nOpenMode );
69     virtual ~DataSupplier();
70 
71     virtual rtl::OUString queryContentIdentifierString( sal_uInt32 nIndex );
72     virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >
73         queryContentIdentifier( sal_uInt32 nIndex );
74     virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent >
75         queryContent( sal_uInt32 nIndex );
76 
77     virtual sal_Bool getResult( sal_uInt32 nIndex );
78 
79     virtual sal_uInt32 totalCount();
80     virtual sal_uInt32 currentCount();
81     virtual sal_Bool isCountFinal();
82 
83     virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XRow >
84         queryPropertyValues( sal_uInt32 nIndex  );
85     virtual void releasePropertyValues( sal_uInt32 nIndex );
86 
87     virtual void close();
88 
89     virtual void validate()
90         throw( com::sun::star::ucb::ResultSetException );
91 };
92 
93 }
94 
95 #endif
96