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