Kaydet (Commit) 4ffdb675 authored tarafından Michael Stahl's avatar Michael Stahl

remove TDE integration (vclplug, address book, config backend)

It has ~no users, can't even be built on modern Linuxes, and it annoys
folks who want to refactor VCL.

Per ESC decision from 2017-06-08, remove --enable-tde and --enable-tdeab.

Change-Id: I51ce4786f29f8fcac2e2bb2a654c41fbfbbd8afd
Reviewed-on: https://gerrit.libreoffice.org/38718Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 144edb88
......@@ -258,17 +258,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,graphicfilter, \
graphicfilter \
))
$(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,tde, \
$(if $(ENABLE_TDE),tdebe1) \
$(if $(USING_X11), \
$(if $(ENABLE_TDE),vclplug_tde) \
) \
))
$(eval $(call gb_Helper_register_executables_for_install,OOO,tde, \
$(if $(ENABLE_TDE),tdefilepicker) \
))
$(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,impress, \
animcore \
PresenterScreen \
......@@ -423,8 +412,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
svxcore \
sw \
syssh \
$(if $(ENABLE_TDEAB),tdeab1) \
$(if $(ENABLE_TDEAB),tdeabdrv1) \
textconversiondlgs \
textfd \
tk \
......
......@@ -2975,28 +2975,6 @@ endef
endif # ENABLE_KDE4
ifeq ($(ENABLE_TDE),TRUE)
define gb_LinkTarget__use_tde
$(call gb_LinkTarget_add_libs,$(1),\
$(TDE_LIBS) \
)
$(call gb_LinkTarget_set_include,$(1),\
$$(INCLUDE) \
$(TDE_CFLAGS) \
)
endef
else # ! ENABLE_TDE
define gb_LinkTarget__use_tde
endef
endif # ENABLE_TDE
# PYTHON
# extra python_headers external because pyuno wrapper must not link python
ifneq ($(SYSTEM_PYTHON),)
......
......@@ -216,15 +216,6 @@ if test "z$OOO_VENDOR" != "zDebian" ; then
cd $FILELISTSDIR
# tde subpackage
test -f $DESTDIR/gid_Module_Optional_Tde && cp $DESTDIR/gid_Module_Optional_Tde tde_list.txt || :
mv_file_between_flists tde_list.txt common_list.txt $INSTALLDIR/program/tdefilepicker
mv_file_between_flists tde_list.txt common_list.txt $INSTALLDIR/program/fps_tdelo.so
mv_file_between_flists tde_list.txt common_list.txt $INSTALLDIR/program/libvclplug_tdel..so
mv_file_between_flists tde_list.txt common_list.txt $INSTALLDIR/program/libtdeab1l..so
mv_file_between_flists tde_list.txt common_list.txt $INSTALLDIR/program/libtdeabdrv1l..so
add_used_directories tde_list.txt common_list.txt
# create kde4 subpackage
test -f $DESTDIR/gid_Module_Optional_Kde && cp $DESTDIR/gid_Module_Optional_Kde kde4_list.txt || :
mv_file_between_flists kde4_list.txt common_list.txt $INSTALLDIR/program/libvclplug_kde4l..so
......@@ -404,7 +395,6 @@ else
create_package_directory gid_Module_Brand_Prg_Base pkg/libreoffice-base
create_package_directory gid_Module_Pyuno pkg/python-uno
create_package_directory gid_Module_Optional_Gnome pkg/libreoffice-gnome
create_package_directory gid_Module_Optional_Tde pkg/libreoffice-tde
create_package_directory gid_Module_Root_Files_2 pkg/libreoffice-common
create_package_directory gid_Module_Root_Files_3 pkg/libreoffice-common
......@@ -476,7 +466,7 @@ else
fi &&
( cd pkg/libreoffice-common/$d
find -maxdepth 1 \
-regex '\./\(.*\.so.*\|.*\.bin\|pagein\|tdefilepicker\|msfontextract\|.*\.rdb\|javaldx\|uri-encode\)' \
-regex '\./\(.*\.so.*\|.*\.bin\|pagein\|msfontextract\|.*\.rdb\|javaldx\|uri-encode\)' \
-exec mv {} $DESTDIR/pkg/libreoffice-core/$d \;
); \
done
......
......@@ -168,8 +168,6 @@ export ENABLE_SDREMOTE_BLUETOOTH=@ENABLE_SDREMOTE_BLUETOOTH@
export ENABLE_SILENT_MSI=@ENABLE_SILENT_MSI@
export ENABLE_SYMBOLS=@ENABLE_SYMBOLS@
export ENABLE_SYSTRAY_GTK=@ENABLE_SYSTRAY_GTK@
export ENABLE_TDE=@ENABLE_TDE@
export ENABLE_TDEAB=@ENABLE_TDEAB@
export ENABLE_VALGRIND=@ENABLE_VALGRIND@
export ENABLE_VLC=@ENABLE_VLC@
export ENABLE_WERROR=@ENABLE_WERROR@
......@@ -562,9 +560,6 @@ export SYSTEM_WPS=@SYSTEM_WPS@
export SYSTEM_ZLIB=@SYSTEM_ZLIB@
export SYSTEM_ZMF=@SYSTEM_ZMF@
export TARFILE_LOCATION=@TARFILE_LOCATION@
export TDE_CFLAGS=$(gb_SPACE)@TDE_CFLAGS@
export TDE_LIBS=$(gb_SPACE)@TDE_LIBS@
export TDE_MOC=$(gb_SPACE)@TDE_MOC@
export TESTINSTALLDIR=@TESTINSTALLDIR@
export THES_SYSTEM_DIR=@THES_SYSTEM_DIR@
export TLS=@TLS@
......
......@@ -9,6 +9,5 @@ Settings about which X11 desktops have support enabled.
#define ENABLE_GTK 0
#define ENABLE_KDE4 0
#define ENABLE_TDE 0
#endif
This diff is collapsed.
# -*- 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_tdeab))
$(eval $(call gb_Configuration_add_spool_modules,driver_tdeab,connectivity/registry/tdeab,\
org/openoffice/Office/DataAccess/Drivers-tdeab.xcu \
))
$(eval $(call gb_Configuration_add_localized_datas,driver_tdeab,connectivity/registry/tdeab,\
org/openoffice/Office/DataAccess/Drivers.xcu \
))
# vim: set noet sw=4 ts=4:
# -*- 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,tdeab1))
$(eval $(call gb_Library_use_externals,tdeab1,\
boost_headers \
tde \
))
$(eval $(call gb_Library_set_componentfile,tdeab1,connectivity/source/drivers/kab/tdeab1))
$(eval $(call gb_Library_set_include,tdeab1,\
-I$(SRCDIR)/connectivity/source/inc \
$$(INCLUDE) \
))
$(eval $(call gb_Library_use_sdk_api,tdeab1))
$(eval $(call gb_Library_use_libraries,tdeab1,\
comphelper \
cppu \
cppuhelper \
dbtools \
sal \
salhelper \
tl \
))
$(eval $(call gb_Library_add_exception_objects,tdeab1,\
connectivity/source/drivers/kab/KDriver \
connectivity/source/drivers/kab/KServices \
))
# vim: set noet sw=4 ts=4:
# -*- 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,tdeabdrv1))
$(eval $(call gb_Library_set_include,tdeabdrv1,\
-I$(SRCDIR)/connectivity/source/inc \
$$(INCLUDE) \
-I$(WORKDIR)/YaccTarget/connectivity/source/parse \
))
$(eval $(call gb_Library_use_sdk_api,tdeabdrv1))
$(eval $(call gb_Library_use_externals,tdeabdrv1,\
boost_headers \
tde \
))
$(eval $(call gb_Library_add_libs,tdeabdrv1,\
-ltdeabc \
))
$(eval $(call gb_Library_use_libraries,tdeabdrv1,\
cppu \
cppuhelper \
sal \
salhelper \
dbtools \
comphelper \
))
$(eval $(call gb_Library_add_exception_objects,tdeabdrv1,\
connectivity/source/drivers/kab/KColumns \
connectivity/source/drivers/kab/KTable \
connectivity/source/drivers/kab/KTables \
connectivity/source/drivers/kab/KCatalog \
connectivity/source/drivers/kab/KResultSet \
connectivity/source/drivers/kab/KStatement \
connectivity/source/drivers/kab/KPreparedStatement \
connectivity/source/drivers/kab/KDatabaseMetaData \
connectivity/source/drivers/kab/KConnection \
connectivity/source/drivers/kab/KResultSetMetaData \
connectivity/source/drivers/kab/kcondition \
connectivity/source/drivers/kab/korder \
connectivity/source/drivers/kab/kfields \
connectivity/source/drivers/kab/KDEInit \
))
# vim: set noet sw=4 ts=4:
......@@ -49,14 +49,6 @@ endif
ifneq ($(OS),WNT)
ifeq ($(ENABLE_TDEAB),TRUE)
$(eval $(call gb_Module_add_targets,connectivity,\
Configuration_tdeab \
Library_tdeab1 \
Library_tdeabdrv1 \
))
endif
ifeq ($(OS),MACOSX)
$(eval $(call gb_Module_add_targets,connectivity,\
Configuration_macab \
......
<?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="tdeab">
<node oor:name="sdbc:address:tdeab" oor:op="replace">
<prop oor:name="Driver">
<value>com.sun.star.comp.sdbc.tdeab.Driver</value>
</prop>
<prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
<value xml:lang="en-US">TDE 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>
</node>
</oor:component-data>
/* -*- 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 "KCatalog.hxx"
#include "KConnection.hxx"
#include "KTables.hxx"
using namespace connectivity::kab;
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;
KabCatalog::KabCatalog(KabConnection* _pCon)
: connectivity::sdbcx::OCatalog(_pCon),
m_pConnection(_pCon)
{
}
void KabCatalog::refreshTables()
{
TStringVector aVector;
Sequence< OUString > aTypes { "%" };
Reference< XResultSet > xResult = m_xMetaData->getTables(
Any(), "%", "%", aTypes);
if (xResult.is())
{
Reference< XRow > xRow(xResult,UNO_QUERY);
OUString aName;
while (xResult->next())
{
// aName = xRow->getString(2);
// aName += sDot;
aName = xRow->getString(3);
aVector.push_back(aName);
}
}
if (m_pTables)
m_pTables->reFill(aVector);
else
m_pTables = new KabTables(m_xMetaData,*this,m_aMutex,aVector);
}
void KabCatalog::refreshViews()
{
}
void KabCatalog::refreshGroups()
{
}
void KabCatalog::refreshUsers()
{
}
// XTablesSupplier
Reference< XNameAccess > SAL_CALL KabCatalog::getTables( )
{
::osl::MutexGuard aGuard(m_aMutex);
checkDisposed(rBHelper.bDisposed);
try
{
if (!m_pTables)
refreshTables();
}
catch( const RuntimeException& )
{
// allowed to leave this method
throw;
}
catch( const Exception& )
{
// allowed
}
return m_pTables;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCATALOG_HXX
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCATALOG_HXX
#include <connectivity/sdbcx/VCatalog.hxx>
namespace connectivity
{
namespace kab
{
class KabConnection;
class KabCatalog : public connectivity::sdbcx::OCatalog
{
KabConnection* m_pConnection; // used to get the metadata
public:
explicit KabCatalog(KabConnection* _pCon);
KabConnection* getConnection() const { return m_pConnection; }
// implementation of the pure virtual methods
virtual void refreshTables() override;
virtual void refreshViews() override;
virtual void refreshGroups() override;
virtual void refreshUsers() override;
// XTablesSupplier
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTables(
) override;
};
}
}
#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCATALOG_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 "KColumns.hxx"
#include "KTable.hxx"
#include "KTables.hxx"
#include "KCatalog.hxx"
#include <connectivity/sdbcx/VColumn.hxx>
using namespace connectivity::kab;
using namespace connectivity::sdbcx;
using namespace connectivity;
using namespace ::comphelper;
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 KabColumns::createObject(const OUString& _rName)
{
const Any aCatalog;
const OUString sCatalogName;
const OUString sSchemaName(m_pTable->getSchema());
const OUString sTableName(m_pTable->getTableName());
Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(
aCatalog, sSchemaName, sTableName, _rName);
sdbcx::ObjectType xRet = nullptr;
if (xResult.is())
{
Reference< XRow > xRow(xResult,UNO_QUERY);
while (xResult->next())
{
if (xRow->getString(4) == _rName)
{
OColumn* pRet = new OColumn(
_rName,
xRow->getString(6),
xRow->getString(13),
xRow->getString(12),
xRow->getInt(11),
xRow->getInt(7),
xRow->getInt(9),
xRow->getInt(5),
false,
false,
false,
true,
sCatalogName,
sSchemaName,
sTableName);
xRet = pRet;
break;
}
}
}
return xRet;
}
void KabColumns::impl_refresh()
{
m_pTable->refreshColumns();
}
KabColumns::KabColumns( KabTable* _pTable,
::osl::Mutex& _rMutex,
const TStringVector &_rVector)
: sdbcx::OCollection(*_pTable, true, _rMutex, _rVector),
m_pTable(_pTable)
{
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCOLUMNS_HXX
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCOLUMNS_HXX
#include "KTable.hxx"
#include <connectivity/sdbcx/VCollection.hxx>
namespace connectivity
{
namespace kab
{
class KabColumns : public sdbcx::OCollection
{
protected:
KabTable* m_pTable;
virtual sdbcx::ObjectType createObject(const OUString& _rName) override;
virtual void impl_refresh() override;
public:
KabColumns( KabTable* _pTable,
::osl::Mutex& _rMutex,
const TStringVector &_rVector);
};
}
}
#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCOLUMNS_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 "KConnection.hxx"
#include "KDatabaseMetaData.hxx"
#include "KStatement.hxx"
#include "KPreparedStatement.hxx"
#include "KCatalog.hxx"
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/TransactionIsolation.hpp>
#include <shell/kde_headers.h>
using namespace connectivity::kab;
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;
IMPLEMENT_SERVICE_INFO(KabConnection, "com.sun.star.sdbc.drivers.KabConnection", "com.sun.star.sdbc.Connection")
KabConnection::KabConnection(
css::uno::Reference<css::uno::XComponentContext> const & componentContext,
css::uno::Reference<css::sdbc::XDriver> const & driver)
: OMetaConnection_BASE(m_aMutex),
OSubComponent<KabConnection, KabConnection_BASE>(driver, this),
m_xMetaData(nullptr),
m_pAddressBook(nullptr),
m_xComponentContext(componentContext)
{}
KabConnection::~KabConnection()
{
if (!isClosed())
close();
}
void SAL_CALL KabConnection::release() throw()
{
release_ChildImpl();
}
//TODO: is doing this after the ctor, and the manual ref counting really
// necessary?
void KabConnection::construct()
{
osl_atomic_increment( &m_refCount );
// create a KDE address book object
m_pAddressBook = KABC::StdAddressBook::self();
KABC::StdAddressBook::setAutomaticSave(false);
osl_atomic_decrement( &m_refCount );
}
// XServiceInfo
Reference< XStatement > SAL_CALL KabConnection::createStatement( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// create a statement
// the statement can only be executed once
Reference< XStatement > xReturn = new KabStatement(this);
m_aStatements.push_back(WeakReferenceHelper(xReturn));
return xReturn;
}
Reference< XPreparedStatement > SAL_CALL KabConnection::prepareStatement( const OUString& _sSql )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// create a statement
// the statement can only be executed more than once
Reference< XPreparedStatement > xReturn = new KabPreparedStatement(this, _sSql);
m_aStatements.push_back(WeakReferenceHelper(xReturn));
return xReturn;
}
Reference< XPreparedStatement > SAL_CALL KabConnection::prepareCall( const OUString& )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// not implemented yet :-) a task to do
return nullptr;
}
OUString SAL_CALL KabConnection::nativeSQL( const OUString& _sSql )
{
::osl::MutexGuard aGuard( m_aMutex );
// when you need to transform SQL92 to you driver specific you can do it here
return _sSql;
}
void SAL_CALL KabConnection::setAutoCommit( sal_Bool )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// here you have to set your commit mode please have a look at the jdbc documentation to get a clear explanation
}
sal_Bool SAL_CALL KabConnection::getAutoCommit( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// you have to distinguish which if you are in autocommit mode or not
// at normal case true should be fine here
return true;
}
void SAL_CALL KabConnection::commit( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// when you database does support transactions you should commit here
}
void SAL_CALL KabConnection::rollback( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// same as commit but for the other case
}
sal_Bool SAL_CALL KabConnection::isClosed( )
{
::osl::MutexGuard aGuard( m_aMutex );
// just simple -> we are closed when we are disposed, that means someone called dispose(); (XComponent)
return KabConnection_BASE::rBHelper.bDisposed;
}
Reference< XDatabaseMetaData > SAL_CALL KabConnection::getMetaData( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_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 KabDatabaseMetaData(this); // need the connection because it can return it
m_xMetaData = xMetaData;
}
return xMetaData;
}
void SAL_CALL KabConnection::setReadOnly( sal_Bool )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// set you connection to readonly
}
sal_Bool SAL_CALL KabConnection::isReadOnly( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// return if your connection to readonly
return false;
}
void SAL_CALL KabConnection::setCatalog( const OUString& )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// if your database doesn't work with catalogs you go to next method otherwise you know what to do
}
OUString SAL_CALL KabConnection::getCatalog( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// return your current catalog
return OUString();
}
void SAL_CALL KabConnection::setTransactionIsolation( sal_Int32 )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// set your isolation level
// please have a look at @see com.sun.star.sdbc.TransactionIsolation
}
sal_Int32 SAL_CALL KabConnection::getTransactionIsolation( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// please have a look at @see com.sun.star.sdbc.TransactionIsolation
return TransactionIsolation::NONE;
}
Reference< css::container::XNameAccess > SAL_CALL KabConnection::getTypeMap( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
// if your driver has special database types you can return it here
return nullptr;
}
void SAL_CALL KabConnection::setTypeMap( const Reference< css::container::XNameAccess >& )
{
// the other way around
}
// XCloseable
void SAL_CALL KabConnection::close( )
{
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
}
dispose();
}
// XWarningsSupplier
Any SAL_CALL KabConnection::getWarnings( )
{
// when you collected some warnings -> return it
return Any();
}
void SAL_CALL KabConnection::clearWarnings( )
{
// you should clear your collected warnings here
}
void KabConnection::disposing()
{
// we noticed that we should be destroyed in near future so we have to dispose our statements
::osl::MutexGuard aGuard(m_aMutex);
for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i)
{
Reference< XComponent > xComp(i->get(), UNO_QUERY);
if (xComp.is())
xComp->dispose();
}
m_aStatements.clear();
if (m_pAddressBook != nullptr)
{
KABC::StdAddressBook::close();
m_pAddressBook = nullptr;
}
m_xMetaData = css::uno::WeakReference< css::sdbc::XDatabaseMetaData>();
dispose_ChildImpl();
KabConnection_BASE::disposing();
}
Reference< XTablesSupplier > SAL_CALL KabConnection::createCatalog()
{
::osl::MutexGuard aGuard( m_aMutex );
Reference< XTablesSupplier > xTab = m_xCatalog;
if (!m_xCatalog.is())
{
KabCatalog *pCat = new KabCatalog(this);
xTab = pCat;
m_xCatalog = xTab;
}
return xTab;
}
::KABC::AddressBook* KabConnection::getAddressBook() const
{
return m_pAddressBook;
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
createKabConnection(
css::uno::Reference<css::uno::XComponentContext> const & componentContext,
css::uno::Reference<css::sdbc::XDriver> const & driver)
{
rtl::Reference<KabConnection> con(
new KabConnection(componentContext, driver));
con->construct();
return cppu::acquire(con.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCONNECTION_HXX
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCONNECTION_HXX
#include <map>
#include <connectivity/OSubComponent.hxx>
#include <connectivity/CommonTools.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/sdbc/SQLWarning.hpp>
#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#include <cppuhelper/basemutex.hxx>
#include <cppuhelper/compbase.hxx>
#include <shell/kde_headers.h>
namespace KABC
{
class StdAddressBook;
class AddressBook;
}
namespace com { namespace sun { namespace star { namespace sdbc {
class XDriver;
} } } }
namespace connectivity
{
namespace kab
{
typedef ::cppu::WeakComponentImplHelper<css::sdbc::XConnection,
css::sdbc::XWarningsSupplier,
css::lang::XServiceInfo
> OMetaConnection_BASE;
typedef OMetaConnection_BASE KabConnection_BASE; // implements basics and text encoding
typedef std::vector< css::uno::WeakReferenceHelper > OWeakRefArray;
class KabConnection : public cppu::BaseMutex,
public KabConnection_BASE,
public OSubComponent<KabConnection, KabConnection_BASE>
{
friend class OSubComponent<KabConnection, KabConnection_BASE>;
protected:
// Data attributes
css::uno::WeakReference< css::sdbc::XDatabaseMetaData > m_xMetaData;
OWeakRefArray m_aStatements; // vector containing a list of all the Statement objects
// for this Connection
::KABC::StdAddressBook* m_pAddressBook; // the address book
css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
css::uno::Reference< css::sdbcx::XTablesSupplier>
m_xCatalog; // needed for the SQL interpreter
public:
void construct();
KabConnection(
css::uno::Reference<css::uno::XComponentContext> const &
componentContext,
css::uno::Reference<css::sdbc::XDriver> const & driver);
virtual ~KabConnection() override;
void closeAllStatements ();
// OComponentHelper
virtual void SAL_CALL disposing() override;
// XInterface
virtual void SAL_CALL release() throw() override;
// XServiceInfo
DECLARE_SERVICE_INFO();
// XConnection
virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement( ) override;
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) override;
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) override;
virtual OUString SAL_CALL nativeSQL( const OUString& sql ) override;
virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) override;
virtual sal_Bool SAL_CALL getAutoCommit( ) override;
virtual void SAL_CALL commit( ) override;
virtual void SAL_CALL rollback( ) override;
virtual sal_Bool SAL_CALL isClosed( ) override;
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) override;
virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) override;
virtual sal_Bool SAL_CALL isReadOnly( ) override;
virtual void SAL_CALL setCatalog( const OUString& catalog ) override;
virtual OUString SAL_CALL getCatalog( ) override;
virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) override;
virtual sal_Int32 SAL_CALL getTransactionIsolation( ) override;
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap( ) override;
virtual void SAL_CALL setTypeMap( const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
// XCloseable
virtual void SAL_CALL close( ) override;
// XWarningsSupplier
virtual css::uno::Any SAL_CALL getWarnings( ) override;
virtual void SAL_CALL clearWarnings( ) override;
// needed for the SQL interpreter
css::uno::Reference< css::sdbcx::XTablesSupplier > SAL_CALL createCatalog();
css::uno::Reference<css::uno::XComponentContext>
getComponentContext() const
{ return m_xComponentContext; }
::KABC::AddressBook* getAddressBook() const;
};
}
}
#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KCONNECTION_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 "KDEInit.h"
#include <osl/diagnose.h>
#include <osl/process.h>
#include <shell/kde_headers.h>
namespace connectivity
{
namespace kab
{
// = KDEInit
class KDEInit
{
private:
/// KDE application if we own it
static KApplication* s_pKApplication;
static bool s_bDidInsertCatalogue;
public:
static void Init();
static void Shutdown();
};
KApplication* KDEInit::s_pKApplication = nullptr;
bool KDEInit::s_bDidInsertCatalogue = false;
void KDEInit::Init()
{
// TODO: All this is not thread-safe
// we create a KDE application only if it is not already done
if (KApplication::kApplication() == nullptr)
{
OSL_ENSURE(s_pKApplication == nullptr, "KDEInit::Init: inconsistency in the application pointers!");
char *kabargs[1] = {const_cast<char*>("libkab1")};
KCmdLineArgs::init(1, kabargs, "KAddressBook", *kabargs, "Address Book driver", KAB_DRIVER_VERSION);
s_pKApplication = new KApplication(false, false);
}
/* FIXME-BCP47: what slumbering dogs may we wake up here? */
// set language
rtl_Locale *pProcessLocale;
osl_getProcessLocale(&pProcessLocale);
// sal_Unicode and QChar are (currently) both 16 bits characters
QString aLanguage(
reinterpret_cast<QChar *>(pProcessLocale->Language->buffer),
(int) pProcessLocale->Language->length);
KGlobal::locale()->setLanguage(aLanguage);
// load KDE address book's localized messages
KGlobal::locale()->insertCatalogue("kaddressbook");
s_bDidInsertCatalogue = true;
}
void KDEInit::Shutdown()
{
if ( s_bDidInsertCatalogue )
// this guard is necessary, since KDE 3.3 seems to crash if we remove a catalogue
// which we did not previously insert
KGlobal::locale()->removeCatalogue("kaddressbook");
if ( s_pKApplication != nullptr )
{
delete s_pKApplication;
s_pKApplication = nullptr;
}
}
}
}
namespace
{
double normalizeVersion( unsigned int major, unsigned int minor )
{
return major + 1.0 * minor / 1000;
}
}
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL initKApplication()
{
::connectivity::kab::KDEInit::Init();
}
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL shutdownKApplication()
{
::connectivity::kab::KDEInit::Shutdown();
}
/** checks whether the KDE version on the system we're running at is supported
by the driver
Has to be called before any other code from this library, in particular,
it has to be called before initKApplication()
If this function returns <code>0</code>, then no other code from this library
has to be called, else the results are unpredictable.
@return
<ul><li><code>0</code> if the KDE version is not supported</li>
<li>a negative value if the version is too old</li>
<li>a positive value if the version is too new to know whether it works with this driver</li>
</ul>
#i60062#
*/
extern "C" SAL_DLLPUBLIC_EXPORT int SAL_CALL matchKDEVersion()
{
double nMinVersion = normalizeVersion( MIN_KDE_VERSION_MAJOR, MIN_KDE_VERSION_MINOR );
double nCurVersion = normalizeVersion( ::KDE::versionMajor(), ::KDE::versionMinor() );
double nMaxVersion = normalizeVersion( MAX_KDE_VERSION_MAJOR, MAX_KDE_VERSION_MINOR );
if ( nCurVersion < nMinVersion )
return -1;
if ( nCurVersion > nMaxVersion )
return 1;
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDEINIT_H
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDEINIT_H
// the address book driver's version
#define KAB_DRIVER_VERSION "0.2"
#define KAB_DRIVER_VERSION_MAJOR 0
#define KAB_DRIVER_VERSION_MINOR 2
#include <config_vclplug.h>
#if ENABLE_TDE
// the minimum TDE version which is required at runtime
#define MIN_KDE_VERSION_MAJOR 14
#define MIN_KDE_VERSION_MINOR 0
#define MAX_KDE_VERSION_MAJOR 255
#define MAX_KDE_VERSION_MINOR 255
#else // ENABLE_TDE
// the minimum KDE version which is required at runtime
#define MIN_KDE_VERSION_MAJOR 3
#define MIN_KDE_VERSION_MINOR 2
#define MAX_KDE_VERSION_MAJOR 3
#define MAX_KDE_VERSION_MINOR 6
#endif // ENABLE_TDE
#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDEINIT_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDRIVER_HXX
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDRIVER_HXX
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/frame/XTerminateListener.hpp>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/compbase.hxx>
#include <osl/module.h>
namespace connectivity
{
namespace kab
{
class KabDriver;
extern "C" {
typedef css::uno::XInterface * (SAL_CALL * ConnectionFactoryFunction)(
css::uno::Reference<css::uno::XComponentContext> const &,
css::uno::Reference<css::sdbc::XDriver> const &);
typedef void (SAL_CALL * ApplicationInitFunction)( void );
typedef void (SAL_CALL * ApplicationShutdownFunction)( void );
typedef int (SAL_CALL * KDEVersionCheckFunction)( void );
}
typedef std::vector< css::uno::WeakReferenceHelper > OWeakRefArray;
// = KabImplModule
class KabImplModule
{
private:
css::uno::Reference< css::uno::XComponentContext >
m_xContext;
/// Did we already attempt to load the module and to retrieve the symbols?
bool m_bAttemptedLoadModule;
/// Did we already check the KDE version and initialize the impl module (or at least attempted to)?
bool m_bAttemptedInitialize;
oslModule m_hConnectorModule;
ConnectionFactoryFunction m_pConnectionFactoryFunc;
ApplicationInitFunction m_pApplicationInitFunc;
ApplicationShutdownFunction m_pApplicationShutdownFunc;
KDEVersionCheckFunction m_pKDEVersionCheckFunc;
public:
explicit KabImplModule( const css::uno::Reference< css::uno::XComponentContext >& _rxContext );
/** determines whether there is a KDE present in the environment
*/
bool isKDEPresent();
enum KDEVersionType
{
eTooOld,
eSupported,
eToNew
};
/** checks whether the KDE version we're running against is supported
@precond
the module is loaded, i.e impl_loadModule has successfully been called
*/
KDEVersionType matchKDEVersion();
/** initializes the implementation module.
@throws css::uno::RuntimeException
if the module could be loaded, but required symbols are missing
@throws css::sdbc::SQLException
if the KDE version we're running against is not supported, or no KDE was found at all
*/
void init();
/** shuts down the impl module (and the KDE application, if we own it)
*/
void shutdown();
/** creates a new connection
@precond
<member>init</member> has been called before
@throws css::uno::RuntimeException
if no connection object could be created (which is a severe error, normally impossible)
*/
css::uno::Reference<css::sdbc::XConnection> createConnection(
KabDriver * driver) const;
private:
/** loads the implementation module and retrieves the needed symbols
Save against being called multiple times.
@return <TRUE/> if the module could be loaded successfully.
@throws css::uno::RuntimeException
if the module could be loaded, but required symbols are missing
*/
bool impl_loadModule();
/** unloads the implementation module, and resets all function pointers to <nullptr/>
@precond m_hConnectorModule is not <nullptr/>
*/
void impl_unloadModule();
/** determines whether it's allowed to run on a too-new (not confirmed to work) version
*/
bool impl_doAllowNewKDEVersion();
};
// = KabDriver
typedef ::cppu::WeakComponentImplHelper< css::sdbc::XDriver,
css::lang::XServiceInfo,
css::frame::XTerminateListener > KDriver_BASE;
class KabDriver : public KDriver_BASE
{
protected:
::osl::Mutex m_aMutex; // mutex is need to control member access
OWeakRefArray m_xConnections; // vector containing a list of all the
// KabConnection objects for this Driver
css::uno::Reference< css::uno::XComponentContext >
m_xContext; // the multi-service factory
KabImplModule m_aImplModule;
public:
static css::uno::Reference< css::uno::XInterface > SAL_CALL Create(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory);
// XServiceInfo - static versions
static OUString getImplementationName_Static( );
static css::uno::Sequence< OUString > getSupportedServiceNames_Static( );
/** returns the path of our configuration settings
*/
static OUString impl_getConfigurationSettingsPath();
protected:
explicit KabDriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
// OComponentHelper
virtual void SAL_CALL disposing() override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
// XDriver
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
virtual sal_Bool SAL_CALL acceptsURL( const OUString& url ) override;
virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
virtual sal_Int32 SAL_CALL getMajorVersion() override;
virtual sal_Int32 SAL_CALL getMinorVersion() override;
// XTerminateListener
virtual void SAL_CALL queryTermination( const css::lang::EventObject& Event ) override;
virtual void SAL_CALL notifyTermination( const css::lang::EventObject& Event ) override;
// XEventListener
virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
private:
/** shuts down the library which contains the real implementations
This method is safe against being called multiple times
@precond our mutex is locked
*/
void impl_shutdownImplementationModule();
};
}
}
#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KDRIVER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 "KPreparedStatement.hxx"
#include "propertyids.hxx"
#include <connectivity/dbexception.hxx>
#include <connectivity/dbtools.hxx>
#include "resource/kab_res.hrc"
#include "resource/sharedresources.hxx"
using namespace connectivity::kab;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::sdbc;
using namespace com::sun::star::util;
IMPLEMENT_SERVICE_INFO(KabPreparedStatement, "com.sun.star.sdbc.drivers.KabPreparedStatement", "com.sun.star.sdbc.PreparedStatement");
void KabPreparedStatement::checkAndResizeParameters(sal_Int32 nParams)
{
if ( !m_aParameterRow.is() )
m_aParameterRow = new OValueVector();
if (nParams < 1)
::dbtools::throwInvalidIndexException(*this);
if (nParams >= (sal_Int32) (m_aParameterRow->get()).size())
(m_aParameterRow->get()).resize(nParams);
}
void KabPreparedStatement::setKabFields() const
{
::rtl::Reference<connectivity::OSQLColumns> xColumns; // selected columns
xColumns = m_aSQLIterator.getSelectColumns();
if (!xColumns.is())
{
::connectivity::SharedResources aResources;
const OUString sError( aResources.getResourceString(
STR_INVALID_COLUMN_SELECTION
) );
::dbtools::throwGenericSQLException(sError,nullptr);
}
m_xMetaData->setKabFields(xColumns);
}
void KabPreparedStatement::resetParameters() const
{
m_nParameterIndex = 0;
}
void KabPreparedStatement::getNextParameter(OUString &rParameter) const
{
if (m_nParameterIndex >= (sal_Int32) (m_aParameterRow->get()).size())
{
::connectivity::SharedResources aResources;
const OUString sError( aResources.getResourceString(
STR_INVALID_PARA_COUNT
) );
::dbtools::throwGenericSQLException(sError,*const_cast<KabPreparedStatement *>(this));
} // if (m_nParameterIndex >= (sal_Int32) (*m_aParameterRow).size())
rParameter = (m_aParameterRow->get())[m_nParameterIndex];
m_nParameterIndex++;
}
KabPreparedStatement::KabPreparedStatement(
KabConnection* _pConnection,
const OUString& sql)
: KabPreparedStatement_BASE(_pConnection),
m_sSqlStatement(sql),
m_bPrepared(false),
m_nParameterIndex(0),
m_aParameterRow()
{
}
KabPreparedStatement::~KabPreparedStatement()
{
}
void KabPreparedStatement::disposing()
{
KabPreparedStatement_BASE::disposing();
if (m_aParameterRow.is())
{
m_aParameterRow->get().clear();
m_aParameterRow = nullptr;
}
}
Reference< XResultSetMetaData > SAL_CALL KabPreparedStatement::getMetaData()
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
if (!m_xMetaData.is())
{
m_xMetaData = new KabResultSetMetaData;
setKabFields();
}
Reference< XResultSetMetaData > xMetaData = m_xMetaData.get();
return xMetaData;
}
void SAL_CALL KabPreparedStatement::close()
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
// Reset last warning message
try {
clearWarnings ();
KabCommonStatement::close();
}
catch (SQLException &) {
// If we get an error, ignore
}
// Remove this Statement object from the Connection object's
// list
}
sal_Bool SAL_CALL KabPreparedStatement::execute()
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
Reference< XResultSet> xRS = KabCommonStatement::executeQuery(m_sSqlStatement);
return xRS.is();
}
sal_Int32 SAL_CALL KabPreparedStatement::executeUpdate()
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
// same as in statement with the difference that this statement also can contain parameter
return 0;
}
Reference< XConnection > SAL_CALL KabPreparedStatement::getConnection()
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
return m_pConnection;
}
Reference< XResultSet > SAL_CALL KabPreparedStatement::executeQuery()
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
Reference< XResultSet > rs = KabCommonStatement::executeQuery(m_sSqlStatement);
return rs;
}
void SAL_CALL KabPreparedStatement::setNull(sal_Int32 parameterIndex, sal_Int32)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
checkAndResizeParameters(parameterIndex);
(m_aParameterRow->get())[parameterIndex - 1].setNull();
}
void SAL_CALL KabPreparedStatement::setObjectNull(sal_Int32, sal_Int32, const OUString&)
{
::dbtools::throwFunctionNotSupportedSQLException("setObjectNull", nullptr);
}
void SAL_CALL KabPreparedStatement::setBoolean(sal_Int32, sal_Bool)
{
::dbtools::throwFunctionNotSupportedSQLException("setBoolean", nullptr);
}
void SAL_CALL KabPreparedStatement::setByte(sal_Int32, sal_Int8)
{
::dbtools::throwFunctionNotSupportedSQLException("setByte", nullptr);
}
void SAL_CALL KabPreparedStatement::setShort(sal_Int32, sal_Int16)
{
::dbtools::throwFunctionNotSupportedSQLException("setShort", nullptr);
}
void SAL_CALL KabPreparedStatement::setInt(sal_Int32, sal_Int32)
{
::dbtools::throwFunctionNotSupportedSQLException("setInt", nullptr);
}
void SAL_CALL KabPreparedStatement::setLong(sal_Int32, sal_Int64)
{
::dbtools::throwFunctionNotSupportedSQLException("", nullptr);
}
void SAL_CALL KabPreparedStatement::setFloat(sal_Int32, float)
{
::dbtools::throwFunctionNotSupportedSQLException("setFloat", nullptr);
}
void SAL_CALL KabPreparedStatement::setDouble(sal_Int32, double)
{
::dbtools::throwFunctionNotSupportedSQLException("setDouble", nullptr);
}
void SAL_CALL KabPreparedStatement::setString(sal_Int32 parameterIndex, const OUString &x)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
checkAndResizeParameters(parameterIndex);
(m_aParameterRow->get())[parameterIndex - 1] = x;
}
void SAL_CALL KabPreparedStatement::setBytes(sal_Int32, const Sequence< sal_Int8 >&)
{
::dbtools::throwFunctionNotSupportedSQLException("setBytes", nullptr);
}
void SAL_CALL KabPreparedStatement::setDate(sal_Int32, const Date&)
{
::dbtools::throwFunctionNotSupportedSQLException("setDate", nullptr);
}
void SAL_CALL KabPreparedStatement::setTime(sal_Int32, const css::util::Time&)
{
::dbtools::throwFunctionNotSupportedSQLException("setTime", nullptr);
}
void SAL_CALL KabPreparedStatement::setTimestamp(sal_Int32, const DateTime&)
{
::dbtools::throwFunctionNotSupportedSQLException("setTimestamp", nullptr);
}
void SAL_CALL KabPreparedStatement::setBinaryStream(sal_Int32, const Reference< css::io::XInputStream >&, sal_Int32)
{
::dbtools::throwFunctionNotSupportedSQLException("setBinaryStream", nullptr);
}
void SAL_CALL KabPreparedStatement::setCharacterStream(sal_Int32, const Reference< css::io::XInputStream >&, sal_Int32)
{
::dbtools::throwFunctionNotSupportedSQLException("setCharacterStream", nullptr);
}
void SAL_CALL KabPreparedStatement::setObject(sal_Int32 parameterIndex, const Any& x)
{
if(!::dbtools::implSetObject(this,parameterIndex,x))
{
throw SQLException();
}
}
void SAL_CALL KabPreparedStatement::setObjectWithInfo(sal_Int32, const Any&, sal_Int32, sal_Int32)
{
::dbtools::throwFunctionNotSupportedSQLException("setObjectWithInfo", nullptr);
}
void SAL_CALL KabPreparedStatement::setRef(sal_Int32, const Reference< XRef >&)
{
::dbtools::throwFunctionNotSupportedSQLException("setRef", nullptr);
}
void SAL_CALL KabPreparedStatement::setBlob(sal_Int32, const Reference< XBlob >&)
{
::dbtools::throwFunctionNotSupportedSQLException("setBlob", nullptr);
}
void SAL_CALL KabPreparedStatement::setClob(sal_Int32, const Reference< XClob >&)
{
::dbtools::throwFunctionNotSupportedSQLException("setClob", nullptr);
}
void SAL_CALL KabPreparedStatement::setArray(sal_Int32, const Reference< XArray >&)
{
::dbtools::throwFunctionNotSupportedSQLException("setArray", nullptr);
}
void SAL_CALL KabPreparedStatement::clearParameters()
{
::dbtools::throwFunctionNotSupportedSQLException("clearParameters", nullptr);
}
void KabPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)
{
switch (nHandle)
{
case PROPERTY_ID_RESULTSETCONCURRENCY:
break;
case PROPERTY_ID_RESULTSETTYPE:
break;
case PROPERTY_ID_FETCHDIRECTION:
break;
case PROPERTY_ID_USEBOOKMARKS:
break;
default:
KabCommonStatement::setFastPropertyValue_NoBroadcast(nHandle,rValue);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KPREPAREDSTATEMENT_HXX
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KPREPAREDSTATEMENT_HXX
#include "KStatement.hxx"
#include "KResultSetMetaData.hxx"
#include <connectivity/FValue.hxx>
#include <com/sun/star/sdbc/XParameters.hpp>
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
#include <cppuhelper/implbase.hxx>
namespace connectivity
{
namespace kab
{
typedef ::cppu::ImplInheritanceHelper< KabCommonStatement,
css::sdbc::XPreparedStatement,
css::sdbc::XParameters,
css::sdbc::XResultSetMetaDataSupplier,
css::lang::XServiceInfo> KabPreparedStatement_BASE;
class KabPreparedStatement : public KabPreparedStatement_BASE
{
protected:
OUString m_sSqlStatement;
::rtl::Reference< KabResultSetMetaData >
m_xMetaData;
bool m_bPrepared;
mutable sal_Int32 m_nParameterIndex;
OValueRow m_aParameterRow;
void checkAndResizeParameters(sal_Int32 nParams);
void setKabFields() const;
protected:
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
sal_Int32 nHandle,
const css::uno::Any& rValue) override;
virtual void resetParameters() const override;
virtual void getNextParameter(OUString &rParameter) const override;
virtual ~KabPreparedStatement() override;
public:
DECLARE_SERVICE_INFO();
KabPreparedStatement(KabConnection* _pConnection, const OUString& sql);
// OComponentHelper
virtual void SAL_CALL disposing() override;
// XPreparedStatement
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( ) override;
virtual sal_Int32 SAL_CALL executeUpdate( ) override;
virtual sal_Bool SAL_CALL execute( ) override;
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override;
using KabCommonStatement::executeQuery;
using KabCommonStatement::executeUpdate;
using KabCommonStatement::execute;
// XParameters
virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) override;
virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName ) override;
virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) override;
virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) override;
virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) override;
virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) override;
virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) override;
virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) override;
virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) override;
virtual void SAL_CALL setString( sal_Int32 parameterIndex, const OUString& x ) override;
virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const css::uno::Sequence< sal_Int8 >& x ) override;
virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const css::util::Date& x ) override;
virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const css::util::Time& x ) override;
virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const css::util::DateTime& x ) override;
virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override;
virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override;
virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const css::uno::Any& x ) override;
virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const css::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) override;
virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XRef >& x ) override;
virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XBlob >& x ) override;
virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XClob >& x ) override;
virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XArray >& x ) override;
virtual void SAL_CALL clearParameters( ) override;
// XCloseable
virtual void SAL_CALL close( ) override;
// XResultSetMetaDataSupplier
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override;
};
}
}
#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KPREPAREDSTATEMENT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KRESULTSETMETADATA_HXX
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KRESULTSETMETADATA_HXX
#include <connectivity/CommonTools.hxx>
#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
#include <cppuhelper/implbase.hxx>
#include <rtl/ref.hxx>
namespace connectivity
{
namespace kab
{
/*
** KabResultSetMetaData
*/
typedef ::cppu::WeakImplHelper< css::sdbc::XResultSetMetaData> KabResultSetMetaData_BASE;
class KabResultSetMetaData : public KabResultSetMetaData_BASE
{
std::vector<sal_Int32> m_aKabFields; // for each selected column, contains the number
// of the corresponding KAddressBook field
protected:
virtual ~KabResultSetMetaData() override;
public:
KabResultSetMetaData();
// avoid ambiguous cast error from the compiler
operator css::uno::Reference< css::sdbc::XResultSetMetaData > () throw()
{ return this; }
void setKabFields(
const ::rtl::Reference<connectivity::OSQLColumns> &xColumns);
sal_uInt32 fieldAtColumn(sal_Int32 columnIndex) const
{ return m_aKabFields[columnIndex - 1]; }
virtual sal_Int32 SAL_CALL getColumnCount( ) override;
virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) override;
virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) override;
virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) override;
virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) override;
virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) override;
virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) override;
virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) override;
virtual OUString SAL_CALL getColumnLabel( sal_Int32 column ) override;
virtual OUString SAL_CALL getColumnName( sal_Int32 column ) override;
virtual OUString SAL_CALL getSchemaName( sal_Int32 column ) override;
virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) override;
virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) override;
virtual OUString SAL_CALL getTableName( sal_Int32 column ) override;
virtual OUString SAL_CALL getCatalogName( sal_Int32 column ) override;
virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) override;
virtual OUString SAL_CALL getColumnTypeName( sal_Int32 column ) override;
virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) override;
virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) override;
virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) override;
virtual OUString SAL_CALL getColumnServiceName( sal_Int32 column ) override;
};
}
}
#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KRESULTSETMETADATA_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KTABLES_HXX
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KTABLES_HXX
#include <connectivity/sdbcx/VCollection.hxx>
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
namespace connectivity
{
namespace kab
{
class KabTables : public sdbcx::OCollection
{
css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData;
protected:
virtual sdbcx::ObjectType createObject(const OUString& _rName) override;
virtual void impl_refresh() override;
public:
KabTables(
const css::uno::Reference< css::sdbc::XDatabaseMetaData >& _rMetaData,
::cppu::OWeakObject& _rParent,
::osl::Mutex& _rMutex,
const TStringVector &_rVector)
: sdbcx::OCollection(_rParent,true,_rMutex,_rVector),
m_xMetaData(_rMetaData)
{ }
virtual void SAL_CALL disposing() override;
};
}
}
#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_KAB_KTABLES_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment