LCOV - code coverage report
Current view: top level - connectivity/source/inc/dbase - DTable.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 2 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 2 50.0 %

           Branch data     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                 :            :         typedef ::std::map< ::rtl::OUString,
      37                 :            :                         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed>, comphelper::UStringMixLess > OContainer;
      38                 :            : 
      39         [ -  + ]:         56 :         class ODbaseTable : public ODbaseTable_BASE
      40                 :            :         {
      41                 :            :         // The first byte of a dBase file specifies its type
      42                 :            :         public:
      43                 :            :             enum DBFType  { dBaseIII         = 0x03,
      44                 :            :                             dBaseIV          = 0x04,
      45                 :            :                             dBaseV           = 0x05,
      46                 :            :                             VisualFoxPro     = 0x30,
      47                 :            :                             VisualFoxProAuto = 0x31, // Visual FoxPro with AutoIncrement field
      48                 :            :                             dBaseFS          = 0x43,
      49                 :            :                             dBaseFSMemo      = 0xB3,
      50                 :            :                             dBaseIIIMemo     = 0x83,
      51                 :            :                             dBaseIVMemo      = 0x8B,
      52                 :            :                             dBaseIVMemoSQL   = 0x8E,
      53                 :            :                             FoxProMemo       = 0xF5
      54                 :            :                           };
      55                 :            :             enum DBFMemoType {  MemodBaseIII = 0,
      56                 :            :                                 MemodBaseIV,
      57                 :            :                                 MemoFoxPro
      58                 :            :                             };
      59                 :            : 
      60                 :            :         private:
      61                 :            :             struct DBFHeader {                       /* Header struct */
      62                 :            :                                 DBFType      db_typ;                        /* File type                    */
      63                 :            :                                 sal_uInt8    db_aedat[3];                   /* Date of last change          */
      64                 :            :                                                                             /* YY MM DD                     */
      65                 :            :                                 sal_uInt32  db_anz;                         /* Data set count               */
      66                 :            :                                 sal_uInt16  db_kopf;                        /* Header length                */
      67                 :            :                                 sal_uInt16  db_slng;                        /* Data set length              */
      68                 :            :                                 sal_uInt8   db_frei[20];                    /* Reserved                     */
      69                 :            :                             };
      70                 :            :             struct DBFColumn {                       /* Column descriptors */
      71                 :            :                                 sal_uInt8    db_fnm[11];                     /* Field name                  */
      72                 :            :                                 sal_uInt8    db_typ;                         /* Field type                  */
      73                 :            :                                 sal_uInt32   db_adr;                         /* Field address               */
      74                 :            :                                 sal_uInt8    db_flng;                        /* Field length                */
      75                 :            :                                 sal_uInt8    db_dez;                         /* Decimal places for N        */
      76                 :            :                                 sal_uInt8    db_frei2[14];                   /* Reserved                    */
      77                 :            :                             };
      78                 :            :             struct DBFMemoHeader
      79                 :            :                             {
      80                 :            :                                 DBFMemoType db_typ;                         /* File type                    */
      81                 :            :                                 sal_uInt32  db_next;                        /* Next free block              */
      82                 :            :                                 sal_uInt16  db_size;                        /* Block size: dBase 3 fixed    */
      83                 :            :                             };
      84                 :            : 
      85                 :            :             ::std::vector<sal_Int32> m_aTypes;      // holds all types for columns just to avoid to ask the propertyset
      86                 :            :             ::std::vector<sal_Int32> m_aPrecisions; // same as above
      87                 :            :             ::std::vector<sal_Int32> m_aScales;
      88                 :            :             ::std::vector<sal_Int32> m_aRealFieldLengths;
      89                 :            :             DBFHeader       m_aHeader;
      90                 :            :             DBFMemoHeader   m_aMemoHeader;
      91                 :            :             SvStream*       m_pMemoStream;
      92                 :            :             rtl_TextEncoding m_eEncoding;
      93                 :            :             sal_Bool        m_bWriteableMemo;
      94                 :            : 
      95                 :            :             void alterColumn(sal_Int32 index,
      96                 :            :                              const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& descriptor ,
      97                 :            :                              const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XDataDescriptorFactory>& xOldColumn );
      98                 :            :             void readHeader();
      99                 :            :             void fillColumns();
     100                 :            :             String createTempFile();
     101                 :            :             void copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos);
     102                 :            :             sal_Bool CreateFile(const INetURLObject& aFile, sal_Bool& bCreateMemo);
     103                 :            :             sal_Bool CreateMemoFile(const INetURLObject& aFile);
     104                 :         38 :             sal_Bool HasMemoFields() const { return m_aHeader.db_typ > dBaseIV;}
     105                 :            :             sal_Bool ReadMemoHeader();
     106                 :            :             sal_Bool ReadMemo(sal_uIntPtr nBlockNo, ORowSetValue& aVariable);
     107                 :            : 
     108                 :            :             sal_Bool WriteMemo(ORowSetValue& aVariable, sal_uIntPtr& rBlockNr);
     109                 :            :             sal_Bool WriteBuffer();
     110                 :            :             sal_Bool UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
     111                 :            :             ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> isUniqueByColumnName(sal_Int32 _nColumnPos);
     112                 :            :             void AllocBuffer();
     113                 :            : 
     114                 :            :             void throwInvalidDbaseFormat();
     115                 :            :             void SAL_CALL renameImpl( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
     116                 :            :             void throwInvalidColumnType(const sal_uInt16 _nErrorId,const ::rtl::OUString& _sColumnName);
     117                 :            : 
     118                 :            :         protected:
     119                 :            :             virtual void FileClose();
     120                 :            : //          using ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper;
     121                 :            : 
     122                 :            :         public:
     123                 :            :             virtual void refreshColumns();
     124                 :            :             virtual void refreshIndexes();
     125                 :            : 
     126                 :            :         public:
     127                 :            :             ODbaseTable( sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection);
     128                 :            :             ODbaseTable( sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection,
     129                 :            :                     const ::rtl::OUString& _Name,
     130                 :            :                     const ::rtl::OUString& _Type,
     131                 :            :                     const ::rtl::OUString& _Description = ::rtl::OUString(),
     132                 :            :                     const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
     133                 :            :                     const ::rtl::OUString& _CatalogName = ::rtl::OUString()
     134                 :            :                 );
     135                 :            : 
     136                 :            :             void construct(); // can throw any exception
     137                 :            : 
     138                 :            :             virtual sal_Int32 getCurrentLastPos() const;
     139                 :            :             virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos);
     140                 :            :             virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool _bUseTableDefs,sal_Bool bRetrieveData);
     141                 :            : 
     142                 :            :             virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
     143                 :            :             //XTypeProvider
     144                 :            :             virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
     145                 :            :             virtual void SAL_CALL disposing(void);
     146                 :            : 
     147                 :            :             // com::sun::star::lang::XUnoTunnel
     148                 :            :             virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
     149                 :            :             static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
     150                 :            :             // XAlterTable
     151                 :            :             virtual void SAL_CALL alterColumnByName( const ::rtl::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);
     152                 :            :             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);
     153                 :            :             // XRename
     154                 :            :             virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
     155                 :            : 
     156                 :            :             sal_Bool    DropImpl();
     157                 :            :             sal_Bool    CreateImpl();
     158                 :            : 
     159                 :            : 
     160                 :            :             virtual sal_Bool InsertRow(OValueRefVector& rRow, sal_Bool bFlush,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
     161                 :            :             virtual sal_Bool DeleteRow(const OSQLColumns& _rCols);
     162                 :            :             virtual sal_Bool UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
     163                 :            : 
     164                 :            :             virtual void addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& descriptor);
     165                 :            :             virtual void dropColumn(sal_Int32 _nPos);
     166                 :            : 
     167                 :            :             static String   getEntry(file::OConnection* _pConnection,const ::rtl::OUString& _sURL );
     168                 :            :             static sal_Bool     Drop_Static(const ::rtl::OUString& _sUrl,sal_Bool _bHasMemoFields,sdbcx::OCollection* _pIndexes );
     169                 :            : 
     170                 :            :             virtual void refreshHeader();
     171                 :            : 
     172                 :            :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const;
     173                 :            :         };
     174                 :            :     }
     175                 :            : }
     176                 :            : #endif // _CONNECTIVITY_DBASE_TABLE_HXX_
     177                 :            : 
     178                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10