[Libreoffice-commits] core.git: connectivity/Library_writer.mk connectivity/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Jul 18 07:10:06 UTC 2017


 connectivity/Library_writer.mk                            |    1 
 connectivity/source/drivers/writer/WConnection.cxx        |   11 ++-
 connectivity/source/drivers/writer/WPreparedStatement.cxx |   40 +++++++++++++
 connectivity/source/inc/writer/WPreparedStatement.hxx     |   43 ++++++++++++++
 4 files changed, 91 insertions(+), 4 deletions(-)

New commits:
commit ac3c24bec925dd53f07b2827dab0d71c0dbaedee
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jul 17 18:20:38 2017 +0200

    connectivity writer driver: add PreparedStatement implementation
    
    Gets rid of the stub warnings in OWriterConnection::prepareStatement().
    
    Change-Id: I05db81898d8117578130e660932608fcc927edf0
    Reviewed-on: https://gerrit.libreoffice.org/40092
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/connectivity/Library_writer.mk b/connectivity/Library_writer.mk
index 4fab8bf043d9..c5cd2ddf3979 100644
--- a/connectivity/Library_writer.mk
+++ b/connectivity/Library_writer.mk
@@ -42,6 +42,7 @@ $(eval $(call gb_Library_add_exception_objects,writer,\
 	connectivity/source/drivers/writer/WConnection \
 	connectivity/source/drivers/writer/WDatabaseMetaData \
 	connectivity/source/drivers/writer/WDriver \
+	connectivity/source/drivers/writer/WPreparedStatement \
 	connectivity/source/drivers/writer/WTable \
 	connectivity/source/drivers/writer/WTables \
 	connectivity/source/drivers/writer/Wservices \
diff --git a/connectivity/source/drivers/writer/WConnection.cxx b/connectivity/source/drivers/writer/WConnection.cxx
index bec672575682..aea1fd2c12ab 100644
--- a/connectivity/source/drivers/writer/WConnection.cxx
+++ b/connectivity/source/drivers/writer/WConnection.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
 #include <tools/urlobj.hxx>
+#include "writer/WPreparedStatement.hxx"
 #include <unotools/pathoptions.hxx>
 #include <connectivity/dbexception.hxx>
 #include <cppuhelper/exc_hlp.hxx>
@@ -231,14 +232,16 @@ uno::Reference< sdbc::XStatement > SAL_CALL OWriterConnection::createStatement()
 }
 
 
-uno::Reference< sdbc::XPreparedStatement > SAL_CALL OWriterConnection::prepareStatement(const OUString& /*sql*/)
+uno::Reference< sdbc::XPreparedStatement > SAL_CALL OWriterConnection::prepareStatement(const OUString& sql)
 {
     ::osl::MutexGuard aGuard(m_aMutex);
     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
 
-    SAL_WARN("connectivity.writer", "TODO implement OWriterConnection::prepareStatement()");
-
-    return nullptr;
+    OWriterPreparedStatement* pStmt = new OWriterPreparedStatement(this);
+    uno::Reference<sdbc::XPreparedStatement> xHoldAlive = pStmt;
+    pStmt->construct(sql);
+    m_aStatements.push_back(uno::WeakReferenceHelper(*pStmt));
+    return pStmt;
 }
 
 
diff --git a/connectivity/source/drivers/writer/WPreparedStatement.cxx b/connectivity/source/drivers/writer/WPreparedStatement.cxx
new file mode 100644
index 000000000000..5dffe6e9b2b3
--- /dev/null
+++ b/connectivity/source/drivers/writer/WPreparedStatement.cxx
@@ -0,0 +1,40 @@
+/* -*- 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/WPreparedStatement.hxx"
+
+using namespace com::sun::star;
+
+namespace connectivity
+{
+namespace writer
+{
+
+file::OResultSet* OWriterPreparedStatement::createResultSet()
+{
+    SAL_WARN("connectivity.writer", "TODO implement OWriterPreparedStatement::createResultSet");
+    return nullptr;
+}
+
+IMPLEMENT_SERVICE_INFO(OWriterPreparedStatement,"com.sun.star.sdbc.driver.writer.PreparedStatement", "com.sun.star.sdbc.PreparedStatement");
+
+} // namespace writer
+} // namespace connectivity
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/inc/writer/WPreparedStatement.hxx b/connectivity/source/inc/writer/WPreparedStatement.hxx
new file mode 100644
index 000000000000..00998cab04bb
--- /dev/null
+++ b/connectivity/source/inc/writer/WPreparedStatement.hxx
@@ -0,0 +1,43 @@
+/* -*- 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_WPREPAREDSTATEMENT_HXX
+#define INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WPREPAREDSTATEMENT_HXX
+
+#include "file/FPreparedStatement.hxx"
+
+namespace connectivity
+{
+namespace writer
+{
+class OConnection;
+class OWriterPreparedStatement : public file::OPreparedStatement
+{
+protected:
+    virtual file::OResultSet* createResultSet() override;
+public:
+    OWriterPreparedStatement(file::OConnection* _pConnection) : file::OPreparedStatement(_pConnection) {}
+    DECLARE_SERVICE_INFO();
+};
+} // namespace writer
+} // namespace connectivity
+
+#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WPREPAREDSTATEMENT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list