fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / ucb / source / ucp / cmis / cmis_datasupplier.cxx
blob195847481d108b70c038286da39857941c669776
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <vector>
12 #include <ucbhelper/contentidentifier.hxx>
13 #include <ucbhelper/providerhelper.hxx>
15 #include <com/sun/star/ucb/OpenMode.hpp>
17 #include "cmis_datasupplier.hxx"
18 #include "cmis_content.hxx"
19 #include "cmis_provider.hxx"
21 using namespace com::sun::star;
22 using namespace std;
24 namespace cmis
27 typedef std::vector< ResultListEntry* > ResultList;
29 DataSupplier::DataSupplier( ChildrenProvider* pChildrenProvider, sal_Int32 nOpenMode )
30 : m_pChildrenProvider( pChildrenProvider ), mnOpenMode(nOpenMode), mbCountFinal(false)
34 bool DataSupplier::getData()
36 if ( mbCountFinal )
37 return true;
39 list< uno::Reference< ucb::XContent > > aChildren = m_pChildrenProvider->getChildren( );
41 // Loop over the results and filter them
42 for ( list< uno::Reference< ucb::XContent > >::iterator it = aChildren.begin();
43 it != aChildren.end(); ++it )
45 OUString sContentType = ( *it )->getContentType( );
46 bool bIsFolder = sContentType != CMIS_FILE_TYPE;
47 if ( ( mnOpenMode == ucb::OpenMode::FOLDERS && bIsFolder ) ||
48 ( mnOpenMode == ucb::OpenMode::DOCUMENTS && !bIsFolder ) ||
49 ( mnOpenMode == ucb::OpenMode::ALL ) )
51 maResults.push_back( new ResultListEntry( *it ) );
54 mbCountFinal = true;
56 return true;
59 DataSupplier::~DataSupplier()
61 while ( maResults.size( ) > 0 )
63 ResultListEntry* back = maResults.back( );
64 maResults.pop_back( );
65 delete( back );
69 OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
71 return queryContentIdentifier( nIndex )->getContentIdentifier( );
74 uno::Reference< ucb::XContentIdentifier > DataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
76 return queryContent( nIndex )->getIdentifier( );
79 uno::Reference< ucb::XContent > DataSupplier::queryContent( sal_uInt32 nIndex )
81 if ( nIndex > maResults.size() )
82 getData( );
84 return maResults[ nIndex ]->xContent;
87 bool DataSupplier::getResult( sal_uInt32 nIndex )
89 if ( maResults.size() > nIndex ) // Result already present.
90 return true;
92 if ( getData() && maResults.size() > nIndex )
93 return true;
95 return false;
98 sal_uInt32 DataSupplier::totalCount()
100 getData();
101 return maResults.size();
104 sal_uInt32 DataSupplier::currentCount()
106 return maResults.size();
109 bool DataSupplier::isCountFinal()
111 return mbCountFinal;
114 uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues( sal_uInt32 nIndex )
116 if ( nIndex < maResults.size() )
118 uno::Reference< sdbc::XRow > xRow = maResults[ nIndex ]->xRow;
119 if ( xRow.is() )
121 // Already cached.
122 return xRow;
126 if ( getResult( nIndex ) )
128 uno::Reference< ucb::XContent > xContent( queryContent( nIndex ) );
129 if ( xContent.is() )
133 uno::Reference< ucb::XCommandProcessor > xCmdProc(
134 xContent, uno::UNO_QUERY_THROW );
135 sal_Int32 nCmdId( xCmdProc->createCommandIdentifier() );
136 ucb::Command aCmd;
137 aCmd.Name = "getPropertyValues";
138 aCmd.Handle = -1;
139 aCmd.Argument <<= getResultSet()->getProperties();
140 uno::Any aResult( xCmdProc->execute(
141 aCmd, nCmdId, getResultSet()->getEnvironment() ) );
142 uno::Reference< sdbc::XRow > xRow;
143 if ( aResult >>= xRow )
145 maResults[ nIndex ]->xRow = xRow;
146 return xRow;
149 catch ( uno::Exception const & )
154 return uno::Reference< sdbc::XRow >();
157 void DataSupplier::releasePropertyValues( sal_uInt32 nIndex )
159 if ( nIndex < maResults.size() )
160 maResults[ nIndex ]->xRow = uno::Reference< sdbc::XRow >();
163 void DataSupplier::close()
167 void DataSupplier::validate() throw( ucb::ResultSetException )
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */