diff options
Diffstat (limited to 'connectivity/source/inc/file')
19 files changed, 3169 insertions, 0 deletions
diff --git a/connectivity/source/inc/file/FCatalog.hxx b/connectivity/source/inc/file/FCatalog.hxx new file mode 100644 index 000000000000..2b16a43f42fc --- /dev/null +++ b/connectivity/source/inc/file/FCatalog.hxx @@ -0,0 +1,71 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_CATALOG_HXX_ +#define _CONNECTIVITY_FILE_CATALOG_HXX_ + +#include "connectivity/sdbcx/VCatalog.hxx" + +#include "file/filedllapi.hxx" + +namespace connectivity +{ + namespace file + { + class OConnection; + class OOO_DLLPUBLIC_FILE SAL_NO_VTABLE OFileCatalog : + public connectivity::sdbcx::OCatalog + { + protected: + OConnection* m_pConnection; + + /** builds the name which should be used to access the object later on in the collection. + Will only be called in fillNames. + @param _xRow + The current row from the resultset given to fillNames. + */ + virtual ::rtl::OUString buildName( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >& _xRow); + + public: + virtual void refreshTables(); + virtual void refreshViews(); + virtual void refreshGroups(); + virtual void refreshUsers(); + + public: + OFileCatalog(OConnection* _pCon); + OConnection* getConnection() { return m_pConnection; } + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + // ::cppu::OComponentHelper + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL disposing(void); + }; + } +} +#endif // _CONNECTIVITY_FILE_CATALOG_HXX_ + diff --git a/connectivity/source/inc/file/FColumns.hxx b/connectivity/source/inc/file/FColumns.hxx new file mode 100644 index 000000000000..119ad228ad55 --- /dev/null +++ b/connectivity/source/inc/file/FColumns.hxx @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_COLUMNS_HXX_ +#define _CONNECTIVITY_FILE_COLUMNS_HXX_ + +#include "connectivity/sdbcx/VCollection.hxx" +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#include "connectivity/sdbcx/IRefreshable.hxx" +#include "file/FTable.hxx" +#include "file/filedllapi.hxx" + +namespace connectivity +{ + namespace file + { + class OOO_DLLPUBLIC_FILE OColumns : public sdbcx::OCollection + { + protected: + OFileTable* m_pTable; + + virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + public: + OColumns( OFileTable* _pTable, + ::osl::Mutex& _rMutex, + const TStringVector &_rVector + ) : sdbcx::OCollection(*_pTable,_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(),_rMutex,_rVector) + ,m_pTable(_pTable) + {} + }; + } +} +#endif // _CONNECTIVITY_FILE_COLUMNS_HXX_ + diff --git a/connectivity/source/inc/file/FConnection.hxx b/connectivity/source/inc/file/FConnection.hxx new file mode 100644 index 000000000000..d908ec836264 --- /dev/null +++ b/connectivity/source/inc/file/FConnection.hxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CONNECTIVITY_FILE_OCONNECTION_HXX_ +#define _CONNECTIVITY_FILE_OCONNECTION_HXX_ + +#include <com/sun/star/ucb/XContent.hpp> +#include <com/sun/star/sdbc/SQLWarning.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include "OSubComponent.hxx" +#ifndef _MAP_ +#include <map> +#endif +#include "connectivity/CommonTools.hxx" +#include "OTypeInfo.hxx" +#include <tools/string.hxx> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/ucb/XDynamicResultSet.hpp> +#include "connectivity/sqlparse.hxx" +#include "connectivity/sqliterator.hxx" +#include "TConnection.hxx" +#include "file/filedllapi.hxx" + +namespace connectivity +{ + namespace file + { + + class OStatement_Base; + class ODatabaseMetaData; + class OFileDriver; + + class OOO_DLLPUBLIC_FILE OConnection : + public connectivity::OMetaConnection, + public connectivity::OSubComponent<OConnection, connectivity::OMetaConnection> + { + friend class connectivity::OSubComponent<OConnection, connectivity::OMetaConnection>; + + protected: + //==================================================================== + // Data attributes + //==================================================================== + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; + + ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by + + String m_aFilenameExtension; + OFileDriver* m_pDriver; // Pointer to the owning + // driver object + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet > m_xDir; // directory + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent> m_xContent; + + sal_Bool m_bClosed; + sal_Bool m_bAutoCommit; + sal_Bool m_bReadOnly; + sal_Bool m_bShowDeleted; + sal_Bool m_bCaseSensitiveExtension; + sal_Bool m_bCheckSQL92; + bool m_bDefaultTextEncoding; + + + void throwUrlNotValid(const ::rtl::OUString & _rsUrl,const ::rtl::OUString & _rsMessage); + + virtual ~OConnection(); + public: + + OConnection(OFileDriver* _pDriver); + + virtual void construct(const ::rtl::OUString& _rUrl,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo ) throw( ::com::sun::star::sdbc::SQLException); + + void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual void SAL_CALL release() throw(); + + // XServiceInfo + DECLARE_SERVICE_INFO(); + + // XConnection + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + //XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + // no interface methods + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet > getDir() const; + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent> getContent() const { return m_xContent; } + // create a catalog or return the catalog already created + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog(); + + sal_Bool matchesExtension( const String& _rExt ) const; + + inline const String& getExtension() const { return m_aFilenameExtension; } + inline sal_Bool isCaseSensitveExtension() const { return m_bCaseSensitiveExtension; } + inline OFileDriver* getDriver() const { return m_pDriver; } + inline sal_Bool showDeleted() const { return m_bShowDeleted; } + inline sal_Bool isCheckEnabled() const { return m_bCheckSQL92; } + inline bool isTextEncodingDefaulted() const { return m_bDefaultTextEncoding; } + + public: + struct GrantAccess + { + friend class ODatabaseMetaData; + private: + GrantAccess() { } + }; + + void setCaseSensitiveExtension( sal_Bool _bIsCS, GrantAccess ) { m_bCaseSensitiveExtension = _bIsCS; } + }; + } +} +#endif // _CONNECTIVITY_FILE_OCONNECTION_HXX_ + diff --git a/connectivity/source/inc/file/FDatabaseMetaData.hxx b/connectivity/source/inc/file/FDatabaseMetaData.hxx new file mode 100644 index 000000000000..4104b72a8045 --- /dev/null +++ b/connectivity/source/inc/file/FDatabaseMetaData.hxx @@ -0,0 +1,197 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_ODATABASEMETADATA_HXX_ +#define _CONNECTIVITY_FILE_ODATABASEMETADATA_HXX_ + +#include "TDatabaseMetaDataBase.hxx" +#include "file/FConnection.hxx" +#include "file/filedllapi.hxx" + +namespace connectivity +{ + namespace file + { + //************************************************************** + //************ Class: ODatabaseMetaData + //************************************************************** + + class OOO_DLLPUBLIC_FILE SAL_NO_VTABLE ODatabaseMetaData : + public ODatabaseMetaDataBase + { + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw(); + // cached database information + virtual ::rtl::OUString impl_getIdentifierQuoteString_throw( ); + virtual sal_Bool impl_isCatalogAtStart_throw( ); + virtual ::rtl::OUString impl_getCatalogSeparator_throw( ); + virtual sal_Bool impl_supportsCatalogsInTableDefinitions_throw( ); + virtual sal_Bool impl_supportsSchemasInTableDefinitions_throw( ) ; + virtual sal_Bool impl_supportsCatalogsInDataManipulation_throw( ); + virtual sal_Bool impl_supportsSchemasInDataManipulation_throw( ) ; + virtual sal_Bool impl_supportsMixedCaseQuotedIdentifiers_throw( ); + virtual sal_Bool impl_supportsAlterTableWithAddColumn_throw( ); + virtual sal_Bool impl_supportsAlterTableWithDropColumn_throw( ); + virtual sal_Int32 impl_getMaxStatements_throw( ); + virtual sal_Int32 impl_getMaxTablesInSelect_throw( ); + virtual sal_Bool impl_storesMixedCaseQuotedIdentifiers_throw( ); + protected: + OConnection* m_pConnection; // I need the native class not only the interface + virtual ~ODatabaseMetaData(); + public: + + ODatabaseMetaData(OConnection* _pCon); + // XDatabaseMetaData + virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getUserName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_FILE_ODATABASEMETADATA_HXX_ + diff --git a/connectivity/source/inc/file/FDateFunctions.hxx b/connectivity/source/inc/file/FDateFunctions.hxx new file mode 100644 index 000000000000..30c553dc17ab --- /dev/null +++ b/connectivity/source/inc/file/FDateFunctions.hxx @@ -0,0 +1,242 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_FDATEFUNCTIONS_HXX_ +#define _CONNECTIVITY_FILE_FDATEFUNCTIONS_HXX_ + +#include "file/fcode.hxx" +#include "file/filedllapi.hxx" + +namespace connectivity +{ + class OSQLParseNode; + namespace file + { + /** DAYOFWEEK(date) + Returns the weekday index for date (1 = Sunday, 2 = Monday, ... 7 = Saturday). These index values correspond to the ODBC standard. + + > SELECT DAYOFWEEK('1998-02-03'); + -> 3 + */ + class OOp_DayOfWeek : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** DAYOFMONTH(date) + Returns the day of the month for date, in the range 1 to 31: + + > SELECT DAYOFMONTH('1998-02-03'); + -> 3 + */ + class OOp_DayOfMonth : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** DAYOFYEAR(date) + Returns the day of the year for date, in the range 1 to 366: + + > SELECT DAYOFYEAR('1998-02-03'); + -> 34 + + */ + class OOp_DayOfYear : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** MONTH(date) + Returns the month for date, in the range 1 to 12: + + > SELECT MONTH('1998-02-03'); + -> 2 + */ + class OOp_Month : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** DAYNAME(date) + Returns the name of the weekday for date: + + > SELECT DAYNAME('1998-02-05'); + -> 'Thursday' + + */ + class OOp_DayName : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** MONTHNAME(date) + Returns the name of the month for date: + + > SELECT MONTHNAME('1998-02-05'); + -> 'February' + + */ + class OOp_MonthName : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** QUARTER(date) + Returns the quarter of the year for date, in the range 1 to 4: + + > SELECT QUARTER('98-04-01'); + -> 2 + + */ + class OOp_Quarter : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** WEEK(date) + WEEK(date,first) + With a single argument, returns the week for date, in the range 0 to 53 (yes, there may be the beginnings of a week 53), for locations where Sunday is the first day of the week. The two-argument form of WEEK() allows you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range 0-53 or 1-52. Here is a table for how the second argument works: + Value Meaning + 0 Week starts on Sunday and return value is in range 0-53 + 1 Week starts on Monday and return value is in range 0-53 + 2 Week starts on Sunday and return value is in range 1-53 + 3 Week starts on Monday and return value is in range 1-53 (ISO 8601) + + > SELECT WEEK('1998-02-20'); + -> 7 + > SELECT WEEK('1998-02-20',0); + -> 7 + > SELECT WEEK('1998-02-20',1); + -> 8 + > SELECT WEEK('1998-12-31',1); + -> 53 + + */ + class OOp_Week : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + + /** YEAR(date) + Returns the year for date, in the range 1000 to 9999: + + > SELECT YEAR('98-02-03'); + -> 1998 + */ + class OOp_Year : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** HOUR(time) + Returns the hour for time, in the range 0 to 23: + + > SELECT HOUR('10:05:03'); + -> 10 + */ + class OOp_Hour : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** MINUTE(time) + Returns the minute for time, in the range 0 to 59: + + > SELECT MINUTE('98-02-03 10:05:03'); + -> 5 + + */ + class OOp_Minute : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** SECOND(time) + Returns the second for time, in the range 0 to 59: + + > SELECT SECOND('10:05:03'); + -> 3 + */ + class OOp_Second : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** CURDATE() + CURRENT_DATE + Returns today's date as a value in 'YYYY-MM-DD' or YYYYMMDD format, depending on whether the function is used in a string or numeric context: + + > SELECT CURDATE(); + -> '1997-12-15' + */ + class OOp_CurDate : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + + /** CURTIME() + CURRENT_TIME + Returns the current time as a value in 'HH:MM:SS' or HHMMSS format, depending on whether the function is used in a string or numeric context: + + > SELECT CURTIME(); + -> '23:50:26' + */ + class OOp_CurTime : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + + /** NOW() + Returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context: + + > SELECT NOW(); + -> '1997-12-15 23:50:26' + */ + class OOp_Now : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + } +} + +#endif // _CONNECTIVITY_FILE_FCODE_HXX_ + diff --git a/connectivity/source/inc/file/FDriver.hxx b/connectivity/source/inc/file/FDriver.hxx new file mode 100644 index 000000000000..416f6e48eb9d --- /dev/null +++ b/connectivity/source/inc/file/FDriver.hxx @@ -0,0 +1,87 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_ODRIVER_HXX_ +#define _CONNECTIVITY_FILE_ODRIVER_HXX_ + +#include <com/sun/star/sdbc/XDriver.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> +#include <cppuhelper/compbase3.hxx> +#include "connectivity/CommonTools.hxx" +#include "file/filedllapi.hxx" + +namespace connectivity +{ + namespace file + { + typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::sdbcx::XDataDefinitionSupplier> ODriver_BASE; + + class OOO_DLLPUBLIC_FILE SAL_NO_VTABLE OFileDriver : public ODriver_BASE + { + protected: + ::osl::Mutex m_aMutex; + + connectivity::OWeakRefArray m_xConnections; // vector containing a list + // of all the Connection objects + // for this Driver + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; + public: + OFileDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // XDriver + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); + + // XDataDefinitionSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getFactory() const { return m_xFactory; } + }; + } + +} +#endif //_CONNECTIVITY_FILE_ODRIVER_HXX_ + + diff --git a/connectivity/source/inc/file/FNumericFunctions.hxx b/connectivity/source/inc/file/FNumericFunctions.hxx new file mode 100644 index 000000000000..cd52f1a1158a --- /dev/null +++ b/connectivity/source/inc/file/FNumericFunctions.hxx @@ -0,0 +1,376 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_ +#define _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_ + +#include "file/fcode.hxx" +#include "file/filedllapi.hxx" + +namespace connectivity +{ + class OSQLParseNode; + namespace file + { + /** ABS(X) + Returns the absolute value of X: + + > SELECT ABS(2); + -> 2 + > SELECT ABS(-32); + -> 32 + + */ + class OOp_Abs : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** SIGN(X) + Returns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive: + + > SELECT SIGN(-32); + -> -1 + > SELECT SIGN(0); + -> 0 + > SELECT SIGN(234); + -> 1 + + */ + class OOp_Sign : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** MOD(N,M) + % + Modulo (like the % operator in C). Returns the remainder of N divided by M: + + > SELECT MOD(234, 10); + -> 4 + > SELECT 253 % 7; + -> 1 + > SELECT MOD(29,9); + -> 2 + > SELECT 29 MOD 9; + -> 2 + */ + class OOp_Mod : public OBinaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const; + }; + + /** FLOOR(X) + Returns the largest integer value not greater than X: + + > SELECT FLOOR(1.23); + -> 1 + > SELECT FLOOR(-1.23); + -> -2 + + */ + class OOp_Floor : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** CEILING(X) + Returns the smallest integer value not less than X: + + > SELECT CEILING(1.23); + -> 2 + > SELECT CEILING(-1.23); + -> -1 + + */ + class OOp_Ceiling : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** ROUND(X) + ROUND(X,D) + Returns the argument X, rounded to the nearest integer. With two arguments rounded to a number to D decimals. + + > SELECT ROUND(-1.23); + -> -1 + > SELECT ROUND(-1.58); + -> -2 + > SELECT ROUND(1.58); + -> 2 + > SELECT ROUND(1.298, 1); + -> 1.3 + > SELECT ROUND(1.298, 0); + -> 1 + > SELECT ROUND(23.298, -1); + -> 20 + */ + class OOp_Round : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + + /** EXP(X) + Returns the value of e (the base of natural logarithms) raised to the power of X: + + > SELECT EXP(2); + -> 7.389056 + > SELECT EXP(-2); + -> 0.135335 + */ + class OOp_Exp : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** LN(X) + Returns the natural logarithm of X: + + > SELECT LN(2); + -> 0.693147 + > SELECT LN(-2); + -> NULL + + */ + class OOp_Ln : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** LOG(X) + LOG(B,X) + If called with one parameter, this function returns the natural logarithm of X: + + > SELECT LOG(2); + -> 0.693147 + > SELECT LOG(-2); + -> NULL + + If called with two parameters, this function returns the logarithm of X for an arbitary base B: + + > SELECT LOG(2,65536); + -> 16.000000 + > SELECT LOG(1,100); + -> NULL + */ + class OOp_Log : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + + /** LOG10(X) + Returns the base-10 logarithm of X: + + > SELECT LOG10(2); + -> 0.301030 + > SELECT LOG10(100); + -> 2.000000 + > SELECT LOG10(-100); + -> NULL + */ + class OOp_Log10 : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** POWER(X,Y) + Returns the value of X raised to the power of Y: + + > SELECT POW(2,2); + -> 4.000000 + > SELECT POW(2,-2); + -> 0.250000 + */ + class OOp_Pow : public OBinaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const; + }; + + /** SQRT(X) + Returns the non-negative square root of X: + + > SELECT SQRT(4); + -> 2.000000 + > SELECT SQRT(20); + -> 4.472136 + */ + class OOp_Sqrt : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** PI() + Returns the value of PI. The default shown number of decimals is 5, but internally uses the full double precession for PI. + + > SELECT PI(); + -> 3.141593 + > SELECT PI()+0.000000000000000000; + -> 3.141592653589793116 + + */ + class OOp_Pi : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + + /** COS(X) + Returns the cosine of X, where X is given in radians: + + > SELECT COS(PI()); + -> -1.000000 + */ + class OOp_Cos : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const; + }; + + /** SIN(X) + Returns the sine of X, where X is given in radians: + + > SELECT SIN(PI()); + -> 0.000000 + + */ + class OOp_Sin : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const; + }; + /** TAN(X) + Returns the tangent of X, where X is given in radians: + + > SELECT TAN(PI()+1); + -> 1.557408 + */ + class OOp_Tan : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const; + }; + + /** ACOS(X) + Returns the arc cosine of X, that is, the value whose cosine is X. Returns NULL if X is not in the range -1 to 1: + + > SELECT ACOS(1); + -> 0.000000 + > SELECT ACOS(1.0001); + -> NULL + > SELECT ACOS(0); + -> 1.570796 + */ + class OOp_ACos : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const; + }; + + /** ASIN(X) + Returns the arc sine of X, that is, the value whose sine is X. Returns NULL if X is not in the range -1 to 1: + + > SELECT ASIN(0.2); + -> 0.201358 + > SELECT ASIN('foo'); + -> 0.000000 + */ + class OOp_ASin : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const; + }; + + /** ATAN(X) + Returns the arc tangent of X, that is, the value whose tangent is X: + + > SELECT ATAN(2); + -> 1.107149 + > SELECT ATAN(-2); + -> -1.107149 + */ + class OOp_ATan : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const; + }; + + /** ATAN2(Y,X) + Returns the arc tangent of the two variables X and Y. It is similar to calculating the arc tangent of Y / X, except that the signs of both arguments are used to determine the quadrant of the result: + + > SELECT ATAN2(-2,2); + -> -0.785398 + > SELECT ATAN2(PI(),0); + -> 1.570796 + + */ + class OOp_ATan2 : public OBinaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const; + }; + + /** DEGREES(X) + Returns the argument X, converted from radians to degrees: + + > SELECT DEGREES(PI()); + -> 180.000000 + */ + class OOp_Degrees : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const; + }; + + /** RADIANS(X) + Returns the argument X, converted from degrees to radians: + + > SELECT RADIANS(90); + -> 1.570796 + + */ + class OOp_Radians : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const; + }; + } +} + +#endif // _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_ + diff --git a/connectivity/source/inc/file/FPreparedStatement.hxx b/connectivity/source/inc/file/FPreparedStatement.hxx new file mode 100644 index 000000000000..9528ca16a508 --- /dev/null +++ b/connectivity/source/inc/file/FPreparedStatement.hxx @@ -0,0 +1,135 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_OPREPAREDSTATEMENT_HXX_ +#define _CONNECTIVITY_FILE_OPREPAREDSTATEMENT_HXX_ + +#include "file/filedllapi.hxx" +#include "file/FStatement.hxx" +#include <com/sun/star/sdbc/XPreparedStatement.hpp> +#include <com/sun/star/sdbc/XParameters.hpp> +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +// #include <com/sun/star/sdbc/XClearParameters.hpp> +#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include "file/FResultSet.hxx" + +namespace connectivity +{ + namespace file + { + + class OOO_DLLPUBLIC_FILE SAL_NO_VTABLE OPreparedStatement : public OStatement_BASE2, + public ::com::sun::star::sdbc::XPreparedStatement, + public ::com::sun::star::sdbc::XParameters, + public ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + public ::com::sun::star::lang::XServiceInfo + + { + protected: + //==================================================================== + // Data attributes + //==================================================================== + ::rtl::OUString m_aSql; + OValueRefRow m_aParameterRow; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; + + OResultSet* m_pResultSet; + ::vos::ORef<connectivity::OSQLColumns> m_xParamColumns; // the parameter columns + + // factory method for resultset's + virtual OResultSet* createResultSet(); + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> initResultSet(); + + void checkAndResizeParameters(sal_Int32 parameterIndex); + void setParameter(sal_Int32 parameterIndex, const ORowSetValue& x); + + UINT32 AddParameter(connectivity::OSQLParseNode * pParameter, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xCol); + void scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes); + void describeColumn(OSQLParseNode* _pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable); + void describeParameter(); + + virtual void parseParamterElem(const String& _sColumnName,OSQLParseNode* pRow_Value_Constructor_Elem); + virtual void initializeResultSet(OResultSet* _pResult); + + virtual ~OPreparedStatement(); + public: + DECLARE_SERVICE_INFO(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OPreparedStatement( OConnection* _pConnection); + + virtual void construct(const ::rtl::OUString& sql) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + //XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XPreparedStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XParameters + virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_FILE_OPREPAREDSTATEMENT_HXX_ + + diff --git a/connectivity/source/inc/file/FResultSet.hxx b/connectivity/source/inc/file/FResultSet.hxx new file mode 100644 index 000000000000..530387ceef4a --- /dev/null +++ b/connectivity/source/inc/file/FResultSet.hxx @@ -0,0 +1,357 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_FRESULTSET_HXX_ +#define _CONNECTIVITY_FILE_FRESULTSET_HXX_ + +#ifndef _COM_SUN_STAR_SQLC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XCLOSEABLE_HPP_ +#include <com/sun/star/sdbc/XCloseable.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XCOLUMNLOCATE_HPP_ +#include <com/sun/star/sdbc/XColumnLocate.hpp> +#endif +#include <com/sun/star/util/XCancellable.hpp> +#ifndef _COM_SUN_STAR_SQLC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XRESULTSETUPDATE_HPP_ +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#endif +#ifndef _COM_SUN_STAR_SQLC_XROWUPDATE_HPP_ +#include <com/sun/star/sdbc/XRowUpdate.hpp> +#endif +#include <cppuhelper/compbase12.hxx> +#include <comphelper/proparrhlp.hxx> +#include "file/FStatement.hxx" +#include "connectivity/CommonTools.hxx" +#include <comphelper/propertycontainer.hxx> +#include "file/fanalyzer.hxx" +#include "file/FTable.hxx" +#include "file/filedllapi.hxx" +#include <comphelper/broadcasthelper.hxx> +#include "connectivity/StdTypeDefs.hxx" +#include "TSortIndex.hxx" +#include "TSkipDeletedSet.hxx" +#include <com/sun/star/lang/XEventListener.hpp> + +namespace connectivity +{ + namespace file + { + /* + ** java_sql_ResultSet + */ + typedef ::cppu::WeakComponentImplHelper12< ::com::sun::star::sdbc::XResultSet, + ::com::sun::star::sdbc::XRow, + ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + ::com::sun::star::util::XCancellable, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::sdbc::XResultSetUpdate, + ::com::sun::star::sdbc::XRowUpdate, + ::com::sun::star::sdbc::XCloseable, + ::com::sun::star::sdbc::XColumnLocate, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::lang::XEventListener, + ::com::sun::star::lang::XUnoTunnel> OResultSet_BASE; + + class OOO_DLLPUBLIC_FILE OResultSet : + public comphelper::OBaseMutex, + public ::connectivity::IResultSetHelper, + public OResultSet_BASE, + public ::comphelper::OPropertyContainer, + public ::comphelper::OPropertyArrayUsageHelper<OResultSet> + { + + protected: + ::std::vector<void*> m_aBindVector; + ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime + + ::std::vector<sal_Int32> m_aOrderbyColumnNumber; + ::std::vector<TAscendingOrder> m_aOrderbyAscending; + + OValueRefRow m_aSelectRow; + OValueRefRow m_aRow; + OValueRefRow m_aEvaluateRow; // contains all values of a row + OValueRefRow m_aParameterRow; + OValueRefRow m_aInsertRow; // needed for insert by cursor + ORefAssignValues m_aAssignValues; // needed for insert,update and parameters + // to compare with the restrictions + TIntVector* m_pEvaluationKeySet; + TIntVector::iterator m_aEvaluateIter; + + +// TInt2IntMap m_aBookmarks; // map from bookmarks to logical position +// ::std::vector<TInt2IntMap::iterator> m_aBookmarksPositions;// vector of iterators to bookmark map, the order is the logical position + OSkipDeletedSet m_aSkipDeletedSet; + + ::vos::ORef<OKeySet> m_pFileSet; + OKeySet::Vector::iterator m_aFileSetIter; + + + + OSortIndex* m_pSortIndex; + ::vos::ORef<connectivity::OSQLColumns> m_xColumns; // this are the select columns + ::vos::ORef<connectivity::OSQLColumns> m_xParamColumns; + OFileTable* m_pTable; + connectivity::OSQLParseNode* m_pParseTree; + + OSQLAnalyzer* m_pSQLAnalyzer; + connectivity::OSQLParseTreeIterator& m_aSQLIterator; + + sal_Int32 m_nFetchSize; + sal_Int32 m_nResultSetType; + sal_Int32 m_nFetchDirection; + sal_Int32 m_nResultSetConcurrency; + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xStatement; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xDBMetaData; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColNames; // table columns + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xColsIdx; // table columns + + + ::rtl::OUString m_aTableRange; + rtl_TextEncoding m_nTextEncoding; + sal_Int32 m_nRowPos; + sal_Int32 m_nFilePos; + sal_Int32 m_nLastVisitedPos; + sal_Int32 m_nRowCountResult; + sal_Int32 m_nCurrentPosition; // current position of the resultset is returned when ask for getRow() + sal_Int32 m_nColumnCount; + sal_Bool m_bWasNull; + sal_Bool m_bEOF; // after last record + sal_Bool m_bLastRecord; + sal_Bool m_bInserted; // true when moveToInsertRow was called + // set to false when cursor moved or cancel + sal_Bool m_bRowUpdated; + sal_Bool m_bRowInserted; + sal_Bool m_bRowDeleted; + sal_Bool m_bShowDeleted; + sal_Bool m_bIsCount; + + void initializeRow(OValueRefRow& _rRow,sal_Int32 _nColumnCount); + void construct(); + sal_Bool evaluate(); + + BOOL ExecuteRow(IResultSetHelper::Movement eFirstCursorPosition, + INT32 nOffset = 1, + BOOL bEvaluate = TRUE, + BOOL bRetrieveData = TRUE); + + OKeyValue* GetOrderbyKeyValue(OValueRefRow& _rRow); + BOOL IsSorted() const { return !m_aOrderbyColumnNumber.empty() && m_aOrderbyColumnNumber[0] != SQL_COLUMN_NOTFOUND;} + + // return true when the select statement is "select count(*) from table" + inline sal_Bool isCount() const { return m_bIsCount; } + void checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException); + + const ORowSetValue& getValue(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException); + void updateValue(sal_Int32 columnIndex,const ORowSetValue& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // clear insert row + void clearInsertRow(); + void sortRows(); + protected: + + using OResultSet_BASE::rBHelper; + + BOOL Move(IResultSetHelper::Movement eCursorPosition, INT32 nOffset, BOOL bRetrieveData); + virtual sal_Bool fillIndexValues(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> &_xIndex); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + virtual ~OResultSet(); + public: + DECLARE_SERVICE_INFO(); + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator); + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *() + { + return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(OResultSet_BASE*)this); + } + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + // XResultSet + virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XResultSetUpdate + virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRowUpdate + virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XColumnLocate + virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + //XEventlistener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + + // special methods + inline sal_Int32 mapColumn(sal_Int32 column); + virtual BOOL OpenImpl(); + virtual void doTableSpecials(const OSQLTable& _xTable); + + inline sal_Int32 getRowCountResult() const { return m_nRowCountResult; } + inline void setParameterRow(const OValueRefRow& _rParaRow) { m_aParameterRow = _rParaRow; } + inline void setEvaluationRow(const OValueRefRow& _aRow) { m_aEvaluateRow = _aRow; } + inline void setParameterColumns(const ::vos::ORef<connectivity::OSQLColumns>& _xParamColumns) { m_xParamColumns = _xParamColumns; } + inline void setAssignValues(const ORefAssignValues& _aAssignValues) { m_aAssignValues = _aAssignValues; } + inline void setBindingRow(const OValueRefRow& _aRow) { m_aRow = _aRow; } + inline void setSelectRow(const OValueRefRow& _rRow) + { + m_aSelectRow = _rRow; + m_nColumnCount = m_aSelectRow->get().size(); + } + inline void setColumnMapping(const ::std::vector<sal_Int32>& _aColumnMapping) { m_aColMapping = _aColumnMapping; } + inline void setSqlAnalyzer(OSQLAnalyzer* _pSQLAnalyzer) { m_pSQLAnalyzer = _pSQLAnalyzer; } + + inline void setOrderByColumns(const ::std::vector<sal_Int32>& _aColumnOrderBy) { m_aOrderbyColumnNumber = _aColumnOrderBy; } + inline void setOrderByAscending(const ::std::vector<TAscendingOrder>& _aOrderbyAsc) { m_aOrderbyAscending = _aOrderbyAsc; } + inline void setEvaluationKeySet(TIntVector* _pEvaluationKeySet) { m_pEvaluationKeySet = _pEvaluationKeySet; } + inline void setMetaData(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData>& _xMetaData) { m_xMetaData = _xMetaData;} + + // clears the resultset so it can be reused by a preparedstatement + void clear(); + static void setBoundedColumns(const OValueRefRow& _rRow, + const OValueRefRow& _rSelectRow, + const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xNames, + sal_Bool _bSetColumnMapping, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData, + ::std::vector<sal_Int32>& _rColMapping); + + // IResultSetHelper + virtual sal_Bool move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData); + virtual sal_Int32 getDriverPos() const; + virtual sal_Bool deletedVisible() const; + virtual sal_Bool isRowDeleted() const; + }; + // ------------------------------------------------------------------------- + inline sal_Int32 OResultSet::mapColumn(sal_Int32 column) + { + sal_Int32 map = column; + + OSL_ENSURE(column > 0, "file::OResultSet::mapColumn: invalid column index!"); + // the first column (index 0) is for convenience only. The first real select column is no 1. + if ((column > 0) && (column < (sal_Int32)m_aColMapping.size())) + map = m_aColMapping[column]; + + return map; + } + } +} +#endif // _CONNECTIVITY_FILE_ORESULTSET_HXX_ + + diff --git a/connectivity/source/inc/file/FResultSetMetaData.hxx b/connectivity/source/inc/file/FResultSetMetaData.hxx new file mode 100644 index 000000000000..60bd3b179709 --- /dev/null +++ b/connectivity/source/inc/file/FResultSetMetaData.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_ORESULTSETMETADATA_HXX_ +#define _CONNECTIVITY_FILE_ORESULTSETMETADATA_HXX_ + +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#include <cppuhelper/implbase1.hxx> +#include "connectivity/CommonTools.hxx" +#include <vos/ref.hxx> +#include "file/filedllapi.hxx" + +namespace connectivity +{ + namespace file + { + class OFileTable; + //************************************************************** + //************ Class: ResultSetMetaData + //************************************************************** + typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE; + + class OOO_DLLPUBLIC_FILE OResultSetMetaData : + public OResultSetMetaData_BASE + { + ::rtl::OUString m_aTableName; + ::vos::ORef<connectivity::OSQLColumns> m_xColumns; + OFileTable* m_pTable; + + void checkColumnIndex(sal_Int32 column) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + protected: + virtual ~OResultSetMetaData(); + public: + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OResultSetMetaData(const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns,const ::rtl::OUString& _aTableName,OFileTable* _pTable); + + /// Avoid ambigous cast error from the compiler. + inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw() + { return this; } + + virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} +#endif // _CONNECTIVITY_FILE_ORESULTSETMETADATA_HXX_ + + diff --git a/connectivity/source/inc/file/FStatement.hxx b/connectivity/source/inc/file/FStatement.hxx new file mode 100644 index 000000000000..0983811b9bd2 --- /dev/null +++ b/connectivity/source/inc/file/FStatement.hxx @@ -0,0 +1,223 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_OSTATEMENT_HXX_ +#define _CONNECTIVITY_FILE_OSTATEMENT_HXX_ + +#include <com/sun/star/sdbc/XStatement.hpp> +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#include <com/sun/star/sdbc/XMultipleResults.hpp> +#include <com/sun/star/sdbc/XBatchExecution.hpp> +#include <com/sun/star/sdbc/XCloseable.hpp> +#include <com/sun/star/sdbc/SQLWarning.hpp> +#include <com/sun/star/util/XCancellable.hpp> +#include <comphelper/proparrhlp.hxx> +#include <cppuhelper/compbase3.hxx> +#include <cppuhelper/implbase2.hxx> +#include <comphelper/uno3.hxx> +#include "connectivity/CommonTools.hxx" +#include "file/FConnection.hxx" +#include "file/filedllapi.hxx" +#ifndef _LIST_ +#include <list> +#endif +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <comphelper/propertycontainer.hxx> +#include "file/fanalyzer.hxx" +#include <comphelper/broadcasthelper.hxx> +#include "TSortIndex.hxx" + +#define SQL_COLUMN_NOTFOUND STRING_NOTFOUND + +namespace connectivity +{ + namespace file + { + class OResultSet; + class OFileTable; + typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::util::XCancellable, + ::com::sun::star::sdbc::XCloseable> OStatement_BASE; + + //************************************************************** + //************ Class: java.sql.Statement + //************************************************************** + class OOO_DLLPUBLIC_FILE OStatement_Base : + public comphelper::OBaseMutex, + public OStatement_BASE, + public ::comphelper::OPropertyContainer, + public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base> + + { + protected: + ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime + ::std::vector<sal_Int32> m_aParameterIndexes; // maps the parameter index to column index + ::std::vector<sal_Int32> m_aOrderbyColumnNumber; + ::std::vector<TAscendingOrder> m_aOrderbyAscending; + + ::com::sun::star::sdbc::SQLWarning m_aLastWarning; + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xDBMetaData; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColNames; // table columns // for this Statement + + + connectivity::OSQLParser m_aParser; + connectivity::OSQLParseTreeIterator m_aSQLIterator; + + OConnection* m_pConnection;// The owning Connection object + connectivity::OSQLParseNode* m_pParseTree; + OSQLAnalyzer* m_pSQLAnalyzer; //the sql analyzer used by the resultset + + ::std::vector<sal_Int32>* m_pEvaluationKeySet; + + OFileTable* m_pTable; // the current table + OValueRefRow m_aSelectRow; + OValueRefRow m_aRow; + OValueRefRow m_aEvaluateRow; // contains all values of a row + ORefAssignValues m_aAssignValues; // needed for insert,update and parameters + // to compare with the restrictions + + ::rtl::OUString m_aCursorName; + sal_Int32 m_nMaxFieldSize; + sal_Int32 m_nMaxRows; + sal_Int32 m_nQueryTimeOut; + sal_Int32 m_nFetchSize; + sal_Int32 m_nResultSetType; + sal_Int32 m_nFetchDirection; + sal_Int32 m_nResultSetConcurrency; + sal_Bool m_bEscapeProcessing; + + ::cppu::OBroadcastHelper& rBHelper; + + protected: + // initialize the column index map (mapping select columns to table columns) + void createColumnMapping(); + // searches the statement for sort criteria + void anylizeSQL(); + void setOrderbyColumn( connectivity::OSQLParseNode* pColumnRef, + connectivity::OSQLParseNode* pAscendingDescending); + + virtual void initializeResultSet(OResultSet* _pResult); + // create the analyzer + virtual OSQLAnalyzer* createAnalyzer(); + + void reset () throw( ::com::sun::star::sdbc::SQLException); + void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException); + void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException); + sal_Int32 getPrecision ( sal_Int32 sqlType); + + void disposeResultSet(); + void GetAssignValues(); + void SetAssignValue(const String& aColumnName, + const String& aValue, + BOOL bSetNull = FALSE, + UINT32 nParameter=SQL_NO_PARAMETER); + void ParseAssignValues( const ::std::vector< String>& aColumnNameList, + connectivity::OSQLParseNode* pRow_Value_Constructor_Elem,xub_StrLen nIndex); + + virtual void parseParamterElem(const String& _sColumnName,OSQLParseNode* pRow_Value_Constructor_Elem); + // factory method for resultset's + virtual OResultSet* createResultSet() = 0; + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + virtual ~OStatement_Base(); + public: + connectivity::OSQLParseNode* getParseTree() const { return m_pParseTree;} + + OStatement_Base(OConnection* _pConnection ); + + OConnection* getOwnConnection() const { return m_pConnection;} + + using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; + + virtual void construct(const ::rtl::OUString& sql) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + // virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException) = 0; + virtual void SAL_CALL acquire() throw(); + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + // XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + + class OOO_DLLPUBLIC_FILE OStatement_BASE2 : + public OStatement_Base, + public connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE> + + { + friend class connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>; + public: + OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ), + connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){} + // OComponentHelper + virtual void SAL_CALL disposing(void); + // XInterface + virtual void SAL_CALL release() throw(); + }; + + typedef ::cppu::ImplHelper2< ::com::sun::star::sdbc::XStatement,::com::sun::star::lang::XServiceInfo > OStatement_XStatement; + class OOO_DLLPUBLIC_FILE OStatement : + public OStatement_BASE2, + public OStatement_XStatement + { + protected: + // factory method for resultset's + virtual OResultSet* createResultSet(); + public: + // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: + OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){} + DECLARE_SERVICE_INFO(); + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + + // XStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + }; + } +} +#endif // _CONNECTIVITY_FILE_OSTATEMENT_HXX_ + diff --git a/connectivity/source/inc/file/FStringFunctions.hxx b/connectivity/source/inc/file/FStringFunctions.hxx new file mode 100644 index 000000000000..d90f53b38cf3 --- /dev/null +++ b/connectivity/source/inc/file/FStringFunctions.hxx @@ -0,0 +1,283 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_FSTRINGFUNCTIONS_HXX_ +#define _CONNECTIVITY_FILE_FSTRINGFUNCTIONS_HXX_ + +#include "file/fcode.hxx" +#include "file/filedllapi.hxx" + +namespace connectivity +{ + class OSQLParseNode; + namespace file + { + /** UCASE(str) + UPPER(str) + Returns the string str with all characters changed to uppercase according to the current character set mapping (the default is ISO-8859-1 Latin1): + + > SELECT UCASE('Hej'); + -> 'HEJ' + + */ + class OOp_Upper : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** LCASE(str) + LOWER(str) + Returns the string str with all characters changed to lowercase according to the current character set mapping (the default is ISO-8859-1 Latin1): + + > SELECT LCASE('QUADRATICALLY'); + -> 'quadratically' + + */ + class OOp_Lower : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** ASCII(str) + Returns the ASCII code value of the leftmost character of the string str. Returns 0 if str is the empty string. Returns NULL if str is NULL: + + > SELECT ASCII('2'); + -> 50 + > SELECT ASCII(2); + -> 50 + > SELECT ASCII('dx'); + -> 100 + + */ + class OOp_Ascii : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** LENGTH(str) + OCTET_LENGTH(str) + CHAR_LENGTH(str) + CHARACTER_LENGTH(str) + Returns the length of the string str: + + > SELECT LENGTH('text'); + -> 4 + > SELECT OCTET_LENGTH('text'); + -> 4 + + */ + class OOp_CharLength : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** CHAR(N,...) + CHAR() interprets the arguments as integers and returns a string consisting of the characters given by the ASCII code values of those integers. NULL values are skipped: + + > SELECT CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t')); + -> 'test' + > SELECT CHAR(77,77.3,'77.3'); + -> 'MMM' + + */ + class OOp_Char : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + + /** CONCAT(str1,str2,...) + Returns the string that results from concatenating the arguments. Returns NULL if any argument is NULL. May have more than 2 arguments. A numeric argument is converted to the equivalent string form: + + > SELECT CONCAT('OO', 'o', 'OO'); + -> 'OOoOO' + > SELECT CONCAT('OO', NULL, 'OO'); + -> NULL + > SELECT CONCAT(14.3); + -> '14.3' + + */ + class OOp_Concat : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + + /** LOCATE(substr,str) + POSITION(substr IN str) + Returns the position of the first occurrence of substring substr in string str. Returns 0 if substr is not in str: + + > SELECT LOCATE('bar', 'foobarbar'); + -> 4 + > SELECT LOCATE('xbar', 'foobar'); + -> 0 + LOCATE(substr,str,pos) + Returns the position of the first occurrence of substring substr in string str, starting at position pos. Returns 0 if substr is not in str: + + > SELECT LOCATE('bar', 'foobarbar',5); + -> 7 + + */ + class OOp_Locate : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + + /** SUBSTRING(str,pos) + SUBSTRING(str FROM pos) + Returns a substring from string str starting at position pos: + + > SELECT SUBSTRING('Quadratically',5); + -> 'ratically' + > SELECT SUBSTRING('foobarbar' FROM 4); + -> 'barbar' + SUBSTRING(str,pos,len) + SUBSTRING(str FROM pos FOR len) + Returns a substring len characters long from string str, starting at position pos. The variant form that uses FROM is SQL-92 syntax: + + > SELECT SUBSTRING('Quadratically',5,6); + -> 'ratica' + + */ + class OOp_SubString : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + + /** LTRIM(str) + Returns the string str with leading space characters removed: + + > SELECT LTRIM(' barbar'); + -> 'barbar' + + */ + class OOp_LTrim : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** RTRIM(str) + Returns the string str with trailing space characters removed: + + > SELECT RTRIM('barbar '); + -> 'barbar' + + */ + class OOp_RTrim : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** SPACE(N) + Returns a string consisting of N space characters: + + > SELECT SPACE(6); + -> ' ' + + */ + class OOp_Space : public OUnaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs) const; + }; + + /** REPLACE(str,from_str,to_str) + Returns the string str with all occurrences of the string from_str replaced by the string to_str: + + > SELECT REPLACE('www.OOo.com', 'w', 'Ww'); + -> 'WwWwWw.OOo.com' + + */ + class OOp_Replace : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + + /** REPEAT(str,count) + Returns a string consisting of the string str repeated count times. If count <= 0, returns an empty string. Returns NULL if str or count are NULL: + + > SELECT REPEAT('OOo', 3); + -> 'OOoOOoOOo' + + */ + class OOp_Repeat : public OBinaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const; + }; + + /** INSERT(str,pos,len,newstr) + Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr: + + > SELECT INSERT('Quadratic', 3, 4, 'What'); + -> 'QuWhattic' + + */ + class OOp_Insert : public ONthOperator + { + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const; + }; + + /** LEFT(str,len) + Returns the leftmost len characters from the string str: + + > SELECT LEFT('foobarbar', 5); + -> 'fooba' + + */ + class OOp_Left : public OBinaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const; + }; + + /** RIGHT(str,len) + Returns the rightmost len characters from the string str: + + > SELECT RIGHT('foobarbar', 4); + -> 'rbar' + */ + class OOp_Right : public OBinaryOperator + { + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const; + }; + } +} + +#endif // _CONNECTIVITY_FILE_FCODE_HXX_ + diff --git a/connectivity/source/inc/file/FTable.hxx b/connectivity/source/inc/file/FTable.hxx new file mode 100644 index 000000000000..bc4cd450f931 --- /dev/null +++ b/connectivity/source/inc/file/FTable.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_TABLE_HXX_ +#define _CONNECTIVITY_FILE_TABLE_HXX_ + +#include "connectivity/sdbcx/VTable.hxx" +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#ifndef _CONNECTIVITY_FILE_BCONNECTION_HXX_ +#include "file/FConnection.hxx" +#endif +#include "file/filedllapi.hxx" +#include <tools/stream.hxx> +#include "connectivity/FValue.hxx" +#include "TResultSetHelper.hxx" + +namespace connectivity +{ + namespace file + { + typedef connectivity::sdbcx::OTable OTable_TYPEDEF; + + class OOO_DLLPUBLIC_FILE OFileTable : public OTable_TYPEDEF + { + protected: + OConnection* m_pConnection; + SvStream* m_pFileStream; + ::vos::ORef<OSQLColumns> m_aColumns; + sal_Int32 m_nFilePos; // aktuelle IResultSetHelper::Movement + sal_uInt8* m_pBuffer; + sal_uInt16 m_nBufferSize; // Groesse des ReadBuffer, wenn pBuffer != NULL + sal_Bool m_bWriteable; // svstream cann't say if we are writeable + // so we have to + + virtual void FileClose(); + virtual ~OFileTable( ); + public: + virtual void refreshColumns(); + virtual void refreshKeys(); + virtual void refreshIndexes(); + public: + OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection); + OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description = ::rtl::OUString(), + const ::rtl::OUString& _SchemaName = ::rtl::OUString(), + const ::rtl::OUString& _CatalogName = ::rtl::OUString() + ); + + //XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + + OConnection* getConnection() const { return m_pConnection;} + virtual sal_Int32 getCurrentLastPos() const {return -1;} + + virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) = 0; + virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool _bUseTableDefs,sal_Bool bRetrieveData) = 0; + + ::vos::ORef<OSQLColumns> getTableColumns() const {return m_aColumns;} + virtual BOOL InsertRow(OValueRefVector& rRow, BOOL bFlush,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols); + virtual BOOL DeleteRow(const OSQLColumns& _rCols); + virtual BOOL UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols); + virtual void addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& descriptor); + virtual void dropColumn(sal_Int32 _nPos); + // refresh the header of file based tables to see changes done by someone + virtual void refreshHeader(); + + ::rtl::OUString SAL_CALL getName() throw() { return m_Name; } + + ::rtl::OUString getSchema() { return m_SchemaName; } + sal_Bool isReadOnly() const { return !m_bWriteable; } + // m_pFileStream && !m_pFileStream->IsWritable(); } + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + + sal_Int32 getFilePos() const { return m_nFilePos; } + + public: + // helper + + // creates a stream using ::utl::UcbStreamHelper::CreateStream, but the error is simplified + // (NULL or non-NULL is returned) + static SvStream* createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode); + }; + } +} +#endif // _CONNECTIVITY_FILE_TABLE_HXX_ + diff --git a/connectivity/source/inc/file/FTables.hxx b/connectivity/source/inc/file/FTables.hxx new file mode 100644 index 000000000000..4a15985c248b --- /dev/null +++ b/connectivity/source/inc/file/FTables.hxx @@ -0,0 +1,61 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_TABLES_HXX_ +#define _CONNECTIVITY_FILE_TABLES_HXX_ + +#include "file/filedllapi.hxx" +#include "connectivity/sdbcx/VCollection.hxx" +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> + +namespace connectivity +{ + namespace file + { + class OOO_DLLPUBLIC_FILE SAL_NO_VTABLE OTables : + public sdbcx::OCollection + { + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + + virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + public: + OTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, + const TStringVector &_rVector) : sdbcx::OCollection(_rParent,_rMetaData->storesMixedCaseQuotedIdentifiers(),_rMutex,_rVector) + ,m_xMetaData(_rMetaData) + {} + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + + // only the name is identical to ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + }; + } +} +#endif // _CONNECTIVITY_FILE_TABLES_HXX_ + diff --git a/connectivity/source/inc/file/fanalyzer.hxx b/connectivity/source/inc/file/fanalyzer.hxx new file mode 100644 index 000000000000..c882b760765a --- /dev/null +++ b/connectivity/source/inc/file/fanalyzer.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_FANALYZER_HXX_ +#define _CONNECTIVITY_FILE_FANALYZER_HXX_ + +#include "file/fcomp.hxx" +#include "file/filedllapi.hxx" + +namespace connectivity +{ + namespace file + { + class OConnection; + class OOO_DLLPUBLIC_FILE OSQLAnalyzer + { + typedef ::std::list<OEvaluateSet*> OEvaluateSetList; + typedef ::std::pair< ::vos::ORef<OPredicateCompiler>,::vos::ORef<OPredicateInterpreter> > TPredicates; + + ::std::vector< TPredicates > m_aSelectionEvaluations; + ::vos::ORef<OPredicateCompiler> m_aCompiler; + ::vos::ORef<OPredicateInterpreter> m_aInterpreter; + OConnection* m_pConnection; + + mutable sal_Bool m_bHasSelectionCode; + mutable sal_Bool m_bSelectionFirstTime; + + void bindRow(OCodeList& rCodeList,const OValueRefRow& _pRow,OEvaluateSetList& _rEvaluateSetList); + + public: + OSQLAnalyzer(OConnection* _pConnection); + virtual ~OSQLAnalyzer(); + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint ) SAL_THROW( () ) + { return _pHint; } + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW( () ) + { } + + OConnection* getConnection() const { return m_pConnection; } + void describeParam(::vos::ORef<OSQLColumns> rParameterColumns); // genauere Beschreibung der Parameter + ::std::vector<sal_Int32>* bindEvaluationRow(OValueRefRow& _pRow); // Anbinden einer Ergebniszeile an die Restrictions + /** bind the select columns if they contain a function which needs a row value + @param _pRow the result row + */ + void bindSelectRow(const OValueRefRow& _pRow); + + /** binds the row to parameter for the restrictions + @param _pRow the parameter row + */ + void bindParameterRow(OValueRefRow& _pRow); + + void setIndexes(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xIndexes); + + void dispose(); + void start(OSQLParseNode* pSQLParseNode); + void clean(); + virtual BOOL hasRestriction() const; + virtual BOOL hasFunctions() const; + inline BOOL evaluateRestriction() { return m_aInterpreter->start(); } + void setSelectionEvaluationResult(OValueRefRow& _pRow,const ::std::vector<sal_Int32>& _rColumnMapping); + void setOrigColumns(const OFileColumns& rCols); + virtual OOperandAttr* createOperandAttr(sal_Int32 _nPos, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xCol, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xIndexes=NULL); + }; + } +} +#endif // _CONNECTIVITY_FILE_FANALYZER_HXX_ + diff --git a/connectivity/source/inc/file/fcode.hxx b/connectivity/source/inc/file/fcode.hxx new file mode 100644 index 000000000000..7a2125206549 --- /dev/null +++ b/connectivity/source/inc/file/fcode.hxx @@ -0,0 +1,396 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_FILE_FCODE_HXX_ +#define _CONNECTIVITY_FILE_FCODE_HXX_ + +#include "connectivity/sqliterator.hxx" +#include <com/sun/star/sdbc/DataType.hpp> +#include "connectivity/CommonTools.hxx" +#include <tools/rtti.hxx> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include "connectivity/FValue.hxx" +#include "file/filedllapi.hxx" + +namespace connectivity +{ + class OSQLParseNode; + namespace dbase + { + class ODbaseIndex; + } + namespace file + { + + class OOperand; + typedef ::std::stack<OOperand*> OCodeStack; + class OBoolOperator; + typedef ::std::map<sal_Int32,sal_Int32> OEvaluateSet; + + typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> OFileColumns; + + + class OOO_DLLPUBLIC_FILE OCode + { + public: + OCode(); + virtual ~OCode(); + + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint ) SAL_THROW( () ) + { return _pHint; } + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW( () ) + { } + + TYPEINFO(); + }; + + + // operands that the parsetree generate + class OOO_DLLPUBLIC_FILE OOperand : public OCode + { + protected: + sal_Int32 m_eDBType; + + OOperand(const sal_Int32& _rType) : m_eDBType(_rType){} + OOperand() : m_eDBType(::com::sun::star::sdbc::DataType::OTHER){} + + public: + virtual const ORowSetValue& getValue() const = 0; + virtual void setValue(const ORowSetValue& _rVal) = 0; + + virtual sal_Int32 getDBType() const {return m_eDBType;} + virtual OEvaluateSet* preProcess(OBoolOperator* pOp, OOperand* pRight = 0); + inline sal_Bool isValid() const; + + TYPEINFO(); + }; + + class OOO_DLLPUBLIC_FILE OOperandRow : public OOperand + { + sal_uInt16 m_nRowPos; + protected: + OValueRefRow m_pRow; + + OOperandRow(sal_uInt16 _nPos, sal_Int32 _rType); + public: + sal_uInt16 getRowPos() const {return m_nRowPos;} + virtual const ORowSetValue& getValue() const; + virtual void setValue(const ORowSetValue& _rVal); + void bindValue(const OValueRefRow& _pRow); // Bindung an den Wert, den der Operand repraesentiert + + TYPEINFO(); + }; + + // Attribute aus einer Ergebniszeile + class OOO_DLLPUBLIC_FILE OOperandAttr : public OOperandRow + { + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xColumn; + + public: + OOperandAttr(sal_uInt16 _nPos, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn); + + virtual sal_Bool isIndexed() const; + virtual OEvaluateSet* preProcess(OBoolOperator* pOp, OOperand* pRight = 0); + TYPEINFO(); + }; + + // Parameter fuer ein Praedikat + class OOperandParam : public OOperandRow + { + public: + OOperandParam(connectivity::OSQLParseNode* pNode, sal_Int32 _nPos); + void describe(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn, ::vos::ORef<connectivity::OSQLColumns> _xParamColumns); + + TYPEINFO(); + }; + + // WerteOperanden + class OOperandValue : public OOperand + { + protected: + ORowSetValue m_aValue; + + protected: + OOperandValue(){} + OOperandValue(const ORowSetValue& _rVar, sal_Int32 eDbType) + : OOperand(eDbType) + , m_aValue(_rVar) + {} + + OOperandValue(sal_Int32 eDbType) :OOperand(eDbType){} + public: + virtual const ORowSetValue& getValue() const; + virtual void setValue(const ORowSetValue& _rVal); + + TYPEINFO(); + }; + + + // Konstanten + class OOperandConst : public OOperandValue + { + public: + OOperandConst(const connectivity::OSQLParseNode& rColumnRef, const rtl::OUString& aStrValue); + + TYPEINFO(); + }; + + + // Ergebnis Operanden + class OOperandResult : public OOperandValue + { + protected: + OOperandResult(const ORowSetValue& _rVar, sal_Int32 eDbType) + :OOperandValue(_rVar, eDbType) {} + OOperandResult(sal_Int32 eDbType) + :OOperandValue(eDbType) {} + public: + OOperandResult(const ORowSetValue& _rVar) + :OOperandValue(_rVar, _rVar.getTypeKind()) {} + TYPEINFO(); + }; + + + class OOperandResultBOOL : public OOperandResult + { + public: + OOperandResultBOOL(sal_Bool bResult) : OOperandResult(::com::sun::star::sdbc::DataType::BIT) + { + m_aValue = bResult ? 1.0 : 0.0; + m_aValue.setBound(sal_True); + } + }; + + class OOperandResultNUM : public OOperandResult + { + public: + OOperandResultNUM(double fNum) : OOperandResult(::com::sun::star::sdbc::DataType::DOUBLE) + { + m_aValue = fNum; + m_aValue.setBound(sal_True); + } + }; + + /** special stop operand + is appended when a list of arguments ends + */ + class OStopOperand : public OOperandValue + { + public: + OStopOperand(){} + TYPEINFO(); + }; + + // Operatoren + class OOO_DLLPUBLIC_FILE OOperator : public OCode + { + public: + virtual void Exec(OCodeStack&) = 0; + virtual sal_uInt16 getRequestedOperands() const; // Anzahl benoetigter Operanden + // Standard ist 2 + TYPEINFO(); + }; + + + // boolsche Operatoren + + class OOO_DLLPUBLIC_FILE OBoolOperator : public OOperator + { + public: + TYPEINFO(); + virtual void Exec(OCodeStack&); + virtual sal_Bool operate(const OOperand*, const OOperand*) const; + }; + + class OOp_NOT : public OBoolOperator + { + public: + TYPEINFO(); + + protected: + virtual void Exec(OCodeStack&); + virtual sal_Bool operate(const OOperand*, const OOperand* = NULL) const; + virtual sal_uInt16 getRequestedOperands() const; + }; + + class OOp_AND : public OBoolOperator + { + public: + TYPEINFO(); + + protected: + virtual sal_Bool operate(const OOperand*, const OOperand*) const; + }; + + class OOp_OR : public OBoolOperator + { + public: + TYPEINFO(); + protected: + virtual sal_Bool operate(const OOperand*, const OOperand*) const; + }; + + class OOO_DLLPUBLIC_FILE OOp_ISNULL : public OBoolOperator + { + public: + TYPEINFO(); + public: + virtual void Exec(OCodeStack&); + virtual sal_uInt16 getRequestedOperands() const; + virtual sal_Bool operate(const OOperand*, const OOperand* = NULL) const; + }; + + class OOO_DLLPUBLIC_FILE OOp_ISNOTNULL : public OOp_ISNULL + { + public: + TYPEINFO(); + virtual sal_Bool operate(const OOperand*, const OOperand* = NULL) const; + }; + + class OOO_DLLPUBLIC_FILE OOp_LIKE : public OBoolOperator + { + public: + TYPEINFO(); + protected: + const sal_Unicode cEscape; + + public: + OOp_LIKE(const sal_Unicode cEsc = L'\0'):cEscape(cEsc){}; + + virtual sal_Bool operate(const OOperand*, const OOperand*) const; + }; + + class OOp_NOTLIKE : public OOp_LIKE + { + public: + TYPEINFO(); + public: + OOp_NOTLIKE(const sal_Unicode cEsc = L'\0'):OOp_LIKE(cEsc){}; + + virtual sal_Bool operate(const OOperand*, const OOperand*) const; + }; + + class OOO_DLLPUBLIC_FILE OOp_COMPARE : public OBoolOperator + { + sal_Int32 aPredicateType; + + public: + TYPEINFO(); + OOp_COMPARE(sal_Int32 aPType) + :aPredicateType(aPType) {} + + inline sal_Int32 getPredicateType() const { return aPredicateType; } + virtual sal_Bool operate(const OOperand*, const OOperand*) const; + }; + + // numerische Operatoren + + class ONumOperator : public OOperator + { + public: + virtual void Exec(OCodeStack&); + + TYPEINFO(); + + protected: + virtual double operate(const double& fLeft,const double& fRight) const = 0; + }; + + class OOp_ADD : public ONumOperator + { + protected: + virtual double operate(const double& fLeft,const double& fRight) const; + }; + + class OOp_SUB : public ONumOperator + { + protected: + virtual double operate(const double& fLeft,const double& fRight) const; + }; + + class OOp_MUL : public ONumOperator + { + protected: + virtual double operate(const double& fLeft,const double& fRight) const; + }; + + class OOp_DIV : public ONumOperator + { + protected: + virtual double operate(const double& fLeft,const double& fRight) const; + }; + + inline sal_Bool OOperand::isValid() const + { + return getValue().getDouble() != double(0.0); + } + + // operator + class ONthOperator : public OOperator + { + public: + virtual void Exec(OCodeStack&); + + TYPEINFO(); + + protected: + virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const = 0; + }; + + class OBinaryOperator : public OOperator + { + public: + virtual void Exec(OCodeStack&); + + TYPEINFO(); + + protected: + virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const = 0; + }; + + class OUnaryOperator : public OOperator + { + public: + virtual void Exec(OCodeStack&); + virtual sal_uInt16 getRequestedOperands() const; + virtual ORowSetValue operate(const ORowSetValue& lhs) const = 0; + + TYPEINFO(); + + }; + } +} + +#endif // _CONNECTIVITY_FILE_FCODE_HXX_ + diff --git a/connectivity/source/inc/file/fcomp.hxx b/connectivity/source/inc/file/fcomp.hxx new file mode 100644 index 000000000000..b46d24ddd089 --- /dev/null +++ b/connectivity/source/inc/file/fcomp.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CONNECTIVITY_FILE_FCOMP_HXX_ +#define _CONNECTIVITY_FILE_FCOMP_HXX_ + +#include "file/fcode.hxx" +#include "file/filedllapi.hxx" +#ifndef _LIST_ +#include <list> +#endif + +namespace connectivity +{ + class OSQLParseNode; + namespace file + { + class OCode; + class OOperand; + class OSQLAnalyzer; + typedef::std::vector<OCode*> OCodeList; + + class OPredicateCompiler : public ::vos::OReference + { + friend class OPredicateInterpreter; + friend class OSQLAnalyzer; + + OCodeList m_aCodeList; + OFileColumns m_orgColumns; // in filecurs this are the filecolumns + OSQLAnalyzer* m_pAnalyzer; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xIndexes; + sal_Int32 m_nParamCounter; + sal_Bool m_bORCondition; + public: + OPredicateCompiler(OSQLAnalyzer* pAnalyzer); + + virtual ~OPredicateCompiler(); + + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint ) SAL_THROW( () ) + { return _pHint; } + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW( () ) + { } + void dispose(); + + void start(connectivity::OSQLParseNode* pSQLParseNode); + OOperand* execute(connectivity::OSQLParseNode* pPredicateNode); + + void Clean(); + sal_Bool isClean() const {return m_aCodeList.empty();} + sal_Bool hasCode() const {return !isClean();} + sal_Bool hasORCondition() const {return m_bORCondition;} + void setOrigColumns(const OFileColumns& rCols) { m_orgColumns = rCols; } + const OFileColumns getOrigColumns() const { return m_orgColumns; } + protected: + OOperand* execute_COMPARE(connectivity::OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + OOperand* execute_LIKE(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + OOperand* execute_BETWEEN(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + OOperand* execute_ISNULL(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + OOperand* execute_Operand(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + OOperand* execute_Fold(OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + OOperand* executeFunction(OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + + + class OPredicateInterpreter : + public ::vos::OReference + { + OCodeStack m_aStack; + ::vos::ORef<OPredicateCompiler> m_rCompiler; + + public: + OPredicateInterpreter(const ::vos::ORef<OPredicateCompiler>& rComp) : m_rCompiler(rComp){} + virtual ~OPredicateInterpreter(); + + sal_Bool evaluate(OCodeList& rCodeList); + void evaluateSelection(OCodeList& rCodeList,ORowSetValueDecoratorRef& _rVal); + + inline sal_Bool start() + { + return evaluate(m_rCompiler->m_aCodeList); + } + + inline void startSelection(ORowSetValueDecoratorRef& _rVal) + { + return evaluateSelection(m_rCompiler->m_aCodeList,_rVal); + } + + + }; + } +} +#endif // _CONNECTIVITY_FILE_FCOMP_HXX_ + diff --git a/connectivity/source/inc/file/filedllapi.hxx b/connectivity/source/inc/file/filedllapi.hxx new file mode 100644 index 000000000000..11f98fa80690 --- /dev/null +++ b/connectivity/source/inc/file/filedllapi.hxx @@ -0,0 +1,40 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FILEDLLAPI_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FILEDLLAPI_HXX + +#include "sal/config.h" + +#include "sal/types.h" + +#if defined OOO_DLLIMPLEMENTATION_FILE +#define OOO_DLLPUBLIC_FILE SAL_DLLPUBLIC_EXPORT +#else +#define OOO_DLLPUBLIC_FILE SAL_DLLPUBLIC_IMPORT +#endif + +#endif diff --git a/connectivity/source/inc/file/quotedstring.hxx b/connectivity/source/inc/file/quotedstring.hxx new file mode 100644 index 000000000000..cb9215a014b2 --- /dev/null +++ b/connectivity/source/inc/file/quotedstring.hxx @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef CONNECTIVITY_QUOTED_STRING_HXX +#define CONNECTIVITY_QUOTED_STRING_HXX + +#include <tools/string.hxx> +#include "file/filedllapi.hxx" + +namespace connectivity +{ + //================================================================== + // Ableitung von String mit ueberladenen GetToken/GetTokenCount-Methoden + // Speziell fuer FLAT FILE-Format: Strings koennen gequotet sein + //================================================================== + class OOO_DLLPUBLIC_FILE QuotedTokenizedString + { + String m_sString; + public: + QuotedTokenizedString() {} + QuotedTokenizedString(const String& _sString) : m_sString(_sString){} + + xub_StrLen GetTokenCount( sal_Unicode cTok , sal_Unicode cStrDel ) const; + void GetTokenSpecial( String& _rStr,xub_StrLen& nStartPos, sal_Unicode cTok = ';', sal_Unicode cStrDel = '\0' ) const; + inline String& GetString() { return m_sString; } + inline xub_StrLen Len() const { return m_sString.Len(); } + inline operator String&() { return m_sString; } + }; +} + +#endif // CONNECTIVITY_QUOTED_STRING_HXX |