merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / inc / dbase / DIndex.hxx
blobaf245cc3fbb8c94f7194dfd4d16d70dbf3ae1a68
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DIndex.hxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONNECTIVITY_DBASE_INDEX_HXX_
32 #define _CONNECTIVITY_DBASE_INDEX_HXX_
34 #include "connectivity/sdbcx/VIndex.hxx"
35 #include <com/sun/star/lang/XUnoTunnel.hpp>
36 #include "dbase/DTable.hxx"
37 #include "dbase/dindexnode.hxx"
39 #define dBASE_III_GROUP "dBase III"
41 namespace connectivity
43 namespace dbase
45 class OIndexIterator;
46 class ONDXKey;
48 typedef sdbcx::OIndex ODbaseIndex_BASE;
49 typedef file::OBoolOperator OBoolOperator_BASE;
50 typedef file::OOperand OOperand_BASE;
52 class ODbaseIndex : public ODbaseIndex_BASE
54 friend SvStream& operator << (SvStream &rStream, ODbaseIndex&);
55 friend SvStream& operator >> (SvStream &rStream, ODbaseIndex&);
57 friend class ONDXNode;
58 friend class ONDXPage;
59 friend class ONDXPagePtr;
60 friend class OIndexIterator;
62 public:
63 //==================================================================
64 // Kopfsatz-Struktur, verbleibt im Speicher
65 //==================================================================
66 struct NDXHeader
68 sal_uInt32 db_rootpage; /* Position der Rootpage */
69 sal_uInt32 db_pagecount; /* Anzahl Pages */
70 sal_uInt8 db_frei[4]; /* reserviert */
71 sal_uInt16 db_keylen; /* Laenge des Schluessels */
72 sal_uInt16 db_maxkeys; /* Max. # keys pro Seite */
73 sal_uInt16 db_keytype; /* Art des Schluessels
74 (0-Text)
75 (1-Numerisch) */
76 sal_uInt16 db_keyrec; /* Laenge eines IndexSatzes
77 SatzNr + keylen */
78 sal_uInt8 db_frei1[3]; /* reserviert */
79 sal_uInt8 db_unique; /* eindeutig */
80 char db_name[488]; /* index_name (Feldname) */
83 private:
84 SvStream* m_pFileStream; // Stream zum Lesen/Schreiben des Index
85 NDXHeader m_aHeader;
86 ONDXPageList m_aCollector; // Pool von nicht mehr benoetigten Seiten
87 ONDXPagePtr m_aRoot, // Wurzel des b+ Baums
88 m_aCurLeaf; // aktuelles Blatt
89 USHORT m_nCurNode; // Position des aktuellen Knoten
91 sal_uInt32 m_nPageCount,
92 m_nRootPage;
94 ODbaseTable* m_pTable;
95 BOOL m_bUseCollector : 1; // Verwenden des GarbageCollectors
97 ::rtl::OUString getCompletePath();
98 void closeImpl();
99 /* closes and kill the index file and throws an error.
101 void impl_killFileAndthrowError_throw(sal_uInt16 _nErrorId,const ::rtl::OUString& _sFile);
102 protected:
103 virtual ~ODbaseIndex();
104 public:
105 ODbaseIndex(ODbaseTable* _pTable);
106 ODbaseIndex(ODbaseTable* _pTable,const NDXHeader& _aHeader,const ::rtl::OUString& _Name);
108 sal_Bool openIndexFile();
109 virtual void refreshColumns();
111 // com::sun::star::lang::XUnoTunnel
112 virtual sal_Int64 SAL_CALL getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(com::sun::star::uno::RuntimeException);
113 static com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
115 virtual void SAL_CALL acquire() throw();
116 virtual void SAL_CALL release() throw();
118 const ODbaseTable* getTable() const { return m_pTable; }
119 const NDXHeader& getHeader() const { return m_aHeader; }
120 virtual OIndexIterator* createIterator(OBoolOperator_BASE* pOp,
121 const OOperand_BASE* pOperand = NULL);
123 void SetRootPos(sal_uInt32 nPos) {m_nRootPage = nPos;}
124 void SetPageCount(sal_uInt32 nCount) {m_nPageCount = nCount;}
126 sal_uInt32 GetRootPos() {return m_nRootPage;}
127 sal_uInt32 GetPageCount() {return m_nPageCount;}
129 BOOL IsText() const {return m_aHeader.db_keytype == 0;}
130 USHORT GetMaxNodes() const {return m_aHeader.db_maxkeys;}
132 virtual BOOL Insert(sal_uInt32 nRec, const ORowSetValue& rValue);
133 virtual BOOL Update(sal_uInt32 nRec, const ORowSetValue&, const ORowSetValue&);
134 virtual BOOL Delete(sal_uInt32 nRec, const ORowSetValue& rValue);
135 virtual BOOL Find(sal_uInt32 nRec, const ORowSetValue& rValue);
137 void createINFEntry();
138 BOOL CreateImpl();
139 BOOL DropImpl();
141 DECLARE_SERVICE_INFO();
142 protected:
144 ONDXPage* CreatePage(sal_uInt32 nPagePos, ONDXPage* pParent = NULL, BOOL bLoad = FALSE);
145 void Collect(ONDXPage*);
146 ONDXPagePtr getRoot();
148 sal_Bool isUnique() const { return m_IsUnique; }
149 BOOL UseCollector() const {return m_bUseCollector;}
150 // Tree operationen
151 void Insert(ONDXPagePtr aCurPage, ONDXNode& rNode);
152 void Release(BOOL bSave = TRUE);
153 BOOL ConvertToKey(ONDXKey* rKey, sal_uInt32 nRec, const ORowSetValue& rValue);
156 SvStream& operator << (SvStream &rStream, ODbaseIndex&);
157 SvStream& operator >> (SvStream &rStream, ODbaseIndex&);
161 #endif // _CONNECTIVITY_DBASE_INDEX_HXX_