1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: CResultSet.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include <com/sun/star/sdbcx/CompareBookmark.hpp>
34 #include "calc/CResultSet.hxx"
35 #include <com/sun/star/lang/DisposedException.hpp>
36 #include <comphelper/sequence.hxx>
37 #include <comphelper/types.hxx>
38 #include <connectivity/dbexception.hxx>
40 using namespace ::comphelper
;
41 using namespace connectivity::calc
;
42 using namespace connectivity::file
;
43 using namespace ::cppu
;
44 using namespace com::sun::star::uno
;
45 using namespace com::sun::star::lang
;
46 using namespace com::sun::star::beans
;
47 using namespace com::sun::star::sdbc
;
48 using namespace com::sun::star::sdbcx
;
49 // using namespace com::sun::star::container;
50 // using namespace com::sun::star::util;
51 //------------------------------------------------------------------------------
52 OCalcResultSet::OCalcResultSet( OStatement_Base
* pStmt
,connectivity::OSQLParseTreeIterator
& _aSQLIterator
)
53 : file::OResultSet(pStmt
,_aSQLIterator
)
54 ,m_bBookmarkable(sal_True
)
56 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE
), PROPERTY_ID_ISBOOKMARKABLE
, PropertyAttribute::READONLY
,&m_bBookmarkable
, ::getBooleanCppuType());
58 // -------------------------------------------------------------------------
59 ::rtl::OUString SAL_CALL
OCalcResultSet::getImplementationName( ) throw ( RuntimeException
)
61 return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.calc.ResultSet");
63 // -------------------------------------------------------------------------
64 Sequence
< ::rtl::OUString
> SAL_CALL
OCalcResultSet::getSupportedServiceNames( ) throw( RuntimeException
)
66 Sequence
< ::rtl::OUString
> aSupported(2);
67 aSupported
[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
68 aSupported
[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet");
71 // -------------------------------------------------------------------------
72 sal_Bool SAL_CALL
OCalcResultSet::supportsService( const ::rtl::OUString
& _rServiceName
) throw( RuntimeException
)
74 Sequence
< ::rtl::OUString
> aSupported(getSupportedServiceNames());
75 const ::rtl::OUString
* pSupported
= aSupported
.getConstArray();
76 const ::rtl::OUString
* pEnd
= pSupported
+ aSupported
.getLength();
77 for (;pSupported
!= pEnd
&& !pSupported
->equals(_rServiceName
); ++pSupported
)
80 return pSupported
!= pEnd
;
82 // -------------------------------------------------------------------------
83 Any SAL_CALL
OCalcResultSet::queryInterface( const Type
& rType
) throw(RuntimeException
)
85 Any aRet
= OResultSet::queryInterface(rType
);
86 return aRet
.hasValue() ? aRet
: OCalcResultSet_BASE::queryInterface(rType
);
88 // -------------------------------------------------------------------------
89 Sequence
< Type
> SAL_CALL
OCalcResultSet::getTypes( ) throw( RuntimeException
)
91 return ::comphelper::concatSequences(OResultSet::getTypes(),OCalcResultSet_BASE::getTypes());
94 // -------------------------------------------------------------------------
96 Any SAL_CALL
OCalcResultSet::getBookmark( ) throw( SQLException
, RuntimeException
)
98 ::osl::MutexGuard
aGuard( m_aMutex
);
99 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
102 return makeAny((sal_Int32
)(m_aRow
->get())[0]->getValue());
104 // -------------------------------------------------------------------------
105 sal_Bool SAL_CALL
OCalcResultSet::moveToBookmark( const Any
& bookmark
) throw( SQLException
, RuntimeException
)
107 ::osl::MutexGuard
aGuard( m_aMutex
);
108 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
111 m_bRowDeleted
= m_bRowInserted
= m_bRowUpdated
= sal_False
;
113 return Move(IResultSetHelper::BOOKMARK
,comphelper::getINT32(bookmark
),sal_True
);
115 // -------------------------------------------------------------------------
116 sal_Bool SAL_CALL
OCalcResultSet::moveRelativeToBookmark( const Any
& bookmark
, sal_Int32 rows
) throw( SQLException
, RuntimeException
)
118 ::osl::MutexGuard
aGuard( m_aMutex
);
119 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
122 m_bRowDeleted
= m_bRowInserted
= m_bRowUpdated
= sal_False
;
124 Move(IResultSetHelper::BOOKMARK
,comphelper::getINT32(bookmark
),sal_False
);
126 return relative(rows
);
129 // -------------------------------------------------------------------------
130 sal_Int32 SAL_CALL
OCalcResultSet::compareBookmarks( const Any
& lhs
, const Any
& rhs
) throw( SQLException
, RuntimeException
)
132 return (lhs
== rhs
) ? 0 : 2;
134 // -------------------------------------------------------------------------
135 sal_Bool SAL_CALL
OCalcResultSet::hasOrderedBookmarks( ) throw( SQLException
, RuntimeException
)
139 // -------------------------------------------------------------------------
140 sal_Int32 SAL_CALL
OCalcResultSet::hashBookmark( const Any
& bookmark
) throw( SQLException
, RuntimeException
)
142 ::osl::MutexGuard
aGuard( m_aMutex
);
143 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
146 return comphelper::getINT32(bookmark
);
148 // -------------------------------------------------------------------------
150 Sequence
< sal_Int32
> SAL_CALL
OCalcResultSet::deleteRows( const Sequence
< Any
>& /*rows*/ ) throw( SQLException
, RuntimeException
)
152 ::osl::MutexGuard
aGuard( m_aMutex
);
153 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
155 ::dbtools::throwFeatureNotImplementedException( "XDeleteRows::deleteRows", *this );
156 return Sequence
< sal_Int32
>();
158 // -------------------------------------------------------------------------
159 sal_Bool
OCalcResultSet::fillIndexValues(const Reference
< XColumnsSupplier
> &/*_xIndex*/)
161 // Calc table has no index
164 // -------------------------------------------------------------------------
165 ::cppu::IPropertyArrayHelper
& OCalcResultSet::getInfoHelper()
167 return *OCalcResultSet_BASE3::getArrayHelper();
169 // -----------------------------------------------------------------------------
170 ::cppu::IPropertyArrayHelper
* OCalcResultSet::createArrayHelper() const
172 Sequence
< Property
> aProps
;
173 describeProperties(aProps
);
174 return new ::cppu::OPropertyArrayHelper(aProps
);
176 // -------------------------------------------------------------------------
177 // -----------------------------------------------------------------------------
178 void SAL_CALL
OCalcResultSet::acquire() throw()
180 OCalcResultSet_BASE2::acquire();
182 // -----------------------------------------------------------------------------
183 void SAL_CALL
OCalcResultSet::release() throw()
185 OCalcResultSet_BASE2::release();
187 // -----------------------------------------------------------------------------
188 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
OCalcResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
)
190 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
192 // -----------------------------------------------------------------------------