[Libreoffice-commits] .: Branch 'feature/mork' - connectivity/Library_mork.mk connectivity/source

David Ostrovsky davido at kemper.freedesktop.org
Sun Jul 22 15:42:40 PDT 2012


 connectivity/Library_mork.mk                     |   18 +
 connectivity/source/drivers/mork/MConnection.cxx |  234 ++++++++++++++++++++++
 connectivity/source/drivers/mork/MConnection.hxx |   97 +++++++++
 connectivity/source/drivers/mork/MDriver.cxx     |  110 ++++++++++
 connectivity/source/drivers/mork/MDriver.hxx     |  102 +++++++++
 connectivity/source/drivers/mork/MServices.cxx   |   37 +++
 connectivity/source/drivers/mork/MorkDriver.cxx  |  243 -----------------------
 connectivity/source/drivers/mork/MorkDriver.hxx  |   58 -----
 connectivity/source/drivers/mork/README          |   41 +++
 connectivity/source/drivers/mork/license.txt     |   31 ++
 10 files changed, 664 insertions(+), 307 deletions(-)

New commits:
commit 1c831d537515f231be067e47377404716160fc31
Author: David Ostrovsky <david at ostrovsky.org>
Date:   Sun Jul 22 20:29:41 2012 +0200

    mork driver: add MServices, MDriver, MConnection
    
    Change-Id: I32fe564e12d14e3891141d65a2c087f699f8f2a0

diff --git a/connectivity/Library_mork.mk b/connectivity/Library_mork.mk
index ec118ed..85e0f81 100644
--- a/connectivity/Library_mork.mk
+++ b/connectivity/Library_mork.mk
@@ -9,14 +9,13 @@
 
 $(eval $(call gb_Library_Library,mork))
 
-$(eval $(call gb_Library_add_exception_objects,mork, \
-    connectivity/source/drivers/mork/MorkDriver \
-    connectivity/source/drivers/mork/MorkParser \
-    connectivity/source/drivers/mork/services \
-))
-
 $(eval $(call gb_Library_set_componentfile,mork,connectivity/source/drivers/mork/mork))
 
