summaryrefslogtreecommitdiffstats
path: root/connectivity
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2012-09-17 22:50:49 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-09-18 08:30:01 +0000
commit77e4adbe4759f21f6cf095d954391a9ddbbec2cf (patch)
treeeb124e090a1b9029cdb34f122a2b0ed557603ce5 /connectivity
parentcorrections ::rtl::OUString, sal_Bool and macros, in avmedia (diff)
downloadcore-77e4adbe4759f21f6cf095d954391a9ddbbec2cf.tar.gz
core-77e4adbe4759f21f6cf095d954391a9ddbbec2cf.zip
mork driver implementation
This is a preparation for merge into master, feature/mork branch is obsoslete and shouldn't be used any more. In context of this change the usage of old mozilla based mork driver depends on platform: all non windows platforms use this new mork driver, windows still uses mozilla. Because mozilla driver shipping was stripped on feature/mork branch for all platforms, the corresponding commits were changed prior to creating this change (the build file changes are reverted now). So the build and shipping of different mork driver implementation should be implemented from scratch: mozilla on windows, new mork dirver on all other platforms. Currently the new mork dirver is compiled (on all platforms), but not used. It can be tested with mork_helper executable. fdo#51004 Change-Id: Ib2413ab6856f163337aa311c4bf7b1182d6c6f63 Reviewed-on: https://gerrit.libreoffice.org/635 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/Configuration_mork.mk20
-rw-r--r--connectivity/Executable_mork_helper.mk30
-rw-r--r--connectivity/Library_mork.mk58
-rw-r--r--connectivity/Module_connectivity.mk2
-rw-r--r--connectivity/registry/mork/org/openoffice/Office/DataAccess/Drivers.xcu66
-rw-r--r--connectivity/source/drivers/mork/MCatalog.cxx111
-rw-r--r--connectivity/source/drivers/mork/MCatalog.hxx55
-rw-r--r--connectivity/source/drivers/mork/MColumnAlias.cxx184
-rw-r--r--connectivity/source/drivers/mork/MColumnAlias.hxx79
-rw-r--r--connectivity/source/drivers/mork/MColumns.cxx87
-rw-r--r--connectivity/source/drivers/mork/MColumns.hxx51
-rw-r--r--connectivity/source/drivers/mork/MConfigAccess.cxx259
-rw-r--r--connectivity/source/drivers/mork/MConfigAccess.hxx32
-rw-r--r--connectivity/source/drivers/mork/MConnection.cxx397
-rw-r--r--connectivity/source/drivers/mork/MConnection.hxx120
-rw-r--r--connectivity/source/drivers/mork/MDatabaseMetaData.cxx1034
-rw-r--r--connectivity/source/drivers/mork/MDatabaseMetaData.hxx202
-rw-r--r--connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx119
-rw-r--r--connectivity/source/drivers/mork/MDatabaseMetaDataHelper.hxx46
-rw-r--r--connectivity/source/drivers/mork/MDriver.cxx124
-rw-r--r--connectivity/source/drivers/mork/MDriver.hxx106
-rw-r--r--connectivity/source/drivers/mork/MErrorResource.hxx71
-rw-r--r--connectivity/source/drivers/mork/MExtConfigAccess.hxx39
-rw-r--r--connectivity/source/drivers/mork/MNSFolders.cxx156
-rw-r--r--connectivity/source/drivers/mork/MNSFolders.hxx34
-rw-r--r--connectivity/source/drivers/mork/MNSINIParser.cxx96
-rw-r--r--connectivity/source/drivers/mork/MNSINIParser.hxx74
-rw-r--r--connectivity/source/drivers/mork/MNSProfileDiscover.cxx224
-rw-r--r--connectivity/source/drivers/mork/MNSProfileDiscover.hxx98
-rw-r--r--connectivity/source/drivers/mork/MPreparedStatement.cxx529
-rw-r--r--connectivity/source/drivers/mork/MPreparedStatement.hxx156
-rw-r--r--connectivity/source/drivers/mork/MQueryHelper.cxx414
-rw-r--r--connectivity/source/drivers/mork/MQueryHelper.hxx215
-rw-r--r--connectivity/source/drivers/mork/MResultSet.cxx2301
-rw-r--r--connectivity/source/drivers/mork/MResultSet.hxx359
-rw-r--r--connectivity/source/drivers/mork/MResultSetMetaData.cxx205
-rw-r--r--connectivity/source/drivers/mork/MResultSetMetaData.hxx92
-rw-r--r--connectivity/source/drivers/mork/MServices.cxx37
-rw-r--r--connectivity/source/drivers/mork/MStatement.cxx589
-rw-r--r--connectivity/source/drivers/mork/MStatement.hxx202
-rw-r--r--connectivity/source/drivers/mork/MTable.cxx80
-rw-r--r--connectivity/source/drivers/mork/MTable.hxx62
-rw-r--r--connectivity/source/drivers/mork/MTables.cxx86
-rw-r--r--connectivity/source/drivers/mork/MTables.hxx48
-rw-r--r--connectivity/source/drivers/mork/MorkParser.cxx694
-rw-r--r--connectivity/source/drivers/mork/MorkParser.hxx168
-rw-r--r--connectivity/source/drivers/mork/README41
-rw-r--r--connectivity/source/drivers/mork/dllapi.h25
-rw-r--r--connectivity/source/drivers/mork/license.txt31
-rw-r--r--connectivity/source/drivers/mork/mork.component16
-rw-r--r--connectivity/source/drivers/mork/mork.xml85
-rw-r--r--connectivity/source/drivers/mork/mork_helper.cxx86
-rw-r--r--connectivity/source/drivers/mork/post_include_windows.h24
-rw-r--r--connectivity/source/drivers/mork/pre_include_windows.h25
-rw-r--r--connectivity/source/drivers/mork/services.cxx40
-rw-r--r--connectivity/source/inc/resource/conn_shared_res.hrc2
-rw-r--r--connectivity/source/inc/resource/mork_res.hrc63
57 files changed, 10649 insertions, 0 deletions
diff --git a/connectivity/Configuration_mork.mk b/connectivity/Configuration_mork.mk
new file mode 100644
index 000000000000..dc36ca83eaa8
--- /dev/null
+++ b/connectivity/Configuration_mork.mk
@@ -0,0 +1,20 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Configuration_Configuration,driver_mork))
+
+$(eval $(call gb_Configuration_add_spool_modules,driver_mork,connectivity/registry/mork,\
+ org/openoffice/Office/DataAccess/Drivers-mork.xcu \
+))
+
+$(eval $(call gb_Configuration_add_localized_datas,driver_mork,connectivity/registry/mork,\
+ org/openoffice/Office/DataAccess/Drivers.xcu \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/connectivity/Executable_mork_helper.mk b/connectivity/Executable_mork_helper.mk
new file mode 100644
index 000000000000..27b8685144f7
--- /dev/null
+++ b/connectivity/Executable_mork_helper.mk
@@ -0,0 +1,30 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Executable_Executable,mork_helper))
+
+$(eval $(call gb_Executable_set_include,mork_helper,\
+ -I$(SRCDIR)/connectivity/source/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Executable_use_sdk_api,mork_helper))
+
+$(eval $(call gb_Executable_use_libraries,mork_helper,\
+ cppu \
+ cppuhelper \
+ mork \
+ sal \
+))
+
+$(eval $(call gb_Executable_add_exception_objects,mork_helper,\
+ connectivity/source/drivers/mork/mork_helper \
+))
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/connectivity/Library_mork.mk b/connectivity/Library_mork.mk
new file mode 100644
index 000000000000..17de768653b8
--- /dev/null
+++ b/connectivity/Library_mork.mk
@@ -0,0 +1,58 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Library_Library,mork))
+
+$(eval $(call gb_Library_set_componentfile,mork,connectivity/source/drivers/mork/mork))
+
+$(eval $(call gb_Library_add_defs,mork,\
+ -DLO_DLLIMPLEMENTATION_MORK \
+))
+
+$(eval $(call gb_Library_set_include,mork,\
+ -I$(SRCDIR)/connectivity/source/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_use_libraries,mork, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ dbtools \
+ sal \
+ salhelper \
+ $(gb_STDLIBS) \
+))
+
+$(eval $(call gb_Library_use_sdk_api,mork))
+
+$(eval $(call gb_Library_add_exception_objects,mork, \
+ connectivity/source/drivers/mork/MColumns \
+ connectivity/source/drivers/mork/MConfigAccess \
+ connectivity/source/drivers/mork/MColumnAlias \
+ connectivity/source/drivers/mork/MNSFolders \
+ connectivity/source/drivers/mork/MNSINIParser \
+ connectivity/source/drivers/mork/MNSProfileDiscover \
+ connectivity/source/drivers/mork/MorkParser \
+ connectivity/source/drivers/mork/MCatalog \
+ connectivity/source/drivers/mork/MConnection \
+ connectivity/source/drivers/mork/MDatabaseMetaData \
+ connectivity/source/drivers/mork/MDatabaseMetaDataHelper \
+ connectivity/source/drivers/mork/MDriver \
+ connectivity/source/drivers/mork/MStatement \
+ connectivity/source/drivers/mork/MResultSet \
+ connectivity/source/drivers/mork/MResultSetMetaData \
+ connectivity/source/drivers/mork/MPreparedStatement \
+ connectivity/source/drivers/mork/MQueryHelper \
+ connectivity/source/drivers/mork/MServices \
+ connectivity/source/drivers/mork/MTable \
+ connectivity/source/drivers/mork/MTables \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/connectivity/Module_connectivity.mk b/connectivity/Module_connectivity.mk
index 2c6649ac8782..a05df43e9174 100644
--- a/connectivity/Module_connectivity.mk
+++ b/connectivity/Module_connectivity.mk
@@ -38,12 +38,14 @@ $(eval $(call gb_Module_add_targets,connectivity,\
Configuration_flat \
Configuration_mysql \
Configuration_odbc \
+ Executable_mork_helper \
Library_calc \
Library_dbase \
Library_dbpool2 \
Library_dbtools \
Library_file \
Library_flat \
+ Library_mork \
Library_mysql \
Library_odbc \
Library_odbcbase \
diff --git a/connectivity/registry/mork/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/mork/org/openoffice/Office/DataAccess/Drivers.xcu
new file mode 100644
index 000000000000..408b005cf1af
--- /dev/null
+++ b/connectivity/registry/mork/org/openoffice/Office/DataAccess/Drivers.xcu
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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 .
+ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed" install:module="mork">
+ <node oor:name="sdbc:address:mozilla:" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.MozabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">SeaMonkey Address Book</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:address:thunderbird:" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.MorkDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Thunderbird/Icedove Address Book</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/mork/MCatalog.cxx b/connectivity/source/drivers/mork/MCatalog.cxx
new file mode 100644
index 000000000000..005037c13adc
--- /dev/null
+++ b/connectivity/source/drivers/mork/MCatalog.cxx
@@ -0,0 +1,111 @@
+/* -*- 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 "MCatalog.hxx"
+#include "MConnection.hxx"
+#include "MTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <cppuhelper/interfacecontainer.h>
+
+// -------------------------------------------------------------------------
+using namespace connectivity::mork;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::cppu;
+
+// -------------------------------------------------------------------------
+OCatalog::OCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
+ ,m_pConnection(_pCon)
+ ,m_xMetaData(m_pConnection->getMetaData( ))
+{
+// osl_incrementInterlockedCount( &m_refCount );
+// refreshTables();
+// refreshViews();
+// refreshGroups();
+// refreshUsers();
+// osl_decrementInterlockedCount( &m_refCount );
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshTables()
+{
+ TStringVector aVector;
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),aTypes);
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ ::rtl::OUString aName;
+ while(xResult->next())
+ {
+ aName = xRow->getString(3);
+ aVector.push_back(aName);
+ }
+ }
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshViews()
+{
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshGroups()
+{
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshUsers()
+{
+}
+// -----------------------------------------------------------------------------
+
+// XTablesSupplier
+Reference< XNameAccess > SAL_CALL OCatalog::getTables( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(rBHelper.bDisposed);
+
+ try
+ {
+ if(!m_pTables || m_pConnection->getForceLoadTables())
+ refreshTables();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return const_cast<OCatalog*>(this)->m_pTables;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MCatalog.hxx b/connectivity/source/drivers/mork/MCatalog.hxx
new file mode 100644
index 000000000000..672346717e42
--- /dev/null
+++ b/connectivity/source/drivers/mork/MCatalog.hxx
@@ -0,0 +1,55 @@
+/* -*- 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 _CONNECTIVITY_MORK_CATALOG_HXX_
+#define _CONNECTIVITY_MORK_CATALOG_HXX_
+
+#include "connectivity/sdbcx/VCatalog.hxx"
+
+namespace connectivity
+{
+ namespace mork
+ {
+ // please don't name the class the same name as in an other namespaces
+ // some compilers have problems with this task as I noticed on windows
+ class OConnection;
+ class OCatalog : public connectivity::sdbcx::OCatalog
+ {
+ OConnection* m_pConnection; // used to get the metadata
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; // just to make things easier
+
+ public:
+ // implementation of the pure virtual methods
+ virtual void refreshTables();
+ virtual void refreshViews() ;
+ virtual void refreshGroups();
+ virtual void refreshUsers() ;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OCatalog(OConnection* _pCon);
+
+ OConnection* getConnection() const { return m_pConnection; }
+ sdbcx::OCollection* getPrivateTables() const { return m_pTables;}
+ sdbcx::OCollection* getPrivateViews() const { return m_pViews; }
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_MORK_CATALOG_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MColumnAlias.cxx b/connectivity/source/drivers/mork/MColumnAlias.cxx
new file mode 100644
index 000000000000..d2c3ad1f3011
--- /dev/null
+++ b/connectivity/source/drivers/mork/MColumnAlias.cxx
@@ -0,0 +1,184 @@
+/* -*- 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 <sal/macros.h>
+#include "MColumnAlias.hxx"
+#include "MConnection.hxx"
+#include "MExtConfigAccess.hxx"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+#include <functional>
+
+using namespace ::connectivity;
+using namespace ::connectivity::mork;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+
+//------------------------------------------------------------------------------
+OColumnAlias::OColumnAlias( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB )
+{
+ static const sal_Char* s_pProgrammaticNames[] =
+ {
+ "FirstName",
+ "LastName",
+ "DisplayName",
+ "NickName",
+ "PrimaryEmail",
+ "SecondEmail",
+ "PreferMailFormat",
+ "WorkPhone",
+ "HomePhone",
+ "FaxNumber",
+ "PagerNumber",
+ "CellularNumber",
+ "HomeAddress",
+ "HomeAddress2",
+ "HomeCity",
+ "HomeState",
+ "HomeZipCode",
+ "HomeCountry",
+ "WorkAddress",
+ "WorkAddress2",
+ "WorkCity",
+ "WorkState",
+ "WorkZipCode",
+ "WorkCountry",
+ "JobTitle",
+ "Department",
+ "Company",
+ "WebPage1",
+ "WebPage2",
+ "BirthYear",
+ "BirthMonth",
+ "BirthDay",
+ "Custom1",
+ "Custom2",
+ "Custom3",
+ "Custom4",
+ "Notes",
+ };
+
+ for ( size_t i = 0; i < sizeof( s_pProgrammaticNames ) / sizeof( s_pProgrammaticNames[0] ); ++i )
+ m_aAliasMap[ ::rtl::OUString::createFromAscii( s_pProgrammaticNames[i] ) ] = AliasEntry( s_pProgrammaticNames[i], i );
+
+ initialize( _rxORB );
+}
+
+//------------------------------------------------------------------------------
+void OColumnAlias::initialize( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB )
+{
+ // open our driver settings config node
+
+ // the config path for our own driver's settings
+ Reference< XPropertySet > xDriverNode = createDriverConfigNode( _rxORB );
+ if ( xDriverNode.is() )
+ {
+ try
+ {
+ //.............................................................
+ Reference< XNameAccess > xAliasesNode;
+ xDriverNode->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ColumnAliases")) ) >>= xAliasesNode;
+ OSL_ENSURE( xAliasesNode.is(), "OColumnAlias::setAlias: missing the aliases node!" );
+
+ // this is a set of string nodes
+ Sequence< ::rtl::OUString > aProgrammaticNames;
+ if ( xAliasesNode.is() )
+ aProgrammaticNames = xAliasesNode->getElementNames();
+
+ //.............................................................
+ // travel through all the set elements
+ const ::rtl::OUString* pProgrammaticNames = aProgrammaticNames.getConstArray();
+ const ::rtl::OUString* pProgrammaticNamesEnd = pProgrammaticNames + aProgrammaticNames.getLength();
+ ::rtl::OUString sAssignedAlias;
+
+ for ( ; pProgrammaticNames < pProgrammaticNamesEnd; ++pProgrammaticNames )
+ {
+ OSL_VERIFY( xAliasesNode->getByName( *pProgrammaticNames ) >>= sAssignedAlias );
+
+ // normalize in case the config data is corrupted
+ // (what we really don't need is an empty alias ...)
+ if ( sAssignedAlias.isEmpty() )
+ sAssignedAlias = *pProgrammaticNames;
+
+ ::rtl::OString sAsciiProgrammaticName( ::rtl::OUStringToOString( *pProgrammaticNames, RTL_TEXTENCODING_ASCII_US ) );
+ //.............................................................
+ #if OSL_DEBUG_LEVEL > 0
+ bool bFound = false;
+ #endif
+ for ( AliasMap::iterator search = m_aAliasMap.begin();
+ ( search != m_aAliasMap.end() );
+ ++search
+ )
+ {
+ if ( search->second.programmaticAsciiName.equals( sAsciiProgrammaticName ) )
+ {
+ AliasEntry entry( search->second );
+ m_aAliasMap.erase( search );
+ m_aAliasMap[ sAssignedAlias ] = entry;
+
+ #if OSL_DEBUG_LEVEL > 0
+ bFound = true;
+ #endif
+
+ break;
+ }
+ }
+
+ OSL_ENSURE( bFound, "OColumnAlias::setAlias: did not find a programmatic name which exists in the configuration!" );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+
+//------------------------------------------------------------------
+::rtl::OString OColumnAlias::getProgrammaticNameOrFallbackToUTF8Alias( const ::rtl::OUString& _rAlias ) const
+{
+ AliasMap::const_iterator pos = m_aAliasMap.find( _rAlias );
+ if ( pos == m_aAliasMap.end() )
+ {
+ OSL_FAIL( "OColumnAlias::getProgrammaticNameOrFallbackToUTF8Alias: no programmatic name for this alias!" );
+ return ::rtl::OUStringToOString( _rAlias, RTL_TEXTENCODING_UTF8 );
+ }
+ return pos->second.programmaticAsciiName;
+}
+
+//------------------------------------------------------------------
+bool OColumnAlias::isColumnSearchable( const ::rtl::OUString _alias ) const
+{
+ ::rtl::OString sProgrammatic = getProgrammaticNameOrFallbackToUTF8Alias( _alias );
+
+ return ( !sProgrammatic.equals( "HomeCountry" )
+ && !sProgrammatic.equals( "WorkCountry" )
+ );
+ // for those, we know that they're not searchable in the Mozilla/LDAP implementation.
+ // There might be more ...
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MColumnAlias.hxx b/connectivity/source/drivers/mork/MColumnAlias.hxx
new file mode 100644
index 000000000000..3b713ae89d56
--- /dev/null
+++ b/connectivity/source/drivers/mork/MColumnAlias.hxx
@@ -0,0 +1,79 @@
+/* -*- 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 _CONNECTIVITY_MORK_COLUMNALIAS_HXX_
+#define _CONNECTIVITY_MORK_COLUMNALIAS_HXX_
+
+#include <unotools/confignode.hxx>
+
+#include <osl/mutex.hxx>
+#include <vector>
+#include <boost/unordered_map.hpp>
+
+namespace connectivity
+{
+ namespace mork
+ {
+ class OColumnAlias
+ {
+ public:
+ struct AliasEntry
+ {
+ ::rtl::OString programmaticAsciiName;
+ size_t columnPosition;
+
+ AliasEntry()
+ :programmaticAsciiName()
+ ,columnPosition( 0 )
+ {
+ }
+ AliasEntry( const sal_Char* _programmaticAsciiName, size_t _columnPosition )
+ :programmaticAsciiName( _programmaticAsciiName )
+ ,columnPosition( _columnPosition )
+ {
+ }
+ };
+ typedef ::boost::unordered_map< ::rtl::OUString, AliasEntry, ::rtl::OUStringHash > AliasMap;
+
+ private:
+ AliasMap m_aAliasMap;
+
+ public:
+ OColumnAlias( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & );
+
+ inline bool hasAlias( const ::rtl::OUString& _rAlias ) const
+ {
+ return m_aAliasMap.find( _rAlias ) != m_aAliasMap.end();
+ }
+ ::rtl::OString getProgrammaticNameOrFallbackToUTF8Alias( const ::rtl::OUString& _rAlias ) const;
+
+ inline AliasMap::const_iterator begin() const { return m_aAliasMap.begin(); }
+ inline AliasMap::const_iterator end() const { return m_aAliasMap.end(); }
+
+ bool isColumnSearchable( const ::rtl::OUString _alias ) const;
+
+ private:
+ void initialize( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB );
+ };
+ }
+}
+#endif // _CONNECTIVITY_MORK_COLUMNALIAS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MColumns.cxx b/connectivity/source/drivers/mork/MColumns.cxx
new file mode 100644
index 000000000000..852bb4d4c012
--- /dev/null
+++ b/connectivity/source/drivers/mork/MColumns.cxx
@@ -0,0 +1,87 @@
+/* -*- 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 "MColumns.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "MTable.hxx"
+#include "MTables.hxx"
+#include "MCatalog.hxx"
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+
+using namespace ::comphelper;
+
+using namespace connectivity::mork;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
+{
+ Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(),
+ m_pTable->getSchema(),m_pTable->getTableName(),_rName);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ if(xRow->getString(4) == _rName)
+ {
+ sal_Int32 nType = xRow->getInt(5);
+ ::rtl::OUString sTypeName = xRow->getString(6);
+ sal_Int32 nPrec = xRow->getInt(7);
+
+ OColumn* pRet = new OColumn(_rName,
+ sTypeName,
+ xRow->getString(13),
+ xRow->getString(12),
+ xRow->getInt(11),
+ nPrec,
+ xRow->getInt(9),
+ nType,
+ sal_False,sal_False,sal_False,sal_True);
+ xRet = pRet;
+ break;
+ }
+ }
+ }
+
+ return xRet;
+}
+
+// -------------------------------------------------------------------------
+void OColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshColumns();
+}
+// -----------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MColumns.hxx b/connectivity/source/drivers/mork/MColumns.hxx
new file mode 100644
index 000000000000..63d982fcedb7
--- /dev/null
+++ b/connectivity/source/drivers/mork/MColumns.hxx
@@ -0,0 +1,51 @@
+/* -*- 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 _CONNECTIVITY_MORK_COLUMNS_HXX_
+#define _CONNECTIVITY_MORK_COLUMNS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "MTable.hxx"
+
+namespace connectivity
+{
+ namespace mork
+ {
+ class OColumns : public sdbcx::OCollection
+ {
+ protected:
+ OTable* m_pTable;
+
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OColumns( OTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector
+ ) : sdbcx::OCollection(*_pTable,sal_True,_rMutex,_rVector)
+ ,m_pTable(_pTable)
+ {}
+ };
+ }
+}
+#endif // _CONNECTIVITY_MORK_COLUMNS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MConfigAccess.cxx b/connectivity/source/drivers/mork/MConfigAccess.cxx
new file mode 100644
index 000000000000..0734f12f11c3
--- /dev/null
+++ b/connectivity/source/drivers/mork/MConfigAccess.cxx
@@ -0,0 +1,259 @@
+/* -*- 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 "com/sun/star/configuration/theDefaultProvider.hpp"
+#include "comphelper/processfactory.hxx"
+
+#include "MConfigAccess.hxx"
+#include "MExtConfigAccess.hxx"
+#include "MConnection.hxx"
+#include "MDriver.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+
+//.........................................................................
+namespace connectivity
+{
+ namespace mork
+ {
+ //-----------------------------------------------------------------
+ Reference< XPropertySet > createDriverConfigNode( Reference< XMultiServiceFactory > _rxORB )
+ {
+ Reference< XPropertySet > xNode;
+ try
+ {
+ //=============================================================
+ // create the config provider
+ Reference< XMultiServiceFactory > xConfigProvider(
+ com::sun::star::configuration::theDefaultProvider::get(
+ comphelper::getComponentContext( _rxORB ) ) );
+
+ ::rtl::OUString sCompleteNodePath(RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.DataAccess/DriverSettings/" ));
+ sCompleteNodePath += MorkDriver::getImplementationName_Static( );
+
+ //=========================================================
+ // arguments for creating the config access
+ Sequence< Any > aArguments(2);
+ // the path to the node to open
+ aArguments[0] <<= PropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("nodepath")),
+ 0,
+ makeAny( sCompleteNodePath ),
+ PropertyState_DIRECT_VALUE
+ );
+ // the depth: -1 means unlimited
+ aArguments[1] <<= PropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("depth")),
+ 0,
+ makeAny( (sal_Int32)-1 ),
+ PropertyState_DIRECT_VALUE
+ );
+
+ //=========================================================
+ // create the access
+ Reference< XInterface > xAccess = xConfigProvider->createInstanceWithArguments(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess" )),
+ aArguments
+ );
+ OSL_ENSURE( xAccess.is(), "createDriverConfigNode: invalid access returned (should throw an exception instead)!" );
+
+ xNode = xNode.query( xAccess );
+ }
+ catch( const Exception& )
+ {
+ OSL_FAIL( "createDriverConfigNode: caught an exception while accessing the driver's config node!" );
+ }
+
+ // outta here
+ return xNode;
+ }
+
+ //-----------------------------------------------------------------
+ namespace
+ {
+ // a private helper to accessing the point where we store the reference
+ // to the factory
+ Reference< XMultiServiceFactory >& accessFactoryStorage( )
+ {
+ static Reference< XMultiServiceFactory > xMozabServiceFactory;
+ return xMozabServiceFactory;
+ }
+ }
+
+ //-----------------------------------------------------------------
+ void setMozabServiceFactory( const Reference< XMultiServiceFactory >& _rxFactory )
+ {
+ accessFactoryStorage( ) = _rxFactory;
+ }
+
+ //-----------------------------------------------------------------
+ const Reference< XMultiServiceFactory >& getMozabServiceFactory( )
+ {
+ return accessFactoryStorage( );
+ }
+
+ //-----------------------------------------------------------------
+ ::rtl::OUString getDescription(const sal_Char* sNode,const ::rtl::OUString & sDefault)
+ {
+ ::rtl::OUString sPreferredName;
+ ::rtl::OUString sDescription;
+
+ Reference< XMultiServiceFactory > xFactory = getMozabServiceFactory();
+ OSL_ENSURE( xFactory.is(), "getPreferredProfileName: invalid service factory!" );
+ if ( xFactory.is() )
+ {
+ try
+ {
+ Reference< XPropertySet > xDriverNode = createDriverConfigNode( xFactory );
+ Reference< XPropertySet > xMozPrefsNode;
+ if ( xDriverNode.is() )
+ xDriverNode->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("MozillaPreferences" )) ) >>= xMozPrefsNode;
+ OSL_ENSURE( xMozPrefsNode.is(), "getPreferredProfileName: could not access the node for the mozilla preferences!" );
+ if ( xMozPrefsNode.is() )
+ xMozPrefsNode->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ProfileName" )) ) >>= sPreferredName;
+ if ( xMozPrefsNode.is() )
+ xMozPrefsNode->getPropertyValue( ::rtl::OUString::createFromAscii(sNode) ) >>= sDescription;
+ if (sDescription.getLength() == 0)
+ sDescription = sDefault;
+ }
+ catch( const Exception& )
+ {
+ OSL_FAIL( "getDescription: caught an exception!" );
+ }
+ }
+ if (sDescription.getLength() == 0)
+ sDescription = sDefault;
+ return sDescription;
+ }
+ //-----------------------------------------------------------------
+ ::rtl::OUString getPreferredProfileName( )
+ {
+ ::rtl::OUString sPreferredName;
+
+ Reference< XMultiServiceFactory > xFactory = getMozabServiceFactory();
+ OSL_ENSURE( xFactory.is(), "getPreferredProfileName: invalid service factory!" );
+ if ( xFactory.is() )
+ {
+ try
+ {
+ Reference< XPropertySet > xDriverNode = createDriverConfigNode( xFactory );
+ Reference< XPropertySet > xMozPrefsNode;
+ if ( xDriverNode.is() )
+ xDriverNode->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("MozillaPreferences" )) ) >>= xMozPrefsNode;
+ OSL_ENSURE( xMozPrefsNode.is(), "getPreferredProfileName: could not access the node for the mozilla preferences!" );
+ if ( xMozPrefsNode.is() )
+ xMozPrefsNode->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ProfileName" )) ) >>= sPreferredName;
+ }
+ catch( const Exception& )
+ {
+ OSL_FAIL( "getPreferredProfileName: caught an exception!" );
+ }
+ }
+ return sPreferredName;
+ }
+ }
+}
+
+//.........................................................................
+
+//-------------------------------------------------------------------------
+extern "C" const sal_Unicode* SAL_CALL getUserProfile( void )
+{
+ static sal_Bool bReadConfig = sal_False;
+ static ::rtl::OUString sUserProfile;
+ if ( !bReadConfig )
+ {
+ sUserProfile = ::connectivity::mork::getPreferredProfileName( );
+ bReadConfig = sal_True;
+ }
+
+ return sUserProfile.getStr();
+}
+//------------------------------------------------------------------------
+extern "C" const sal_Char* SAL_CALL getPabDescription( void )
+{
+ static sal_Bool bReadConfig = sal_False;
+ static ::rtl::OUString usPabDescription;
+ static ::rtl::OString sPabDescription;
+
+ if ( !bReadConfig )
+ {
+ usPabDescription = ::connectivity::mork::getDescription(
+ "PabDescription" ,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Personal Address Book" )));
+ sPabDescription = ::rtl::OUStringToOString( usPabDescription,
+ RTL_TEXTENCODING_UTF8);
+ bReadConfig = sal_True;
+ }
+
+ return sPabDescription.getStr();
+}
+
+//-------------------------------------------------------------------------
+extern "C" const sal_Char* SAL_CALL getHisDescription( void )
+{
+ static sal_Bool bReadConfig = sal_False;
+ static ::rtl::OUString usHisDescription;
+ static ::rtl::OString sHisDescription;
+
+ if ( !bReadConfig )
+ {
+ usHisDescription = ::connectivity::mork::getDescription(
+ "HisDescription" ,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Collected Addresses" )));
+ sHisDescription = ::rtl::OUStringToOString( usHisDescription,
+ RTL_TEXTENCODING_UTF8);
+ bReadConfig = sal_True;
+ }
+
+ return sHisDescription.getStr();
+}
+
+//-------------------------------------------------------------------------
+// MConfigAccess was invented to allow non-UNO parts access to the configuration.
+// Unfortunately, configuration access requires a XMultiServiceFactory - which the
+// mozilla side does not have.
+// So we create a "library-local" service factory here: Every need for a service
+// factory can be fullfilled by this factory (similar to the get/setProcessServiceFactory
+// in comphelper).
+// This is halfway valid, as usually, the mozabdrv library is invoked from the mozab library
+// only. The latter contains the driver class (and only this class and nothing more), and
+// the driver class is a singleton. The driver itself is created with a service factory,
+// which (by definition) can and should be used for all subsequent service requests.
+// And this is exactly what we're allowing with the following functions ....
+
+/** _pFactory must point to an XMultiServiceFactory, which must be aquired once
+ for purpose of safely transfering it. The callee will release this interface
+ when it has stored the pointer somewhere else.
+*/
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL setMozabServiceFactory(
+ void* _pFactory )
+{
+ Reference< XMultiServiceFactory > xFactory = static_cast< XMultiServiceFactory* >( _pFactory );
+ // ::connectivity::mozab::setMozabServiceFactory( xFactory );
+
+ // by definition, the object behind the interface pointer has been acquired once for purpose
+ // of safely transporting it
+ xFactory->release();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MConfigAccess.hxx b/connectivity/source/drivers/mork/MConfigAccess.hxx
new file mode 100644
index 000000000000..e00986b92baa
--- /dev/null
+++ b/connectivity/source/drivers/mork/MConfigAccess.hxx
@@ -0,0 +1,32 @@
+/* -*- 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 CONNECTIVITY_MORK_MCONFIGACCESS_HXX
+
+#include <sal/types.h>
+
+extern "C" const sal_Unicode* SAL_CALL getUserProfile( void );
+
+extern "C" const sal_Char* SAL_CALL getPabDescription( void );
+
+extern "C" const sal_Char* SAL_CALL getHisDescription( void );
+
+#endif // CONNECTIVITY_MORK_MCONFIGACCESS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MConnection.cxx b/connectivity/source/drivers/mork/MConnection.cxx
new file mode 100644
index 000000000000..bb16d729f2fb
--- /dev/null
+++ b/connectivity/source/drivers/mork/MConnection.cxx
@@ -0,0 +1,397 @@
+/* -*- 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 "MNSProfileDiscover.hxx"
+#include "MConnection.hxx"
+#include "MDriver.hxx"
+#include "MDatabaseMetaData.hxx"
+#include "MCatalog.hxx"
+#include "MPreparedStatement.hxx"
+#include "MorkParser.hxx"
+
+#include <connectivity/dbcharset.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/sqlerror.hxx>
+
+#include "resource/mork_res.hrc"
+#include "resource/common_res.hrc"
+
+#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>
+
+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 {
+
+static const int defaultScope = 0x80;
+
+// -----------------------------------------------------------------------------
+
+OConnection::OConnection(MorkDriver* _pDriver)
+ :OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this)
+ ,m_pDriver(_pDriver)
+ ,m_aColumnAlias( _pDriver->getFactory() )
+{
+ m_pDriver->acquire();
+ m_pProfileAccess = new ProfileAccess();
+ m_pMork = new MorkParser();
+}
+//-----------------------------------------------------------------------------
+OConnection::~OConnection()
+{
+ acquire();
+ if(!isClosed())
+ close();
+ m_pDriver->release();
+ m_pDriver = NULL;
+ delete m_pProfileAccess;
+ delete m_pMork;
+}
+//-----------------------------------------------------------------------------
+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
+ SAL_INFO("connectivity.mork", "=> OConnection::construct()" );
+ // open file
+ setURL(url);
+ //
+ // Skip 'sdbc:mozab: part of URL
+ //
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ OSL_ENSURE( url.copy( 0, nLen ) == "sdbc:address", "OConnection::construct: invalid start of the URI - should never have survived XDriver::acceptsURL!" );
+
+ ::rtl::OUString aAddrbookURI(url.copy(nLen+1));
+ // Get Scheme
+ nLen = aAddrbookURI.indexOf(':');
+ ::rtl::OUString aAddrbookScheme;
+ ::rtl::OUString sAdditionalInfo;
+ if ( nLen == -1 )
+ {
+ // There isn't any subschema: - but could be just subschema
+ if ( !aAddrbookURI.isEmpty() )
+ {
+ aAddrbookScheme= aAddrbookURI;
+ }
+ else
+ {
+ SAL_WARN("connectivity.mork", "No subschema given!!!");
+ throwGenericSQLException( STR_URI_SYNTAX_ERROR, *this );
+ }
+ }
+ else
+ {
+ aAddrbookScheme = aAddrbookURI.copy(0, nLen);
+ sAdditionalInfo = aAddrbookURI.copy( nLen + 1 );
+ }
+
+ SAL_INFO("connectivity.mork", "URI = " << aAddrbookURI );
+ SAL_INFO("connectivity.mork", "Scheme = " << aAddrbookScheme );
+
+ ::rtl::OUString defaultProfile = m_pProfileAccess->getDefaultProfile(::com::sun::star::mozilla::MozillaProductType_Thunderbird);
+ SAL_INFO("connectivity.mork", "DefaultProfile: " << defaultProfile);
+
+ ::rtl::OUString path = m_pProfileAccess->getProfilePath(::com::sun::star::mozilla::MozillaProductType_Thunderbird, defaultProfile);
+ SAL_INFO("connectivity.mork", "ProfilePath: " << path);
+
+ path += rtl::OUString( "/abook.mab" );
+
+ SAL_INFO("connectivity.mork", "AdressbookPath: " << path);
+
+ rtl::OString strPath = ::rtl::OUStringToOString(path, RTL_TEXTENCODING_UTF8 );
+
+ // Open and parse mork file
+ if (!m_pMork->open(strPath.getStr()))
+ {
+ SAL_WARN("connectivity.mork", "Can not parse mork file!");
+ throwGenericSQLException( STR_COULD_NOT_LOAD_FILE, *this );
+ }
+
+ // check that we can retrieve the tables:
+ MorkTableMap *Tables = m_pMork->getTables( defaultScope );
+ MorkTableMap::iterator tableIter;
+ if (Tables)
+ {
+ // Iterate all tables
+ for ( tableIter = Tables->begin(); tableIter != Tables->end(); tableIter++ )
+ {
+ if ( 0 == tableIter->first ) continue;
+ SAL_INFO("connectivity.mork", "table->first : " << tableIter->first);
+ }
+ }
+}
+
+// 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)
+{
+ SAL_INFO("connectivity.mork", "=> OConnection::createStatement()" );
+
+ ::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 xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OConnection::prepareStatement()" );
+ SAL_INFO("connectivity.mork", "OConnection::prepareStatement( " << _sSql << " )");
+
+ OSL_UNUSED( _sSql );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // the pre
+ // create a statement
+ // the statement can only be executed more than once
+ OPreparedStatement* pPrepared = new OPreparedStatement(this,_sSql);
+ Reference< XPreparedStatement > xReturn = pPrepared;
+ pPrepared->lateInit();
+
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OConnection::prepareCall()" );
+ SAL_INFO("connectivity.mork", "sql: " << _sSql);
+ OSL_UNUSED( _sSql );
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
+ SAL_INFO("connectivity.mork", "OConnection::prepareCall( " << _sSql << " )");
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OConnection::nativeSQL()" );
+ SAL_INFO("connectivity.mork", "sql: " << _sSql);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ // when you need to transform SQL92 to you driver specific you can do it here
+ SAL_INFO("connectivity.mork", "OConnection::nativeSQL(" << _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)
+{
+ SAL_INFO("connectivity.mork", "=> OConnection::getMetaData()" );
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // here we have to create the class with biggest interface
+ // The answer is 42 :-)
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new ODatabaseMetaData(this); // need the connection because it can return it
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+// --------------------------------------------------------------------------------
+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();
+}
+// -----------------------------------------------------------------------------
+
+Reference< XTablesSupplier > SAL_CALL OConnection::createCatalog()
+{
+ OSL_TRACE("IN OConnection::createCatalog()" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!m_xCatalog.is())
+ {
+ OCatalog *pCat = new OCatalog(this);
+ xTab = pCat;
+ m_xCatalog = xTab;
+ }
+ OSL_TRACE( "\tOUT OConnection::createCatalog()" );
+ return xTab;
+}
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+void OConnection::throwSQLException( const ErrorDescriptor& _rError, const Reference< XInterface >& _rxContext )
+{
+ if ( _rError.getResId() != 0 )
+ {
+ OSL_ENSURE( ( _rError.getErrorCondition() == 0 ),
+ "OConnection::throwSQLException: unsupported error code combination!" );
+
+ ::rtl::OUString sParameter( _rError.getParameter() );
+ if ( !sParameter.isEmpty() )
+ {
+ const ::rtl::OUString sError( getResources().getResourceStringWithSubstitution(
+ _rError.getResId(),
+ "$1$", sParameter
+ ) );
+ ::dbtools::throwGenericSQLException( sError, _rxContext );
+ OSL_FAIL( "OConnection::throwSQLException: unreachable (1)!" );
+ }
+
+ throwGenericSQLException( _rError.getResId(), _rxContext );
+ OSL_FAIL( "OConnection::throwSQLException: unreachable (2)!" );
+ }
+
+ if ( _rError.getErrorCondition() != 0 )
+ {
+ SQLError aErrorHelper( getDriver()->getFactory() );
+ ::rtl::OUString sParameter( _rError.getParameter() );
+ if ( !sParameter.isEmpty() )
+ aErrorHelper.raiseException( _rError.getErrorCondition(), _rxContext, sParameter );
+ else
+ aErrorHelper.raiseException( _rError.getErrorCondition(), _rxContext);
+ OSL_FAIL( "OConnection::throwSQLException: unreachable (3)!" );
+ }
+
+ throwGenericSQLException( STR_UNSPECIFIED_ERROR, _rxContext );
+}
+
+// -----------------------------------------------------------------------------
+void OConnection::throwSQLException( const sal_uInt16 _nErrorResourceId, const Reference< XInterface >& _rxContext )
+{
+ ErrorDescriptor aError;
+ aError.setResId( _nErrorResourceId );
+ throwSQLException( aError, _rxContext );
+}
+
+} } // 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 000000000000..5dd1a7847121
--- /dev/null
+++ b/connectivity/source/drivers/mork/MConnection.hxx
@@ -0,0 +1,120 @@
+/* -*- 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 "MColumnAlias.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>
+
+// do we want here namespace too?
+class MorkParser;
+
+namespace connectivity
+{
+ namespace mork
+ {
+ namespace css = com::sun::star;
+
+ class MorkDriver;
+ class ProfileAccess;
+ 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
+ OColumnAlias m_aColumnAlias;
+ // Profile Access
+ ProfileAccess* m_pProfileAccess;
+ // Mork Parser
+ MorkParser* m_pMork;
+ // 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();
+
+ MorkDriver* getDriver() {return m_pDriver;};
+ MorkParser* getMorkParser() {return m_pMork;};
+ 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);
+
+ const OColumnAlias & getColumnAlias() const { return (m_aColumnAlias); }
+
+ static ::rtl::OUString getDriverImplementationName();
+
+ sal_Bool getForceLoadTables() {return true;}
+
+ // Added to enable me to use SQLInterpreter which requires an
+ // XNameAccess i/f to access tables.
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL createCatalog();
+
+ void throwSQLException( const ErrorDescriptor& _rError, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext );
+ void throwSQLException( const sal_uInt16 _nErrorResourceId, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext );
+ };
+ }
+}
+#endif // CONNECTIVITY_SCONNECTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MDatabaseMetaData.cxx b/connectivity/source/drivers/mork/MDatabaseMetaData.cxx
new file mode 100644
index 000000000000..fce033031631
--- /dev/null
+++ b/connectivity/source/drivers/mork/MDatabaseMetaData.cxx
@@ -0,0 +1,1034 @@
+/* -*- 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 "MDatabaseMetaData.hxx"
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+#include <connectivity/FValue.hxx>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#include "resource/common_res.hrc"
+#include <vector>
+
+#include "MDatabaseMetaDataHelper.hxx"
+#include "MorkParser.hxx"
+#include "connectivity/dbtools.hxx"
+
+#if 0
+#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 */
+#endif
+
+using namespace dbtools;
+using namespace connectivity::mork;
+using namespace connectivity;
+
+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
+ {
+ static sal_Int32 const s_nCOLUMN_SIZE = 256;
+ static sal_Int32 const s_nDECIMAL_DIGITS = 0;
+ static sal_Int32 const s_nNULLABLE = 1;
+ static sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535;
+ }
+}
+
+ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon)
+ : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
+ ,m_pConnection(_pCon)
+{
+ OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
+ m_pMetaDataHelper = new MDatabaseMetaDataHelper();
+}
+// -------------------------------------------------------------------------
+ODatabaseMetaData::~ODatabaseMetaData()
+{
+ delete m_pMetaDataHelper;
+}
+
+// -------------------------------------------------------------------------
+ODatabaseMetaDataResultSet::ORows& SAL_CALL ODatabaseMetaData::getColumnRows(
+ const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException)
+{
+ SAL_INFO("connectivity.mork", "=> ODatabaseMetaData::getColumnRows()" );
+ SAL_INFO("connectivity.mork", "tableNamePattern: " << tableNamePattern);
+ SAL_INFO("connectivity.mork", "columnNamePattern: " << columnNamePattern);
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ ODatabaseMetaDataResultSet::ORow aRow(19);
+ aRows.clear();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::std::vector< ::rtl::OUString > tables;
+ if (!m_pMetaDataHelper->getTableStrings(m_pConnection, tables))
+ {
+ ::connectivity::SharedResources aResources;
+ // TODO:
+ // get better message here?
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_UNKNOWN_COLUMN_TYPE);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ }
+
+ // ****************************************************
+ // Some entries in a row never change, so set them now
+ // ****************************************************
+
+ // Catalog
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")));
+ // Schema
+ aRow[2] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")));
+ // DATA_TYPE
+ aRow[5] = new ORowSetValueDecorator(static_cast<sal_Int16>(DataType::VARCHAR));
+ // TYPE_NAME, not used
+ aRow[6] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VARCHAR")));
+ // COLUMN_SIZE
+ aRow[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE);
+ // BUFFER_LENGTH, not used
+ aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // DECIMAL_DIGITS.
+ aRow[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS);
+ // NUM_PREC_RADIX
+ aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
+ // NULLABLE
+ aRow[11] = new ORowSetValueDecorator(s_nNULLABLE);
+ // REMARKS
+ aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // COULUMN_DEF, not used
+ aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // SQL_DATA_TYPE, not used
+ aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // SQL_DATETIME_SUB, not used
+ aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // CHAR_OCTET_LENGTH, refer to [5]
+ aRow[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH);
+ // IS_NULLABLE
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("YES")));
+
+ // Iterate over all tables
+ for(size_t j = 0; j < tables.size(); j++ ) {
+ if(match(tableNamePattern, tables[j],'\0')) {
+ // TABLE_NAME
+ aRow[3] = new ORowSetValueDecorator( tables[j] );
+
+ const OColumnAlias& colNames = m_pConnection->getColumnAlias();
+
+ SAL_INFO("connectivity.mork", "\tTableName = : " << tables[j]);
+ // Iterate over all collumns in the table.
+ for ( OColumnAlias::AliasMap::const_iterator compare = colNames.begin();
+ compare != colNames.end();
+ ++compare
+ )
+ {
+ if ( match( columnNamePattern, compare->first, '\0' ) )
+ {
+// OSL_TRACE( "\t\t\tColumnName = %s;", OUtoCStr( compare->first ) );
+ SAL_INFO("connectivity.mork", "\t\tColumnNam : " << compare->first);
+
+ // COLUMN_NAME
+ aRow[4] = new ORowSetValueDecorator( compare->first );
+ // ORDINAL_POSITION
+ aRow[17] = new ORowSetValueDecorator( static_cast< sal_Int32 >( compare->second.columnPosition ) + 1 );
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ }
+ return( aRows );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 65535; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 254; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 20; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
+{
+ // We only support a single table
+ return 1;
+}
+// -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ return aVal;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
+{
+ // normally this is "
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("\""));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ return aVal;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
+{
+ //We support create table
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_True; // should be supported at least
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
+{
+ // We allow you to select from any table.
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ //we support insert/update/delete now
+ //But we have to set this to return sal_True otherwise the UI will add create "table/edit table"
+ //entry to the popup menu. We should avoid them.
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
+{
+ // Support added for this.
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
+{
+ // Any case may be used
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return m_pConnection->getURL();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue = ::rtl::OUString::valueOf((sal_Int32)1);
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue = ::rtl::OUString::valueOf((sal_Int32)0);
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
+{
+ return 1;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ return TransactionIsolation::NONE;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+// here follow all methods which return a resultset
+// the first methods is an example implementation how to use this resultset
+// of course you could implement it on your and you should do this because
+// the general way is more memory expensive
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
+{
+ // there exists no possibility to get table types so we have to check
+ static ::rtl::OUString sTableTypes[] =
+ {
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TABLE")),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VIEW"))
+ // Currently we only support a 'TABLE' and 'VIEW' nothing more complex
+ //
+ // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYSTEM TABLE")),
+ // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("GLOBAL TEMPORARY")),
+ // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LOCAL TEMPORARY")),
+ // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ALIAS")),
+ // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYNONYM"))
+ };
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes);
+ Reference< XResultSet > xRef = pResult;
+
+ // here we fill the rows which should be visible when ask for data from the resultset returned here
+ const sal_Int32 nSize = sizeof(sTableTypes) / sizeof(::rtl::OUString);
+ ODatabaseMetaDataResultSet::ORows aRows;
+ for(sal_Int32 i=0;i < nSize;++i)
+ {
+ ODatabaseMetaDataResultSet::ORow aRow;
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator(sTableTypes[i]));
+ // bound row
+ aRows.push_back(aRow);
+ }
+ // here we set the rows at the resultset
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ // this returns an empty resultset where the column-names are already set
+ // in special the metadata of the resultset already returns the right columns
+ ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
+ Reference< XResultSet > xResultSet = pResultSet;
+ static ODatabaseMetaDataResultSet::ORows aRows;
+
+ if(aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow;
+ aRow.reserve(19);
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VARCHAR"))));
+ aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR));
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)s_nCHAR_OCTET_LENGTH));
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
+
+ aRows.push_back(aRow);
+
+ }
+ pResultSet->setRows(aRows);
+ return xResultSet;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ // this returns an empty resultset where the column-names are already set
+ // in special the metadata of the resultset already returns the right columns
+ ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns);
+ Reference< XResultSet > xResultSet = pResultSet;
+ pResultSet->setRows( getColumnRows( tableNamePattern, columnNamePattern ));
+ return xResultSet;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
+ const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& /*types*/ ) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> ODatabaseMetaData::getTables()" );
+ // this returns an empty resultset where the column-names are already set
+ // in special the metadata of the resultset already returns the right columns
+ ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables);
+ Reference< XResultSet > xResultSet = pResultSet;
+
+ // ODatabaseMetaDataResultSet::ORows aRows;
+ // aRows = m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern );
+ // pResultSet->setRows( aRows );
+ ODatabaseMetaDataResultSet::ORows _rRows;
+ if ( !m_pMetaDataHelper->getTables( m_pConnection, tableNamePattern, _rRows ) ) {
+ ::connectivity::SharedResources aResources;
+ // TODO:
+ // get better message here?
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_UNKNOWN_COLUMN_TYPE);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ }
+ pResultSet->setRows( _rRows );
+
+ return xResultSet;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> ODatabaseMetaData::getTablePrivileges()" );
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges);
+ Reference< XResultSet > xRef = NULL;
+
+ xRef = pResult;
+
+ ::std::vector< ::rtl::OUString > tables;
+ if ( !m_pMetaDataHelper->getTableStrings( m_pConnection, tables) )
+ {
+ ::connectivity::SharedResources aResources;
+ // TODO:
+ // get better message here?
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_UNKNOWN_COLUMN_TYPE);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ }
+
+ ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
+ ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(8);
+ aRows.reserve(8);
+ aRow[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
+ aRow[7] = new ::connectivity::ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NO")));
+
+
+ // Iterate over all tables
+ for(size_t j = 0; j < tables.size(); j++ ) {
+ if(match(tableNamePattern, tables[j],'\0'))
+ {
+ // TABLE_NAME
+ aRow[2] = new ORowSetValueDecorator( tables[j] );
+
+ SAL_INFO("connectivity.mork", "\tTableName = : " << tables[j]);
+
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
+ aRows.push_back(aRow);
+ }
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MDatabaseMetaData.hxx b/connectivity/source/drivers/mork/MDatabaseMetaData.hxx
new file mode 100644
index 000000000000..28c84de23b0e
--- /dev/null
+++ b/connectivity/source/drivers/mork/MDatabaseMetaData.hxx
@@ -0,0 +1,202 @@
+/* -*- 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_MORK_METADATA_HXX
+#define CONNECTIVITY_MORK_METADATA_HXX
+
+#include "connectivity/CommonTools.hxx"
+#include "connectivity/OSubComponent.hxx"
+
+#include "MConnection.hxx"
+#include "MDatabaseMetaDataHelper.hxx"
+#include "TDatabaseMetaDataBase.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
+ {
+ class MDatabaseMetaDataHelper;
+ //**************************************************************
+ //************ Class: ODatabaseMetaData
+ //**************************************************************
+
+ class ODatabaseMetaData : public ODatabaseMetaDataBase
+ {
+ OConnection* m_pConnection;
+ MDatabaseMetaDataHelper* m_pMetaDataHelper;
+
+ ODatabaseMetaDataResultSet::ORows& SAL_CALL getColumnRows( const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw( ::com::sun::star::sdbc::SQLException );
+
+ protected:
+ virtual ~ODatabaseMetaData();
+ public:
+
+ inline OConnection* getOwnConnection() const { return m_pConnection; }
+
+ ODatabaseMetaData(OConnection* _pCon);
+
+ private:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw();
+ // cached database information
+ virtual ::rtl::OUString impl_getIdentifierQuoteString_throw( );
+ virtual sal_Bool impl_isCatalogAtStart_throw( );
+ virtual ::rtl::OUString impl_getCatalogSeparator_throw( );
+ virtual sal_Bool impl_supportsCatalogsInTableDefinitions_throw( );
+ virtual sal_Bool impl_supportsSchemasInTableDefinitions_throw( ) ;
+ virtual sal_Bool impl_supportsCatalogsInDataManipulation_throw( );
+ virtual sal_Bool impl_supportsSchemasInDataManipulation_throw( ) ;
+ virtual sal_Bool impl_supportsMixedCaseQuotedIdentifiers_throw( ) ;
+ virtual sal_Bool impl_supportsAlterTableWithAddColumn_throw( );
+ virtual sal_Bool impl_supportsAlterTableWithDropColumn_throw( );
+ virtual sal_Int32 impl_getMaxStatements_throw( );
+ virtual sal_Int32 impl_getMaxTablesInSelect_throw( );
+ virtual sal_Bool impl_storesMixedCaseQuotedIdentifiers_throw( );
+
+ // as I mentioned before this interface is really BIG
+ // XDatabaseMetaData
+ virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getUserName( ) 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 sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // CONNECTIVITY_MORK_METADATA_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx b/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx
new file mode 100644
index 000000000000..7a28c4562d22
--- /dev/null
+++ b/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx
@@ -0,0 +1,119 @@
+/* -*- 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 "MDatabaseMetaDataHelper.hxx"
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <connectivity/dbexception.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/sequence.hxx>
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+
+// do we need it?
+static ::osl::Mutex m_aMetaMutex;
+
+#include <osl/diagnose.h>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#include <comphelper/processfactory.hxx>
+
+using namespace connectivity;
+using namespace connectivity::mork;
+
+// -------------------------------------------------------------------------
+MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()
+{
+ SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()" );
+}
+
+// -------------------------------------------------------------------------
+MDatabaseMetaDataHelper::~MDatabaseMetaDataHelper()
+{
+}
+
+sal_Bool MDatabaseMetaDataHelper::getTableStrings( OConnection* _pCon,
+ ::std::vector< ::rtl::OUString >& _rStrings)
+{
+ ::rtl::OUString sAbURI;
+ ::rtl::OString sAbURIString;
+
+ SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTableStrings()");
+ _pCon->getMorkParser();
+ // TODO: retrieve Tables from MorkParser
+ // only put for now the private adress book
+ rtl::OUString table = rtl::OUString::createFromAscii( "AddressBook");
+ _rStrings.push_back(table);
+ return( sal_True );
+}
+
+sal_Bool MDatabaseMetaDataHelper::getTables( OConnection* _pCon,
+ const ::rtl::OUString& tableNamePattern,
+ ODatabaseMetaDataResultSet::ORows& _rRows)
+{
+
+ SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTables()");
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+
+ SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTables()" );
+ ::osl::MutexGuard aGuard( m_aMetaMutex );
+
+ ODatabaseMetaDataResultSet::ORows().swap(aRows); // this makes real clear where memory is freed as well
+ aRows.clear();
+
+ ::std::vector< ::rtl::OUString > tables;
+// ::std::vector< ::rtl::OUString > tabletypes;
+ ::rtl::OUString matchAny = rtl::OUString::createFromAscii("%");
+
+ if ( !getTableStrings( _pCon, tables ) )
+ return sal_False;
+
+ for ( size_t i = 0; i < tables.size(); i++ ) {
+ ODatabaseMetaDataResultSet::ORow aRow(3);
+
+ ::rtl::OUString aTableName = tables[i];
+ //::rtl::OUString aTableType = tabletypes[i];
+ SAL_INFO("connectivity.mork", "TableName: " << aTableName );
+
+
+ // return tables to caller
+ if (match( tableNamePattern, aTableName, '\0' ))
+#if 0
+ &&
+ 0 != ::comphelper::findValue( types, aTableType, sal_True ).getLength() ||
+ 0 != ::comphelper::findValue( types, matchAny, sal_True ).getLength()))
+#endif
+ {
+ if ( aTableName.isEmpty() ) {
+ aTableName = rtl::OUString::createFromAscii("AddressBook");
+ }
+
+ SAL_INFO("connectivity.mork", "TableName: " << aTableName);
+
+ aRow.push_back( new ORowSetValueDecorator( aTableName ) ); // Table name
+// aRow.push_back( new ORowSetValueDecorator( aTableType ) ); // Table type
+ aRow.push_back( new ORowSetValueDecorator( rtl::OUString::createFromAscii("TABLE") ) ); // Table type
+ aRow.push_back( ODatabaseMetaDataResultSet::getEmptyValue() ); // Remarks
+ aRows.push_back(aRow);
+ }
+ }
+
+ _rRows = aRows;
+ return(sal_True);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.hxx b/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.hxx
new file mode 100644
index 000000000000..d855315de56e
--- /dev/null
+++ b/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.hxx
@@ -0,0 +1,46 @@
+/* -*- 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_MORK_DBMETADATAHELPER_HXX
+#define CONNECTIVITY_MORK_DBMETADATAHELPER_HXX
+
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include "FDatabaseMetaDataResultSet.hxx"
+#include "MErrorResource.hxx"
+
+#include <MConnection.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+
+
+namespace connectivity
+{
+ namespace mork
+ {
+ class MDatabaseMetaDataHelper
+ {
+ public:
+ MDatabaseMetaDataHelper();
+ ~MDatabaseMetaDataHelper();
+
+ //
+ sal_Bool getTableStrings( OConnection* _pCon,
+ ::std::vector< ::rtl::OUString >& _rStrings);
+
+ sal_Bool getTables( OConnection* _pCon,
+ const ::rtl::OUString& tableNamePattern,
+ ODatabaseMetaDataResultSet::ORows& _rRows);
+ };
+ }
+}
+
+#endif // CONNECTIVITY_MORK_DBMETADATAHELPER_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 000000000000..c5998921e324
--- /dev/null
+++ b/connectivity/source/drivers/mork/MDriver.cxx
@@ -0,0 +1,124 @@
+/* -*- 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"
+#include "MNSProfileDiscover.hxx"
+
+#include "resource/mork_res.hrc"
+#include "resource/common_res.hrc"
+
+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),
+ m_xFactory(context_->getServiceManager(), css::uno::UNO_QUERY)
+{
+ SAL_INFO("connectivity.mork", "=> MorkDriver::MorkDriver()" );
+// css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceFactory(;
+ m_ProfileAccess = new ProfileAccess();
+ 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)
+{
+ SAL_INFO("connectivity.mork", "=> MorkDriver::connect()" );
+
+ (void) url; (void) info; // avoid warnings
+ css::uno::Reference< css::sdbc::XConnection > xCon;
+ OConnection* pCon = new OConnection(this);
+ xCon = pCon; // important here because otherwise the connection could be deleted inside (refcount goes -> 0)
+ pCon->construct(url, info);
+ return xCon;
+}
+
+sal_Bool MorkDriver::acceptsURL(rtl::OUString const & url)
+ throw (css::sdbc::SQLException, css::uno::RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> MorkDriver::acceptsURL()" );
+
+ //... TODO
+ (void) url; // avoid warnings
+ return true;
+}
+
+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 000000000000..722bb9239f4d
--- /dev/null
+++ b/connectivity/source/drivers/mork/MDriver.hxx
@@ -0,0 +1,106 @@
+/* -*- 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 <com/sun/star/lang/XMultiServiceFactory.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 {
+class ProfileAccess;
+namespace css = com::sun::star;
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL
+create(css::uno::Reference< css::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);
+
+ css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > getFactory(){return m_xFactory;}
+private:
+
+ ProfileAccess* m_ProfileAccess;
+ 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_;
+ css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MErrorResource.hxx b/connectivity/source/drivers/mork/MErrorResource.hxx
new file mode 100644
index 000000000000..d0e4263e73b8
--- /dev/null
+++ b/connectivity/source/drivers/mork/MErrorResource.hxx
@@ -0,0 +1,71 @@
+/* -*- 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 CONNECITIVITY_MORK_ERROR_RESOURCE_HXX
+#define CONNECITIVITY_MORK_ERROR_RESOURCE_HXX
+
+#include <rtl/ustring.hxx>
+
+namespace connectivity
+{
+ namespace mork
+ {
+ class ErrorDescriptor
+ {
+ private:
+ sal_uInt16 m_nErrorResourceId;
+ sal_Int32 m_nErrorCondition;
+ ::rtl::OUString m_sParameter;
+
+ public:
+ ErrorDescriptor()
+ :m_nErrorResourceId(0)
+ ,m_nErrorCondition(0)
+ ,m_sParameter()
+ {
+ }
+
+ inline void set( const sal_uInt16 _nErrorResourceId, const sal_Int32 _nErrorCondition, const ::rtl::OUString& _rParam )
+ {
+ m_nErrorResourceId = _nErrorResourceId;
+ m_nErrorCondition = _nErrorCondition;
+ m_sParameter = _rParam;
+ }
+ inline void setResId( const sal_uInt16 _nErrorResourceId )
+ {
+ m_nErrorResourceId = _nErrorResourceId;
+ }
+ inline void reset()
+ {
+ m_nErrorResourceId = 0;
+ m_nErrorCondition = 0;
+ }
+
+ inline sal_uInt16 getResId() const { return m_nErrorResourceId; }
+ inline sal_Int32 getErrorCondition() const { return m_nErrorCondition; }
+ inline const ::rtl::OUString& getParameter() const { return m_sParameter; }
+
+ inline bool is() const { return ( m_nErrorResourceId != 0 ) || ( m_nErrorCondition != 0 ); }
+ };
+ }
+}
+
+#endif // CONNECITIVITY_MORK_ERROR_RESOURCE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MExtConfigAccess.hxx b/connectivity/source/drivers/mork/MExtConfigAccess.hxx
new file mode 100644
index 000000000000..44e7a86ee59f
--- /dev/null
+++ b/connectivity/source/drivers/mork/MExtConfigAccess.hxx
@@ -0,0 +1,39 @@
+/* -*- 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 CONNECTIVITY_MORK_MEXTCONFIGACCESS_HXX
+
+// This is the extended version (for use on the SO side of the driver) of MConfigAccess
+// (which is for use on the mozilla side only)
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+namespace connectivity
+{
+ namespace mork
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ createDriverConfigNode( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB );
+ }
+}
+
+#endif // CONNECTIVITY_MORK_MEXTCONFIGACCESS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MNSFolders.cxx b/connectivity/source/drivers/mork/MNSFolders.cxx
new file mode 100644
index 000000000000..e0da76870f0a
--- /dev/null
+++ b/connectivity/source/drivers/mork/MNSFolders.cxx
@@ -0,0 +1,156 @@
+/* -*- 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 <MNSFolders.hxx>
+
+#ifdef UNIX
+#include <sys/types.h>
+#include <strings.h>
+#include <string.h>
+#endif // End UNIX
+
+#ifdef WNT
+#include "pre_include_windows.h"
+#include <windows.h>
+#include <stdlib.h>
+#include <shlobj.h>
+#include <objidl.h>
+#include "post_include_windows.h"
+#endif // End WNT
+#include <osl/security.hxx>
+#include <osl/file.hxx>
+#include <osl/thread.h>
+
+using namespace ::com::sun::star::mozilla;
+
+namespace
+{
+ // -------------------------------------------------------------------
+ static ::rtl::OUString lcl_getUserDataDirectory()
+ {
+ ::osl::Security aSecurity;
+ ::rtl::OUString aConfigPath;
+
+ #if defined(XP_WIN) || defined(MACOSX)
+ aSecurity.getConfigDir( aConfigPath );
+ #else
+ //This is to find the dir under which .mozilla/.thunderbird is created.
+ //mozilla doesn't honour XDG_CONFIG_HOME, so raw home dir required here
+ //not xdg-config dir
+ aSecurity.getHomeDir( aConfigPath );
+ #endif
+
+ return aConfigPath + ::rtl::OUString("/");
+ }
+
+ // -------------------------------------------------------------------
+ const size_t NB_PRODUCTS = 3;
+ const size_t NB_CANDIDATES = 4;
+
+ static const char* DefaultProductDir[NB_PRODUCTS][NB_CANDIDATES] =
+ {
+ #if defined(XP_WIN)
+ { "Mozilla/SeaMonkey/", NULL, NULL, NULL },
+ { "Mozilla/Firefox/", NULL, NULL, NULL },
+ { "Thunderbird/", "Mozilla/Thunderbird/", NULL, NULL }
+ #elif(MACOSX)
+ { "../Mozilla/SeaMonkey/", NULL, NULL, NULL },
+ { "Firefox/", NULL, NULL, NULL },
+ { "../Thunderbird/", NULL, NULL, NULL }
+ #else
+ { ".mozilla/seamonkey/", NULL, NULL, NULL },
+ { ".mozilla/firefox/", NULL, NULL, NULL },
+ { ".thunderbird/", ".mozilla-thunderbird/", ".mozilla/thunderbird/", ".icedove" }
+ #endif
+ };
+
+ static const char* ProductRootEnvironmentVariable[NB_PRODUCTS] =
+ {
+ "MOZILLA_PROFILE_ROOT",
+ "MOZILLA_FIREFOX_PROFILE_ROOT",
+ "MOZILLA_THUNDERBIRD_PROFILE_ROOT",
+ };
+
+ // -------------------------------------------------------------------
+ static ::rtl::OUString lcl_guessProfileRoot( MozillaProductType _product )
+ {
+ size_t productIndex = _product - 1;
+
+ static ::rtl::OUString s_productDirectories[NB_PRODUCTS];
+
+ if ( s_productDirectories[ productIndex ].isEmpty() )
+ {
+ ::rtl::OUString sProductPath;
+
+ // check whether we have an anevironment variable which helps us
+ const char* pProfileByEnv = getenv( ProductRootEnvironmentVariable[ productIndex ] );
+ if ( pProfileByEnv )
+ {
+ sProductPath = ::rtl::OUString( pProfileByEnv, rtl_str_getLength( pProfileByEnv ), osl_getThreadTextEncoding() );
+ // asume that this is fine, no further checks
+ }
+ else
+ {
+ ::rtl::OUString sProductDirCandidate;
+ const char* pProfileRegistry = "profiles.ini";
+
+ // check all possible candidates
+ for ( size_t i=0; i<NB_CANDIDATES; ++i )
+ {
+ if ( NULL == DefaultProductDir[ productIndex ][ i ] )
+ break;
+
+ sProductDirCandidate = lcl_getUserDataDirectory() +
+ ::rtl::OUString::createFromAscii( DefaultProductDir[ productIndex ][ i ] );
+
+ // check existence
+ ::osl::DirectoryItem aRegistryItem;
+ ::osl::FileBase::RC result = ::osl::DirectoryItem::get( sProductDirCandidate + ::rtl::OUString::createFromAscii( pProfileRegistry ), aRegistryItem );
+ if ( result == ::osl::FileBase::E_None )
+ {
+ ::osl::FileStatus aStatus( osl_FileStatus_Mask_Validate );
+ result = aRegistryItem.getFileStatus( aStatus );
+ if ( result == ::osl::FileBase::E_None )
+ {
+ // the registry file exists
+ break;
+ }
+ }
+ }
+
+ ::osl::FileBase::getSystemPathFromFileURL( sProductDirCandidate, sProductPath );
+ }
+
+ s_productDirectories[ productIndex ] = sProductPath;
+ }
+
+ return s_productDirectories[ productIndex ];
+ }
+}
+
+// -----------------------------------------------------------------------
+::rtl::OUString getRegistryDir(MozillaProductType product)
+{
+ if (product == MozillaProductType_Default)
+ return ::rtl::OUString();
+
+ return lcl_guessProfileRoot( product );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MNSFolders.hxx b/connectivity/source/drivers/mork/MNSFolders.hxx
new file mode 100644
index 000000000000..609d0ea24e89
--- /dev/null
+++ b/connectivity/source/drivers/mork/MNSFolders.hxx
@@ -0,0 +1,34 @@
+/* -*- 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 _MNSFOLDERS_HXX_
+#define _MNSFOLDERS_HXX_
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/conditn.hxx>
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+
+#include <rtl/ustring.hxx>
+
+::rtl::OUString getRegistryDir(::com::sun::star::mozilla::MozillaProductType product);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MNSINIParser.cxx b/connectivity/source/drivers/mork/MNSINIParser.cxx
new file mode 100644
index 000000000000..c601213bd654
--- /dev/null
+++ b/connectivity/source/drivers/mork/MNSINIParser.cxx
@@ -0,0 +1,96 @@
+/* -*- 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 <MNSINIParser.hxx>
+#include <rtl/byteseq.hxx>
+
+IniParser::IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException )
+{
+ OUString iniUrl;
+ if (osl_File_E_None != osl_getFileURLFromSystemPath(rIniName.pData, &iniUrl.pData))
+ return;
+
+ SAL_INFO("connectivity.mork", "IniParser: " << iniUrl);
+ oslFileHandle handle=NULL;
+ oslFileError fileError = osl_File_E_INVAL;
+ try{
+ if (!iniUrl.isEmpty())
+ fileError = osl_openFile(iniUrl.pData, &handle, osl_File_OpenFlag_Read);
+ }
+ catch(const ::com::sun::star::io::IOException&)
+ {
+ SAL_WARN("connectivity.mork", "IniParser -- couldn't open file: " << iniUrl);
+ return;
+ }
+
+ if (osl_File_E_None == fileError)
+ {
+ rtl::ByteSequence seq;
+ sal_uInt64 nSize = 0;
+
+ osl_getFileSize(handle, &nSize);
+ OUString sectionName( "no name section" );
+ while (true)
+ {
+ sal_uInt64 nPos;
+ if (osl_File_E_None != osl_getFilePos(handle, &nPos) || nPos >= nSize)
+ break;
+ if (osl_File_E_None != osl_readLine(handle , (sal_Sequence **) &seq))
+ break;
+ OString line( (const sal_Char *) seq.getConstArray(), seq.getLength() );
+ sal_Int32 nIndex = line.indexOf('=');
+ if (nIndex >= 1)
+ {
+ ini_Section *aSection = &mAllSection[sectionName];
+ struct ini_NameValue nameValue;
+ nameValue.sName = OStringToOUString(
+ line.copy(0,nIndex).trim(), RTL_TEXTENCODING_ASCII_US );
+ nameValue.sValue = OStringToOUString(
+ line.copy(nIndex+1).trim(), RTL_TEXTENCODING_UTF8 );
+
+ aSection->lList.push_back(nameValue);
+
+ }
+ else
+ {
+ sal_Int32 nIndexStart = line.indexOf('[');
+ sal_Int32 nIndexEnd = line.indexOf(']');
+ if ( nIndexEnd > nIndexStart && nIndexStart >=0)
+ {
+ sectionName = OStringToOUString(
+ line.copy(nIndexStart + 1,nIndexEnd - nIndexStart -1).trim(), RTL_TEXTENCODING_ASCII_US );
+ if (sectionName.isEmpty())
+ sectionName = OUString("no name section");
+
+ ini_Section *aSection = &mAllSection[sectionName];
+ aSection->sName = sectionName;
+ }
+ }
+ }
+ osl_closeFile(handle);
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else
+ {
+ SAL_WARN("connectivity.mork", "IniParser -- couldn't open file: " << iniUrl);
+ }
+#endif
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MNSINIParser.hxx b/connectivity/source/drivers/mork/MNSINIParser.hxx
new file mode 100644
index 000000000000..e6941bcc5bad
--- /dev/null
+++ b/connectivity/source/drivers/mork/MNSINIParser.hxx
@@ -0,0 +1,74 @@
+/* -*- 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 __MNSINIPARSER_HXX__
+#define __MNSINIPARSER_HXX__
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/io/IOException.hpp>
+#include <osl/process.h>
+
+#include <map>
+#include <list>
+
+#if OSL_DEBUG_LEVEL > 0
+#include <stdio.h>
+#endif
+
+using ::rtl::OUString;
+using ::rtl::OString;
+
+struct ini_NameValue
+{
+ rtl::OUString sName;
+ rtl::OUString sValue;
+
+ inline ini_NameValue() SAL_THROW(())
+ {}
+ inline ini_NameValue(
+ OUString const & name, OUString const & value ) SAL_THROW(())
+ : sName( name ),
+ sValue( value )
+ {}
+};
+
+typedef std::list<
+ ini_NameValue
+> NameValueList;
+
+struct ini_Section
+{
+ rtl::OUString sName;
+ NameValueList lList;
+};
+typedef std::map<rtl::OUString,
+ ini_Section
+ >IniSectionMap;
+
+
+class IniParser
+{
+ IniSectionMap mAllSection;
+public:
+ IniSectionMap * getAllSection(){return &mAllSection;};
+ IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MNSProfileDiscover.cxx b/connectivity/source/drivers/mork/MNSProfileDiscover.cxx
new file mode 100644
index 000000000000..014e17cc89e9
--- /dev/null
+++ b/connectivity/source/drivers/mork/MNSProfileDiscover.cxx
@@ -0,0 +1,224 @@
+/* -*- 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 "MNSProfileDiscover.hxx"
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+#include <MNSFolders.hxx>
+#include <MNSINIParser.hxx>
+
+namespace connectivity
+{
+ namespace mork
+ {
+ ProfileStruct::ProfileStruct(MozillaProductType aProduct,::rtl::OUString aProfileName,
+ const ::rtl::OUString& aProfilePath
+ )
+ {
+ product=aProduct;
+ profileName = aProfileName;
+ profilePath = aProfilePath;
+ }
+ ::rtl::OUString ProfileStruct::getProfilePath()
+ {
+ return profilePath;
+ }
+
+ ProfileAccess::~ProfileAccess()
+ {
+ }
+ ProfileAccess::ProfileAccess()
+ {
+ LoadProductsInfo();
+ }
+
+ sal_Int32 ProfileAccess::LoadProductsInfo()
+ {
+ //load SeaMonkey 2 profiles to m_ProductProfileList
+ sal_Int32 count = LoadXPToolkitProfiles(MozillaProductType_Mozilla);
+
+ //load thunderbird profiles to m_ProductProfileList
+ count += LoadXPToolkitProfiles(MozillaProductType_Thunderbird);
+
+ //load firefox profiles to m_ProductProfileList
+ //firefox profile does not containt address book, but maybe others need them
+ count += LoadXPToolkitProfiles(MozillaProductType_Firefox);
+ return count;
+ }
+ //Thunderbird and firefox profiles are saved in profiles.ini
+ sal_Int32 ProfileAccess::LoadXPToolkitProfiles(MozillaProductType product)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+
+ ::rtl::OUString regDir = getRegistryDir(product);
+ ::rtl::OUString profilesIni( regDir );
+ profilesIni += ::rtl::OUString("profiles.ini");
+ IniParser parser( profilesIni );
+ IniSectionMap &mAllSection = *(parser.getAllSection());
+
+ IniSectionMap::iterator iBegin = mAllSection.begin();
+ IniSectionMap::iterator iEnd = mAllSection.end();
+ for(;iBegin != iEnd;++iBegin)
+ {
+ ini_Section *aSection = &(*iBegin).second;
+ ::rtl::OUString profileName;
+ ::rtl::OUString profilePath;
+ ::rtl::OUString sIsRelative;
+ ::rtl::OUString sIsDefault;
+
+ for(NameValueList::iterator itor=aSection->lList.begin();
+ itor != aSection->lList.end();
+ ++itor)
+ {
+ struct ini_NameValue * aValue = &(*itor);
+ if ( aValue->sName == "Name" )
+ {
+ profileName = aValue->sValue;
+ }
+ else if ( aValue->sName == "IsRelative" )
+ {
+ sIsRelative = aValue->sValue;
+ }
+ else if ( aValue->sName == "Path" )
+ {
+ profilePath = aValue->sValue;
+ }
+ else if ( aValue->sName == "Default" )
+ {
+ sIsDefault = aValue->sValue;
+ }
+ }
+ if (!(profileName.isEmpty() && profilePath.isEmpty()))
+ {
+ sal_Int32 isRelative = 0;
+ if (!sIsRelative.isEmpty())
+ {
+ isRelative = sIsRelative.toInt32();
+ }
+
+ rtl::OUString fullProfilePath;
+ if(isRelative)
+ {
+ fullProfilePath = regDir + profilePath;
+ }
+ else
+ {
+ fullProfilePath = profilePath;
+ }
+
+ ProfileStruct* profileItem = new ProfileStruct(product,profileName,
+ fullProfilePath
+ );
+ m_Product.mProfileList[profileName] = profileItem;
+
+ sal_Int32 isDefault = 0;
+ if (!sIsDefault.isEmpty())
+ {
+ isDefault = sIsDefault.toInt32();
+ }
+ if (isDefault)
+ m_Product.mCurrentProfileName = profileName;
+
+ }
+
+ }
+ return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
+ }
+
+ ::rtl::OUString ProfileAccess::getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ if (!m_Product.mProfileList.size() || m_Product.mProfileList.find(profileName) == m_Product.mProfileList.end())
+ {
+ //Profile not found
+ return ::rtl::OUString();
+ }
+ else
+ return m_Product.mProfileList[profileName]->getProfilePath();
+ }
+
+ ::sal_Int32 ProfileAccess::getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
+ }
+ ::sal_Int32 ProfileAccess::getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ list.realloc(static_cast<sal_Int32>(m_Product.mProfileList.size()));
+ sal_Int32 i=0;
+ for(ProfileList::iterator itor=m_Product.mProfileList.begin();
+ itor != m_Product.mProfileList.end();
+ ++itor)
+ {
+ ProfileStruct * aProfile = (*itor).second;
+ list[i] = aProfile->getProfileName();
+ i++;
+ }
+
+ return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
+ }
+
+ ::rtl::OUString ProfileAccess::getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ if (!m_Product.mCurrentProfileName.isEmpty())
+ {
+ //default profile setted in mozilla registry
+ return m_Product.mCurrentProfileName;
+ }
+ if (m_Product.mProfileList.empty())
+ {
+ //there are not any profiles
+ return ::rtl::OUString();
+ }
+ ProfileStruct * aProfile = (*m_Product.mProfileList.begin()).second;
+ return aProfile->getProfileName();
+ }
+ ::sal_Bool ProfileAccess::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ (void)product; /* avoid warning about unused parameter */
+ (void)profileName; /* avoid warning about unused parameter */
+ return sal_True;
+ }
+
+ ::sal_Bool ProfileAccess::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ if (!m_Product.mProfileList.size() || m_Product.mProfileList.find(profileName) == m_Product.mProfileList.end())
+ {
+ return sal_False;
+ }
+ else
+ return sal_True;
+ }
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MNSProfileDiscover.hxx b/connectivity/source/drivers/mork/MNSProfileDiscover.hxx
new file mode 100644
index 000000000000..1cb44cdcfeb8
--- /dev/null
+++ b/connectivity/source/drivers/mork/MNSProfileDiscover.hxx
@@ -0,0 +1,98 @@
+/* -*- 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 __MNSProfileDiscover_h___
+#define __MNSProfileDiscover_h___
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/conditn.hxx>
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/ustring.hxx>
+
+#include <vector>
+#include <map>
+
+#include "dllapi.h"
+
+using namespace com::sun::star::mozilla;
+namespace connectivity
+{
+ namespace mork
+ {
+ class ProfileStruct;
+ }
+}
+typedef ::std::map < ::rtl::OUString, ::connectivity::mork::ProfileStruct* > ProfileList;
+namespace connectivity
+{
+ namespace mork
+ {
+ class ProfileStruct
+ {
+ public:
+ ProfileStruct(MozillaProductType aProduct,::rtl::OUString aProfileName,
+ const ::rtl::OUString &aProfilePath
+ );
+ MozillaProductType getProductType() { return product;}
+ ::rtl::OUString getProfileName(){ return profileName;}
+ ::rtl::OUString getProfilePath() ;
+ protected:
+ MozillaProductType product;
+ ::rtl::OUString profileName;
+ ::rtl::OUString profilePath;
+ };
+
+ class ProductStruct
+ {
+ public:
+ void setCurrentProfile(::rtl::OUString aProfileName){mCurrentProfileName = aProfileName;}
+
+ ::rtl::OUString mCurrentProfileName;
+
+ ProfileList mProfileList;
+ };
+
+ //Used to query profiles information
+ class LO_DLLPUBLIC_MORK ProfileAccess
+ {
+ public:
+
+ virtual ~ProfileAccess();
+ ProfileAccess();
+ ::rtl::OUString getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Int32 getProfileCount( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Int32 getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException);
+ ::rtl::OUString getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Bool SAL_CALL isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Bool SAL_CALL getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ protected:
+ ProductStruct m_ProductProfileList[4];
+ sal_Int32 LoadProductsInfo();
+ sal_Int32 LoadXPToolkitProfiles(MozillaProductType product);
+ };
+
+ }
+}
+
+#endif // __MNSProfileDiscover_h___
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MPreparedStatement.cxx b/connectivity/source/drivers/mork/MPreparedStatement.cxx
new file mode 100644
index 000000000000..c34de94576e1
--- /dev/null
+++ b/connectivity/source/drivers/mork/MPreparedStatement.cxx
@@ -0,0 +1,529 @@
+/* -*- 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 <stdio.h>
+#include <osl/diagnose.h>
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "MPreparedStatement.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include "MResultSetMetaData.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "diagnose_ex.h"
+
+#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 ::comphelper;
+using namespace connectivity;
+using namespace connectivity::mork;
+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;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.mork.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
+
+OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const ::rtl::OUString& sql)
+ :OCommonStatement(_pConnection)
+ ,m_nNumParams(0)
+ ,m_sSqlStatement(sql)
+ ,m_bPrepared(sal_False)
+ ,m_pResultSet()
+{
+}
+// -----------------------------------------------------------------------------
+OPreparedStatement::~OPreparedStatement()
+{
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::lateInit()
+{
+ if ( eSelect != parseSql( m_sSqlStatement ) )
+ throw SQLException();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ OCommonStatement::disposing();
+
+ m_xMetaData.clear();
+ if(m_aParameterRow.is())
+ {
+ m_aParameterRow->get().clear();
+ m_aParameterRow = NULL;
+ }
+ m_xParamColumns = NULL;
+}
+// -----------------------------------------------------------------------------
+
+OCommonStatement::StatementType OPreparedStatement::parseSql( const ::rtl::OUString& sql , sal_Bool bAdjusted )
+ throw ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException )
+{
+ SAL_INFO("connectivity.mork", "=> OPreparedStatement::parseSql()" );
+
+ StatementType eStatementType = OCommonStatement::parseSql( sql, bAdjusted );
+ if ( eStatementType != eSelect )
+ return eStatementType;
+
+ m_xParamColumns = new OSQLColumns();
+
+ // describe all parameters need for the resultset
+ describeParameter();
+
+ Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
+ OResultSet::setBoundedColumns( m_aRow, m_xParamColumns, xNames, sal_False, m_xDBMetaData, m_aColMapping );
+
+ return eStatementType;
+}
+
+// -----------------------------------------------------------------------------
+void OPreparedStatement::initializeResultSet( OResultSet* _pResult )
+{
+ OCommonStatement::initializeResultSet( _pResult );
+ _pResult->setParameterColumns( m_xParamColumns );
+ _pResult->setParameterRow( m_aParameterRow );
+}
+
+// -----------------------------------------------------------------------------
+void OPreparedStatement::clearCachedResultSet()
+{
+ OCommonStatement::clearCachedResultSet();
+ m_pResultSet.clear();
+ m_xMetaData.clear();
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult )
+{
+ OCommonStatement::cacheResultSet( _pResult );
+ OSL_PRECOND( m_pResultSet == NULL, "OPreparedStatement::parseSql: you should call clearCachedResultSet before!" );
+ m_pResultSet = _pResult;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::acquire() throw()
+{
+ OCommonStatement::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::release() throw()
+{
+ OCommonStatement::release();
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OCommonStatement::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OPreparedStatement_BASE::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OCommonStatement::getTypes());
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OPreparedStatement::getMetaData()" );
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ sal_Bool bReadOnly = sal_True;
+ if ( m_pResultSet.is() )
+ bReadOnly = m_pResultSet->determineReadOnly();
+ // if we do not have a result set, then we have not been executed, yet. In this case, assuming readonly=true is
+ // okay, /me thinks.
+
+ if ( !m_xMetaData.is() )
+ m_xMetaData = new OResultSetMetaData( m_pSQLIterator->getSelectColumns(), m_pSQLIterator->getTables().begin()->first ,m_pTable,bReadOnly );
+
+ return m_xMetaData;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OPreparedStatement::execute()" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ Reference< XResultSet> xResult = executeQuery();
+ return xResult.is();
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OPreparedStatement::executeUpdate()" );
+
+ ::dbtools::throwFeatureNotImplementedException( "XStatement::executeUpdate", *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ OSL_TRACE("prepStmt::setString( %s )", OUtoCStr( x ) );
+ setParameter( parameterIndex, x );
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OPreparedStatement::executeQuery()" );
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_TRACE("In: OPreparedStatement::executeQuery" );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ // our statement has already been parsed in lateInit, no need to do all this (potentially expensive)
+ // stuff again. Just execute.
+ return impl_executeCurrentQuery();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 /*parameterIndex*/, sal_Bool /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setBoolean", *this );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setByte( sal_Int32 /*parameterIndex*/, sal_Int8 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setByte", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDate( sal_Int32 /*parameterIndex*/, const Date& /*aData*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setDate", *this );
+}
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL OPreparedStatement::setTime( sal_Int32 /*parameterIndex*/, const Time& /*aVal*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setTime", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 /*parameterIndex*/, const DateTime& /*aVal*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setTimestamp", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDouble( sal_Int32 /*parameterIndex*/, double /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setDouble", *this );
+}
+
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setFloat( sal_Int32 /*parameterIndex*/, float /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setFloat", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setInt( sal_Int32 /*parameterIndex*/, sal_Int32 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setInt", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setLong( sal_Int32 /*parameterIndex*/, sal_Int64 /*aVal*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setLong", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ checkAndResizeParameters(parameterIndex);
+
+ (m_aParameterRow->get())[parameterIndex].setNull();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setClob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setBlob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setArray", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setRef", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 /*parameterIndex*/, const Any& /*x*/, sal_Int32 /*sqlType*/, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setObjectWithInfo", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
+{
+ setNull(parameterIndex,sqlType);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::implSetObject(this,parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setShort( sal_Int32 /*parameterIndex*/, sal_Int16 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setShort", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBytes( sal_Int32 /*parameterIndex*/, const Sequence< sal_Int8 >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setBytes", *this );
+}
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setCharacterStream", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 /*parameterIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setBinaryStream", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ break;
+ case PROPERTY_ID_USEBOOKMARKS:
+ break;
+ default:
+ OCommonStatement::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OPreparedStatement::checkAndResizeParameters(sal_Int32 parameterIndex)
+{
+ ::connectivity::checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ if ( !m_aParameterRow.is() ) {
+ m_aParameterRow = new OValueVector();
+ m_aParameterRow->get().push_back(sal_Int32(0));
+ }
+
+ if ((sal_Int32)(m_aParameterRow->get()).size() <= parameterIndex)
+ (m_aParameterRow->get()).resize(parameterIndex+1);
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const
+ORowSetValue& x)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkAndResizeParameters(parameterIndex);
+
+ OSL_TRACE("setParameter( %d, '%s')", parameterIndex, OUtoCStr(x) );
+ (m_aParameterRow->get())[parameterIndex] = x;
+}
+
+//------------------------------------------------------------------
+size_t OPreparedStatement::AddParameter(OSQLParseNode * pParameter, const Reference<XPropertySet>& _xCol)
+{
+ OSL_UNUSED( pParameter );
+ // Count of the newly added Parameters
+ size_t nParameter = m_xParamColumns->get().size()+1;
+
+ OSL_ENSURE(SQL_ISRULE(pParameter,parameter),"OResultSet::AddParameter: Argument is not a Parameter");
+ OSL_ENSURE(pParameter->count() > 0,"OResultSet: error in parse tree");
+#if OSL_DEBUG_LEVEL > 0
+ OSQLParseNode * pMark = pParameter->getChild(0);
+ OSL_UNUSED( pMark );
+#endif
+
+ ::rtl::OUString sParameterName;
+
+ // set up Parameter-Column:
+ sal_Int32 eType = DataType::VARCHAR;
+ sal_uInt32 nPrecision = 255;
+ sal_Int32 nScale = 0;
+ sal_Int32 nNullable = ColumnValue::NULLABLE;
+
+ if (_xCol.is())
+ {
+ // Type, Precision, Scale ... utilize the selected Columns,
+ // then this Column will get the value assigned or with this
+ // Column will the value be compared.
+ eType = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
+ nPrecision = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
+ nScale = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)));
+ nNullable = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
+ _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sParameterName;
+ }
+
+ Reference<XPropertySet> xParaColumn = new connectivity::sdbcx::OColumn(sParameterName
+ ,::rtl::OUString()
+ ,::rtl::OUString()
+ ,::rtl::OUString()
+ ,nNullable
+ ,nPrecision
+ ,nScale
+ ,eType
+ ,sal_False
+ ,sal_False
+ ,sal_False
+ ,m_pSQLIterator->isCaseSensitive());
+ m_xParamColumns->get().push_back(xParaColumn);
+ return nParameter;
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::describeColumn(OSQLParseNode*
+_pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable)
+{
+ Reference<XPropertySet> xProp;
+ if(SQL_ISRULE(_pNode,column_ref))
+ {
+ ::rtl::OUString sColumnName,sTableRange;
+ m_pSQLIterator->getColumnRange(_pNode,sColumnName,sTableRange);
+ if(!sColumnName.isEmpty())
+ {
+ Reference<XNameAccess> xNameAccess = _xTable->getColumns();
+ if(xNameAccess->hasByName(sColumnName))
+ xNameAccess->getByName(sColumnName) >>= xProp;
+ AddParameter(_pParameter,xProp);
+ }
+ }
+ // else
+ // AddParameter(_pParameter,xProp);
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::describeParameter()
+{
+ ::std::vector< OSQLParseNode*> aParseNodes;
+ scanParameter(m_pParseTree,aParseNodes);
+ if(!aParseNodes.empty())
+ {
+ m_xParamColumns = new OSQLColumns();
+ const OSQLTables& xTabs = m_pSQLIterator->getTables();
+ if(xTabs.size())
+ {
+ OSQLTable xTable = xTabs.begin()->second;
+ ::std::vector< OSQLParseNode*>::const_iterator aIter =
+aParseNodes.begin();
+ for (;aIter != aParseNodes.end();++aIter )
+ {
+ describeColumn(*aIter,(*aIter)->getParent()->getChild(0),xTable);
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes)
+{
+ OSL_ENSURE(pParseNode != NULL,"OResultSet: internal error: invalid ParseNode");
+
+ // Parameter Name-Row found?
+ if (SQL_ISRULE(pParseNode,parameter))
+ {
+ OSL_ENSURE(pParseNode->count() >= 1,"OResultSet: Faulty Parse Tree");
+ OSL_ENSURE(pParseNode->getChild(0)->getNodeType() == SQL_NODE_PUNCTUATION,"OResultSet: Faulty Parse Tree");
+
+ _rParaNodes.push_back(pParseNode);
+ // further search isn't necessary
+ return;
+ }
+
+ // Search on in Parse Tree
+ for (sal_uInt32 i = 0; i < pParseNode->count(); i++)
+ scanParameter(pParseNode->getChild(i),_rParaNodes);
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL OPreparedStatement::getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OPreparedStatement::getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OPreparedStatement::getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MPreparedStatement.hxx b/connectivity/source/drivers/mork/MPreparedStatement.hxx
new file mode 100644
index 000000000000..0c38cbacb78b
--- /dev/null
+++ b/connectivity/source/drivers/mork/MPreparedStatement.hxx
@@ -0,0 +1,156 @@
+/* -*- 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 CONNECTIVITY_SPREPAREDSTATEMENT_HXX
+#define CONNECTIVITY_SPREPAREDSTATEMENT_HXX
+
+#include "MResultSet.hxx"
+#include "MStatement.hxx"
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/sdbc/XMultipleResults.hpp>
+#include <cppuhelper/compbase5.hxx>
+
+namespace connectivity
+{
+ namespace mork
+ {
+
+ typedef ::cppu::ImplHelper5< ::com::sun::star::sdbc::XPreparedStatement,
+ ::com::sun::star::sdbc::XParameters,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::sdbc::XMultipleResults,
+ ::com::sun::star::lang::XServiceInfo> OPreparedStatement_BASE;
+
+ class OPreparedStatement : public OCommonStatement,
+ public OPreparedStatement_BASE
+ {
+ protected:
+ struct Parameter
+ {
+ ::com::sun::star::uno::Any aValue;
+ sal_Int32 nDataType;
+
+ Parameter(const ::com::sun::star::uno::Any& rValue,
+ sal_Int32 rDataType) : aValue(rValue),nDataType(rDataType)
+ {
+ }
+
+ };
+
+ ::std::vector< Parameter> m_aParameters;
+ //====================================================================
+ // Data attributes
+ //====================================================================
+ sal_Int32 m_nNumParams; // Number of parameter markers for the prepared statement
+
+ ::rtl::OUString m_sSqlStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData;
+ sal_Bool m_bPrepared;
+ ::rtl::Reference< OResultSet > m_pResultSet;
+ ::rtl::Reference<connectivity::OSQLColumns> m_xParamColumns; // the parameter columns
+ OValueRow m_aParameterRow;
+
+ protected:
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue)
+ throw (::com::sun::star::uno::Exception);
+ virtual ~OPreparedStatement();
+
+ virtual void SAL_CALL disposing();
+
+ // OCommonStatement overridables
+ virtual StatementType
+ parseSql( const ::rtl::OUString& sql , sal_Bool bAdjusted = sal_False) throw ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ virtual void initializeResultSet( OResultSet* _pResult );
+ virtual void clearCachedResultSet();
+ virtual void cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult );
+
+
+ void checkAndResizeParameters(sal_Int32 parameterIndex);
+ void setParameter(sal_Int32 parameterIndex, const ORowSetValue& x);
+
+ size_t AddParameter(connectivity::OSQLParseNode * pParameter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xCol);
+ void scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes);
+ void describeColumn(OSQLParseNode* _pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable);
+ void describeParameter();
+
+ public:
+ DECLARE_SERVICE_INFO();
+ // A ctor need for returning the object
+ OPreparedStatement( OConnection* _pConnection,const ::rtl::OUString& sql);
+ void lateInit();
+
+ //XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPreparedStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XParameters
+ virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XMultipleResults
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ public:
+ using OCommonStatement::executeQuery;
+ using OCommonStatement::executeUpdate;
+ using OCommonStatement::execute;
+ protected:
+ using OPropertySetHelper::getFastPropertyValue;
+ };
+ }
+}
+#endif // CONNECTIVITY_SPREPAREDSTATEMENT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MQueryHelper.cxx b/connectivity/source/drivers/mork/MQueryHelper.cxx
new file mode 100644
index 000000000000..ffc2a5f5da7f
--- /dev/null
+++ b/connectivity/source/drivers/mork/MQueryHelper.cxx
@@ -0,0 +1,414 @@
+/* -*- 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 "MColumnAlias.hxx"
+#include "MQueryHelper.hxx"
+#include "MConnection.hxx"
+
+#include "MorkParser.hxx"
+#include <stdlib.h>
+#include <sstream>
+#include <string>
+#include <string.h>
+
+
+#include <connectivity/dbexception.hxx>
+
+using namespace connectivity::mork;
+using namespace connectivity;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace connectivity;
+
+
+extern
+::std::vector< sal_Bool > entryMatchedByExpression(MQueryHelper* _aQuery, MQueryExpression* _aExpr, MQueryHelperResultEntry* entry);
+
+MQueryHelperResultEntry::MQueryHelperResultEntry()
+{
+}
+
+MQueryHelperResultEntry::~MQueryHelperResultEntry()
+{
+}
+
+void MQueryHelperResultEntry::insert( const rtl::OString &key, rtl::OUString &value )
+{
+ m_Fields[ key ] = value;
+}
+
+rtl::OUString MQueryHelperResultEntry::getValue( const rtl::OString &key ) const
+{
+ FieldMap::const_iterator iter = m_Fields.find( key );
+ if ( iter == m_Fields.end() )
+ {
+ return rtl::OUString();
+ }
+ else
+ {
+ return iter->second;
+ }
+}
+
+void MQueryHelperResultEntry::setValue( const rtl::OString &key, const rtl::OUString & rValue)
+{
+// SAL_INFO("connectivity.mork", "MQueryHelper::setValue()" );
+// SAL_INFO("connectivity.mork", "key: " << &key << " value: " << &rValue);
+
+ m_Fields[ key ] = rValue;
+}
+
+MQueryHelper::MQueryHelper(const OColumnAlias& _ca)
+ :m_nIndex( 0 )
+ ,m_bHasMore( sal_True )
+ ,m_bAtEnd( sal_False )
+ ,m_rColumnAlias( _ca )
+{
+ m_aResults.clear();
+}
+
+MQueryHelper::~MQueryHelper()
+{
+ SAL_INFO("connectivity.mork", "MQueryHelper::~MQueryHelper()");
+
+ clear_results();
+ OSL_TRACE("OUT MQueryHelper::~MQueryHelper()");
+}
+
+// -------------------------------------------------------------------------
+void MQueryHelper::setAddressbook(::rtl::OUString &ab)
+{
+ SAL_INFO("connectivity.mork", "MQueryHelper::setAddressbook()");
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_aAddressbook = ab;
+
+ OSL_TRACE("\tOUT MQuery::setAddressbook()");
+}
+// -------------------------------------------------------------------------
+void MQueryHelper::setExpression( MQueryExpression &_expr )
+{
+ SAL_INFO("connectivity.mork", "MQueryHelper::setExpression()");
+ OSL_TRACE("IN MQueryHelper::setExpression()");
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_aExpr = _expr;
+
+ OSL_TRACE("\tOUT MQuery::setExpression()");
+}
+
+void MQueryHelper::append(MQueryHelperResultEntry* resEnt)
+{
+// SAL_INFO("connectivity.mork", "MQueryHelper::append()");
+
+ if ( resEnt != NULL ) {
+ m_aResults.push_back( resEnt );
+ m_bAtEnd = sal_False;
+ }
+}
+
+void MQueryHelper::clear_results()
+{
+ resultsArray::iterator iter = m_aResults.begin();
+ while ( iter != m_aResults.end() ) {
+ delete (*iter);
+ ++iter;
+ }
+ m_aResults.clear();
+}
+
+void MQueryHelper::reset()
+{
+ m_nIndex = 0;
+ m_bHasMore = sal_True;
+ m_bAtEnd = sal_False;
+ clear_results();
+}
+
+MQueryHelperResultEntry* MQueryHelper::next()
+{
+ MQueryHelperResultEntry* result;
+ sal_uInt32 index;
+
+ m_aMutex.acquire();
+ index = m_nIndex;
+ m_aMutex.release();
+
+ result = getByIndex( index + 1) ; // Add 1 as Row is numbered from 1 to N
+
+ if ( result ) {
+ m_aMutex.acquire();
+ m_nIndex++;
+ m_aMutex.release();
+ }
+
+ return( result );
+}
+
+MQueryHelperResultEntry*
+MQueryHelper::getByIndex(sal_uInt32 nRow)
+{
+ // Row numbers are from 1 to N, need to ensure this, and then
+ // substract 1
+ if ( nRow < 1 ) {
+ return( NULL );
+ }
+ return m_aResults[nRow -1];
+}
+
+sal_Int32 MQueryHelper::getResultCount() const
+{
+// SAL_INFO("connectivity.mork", "MQueryHelper::getResultCount()" );
+ sal_Int32 result = static_cast<sal_Int32>(m_aResults.size());
+// SAL_INFO("connectivity.mork", "result: " << result);
+
+ return result;
+}
+
+// -------------------------------------------------------------------------
+
+sal_Bool MQueryHelper::queryComplete() const
+{
+ return sal_True;
+}
+
+sal_Bool MQueryHelper::checkRowAvailable( sal_Int32 nDBRow )
+{
+/*
+ while (!queryComplete() && getResultCount() <= (sal_uInt32)nDBRow)
+ {
+ if ( !m_aQueryHelper->waitForRow( nDBRow ) ) {
+ m_aError = m_aQueryHelper->getError();
+ return( sal_False );
+ }
+ }
+*/
+ return( getResultCount() > nDBRow );
+}
+
+
+sal_Bool MQueryHelper::getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const rtl::OUString& aDBColumnName, sal_Int32 nType )
+{
+ SAL_INFO("connectivity.mork", "MQueryHelper::getRowValue()" );
+ MQueryHelperResultEntry* xResEntry = getByIndex( nDBRow );
+
+ OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL");
+ if (xResEntry == NULL )
+ {
+ rValue.setNull();
+ return sal_False;
+ }
+ switch ( nType )
+ {
+ case DataType::VARCHAR:
+ rValue = xResEntry->getValue( m_rColumnAlias.getProgrammaticNameOrFallbackToUTF8Alias( aDBColumnName ) );
+ break;
+
+ default:
+ rValue.setNull();
+ break;
+ }
+
+ return sal_True;
+}
+
+sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection)
+{
+ SAL_INFO("connectivity.mork", "MQueryHelper::executeQuery()" );
+ reset();
+
+ //dumpExpression(this, &m_aExpr);
+ MorkTableMap::iterator tableIter;
+ MorkTableMap *Tables = xConnection->getMorkParser()->getTables( 0x80 );
+ MorkRowMap *Rows = 0;
+ MorkRowMap::iterator rowIter;
+
+ for ( tableIter = Tables->begin(); tableIter != Tables->end(); tableIter++ )
+ {
+ // Iterate all tables
+ for ( tableIter = Tables->begin(); tableIter != Tables->end(); tableIter++ )
+ {
+ if (tableIter->first != 1) break;
+ Rows = xConnection->getMorkParser()->getRows( 0x80, &tableIter->second );
+ if ( Rows )
+ {
+ // Iterate all rows
+ for ( rowIter = Rows->begin(); rowIter != Rows->end(); rowIter++ )
+ {
+ MQueryHelperResultEntry* entry = new MQueryHelperResultEntry();
+ for (MorkCells::iterator CellsIter = rowIter->second.begin();
+ CellsIter != rowIter->second.end(); CellsIter++ )
+ {
+ std::string column = xConnection->getMorkParser()->getColumn(CellsIter->first);
+ std::string value = xConnection->getMorkParser()->getValue(CellsIter->second);
+
+ //SAL_INFO("connectivity.mork", "key: " << column << " value: " << value);
+
+ OString key(column.c_str(), static_cast<sal_Int32>(column.size()));
+ OString valueOString(value.c_str(), static_cast<sal_Int32>(value.size()));
+ rtl::OUString valueOUString = ::rtl::OStringToOUString( valueOString, RTL_TEXTENCODING_UTF8 );
+ entry->setValue(key, valueOUString);
+ }
+ ::std::vector< sal_Bool > vector = entryMatchedByExpression(this, &m_aExpr, entry);
+ sal_Bool result = sal_True;
+ for (::std::vector<sal_Bool>::iterator iter = vector.begin(); iter != vector.end(); ++iter) {
+ result = result && *iter;
+ }
+ if (result) {
+ append(entry);
+ }
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+::std::vector< sal_Bool > entryMatchedByExpression(MQueryHelper* _aQuery, MQueryExpression* _aExpr, MQueryHelperResultEntry* entry)
+{
+ ::std::vector< sal_Bool > resultVector;
+ MQueryExpression::ExprVector::iterator evIter;
+ for( evIter = _aExpr->getExpressions().begin();
+ evIter != _aExpr->getExpressions().end();
+ ++evIter )
+ {
+ if ( (*evIter)->isStringExpr() ) {
+ MQueryExpressionString* evStr = static_cast<MQueryExpressionString*> (*evIter);
+
+ // Set the 'name' property of the boolString.
+ // Check if it's an alias first...
+ rtl::OString attrName = _aQuery->getColumnAlias().getProgrammaticNameOrFallbackToUTF8Alias( evStr->getName() );
+ //OSL_TRACE("Name = %s ;", attrName.getStr() );
+ SAL_INFO("connectivity.mork", "Name = " << attrName.getStr());
+ // Set the 'matchType' property of the boolString. Check for equal length.
+ sal_Bool requiresValue = sal_True;
+ switch(evStr->getCond()) {
+ case MQueryOp::Exists:
+ SAL_INFO("connectivity.mork", "MQueryOp::Exists; done");
+ //boolString->SetCondition(nsIAbBooleanConditionTypes::Exists);
+ requiresValue = sal_False;
+ break;
+ case MQueryOp::DoesNotExist:
+ SAL_INFO("connectivity.mork", "MQueryOp::DoesNotExist; done");
+ //boolString->SetCondition(nsIAbBooleanConditionTypes::DoesNotExist);
+ requiresValue = sal_False;
+ break;
+ case MQueryOp::Contains:
+ SAL_INFO("connectivity.mork", "MQueryOp::Contains; done");
+ //boolString->SetCondition(nsIAbBooleanConditionTypes::Contains);
+ break;
+ case MQueryOp::DoesNotContain:
+ SAL_INFO("connectivity.mork", "MQueryOp::DoesNotContain; done");
+ //boolString->SetCondition(nsIAbBooleanConditionTypes::DoesNotContain);
+ break;
+ case MQueryOp::Is:
+ SAL_INFO("connectivity.mork", "MQueryOp::Is; done");
+ //boolString->SetCondition(nsIAbBooleanConditionTypes::Is);
+ break;
+ case MQueryOp::IsNot:
+ SAL_INFO("connectivity.mork", "MQueryOp::IsNot; done");
+ //boolString->SetCondition(nsIAbBooleanConditionTypes::IsNot);
+ break;
+ case MQueryOp::BeginsWith:
+ SAL_INFO("connectivity.mork", "MQueryOp::BeginsWith; done");
+ //boolString->SetCondition(nsIAbBooleanConditionTypes::BeginsWith);
+ break;
+ case MQueryOp::EndsWith:
+ SAL_INFO("connectivity.mork", "MQueryOp::EndsWith; done");
+ //boolString->SetCondition(nsIAbBooleanConditionTypes::EndsWith);
+ break;
+ case MQueryOp::SoundsLike:
+ SAL_INFO("connectivity.mork", "MQueryOp::SoundsLike; TODO");
+ //boolString->SetCondition(nsIAbBooleanConditionTypes::SoundsLike);
+ break;
+ case MQueryOp::RegExp:
+ SAL_INFO("connectivity.mork", "MQueryOp::RegExp; TODO");
+ //boolString->SetCondition(nsIAbBooleanConditionTypes::RegExp);
+ break;
+ default:
+ SAL_INFO("connectivity.mork", "(default) MQueryOp::Is; ");
+ //boolString->SetCondition(nsIAbBooleanConditionTypes::Is);
+ break;
+ }
+ rtl::OUString currentValue = entry->getValue(attrName);
+ // Set the 'matchValue' property of the boolString. Value returned in unicode.
+ if ( requiresValue )
+ {
+ SAL_INFO("connectivity.mork", "Value = " << evStr->getValue() );
+ rtl::OUString searchedValue = evStr->getValue();
+ if (evStr->getCond() == MQueryOp::Is) {
+ resultVector.push_back((currentValue == searchedValue) ? sal_True : sal_False);
+ } else if (evStr->getCond() == MQueryOp::IsNot) {
+ resultVector.push_back((currentValue == searchedValue) ? sal_False : sal_True);
+ } else if (evStr->getCond() == MQueryOp::EndsWith) {
+ resultVector.push_back((currentValue.endsWith(searchedValue)) ? sal_True : sal_False);
+ } else if (evStr->getCond() == MQueryOp::BeginsWith) {
+ resultVector.push_back((currentValue.indexOf(searchedValue) == 0) ? sal_True : sal_False);
+ } else if (evStr->getCond() == MQueryOp::Contains) {
+ resultVector.push_back((currentValue.indexOf(searchedValue) == -1) ? sal_False : sal_True);
+ } else if (evStr->getCond() == MQueryOp::DoesNotContain) {
+ resultVector.push_back((currentValue.indexOf(searchedValue) == -1) ? sal_True : sal_False);
+ } else {
+ OSL_FAIL("not yet implemented");
+ }
+ }
+
+ // Find it and change it ;-)
+ // class rtl::OUString "has no element named" isEmtpy
+ if (evStr->getCond() == MQueryOp::Exists) {
+ resultVector.push_back((currentValue.getLength() == 0) ? sal_False : sal_True);
+ } else if (evStr->getCond() == MQueryOp::DoesNotExist) {
+ resultVector.push_back((currentValue.getLength() == 0) ? sal_True : sal_False);
+ }
+ }
+ else if ( (*evIter)->isExpr() ) {
+ SAL_INFO("connectivity.mork", "Appending Subquery Expression");
+ MQueryExpression* queryExpression = static_cast<MQueryExpression*> (*evIter);
+ ::std::vector<sal_Bool> subquery_result = entryMatchedByExpression(_aQuery, queryExpression, entry);
+ MQueryExpression::bool_cond condition = queryExpression->getExpressionCondition();
+ if (condition == MQueryExpression::OR) {
+ sal_Bool result = sal_False;
+ for (::std::vector<sal_Bool>::iterator iter = subquery_result.begin(); iter != subquery_result.end(); ++iter) {
+ result = result || *iter;
+ }
+ resultVector.push_back(result);
+ } else if (condition == MQueryExpression::AND) {
+ sal_Bool result = sal_True;
+ for (::std::vector<sal_Bool>::iterator iter = subquery_result.begin(); iter != subquery_result.end(); ++iter) {
+ result = result && *iter;
+ }
+ resultVector.push_back(result);
+ } else {
+ OSL_FAIL("Unknown Expression Type");
+ }
+ }
+ else {
+ // Should never see this...
+ // OSL_FAIL("Unknown Expression Type!");
+ SAL_WARN("connectivity.mork", "Unknown Expression Type!");
+ return resultVector;
+ }
+ }
+ return resultVector;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MQueryHelper.hxx b/connectivity/source/drivers/mork/MQueryHelper.hxx
new file mode 100644
index 000000000000..4cc33f94ae00
--- /dev/null
+++ b/connectivity/source/drivers/mork/MQueryHelper.hxx
@@ -0,0 +1,215 @@
+/* -*- 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 _CONNECTIVITY_MORK_QUERYHELPER_HXX_
+#define _CONNECTIVITY_MORK_QUERYHELPER_HXX_
+
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+#include <comphelper/stl_types.hxx>
+#include <osl/thread.hxx>
+#include <connectivity/FValue.hxx>
+
+#include <boost/unordered_map.hpp>
+
+#include "MErrorResource.hxx"
+
+namespace connectivity
+{
+ namespace mork
+ {
+ class OConnection;
+ class MQueryHelper;
+ class ErrorDescriptor;
+
+ namespace MQueryOp {
+ typedef enum {
+ Exists = 0,
+ DoesNotExist = 1,
+ Contains = 2,
+ DoesNotContain = 3,
+ Is = 4,
+ IsNot = 5,
+ BeginsWith = 6,
+ EndsWith = 7,
+ SoundsLike = 8,
+ RegExp = 9
+ } cond_type;
+ }
+
+ class MQueryExpressionBase {
+ public:
+ typedef enum {
+ Unknown,
+ StringExpr,
+ Expr
+ } node_type;
+
+ protected:
+ node_type m_eNodeType;
+
+ MQueryExpressionBase() : m_eNodeType( Unknown ) {}
+ MQueryExpressionBase( node_type _eNodeType ) : m_eNodeType( _eNodeType ) {}
+
+ public:
+ sal_Bool isUnknown( ) const { return m_eNodeType == Unknown; }
+ sal_Bool isStringExpr( ) const { return m_eNodeType == StringExpr; }
+ sal_Bool isExpr( ) const { return m_eNodeType == Expr; }
+ };
+
+ class MQueryExpressionString : public MQueryExpressionBase {
+ protected:
+ ::rtl::OUString m_aName; // LHS
+ MQueryOp::cond_type m_aBooleanCondition;
+ ::rtl::OUString m_aValue; // RHS
+
+ public:
+
+ MQueryExpressionString( ::rtl::OUString& lhs,
+ MQueryOp::cond_type cond,
+ ::rtl::OUString rhs )
+ : MQueryExpressionBase( MQueryExpressionBase::StringExpr )
+ , m_aName( lhs )
+ , m_aBooleanCondition( cond )
+ , m_aValue( rhs )
+ {
+ }
+
+ MQueryExpressionString( ::rtl::OUString& lhs,
+ MQueryOp::cond_type cond )
+ : MQueryExpressionBase( MQueryExpressionBase::StringExpr )
+ , m_aName( lhs )
+ , m_aBooleanCondition( cond )
+ , m_aValue( ::rtl::OUString() )
+ {
+ }
+
+ const ::rtl::OUString& getName() const { return m_aName; }
+ MQueryOp::cond_type getCond() const { return m_aBooleanCondition; }
+ const ::rtl::OUString& getValue() const { return m_aValue; }
+ };
+
+ class MQueryExpression : public MQueryExpressionBase
+ {
+ friend class MQueryHelper;
+
+ public:
+ typedef ::std::vector< MQueryExpressionBase* > ExprVector;
+
+ typedef enum {
+ AND,
+ OR
+ } bool_cond;
+
+ void setExpressions( ExprVector& _exprVector )
+ { m_aExprVector = _exprVector; }
+
+ // All expressions on a peer level use same condition operator
+ void setExpressionCondition( bool_cond _cond )
+ { m_aExprCondType = _cond; }
+
+ ExprVector& getExpressions( )
+ { return m_aExprVector; }
+
+ // All expressions on a peer level use same condition operator
+ bool_cond getExpressionCondition( ) const
+ { return m_aExprCondType; }
+
+ MQueryExpression() : MQueryExpressionBase( MQueryExpressionBase::Expr ),
+ m_aExprCondType( OR )
+ { m_aExprVector.clear(); }
+
+
+ protected:
+ ExprVector m_aExprVector;
+ bool_cond m_aExprCondType;
+
+ };
+
+ class MQueryHelperResultEntry
+ {
+ private:
+ typedef ::boost::unordered_map< ::rtl::OString, ::rtl::OUString, ::rtl::OStringHash > FieldMap;
+
+ mutable ::osl::Mutex m_aMutex;
+ FieldMap m_Fields;
+
+ public:
+ MQueryHelperResultEntry();
+ ~MQueryHelperResultEntry();
+
+ void insert( const rtl::OString &key, rtl::OUString &value );
+ rtl::OUString getValue( const rtl::OString &key ) const;
+ void setValue( const rtl::OString &key, const rtl::OUString & rValue);
+ };
+
+ class MQueryHelper
+ {
+ private:
+ typedef std::vector< MQueryHelperResultEntry* > resultsArray;
+
+ mutable ::osl::Mutex m_aMutex;
+ ::osl::Condition m_aCondition;
+ resultsArray m_aResults;
+ sal_uInt32 m_nIndex;
+ sal_Bool m_bHasMore;
+ sal_Bool m_bAtEnd;
+ void append(MQueryHelperResultEntry* resEnt );
+ void clear_results();
+ OColumnAlias m_rColumnAlias;
+ ErrorDescriptor m_aError;
+ ::rtl::OUString m_aAddressbook;
+ MQueryExpression m_aExpr;
+
+/*
+ void clearResultOrComplete();
+ void notifyResultOrComplete();
+ sal_Bool waitForResultOrComplete( );
+ void getCardValues(nsIAbCard *card,sal_uInt32 rowIndex=0);
+*/
+
+ public:
+ MQueryHelper(const OColumnAlias& _ca);
+ virtual ~MQueryHelper();
+
+ void reset();
+ MQueryHelperResultEntry* next();
+ MQueryHelperResultEntry* getByIndex( sal_uInt32 nRow );
+ sal_Bool isError() const;
+ sal_Bool queryComplete() const;
+ sal_Int32 getResultCount() const;
+ sal_Bool checkRowAvailable( sal_Int32 nDBRow );
+ sal_Bool getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const rtl::OUString& aDBColumnName, sal_Int32 nType );
+ sal_Int32 executeQuery(OConnection* xConnection);
+ const OColumnAlias& getColumnAlias() const { return m_rColumnAlias; }
+ bool hadError() const { return m_aError.is(); }
+ inline const ErrorDescriptor& getError() const { return m_aError; }
+
+ void setAddressbook( ::rtl::OUString&);
+ void setExpression( MQueryExpression &_expr );
+
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MORK_QUERYHELPER_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MResultSet.cxx b/connectivity/source/drivers/mork/MResultSet.cxx
new file mode 100644
index 000000000000..45b478287ee8
--- /dev/null
+++ b/connectivity/source/drivers/mork/MResultSet.cxx
@@ -0,0 +1,2301 @@
+/* -*- 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 <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+
+#include <TSortIndex.hxx>
+#include <rtl/string.hxx>
+#include <vector>
+#include <algorithm>
+#include "MResultSet.hxx"
+#include "MResultSetMetaData.hxx"
+#include "FDatabaseMetaDataResultSet.hxx"
+
+#include "resource/mork_res.hrc"
+#include "resource/common_res.hrc"
+
+#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 ::comphelper;
+using namespace connectivity;
+using namespace connectivity::mork;
+using namespace ::cppu;
+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::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+//------------------------------------------------------------------------------
+// IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet");
+::rtl::OUString SAL_CALL OResultSet::getImplementationName( ) throw ( RuntimeException) \
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbcx.mork.ResultSet"));
+}
+// -------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames( ) throw( RuntimeException)
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.ResultSet"));
+ aSupported[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbcx.ResultSet"));
+ return aSupported;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+// -------------------------------------------------------------------------
+OResultSet::OResultSet(OCommonStatement* pStmt, const ::boost::shared_ptr< connectivity::OSQLParseTreeIterator >& _pSQLIterator )
+ : OResultSet_BASE(m_aMutex)
+ ,OPropertySetHelper(OResultSet_BASE::rBHelper)
+ ,m_pStatement(pStmt)
+ ,m_xStatement(*pStmt)
+ ,m_xMetaData(NULL)
+ ,m_nRowPos(0)
+ ,m_nOldRowPos(0)
+ ,m_nFetchSize(0)
+ ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE)
+ ,m_nFetchDirection(FetchDirection::FORWARD)
+ ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
+ ,m_pSQLIterator( _pSQLIterator )
+ ,m_pParseTree( _pSQLIterator->getParseTree() )
+ //,m_aQuery( pStmt->getOwnConnection()->getColumnAlias() )
+ ,m_aQueryHelper(pStmt->getOwnConnection()->getColumnAlias())
+ ,m_pTable(NULL)
+ ,m_CurrentRowCount(0)
+ ,m_nParamIndex(0)
+ ,m_bIsAlwaysFalseQuery(sal_False)
+ ,m_pKeySet(NULL)
+ ,m_nNewRow(0)
+ ,m_nUpdatedRow(0)
+ ,m_RowStates(0)
+ ,m_bIsReadOnly(-1)
+{
+
+ //m_aQuery.setMaxNrOfReturns(pStmt->getOwnConnection()->getMaxResultRecords());
+}
+// -------------------------------------------------------------------------
+OResultSet::~OResultSet()
+{
+}
+
+// -------------------------------------------------------------------------
+void OResultSet::disposing(void)
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_xStatement.clear();
+ m_xMetaData.clear();
+ m_pParseTree = NULL;
+ m_xColumns = NULL;
+ m_xParamColumns = NULL;
+ m_pKeySet = NULL;
+ if(m_pTable)
+ {
+ m_pTable->release();
+ m_pTable = NULL;
+ }
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OResultSet_BASE::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL OResultSet::getTypes( ) throw( RuntimeException)
+{
+ OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+void OResultSet::methodEntry()
+{
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ if ( !m_pTable )
+ {
+ OSL_FAIL( "OResultSet::methodEntry: looks like we're disposed, but how is this possible?" );
+ throw DisposedException( ::rtl::OUString(), *this );
+ }
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ // find the first column with the name columnName
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+ sal_Int32 i = 1;
+ for(;i<=nLen;++i)
+ if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
+ columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
+ break;
+ return i;
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ m_bWasNull = sal_True;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return Sequence< sal_Int8 >();
+}
+// -------------------------------------------------------------------------
+
+Date SAL_CALL OResultSet::getDate( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return Date();
+}
+// -------------------------------------------------------------------------
+
+double SAL_CALL OResultSet::getDouble( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return 0.0;
+}
+// -------------------------------------------------------------------------
+
+float SAL_CALL OResultSet::getFloat( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return 0;
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_TRACE("In/Out: OResultSet::getRow, return = %u", m_nRowPos );
+ return m_nRowPos;
+}
+// -------------------------------------------------------------------------
+
+sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return sal_Int64();
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new OResultSetMetaData(
+ m_pSQLIterator->getSelectColumns(), m_pSQLIterator->getTables().begin()->first ,m_pTable,determineReadOnly());
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OResultSet::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+// -------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+void OResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
+{
+ if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->get().size())
+ ::dbtools::throwInvalidIndexException(*this);
+}
+// -------------------------------------------------------------------------
+sal_uInt32 OResultSet::currentRowCount()
+{
+ if ( m_bIsAlwaysFalseQuery )
+ return 0;
+ //return 0;//m_aQuery.getRealRowCount() - deletedCount();
+ // new implementation
+ return m_aQueryHelper.getResultCount();
+}
+
+// -------------------------------------------------------------------------
+
+sal_Bool OResultSet::fetchCurrentRow( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("fetchCurrentRow, m_nRowPos = %u", m_nRowPos );
+ return fetchRow(getCurrentCardNumber());
+}
+
+// -------------------------------------------------------------------------
+sal_Bool OResultSet::pushCard(sal_uInt32 /*cardNumber*/) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OResultSet::pushCard()" );
+ return sal_True;
+/*
+ if (cardNumber == 0)
+ return sal_True;
+ // Check whether we are storing the updated row
+ if ( (m_aRow->get())[0].isNull() || (sal_Int32)(m_aRow->get())[0] != (sal_Int32)cardNumber )
+ return sal_False;
+
+ sal_Int32 nCount = m_aColumnNames.getLength();
+ m_aQuery.setRowStates(cardNumber,m_RowStates);
+ for( sal_Int32 i = 1; i <= nCount; i++ )
+ {
+ if ( (m_aRow->get())[i].isBound() )
+ {
+ //
+ // Everything in the addressbook is a string!
+ //
+ if ( !m_aQuery.setRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR ))
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this );
+ }
+ }
+ }
+ return sal_True;
+*/
+}
+// -------------------------------------------------------------------------
+sal_Bool OResultSet::fetchRow(sal_Int32 cardNumber,sal_Bool bForceReload) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OResultSet::fetchRow()" );
+
+ OSL_TRACE("fetchRow, cardNumber = %u", cardNumber );
+ if (!bForceReload)
+ {
+ // Check whether we've already fetched the row...
+ if ( !(m_aRow->get())[0].isNull() && (sal_Int32)(m_aRow->get())[0] == (sal_Int32)cardNumber )
+ return sal_True;
+ //Check whether the old row has been changed
+ if (cardNumber == m_nUpdatedRow)
+ {
+ //write back the changes first
+ if (!pushCard(cardNumber)) //error write back the changes
+ throw SQLException();
+ }
+ }
+// else
+// m_aQuery.resyncRow(cardNumber);
+
+ if ( validRow( cardNumber ) == sal_False )
+ return sal_False;
+
+ (m_aRow->get())[0] = (sal_Int32)cardNumber;
+ sal_Int32 nCount = m_aColumnNames.getLength();
+ //m_RowStates = m_aQuery.getRowStates(cardNumber);
+ for( sal_Int32 i = 1; i <= nCount; i++ )
+ {
+ if ( (m_aRow->get())[i].isBound() )
+ {
+ //
+ // Everything in the addressbook is a string!
+ //
+ if ( !m_aQueryHelper.getRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR ))
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQueryHelper.getError(), *this );
+ }
+ }
+ }
+ return sal_True;
+
+}
+// -------------------------------------------------------------------------
+
+const ORowSetValue& OResultSet::getValue(sal_Int32 cardNumber, sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ if ( fetchRow( cardNumber ) == sal_False )
+ {
+ OSL_FAIL("fetchRow() returned False" );
+ m_bWasNull = sal_True;
+ return *ODatabaseMetaDataResultSet::getEmptyValue();
+ }
+
+ m_bWasNull = (m_aRow->get())[columnIndex].isNull();
+ return (m_aRow->get())[columnIndex];
+
+}
+// -------------------------------------------------------------------------
+
+
+::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_ENSURE(m_xColumns.is(), "Need the Columns!!");
+ OSL_ENSURE(columnIndex <= (sal_Int32)m_xColumns->get().size(), "Trying to access invalid columns number");
+ checkIndex( columnIndex );
+
+ // If this query was sorted then we should have a valid KeySet, so use it
+ return getValue(getCurrentCardNumber(), mapColumn( columnIndex ) );
+
+}
+// -------------------------------------------------------------------------
+
+Time SAL_CALL OResultSet::getTime( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return Time();
+}
+// -------------------------------------------------------------------------
+
+
+DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return DateTime();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ // here you have to implement your movements
+ // return true means there is no data
+ OSL_TRACE("In/Out: OResultSet::isBeforeFirst" );
+ return( m_nRowPos < 1 );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ SAL_WARN("connectivity.mork", "OResultSet::isAfterLast() NOT IMPLEMENTED!");
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_TRACE("In/Out: OResultSet::isAfterLast" );
+// return sal_True;
+ return m_nRowPos > currentRowCount() && m_aQueryHelper.queryComplete();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_TRACE("In/Out: OResultSet::isFirst" );
+ return m_nRowPos == 1;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ SAL_WARN("connectivity.mork", "OResultSet::isLast() NOT IMPLEMENTED!");
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_TRACE("In/Out: OResultSet::isLast" );
+// return sal_True;
+ return m_nRowPos == currentRowCount() && m_aQueryHelper.queryComplete();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ // move before the first row so that isBeforeFirst returns false
+ OSL_TRACE("In/Out: OResultSet::beforeFirst" );
+ if ( first() )
+ previous();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::afterLast" );
+
+ if(last())
+ next();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::close() throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::close" );
+ OSL_FAIL( "OResultSet::close: going to dispose()" );
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::first" );
+ return seekRow( FIRST_POS );
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::last" );
+ return seekRow( LAST_POS );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::absolute" );
+ return seekRow( ABSOLUTE_POS, row );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::relative" );
+ return seekRow( RELATIVE_POS, row );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::previous" );
+ return seekRow( PRIOR_POS );
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_TRACE("In/Out: OResultSet::getStatement" );
+ return m_xStatement;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ SAL_WARN("connectivity.mork", "OResultSet::rowDeleted() NOT IMPLEMENTED!");
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::rowDeleted, m_RowStates=%u",m_RowStates );
+ return sal_True;//return ((m_RowStates & RowStates_Deleted) == RowStates_Deleted) ;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException)
+{
+ SAL_WARN("connectivity.mork", "OResultSet::rowInserted() NOT IMPLEMENTED!");
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::rowInserted,m_RowStates=%u",m_RowStates );
+ return sal_True;//return ((m_RowStates & RowStates_Inserted) == RowStates_Inserted);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ SAL_WARN("connectivity.mork", "OResultSet::rowUpdated() NOT IMPLEMENTED!");
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::rowUpdated,m_RowStates=%u",m_RowStates );
+ return sal_True;// return ((m_RowStates & RowStates_Updated) == RowStates_Updated) ;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ return seekRow( NEXT_POS );
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ return m_bWasNull;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::cancel( ) throw(RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::cancel" );
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::clearWarnings" );
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::getWarnings" );
+ return Any();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::refreshRow" );
+ if (fetchRow(getCurrentCardNumber(),sal_True)) {
+ //force fetch current row will cause we lose all change to the current row
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_REFRESH_ROW, *this );
+ }
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
+{
+ Sequence< Property > aProps(5);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP0(FETCHDIRECTION, sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY);
+
+ return new OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper & OResultSet::getInfoHelper()
+{
+ return *const_cast<OResultSet*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool OResultSet::convertFastPropertyValue(
+ Any & /*rConvertedValue*/,
+ Any & /*rOldValue*/,
+ sal_Int32 nHandle,
+ const Any& /*rValue*/ )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ OSL_FAIL( "OResultSet::convertFastPropertyValue: not implemented!" );
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ default:
+ ;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void OResultSet::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const Any& /*rValue*/
+ )
+ throw (Exception)
+{
+ OSL_FAIL( "OResultSet::setFastPropertyValue_NoBroadcast: not implemented!" );
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw Exception();
+ case PROPERTY_ID_FETCHDIRECTION:
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ break;
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void OResultSet::getFastPropertyValue(
+ Any& rValue,
+ sal_Int32 nHandle
+ ) const
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ rValue <<= (sal_Int32)m_nResultSetConcurrency;
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ rValue <<= m_nResultSetType;
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ rValue <<= m_nFetchDirection;
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ rValue <<= m_nFetchSize;
+ break;
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ const_cast< OResultSet* >( this )->determineReadOnly();
+ rValue <<= !m_bIsReadOnly;
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::acquire() throw()
+{
+ OResultSet_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::release() throw()
+{
+ OResultSet_BASE::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+
+// -------------------------------------------------------------------------
+void OResultSet::parseParameter( const OSQLParseNode* pNode, rtl::OUString& rMatchString )
+{
+ OSL_ENSURE(pNode->count() > 0,"Error parsing parameter in Parse Tree");
+ OSQLParseNode *pMark = pNode->getChild(0);
+
+ // Initialize to empty string
+ rMatchString = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(""));
+
+ rtl::OUString aParameterName;
+ if (SQL_ISPUNCTUATION(pMark,"?")) {
+ aParameterName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("?"));
+ }
+ else if (SQL_ISPUNCTUATION(pMark,":")) {
+ aParameterName = pNode->getChild(1)->getTokenValue();
+ }
+ // XXX - Now we know name, what's value????
+ m_nParamIndex ++;
+ OSL_TRACE("Parameter name [%d]: %s", m_nParamIndex,OUtoCStr(aParameterName) );
+
+ if ( m_aParameterRow.is() ) {
+ OSL_ENSURE( m_nParamIndex < (sal_Int32)m_aParameterRow->get().size() + 1, "More parameters than values found" );
+ rMatchString = (m_aParameterRow->get())[(sal_uInt16)m_nParamIndex];
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("Prop Value : %s", OUtoCStr( rMatchString ) );
+#endif
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else {
+ OSL_TRACE("Prop Value : Invalid ParameterRow!" );
+ }
+#endif
+}
+
+void OResultSet::analyseWhereClause( const OSQLParseNode* parseTree,
+ MQueryExpression &queryExpression)
+{
+ ::rtl::OUString columnName;
+ MQueryOp::cond_type op( MQueryOp::Is );
+ ::rtl::OUString matchString;
+
+ if ( parseTree == NULL )
+ return;
+
+ if ( m_pSQLIterator->getParseTree() != NULL ) {
+ ::rtl::Reference<OSQLColumns> xColumns = m_pSQLIterator->getParameters();
+ if(xColumns.is())
+ {
+ ::rtl::OUString aColName, aParameterValue;
+ OSQLColumns::Vector::iterator aIter = xColumns->get().begin();
+ sal_Int32 i = 1;
+ for(;aIter != xColumns->get().end();++aIter)
+ {
+ (*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
+ OSL_TRACE("Prop Column Name : %s", OUtoCStr( aColName ) );
+ if ( m_aParameterRow.is() ) {
+ aParameterValue = (m_aParameterRow->get())[(sal_uInt16)i];
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("Prop Value : %s", OUtoCStr( aParameterValue ) );
+#endif
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else {
+ OSL_TRACE("Prop Value : Invalid ParameterRow!" );
+ }
+#endif
+ i++;
+ }
+ }
+
+ }
+
+ if ( SQL_ISRULE(parseTree,where_clause) )
+ {
+ OSL_TRACE("analyseSQL : Got WHERE clause");
+ // Reset Parameter Counter
+ resetParameters();
+ analyseWhereClause( parseTree->getChild( 1 ), queryExpression );
+ }
+ else if ( parseTree->count() == 3 && // Handle ()'s
+ SQL_ISPUNCTUATION(parseTree->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(parseTree->getChild(2),")"))
+ {
+
+ OSL_TRACE("analyseSQL : Got Punctuation ()");
+ MQueryExpression *subExpression = new MQueryExpression();
+ analyseWhereClause( parseTree->getChild( 1 ), *subExpression );
+ queryExpression.getExpressions().push_back( subExpression );
+ }
+ else if ((SQL_ISRULE(parseTree,search_condition) || (SQL_ISRULE(parseTree,boolean_term)))
+ && parseTree->count() == 3) // Handle AND/OR
+ {
+
+ OSL_TRACE("analyseSQL : Got AND/OR clause");
+
+ // TODO - Need to take care or AND, for now match is always OR
+ analyseWhereClause( parseTree->getChild( 0 ), queryExpression );
+ analyseWhereClause( parseTree->getChild( 2 ), queryExpression );
+
+ if (SQL_ISTOKEN(parseTree->getChild(1),OR)) { // OR-Operator
+ queryExpression.setExpressionCondition( MQueryExpression::OR );
+ }
+ else if (SQL_ISTOKEN(parseTree->getChild(1),AND)) { // AND-Operator
+ queryExpression.setExpressionCondition( MQueryExpression::AND );
+ }
+ else {
+ OSL_FAIL("analyseSQL: Error in Parse Tree");
+ }
+ }
+ else if (SQL_ISRULE(parseTree,comparison_predicate))
+ {
+ OSL_ENSURE(parseTree->count() == 3, "Error parsing COMPARE predicate");
+ if (!(SQL_ISRULE(parseTree->getChild(0),column_ref) ||
+ parseTree->getChild(2)->getNodeType() == SQL_NODE_STRING ||
+ parseTree->getChild(2)->getNodeType() == SQL_NODE_INTNUM ||
+ parseTree->getChild(2)->getNodeType() == SQL_NODE_APPROXNUM ||
+ SQL_ISTOKEN(parseTree->getChild(2),TRUE) ||
+ SQL_ISTOKEN(parseTree->getChild(2),FALSE) ||
+ SQL_ISRULE(parseTree->getChild(2),parameter) ||
+ // odbc date
+ (SQL_ISRULE(parseTree->getChild(2),set_fct_spec) && SQL_ISPUNCTUATION(parseTree->getChild(2)->getChild(0),"{"))))
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
+ }
+
+ OSQLParseNode *pPrec = parseTree->getChild(1);
+ if (pPrec->getNodeType() == SQL_NODE_EQUAL)
+ op = MQueryOp::Is;
+ else if (pPrec->getNodeType() == SQL_NODE_NOTEQUAL)
+ op = MQueryOp::IsNot;
+
+ ::rtl::OUString sTableRange;
+ if(SQL_ISRULE(parseTree->getChild(0),column_ref))
+ m_pSQLIterator->getColumnRange(parseTree->getChild(0),columnName,sTableRange);
+ else if(parseTree->getChild(0)->isToken())
+ columnName = parseTree->getChild(0)->getTokenValue();
+
+ if ( SQL_ISRULE(parseTree->getChild(2),parameter) ) {
+ parseParameter( parseTree->getChild(2), matchString );
+ }
+ else {
+ matchString = parseTree->getChild(2)->getTokenValue();
+ }
+
+ if ( columnName.compareToAscii("0") ==0 && op == MQueryOp::Is &&
+ matchString.compareToAscii("1") == 0 ) {
+ OSL_TRACE("Query always evaluates to FALSE");
+ m_bIsAlwaysFalseQuery = sal_True;
+ }
+ queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op, matchString ));
+ }
+ else if (SQL_ISRULE(parseTree,like_predicate))
+ {
+ OSL_ENSURE(parseTree->count() == 2, "Error parsing LIKE predicate");
+
+ OSL_TRACE("analyseSQL : Got LIKE rule");
+
+ if ( !(SQL_ISRULE(parseTree->getChild(0), column_ref)) )
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_COLUMN, *this );
+ }
+
+
+ OSQLParseNode *pColumn;
+ OSQLParseNode *pAtom;
+ OSQLParseNode *pOptEscape;
+ const OSQLParseNode* pPart2 = parseTree->getChild(1);
+ pColumn = parseTree->getChild(0); // Match Item
+ pAtom = pPart2->getChild(static_cast<sal_uInt32>(pPart2->count()-2)); // Match String
+ pOptEscape = pPart2->getChild(static_cast<sal_uInt32>(pPart2->count()-1)); // Opt Escape Rule
+ (void)pOptEscape;
+ const bool bNot = SQL_ISTOKEN(pPart2->getChild(0), NOT);
+
+ if (!(pAtom->getNodeType() == SQL_NODE_STRING ||
+ pAtom->getNodeType() == SQL_NODE_NAME ||
+ SQL_ISRULE(pAtom,parameter) ||
+ ( pAtom->getChild(0) && pAtom->getChild(0)->getNodeType() == SQL_NODE_NAME ) ||
+ ( pAtom->getChild(0) && pAtom->getChild(0)->getNodeType() == SQL_NODE_STRING )
+ ) )
+ {
+ OSL_TRACE("analyseSQL : pAtom->count() = %d", pAtom->count() );
+
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_STRING, *this );
+ }
+
+ const sal_Unicode WILDCARD = '%';
+ const sal_Unicode ALT_WILDCARD = '*';
+ const sal_Unicode MATCHCHAR = '_';
+
+ ::rtl::OUString sTableRange;
+ if(SQL_ISRULE(pColumn,column_ref))
+ m_pSQLIterator->getColumnRange(pColumn,columnName,sTableRange);
+
+ OSL_TRACE("ColumnName = %s", OUtoCStr( columnName ) );
+
+ if ( SQL_ISRULE(pAtom,parameter) ) {
+ parseParameter( pAtom, matchString );
+ // Replace all '*' with '%' : UI Usually does this but not with
+ // Parameters for some reason.
+ matchString = matchString.replace( ALT_WILDCARD, WILDCARD );
+ }
+ else
+ {
+ matchString = pAtom->getTokenValue();
+ }
+
+ // Determine where '%' character is...
+
+ if ( matchString.equals( ::rtl::OUString::valueOf( WILDCARD ) ) )
+ {
+ // String containing only a '%' and nothing else
+ op = MQueryOp::Exists;
+ // Will be ignored for Exists case, but clear anyway.
+ matchString = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(""));
+ }
+ else if ( matchString.indexOf ( WILDCARD ) == -1 &&
+ matchString.indexOf ( MATCHCHAR ) == -1 )
+ {
+ // Simple string , eg. "to match"
+ if ( bNot )
+ op = MQueryOp::DoesNotContain;
+ else
+ op = MQueryOp::Contains;
+ }
+ else if ( matchString.indexOf ( WILDCARD ) == 0
+ && matchString.lastIndexOf ( WILDCARD ) == matchString.getLength() -1
+ && matchString.indexOf ( WILDCARD, 1 ) == matchString.lastIndexOf ( WILDCARD )
+ && matchString.indexOf( MATCHCHAR ) == -1
+ )
+ {
+ // Relatively simple "%string%" - ie, contains...
+ // Cut '%' from front and rear
+ matchString = matchString.replaceAt( 0, 1, rtl::OUString() );
+ matchString = matchString.replaceAt( matchString.getLength() -1 , 1, rtl::OUString() );
+
+ if (bNot)
+ op = MQueryOp::DoesNotContain;
+ else
+ op = MQueryOp::Contains;
+ }
+ else if ( bNot )
+ {
+ // We currently can't handle a 'NOT LIKE' when there are '%' or
+ // '_' dispersed throughout
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_NOT_LIKE_TOO_COMPLEX, *this );
+ }
+ else
+ {
+ if ( (matchString.indexOf ( WILDCARD ) == matchString.lastIndexOf ( WILDCARD ))
+ && matchString.indexOf( MATCHCHAR ) == -1
+ )
+ {
+ // One occurrence of '%' - no '_' matches...
+ if ( matchString.indexOf ( WILDCARD ) == 0 )
+ {
+ op = MQueryOp::EndsWith;
+ matchString = matchString.replaceAt( 0, 1, rtl::OUString());
+ }
+ else if ( matchString.indexOf ( WILDCARD ) == matchString.getLength() -1 )
+ {
+ op = MQueryOp::BeginsWith;
+ matchString = matchString.replaceAt( matchString.getLength() -1 , 1, rtl::OUString() );
+ }
+ else
+ {
+ sal_Int32 pos = matchString.indexOf ( WILDCARD );
+ matchString = matchString.replaceAt( pos, 1,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".*")) );
+ op = MQueryOp::RegExp;
+ }
+
+ }
+ else
+ {
+ // Most Complex, need to use an RE
+ sal_Int32 pos = matchString.indexOf ( WILDCARD );
+ while ( (pos = matchString.indexOf ( WILDCARD )) != -1 )
+ {
+ matchString = matchString.replaceAt( pos, 1, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".*")) );
+ }
+
+ pos = matchString.indexOf ( MATCHCHAR );
+ while ( (pos = matchString.indexOf( MATCHCHAR )) != -1 )
+ {
+ matchString = matchString.replaceAt( pos, 1, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".")) );
+ }
+
+ op = MQueryOp::RegExp;
+ }
+ }
+
+ queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op, matchString ));
+ }
+ else if (SQL_ISRULE(parseTree,test_for_null))
+ {
+ OSL_ENSURE(parseTree->count() == 2,"Error in ParseTree");
+ const OSQLParseNode* pPart2 = parseTree->getChild(1);
+ OSL_ENSURE(SQL_ISTOKEN(pPart2->getChild(0),IS),"Error in ParseTree");
+
+ if (!SQL_ISRULE(parseTree->getChild(0),column_ref))
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_IS_NULL_COLUMN, *this );
+ }
+
+ if (SQL_ISTOKEN(pPart2->getChild(1),NOT))
+ {
+ op = MQueryOp::Exists;
+ }
+ else
+ op = MQueryOp::DoesNotExist;
+
+ ::rtl::OUString sTableRange;
+ m_pSQLIterator->getColumnRange(parseTree->getChild(0),columnName,sTableRange);
+
+ queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op ));
+ }
+ else
+ {
+ OSL_TRACE( "Unexpected statement!!!" );
+
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OResultSet::fillRowData()
+ throw( ::com::sun::star::sdbc::SQLException )
+{
+ OSL_ENSURE( m_pStatement, "Require a statement" );
+
+ MQueryExpression queryExpression;
+
+ OConnection* xConnection = static_cast<OConnection*>(m_pStatement->getConnection().get());
+ m_xColumns = m_pSQLIterator->getSelectColumns();
+
+ OSL_ENSURE(m_xColumns.is(), "Need the Columns!!");
+
+ OSQLColumns::Vector::const_iterator aIter = m_xColumns->get().begin();
+ const ::rtl::OUString sProprtyName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
+ ::rtl::OUString sName;
+ m_aAttributeStrings.clear();
+ m_aAttributeStrings.reserve(m_xColumns->get().size());
+ for (sal_Int32 i = 1; aIter != m_xColumns->get().end();++aIter, i++)
+ {
+ (*aIter)->getPropertyValue(sProprtyName) >>= sName;
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("Query Columns : (%d) %s", i, OUtoCStr(sName) );
+#endif
+ m_aAttributeStrings.push_back( sName );
+ }
+
+ // Generate Match Conditions for Query
+ const OSQLParseNode* pParseTree = m_pSQLIterator->getWhereTree();
+
+ m_bIsAlwaysFalseQuery = sal_False;
+ if ( pParseTree != NULL )
+ {
+ // Extract required info
+
+ OSL_TRACE("\tHave a Where Clause");
+
+ analyseWhereClause( pParseTree, queryExpression );
+ }
+#if 0
+ else
+ {
+ OSL_TRACE("\tDon't have a Where Clause");
+
+ MQueryExpression::ExprVector eVector;
+
+ // LDAP does not allow a query without restriction, so we add a dummy
+ // for PrimaryEmail
+ // For other types we stick to the old behaviour of using
+ // card:nsIAbCard.
+ OSL_ENSURE(m_pStatement, "Cannot determine Parent Statement");
+ ::rtl::OUString aStr;
+ if (xConnection->isLDAP())
+ aStr = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrimaryEmail"));
+ else
+ aStr = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("card:nsIAbCard"));
+ eVector.push_back( new MQueryExpressionString(aStr, MQueryOp::Exists) );
+
+ queryExpression.setExpressions( eVector );
+ }
+#endif
+
+ // If the query is a 0=1 then set Row count to 0 and return
+ if ( m_bIsAlwaysFalseQuery )
+ {
+ m_bIsReadOnly = 1;
+ return;
+ }
+
+ m_aQueryHelper.setExpression( queryExpression );
+
+ rtl::OUString aStr( m_pTable->getName() );
+ m_aQueryHelper.setAddressbook( aStr );
+
+ sal_Int32 rv = m_aQueryHelper.executeQuery(xConnection);
+ if ( rv == -1 ) {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERR_EXECUTING_QUERY, *this );
+ }
+ //determine whether the address book is readonly
+ determineReadOnly();
+
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE( "executeQuery returned %d", rv );
+
+ OSL_TRACE( "\tOUT OResultSet::fillRowData()" );
+#endif
+}
+
+#if 0
+// -----------------------------------------------------------------------------
+void OResultSet::fillRowData()
+ throw( ::com::sun::star::sdbc::SQLException )
+{
+ SAL_INFO("connectivity.mork", "=> OResultSet::fillRowData()" );
+ OSL_ENSURE( m_pStatement, "Require a statement" );
+
+ m_xColumns = m_pSQLIterator->getSelectColumns();
+
+ OSL_ENSURE(m_xColumns.is(), "Need the Columns!!");
+
+ OConnection* xConnection = static_cast<OConnection*>(m_pStatement->getConnection().get());
+ sal_Int32 rv = m_aQueryHelper.executeQuery(xConnection);
+
+ if (rv == -1)
+ {
+ OSL_FAIL( "Error in executeQuery!" );
+ }
+
+ MQueryExpression queryExpression;
+
+ OSQLColumns::Vector::const_iterator aIter = m_xColumns->get().begin();
+ const ::rtl::OUString sProprtyName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
+ ::rtl::OUString sName;
+ m_aAttributeStrings.clear();
+ m_aAttributeStrings.reserve(m_xColumns->get().size());
+ for (sal_Int32 i = 1; aIter != m_xColumns->get().end();++aIter, i++)
+ {
+ (*aIter)->getPropertyValue(sProprtyName) >>= sName;
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("Query Columns : (%d) %s", i, OUtoCStr(sName) );
+#endif
+ m_aAttributeStrings.push_back( sName );
+ }
+
+
+ // Generate Match Conditions for Query
+ const OSQLParseNode* pParseTree = m_pSQLIterator->getWhereTree();
+
+ // const OSQLParseNode* pParseTree = NULL;
+
+ m_bIsAlwaysFalseQuery = sal_False;
+ if ( pParseTree != NULL )
+ {
+ // Extract required info
+
+ OSL_TRACE("\tHave a Where Clause");
+
+ analyseWhereClause( pParseTree, queryExpression );
+ }
+#if 0
+ else
+ {
+ OSL_TRACE("\tDon't have a Where Clause");
+
+ MQueryExpression::ExprVector eVector;
+
+ // LDAP does not allow a query without restriction, so we add a dummy
+ // for PrimaryEmail
+ // For other types we stick to the old behaviour of using
+ // card:nsIAbCard.
+ OSL_ENSURE(m_pStatement, "Cannot determine Parent Statement");
+ ::rtl::OUString aStr;
+ if (xConnection->isLDAP())
+ aStr = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrimaryEmail"));
+ else
+ aStr = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("card:nsIAbCard"));
+ eVector.push_back( new MQueryExpressionString(aStr, MQueryOp::Exists) );
+
+ queryExpression.setExpressions( eVector );
+ }
+#endif
+
+ // If the query is a 0=1 then set Row count to 0 and return
+ if ( m_bIsAlwaysFalseQuery )
+ {
+ m_bIsReadOnly = 1;
+ return;
+ }
+
+ m_aQueryHelper.setExpression( queryExpression );
+
+ rtl::OUString aStr( m_pTable->getName() );
+ m_aQueryHelper.setAddressbook( aStr );
+
+ sal_Int32 rv = m_aQueryHelper.executeQuery(xConnection);
+ if ( rv == -1 ) {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERR_EXECUTING_QUERY, *this );
+ }
+ //determine whether the address book is readonly
+ determineReadOnly();
+
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE( "executeQuery returned %d", rv );
+
+ OSL_TRACE( "\tOUT OResultSet::fillRowData()" );
+#endif
+
+}
+#endif
+
+// -----------------------------------------------------------------------------
+static sal_Bool matchRow( OValueRow& row1, OValueRow& row2 )
+{
+ OValueVector::Vector::iterator row1Iter = row1->get().begin();
+ OValueVector::Vector::iterator row2Iter = row2->get().begin();
+ for ( ++row1Iter,++row2Iter; // the first column is the bookmark column
+ row1Iter != row1->get().end(); ++row1Iter,++row2Iter)
+ {
+ if ( row1Iter->isBound())
+ {
+ // Compare values, if at anytime there's a mismatch return false
+ if ( !( (*row1Iter) == (*row2Iter) ) )
+ return sal_False;
+ }
+ }
+
+ // If we get to here the rows match
+ return sal_True;
+}
+
+sal_Int32 OResultSet::getRowForCardNumber(sal_Int32 nCardNum)
+{
+ OSL_TRACE("In/Out: OResultSet::getRowForCardNumber, nCardNum = %u", nCardNum );
+
+ if ( m_pKeySet.is() )
+ {
+ sal_Int32 nPos;
+ for(nPos=0;nPos < (sal_Int32)m_pKeySet->get().size();nPos++)
+ {
+ if (nCardNum == (m_pKeySet->get())[nPos])
+ {
+ OSL_TRACE("In/Out: OResultSet::getRowForCardNumber, return = %u", nPos+1 );
+ return nPos+1;
+ }
+ }
+ }
+
+ m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK, *this );
+
+ return 0;
+}
+
+#if 0
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OResultSet::executeQuery()" );
+
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_ENSURE( m_pTable, "Need a Table object");
+ if(!m_pTable)
+ {
+ const OSQLTables& xTabs = m_pSQLIterator->getTables();
+ if ((xTabs.begin() == xTabs.end()) || !xTabs.begin()->second.is()) {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
+ }
+
+ m_pTable = static_cast< OTable* > ((xTabs.begin()->second).get());
+
+ }
+
+ m_nRowPos = 0;
+
+ fillRowData();
+
+ m_pKeySet = new OKeySet();
+ m_pSortIndex = new OSortIndex(SQL_ORDERBYKEY_DOUBLE, m_aOrderbyAscending);
+ m_pKeySet = m_pSortIndex->CreateKeySet();
+
+ OSL_ENSURE(m_xColumns.is(), "Need the Columns!!");
+
+ switch( m_pSQLIterator->getStatementType() )
+ {
+ case SQL_STATEMENT_SELECT:
+ {
+ if(m_bIsAlwaysFalseQuery) {
+ break;
+ }
+ else if(isCount())
+ {
+ OSL_FAIL( "STR_NO_COUNT_SUPPORT!" );
+ m_pStatement->getOwnConnection()->throwSQLException( STR_NO_COUNT_SUPPORT, *this );
+ }
+ else
+ {
+ sal_Bool bDistinct = sal_False;
+ OSQLParseNode *pDistinct = m_pParseTree->getChild(1);
+ if (pDistinct && pDistinct->getTokenID() == SQL_TOKEN_DISTINCT)
+ {
+ if(!IsSorted())
+ {
+ m_aOrderbyColumnNumber.push_back(m_aColMapping[1]);
+ m_aOrderbyAscending.push_back(SQL_DESC);
+ }
+ bDistinct = sal_True;
+ }
+
+ OSortIndex::TKeyTypeVector eKeyType(m_aOrderbyColumnNumber.size());
+ ::std::vector<sal_Int32>::iterator aOrderByIter = m_aOrderbyColumnNumber.begin();
+ for ( ::std::vector<sal_Int16>::size_type i = 0; aOrderByIter != m_aOrderbyColumnNumber.end(); ++aOrderByIter,++i)
+ {
+ OSL_ENSURE((sal_Int32)m_aRow->get().size() > *aOrderByIter,"Invalid Index");
+ switch ((m_aRow->get().begin()+*aOrderByIter)->getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ eKeyType[i] = SQL_ORDERBYKEY_STRING;
+ break;
+
+ case DataType::OTHER:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ case DataType::BIT:
+ eKeyType[i] = SQL_ORDERBYKEY_DOUBLE;
+ break;
+
+ // Other types aren't implemented (so they are always FALSE)
+ default:
+ eKeyType[i] = SQL_ORDERBYKEY_NONE;
+ OSL_FAIL("MResultSet::executeQuery: Order By Data Type not implemented");
+ break;
+ }
+ }
+
+ if (IsSorted())
+ {
+ // Implement Sorting
+
+ // So that we can sort we need to wait until the executed
+ // query to the mozilla addressbooks has returned all
+ // values.
+
+ OSL_TRACE("Query is to be sorted");
+ if( ! m_aQueryHelper.queryComplete() )
+ if ( !m_aQueryHelper.waitForQueryComplete() )
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQueryHelper.getError(), *this );
+ }
+
+ OSL_ENSURE( m_aQueryHelper.queryComplete(), "Query not complete!!");
+
+ m_pSortIndex = new OSortIndex(eKeyType,m_aOrderbyAscending);
+
+ OSL_TRACE("OrderbyColumnNumber->size() = %d",m_aOrderbyColumnNumber.size());
+#if OSL_DEBUG_LEVEL > 0
+ for ( ::std::vector<sal_Int32>::size_type i = 0; i < m_aColMapping.size(); i++ )
+ OSL_TRACE("Mapped: %d -> %d", i, m_aColMapping[i] );
+#endif
+ for ( sal_Int32 nRow = 1; nRow <= m_aQueryHelper.getRowCount(); nRow++ ) {
+
+ OKeyValue* pKeyValue = OKeyValue::createKeyValue((nRow));
+
+ ::std::vector<sal_Int32>::iterator aIter = m_aOrderbyColumnNumber.begin();
+ for (;aIter != m_aOrderbyColumnNumber.end(); ++aIter)
+ {
+ const ORowSetValue& value = getValue(nRow, *aIter);
+
+ OSL_TRACE( "Adding Value: (%d,%d) : %s", nRow, *aIter,OUtoCStr( value ));
+
+ pKeyValue->pushKey(new ORowSetValueDecorator(value));
+ }
+
+ m_pSortIndex->AddKeyValue( pKeyValue );
+ }
+
+ m_pKeySet = m_pSortIndex->CreateKeySet();
+ m_CurrentRowCount = static_cast<sal_Int32>(m_pKeySet->get().size());
+#if OSL_DEBUG_LEVEL > 0
+ for( OKeySet::Vector::size_type i = 0; i < m_pKeySet->get().size(); i++ )
+ OSL_TRACE("Sorted: %d -> %d", i, (m_pKeySet->get())[i] );
+#endif
+
+ m_pSortIndex = NULL;
+ beforeFirst(); // Go back to start
+ }
+ else //we always need m_pKeySet now
+ m_pKeySet = new OKeySet();
+
+ // Handle the DISTINCT case
+ if ( bDistinct && m_pKeySet.is() )
+ {
+ OValueRow aSearchRow = new OValueVector( m_aRow->get().size() );
+
+ for( OKeySet::Vector::size_type i = 0; i < m_pKeySet->get().size(); i++ )
+ {
+ fetchRow( (m_pKeySet->get())[i] ); // Fills m_aRow
+ if ( matchRow( m_aRow, aSearchRow ) )
+ {
+ (m_pKeySet->get())[i] = 0; // Marker for later to be removed
+ }
+ else
+ {
+ // They don't match, so it's not a duplicate.
+ // Use the current Row as the next one to match against
+ *aSearchRow = *m_aRow;
+ }
+ }
+ // Now remove any keys marked with a 0
+ m_pKeySet->get().erase(::std::remove_if(m_pKeySet->get().begin(),m_pKeySet->get().end()
+ ,::std::bind2nd(::std::equal_to<sal_Int32>(),0))
+ ,m_pKeySet->get().end());
+
+ }
+ }
+ } break;
+
+ case SQL_STATEMENT_UPDATE:
+ case SQL_STATEMENT_DELETE:
+ case SQL_STATEMENT_INSERT:
+ break;
+ default:
+ m_pStatement->getOwnConnection()->throwSQLException( STR_STMT_TYPE_NOT_SUPPORTED, *this );
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
+#endif
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_ENSURE( m_pTable, "Need a Table object");
+ if(!m_pTable)
+ {
+ const OSQLTables& xTabs = m_pSQLIterator->getTables();
+ if ((xTabs.begin() == xTabs.end()) || !xTabs.begin()->second.is())
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
+
+ m_pTable = static_cast< OTable* > ((xTabs.begin()->second).get());
+
+ }
+
+ m_nRowPos = 0;
+
+ fillRowData();
+
+ OSL_ENSURE(m_xColumns.is(), "Need the Columns!!");
+
+ switch( m_pSQLIterator->getStatementType() )
+ {
+ case SQL_STATEMENT_SELECT:
+ {
+ if(m_bIsAlwaysFalseQuery) {
+ break;
+ }
+ else if(isCount())
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_NO_COUNT_SUPPORT, *this );
+ }
+ else
+ {
+ sal_Bool bDistinct = sal_False;
+ OSQLParseNode *pDistinct = m_pParseTree->getChild(1);
+ if (pDistinct && pDistinct->getTokenID() == SQL_TOKEN_DISTINCT)
+ {
+ if(!IsSorted())
+ {
+ m_aOrderbyColumnNumber.push_back(m_aColMapping[1]);
+ m_aOrderbyAscending.push_back(SQL_DESC);
+ }
+ bDistinct = sal_True;
+ }
+
+ OSortIndex::TKeyTypeVector eKeyType(m_aOrderbyColumnNumber.size());
+ ::std::vector<sal_Int32>::iterator aOrderByIter = m_aOrderbyColumnNumber.begin();
+ for ( ::std::vector<sal_Int16>::size_type i = 0; aOrderByIter != m_aOrderbyColumnNumber.end(); ++aOrderByIter,++i)
+ {
+ OSL_ENSURE((sal_Int32)m_aRow->get().size() > *aOrderByIter,"Invalid Index");
+ switch ((m_aRow->get().begin()+*aOrderByIter)->getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ eKeyType[i] = SQL_ORDERBYKEY_STRING;
+ break;
+
+ case DataType::OTHER:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ case DataType::BIT:
+ eKeyType[i] = SQL_ORDERBYKEY_DOUBLE;
+ break;
+
+ // Other types aren't implemented (so they are always FALSE)
+ default:
+ eKeyType[i] = SQL_ORDERBYKEY_NONE;
+ OSL_FAIL("MResultSet::executeQuery: Order By Data Type not implemented");
+ break;
+ }
+ }
+
+ if (IsSorted())
+ {
+ // Implement Sorting
+
+ // So that we can sort we need to wait until the executed
+ // query to the mozilla addressbooks has returned all
+ // values.
+
+ OSL_TRACE("Query is to be sorted");
+#if 0
+ if( ! m_aQueryHelper.queryComplete() )
+ if ( !m_aQueryHelper.waitForQueryComplete() )
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQueryHelper.getError(), *this );
+ }
+#endif
+
+ OSL_ENSURE( m_aQueryHelper.queryComplete(), "Query not complete!!");
+
+ m_pSortIndex = new OSortIndex(eKeyType,m_aOrderbyAscending);
+
+ OSL_TRACE("OrderbyColumnNumber->size() = %d",m_aOrderbyColumnNumber.size());
+#if OSL_DEBUG_LEVEL > 0
+ for ( ::std::vector<sal_Int32>::size_type i = 0; i < m_aColMapping.size(); i++ )
+ OSL_TRACE("Mapped: %d -> %d", i, m_aColMapping[i] );
+#endif
+ for ( sal_Int32 nRow = 1; nRow <= m_aQueryHelper.getResultCount(); nRow++ ) {
+
+ OKeyValue* pKeyValue = OKeyValue::createKeyValue((nRow));
+
+ ::std::vector<sal_Int32>::iterator aIter = m_aOrderbyColumnNumber.begin();
+ for (;aIter != m_aOrderbyColumnNumber.end(); ++aIter)
+ {
+ const ORowSetValue& value = getValue(nRow, *aIter);
+
+ OSL_TRACE( "Adding Value: (%d,%d) : %s", nRow, *aIter,OUtoCStr( value ));
+
+ pKeyValue->pushKey(new ORowSetValueDecorator(value));
+ }
+
+ m_pSortIndex->AddKeyValue( pKeyValue );
+ }
+
+ m_pKeySet = m_pSortIndex->CreateKeySet();
+ m_CurrentRowCount = static_cast<sal_Int32>(m_pKeySet->get().size());
+#if OSL_DEBUG_LEVEL > 0
+ for( OKeySet::Vector::size_type i = 0; i < m_pKeySet->get().size(); i++ )
+ OSL_TRACE("Sorted: %d -> %d", i, (m_pKeySet->get())[i] );
+#endif
+
+ m_pSortIndex = NULL;
+ beforeFirst(); // Go back to start
+ }
+ else //we always need m_pKeySet now
+ m_pKeySet = new OKeySet();
+
+ // Handle the DISTINCT case
+ if ( bDistinct && m_pKeySet.is() )
+ {
+ OValueRow aSearchRow = new OValueVector( m_aRow->get().size() );
+
+ for( OKeySet::Vector::size_type i = 0; i < m_pKeySet->get().size(); i++ )
+ {
+ fetchRow( (m_pKeySet->get())[i] ); // Fills m_aRow
+ if ( matchRow( m_aRow, aSearchRow ) )
+ {
+ (m_pKeySet->get())[i] = 0; // Marker for later to be removed
+ }
+ else
+ {
+ // They don't match, so it's not a duplicate.
+ // Use the current Row as the next one to match against
+ *aSearchRow = *m_aRow;
+ }
+ }
+ // Now remove any keys marked with a 0
+ m_pKeySet->get().erase(::std::remove_if(m_pKeySet->get().begin(),m_pKeySet->get().end()
+ ,::std::bind2nd(::std::equal_to<sal_Int32>(),0))
+ ,m_pKeySet->get().end());
+
+ }
+ }
+ } break;
+
+ case SQL_STATEMENT_UPDATE:
+ case SQL_STATEMENT_DELETE:
+ case SQL_STATEMENT_INSERT:
+ break;
+ default:
+ m_pStatement->getOwnConnection()->throwSQLException( STR_STMT_TYPE_NOT_SUPPORTED, *this );
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+
+void OResultSet::setBoundedColumns(const OValueRow& _rRow,
+ const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,
+ const Reference<XIndexAccess>& _xNames,
+ sal_Bool _bSetColumnMapping,
+ const Reference<XDatabaseMetaData>& _xMetaData,
+ ::std::vector<sal_Int32>& _rColMapping)
+{
+ ::comphelper::UStringMixEqual aCase(_xMetaData->supportsMixedCaseQuotedIdentifiers());
+
+ Reference<XPropertySet> xTableColumn;
+ ::rtl::OUString sTableColumnName, sSelectColumnRealName;
+
+ const ::rtl::OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
+ const ::rtl::OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME);
+
+ ::std::vector< ::rtl::OUString> aColumnNames;
+ aColumnNames.reserve(_rxColumns->get().size());
+ OValueVector::Vector::iterator aRowIter = _rRow->get().begin()+1;
+ for (sal_Int32 i=0; // the first column is the bookmark column
+ aRowIter != _rRow->get().end();
+ ++i, ++aRowIter
+ )
+ {
+ try
+ {
+ // get the table column and it's name
+ _xNames->getByIndex(i) >>= xTableColumn;
+ OSL_ENSURE(xTableColumn.is(), "OResultSet::setBoundedColumns: invalid table column!");
+ if (xTableColumn.is())
+ xTableColumn->getPropertyValue(sName) >>= sTableColumnName;
+ else
+ sTableColumnName = ::rtl::OUString();
+
+ // look if we have such a select column
+ // TODO: would like to have a O(log n) search here ...
+ sal_Int32 nColumnPos = 0;
+ for ( OSQLColumns::Vector::iterator aIter = _rxColumns->get().begin();
+ aIter != _rxColumns->get().end();
+ ++aIter,++nColumnPos
+ )
+ {
+ if ( nColumnPos < (sal_Int32)aColumnNames.size() )
+ sSelectColumnRealName = aColumnNames[nColumnPos];
+ else
+ {
+ if((*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName))
+ (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName;
+ else
+ (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName;
+ aColumnNames.push_back(sSelectColumnRealName);
+ }
+
+ if (aCase(sTableColumnName, sSelectColumnRealName))
+ {
+ if(_bSetColumnMapping)
+ {
+ sal_Int32 nSelectColumnPos = static_cast<sal_Int32>(aIter - _rxColumns->get().begin() + 1);
+ // the getXXX methods are 1-based ...
+ sal_Int32 nTableColumnPos = i + 1;
+ // get first table column is the bookmark column
+ // ...
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("Set Col Mapping: %d -> %d", nSelectColumnPos, nTableColumnPos );
+#endif
+ _rColMapping[nSelectColumnPos] = nTableColumnPos;
+ }
+
+ aRowIter->setBound(sal_True);
+ aRowIter->setTypeKind(DataType::VARCHAR);
+ }
+ }
+ }
+ catch (Exception&)
+ {
+ OSL_FAIL("OResultSet::setBoundedColumns: caught an Exception!");
+ }
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::isCount() const
+{
+ return (m_pParseTree &&
+ m_pParseTree->count() > 2 &&
+ SQL_ISRULE(m_pParseTree->getChild(2),scalar_exp_commalist) &&
+ SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0),derived_column) &&
+ SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0)->getChild(0),general_set_fct) &&
+ m_pParseTree->getChild(2)->getChild(0)->getChild(0)->count() == 4
+ );
+}
+
+// -----------------------------------------------------------------------------
+//
+// Check for valid row in m_aQuery
+//
+sal_Bool OResultSet::validRow( sal_uInt32 nRow)
+{
+ sal_Int32 nNumberOfRecords = m_aQueryHelper.getResultCount();
+
+ while ( nRow > (sal_uInt32)nNumberOfRecords && !m_aQueryHelper.queryComplete() ) {
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("validRow: waiting...");
+#endif
+ if (m_aQueryHelper.checkRowAvailable( nRow ) == sal_False)
+ {
+ OSL_TRACE("validRow(%u): return False", nRow);
+ return sal_False;
+ }
+
+ if ( m_aQueryHelper.hadError() )
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQueryHelper.getError(), *this );
+ }
+
+ nNumberOfRecords = m_aQueryHelper.getResultCount();
+ }
+
+ if (( nRow == 0 ) ||
+ ( nRow > (sal_uInt32)nNumberOfRecords && m_aQueryHelper.queryComplete()) ){
+ OSL_TRACE("validRow(%u): return False", nRow);
+ return sal_False;
+ }
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("validRow(%u): return True", nRow);
+#endif
+
+ return sal_True;
+}
+sal_Bool OResultSet::fillKeySet(sal_Int32 nMaxCardNumber)
+{
+ impl_ensureKeySet();
+ if (m_CurrentRowCount < nMaxCardNumber)
+ {
+ sal_Int32 nKeyValue;
+ if ( (sal_Int32)m_pKeySet->get().capacity() < nMaxCardNumber )
+ m_pKeySet->get().reserve(nMaxCardNumber + 20 );
+
+ for (nKeyValue = m_CurrentRowCount+1; nKeyValue <= nMaxCardNumber; nKeyValue ++)
+ m_pKeySet->get().push_back( nKeyValue );
+ m_CurrentRowCount = nMaxCardNumber;
+ }
+ return sal_True;
+}
+
+sal_Int32 OResultSet::deletedCount()
+{
+ impl_ensureKeySet();
+ return m_CurrentRowCount - static_cast<sal_Int32>(m_pKeySet->get().size());
+
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::seekRow( eRowPosition pos, sal_Int32 nOffset )
+{
+ SAL_INFO("connectivity.mork", "=> OResultSet::seekRow()" );
+
+ ResultSetEntryGuard aGuard( *this );
+ if ( !m_pKeySet.is() )
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ILLEGAL_MOVEMENT, *this );
+
+ sal_Int32 nNumberOfRecords = m_aQueryHelper.getResultCount();
+ sal_Int32 nRetrivedRows = currentRowCount();
+ sal_Int32 nCurPos = m_nRowPos;
+
+ OSL_TRACE("seekRow: nCurPos = %d", nCurPos );
+ switch( pos ) {
+ case NEXT_POS:
+ OSL_TRACE("seekRow: NEXT");
+ nCurPos++;
+ break;
+ case PRIOR_POS:
+ OSL_TRACE("seekRow: PRIOR");
+ if ( nCurPos > 0 )
+ nCurPos--;
+ break;
+
+ case FIRST_POS:
+ OSL_TRACE("seekRow: FIRST");
+ nCurPos = 1;
+ break;
+
+ case LAST_POS:
+ OSL_TRACE("seekRow: LAST");
+ nCurPos = nRetrivedRows;
+ break;
+ case ABSOLUTE_POS:
+ OSL_TRACE("seekRow: ABSOLUTE : %d", nOffset);
+ nCurPos = nOffset;
+ break;
+ case RELATIVE_POS:
+ OSL_TRACE("seekRow: RELATIVE : %d", nOffset);
+ nCurPos += sal_uInt32( nOffset );
+ break;
+ }
+
+ if ( nCurPos <= 0 ) {
+ m_nRowPos = 0;
+ OSL_TRACE("seekRow: return False, m_nRowPos = %u", m_nRowPos );
+ return sal_False;
+ }
+ sal_Int32 nCurCard = nCurPos;
+ if ( nCurPos < (sal_Int32)m_pKeySet->get().size() ) //The requested row is exist in m_pKeySet, so we just use it
+ {
+ nCurCard = (m_pKeySet->get())[nCurPos-1];
+ }
+ else //The requested row has not been retrived until now. We should get the right card for it.
+ nCurCard = nCurPos + deletedCount();
+
+ // davido: what is this loop for?
+ // it leads to infinite loop, once nCurCard is greater then nNumberOfRecords
+#if 0
+ while ( nCurCard > nNumberOfRecords ) {
+ m_aQueryHelper.checkRowAvailable( nCurCard );
+ if ( m_aQueryHelper.hadError() )
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQueryHelper.getError(), *this );
+ }
+ nNumberOfRecords = m_aQueryHelper.getResultCount();
+ }
+#endif
+
+ if ( nCurCard > nNumberOfRecords) {
+ fillKeySet(nNumberOfRecords);
+ m_nRowPos = static_cast<sal_uInt32>(m_pKeySet->get().size() + 1);
+ OSL_TRACE("seekRow: return False, m_nRowPos = %u", m_nRowPos );
+ return sal_False;
+ }
+ //Insert new retrived items for later use
+ fillKeySet(nNumberOfRecords);
+ m_nRowPos = (sal_uInt32)nCurPos;
+ OSL_TRACE("seekRow: return True, m_nRowPos = %u", m_nRowPos );
+ fetchCurrentRow();
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void OResultSet::setColumnMapping(const ::std::vector<sal_Int32>& _aColumnMapping)
+{
+ m_aColMapping = _aColumnMapping;
+#if OSL_DEBUG_LEVEL > 0
+ for ( sal_uInt32 i = 0; i < m_aColMapping.size(); i++ )
+ OSL_TRACE("Set Mapped: %d -> %d", i, m_aColMapping[i] );
+#endif
+}
+// -----------------------------------------------------------------------------
+
+::com::sun::star::uno::Any OResultSet::getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ OSL_TRACE("getBookmark, m_nRowPos = %u", m_nRowPos );
+ ResultSetEntryGuard aGuard( *this );
+ if ( fetchCurrentRow() == sal_False ) {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this );
+ }
+
+ OSL_ENSURE((!m_aRow->isDeleted()),"getBookmark called for deleted row");
+ return makeAny((sal_Int32)(m_aRow->get())[0]);
+}
+sal_Bool OResultSet::moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("moveToBookmark, bookmark = %u", comphelper::getINT32(bookmark) );
+ sal_Int32 nCardNum = comphelper::getINT32(bookmark);
+ m_nRowPos = getRowForCardNumber(nCardNum);
+ fetchCurrentRow();
+ return sal_True;
+}
+sal_Bool OResultSet::moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("moveRelativeToBookmark, bookmark = %u rows= %u", comphelper::getINT32(bookmark),rows );
+ sal_Int32 nCardNum = comphelper::getINT32(bookmark);
+ m_nRowPos = getRowForCardNumber(nCardNum);
+ return seekRow(RELATIVE_POS,rows );
+}
+sal_Int32 OResultSet::compareBookmarks( const ::com::sun::star::uno::Any& lhs, const ::com::sun::star::uno::Any& rhs ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("compareBookmarks, m_nRowPos = %u", m_nRowPos );
+ sal_Int32 nFirst=0;
+ sal_Int32 nSecond=0;
+ sal_Int32 nResult=0;
+
+ if ( !( lhs >>= nFirst ) || !( rhs >>= nSecond ) ) {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK, *this );
+ }
+
+ if(nFirst < nSecond)
+ nResult = -1;
+ else if(nFirst > nSecond)
+ nResult = 1;
+ else
+ nResult = 0;
+
+ return nResult;
+}
+sal_Bool OResultSet::hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("hasOrderedBookmarks, m_nRowPos = %u", m_nRowPos );
+ return sal_True;
+}
+sal_Int32 OResultSet::hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("hashBookmark, m_nRowPos = %u", m_nRowPos );
+ return comphelper::getINT32(bookmark);
+}
+
+sal_Int32 OResultSet::getCurrentCardNumber()
+{
+ if ( ( m_nRowPos == 0 ) || !m_pKeySet.is() )
+ return 0;
+ if (m_pKeySet->get().size() < m_nRowPos)
+ return 0;
+ return (m_pKeySet->get())[m_nRowPos-1];
+}
+void OResultSet::checkPendingUpdate() throw(SQLException, RuntimeException)
+{
+ OSL_FAIL( "OResultSet::checkPendingUpdate() not implemented" );
+/*
+ OSL_TRACE("checkPendingUpdate, m_nRowPos = %u", m_nRowPos );
+ const sal_Int32 nCurrentRow = getCurrentCardNumber();
+
+ if ((m_nNewRow && nCurrentRow != m_nNewRow)
+ || ( m_nUpdatedRow && m_nUpdatedRow != nCurrentRow))
+ {
+ const ::rtl::OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COMMIT_ROW,
+ "$position$", ::rtl::OUString::valueOf(nCurrentRow)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+*/
+
+}
+void OResultSet::updateValue(sal_Int32 columnIndex ,const ORowSetValue& x) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("updateValue, m_nRowPos = %u", m_nRowPos );
+ ResultSetEntryGuard aGuard( *this );
+ if ( fetchCurrentRow() == sal_False ) {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this );
+ }
+
+ checkPendingUpdate();
+
+ checkIndex(columnIndex );
+ columnIndex = mapColumn(columnIndex);
+
+ (m_aRow->get())[columnIndex].setBound(sal_True);
+ (m_aRow->get())[columnIndex] = x;
+ m_nUpdatedRow = getCurrentCardNumber();
+// m_RowStates = m_RowStates | RowStates_Updated;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("updateNull, m_nRowPos = %u", m_nRowPos );
+ ResultSetEntryGuard aGuard( *this );
+ if ( fetchCurrentRow() == sal_False )
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this );
+
+ checkPendingUpdate();
+ checkIndex(columnIndex );
+ columnIndex = mapColumn(columnIndex);
+
+ (m_aRow->get())[columnIndex].setBound(sal_True);
+ (m_aRow->get())[columnIndex].setNull();
+ m_nUpdatedRow = getCurrentCardNumber();
+// m_RowStates = m_RowStates | RowStates_Updated;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateLong", *this );
+}
+// -----------------------------------------------------------------------
+void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ if(!x.is())
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ Sequence<sal_Int8> aSeq;
+ x->readBytes(aSeq,length);
+ updateValue(columnIndex,aSeq);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ updateBinaryStream(columnIndex,x,length);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ {
+ const ::rtl::OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COLUMN_NOT_UPDATEABLE,
+ "$position$", ::rtl::OUString::valueOf(columnIndex)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ } // if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ }
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
+{
+ if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ {
+ const ::rtl::OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COLUMN_NOT_UPDATEABLE,
+ "$position$", ::rtl::OUString::valueOf(columnIndex)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+}
+
+// XResultSetUpdate
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("insertRow in, m_nRowPos = %u", m_nRowPos );
+// m_RowStates = RowStates_Inserted;
+ updateRow();
+ m_nOldRowPos = 0;
+ m_nNewRow = 0;
+ //m_aQueryHelper.setRowStates(getCurrentCardNumber(),m_RowStates);
+ OSL_TRACE("insertRow out, m_nRowPos = %u", m_nRowPos );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ OSL_FAIL( "OResultSet::updateRow( ) not implemented" );
+#if 0
+ OSL_TRACE("updateRow in, m_nRowPos = %u", m_nRowPos );
+ ResultSetEntryGuard aGuard( *this );
+ impl_ensureKeySet();
+
+ if (!m_nRowPos || m_pKeySet->get().size() < m_nRowPos )
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_ROW_UPDATE, *this );
+ }
+
+ const sal_Int32 nCurrentCard = getCurrentCardNumber();
+
+ if (!pushCard(nCurrentCard))
+ {
+ m_RowStates = RowStates_Error;
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ROW_CAN_NOT_SAVE, *this );
+ }
+
+ if (!m_aQueryHelper.commitRow(nCurrentCard))
+ {
+ m_RowStates = RowStates_Error;
+ m_nUpdatedRow = 0;
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQueryHelper.getError(), *this );
+ }
+
+ m_nUpdatedRow = 0;
+ fetchCurrentRow();
+ OSL_TRACE("updateRow out, m_nRowPos = %u", m_nRowPos );
+#endif
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ OSL_FAIL( "OResultSet::deleteRow( ) not implemented" );
+#if 0
+ OSL_TRACE("deleteRow, m_nRowPos = %u", m_nRowPos );
+ ResultSetEntryGuard aGuard( *this );
+ if (rowDeleted())
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ROW_ALREADY_DELETED, *this );
+
+ const sal_Int32 nCurrentRow = getCurrentCardNumber();
+ //fetchRow(nCurrentRow);
+ if (!nCurrentRow)
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this );
+
+ sal_Bool m_bRowDeleted = ( m_aQueryHelper.deleteRow( nCurrentRow ) > 0 );
+ if (!m_bRowDeleted)
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQueryHelper.getError(), *this );
+
+ m_aQueryHelper.setRowStates(nCurrentRow,RowStates_Deleted);
+ m_pKeySet->get().erase(m_pKeySet->get().begin() + m_nRowPos -1);
+ m_RowStates = RowStates_Deleted;
+ OSL_TRACE("deleteRow out, m_nRowPos = %u", m_nRowPos );
+#endif
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ OSL_FAIL( "OResultSet::cancelRowUpdates( ) not implemented" );
+#if 0
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("cancelRowUpdates, m_nRowPos = %u", m_nRowPos );
+ if (fetchRow(getCurrentCardNumber(),sal_True)) //force fetch current row will cause we lose all change to the current row
+ m_pStatement->getOwnConnection()->throwSQLException( STR_CAN_NOT_CANCEL_ROW_UPDATE, *this );
+#endif
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ OSL_FAIL( "OResultSet::moveToInsertRow( ) not implemented" );
+#if 0
+ OSL_TRACE("moveToInsertRow in, m_nRowPos = %u", m_nRowPos );
+ ResultSetEntryGuard aGuard( *this );
+ m_nOldRowPos = m_nRowPos;
+
+ if (!m_nNewRow) //no new row now, insert one
+ {
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ checkPendingUpdate();
+ if (rowUpdated())
+ {
+ if (m_nRowPos && !pushCard(getCurrentCardNumber()))
+ throw SQLException();
+ }
+ m_nNewRow = m_aQueryHelper.createNewCard();
+ if (!m_nNewRow)
+ m_pStatement->getOwnConnection()->throwSQLException( STR_CAN_NOT_CREATE_ROW, *this );
+
+ m_RowStates = RowStates_Normal;
+ fillKeySet(m_nNewRow);
+ }
+ else
+ m_nUpdatedRow = 0;
+
+ m_nRowPos = static_cast<sal_uInt32>(m_pKeySet->get().size());
+ fetchCurrentRow();
+ OSL_TRACE("moveToInsertRow out, m_nRowPos = %u", m_nRowPos );
+#endif
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("moveToCurrentRow, m_nRowPos = %u", m_nRowPos );
+ if (rowInserted())
+ {
+ m_nRowPos = m_nOldRowPos;
+ fetchCurrentRow();
+ }
+}
+
+sal_Bool OResultSet::determineReadOnly()
+{
+// OSL_FAIL( "OResultSet::determineReadOnly( ) not implemented" );
+
+ if (m_bIsReadOnly == -1)
+ {
+ m_bIsReadOnly = sal_True;
+// OConnection* xConnection = static_cast<OConnection*>(m_pStatement->getConnection().get());
+// m_bIsReadOnly = !m_aQueryHelper.isWritable(xConnection) || m_bIsAlwaysFalseQuery;
+ }
+
+ return m_bIsReadOnly != 0;
+}
+
+void OResultSet::setTable(OTable* _rTable)
+{
+ OSL_TRACE("In : setTable");
+ m_pTable = _rTable;
+ m_pTable->acquire();
+ m_xTableColumns = m_pTable->getColumns();
+ if(m_xTableColumns.is())
+ m_aColumnNames = m_xTableColumns->getElementNames();
+ OSL_TRACE("Out : setTable");
+}
+
+void OResultSet::setOrderByColumns(const ::std::vector<sal_Int32>& _aColumnOrderBy)
+{
+ m_aOrderbyColumnNumber = _aColumnOrderBy;
+}
+
+void OResultSet::setOrderByAscending(const ::std::vector<TAscendingOrder>& _aOrderbyAsc)
+{
+ m_aOrderbyAscending = _aOrderbyAsc;
+}
+Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& /*rows*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XDeleteRows::deleteRows", *this );
+ return Sequence< sal_Int32 >();
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MResultSet.hxx b/connectivity/source/drivers/mork/MResultSet.hxx
new file mode 100644
index 000000000000..e4feaeebe200
--- /dev/null
+++ b/connectivity/source/drivers/mork/MResultSet.hxx
@@ -0,0 +1,359 @@
+/* -*- 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 CONNECTIVITY_SRESULTSET_HXX
+#define CONNECTIVITY_SRESULTSET_HXX
+
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <cppuhelper/compbase12.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include "MStatement.hxx"
+#include "MQueryHelper.hxx"
+#include "connectivity/CommonTools.hxx"
+#include "connectivity/FValue.hxx"
+#include "connectivity/sqliterator.hxx"
+#include "TSortIndex.hxx"
+
+namespace connectivity
+{
+ namespace mork
+ {
+
+ /*
+ ** java_sql_ResultSet
+ */
+ typedef ::cppu::WeakComponentImplHelper12< ::com::sun::star::sdbc::XResultSet,
+ ::com::sun::star::sdbc::XRow,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::util::XCancellable,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XColumnLocate,
+ ::com::sun::star::sdbc::XResultSetUpdate,
+ ::com::sun::star::sdbc::XRowUpdate,
+ ::com::sun::star::sdbcx::XRowLocate,
+ ::com::sun::star::sdbcx::XDeleteRows,
+ ::com::sun::star::lang::XServiceInfo> OResultSet_BASE;
+
+
+ typedef sal_Int64 TVoidPtr;
+ typedef ::std::allocator< TVoidPtr > TVoidAlloc;
+ typedef ::std::vector<TVoidPtr> TVoidVector;
+
+ class OResultSet : public comphelper::OBaseMutex,
+ public OResultSet_BASE,
+ public ::cppu::OPropertySetHelper,
+ public ::comphelper::OPropertyArrayUsageHelper<OResultSet>
+ {
+ protected:
+ OCommonStatement* m_pStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+ sal_uInt32 m_nRowPos;
+ sal_uInt32 m_nOldRowPos;
+ sal_Bool m_bWasNull;
+ sal_Int32 m_nFetchSize;
+ sal_Int32 m_nResultSetType;
+ sal_Int32 m_nFetchDirection;
+ sal_Int32 m_nResultSetConcurrency;
+
+
+
+ ::boost::shared_ptr< ::connectivity::OSQLParseTreeIterator >
+ m_pSQLIterator;
+ const connectivity::OSQLParseNode* m_pParseTree;
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue
+ )
+ throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle
+ ) const;
+
+ // you can't delete objects of this type
+ virtual ~OResultSet();
+ public:
+ DECLARE_SERVICE_INFO();
+
+ OResultSet(OCommonStatement* pStmt, const ::boost::shared_ptr< ::connectivity::OSQLParseTreeIterator >& _pSQLIterator );
+
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *()
+ {
+ return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(OResultSet_BASE*)this);
+ }
+
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // XResultSet
+ virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XRow
+ virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XCancellable
+ virtual void SAL_CALL cancel( ) throw(::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);
+ // XColumnLocate
+ virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XResultSetUpdate
+ virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XRowUpdate
+ virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XRowLocate
+ virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XDeleteRows
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+protected:
+ //MQuery m_aQuery;
+ MQueryHelper m_aQueryHelper;
+ OTable* m_pTable;
+ sal_Int32 m_CurrentRowCount;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ m_xTableColumns;
+
+ ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime
+ ::std::vector<sal_Int32> m_aOrderbyColumnNumber;
+ ::std::vector<TAscendingOrder> m_aOrderbyAscending;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString> m_aColumnNames;
+ OValueRow m_aRow;
+ OValueRow m_aParameterRow;
+ ::std::vector< ::rtl::OUString> m_aAttributeStrings;
+ sal_Int32 m_nParamIndex;
+ sal_Bool m_bIsAlwaysFalseQuery;
+ ::rtl::Reference<OKeySet> m_pKeySet;
+ OSortIndex* m_pSortIndex;
+ sal_Int32 m_nNewRow; //inserted row
+ sal_Int32 m_nUpdatedRow; //updated row
+ sal_Int32 m_RowStates;
+ sal_Int32 m_bIsReadOnly;
+ inline void resetParameters() { m_nParamIndex = 0; }
+
+ ::rtl::Reference<connectivity::OSQLColumns> m_xColumns; // this are the select columns
+ ::rtl::Reference<connectivity::OSQLColumns> m_xParamColumns;
+
+ void parseParameter( const OSQLParseNode* pNode, rtl::OUString& rMatchString );
+ void fillRowData() throw( ::com::sun::star::sdbc::SQLException );
+ void analyseWhereClause( const OSQLParseNode* parseTree,
+ MQueryExpression &queryExpression);
+
+ sal_Bool isCount() const;
+
+ // XXX sal_Bool IsSorted() const { return !m_aOrderbyColumnNumber.empty() && m_aOrderbyColumnNumber[0] != STRING_NOTFOUND ;}
+ sal_Bool IsSorted() const { return !m_aOrderbyColumnNumber.empty(); }
+
+ enum eRowPosition {
+ NEXT_POS, PRIOR_POS, FIRST_POS, LAST_POS, ABSOLUTE_POS, RELATIVE_POS
+ };
+
+ sal_uInt32 currentRowCount();
+
+ sal_Bool fetchRow(sal_Int32 rowIndex,sal_Bool bForceReload=sal_False) throw( ::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ sal_Bool fetchCurrentRow() throw( ::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ sal_Bool pushCard(sal_uInt32 rowIndex) throw( ::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ sal_Bool validRow( sal_uInt32 nRow );
+ sal_Bool seekRow( eRowPosition pos, sal_Int32 nOffset = 0 );
+ sal_Int32 deletedCount();
+ sal_Bool fillKeySet(sal_Int32 nMaxCardNumber); //When we get new rows, fill the m_pKeySet items for them
+ sal_Int32 getRowForCardNumber(sal_Int32 nCardNum);
+ const ORowSetValue& getValue(sal_Int32 rowIndex, sal_Int32 columnIndex)
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ void updateValue(sal_Int32 columnIndex,const ORowSetValue& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void checkPendingUpdate() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getCurrentCardNumber();
+
+public:
+ sal_Bool determineReadOnly();
+ // MozAddressbook Specific methods
+ void SAL_CALL executeQuery() throw( ::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+
+ void setTable(OTable* _rTable);
+
+ void setParameterRow(const OValueRow& _rParaRow)
+ { m_aParameterRow = _rParaRow; }
+
+ void setParameterColumns(const ::rtl::Reference<connectivity::OSQLColumns>& _xParamColumns)
+ { m_xParamColumns = _xParamColumns; }
+
+ void setBindingRow(const OValueRow& _aRow)
+ { m_aRow = _aRow; }
+
+ void setColumnMapping(const ::std::vector<sal_Int32>& _aColumnMapping);
+
+ void setOrderByColumns(const ::std::vector<sal_Int32>& _aColumnOrderBy);
+
+ void setOrderByAscending(const ::std::vector<TAscendingOrder>& _aOrderbyAsc);
+
+ inline sal_Int32 mapColumn(sal_Int32 column);
+
+ void checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException);
+
+ static void setBoundedColumns(
+ const OValueRow& _rRow,
+ const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xNames,
+ sal_Bool _bSetColumnMapping,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData,
+ ::std::vector<sal_Int32>& _rColMapping);
+
+ ::osl::Mutex& getMutex() { return m_aMutex; }
+ void methodEntry();
+
+ private:
+ inline void impl_ensureKeySet()
+ {
+ if ( !m_pKeySet.is() )
+ m_pKeySet = new OKeySet();
+ }
+
+ protected:
+ using OPropertySetHelper::getFastPropertyValue;
+ };
+
+ inline sal_Int32 OResultSet::mapColumn(sal_Int32 column)
+ {
+ sal_Int32 map = column;
+
+ OSL_ENSURE(column > 0, "OResultSet::mapColumn: invalid column index!");
+ // the first column (index 0) is for convenience only. The
+ // first real select column is no 1.
+ if ((column > 0) && (column < (sal_Int32)m_aColMapping.size()))
+ map = m_aColMapping[column];
+
+ return map;
+ }
+
+ class ResultSetEntryGuard : public ::osl::MutexGuard
+ {
+ public:
+ ResultSetEntryGuard( OResultSet& _rRS ) : ::osl::MutexGuard( _rRS.getMutex() )
+ {
+ _rRS.methodEntry();
+ }
+ };
+
+ }
+}
+#endif // CONNECTIVITY_SRESULTSET_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MResultSetMetaData.cxx b/connectivity/source/drivers/mork/MResultSetMetaData.cxx
new file mode 100644
index 000000000000..581e9305a2c9
--- /dev/null
+++ b/connectivity/source/drivers/mork/MResultSetMetaData.cxx
@@ -0,0 +1,205 @@
+/* -*- 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 "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+#include <comphelper/types.hxx>
+#include <comphelper/extract.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <tools/diagnose_ex.h>
+#include "MResultSetMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+
+using namespace connectivity::mork;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::beans;
+using namespace ::dbtools;
+using namespace ::comphelper;
+
+// -------------------------------------------------------------------------
+OResultSetMetaData::~OResultSetMetaData()
+{
+ m_xColumns = NULL;
+}
+
+// -----------------------------------------------------------------------------
+void OResultSetMetaData::checkColumnIndex(sal_Int32 column) throw(SQLException, RuntimeException)
+{
+ if(column <= 0 || column > (sal_Int32)(sal_Int32)m_xColumns->get().size())
+ throwInvalidIndexException(*this);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getPrecision(column);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return DataType::VARCHAR; // at the moment there exists only this type
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
+{
+ return static_cast<sal_Int32>((m_xColumns->get()).size());
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ checkColumnIndex(column);
+
+ ::rtl::OUString sColumnName;
+ try
+ {
+ Reference< XPropertySet > xColumnProps( (m_xColumns->get())[column-1], UNO_QUERY_THROW );
+ OSL_VERIFY( xColumnProps->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_NAME ) ) >>= sColumnName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sColumnName;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return m_aTableName;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ checkColumnIndex(column);
+ return getString((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getColumnName(column);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ checkColumnIndex(column);
+ return getBOOL((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)));
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)));
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString sColumnName( getColumnName( column ) );
+
+ if ( !m_pTable || !m_pTable->getConnection() )
+ {
+ OSL_FAIL( "OResultSetMetaData::isSearchable: suspicious: called without table or connection!" );
+ return sal_False;
+ }
+
+#if 0
+ if ( m_pTable->getConnection()->isLDAP() )
+ {
+ const OColumnAlias& aAliases( m_pTable->getConnection()->getColumnAlias() );
+ if ( !aAliases.isColumnSearchable( sColumnName ) )
+ return sal_False;
+ }
+#endif
+
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ checkColumnIndex(column);
+ sal_Bool bReadOnly = (m_xColumns->get())[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) &&
+ ::cppu::any2bool((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)));
+
+ return m_bReadOnly || bReadOnly || m_pTable->isReadOnly();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return !isReadOnly(column);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return !isReadOnly(column);
+}
+// -------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MResultSetMetaData.hxx b/connectivity/source/drivers/mork/MResultSetMetaData.hxx
new file mode 100644
index 000000000000..89b50cf6fa1b
--- /dev/null
+++ b/connectivity/source/drivers/mork/MResultSetMetaData.hxx
@@ -0,0 +1,92 @@
+/* -*- 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 CONNECTIVITY_SRESULSETMETADATA_HXX
+#define CONNECTIVITY_SRESULSETMETADATA_HXX
+
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <vector>
+#include <rtl/ref.hxx>
+#include "MConnection.hxx"
+#include "MTable.hxx"
+
+namespace connectivity
+{
+ namespace mork
+ {
+ //**************************************************************
+ //************ Class: ResultSetMetaData
+ //**************************************************************
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE;
+
+ class OResultSetMetaData : public OResultSetMetaData_BASE
+ {
+ ::rtl::OUString m_aTableName;
+ ::rtl::Reference<connectivity::OSQLColumns> m_xColumns;
+ OTable* m_pTable;
+ sal_Bool m_bReadOnly;
+
+ protected:
+ virtual ~OResultSetMetaData();
+ public:
+ // a constructor that is needed to return the object:
+ // OResultSetMetaData(OConnection* _pConnection) : m_pConnection(_pConnection){}
+ OResultSetMetaData(const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,
+ const ::rtl::OUString& _aTableName,OTable* _pTable,sal_Bool aReadOnly
+ )
+ :m_aTableName(_aTableName)
+ ,m_xColumns(_rxColumns)
+ ,m_pTable(_pTable)
+ ,m_bReadOnly(aReadOnly)
+ {}
+
+
+ /// Avoid ambigous cast error from the compiler.
+ inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
+ { return this; }
+
+ void checkColumnIndex(sal_Int32 column) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // CONNECTIVITY_SRESULSETMETADATA_HXX
+
+/* 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 000000000000..3dfeb2053c5a
--- /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/MStatement.cxx b/connectivity/source/drivers/mork/MStatement.cxx
new file mode 100644
index 000000000000..6547a179f564
--- /dev/null
+++ b/connectivity/source/drivers/mork/MStatement.cxx
@@ -0,0 +1,589 @@
+/* -*- 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 <stdio.h>
+#include <osl/diagnose.h>
+#include <comphelper/property.hxx>
+#include <comphelper/uno3.hxx>
+#include <osl/thread.h>
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <com/sun/star/container/XIndexAccess.hpp>
+
+#include <algorithm>
+
+#include "diagnose_ex.h"
+#include "MDriver.hxx"
+#include "MStatement.hxx"
+#include "MConnection.hxx"
+#include "MResultSet.hxx"
+#include "MDatabaseMetaData.hxx"
+
+#include "resource/mork_res.hrc"
+#include "resource/common_res.hrc"
+
+#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 */
+
+static ::osl::Mutex m_ThreadMutex;
+
+using namespace ::comphelper;
+using namespace connectivity::mork;
+using namespace connectivity;
+//------------------------------------------------------------------------------
+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::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+//------------------------------------------------------------------------------
+
+OStatement::OStatement( OConnection* _pConnection) : OCommonStatement( _pConnection)
+{
+ SAL_INFO("connectivity.mork", "=> OStatement::OStatement()" );
+}
+
+OCommonStatement::OCommonStatement(OConnection* _pConnection )
+ :OCommonStatement_IBASE(m_aMutex)
+ ,OPropertySetHelper(OCommonStatement_IBASE::rBHelper)
+ ,OCommonStatement_SBASE((::cppu::OWeakObject*)_pConnection, this)
+ ,m_pTable(NULL)
+ ,m_pConnection(_pConnection)
+ ,m_aParser(_pConnection->getDriver()->getFactory())
+ ,m_pSQLIterator( new OSQLParseTreeIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ) )
+ ,rBHelper(OCommonStatement_IBASE::rBHelper)
+{
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::OCommonStatement()" );
+ m_xDBMetaData = _pConnection->getMetaData();
+ m_pParseTree = NULL;
+ m_pConnection->acquire();
+}
+
+// -----------------------------------------------------------------------------
+OCommonStatement::~OCommonStatement()
+{
+}
+
+//------------------------------------------------------------------------------
+void OCommonStatement::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ clearWarnings();
+ clearCachedResultSet();
+
+ if (m_pConnection)
+ m_pConnection->release();
+ m_pConnection = NULL;
+
+ m_pSQLIterator->dispose();
+
+ dispose_ChildImpl();
+ OCommonStatement_IBASE::disposing();
+}
+//-----------------------------------------------------------------------------
+Any SAL_CALL OCommonStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OCommonStatement_IBASE::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OCommonStatement::getTypes( ) throw(RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OCommonStatement_IBASE::getTypes());
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OCommonStatement::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+ }
+ dispose();
+}
+
+
+// -------------------------------------------------------------------------
+void OCommonStatement::createTable( ) throw ( SQLException, RuntimeException )
+{
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::createTable()" );
+
+/*
+ if(m_pParseTree)
+ {
+ ::rtl::Reference<connectivity::OSQLColumns> xCreateColumn;
+ if (m_pSQLIterator->getStatementType() == SQL_STATEMENT_CREATE_TABLE)
+ {
+ const OSQLTables& xTabs = m_pSQLIterator->getTables();
+ OSL_ENSURE( !xTabs.empty(), "Need a Table");
+ ::rtl::OUString ouTableName=xTabs.begin()->first;
+ xCreateColumn = m_pSQLIterator->getCreateColumns();
+ OSL_ENSURE(xCreateColumn.is(), "Need the Columns!!");
+
+ const OColumnAlias& aColumnAlias = m_pConnection->getColumnAlias();
+
+ OSQLColumns::Vector::const_iterator aIter = xCreateColumn->get().begin();
+ const ::rtl::OUString sProprtyName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
+ ::rtl::OUString sName;
+ for (sal_Int32 i = 1; aIter != xCreateColumn->get().end();++aIter, i++)
+ {
+ (*aIter)->getPropertyValue(sProprtyName) >>= sName;
+ if ( !aColumnAlias.hasAlias( sName ) )
+ {
+
+ const ::rtl::OUString sError( getOwnConnection()->getResources().getResourceStringWithSubstitution(
+ STR_INVALID_COLUMNNAME,
+ "$columnname$", sName
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+ }
+ MDatabaseMetaDataHelper _aDbHelper;
+ if (!_aDbHelper.NewAddressBook(m_pConnection,ouTableName))
+ {
+ getOwnConnection()->throwSQLException( _aDbHelper.getError(), *this );
+ }
+ m_pSQLIterator.reset( new ::connectivity::OSQLParseTreeIterator(
+ m_pConnection, m_pConnection->createCatalog()->getTables(), m_aParser, NULL ) );
+ }
+
+ }
+ else
+ getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
+*/
+}
+// -------------------------------------------------------------------------
+OCommonStatement::StatementType OCommonStatement::parseSql( const ::rtl::OUString& sql , sal_Bool bAdjusted)
+ throw ( SQLException, RuntimeException )
+{
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::parseSql()" );
+
+ ::rtl::OUString aErr;
+
+ m_pParseTree = m_aParser.parseTree(aErr,sql);
+
+#if OSL_DEBUG_LEVEL > 0
+ {
+ const char* str = OUtoCStr(sql);
+ OSL_UNUSED( str );
+ OSL_TRACE("ParseSQL: %s", OUtoCStr( sql ) );
+ }
+#endif // OSL_DEBUG_LEVEL
+
+ if(m_pParseTree)
+ {
+ m_pSQLIterator->setParseTree(m_pParseTree);
+ m_pSQLIterator->traverseAll();
+ const OSQLTables& xTabs = m_pSQLIterator->getTables();
+
+ if (xTabs.empty())
+ {
+ getOwnConnection()->throwSQLException( STR_QUERY_AT_LEAST_ONE_TABLES, *this );
+ }
+
+#if OSL_DEBUG_LEVEL > 0
+ OSQLTables::const_iterator citer;
+ for( citer = xTabs.begin(); citer != xTabs.end(); ++citer ) {
+ OSL_TRACE("SELECT Table : %s", OUtoCStr(citer->first) );
+ }
+#endif
+
+ Reference<XIndexAccess> xNames;
+ switch(m_pSQLIterator->getStatementType())
+ {
+ case SQL_STATEMENT_SELECT:
+
+ // at this moment we support only one table per select statement
+
+ OSL_ENSURE( xTabs.begin() != xTabs.end(), "Need a Table");
+
+ m_pTable = static_cast< OTable* > (xTabs.begin()->second.get());
+ m_xColNames = m_pTable->getColumns();
+ xNames = Reference<XIndexAccess>(m_xColNames,UNO_QUERY);
+ // set the binding of the resultrow
+ m_aRow = new OValueVector(xNames->getCount());
+ (m_aRow->get())[0].setBound(sal_True);
+ ::std::for_each(m_aRow->get().begin()+1,m_aRow->get().end(),TSetBound(sal_False));
+ // create the column mapping
+ createColumnMapping();
+
+ analyseSQL();
+ return eSelect;
+
+ case SQL_STATEMENT_CREATE_TABLE:
+ createTable();
+ return eCreateTable;
+
+ default:
+ break;
+ }
+ }
+ else if(!bAdjusted) //Our sql parser does not support a statement like "create table foo"
+ // So we append ("E-mail" varchar) to the last of it to make it work
+ {
+ return parseSql(sql + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("(""E-mail"" caracter)")),sal_True);
+ }
+
+ getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
+ OSL_FAIL( "OCommonStatement::parseSql: unreachable!" );
+ return eSelect;
+
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > OCommonStatement::impl_executeCurrentQuery()
+{
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::impl_executeCurrentQuery()" );
+
+ clearCachedResultSet();
+
+ ::rtl::Reference< OResultSet > pResult( new OResultSet( this, m_pSQLIterator ) );
+ initializeResultSet( pResult.get() );
+
+ pResult->executeQuery();
+ cacheResultSet( pResult ); // only cache if we survived the execution
+
+ return pResult.get();
+
+}
+
+// -------------------------------------------------------------------------
+void OCommonStatement::initializeResultSet( OResultSet* _pResult )
+{
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::initializeResultSet()" );
+
+ ENSURE_OR_THROW( _pResult, "invalid result set" );
+
+ _pResult->setColumnMapping(m_aColMapping);
+ _pResult->setOrderByColumns(m_aOrderbyColumnNumber);
+ _pResult->setOrderByAscending(m_aOrderbyAscending);
+ _pResult->setBindingRow(m_aRow);
+ _pResult->setTable(m_pTable);
+}
+
+// -------------------------------------------------------------------------
+void OCommonStatement::clearCachedResultSet()
+{
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::clearCachedResultSet()" );
+
+ Reference< XResultSet > xResultSet( m_xResultSet.get(), UNO_QUERY );
+ if ( !xResultSet.is() )
+ return;
+
+ try
+ {
+ Reference< XCloseable > xCloseable( xResultSet, UNO_QUERY_THROW );
+ xCloseable->close();
+ }
+ catch( const DisposedException& )
+ {
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::clearCachedResultSet()" );
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_xResultSet = Reference< XResultSet >();
+}
+
+// -------------------------------------------------------------------------
+void OCommonStatement::cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult )
+{
+ ENSURE_OR_THROW( _pResult.is(), "invalid result set" );
+ m_xResultSet = Reference< XResultSet >( _pResult.get() );
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCommonStatement::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::execute()" );
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ OSL_TRACE("Statement::execute( %s )", OUtoCStr( sql ) );
+
+ Reference< XResultSet > xRS = executeQuery( sql );
+ // returns true when a resultset is available
+ return xRS.is();
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCommonStatement::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::executeQuery()" );
+
+ ::osl::MutexGuard aGuard( m_ThreadMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ OSL_TRACE("Statement::executeQuery( %s )", OUtoCStr( sql ) );
+
+ // parse the statement
+ StatementType eStatementType = parseSql( sql );
+ if ( eStatementType != eSelect )
+ return NULL;
+
+ return impl_executeCurrentQuery();
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OCommonStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::getConnection()" );
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ // just return our connection here
+ return (Reference< XConnection >)m_pConnection;
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::queryInterface()" );
+
+ Any aRet = ::cppu::queryInterface(rType,static_cast< XServiceInfo*> (this));
+ if(!aRet.hasValue())
+ aRet = OCommonStatement::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCommonStatement::executeUpdate( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XStatement::executeUpdate", *this );
+ return 0;
+
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OCommonStatement::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ return makeAny(m_aLastWarning);
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+void SAL_CALL OCommonStatement::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+
+ m_aLastWarning = SQLWarning();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OCommonStatement::createArrayHelper( ) const
+{
+ // this properties are define by the service resultset
+ // they must in alphabetic order
+ Sequence< Property > aProps(9);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP0(CURSORNAME, ::rtl::OUString);
+ DECL_BOOL_PROP0(ESCAPEPROCESSING);
+ DECL_PROP0(FETCHDIRECTION,sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP0(MAXFIELDSIZE,sal_Int32);
+ DECL_PROP0(MAXROWS, sal_Int32);
+ DECL_PROP0(QUERYTIMEOUT,sal_Int32);
+ DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
+ DECL_PROP0(RESULTSETTYPE,sal_Int32);
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OCommonStatement::getInfoHelper()
+{
+ return *const_cast<OCommonStatement*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool OCommonStatement::convertFastPropertyValue(
+ Any & /*rConvertedValue*/,
+ Any & /*rOldValue*/,
+ sal_Int32 /*nHandle*/,
+ const Any& /*rValue*/ )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ sal_Bool bConverted = sal_False;
+ // here we have to try to convert
+ return bConverted;
+}
+// -------------------------------------------------------------------------
+void OCommonStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& /*rValue*/) throw (Exception)
+{
+ // set the value to whatever is necessary
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ case PROPERTY_ID_MAXFIELDSIZE:
+ case PROPERTY_ID_MAXROWS:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void OCommonStatement::getFastPropertyValue(Any& /*rValue*/,sal_Int32 nHandle) const
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ case PROPERTY_ID_MAXFIELDSIZE:
+ case PROPERTY_ID_MAXROWS:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement");
+// -----------------------------------------------------------------------------
+void SAL_CALL OCommonStatement::acquire() throw()
+{
+ OCommonStatement_IBASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OCommonStatement::release() throw()
+{
+ relase_ChildImpl();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::acquire() throw()
+{
+ OCommonStatement::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::release() throw()
+{
+ OCommonStatement::release();
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OCommonStatement::getPropertySetInfo( ) throw(RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+void OCommonStatement::createColumnMapping()
+{
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::createColumnMapping()" );
+
+ size_t i;
+
+ // initialize the column index map (mapping select columns to table columns)
+ ::rtl::Reference<connectivity::OSQLColumns> xColumns = m_pSQLIterator->getSelectColumns();
+ m_aColMapping.resize(xColumns->get().size() + 1);
+ for (i=0; i<m_aColMapping.size(); ++i)
+ m_aColMapping[i] = static_cast<sal_Int32>(i);
+
+ Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
+ // now check which columns are bound
+#if OSL_DEBUG_LEVEL > 0
+ for ( i = 0; i < m_aColMapping.size(); i++ )
+ OSL_TRACE("BEFORE Mapped: %d -> %d", i, m_aColMapping[i] );
+#endif
+ OResultSet::setBoundedColumns(m_aRow,xColumns,xNames,sal_True,m_xDBMetaData,m_aColMapping);
+#if OSL_DEBUG_LEVEL > 0
+ for ( i = 0; i < m_aColMapping.size(); i++ )
+ OSL_TRACE("AFTER Mapped: %d -> %d", i, m_aColMapping[i] );
+#endif
+}
+// -----------------------------------------------------------------------------
+
+void OCommonStatement::analyseSQL()
+{
+ const OSQLParseNode* pOrderbyClause = m_pSQLIterator->getOrderTree();
+ if(pOrderbyClause)
+ {
+ OSQLParseNode * pOrderingSpecCommalist = pOrderbyClause->getChild(2);
+ OSL_ENSURE(SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OResultSet: Fehler im Parse Tree");
+
+ for (sal_uInt32 m = 0; m < pOrderingSpecCommalist->count(); m++)
+ {
+ OSQLParseNode * pOrderingSpec = pOrderingSpecCommalist->getChild(m);
+ OSL_ENSURE(SQL_ISRULE(pOrderingSpec,ordering_spec),"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(pOrderingSpec->count() == 2,"OResultSet: Fehler im Parse Tree");
+
+ OSQLParseNode * pColumnRef = pOrderingSpec->getChild(0);
+ if(!SQL_ISRULE(pColumnRef,column_ref))
+ {
+ throw SQLException();
+ }
+ OSQLParseNode * pAscendingDescending = pOrderingSpec->getChild(1);
+ setOrderbyColumn(pColumnRef,pAscendingDescending);
+ }
+ }
+}
+//------------------------------------------------------------------
+void OCommonStatement::setOrderbyColumn( OSQLParseNode* pColumnRef,
+ OSQLParseNode* pAscendingDescending)
+{
+ SAL_INFO("connectivity.mork", "=> OCommonStatement::setOrderbyColumn()" );
+
+ ::rtl::OUString aColumnName;
+ if (pColumnRef->count() == 1)
+ aColumnName = pColumnRef->getChild(0)->getTokenValue();
+ else if (pColumnRef->count() == 3)
+ {
+ pColumnRef->getChild(2)->parseNodeToStr( aColumnName, getOwnConnection(), NULL, sal_False, sal_False );
+ }
+ else
+ {
+ throw SQLException();
+ }
+
+ Reference<XColumnLocate> xColLocate(m_xColNames,UNO_QUERY);
+ if(!xColLocate.is())
+ return;
+
+ m_aOrderbyColumnNumber.push_back(xColLocate->findColumn(aColumnName));
+
+ // Ascending or Descending?
+ m_aOrderbyAscending.push_back((SQL_ISTOKEN(pAscendingDescending,DESC)) ? SQL_DESC : SQL_ASC);
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MStatement.hxx b/connectivity/source/drivers/mork/MStatement.hxx
new file mode 100644
index 000000000000..8fb3c08561b2
--- /dev/null
+++ b/connectivity/source/drivers/mork/MStatement.hxx
@@ -0,0 +1,202 @@
+/* -*- 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 CONNECTIVITY_SSTATEMENT_HXX
+#define CONNECTIVITY_SSTATEMENT_HXX
+
+#include <com/sun/star/sdbc/XStatement.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XBatchExecution.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <comphelper/proparrhlp.hxx>
+#include <cppuhelper/compbase3.hxx>
+#include <comphelper/uno3.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <list>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/sqliterator.hxx"
+#include "connectivity/sqlparse.hxx"
+#include <connectivity/FValue.hxx>
+#include "TSortIndex.hxx"
+#include "MConnection.hxx"
+#include "MTable.hxx"
+
+#include <boost/shared_ptr.hpp>
+
+namespace connectivity
+{
+ namespace mork
+ {
+ class OResultSet;
+
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XStatement,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::sdbc::XCloseable> OCommonStatement_IBASE;
+
+ //**************************************************************
+ //************ Class: OCommonStatement
+ // is a base class for the normal statement and for the prepared statement
+ //**************************************************************
+ class OCommonStatement;
+ typedef ::connectivity::OSubComponent< OCommonStatement, OCommonStatement_IBASE > OCommonStatement_SBASE;
+
+ class OCommonStatement :public comphelper::OBaseMutex
+ ,public OCommonStatement_IBASE
+ ,public ::cppu::OPropertySetHelper
+ ,public ::comphelper::OPropertyArrayUsageHelper< OCommonStatement >
+ ,public OCommonStatement_SBASE
+ {
+ friend class ::connectivity::OSubComponent< OCommonStatement, OCommonStatement_IBASE >;
+
+ private:
+ ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
+
+ protected:
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet > m_xResultSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xDBMetaData;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColNames; // table columns
+
+ // for this Statement
+
+ ::std::list< ::rtl::OUString> m_aBatchList;
+
+ OTable* m_pTable;
+ OConnection* m_pConnection; // The owning Connection object
+
+ OValueRow m_aRow;
+
+ connectivity::OSQLParser m_aParser;
+ ::boost::shared_ptr< ::connectivity::OSQLParseTreeIterator >
+ m_pSQLIterator;
+
+ connectivity::OSQLParseNode* m_pParseTree;
+
+ ::std::vector<sal_Int32> m_aColMapping;
+ ::std::vector<sal_Int32> m_aOrderbyColumnNumber;
+ ::std::vector<TAscendingOrder> m_aOrderbyAscending;
+
+ ::cppu::OBroadcastHelper& rBHelper;
+
+ protected:
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle) const;
+ virtual ~OCommonStatement();
+
+ protected:
+ //
+ // Driver Internal Methods
+ //
+ enum StatementType { eSelect, eCreateTable };
+ /** called to do the parsing of a to-be-executed SQL statement, and set all members as needed
+ */
+ virtual StatementType
+ parseSql( const ::rtl::OUString& sql , sal_Bool bAdjusted = sal_False) throw ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ /** called to initialize a result set, according to a previously parsed SQL statement
+ */
+ virtual void initializeResultSet( OResultSet* _pResult );
+ /** called when a possible cached instance of our last result set should be cleared
+ */
+ virtual void clearCachedResultSet();
+ /** caches a result set which has just been created by an execution of an SQL statement
+ */
+ virtual void cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult );
+
+
+ /** executes the current query (the one which has been passed to the last parseSql call)
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >
+ impl_executeCurrentQuery();
+
+ void createColumnMapping();
+ void analyseSQL();
+ void setOrderbyColumn( connectivity::OSQLParseNode* pColumnRef,
+ connectivity::OSQLParseNode* pAscendingDescending);
+ virtual void createTable( ) throw (
+ ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+
+ public:
+ // other methods
+ OConnection* getOwnConnection() const { return m_pConnection;}
+
+ OCommonStatement(OConnection* _pConnection );
+ using OCommonStatement_IBASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // XInterface
+ virtual void SAL_CALL release() throw();
+ virtual void SAL_CALL acquire() throw();
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // XStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ virtual sal_Bool SAL_CALL execute( 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::XConnection > SAL_CALL getConnection( ) 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);
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ protected:
+ using OPropertySetHelper::getFastPropertyValue;
+ };
+
+ class OStatement : public OCommonStatement,
+ public ::com::sun::star::lang::XServiceInfo
+ {
+ protected:
+ ~OStatement(){}
+ public:
+ // a constructor, for when the object needs to be returned:
+ OStatement( OConnection* _pConnection);
+ DECLARE_SERVICE_INFO();
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ };
+ }
+}
+#endif // CONNECTIVITY_SSTATEMENT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MTable.cxx b/connectivity/source/drivers/mork/MTable.cxx
new file mode 100644
index 000000000000..af142fe4210a
--- /dev/null
+++ b/connectivity/source/drivers/mork/MTable.cxx
@@ -0,0 +1,80 @@
+/* -*- 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 "MTable.hxx"
+#include "MTables.hxx"
+#include "MColumns.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <comphelper/sequence.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/TKeys.hxx"
+#include "connectivity/TIndexes.hxx"
+#include "MCatalog.hxx"
+
+
+using namespace ::comphelper;
+using namespace connectivity::mork;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+OTable::OTable( sdbcx::OCollection* _pTables, OConnection* _pConnection,
+ const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description )
+ :OTable_Base(_pTables, _pConnection, sal_True, _Name, _Type, _Description )
+ ,m_pConnection( _pConnection )
+{
+ construct();
+}
+
+//--------------------------------------------------------------------------
+sdbcx::OCollection* OTable::createColumns( const TStringVector& _rNames )
+{
+ return new OColumns( this, m_aMutex, _rNames );
+}
+
+//--------------------------------------------------------------------------
+sdbcx::OCollection* OTable::createKeys(const TStringVector& _rNames)
+{
+ return new OKeysHelper( this, m_aMutex, _rNames );
+}
+
+//--------------------------------------------------------------------------
+sdbcx::OCollection* OTable::createIndexes(const TStringVector& _rNames)
+{
+ return new OIndexesHelper( this, m_aMutex, _rNames );
+}
+
+// -----------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MTable.hxx b/connectivity/source/drivers/mork/MTable.hxx
new file mode 100644
index 000000000000..18d051034341
--- /dev/null
+++ b/connectivity/source/drivers/mork/MTable.hxx
@@ -0,0 +1,62 @@
+/* -*- 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 _CONNECTIVITY_MORK_TABLE_HXX_
+#define _CONNECTIVITY_MORK_TABLE_HXX_
+
+#include "connectivity/TTableHelper.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "MConnection.hxx"
+
+namespace connectivity
+{
+ namespace mork
+ {
+ typedef ::connectivity::OTableHelper OTable_Base;
+
+ class OTable : public OTable_Base
+ {
+ OConnection* m_pConnection;
+
+ public:
+ OTable( sdbcx::OCollection* _pTables,
+ OConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description );
+
+ OConnection* getConnection() { return m_pConnection;}
+
+ sal_Bool isReadOnly() const { return sal_False; }
+
+ ::rtl::OUString getTableName() const { return m_Name; }
+ ::rtl::OUString getSchema() const { return m_SchemaName; }
+
+ // OTableHelper overridables
+ virtual sdbcx::OCollection* createColumns( const TStringVector& _rNames );
+ virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames);
+ virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames);
+ private:
+ using OTable_Base::getConnection;
+ };
+ }
+}
+#endif // _CONNECTIVITY_MORK_TABLE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MTables.cxx b/connectivity/source/drivers/mork/MTables.cxx
new file mode 100644
index 000000000000..725f665b153e
--- /dev/null
+++ b/connectivity/source/drivers/mork/MTables.cxx
@@ -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 .
+ */
+
+#include "MTables.hxx"
+#include "MTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "MCatalog.hxx"
+#include "MConnection.hxx"
+#include <comphelper/extract.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace ::cppu;
+using namespace connectivity::mork;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+
+sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString aName,aSchema;
+ aSchema = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
+ aName = _rName;
+
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
+
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),aSchema,aName,aTypes);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ if(xResult->next()) // there can be only one table with this name
+ {
+ OTable* pRet = new OTable( this, static_cast<OCatalog&>(m_rParent).getConnection(),
+ aName,xRow->getString(4),xRow->getString(5));
+ xRet = pRet;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OTables::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MTables.hxx b/connectivity/source/drivers/mork/MTables.hxx
new file mode 100644
index 000000000000..d72a6d372dd8
--- /dev/null
+++ b/connectivity/source/drivers/mork/MTables.hxx
@@ -0,0 +1,48 @@
+/* -*- 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 _CONNECTIVITY_MORK_TABLES_HXX_
+#define _CONNECTIVITY_MORK_TABLES_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+namespace connectivity
+{
+ namespace mork
+ {
+ class OTables : public sdbcx::OCollection
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ // OCatalog* m_pParent;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector) : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector)
+ ,m_xMetaData(_rMetaData)
+ {}
+
+ // only the name is identical to ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ };
+ }
+}
+#endif // _CONNECTIVITY_MORK_TABLES_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MorkParser.cxx b/connectivity/source/drivers/mork/MorkParser.cxx
new file mode 100644
index 000000000000..b57fb94f6952
--- /dev/null
+++ b/connectivity/source/drivers/mork/MorkParser.cxx
@@ -0,0 +1,694 @@
+/*
+ * 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.
+ */
+
+#include "MorkParser.hxx"
+#include <stdlib.h>
+#include <sstream>
+#include <string>
+#include <string.h>
+#include <stdexcept>
+#include <fstream>
+#include <iostream>
+
+std::string g_Empty = "";
+
+// Mork header of supported format version
+const char *MorkMagicHeader = "// <!-- <mdb:mork:z v=\"1.4\"/> -->";
+
+const char *MorkDictColumnMeta = "<(a=c)>";
+
+
+MorkParser::MorkParser( int DefaultScope ) :
+ columns_(),
+ values_(),
+ mork_(),
+ currentCells_(0),
+ error_(NoError),
+ morkData_(),
+ morkPos_(0),
+ nextAddValueId_(0x7fffffff),
+ defaultScope_(DefaultScope),
+ defaultListScope_(0x81),
+ defaultTableId_(1),
+ nowParsing_(NPValues)
+{
+}
+
+bool MorkParser::open( const std::string &path )
+{
+ initVars();
+ std::string line;
+ std::ifstream infile(path.c_str(), std::ios_base::in);
+ if(!infile.is_open())
+ {
+ error_ = FailedToOpen;
+ return false;
+ }
+
+ while (getline(infile, line, '\n'))
+ {
+ morkData_.append(line);
+ morkData_.append("\n");
+ }
+
+ // Parse mork
+ return parse();
+}
+
+inline MorkErrors MorkParser::error()
+{
+ return error_;
+}
+
+void MorkParser::initVars()
+{
+ error_ = NoError;
+ morkPos_ = 0;
+ nowParsing_ = NPValues;
+ currentCells_ = 0;
+ nextAddValueId_ = 0x7fffffff;
+}
+
+bool MorkParser::parse()
+{
+ bool Result = true;
+ char cur = 0;
+
+ // Run over mork chars and parse each term
+ cur = nextChar();
+
+ int i = 0;
+
+ while ( Result && cur )
+ {
+ if ( !isWhiteSpace( cur ) )
+ {
+ i++;
+ // Figure out what a term
+ switch ( cur )
+ {
+ case '<':
+ // Dict
+ Result = parseDict();
+ break;
+ case '/':
+ // Comment
+ Result = parseComment();
+ break;
+ case '{':
+ Result = parseTable();
+ // Table
+ break;
+ case '[':
+ Result = parseRow( 0, 0 );
+ // Row
+ break;
+ case '@':
+ Result = parseGroup();
+ // Group
+ break;
+ default:
+ error_ = DefectedFormat;
+ Result = false;
+ break;
+ }
+ }
+
+ // Get next char
+ cur = nextChar();
+ }
+
+ return Result;
+}
+
+bool MorkParser::isWhiteSpace( char c )
+{
+ switch ( c )
+ {
+ case ' ':
+ case '\t':
+ case '\r':
+ case '\n':
+ case '\f':
+ return true;
+ default:
+ return false;
+ }
+}
+
+inline char MorkParser::nextChar()
+{
+ char cur = 0;
+
+
+ if ( morkPos_ < morkData_.length() )
+ {
+ cur = morkData_[ morkPos_ ];
+ morkPos_++;
+ }
+
+ if ( !cur )
+ {
+ cur = 0;
+ }
+
+ return cur;
+}
+
+bool MorkParser::parseDict()
+{
+ char cur = nextChar();
+ bool Result = true;
+ nowParsing_ = NPValues;
+
+ while ( Result && cur != '>' && cur )
+ {
+ if ( !isWhiteSpace( cur ) )
+ {
+ switch ( cur )
+ {
+ case '<':
+ {
+
+ if ( morkData_.substr( morkPos_ - 1, strlen( MorkDictColumnMeta ) ) == MorkDictColumnMeta )
+ {
+ nowParsing_ = NPColumns;
+ morkPos_ += strlen( MorkDictColumnMeta ) - 1;
+ }
+
+
+ break;
+ }
+ case '(':
+ Result = parseCell();
+ break;
+ case '/':
+ Result = parseComment();
+ break;
+
+ }
+ }
+
+ cur = nextChar();
+ }
+
+ return Result;
+}
+
+inline bool MorkParser::parseComment()
+{
+ char cur = nextChar();
+ if ( '/' != cur ) return false;
+
+ while ( cur != '\r' && cur != '\n' && cur )
+ {
+ cur = nextChar();
+ }
+
+ return true;
+}
+
+bool MorkParser::parseCell()
+{
+ bool Result = true;
+ bool bValueOid = false;
+ bool bColumn = true;
+ int Corners = 0;
+
+ // Column = Value
+ std::string Column;
+ std::string Text;
+ Column.reserve( 4 );
+ Text.reserve( 32 );
+
+ char cur = nextChar();
+
+ // Process cell start with column (bColumn == true)
+ while ( Result && cur != ')' && cur )
+ {
+ switch ( cur )
+ {
+ case '^':
+ // Oids
+ Corners++;
+ if ( 1 == Corners )
+ {
+ }
+ else if ( 2 == Corners )
+ {
+ bColumn = false;
+ bValueOid = true;
+ }
+ else
+ {
+ Text += cur;
+ }
+
+ break;
+ case '=':
+ // From column to value
+ if ( bColumn )
+ {
+ bColumn = false;
+ }
+ else
+ {
+ Text += cur;
+ }
+ break;
+ case '\\':
+ {
+ // Get next two chars
+ char NextChar= nextChar();
+ if ( '\r' != NextChar && '\n' != NextChar )
+ {
+ Text += NextChar;
+ }
+ else nextChar();
+ }
+ break;
+ case '$':
+ {
+ // Get next two chars
+ std::string HexChar;
+ HexChar += nextChar();
+ HexChar += nextChar();
+ Text += (char)strtoul(HexChar.c_str(), 0, 16);
+ }
+ break;
+ default:
+ // Just a char
+ if ( bColumn )
+ {
+ Column += cur;
+ }
+ else
+ {
+ Text += cur;
+ }
+ break;
+ }
+
+ cur = nextChar();
+ }
+
+ // Apply column and text
+ int ColumnId = strtoul(Column.c_str(), 0, 16);
+
+ if ( NPRows != nowParsing_ )
+ {
+ // Dicts
+ if ( "" != Text )
+ {
+ if ( nowParsing_ == NPColumns )
+ {
+ columns_[ ColumnId ] = Text;
+ }
+ else
+ {
+ values_[ ColumnId ] = Text;
+ }
+ }
+ }
+ else
+ {
+ if ( "" != Text )
+ {
+ // Rows
+ //int ValueId = string( Text.c_str() ).toInt( 0, 16 );
+ int ValueId = strtoul(Text.c_str(), 0, 16);
+
+ if ( bValueOid )
+ {
+ ( *currentCells_ )[ ColumnId ] = ValueId;
+ }
+ else
+ {
+ nextAddValueId_--;
+ values_[ nextAddValueId_ ] = Text;
+ ( *currentCells_ )[ ColumnId ] = nextAddValueId_;
+ }
+ }
+ }
+
+ return Result;
+}
+
+bool MorkParser::parseTable()
+{
+ bool Result = true;
+ std::string TextId;
+ int Id = 0, Scope = 0;
+
+ char cur = nextChar();
+
+ // Get id
+ while ( cur != '{' && cur != '[' && cur != '}' && cur )
+ {
+ if ( !isWhiteSpace( cur ) )
+ {
+ TextId += cur;
+ }
+
+ cur = nextChar();
+ }
+
+ parseScopeId( TextId, &Id, &Scope );
+
+ // Parse the table
+ while ( Result && cur != '}' && cur )
+ {
+ if ( !isWhiteSpace( cur ) )
+ {
+ switch ( cur )
+ {
+ case '{':
+ Result = parseMeta( '}' );
+ break;
+ case '[':
+ Result = parseRow( Id, Scope );
+ break;
+ case '-':
+ case '+':
+ break;
+ default:
+ {
+ std::string JustId;
+ while ( !isWhiteSpace( cur ) && cur )
+ {
+ JustId += cur;
+ cur = nextChar();
+
+ if ( cur == '}' )
+ {
+ return Result;
+ }
+ }
+
+ int JustIdNum = 0, JustScopeNum = 0;
+ parseScopeId( JustId, &JustIdNum, &JustScopeNum );
+
+ setCurrentRow( Scope, Id, JustScopeNum, JustIdNum );
+ }
+ break;
+ }
+ }
+
+ cur = nextChar();
+ }
+
+ return Result;
+}
+
+void MorkParser::parseScopeId( const std::string &TextId, int *Id, int *Scope )
+{
+ int Pos = 0;
+
+ if ( ( Pos = TextId.find( ':' ) ) >= 0 )
+ {
+ std::string tId = TextId.substr( 0, Pos );
+ std::string tSc = TextId.substr( Pos + 1, TextId.length() - Pos );
+
+ if ( tSc.length() > 1 && '^' == tSc[ 0 ] )
+ {
+ // Delete '^'
+ tSc.erase( 0, 1 );
+ }
+
+ *Id = strtoul(tId.c_str(), 0, 16);
+
+ *Scope = strtoul(tSc.c_str(), 0, 16);
+ }
+ else
+ {
+ *Id = strtoul(TextId.c_str(), 0, 16);
+ }
+}
+
+inline void MorkParser::setCurrentRow( int TableScope, int TableId, int RowScope, int RowId )
+{
+ if ( !RowScope )
+ {
+ RowScope = defaultScope_;
+ }
+
+ if ( !TableScope )
+ {
+ TableScope = defaultScope_;
+ }
+
+ // 01.08.2012 davido
+ // TableId 0 is wrong here.
+ // Straying rows (rows that defined outside the table) belong to the default scope and table is the last was seen: 1:^80
+ // (at least i read so the specification)
+ if (TableId)
+ {
+ defaultTableId_ = TableId;
+ }
+
+ if (!TableId)
+ {
+ TableId = defaultTableId_;
+ }
+
+ currentCells_ = &( mork_[ abs( TableScope ) ][ abs( TableId ) ][ abs( RowScope ) ][ abs( RowId ) ] );
+}
+
+bool MorkParser::parseRow( int TableId, int TableScope )
+{
+ bool Result = true;
+ std::string TextId;
+ int Id = 0, Scope = 0;
+ nowParsing_ = NPRows;
+
+ char cur = nextChar();
+
+ // Get id
+ while ( cur != '(' && cur != ']' && cur != '[' && cur )
+ {
+ if ( !isWhiteSpace( cur ) )
+ {
+ TextId += cur;
+ }
+
+ cur = nextChar();
+ }
+
+ parseScopeId( TextId, &Id, &Scope );
+ setCurrentRow( TableScope, TableId, Scope, Id );
+
+ // Parse the row
+ while ( Result && cur != ']' && cur )
+ {
+ if ( !isWhiteSpace( cur ) )
+ {
+ switch ( cur )
+ {
+ case '(':
+ Result = parseCell();
+ break;
+ case '[':
+ Result = parseMeta( ']' );
+ break;
+ default:
+ Result = false;
+ break;
+ }
+ }
+
+ cur = nextChar();
+ }
+
+ return Result;
+}
+
+bool MorkParser::parseGroup()
+{
+ return parseMeta( '@' );
+}
+
+bool MorkParser::parseMeta( char c )
+{
+ char cur = nextChar();
+
+ while ( cur != c && cur )
+ {
+ cur = nextChar();
+ }
+
+ return true;
+}
+
+MorkTableMap *MorkParser::getTables( int TableScope )
+{
+ TableScopeMap::iterator iter;
+ iter = mork_.find( TableScope );
+
+ if ( iter == mork_.end() )
+ {
+ return 0;
+ }
+
+ return &iter->second;
+}
+
+MorkRowMap *MorkParser::getRows( int RowScope, RowScopeMap *table )
+{
+ RowScopeMap::iterator iter;
+ iter = table->find( RowScope );
+
+ if ( iter == table->end() )
+ {
+ return 0;
+ }
+
+ return &iter->second;
+}
+
+std::string &MorkParser::getValue( int oid )
+{
+ MorkDict::iterator foundIter = values_.find( oid );
+
+ if ( values_.end() == foundIter )
+ {
+ return g_Empty;
+ }
+
+ return foundIter->second;
+}
+
+std::string &MorkParser::getColumn( int oid )
+{
+ MorkDict::iterator foundIter = columns_.find( oid );
+
+ if ( columns_.end() == foundIter )
+ {
+ return g_Empty;
+ }
+
+ return foundIter->second;
+}
+
+void MorkParser::dump()
+{
+ std::cout << "Column Dict:\r\n";
+ std::cout << "=============================================\r\n\r\n";
+
+ //// columns dict
+ for ( MorkDict::iterator iter = columns_.begin();
+ iter != columns_.end(); iter++ )
+ {
+ std::cout << std::hex << std::uppercase << iter->first
+ << " : "
+ << iter->second
+ << std::endl;
+ }
+
+ //// values dict
+ std::cout << "\r\nValues Dict:\r\n";
+ std::cout << "=============================================\r\n\r\n";
+
+ for ( MorkDict::iterator iter = values_.begin();
+ iter != values_.end(); iter++ )
+ {
+ if (iter->first >= nextAddValueId_) {
+ continue;
+ }
+
+ std::cout << std::hex << std::uppercase << iter->first
+ << " : "
+ << iter->second
+ << "\r\n";
+ }
+
+ std::cout << std::endl << "Data:" << std::endl;
+ std::cout << "============================================="
+ << std::endl << std::endl;
+
+ //// Mork data
+ for ( TableScopeMap::iterator iter = mork_.begin();
+ iter != mork_.end(); iter++ )
+ {
+ std::cout << "\r\n Scope:" << std::hex << std::uppercase
+ << iter->first << std::endl;
+
+ for ( MorkTableMap::iterator TableIter = iter->second.begin();
+ TableIter != iter->second.end(); TableIter++ )
+ {
+ std::cout << "\t Table:"
+ << ( ( int ) TableIter->first < 0 ? "-" : " " )
+ << std::hex << std::uppercase << TableIter->first << std::endl;
+
+ for (RowScopeMap::iterator RowScopeIter = TableIter->second.begin();
+ RowScopeIter != TableIter->second.end(); RowScopeIter++ )
+ {
+ std::cout << "\t\t RowScope:"
+ << std::hex << std::uppercase
+ << RowScopeIter->first << std::endl;
+
+ for (MorkRowMap::iterator RowIter = RowScopeIter->second.begin();
+ RowIter != RowScopeIter->second.end(); RowIter++ )
+ {
+ std::cout << "\t\t\t Row Id:"
+ << ((int) RowIter->first < 0 ? "-" : " ")
+ << std::hex << std::uppercase
+ << RowIter->first << std::endl;
+ std::cout << "\t\t\t\t Cells:" << std::endl;
+
+ for (MorkCells::iterator CellsIter = RowIter->second.begin();
+ CellsIter != RowIter->second.end(); CellsIter++ )
+ {
+ // Write ids
+ std::cout << "\t\t\t\t\t"
+ << std::hex << std::uppercase
+ << CellsIter->first
+ << " : "
+ << std::hex << std::uppercase
+ << CellsIter->second
+ << " => ";
+
+ MorkDict::iterator FoundIter = values_.find( CellsIter->second );
+ if ( FoundIter != values_.end() )
+ {
+ // Write string values
+ std::cout << columns_[ CellsIter->first ].c_str()
+ << " : "
+ << FoundIter->second.c_str()
+ << std::endl;
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/connectivity/source/drivers/mork/MorkParser.hxx b/connectivity/source/drivers/mork/MorkParser.hxx
new file mode 100644
index 000000000000..76544411264a
--- /dev/null
+++ b/connectivity/source/drivers/mork/MorkParser.hxx
@@ -0,0 +1,168 @@
+/*
+ * 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.
+ */
+
+#ifndef _MORK_PARSER_HXX_
+#define _MORK_PARSER_HXX_
+
+#include <sal/types.h>
+
+#include <string>
+#include <map>
+
+#include "dllapi.h"
+
+// Types
+
+typedef std::map< int, std::string > MorkDict;
+typedef std::map< int, int > MorkCells; // ColumnId : ValueId
+typedef std::map< int, MorkCells > MorkRowMap; // Row id
+typedef std::map< int, MorkRowMap > RowScopeMap; // Row scope
+typedef std::map< int, RowScopeMap > MorkTableMap; // Table id
+typedef std::map< int, MorkTableMap > TableScopeMap; // Table Scope
+
+// Error codes
+enum MorkErrors
+{
+ NoError = 0,
+ FailedToOpen,
+ UnsupportedVersion,
+ DefectedFormat
+};
+
+// Mork term types
+enum MorkTerm
+{
+ NoneTerm = 0,
+ DictTerm,
+ GroupTerm,
+ TableTerm,
+ RowTerm,
+ CellTerm,
+ CommentTerm,
+ LiteralTerm
+};
+
+
+/// Class MorkParser
+
+class LO_DLLPUBLIC_MORK MorkParser
+{
+public:
+
+ MorkParser( int defaultScope = 0x80 );
+
+ ///
+ /// Open and parse mork file
+
+ bool open( const std::string &path );
+
+ ///
+ /// Return error status
+
+ MorkErrors error();
+
+ ///
+ /// Returns all tables of specified scope
+
+ MorkTableMap *getTables( int tableScope );
+
+ ///
+ /// Rerturns all rows under specified scope
+
+ MorkRowMap *getRows( int rowScope, RowScopeMap *table );
+
+ ///
+ /// Return value of specified value oid
+
+ std::string &getValue( int oid );
+
+ ///
+ /// Return value of specified column oid
+
+ std::string &getColumn( int oid );
+
+ void dump();
+
+protected: // Members
+
+ void initVars();
+
+ bool isWhiteSpace( char c );
+ char nextChar();
+
+ void parseScopeId( const std::string &TextId, int *Id, int *Scope );
+ void setCurrentRow( int TableScope, int TableId, int RowScope, int RowId );
+
+ // Parse methods
+ bool parse();
+ bool parseDict();
+ bool parseComment();
+ bool parseCell();
+ bool parseTable();
+ bool parseMeta( char c );
+ bool parseRow( int TableId, int TableScope );
+ bool parseGroup();
+
+protected: // Data
+
+ // Columns in mork means value names
+ MorkDict columns_;
+ MorkDict values_;
+
+ // All mork file data
+ TableScopeMap mork_;
+ MorkCells *currentCells_;
+
+ // Error status of last operation
+ MorkErrors error_;
+
+ // All Mork data
+ std::string morkData_;
+
+ unsigned morkPos_;
+ int nextAddValueId_;
+ int defaultScope_;
+ int defaultListScope_;
+ int defaultTableId_;
+
+ // Indicates intity is being parsed
+ enum { NPColumns, NPValues, NPRows } nowParsing_;
+
+private:
+ MorkParser(const MorkParser &);
+ MorkParser &operator=(const MorkParser &);
+
+};
+
+#endif // __MorkParser_h__
+
diff --git a/connectivity/source/drivers/mork/README b/connectivity/source/drivers/mork/README
new file mode 100644
index 000000000000..9d8eb818e5fb
--- /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@scalingweb.com
+
+ http://www.scalingweb.com/
+
+Thanks
+-------------
+Thanks to Petr Stejskal <stejsky@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/dllapi.h b/connectivity/source/drivers/mork/dllapi.h
new file mode 100644
index 000000000000..80f7cec756c8
--- /dev/null
+++ b/connectivity/source/drivers/mork/dllapi.h
@@ -0,0 +1,25 @@
+
+/* -*- 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_DLLAPI_H
+#define _MORK_DLLAPI_H
+
+#include "sal/config.h"
+#include "sal/types.h"
+
+#if defined LO_DLLIMPLEMENTATION_MORK
+#define LO_DLLPUBLIC_MORK SAL_DLLPUBLIC_EXPORT
+#else
+#define LO_DLLPUBLIC_MORK SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/license.txt b/connectivity/source/drivers/mork/license.txt
new file mode 100644
index 000000000000..3e41befc7e7c
--- /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.
+
diff --git a/connectivity/source/drivers/mork/mork.component b/connectivity/source/drivers/mork/mork.component
new file mode 100644
index 000000000000..b8124faeb922
--- /dev/null
+++ b/connectivity/source/drivers/mork/mork.component
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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/.
+ *
+-->
+
+<component loader="com.sun.star.loader.SharedLibrary"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.sdbc.MorkDriver">
+ <service name="com.sun.star.sdbc.Driver"/>
+ </implementation>
+</component>
diff --git a/connectivity/source/drivers/mork/mork.xml b/connectivity/source/drivers/mork/mork.xml
new file mode 100644
index 000000000000..cb1ce0b47c1e
--- /dev/null
+++ b/connectivity/source/drivers/mork/mork.xml
@@ -0,0 +1,85 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<!--
+ * 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 .
+ -->
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> mork </module-name>
+ <component-description>
+ <Author>David Ostrovsky</Author>
+ <Name>com.sun.star.comp.sdbc.MorkDriver</Name>
+ <Description>
+ This is the implementation of the sdbc-mork bridge.
+ </Description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service> com.sun.star.sdbc.Driver </supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+
+ <runtime-module-dependency> cppuhelper </runtime-module-dependency>
+ <runtime-module-dependency> cppu1 </runtime-module-dependency>
+ <runtime-module-dependency> sal1 </runtime-module-dependency>
+
+
+
+ <type> com.sun.star.util.XCancellable </type>
+ <type> com.sun.star.util.XNumberFormatter </type>
+ <type> com.sun.star.uno.TypeClass </type>
+ <type> com.sun.star.uno.XWeak </type>
+ <type> com.sun.star.uno.XAggregation </type>
+ <type> com.sun.star.beans.XPropertyState </type>
+ <type> com.sun.star.beans.XPropertySet </type>
+ <type> com.sun.star.beans.PropertyValue </type>
+ <type> com.sun.star.beans.XMultiPropertySet </type>
+ <type> com.sun.star.beans.XFastPropertySet </type>
+ <type> com.sun.star.lang.XTypeProvider </type>
+ <type> com.sun.star.lang.EventObject </type>
+ <type> com.sun.star.lang.XComponent </type>
+ <type> com.sun.star.lang.IllegalArgumentException </type>
+ <type> com.sun.star.lang.XMultiServiceFactory </type>
+ <type> com.sun.star.java.XJavaThreadRegister_11 </type>
+ <type> com.sun.star.java.XJavaVM </type>
+ <type> com.sun.star.sdbc.XConnection </type>
+ <type> com.sun.star.sdbc.XStatement </type>
+ <type> com.sun.star.sdbc.XResultSet </type>
+ <type> com.sun.star.sdbc.XResultSetMetaDataSupplier</type>
+ <type> com.sun.star.sdbc.XColumnLocate </type>
+ <type> com.sun.star.sdbc.XResultSetUpdate </type>
+ <type> com.sun.star.sdbc.XWarningsSupplier </type>
+ <type> com.sun.star.sdbc.XRowUpdate </type>
+ <type> com.sun.star.sdbc.XMultipleResults </type>
+ <type> com.sun.star.sdbc.XBatchExecution </type>
+ <type> com.sun.star.sdbc.XPreparedBatchExecution </type>
+ <type> com.sun.star.sdbc.XParameters </type>
+ <type> com.sun.star.sdbc.XOutParameters </type>
+ <type> com.sun.star.sdbc.DriverPropertyInfo </type>
+ <type> com.sun.star.sdbc.XRow </type>
+ <type> com.sun.star.sdb.XColumnUpdate </type>
+ <type> com.sun.star.sdb.XColumn </type>
+ <type> com.sun.star.sdbc.XResultSetUpdate </type>
+ <type> com.sun.star.sdbc.XRowUpdate </type>
+ <type> com.sun.star.sdbcx.XRowLocate </type>
+ <type> com.sun.star.sdbcx.XDeleteRows </type>
+
+</module-description>
+
+
diff --git a/connectivity/source/drivers/mork/mork_helper.cxx b/connectivity/source/drivers/mork/mork_helper.cxx
new file mode 100644
index 000000000000..74a344f720eb
--- /dev/null
+++ b/connectivity/source/drivers/mork/mork_helper.cxx
@@ -0,0 +1,86 @@
+#include "MNSProfileDiscover.hxx"
+#include "MorkParser.hxx"
+
+
+using namespace connectivity::mork;
+
+bool openAddressBook(const std::string& path)
+{
+ MorkParser mork;
+ // Open and parse mork file
+ if (!mork.open(path))
+ {
+ return false;
+ }
+ const int defaultScope = 0x80;
+ MorkTableMap *Tables = 0;
+ MorkTableMap::iterator tableIter;
+ MorkRowMap::iterator rowIter;
+ Tables = mork.getTables( defaultScope );
+ if ( Tables )
+ {
+ // Iterate all tables
+ for ( tableIter = Tables->begin(); tableIter != Tables->end(); tableIter++ )
+ {
+ if ( 0 == tableIter->first ) continue;
+ SAL_INFO("connectivity.mork", "table->first : " << tableIter->first);
+ std::string column = mork.getColumn( tableIter->first );
+ std::string value = mork.getValue( tableIter->first );
+ SAL_INFO("connectivity.mork", "table.column : " << column);
+ SAL_INFO("connectivity.mork", "table.value : " << value);
+#if 0
+ MorkRowMap *Rows = 0;
+ // Get rows
+ Rows = mork.getRows( defaultScope, &tableIter->second );
+ if ( Rows ) {
+ // Iterate all rows
+ for ( rowIter = Rows->begin(); rowIter != Rows->end(); rowIter++ )
+ {
+ if ( 0 == rowIter->first ) continue;
+ RawAbeMap ram;
+ std::string column;
+ std::string value;
+ char buffer[20];
+ sprintf( buffer, "%d", rowIter->first );
+ abe.id = std::string( buffer );
+ // Get cells
+ for ( MorkCells::iterator cellsIter = rowIter->second.begin();
+ cellsIter != rowIter->second.end(); cellsIter++ )
+ {
+ column = mork.getColumn( cellsIter->first );
+ value = mork.getValue( cellsIter->second );
+ ram[ column ] = value;
+ }
+ AbeMap::iterator abeIter;
+ abes_[ rowIter->first ] = abe;
+ abeIter = abes_.find( rowIter->first );
+ addEntry( ram, abeIter->second );
+ }
+ }
+#endif
+ }
+ }
+
+ mork.dump();
+
+ return true;
+}
+
+int main( int argc, const char* argv[] )
+{
+ int x = argc;
+ x++;
+ argv++;
+ ProfileAccess* access = new ProfileAccess();
+ ::rtl::OUString defaultProfile = access->getDefaultProfile(::com::sun::star::mozilla::MozillaProductType_Thunderbird);
+ SAL_INFO("connectivity.mork", "DefaultProfile: " << defaultProfile);
+
+ ::rtl::OUString profilePath = access->getProfilePath(::com::sun::star::mozilla::MozillaProductType_Thunderbird, defaultProfile);
+ SAL_INFO("connectivity.mork", "ProfilePath: " << profilePath);
+
+ profilePath += rtl::OUString( "/abook.mab" );
+
+ SAL_INFO("connectivity.mork", "abook.mab: " << profilePath);
+ rtl::OString aOString = ::rtl::OUStringToOString( profilePath, RTL_TEXTENCODING_UTF8 );
+ openAddressBook(aOString.getStr());
+}
diff --git a/connectivity/source/drivers/mork/post_include_windows.h b/connectivity/source/drivers/mork/post_include_windows.h
new file mode 100644
index 000000000000..bd49753b7bd7
--- /dev/null
+++ b/connectivity/source/drivers/mork/post_include_windows.h
@@ -0,0 +1,24 @@
+/* -*- 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 .
+ */
+
+#ifdef _MSC_VER
+ #pragma warning(pop)
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/pre_include_windows.h b/connectivity/source/drivers/mork/pre_include_windows.h
new file mode 100644
index 000000000000..7d68ce298f9e
--- /dev/null
+++ b/connectivity/source/drivers/mork/pre_include_windows.h
@@ -0,0 +1,25 @@
+/* -*- 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 .
+ */
+
+#ifdef _MSC_VER
+ #pragma warning(push,1)
+ #pragma warning(disable:4668 4917)
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/services.cxx b/connectivity/source/drivers/mork/services.cxx
new file mode 100644
index 000000000000..aa610e1f73bc
--- /dev/null
+++ b/connectivity/source/drivers/mork/services.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/.
+ */
+
+#include "sal/config.h"
+
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "sal/types.h"
+
+#include "MorkDriver.hxx"
+
+namespace
+{
+
+static cppu::ImplementationEntry const services[] =
+{
+ {
+ &connectivity::mork::create, &connectivity::mork::getImplementationName,
+ &connectivity::mork::getSupportedServiceNames,
+ &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/inc/resource/conn_shared_res.hrc b/connectivity/source/inc/resource/conn_shared_res.hrc
index 47171b89c7d0..e854dd2442eb 100644
--- a/connectivity/source/inc/resource/conn_shared_res.hrc
+++ b/connectivity/source/inc/resource/conn_shared_res.hrc
@@ -24,6 +24,8 @@
// Mozilla driver resource ids
#define STR_MOZAB_BASE 1000
+// either mozab or mork is actually used
+#define STR_MORK_BASE 1000
// common resource ids
#define STR_COMMON_BASE 1200
diff --git a/connectivity/source/inc/resource/mork_res.hrc b/connectivity/source/inc/resource/mork_res.hrc
new file mode 100644
index 000000000000..c8d44edb0c34
--- /dev/null
+++ b/connectivity/source/inc/resource/mork_res.hrc
@@ -0,0 +1,63 @@
+/*
+ * 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 CONNECTIVITY_RESOURCE_MORK_HRC
+#define CONNECTIVITY_RESOURCE_MORK_HRC
+
+#include "resource/conn_shared_res.hrc"
+
+// ============================================================================
+// = the mozab driver's resource strings
+// ============================================================================
+
+#define STR_MOZILLA_ADDRESSBOOKS ( STR_MORK_BASE + 0 )
+#define STR_THUNDERBIRD_ADDRESSBOOKS ( STR_MORK_BASE + 1 )
+#define STR_OE_ADDRESSBOOK ( STR_MORK_BASE + 2 )
+#define STR_OUTLOOK_MAPI_ADDRESSBOOK ( STR_MORK_BASE + 3 )
+ // FREE
+#define STR_NO_TABLE_CREATION_SUPPORT ( STR_MORK_BASE + 5 )
+#define STR_MOZILLA_IS_RUNNING ( STR_MORK_BASE + 6 )
+#define STR_COULD_NOT_RETRIEVE_AB_ENTRY ( STR_MORK_BASE + 7 )
+#define STR_COULD_NOT_GET_DIRECTORY_NAME ( STR_MORK_BASE + 8 )
+#define STR_TIMEOUT_WAITING ( STR_MORK_BASE + 9 )
+#define STR_ERR_EXECUTING_QUERY ( STR_MORK_BASE + 10 )
+#define STR_MOZILLA_IS_RUNNIG_NO_CHANGES ( STR_MORK_BASE + 11 )
+#define STR_FOREIGN_PROCESS_CHANGED_AB ( STR_MORK_BASE + 12 )
+#define STR_CANT_FIND_ROW ( STR_MORK_BASE + 13 )
+#define STR_CANT_FIND_CARD_FOR_ROW ( STR_MORK_BASE + 14 )
+#define STR_QUERY_INVALID_IS_NULL_COLUMN ( STR_MORK_BASE + 15 )
+#define STR_NO_HOSTNAME ( STR_MORK_BASE + 16 )
+#define STR_NO_BASEDN ( STR_MORK_BASE + 17 )
+#define STR_COULD_NOT_CONNECT_LDAP ( STR_MORK_BASE + 18 )
+#define STR_ERROR_REFRESH_ROW ( STR_MORK_BASE + 19 )
+#define STR_ILLEGAL_MOVEMENT ( STR_MORK_BASE + 20 )
+#define STR_ERROR_GET_ROW ( STR_MORK_BASE + 21 )
+#define STR_COMMIT_ROW ( STR_MORK_BASE + 22 )
+#define STR_INVALID_ROW_UPDATE ( STR_MORK_BASE + 23 )
+#define STR_ROW_CAN_NOT_SAVE ( STR_MORK_BASE + 24 )
+#define STR_CAN_NOT_CANCEL_ROW_UPDATE ( STR_MORK_BASE + 25 )
+#define STR_CAN_NOT_CREATE_ROW ( STR_MORK_BASE + 26 )
+#define STR_QUERY_AT_LEAST_ONE_TABLES ( STR_MORK_BASE + 27 )
+#define STR_NO_COUNT_SUPPORT ( STR_MORK_BASE + 28 )
+#define STR_STMT_TYPE_NOT_SUPPORTED ( STR_MORK_BASE + 29 )
+#define STR_COULD_NOT_LOAD_LIB ( STR_MORK_BASE + 30 )
+#define STR_UNSPECIFIED_ERROR ( STR_MORK_BASE + 31 )
+#define STR_COULD_NOT_CREATE_ADDRESSBOOK ( STR_MORK_BASE + 32 )
+
+#endif // CONNECTIVITY_RESOURCE_MOZAB_HRC
+