diff options
Diffstat (limited to 'connectivity/source/inc/dbase')
-rw-r--r-- | connectivity/source/inc/dbase/DCatalog.hxx | 16 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DColumns.hxx | 30 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DConnection.hxx | 32 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DDatabaseMetaData.hxx | 56 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DDriver.hxx | 26 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DIndex.hxx | 192 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DIndexColumns.hxx | 32 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DIndexIter.hxx | 60 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DIndexes.hxx | 40 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DPreparedStatement.hxx | 18 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DResultSet.hxx | 82 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DStatement.hxx | 18 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DTable.hxx | 286 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DTables.hxx | 32 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/dindexnode.hxx | 530 |
15 files changed, 725 insertions, 725 deletions
diff --git a/connectivity/source/inc/dbase/DCatalog.hxx b/connectivity/source/inc/dbase/DCatalog.hxx index f8954d012211..9004080aedf6 100644 --- a/connectivity/source/inc/dbase/DCatalog.hxx +++ b/connectivity/source/inc/dbase/DCatalog.hxx @@ -22,16 +22,16 @@ #include <file/FCatalog.hxx> namespace connectivity::dbase +{ + class ODbaseConnection; + class ODbaseCatalog : public file::OFileCatalog { - class ODbaseConnection; - class ODbaseCatalog : public file::OFileCatalog - { - public: - virtual void refreshTables() override; +public: + virtual void refreshTables() override; - public: - ODbaseCatalog(ODbaseConnection* _pCon); - }; + public: + ODbaseCatalog(ODbaseConnection* _pCon); + }; } diff --git a/connectivity/source/inc/dbase/DColumns.hxx b/connectivity/source/inc/dbase/DColumns.hxx index c9bbf2eebe90..5237ef67b5a7 100644 --- a/connectivity/source/inc/dbase/DColumns.hxx +++ b/connectivity/source/inc/dbase/DColumns.hxx @@ -22,22 +22,22 @@ #include <file/FColumns.hxx> namespace connectivity::dbase +{ + class ODbaseColumns : public file::OColumns { - class ODbaseColumns : public file::OColumns - { - protected: - virtual css::uno::Reference< css::beans::XPropertySet > createObject(const OUString& _rName) override; - virtual void impl_refresh() override; - virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; - virtual css::uno::Reference< css::beans::XPropertySet > appendObject( const OUString& _rForName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; - virtual void dropObject(sal_Int32 _nPos, const OUString& _sElementName) override; - public: - ODbaseColumns(file::OFileTable* _pTable, - ::osl::Mutex& _rMutex, - const ::std::vector< OUString> &_rVector - ) : file::OColumns(_pTable,_rMutex,_rVector) - {} - }; + protected: + virtual css::uno::Reference< css::beans::XPropertySet > createObject(const OUString& _rName) override; + virtual void impl_refresh() override; + virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; + virtual css::uno::Reference< css::beans::XPropertySet > appendObject( const OUString& _rForName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; + virtual void dropObject(sal_Int32 _nPos, const OUString& _sElementName) override; + public: + ODbaseColumns(file::OFileTable* _pTable, + ::osl::Mutex& _rMutex, + const ::std::vector< OUString> &_rVector + ) : file::OColumns(_pTable,_rMutex,_rVector) + {} + }; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/dbase/DConnection.hxx b/connectivity/source/inc/dbase/DConnection.hxx index 864e9a22c870..26a51efb8e8b 100644 --- a/connectivity/source/inc/dbase/DConnection.hxx +++ b/connectivity/source/inc/dbase/DConnection.hxx @@ -22,24 +22,24 @@ #include <file/FConnection.hxx> namespace connectivity::dbase +{ + class ODriver; + class ODbaseConnection : public file::OConnection { - class ODriver; - class ODbaseConnection : public file::OConnection - { - protected: - virtual ~ODbaseConnection() override; - public: - ODbaseConnection(ODriver* _pDriver); - // XServiceInfo - DECLARE_SERVICE_INFO(); + protected: + virtual ~ODbaseConnection() override; + public: + ODbaseConnection(ODriver* _pDriver); + // XServiceInfo + DECLARE_SERVICE_INFO(); - // XConnection - virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) override; - virtual css::uno::Reference< css::sdbcx::XTablesSupplier > createCatalog() override; - virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement( ) override; - virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) override; - virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) override; - }; + // XConnection + virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) override; + virtual css::uno::Reference< css::sdbcx::XTablesSupplier > createCatalog() override; + virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement( ) override; + virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) override; + virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) override; + }; } diff --git a/connectivity/source/inc/dbase/DDatabaseMetaData.hxx b/connectivity/source/inc/dbase/DDatabaseMetaData.hxx index fed3fcc70ea9..05a7fd8c8614 100644 --- a/connectivity/source/inc/dbase/DDatabaseMetaData.hxx +++ b/connectivity/source/inc/dbase/DDatabaseMetaData.hxx @@ -22,35 +22,35 @@ #include <file/FDatabaseMetaData.hxx> namespace connectivity::dbase - { +{ + + //************ Class: java.sql.DatabaseMetaDataDate - //************ Class: java.sql.DatabaseMetaDataDate - - - class ODbaseDatabaseMetaData : public file::ODatabaseMetaData - { - virtual css::uno::Reference< css::sdbc::XResultSet > impl_getTypeInfo_throw() override; - virtual sal_Bool SAL_CALL isReadOnly( ) override; - virtual OUString SAL_CALL getURL( ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getColumns( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const OUString& columnNamePattern ) override; - virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getIndexInfo( const css::uno::Any& catalog, const OUString& schema, const OUString& table, sal_Bool unique, sal_Bool approximate ) override; - - virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) override; - virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) override; - virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) override; - - virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) override; - virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) override; - - virtual bool impl_storesMixedCaseQuotedIdentifiers_throw( ) override; - virtual bool impl_supportsMixedCaseQuotedIdentifiers_throw( ) override; - protected: - virtual ~ODbaseDatabaseMetaData() override; - public: - ODbaseDatabaseMetaData(file::OConnection* _pCon); - }; + + class ODbaseDatabaseMetaData : public file::ODatabaseMetaData + { + virtual css::uno::Reference< css::sdbc::XResultSet > impl_getTypeInfo_throw() override; + virtual sal_Bool SAL_CALL isReadOnly( ) override; + virtual OUString SAL_CALL getURL( ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getColumns( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const OUString& columnNamePattern ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getIndexInfo( const css::uno::Any& catalog, const OUString& schema, const OUString& table, sal_Bool unique, sal_Bool approximate ) override; + + virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) override; + virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) override; + virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) override; + virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) override; + virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) override; + + virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) override; + virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) override; + + virtual bool impl_storesMixedCaseQuotedIdentifiers_throw( ) override; + virtual bool impl_supportsMixedCaseQuotedIdentifiers_throw( ) override; + protected: + virtual ~ODbaseDatabaseMetaData() override; + public: + ODbaseDatabaseMetaData(file::OConnection* _pCon); + }; } diff --git a/connectivity/source/inc/dbase/DDriver.hxx b/connectivity/source/inc/dbase/DDriver.hxx index 310f9b1dc8d5..e832d8ad91eb 100644 --- a/connectivity/source/inc/dbase/DDriver.hxx +++ b/connectivity/source/inc/dbase/DDriver.hxx @@ -24,22 +24,22 @@ #include <file/FDriver.hxx> namespace connectivity::dbase - { - /// @throws css::uno::Exception - css::uno::Reference< css::uno::XInterface > ODriver_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory); +{ + /// @throws css::uno::Exception + css::uno::Reference< css::uno::XInterface > ODriver_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory); - class ODriver : public file::OFileDriver - { - public: - ODriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext) : file::OFileDriver(_rxContext){} + class ODriver : public file::OFileDriver + { + public: + ODriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext) : file::OFileDriver(_rxContext){} - OUString SAL_CALL getImplementationName( ) override; + OUString SAL_CALL getImplementationName( ) override; - // XDriver - virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override; - virtual sal_Bool SAL_CALL acceptsURL( const OUString& url ) override; - virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override; - }; + // XDriver + virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override; + virtual sal_Bool SAL_CALL acceptsURL( const OUString& url ) override; + virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override; + }; } diff --git a/connectivity/source/inc/dbase/DIndex.hxx b/connectivity/source/inc/dbase/DIndex.hxx index 3cc7da9ad1d3..9b3755913644 100644 --- a/connectivity/source/inc/dbase/DIndex.hxx +++ b/connectivity/source/inc/dbase/DIndex.hxx @@ -26,109 +26,109 @@ inline constexpr OString dBASE_III_GROUP = "dBase III"_ostr; namespace connectivity::dbase +{ + class OIndexIterator; + class ONDXKey; + + typedef sdbcx::OIndex ODbaseIndex_BASE; + + class ODbaseIndex : public ODbaseIndex_BASE { - class OIndexIterator; - class ONDXKey; + friend SvStream& WriteODbaseIndex(SvStream &rStream, const ODbaseIndex&); + friend SvStream& operator >> (SvStream &rStream, ODbaseIndex&); + + friend class ONDXNode; + friend class ONDXPage; + friend class ONDXPagePtr; + friend class OIndexIterator; - typedef sdbcx::OIndex ODbaseIndex_BASE; + public: - class ODbaseIndex : public ODbaseIndex_BASE + // Header struct - stays in memory + + struct NDXHeader { - friend SvStream& WriteODbaseIndex(SvStream &rStream, const ODbaseIndex&); - friend SvStream& operator >> (SvStream &rStream, ODbaseIndex&); - - friend class ONDXNode; - friend class ONDXPage; - friend class ONDXPagePtr; - friend class OIndexIterator; - - public: - - // Header struct - stays in memory - - struct NDXHeader - { - sal_uInt32 db_rootpage; /* Rootpage position */ - sal_uInt32 db_pagecount; /* Page count */ - sal_uInt8 db_free[4]; /* Reserved */ - sal_uInt16 db_keylen; /* Key length */ - sal_uInt16 db_maxkeys; /* Maximum number of keys per page */ - sal_uInt16 db_keytype; /* Type of key: - 0 = Text - 1 = Numerical */ - sal_uInt16 db_keyrec; /* Length of an index record - RecordNumber + keylen */ - sal_uInt8 db_free1[3]; /* Reserved */ - sal_uInt8 db_unique; /* Unique */ - char db_name[488]; /* index_name (field name) */ - }; - - private: - std::unique_ptr<SvStream> m_pFileStream; // Stream to read/write the index - NDXHeader m_aHeader = {}; - std::vector<ONDXPage*> - m_aCollector; // Pool of obsolete pages - ONDXPagePtr m_aRoot, // Root of the B+ tree - m_aCurLeaf; // Current leaf - sal_uInt16 m_nCurNode; // Position of the current node - - sal_uInt32 m_nPageCount, - m_nRootPage; - - ODbaseTable* m_pTable; - bool m_bUseCollector : 1; // Use the Garbage Collector - - OUString getCompletePath() const; - void closeImpl(); - // Closes and kills the index file and throws an error - void impl_killFileAndthrowError_throw(TranslateId pErrorId, const OUString& _sFile); - protected: - virtual ~ODbaseIndex() override; - public: - ODbaseIndex(ODbaseTable* _pTable); - ODbaseIndex(ODbaseTable* _pTable,const NDXHeader& _aHeader,const OUString& Name); - - void openIndexFile(); - virtual void refreshColumns() override; - - const ODbaseTable* getTable() const { return m_pTable; } - const NDXHeader& getHeader() const { return m_aHeader; } - std::unique_ptr<OIndexIterator> createIterator(); - - void SetRootPos(sal_uInt32 nPos) {m_nRootPage = nPos;} - void SetPageCount(sal_uInt32 nCount) {m_nPageCount = nCount;} - - sal_uInt32 GetPageCount() const {return m_nPageCount;} - - sal_uInt16 GetMaxNodes() const {return m_aHeader.db_maxkeys;} - - bool Insert(sal_uInt32 nRec, const ORowSetValue& rValue); - bool Update(sal_uInt32 nRec, const ORowSetValue&, const ORowSetValue&); - bool Delete(sal_uInt32 nRec, const ORowSetValue& rValue); - bool Find(sal_uInt32 nRec, const ORowSetValue& rValue); - - void createINFEntry(); - void CreateImpl(); - void DropImpl(); - - DECLARE_SERVICE_INFO(); - protected: - - ONDXPage* CreatePage(sal_uInt32 nPagePos, ONDXPage* pParent = nullptr, bool bLoad = false); - void Collect(ONDXPage*); - ONDXPagePtr const & getRoot(); - - bool isUnique() const { return m_IsUnique; } - bool UseCollector() const {return m_bUseCollector;} - // Tree operations - void Release(bool bSave = true); - bool ConvertToKey(ONDXKey* rKey, sal_uInt32 nRec, const ORowSetValue& rValue); + sal_uInt32 db_rootpage; /* Rootpage position */ + sal_uInt32 db_pagecount; /* Page count */ + sal_uInt8 db_free[4]; /* Reserved */ + sal_uInt16 db_keylen; /* Key length */ + sal_uInt16 db_maxkeys; /* Maximum number of keys per page */ + sal_uInt16 db_keytype; /* Type of key: + 0 = Text + 1 = Numerical */ + sal_uInt16 db_keyrec; /* Length of an index record + RecordNumber + keylen */ + sal_uInt8 db_free1[3]; /* Reserved */ + sal_uInt8 db_unique; /* Unique */ + char db_name[488]; /* index_name (field name) */ }; - SvStream& WriteODbaseIndex(SvStream &rStream, const ODbaseIndex&); - SvStream& operator >> (SvStream &rStream, ODbaseIndex&); + private: + std::unique_ptr<SvStream> m_pFileStream; // Stream to read/write the index + NDXHeader m_aHeader = {}; + std::vector<ONDXPage*> + m_aCollector; // Pool of obsolete pages + ONDXPagePtr m_aRoot, // Root of the B+ tree + m_aCurLeaf; // Current leaf + sal_uInt16 m_nCurNode; // Position of the current node + + sal_uInt32 m_nPageCount, + m_nRootPage; + + ODbaseTable* m_pTable; + bool m_bUseCollector : 1; // Use the Garbage Collector + + OUString getCompletePath() const; + void closeImpl(); + // Closes and kills the index file and throws an error + void impl_killFileAndthrowError_throw(TranslateId pErrorId, const OUString& _sFile); + protected: + virtual ~ODbaseIndex() override; + public: + ODbaseIndex(ODbaseTable* _pTable); + ODbaseIndex(ODbaseTable* _pTable,const NDXHeader& _aHeader,const OUString& Name); + + void openIndexFile(); + virtual void refreshColumns() override; + + const ODbaseTable* getTable() const { return m_pTable; } + const NDXHeader& getHeader() const { return m_aHeader; } + std::unique_ptr<OIndexIterator> createIterator(); + + void SetRootPos(sal_uInt32 nPos) {m_nRootPage = nPos;} + void SetPageCount(sal_uInt32 nCount) {m_nPageCount = nCount;} + + sal_uInt32 GetPageCount() const {return m_nPageCount;} + + sal_uInt16 GetMaxNodes() const {return m_aHeader.db_maxkeys;} + + bool Insert(sal_uInt32 nRec, const ORowSetValue& rValue); + bool Update(sal_uInt32 nRec, const ORowSetValue&, const ORowSetValue&); + bool Delete(sal_uInt32 nRec, const ORowSetValue& rValue); + bool Find(sal_uInt32 nRec, const ORowSetValue& rValue); + + void createINFEntry(); + void CreateImpl(); + void DropImpl(); + + DECLARE_SERVICE_INFO(); + protected: + + ONDXPage* CreatePage(sal_uInt32 nPagePos, ONDXPage* pParent = nullptr, bool bLoad = false); + void Collect(ONDXPage*); + ONDXPagePtr const & getRoot(); + + bool isUnique() const { return m_IsUnique; } + bool UseCollector() const {return m_bUseCollector;} + // Tree operations + void Release(bool bSave = true); + bool ConvertToKey(ONDXKey* rKey, sal_uInt32 nRec, const ORowSetValue& rValue); + }; + + SvStream& WriteODbaseIndex(SvStream &rStream, const ODbaseIndex&); + SvStream& operator >> (SvStream &rStream, ODbaseIndex&); - void ReadHeader(SvStream & rStream, ODbaseIndex::NDXHeader & rHeader); + void ReadHeader(SvStream & rStream, ODbaseIndex::NDXHeader & rHeader); } diff --git a/connectivity/source/inc/dbase/DIndexColumns.hxx b/connectivity/source/inc/dbase/DIndexColumns.hxx index eaf2f5cc0ccf..0d97cea113f6 100644 --- a/connectivity/source/inc/dbase/DIndexColumns.hxx +++ b/connectivity/source/inc/dbase/DIndexColumns.hxx @@ -24,24 +24,24 @@ #include <dbase/DTable.hxx> namespace connectivity::dbase +{ + class ODbaseIndexColumns : public sdbcx::OCollection { - class ODbaseIndexColumns : public sdbcx::OCollection - { - ODbaseIndex* m_pIndex; - protected: - virtual css::uno::Reference< css::beans::XPropertySet > createObject(const OUString& _rName) override; - virtual void impl_refresh() override; - virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; - virtual css::uno::Reference< css::beans::XPropertySet > appendObject( const OUString& _rForName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; - public: - ODbaseIndexColumns( ODbaseIndex* _pIndex, - ::osl::Mutex& _rMutex, - const ::std::vector< OUString> &_rVector) - : sdbcx::OCollection(*_pIndex,_pIndex->getTable()->getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers(),_rMutex,_rVector) - , m_pIndex(_pIndex) - {} + ODbaseIndex* m_pIndex; + protected: + virtual css::uno::Reference< css::beans::XPropertySet > createObject(const OUString& _rName) override; + virtual void impl_refresh() override; + virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; + virtual css::uno::Reference< css::beans::XPropertySet > appendObject( const OUString& _rForName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; + public: + ODbaseIndexColumns( ODbaseIndex* _pIndex, + ::osl::Mutex& _rMutex, + const ::std::vector< OUString> &_rVector) + : sdbcx::OCollection(*_pIndex,_pIndex->getTable()->getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers(),_rMutex,_rVector) + , m_pIndex(_pIndex) + {} - }; + }; } diff --git a/connectivity/source/inc/dbase/DIndexIter.hxx b/connectivity/source/inc/dbase/DIndexIter.hxx index 2de327be1138..353f1081b9db 100644 --- a/connectivity/source/inc/dbase/DIndexIter.hxx +++ b/connectivity/source/inc/dbase/DIndexIter.hxx @@ -24,43 +24,43 @@ #include <dbase/dindexnode.hxx> namespace connectivity::dbase - { +{ - // IndexIterator + // IndexIterator - class OIndexIterator final - { - file::OBoolOperator* m_pOperator; - const file::OOperand* m_pOperand; - rtl::Reference<ODbaseIndex> m_xIndex; - ONDXPagePtr m_aRoot, - m_aCurLeaf; - sal_uInt16 m_nCurNode; + class OIndexIterator final + { + file::OBoolOperator* m_pOperator; + const file::OOperand* m_pOperand; + rtl::Reference<ODbaseIndex> m_xIndex; + ONDXPagePtr m_aRoot, + m_aCurLeaf; + sal_uInt16 m_nCurNode; - sal_uInt32 Find(bool bFirst); - sal_uInt32 GetCompare(bool bFirst); - sal_uInt32 GetLike(bool bFirst); - sal_uInt32 GetNull(bool bFirst); - sal_uInt32 GetNotNull(bool bFirst); + sal_uInt32 Find(bool bFirst); + sal_uInt32 GetCompare(bool bFirst); + sal_uInt32 GetLike(bool bFirst); + sal_uInt32 GetNull(bool bFirst); + sal_uInt32 GetNotNull(bool bFirst); - ONDXKey* GetFirstKey(ONDXPage* pPage, - const file::OOperand& rKey); - ONDXKey* GetNextKey(); + ONDXKey* GetFirstKey(ONDXPage* pPage, + const file::OOperand& rKey); + ONDXKey* GetNextKey(); - public: - OIndexIterator(ODbaseIndex* pInd) - :m_pOperator(nullptr) - ,m_pOperand(nullptr) - ,m_xIndex(pInd) - ,m_nCurNode(NODE_NOTFOUND) - { - } + public: + OIndexIterator(ODbaseIndex* pInd) + :m_pOperator(nullptr) + ,m_pOperand(nullptr) + ,m_xIndex(pInd) + ,m_nCurNode(NODE_NOTFOUND) + { + } - ~OIndexIterator(); - sal_uInt32 First(); - sal_uInt32 Next(); + ~OIndexIterator(); + sal_uInt32 First(); + sal_uInt32 Next(); - }; + }; } diff --git a/connectivity/source/inc/dbase/DIndexes.hxx b/connectivity/source/inc/dbase/DIndexes.hxx index aadb531f4107..73987dbe700e 100644 --- a/connectivity/source/inc/dbase/DIndexes.hxx +++ b/connectivity/source/inc/dbase/DIndexes.hxx @@ -23,27 +23,27 @@ #include <dbase/DTable.hxx> namespace connectivity::dbase +{ + class ODbaseTable; + + typedef sdbcx::OCollection ODbaseIndexes_BASE; + + class ODbaseIndexes : public ODbaseIndexes_BASE { - class ODbaseTable; - - typedef sdbcx::OCollection ODbaseIndexes_BASE; - - class ODbaseIndexes : public ODbaseIndexes_BASE - { - ODbaseTable* m_pTable; - protected: - virtual css::uno::Reference< css::beans::XPropertySet > createObject(const OUString& _rName) override; - virtual void impl_refresh() override; - virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; - virtual css::uno::Reference< css::beans::XPropertySet > appendObject( const OUString& _rForName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; - virtual void dropObject(sal_Int32 _nPos, const OUString& _sElementName) override; - public: - ODbaseIndexes(ODbaseTable* _pTable, ::osl::Mutex& _rMutex, - const ::std::vector< OUString> &_rVector) : ODbaseIndexes_BASE(*_pTable,_pTable->getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers(),_rMutex,_rVector) - , m_pTable(_pTable) - {} - - }; + ODbaseTable* m_pTable; + protected: + virtual css::uno::Reference< css::beans::XPropertySet > createObject(const OUString& _rName) override; + virtual void impl_refresh() override; + virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; + virtual css::uno::Reference< css::beans::XPropertySet > appendObject( const OUString& _rForName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; + virtual void dropObject(sal_Int32 _nPos, const OUString& _sElementName) override; + public: + ODbaseIndexes(ODbaseTable* _pTable, ::osl::Mutex& _rMutex, + const ::std::vector< OUString> &_rVector) : ODbaseIndexes_BASE(*_pTable,_pTable->getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers(),_rMutex,_rVector) + , m_pTable(_pTable) + {} + + }; } diff --git a/connectivity/source/inc/dbase/DPreparedStatement.hxx b/connectivity/source/inc/dbase/DPreparedStatement.hxx index a2a792f62342..55f73e6d1913 100644 --- a/connectivity/source/inc/dbase/DPreparedStatement.hxx +++ b/connectivity/source/inc/dbase/DPreparedStatement.hxx @@ -22,16 +22,16 @@ #include <file/FPreparedStatement.hxx> namespace connectivity::dbase +{ + class OConnection; + class ODbasePreparedStatement : public file::OPreparedStatement { - class OConnection; - class ODbasePreparedStatement : public file::OPreparedStatement - { - protected: - virtual rtl::Reference<file::OResultSet> createResultSet() override; - public: - ODbasePreparedStatement( file::OConnection* _pConnection) : file::OPreparedStatement( _pConnection){} - DECLARE_SERVICE_INFO(); - }; + protected: + virtual rtl::Reference<file::OResultSet> createResultSet() override; + public: + ODbasePreparedStatement( file::OConnection* _pConnection) : file::OPreparedStatement( _pConnection){} + DECLARE_SERVICE_INFO(); + }; } diff --git a/connectivity/source/inc/dbase/DResultSet.hxx b/connectivity/source/inc/dbase/DResultSet.hxx index 106a63cbb842..4dfbc3317c2c 100644 --- a/connectivity/source/inc/dbase/DResultSet.hxx +++ b/connectivity/source/inc/dbase/DResultSet.hxx @@ -24,54 +24,54 @@ #include <cppuhelper/implbase2.hxx> namespace connectivity::dbase - { - class ODbaseResultSet; - // these typedef's are only necessary for the compiler - typedef ::cppu::ImplHelper2< css::sdbcx::XRowLocate, - css::sdbcx::XDeleteRows> ODbaseResultSet_BASE; - typedef file::OResultSet ODbaseResultSet_BASE2; - typedef ::comphelper::OPropertyArrayUsageHelper<ODbaseResultSet> ODbaseResultSet_BASE3; +{ + class ODbaseResultSet; + // these typedef's are only necessary for the compiler + typedef ::cppu::ImplHelper2< css::sdbcx::XRowLocate, + css::sdbcx::XDeleteRows> ODbaseResultSet_BASE; + typedef file::OResultSet ODbaseResultSet_BASE2; + typedef ::comphelper::OPropertyArrayUsageHelper<ODbaseResultSet> ODbaseResultSet_BASE3; - class ODbaseResultSet : public ODbaseResultSet_BASE2, - public ODbaseResultSet_BASE, - public ODbaseResultSet_BASE3 - { - bool m_bBookmarkable; - protected: - // OPropertyArrayUsageHelper - virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override; - // OPropertySetHelper - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; - virtual bool fillIndexValues(const css::uno::Reference< css::sdbcx::XColumnsSupplier> &_xIndex) override; - public: - DECLARE_SERVICE_INFO(); + class ODbaseResultSet : public ODbaseResultSet_BASE2, + public ODbaseResultSet_BASE, + public ODbaseResultSet_BASE3 + { + bool m_bBookmarkable; + protected: + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + virtual bool fillIndexValues(const css::uno::Reference< css::sdbcx::XColumnsSupplier> &_xIndex) override; + public: + DECLARE_SERVICE_INFO(); - ODbaseResultSet( file::OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator); + ODbaseResultSet( file::OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator); - // XInterface - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - virtual void SAL_CALL acquire() noexcept override; - virtual void SAL_CALL release() noexcept override; - //XTypeProvider - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; - // XPropertySet - virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; - // XRowLocate - virtual css::uno::Any SAL_CALL getBookmark( ) override; - virtual sal_Bool SAL_CALL moveToBookmark( const css::uno::Any& bookmark ) override; - virtual sal_Bool SAL_CALL moveRelativeToBookmark( const css::uno::Any& bookmark, sal_Int32 rows ) override; - virtual sal_Int32 SAL_CALL compareBookmarks( const css::uno::Any& first, const css::uno::Any& second ) override; - virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) override; - virtual sal_Int32 SAL_CALL hashBookmark( const css::uno::Any& bookmark ) override; - // XDeleteRows - virtual css::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const css::uno::Sequence< css::uno::Any >& rows ) override; + // XRowLocate + virtual css::uno::Any SAL_CALL getBookmark( ) override; + virtual sal_Bool SAL_CALL moveToBookmark( const css::uno::Any& bookmark ) override; + virtual sal_Bool SAL_CALL moveRelativeToBookmark( const css::uno::Any& bookmark, sal_Int32 rows ) override; + virtual sal_Int32 SAL_CALL compareBookmarks( const css::uno::Any& first, const css::uno::Any& second ) override; + virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) override; + virtual sal_Int32 SAL_CALL hashBookmark( const css::uno::Any& bookmark ) override; + // XDeleteRows + virtual css::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const css::uno::Sequence< css::uno::Any >& rows ) override; - // own methods - sal_Int32 getCurrentFilePos() const; + // own methods + sal_Int32 getCurrentFilePos() const; - }; + }; } diff --git a/connectivity/source/inc/dbase/DStatement.hxx b/connectivity/source/inc/dbase/DStatement.hxx index cb4b1d8e4a03..83fc73aa2b9c 100644 --- a/connectivity/source/inc/dbase/DStatement.hxx +++ b/connectivity/source/inc/dbase/DStatement.hxx @@ -22,16 +22,16 @@ #include <file/FStatement.hxx> namespace connectivity::dbase +{ + class OConnection; + class ODbaseStatement : public file::OStatement { - class OConnection; - class ODbaseStatement : public file::OStatement - { - protected: - virtual rtl::Reference<file::OResultSet> createResultSet() override; - public: - ODbaseStatement( file::OConnection* _pConnection) : file::OStatement( _pConnection){} - DECLARE_SERVICE_INFO(); - }; + protected: + virtual rtl::Reference<file::OResultSet> createResultSet() override; + public: + ODbaseStatement( file::OConnection* _pConnection) : file::OStatement( _pConnection){} + DECLARE_SERVICE_INFO(); + }; } diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx index bb0b6baa5fa2..ea7d8e8a6626 100644 --- a/connectivity/source/inc/dbase/DTable.hxx +++ b/connectivity/source/inc/dbase/DTable.hxx @@ -25,166 +25,166 @@ namespace connectivity::dbase - { - typedef file::OFileTable ODbaseTable_BASE; - class ODbaseConnection; +{ + typedef file::OFileTable ODbaseTable_BASE; + class ODbaseConnection; - class ODbaseTable : public ODbaseTable_BASE + class ODbaseTable : public ODbaseTable_BASE + { + // The first byte of a dBase file specifies its type + public: + enum DBFType { dBaseIII = 0x03, + dBaseIV = 0x04, + dBaseV = 0x05, + VisualFoxPro = 0x30, + VisualFoxProAuto = 0x31, // Visual FoxPro with AutoIncrement field + dBaseFS = 0x43, + dBaseFSMemo = 0xB3, + dBaseIIIMemo = 0x83, + dBaseIVMemo = 0x8B, + dBaseIVMemoSQL = 0x8E, + FoxProMemo = 0xF5 + }; + enum DBFMemoType { MemodBaseIII = 0, + MemodBaseIV, + MemoFoxPro + }; + + private: + // sources: https://www.clicketyclick.dk/databases/xbase/format/dbf.html (dBASE III and 5) + // http://www.dbase.com/KnowledgeBase/int/db7_file_fmt.htm (dBASE 7) which is similar at least for this part + struct DBFHeader { // address/pos in trailer + DBFType type; // dBASE/xBASE type, see DBFType 00h + sal_uInt8 dateElems[3]; // Date of last change (YYMMDD) 01h + sal_uInt32 nbRecords; // Number of records 04h + sal_uInt16 headerLength; // 08h + sal_uInt16 recordLength; // Length of 1 record 10h + sal_uInt8 trailer[20]; + // this last field contains these data: + // - reserved:2 bytes:should be filled with 0 12h/0 + // - incomplete transaction:1 byte:dBASE IV 14h/2 + // 00h Transaction ended (or rolled back) + // 01h Transaction started + // - encryptionFlag:1 byte: dBASE IV 15h/3 + // 00h not encrypted + // 01h for encrypted + // - freeRecordThread:4 bytes:reserved for LAN only 16h/4 + // - multiUserdBASE:8 bytes:reserved for multi-user dBASE (dBASE III+) 20h/8 + // - MDXFlag:1 byte:dBASE IV 28h/16 + // 0x01 if a production .MDX file exists for this table + // 0x00 if no .MDX file exists + // - languageDriver:1 byte:codepage (from Foxpro) 29h/17 + // - reserved:2 bytes: should be filled with 0 30h/18 + }; + struct DBFColumn { /* Column descriptors */ + sal_uInt8 db_fnm[11]; /* Field name */ + sal_uInt8 db_typ; /* Field type */ + sal_uInt32 db_adr; /* Field address */ + sal_uInt8 db_flng; /* Field length */ + sal_uInt8 db_dez; /* Decimal places for N */ + sal_uInt8 db_free2[14]; /* Reserved */ + }; + struct DBFMemoHeader { - // The first byte of a dBase file specifies its type - public: - enum DBFType { dBaseIII = 0x03, - dBaseIV = 0x04, - dBaseV = 0x05, - VisualFoxPro = 0x30, - VisualFoxProAuto = 0x31, // Visual FoxPro with AutoIncrement field - dBaseFS = 0x43, - dBaseFSMemo = 0xB3, - dBaseIIIMemo = 0x83, - dBaseIVMemo = 0x8B, - dBaseIVMemoSQL = 0x8E, - FoxProMemo = 0xF5 - }; - enum DBFMemoType { MemodBaseIII = 0, - MemodBaseIV, - MemoFoxPro - }; - - private: - // sources: https://www.clicketyclick.dk/databases/xbase/format/dbf.html (dBASE III and 5) - // http://www.dbase.com/KnowledgeBase/int/db7_file_fmt.htm (dBASE 7) which is similar at least for this part - struct DBFHeader { // address/pos in trailer - DBFType type; // dBASE/xBASE type, see DBFType 00h - sal_uInt8 dateElems[3]; // Date of last change (YYMMDD) 01h - sal_uInt32 nbRecords; // Number of records 04h - sal_uInt16 headerLength; // 08h - sal_uInt16 recordLength; // Length of 1 record 10h - sal_uInt8 trailer[20]; - // this last field contains these data: - // - reserved:2 bytes:should be filled with 0 12h/0 - // - incomplete transaction:1 byte:dBASE IV 14h/2 - // 00h Transaction ended (or rolled back) - // 01h Transaction started - // - encryptionFlag:1 byte: dBASE IV 15h/3 - // 00h not encrypted - // 01h for encrypted - // - freeRecordThread:4 bytes:reserved for LAN only 16h/4 - // - multiUserdBASE:8 bytes:reserved for multi-user dBASE (dBASE III+) 20h/8 - // - MDXFlag:1 byte:dBASE IV 28h/16 - // 0x01 if a production .MDX file exists for this table - // 0x00 if no .MDX file exists - // - languageDriver:1 byte:codepage (from Foxpro) 29h/17 - // - reserved:2 bytes: should be filled with 0 30h/18 - }; - struct DBFColumn { /* Column descriptors */ - sal_uInt8 db_fnm[11]; /* Field name */ - sal_uInt8 db_typ; /* Field type */ - sal_uInt32 db_adr; /* Field address */ - sal_uInt8 db_flng; /* Field length */ - sal_uInt8 db_dez; /* Decimal places for N */ - sal_uInt8 db_free2[14]; /* Reserved */ - }; - struct DBFMemoHeader + DBFMemoType db_typ; /* File type */ + sal_uInt32 db_next; /* Next free block */ + sal_uInt16 db_size; /* Block size: dBase 3 fixed */ + DBFMemoHeader() + : db_typ(MemodBaseIII) + , db_next(0) + , db_size(0) { - DBFMemoType db_typ; /* File type */ - sal_uInt32 db_next; /* Next free block */ - sal_uInt16 db_size; /* Block size: dBase 3 fixed */ - DBFMemoHeader() - : db_typ(MemodBaseIII) - , db_next(0) - , db_size(0) - { - } - }; - - std::vector<sal_Int32> m_aTypes; // holds all types for columns just to avoid to ask the propertyset - std::vector<sal_Int32> m_aPrecisions; // same as above - std::vector<sal_Int32> m_aScales; - std::vector<sal_Int32> m_aRealFieldLengths; - DBFHeader m_aHeader = {}; - DBFMemoHeader m_aMemoHeader; - std::unique_ptr<SvStream> m_pMemoStream; - rtl_TextEncoding m_eEncoding; - - void alterColumn(sal_Int32 index, - const css::uno::Reference< css::beans::XPropertySet>& descriptor , - const css::uno::Reference< css::sdbcx::XDataDescriptorFactory>& xOldColumn ); - void readHeader(); - void fillColumns(); - OUString createTempFile(); - void copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos); - bool CreateFile(const INetURLObject& aFile, bool& bCreateMemo); - bool CreateMemoFile(const INetURLObject& aFile); - bool HasMemoFields() const; - void ReadMemoHeader(); - bool ReadMemo(std::size_t nBlockNo, ORowSetValue& aVariable); - - void WriteMemo(const ORowSetValue& aVariable, std::size_t& rBlockNr); - bool WriteBuffer(); - bool UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRow, const css::uno::Reference< css::container::XIndexAccess>& _xCols, bool bForceAllFields); - css::uno::Reference< css::beans::XPropertySet> isUniqueByColumnName(sal_Int32 _nColumnPos); - bool AllocBuffer(); - - void throwInvalidDbaseFormat(); - /// @throws css::sdbc::SQLException - /// @throws css::container::ElementExistException - /// @throws css::uno::RuntimeException - void renameImpl( const OUString& newName ); - void throwInvalidColumnType(TranslateId pErrorId, const OUString& _sColumnName); - - protected: - virtual void FileClose() override; + } + }; + + std::vector<sal_Int32> m_aTypes; // holds all types for columns just to avoid to ask the propertyset + std::vector<sal_Int32> m_aPrecisions; // same as above + std::vector<sal_Int32> m_aScales; + std::vector<sal_Int32> m_aRealFieldLengths; + DBFHeader m_aHeader = {}; + DBFMemoHeader m_aMemoHeader; + std::unique_ptr<SvStream> m_pMemoStream; + rtl_TextEncoding m_eEncoding; + + void alterColumn(sal_Int32 index, + const css::uno::Reference< css::beans::XPropertySet>& descriptor , + const css::uno::Reference< css::sdbcx::XDataDescriptorFactory>& xOldColumn ); + void readHeader(); + void fillColumns(); + OUString createTempFile(); + void copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos); + bool CreateFile(const INetURLObject& aFile, bool& bCreateMemo); + bool CreateMemoFile(const INetURLObject& aFile); + bool HasMemoFields() const; + void ReadMemoHeader(); + bool ReadMemo(std::size_t nBlockNo, ORowSetValue& aVariable); + + void WriteMemo(const ORowSetValue& aVariable, std::size_t& rBlockNr); + bool WriteBuffer(); + bool UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRow, const css::uno::Reference< css::container::XIndexAccess>& _xCols, bool bForceAllFields); + css::uno::Reference< css::beans::XPropertySet> isUniqueByColumnName(sal_Int32 _nColumnPos); + bool AllocBuffer(); + + void throwInvalidDbaseFormat(); + /// @throws css::sdbc::SQLException + /// @throws css::container::ElementExistException + /// @throws css::uno::RuntimeException + void renameImpl( const OUString& newName ); + void throwInvalidColumnType(TranslateId pErrorId, const OUString& _sColumnName); + + protected: + virtual void FileClose() override; // using ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper; - public: - virtual void refreshColumns() override; - virtual void refreshIndexes() override; + public: + virtual void refreshColumns() override; + virtual void refreshIndexes() override; - public: - ODbaseTable( sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection); - ODbaseTable( sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection, - const OUString& Name, - const OUString& Type, - const OUString& Description = OUString(), - const OUString& SchemaName = OUString(), - const OUString& CatalogName = OUString() - ); + public: + ODbaseTable( sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection); + ODbaseTable( sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection, + const OUString& Name, + const OUString& Type, + const OUString& Description = OUString(), + const OUString& SchemaName = OUString(), + const OUString& CatalogName = OUString() + ); - void construct() override; // can throw any exception + void construct() override; // can throw any exception - virtual sal_Int32 getCurrentLastPos() const override; - virtual bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) override; - virtual bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, bool bRetrieveData) override; + virtual sal_Int32 getCurrentLastPos() const override; + virtual bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) override; + virtual bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, bool bRetrieveData) override; - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - //XTypeProvider - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; - virtual void SAL_CALL disposing() override; + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual void SAL_CALL disposing() override; - // XAlterTable - virtual void SAL_CALL alterColumnByName( const OUString& colName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; - virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; - // XRename - virtual void SAL_CALL rename( const OUString& newName ) override; + // XAlterTable + virtual void SAL_CALL alterColumnByName( const OUString& colName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; + virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; + // XRename + virtual void SAL_CALL rename( const OUString& newName ) override; - bool DropImpl(); - bool CreateImpl(); + bool DropImpl(); + bool CreateImpl(); - virtual bool InsertRow(OValueRefVector& rRow, const css::uno::Reference< css::container::XIndexAccess>& _xCols) override; - virtual bool DeleteRow(const OSQLColumns& _rCols) override; - virtual bool UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const css::uno::Reference< css::container::XIndexAccess>& _xCols) override; + virtual bool InsertRow(OValueRefVector& rRow, const css::uno::Reference< css::container::XIndexAccess>& _xCols) override; + virtual bool DeleteRow(const OSQLColumns& _rCols) override; + virtual bool UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const css::uno::Reference< css::container::XIndexAccess>& _xCols) override; - virtual void addColumn(const css::uno::Reference< css::beans::XPropertySet>& descriptor) override; - virtual void dropColumn(sal_Int32 _nPos) override; + virtual void addColumn(const css::uno::Reference< css::beans::XPropertySet>& descriptor) override; + virtual void dropColumn(sal_Int32 _nPos) override; - static OUString getEntry(file::OConnection const * _pConnection, std::u16string_view _sURL ); - static bool Drop_Static(std::u16string_view _sUrl, bool _bHasMemoFields, sdbcx::OCollection* _pIndexes ); + static OUString getEntry(file::OConnection const * _pConnection, std::u16string_view _sURL ); + static bool Drop_Static(std::u16string_view _sUrl, bool _bHasMemoFields, sdbcx::OCollection* _pIndexes ); - virtual void refreshHeader() override; + virtual void refreshHeader() override; - virtual css::uno::Reference< css::sdbc::XDatabaseMetaData> getMetaData() const override; - }; + virtual css::uno::Reference< css::sdbc::XDatabaseMetaData> getMetaData() const override; + }; } diff --git a/connectivity/source/inc/dbase/DTables.hxx b/connectivity/source/inc/dbase/DTables.hxx index 058ea0802f4a..f364a3d9dd83 100644 --- a/connectivity/source/inc/dbase/DTables.hxx +++ b/connectivity/source/inc/dbase/DTables.hxx @@ -22,24 +22,24 @@ #include <file/FTables.hxx> namespace connectivity::dbase - { - typedef file::OTables ODbaseTables_BASE; +{ + typedef file::OTables ODbaseTables_BASE; - class ODbaseTables : public ODbaseTables_BASE - { - protected: - virtual css::uno::Reference< css::beans::XPropertySet > createObject(const OUString& _rName) override; - virtual void impl_refresh() override; - virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; - virtual css::uno::Reference< css::beans::XPropertySet > appendObject( const OUString& _rForName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; - virtual void dropObject(sal_Int32 _nPos, const OUString& _sElementName) override; - public: - ODbaseTables(const css::uno::Reference< css::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, - const ::std::vector< OUString> &_rVector) : ODbaseTables_BASE(_rMetaData,_rParent,_rMutex,_rVector) - {} + class ODbaseTables : public ODbaseTables_BASE + { + protected: + virtual css::uno::Reference< css::beans::XPropertySet > createObject(const OUString& _rName) override; + virtual void impl_refresh() override; + virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; + virtual css::uno::Reference< css::beans::XPropertySet > appendObject( const OUString& _rForName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; + virtual void dropObject(sal_Int32 _nPos, const OUString& _sElementName) override; + public: + ODbaseTables(const css::uno::Reference< css::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, + const ::std::vector< OUString> &_rVector) : ODbaseTables_BASE(_rMetaData,_rParent,_rMutex,_rVector) + {} - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; - }; + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + }; } diff --git a/connectivity/source/inc/dbase/dindexnode.hxx b/connectivity/source/inc/dbase/dindexnode.hxx index c1db23f76b60..181c6ff74322 100644 --- a/connectivity/source/inc/dbase/dindexnode.hxx +++ b/connectivity/source/inc/dbase/dindexnode.hxx @@ -28,277 +28,277 @@ class SvStream; namespace connectivity::dbase +{ + + class ONDXNode; + class ODbaseIndex; + + // Index Key + + typedef file::OOperand ONDXKey_BASE; + class ONDXKey : public ONDXKey_BASE { + friend class ONDXNode; + sal_uInt32 nRecord; /* Record pointer */ + ORowSetValue xValue; /* Key values */ + + public: + ONDXKey(); + ONDXKey(ORowSetValue aVal, sal_Int32 eType, sal_uInt32 nRec); + ONDXKey(const OUString& aStr, sal_uInt32 nRec); + ONDXKey(double aVal, sal_uInt32 nRec); + + inline ONDXKey(const ONDXKey& rKey); + + inline ONDXKey& operator= (const ONDXKey& rKey); + virtual void setValue(const ORowSetValue& _rVal) override; + + virtual const ORowSetValue& getValue() const override; + + sal_uInt32 GetRecord() const { return nRecord; } + void setRecord(sal_uInt32 _nRec) { nRecord = _nRec; } + void ResetRecord() { nRecord = 0; } + + bool operator == (const ONDXKey& rKey) const; + bool operator != (const ONDXKey& rKey) const; + bool operator < (const ONDXKey& rKey) const; + bool operator <= (const ONDXKey& rKey) const; + bool operator > (const ONDXKey& rKey) const; + + static bool IsText(sal_Int32 eType); - class ONDXNode; - class ODbaseIndex; - - // Index Key - - typedef file::OOperand ONDXKey_BASE; - class ONDXKey : public ONDXKey_BASE - { - friend class ONDXNode; - sal_uInt32 nRecord; /* Record pointer */ - ORowSetValue xValue; /* Key values */ - - public: - ONDXKey(); - ONDXKey(ORowSetValue aVal, sal_Int32 eType, sal_uInt32 nRec); - ONDXKey(const OUString& aStr, sal_uInt32 nRec); - ONDXKey(double aVal, sal_uInt32 nRec); - - inline ONDXKey(const ONDXKey& rKey); - - inline ONDXKey& operator= (const ONDXKey& rKey); - virtual void setValue(const ORowSetValue& _rVal) override; - - virtual const ORowSetValue& getValue() const override; - - sal_uInt32 GetRecord() const { return nRecord; } - void setRecord(sal_uInt32 _nRec) { nRecord = _nRec; } - void ResetRecord() { nRecord = 0; } - - bool operator == (const ONDXKey& rKey) const; - bool operator != (const ONDXKey& rKey) const; - bool operator < (const ONDXKey& rKey) const; - bool operator <= (const ONDXKey& rKey) const; - bool operator > (const ONDXKey& rKey) const; - - static bool IsText(sal_Int32 eType); - - private: - int Compare(const ONDXKey& rKey) const; - }; - - - class ONDXPage; - - // Index Page Pointer - // This is ref-count pointer class - class ONDXPagePtr - { - friend SvStream& WriteONDXPagePtr(SvStream &rStream, const ONDXPagePtr&); - friend SvStream& operator >> (SvStream &rStream, ONDXPagePtr&); - - ONDXPage* mpPage; - sal_uInt32 nPagePos; // Position in the index file - - public: - ONDXPagePtr(); - ONDXPagePtr(ONDXPagePtr&& rObj) noexcept; - ONDXPagePtr(ONDXPagePtr const & rRef); - ONDXPagePtr(ONDXPage* pRefPage); - ~ONDXPagePtr(); - void Clear(); - ONDXPagePtr& operator=(ONDXPagePtr const & rRef); - ONDXPagePtr& operator=(ONDXPagePtr && rRef); - bool Is() const { return mpPage != nullptr; } - - ONDXPage * operator ->() const { assert(mpPage != nullptr); return mpPage; } - operator ONDXPage *() const { return mpPage; } - - sal_uInt32 GetPagePos() const {return nPagePos;} - bool HasPage() const {return nPagePos != 0;} - }; - - // Index Page - // This is a ref-counted class, with re-cycling - class ONDXPage - { - friend class ODbaseIndex; - friend class ONDXPagePtr; - - friend SvStream& WriteONDXPage(SvStream &rStream, const ONDXPage&); - friend SvStream& operator >> (SvStream &rStream, ONDXPage&); - - // work around a clang 3.5 optimization bug: if the bNoDelete is *first* - // it mis-compiles "if (--nRefCount == 0)" and never deletes any object - unsigned int nRefCount : 31; - // the only reason this is not bool is because MSVC cannot handle mixed type bitfields - unsigned int bNoDelete : 1; - sal_uInt32 nPagePos; // Position in the index file - bool bModified : 1; - sal_uInt16 nCount; - - ONDXPagePtr aParent, // Parent page - aChild; // Pointer to the right child page - ODbaseIndex& rIndex; - std::unique_ptr<ONDXNode[]> - ppNodes; // Array of nodes - - public: - // Node operations - sal_uInt16 Count() const {return nCount;} - - bool Insert(ONDXNode& rNode, sal_uInt32 nRowsLeft = 0); - bool Insert(sal_uInt16 nIndex, ONDXNode& rNode); - bool Append(ONDXNode& rNode); - void Delete(sal_uInt16); - void Remove(sal_uInt16); - void Release(bool bSave = true); - void ReleaseFull(); - - // Split and merge - ONDXNode Split(ONDXPage& rPage); - void Merge(sal_uInt16 nParentNodePos, const ONDXPagePtr& xPage); - - // Access operators - ONDXNode& operator[] (sal_uInt16 nPos); - const ONDXNode& operator[] (sal_uInt16 nPos) const; - - bool IsRoot() const; - bool IsLeaf() const; - bool IsModified() const; - bool HasParent() const; - - bool IsFull() const; - - sal_uInt32 GetPagePos() const {return nPagePos;} - ONDXPagePtr& GetChild(ODbaseIndex const * pIndex = nullptr); - - // Parent does not need to be reloaded - const ONDXPagePtr& GetParent() const; - ODbaseIndex& GetIndex() {return rIndex;} - const ODbaseIndex& GetIndex() const {return rIndex;} - - // Setting the child, via reference to retain the PagePos - void SetChild(const ONDXPagePtr& rCh); - void SetParent(const ONDXPagePtr& rPa); - - sal_uInt16 Search(const ONDXKey& rSearch); - sal_uInt16 Search(const ONDXPage* pPage); - void SearchAndReplace(const ONDXKey& rSearch, ONDXKey const & rReplace); - - protected: - ONDXPage(ODbaseIndex& rIndex, sal_uInt32 nPos, ONDXPage*); - ~ONDXPage(); - - void ReleaseRef(); - void QueryDelete(); - void AddNextRef() - { - assert( nRefCount < (1 << 30) && "Do not add refs to dead objects" ); - ++nRefCount; - } - void AddFirstRef() - { - assert( nRefCount < (1 << 30) && "Do not add refs to dead objects" ); - if( bNoDelete ) - bNoDelete = 0; - ++nRefCount; - } - - void SetModified(bool bMod) {bModified = bMod;} - void SetPagePos(sal_uInt32 nPage) {nPagePos = nPage;} - - bool Find(const ONDXKey&); // Descend recursively - sal_uInt16 FindPos(const ONDXKey& rKey) const; + private: + int Compare(const ONDXKey& rKey) const; + }; + + + class ONDXPage; + + // Index Page Pointer + // This is ref-count pointer class + class ONDXPagePtr + { + friend SvStream& WriteONDXPagePtr(SvStream &rStream, const ONDXPagePtr&); + friend SvStream& operator >> (SvStream &rStream, ONDXPagePtr&); + + ONDXPage* mpPage; + sal_uInt32 nPagePos; // Position in the index file + + public: + ONDXPagePtr(); + ONDXPagePtr(ONDXPagePtr&& rObj) noexcept; + ONDXPagePtr(ONDXPagePtr const & rRef); + ONDXPagePtr(ONDXPage* pRefPage); + ~ONDXPagePtr(); + void Clear(); + ONDXPagePtr& operator=(ONDXPagePtr const & rRef); + ONDXPagePtr& operator=(ONDXPagePtr && rRef); + bool Is() const { return mpPage != nullptr; } + + ONDXPage * operator ->() const { assert(mpPage != nullptr); return mpPage; } + operator ONDXPage *() const { return mpPage; } + + sal_uInt32 GetPagePos() const {return nPagePos;} + bool HasPage() const {return nPagePos != 0;} + }; + + // Index Page + // This is a ref-counted class, with re-cycling + class ONDXPage + { + friend class ODbaseIndex; + friend class ONDXPagePtr; + + friend SvStream& WriteONDXPage(SvStream &rStream, const ONDXPage&); + friend SvStream& operator >> (SvStream &rStream, ONDXPage&); + + // work around a clang 3.5 optimization bug: if the bNoDelete is *first* + // it mis-compiles "if (--nRefCount == 0)" and never deletes any object + unsigned int nRefCount : 31; + // the only reason this is not bool is because MSVC cannot handle mixed type bitfields + unsigned int bNoDelete : 1; + sal_uInt32 nPagePos; // Position in the index file + bool bModified : 1; + sal_uInt16 nCount; + + ONDXPagePtr aParent, // Parent page + aChild; // Pointer to the right child page + ODbaseIndex& rIndex; + std::unique_ptr<ONDXNode[]> + ppNodes; // Array of nodes + + public: + // Node operations + sal_uInt16 Count() const {return nCount;} + + bool Insert(ONDXNode& rNode, sal_uInt32 nRowsLeft = 0); + bool Insert(sal_uInt16 nIndex, ONDXNode& rNode); + bool Append(ONDXNode& rNode); + void Delete(sal_uInt16); + void Remove(sal_uInt16); + void Release(bool bSave = true); + void ReleaseFull(); + + // Split and merge + ONDXNode Split(ONDXPage& rPage); + void Merge(sal_uInt16 nParentNodePos, const ONDXPagePtr& xPage); + + // Access operators + ONDXNode& operator[] (sal_uInt16 nPos); + const ONDXNode& operator[] (sal_uInt16 nPos) const; + + bool IsRoot() const; + bool IsLeaf() const; + bool IsModified() const; + bool HasParent() const; + + bool IsFull() const; + + sal_uInt32 GetPagePos() const {return nPagePos;} + ONDXPagePtr& GetChild(ODbaseIndex const * pIndex = nullptr); + + // Parent does not need to be reloaded + const ONDXPagePtr& GetParent() const; + ODbaseIndex& GetIndex() {return rIndex;} + const ODbaseIndex& GetIndex() const {return rIndex;} + + // Setting the child, via reference to retain the PagePos + void SetChild(const ONDXPagePtr& rCh); + void SetParent(const ONDXPagePtr& rPa); + + sal_uInt16 Search(const ONDXKey& rSearch); + sal_uInt16 Search(const ONDXPage* pPage); + void SearchAndReplace(const ONDXKey& rSearch, ONDXKey const & rReplace); + + protected: + ONDXPage(ODbaseIndex& rIndex, sal_uInt32 nPos, ONDXPage*); + ~ONDXPage(); + + void ReleaseRef(); + void QueryDelete(); + void AddNextRef() + { + assert( nRefCount < (1 << 30) && "Do not add refs to dead objects" ); + ++nRefCount; + } + void AddFirstRef() + { + assert( nRefCount < (1 << 30) && "Do not add refs to dead objects" ); + if( bNoDelete ) + bNoDelete = 0; + ++nRefCount; + } + + void SetModified(bool bMod) {bModified = bMod;} + void SetPagePos(sal_uInt32 nPage) {nPagePos = nPage;} + + bool Find(const ONDXKey&); // Descend recursively + sal_uInt16 FindPos(const ONDXKey& rKey) const; #if OSL_DEBUG_LEVEL > 1 - void PrintPage(); + void PrintPage(); #endif - }; - - SvStream& WriteONDXPagePtr(SvStream &rStream, const ONDXPagePtr&); - SvStream& operator >> (SvStream &rStream, ONDXPagePtr&); - - inline bool ONDXPage::IsRoot() const {return !aParent.Is();} - inline bool ONDXPage::IsLeaf() const {return !aChild.HasPage();} - inline bool ONDXPage::IsModified() const {return bModified;} - inline bool ONDXPage::HasParent() const {return aParent.Is();} - inline const ONDXPagePtr& ONDXPage::GetParent() const {return aParent;} - - inline void ONDXPage::SetParent(const ONDXPagePtr& rPa = ONDXPagePtr()) - { - aParent = rPa; - } - - inline void ONDXPage::SetChild(const ONDXPagePtr& rCh = ONDXPagePtr()) - { - aChild = rCh; - if (aChild.Is()) - aChild->SetParent(this); - } - SvStream& operator >> (SvStream &rStream, ONDXPage& rPage); - SvStream& WriteONDXPage(SvStream &rStream, const ONDXPage& rPage); - - - // Index Node - - class ONDXNode - { - friend class ONDXPage; - ONDXPagePtr aChild; /* Next page reference */ - ONDXKey aKey; - - public: - ONDXNode(){} - ONDXNode(const ONDXKey& rKey) - :aKey(rKey) {} - - // Does the node point to a page? - bool HasChild() const {return aChild.HasPage();} - // If an index is provided, we may be able to retrieve the page - ONDXPagePtr& GetChild(ODbaseIndex* pIndex = nullptr, ONDXPage* = nullptr); - - const ONDXKey& GetKey() const { return aKey;} - ONDXKey& GetKey() { return aKey;} - - // Setting the child, via reference to retain the PagePos - void SetChild(const ONDXPagePtr& rCh = ONDXPagePtr(), ONDXPage* = nullptr); - - void Write(SvStream &rStream, const ONDXPage& rPage) const; - void Read(SvStream &rStream, ODbaseIndex const &); - }; - - inline ONDXKey::ONDXKey(const ONDXKey& rKey) - : ONDXKey_BASE(rKey.getDBType()) - ,nRecord(rKey.nRecord) - ,xValue(rKey.xValue) - { - } - - inline ONDXKey& ONDXKey::operator=(const ONDXKey& rKey) - { - if(&rKey == this) - return *this; - - xValue = rKey.xValue; - nRecord = rKey.nRecord; - m_eDBType = rKey.getDBType(); + }; + + SvStream& WriteONDXPagePtr(SvStream &rStream, const ONDXPagePtr&); + SvStream& operator >> (SvStream &rStream, ONDXPagePtr&); + + inline bool ONDXPage::IsRoot() const {return !aParent.Is();} + inline bool ONDXPage::IsLeaf() const {return !aChild.HasPage();} + inline bool ONDXPage::IsModified() const {return bModified;} + inline bool ONDXPage::HasParent() const {return aParent.Is();} + inline const ONDXPagePtr& ONDXPage::GetParent() const {return aParent;} + + inline void ONDXPage::SetParent(const ONDXPagePtr& rPa = ONDXPagePtr()) + { + aParent = rPa; + } + + inline void ONDXPage::SetChild(const ONDXPagePtr& rCh = ONDXPagePtr()) + { + aChild = rCh; + if (aChild.Is()) + aChild->SetParent(this); + } + SvStream& operator >> (SvStream &rStream, ONDXPage& rPage); + SvStream& WriteONDXPage(SvStream &rStream, const ONDXPage& rPage); + + + // Index Node + + class ONDXNode + { + friend class ONDXPage; + ONDXPagePtr aChild; /* Next page reference */ + ONDXKey aKey; + + public: + ONDXNode(){} + ONDXNode(const ONDXKey& rKey) + :aKey(rKey) {} + + // Does the node point to a page? + bool HasChild() const {return aChild.HasPage();} + // If an index is provided, we may be able to retrieve the page + ONDXPagePtr& GetChild(ODbaseIndex* pIndex = nullptr, ONDXPage* = nullptr); + + const ONDXKey& GetKey() const { return aKey;} + ONDXKey& GetKey() { return aKey;} + + // Setting the child, via reference to retain the PagePos + void SetChild(const ONDXPagePtr& rCh = ONDXPagePtr(), ONDXPage* = nullptr); + + void Write(SvStream &rStream, const ONDXPage& rPage) const; + void Read(SvStream &rStream, ODbaseIndex const &); + }; + + inline ONDXKey::ONDXKey(const ONDXKey& rKey) + : ONDXKey_BASE(rKey.getDBType()) + ,nRecord(rKey.nRecord) + ,xValue(rKey.xValue) + { + } + + inline ONDXKey& ONDXKey::operator=(const ONDXKey& rKey) + { + if(&rKey == this) return *this; - } - - inline bool ONDXKey::operator == (const ONDXKey& rKey) const - { - if(&rKey == this) - return true; - return Compare(rKey) == 0; - } - inline bool ONDXKey::operator != (const ONDXKey& rKey) const - { - return !operator== (rKey); - } - inline bool ONDXKey::operator < (const ONDXKey& rKey) const - { - return Compare(rKey) < 0; - } - inline bool ONDXKey::operator > (const ONDXKey& rKey) const - { - return Compare(rKey) > 0; - } - inline bool ONDXKey::operator <= (const ONDXKey& rKey) const - { - return !operator > (rKey); - } - - inline void ONDXNode::SetChild(const ONDXPagePtr& rCh, ONDXPage* pParent) - { - aChild = rCh; - if (aChild.Is()) - aChild->SetParent(pParent); - } + + xValue = rKey.xValue; + nRecord = rKey.nRecord; + m_eDBType = rKey.getDBType(); + return *this; + } + + inline bool ONDXKey::operator == (const ONDXKey& rKey) const + { + if(&rKey == this) + return true; + return Compare(rKey) == 0; + } + inline bool ONDXKey::operator != (const ONDXKey& rKey) const + { + return !operator== (rKey); + } + inline bool ONDXKey::operator < (const ONDXKey& rKey) const + { + return Compare(rKey) < 0; + } + inline bool ONDXKey::operator > (const ONDXKey& rKey) const + { + return Compare(rKey) > 0; + } + inline bool ONDXKey::operator <= (const ONDXKey& rKey) const + { + return !operator > (rKey); + } + + inline void ONDXNode::SetChild(const ONDXPagePtr& rCh, ONDXPage* pParent) + { + aChild = rCh; + if (aChild.Is()) + aChild->SetParent(pParent); + } } |