LibreOffice Module connectivity (master) 1
DResultSet.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <com/sun/star/sdbcx/CompareBookmark.hpp>
21#include <dbase/DResultSet.hxx>
22#include <com/sun/star/beans/PropertyAttribute.hpp>
26#include <dbase/DIndex.hxx>
27#include <dbase/DIndexIter.hxx>
28#include <comphelper/types.hxx>
30#include <strings.hrc>
31
32using namespace ::comphelper;
33
34using namespace connectivity::dbase;
35using namespace connectivity::file;
36using namespace ::cppu;
37using namespace com::sun::star::uno;
38using namespace com::sun::star::lang;
39using namespace com::sun::star::beans;
40using namespace com::sun::star::sdbc;
41using namespace com::sun::star::sdbcx;
42
43ODbaseResultSet::ODbaseResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator)
44 : file::OResultSet(pStmt,_aSQLIterator)
45 ,m_bBookmarkable(true)
46{
48}
49
50OUString SAL_CALL ODbaseResultSet::getImplementationName( )
51{
52 return "com.sun.star.sdbcx.dbase.ResultSet";
53}
54
55Sequence< OUString > SAL_CALL ODbaseResultSet::getSupportedServiceNames( )
56{
57 return { "com.sun.star.sdbc.ResultSet", "com.sun.star.sdbcx.ResultSet" };
58}
59
60sal_Bool SAL_CALL ODbaseResultSet::supportsService( const OUString& _rServiceName )
61{
62 return cppu::supportsService(this, _rServiceName);
63}
64
65Any SAL_CALL ODbaseResultSet::queryInterface( const Type & rType )
66{
68 return aRet.hasValue() ? aRet : OResultSet::queryInterface(rType);
69}
70
72{
73 return ::comphelper::concatSequences(OResultSet::getTypes(),ODbaseResultSet_BASE::getTypes());
74}
75
76
77// XRowLocate
79{
80 ::osl::MutexGuard aGuard( m_aMutex );
81 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
82 OSL_ENSURE((m_bShowDeleted || !m_aRow->isDeleted()),"getBookmark called for deleted row");
83
84 return Any((*m_aRow)[0]->getValue().getInt32());
85}
86
87sal_Bool SAL_CALL ODbaseResultSet::moveToBookmark( const Any& bookmark )
88{
89 ::osl::MutexGuard aGuard( m_aMutex );
90 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
91
92
94
95 return m_pTable.is() && Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true);
96}
97
98sal_Bool SAL_CALL ODbaseResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows )
99{
100 ::osl::MutexGuard aGuard( m_aMutex );
101 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
102 if(!m_pTable.is())
103 return false;
104
105
107
108 return relative(rows);
109}
110
111
112sal_Int32 SAL_CALL ODbaseResultSet::compareBookmarks( const Any& lhs, const Any& rhs )
113{
114 sal_Int32 nFirst(0),nSecond(0),nResult(0);
115 if ( !( lhs >>= nFirst ) || !( rhs >>= nSecond ) )
116 {
118 const OUString sMessage = aResources.getResourceString(STR_INVALID_BOOKMARK);
120 } // if ( !( lhs >>= nFirst ) || !( rhs >>= nSecond ) )
121
122 if(nFirst < nSecond)
123 nResult = CompareBookmark::LESS;
124 else if(nFirst > nSecond)
125 nResult = CompareBookmark::GREATER;
126 else
127 nResult = CompareBookmark::EQUAL;
128
129 return nResult;
130}
131
133{
134 return true;
135}
136
137sal_Int32 SAL_CALL ODbaseResultSet::hashBookmark( const Any& bookmark )
138{
139 ::osl::MutexGuard aGuard( m_aMutex );
140 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
141
142
143 return comphelper::getINT32(bookmark);
144}
145
146// XDeleteRows
148{
149 ::osl::MutexGuard aGuard( m_aMutex );
150 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
151
152 ::dbtools::throwFeatureNotImplementedSQLException( "XDeleteRows::deleteRows", *this );
153 return Sequence< sal_Int32 >();
154}
155
157{
158 auto pIndex = dynamic_cast<dbase::ODbaseIndex*>(_xIndex.get());
159 if(pIndex)
160 {
161 std::unique_ptr<dbase::OIndexIterator> pIter = pIndex->createIterator();
162
163 if (pIter)
164 {
165 sal_uInt32 nRec = pIter->First();
166 while (nRec != NODE_NOTFOUND)
167 {
168 m_pFileSet->push_back(nRec);
169 nRec = pIter->Next();
170 }
171 m_pFileSet->setFrozen();
172 return true;
173 }
174 }
175 return false;
176}
177
179{
181}
182
184{
186 describeProperties(aProps);
187 return new ::cppu::OPropertyArrayHelper(aProps);
188}
189
190void SAL_CALL ODbaseResultSet::acquire() noexcept
191{
193}
194
195void SAL_CALL ODbaseResultSet::release() noexcept
196{
198}
199
200css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL ODbaseResultSet::getPropertySetInfo( )
201{
202 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
203}
204
206{
207 return m_pTable->getFilePos();
208}
209
210
211/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::cppu::IPropertyArrayHelper * getArrayHelper()
void describeProperties(css::uno::Sequence< css::beans::Property > &_rProps) const
void registerProperty(const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void *_pPointerToMember, const css::uno::Type &_rMemberType)
::dbtools::OPropertyMap & getPropMap()
Definition: TConnection.cxx:68
helper class for accessing resources shared by different libraries in the connectivity module
OUString getResourceString(TranslateId pResId) const
loads a string from the shared resource file
std::unique_ptr< OIndexIterator > createIterator()
Definition: DIndex.cxx:142
virtual sal_Bool SAL_CALL moveToBookmark(const css::uno::Any &bookmark) override
Definition: DResultSet.cxx:87
virtual bool fillIndexValues(const css::uno::Reference< css::sdbcx::XColumnsSupplier > &_xIndex) override
Definition: DResultSet.cxx:156
virtual css::uno::Sequence< sal_Int32 > SAL_CALL deleteRows(const css::uno::Sequence< css::uno::Any > &rows) override
Definition: DResultSet.cxx:147
virtual sal_Int32 SAL_CALL hashBookmark(const css::uno::Any &bookmark) override
Definition: DResultSet.cxx:137
virtual css::uno::Any SAL_CALL getBookmark() override
Definition: DResultSet.cxx:78
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: DResultSet.cxx:200
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
Definition: DResultSet.cxx:183
virtual sal_Int32 SAL_CALL compareBookmarks(const css::uno::Any &first, const css::uno::Any &second) override
Definition: DResultSet.cxx:112
virtual void SAL_CALL acquire() noexcept override
Definition: DResultSet.cxx:190
virtual sal_Bool SAL_CALL moveRelativeToBookmark(const css::uno::Any &bookmark, sal_Int32 rows) override
Definition: DResultSet.cxx:98
virtual void SAL_CALL release() noexcept override
Definition: DResultSet.cxx:195
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: DResultSet.cxx:71
virtual sal_Bool SAL_CALL hasOrderedBookmarks() override
Definition: DResultSet.cxx:132
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: DResultSet.cxx:65
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
Definition: DResultSet.cxx:178
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
Definition: FResultSet.cxx:416
const ORowSetValue & getValue(sal_Int32 columnIndex)
Definition: FResultSet.cxx:189
rtl::Reference< OFileTable > m_pTable
Definition: FResultSet.hxx:87
virtual void SAL_CALL release() noexcept override
::rtl::Reference< OKeySet > m_pFileSet
Definition: FResultSet.hxx:81
virtual void SAL_CALL acquire() noexcept override
bool Move(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, bool bRetrieveData)
Definition: FResultSet.cxx:878
mutable::osl::Mutex m_aMutex
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
#define NODE_NOTFOUND
Definition: dindexnode.hxx:25
sal_Int32 getINT32(const Any &_rAny)
Type
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
void throwFeatureNotImplementedSQLException(const OUString &_rFeatureName, const Reference< XInterface > &_rxContext, const Any &_rNextException)
void throwGenericSQLException(const OUString &_rMsg, const css::uno::Reference< css::uno::XInterface > &_rxSource)
throw a generic SQLException, i.e.
#define PROPERTY_ID_ISBOOKMARKABLE
Definition: propertyids.hxx:82
OUString sMessage
unsigned char sal_Bool