diff options
Diffstat (limited to 'connectivity/source/drivers/macab')
33 files changed, 292 insertions, 288 deletions
diff --git a/connectivity/source/drivers/macab/MacabAddressBook.cxx b/connectivity/source/drivers/macab/MacabAddressBook.cxx index a14b7abee9b9..7ade1ac0a830 100644 --- a/connectivity/source/drivers/macab/MacabAddressBook.cxx +++ b/connectivity/source/drivers/macab/MacabAddressBook.cxx @@ -82,6 +82,13 @@ MacabAddressBook::MacabAddressBook( ) m_xMacabRecords(nullptr), m_bRetrievedGroups(false) { + if(m_aAddressBook == nullptr) + { + // TODO: tell the user to reset the permission via "tccutil reset AddressBook" + // or the system preferences and try again, this time granting the access + throw RuntimeException( + "failed to access the macOS address book - permission not granted?" ); + } } @@ -106,8 +113,8 @@ MacabAddressBook::~MacabAddressBook() const OUString & MacabAddressBook::getDefaultTableName() { /* This string probably needs to be localized. */ - static const OUString aDefaultTableName - (OUString("Address Book")); + static constexpr OUString aDefaultTableName + (u"Address Book"_ustr); return aDefaultTableName; } diff --git a/connectivity/source/drivers/macab/MacabAddressBook.hxx b/connectivity/source/drivers/macab/MacabAddressBook.hxx index 23fec939f701..a23e0c1eb2e7 100644 --- a/connectivity/source/drivers/macab/MacabAddressBook.hxx +++ b/connectivity/source/drivers/macab/MacabAddressBook.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABADDRESSBOOK_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABADDRESSBOOK_HXX +#pragma once #include "MacabRecords.hxx" #include "MacabGroup.hxx" @@ -58,6 +57,4 @@ namespace connectivity::macab } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABADDRESSBOOK_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabCatalog.cxx b/connectivity/source/drivers/macab/MacabCatalog.cxx index 96ff62fd5b6a..d6485ab1c971 100644 --- a/connectivity/source/drivers/macab/MacabCatalog.cxx +++ b/connectivity/source/drivers/macab/MacabCatalog.cxx @@ -80,7 +80,7 @@ void MacabCatalog::refreshUsers() const OUString& MacabCatalog::getDot() { - static const OUString sDot = "."; + static constexpr OUString sDot = u"."_ustr; return sDot; } diff --git a/connectivity/source/drivers/macab/MacabCatalog.hxx b/connectivity/source/drivers/macab/MacabCatalog.hxx index 88aad76bede3..1757bb908851 100644 --- a/connectivity/source/drivers/macab/MacabCatalog.hxx +++ b/connectivity/source/drivers/macab/MacabCatalog.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABCATALOG_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABCATALOG_HXX +#pragma once #include <sdbcx/VCatalog.hxx> @@ -49,6 +48,4 @@ namespace connectivity::macab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABCATALOG_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabColumns.cxx b/connectivity/source/drivers/macab/MacabColumns.cxx index 6eaa51aa7906..6a49ad1d066c 100644 --- a/connectivity/source/drivers/macab/MacabColumns.cxx +++ b/connectivity/source/drivers/macab/MacabColumns.cxx @@ -54,7 +54,7 @@ sdbcx::ObjectType MacabColumns::createObject(const OUString& _rName) { if (xRow->getString(4) == _rName) { - OColumn* pRet = new OColumn( + xRet = new OColumn( _rName, xRow->getString(6), xRow->getString(13), @@ -70,7 +70,6 @@ sdbcx::ObjectType MacabColumns::createObject(const OUString& _rName) sCatalogName, sSchemaName, sTableName); - xRet = pRet; break; } } diff --git a/connectivity/source/drivers/macab/MacabColumns.hxx b/connectivity/source/drivers/macab/MacabColumns.hxx index 1a85da155d62..7123af89d30a 100644 --- a/connectivity/source/drivers/macab/MacabColumns.hxx +++ b/connectivity/source/drivers/macab/MacabColumns.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABCOLUMNS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABCOLUMNS_HXX +#pragma once #include "MacabTable.hxx" #include <connectivity/sdbcx/VCollection.hxx> @@ -40,6 +39,4 @@ namespace connectivity::macab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABCOLUMNS_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabConnection.cxx b/connectivity/source/drivers/macab/MacabConnection.cxx index 4e5a27354e54..eaa6cf523222 100644 --- a/connectivity/source/drivers/macab/MacabConnection.cxx +++ b/connectivity/source/drivers/macab/MacabConnection.cxx @@ -27,6 +27,7 @@ #include "MacabCatalog.hxx" #include <com/sun/star/sdbc/ColumnValue.hpp> #include <com/sun/star/sdbc/TransactionIsolation.hpp> +#include <cppuhelper/weak.hxx> using namespace connectivity::macab; using namespace com::sun::star::uno; @@ -295,8 +296,7 @@ Reference< XTablesSupplier > MacabConnection::createCatalog() Reference< XTablesSupplier > xTab = m_xCatalog; if (!m_xCatalog.is()) { - MacabCatalog *pCat = new MacabCatalog(this); - xTab = pCat; + xTab = new MacabCatalog(this); m_xCatalog = xTab; } return xTab; @@ -309,10 +309,8 @@ MacabAddressBook* MacabConnection::getAddressBook() const extern "C" SAL_DLLPUBLIC_EXPORT void* createMacabConnection( void* _pDriver ) { - MacabConnection* pConnection = new MacabConnection( static_cast< MacabDriver* >( _pDriver ) ); // by definition, the pointer crossing library boundaries as void ptr is acquired once - pConnection->acquire(); - return pConnection; + return cppu::acquire(new MacabConnection( static_cast< MacabDriver* >( _pDriver ) )); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabConnection.hxx b/connectivity/source/drivers/macab/MacabConnection.hxx index 73ee0a731a76..dc2bfa34f5fd 100644 --- a/connectivity/source/drivers/macab/MacabConnection.hxx +++ b/connectivity/source/drivers/macab/MacabConnection.hxx @@ -17,13 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABCONNECTION_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABCONNECTION_HXX +#pragma once -#include <map> #include <connectivity/CommonTools.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/sdbc/SQLWarning.hpp> #include <com/sun/star/sdbc/XWarningsSupplier.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdbcx/XTablesSupplier.hpp> @@ -110,6 +107,4 @@ namespace connectivity::macab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABCONNECTION_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabDatabaseMetaData.cxx b/connectivity/source/drivers/macab/MacabDatabaseMetaData.cxx index 540e333aa639..b0b04fc08f21 100644 --- a/connectivity/source/drivers/macab/MacabDatabaseMetaData.cxx +++ b/connectivity/source/drivers/macab/MacabDatabaseMetaData.cxx @@ -30,7 +30,9 @@ #include <com/sun/star/sdbc/ColumnSearch.hpp> #include <com/sun/star/sdbc/ColumnValue.hpp> #include <com/sun/star/sdbc/ResultSetType.hpp> +#include <com/sun/star/sdbc/SQLException.hpp> #include <com/sun/star/sdbc/TransactionIsolation.hpp> +#include <rtl/ref.hxx> #include <vector> @@ -729,15 +731,14 @@ sal_Bool SAL_CALL MacabDatabaseMetaData::supportsBatchUpdates( ) Reference< XConnection > SAL_CALL MacabDatabaseMetaData::getConnection( ) { - return m_xConnection.get(); + return m_xConnection; } Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTableTypes( ) { - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes); - Reference< XResultSet > xRef = pResult; + rtl::Reference<::connectivity::ODatabaseMetaDataResultSet> pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes); - static ODatabaseMetaDataResultSet::ORows aRows = [&] + static ODatabaseMetaDataResultSet::ORows aRows = [] { static constexpr OUStringLiteral aTable = u"TABLE"; ODatabaseMetaDataResultSet::ORows tmp; @@ -747,16 +748,15 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTableTypes( ) tmp.push_back(aRow); return tmp; }(); - pResult->setRows(aRows); - return xRef; + pResult->setRows(std::vector(aRows)); + return pResult; } Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTypeInfo( ) { - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo); - Reference< XResultSet > xRef = pResult; + rtl::Reference<ODatabaseMetaDataResultSet> pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo); - static ODatabaseMetaDataResultSet::ORows aRows = [&]() + static ODatabaseMetaDataResultSet::ORows aRows = []() { ODatabaseMetaDataResultSet::ORows tmp; ODatabaseMetaDataResultSet::ORow aRow(19); @@ -805,8 +805,8 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTypeInfo( ) return tmp; }(); - pResult->setRows(aRows); - return xRef; + pResult->setRows(std::vector(aRows)); + return pResult; } Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getCatalogs( ) @@ -832,8 +832,7 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getColumns( const OUString& tableNamePattern, const OUString& columnNamePattern) { - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns); - Reference< XResultSet > xRef = pResult; + rtl::Reference<::connectivity::ODatabaseMetaDataResultSet> pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns); MacabRecords *aRecords; OUString sTableName; @@ -909,8 +908,8 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getColumns( } } } - pResult->setRows(aRows); - return xRef; + pResult->setRows(std::move(aRows)); + return pResult; } Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTables( @@ -919,13 +918,12 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTables( const OUString&, const Sequence< OUString >& types) { - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables); - Reference< XResultSet > xRef = pResult; + rtl::Reference<ODatabaseMetaDataResultSet> pResult = new ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables); // check whether we have tables in the requested types // for the moment, we answer only the "TABLE" table type // when no types are given at all, we return all the tables - static constexpr OUStringLiteral aTable = u"TABLE"; + static constexpr OUString aTable = u"TABLE"_ustr; bool bTableFound = false; const OUString* p = types.getConstArray(), * pEnd = p + types.getLength(); @@ -944,7 +942,7 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTables( p++; } if (!bTableFound) - return xRef; + return pResult; static ODatabaseMetaDataResultSet::ORows aRows = [&]() { @@ -960,7 +958,7 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTables( aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue(); aRow[2] = ODatabaseMetaDataResultSet::getEmptyValue(); aRow[3] = new ORowSetValueDecorator(xRecords->getName()); - aRow[4] = new ORowSetValueDecorator(OUString(aTable)); + aRow[4] = new ORowSetValueDecorator(aTable); aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue(); tmp.push_back(aRow); @@ -971,8 +969,8 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTables( } return tmp; }(); - pResult->setRows(aRows); - return xRef; + pResult->setRows(std::vector(aRows)); + return pResult; } Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getProcedureColumns( @@ -992,8 +990,7 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getProcedures( Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getVersionColumns( const Any&, const OUString&, const OUString& table ) { - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns); - Reference< XResultSet > xRef = pResult; + rtl::Reference<::connectivity::ODatabaseMetaDataResultSet> pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns); ODatabaseMetaDataResultSet::ORows aRows; @@ -1016,8 +1013,8 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getVersionColumns( aRows.push_back(aRow); } - pResult->setRows(aRows); - return xRef; + pResult->setRows(std::move(aRows)); + return pResult; } Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getExportedKeys( diff --git a/connectivity/source/drivers/macab/MacabDatabaseMetaData.hxx b/connectivity/source/drivers/macab/MacabDatabaseMetaData.hxx index 46cb6769bf0e..662be1c018ce 100644 --- a/connectivity/source/drivers/macab/MacabDatabaseMetaData.hxx +++ b/connectivity/source/drivers/macab/MacabDatabaseMetaData.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABDATABASEMETADATA_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABDATABASEMETADATA_HXX +#pragma once #include "MacabConnection.hxx" #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> @@ -193,6 +192,4 @@ namespace connectivity::macab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABDATABASEMETADATA_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabDriver.cxx b/connectivity/source/drivers/macab/MacabDriver.cxx index 4667c690a8b1..9c68e48f12a7 100644 --- a/connectivity/source/drivers/macab/MacabDriver.cxx +++ b/connectivity/source/drivers/macab/MacabDriver.cxx @@ -25,7 +25,7 @@ #include <com/sun/star/lang/NullPointerException.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <sal/log.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <strings.hrc> #include <cppuhelper/supportsservice.hxx> @@ -115,7 +115,7 @@ bool MacabImplModule::impl_loadModule() OSL_ENSURE( !m_hConnectorModule && !m_pConnectionFactoryFunc, "MacabImplModule::impl_loadModule: inconsistence: inconsistency (never attempted load before, but some values already set)!"); - const OUString sModuleName( SAL_MODULENAME( "macabdrv1" ) ); + constexpr OUString sModuleName( u"" SAL_MODULENAME( "macabdrv1" ) ""_ustr ); m_hConnectorModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, SAL_LOADMODULE_NOW ); // LAZY! #i61335# OSL_ENSURE( m_hConnectorModule, "MacabImplModule::impl_loadModule: could not load the implementation library!" ); if ( !m_hConnectorModule ) diff --git a/connectivity/source/drivers/macab/MacabDriver.hxx b/connectivity/source/drivers/macab/MacabDriver.hxx index ca7707228164..d18f5e9827f4 100644 --- a/connectivity/source/drivers/macab/MacabDriver.hxx +++ b/connectivity/source/drivers/macab/MacabDriver.hxx @@ -17,12 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABDRIVER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABDRIVER_HXX +#pragma once #include <com/sun/star/sdbc/XDriver.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/frame/XTerminateListener.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/compbase.hxx> @@ -160,6 +158,4 @@ namespace connectivity::macab } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABDRIVER_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabGroup.hxx b/connectivity/source/drivers/macab/MacabGroup.hxx index 65240661b138..ddcd47b46423 100644 --- a/connectivity/source/drivers/macab/MacabGroup.hxx +++ b/connectivity/source/drivers/macab/MacabGroup.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABGROUP_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABGROUP_HXX +#pragma once #include "MacabRecords.hxx" @@ -36,6 +35,4 @@ namespace connectivity::macab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABGROUP_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabHeader.cxx b/connectivity/source/drivers/macab/MacabHeader.cxx index 46f0c177d3fc..da270dd05ac8 100644 --- a/connectivity/source/drivers/macab/MacabHeader.cxx +++ b/connectivity/source/drivers/macab/MacabHeader.cxx @@ -290,10 +290,6 @@ MacabHeader::iterator::iterator () } -MacabHeader::iterator::~iterator () -{ -} - MacabHeader::iterator& MacabHeader::iterator::operator= (MacabHeader *_record) { id = 0; diff --git a/connectivity/source/drivers/macab/MacabHeader.hxx b/connectivity/source/drivers/macab/MacabHeader.hxx index 839a755fb6f1..24b3fc7b0b9c 100644 --- a/connectivity/source/drivers/macab/MacabHeader.hxx +++ b/connectivity/source/drivers/macab/MacabHeader.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABHEADER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABHEADER_HXX +#pragma once #include <sal/config.h> @@ -51,7 +50,6 @@ namespace connectivity::macab public: iterator& operator= (MacabHeader *_record); iterator(); - ~iterator(); void operator++ (); bool operator!= (const sal_Int32 i) const; bool operator== (const sal_Int32 i) const; @@ -60,6 +58,4 @@ namespace connectivity::macab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABHEADER_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabPreparedStatement.cxx b/connectivity/source/drivers/macab/MacabPreparedStatement.cxx index cbb3dc75608c..6d72345b6021 100644 --- a/connectivity/source/drivers/macab/MacabPreparedStatement.cxx +++ b/connectivity/source/drivers/macab/MacabPreparedStatement.cxx @@ -78,7 +78,7 @@ void MacabPreparedStatement::getNextParameter(OUString &rParameter) const ::dbtools::throwGenericSQLException(sError,*const_cast<MacabPreparedStatement *>(this)); } - rParameter = (*m_aParameterRow)[m_nParameterIndex]; + rParameter = (*m_aParameterRow)[m_nParameterIndex].getString(); m_nParameterIndex++; } @@ -131,7 +131,7 @@ Reference< XResultSetMetaData > SAL_CALL MacabPreparedStatement::getMetaData() m_xMetaData = new MacabResultSetMetaData(getOwnConnection(),sTableName); setMacabFields(); } - Reference< XResultSetMetaData > xMetaData = m_xMetaData.get(); + Reference< XResultSetMetaData > xMetaData = m_xMetaData; return xMetaData; } diff --git a/connectivity/source/drivers/macab/MacabPreparedStatement.hxx b/connectivity/source/drivers/macab/MacabPreparedStatement.hxx index 42c401efb1dd..6e649bf647f3 100644 --- a/connectivity/source/drivers/macab/MacabPreparedStatement.hxx +++ b/connectivity/source/drivers/macab/MacabPreparedStatement.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABPREPAREDSTATEMENT_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABPREPAREDSTATEMENT_HXX +#pragma once #include "MacabStatement.hxx" #include "MacabResultSetMetaData.hxx" @@ -109,6 +108,4 @@ namespace connectivity::macab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABPREPAREDSTATEMENT_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabRecord.hxx b/connectivity/source/drivers/macab/MacabRecord.hxx index 3183ec9109e1..5184eefc8ab4 100644 --- a/connectivity/source/drivers/macab/MacabRecord.hxx +++ b/connectivity/source/drivers/macab/MacabRecord.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABRECORD_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABRECORD_HXX +#pragma once #include <sal/config.h> @@ -69,6 +68,4 @@ namespace connectivity::macab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABRECORD_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabRecords.cxx b/connectivity/source/drivers/macab/MacabRecords.cxx index 737cdee7d6f8..07d462425e65 100644 --- a/connectivity/source/drivers/macab/MacabRecords.cxx +++ b/connectivity/source/drivers/macab/MacabRecords.cxx @@ -344,7 +344,7 @@ MacabHeader *MacabRecords::createHeaderForRecordType(const CFArrayRef _records, /* While searching through the properties for required properties, these * sal_Bools will keep track of what we have found. */ - bool bFoundRequiredProperties[requiredProperties.size()]; + auto const bFoundRequiredProperties = std::make_unique<bool[]>(requiredProperties.size()); /* We have three MacabHeaders: headerDataForProperty is where we @@ -530,34 +530,34 @@ MacabHeader *MacabRecords::createHeaderForProperty(const ABPropertyType _propert */ if(_propertyValue != nullptr) { - sal_Int32 i; + sal_Int32 i; - sal_Int32 multiLength = ABMultiValueCount(static_cast<ABMutableMultiValueRef>(const_cast<void *>(_propertyValue))); - CFStringRef multiLabel, localizedMultiLabel; - OUString multiLabelString; - OUString multiPropertyString; - OUString headerNameString; - ABPropertyType multiType = static_cast<ABPropertyType>(ABMultiValuePropertyType(static_cast<ABMutableMultiValueRef>(const_cast<void *>(_propertyValue))) - 0x100); + sal_Int32 multiLength = ABMultiValueCount(static_cast<ABMutableMultiValueRef>(const_cast<void *>(_propertyValue))); + CFStringRef multiLabel, localizedMultiLabel; + OUString multiLabelString; + OUString multiPropertyString; + OUString headerNameString; + ABPropertyType multiType = static_cast<ABPropertyType>(ABMultiValuePropertyType(static_cast<ABMutableMultiValueRef>(const_cast<void *>(_propertyValue))) - 0x100); - length = multiLength; - headerNames = new macabfield *[multiLength]; - multiPropertyString = CFStringToOUString(_propertyName); + length = multiLength; + headerNames = new macabfield *[multiLength]; + multiPropertyString = CFStringToOUString(_propertyName); - /* Go through each element, and - since each element is a scalar - - * just create a new macabfield for it. - */ - for(i = 0; i < multiLength; i++) - { - multiLabel = ABMultiValueCopyLabelAtIndex(static_cast<ABMutableMultiValueRef>(const_cast<void *>(_propertyValue)), i); - localizedMultiLabel = ABCopyLocalizedPropertyOrLabel(multiLabel); - multiLabelString = CFStringToOUString(localizedMultiLabel); - CFRelease(multiLabel); - CFRelease(localizedMultiLabel); - headerNameString = multiPropertyString + ": " + fixLabel(multiLabelString); - headerNames[i] = new macabfield; - headerNames[i]->value = OUStringToCFString(headerNameString); - headerNames[i]->type = multiType; - } + /* Go through each element, and - since each element is a scalar - + * just create a new macabfield for it. + */ + for(i = 0; i < multiLength; i++) + { + multiLabel = ABMultiValueCopyLabelAtIndex(static_cast<ABMutableMultiValueRef>(const_cast<void *>(_propertyValue)), i); + localizedMultiLabel = ABCopyLocalizedPropertyOrLabel(multiLabel); + multiLabelString = CFStringToOUString(localizedMultiLabel); + CFRelease(multiLabel); + CFRelease(localizedMultiLabel); + headerNameString = multiPropertyString + ": " + fixLabel(multiLabelString); + headerNames[i] = new macabfield; + headerNames[i]->value = OUStringToCFString(headerNameString); + headerNames[i]->type = multiType; + } } break; @@ -653,77 +653,77 @@ MacabHeader *MacabRecords::createHeaderForProperty(const ABPropertyType _propert */ if(_propertyValue != nullptr) { - /* Assume all keys are strings */ - sal_Int32 numRecords = static_cast<sal_Int32>(CFDictionaryGetCount(static_cast<CFDictionaryRef>(_propertyValue))); + /* Assume all keys are strings */ + sal_Int32 numRecords = static_cast<sal_Int32>(CFDictionaryGetCount(static_cast<CFDictionaryRef>(_propertyValue))); - /* The only method for getting info out of a CFDictionary, of both - * keys and values, is to all of them all at once, so these - * variables will hold them. - */ - CFStringRef *dictKeys; - CFTypeRef *dictValues; - - sal_Int32 i,j,k; - OUString dictKeyString, propertyNameString; - ABPropertyType dictType; - MacabHeader **dictHeaders = new MacabHeader *[numRecords]; - OUString dictLabelString; - CFStringRef dictLabel, localizedDictKey; - - /* Get the keys and values */ - dictKeys = static_cast<CFStringRef *>(malloc(sizeof(CFStringRef)*numRecords)); - dictValues = static_cast<CFTypeRef *>(malloc(sizeof(CFTypeRef)*numRecords)); - CFDictionaryGetKeysAndValues(static_cast<CFDictionaryRef>(_propertyValue), reinterpret_cast<const void **>(dictKeys), dictValues); - - propertyNameString = CFStringToOUString(_propertyName); - - length = 0; - /* Go through each element - assuming that the key is a string but - * that the value could be anything. Since the value could be - * anything, we can't assume that it is scalar (it could even be - * another dictionary), so we attempt to get its type using - * the method getABTypeFromCFType and then run this method - * recursively on that element, storing the MacabHeader that - * results. Then, we just combine all of the MacabHeaders into - * one. - */ - for(i = 0; i < numRecords; i++) - { - dictType = getABTypeFromCFType( CFGetTypeID(dictValues[i]) ); - localizedDictKey = ABCopyLocalizedPropertyOrLabel(dictKeys[i]); - dictKeyString = CFStringToOUString(localizedDictKey); - dictLabelString = propertyNameString + ": " + fixLabel(dictKeyString); - dictLabel = OUStringToCFString(dictLabelString); - dictHeaders[i] = createHeaderForProperty(dictType, dictValues[i], dictLabel); - if (!dictHeaders[i]) - dictHeaders[i] = new MacabHeader(); - length += dictHeaders[i]->getSize(); - CFRelease(dictLabel); - CFRelease(localizedDictKey); - } + /* The only method for getting info out of a CFDictionary, of both + * keys and values, is to all of them all at once, so these + * variables will hold them. + */ + CFStringRef *dictKeys; + CFTypeRef *dictValues; - /* Combine all of the macabfields in each MacabHeader into the - * headerNames array, which (at the end of this method) is used - * to create the MacabHeader that is returned. - */ - headerNames = new macabfield *[length]; - for(i = 0, j = 0, k = 0; i < length; i++,k++) - { - while(dictHeaders[j]->getSize() == k) + sal_Int32 i,j,k; + OUString dictKeyString, propertyNameString; + ABPropertyType dictType; + MacabHeader **dictHeaders = new MacabHeader *[numRecords]; + OUString dictLabelString; + CFStringRef dictLabel, localizedDictKey; + + /* Get the keys and values */ + dictKeys = static_cast<CFStringRef *>(malloc(sizeof(CFStringRef)*numRecords)); + dictValues = static_cast<CFTypeRef *>(malloc(sizeof(CFTypeRef)*numRecords)); + CFDictionaryGetKeysAndValues(static_cast<CFDictionaryRef>(_propertyValue), reinterpret_cast<const void **>(dictKeys), dictValues); + + propertyNameString = CFStringToOUString(_propertyName); + + length = 0; + /* Go through each element - assuming that the key is a string but + * that the value could be anything. Since the value could be + * anything, we can't assume that it is scalar (it could even be + * another dictionary), so we attempt to get its type using + * the method getABTypeFromCFType and then run this method + * recursively on that element, storing the MacabHeader that + * results. Then, we just combine all of the MacabHeaders into + * one. + */ + for(i = 0; i < numRecords; i++) { - j++; - k = 0; + dictType = getABTypeFromCFType( CFGetTypeID(dictValues[i]) ); + localizedDictKey = ABCopyLocalizedPropertyOrLabel(dictKeys[i]); + dictKeyString = CFStringToOUString(localizedDictKey); + dictLabelString = propertyNameString + ": " + fixLabel(dictKeyString); + dictLabel = OUStringToCFString(dictLabelString); + dictHeaders[i] = createHeaderForProperty(dictType, dictValues[i], dictLabel); + if (!dictHeaders[i]) + dictHeaders[i] = new MacabHeader(); + length += dictHeaders[i]->getSize(); + CFRelease(dictLabel); + CFRelease(localizedDictKey); } - headerNames[i] = dictHeaders[j]->copy(k); - } + /* Combine all of the macabfields in each MacabHeader into the + * headerNames array, which (at the end of this method) is used + * to create the MacabHeader that is returned. + */ + headerNames = new macabfield *[length]; + for(i = 0, j = 0, k = 0; i < length; i++,k++) + { + while(dictHeaders[j]->getSize() == k) + { + j++; + k = 0; + } - for(i = 0; i < numRecords; i++) - delete dictHeaders[i]; + headerNames[i] = dictHeaders[j]->copy(k); + } - delete [] dictHeaders; - free(dictKeys); - free(dictValues); + for(i = 0; i < numRecords; i++) + delete dictHeaders[i]; + + delete [] dictHeaders; + free(dictKeys); + free(dictValues); } break; @@ -1099,11 +1099,6 @@ MacabRecords::iterator::iterator () } -MacabRecords::iterator::~iterator () -{ -} - - MacabRecords::iterator& MacabRecords::iterator::operator= (MacabRecords *_records) { id = 0; diff --git a/connectivity/source/drivers/macab/MacabRecords.hxx b/connectivity/source/drivers/macab/MacabRecords.hxx index 7e7da60a5486..8d0d5cf6f796 100644 --- a/connectivity/source/drivers/macab/MacabRecords.hxx +++ b/connectivity/source/drivers/macab/MacabRecords.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABRECORDS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABRECORDS_HXX +#pragma once #include <sal/config.h> @@ -114,7 +113,6 @@ namespace connectivity::macab sal_Int32 id; iterator& operator= (MacabRecords *_records); iterator(); - ~iterator(); void operator++ (); bool operator!= (const sal_Int32 i) const; bool operator== (const sal_Int32 i) const; @@ -124,6 +122,4 @@ namespace connectivity::macab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABRECORDS_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabResultSet.cxx b/connectivity/source/drivers/macab/MacabResultSet.cxx index da2d2dafd3ed..4142fcb6cce0 100644 --- a/connectivity/source/drivers/macab/MacabResultSet.cxx +++ b/connectivity/source/drivers/macab/MacabResultSet.cxx @@ -33,6 +33,7 @@ #include <comphelper/types.hxx> #include <connectivity/dbexception.hxx> #include <resource/sharedresources.hxx> +#include <rtl/ref.hxx> #include <strings.hrc> using namespace connectivity::macab; @@ -64,14 +65,14 @@ MacabResultSet::~MacabResultSet() void MacabResultSet::allMacabRecords() { - MacabConnection* pConnection = static_cast< MacabConnection *>(m_xStatement->getConnection().get()); + rtl::Reference<MacabConnection> pConnection = static_cast< MacabConnection *>(m_xStatement->getConnection().get()); m_aMacabRecords = pConnection->getAddressBook()->getMacabRecords(m_sTableName); } void MacabResultSet::someMacabRecords(const MacabCondition *pCondition) { - MacabConnection* pConnection = static_cast< MacabConnection *>(m_xStatement->getConnection().get()); + rtl::Reference<MacabConnection> pConnection = static_cast< MacabConnection *>(m_xStatement->getConnection().get()); MacabRecords* allRecords; allRecords = pConnection->getAddressBook()->getMacabRecords(m_sTableName); @@ -156,12 +157,12 @@ Any SAL_CALL MacabResultSet::queryInterface(const Type & rType) return aRet; } -void SAL_CALL MacabResultSet::acquire() throw() +void SAL_CALL MacabResultSet::acquire() noexcept { MacabResultSet_BASE::acquire(); } -void SAL_CALL MacabResultSet::release() throw() +void SAL_CALL MacabResultSet::release() noexcept { MacabResultSet_BASE::release(); } @@ -513,7 +514,7 @@ Reference< XResultSetMetaData > SAL_CALL MacabResultSet::getMetaData() if (!m_xMetaData.is()) m_xMetaData = new MacabResultSetMetaData(m_xStatement->getOwnConnection(), m_sTableName); - Reference< XResultSetMetaData > xMetaData = m_xMetaData.get(); + Reference< XResultSetMetaData > xMetaData = m_xMetaData; return xMetaData; } @@ -668,7 +669,7 @@ Reference< XInterface > SAL_CALL MacabResultSet::getStatement() ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed); - Reference< XStatement > xStatement = m_xStatement.get(); + Reference< XStatement > xStatement = m_xStatement; return xStatement; } @@ -884,7 +885,7 @@ Any SAL_CALL MacabResultSet::getBookmark() { if(uidField->type == kABStringProperty) { - return makeAny(CFStringToOUString( static_cast<CFStringRef>(uidField->value) )); + return Any(CFStringToOUString( static_cast<CFStringRef>(uidField->value) )); } } } @@ -980,28 +981,47 @@ Sequence< sal_Int32 > SAL_CALL MacabResultSet::deleteRows(const Sequence< Any IPropertyArrayHelper* MacabResultSet::createArrayHelper() const { - Sequence< Property > aProps(6); - 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(), PropertyAttribute::READONLY); - - 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); + return new OPropertyArrayHelper + { + { + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME), + PROPERTY_ID_CURSORNAME, + cppu::UnoType<OUString>::get(), + PropertyAttribute::READONLY + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), + PROPERTY_ID_FETCHDIRECTION, + cppu::UnoType<sal_Int32>::get(), + 0 + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), + PROPERTY_ID_FETCHSIZE, + cppu::UnoType<sal_Int32>::get(), + 0 + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), + PROPERTY_ID_ISBOOKMARKABLE, + cppu::UnoType<bool>::get(), + PropertyAttribute::READONLY + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), + PROPERTY_ID_RESULTSETCONCURRENCY, + cppu::UnoType<sal_Int32>::get(), + PropertyAttribute::READONLY + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), + PROPERTY_ID_RESULTSETTYPE, + cppu::UnoType<sal_Int32>::get(), + PropertyAttribute::READONLY + } + } + }; } IPropertyArrayHelper & MacabResultSet::getInfoHelper() diff --git a/connectivity/source/drivers/macab/MacabResultSet.hxx b/connectivity/source/drivers/macab/MacabResultSet.hxx index d0d8061f417c..306ef562d3b4 100644 --- a/connectivity/source/drivers/macab/MacabResultSet.hxx +++ b/connectivity/source/drivers/macab/MacabResultSet.hxx @@ -104,8 +104,8 @@ namespace connectivity::macab // 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; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; // XTypeProvider virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; diff --git a/connectivity/source/drivers/macab/MacabResultSetMetaData.cxx b/connectivity/source/drivers/macab/MacabResultSetMetaData.cxx index d0ed7298f92b..e08d92cfceb6 100644 --- a/connectivity/source/drivers/macab/MacabResultSetMetaData.cxx +++ b/connectivity/source/drivers/macab/MacabResultSetMetaData.cxx @@ -23,6 +23,7 @@ #include "MacabRecords.hxx" #include "MacabAddressBook.hxx" #include "macabutilities.hxx" +#include <connectivity/dbexception.hxx> #include <strings.hrc> using namespace connectivity::macab; diff --git a/connectivity/source/drivers/macab/MacabResultSetMetaData.hxx b/connectivity/source/drivers/macab/MacabResultSetMetaData.hxx index 6db5f240ac24..b82088154cb9 100644 --- a/connectivity/source/drivers/macab/MacabResultSetMetaData.hxx +++ b/connectivity/source/drivers/macab/MacabResultSetMetaData.hxx @@ -23,7 +23,6 @@ #include <connectivity/CommonTools.hxx> #include <com/sun/star/sdbc/XResultSetMetaData.hpp> #include <cppuhelper/implbase.hxx> -#include <connectivity/dbexception.hxx> #include <rtl/ref.hxx> namespace connectivity::macab @@ -45,7 +44,7 @@ namespace connectivity::macab MacabResultSetMetaData(MacabConnection* _pConnection, OUString const & _sTableName); // avoid ambiguous cast error from the compiler - operator css::uno::Reference< css::sdbc::XResultSetMetaData > () throw() + operator css::uno::Reference< css::sdbc::XResultSetMetaData > () noexcept { return this; } /// @throws css::sdbc::SQLException diff --git a/connectivity/source/drivers/macab/MacabStatement.cxx b/connectivity/source/drivers/macab/MacabStatement.cxx index 407c90527eef..95b922ce6bc7 100644 --- a/connectivity/source/drivers/macab/MacabStatement.cxx +++ b/connectivity/source/drivers/macab/MacabStatement.cxx @@ -32,6 +32,7 @@ #include <cppuhelper/typeprovider.hxx> #include <connectivity/dbexception.hxx> #include <resource/sharedresources.hxx> +#include <rtl/ref.hxx> #include <strings.hrc> using namespace connectivity::macab; @@ -46,7 +47,7 @@ using namespace com::sun::star::util; namespace connectivity::macab { - void impl_throwError(const char* pErrorId) + void impl_throwError(TranslateId pErrorId) { ::connectivity::SharedResources aResources; const OUString sError( aResources.getResourceString(pErrorId) ); @@ -288,7 +289,7 @@ OUString MacabCommonStatement::getTableName() const void MacabCommonStatement::setMacabFields(MacabResultSet *pResult) const { ::rtl::Reference<connectivity::OSQLColumns> xColumns; // selected columns - MacabResultSetMetaData *pMeta; // meta information - holds the list of AddressBook fields + rtl::Reference<MacabResultSetMetaData> pMeta; // meta information - holds the list of AddressBook fields xColumns = m_aSQLIterator.getSelectColumns(); if (!xColumns.is()) @@ -397,8 +398,7 @@ Reference< XResultSet > SAL_CALL MacabCommonStatement::executeQuery( ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(rBHelper.bDisposed); - MacabResultSet* pResult = new MacabResultSet(this); - Reference< XResultSet > xRS = pResult; + rtl::Reference<MacabResultSet> pResult = new MacabResultSet(this); OUString aErr; m_pParseTree = m_aParser.parseTree(aErr, sql).release(); @@ -428,9 +428,9 @@ Reference< XResultSet > SAL_CALL MacabCommonStatement::executeQuery( pResult->setTableName(sTableName); - setMacabFields(pResult); // SELECT which columns ? - selectRecords(pResult); // WHERE which condition ? - sortRecords(pResult); // ORDER BY which columns ? + setMacabFields(pResult.get()); // SELECT which columns ? + selectRecords(pResult.get()); // WHERE which condition ? + sortRecords(pResult.get()); // ORDER BY which columns ? } // To be continued: DISTINCT // etc... @@ -446,7 +446,7 @@ Reference< XResultSet > SAL_CALL MacabCommonStatement::executeQuery( } m_xResultSet = Reference<XResultSet>(pResult); - return xRS; + return pResult; } Reference< XConnection > SAL_CALL MacabCommonStatement::getConnection( ) @@ -472,7 +472,7 @@ Any SAL_CALL MacabCommonStatement::getWarnings( ) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(rBHelper.bDisposed); - return makeAny(m_aLastWarning); + return Any(m_aLastWarning); } void SAL_CALL MacabCommonStatement::clearWarnings( ) @@ -487,31 +487,71 @@ void SAL_CALL MacabCommonStatement::clearWarnings( ) { // this properties are defined by the service statement // they must be in alphabetic order - Sequence< Property > aProps(10); - 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); - pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_USEBOOKMARKS), - PROPERTY_ID_USEBOOKMARKS, cppu::UnoType<bool>::get(), 0); - - return new ::cppu::OPropertyArrayHelper(aProps); + return new ::cppu::OPropertyArrayHelper + { + { + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME), + PROPERTY_ID_CURSORNAME, + cppu::UnoType<OUString>::get(), + 0 + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING), + PROPERTY_ID_ESCAPEPROCESSING, + cppu::UnoType<bool>::get(), + 0 + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), + PROPERTY_ID_FETCHDIRECTION, + cppu::UnoType<sal_Int32>::get(), + 0 + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), + PROPERTY_ID_FETCHSIZE, + cppu::UnoType<sal_Int32>::get(), + 0 + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE), + PROPERTY_ID_MAXFIELDSIZE, + cppu::UnoType<sal_Int32>::get(), + 0 + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXROWS), + PROPERTY_ID_MAXROWS, + cppu::UnoType<sal_Int32>::get(), + 0 + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT), + PROPERTY_ID_QUERYTIMEOUT, + cppu::UnoType<sal_Int32>::get(), + 0 + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), + PROPERTY_ID_RESULTSETCONCURRENCY, + cppu::UnoType<sal_Int32>::get(), + 0 + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), + PROPERTY_ID_RESULTSETTYPE, + cppu::UnoType<sal_Int32>::get(), + 0 + }, + { + ::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_USEBOOKMARKS), + PROPERTY_ID_USEBOOKMARKS, + cppu::UnoType<bool>::get(), + 0 + } + } + }; } ::cppu::IPropertyArrayHelper & MacabCommonStatement::getInfoHelper() @@ -568,12 +608,12 @@ void MacabCommonStatement::getFastPropertyValue(Any&,sal_Int32 nHandle) const } } -void SAL_CALL MacabCommonStatement::acquire() throw() +void SAL_CALL MacabCommonStatement::acquire() noexcept { MacabCommonStatement_BASE::acquire(); } -void SAL_CALL MacabCommonStatement::release() throw() +void SAL_CALL MacabCommonStatement::release() noexcept { MacabCommonStatement_BASE::release(); } diff --git a/connectivity/source/drivers/macab/MacabStatement.hxx b/connectivity/source/drivers/macab/MacabStatement.hxx index 83142fc56618..700a895c0a38 100644 --- a/connectivity/source/drivers/macab/MacabStatement.hxx +++ b/connectivity/source/drivers/macab/MacabStatement.hxx @@ -24,6 +24,7 @@ #include <connectivity/sqliterator.hxx> #include <connectivity/sqlparse.hxx> #include <com/sun/star/sdbc/XStatement.hpp> +#include <com/sun/star/sdbc/SQLWarning.hpp> #include <com/sun/star/util/XCancellable.hpp> #include <cppuhelper/compbase.hxx> #include <cppuhelper/implbase.hxx> @@ -106,8 +107,8 @@ namespace connectivity::macab using MacabCommonStatement_BASE::disposing; // XInterface - virtual void SAL_CALL release() throw() override; - virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() noexcept override; + virtual void SAL_CALL acquire() noexcept override; virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; diff --git a/connectivity/source/drivers/macab/MacabTable.cxx b/connectivity/source/drivers/macab/MacabTable.cxx index 75da75bc1035..1628cd297bfd 100644 --- a/connectivity/source/drivers/macab/MacabTable.cxx +++ b/connectivity/source/drivers/macab/MacabTable.cxx @@ -71,8 +71,8 @@ void MacabTable::refreshColumns() if (xResult.is()) { - Reference< XRow > xRow(xResult, UNO_QUERY); - while (xResult->next()) + Reference< XRow > xRow(xResult, UNO_QUERY); + while (xResult->next()) aVector.push_back(xRow->getString(4)); } } @@ -80,7 +80,7 @@ void MacabTable::refreshColumns() if (m_xColumns) m_xColumns->reFill(aVector); else - m_xColumns = new MacabColumns(this,m_aMutex,aVector); + m_xColumns.reset(new MacabColumns(this, m_aMutex, aVector)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabTable.hxx b/connectivity/source/drivers/macab/MacabTable.hxx index 3db8ab0aae50..897d589cc697 100644 --- a/connectivity/source/drivers/macab/MacabTable.hxx +++ b/connectivity/source/drivers/macab/MacabTable.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABTABLE_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABTABLE_HXX +#pragma once #include "MacabConnection.hxx" #include <connectivity/sdbcx/VTable.hxx> @@ -52,6 +51,4 @@ namespace connectivity::macab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABTABLE_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/MacabTables.cxx b/connectivity/source/drivers/macab/MacabTables.cxx index c70aa87f87d5..e7149d2646c1 100644 --- a/connectivity/source/drivers/macab/MacabTables.cxx +++ b/connectivity/source/drivers/macab/MacabTables.cxx @@ -52,14 +52,13 @@ sdbcx::ObjectType MacabTables::createObject(const OUString& _rName) Reference< XRow > xRow(xResult, UNO_QUERY); if (xResult->next()) // there can be only one table with this name { - MacabTable* pRet = new MacabTable( + xRet = new MacabTable( this, static_cast<MacabCatalog&>(m_rParent).getConnection(), aName, xRow->getString(4), xRow->getString(5), ""); - xRet = pRet; } } ::comphelper::disposeComponent(xResult); diff --git a/connectivity/source/drivers/macab/MacabTables.hxx b/connectivity/source/drivers/macab/MacabTables.hxx index 43922585e46b..0b0d841b7a43 100644 --- a/connectivity/source/drivers/macab/MacabTables.hxx +++ b/connectivity/source/drivers/macab/MacabTables.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABTABLES_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABTABLES_HXX +#pragma once #include <connectivity/sdbcx/VCollection.hxx> #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> @@ -47,6 +46,4 @@ namespace connectivity::macab }; } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABTABLES_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/macabcondition.hxx b/connectivity/source/drivers/macab/macabcondition.hxx index 15c2478197b8..32e7b7071cf3 100644 --- a/connectivity/source/drivers/macab/macabcondition.hxx +++ b/connectivity/source/drivers/macab/macabcondition.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABCONDITION_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABCONDITION_HXX +#pragma once #include <sal/config.h> @@ -163,6 +162,4 @@ class MacabConditionAnd : public MacabConditionBoolean } -#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABCONDITION_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/macaborder.hxx b/connectivity/source/drivers/macab/macaborder.hxx index dfdf5ce5a950..e5eb6c987ce2 100644 --- a/connectivity/source/drivers/macab/macaborder.hxx +++ b/connectivity/source/drivers/macab/macaborder.hxx @@ -17,8 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABORDER_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABORDER_HXX +#pragma once #include <rtl/ustring.hxx> #include "MacabHeader.hxx" @@ -62,6 +61,4 @@ namespace connectivity::macab }; } -#endif - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/macab/macabutilities.hxx b/connectivity/source/drivers/macab/macabutilities.hxx index d0027c8da6ed..7e0f6b091085 100644 --- a/connectivity/source/drivers/macab/macabutilities.hxx +++ b/connectivity/source/drivers/macab/macabutilities.hxx @@ -17,11 +17,15 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABUTILITIES_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MACAB_MACABUTILITIES_HXX +#pragma once + +#include <sal/config.h> + +#include <memory> #include <com/sun/star/util/DateTime.hpp> #include <com/sun/star/sdbc/DataType.hpp> +#include <unotools/resmgr.hxx> #include <time.h> #include <premac.h> @@ -47,15 +51,15 @@ namespace connectivity::macab CFRetain(sOrig); CFIndex nStringLength = CFStringGetLength(sOrig); - UniChar unichars[nStringLength+1]; + auto const unichars = std::make_unique<UniChar[]>(nStringLength+1); //'close' the string buffer correctly unichars[nStringLength] = '\0'; - CFStringGetCharacters (sOrig, CFRangeMake(0,nStringLength), unichars); + CFStringGetCharacters (sOrig, CFRangeMake(0,nStringLength), unichars.get()); CFRelease(sOrig); - return OUString(reinterpret_cast<sal_Unicode *>(unichars)); + return OUString(reinterpret_cast<sal_Unicode *>(unichars.get())); } @@ -132,9 +136,7 @@ namespace connectivity::macab return dataType; } - void impl_throwError(const char* pErrorId); + void impl_throwError(TranslateId pErrorId); } -#endif // _ CONNECTIVITY_MACAB_UTILITIES_HXX_ - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |