Line data Source code
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 <com/sun/star/sdbcx/XDeleteRows.hpp>
22 : #include "flat/EResultSet.hxx"
23 : #include <com/sun/star/lang/DisposedException.hpp>
24 : #include <comphelper/sequence.hxx>
25 : #include <comphelper/types.hxx>
26 : #include <cppuhelper/supportsservice.hxx>
27 :
28 : using namespace ::comphelper;
29 :
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;
38 :
39 :
40 0 : OFlatResultSet::OFlatResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator)
41 : : file::OResultSet(pStmt,_aSQLIterator)
42 0 : ,m_bBookmarkable(true)
43 : {
44 0 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, cppu::UnoType<bool>::get());
45 0 : }
46 :
47 0 : OUString SAL_CALL OFlatResultSet::getImplementationName( ) throw ( RuntimeException, std::exception)
48 : {
49 0 : return OUString("com.sun.star.sdbcx.flat.ResultSet");
50 : }
51 :
52 0 : Sequence< OUString > SAL_CALL OFlatResultSet::getSupportedServiceNames( ) throw( RuntimeException, std::exception)
53 : {
54 0 : Sequence< OUString > aSupported(2);
55 0 : aSupported[0] = "com.sun.star.sdbc.ResultSet";
56 0 : aSupported[1] = "com.sun.star.sdbcx.ResultSet";
57 0 : return aSupported;
58 : }
59 :
60 0 : sal_Bool SAL_CALL OFlatResultSet::supportsService( const OUString& _rServiceName ) throw( RuntimeException, std::exception)
61 : {
62 0 : return cppu::supportsService(this, _rServiceName);
63 : }
64 :
65 0 : Any SAL_CALL OFlatResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
66 : {
67 0 : if(rType == cppu::UnoType<XDeleteRows>::get()|| rType == cppu::UnoType<XResultSetUpdate>::get()
68 0 : || rType == cppu::UnoType<XRowUpdate>::get())
69 0 : return Any();
70 :
71 0 : const Any aRet = OResultSet::queryInterface(rType);
72 0 : return aRet.hasValue() ? aRet : OFlatResultSet_BASE::queryInterface(rType);
73 : }
74 :
75 0 : Sequence< Type > SAL_CALL OFlatResultSet::getTypes( ) throw( RuntimeException, std::exception)
76 : {
77 0 : Sequence< Type > aTypes = OResultSet::getTypes();
78 0 : ::std::vector<Type> aOwnTypes;
79 0 : aOwnTypes.reserve(aTypes.getLength());
80 0 : const Type* pBegin = aTypes.getConstArray();
81 0 : const Type* pEnd = pBegin + aTypes.getLength();
82 0 : for(;pBegin != pEnd;++pBegin)
83 : {
84 0 : if(!(*pBegin == cppu::UnoType<XDeleteRows>::get()||
85 0 : *pBegin == cppu::UnoType<XResultSetUpdate>::get()||
86 0 : *pBegin == cppu::UnoType<XRowUpdate>::get()))
87 : {
88 0 : aOwnTypes.push_back(*pBegin);
89 : }
90 : }
91 0 : Sequence< Type > aRet(aOwnTypes.data(), aOwnTypes.size());
92 0 : return ::comphelper::concatSequences(aRet,OFlatResultSet_BASE::getTypes());
93 : }
94 :
95 :
96 : // XRowLocate
97 0 : Any SAL_CALL OFlatResultSet::getBookmark( ) throw( SQLException, RuntimeException, std::exception)
98 : {
99 0 : ::osl::MutexGuard aGuard( m_aMutex );
100 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
101 :
102 0 : return makeAny((sal_Int32)(m_aRow->get())[0]->getValue());
103 : }
104 :
105 0 : sal_Bool SAL_CALL OFlatResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException, std::exception)
106 : {
107 0 : ::osl::MutexGuard aGuard( m_aMutex );
108 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
109 :
110 :
111 0 : m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false;
112 :
113 0 : return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true);
114 : }
115 :
116 0 : sal_Bool SAL_CALL OFlatResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException, std::exception)
117 : {
118 0 : ::osl::MutexGuard aGuard( m_aMutex );
119 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
120 :
121 :
122 0 : m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false;
123 :
124 0 : Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),false);
125 :
126 0 : return relative(rows);
127 : }
128 :
129 :
130 0 : sal_Int32 SAL_CALL OFlatResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException, std::exception)
131 : {
132 0 : return (lhs == rhs) ? CompareBookmark::EQUAL : CompareBookmark::NOT_EQUAL;
133 : }
134 :
135 0 : sal_Bool SAL_CALL OFlatResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException, std::exception)
136 : {
137 0 : return sal_True;
138 : }
139 :
140 0 : sal_Int32 SAL_CALL OFlatResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException, std::exception)
141 : {
142 0 : return comphelper::getINT32(bookmark);
143 : }
144 :
145 0 : IPropertyArrayHelper* OFlatResultSet::createArrayHelper( ) const
146 : {
147 0 : Sequence< Property > aProps;
148 0 : describeProperties(aProps);
149 0 : return new ::cppu::OPropertyArrayHelper(aProps);
150 : }
151 :
152 0 : IPropertyArrayHelper & OFlatResultSet::getInfoHelper()
153 : {
154 0 : return *OFlatResultSet_BASE3::getArrayHelper();
155 : }
156 :
157 0 : void SAL_CALL OFlatResultSet::acquire() throw()
158 : {
159 0 : OFlatResultSet_BASE2::acquire();
160 0 : }
161 :
162 0 : void SAL_CALL OFlatResultSet::release() throw()
163 : {
164 0 : OFlatResultSet_BASE2::release();
165 0 : }
166 :
167 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OFlatResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
168 : {
169 0 : return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
170 : }
171 :
172 :
173 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|