summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-07-18 10:53:15 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-07-18 15:55:50 +0200
commita93c89894feb663df37609c95d4db523120c0bc1 (patch)
treedd17e929e2a10d369a2b958580a9419b0969c61a /connectivity
parent48ae7e505f59df0920b417ce1951cb3d0e905419 (diff)
connectivity writer driver: add ResultSet implementation
Now column headers and table data show up on the UI. Change-Id: I84100c5a7ac65c3be1e985be8ae7195835c45145 Reviewed-on: https://gerrit.libreoffice.org/40128 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/Library_writer.mk1
-rw-r--r--connectivity/source/drivers/writer/WPreparedStatement.cxx5
-rw-r--r--connectivity/source/drivers/writer/WResultSet.cxx165
-rw-r--r--connectivity/source/inc/writer/WResultSet.hxx86
4 files changed, 255 insertions, 2 deletions
diff --git a/connectivity/Library_writer.mk b/connectivity/Library_writer.mk
index c5cd2ddf3979..99db1f98529f 100644
--- a/connectivity/Library_writer.mk
+++ b/connectivity/Library_writer.mk
@@ -43,6 +43,7 @@ $(eval $(call gb_Library_add_exception_objects,writer,\
connectivity/source/drivers/writer/WDatabaseMetaData \
connectivity/source/drivers/writer/WDriver \
connectivity/source/drivers/writer/WPreparedStatement \
+ connectivity/source/drivers/writer/WResultSet \
connectivity/source/drivers/writer/WTable \
connectivity/source/drivers/writer/WTables \
connectivity/source/drivers/writer/Wservices \
diff --git a/connectivity/source/drivers/writer/WPreparedStatement.cxx b/connectivity/source/drivers/writer/WPreparedStatement.cxx
index 5dffe6e9b2b3..9328d15be765 100644
--- a/connectivity/source/drivers/writer/WPreparedStatement.cxx
+++ b/connectivity/source/drivers/writer/WPreparedStatement.cxx
@@ -19,6 +19,8 @@
#include "writer/WPreparedStatement.hxx"
+#include "writer/WResultSet.hxx"
+
using namespace com::sun::star;
namespace connectivity
@@ -28,8 +30,7 @@ namespace writer
file::OResultSet* OWriterPreparedStatement::createResultSet()
{
- SAL_WARN("connectivity.writer", "TODO implement OWriterPreparedStatement::createResultSet");
- return nullptr;
+ return new OWriterResultSet(this, m_aSQLIterator);
}
IMPLEMENT_SERVICE_INFO(OWriterPreparedStatement,"com.sun.star.sdbc.driver.writer.PreparedStatement", "com.sun.star.sdbc.PreparedStatement");
diff --git a/connectivity/source/drivers/writer/WResultSet.cxx b/connectivity/source/drivers/writer/WResultSet.cxx
new file mode 100644
index 000000000000..93919657aad5
--- /dev/null
+++ b/connectivity/source/drivers/writer/WResultSet.cxx
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "writer/WResultSet.hxx"
+
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <connectivity/dbexception.hxx>
+
+using namespace com::sun::star;
+
+namespace connectivity
+{
+namespace writer
+{
+
+OWriterResultSet::OWriterResultSet(file::OStatement_Base* pStmt, connectivity::OSQLParseTreeIterator& _aSQLIterator)
+ : file::OResultSet(pStmt,_aSQLIterator)
+ ,m_bBookmarkable(true)
+{
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, beans::PropertyAttribute::READONLY,&m_bBookmarkable, cppu::UnoType<bool>::get());
+}
+
+OUString SAL_CALL OWriterResultSet::getImplementationName()
+{
+ return OUString("com.sun.star.sdbcx.writer.ResultSet");
+}
+
+uno::Sequence<OUString> SAL_CALL OWriterResultSet::getSupportedServiceNames()
+{
+ uno::Sequence<OUString> aSupported(2);
+ aSupported[0] = "com.sun.star.sdbc.ResultSet";
+ aSupported[1] = "com.sun.star.sdbcx.ResultSet";
+ return aSupported;
+}
+
+sal_Bool SAL_CALL OWriterResultSet::supportsService(const OUString& _rServiceName)
+{
+ return cppu::supportsService(this, _rServiceName);
+}
+
+uno::Any SAL_CALL OWriterResultSet::queryInterface(const uno::Type& rType)
+{
+ uno::Any aRet = OResultSet::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OWriterResultSet_BASE::queryInterface(rType);
+}
+
+uno::Sequence<uno::Type> SAL_CALL OWriterResultSet::getTypes()
+{
+ return ::comphelper::concatSequences(OResultSet::getTypes(), OWriterResultSet_BASE::getTypes());
+}
+
+uno::Any SAL_CALL OWriterResultSet::getBookmark()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(file::OResultSet_BASE::rBHelper.bDisposed);
+
+ return uno::makeAny((sal_Int32)(m_aRow->get())[0]->getValue());
+}
+
+sal_Bool SAL_CALL OWriterResultSet::moveToBookmark(const uno::Any& bookmark)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(file::OResultSet_BASE::rBHelper.bDisposed);
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false;
+
+ return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true);
+}
+
+sal_Bool SAL_CALL OWriterResultSet::moveRelativeToBookmark(const uno::Any& bookmark, sal_Int32 rows)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(file::OResultSet_BASE::rBHelper.bDisposed);
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false;
+
+ Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),false);
+
+ return relative(rows);
+}
+
+sal_Int32 SAL_CALL OWriterResultSet::compareBookmarks(const uno::Any& lhs, const uno::Any& rhs)
+{
+ return (lhs == rhs) ? css::sdbcx::CompareBookmark::EQUAL : css::sdbcx::CompareBookmark::NOT_EQUAL;
+}
+
+sal_Bool SAL_CALL OWriterResultSet::hasOrderedBookmarks()
+{
+ return true;
+}
+
+sal_Int32 SAL_CALL OWriterResultSet::hashBookmark(const uno::Any& bookmark)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(file::OResultSet_BASE::rBHelper.bDisposed);
+
+ return comphelper::getINT32(bookmark);
+}
+
+uno::Sequence<sal_Int32> SAL_CALL OWriterResultSet::deleteRows(const uno::Sequence<uno::Any>& /*rows*/)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(file::OResultSet_BASE::rBHelper.bDisposed);
+
+ ::dbtools::throwFeatureNotImplementedSQLException("XDeleteRows::deleteRows", *this);
+ return uno::Sequence<sal_Int32>();
+}
+
+bool OWriterResultSet::fillIndexValues(const uno::Reference<css::sdbcx::XColumnsSupplier>& /*_xIndex*/)
+{
+ // Writer table have no index.
+ return false;
+}
+
+::cppu::IPropertyArrayHelper& OWriterResultSet::getInfoHelper()
+{
+ return *OWriterResultSet_BASE3::getArrayHelper();
+}
+
+cppu::IPropertyArrayHelper* OWriterResultSet::createArrayHelper() const
+{
+ uno::Sequence<beans::Property> aProps;
+ describeProperties(aProps);
+ return new cppu::OPropertyArrayHelper(aProps);
+}
+
+void SAL_CALL OWriterResultSet::acquire() throw()
+{
+ OWriterResultSet_BASE2::acquire();
+}
+
+void SAL_CALL OWriterResultSet::release() throw()
+{
+ OWriterResultSet_BASE2::release();
+}
+
+css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OWriterResultSet::getPropertySetInfo()
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+
+} // namespace writer
+} // namespace connectivity
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/inc/writer/WResultSet.hxx b/connectivity/source/inc/writer/WResultSet.hxx
new file mode 100644
index 000000000000..c97b4519bacf
--- /dev/null
+++ b/connectivity/source/inc/writer/WResultSet.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WRESULTSET_HXX
+#define INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WRESULTSET_HXX
+
+#include "file/FResultSet.hxx"
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+namespace connectivity
+{
+namespace writer
+{
+class OWriterResultSet;
+// these typedef's are only necessary for the compiler
+typedef ::cppu::ImplHelper2< css::sdbcx::XRowLocate,
+ css::sdbcx::XDeleteRows> OWriterResultSet_BASE;
+typedef file::OResultSet OWriterResultSet_BASE2;
+typedef ::comphelper::OPropertyArrayUsageHelper<OWriterResultSet> OWriterResultSet_BASE3;
+
+
+class OWriterResultSet : public OWriterResultSet_BASE2,
+ public OWriterResultSet_BASE,
+ public OWriterResultSet_BASE3
+{
+ bool m_bBookmarkable;
+protected:
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
+ virtual bool fillIndexValues(const css::uno::Reference< css::sdbcx::XColumnsSupplier>& _xIndex) override;
+public:
+ DECLARE_SERVICE_INFO();
+
+ OWriterResultSet(file::OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator);
+
+private:
+ // XInterface
+ virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& rType) override;
+ virtual void SAL_CALL acquire() throw() override;
+ virtual void SAL_CALL release() throw() override;
+ //XTypeProvider
+ virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
+ // XPropertySet
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
+
+ // XRowLocate
+ virtual css::uno::Any SAL_CALL getBookmark() override;
+ virtual sal_Bool SAL_CALL moveToBookmark(const css::uno::Any& bookmark) override;
+ virtual sal_Bool SAL_CALL moveRelativeToBookmark(const css::uno::Any& bookmark, sal_Int32 rows) override;
+ virtual sal_Int32 SAL_CALL compareBookmarks(const css::uno::Any& first, const css::uno::Any& second) override;
+ virtual sal_Bool SAL_CALL hasOrderedBookmarks() override;
+ virtual sal_Int32 SAL_CALL hashBookmark(const css::uno::Any& bookmark) override;
+ // XDeleteRows
+ virtual css::uno::Sequence< sal_Int32 > SAL_CALL deleteRows(const css::uno::Sequence< css::uno::Any >& rows) override;
+
+ virtual bool isRowDeleted() const override
+ {
+ return false;
+ }
+
+};
+} // namespace writer
+} // namespace connectivity
+
+#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WRESULTSET_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */