LCOV - code coverage report
Current view: top level - connectivity/source/inc/dbase - DTable.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 2 0.0 %
Date: 2014-04-14 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef _CONNECTIVITY_DBASE_TABLE_HXX_
      21             : #define _CONNECTIVITY_DBASE_TABLE_HXX_
      22             : 
      23             : #include "file/FTable.hxx"
      24             : #include "connectivity/sdbcx/VColumn.hxx"
      25             : #include "connectivity/CommonTools.hxx"
      26             : #include <tools/urlobj.hxx>
      27             : 
      28             : 
      29             : namespace connectivity
      30             : {
      31             :     namespace dbase
      32             :     {
      33             :         typedef file::OFileTable ODbaseTable_BASE;
      34             :         class ODbaseConnection;
      35             : 
      36           0 :         class ODbaseTable : public ODbaseTable_BASE
      37             :         {
      38             :         // The first byte of a dBase file specifies its type
      39             :         public:
      40             :             enum DBFType  { dBaseIII         = 0x03,
      41             :                             dBaseIV          = 0x04,
      42             :                             dBaseV           = 0x05,
      43             :                             VisualFoxPro     = 0x30,
      44             :                             VisualFoxProAuto = 0x31, // Visual FoxPro with AutoIncrement field
      45             :                             dBaseFS          = 0x43,
      46             :                             dBaseFSMemo      = 0xB3,
      47             :                             dBaseIIIMemo     = 0x83,
      48             :                             dBaseIVMemo      = 0x8B,
      49             :                             dBaseIVMemoSQL   = 0x8E,
      50             :                             FoxProMemo       = 0xF5
      51             :                           };
      52             :             enum DBFMemoType {  MemodBaseIII = 0,
      53             :                                 MemodBaseIV,
      54             :                                 MemoFoxPro
      55             :                             };
      56             : 
      57             :         private:
      58             :             struct DBFHeader {                       /* Header struct */
      59             :                                 DBFType      db_typ;                        /* File type                    */
      60             :                                 sal_uInt8    db_aedat[3];                   /* Date of last change          */
      61             :                                                                             /* YY MM DD                     */
      62             :                                 sal_uInt32  db_anz;                         /* Data set count               */
      63             :                                 sal_uInt16  db_kopf;                        /* Header length                */
      64             :                                 sal_uInt16  db_slng;                        /* Data set length              */
      65             :                                 sal_uInt8   db_frei[20];                    /* Reserved                     */
      66             :                             };
      67             :             struct DBFColumn {                       /* Column descriptors */
      68             :                                 sal_uInt8    db_fnm[11];                     /* Field name                  */
      69             :                                 sal_uInt8    db_typ;                         /* Field type                  */
      70             :                                 sal_uInt32   db_adr;                         /* Field address               */
      71             :                                 sal_uInt8    db_flng;                        /* Field length                */
      72             :                                 sal_uInt8    db_dez;                         /* Decimal places for N        */
      73             :                                 sal_uInt8    db_frei2[14];                   /* Reserved                    */
      74             :                             };
      75             :             struct DBFMemoHeader
      76             :                             {
      77             :                                 DBFMemoType db_typ;                         /* File type                    */
      78             :                                 sal_uInt32  db_next;                        /* Next free block              */
      79             :                                 sal_uInt16  db_size;                        /* Block size: dBase 3 fixed    */
      80             :                             };
      81             : 
      82             :             ::std::vector<sal_Int32> m_aTypes;      // holds all types for columns just to avoid to ask the propertyset
      83             :             ::std::vector<sal_Int32> m_aPrecisions; // same as above
      84             :             ::std::vector<sal_Int32> m_aScales;
      85             :             ::std::vector<sal_Int32> m_aRealFieldLengths;
      86             :             DBFHeader       m_aHeader;
      87             :             DBFMemoHeader   m_aMemoHeader;
      88             :             SvStream*       m_pMemoStream;
      89             :             rtl_TextEncoding m_eEncoding;
      90             :             sal_Bool        m_bWriteableMemo;
      91             : 
      92             :             void alterColumn(sal_Int32 index,
      93             :                              const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& descriptor ,
      94             :                              const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XDataDescriptorFactory>& xOldColumn );
      95             :             void readHeader();
      96             :             void fillColumns();
      97             :             OUString createTempFile();
      98             :             void copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos);
      99             :             sal_Bool CreateFile(const INetURLObject& aFile, sal_Bool& bCreateMemo);
     100             :             sal_Bool CreateMemoFile(const INetURLObject& aFile);
     101           0 :             sal_Bool HasMemoFields() const { return m_aHeader.db_typ > dBaseIV;}
     102             :             sal_Bool ReadMemoHeader();
     103             :             sal_Bool ReadMemo(sal_Size nBlockNo, ORowSetValue& aVariable);
     104             : 
     105             :             sal_Bool WriteMemo(const ORowSetValue& aVariable, sal_Size& rBlockNr);
     106             :             sal_Bool WriteBuffer();
     107             :             sal_Bool UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols, bool bForceAllFields);
     108             :             ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> isUniqueByColumnName(sal_Int32 _nColumnPos);
     109             :             void AllocBuffer();
     110             : 
     111             :             void throwInvalidDbaseFormat();
     112             :             void SAL_CALL renameImpl( const OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
     113             :             void throwInvalidColumnType(const sal_uInt16 _nErrorId,const OUString& _sColumnName);
     114             : 
     115             :         protected:
     116             :             virtual void FileClose() SAL_OVERRIDE;
     117             : //          using ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper;
     118             : 
     119             :         public:
     120             :             virtual void refreshColumns() SAL_OVERRIDE;
     121             :             virtual void refreshIndexes() SAL_OVERRIDE;
     122             : 
     123             :         public:
     124             :             ODbaseTable( sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection);
     125             :             ODbaseTable( sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection,
     126             :                     const OUString& _Name,
     127             :                     const OUString& _Type,
     128             :                     const OUString& _Description = OUString(),
     129             :                     const OUString& _SchemaName = OUString(),
     130             :                     const OUString& _CatalogName = OUString()
     131             :                 );
     132             : 
     133             :             void construct() SAL_OVERRIDE; // can throw any exception
     134             : 
     135             :             virtual sal_Int32 getCurrentLastPos() const SAL_OVERRIDE;
     136             :             virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) SAL_OVERRIDE;
     137             :             virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool _bUseTableDefs,sal_Bool bRetrieveData) SAL_OVERRIDE;
     138             : 
     139             :             virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     140             :             //XTypeProvider
     141             :             virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     142             :             virtual void SAL_CALL disposing(void) SAL_OVERRIDE;
     143             : 
     144             :             // com::sun::star::lang::XUnoTunnel
     145             :             virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     146             :             static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
     147             :             // XAlterTable
     148             :             virtual void SAL_CALL alterColumnByName( const OUString& colName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     149             :             virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     150             :             // XRename
     151             :             virtual void SAL_CALL rename( const OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     152             : 
     153             :             sal_Bool    DropImpl();
     154             :             sal_Bool    CreateImpl();
     155             : 
     156             : 
     157             :             virtual sal_Bool InsertRow(OValueRefVector& rRow, sal_Bool bFlush,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols) SAL_OVERRIDE;
     158             :             virtual sal_Bool DeleteRow(const OSQLColumns& _rCols) SAL_OVERRIDE;
     159             :             virtual sal_Bool UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols) SAL_OVERRIDE;
     160             : 
     161             :             virtual void addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& descriptor) SAL_OVERRIDE;
     162             :             virtual void dropColumn(sal_Int32 _nPos) SAL_OVERRIDE;
     163             : 
     164             :             static OUString   getEntry(file::OConnection* _pConnection,const OUString& _sURL );
     165             :             static sal_Bool     Drop_Static(const OUString& _sUrl,sal_Bool _bHasMemoFields,sdbcx::OCollection* _pIndexes );
     166             : 
     167             :             virtual void refreshHeader() SAL_OVERRIDE;
     168             : 
     169             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const SAL_OVERRIDE;
     170             :         };
     171             :     }
     172             : }
     173             : #endif // _CONNECTIVITY_DBASE_TABLE_HXX_
     174             : 
     175             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10