+$(eval $(call gb_Library_set_include,mork,\
+	-I$(SRCDIR)/connectivity/source/inc \
+	$$(INCLUDE) \
+))
+
 $(eval $(call gb_Library_use_libraries,mork, \
     cppu \
     cppuhelper \
@@ -26,4 +25,11 @@ $(eval $(call gb_Library_use_libraries,mork, \
 
 $(eval $(call gb_Library_use_sdk_api,mork))
 
+$(eval $(call gb_Library_add_exception_objects,mork, \
+    connectivity/source/drivers/mork/MorkParser \
+    connectivity/source/drivers/mork/MDriver \
+    connectivity/source/drivers/mork/MConnection \
+    connectivity/source/drivers/mork/MServices \
+))
+
 # vim: set noet sw=4 ts=4:
diff --git a/connectivity/source/drivers/mork/MConnection.cxx b/connectivity/source/drivers/mork/MConnection.cxx
new file mode 100644
index 0000000..848ced5
--- /dev/null
+++ b/connectivity/source/drivers/mork/MConnection.cxx
@@ -0,0 +1,234 @@
+/* -*- 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/.
+ */
+
+#include "diagnose_ex.h"
+#include "MConnection.hxx"
+#include "MDriver.hxx"
+
+#include <connectivity/dbcharset.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/sqlerror.hxx>
+
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+
+#include <comphelper/officeresourcebundle.hxx>
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+using namespace dbtools;
+
+//------------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+// --------------------------------------------------------------------------------
+
+namespace connectivity { namespace mork {
+
+// -----------------------------------------------------------------------------
+
+OConnection::OConnection(MorkDriver* _pDriver)
+    :OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this)
+    ,m_pDriver(_pDriver)
+{
+    m_pDriver->acquire();
+
+}
+//-----------------------------------------------------------------------------
+OConnection::~OConnection()
+{
+    acquire();
+    if(!isClosed())
+        close();
+    m_pDriver->release();
+    m_pDriver = NULL;
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL OConnection::release() throw()
+{
+    relase_ChildImpl();
+}
+// -----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info)  throw(SQLException)
+{
+    (void) info; // avoid warnings
+    OSL_TRACE("IN OConnection::construct()" );
+    //  open file
+    setURL(url);
+}
+// XServiceInfo
+// --------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.mork.OConnection", "com.sun.star.sdbc.Connection")
+
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OConnection::createStatement(  ) throw(SQLException, RuntimeException)
+{
+    ::osl::MutexGuard aGuard( m_aMutex );
+    checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+    // create a statement
+    // the statement can only be executed once
+    // Reference< XStatement > xReturn = new OStatement(this);
+    // m_aStatements.push_back(WeakReferenceHelper(xReturn));
+    return NULL;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+    OSL_UNUSED( _sSql );
+    ::osl::MutexGuard aGuard( m_aMutex );
+    checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+    OSL_TRACE("OConnection::prepareStatement( %s )", OUtoCStr( _sSql ) );
+    return NULL;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+    OSL_UNUSED( _sSql );
+    ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
+    OSL_TRACE("OConnection::prepareCall( %s )", OUtoCStr( _sSql ) );
+    return NULL;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+    ::osl::MutexGuard aGuard( m_aMutex );
+    // when you need to transform SQL92 to you driver specific you can do it here
+    OSL_TRACE("OConnection::nativeSQL( %s )", OUtoCStr( _sSql ) );
+
+    return _sSql;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setAutoCommit( sal_Bool /*autoCommit*/ ) throw(SQLException, RuntimeException)
+{
+    ::dbtools::throwFeatureNotImplementedException( "XConnection::setAutoCommit", *this );
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::getAutoCommit(  ) throw(SQLException, RuntimeException)
+{
+    // you have to distinguish which if you are in autocommit mode or not
+    // at normal case true should be fine here
+
+    return sal_True;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::commit(  ) throw(SQLException, RuntimeException)
+{
+    // when you database does support transactions you should commit here
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::rollback(  ) throw(SQLException, RuntimeException)
+{
+    // same as commit but for the other case
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isClosed(  ) throw(SQLException, RuntimeException)
+{
+    ::osl::MutexGuard aGuard( m_aMutex );
+
+    // just simple -> we are close when we are disposed taht means someone called dispose(); (XComponent)
+    return OConnection_BASE::rBHelper.bDisposed;
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData(  ) throw(SQLException, RuntimeException)
+{
+    ::osl::MutexGuard aGuard( m_aMutex );
+    checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+    return NULL;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setReadOnly( sal_Bool /*readOnly*/ ) throw(SQLException, RuntimeException)
+{
+    ::dbtools::throwFeatureNotImplementedException( "XConnection::setReadOnly", *this );
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isReadOnly(  ) throw(SQLException, RuntimeException)
+{
+    // return if your connection to readonly
+    return sal_False;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& /*catalog*/ ) throw(SQLException, RuntimeException)
+{
+    ::dbtools::throwFeatureNotImplementedException( "XConnection::setCatalog", *this );
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::getCatalog(  ) throw(SQLException, RuntimeException)
+{
+    return ::rtl::OUString();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
+{
+    ::dbtools::throwFeatureNotImplementedException( "XConnection::setTransactionIsolation", *this );
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OConnection::getTransactionIsolation(  ) throw(SQLException, RuntimeException)
+{
+    // please have a look at @see com.sun.star.sdbc.TransactionIsolation
+    return TransactionIsolation::NONE;
+}
+// --------------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap(  ) throw(SQLException, RuntimeException)
+{
+    // if your driver has special database types you can return it here
+    return NULL;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+    ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this );
+}
+// --------------------------------------------------------------------------------
+// XCloseable
+void SAL_CALL OConnection::close(  ) throw(SQLException, RuntimeException)
+{
+    // we just dispose us
+    {
+        ::osl::MutexGuard aGuard( m_aMutex );
+        checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+    }
+    dispose();
+}
+// --------------------------------------------------------------------------------
+// XWarningsSupplier
+Any SAL_CALL OConnection::getWarnings(  ) throw(SQLException, RuntimeException)
+{
+    // when you collected some warnings -> return it
+    return Any();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::clearWarnings(  ) throw(SQLException, RuntimeException)
+{
+    // you should clear your collected warnings here
+}
+//------------------------------------------------------------------------------
+void OConnection::disposing()
+{
+    // we noticed that we should be destroied in near future so we have to dispose our statements
+    ::osl::MutexGuard aGuard(m_aMutex);
+    dispose_ChildImpl();
+}
+// -----------------------------------------------------------------------------
+
+
+} } // namespace connectivity::mork
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MConnection.hxx b/connectivity/source/drivers/mork/MConnection.hxx
new file mode 100644
index 0000000..f1fabdc
--- /dev/null
+++ b/connectivity/source/drivers/mork/MConnection.hxx
@@ -0,0 +1,97 @@
+/* -*- 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/.
+ */
+
+#ifndef CONNECTIVITY_SCONNECTION_HXX
+#define CONNECTIVITY_SCONNECTION_HXX
+
+#include "connectivity/CommonTools.hxx"
+
+#include "connectivity/OSubComponent.hxx"
+#include "TConnection.hxx"
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+
+#include <cppuhelper/weakref.hxx>
+
+#include <memory>
+
+namespace connectivity
+{
+    namespace mork
+    {
+        namespace css = com::sun::star;
+
+        class MorkDriver;
+        class ErrorDescriptor;
+
+        typedef connectivity::OMetaConnection OConnection_BASE; // implements basics and text encoding
+
+        class OConnection : public OConnection_BASE,
+                            public connectivity::OSubComponent<OConnection, OConnection_BASE>
+        {
+            friend class connectivity::OSubComponent<OConnection, OConnection_BASE>;
+
+        protected:
+            //====================================================================
+            // Data attributes
+            //====================================================================
+            ::com::sun::star::sdbc::SQLWarning      m_aLastWarning;
+            MorkDriver*                             m_pDriver;      //  Pointer to the owning
+                                                                    //  driver object
+            // Store Catalog
+            ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier>         m_xCatalog;
+
+        public:
+            virtual void construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
+            OConnection(MorkDriver* const driver);
+            virtual ~OConnection();
+
+            void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
+
+            // OComponentHelper
+            virtual void SAL_CALL disposing(void);
+            // XInterface
+            virtual void SAL_CALL release() throw();
+
+            // XServiceInfo
+            DECLARE_SERVICE_INFO();
+            // XConnection
+            virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual sal_Bool SAL_CALL getAutoCommit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual void SAL_CALL commit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual void SAL_CALL rollback(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual sal_Bool SAL_CALL isClosed(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual sal_Bool SAL_CALL isReadOnly(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual ::rtl::OUString SAL_CALL getCatalog(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual sal_Int32 SAL_CALL getTransactionIsolation(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            // XCloseable
+            virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            // XWarningsSupplier
+            virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+            virtual void SAL_CALL clearWarnings() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+            static ::rtl::OUString getDriverImplementationName();
+        };
+    }
+}
+#endif // CONNECTIVITY_SCONNECTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MDriver.cxx b/connectivity/source/drivers/mork/MDriver.cxx
new file mode 100644
index 0000000..7c73eef
--- /dev/null
+++ b/connectivity/source/drivers/mork/MDriver.cxx
@@ -0,0 +1,110 @@
+/* -*- 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/.
+ */
+
+#include "MDriver.hxx"
+#include "MConnection.hxx"
+
+using namespace connectivity::mork;
+
+namespace connectivity
+{
+    namespace mork
+    {
+        css::uno::Reference< css::uno::XInterface > create(css::uno::Reference< css::uno::XComponentContext > const & context)
+        {
+            return static_cast< cppu::OWeakObject * >(new MorkDriver(context));
+        }
+    }
+}
+
+MorkDriver::MorkDriver(css::uno::Reference< css::uno::XComponentContext > const context):
+    context_(context)
+{
+    assert(context.is());
+}
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString MorkDriver::getImplementationName_Static(  ) throw(css::uno::RuntimeException)
+{
+    return rtl::OUString(MORK_DRIVER_IMPL_NAME);
+}
+
+//------------------------------------------------------------------------------
+css::uno::Sequence< ::rtl::OUString > MorkDriver::getSupportedServiceNames_Static(  ) throw (css::uno::RuntimeException)
+{
+    css::uno::Sequence< ::rtl::OUString > aSNS(1);
+    aSNS[0] = ::rtl::OUString( "com.sun.star.sdbc.Driver");
+    return aSNS;
+}
+
+rtl::OUString SAL_CALL MorkDriver::getImplementationName()
+    throw (css::uno::RuntimeException)
+{
+    return getImplementationName_Static();
+}
+
+sal_Bool SAL_CALL MorkDriver::supportsService(const rtl::OUString& serviceName)
+    throw (css::uno::RuntimeException)
+{
+    css::uno::Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+    const ::rtl::OUString* pSupported = aSupported.getConstArray();
+    const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+    for (;pSupported != pEnd && !pSupported->equals(serviceName); ++pSupported)
+        ;
+
+    return pSupported != pEnd;
+}
+
+css::uno::Sequence< rtl::OUString > MorkDriver::getSupportedServiceNames()
+    throw (css::uno::RuntimeException)
+{
+    return getSupportedServiceNames_Static();
+}
+
+css::uno::Reference< css::sdbc::XConnection > MorkDriver::connect(
+    rtl::OUString const & url,
+    css::uno::Sequence< css::beans::PropertyValue > const & info)
+    throw (css::sdbc::SQLException, css::uno::RuntimeException)
+{
+    //... TODO
+    (void) url; (void) info; // avoid warnings
+    //    return static_cast< cppu::OWeakObject * >(new MConnection(this));
+    return NULL;
+}
+
+sal_Bool MorkDriver::acceptsURL(rtl::OUString const & url)
+    throw (css::sdbc::SQLException, css::uno::RuntimeException)
+{
+    //... TODO
+    (void) url; // avoid warnings
+    return false;
+}
+
+css::uno::Sequence< css::sdbc::DriverPropertyInfo > MorkDriver::getPropertyInfo(
+    rtl::OUString const & url,
+    css::uno::Sequence< css::beans::PropertyValue > const & info)
+    throw (css::sdbc::SQLException, css::uno::RuntimeException)
+{
+    //... TODO
+    (void) url; (void) info; // avoid warnings
+    return css::uno::Sequence< css::sdbc::DriverPropertyInfo >();
+}
+
+sal_Int32 MorkDriver::getMajorVersion() throw (css::uno::RuntimeException) {
+    //... TODO
+    return 0;
+}
+
+sal_Int32 MorkDriver::getMinorVersion() throw (css::uno::RuntimeException) {
+    //... TODO
+    return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MDriver.hxx b/connectivity/source/drivers/mork/MDriver.hxx
new file mode 100644
index 0000000..08ecf46
--- /dev/null
+++ b/connectivity/source/drivers/mork/MDriver.hxx
@@ -0,0 +1,102 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_DRIVER_HXX
+#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_DRIVER_HXX
+
+#include "sal/config.h"
+
+#include <cassert>
+
+#include "boost/noncopyable.hpp"
+#include "com/sun/star/beans/PropertyValue.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/sdbc/DriverPropertyInfo.hpp"
+#include "com/sun/star/sdbc/SQLException.hpp"
+#include "com/sun/star/sdbc/XConnection.hpp"
+#include "com/sun/star/sdbc/XDriver.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "cppuhelper/implbase2.hxx"
+#include "cppuhelper/weak.hxx"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+
+#define MORK_DRIVER_IMPL_NAME "com.sun.star.comp.sdbc.MorkDriver"
+
+namespace com { namespace sun { namespace star {
+    namespace uno {
+        class XComponentContext;
+        class XInterface;
+    }
+} } }
+namespace rtl { class OUString; }
+
+namespace connectivity { namespace mork {
+
+namespace css = com::sun::star;
+
+com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL
+create(
+    com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+        const &);
+
+class MorkDriver:
+    public cppu::WeakImplHelper2< css::lang::XServiceInfo, css::sdbc::XDriver >,
+    private boost::noncopyable
+{
+public:
+    MorkDriver(css::uno::Reference< css::uno::XComponentContext > const context);
+    static ::rtl::OUString getImplementationName_Static()
+        throw(css::uno::RuntimeException);
+    static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static()
+        throw (css::uno::RuntimeException);
+private:
+    virtual ~MorkDriver() {}
+
+    virtual rtl::OUString SAL_CALL getImplementationName()
+        throw (css::uno::RuntimeException);
+
+    virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
+        throw (css::uno::RuntimeException);
+
+    virtual css::uno::Sequence< rtl::OUString > SAL_CALL
+    getSupportedServiceNames() throw (css::uno::RuntimeException);
+
+    virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect(
+        rtl::OUString const & url,
+        css::uno::Sequence< css::beans::PropertyValue > const & info)
+        throw (css::sdbc::SQLException, css::uno::RuntimeException);
+
+    virtual sal_Bool SAL_CALL acceptsURL(
+        rtl::OUString const & url)
+        throw (css::sdbc::SQLException, css::uno::RuntimeException);
+
+    virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL
+    getPropertyInfo(
+        rtl::OUString const & url,
+        css::uno::Sequence< css::beans::PropertyValue > const & info)
+        throw (css::sdbc::SQLException, css::uno::RuntimeException);
+
+    virtual sal_Int32 SAL_CALL getMajorVersion()
+        throw (css::uno::RuntimeException);
+
+    virtual sal_Int32 SAL_CALL getMinorVersion()
+        throw (css::uno::RuntimeException);
+
+    css::uno::Reference< css::uno::XComponentContext > context_;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MServices.cxx b/connectivity/source/drivers/mork/MServices.cxx
new file mode 100644
index 0000000..3dfeb20
--- /dev/null
+++ b/connectivity/source/drivers/mork/MServices.cxx
@@ -0,0 +1,37 @@
+/* -*- 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/.
+ */
+
+#include "sal/config.h"
+
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "sal/types.h"
+
+#include "MDriver.hxx"
+
+namespace {
+
+static cppu::ImplementationEntry const services[] = {
+    { &connectivity::mork::create,
+      &connectivity::mork::MorkDriver::getImplementationName_Static,
+      &connectivity::mork::MorkDriver::getSupportedServiceNames_Static,
+      &cppu::createSingleComponentFactory, 0, 0 },
+    { 0, 0, 0, 0, 0, 0 }
+};
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+    char const * pImplName, void * pServiceManager, void * pRegistryKey)
+{
+    return cppu::component_getFactoryHelper(
+        pImplName, pServiceManager, pRegistryKey, services);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MorkDriver.cxx b/connectivity/source/drivers/mork/MorkDriver.cxx
deleted file mode 100644
index 83f9d7c..0000000
--- a/connectivity/source/drivers/mork/MorkDriver.cxx
+++ /dev/null
@@ -1,243 +0,0 @@
-/* -*- 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/.
- */
-
-#include "sal/config.h"
-
-#include <cassert>
-
-#include "boost/noncopyable.hpp"
-#include "com/sun/star/beans/PropertyValue.hpp"
-#include "com/sun/star/lang/XServiceInfo.hpp"
-#include "com/sun/star/sdbc/DriverPropertyInfo.hpp"
-#include "com/sun/star/sdbc/SQLException.hpp"
-#include "com/sun/star/sdbc/XConnection.hpp"
-#include "com/sun/star/sdbc/XDriver.hpp"
-#include "com/sun/star/uno/Reference.hxx"
-#include "com/sun/star/uno/RuntimeException.hpp"
-#include "com/sun/star/uno/Sequence.hxx"
-#include "com/sun/star/uno/XComponentContext.hpp"
-#include "cppuhelper/implbase1.hxx"
-#include "cppuhelper/implbase2.hxx"
-#include "cppuhelper/weak.hxx"
-#include "rtl/ustring.hxx"
-#include "sal/types.h"
-
-#include "MorkDriver.hxx"
-
-namespace css = com::sun::star;
-
-namespace connectivity
-{
-namespace mork
-{
-
-class Service:
-    public cppu::WeakImplHelper2< css::lang::XServiceInfo, css::sdbc::XDriver >,
-    private boost::noncopyable
-{
-public:
-    Service(css::uno::Reference< css::uno::XComponentContext > const context):
-        context_(context)
-    {
-        assert(context.is());
-    }
-
-private:
-    virtual ~Service() {}
-
-    rtl::OUString SAL_CALL getImplementationName()
-    throw (css::uno::RuntimeException)
-    {
-        return connectivity::mork::getImplementationName();
-    }
-
-    sal_Bool SAL_CALL supportsService(rtl::OUString const &ServiceName)
-    throw (css::uno::RuntimeException)
-    {
-        return ServiceName == getSupportedServiceNames()[0];    //TODO
-    }
-
-    css::uno::Sequence< rtl::OUString > SAL_CALL
-    getSupportedServiceNames() throw (css::uno::RuntimeException)
-    {
-        return connectivity::mork::getSupportedServiceNames();
-    }
-
-    css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect(
-        rtl::OUString const &url,
-        css::uno::Sequence< css::beans::PropertyValue > const &info)
-    throw (css::sdbc::SQLException, css::uno::RuntimeException);
-
-    sal_Bool SAL_CALL acceptsURL(
-        rtl::OUString const &url)
-    throw (css::sdbc::SQLException, css::uno::RuntimeException);
-
-    css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL
-    getPropertyInfo(
-        rtl::OUString const &url,
-        css::uno::Sequence< css::beans::PropertyValue > const &info)
-    throw (css::sdbc::SQLException, css::uno::RuntimeException);
-
-    sal_Int32 SAL_CALL getMajorVersion()
-    throw (css::uno::RuntimeException);
-
-    sal_Int32 SAL_CALL getMinorVersion()
-    throw (css::uno::RuntimeException);
-
-    css::uno::Reference< css::uno::XComponentContext > context_;
-};
-
-class Connection:
-    public cppu::WeakImplHelper1< css::sdbc::XConnection >,
-    private boost::noncopyable
-{
-public:
-    Connection(
-        css::uno::Reference< css::uno::XComponentContext > const context);
-
-private:
-    ~Connection();
-
-    // XConnection
-    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement(  )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString &sql )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString &sql )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString &sql )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    void SAL_CALL setAutoCommit( sal_Bool autoCommit )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    sal_Bool SAL_CALL getAutoCommit(  )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    void SAL_CALL commit(  )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    void SAL_CALL rollback(  )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    sal_Bool SAL_CALL isClosed(  )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData(  )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    void SAL_CALL setReadOnly( sal_Bool readOnly )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    sal_Bool SAL_CALL isReadOnly(  )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    void SAL_CALL setCatalog( const ::rtl::OUString &catalog )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    ::rtl::OUString SAL_CALL getCatalog(  )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    void SAL_CALL setTransactionIsolation( sal_Int32 level )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    sal_Int32 SAL_CALL getTransactionIsolation(  )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap(  )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
-    throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-    // XCloseable
-    void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-
-    css::uno::Reference< css::uno::XComponentContext > context_;
-};
-
-}
-}
-
-connectivity::mork::Connection::Connection(
-    css::uno::Reference< css::uno::XComponentContext > const context):
-    context_(context)
-{
-    assert(context.is());
-}
-
-connectivity::mork::Connection::~Connection()
-{
-}
-
-css::uno::Reference< css::sdbc::XConnection > connectivity::mork::Service::connect(
-    rtl::OUString const &url,
-    css::uno::Sequence< css::beans::PropertyValue > const &info)
-throw (css::sdbc::SQLException, css::uno::RuntimeException)
-{
-    //... TODO
-    (void) url;
-    (void) info; // avoid warnings
-
-    return new connectivity::mork::Connection(context_);
-}
-
-sal_Bool connectivity::mork::Service::acceptsURL(rtl::OUString const &url)
-throw (css::sdbc::SQLException, css::uno::RuntimeException)
-{
-    //... TODO
-    (void) url; // avoid warnings
-    return false;
-}
-
-css::uno::Sequence< css::sdbc::DriverPropertyInfo > connectivity::mork::Service::getPropertyInfo(
-    rtl::OUString const &url,
-    css::uno::Sequence< css::beans::PropertyValue > const &info)
-throw (css::sdbc::SQLException, css::uno::RuntimeException)
-{
-    //... TODO
-    (void) url;
-    (void) info; // avoid warnings
-    return css::uno::Sequence< css::sdbc::DriverPropertyInfo >();
-}
-
-sal_Int32 connectivity::mork::Service::getMajorVersion() throw (css::uno::RuntimeException)
-{
-    //... TODO
-    return 0;
-}
-
-sal_Int32 connectivity::mork::Service::getMinorVersion() throw (css::uno::RuntimeException)
-{
-    //... TODO
-    return 0;
-}
-
-css::uno::Reference< css::uno::XInterface > create(
-    css::uno::Reference< css::uno::XComponentContext > const &context)
-{
-    return static_cast< cppu::OWeakObject * >(new connectivity::mork::Service(context));
-}
-
-rtl::OUString connectivity::mork::getImplementationName()
-{
-    return rtl::OUString("com.sun.star.comp.sdbc.MorkDriver");
-}
-
-css::uno::Sequence< rtl::OUString > connectivity::mork::getSupportedServiceNames()
-{
-    rtl::OUString name("com.sun.star.sdbc.Driver");
-    return css::uno::Sequence< rtl::OUString >(&name, 1);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MorkDriver.hxx b/connectivity/source/drivers/mork/MorkDriver.hxx
deleted file mode 100644
index 3ec2890..0000000
--- a/connectivity/source/drivers/mork/MorkDriver.hxx
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- 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/.
- */
-
-#ifndef _MORK_DRIVER_HXX_
-#define _MORK_DRIVER_HXX_
-
-#include "sal/config.h"
-
-#include "com/sun/star/uno/Reference.hxx"
-#include "com/sun/star/uno/Sequence.hxx"
-#include "sal/types.h"
-
-namespace com
-{
-namespace sun
-{
-namespace star
-{
-namespace uno
-{
-class XComponentContext;
-class XInterface;
-}
-}
-}
-}
-namespace rtl
-{
-class OUString;
-}
-
-namespace connectivity
-{
-namespace mork
-{
-
-com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL
-create(
-    com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
-    const &);
-
-rtl::OUString SAL_CALL getImplementationName();
-
-com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
-getSupportedServiceNames();
-
-}
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/README b/connectivity/source/drivers/mork/README
new file mode 100644
index 0000000..0b1e30b
--- /dev/null
+++ b/connectivity/source/drivers/mork/README
@@ -0,0 +1,41 @@
+Mork Format Parsing Library
+=============================
+
+Description
+-----------
+
+Cross Platform Mozilla Mork format reader.
+
+
+Compillation
+------------
+
+g++ -o MorkParser main.cpp MorkParser.cpp
+
+
+License
+-------
+
+This program is licensed under permissive BSD license.
+See the license.txt file for more information.
+
+
+Date: October 16th, 2007
+
+Project Maintainers:
+  Yuriy Soroka
+  ysoroka at scalingweb.com
+
+  http://www.scalingweb.com/
+
+Thanks
+-------------
+Thanks to Petr Stejskal <stejsky at volny.cz> who helped with porting this code from Qt to STL.
+
+  
+How you can help
+----------------
+
+  Comments, patches, bug reports are welcome.
+
+
diff --git a/connectivity/source/drivers/mork/license.txt b/connectivity/source/drivers/mork/license.txt
new file mode 100644
index 0000000..aed4ba1
--- /dev/null
+++ b/connectivity/source/drivers/mork/license.txt
@@ -0,0 +1,31 @@
+Software License Agreement (BSD License)
+
+Copyright (c) 2006, ScalingWeb.com
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms, with or without modification, are
+permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above
+  copyright notice, this list of conditions and the
+  following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+  copyright notice, this list of conditions and the
+  following disclaimer in the documentation and/or other
+  materials provided with the distribution.
+
+* Neither the name of ScalingWeb.com nor the names of its
+  contributors may be used to endorse or promote products
+  derived from this software without specific prior
+  written permission of ScalingWeb.com.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+


More information about the Libreoffice-commits mailing list