1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/sdbcx/CompareBookmark.hpp>
21 #include <com/sun/star/sdbcx/XDeleteRows.hpp>
22 #include <flat/EResultSet.hxx>
23 #include <com/sun/star/beans/PropertyAttribute.hpp>
24 #include <comphelper/sequence.hxx>
25 #include <comphelper/types.hxx>
26 #include <cppuhelper/supportsservice.hxx>
28 using namespace ::comphelper
;
30 using namespace connectivity::flat
;
31 using namespace connectivity::file
;
32 using namespace ::cppu
;
33 using namespace com::sun::star::uno
;
34 using namespace com::sun::star::lang
;
35 using namespace com::sun::star::beans
;
36 using namespace com::sun::star::sdbc
;
37 using namespace com::sun::star::sdbcx
;
40 OFlatResultSet::OFlatResultSet( OStatement_Base
* pStmt
,connectivity::OSQLParseTreeIterator
& _aSQLIterator
)
41 : file::OResultSet(pStmt
,_aSQLIterator
)
42 ,m_bBookmarkable(true)
44 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE
), PROPERTY_ID_ISBOOKMARKABLE
, PropertyAttribute::READONLY
,&m_bBookmarkable
, cppu::UnoType
<bool>::get());
47 OUString SAL_CALL
OFlatResultSet::getImplementationName( )
49 return "com.sun.star.sdbcx.flat.ResultSet";
52 Sequence
< OUString
> SAL_CALL
OFlatResultSet::getSupportedServiceNames( )
54 return { "com.sun.star.sdbc.ResultSet", "com.sun.star.sdbcx.ResultSet" };
57 sal_Bool SAL_CALL
OFlatResultSet::supportsService( const OUString
& _rServiceName
)
59 return cppu::supportsService(this, _rServiceName
);
62 Any SAL_CALL
OFlatResultSet::queryInterface( const Type
& rType
)
64 if(rType
== cppu::UnoType
<XDeleteRows
>::get()|| rType
== cppu::UnoType
<XResultSetUpdate
>::get()
65 || rType
== cppu::UnoType
<XRowUpdate
>::get())
68 const Any aRet
= OResultSet::queryInterface(rType
);
69 return aRet
.hasValue() ? aRet
: OFlatResultSet_BASE::queryInterface(rType
);
72 Sequence
< Type
> SAL_CALL
OFlatResultSet::getTypes( )
74 Sequence
< Type
> aTypes
= OResultSet::getTypes();
75 std::vector
<Type
> aOwnTypes
;
76 aOwnTypes
.reserve(aTypes
.getLength());
77 const Type
* pBegin
= aTypes
.getConstArray();
78 const Type
* pEnd
= pBegin
+ aTypes
.getLength();
79 for(;pBegin
!= pEnd
;++pBegin
)
81 if(!(*pBegin
== cppu::UnoType
<XDeleteRows
>::get()||
82 *pBegin
== cppu::UnoType
<XResultSetUpdate
>::get()||
83 *pBegin
== cppu::UnoType
<XRowUpdate
>::get()))
85 aOwnTypes
.push_back(*pBegin
);
88 Sequence
< Type
> aRet(aOwnTypes
.data(), aOwnTypes
.size());
89 return ::comphelper::concatSequences(aRet
,OFlatResultSet_BASE::getTypes());
94 Any SAL_CALL
OFlatResultSet::getBookmark( )
96 ::osl::MutexGuard
aGuard( m_aMutex
);
97 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
99 return makeAny(static_cast<sal_Int32
>((*m_aRow
)[0]->getValue()));
102 sal_Bool SAL_CALL
OFlatResultSet::moveToBookmark( const Any
& bookmark
)
104 ::osl::MutexGuard
aGuard( m_aMutex
);
105 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
108 m_bRowDeleted
= m_bRowInserted
= m_bRowUpdated
= false;
110 return Move(IResultSetHelper::BOOKMARK
,comphelper::getINT32(bookmark
),true);
113 sal_Bool SAL_CALL
OFlatResultSet::moveRelativeToBookmark( const Any
& bookmark
, sal_Int32 rows
)
115 ::osl::MutexGuard
aGuard( m_aMutex
);
116 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
118 m_bRowDeleted
= m_bRowInserted
= m_bRowUpdated
= false;
120 Move(IResultSetHelper::BOOKMARK
,comphelper::getINT32(bookmark
),false);
122 return relative(rows
);
126 sal_Int32 SAL_CALL
OFlatResultSet::compareBookmarks( const Any
& lhs
, const Any
& rhs
)
128 return (lhs
== rhs
) ? CompareBookmark::EQUAL
: CompareBookmark::NOT_EQUAL
;
131 sal_Bool SAL_CALL
OFlatResultSet::hasOrderedBookmarks( )
136 sal_Int32 SAL_CALL
OFlatResultSet::hashBookmark( const Any
& bookmark
)
138 return comphelper::getINT32(bookmark
);
141 IPropertyArrayHelper
* OFlatResultSet::createArrayHelper( ) const
143 Sequence
< Property
> aProps
;
144 describeProperties(aProps
);
145 return new ::cppu::OPropertyArrayHelper(aProps
);
148 IPropertyArrayHelper
& OFlatResultSet::getInfoHelper()
150 return *OFlatResultSet_BASE3::getArrayHelper();
153 void SAL_CALL
OFlatResultSet::acquire() noexcept
155 OFlatResultSet_BASE2::acquire();
158 void SAL_CALL
OFlatResultSet::release() noexcept
160 OFlatResultSet_BASE2::release();
163 css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
OFlatResultSet::getPropertySetInfo( )
165 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */