diff options
author | Rene Engelhard <rene@debian.org> | 2020-12-10 18:39:26 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2020-12-13 17:29:09 +0100 |
commit | ee9ed2192b56c98e5b8ee9890ddb4c533117332a (patch) | |
tree | bdbc4f7d4bb0b0228d3e94b29e5428a07fc32b7f | |
parent | e7fb2c18e96d04ec54274721df003ab01f2064ab (diff) |
tdf#138715 remove mork driver
since TB moved to sqlite
Change-Id: Ifddf1a6c9783a294ee9ccfac667c7e798674d7a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107574
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
64 files changed, 0 insertions, 9532 deletions
diff --git a/compilerplugins/clang/constantparam.numbers.results b/compilerplugins/clang/constantparam.numbers.results index 6d9d11c8e5a0..07016070b487 100644 --- a/compilerplugins/clang/constantparam.numbers.results +++ b/compilerplugins/clang/constantparam.numbers.results @@ -102,14 +102,6 @@ connectivity/source/drivers/firebird/Util.hxx:122 class rtl::OUString escapeWith(const class rtl::OUString &,const char,const char) const char aKey 39 -connectivity/source/drivers/mork/MorkParser.hxx:79 - struct MorkTableMap * MorkParser::getTables(int) - int tableScope - 128 -connectivity/source/drivers/mork/MQueryHelper.hxx:169 - _Bool connectivity::mork::MQueryHelper::getRowValue(class connectivity::ORowSetValue &,int,const class rtl::OUString &,int) - int nType - 12 connectivity/source/inc/java/sql/ConnectionLog.hxx:106 void connectivity::java::sql::ConnectionLog::log(const int,const class rtl::OUString &,type-parameter-?-?,type-parameter-?-?,type-parameter-?-?) const const int _nLogLevel diff --git a/compilerplugins/clang/unusedenumconstants.writeonly.results b/compilerplugins/clang/unusedenumconstants.writeonly.results index b8ff65f99e98..3465277daf9a 100644 --- a/compilerplugins/clang/unusedenumconstants.writeonly.results +++ b/compilerplugins/clang/unusedenumconstants.writeonly.results @@ -976,16 +976,6 @@ configmgr/source/access.hxx:442 enum configmgr::Access::(anonymous at /home/noel/libo/configmgr/source/access.hxx:441:5) IS_ANY configmgr/source/partial.hxx:33 enum configmgr::Partial::Containment CONTAINS_SUBNODES -connectivity/source/drivers/mork/MorkParser.hxx:59 - enum MorkErrors NoError -connectivity/source/drivers/mork/MorkParser.hxx:60 - enum MorkErrors FailedToOpen -connectivity/source/drivers/mork/MorkParser.hxx:61 - enum MorkErrors DefectedFormat -connectivity/source/drivers/mork/MorkParser.hxx:143 - enum MorkParser::NP Values -connectivity/source/drivers/mork/MStatement.hxx:99 - enum connectivity::mork::OCommonStatement::StatementType eCreateTable connectivity/source/inc/java/sql/ConnectionLog.hxx:67 enum connectivity::java::sql::ConnectionLog::ObjectType CONNECTION connectivity/source/inc/java/sql/ConnectionLog.hxx:68 diff --git a/compilerplugins/clang/unusedfields.untouched.results b/compilerplugins/clang/unusedfields.untouched.results index ff36b9e4d6b3..17de79de05b5 100644 --- a/compilerplugins/clang/unusedfields.untouched.results +++ b/compilerplugins/clang/unusedfields.untouched.results @@ -12,8 +12,6 @@ chart2/source/inc/ModifyListenerCallBack.hxx:53 chart::ModifyListenerCallBack m_xModifyListener css::uno::Reference<css::util::XModifyListener> comphelper/source/container/enumerablemap.cxx:297 comphelper::(anonymous namespace)::MapEnumeration m_xKeepMapAlive Reference<class com::sun::star::uno::XInterface> -connectivity/source/drivers/mork/MDatabaseMetaData.hxx:28 - connectivity::mork::ODatabaseMetaData m_pMetaDataHelper std::unique_ptr<MDatabaseMetaDataHelper> cppu/source/threadpool/threadpool.cxx:365 _uno_ThreadPool dummy sal_Int32 cppu/source/typelib/typelib.cxx:59 diff --git a/compilerplugins/clang/unusedfields.writeonly.results b/compilerplugins/clang/unusedfields.writeonly.results index 5d16d0717968..2f9e21552c0e 100644 --- a/compilerplugins/clang/unusedfields.writeonly.results +++ b/compilerplugins/clang/unusedfields.writeonly.results @@ -110,8 +110,6 @@ comphelper/source/misc/asyncnotification.cxx:86 comphelper::EventNotifierImpl pKeepThisAlive std::shared_ptr<AsyncEventNotifierAutoJoin> configmgr/source/components.cxx:162 configmgr::Components::WriteThread reference_ rtl::Reference<WriteThread> * -connectivity/source/drivers/mork/MorkParser.hxx:132 - MorkParser error_ enum MorkErrors connectivity/source/inc/calc/CConnection.hxx:51 connectivity::calc::OCalcConnection::CloseVetoButTerminateListener m_pCloseListener std::unique_ptr<utl::CloseVeto> connectivity/source/inc/odbc/OConnection.hxx:54 diff --git a/compilerplugins/clang/unusedmethods.results b/compilerplugins/clang/unusedmethods.results index 34d876877891..83e17844b03d 100644 --- a/compilerplugins/clang/unusedmethods.results +++ b/compilerplugins/clang/unusedmethods.results @@ -56,8 +56,6 @@ connectivity/source/drivers/firebird/Util.hxx:72 short connectivity::firebird::ColumnTypeInfo::getSubType() const connectivity/source/drivers/firebird/Util.hxx:74 const class rtl::OUString & connectivity::firebird::ColumnTypeInfo::getCharacterSet() const -connectivity/source/drivers/mork/mork_helper.cxx:37 - int main(int,char **) connectivity/source/drivers/mysqlc/mysqlc_connection.hxx:176 class rtl::OUString connectivity::mysqlc::OConnection::transFormPreparedStatement(const class rtl::OUString &) connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx:94 diff --git a/connectivity/Configuration_mork.mk b/connectivity/Configuration_mork.mk deleted file mode 100644 index dc36ca83eaa8..000000000000 --- a/connectivity/Configuration_mork.mk +++ /dev/null @@ -1,20 +0,0 @@ -# -*- 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/CppunitTest_connectivity_mork.mk b/connectivity/CppunitTest_connectivity_mork.mk deleted file mode 100644 index 6504adef8d99..000000000000 --- a/connectivity/CppunitTest_connectivity_mork.mk +++ /dev/null @@ -1,56 +0,0 @@ -# -*- 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_CppunitTest_CppunitTest,connectivity_mork)) - -$(eval $(call gb_CppunitTest_set_include,connectivity_mork,\ - -I$(SRCDIR)/connectivity/source/inc \ - -I$(SRCDIR)/connectivity/source/drivers/mork \ - $$(INCLUDE) \ -)) - -$(eval $(call gb_CppunitTest_use_external,connectivity_mork,boost_headers)) - -$(eval $(call gb_CppunitTest_use_sdk_api,connectivity_mork)) - -$(eval $(call gb_CppunitTest_use_ure,connectivity_mork)) -$(eval $(call gb_CppunitTest_use_vcl,connectivity_mork)) - -$(eval $(call gb_CppunitTest_use_sdk_api,connectivity_mork)) - -$(eval $(call gb_CppunitTest_add_exception_objects,connectivity_mork, \ - connectivity/qa/connectivity/mork/DriverTest \ -)) - -$(eval $(call gb_CppunitTest_use_libraries,connectivity_mork, \ - comphelper \ - cppu \ - cppuhelper \ - i18nlangtag \ - mork \ - sal \ - salhelper \ - sb \ - test \ - unotest \ - ucbhelper \ - utl \ -)) - -$(eval $(call gb_CppunitTest_use_components,connectivity_mork,\ - configmgr/source/configmgr \ - i18npool/util/i18npool \ - connectivity/source/drivers/mork/mork \ - ucb/source/core/ucb1 \ - ucb/source/ucp/file/ucpfile1 \ -)) - -$(eval $(call gb_CppunitTest_use_configuration,connectivity_mork)) - -# vim: set noet sw=4 ts=4: diff --git a/connectivity/Executable_mork_helper.mk b/connectivity/Executable_mork_helper.mk deleted file mode 100644 index 2c80a0ad5f4d..000000000000 --- a/connectivity/Executable_mork_helper.mk +++ /dev/null @@ -1,30 +0,0 @@ -# -*- 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 noet sw=4 ts=4: diff --git a/connectivity/IwyuFilter_connectivity.yaml b/connectivity/IwyuFilter_connectivity.yaml index 94f4f1d6c1ff..8ce2a6d004bf 100644 --- a/connectivity/IwyuFilter_connectivity.yaml +++ b/connectivity/IwyuFilter_connectivity.yaml @@ -65,15 +65,6 @@ excludelist: - com/sun/star/util/Date.hpp - com/sun/star/util/Time.hpp - com/sun/star/util/DateTime.hpp - connectivity/source/drivers/mork/MorkParser.cxx: - # Needed for std::ifstream - - fstream - connectivity/source/drivers/mork/MDriver.cxx: - # Actually used - - com/sun/star/uno/XComponentContext.hpp - connectivity/source/drivers/mork/MColumnAlias.cxx: - # Needed for indirect dtor - - com/sun/star/container/XHierarchicalNameAccess.hpp connectivity/source/drivers/mysql_jdbc/YDriver.cxx: # Actually used - com/sun/star/uno/XComponentContext.hpp diff --git a/connectivity/Library_mork.mk b/connectivity/Library_mork.mk deleted file mode 100644 index 7c0a89b56a2c..000000000000 --- a/connectivity/Library_mork.mk +++ /dev/null @@ -1,62 +0,0 @@ -# -*- 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/inc \ - -I$(SRCDIR)/connectivity/source/inc \ - $$(INCLUDE) \ - -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ -)) - -$(eval $(call gb_Library_use_custom_headers,mork,\ - officecfg/registry \ -)) - -$(eval $(call gb_Library_use_external,mork,boost_headers)) - -$(eval $(call gb_Library_use_libraries,mork, \ - comphelper \ - cppu \ - cppuhelper \ - dbtools \ - sal \ - salhelper \ - tl \ - utl \ -)) - -$(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/MColumnAlias \ - 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/MTable \ - connectivity/source/drivers/mork/MTables \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_mozbootstrap.mk b/connectivity/Library_mozbootstrap.mk deleted file mode 100644 index 237726caf8a8..000000000000 --- a/connectivity/Library_mozbootstrap.mk +++ /dev/null @@ -1,35 +0,0 @@ -# -*- 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,mozbootstrap)) - -$(eval $(call gb_Library_set_componentfile,mozbootstrap,connectivity/source/drivers/mozab/bootstrap/mozbootstrap)) - -$(eval $(call gb_Library_set_include,mozbootstrap,\ - -I$(SRCDIR)/connectivity/source/drivers/mozab \ - $$(INCLUDE) \ -)) - -$(eval $(call gb_Library_use_sdk_api,mozbootstrap)) - -$(eval $(call gb_Library_use_libraries,mozbootstrap,\ - comphelper \ - cppu \ - cppuhelper \ - sal \ -)) - -$(eval $(call gb_Library_add_exception_objects,mozbootstrap,\ - connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap \ - connectivity/source/drivers/mozab/bootstrap/MNSFolders \ - connectivity/source/drivers/mozab/bootstrap/MNSINIParser \ - connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/connectivity/Module_connectivity.mk b/connectivity/Module_connectivity.mk index 6a5dd926331b..faac5a8827a1 100644 --- a/connectivity/Module_connectivity.mk +++ b/connectivity/Module_connectivity.mk @@ -99,21 +99,6 @@ $(eval $(call gb_Module_add_targets,connectivity,\ )) endif -ifneq (,$(filter DESKTOP,$(BUILD_TYPE))) - -$(eval $(call gb_Module_add_targets,connectivity,\ - Configuration_mork \ - Executable_mork_helper \ - Library_mork \ - Library_mozbootstrap \ -)) - -$(eval $(call gb_Module_add_check_targets,connectivity,\ - CppunitTest_connectivity_mork \ -)) - -endif - ifeq ($(OS),WNT) # "ADO is not available on 64bit" said the commit ifneq ($(CPUNAME),X86_64) diff --git a/connectivity/qa/connectivity/mork/DriverTest.cxx b/connectivity/qa/connectivity/mork/DriverTest.cxx deleted file mode 100644 index bea76fd028dc..000000000000 --- a/connectivity/qa/connectivity/mork/DriverTest.cxx +++ /dev/null @@ -1,195 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include <test/bootstrapfixture.hxx> - -#include <com/sun/star/sdbc/XDriver.hpp> -#include <com/sun/star/sdbc/XRow.hpp> - -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::uno; - -namespace connectivity::mork { - - -class MorkDriverTest: public test::BootstrapFixture -{ -public: - MorkDriverTest() : test::BootstrapFixture(false, false) {}; - - void checkAcceptsURL(Reference< XDriver> const & xDriver, const char* url, bool expected); - void test_metadata(); - void test_select_default_all(); - void test_select_list_table_joe_doe_5(); - - virtual void setUp() override; - virtual void tearDown() override; - - CPPUNIT_TEST_SUITE(MorkDriverTest); - - CPPUNIT_TEST(test_metadata); - CPPUNIT_TEST(test_select_default_all); - CPPUNIT_TEST(test_select_list_table_joe_doe_5); - CPPUNIT_TEST_SUITE_END(); - -private: - Reference<XInterface> m_xMorkComponent; - Reference<XConnection> m_xConnection; -}; - -void MorkDriverTest::checkAcceptsURL(Reference< XDriver> const & xDriver, const char* url, bool expected) -{ - bool res = xDriver->acceptsURL(OUString::createFromAscii(url)); - if (res != expected) - { - CPPUNIT_ASSERT_MESSAGE("wrong URL outcome!", true); - } -} - -void MorkDriverTest::setUp() -{ - test::BootstrapFixture::setUp(); - m_xMorkComponent = getMultiServiceFactory()->createInstance("com.sun.star.comp.sdbc.MorkDriver"); - CPPUNIT_ASSERT_MESSAGE("no mork component!", m_xMorkComponent.is()); - - // is this the best way to pass test file through URL? - // may be take a custom Sequence< PropertyValue > route? - OUString url = "sdbc:address:thunderbird:unittest:" + - m_directories.getPathFromSrc("/connectivity/qa/connectivity/mork/abook_10_john_does.mab"); - - Sequence< PropertyValue > info; - Reference< XDriver> xDriver(m_xMorkComponent, UNO_QUERY); - if (!xDriver.is()) - { - CPPUNIT_ASSERT_MESSAGE("cannot connect to mork driver!", xDriver.is()); - } - - // bad - checkAcceptsURL(xDriver, "sdbc:address:macab", false); - checkAcceptsURL(xDriver, "sdbc:mozab:ldap:", false); - checkAcceptsURL(xDriver, "sdbc:mozab:outlook:", false); - checkAcceptsURL(xDriver, "sdbc:mozab:outlookexp:", false); - - // good - checkAcceptsURL(xDriver, "sdbc:mozab:mozilla:", true); - checkAcceptsURL(xDriver, "sdbc:mozab:thunderbird:", true); - checkAcceptsURL(xDriver, "sdbc:address:mozilla:", true); - checkAcceptsURL(xDriver, "sdbc:address:thunderbird:", true); - - m_xConnection = xDriver->connect(url, info); - if (!m_xConnection.is()) - { - CPPUNIT_ASSERT_MESSAGE("cannot connect to address book data source!", m_xConnection.is()); - } -} - -void MorkDriverTest::tearDown() -{ -// how to make dispose() work? -// Reference< css::lang::XComponent >( m_xMorkComponent, UNO_QUERY_THROW )->dispose(); - m_xConnection->close(); - test::BootstrapFixture::tearDown(); -} - -void MorkDriverTest::test_metadata() -{ - Reference< XDatabaseMetaData > xDatabaseMetaData = m_xConnection->getMetaData(); - if (!xDatabaseMetaData.is()) - { - CPPUNIT_ASSERT_MESSAGE("cannot retrieve meta data!", xDatabaseMetaData.is()); - } - - const Any catalog; - const Sequence< OUString > types; - - Reference< XResultSet > xResultSet = - xDatabaseMetaData->getTables(catalog, "%", "%", types); - if (!xResultSet.is()) - { - CPPUNIT_ASSERT_MESSAGE("cannot retrieve tables!", xResultSet.is()); - } - - // TODO: how to access that result set and check the tables? - // it should be 3 tables inside: AddressBook, does_5 and does_10 -} - -void MorkDriverTest::test_select_default_all() -{ - Reference< XPreparedStatement > xStatement = m_xConnection->prepareStatement("select \"E-mail\" from \"AddressBook\" ORDER BY \"E-mail\""); - if (!xStatement.is()) - { - CPPUNIT_ASSERT_MESSAGE("cannot create prepared statement!", xStatement.is()); - } - - Reference< XResultSet > xResultSet = xStatement->executeQuery(); - if (!xResultSet.is()) - { - CPPUNIT_ASSERT_MESSAGE("cannot execute sql statement!", xResultSet.is()); - } - - Reference< XRow > xDelegatorRow(xResultSet, UNO_QUERY); - if (!xDelegatorRow.is()) - { - CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xDelegatorRow.is()); - } - - bool result = xResultSet->first(); - CPPUNIT_ASSERT_MESSAGE("fetch first row failed!", result); - OUString mail = xDelegatorRow->getString(1); - CPPUNIT_ASSERT_EQUAL_MESSAGE("first row is not john@doe.org!", OUString("john@doe.org"), mail); - - result = xResultSet->next(); - CPPUNIT_ASSERT_MESSAGE("fetch second row failed!", result); - mail = xDelegatorRow->getString(1); - CPPUNIT_ASSERT_EQUAL_MESSAGE("second row is not john@doe10.org!", OUString("john@doe10.org"), mail); - - result = xResultSet->last(); - CPPUNIT_ASSERT_MESSAGE("fetch last row failed!", result); - mail = xDelegatorRow->getString(1); - CPPUNIT_ASSERT_EQUAL_MESSAGE("last row is not john@doe9.org!", OUString("john@doe9.org"), mail); - - css::uno::Reference<css::sdbc::XCloseable>( - xStatement, css::uno::UNO_QUERY_THROW)->close(); -} - -void MorkDriverTest::test_select_list_table_joe_doe_5() -{ - Reference< XPreparedStatement > xStatement = m_xConnection->prepareStatement("select \"E-mail\" from \"does_5\" where \"E-mail\" LIKE '%doe5.org' "); - if (!xStatement.is()) - { - CPPUNIT_ASSERT_MESSAGE("cannot create prepared statement!", xStatement.is()); - } - - Reference< XResultSet > xResultSet = xStatement->executeQuery(); - if (!xResultSet.is()) - { - CPPUNIT_ASSERT_MESSAGE("cannot execute sql statement!", xResultSet.is()); - } - - Reference< XRow > xDelegatorRow(xResultSet, UNO_QUERY); - if (!xDelegatorRow.is()) - { - CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xDelegatorRow.is()); - } - - bool result = xResultSet->first(); - CPPUNIT_ASSERT_MESSAGE("fetch first row failed!", result); - OUString mail = xDelegatorRow->getString(1); - CPPUNIT_ASSERT_EQUAL_MESSAGE("last row is not john@doe5.org!", OUString("john@doe5.org"), mail); - - css::uno::Reference<css::sdbc::XCloseable>( - xStatement, css::uno::UNO_QUERY_THROW)->close(); -} - -CPPUNIT_TEST_SUITE_REGISTRATION(MorkDriverTest); - -} - -CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/connectivity/qa/connectivity/mork/abook_10_john_does.mab b/connectivity/qa/connectivity/mork/abook_10_john_does.mab deleted file mode 100644 index 41aac4c3e42c..000000000000 --- a/connectivity/qa/connectivity/mork/abook_10_john_does.mab +++ /dev/null @@ -1,159 +0,0 @@ -// <!-- <mdb:mork:z v="1.4"/> --> -< <(a=c)> // (f=iso-8859-1) - (B8=LastModifiedDate)(B9=RecordKey)(BA=AddrCharSet)(BB=LastRecordKey) - (BC=ns:addrbk:db:table:kind:pab)(BD=ListName)(BE=ListNickName) - (BF=ListDescription)(C0=ListTotalAddresses)(C1=LowercaseListName) - (C2=ns:addrbk:db:table:kind:deleted)(C3=_Yahoo)(C4=_MSN) - (C5=_GoogleTalk)(C6=_Skype)(C7=_JabberId)(C8=PreferDisplayName) - (C9=PhotoURI)(CA=PhotoType)(CB=PhotoName)(CC=DbRowID)(CD=_QQ)(CE=_ICQ) - (80=ns:addrbk:db:row:scope:card:all) - (81=ns:addrbk:db:row:scope:list:all) - (82=ns:addrbk:db:row:scope:data:all)(83=FirstName)(84=LastName) - (85=PhoneticFirstName)(86=PhoneticLastName)(87=DisplayName) - (88=NickName)(89=PrimaryEmail)(8A=LowercasePrimaryEmail) - (8B=SecondEmail)(8C=PreferMailFormat)(8D=PopularityIndex) - (8E=AllowRemoteContent)(8F=WorkPhone)(90=HomePhone)(91=FaxNumber) - (92=PagerNumber)(93=CellularNumber)(94=WorkPhoneType)(95=HomePhoneType) - (96=FaxNumberType)(97=PagerNumberType)(98=CellularNumberType) - (99=HomeAddress)(9A=HomeAddress2)(9B=HomeCity)(9C=HomeState) - (9D=HomeZipCode)(9E=HomeCountry)(9F=WorkAddress)(A0=WorkAddress2) - (A1=WorkCity)(A2=WorkState)(A3=WorkZipCode)(A4=WorkCountry) - (A5=JobTitle)(A6=Department)(A7=Company)(A8=_AimScreenName) - (A9=AnniversaryYear)(AA=AnniversaryMonth)(AB=AnniversaryDay) - (AC=SpouseName)(AD=FamilyName)(AE=WebPage1)(AF=WebPage2)(B0=BirthYear) - (B1=BirthMonth)(B2=BirthDay)(B3=Custom1)(B4=Custom2)(B5=Custom3) - (B6=Custom4)(B7=Notes)> - -<(AF=b)(81=John Doe)(82=)(80=0)(83=John)(84=1)(85=Doe)(86=john@doe.org) - (87=generic)(88=John Doe2)(89=Doe2)(8A=john@doe2.org)(8B=2)(8C=John Doe3) - (8D=Doe3)(8E=john@doe3.org)(8F=3)(90=John Doe4)(91=Doe4)(92 - =john@doe4.org)(93=4)(94=John Doe5)(95=Doe5)(96=john@doe5.org)(97=5) - (98=John Doe6)(99=Doe6)(9A=john@doe6.org)(9B=6)(9C=John Doe7)(9D=Doe7) - (9E=john@doe7.org)(9F=7)(A0=John Doe8)(A1=Doe8)(A2=john@doe8.org) - (A3=8)(A4=John Doe9)(A5=Doe9)(A6=john@doe9.org)(A7=9)(A8=John Doe10) - (A9=Doe10)(AA=john@doe10.org)(AB=10)(AC=a)(AD=Does_5)(AE=does_5)> -{1:^80 {(k^BC:c)(s=9)} - [1:^82(^BB=b)] - [1(^87^81)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) - (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) - (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^85)(^92=)(^C9=) - (^B6=)(^9D=)(^89^86)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) - (^90=)(^CC=1)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) - (^CE=)(^B5=)(^8A^86)(^B9=1)] - [2(^87^88)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) - (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) - (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^89)(^92=)(^C9=) - (^B6=)(^9D=)(^89^8A)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) - (^90=)(^CC=2)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) - (^CE=)(^B5=)(^8A^8A)(^B9=2)] - [3(^87^8C)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) - (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) - (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^8D)(^92=)(^C9=) - (^B6=)(^9D=)(^89^8E)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) - (^90=)(^CC=3)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) - (^CE=)(^B5=)(^8A^8E)(^B9=3)] - [4(^87^90)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) - (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) - (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^91)(^92=)(^C9=) - (^B6=)(^9D=)(^89^92)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) - (^90=)(^CC=4)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) - (^CE=)(^B5=)(^8A^92)(^B9=4)] - [5(^87^94)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) - (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) - (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^95)(^92=)(^C9=) - (^B6=)(^9D=)(^89^96)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) - (^90=)(^CC=5)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) - (^CE=)(^B5=)(^8A^96)(^B9=5)] - [6(^87^98)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) - (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) - (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^99)(^92=)(^C9=) - (^B6=)(^9D=)(^89^9A)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) - (^90=)(^CC=6)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) - (^CE=)(^B5=)(^8A^9A)(^B9=6)] - [7(^87^9C)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) - (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) - (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^9D)(^92=)(^C9=) - (^B6=)(^9D=)(^89^9E)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) - (^90=)(^CC=7)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) - (^CE=)(^B5=)(^8A^9E)(^B9=7)] - [8(^87^A0)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) - (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) - (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^A1)(^92=)(^C9=) - (^B6=)(^9D=)(^89^A2)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) - (^90=)(^CC=8)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) - (^CE=)(^B5=)(^8A^A2)(^B9=8)] - [9(^87^A4)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) - (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) - (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^A5)(^92=)(^C9=) - (^B6=)(^9D=)(^89^A6)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) - (^90=)(^CC=9)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) - (^CE=)(^B5=)(^8A^A6)(^B9=9)] - [A(^87^A8)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) - (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) - (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^A9)(^92=)(^C9=) - (^B6=)(^9D=)(^89^AA)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) - (^90=)(^CC=10)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) - (^CE=)(^B5=)(^8A^AA)(^B9=a)] - [1:^81(^BD^AD)(^C1^AE)(^BE=)(^BF=)(^C0=0)(^B9=b)]} - -@$${9{@ - -<(B2=c)(B0=Does_10)(B1=does_10)> -{1:^80 {(k^BC:c)(s=9)} - [-2:^81(^BD^B0)(^C1^B1)(^BE=)(^BF=)(^C0=0)(^B9=c)]} -[1:^82(^BB=c)] -@$$}9}@ - -@$${A{@ -< <(a=c)> // (f=iso-8859-1) - (CF=Address1)> -[-1:^81(^BD^AD)(^C1^AE)(^BE=)(^BF=)(^C0=1)(^B9=b)(^CF=1)] -@$$}A}@ - -@$${B{@ -< <(a=c)> // (f=iso-8859-1) - (D0=Address2)> -[-1:^81(^BD^AD)(^C1^AE)(^BE=)(^BF=)(^C0=2)(^B9=b)(^CF=1)(^D0=2)] -@$$}B}@ - -@$${C{@ -< <(a=c)> // (f=iso-8859-1) - (D1=Address3)> -[-1:^81(^BD^AD)(^C1^AE)(^BE=)(^BF=)(^C0=3)(^B9=b)(^CF=1)(^D0=2)(^D1=3)] -@$$}C}@ - -@$${D{@ -< <(a=c)> // (f=iso-8859-1) - (D2=Address4)> -[-1:^81(^BD^AD)(^C1^AE)(^BE=)(^BF=)(^C0=4)(^B9=b)(^CF=1)(^D0=2)(^D1=3) - (^D2=4)] -@$$}D}@ - -@$${E{@ -< <(a=c)> // (f=iso-8859-1) - (D3=Address5)> -[-1:^81(^BD^AD)(^C1^AE)(^BE=)(^BF=)(^C0=5)(^B9=b)(^CF=1)(^D0=2)(^D1=3) - (^D2=4)(^D3=5)] -@$$}E}@ - -@$${F{@ -[-2:^81(^BD^B0)(^C1^B1)(^BE=)(^BF=)(^C0=1)(^B9=c)(^CF=a)] -@$$}F}@ - -@$${10{@ -[-2:^81(^BD^B0)(^C1^B1)(^BE=)(^BF=)(^C0=2)(^B9=c)(^CF=a)(^D0=6)] -@$$}10}@ - -@$${11{@ -[-2:^81(^BD^B0)(^C1^B1)(^BE=)(^BF=)(^C0=3)(^B9=c)(^CF=a)(^D0=6)(^D1=7)] -@$$}11}@ - -@$${12{@ -[-2:^81(^BD^B0)(^C1^B1)(^BE=)(^BF=)(^C0=4)(^B9=c)(^CF=a)(^D0=6)(^D1=7) - (^D2=8)] -@$$}12}@ - -@$${13{@ -[-2:^81(^BD^B0)(^C1^B1)(^BE=)(^BF=)(^C0=5)(^B9=c)(^CF=a)(^D0=6)(^D1=7) - (^D2=8)(^D3=9)] -@$$}13}@ diff --git a/connectivity/registry/mork/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/mork/org/openoffice/Office/DataAccess/Drivers.xcu deleted file mode 100644 index 8e559cdf153d..000000000000 --- a/connectivity/registry/mork/org/openoffice/Office/DataAccess/Drivers.xcu +++ /dev/null @@ -1,51 +0,0 @@ -<?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: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 Address Book</value> - </prop> - <node oor:name="Properties"> - <node oor:name="EscapeDateTime" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - </node> - <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 deleted file mode 100644 index 743d1e5ab9c6..000000000000 --- a/connectivity/source/drivers/mork/MCatalog.cxx +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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> - - -using namespace connectivity::mork; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; - - -OCatalog::OCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon) - ,m_pConnection(_pCon) -{ -// osl_atomic_increment( &m_refCount ); -// refreshTables(); -// refreshViews(); -// refreshGroups(); -// refreshUsers(); -// osl_atomic_decrement( &m_refCount ); -} - -void OCatalog::refreshTables() -{ - ::std::vector< OUString> 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(3); - aVector.push_back(aName); - } - } - if(m_pTables) - m_pTables->reFill(aVector); - else - m_pTables.reset( new OTables(m_xMetaData,*this,m_aMutex,aVector) ); -} - -void OCatalog::refreshViews() -{ -} - -void OCatalog::refreshGroups() -{ -} - -void OCatalog::refreshUsers() -{ -} - - -// XTablesSupplier -Reference< XNameAccess > SAL_CALL OCatalog::getTables( ) -{ - ::osl::MutexGuard aGuard(m_aMutex); - checkDisposed(rBHelper.bDisposed); - - try - { - if(!m_pTables || OConnection::getForceLoadTables()) - refreshTables(); - } - catch( const RuntimeException& ) - { - // allowed to leave this method - throw; - } - catch( const Exception& ) - { - // allowed - } - - return m_pTables.get(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MCatalog.hxx b/connectivity/source/drivers/mork/MCatalog.hxx deleted file mode 100644 index 32d6d2b7e216..000000000000 --- a/connectivity/source/drivers/mork/MCatalog.hxx +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MORK_MCATALOG_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MCATALOG_HXX - -#include <sdbcx/VCatalog.hxx> - -namespace connectivity::mork - { - // please don't name the class the same name as in another 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 - - public: - // implementation of the pure virtual methods - virtual void refreshTables() override; - virtual void refreshViews() override ; - virtual void refreshGroups() override; - virtual void refreshUsers() override ; - virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTables( ) override; - public: - explicit OCatalog(OConnection* _pCon); - - OConnection* getConnection() const { return m_pConnection; } - - }; - -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MCATALOG_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MColumnAlias.cxx b/connectivity/source/drivers/mork/MColumnAlias.cxx deleted file mode 100644 index b320d8c459e3..000000000000 --- a/connectivity/source/drivers/mork/MColumnAlias.cxx +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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 <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <officecfg/Office/DataAccess.hxx> - -#include <osl/diagnose.h> -#include <sal/log.hxx> - -#include <algorithm> - -using namespace ::connectivity::mork; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::container; - - -OColumnAlias::OColumnAlias( const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxORB ) -{ - static const 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 < SAL_N_ELEMENTS( s_pProgrammaticNames ); ++i ) - m_aAliasMap[ OUString::createFromAscii( s_pProgrammaticNames[i] ) ] = AliasEntry( s_pProgrammaticNames[i], i ); - - initialize( _rxORB ); -} - - -void OColumnAlias::initialize( const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxORB ) -{ - Reference< XNameAccess > xAliasesNode( - officecfg::Office::DataAccess::DriverSettings:: - com_sun_star_comp_sdbc_MozabDriver::ColumnAliases::get( - comphelper::getComponentContext(_rxORB)), - UNO_QUERY_THROW); - const Sequence< OUString > aProgrammaticNames(xAliasesNode->getElementNames()); - for (const auto& rProgrammaticName : aProgrammaticNames) { - OString sAsciiProgrammaticName( - OUStringToOString( - rProgrammaticName, RTL_TEXTENCODING_ASCII_US)); - auto j = std::find_if(m_aAliasMap.begin(), m_aAliasMap.end(), - [&sAsciiProgrammaticName](const AliasMap::value_type& rEntry) { - return rEntry.second.programmaticAsciiName == sAsciiProgrammaticName; }); - if (j != m_aAliasMap.end()) { - OUString sAssignedAlias; - xAliasesNode->getByName(rProgrammaticName) >>= - sAssignedAlias; - if (sAssignedAlias.isEmpty()) { - sAssignedAlias = rProgrammaticName; - } - AliasEntry entry(j->second); - m_aAliasMap.erase(j); - m_aAliasMap[sAssignedAlias] = entry; - } - else { - SAL_WARN( - "connectivity.mork", - "unknown programmatic name " << rProgrammaticName - <<" from configuration"); - } - } -} - - -OString OColumnAlias::getProgrammaticNameOrFallbackToUTF8Alias( const 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 OUStringToOString( _rAlias, RTL_TEXTENCODING_UTF8 ); - } - return pos->second.programmaticAsciiName; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MColumnAlias.hxx b/connectivity/source/drivers/mork/MColumnAlias.hxx deleted file mode 100644 index 1482802768ff..000000000000 --- a/connectivity/source/drivers/mork/MColumnAlias.hxx +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MORK_MCOLUMNALIAS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MCOLUMNALIAS_HXX - -#include <unotools/confignode.hxx> - -#include <unordered_map> - -namespace connectivity::mork - { - class OColumnAlias - { - public: - struct AliasEntry - { - OString programmaticAsciiName; - size_t columnPosition; - - AliasEntry() - :programmaticAsciiName() - ,columnPosition( 0 ) - { - } - AliasEntry( const char* _programmaticAsciiName, size_t _columnPosition ) - :programmaticAsciiName( _programmaticAsciiName ) - ,columnPosition( _columnPosition ) - { - } - }; - typedef std::unordered_map< OUString, AliasEntry > AliasMap; - - private: - AliasMap m_aAliasMap; - - public: - explicit OColumnAlias( const css::uno::Reference< css::lang::XMultiServiceFactory > & ); - - OString getProgrammaticNameOrFallbackToUTF8Alias( const OUString& _rAlias ) const; - - AliasMap::const_iterator begin() const { return m_aAliasMap.begin(); } - AliasMap::const_iterator end() const { return m_aAliasMap.end(); } - - - private: - void initialize( const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxORB ); - }; - -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MCOLUMNALIAS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MColumns.cxx b/connectivity/source/drivers/mork/MColumns.cxx deleted file mode 100644 index c9163a6ab96b..000000000000 --- a/connectivity/source/drivers/mork/MColumns.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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 <com/sun/star/sdbc/XRow.hpp> -#include <connectivity/sdbcx/VColumn.hxx> - -using namespace connectivity::mork; -using namespace connectivity::sdbcx; -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::sdbc; - - -sdbcx::ObjectType OColumns::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; - if(xResult.is()) - { - Reference< XRow > xRow(xResult,UNO_QUERY); - while(xResult->next()) - { - if(xRow->getString(4) == _rName) - { - sal_Int32 nType = xRow->getInt(5); - 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, - false,false,false,true, - sCatalogName, - sSchemaName, - sTableName); - xRet = pRet; - break; - } - } - } - - return xRet; -} - - -void OColumns::impl_refresh() -{ - 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 deleted file mode 100644 index fa7a6f03bd8a..000000000000 --- a/connectivity/source/drivers/mork/MColumns.hxx +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MORK_MCOLUMNS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MCOLUMNS_HXX - -#include <connectivity/sdbcx/VCollection.hxx> -#include "MTable.hxx" - -namespace connectivity::mork - { - class OColumns final : public sdbcx::OCollection - { - OTable* m_pTable; - - virtual sdbcx::ObjectType createObject(const OUString& _rName) override; - virtual void impl_refresh() override; - public: - OColumns( OTable* _pTable, - ::osl::Mutex& _rMutex, - const ::std::vector< OUString> &_rVector - ) : sdbcx::OCollection(*_pTable, true, _rMutex, _rVector) - ,m_pTable(_pTable) - {} - }; - -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MCOLUMNS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MConnection.cxx b/connectivity/source/drivers/mork/MConnection.cxx deleted file mode 100644 index 2e1c08d0cdcf..000000000000 --- a/connectivity/source/drivers/mork/MConnection.cxx +++ /dev/null @@ -1,377 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include "MConnection.hxx" -#include "MDriver.hxx" -#include "MDatabaseMetaData.hxx" -#include "MCatalog.hxx" -#include "MPreparedStatement.hxx" -#include "MorkParser.hxx" - -#include <connectivity/dbexception.hxx> -#include <sal/log.hxx> - -#include <strings.hrc> - -#include <com/sun/star/sdbc/TransactionIsolation.hpp> - -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::mork { - -const int defaultScope = 0x80; - - -OConnection::OConnection(MorkDriver* _pDriver) - :m_xDriver(_pDriver) - ,m_aColumnAlias( _pDriver->getFactory() ) -{ - m_pBook.reset( new MorkParser() ); - m_pHistory.reset( new MorkParser() ); -} - -OConnection::~OConnection() -{ - if(!isClosed()) - close(); - m_pBook.reset(); - m_pHistory.reset(); -} - -void OConnection::construct(const OUString& url) -{ - 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.startsWith("sdbc:address:"), "OConnection::construct: invalid start of the URI - should never have survived XDriver::acceptsURL!" ); - - OUString aAddrbookURI(url.copy(nLen+1)); - // Get Scheme - nLen = aAddrbookURI.indexOf(':'); - OUString aAddrbookScheme; - 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); - } - - SAL_INFO("connectivity.mork", "URI = " << aAddrbookURI ); - SAL_INFO("connectivity.mork", "Scheme = " << aAddrbookScheme ); - - OUString abook; - OUString history; - const OUString UNITTEST_URL = "thunderbird:unittest:"; - sal_Int32 unittestIndex = url.indexOf(UNITTEST_URL); - - // production? - if (unittestIndex == -1) - { - OUString path = m_xDriver->getProfilePath(); - SAL_INFO("connectivity.mork", "ProfilePath: " << path); - abook = path + "/abook.mab"; - history = path + "/history.mab"; - SAL_INFO("connectivity.mork", "AdressbookPath (abook): " << abook); - SAL_INFO("connectivity.mork", "AdressbookPath (history): " << history); - } - else - { - abook = aAddrbookURI.replaceFirst(UNITTEST_URL, ""); - SAL_INFO("connectivity.mork", "unit test: " << abook); - } - - OString strPath = OUStringToOString(abook, RTL_TEXTENCODING_UTF8); - - // Open and parse mork file - if (!m_pBook->open(strPath.getStr())) - { - SAL_WARN("connectivity.mork", "Can not parse abook mork file: " << strPath); - const OUString sError( getResources().getResourceStringWithSubstitution( - STR_COULD_NOT_LOAD_FILE, "$filename$", abook)); - ::dbtools::throwGenericSQLException( sError, *this ); - } - - // read history only in production - if (unittestIndex == -1) - { - strPath = OUStringToOString(history, RTL_TEXTENCODING_UTF8); - if (!m_pHistory->open(strPath.getStr())) - { - SAL_WARN("connectivity.mork", "Can not parse history mork file: " << strPath); - const OUString sError( getResources().getResourceStringWithSubstitution( - STR_COULD_NOT_LOAD_FILE, "$filename$", history)); - ::dbtools::throwGenericSQLException( sError, *this ); - } - } - - // check that we can retrieve the tables: - MorkTableMap *Tables = m_pBook->getTables( defaultScope ); - if (Tables) - { - // Iterate all tables - for ( const auto& rEntry : Tables->map ) - { - if ( 0 == rEntry.first ) continue; - SAL_INFO("connectivity.mork", "table->first : " << rEntry.first); - } - } - // check that we can retrieve the history tables: - MorkTableMap *Tables_hist = m_pHistory->getTables( defaultScope ); - if (Tables_hist) - { - // Iterate all tables - for ( const auto& rEntry : Tables_hist->map ) - { - if ( 0 == rEntry.first ) continue; - SAL_INFO("connectivity.mork", "table->first : " << rEntry.first); - } - } -} - -// XServiceInfo - -IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.mork.OConnection", "com.sun.star.sdbc.Connection") - - -Reference< XStatement > SAL_CALL OConnection::createStatement( ) -{ - 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 OUString& _sSql ) -{ - SAL_INFO("connectivity.mork", "=> OConnection::prepareStatement()" ); - SAL_INFO("connectivity.mork", "OConnection::prepareStatement( " << _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 OUString& _sSql ) -{ - SAL_INFO("connectivity.mork", "=> OConnection::prepareCall()" ); - SAL_INFO("connectivity.mork", "sql: " << _sSql); - ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::prepareCall", *this ); - SAL_INFO("connectivity.mork", "OConnection::prepareCall( " << _sSql << " )"); - return nullptr; -} - -OUString SAL_CALL OConnection::nativeSQL( const OUString& _sSql ) -{ - 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*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setAutoCommit", *this ); -} - -sal_Bool SAL_CALL OConnection::getAutoCommit( ) -{ - // 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 OConnection::commit( ) -{ - // when you database does support transactions you should commit here -} - -void SAL_CALL OConnection::rollback( ) -{ - // same as commit but for the other case -} - -sal_Bool SAL_CALL OConnection::isClosed( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - // just simple -> we are close when we are disposed that means someone called dispose(); (XComponent) - return OConnection_BASE::rBHelper.bDisposed; -} - -Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) -{ - 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*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setReadOnly", *this ); -} - -sal_Bool SAL_CALL OConnection::isReadOnly( ) -{ - // return if your connection to readonly - return false; -} - -void SAL_CALL OConnection::setCatalog( const OUString& /*catalog*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setCatalog", *this ); -} - -OUString SAL_CALL OConnection::getCatalog( ) -{ - return OUString(); -} - -void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 /*level*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setTransactionIsolation", *this ); -} - -sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) -{ - // please have a look at @see com.sun.star.sdbc.TransactionIsolation - return TransactionIsolation::NONE; -} - -Reference< css::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) -{ - // if your driver has special database types you can return it here - return nullptr; -} - -void SAL_CALL OConnection::setTypeMap( const Reference< css::container::XNameAccess >& /*typeMap*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XConnection::setTypeMap", *this ); -} - -// XCloseable -void SAL_CALL OConnection::close( ) -{ - // we just dispose us - { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OConnection_BASE::rBHelper.bDisposed); - - } - dispose(); -} - -// XWarningsSupplier -Any SAL_CALL OConnection::getWarnings( ) -{ - // when you collected some warnings -> return it - return Any(); -} - -void SAL_CALL OConnection::clearWarnings( ) -{ - // you should clear your collected warnings here -} - -void OConnection::disposing() -{ - // we noticed that we should be destroyed in near future so we have to dispose our statements - ::osl::MutexGuard aGuard(m_aMutex); - m_xCatalog.clear(); -} - -Reference< XTablesSupplier > 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; - } - return xTab; -} - -void OConnection::throwSQLException( const ErrorDescriptor& _rError, const Reference< XInterface >& _rxContext ) -{ - if (_rError.getResId() != nullptr) - { - throwGenericSQLException( _rError.getResId(), _rxContext ); - OSL_FAIL( "OConnection::throwSQLException: unreachable (2)!" ); - } - - throwGenericSQLException( STR_UNSPECIFIED_ERROR, _rxContext ); -} - -void OConnection::throwSQLException( const char* pErrorResourceId, const Reference< XInterface >& _rxContext ) -{ - ErrorDescriptor aError; - aError.setResId(pErrorResourceId); - 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 deleted file mode 100644 index 67511b891d84..000000000000 --- a/connectivity/source/drivers/mork/MConnection.hxx +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MCONNECTION_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MCONNECTION_HXX - -#include <TConnection.hxx> -#include "MColumnAlias.hxx" - -#include <rtl/ref.hxx> - -#include <com/sun/star/sdbcx/XTablesSupplier.hpp> - -// do we want here namespace too? -class MorkParser; - -namespace connectivity::mork - { - class MorkDriver; - class ErrorDescriptor; - - typedef connectivity::OMetaConnection OConnection_BASE; // implements basics and text encoding - - class OConnection final : public OConnection_BASE - { - // Data attributes - - rtl::Reference<MorkDriver> m_xDriver; // Pointer to the owning - // driver object - OColumnAlias m_aColumnAlias; - // Mork Parser (abook) - std::unique_ptr<MorkParser> m_pBook; - // Mork Parser (history) - std::unique_ptr<MorkParser> m_pHistory; - // Store Catalog - css::uno::Reference< css::sdbcx::XTablesSupplier> m_xCatalog; - - public: - /// @throws css::sdbc::SQLException - void construct( const OUString& url); - explicit OConnection(MorkDriver* const driver); - virtual ~OConnection() override; - - const rtl::Reference<MorkDriver>& getDriver() const {return m_xDriver;}; - MorkParser* getMorkParser(std::string_view t) {return t == "CollectedAddressBook" ? m_pHistory.get() : m_pBook.get();}; - - // OComponentHelper - virtual void SAL_CALL disposing() 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; - - const OColumnAlias & getColumnAlias() const { return m_aColumnAlias; } - - static bool getForceLoadTables() {return true;} - - // Added to enable me to use SQLInterpreter which requires an - // XNameAccess i/f to access tables. - css::uno::Reference< css::sdbcx::XTablesSupplier > createCatalog(); - - void throwSQLException( const ErrorDescriptor& _rError, const css::uno::Reference< css::uno::XInterface >& _rxContext ); - void throwSQLException( const char* pErrorResourceId, const css::uno::Reference< css::uno::XInterface >& _rxContext ); - }; - -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MCONNECTION_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MDatabaseMetaData.cxx b/connectivity/source/drivers/mork/MDatabaseMetaData.cxx deleted file mode 100644 index 959494095b9f..000000000000 --- a/connectivity/source/drivers/mork/MDatabaseMetaData.cxx +++ /dev/null @@ -1,959 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include "MConnection.hxx" -#include "MDatabaseMetaData.hxx" - -#include <com/sun/star/sdbc/TransactionIsolation.hpp> -#include <com/sun/star/sdbc/ColumnSearch.hpp> -#include <sal/log.hxx> - -#include <string_view> -#include <vector> - -#include "MDatabaseMetaDataHelper.hxx" - -using namespace connectivity::mork; -using namespace connectivity; - -using namespace com::sun::star::uno; -using namespace com::sun::star::sdbc; - - -namespace connectivity::mork -{ - sal_Int32 const s_nCOLUMN_SIZE = 256; - sal_Int32 const s_nDECIMAL_DIGITS = 0; - sal_Int32 const s_nNULLABLE = 1; - sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535; -} - -ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon) - : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo()) - ,m_pConnection(_pCon) - ,m_pMetaDataHelper(new MDatabaseMetaDataHelper) -{ - OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!"); -} - -ODatabaseMetaData::~ODatabaseMetaData() -{ -} - - -ODatabaseMetaDataResultSet::ORows ODatabaseMetaData::getColumnRows( - const OUString& tableNamePattern, - const OUString& columnNamePattern ) -{ - SAL_INFO("connectivity.mork", "=> ODatabaseMetaData::getColumnRows()" ); - SAL_INFO("connectivity.mork", "tableNamePattern: " << tableNamePattern); - SAL_INFO("connectivity.mork", "columnNamePattern: " << columnNamePattern); - - ODatabaseMetaDataResultSet::ORows aRows; - ODatabaseMetaDataResultSet::ORow aRow(19); - - ::osl::MutexGuard aGuard( m_aMutex ); - std::vector< OUString > tables; - connectivity::mork::MDatabaseMetaDataHelper::getTableStrings(m_pConnection, tables); - - // **************************************************** - // Some entries in a row never change, so set them now - // **************************************************** - - // Catalog - aRow[1] = new ORowSetValueDecorator(OUString()); - // Schema - aRow[2] = new ORowSetValueDecorator(OUString()); - // DATA_TYPE - aRow[5] = new ORowSetValueDecorator(static_cast<sal_Int16>(DataType::VARCHAR)); - // TYPE_NAME, not used - aRow[6] = new ORowSetValueDecorator(OUString("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(OUString("YES")); - - // Iterate over all tables - for(const OUString & table : tables) { - if(match(tableNamePattern, table,'\0')) { - // TABLE_NAME - aRow[3] = new ORowSetValueDecorator( table ); - - const OColumnAlias& colNames = m_pConnection->getColumnAlias(); - - SAL_INFO("connectivity.mork", "\tTableName = : " << table); - // Iterate over all columns in the table. - for (const auto& [rName, rAlias] : colNames) - { - if ( match( columnNamePattern, rName, '\0' ) ) - { - SAL_INFO("connectivity.mork", "\t\tColumnNam : " << rName); - - // COLUMN_NAME - aRow[4] = new ORowSetValueDecorator( rName ); - // ORDINAL_POSITION - aRow[17] = new ORowSetValueDecorator( static_cast< sal_Int32 >( rAlias.columnPosition ) + 1 ); - aRows.push_back(aRow); - } - } - } - } - return aRows; -} - -OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( ) -{ - return OUString(); -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) -{ - return 65535; // 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) -{ - return 0; // 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) -{ - return 0; // 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) -{ - return 254; // 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) -{ - return 20; // 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) -{ - return 0; // 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) -{ - return 0; // 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) -{ - return 0; // 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) -{ - return 0; // 0 means no limit -} - -sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( ) -{ - return 0; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) -{ - return 0; // 0 means no limit -} - -sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( ) -{ - // We only support a single table - return 1; -} - - -sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) -{ - return false; -} - -bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) -{ - return false; -} - -bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( ) -{ - return false; -} - -bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( ) -{ - return false; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) -{ - return 0; // 0 means no limit -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) -{ - return false; -} - -OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) -{ - return OUString(); -} - -OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( ) -{ - // normally this is " - return "\""; -} - -OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) -{ - return OUString(); -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) -{ - return true; -} - -bool ODatabaseMetaData::impl_isCatalogAtStart_throw( ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) -{ - //We support create table - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ ) -{ - return false; -} - -bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) -{ - return true; // should be supported at least -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) -{ - return false; -} - -bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( ) -{ - return false; -} - -bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) -{ - return false; -} - -bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) -{ - return false; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) -{ - return 0;// 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) -{ - return 0; // 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) -{ - return 0; // 0 means no limit -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) -{ - // We allow you to select from any table. - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) -{ - //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 true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) -{ - // Support added for this. - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) -{ - return true; -} - -bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( ) -{ - // Any case may be used - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) -{ - return false; -} - -OUString SAL_CALL ODatabaseMetaData::getURL( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - return m_pConnection->getURL(); -} - -OUString SAL_CALL ODatabaseMetaData::getUserName( ) -{ - return OUString(); -} - -OUString SAL_CALL ODatabaseMetaData::getDriverName( ) -{ - return OUString(); -} - -OUString SAL_CALL ODatabaseMetaData::getDriverVersion() -{ - OUString aValue = OUString::number(1); - return aValue; -} - -OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) -{ - OUString aValue = OUString::number(0); - return aValue; -} - -OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) -{ - return OUString(); -} - -OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) -{ - return OUString(); -} - -OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) -{ - return OUString(); -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) -{ - return 1; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) -{ - return TransactionIsolation::NONE; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) -{ - return 0; -} - -OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) -{ - return OUString(); -} - -OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) -{ - return OUString(); -} - -OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) -{ - return OUString(); -} - -OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) -{ - return OUString(); -} - -OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) -{ - return OUString(); -} - -OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) -{ - return OUString(); -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) -{ - return false; -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) -{ - return 0; // 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) -{ - return 0; // 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) -{ - return 0; // 0 means no limit -} - -sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) -{ - return 0; // 0 means no limit -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ ) -{ - return false; -} - -sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) -{ - return true; -} - -sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) -{ - return 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( ) -{ - // there exists no possibility to get table types so we have to check - static const std::u16string_view sTableTypes[] = - { - u"TABLE", - u"VIEW" - // Currently we only support a 'TABLE' and 'VIEW' nothing more complex - - // OUString("SYSTEM TABLE"), - // OUString("GLOBAL TEMPORARY"), - // OUString("LOCAL TEMPORARY"), - // OUString("ALIAS"), - // OUString("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 - ODatabaseMetaDataResultSet::ORows aRows; - for(const auto & sTableType : sTableTypes) - { - ODatabaseMetaDataResultSet::ORow aRow; - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator(OUString(sTableType))); - // 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 = [&]() - { - ODatabaseMetaDataResultSet::ORows tmp; - ODatabaseMetaDataResultSet::ORow aRow; - aRow.reserve(19); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator(OUString("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))); - - tmp.push_back(aRow); - return tmp; - }(); - pResultSet->setRows(aRows); - return xResultSet; -} - -Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns( - const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& tableNamePattern, - const OUString& columnNamePattern ) -{ - // 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 OUString& /*schemaPattern*/, - const OUString& tableNamePattern, const Sequence< OUString >& /*types*/ ) -{ - 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; - connectivity::mork::MDatabaseMetaDataHelper::getTables( m_pConnection, tableNamePattern, _rRows ); - pResultSet->setRows( _rRows ); - - return xResultSet; -} - -Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( - const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& tableNamePattern ) -{ - SAL_INFO("connectivity.mork", "=> ODatabaseMetaData::getTablePrivileges()" ); - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges); - Reference< XResultSet > xRef = pResult; - - std::vector< OUString > tables; - connectivity::mork::MDatabaseMetaDataHelper::getTableStrings( m_pConnection, tables); - - ::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(OUString("NO")); - - - // Iterate over all tables - for(const OUString & table : tables) { - if(match(tableNamePattern, table,'\0')) - { - // TABLE_NAME - aRow[2] = new ORowSetValueDecorator( table ); - - SAL_INFO("connectivity.mork", "\tTableName = : " << table); - - 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 OUString& /*schemaPattern*/, const OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) -{ - return nullptr; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MDatabaseMetaData.hxx b/connectivity/source/drivers/mork/MDatabaseMetaData.hxx deleted file mode 100644 index 22f4aad769e6..000000000000 --- a/connectivity/source/drivers/mork/MDatabaseMetaData.hxx +++ /dev/null @@ -1,189 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MDATABASEMETADATA_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MDATABASEMETADATA_HXX - -#include <memory> -#include <TDatabaseMetaDataBase.hxx> -#include "MConnection.hxx" - -namespace connectivity::mork - { - class MDatabaseMetaDataHelper; - - //************ Class: ODatabaseMetaData - - - class ODatabaseMetaData : public ODatabaseMetaDataBase - { - OConnection* m_pConnection; - std::unique_ptr<MDatabaseMetaDataHelper> - m_pMetaDataHelper; - - /// @throws css::sdbc::SQLException - ODatabaseMetaDataResultSet::ORows getColumnRows( const OUString& tableNamePattern, const OUString& columnNamePattern ); - - protected: - virtual ~ODatabaseMetaData() override; - - public: - explicit ODatabaseMetaData(OConnection* _pCon); - - private: - virtual css::uno::Reference< css::sdbc::XResultSet > impl_getTypeInfo_throw() override; - // cached database information - virtual OUString impl_getIdentifierQuoteString_throw( ) override; - virtual bool impl_isCatalogAtStart_throw( ) override; - virtual OUString impl_getCatalogSeparator_throw( ) override; - virtual bool impl_supportsCatalogsInTableDefinitions_throw( ) override; - virtual bool impl_supportsSchemasInTableDefinitions_throw( ) override ; - virtual bool impl_supportsCatalogsInDataManipulation_throw( ) override; - virtual bool impl_supportsSchemasInDataManipulation_throw( ) override ; - virtual bool impl_supportsMixedCaseQuotedIdentifiers_throw( ) override ; - virtual bool impl_supportsAlterTableWithAddColumn_throw( ) override; - virtual bool impl_supportsAlterTableWithDropColumn_throw( ) override; - virtual sal_Int32 impl_getMaxStatements_throw( ) override; - virtual sal_Int32 impl_getMaxTablesInSelect_throw( ) override; - virtual bool impl_storesMixedCaseQuotedIdentifiers_throw( ) override; - - // as I mentioned before this interface is really BIG - // XDatabaseMetaData - virtual sal_Bool SAL_CALL allProceduresAreCallable( ) override; - virtual sal_Bool SAL_CALL allTablesAreSelectable( ) override; - virtual OUString SAL_CALL getURL( ) override; - virtual OUString SAL_CALL getUserName( ) override; - virtual sal_Bool SAL_CALL isReadOnly( ) override; - virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) override; - virtual sal_Bool SAL_CALL nullsAreSortedLow( ) override; - virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) override; - virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) override; - virtual OUString SAL_CALL getDatabaseProductName( ) override; - virtual OUString SAL_CALL getDatabaseProductVersion( ) override; - virtual OUString SAL_CALL getDriverName( ) override; - virtual OUString SAL_CALL getDriverVersion( ) override; - virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) override; - virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) override; - virtual sal_Bool SAL_CALL usesLocalFiles( ) override; - virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) override; - virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) override; - virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) override; - virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) override; - virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) override; - virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) override; - virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) override; - virtual OUString SAL_CALL getSQLKeywords( ) override; - virtual OUString SAL_CALL getNumericFunctions( ) override; - virtual OUString SAL_CALL getStringFunctions( ) override; - virtual OUString SAL_CALL getSystemFunctions( ) override; - virtual OUString SAL_CALL getTimeDateFunctions( ) override; - virtual OUString SAL_CALL getSearchStringEscape( ) override; - virtual OUString SAL_CALL getExtraNameCharacters( ) override; - virtual sal_Bool SAL_CALL supportsColumnAliasing( ) override; - virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) override; - virtual sal_Bool SAL_CALL supportsTypeConversion( ) override; - virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) override; - virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) override; - virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) override; - virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) override; - virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) override; - virtual sal_Bool SAL_CALL supportsGroupBy( ) override; - virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) override; - virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) override; - virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) override; - virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) override; - virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) override; - virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) override; - virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) override; - virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) override; - virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) override; - virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) override; - virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) override; - virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) override; - virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) override; - virtual sal_Bool SAL_CALL supportsOuterJoins( ) override; - virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) override; - virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) override; - virtual OUString SAL_CALL getSchemaTerm( ) override; - virtual OUString SAL_CALL getProcedureTerm( ) override; - virtual OUString SAL_CALL getCatalogTerm( ) override; - virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) override; - virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) override; - virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) override; - virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) override; - virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) override; - virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) override; - virtual sal_Bool SAL_CALL supportsPositionedDelete( ) override; - virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) override; - virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) override; - virtual sal_Bool SAL_CALL supportsStoredProcedures( ) override; - virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) override; - virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) override; - virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) override; - virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) override; - virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) override; - virtual sal_Bool SAL_CALL supportsUnion( ) override; - virtual sal_Bool SAL_CALL supportsUnionAll( ) override; - virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) override; - virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) override; - virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) override; - virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) override; - virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) override; - virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) override; - virtual sal_Int32 SAL_CALL getMaxConnections( ) override; - virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxIndexLength( ) override; - virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxRowSize( ) override; - virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) override; - virtual sal_Int32 SAL_CALL getMaxStatementLength( ) override; - virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) override; - virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) override; - virtual sal_Bool SAL_CALL supportsTransactions( ) override; - virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) override; - virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) override; - virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) override; - virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) override; - virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) override; - - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTables( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const css::uno::Sequence< OUString >& types ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTableTypes( ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTablePrivileges( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getColumns( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const OUString& columnNamePattern ) override; - - virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) override; - virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) override; - virtual sal_Bool SAL_CALL supportsBatchUpdates( ) override; - - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getUDTs( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& typeNamePattern, const css::uno::Sequence< sal_Int32 >& types ) override; - }; - -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MDATABASEMETADATA_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx b/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx deleted file mode 100644 index ca699bafaefd..000000000000 --- a/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include "MConnection.hxx" -#include "MDatabaseMetaDataHelper.hxx" - -// do we need it? -static ::osl::Mutex m_aMetaMutex; - -#include <sal/log.hxx> - -#include "MorkParser.hxx" - -using namespace connectivity; -using namespace connectivity::mork; - - -MDatabaseMetaDataHelper::MDatabaseMetaDataHelper() -{ - SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()" ); -} - - -MDatabaseMetaDataHelper::~MDatabaseMetaDataHelper() -{ -} - -void MDatabaseMetaDataHelper::getTableStrings( OConnection* _pCon, - std::vector< OUString >& _rStrings) -{ - SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTableStrings()"); - - /* add default tables */ - _rStrings.push_back("AddressBook"); - _rStrings.push_back("CollectedAddressBook"); - - /* retrieve list table names (not from collected ab) */ - std::set<std::string> lists; - MorkParser* pMork = _pCon->getMorkParser("AddressBook"); - pMork->retrieveLists(lists); - for (auto const& elem : lists) - { - OUString groupTableName = OStringToOUString(elem.c_str(), RTL_TEXTENCODING_UTF8); - SAL_INFO("connectivity.mork", "add Table " << groupTableName); - - _rStrings.push_back(groupTableName); - // remember the list in the mork parser, we'll use it later - pMork->lists_.push_back(groupTableName); - } - - std::set<std::string> lists_history; - pMork = _pCon->getMorkParser("CollectedAddressBook"); - pMork->retrieveLists(lists_history); - for (auto const& elem : lists_history) - { - OUString groupTableName = OStringToOUString(elem.c_str(), RTL_TEXTENCODING_UTF8); - SAL_INFO("connectivity.mork", "add Table " << groupTableName); - - _rStrings.push_back(groupTableName); - // remember the list in the mork parser, we'll use it later - pMork->lists_.push_back(groupTableName); - } -} - -void MDatabaseMetaDataHelper::getTables( OConnection* _pCon, - const OUString& tableNamePattern, - ODatabaseMetaDataResultSet::ORows& _rRows) -{ - - SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTables()"); - - static ODatabaseMetaDataResultSet::ORows aRows; - - SAL_INFO("connectivity.mork", "=> MDatabaseMetaDataHelper::getTables()" ); - SAL_INFO("connectivity.mork", "tableNamePattern : " << tableNamePattern); - ::osl::MutexGuard aGuard( m_aMetaMutex ); - - ODatabaseMetaDataResultSet::ORows().swap(aRows); // this makes real clear where memory is freed as well - aRows.clear(); - - std::vector< OUString > tables; - - getTableStrings( _pCon, tables ); - - for (OUString& aTableName : tables) { - ODatabaseMetaDataResultSet::ORow aRow { nullptr, nullptr, nullptr }; - - SAL_INFO("connectivity.mork", "TableName: " << aTableName ); - - - // return tables to caller - if (match( tableNamePattern, aTableName, '\0' )) - { - if ( aTableName.isEmpty() ) { - aTableName = "AddressBook"; - } - - SAL_INFO("connectivity.mork", "TableName: " << aTableName); - - aRow.push_back( new ORowSetValueDecorator( aTableName ) ); // Table/View name - if ((aTableName == "AddressBook") || (aTableName == "CollectedAddressBook")) - { - aRow.push_back( new ORowSetValueDecorator( OUString("TABLE") ) ); // Table type - } - else - { - aRow.push_back( new ORowSetValueDecorator( OUString("VIEW") ) ); // View type - } - aRow.push_back( ODatabaseMetaDataResultSet::getEmptyValue() ); // Remarks - aRows.push_back(aRow); - } - } - - _rRows = aRows; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.hxx b/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.hxx deleted file mode 100644 index 6c709b256a3b..000000000000 --- a/connectivity/source/drivers/mork/MDatabaseMetaDataHelper.hxx +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MDATABASEMETADATAHELPER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MDATABASEMETADATAHELPER_HXX - -#include <FDatabaseMetaDataResultSet.hxx> -#include "MConnection.hxx" - -namespace connectivity::mork - { - class MDatabaseMetaDataHelper - { - public: - MDatabaseMetaDataHelper(); - ~MDatabaseMetaDataHelper(); - - - static void getTableStrings( OConnection* _pCon, - std::vector< OUString >& _rStrings); - - static void getTables( OConnection* _pCon, - const OUString& tableNamePattern, - ODatabaseMetaDataResultSet::ORows& _rRows); - }; - -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MDATABASEMETADATAHELPER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MDriver.cxx b/connectivity/source/drivers/mork/MDriver.cxx deleted file mode 100644 index 0351b6c3e04f..000000000000 --- a/connectivity/source/drivers/mork/MDriver.cxx +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include "MDriver.hxx" -#include "MConnection.hxx" - -#include <com/sun/star/mozilla/XMozillaBootstrap.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> - -#include <sal/log.hxx> - -using namespace connectivity::mork; - -extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_sdbc_MorkDriver_get_implementation( - css::uno::XComponentContext* context, - css::uno::Sequence<css::uno::Any> const &) -{ - return cppu::acquire(new MorkDriver(context)); -} - -MorkDriver::MorkDriver(const css::uno::Reference< css::uno::XComponentContext >& context): - context_(context), - m_xFactory(context_->getServiceManager(), css::uno::UNO_QUERY) -{ - SAL_INFO("connectivity.mork", "=> MorkDriver::MorkDriver()" ); -} - -OUString SAL_CALL MorkDriver::getImplementationName() -{ - return MORK_DRIVER_IMPL_NAME; -} - -sal_Bool SAL_CALL MorkDriver::supportsService(const OUString& serviceName) -{ - return cppu::supportsService(this, serviceName); -} - -css::uno::Sequence< OUString > MorkDriver::getSupportedServiceNames() -{ - return { "com.sun.star.sdbc.Driver" }; -} - -css::uno::Reference< css::sdbc::XConnection > MorkDriver::connect( - OUString const & url, - css::uno::Sequence< css::beans::PropertyValue > const &) -{ - SAL_INFO("connectivity.mork", "=> MorkDriver::connect()" ); - - // Profile discovery - css::uno::Reference<css::uno::XInterface> xInstance = context_->getServiceManager()->createInstanceWithContext("com.sun.star.mozilla.MozillaBootstrap", context_); - OSL_ENSURE( xInstance.is(), "failed to create instance" ); - - css::uno::Reference<css::mozilla::XMozillaBootstrap> xMozillaBootstrap(xInstance, css::uno::UNO_QUERY); - OSL_ENSURE( xMozillaBootstrap.is(), "failed to create instance" ); - - if (xMozillaBootstrap.is()) - { - OUString defaultProfile = xMozillaBootstrap->getDefaultProfile(css::mozilla::MozillaProductType_Thunderbird); - - if (!defaultProfile.isEmpty()) - { - m_sProfilePath = xMozillaBootstrap->getProfilePath(css::mozilla::MozillaProductType_Thunderbird, defaultProfile); - SAL_INFO("connectivity.mork", "Using Thunderbird profile " << m_sProfilePath); - } - } - - 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); - return xCon; -} - -sal_Bool MorkDriver::acceptsURL(OUString const & url) -{ - SAL_INFO("connectivity.mork", "=> MorkDriver::acceptsURL()" ); - // Skip 'sdbc:mozab: part of URL - - sal_Int32 nLen = url.indexOf(':'); - nLen = url.indexOf(':',nLen+1); - OUString aAddrbookURI(url.copy(nLen+1)); - // Get Scheme - nLen = aAddrbookURI.indexOf(':'); - OUString aAddrbookScheme; - if ( nLen == -1 ) - { - // There isn't any subschema: - but could be just subschema - if ( !aAddrbookURI.isEmpty() ) - { - aAddrbookScheme= aAddrbookURI; - } - else if( url == "sdbc:address:" ) - { - return false; - } - else - { - return false; - } - } - else - { - aAddrbookScheme = aAddrbookURI.copy(0, nLen); - } - - return aAddrbookScheme == "thunderbird" || aAddrbookScheme == "mozilla"; -} - -css::uno::Sequence< css::sdbc::DriverPropertyInfo > MorkDriver::getPropertyInfo( - OUString const &, - css::uno::Sequence< css::beans::PropertyValue > const &) -{ - //... TODO - return css::uno::Sequence< css::sdbc::DriverPropertyInfo >(); -} - -sal_Int32 MorkDriver::getMajorVersion() { - //... TODO - return 0; -} - -sal_Int32 MorkDriver::getMinorVersion() { - //... 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 deleted file mode 100644 index 6f6946af6f5b..000000000000 --- a/connectivity/source/drivers/mork/MDriver.hxx +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MDRIVER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MDRIVER_HXX - -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/sdbc/DriverPropertyInfo.hpp> - -#include <com/sun/star/sdbc/XDriver.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <cppuhelper/implbase.hxx> - -#define MORK_DRIVER_IMPL_NAME "com.sun.star.comp.sdbc.MorkDriver" - -namespace com::sun::star { - namespace uno { - class XComponentContext; - class XInterface; - } -} - -namespace connectivity::mork { -class ProfileAccess; - -class MorkDriver: - public cppu::WeakImplHelper< css::lang::XServiceInfo, css::sdbc::XDriver > -{ -public: - explicit MorkDriver(const css::uno::Reference< css::uno::XComponentContext >& context); - - const css::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& getFactory() const {return m_xFactory;} - const OUString& getProfilePath() const {return m_sProfilePath;} -private: - - MorkDriver(const MorkDriver&) = delete; - MorkDriver& operator=(const MorkDriver&) = delete; - - virtual ~MorkDriver() override {} - - virtual OUString SAL_CALL getImplementationName() override; - - virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; - - virtual css::uno::Sequence< OUString > SAL_CALL - getSupportedServiceNames() override; - - virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect( - OUString const & url, - css::uno::Sequence< css::beans::PropertyValue > const & info) override; - - virtual sal_Bool SAL_CALL acceptsURL( - OUString const & url) override; - - virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL - getPropertyInfo( - OUString const & url, - css::uno::Sequence< css::beans::PropertyValue > const & info) override; - - virtual sal_Int32 SAL_CALL getMajorVersion() override; - - virtual sal_Int32 SAL_CALL getMinorVersion() override; - - css::uno::Reference< css::uno::XComponentContext > context_; - css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; - OUString m_sProfilePath; -}; - -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MErrorResource.hxx b/connectivity/source/drivers/mork/MErrorResource.hxx deleted file mode 100644 index a0efc09cbd9b..000000000000 --- a/connectivity/source/drivers/mork/MErrorResource.hxx +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MORK_MERRORRESOURCE_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MERRORRESOURCE_HXX - -namespace connectivity::mork - { - class ErrorDescriptor - { - private: - const char* m_pErrorResourceId; - - public: - ErrorDescriptor() - :m_pErrorResourceId(nullptr) - { - } - - void setResId(const char* pErrorResourceId) - { - m_pErrorResourceId = pErrorResourceId; - } - void reset() - { - m_pErrorResourceId = nullptr; - } - - const char* getResId() const { return m_pErrorResourceId; } - - bool is() const { return m_pErrorResourceId != nullptr; } - }; - -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MERRORRESOURCE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MPreparedStatement.cxx b/connectivity/source/drivers/mork/MPreparedStatement.cxx deleted file mode 100644 index f2cd8fdc752e..000000000000 --- a/connectivity/source/drivers/mork/MPreparedStatement.cxx +++ /dev/null @@ -1,486 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include <connectivity/sdbcx/VColumn.hxx> -#include "MPreparedStatement.hxx" -#include "MResultSetMetaData.hxx" -#include <connectivity/dbtools.hxx> -#include <comphelper/types.hxx> -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <sal/log.hxx> - -using namespace ::comphelper; -using namespace connectivity; -using namespace connectivity::mork; -using namespace com::sun::star::uno; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::container; -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 OUString& sql) - :OCommonStatement(_pConnection) - ,m_sSqlStatement(sql) - ,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->clear(); - m_aParameterRow = nullptr; - } - m_xParamColumns = nullptr; -} - -OCommonStatement::StatementType OPreparedStatement::parseSql( const OUString& sql , bool bAdjusted ) -{ - 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, false, m_xDBMetaData, m_aColMapping ); - - return eStatementType; -} - -void OPreparedStatement::initializeResultSet( OResultSet* _pResult ) -{ - OCommonStatement::initializeResultSet( _pResult ); - _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 == nullptr, "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 ) -{ - Any aRet = OCommonStatement::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OPreparedStatement_BASE::queryInterface(rType); - return aRet; -} - -css::uno::Sequence< css::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) -{ - return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OCommonStatement::getTypes()); -} - - -Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - bool bReadOnly = 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( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - Reference< XResultSet> xResult = executeQuery(); - return xResult.is(); -} - - -sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XStatement::executeUpdate", *this ); - return 0; -} - - -void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const OUString& x ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - setParameter( parameterIndex, x ); -} - - -Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - return Reference< XConnection >(m_pConnection.get()); -} - - -Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - 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*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setBoolean", *this ); -} - -void SAL_CALL OPreparedStatement::setByte( sal_Int32 /*parameterIndex*/, sal_Int8 /*x*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setByte", *this ); -} - - -void SAL_CALL OPreparedStatement::setDate( sal_Int32 /*parameterIndex*/, const Date& /*aData*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setDate", *this ); -} - - -void SAL_CALL OPreparedStatement::setTime( sal_Int32 /*parameterIndex*/, const css::util::Time& /*aVal*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setTime", *this ); -} - - -void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 /*parameterIndex*/, const DateTime& /*aVal*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setTimestamp", *this ); -} - - -void SAL_CALL OPreparedStatement::setDouble( sal_Int32 /*parameterIndex*/, double /*x*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setDouble", *this ); -} - - -void SAL_CALL OPreparedStatement::setFloat( sal_Int32 /*parameterIndex*/, float /*x*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setFloat", *this ); -} - - -void SAL_CALL OPreparedStatement::setInt( sal_Int32 /*parameterIndex*/, sal_Int32 /*x*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setInt", *this ); -} - - -void SAL_CALL OPreparedStatement::setLong( sal_Int32 /*parameterIndex*/, sal_Int64 /*aVal*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setLong", *this ); -} - - -void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - checkAndResizeParameters(parameterIndex); - - (*m_aParameterRow)[parameterIndex].setNull(); -} - - -void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setClob", *this ); -} - - -void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setBlob", *this ); -} - - -void SAL_CALL OPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setArray", *this ); -} - - -void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setRef", *this ); -} - - -void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 /*parameterIndex*/, const Any& /*x*/, sal_Int32 /*sqlType*/, sal_Int32 /*scale*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setObjectWithInfo", *this ); -} - - -void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& /*typeName*/ ) -{ - setNull(parameterIndex,sqlType); -} - - -void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) -{ - ::dbtools::implSetObject(this,parameterIndex,x); -} - - -void SAL_CALL OPreparedStatement::setShort( sal_Int32 /*parameterIndex*/, sal_Int16 /*x*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setShort", *this ); -} - - -void SAL_CALL OPreparedStatement::setBytes( sal_Int32 /*parameterIndex*/, const Sequence< sal_Int8 >& /*x*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setBytes", *this ); -} - - -void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< css::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setCharacterStream", *this ); -} - - -void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 /*parameterIndex*/, const Reference< css::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XParameters::setBinaryStream", *this ); -} - - -void SAL_CALL OPreparedStatement::clearParameters( ) -{ -} - -void OPreparedStatement::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: - 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->push_back(sal_Int32(0)); - } - - if (static_cast<sal_Int32>(m_aParameterRow->size()) <= parameterIndex) - m_aParameterRow->resize(parameterIndex+1); -} - -void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const -ORowSetValue& x) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkAndResizeParameters(parameterIndex); - - SAL_INFO( - "connectivity.mork", - "setParameter(" << parameterIndex << ", '" << x.getString() << "')"); - (*m_aParameterRow)[parameterIndex] = x; -} - - -void OPreparedStatement::AddParameter(OSQLParseNode const * pParameter, const Reference<XPropertySet>& _xCol) -{ - OSL_ENSURE(SQL_ISRULE(pParameter,parameter),"OResultSet::AddParameter: Argument is not a Parameter"); - OSL_ENSURE(pParameter->count() > 0,"OResultSet: error in parse tree"); - - 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 - ,OUString() - ,OUString() - ,OUString() - ,nNullable - ,nPrecision - ,nScale - ,eType - ,false - ,false - ,false - ,m_pSQLIterator->isCaseSensitive() - ,OUString() - ,OUString() - ,OUString()); - m_xParamColumns->push_back(xParaColumn); -} - -void OPreparedStatement::describeColumn(OSQLParseNode const * _pParameter, - OSQLParseNode const * _pNode, - const OSQLTable& _xTable) -{ - Reference<XPropertySet> xProp; - if(SQL_ISRULE(_pNode,column_ref)) - { - 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.get(), aParseNodes); - if(aParseNodes.empty()) - return; - - m_xParamColumns = new OSQLColumns(); - const OSQLTables& rTabs = m_pSQLIterator->getTables(); - if(!rTabs.empty()) - { - OSQLTable xTable = rTabs.begin()->second; - for (auto const& parseNode : aParseNodes) - { - describeColumn(parseNode,parseNode->getParent()->getChild(0),xTable); - } - } -} - - -void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,std::vector< OSQLParseNode*>& _rParaNodes) -{ - OSL_ENSURE(pParseNode != nullptr,"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() == SQLNodeType::Punctuation,"OResultSet: Faulty Parse Tree"); - - _rParaNodes.push_back(pParseNode); - // further search isn't necessary - return; - } - - // Search on in Parse Tree - for (size_t i = 0; i < pParseNode->count(); i++) - scanParameter(pParseNode->getChild(i),_rParaNodes); -} - -css::uno::Reference< css::sdbc::XResultSet > SAL_CALL OPreparedStatement::getResultSet( ) -{ - return nullptr; -} - -sal_Int32 SAL_CALL OPreparedStatement::getUpdateCount( ) -{ - return 0; -} - -sal_Bool SAL_CALL OPreparedStatement::getMoreResults( ) -{ - return false; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MPreparedStatement.hxx b/connectivity/source/drivers/mork/MPreparedStatement.hxx deleted file mode 100644 index d7caad8e76f1..000000000000 --- a/connectivity/source/drivers/mork/MPreparedStatement.hxx +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MORK_MPREPAREDSTATEMENT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MPREPAREDSTATEMENT_HXX - -#include "MResultSet.hxx" -#include <com/sun/star/sdbc/XParameters.hpp> -#include <com/sun/star/sdbc/XMultipleResults.hpp> -#include <cppuhelper/implbase5.hxx> - -namespace connectivity::mork - { - - typedef ::cppu::ImplHelper5< css::sdbc::XPreparedStatement, - css::sdbc::XParameters, - css::sdbc::XResultSetMetaDataSupplier, - css::sdbc::XMultipleResults, - css::lang::XServiceInfo> OPreparedStatement_BASE; - - class OPreparedStatement final : public OCommonStatement, - public OPreparedStatement_BASE - { - // Data attributes - - OUString m_sSqlStatement; - css::uno::Reference< css::sdbc::XResultSetMetaData > m_xMetaData; - ::rtl::Reference< OResultSet > m_pResultSet; - ::rtl::Reference<connectivity::OSQLColumns> m_xParamColumns; // the parameter columns - OValueRow m_aParameterRow; - - virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, - const css::uno::Any& rValue) override; - virtual ~OPreparedStatement() override; - - virtual void SAL_CALL disposing() override; - - // OCommonStatement overridables - virtual StatementType - parseSql( const OUString& sql , bool bAdjusted = false) override; - virtual void initializeResultSet( OResultSet* _pResult ) override; - virtual void clearCachedResultSet() override; - virtual void cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult ) override; - - - void checkAndResizeParameters(sal_Int32 parameterIndex); - void setParameter(sal_Int32 parameterIndex, const ORowSetValue& x); - - void AddParameter(connectivity::OSQLParseNode const * pParameter, - const css::uno::Reference< css::beans::XPropertySet>& _xCol); - void scanParameter(OSQLParseNode* pParseNode,std::vector< OSQLParseNode*>& _rParaNodes); - void describeColumn(OSQLParseNode const * _pParameter, OSQLParseNode const * _pNode, const OSQLTable& _xTable); - void describeParameter(); - - public: - DECLARE_SERVICE_INFO(); - // A ctor need for returning the object - OPreparedStatement( OConnection* _pConnection,const OUString& sql); - void lateInit(); - - //XInterface - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - virtual void SAL_CALL acquire() throw() override; - virtual void SAL_CALL release() throw() override; - //XTypeProvider - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; - - // 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; - // 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; - // XResultSetMetaDataSupplier - virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override; - // XMultipleResults - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet( ) override; - virtual sal_Int32 SAL_CALL getUpdateCount( ) override; - virtual sal_Bool SAL_CALL getMoreResults( ) override; - - public: - using OCommonStatement::executeQuery; - using OCommonStatement::executeUpdate; - using OCommonStatement::execute; - private: - using OPropertySetHelper::getFastPropertyValue; - }; - -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MPREPAREDSTATEMENT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MQueryHelper.cxx b/connectivity/source/drivers/mork/MQueryHelper.cxx deleted file mode 100644 index 6c63e2889ec8..000000000000 --- a/connectivity/source/drivers/mork/MQueryHelper.cxx +++ /dev/null @@ -1,321 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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 <string> -#include <vector> -#include <algorithm> - -#include <strings.hrc> - -#include <unotools/textsearch.hxx> -#include <sal/log.hxx> - -using namespace connectivity::mork; -using namespace connectivity; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; - - -static -std::vector<bool> entryMatchedByExpression(MQueryHelper* _aQuery, MQueryExpression const * _aExpr, MQueryHelperResultEntry* entry); - -MQueryHelperResultEntry::MQueryHelperResultEntry() -{ -} - -MQueryHelperResultEntry::~MQueryHelperResultEntry() -{ -} - -OUString MQueryHelperResultEntry::getValue( const OString &key ) const -{ - FieldMap::const_iterator iter = m_Fields.find( key ); - if ( iter == m_Fields.end() ) - { - return OUString(); - } - else - { - return iter->second; - } -} - -void MQueryHelperResultEntry::setValue( const OString &key, const OUString & rValue) -{ - m_Fields[ key ] = rValue; -} - -MQueryHelper::MQueryHelper(const OColumnAlias& _ca) - :m_rColumnAlias( _ca ) - ,m_aError() -{ - m_aResults.clear(); -} - -MQueryHelper::~MQueryHelper() -{ - clear_results(); -} - - -void MQueryHelper::setAddressbook(OUString const &ab) -{ - ::osl::MutexGuard aGuard(m_aMutex); - m_aAddressbook = ab; -} - -void MQueryHelper::append(std::unique_ptr<MQueryHelperResultEntry> resEnt) -{ - assert(resEnt); - m_aResults.push_back( std::move(resEnt) ); -} - -void MQueryHelper::clear_results() -{ - m_aResults.clear(); -} - -void MQueryHelper::reset() -{ - clear_results(); - m_aError.reset(); -} - -MQueryHelperResultEntry* -MQueryHelper::getByIndex(sal_uInt32 nRow) -{ - // Row numbers are from 1 to N, need to ensure this, and then - // subtract 1 - if ( nRow < 1 ) { - return nullptr; - } - return m_aResults[nRow -1].get(); -} - -sal_Int32 MQueryHelper::getResultCount() const -{ - sal_Int32 result = static_cast<sal_Int32>(m_aResults.size()); - - return result; -} - -bool MQueryHelper::getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const OUString& aDBColumnName, sal_Int32 nType ) -{ - MQueryHelperResultEntry* pResEntry = getByIndex( nDBRow ); - - OSL_ENSURE( pResEntry != nullptr, "xResEntry == NULL"); - if (pResEntry == nullptr ) - { - rValue.setNull(); - return false; - } - switch ( nType ) - { - case DataType::VARCHAR: - rValue = pResEntry->getValue( m_rColumnAlias.getProgrammaticNameOrFallbackToUTF8Alias( aDBColumnName ) ); - break; - - default: - rValue.setNull(); - break; - } - - return true; -} - -sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection, MQueryExpression & expr) -{ - reset(); - - OString oStringTable = OUStringToOString( m_aAddressbook, RTL_TEXTENCODING_UTF8 ); - std::set<int> listRecords; - bool handleListTable = false; - MorkParser* pMork; - - // check if we are retrieving the default table - if (oStringTable == "AddressBook" || oStringTable == "CollectedAddressBook") - { - pMork = xConnection->getMorkParser(oStringTable); - } - else - { - // Let's try to retrieve the list in Collected Addresses book - pMork = xConnection->getMorkParser("CollectedAddressBook"); - if (std::find(pMork->lists_.begin(), pMork->lists_.end(), m_aAddressbook) == pMork->lists_.end()) - { - // so the list is in Address book - // TODO : manage case where an address book has been created - pMork = xConnection->getMorkParser("AddressBook"); - } - handleListTable = true; - // retrieve row ids for that list table - std::string listTable = oStringTable.getStr(); - pMork->getRecordKeysForListTable(listTable, listRecords); - } - - MorkTableMap *Tables = pMork->getTables( 0x80 ); - if (!Tables) - return -1; - - MorkRowMap *Rows = nullptr; - - // Iterate all tables - for (auto & table : Tables->map) - { - if (table.first != 1) break; - Rows = MorkParser::getRows( 0x80, &table.second ); - if ( Rows ) - { - // Iterate all rows - for (auto const& row : Rows->map) - { - // list specific table - // only retrieve rowIds that belong to that list table. - if (handleListTable) - { - int rowId = row.first; - // belongs this row id to the list table? - if (listRecords.end() == listRecords.find(rowId)) - { - // no, skip it - continue; - } - } - - std::unique_ptr<MQueryHelperResultEntry> entry(new MQueryHelperResultEntry()); - for (auto const& cell : row.second) - { - std::string column = pMork->getColumn(cell.first); - std::string value = pMork->getValue(cell.second); - OString key(column.c_str(), static_cast<sal_Int32>(column.size())); - OString valueOString(value.c_str(), static_cast<sal_Int32>(value.size())); - OUString valueOUString = OStringToOUString( valueOString, RTL_TEXTENCODING_UTF8 ); - entry->setValue(key, valueOUString); - } - bool result = true; - for (bool elem : entryMatchedByExpression(this, &expr, entry.get())) - { - result = result && elem; - } - if (result) - { - append(std::move(entry)); - } - } - } - } - return 0; -} - -std::vector<bool> entryMatchedByExpression(MQueryHelper* _aQuery, MQueryExpression const * _aExpr, MQueryHelperResultEntry* entry) -{ - std::vector<bool> resultVector; - for (auto const& expr : _aExpr->getExpressions()) - { - if ( expr->isStringExpr() ) { - MQueryExpressionString* evStr = static_cast<MQueryExpressionString*> (expr.get()); - // Set the 'name' property of the boolString. - OString attrName = _aQuery->getColumnAlias().getProgrammaticNameOrFallbackToUTF8Alias( evStr->getName() ); - SAL_INFO("connectivity.mork", "Name = " << attrName); - bool bRequiresValue = true; - OUString currentValue = entry->getValue(attrName); - if (evStr->getCond() == MQueryOp::Exists || evStr->getCond() == MQueryOp::DoesNotExist) - { - bRequiresValue = false; - } - if (bRequiresValue) - { - SAL_INFO("connectivity.mork", "Value = " << evStr->getValue() ); - const OUString& searchedValue = evStr->getValue(); - if (evStr->getCond() == MQueryOp::Is) { - SAL_INFO("connectivity.mork", "MQueryOp::Is; done"); - resultVector.push_back(currentValue == searchedValue); - } else if (evStr->getCond() == MQueryOp::IsNot) { - SAL_INFO("connectivity.mork", "MQueryOp::IsNot; done"); - resultVector.push_back(currentValue != searchedValue); - } else if (evStr->getCond() == MQueryOp::EndsWith) { - SAL_INFO("connectivity.mork", "MQueryOp::EndsWith; done"); - resultVector.push_back(currentValue.endsWith(searchedValue)); - } else if (evStr->getCond() == MQueryOp::BeginsWith) { - SAL_INFO("connectivity.mork", "MQueryOp::BeginsWith; done"); - resultVector.push_back(currentValue.startsWith(searchedValue)); - } else if (evStr->getCond() == MQueryOp::Contains) { - SAL_INFO("connectivity.mork", "MQueryOp::Contains; done"); - resultVector.push_back(currentValue.indexOf(searchedValue) != -1); - } else if (evStr->getCond() == MQueryOp::DoesNotContain) { - SAL_INFO("connectivity.mork", "MQueryOp::DoesNotContain; done"); - resultVector.push_back(currentValue.indexOf(searchedValue) == -1); - } else if (evStr->getCond() == MQueryOp::RegExp) { - SAL_INFO("connectivity.mork", "MQueryOp::RegExp; done"); - utl::SearchParam param( - searchedValue, utl::SearchParam::SearchType::Regexp); - utl::TextSearch ts(param, LANGUAGE_DONTKNOW); - sal_Int32 start = 0; - sal_Int32 end = currentValue.getLength(); - resultVector.push_back( - ts.SearchForward(currentValue, &start, &end)); - } - } else if (evStr->getCond() == MQueryOp::Exists) { - SAL_INFO("connectivity.mork", "MQueryOp::Exists; done"); - resultVector.push_back(!currentValue.isEmpty()); - } else if (evStr->getCond() == MQueryOp::DoesNotExist) { - SAL_INFO("connectivity.mork", "MQueryOp::DoesNotExist; done"); - resultVector.push_back(currentValue.isEmpty()); - } - } - else if ( expr->isExpr() ) { - SAL_INFO("connectivity.mork", "Appending Subquery Expression"); - MQueryExpression* queryExpression = static_cast<MQueryExpression*> (expr.get()); - // recursive call - std::vector<bool> subquery_result = entryMatchedByExpression(_aQuery, queryExpression, entry); - MQueryExpression::bool_cond condition = queryExpression->getExpressionCondition(); - if (condition == MQueryExpression::OR) { - bool result = false; - for (bool elem : subquery_result) - { - result = result || elem; - } - resultVector.push_back(result); - } else { - assert(condition == MQueryExpression::AND && "only OR or AND should exist"); - bool result = true; - for (bool elem : subquery_result) - { - result = result && elem; - } - resultVector.push_back(result); - } - } - else { - // Should never see this... - SAL_WARN("connectivity.mork", "Unknown Expression Type!"); - _aQuery->getError().setResId(STR_ERROR_GET_ROW); - 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 deleted file mode 100644 index dc9bde32f615..000000000000 --- a/connectivity/source/drivers/mork/MQueryHelper.hxx +++ /dev/null @@ -1,182 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MORK_MQUERYHELPER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MQUERYHELPER_HXX - -#include <connectivity/FValue.hxx> -#include "MErrorResource.hxx" -#include "MColumnAlias.hxx" - -namespace connectivity::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, - RegExp = 8 - } cond_type; - } - - class MQueryExpressionBase { - public: - enum class node_type { - StringExpr, - Expr - }; - - protected: - node_type m_eNodeType; - - explicit MQueryExpressionBase( node_type _eNodeType ) : m_eNodeType( _eNodeType ) {} - - public: - virtual ~MQueryExpressionBase() {} - - bool isStringExpr( ) const { return m_eNodeType == node_type::StringExpr; } - bool isExpr( ) const { return m_eNodeType == node_type::Expr; } - }; - - class MQueryExpressionString final : public MQueryExpressionBase { - OUString m_aName; // LHS - MQueryOp::cond_type m_aBooleanCondition; - OUString m_aValue; // RHS - - public: - - MQueryExpressionString( const OUString& lhs, - MQueryOp::cond_type cond, - const OUString& rhs ) - : MQueryExpressionBase( MQueryExpressionBase::node_type::StringExpr ) - , m_aName( lhs ) - , m_aBooleanCondition( cond ) - , m_aValue( rhs ) - { - } - - MQueryExpressionString( const OUString& lhs, - MQueryOp::cond_type cond ) - : MQueryExpressionBase( MQueryExpressionBase::node_type::StringExpr ) - , m_aName( lhs ) - , m_aBooleanCondition( cond ) - , m_aValue( OUString() ) - { - } - - const OUString& getName() const { return m_aName; } - MQueryOp::cond_type getCond() const { return m_aBooleanCondition; } - const OUString& getValue() const { return m_aValue; } - }; - - class MQueryExpression final : public MQueryExpressionBase - { - friend class MQueryHelper; - - public: - typedef std::vector< std::unique_ptr<MQueryExpressionBase> > ExprVector; - - typedef enum { - AND, - OR - } bool_cond; - - // All expressions on a peer level use same condition operator - void setExpressionCondition( bool_cond _cond ) - { m_aExprCondType = _cond; } - - void addExpression(std::unique_ptr<MQueryExpressionBase> expr) - { m_aExprVector.push_back(std::move(expr)); } - - ExprVector const & getExpressions( ) const - { return m_aExprVector; } - - // All expressions on a peer level use same condition operator - bool_cond getExpressionCondition( ) const - { return m_aExprCondType; } - - MQueryExpression() : MQueryExpressionBase( MQueryExpressionBase::node_type::Expr ), - m_aExprCondType( OR ) - {} - - private: - ExprVector m_aExprVector; - bool_cond m_aExprCondType; - - MQueryExpression(const MQueryExpression&) = delete; - MQueryExpression& operator=(const MQueryExpression&) = delete; - }; - - class MQueryHelperResultEntry - { - private: - typedef std::unordered_map< OString, OUString > FieldMap; - - FieldMap m_Fields; - - public: - MQueryHelperResultEntry(); - ~MQueryHelperResultEntry(); - - OUString getValue( const OString &key ) const; - void setValue( const OString &key, const OUString & rValue); - }; - - class MQueryHelper final - { - private: - - mutable ::osl::Mutex m_aMutex; - std::vector< std::unique_ptr<MQueryHelperResultEntry> > m_aResults; - void append(std::unique_ptr<MQueryHelperResultEntry> resEnt ); - void clear_results(); - OColumnAlias m_rColumnAlias; - ErrorDescriptor m_aError; - OUString m_aAddressbook; - - public: - explicit MQueryHelper(const OColumnAlias& _ca); - ~MQueryHelper(); - - void reset(); - MQueryHelperResultEntry* getByIndex( sal_uInt32 nRow ); - sal_Int32 getResultCount() const; - bool getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const OUString& aDBColumnName, sal_Int32 nType ); - sal_Int32 executeQuery(OConnection* xConnection, MQueryExpression & expr); - const OColumnAlias& getColumnAlias() const { return m_rColumnAlias; } - bool hadError() const { return m_aError.is(); } - ErrorDescriptor& getError() { return m_aError; } - - void setAddressbook( OUString const &); - }; - -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MQUERYHELPER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MResultSet.cxx b/connectivity/source/drivers/mork/MResultSet.cxx deleted file mode 100644 index 6a6d14f63fb7..000000000000 --- a/connectivity/source/drivers/mork/MResultSet.cxx +++ /dev/null @@ -1,1711 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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/ResultSetType.hpp> -#include <com/sun/star/sdbc/FetchDirection.hpp> -#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> -#include <com/sun/star/sdbcx/CompareBookmark.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <connectivity/dbtools.hxx> -#include <comphelper/types.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <o3tl/safeint.hxx> -#include <sal/log.hxx> -#include <tools/diagnose_ex.h> - -#include <vector> -#include <algorithm> -#include "MResultSet.hxx" -#include <sqlbison.hxx> -#include "MResultSetMetaData.hxx" -#include <FDatabaseMetaDataResultSet.hxx> - -#include <strings.hrc> - -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::sdbcx; -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"); -OUString SAL_CALL OResultSet::getImplementationName( ) -{ - return "com.sun.star.sdbcx.mork.ResultSet"; -} - - Sequence< OUString > SAL_CALL OResultSet::getSupportedServiceNames( ) -{ - return {"com.sun.star.sdbc.ResultSet","com.sun.star.sdbcx.ResultSet"}; -} - -sal_Bool SAL_CALL OResultSet::supportsService( const OUString& _rServiceName ) -{ - return cppu::supportsService(this, _rServiceName); -} - - -OResultSet::OResultSet(OCommonStatement* pStmt, const std::shared_ptr< connectivity::OSQLParseTreeIterator >& _pSQLIterator ) - : OResultSet_BASE(m_aMutex) - ,OPropertySetHelper(OResultSet_BASE::rBHelper) - ,m_pStatement(pStmt) - ,m_xStatement(*pStmt) - ,m_nRowPos(0) - ,m_bWasNull(false) - ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE) - ,m_nFetchDirection(FetchDirection::FORWARD) - ,m_pSQLIterator( _pSQLIterator ) - ,m_pParseTree( _pSQLIterator->getParseTree() ) - ,m_aQueryHelper(pStmt->getOwnConnection()->getColumnAlias()) - ,m_CurrentRowCount(0) - ,m_nParamIndex(0) - ,m_bIsAlwaysFalseQuery(false) - ,m_bIsReadOnly(TRISTATE_INDET) -{ - //m_aQuery.setMaxNrOfReturns(pStmt->getOwnConnection()->getMaxResultRecords()); -} - -OResultSet::~OResultSet() -{ -} - - -void OResultSet::disposing() -{ - OPropertySetHelper::disposing(); - - ::osl::MutexGuard aGuard(m_aMutex); - - m_xStatement.clear(); - m_xMetaData.clear(); - m_pParseTree = nullptr; - m_xColumns = nullptr; - m_pKeySet = nullptr; - m_xTable.clear(); -} - -Any SAL_CALL OResultSet::queryInterface( const Type & rType ) -{ - Any aRet = OPropertySetHelper::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OResultSet_BASE::queryInterface(rType); - return aRet; -} - - Sequence< Type > SAL_CALL OResultSet::getTypes( ) -{ - OTypeCollection aTypes( cppu::UnoType<css::beans::XMultiPropertySet>::get(), - cppu::UnoType<css::beans::XFastPropertySet>::get(), - cppu::UnoType<css::beans::XPropertySet>::get()); - - return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes()); -} - -void OResultSet::methodEntry() -{ - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if ( !m_xTable.is() ) - { - OSL_FAIL( "OResultSet::methodEntry: looks like we're disposed, but how is this possible?" ); - throw DisposedException( OUString(), *this ); - } -} - - -sal_Int32 SAL_CALL OResultSet::findColumn( const OUString& columnName ) -{ - 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))) - return i; - } - - ::dbtools::throwInvalidColumnException( columnName, *this ); - assert(false); - return 0; // Never reached -} - -Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) -{ - return nullptr; -} - -Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) -{ - return nullptr; -} - - -sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 /*columnIndex*/ ) -{ - ResultSetEntryGuard aGuard( *this ); - m_bWasNull = true; - return false; -} - - -sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 /*columnIndex*/ ) -{ - return 0; -} - - -Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 /*columnIndex*/ ) -{ - return Sequence< sal_Int8 >(); -} - - -Date SAL_CALL OResultSet::getDate( sal_Int32 /*columnIndex*/ ) -{ - return Date(); -} - - -double SAL_CALL OResultSet::getDouble( sal_Int32 /*columnIndex*/ ) -{ - return 0.0; -} - - -float SAL_CALL OResultSet::getFloat( sal_Int32 /*columnIndex*/ ) -{ - return 0; -} - - -sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 /*columnIndex*/ ) -{ - return 0; -} - - -sal_Int32 SAL_CALL OResultSet::getRow( ) -{ - ResultSetEntryGuard aGuard( *this ); - - SAL_INFO("connectivity.mork", "return = " << m_nRowPos); - return m_nRowPos; -} - - -sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 /*columnIndex*/ ) -{ - return sal_Int64(); -} - - -Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) -{ - ResultSetEntryGuard aGuard( *this ); - - if(!m_xMetaData.is()) - m_xMetaData = new OResultSetMetaData( - m_pSQLIterator->getSelectColumns(), m_pSQLIterator->getTables().begin()->first, m_xTable.get(), determineReadOnly()); - return m_xMetaData; -} - -Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) -{ - return nullptr; -} - - -Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) -{ - return nullptr; -} - -Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) -{ - return nullptr; -} - - -Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) -{ - return nullptr; -} - - -Any SAL_CALL OResultSet::getObject( sal_Int32 /*columnIndex*/, const Reference< css::container::XNameAccess >& /*typeMap*/ ) -{ - return Any(); -} - - -sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 /*columnIndex*/ ) -{ - return 0; -} - - -void OResultSet::checkIndex(sal_Int32 columnIndex ) -{ - if(columnIndex <= 0 || columnIndex > static_cast<sal_Int32>(m_xColumns->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(); -} - - -bool OResultSet::fetchCurrentRow( ) -{ - SAL_INFO("connectivity.mork", "m_nRowPos = " << m_nRowPos); - return fetchRow(getCurrentCardNumber()); -} - - -bool OResultSet::fetchRow(sal_Int32 cardNumber,bool bForceReload) -{ - SAL_INFO("connectivity.mork", "cardNumber = " << cardNumber); - if (!bForceReload) - { - // Check whether we've already fetched the row... - if ( !(*m_aRow)[0].isNull() && static_cast<sal_Int32>((*m_aRow)[0]) == cardNumber ) - return true; - } -// else -// m_aQuery.resyncRow(cardNumber); - - if ( !validRow( cardNumber ) ) - return false; - - (*m_aRow)[0] = cardNumber; - sal_Int32 nCount = m_aColumnNames.getLength(); - //m_RowStates = m_aQuery.getRowStates(cardNumber); - for( sal_Int32 i = 1; i <= nCount; i++ ) - { - if ( (*m_aRow)[i].isBound() ) - { - - // Everything in the addressbook is a string! - - if ( !m_aQueryHelper.getRowValue( (*m_aRow)[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR )) - { - m_pStatement->getOwnConnection()->throwSQLException( m_aQueryHelper.getError(), *this ); - } - } - } - return true; - -} - - -const ORowSetValue& OResultSet::getValue(sal_Int32 cardNumber, sal_Int32 columnIndex ) -{ - if ( !fetchRow( cardNumber ) ) - { - OSL_FAIL("fetchRow() returned False" ); - m_bWasNull = true; - return *ODatabaseMetaDataResultSet::getEmptyValue(); - } - - m_bWasNull = (*m_aRow)[columnIndex].isNull(); - return (*m_aRow)[columnIndex]; - -} - - -OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) -{ - ResultSetEntryGuard aGuard( *this ); - - OSL_ENSURE(m_xColumns.is(), "Need the Columns!!"); - OSL_ENSURE(columnIndex <= static_cast<sal_Int32>(m_xColumns->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*/ ) -{ - ResultSetEntryGuard aGuard( *this ); - return Time(); -} - - -DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 /*columnIndex*/ ) -{ - ResultSetEntryGuard aGuard( *this ); - return DateTime(); -} - - -sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) -{ - ResultSetEntryGuard aGuard( *this ); - - // here you have to implement your movements - // return true means there is no data - return( m_nRowPos < 1 ); -} - -sal_Bool SAL_CALL OResultSet::isAfterLast( ) -{ - SAL_WARN("connectivity.mork", "OResultSet::isAfterLast() NOT IMPLEMENTED!"); - ResultSetEntryGuard aGuard( *this ); - - return m_nRowPos > currentRowCount(); -} - -sal_Bool SAL_CALL OResultSet::isFirst( ) -{ - ResultSetEntryGuard aGuard( *this ); - - return m_nRowPos == 1; -} - -sal_Bool SAL_CALL OResultSet::isLast( ) -{ - SAL_WARN("connectivity.mork", "OResultSet::isLast() NOT IMPLEMENTED!"); - ResultSetEntryGuard aGuard( *this ); - -// return sal_True; - return m_nRowPos == currentRowCount(); -} - -void SAL_CALL OResultSet::beforeFirst( ) -{ - ResultSetEntryGuard aGuard( *this ); - - // move before the first row so that isBeforeFirst returns false - if ( first() ) - previous(); -} - -void SAL_CALL OResultSet::afterLast( ) -{ - ResultSetEntryGuard aGuard( *this ); - - if(last()) - next(); -} - - -void SAL_CALL OResultSet::close() -{ - dispose(); -} - - -sal_Bool SAL_CALL OResultSet::first( ) -{ - return seekRow( FIRST_POS ); -} - - -sal_Bool SAL_CALL OResultSet::last( ) -{ - return seekRow( LAST_POS ); -} - -sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) -{ - return seekRow( ABSOLUTE_POS, row ); -} - -sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) -{ - return seekRow( RELATIVE_POS, row ); -} - -sal_Bool SAL_CALL OResultSet::previous( ) -{ - ResultSetEntryGuard aGuard( *this ); - return seekRow( PRIOR_POS ); -} - -Reference< XInterface > SAL_CALL OResultSet::getStatement( ) -{ - ResultSetEntryGuard aGuard( *this ); - return m_xStatement; -} - - -sal_Bool SAL_CALL OResultSet::rowDeleted( ) -{ - SAL_WARN("connectivity.mork", "OResultSet::rowDeleted() NOT IMPLEMENTED!"); - ResultSetEntryGuard aGuard( *this ); - return true;//return ((m_RowStates & RowStates_Deleted) == RowStates_Deleted) ; -} - -sal_Bool SAL_CALL OResultSet::rowInserted( ) -{ - SAL_WARN("connectivity.mork", "OResultSet::rowInserted() NOT IMPLEMENTED!"); - ResultSetEntryGuard aGuard( *this ); - return true;//return ((m_RowStates & RowStates_Inserted) == RowStates_Inserted); -} - -sal_Bool SAL_CALL OResultSet::rowUpdated( ) -{ - SAL_WARN("connectivity.mork", "OResultSet::rowUpdated() NOT IMPLEMENTED!"); - ResultSetEntryGuard aGuard( *this ); - return true;// return ((m_RowStates & RowStates_Updated) == RowStates_Updated) ; -} - - -sal_Bool SAL_CALL OResultSet::next( ) -{ - return seekRow( NEXT_POS ); -} - - -sal_Bool SAL_CALL OResultSet::wasNull( ) -{ - ResultSetEntryGuard aGuard( *this ); - - return m_bWasNull; -} - - -void SAL_CALL OResultSet::cancel( ) -{ -} - -void SAL_CALL OResultSet::clearWarnings( ) -{ -} - -Any SAL_CALL OResultSet::getWarnings( ) -{ - return Any(); -} - -void SAL_CALL OResultSet::refreshRow( ) -{ - if (fetchRow(getCurrentCardNumber(),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; - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), - PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0); - - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), - PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0); - - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), - PROPERTY_ID_ISBOOKMARKABLE, cppu::UnoType<bool>::get(), PropertyAttribute::READONLY); - - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), - PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY); - - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), - PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY); - - return new OPropertyArrayHelper(aProps); -} - -IPropertyArrayHelper & OResultSet::getInfoHelper() -{ - return *getArrayHelper(); -} - -sal_Bool OResultSet::convertFastPropertyValue( - Any & /*rConvertedValue*/, - Any & /*rOldValue*/, - sal_Int32 nHandle, - const Any& /*rValue*/ ) -{ - OSL_FAIL( "OResultSet::convertFastPropertyValue: not implemented!" ); - switch(nHandle) - { - case PROPERTY_ID_ISBOOKMARKABLE: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - throw css::lang::IllegalArgumentException(); - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - default: - ; - } - return false; -} - -void OResultSet::setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const Any& /*rValue*/ - ) -{ - OSL_FAIL( "OResultSet::setFastPropertyValue_NoBroadcast: not implemented!" ); - switch(nHandle) - { - case PROPERTY_ID_ISBOOKMARKABLE: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - throw Exception("cannot set prop " + OUString::number(nHandle), nullptr); - 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(ResultSetConcurrency::UPDATABLE); - break; - case PROPERTY_ID_RESULTSETTYPE: - rValue <<= m_nResultSetType; - break; - case PROPERTY_ID_FETCHDIRECTION: - rValue <<= m_nFetchDirection; - break; - case PROPERTY_ID_FETCHSIZE: - rValue <<= sal_Int32(0); - break; - case PROPERTY_ID_ISBOOKMARKABLE: - const_cast< OResultSet* >( this )->determineReadOnly(); - rValue <<= (m_bIsReadOnly == TRISTATE_FALSE); - break; - } -} - -void SAL_CALL OResultSet::acquire() throw() -{ - OResultSet_BASE::acquire(); -} - -void SAL_CALL OResultSet::release() throw() -{ - OResultSet_BASE::release(); -} - -css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( ) -{ - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); -} - - -void OResultSet::parseParameter( const OSQLParseNode* pNode, OUString& rMatchString ) -{ - OSL_ENSURE(pNode->count() > 0,"Error parsing parameter in Parse Tree"); - OSQLParseNode *pMark = pNode->getChild(0); - - // Initialize to empty string - rMatchString.clear(); - - OUString aParameterName; - if (SQL_ISPUNCTUATION(pMark,"?")) { - aParameterName = "?"; - } - else if (SQL_ISPUNCTUATION(pMark,":")) { - aParameterName = pNode->getChild(1)->getTokenValue(); - } - // XXX - Now we know name, what's value???? - m_nParamIndex ++; - SAL_INFO( - "connectivity.mork", - "Parameter name [" << m_nParamIndex << "]: " << aParameterName); - - if ( m_aParameterRow.is() ) { - OSL_ENSURE( m_nParamIndex < static_cast<sal_Int32>(m_aParameterRow->size()) + 1, "More parameters than values found" ); - rMatchString = (*m_aParameterRow)[static_cast<sal_uInt16>(m_nParamIndex)]; - SAL_INFO("connectivity.mork", "Prop Value: " << rMatchString); - } - else { - SAL_INFO("connectivity.mork", "Prop Value: Invalid ParameterRow!"); - } -} - -#define WILDCARD "%" -#define ALT_WILDCARD "*" -const sal_Unicode MATCHCHAR = '_'; - -void OResultSet::analyseWhereClause( const OSQLParseNode* parseTree, - MQueryExpression &queryExpression) -{ - OUString columnName; - MQueryOp::cond_type op( MQueryOp::Is ); - OUString matchString; - - if ( parseTree == nullptr ) - return; - - if ( m_pSQLIterator->getParseTree() != nullptr ) { - ::rtl::Reference<OSQLColumns> xColumns = m_pSQLIterator->getParameters(); - if(xColumns.is()) - { - OUString aColName, aParameterValue; - sal_Int32 i = 1; - for (auto const& column : *xColumns) - { - column->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName; - SAL_INFO("connectivity.mork", "Prop Column Name: " << aColName); - if ( m_aParameterRow.is() ) { - aParameterValue = (*m_aParameterRow)[static_cast<sal_uInt16>(i)]; - SAL_INFO("connectivity.mork", "Prop Value: " << aParameterValue); - } - else { - SAL_INFO("connectivity.mork", "Prop Value: Invalid ParameterRow!"); - } - i++; - } - } - - } - - if ( SQL_ISRULE(parseTree,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),")")) - { - auto subExpression = std::make_unique<MQueryExpression>(); - analyseWhereClause( parseTree->getChild( 1 ), *subExpression ); - queryExpression.addExpression( std::move(subExpression) ); - } - else if ((SQL_ISRULE(parseTree,search_condition) || SQL_ISRULE(parseTree,boolean_term)) - && parseTree->count() == 3) // Handle AND/OR - { - // 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() == SQLNodeType::String || - parseTree->getChild(2)->getNodeType() == SQLNodeType::IntNum || - parseTree->getChild(2)->getNodeType() == SQLNodeType::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() == SQLNodeType::Equal) - op = MQueryOp::Is; - else if (pPrec->getNodeType() == SQLNodeType::NotEqual) - op = MQueryOp::IsNot; - - 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 == "0" && op == MQueryOp::Is && matchString == "1" ) { - m_bIsAlwaysFalseQuery = true; - } - queryExpression.addExpression( std::make_unique<MQueryExpressionString>( columnName, op, matchString )); - } - else if (SQL_ISRULE(parseTree,like_predicate)) - { - OSL_ENSURE(parseTree->count() == 2, "Error parsing LIKE predicate"); - - 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() == SQLNodeType::String || - pAtom->getNodeType() == SQLNodeType::Name || - SQL_ISRULE(pAtom,parameter) || - ( pAtom->getChild(0) && pAtom->getChild(0)->getNodeType() == SQLNodeType::Name ) || - ( pAtom->getChild(0) && pAtom->getChild(0)->getNodeType() == SQLNodeType::String ) - ) ) - { - m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_STRING, *this ); - } - - OUString sTableRange; - if(SQL_ISRULE(pColumn,column_ref)) - m_pSQLIterator->getColumnRange(pColumn,columnName,sTableRange); - - SAL_INFO("connectivity.mork", "ColumnName = " << 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.replaceAll( ALT_WILDCARD, WILDCARD ); - } - else - { - matchString = pAtom->getTokenValue(); - } - - // Determine where '%' character is... - - if ( matchString == WILDCARD ) - { - // String containing only a '%' and nothing else - op = MQueryOp::Exists; - // Will be ignored for Exists case, but clear anyway. - matchString.clear(); - } - 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.startsWith( WILDCARD ) - && matchString.endsWith( WILDCARD ) - && 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, OUString() ); - matchString = matchString.replaceAt( matchString.getLength() -1 , 1, 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.startsWith( WILDCARD ) ) - { - op = MQueryOp::EndsWith; - matchString = matchString.replaceAt( 0, 1, OUString()); - } - else if ( matchString.indexOf ( WILDCARD ) == matchString.getLength() -1 ) - { - op = MQueryOp::BeginsWith; - matchString = matchString.replaceAt( matchString.getLength() -1 , 1, OUString() ); - } - else - { - sal_Int32 pos = matchString.indexOf ( WILDCARD ); - matchString = matchString.replaceAt( pos, 1, ".*" ); - op = MQueryOp::RegExp; - } - - } - else - { - // Most Complex, need to use a RE - sal_Int32 pos; - while ( (pos = matchString.indexOf ( WILDCARD )) != -1 ) - { - matchString = matchString.replaceAt( pos, 1, ".*" ); - } - - while ( (pos = matchString.indexOf( MATCHCHAR )) != -1 ) - { - matchString = matchString.replaceAt( pos, 1, "." ); - } - - op = MQueryOp::RegExp; - } - } - - queryExpression.addExpression( std::make_unique<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; - } - - OUString sTableRange; - m_pSQLIterator->getColumnRange(parseTree->getChild(0),columnName,sTableRange); - - queryExpression.addExpression( std::make_unique<MQueryExpressionString>( columnName, op )); - } - else - { - SAL_WARN("connectivity.mork", "Unexpected statement!!!" ); - m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); - } -} - -void OResultSet::fillRowData() -{ - OSL_ENSURE( m_pStatement, "Require a statement" ); - - MQueryExpression queryExpression; - - OConnection* pConnection = static_cast<OConnection*>(m_pStatement->getConnection().get()); - m_xColumns = m_pSQLIterator->getSelectColumns(); - - OSL_ENSURE(m_xColumns.is(), "Need the Columns!!"); - - const OUString sPropertyName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME); - OUString sName; - sal_Int32 i = 1; - for (const auto& rxColumn : *m_xColumns) - { - rxColumn->getPropertyValue(sPropertyName) >>= sName; - SAL_INFO( - "connectivity.mork", "Query Columns : (" << i << ") " << sName); - i++; - } - - // Generate Match Conditions for Query - const OSQLParseNode* pParseTree = m_pSQLIterator->getWhereTree(); - - m_bIsAlwaysFalseQuery = false; - if ( pParseTree != nullptr ) - { - // Extract required info - - analyseWhereClause( pParseTree, queryExpression ); - } - // If the query is a 0=1 then set Row count to 0 and return - if ( m_bIsAlwaysFalseQuery ) - { - m_bIsReadOnly = TRISTATE_TRUE; - return; - } - - OUString aStr( m_xTable->getName() ); - m_aQueryHelper.setAddressbook( aStr ); - - sal_Int32 rv = m_aQueryHelper.executeQuery(pConnection, queryExpression); - if ( rv == -1 ) { - m_pStatement->getOwnConnection()->throwSQLException( STR_ERR_EXECUTING_QUERY, *this ); - } - - if (m_aQueryHelper.hadError()) - { - m_pStatement->getOwnConnection()->throwSQLException( m_aQueryHelper.getError(), *this ); - } - - //determine whether the address book is readonly - determineReadOnly(); - - SAL_INFO("connectivity.mork", "executeQuery returned " << rv); -} - - -static bool matchRow( OValueRow const & row1, OValueRow const & row2 ) -{ - // the first column is the bookmark column - return std::equal(std::next(row1->begin()), row1->end(), std::next(row2->begin()), - [](const ORowSetValue& a, const ORowSetValue& b) { return !a.isBound() || a == b; }); -} - -sal_Int32 OResultSet::getRowForCardNumber(sal_Int32 nCardNum) -{ - SAL_INFO("connectivity.mork", "nCardNum = " << nCardNum); - - if ( m_pKeySet.is() ) - { - sal_Int32 nPos; - for(nPos=0;nPos < static_cast<sal_Int32>(m_pKeySet->size());nPos++) - { - if (nCardNum == (*m_pKeySet)[nPos]) - { - SAL_INFO("connectivity.mork", "return = " << nPos+1); - return nPos+1; - } - } - } - - m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK, *this ); - - return 0; -} - -void OResultSet::executeQuery() -{ - ResultSetEntryGuard aGuard( *this ); - - OSL_ENSURE( m_xTable.is(), "Need a Table object"); - if(!m_xTable.is()) - { - const OSQLTables& rTabs = m_pSQLIterator->getTables(); - if (rTabs.empty() || !rTabs.begin()->second.is()) - m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); - - m_xTable = static_cast< OTable* > (rTabs.begin()->second.get()); - } - - m_nRowPos = 0; - - fillRowData(); - - OSL_ENSURE(m_xColumns.is(), "Need the Columns!!"); - - switch( m_pSQLIterator->getStatementType() ) - { - case OSQLStatementType::Select: - { - if(m_bIsAlwaysFalseQuery) { - break; - } - else if(isCount()) - { - m_pStatement->getOwnConnection()->throwSQLException( STR_NO_COUNT_SUPPORT, *this ); - } - else - { - bool bDistinct = 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(TAscendingOrder::DESC); - } - bDistinct = true; - } - - OSortIndex::TKeyTypeVector eKeyType(m_aOrderbyColumnNumber.size()); - std::vector<sal_Int16>::size_type index = 0; - for (const auto& rColIndex : m_aOrderbyColumnNumber) - { - OSL_ENSURE(static_cast<sal_Int32>(m_aRow->size()) > rColIndex,"Invalid Index"); - switch ((m_aRow->begin()+rColIndex)->getTypeKind()) - { - case DataType::CHAR: - case DataType::VARCHAR: - eKeyType[index] = OKeyType::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[index] = OKeyType::Double; - break; - - // Other types aren't implemented (so they are always FALSE) - default: - eKeyType[index] = OKeyType::NONE; - OSL_FAIL("MResultSet::executeQuery: Order By Data Type not implemented"); - break; - } - ++index; - } - - 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. - - OSortIndex aSortIndex(eKeyType,m_aOrderbyAscending); - -#if OSL_DEBUG_LEVEL > 0 - for ( std::vector<sal_Int32>::size_type i = 0; i < m_aColMapping.size(); i++ ) - SAL_INFO( - "connectivity.mork", - "Mapped: " << i << " -> " << m_aColMapping[i]); -#endif - for ( sal_Int32 nRow = 1; nRow <= m_aQueryHelper.getResultCount(); nRow++ ) { - - std::unique_ptr<OKeyValue> pKeyValue = OKeyValue::createKeyValue(nRow); - - for (const auto& rColIndex : m_aOrderbyColumnNumber) - { - const ORowSetValue& value = getValue(nRow, rColIndex); - - SAL_INFO( - "connectivity.mork", - "Adding Value: (" << nRow << "," << rColIndex - << ") : " << value.getString()); - - pKeyValue->pushKey(new ORowSetValueDecorator(value)); - } - - aSortIndex.AddKeyValue( std::move(pKeyValue) ); - } - - m_pKeySet = aSortIndex.CreateKeySet(); - m_CurrentRowCount = static_cast<sal_Int32>(m_pKeySet->size()); -#if OSL_DEBUG_LEVEL > 0 - for( OKeySet::size_type i = 0; i < m_pKeySet->size(); i++ ) - SAL_INFO( - "connectivity.mork", - "Sorted: " << i << " -> " << (*m_pKeySet)[i]); -#endif - - 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->size() ); - - for(sal_Int32 & i : *m_pKeySet) - { - fetchRow( i ); // Fills m_aRow - if ( matchRow( m_aRow, aSearchRow ) ) - { - 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->erase(std::remove_if(m_pKeySet->begin(),m_pKeySet->end() - ,[](sal_Int32 n) { return n == 0; }) - ,m_pKeySet->end()); - - } - } - } break; - - case OSQLStatementType::Update: - case OSQLStatementType::Delete: - case OSQLStatementType::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, - bool _bSetColumnMapping, - const Reference<XDatabaseMetaData>& _xMetaData, - std::vector<sal_Int32>& _rColMapping) -{ - ::comphelper::UStringMixEqual aCase(_xMetaData->supportsMixedCaseQuotedIdentifiers()); - - Reference<XPropertySet> xTableColumn; - OUString sTableColumnName, sSelectColumnRealName; - - const OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME); - const OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME); - - std::vector< OUString> aColumnNames; - aColumnNames.reserve(_rxColumns->size()); - OValueVector::iterator aRowIter = _rRow->begin()+1; - for (sal_Int32 i=0; // the first column is the bookmark column - aRowIter != _rRow->end(); - ++i, ++aRowIter - ) - { - try - { - // get the table column and its name - _xNames->getByIndex(i) >>= xTableColumn; - OSL_ENSURE(xTableColumn.is(), "OResultSet::setBoundedColumns: invalid table column!"); - if (xTableColumn.is()) - xTableColumn->getPropertyValue(sName) >>= sTableColumnName; - else - sTableColumnName.clear(); - - // look if we have such a select column - // TODO: would like to have a O(log n) search here ... - sal_Int32 nColumnPos = 0; - for (const auto& rxColumn : *_rxColumns) - { - if ( nColumnPos < static_cast<sal_Int32>(aColumnNames.size()) ) - sSelectColumnRealName = aColumnNames[nColumnPos]; - else - { - if(rxColumn->getPropertySetInfo()->hasPropertyByName(sRealName)) - rxColumn->getPropertyValue(sRealName) >>= sSelectColumnRealName; - else - rxColumn->getPropertyValue(sName) >>= sSelectColumnRealName; - aColumnNames.push_back(sSelectColumnRealName); - } - - if (aCase(sTableColumnName, sSelectColumnRealName)) - { - if(_bSetColumnMapping) - { - sal_Int32 nSelectColumnPos = nColumnPos + 1; - // the getXXX methods are 1-based ... - sal_Int32 nTableColumnPos = i + 1; - // get first table column is the bookmark column - - SAL_INFO( - "connectivity.mork", - "Set Col Mapping: " << nSelectColumnPos << " -> " - << nTableColumnPos); - _rColMapping[nSelectColumnPos] = nTableColumnPos; - } - - aRowIter->setBound(true); - aRowIter->setTypeKind(DataType::VARCHAR); - } - - ++nColumnPos; - } - } - catch (Exception&) - { - TOOLS_WARN_EXCEPTION( "connectivity.hsqldb", "OResultSet::setBoundedColumns"); - } - } -} - - -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 - -bool OResultSet::validRow( sal_uInt32 nRow) -{ - sal_Int32 nNumberOfRecords = m_aQueryHelper.getResultCount(); - - if (( nRow == 0 ) || - ( nRow > o3tl::make_unsigned(nNumberOfRecords)) ){ - SAL_INFO("connectivity.mork", "validRow(" << nRow << "): return False"); - return false; - } - SAL_INFO("connectivity.mork", "validRow(" << nRow << "): return True"); - - return true; -} - -void OResultSet::fillKeySet(sal_Int32 nMaxCardNumber) -{ - impl_ensureKeySet(); - if (m_CurrentRowCount < nMaxCardNumber) - { - sal_Int32 nKeyValue; - if ( static_cast<sal_Int32>(m_pKeySet->capacity()) < nMaxCardNumber ) - m_pKeySet->reserve(nMaxCardNumber + 20 ); - - for (nKeyValue = m_CurrentRowCount+1; nKeyValue <= nMaxCardNumber; nKeyValue ++) - m_pKeySet->push_back( nKeyValue ); - m_CurrentRowCount = nMaxCardNumber; - } -} - -sal_Int32 OResultSet::deletedCount() -{ - impl_ensureKeySet(); - return m_CurrentRowCount - static_cast<sal_Int32>(m_pKeySet->size()); - -} - -bool OResultSet::seekRow( eRowPosition pos, sal_Int32 nOffset ) -{ - ResultSetEntryGuard aGuard( *this ); - if ( !m_pKeySet.is() ) - m_pStatement->getOwnConnection()->throwSQLException( STR_ILLEGAL_MOVEMENT, *this ); - - sal_Int32 nNumberOfRecords = m_aQueryHelper.getResultCount(); - sal_Int32 nRetrievedRows = currentRowCount(); - sal_Int32 nCurPos = m_nRowPos; - - SAL_INFO("connectivity.mork", "nCurPos = " << nCurPos); - switch( pos ) { - case NEXT_POS: - nCurPos++; - break; - case PRIOR_POS: - if ( nCurPos > 0 ) - nCurPos--; - break; - case FIRST_POS: - nCurPos = 1; - break; - case LAST_POS: - nCurPos = nRetrievedRows; - break; - case ABSOLUTE_POS: - nCurPos = nOffset; - break; - case RELATIVE_POS: - nCurPos += sal_uInt32( nOffset ); - break; - } - - if ( nCurPos <= 0 ) { - m_nRowPos = 0; - SAL_INFO( - "connectivity.mork", "return False, m_nRowPos = " << m_nRowPos); - return false; - } - sal_Int32 nCurCard; - if ( nCurPos < static_cast<sal_Int32>(m_pKeySet->size()) ) //The requested row is exist in m_pKeySet, so we just use it - { - nCurCard = (*m_pKeySet)[nCurPos-1]; - } - else //The requested row has not been retrieved until now. We should get the right card for it. - nCurCard = nCurPos + deletedCount(); - - if ( nCurCard > nNumberOfRecords) { - fillKeySet(nNumberOfRecords); - m_nRowPos = static_cast<sal_uInt32>(m_pKeySet->size() + 1); - SAL_INFO( - "connectivity.mork", "return False, m_nRowPos = " << m_nRowPos); - return false; - } - //Insert new retrieved items for later use - fillKeySet(nNumberOfRecords); - m_nRowPos = static_cast<sal_uInt32>(nCurPos); - SAL_INFO("connectivity.mork", "return True, m_nRowPos = " << m_nRowPos); - fetchCurrentRow(); - return true; -} - -void OResultSet::setColumnMapping(const std::vector<sal_Int32>& _aColumnMapping) -{ - m_aColMapping = _aColumnMapping; -#if OSL_DEBUG_LEVEL > 0 - for ( size_t i = 0; i < m_aColMapping.size(); i++ ) - SAL_INFO( - "connectivity.mork", - "Set Mapped: " << i << " -> " << m_aColMapping[i]); -#endif -} - - -css::uno::Any OResultSet::getBookmark( ) -{ - SAL_INFO("connectivity.mork", "m_nRowPos = " << m_nRowPos); - ResultSetEntryGuard aGuard( *this ); - if ( !fetchCurrentRow() ) { - m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this ); - } - - OSL_ENSURE((!m_aRow->isDeleted()),"getBookmark called for deleted row"); - return makeAny(static_cast<sal_Int32>((*m_aRow)[0])); -} -sal_Bool OResultSet::moveToBookmark( const css::uno::Any& bookmark ) -{ - ResultSetEntryGuard aGuard( *this ); - SAL_INFO( - "connectivity.mork", "bookmark = " << comphelper::getINT32(bookmark)); - sal_Int32 nCardNum = comphelper::getINT32(bookmark); - m_nRowPos = getRowForCardNumber(nCardNum); - fetchCurrentRow(); - return true; -} -sal_Bool OResultSet::moveRelativeToBookmark( const css::uno::Any& bookmark, sal_Int32 rows ) -{ - ResultSetEntryGuard aGuard( *this ); - SAL_INFO( - "connectivity.mork", - "bookmark = " << comphelper::getINT32(bookmark) << " rows= " << rows); - sal_Int32 nCardNum = comphelper::getINT32(bookmark); - m_nRowPos = getRowForCardNumber(nCardNum); - return seekRow(RELATIVE_POS,rows ); -} -sal_Int32 OResultSet::compareBookmarks( const css::uno::Any& lhs, const css::uno::Any& rhs ) -{ - ResultSetEntryGuard aGuard( *this ); - SAL_INFO("connectivity.mork", "m_nRowPos = " << 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 = CompareBookmark::LESS; - else if(nFirst > nSecond) - nResult = CompareBookmark::GREATER; - else - nResult = CompareBookmark::EQUAL; - - return nResult; -} -sal_Bool OResultSet::hasOrderedBookmarks( ) -{ - ResultSetEntryGuard aGuard( *this ); - SAL_INFO("connectivity.mork", "m_nRowPos = " << m_nRowPos); - return true; -} -sal_Int32 OResultSet::hashBookmark( const css::uno::Any& bookmark ) -{ - ResultSetEntryGuard aGuard( *this ); - SAL_INFO("connectivity.mork", "m_nRowPos = " << m_nRowPos); - return comphelper::getINT32(bookmark); -} - -sal_Int32 OResultSet::getCurrentCardNumber() -{ - if ( ( m_nRowPos == 0 ) || !m_pKeySet.is() ) - return 0; - if (m_pKeySet->size() < m_nRowPos) - return 0; - return (*m_pKeySet)[m_nRowPos-1]; -} -void OResultSet::checkPendingUpdate() -{ - OSL_FAIL( "OResultSet::checkPendingUpdate() not implemented" ); -/* - const sal_Int32 nCurrentRow = getCurrentCardNumber(); - - if ((m_nNewRow && nCurrentRow != m_nNewRow) - || ( m_nUpdatedRow && m_nUpdatedRow != nCurrentRow)) - { - const OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution( - STR_COMMIT_ROW, - "$position$", OUString::valueOf(nCurrentRow) - ) ); - ::dbtools::throwGenericSQLException(sError,*this); - } -*/ - -} -void OResultSet::updateValue(sal_Int32 columnIndex ,const ORowSetValue& x) -{ - SAL_INFO("connectivity.mork", "m_nRowPos = " << m_nRowPos); - ResultSetEntryGuard aGuard( *this ); - if ( !fetchCurrentRow() ) { - m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this ); - } - - checkPendingUpdate(); - - checkIndex(columnIndex ); - columnIndex = mapColumn(columnIndex); - - (*m_aRow)[columnIndex].setBound(true); - (*m_aRow)[columnIndex] = x; -} - - -void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) -{ - SAL_INFO("connectivity.mork", "m_nRowPos = " << m_nRowPos); - ResultSetEntryGuard aGuard( *this ); - if ( !fetchCurrentRow() ) - m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this ); - - checkPendingUpdate(); - checkIndex(columnIndex ); - columnIndex = mapColumn(columnIndex); - - (*m_aRow)[columnIndex].setBound(true); - (*m_aRow)[columnIndex].setNull(); -} - - -void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) -{ - updateValue(columnIndex, static_cast<bool>(x)); -} - -void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) -{ - updateValue(columnIndex,x); -} - - -void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) -{ - updateValue(columnIndex,x); -} - -void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) -{ - updateValue(columnIndex,x); -} - -void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XRowUpdate::updateLong", *this ); -} - -void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) -{ - updateValue(columnIndex,x); -} - - -void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) -{ - updateValue(columnIndex,x); -} - -void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const OUString& x ) -{ - updateValue(columnIndex,x); -} - -void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) -{ - updateValue(columnIndex,x); -} - -void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const css::util::Date& x ) -{ - updateValue(columnIndex,x); -} - - -void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const css::util::Time& x ) -{ - updateValue(columnIndex,x); -} - - -void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const css::util::DateTime& x ) -{ - updateValue(columnIndex,x); -} - - -void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length ) -{ - 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< css::io::XInputStream >& x, sal_Int32 length ) -{ - updateBinaryStream(columnIndex,x,length); -} - -void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) -{ - if (!::dbtools::implUpdateObject(this, columnIndex, x)) - { - const OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution( - STR_COLUMN_NOT_UPDATEABLE, - "$position$", OUString::number(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*/ ) -{ - if (!::dbtools::implUpdateObject(this, columnIndex, x)) - { - const OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution( - STR_COLUMN_NOT_UPDATEABLE, - "$position$", OUString::number(columnIndex) - ) ); - ::dbtools::throwGenericSQLException(sError,*this); - } -} - -// XResultSetUpdate - -void SAL_CALL OResultSet::insertRow( ) -{ - ResultSetEntryGuard aGuard( *this ); - SAL_INFO("connectivity.mork", "in, m_nRowPos = " << m_nRowPos); -// m_RowStates = RowStates_Inserted; - updateRow(); - //m_aQueryHelper.setRowStates(getCurrentCardNumber(),m_RowStates); - SAL_INFO("connectivity.mork", "out, m_nRowPos = " << m_nRowPos); -} - -void SAL_CALL OResultSet::updateRow( ) -{ - OSL_FAIL( "OResultSet::updateRow( ) not implemented" ); -} - -void SAL_CALL OResultSet::deleteRow( ) -{ - OSL_FAIL( "OResultSet::deleteRow( ) not implemented" ); -} - -void SAL_CALL OResultSet::cancelRowUpdates( ) -{ - OSL_FAIL( "OResultSet::cancelRowUpdates( ) not implemented" ); -} - -void SAL_CALL OResultSet::moveToInsertRow( ) -{ - OSL_FAIL( "OResultSet::moveToInsertRow( ) not implemented" ); -} - -void SAL_CALL OResultSet::moveToCurrentRow( ) -{ - ResultSetEntryGuard aGuard( *this ); - SAL_INFO("connectivity.mork", "m_nRowPos = " << m_nRowPos); - if (rowInserted()) - { - m_nRowPos = 0; - fetchCurrentRow(); - } -} - -bool OResultSet::determineReadOnly() -{ -// OSL_FAIL( "OResultSet::determineReadOnly( ) not implemented" ); - - if (m_bIsReadOnly == TRISTATE_INDET) - { - m_bIsReadOnly = TRISTATE_TRUE; -// OConnection* xConnection = static_cast<OConnection*>(m_pStatement->getConnection().get()); -// m_bIsReadOnly = !m_aQueryHelper.isWritable(xConnection) || m_bIsAlwaysFalseQuery; - } - - return m_bIsReadOnly != TRISTATE_FALSE; -} - -void OResultSet::setTable(OTable* _rTable) -{ - m_xTable = _rTable; - m_xTableColumns = m_xTable->getColumns(); - if(m_xTableColumns.is()) - m_aColumnNames = m_xTableColumns->getElementNames(); -} - -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*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "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 deleted file mode 100644 index a63b71b901dd..000000000000 --- a/connectivity/source/drivers/mork/MResultSet.hxx +++ /dev/null @@ -1,347 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MORK_MRESULTSET_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MRESULTSET_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/compbase.hxx> -#include <comphelper/proparrhlp.hxx> -#include <tools/gen.hxx> -#include <rtl/ref.hxx> -#include "MStatement.hxx" -#include "MQueryHelper.hxx" -#include <connectivity/CommonTools.hxx> -#include <connectivity/FValue.hxx> -#include <connectivity/sqliterator.hxx> -#include <TSortIndex.hxx> - -namespace connectivity::mork - { - - /* - ** java_sql_ResultSet - */ - typedef ::cppu::WeakComponentImplHelper< css::sdbc::XResultSet, - css::sdbc::XRow, - css::sdbc::XResultSetMetaDataSupplier, - css::util::XCancellable, - css::sdbc::XWarningsSupplier, - css::sdbc::XCloseable, - css::sdbc::XColumnLocate, - css::sdbc::XResultSetUpdate, - css::sdbc::XRowUpdate, - css::sdbcx::XRowLocate, - css::sdbcx::XDeleteRows, - css::lang::XServiceInfo> OResultSet_BASE; - - - typedef sal_Int64 TVoidPtr; - typedef std::allocator< TVoidPtr > TVoidAlloc; - typedef std::vector<TVoidPtr> TVoidVector; - - class OResultSet : public cppu::BaseMutex, - public OResultSet_BASE, - public ::cppu::OPropertySetHelper, - public ::comphelper::OPropertyArrayUsageHelper<OResultSet> - { - protected: - OCommonStatement* m_pStatement; - css::uno::Reference< css::uno::XInterface> m_xStatement; - css::uno::Reference< css::sdbc::XResultSetMetaData> m_xMetaData; - sal_uInt32 m_nRowPos; - bool m_bWasNull; - sal_Int32 m_nResultSetType; - sal_Int32 m_nFetchDirection; - - - std::shared_ptr< ::connectivity::OSQLParseTreeIterator > - m_pSQLIterator; - const connectivity::OSQLParseNode* m_pParseTree; - - // OPropertyArrayUsageHelper - virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override; - // OPropertySetHelper - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; - - virtual sal_Bool SAL_CALL convertFastPropertyValue( - css::uno::Any & rConvertedValue, - css::uno::Any & rOldValue, - sal_Int32 nHandle, - const css::uno::Any& rValue ) override; - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const css::uno::Any& rValue - ) override; - virtual void SAL_CALL getFastPropertyValue( - css::uno::Any& rValue, - sal_Int32 nHandle - ) const override; - - // you can't delete objects of this type - virtual ~OResultSet() override; - public: - DECLARE_SERVICE_INFO(); - - OResultSet(OCommonStatement* pStmt, const std::shared_ptr< ::connectivity::OSQLParseTreeIterator >& _pSQLIterator ); - - // ::cppu::OComponentHelper - virtual void SAL_CALL disposing() override; - // XInterface - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - virtual void SAL_CALL acquire() throw() override; - virtual void SAL_CALL release() throw() override; - //XTypeProvider - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; - // XPropertySet - virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; - // XResultSet - virtual sal_Bool SAL_CALL next( ) override; - virtual sal_Bool SAL_CALL isBeforeFirst( ) override; - virtual sal_Bool SAL_CALL isAfterLast( ) override; - virtual sal_Bool SAL_CALL isFirst( ) override; - virtual sal_Bool SAL_CALL isLast( ) override; - virtual void SAL_CALL beforeFirst( ) override; - virtual void SAL_CALL afterLast( ) override; - virtual sal_Bool SAL_CALL first( ) override; - virtual sal_Bool SAL_CALL last( ) override; - virtual sal_Int32 SAL_CALL getRow( ) override; - virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) override; - virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) override; - virtual sal_Bool SAL_CALL previous( ) override; - virtual void SAL_CALL refreshRow( ) override; - virtual sal_Bool SAL_CALL rowUpdated( ) override; - virtual sal_Bool SAL_CALL rowInserted( ) override; - virtual sal_Bool SAL_CALL rowDeleted( ) override; - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement( ) override; - // XRow - virtual sal_Bool SAL_CALL wasNull( ) override; - virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) override; - virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) override; - virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) override; - virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) override; - virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) override; - virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) override; - virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) override; - virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) override; - virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) override; - virtual css::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) override; - virtual css::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) override; - virtual css::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) override; - virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) override; - virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) override; - virtual css::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess >& typeMap ) override; - virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) override; - virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) override; - virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) override; - virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) override; - // XResultSetMetaDataSupplier - virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override; - // XCancellable - virtual void SAL_CALL cancel( ) override; - // XCloseable - virtual void SAL_CALL close( ) override; - // XWarningsSupplier - virtual css::uno::Any SAL_CALL getWarnings( ) override; - virtual void SAL_CALL clearWarnings( ) override; - // XColumnLocate - virtual sal_Int32 SAL_CALL findColumn( const OUString& columnName ) override; - - // XResultSetUpdate - virtual void SAL_CALL insertRow( ) override; - virtual void SAL_CALL updateRow( ) override; - virtual void SAL_CALL deleteRow( ) override; - virtual void SAL_CALL cancelRowUpdates( ) override; - virtual void SAL_CALL moveToInsertRow( ) override; - virtual void SAL_CALL moveToCurrentRow( ) override; - // XRowUpdate - virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) override; - virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) override; - virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) override; - virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) override; - virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) override; - virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) override; - virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) override; - virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) override; - virtual void SAL_CALL updateString( sal_Int32 columnIndex, const OUString& x ) override; - virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const css::uno::Sequence< sal_Int8 >& x ) override; - virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const css::util::Date& x ) override; - virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const css::util::Time& x ) override; - virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const css::util::DateTime& x ) override; - virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override; - virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override; - virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const css::uno::Any& x ) override; - virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const css::uno::Any& x, sal_Int32 scale ) override; - // XRowLocate - virtual css::uno::Any SAL_CALL getBookmark( ) override; - virtual sal_Bool SAL_CALL moveToBookmark( const css::uno::Any& bookmark ) override; - virtual sal_Bool SAL_CALL moveRelativeToBookmark( const css::uno::Any& bookmark, sal_Int32 rows ) override; - virtual sal_Int32 SAL_CALL compareBookmarks( const css::uno::Any& first, const css::uno::Any& second ) override; - virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) override; - virtual sal_Int32 SAL_CALL hashBookmark( const css::uno::Any& bookmark ) override; - // XDeleteRows - virtual css::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const css::uno::Sequence< css::uno::Any >& rows ) override; - -protected: - //MQuery m_aQuery; - MQueryHelper m_aQueryHelper; - rtl::Reference<OTable> m_xTable; - sal_Int32 m_CurrentRowCount; - css::uno::Reference< css::container::XNameAccess > - m_xTableColumns; - - std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 every time - std::vector<sal_Int32> m_aOrderbyColumnNumber; - std::vector<TAscendingOrder> m_aOrderbyAscending; - css::uno::Sequence< OUString> m_aColumnNames; - OValueRow m_aRow; - OValueRow m_aParameterRow; - sal_Int32 m_nParamIndex; - bool m_bIsAlwaysFalseQuery; - ::rtl::Reference<OKeySet> m_pKeySet; - TriState m_bIsReadOnly; - void resetParameters() { m_nParamIndex = 0; } - - ::rtl::Reference<connectivity::OSQLColumns> m_xColumns; // this are the select columns - - void parseParameter( const OSQLParseNode* pNode, OUString& rMatchString ); - /// @throws css::sdbc::SQLException - /// @throws css::uno::RuntimeException - void fillRowData(); - void analyseWhereClause( const OSQLParseNode* parseTree, - MQueryExpression &queryExpression); - - bool isCount() const; - - bool IsSorted() const { return !m_aOrderbyColumnNumber.empty(); } - - enum eRowPosition { - NEXT_POS, PRIOR_POS, FIRST_POS, LAST_POS, ABSOLUTE_POS, RELATIVE_POS - }; - - sal_uInt32 currentRowCount(); - - /// @throws css::sdbc::SQLException - /// @throws css::uno::RuntimeException - bool fetchRow(sal_Int32 rowIndex,bool bForceReload=false); - /// @throws css::sdbc::SQLException - /// @throws css::uno::RuntimeException - bool fetchCurrentRow(); - bool validRow( sal_uInt32 nRow ); - bool seekRow( eRowPosition pos, sal_Int32 nOffset = 0 ); - sal_Int32 deletedCount(); - void fillKeySet(sal_Int32 nMaxCardNumber); //When we get new rows, fill the m_pKeySet items for them - sal_Int32 getRowForCardNumber(sal_Int32 nCardNum); - /// @throws css::sdbc::SQLException - /// @throws css::uno::RuntimeException - const ORowSetValue& getValue(sal_Int32 rowIndex, sal_Int32 columnIndex); - - /// @throws css::sdbc::SQLException - /// @throws css::uno::RuntimeException - void updateValue(sal_Int32 columnIndex,const ORowSetValue& x ); - /// @throws css::sdbc::SQLException - /// @throws css::uno::RuntimeException - static void checkPendingUpdate(); - sal_Int32 getCurrentCardNumber(); - -public: - bool determineReadOnly(); - // MozAddressbook Specific methods - /// @throws css::sdbc::SQLException - /// @throws css::uno::RuntimeException - void executeQuery(); - - void setTable(OTable* _rTable); - - void setParameterRow(const OValueRow& _rParaRow) - { m_aParameterRow = _rParaRow; } - - 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); - - /// @throws css::sdbc::SQLException - void checkIndex(sal_Int32 columnIndex ); - - static void setBoundedColumns( - const OValueRow& _rRow, - const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns, - const css::uno::Reference< css::container::XIndexAccess>& _xNames, - bool _bSetColumnMapping, - const css::uno::Reference< css::sdbc::XDatabaseMetaData>& _xMetaData, - std::vector<sal_Int32>& _rColMapping); - - ::osl::Mutex& getMutex() { return m_aMutex; } - void methodEntry(); - - private: - 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 < static_cast<sal_Int32>(m_aColMapping.size()))) - map = m_aColMapping[column]; - - return map; - } - - class ResultSetEntryGuard : public ::osl::MutexGuard - { - public: - explicit ResultSetEntryGuard( OResultSet& _rRS ) : ::osl::MutexGuard( _rRS.getMutex() ) - { - _rRS.methodEntry(); - } - }; - -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MRESULTSET_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MResultSetMetaData.cxx b/connectivity/source/drivers/mork/MResultSetMetaData.cxx deleted file mode 100644 index e05eced22da2..000000000000 --- a/connectivity/source/drivers/mork/MResultSetMetaData.cxx +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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 <comphelper/types.hxx> -#include <comphelper/extract.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 = nullptr; -} - - -void OResultSetMetaData::checkColumnIndex(sal_Int32 column) -{ - if(column <= 0 || column > static_cast<sal_Int32>(m_xColumns->size())) - throwInvalidIndexException(*this); -} - -sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) -{ - return getPrecision(column); -} - - -sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 /*column*/ ) -{ - return DataType::VARCHAR; // at the moment there exists only this type -} - - -sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) -{ - return static_cast<sal_Int32>(m_xColumns->size()); -} - - -sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ ) -{ - return false; -} - - -OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) -{ - return OUString(); -} - - -OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) -{ - checkColumnIndex(column); - - OUString sColumnName; - try - { - Reference< XPropertySet > xColumnProps( (*m_xColumns)[column-1], UNO_SET_THROW ); - OSL_VERIFY( xColumnProps->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_NAME ) ) >>= sColumnName ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("connectivity.mork"); - } - return sColumnName; -} - -OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 /*column*/ ) -{ - return m_aTableName; -} - -OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) -{ - return OUString(); -} - -OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) -{ - checkColumnIndex(column); - return getString((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))); -} - -OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) -{ - return getColumnName(column); -} - -OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) -{ - return OUString(); -} - - -sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) -{ - checkColumnIndex(column); - return getBOOL((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY))); -} - - -sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*column*/ ) -{ - return false; -} - -sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ ) -{ - return false; -} - -sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) -{ - checkColumnIndex(column); - return getINT32((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))); -} - -sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) -{ - checkColumnIndex(column); - return getINT32((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))); -} - - -sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) -{ - checkColumnIndex(column); - return getINT32((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))); -} - - -sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 /*column*/ ) -{ - if ( !m_pTable || !m_pTable->getConnection() ) - { - OSL_FAIL( "OResultSetMetaData::isSearchable: suspicious: called without table or connection!" ); - return false; - } - - return true; -} - - -sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) -{ - checkColumnIndex(column); - bool bReadOnly = (*m_xColumns)[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) && - ::cppu::any2bool((*m_xColumns)[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION))); - - return m_bReadOnly || bReadOnly || OTable::isReadOnly(); -} - - -sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) -{ - return !isReadOnly(column); -} - -sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) -{ - 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 deleted file mode 100644 index 953ed6b214ef..000000000000 --- a/connectivity/source/drivers/mork/MResultSetMetaData.hxx +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MORK_MRESULTSETMETADATA_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MRESULTSETMETADATA_HXX - -#include <com/sun/star/sdbc/XResultSetMetaData.hpp> -#include <cppuhelper/implbase.hxx> -#include <rtl/ref.hxx> -#include "MTable.hxx" - -namespace connectivity::mork - { - - //************ Class: ResultSetMetaData - - typedef ::cppu::WeakImplHelper<css::sdbc::XResultSetMetaData> OResultSetMetaData_BASE; - - class OResultSetMetaData : public OResultSetMetaData_BASE - { - OUString m_aTableName; - ::rtl::Reference<connectivity::OSQLColumns> m_xColumns; - OTable* m_pTable; - bool m_bReadOnly; - - protected: - virtual ~OResultSetMetaData() override; - public: - // a constructor that is needed to return the object: - // OResultSetMetaData(OConnection* _pConnection) : m_pConnection(_pConnection){} - OResultSetMetaData(const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns, - const OUString& _aTableName,OTable* _pTable,bool aReadOnly - ) - :m_aTableName(_aTableName) - ,m_xColumns(_rxColumns) - ,m_pTable(_pTable) - ,m_bReadOnly(aReadOnly) - {} - - /// @throws css::sdbc::SQLException - /// @throws css::uno::RuntimeException - void checkColumnIndex(sal_Int32 column); - 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_MORK_MRESULTSETMETADATA_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MStatement.cxx b/connectivity/source/drivers/mork/MStatement.cxx deleted file mode 100644 index bd153afa6438..000000000000 --- a/connectivity/source/drivers/mork/MStatement.cxx +++ /dev/null @@ -1,471 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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 <tools/diagnose_ex.h> -#include <sal/log.hxx> -#include <cppuhelper/queryinterface.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <comphelper/processfactory.hxx> -#include <connectivity/dbexception.hxx> - -#include <algorithm> - -#include "MDriver.hxx" -#include "MStatement.hxx" -#include <sqlbison.hxx> -#include "MResultSet.hxx" - -#include <strings.hrc> - -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) -{ -} - -OCommonStatement::OCommonStatement(OConnection* _pConnection ) - :OCommonStatement_IBASE(m_aMutex) - ,OPropertySetHelper(OCommonStatement_IBASE::rBHelper) - ,m_xDBMetaData (_pConnection->getMetaData()) - ,m_pTable(nullptr) - ,m_pConnection(_pConnection) - ,m_aParser( comphelper::getComponentContext(_pConnection->getDriver()->getFactory()) ) - ,m_pSQLIterator( std::make_shared<OSQLParseTreeIterator>( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser ) ) -{ -} - - -OCommonStatement::~OCommonStatement() -{ -} - - -void OCommonStatement::disposing() -{ - ::osl::MutexGuard aGuard(m_aMutex); - - clearWarnings(); - clearCachedResultSet(); - - m_pConnection.clear(); - - m_pSQLIterator->dispose(); - m_pParseTree.reset(); - - OCommonStatement_IBASE::disposing(); -} - -Any SAL_CALL OCommonStatement::queryInterface( const Type & rType ) -{ - Any aRet = OCommonStatement_IBASE::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OPropertySetHelper::queryInterface(rType); - return aRet; -} - -Sequence< Type > SAL_CALL OCommonStatement::getTypes( ) -{ - ::cppu::OTypeCollection aTypes( cppu::UnoType<XMultiPropertySet>::get(), - cppu::UnoType<XFastPropertySet>::get(), - cppu::UnoType<XPropertySet>::get()); - - return ::comphelper::concatSequences(aTypes.getTypes(),OCommonStatement_IBASE::getTypes()); -} - -void SAL_CALL OCommonStatement::close( ) -{ - { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - } - dispose(); -} - -OCommonStatement::StatementType OCommonStatement::parseSql( const OUString& sql , bool bAdjusted) -{ - OUString aErr; - - m_pParseTree = m_aParser.parseTree(aErr,sql); - - if(m_pParseTree) - { - m_pSQLIterator->setParseTree(m_pParseTree.get()); - m_pSQLIterator->traverseAll(); - const OSQLTables& rTabs = m_pSQLIterator->getTables(); - - if (rTabs.empty()) - { - getOwnConnection()->throwSQLException( STR_QUERY_AT_LEAST_ONE_TABLES, *this ); - } - - Reference<XIndexAccess> xNames; - switch(m_pSQLIterator->getStatementType()) - { - case OSQLStatementType::Select: - - // at this moment we support only one table per select statement - - OSL_ENSURE( !rTabs.empty(), "Need a Table"); - - m_pTable = static_cast< OTable* > (rTabs.begin()->second.get()); - m_xColNames = m_pTable->getColumns(); - xNames.set(m_xColNames,UNO_QUERY); - // set the binding of the resultrow - m_aRow = new OValueVector(xNames->getCount()); - (*m_aRow)[0].setBound(true); - std::for_each(m_aRow->begin()+1,m_aRow->end(),TSetBound(false)); - // create the column mapping - createColumnMapping(); - - analyseSQL(); - return eSelect; - - case OSQLStatementType::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 + "(""E-mail"" character)", true); - } - - getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); - OSL_FAIL( "OCommonStatement::parseSql: unreachable!" ); - return eSelect; - -} - -Reference< XResultSet > OCommonStatement::impl_executeCurrentQuery() -{ - clearCachedResultSet(); - - ::rtl::Reference 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 ) -{ - 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() -{ - Reference< XResultSet > xResultSet( m_xResultSet.get(), UNO_QUERY ); - if ( !xResultSet.is() ) - return; - - Reference< XCloseable >( xResultSet, UNO_QUERY_THROW )->close(); - - m_xResultSet.clear(); -} - - -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 OUString& sql ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - Reference< XResultSet > xRS = executeQuery( sql ); - // returns true when a resultset is available - return xRS.is(); -} - - -Reference< XResultSet > SAL_CALL OCommonStatement::executeQuery( const OUString& sql ) -{ - ::osl::MutexGuard aGuard( m_ThreadMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - // parse the statement - StatementType eStatementType = parseSql( sql ); - if ( eStatementType != eSelect ) - return nullptr; - - return impl_executeCurrentQuery(); -} - - -Reference< XConnection > SAL_CALL OCommonStatement::getConnection( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - // just return our connection here - return Reference< XConnection >(m_pConnection.get()); -} - -Any SAL_CALL OStatement::queryInterface( const Type & rType ) -{ - 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 OUString& /*sql*/ ) -{ - ::dbtools::throwFeatureNotImplementedSQLException( "XStatement::executeUpdate", *this ); - return 0; - -} - -Any SAL_CALL OCommonStatement::getWarnings( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); - - return makeAny(m_aLastWarning); -} - - -void SAL_CALL OCommonStatement::clearWarnings( ) -{ - ::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; - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME), - PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING), - PROPERTY_ID_ESCAPEPROCESSING, cppu::UnoType<bool>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), - PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), - PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE), - PROPERTY_ID_MAXFIELDSIZE, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXROWS), - PROPERTY_ID_MAXROWS, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT), - PROPERTY_ID_QUERYTIMEOUT, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), - PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), 0); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), - PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), 0); - - return new ::cppu::OPropertyArrayHelper(aProps); -} - - -::cppu::IPropertyArrayHelper & OCommonStatement::getInfoHelper() -{ - return *getArrayHelper(); -} - -sal_Bool OCommonStatement::convertFastPropertyValue( - Any & /*rConvertedValue*/, - Any & /*rOldValue*/, - sal_Int32 /*nHandle*/, - const Any& /*rValue*/ ) -{ - // here we have to try to convert - return false; -} - -void OCommonStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& /*rValue*/) -{ - // 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() -{ - OCommonStatement_IBASE::release(); -} - -void SAL_CALL OStatement::acquire() throw() -{ - OCommonStatement::acquire(); -} - -void SAL_CALL OStatement::release() throw() -{ - OCommonStatement::release(); -} - -Reference< css::beans::XPropertySetInfo > SAL_CALL OCommonStatement::getPropertySetInfo( ) -{ - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); -} - -void 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->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++ ) - SAL_INFO( - "connectivity.mork", - "BEFORE Mapped: " << i << " -> " << m_aColMapping[i]); -#endif - OResultSet::setBoundedColumns(m_aRow,xColumns,xNames,true,m_xDBMetaData,m_aColMapping); -#if OSL_DEBUG_LEVEL > 0 - for ( i = 0; i < m_aColMapping.size(); i++ ) - SAL_INFO( - "connectivity.mork", - "AFTER Mapped: " << i << " -> " << m_aColMapping[i]); -#endif -} - - -void OCommonStatement::analyseSQL() -{ - const OSQLParseNode* pOrderbyClause = m_pSQLIterator->getOrderTree(); - if(!pOrderbyClause) - return; - - OSQLParseNode * pOrderingSpecCommalist = pOrderbyClause->getChild(2); - OSL_ENSURE(SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OResultSet: Error in Parse Tree"); - - for (size_t m = 0; m < pOrderingSpecCommalist->count(); m++) - { - OSQLParseNode * pOrderingSpec = pOrderingSpecCommalist->getChild(m); - OSL_ENSURE(SQL_ISRULE(pOrderingSpec,ordering_spec),"OResultSet: Error in Parse Tree"); - OSL_ENSURE(pOrderingSpec->count() == 2,"OResultSet: Error in 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 const * pColumnRef, - OSQLParseNode const * pAscendingDescending) -{ - OUString aColumnName; - if (pColumnRef->count() == 1) - aColumnName = pColumnRef->getChild(0)->getTokenValue(); - else if (pColumnRef->count() == 3) - { - pColumnRef->getChild(2)->parseNodeToStr( aColumnName, getOwnConnection(), nullptr, false, 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) ? TAscendingOrder::DESC : TAscendingOrder::ASC); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MStatement.hxx b/connectivity/source/drivers/mork/MStatement.hxx deleted file mode 100644 index 9aade8c5c96f..000000000000 --- a/connectivity/source/drivers/mork/MStatement.hxx +++ /dev/null @@ -1,182 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MORK_MSTATEMENT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MSTATEMENT_HXX - -#include <comphelper/proparrhlp.hxx> -#include <connectivity/sqliterator.hxx> -#include <connectivity/sqlparse.hxx> -#include <com/sun/star/sdbc/SQLWarning.hpp> -#include <TSortIndex.hxx> -#include "MTable.hxx" - -#include <memory> - -namespace connectivity::mork - { - class OResultSet; - - typedef ::cppu::WeakComponentImplHelper< css::sdbc::XStatement, - css::sdbc::XWarningsSupplier, - css::sdbc::XCloseable> OCommonStatement_IBASE; - - - //************ Class: OCommonStatement - // is a base class for the normal statement and for the prepared statement - - class OCommonStatement; - - class OCommonStatement :public cppu::BaseMutex - ,public OCommonStatement_IBASE - ,public ::cppu::OPropertySetHelper - ,public ::comphelper::OPropertyArrayUsageHelper< OCommonStatement > - { - private: - css::sdbc::SQLWarning m_aLastWarning; - - protected: - css::uno::WeakReference< css::sdbc::XResultSet > m_xResultSet; - css::uno::Reference< css::sdbc::XDatabaseMetaData> m_xDBMetaData; - css::uno::Reference< css::container::XNameAccess> m_xColNames; // table columns - - // for this Statement - - OTable* m_pTable; - rtl::Reference<OConnection> m_pConnection; // The owning Connection object - - OValueRow m_aRow; - - connectivity::OSQLParser m_aParser; - std::shared_ptr< ::connectivity::OSQLParseTreeIterator > - m_pSQLIterator; - - std::unique_ptr<connectivity::OSQLParseNode> m_pParseTree; - - std::vector<sal_Int32> m_aColMapping; - std::vector<sal_Int32> m_aOrderbyColumnNumber; - std::vector<TAscendingOrder> m_aOrderbyAscending; - - protected: - - // OPropertyArrayUsageHelper - virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override; - // OPropertySetHelper - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; - virtual sal_Bool SAL_CALL convertFastPropertyValue( - css::uno::Any & rConvertedValue, - css::uno::Any & rOldValue, - sal_Int32 nHandle, - const css::uno::Any& rValue ) override; - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const css::uno::Any& rValue) override; - virtual void SAL_CALL getFastPropertyValue( - css::uno::Any& rValue, - sal_Int32 nHandle) const override; - virtual ~OCommonStatement() override; - - 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 - - @throws css::sdbc::SQLException - @throws css::uno::RuntimeException - */ - virtual StatementType - parseSql( const OUString& sql , bool bAdjusted = false); - /** 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) - */ - css::uno::Reference< css::sdbc::XResultSet > - impl_executeCurrentQuery(); - - void createColumnMapping(); - void analyseSQL(); - void setOrderbyColumn( connectivity::OSQLParseNode const * pColumnRef, - connectivity::OSQLParseNode const * pAscendingDescending); - - public: - // other methods - OConnection* getOwnConnection() const { return m_pConnection.get(); } - - explicit OCommonStatement(OConnection* _pConnection ); - using OCommonStatement_IBASE::operator css::uno::Reference< css::uno::XInterface >; - - // OComponentHelper - virtual void SAL_CALL disposing() override; - - // XInterface - virtual void SAL_CALL release() throw() override; - virtual void SAL_CALL acquire() throw() override; - // XInterface - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - //XTypeProvider - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; - - // XPropertySet - virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; - // XStatement - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( const OUString& sql ) override ; - virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) override ; - virtual sal_Bool SAL_CALL execute( const OUString& sql ) override ; - virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override ; - // XWarningsSupplier - virtual css::uno::Any SAL_CALL getWarnings( ) override; - virtual void SAL_CALL clearWarnings( ) override; - // XCloseable - virtual void SAL_CALL close( ) override; - - protected: - using OPropertySetHelper::getFastPropertyValue; - }; - - class OStatement : public OCommonStatement, - public css::lang::XServiceInfo - { - protected: - virtual ~OStatement() override {} - public: - // a constructor, for when the object needs to be returned: - explicit OStatement( OConnection* _pConnection); - DECLARE_SERVICE_INFO(); - - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - virtual void SAL_CALL acquire() throw() override; - virtual void SAL_CALL release() throw() override; - }; - -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MSTATEMENT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MTable.cxx b/connectivity/source/drivers/mork/MTable.cxx deleted file mode 100644 index 76db19fc6915..000000000000 --- a/connectivity/source/drivers/mork/MTable.cxx +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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 "MColumns.hxx" -#include <connectivity/TKeys.hxx> -#include <connectivity/TIndexes.hxx> - - -using namespace connectivity::mork; -using namespace connectivity; - - -OTable::OTable( sdbcx::OCollection* _pTables, OConnection* _pConnection, - const OUString& Name, const OUString& Type, const OUString& Description ) - :OTable_Base(_pTables, _pConnection, true, Name, Type, Description ) - ,m_pConnection( _pConnection ) -{ - construct(); -} - - -sdbcx::OCollection* OTable::createColumns( const ::std::vector< OUString>& _rNames ) -{ - return new OColumns( this, m_aMutex, _rNames ); -} - - -sdbcx::OCollection* OTable::createKeys(const ::std::vector< OUString>& _rNames) -{ - return new OKeysHelper( this, m_aMutex, _rNames ); -} - - -sdbcx::OCollection* OTable::createIndexes(const ::std::vector< OUString>& _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 deleted file mode 100644 index cf2b80d58287..000000000000 --- a/connectivity/source/drivers/mork/MTable.hxx +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MORK_MTABLE_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MTABLE_HXX - -#include <connectivity/TTableHelper.hxx> -#include "MConnection.hxx" - -namespace connectivity::mork - { - typedef ::connectivity::OTableHelper OTable_Base; - - class OTable : public OTable_Base - { - OConnection* m_pConnection; - - public: - OTable( sdbcx::OCollection* _pTables, - OConnection* _pConnection, - const OUString& Name, - const OUString& Type, - const OUString& Description ); - - OConnection* getConnection() { return m_pConnection;} - - static bool isReadOnly() { return false; } - - const OUString& getTableName() const { return m_Name; } - const OUString& getSchema() const { return m_SchemaName; } - - // OTableHelper overridables - virtual sdbcx::OCollection* createColumns( const ::std::vector< OUString>& _rNames ) override; - virtual sdbcx::OCollection* createKeys(const ::std::vector< OUString>& _rNames) override; - virtual sdbcx::OCollection* createIndexes(const ::std::vector< OUString>& _rNames) override; - private: - using OTable_Base::getConnection; - }; - -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MTABLE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MTables.cxx b/connectivity/source/drivers/mork/MTables.cxx deleted file mode 100644 index f211eff06bbb..000000000000 --- a/connectivity/source/drivers/mork/MTables.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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 "MCatalog.hxx" -#include <comphelper/types.hxx> - -#include <com/sun/star/sdbc/XRow.hpp> - -using namespace connectivity; -using namespace connectivity::mork; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::sdbc; - -sdbcx::ObjectType OTables::createObject(const OUString& _rName) -{ - OUString aName, aSchema; - aSchema = "%"; - aName = _rName; - - Sequence<OUString> aTypes{ "%" }; - - Reference<XResultSet> xResult = m_xMetaData->getTables(Any(), aSchema, aName, aTypes); - - sdbcx::ObjectType xRet; - 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() { static_cast<OCatalog&>(m_rParent).refreshTables(); } - -void OTables::disposing() -{ - 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 deleted file mode 100644 index d0a1d420a0d5..000000000000 --- a/connectivity/source/drivers/mork/MTables.hxx +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MORK_MTABLES_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MTABLES_HXX - -#include <connectivity/sdbcx/VCollection.hxx> -#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> -namespace connectivity::mork - { - class OTables : 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: - OTables(const css::uno::Reference< css::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, - const ::std::vector< OUString> &_rVector) : sdbcx::OCollection(_rParent, true, _rMutex, _rVector) - ,m_xMetaData(_rMetaData) - {} - - // only the name is identical to ::cppu::OComponentHelper - virtual void disposing() override; - }; - -} -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MTABLES_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MorkParser.cxx b/connectivity/source/drivers/mork/MorkParser.cxx deleted file mode 100644 index 3b8b38120b3b..000000000000 --- a/connectivity/source/drivers/mork/MorkParser.cxx +++ /dev/null @@ -1,757 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 <boost/io/ios_state.hpp> -#include <stdlib.h> -#include <string> -#include <string.h> -#include <fstream> -#include <iostream> - -std::string const g_Empty = ""; - -const char * const MorkDictColumnMeta = "<(a=c)>"; - -const int defaultScope_ = 0x80; - -MorkParser::MorkParser() : - columns_(), - values_(), - mork_(), - currentCells_(nullptr), - error_(NoError), - morkData_(), - morkPos_(0), - nextAddValueId_(0x7fffffff), - defaultTableId_(1), - nowParsing_(NP::Values) -{ -} - -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(); -} - -void MorkParser::initVars() -{ - error_ = NoError; - morkPos_ = 0; - nowParsing_ = NP::Values; - currentCells_ = nullptr; - nextAddValueId_ = 0x7fffffff; -} - -bool MorkParser::parse() -{ - bool Result = true; - - // Run over mork chars and parse each term - char cur = nextChar(); - - while ( Result && cur ) - { - if ( !isWhiteSpace( cur ) ) - { - // 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 '@': - 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_ = NP::Values; - - while ( Result && cur != '>' && cur ) - { - if ( !isWhiteSpace( cur ) ) - { - switch ( cur ) - { - case '<': - { - - if ( morkData_.substr( morkPos_ - 1, strlen( MorkDictColumnMeta ) ) == MorkDictColumnMeta ) - { - nowParsing_ = NP::Columns; - 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 - { - (void)nextChar(); - } - } - break; - case '$': - { - // Get next two chars - std::string HexChar; - HexChar += nextChar(); - HexChar += nextChar(); - Text += static_cast<char>(strtoul(HexChar.c_str(), nullptr, 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(), nullptr, 16); - - if ( NP::Rows != nowParsing_ ) - { - // Dicts - if ( !Text.empty() ) - { - if ( nowParsing_ == NP::Columns ) - { - columns_[ ColumnId ] = Text; - } - else - { - values_[ ColumnId ] = Text; - } - } - } - else - { - if ( !Text.empty() ) - { - // Rows - //int ValueId = string( Text.c_str() ).toInt( 0, 16 ); - int ValueId = strtoul(Text.c_str(), nullptr, 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 '{': - 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(), nullptr, 16); - - *Scope = strtoul(tSc.c_str(), nullptr, 16); - } - else - { - *Id = strtoul(TextId.c_str(), nullptr, 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_.map[ abs( TableScope ) ].map[ abs( TableId ) ].map[ abs( RowScope ) ].map[ abs( RowId ) ] ); -} - -bool MorkParser::parseRow( int TableId, int TableScope ) -{ - bool Result = true; - std::string TextId; - int Id = 0, Scope = 0; - nowParsing_ = NP::Rows; - - 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 '[': - parseMeta( ']' ); - break; - default: - Result = false; - break; - } - } - - cur = nextChar(); - } - - return Result; -} - -void MorkParser::parseGroup() -{ - parseMeta( '@' ); -} - -void MorkParser::parseMeta( char c ) -{ - char cur = nextChar(); - - while ( cur != c && cur ) - { - cur = nextChar(); - } -} - -MorkTableMap *MorkParser::getTables( int TableScope ) -{ - TableScopeMap::Map::iterator iter = mork_.map.find( TableScope ); - - if ( iter == mork_.map.end() ) - { - return nullptr; - } - - return &iter->second; -} - -MorkRowMap *MorkParser::getRows( int RowScope, RowScopeMap *table ) -{ - RowScopeMap::Map::iterator iter = table->map.find( RowScope ); - - if ( iter == table->map.end() ) - { - return nullptr; - } - - return &iter->second; -} - -std::string const &MorkParser::getValue( int oid ) -{ - MorkDict::iterator foundIter = values_.find( oid ); - - if ( values_.end() == foundIter ) - { - return g_Empty; - } - - return foundIter->second; -} - -std::string const &MorkParser::getColumn( int oid ) -{ - MorkDict::iterator foundIter = columns_.find( oid ); - - if ( columns_.end() == foundIter ) - { - return g_Empty; - } - - return foundIter->second; -} - -void MorkParser::retrieveLists(std::set<std::string>& lists) -{ -#ifdef VERBOSE - boost::io::ios_all_saver ias(std::cout); - std::cout << std::hex << std::uppercase; -#endif - - MorkTableMap* tables = getTables(defaultScope_); - if (!tables) return; - for (auto& rTable : tables->map) - { -#ifdef VERBOSE - std::cout << "\t Table:" - << ( ( int ) rTable.first < 0 ? "-" : " " ) - << rTable.first << std::endl; -#endif - MorkRowMap* rows = getRows( 0x81/*defaultListScope*/, &rTable.second ); - if (!rows) return; - for ( const auto& rRow : rows->map ) - { -#ifdef VERBOSE - std::cout << "\t\t\t Row Id:" - << ( ( int ) rRow.first < 0 ? "-" : " ") - << rRow.first << std::endl; - std::cout << "\t\t\t\t Cells:\r\n"; -#endif - // Get cells - MorkCells::const_iterator cellsIter = rRow.second.find(0xC1); - if (cellsIter != rRow.second.end()) - lists.insert(getValue( cellsIter->second )); - } - } -} - -void MorkParser::getRecordKeysForListTable(std::string const & listName, std::set<int>& records) -{ -#ifdef VERBOSE - boost::io::ios_all_saver ias(std::cout); - std::cout << std::hex << std::uppercase; -#endif - - MorkTableMap* tables = getTables(defaultScope_); - if (!tables) return; - for (auto& rTable : tables->map) - { -#ifdef VERBOSE - std::cout << "\t Table:" - << ( ( int ) rTable.first < 0 ? "-" : " " ) - << rTable.first << std::endl; -#endif - MorkRowMap* rows = getRows( 0x81, &rTable.second ); - if (!rows) return; - for ( const auto& rRow : rows->map ) - { -#ifdef VERBOSE - std::cout << "\t\t\t Row Id:" - << ( ( int ) rRow.first < 0 ? "-" : " ") - << rRow.first << std::endl; - std::cout << "\t\t\t\t Cells:\r\n"; -#endif - // Get cells - bool isListFound = false; - for ( const auto& [rColumnId, rValueId] : rRow.second ) - { - if (isListFound) - { - if (rColumnId >= 0xC7) - { - std::string value = getValue(rValueId); - int id = strtoul(value.c_str(), nullptr, 16); - records.insert(id); - } - } - else if ((rColumnId == 0xC1) && - listName == getValue( rValueId )) - { - isListFound = true; - } - } - - } - } -} - -void MorkParser::dump() -{ - boost::io::ios_all_saver ias(std::cout); - std::cout << std::hex << std::uppercase; - - std::cout << "Column Dict:\r\n"; - std::cout << "=============================================\r\n\r\n"; - - //// columns dict - for ( const auto& [rColumnId, rText] : columns_ ) - { - std::cout << rColumnId - << " : " - << rText - << std::endl; - } - - //// values dict - std::cout << "\r\nValues Dict:\r\n"; - std::cout << "=============================================\r\n\r\n"; - - for ( const auto& [rValueId, rText] : values_ ) - { - if (rValueId >= nextAddValueId_) { - continue; - } - - std::cout << rValueId - << " : " - << rText - << "\r\n"; - } - - std::cout << std::endl << "Data:" << std::endl; - std::cout << "=============================================" - << std::endl << std::endl; - - //// Mork data - for ( const auto& [rTableScopeId, rTableScope] : mork_.map ) - { - std::cout << "\r\n Scope:" << rTableScopeId << std::endl; - - for ( const auto& [rTableId, rTable] : rTableScope.map ) - { - std::cout << "\t Table:" - << ( rTableId < 0 ? "-" : " " ) - << rTableId << std::endl; - - for (const auto& [rRowScopeId, rRowScope] : rTable.map) - { - std::cout << "\t\t RowScope:" - << rRowScopeId << std::endl; - - for (const auto& [rRowId, rRow] : rRowScope.map) - { - std::cout << "\t\t\t Row Id:" - << (rRowId < 0 ? "-" : " ") - << rRowId << std::endl; - std::cout << "\t\t\t\t Cells:" << std::endl; - - for (const auto& [rColumnId, rValueId] : rRow) - { - // Write ids - std::cout << "\t\t\t\t\t" - << rColumnId - << " : " - << rValueId - << " => "; - - MorkDict::const_iterator FoundIter = values_.find( rValueId ); - if ( FoundIter != values_.end() ) - { - // Write string values - std::cout << columns_[ rColumnId ].c_str() - << " : " - << FoundIter->second.c_str() - << std::endl; - } - } - } - } - } - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MorkParser.hxx b/connectivity/source/drivers/mork/MorkParser.hxx deleted file mode 100644 index d16fc417dacd..000000000000 --- a/connectivity/source/drivers/mork/MorkParser.hxx +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MORKPARSER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MORKPARSER_HXX - -#include <rtl/ustring.hxx> - -#include <string> -#include <map> -#include <set> -#include <vector> - -#include "dllapi.h" - -// Types - -typedef std::map< int, std::string > MorkDict; -typedef std::map< int, int > MorkCells; // ColumnId : ValueId -struct MorkRowMap { typedef std::map< int, MorkCells > Map; Map map; }; // Row id -struct RowScopeMap { typedef std::map< int, MorkRowMap > Map; Map map; }; // Row scope -struct MorkTableMap { typedef std::map< int, RowScopeMap > Map; Map map; }; // Table id -struct TableScopeMap { typedef std::map< int, MorkTableMap > Map; Map map; }; // Table Scope - -// Error codes -enum MorkErrors -{ - NoError = 0, - FailedToOpen, - DefectedFormat -}; - - -/// Class MorkParser - -class LO_DLLPUBLIC_MORK MorkParser final -{ -public: - - explicit MorkParser(); - - /// Open and parse mork file - - bool open( const std::string &path ); - - /// Returns all tables of specified scope - - MorkTableMap *getTables( int tableScope ); - - /// Returns all rows under specified scope - - static MorkRowMap *getRows( int rowScope, RowScopeMap *table ); - - /// Return value of specified value oid - - std::string const &getValue( int oid ); - - /// Return value of specified column oid - - std::string const &getColumn( int oid ); - - void retrieveLists(std::set<std::string>& lists); - void getRecordKeysForListTable(std::string const & listName, std::set<int>& records); - - void dump(); - - // All lists - std::vector<OUString> lists_; - -private: // Members - - void initVars(); - - static bool isWhiteSpace( char c ); - char nextChar(); - - static 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(); - void parseMeta( char c ); - bool parseRow( int TableId, int TableScope ); - void parseGroup(); - -private: // 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 defaultTableId_; - - // Indicates entity is being parsed - enum class NP { Columns, Values, Rows } nowParsing_; - - MorkParser(const MorkParser &) = delete; - MorkParser &operator=(const MorkParser &) = delete; - -}; - -#endif // __MorkParser_h__ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/README b/connectivity/source/drivers/mork/README deleted file mode 100644 index 0d4207b0ca0d..000000000000 --- a/connectivity/source/drivers/mork/README +++ /dev/null @@ -1,41 +0,0 @@ -Mork Format Parsing Library -============================= - -Description ------------ - -Cross Platform Mozilla Mork format reader. - - -Compilation ------------- - -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 deleted file mode 100644 index adf269107d22..000000000000 --- a/connectivity/source/drivers/mork/dllapi.h +++ /dev/null @@ -1,25 +0,0 @@ - -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_DLLAPI_H -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_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 deleted file mode 100644 index 3e41befc7e7c..000000000000 --- a/connectivity/source/drivers/mork/license.txt +++ /dev/null @@ -1,31 +0,0 @@ -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 deleted file mode 100644 index 1eeb6affb894..000000000000 --- a/connectivity/source/drivers/mork/mork.component +++ /dev/null @@ -1,17 +0,0 @@ -<?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" environment="@CPPU_ENV@" - xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.sdbc.MorkDriver" - constructor="com_sun_star_comp_sdbc_MorkDriver_get_implementation"> - <service name="com.sun.star.sdbc.Driver"/> - </implementation> -</component> diff --git a/connectivity/source/drivers/mork/mork_helper.cxx b/connectivity/source/drivers/mork/mork_helper.cxx deleted file mode 100644 index 4cb11864fee5..000000000000 --- a/connectivity/source/drivers/mork/mork_helper.cxx +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -#include "MorkParser.hxx" -#include <iostream> -#include <sal/log.hxx> - -static 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 = mork.getTables( defaultScope ); - if ( Tables ) - { - // Iterate all tables - for (auto const& table : Tables->map) - { - if ( 0 == table.first ) continue; - SAL_INFO("connectivity.mork", "table->first : " << table.first); - std::string column = mork.getColumn( table.first ); - std::string value = mork.getValue( table.first ); - SAL_INFO("connectivity.mork", "table.column : " << column); - SAL_INFO("connectivity.mork", "table.value : " << value); - } - } - - mork.dump(); - - return true; -} - -int main(int argc, char* argv[]) -{ - if (argc < 2) - { - std::cerr << "Usage: " << argv[0] << " <path-to>/abook.mab" << std::endl; - std::cerr << "Example: " << argv[0] << " /home/johndoe/.thunderbird/m0tpqlky.default/abook.mab" << std::endl; - - return 1; - } - - OString aOString(argv[1]); - SAL_INFO("connectivity.mork", "abook.mab: " << aOString); - openAddressBook(aOString.getStr()); - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx deleted file mode 100644 index 71cb17b0f4ec..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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/lang/XMultiServiceFactory.hpp> -#include <cppuhelper/factory.hxx> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <cppuhelper/supportsservice.hxx> -#include <cppuhelper/weak.hxx> -#include "MMozillaBootstrap.hxx" -#include "MNSProfileDiscover.hxx" - -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::mozilla; -using namespace connectivity::mozab; - -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::lang::XSingleServiceFactory; -using ::com::sun::star::lang::XMultiServiceFactory; - -MozillaBootstrap::MozillaBootstrap() - : OMozillaBootstrap_BASE(m_aMutex) -{ - m_ProfileAccess.reset(new ProfileAccess); - bootupProfile(css::mozilla::MozillaProductType_Mozilla,OUString()); -} - -MozillaBootstrap::~MozillaBootstrap() -{ -} - -void MozillaBootstrap::disposing() -{ - ::osl::MutexGuard aGuard(m_aMutex); - OMozillaBootstrap_BASE::disposing(); -} - -OUString SAL_CALL MozillaBootstrap::getImplementationName( ) -{ - return "com.sun.star.comp.mozilla.MozillaBootstrap"; -} - -sal_Bool SAL_CALL MozillaBootstrap::supportsService( const OUString& _rServiceName ) -{ - return cppu::supportsService(this, _rServiceName); -} - -Sequence< OUString > SAL_CALL MozillaBootstrap::getSupportedServiceNames( ) -{ - // which service is supported - // for more information @see com.sun.star.mozilla.MozillaBootstrap - return { "com.sun.star.mozilla.MozillaBootstrap" }; -} - - -// XProfileDiscover -::sal_Int32 SAL_CALL MozillaBootstrap::getProfileCount( css::mozilla::MozillaProductType product) -{ - return m_ProfileAccess->getProfileCount(product); -} -::sal_Int32 SAL_CALL MozillaBootstrap::getProfileList( css::mozilla::MozillaProductType product, css::uno::Sequence< OUString >& list ) -{ - return m_ProfileAccess->getProfileList(product,list); -} -OUString SAL_CALL MozillaBootstrap::getDefaultProfile( css::mozilla::MozillaProductType product ) -{ - return m_ProfileAccess->getDefaultProfile(product); -} -OUString SAL_CALL MozillaBootstrap::getProfilePath( css::mozilla::MozillaProductType product, const OUString& profileName ) -{ - return m_ProfileAccess->getProfilePath(product,profileName); -} -sal_Bool SAL_CALL MozillaBootstrap::isProfileLocked( css::mozilla::MozillaProductType /*product*/, const OUString& /*profileName*/ ) -{ - return true; -} -sal_Bool SAL_CALL MozillaBootstrap::getProfileExists( css::mozilla::MozillaProductType product, const OUString& profileName ) -{ - return m_ProfileAccess->getProfileExists(product,profileName); -} - -// XProfileManager -::sal_Int32 SAL_CALL MozillaBootstrap::bootupProfile( css::mozilla::MozillaProductType, const OUString& ) -{ - return -1; -} -::sal_Int32 SAL_CALL MozillaBootstrap::shutdownProfile( ) -{ - return -1; -} -css::mozilla::MozillaProductType SAL_CALL MozillaBootstrap::getCurrentProduct( ) -{ - return css::mozilla::MozillaProductType_Default; -} -OUString SAL_CALL MozillaBootstrap::getCurrentProfile( ) -{ - return OUString(); -} -sal_Bool SAL_CALL MozillaBootstrap::isCurrentProfileLocked( ) -{ - return true; -} -OUString SAL_CALL MozillaBootstrap::setCurrentProfile( css::mozilla::MozillaProductType, const OUString& ) -{ - return OUString(); -} - -// XProxyRunner -::sal_Int32 SAL_CALL MozillaBootstrap::Run( const css::uno::Reference< css::mozilla::XCodeProxy >& ) -{ - return -1; -} - -extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* -connectivity_moz_MozillaBootstrap_get_implementation( - css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&) -{ - return cppu::acquire( - static_cast<cppu::OWeakObject*>(new connectivity::mozab::MozillaBootstrap())); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx deleted file mode 100644 index e3d3fa7e4aac..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MOZAB_BOOTSTRAP_MMOZILLABOOTSTRAP_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MMOZILLABOOTSTRAP_HXX - -#include <sal/config.h> - -#include <memory> - -#include <com/sun/star/mozilla/XMozillaBootstrap.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <cppuhelper/compbase.hxx> - - -namespace connectivity::mozab -{ - typedef ::cppu::WeakComponentImplHelper< css::mozilla::XMozillaBootstrap, - css::lang::XServiceInfo > OMozillaBootstrap_BASE; - class ProfileAccess; - class ProfileManager; - class MozillaBootstrap : public OMozillaBootstrap_BASE - { - private: - ::osl::Mutex m_aMutex; // mutex is need to control member access - virtual ~MozillaBootstrap() override; - std::unique_ptr<ProfileAccess> m_ProfileAccess; - public: - - MozillaBootstrap(); - - // 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; - - // XMozillaBootstrap - - // XProfileDiscover - virtual ::sal_Int32 SAL_CALL getProfileCount( css::mozilla::MozillaProductType product) override; - virtual ::sal_Int32 SAL_CALL getProfileList( css::mozilla::MozillaProductType product, css::uno::Sequence< OUString >& list ) override; - virtual OUString SAL_CALL getDefaultProfile( css::mozilla::MozillaProductType product ) override; - virtual OUString SAL_CALL getProfilePath( css::mozilla::MozillaProductType product, const OUString& profileName ) override; - virtual sal_Bool SAL_CALL isProfileLocked( css::mozilla::MozillaProductType product, const OUString& profileName ) override; - virtual sal_Bool SAL_CALL getProfileExists( css::mozilla::MozillaProductType product, const OUString& profileName ) override; - - // XProfileManager - virtual ::sal_Int32 SAL_CALL bootupProfile( css::mozilla::MozillaProductType product, const OUString& profileName ) override; - virtual ::sal_Int32 SAL_CALL shutdownProfile( ) override; - virtual css::mozilla::MozillaProductType SAL_CALL getCurrentProduct( ) override; - virtual OUString SAL_CALL getCurrentProfile( ) override; - virtual sal_Bool SAL_CALL isCurrentProfileLocked( ) override; - virtual OUString SAL_CALL setCurrentProfile( css::mozilla::MozillaProductType product, const OUString& profileName ) override; - - // XProxyRunner - virtual ::sal_Int32 SAL_CALL Run( const css::uno::Reference< css::mozilla::XCodeProxy >& aCode ) override; - }; - -} - -#endif // CONNECTIVITY_SMozillaBootstrap_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx deleted file mode 100644 index 71c70c641b30..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx +++ /dev/null @@ -1,159 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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 <string.h> -#endif // End UNIX - -#ifdef _WIN32 -#if !defined WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -#endif -#include <windows.h> -#include <stdlib.h> -#include <shlobj.h> -#include <objidl.h> -#endif // End _WIN32 -#include <osl/security.hxx> -#include <osl/file.hxx> -#include <osl/thread.h> - -using namespace ::com::sun::star::mozilla; - -namespace -{ - - OUString lcl_getUserDataDirectory() - { - ::osl::Security aSecurity; - OUString aConfigPath; - - #if defined(_WIN32) || 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 + "/"; - } - - - const size_t NB_PRODUCTS = 3; - const size_t NB_CANDIDATES = 4; - - // The order (index) of entries in DefaultProductDir and - // ProductRootEnvironmentVariable *must* match the constants - // (minus 1) in offapi/com/sun/star/mozilla/MozillaProductType.idl - // DO NOT CHANGE THE ORDER; ADD ONLY TO THE END - const char* DefaultProductDir[NB_PRODUCTS][NB_CANDIDATES] = - { - #if defined(_WIN32) - { "Mozilla/SeaMonkey/", nullptr, nullptr, nullptr }, - { "Mozilla/Firefox/", nullptr, nullptr, nullptr }, - { "Thunderbird/", "Mozilla/Thunderbird/", nullptr, nullptr } - #elif defined(MACOSX) - { "../Mozilla/SeaMonkey/", nullptr, nullptr, nullptr }, - { "Firefox/", nullptr, nullptr, nullptr }, - { "../Thunderbird/", nullptr, nullptr, nullptr } - #else - { ".mozilla/seamonkey/", nullptr, nullptr, nullptr }, - { ".mozilla/firefox/", nullptr, nullptr, nullptr }, - { ".thunderbird/", ".mozilla-thunderbird/", ".mozilla/thunderbird/", ".icedove/" } - #endif - }; - - const char* ProductRootEnvironmentVariable[NB_PRODUCTS] = - { - "MOZILLA_PROFILE_ROOT", - "MOZILLA_FIREFOX_PROFILE_ROOT", - "MOZILLA_THUNDERBIRD_PROFILE_ROOT", - }; - - - OUString const & lcl_guessProfileRoot( MozillaProductType _product ) - { - size_t productIndex = static_cast<int>(_product) - 1; - - static OUString s_productDirectories[NB_PRODUCTS]; - - if ( s_productDirectories[ productIndex ].isEmpty() ) - { - OUString sProductPath; - - // check whether we have an environment variable which help us - const char* pProfileByEnv = getenv( ProductRootEnvironmentVariable[ productIndex ] ); - if ( pProfileByEnv ) - { - sProductPath = OUString( pProfileByEnv, rtl_str_getLength( pProfileByEnv ), osl_getThreadTextEncoding() ); - // assume that this is fine, no further checks - } - else - { - OUString sProductDirCandidate; - const char pProfileRegistry[] = "profiles.ini"; - - // check all possible candidates - for ( size_t i=0; i<NB_CANDIDATES; ++i ) - { - if ( nullptr == DefaultProductDir[ productIndex ][ i ] ) - break; - - sProductDirCandidate = lcl_getUserDataDirectory() + - OUString::createFromAscii( DefaultProductDir[ productIndex ][ i ] ); - - // check existence - ::osl::DirectoryItem aRegistryItem; - ::osl::FileBase::RC result = ::osl::DirectoryItem::get( sProductDirCandidate + 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 ]; - } -} - - -OUString getRegistryDir(MozillaProductType product) -{ - if (product == MozillaProductType_Default) - return OUString(); - - return lcl_guessProfileRoot( product ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSFolders.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.hxx deleted file mode 100644 index 50c992f230af..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSFolders.hxx +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MOZAB_BOOTSTRAP_MNSFOLDERS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSFOLDERS_HXX - -#include <com/sun/star/mozilla/MozillaProductType.hpp> - -#include <rtl/ustring.hxx> - -OUString getRegistryDir(css::mozilla::MozillaProductType product); - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx deleted file mode 100644 index ae775b6fca01..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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 <com/sun/star/io/IOException.hpp> -#include <osl/file.h> -#include <rtl/byteseq.hxx> -#include <sal/log.hxx> - -IniParser::IniParser(OUString const & rIniName) -{ - OUString iniUrl; - if (osl_File_E_None != osl_getFileURLFromSystemPath(rIniName.pData, &iniUrl.pData)) - return; - - - oslFileHandle handle=nullptr; - oslFileError fileError = osl_File_E_INVAL; - try{ - if (!iniUrl.isEmpty()) - fileError = osl_openFile(iniUrl.pData, &handle, osl_File_OpenFlag_Read); - } - catch(const css::io::IOException&) - { - SAL_WARN("connectivity.mozab", "couldn't open file: " << iniUrl ); - } - - 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, reinterpret_cast<sal_Sequence **>(&seq))) - break; - OString line(reinterpret_cast<const 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->vVector.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 = "no name section"; - } - } - } - osl_closeFile(handle); - } - else - { - SAL_INFO("connectivity.mozab", "couldn't open file: " << iniUrl ); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx deleted file mode 100644 index 210553b73bcc..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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_MOZAB_BOOTSTRAP_MNSINIPARSER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_BOOTSTRAP_MNSINIPARSER_HXX - -#include <rtl/ustring.hxx> - -#include <map> -#include <vector> - -struct ini_NameValue -{ - OUString sName; - OUString sValue; -}; - -typedef std::vector< - ini_NameValue -> NameValueVector; - -struct ini_Section -{ - NameValueVector vVector; -}; -typedef std::map<OUString, - ini_Section - >IniSectionMap; - - -class IniParser -{ - IniSectionMap mAllSection; -public: - IniSectionMap& getAllSection() { return mAllSection; } - /// @throws css::io::IOException - explicit IniParser(OUString const & rIniName); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx deleted file mode 100644 index 4dd9110a6f0f..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx +++ /dev/null @@ -1,209 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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" -#include "MNSFolders.hxx" -#include "MNSINIParser.hxx" - -namespace connectivity::mozab -{ - ProfileStruct::ProfileStruct() - { - } - - ProfileStruct::ProfileStruct(const OUString& aProfileName, - const OUString& aProfilePath) - : profileName(aProfileName) - , profilePath(aProfilePath) - { - } - - const OUString& ProfileStruct::getProfilePath() const - { - return profilePath; - } - - ProfileAccess::~ProfileAccess() - { - } - - ProfileAccess::ProfileAccess() - { - LoadProductsInfo(); - } - - void ProfileAccess::LoadProductsInfo() - { - //tdf#39279: LO should search Thunderbird first then Seamonkey and finally Firefox - //load thunderbird profiles to m_ProductProfileList - LoadXPToolkitProfiles(MozillaProductType_Thunderbird); - - //load SeaMonkey 2 profiles to m_ProductProfileList - LoadXPToolkitProfiles(MozillaProductType_Mozilla); - - //load firefox profiles to m_ProductProfileList - //firefox profile does not contain address book, but maybe others need them - LoadXPToolkitProfiles(MozillaProductType_Firefox); - } - //Thunderbird and firefox profiles are saved in profiles.ini - void ProfileAccess::LoadXPToolkitProfiles(MozillaProductType product) - { - sal_Int32 index=static_cast<sal_Int32>(product); - ProductStruct &rProduct = m_ProductProfileList[index]; - - OUString regDir = getRegistryDir(product); - OUString profilesIni = regDir + "profiles.ini"; - IniParser parser( profilesIni ); - IniSectionMap &rAllSection = parser.getAllSection(); - - for(auto& rSection : rAllSection) - { - ini_Section *aSection = &rSection.second; - OUString profileName; - OUString profilePath; - OUString sIsRelative; - OUString sIsDefault; - - for(auto& rValue : aSection->vVector) - { - struct ini_NameValue * aValue = &rValue; - 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(); - } - - OUString fullProfilePath; - if(isRelative) - { - fullProfilePath = regDir + profilePath; - } - else - { - fullProfilePath = profilePath; - } - - rProduct.mProfileList[profileName] = ProfileStruct(profileName,fullProfilePath); - - sal_Int32 isDefault = 0; - if (!sIsDefault.isEmpty()) - { - isDefault = sIsDefault.toInt32(); - } - if (isDefault) - rProduct.mCurrentProfileName = profileName; - - } - - // Depending on TB versions, some generate "default" profile - // others "default-release" profile - // See https://support.mozilla.org/gl/questions/1264072 - // for some background info (the link quotes Firefox but it seems - // the same for TB). - if (profileName == "default-release") - { - rProduct.mCurrentProfileName = profileName; - break; - } - } - } - - OUString ProfileAccess::getProfilePath( css::mozilla::MozillaProductType product, const OUString& profileName ) - { - sal_Int32 index=static_cast<sal_Int32>(product); - ProductStruct &rProduct = m_ProductProfileList[index]; - if (rProduct.mProfileList.empty() || rProduct.mProfileList.find(profileName) == rProduct.mProfileList.end()) - { - //Profile not found - return OUString(); - } - else - return rProduct.mProfileList[profileName].getProfilePath(); - } - - ::sal_Int32 ProfileAccess::getProfileCount( css::mozilla::MozillaProductType product) - { - sal_Int32 index=static_cast<sal_Int32>(product); - ProductStruct &rProduct = m_ProductProfileList[index]; - return static_cast< ::sal_Int32 >(rProduct.mProfileList.size()); - } - ::sal_Int32 ProfileAccess::getProfileList( css::mozilla::MozillaProductType product, css::uno::Sequence< OUString >& list ) - { - sal_Int32 index=static_cast<sal_Int32>(product); - ProductStruct &rProduct = m_ProductProfileList[index]; - list.realloc(static_cast<sal_Int32>(rProduct.mProfileList.size())); - sal_Int32 i=0; - for(const auto& rEntry : rProduct.mProfileList) - { - const ProfileStruct& rProfile = rEntry.second; - list[i] = rProfile.getProfileName(); - i++; - } - - return static_cast< ::sal_Int32 >(rProduct.mProfileList.size()); - } - - OUString ProfileAccess::getDefaultProfile( css::mozilla::MozillaProductType product ) - { - sal_Int32 index=static_cast<sal_Int32>(product); - ProductStruct &rProduct = m_ProductProfileList[index]; - if (!rProduct.mCurrentProfileName.isEmpty()) - { - //default profile set in mozilla registry - return rProduct.mCurrentProfileName; - } - if (rProduct.mProfileList.empty()) - { - //there are not any profiles - return OUString(); - } - const ProfileStruct& rProfile = (*rProduct.mProfileList.begin()).second; - return rProfile.getProfileName(); - } - - bool ProfileAccess::getProfileExists( css::mozilla::MozillaProductType product, const OUString& profileName ) - { - sal_Int32 index=static_cast<sal_Int32>(product); - ProductStruct &rProduct = m_ProductProfileList[index]; - return rProduct.mProfileList.find(profileName) != rProduct.mProfileList.end(); - } -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx deleted file mode 100644 index a5f271183b27..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * 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 . - */ - -#pragma once - -#include <sal/types.h> -#include <com/sun/star/mozilla/MozillaProductType.hpp> -#include <com/sun/star/uno/Sequence.hxx> -#include <rtl/ustring.hxx> - -#include <vector> -#include <map> - -using namespace com::sun::star::mozilla; -namespace connectivity::mozab { class ProfileStruct; } - -typedef std::map<OUString, ::connectivity::mozab::ProfileStruct> ProfileList; -namespace connectivity::mozab - { - class ProfileStruct - { - public: - ProfileStruct(); - ProfileStruct(const OUString& aProfileName, const OUString &aProfilePath); - const OUString& getProfileName() const { return profileName;} - const OUString& getProfilePath() const; - private: - OUString profileName; - OUString profilePath; - }; - - class ProductStruct - { - public: - OUString mCurrentProfileName; - ProfileList mProfileList; - }; - - //Used to query profiles information - class ProfileAccess final - { - public: - ~ProfileAccess(); - ProfileAccess(); - /// @throws css::uno::RuntimeException - OUString getProfilePath( css::mozilla::MozillaProductType product, const OUString& profileName ); - /// @throws css::uno::RuntimeException - ::sal_Int32 getProfileCount( css::mozilla::MozillaProductType product ); - /// @throws css::uno::RuntimeException - ::sal_Int32 getProfileList( css::mozilla::MozillaProductType product, css::uno::Sequence< OUString >& list ); - /// @throws css::uno::RuntimeException - OUString getDefaultProfile( css::mozilla::MozillaProductType product ); - /// @throws css::uno::RuntimeException - bool getProfileExists( css::mozilla::MozillaProductType product, const OUString& profileName ); - private: - ProductStruct m_ProductProfileList[4]; - void LoadProductsInfo(); - void LoadXPToolkitProfiles(MozillaProductType product); - }; - -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mozab/bootstrap/mozbootstrap.component b/connectivity/source/drivers/mozab/bootstrap/mozbootstrap.component deleted file mode 100644 index bfc0afe389ef..000000000000 --- a/connectivity/source/drivers/mozab/bootstrap/mozbootstrap.component +++ /dev/null @@ -1,26 +0,0 @@ -<?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 . - --> - -<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.mozilla.MozillaBootstrap" - constructor="connectivity_moz_MozillaBootstrap_get_implementation" single-instance="true"> - <service name="com.sun.star.mozilla.MozillaBootstrap"/> - </implementation> -</component> diff --git a/extensions/source/abpilot/typeselectionpage.cxx b/extensions/source/abpilot/typeselectionpage.cxx index 3aac37ef7dcb..6b58097ab0b3 100644 --- a/extensions/source/abpilot/typeselectionpage.cxx +++ b/extensions/source/abpilot/typeselectionpage.cxx @@ -51,13 +51,11 @@ namespace abp // // On Linux: // - EVOLUTION, EVOLUTION_GROUPWISE, EVOLUTION_LDAP (if applicable) - // - MORK (via mork driver, which is built unconditionally) // - KAB (if applicable) // - OTHER // // On macOS: // - MACAB (if applicable) - // - MORK (via mork driver, which is built unconditionally) // - OTHER // // On Windows: @@ -113,7 +111,6 @@ namespace abp m_aAllTypes.push_back( ButtonItem( m_xEvolution.get(), AST_EVOLUTION, bHaveEvolution ) ); m_aAllTypes.push_back( ButtonItem( m_xEvolutionGroupwise.get(), AST_EVOLUTION_GROUPWISE, bHaveEvolution ) ); m_aAllTypes.push_back( ButtonItem( m_xEvolutionLdap.get(), AST_EVOLUTION_LDAP, bHaveEvolution ) ); - m_aAllTypes.push_back( ButtonItem( m_xMORK.get(), AST_MORK, true ) ); m_aAllTypes.push_back( ButtonItem( m_xThunderbird.get(), AST_THUNDERBIRD, true ) ); m_aAllTypes.push_back( ButtonItem( m_xKab.get(), AST_KAB, bHaveKab ) ); m_aAllTypes.push_back( ButtonItem( m_xMacab.get(), AST_MACAB, bHaveMacab ) ); diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk index fd0f8d5a7377..7e47c3803492 100644 --- a/postprocess/CustomTarget_registry.mk +++ b/postprocess/CustomTarget_registry.mk @@ -281,12 +281,6 @@ postprocess_FILES_main += \ $(call gb_XcuModuleTarget_get_target,connectivity/registry/odbc)/org/openoffice/Office/DataAccess/Drivers-odbc.xcu \ $(call gb_XcuModuleTarget_get_target,connectivity/registry/mysql_jdbc)/org/openoffice/Office/DataAccess/Drivers-mysql_jdbc.xcu postprocess_DRIVERS += dbase flat odbc mysql_jdbc -ifeq (DBCONNECTIVITY,$(filter DBCONNECTIVITY,$(BUILD_TYPE))) -ifneq (,$(filter DESKTOP,$(BUILD_TYPE))) -postprocess_FILES_main += $(call gb_XcuModuleTarget_get_target,connectivity/registry/mork)/org/openoffice/Office/DataAccess/Drivers-mork.xcu -postprocess_DRIVERS += mork -endif -endif endif ifeq (MACOSX,$(OS)) postprocess_FILES_main += \ diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk index d4d295ad2c2f..547f2b30d03f 100644 --- a/postprocess/Rdb_services.mk +++ b/postprocess/Rdb_services.mk @@ -276,13 +276,6 @@ $(eval $(call gb_Rdb_add_components,services,\ ) \ )) -ifneq (,$(filter DESKTOP,$(BUILD_TYPE))) -$(eval $(call gb_Rdb_add_components,services,\ - connectivity/source/drivers/mork/mork \ - connectivity/source/drivers/mozab/bootstrap/mozbootstrap \ -)) -endif # DESKTOP - endif # DBCONNECTIVITY ifeq (DESKTOP,$(filter DESKTOP,$(BUILD_TYPE))) diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index aae526e5dbe8..db388fdefd77 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -1724,7 +1724,6 @@ connectivity/inc/sdbcx/VUser.hxx connectivity/inc/strings.hxx connectivity/qa/connectivity/ado/DriverTest.cxx connectivity/qa/connectivity/commontools/FValue_test.cxx -connectivity/qa/connectivity/mork/DriverTest.cxx connectivity/source/commontools/AutoRetrievingBase.cxx connectivity/source/commontools/BlobHelper.cxx connectivity/source/commontools/CommonTools.cxx @@ -1990,44 +1989,6 @@ connectivity/source/drivers/macab/macabcondition.hxx connectivity/source/drivers/macab/macaborder.cxx connectivity/source/drivers/macab/macaborder.hxx connectivity/source/drivers/macab/macabutilities.hxx -connectivity/source/drivers/mork/MCatalog.cxx -connectivity/source/drivers/mork/MCatalog.hxx -connectivity/source/drivers/mork/MColumnAlias.cxx -connectivity/source/drivers/mork/MColumnAlias.hxx -connectivity/source/drivers/mork/MColumns.cxx -connectivity/source/drivers/mork/MColumns.hxx -connectivity/source/drivers/mork/MConnection.cxx -connectivity/source/drivers/mork/MConnection.hxx -connectivity/source/drivers/mork/MDatabaseMetaData.cxx -connectivity/source/drivers/mork/MDatabaseMetaData.hxx -connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx -connectivity/source/drivers/mork/MDatabaseMetaDataHelper.hxx -connectivity/source/drivers/mork/MDriver.cxx -connectivity/source/drivers/mork/MDriver.hxx -connectivity/source/drivers/mork/MErrorResource.hxx -connectivity/source/drivers/mork/MPreparedStatement.cxx -connectivity/source/drivers/mork/MPreparedStatement.hxx -connectivity/source/drivers/mork/MQueryHelper.cxx -connectivity/source/drivers/mork/MQueryHelper.hxx -connectivity/source/drivers/mork/MResultSet.cxx -connectivity/source/drivers/mork/MResultSet.hxx -connectivity/source/drivers/mork/MResultSetMetaData.cxx -connectivity/source/drivers/mork/MResultSetMetaData.hxx -connectivity/source/drivers/mork/MStatement.cxx -connectivity/source/drivers/mork/MStatement.hxx -connectivity/source/drivers/mork/MTable.cxx -connectivity/source/drivers/mork/MTable.hxx -connectivity/source/drivers/mork/MTables.hxx -connectivity/source/drivers/mork/MorkParser.cxx -connectivity/source/drivers/mork/MorkParser.hxx -connectivity/source/drivers/mork/mork_helper.cxx -connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx -connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx -connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx -connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx -connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx -connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx -connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx connectivity/source/drivers/odbc/OConnection.cxx connectivity/source/drivers/odbc/ODatabaseMetaData.cxx connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx |