1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DIndex.cxx,v $
10 * $Revision: 1.43.56.1 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "dbase/DIndex.hxx"
34 #include "dbase/DIndexColumns.hxx"
35 #include <com/sun/star/lang/DisposedException.hpp>
36 #include "connectivity/sdbcx/VColumn.hxx"
37 #include <comphelper/sequence.hxx>
38 #include "dbase/DTable.hxx"
39 #include "dbase/DIndexIter.hxx"
40 #include <tools/config.hxx>
41 #include "connectivity/CommonTools.hxx"
42 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
43 #include <com/sun/star/sdbc/XResultSet.hpp>
44 #include <com/sun/star/sdbcx/XRowLocate.hpp>
45 #include <com/sun/star/sdbc/XRow.hpp>
46 #include <comphelper/extract.hxx>
47 #include <unotools/localfilehelper.hxx>
48 #include <unotools/ucbhelper.hxx>
49 #include <comphelper/types.hxx>
50 #include <connectivity/dbexception.hxx>
51 #include "dbase/DResultSet.hxx"
52 #include "diagnose_ex.h"
53 #include <comphelper/types.hxx>
54 #include "resource/dbase_res.hrc"
55 #include <unotools/sharedunocomponent.hxx>
57 using namespace ::comphelper
;
58 // -------------------------------------------------------------------------
59 using namespace connectivity
;
61 using namespace ::cppu
;
62 using namespace connectivity::file
;
63 using namespace connectivity::sdbcx
;
64 using namespace connectivity::dbase
;
65 using namespace com::sun::star::sdbc
;
66 using namespace com::sun::star::sdbcx
;
67 using namespace com::sun::star::uno
;
68 using namespace com::sun::star::beans
;
69 using namespace com::sun::star::lang
;
71 IMPLEMENT_SERVICE_INFO(ODbaseIndex
,"com.sun.star.sdbcx.driver.dbase.Index","com.sun.star.sdbcx.Index");
72 // -------------------------------------------------------------------------
73 ODbaseIndex::ODbaseIndex(ODbaseTable
* _pTable
) : OIndex(sal_True
/*_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()*/)
75 ,m_nCurNode(NODE_NOTFOUND
)
78 m_aHeader
.db_pagecount
= m_aHeader
.db_rootpage
= m_aHeader
.db_keytype
= m_aHeader
.db_maxkeys
= m_aHeader
.db_keylen
= 0;
79 m_aHeader
.db_name
[0] = '\0';
82 // -------------------------------------------------------------------------
83 ODbaseIndex::ODbaseIndex( ODbaseTable
* _pTable
,
84 const NDXHeader
& _rHeader
,
85 const ::rtl::OUString
& _rName
)
86 :OIndex(_rName
,::rtl::OUString(),_rHeader
.db_unique
,sal_False
,sal_False
,sal_True
) // _pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()
89 ,m_nCurNode(NODE_NOTFOUND
)
94 // -----------------------------------------------------------------------------
95 ODbaseIndex::~ODbaseIndex()
99 // -------------------------------------------------------------------------
100 void ODbaseIndex::refreshColumns()
102 ::osl::MutexGuard
aGuard( m_aMutex
);
104 TStringVector aVector
;
107 OSL_ENSURE(m_pFileStream
,"FileStream is not opened!");
108 OSL_ENSURE(m_aHeader
.db_name
[0] != '\0',"Invalid name for the column!");
109 aVector
.push_back(::rtl::OUString::createFromAscii(m_aHeader
.db_name
));
113 m_pColumns
->reFill(aVector
);
115 m_pColumns
= new ODbaseIndexColumns(this,m_aMutex
,aVector
);
117 //--------------------------------------------------------------------------
118 Sequence
< sal_Int8
> ODbaseIndex::getUnoTunnelImplementationId()
120 static ::cppu::OImplementationId
* pId
= 0;
123 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
126 static ::cppu::OImplementationId aId
;
130 return pId
->getImplementationId();
134 //------------------------------------------------------------------
135 sal_Int64
ODbaseIndex::getSomething( const Sequence
< sal_Int8
> & rId
) throw (RuntimeException
)
137 return (rId
.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
138 ? reinterpret_cast< sal_Int64
>( this )
139 : ODbaseIndex_BASE::getSomething(rId
);
141 //------------------------------------------------------------------
142 ONDXPagePtr
ODbaseIndex::getRoot()
147 m_nRootPage
= m_aHeader
.db_rootpage
;
148 m_nPageCount
= m_aHeader
.db_pagecount
;
149 m_aRoot
= CreatePage(m_nRootPage
,NULL
,TRUE
);
153 //------------------------------------------------------------------
154 sal_Bool
ODbaseIndex::openIndexFile()
158 ::rtl::OUString sFile
= getCompletePath();
159 if(UCBContentHelper::Exists(sFile
))
161 m_pFileStream
= OFileTable::createStream_simpleError(sFile
, STREAM_READWRITE
| STREAM_NOCREATE
| STREAM_SHARE_DENYWRITE
);
163 m_pFileStream
= OFileTable::createStream_simpleError(sFile
,STREAM_READ
| STREAM_NOCREATE
| STREAM_SHARE_DENYNONE
);
166 m_pFileStream
->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN
);
167 m_pFileStream
->SetBufferSize(PAGE_SIZE
);
168 (*m_pFileStream
) >> *this;
173 const ::rtl::OUString
sError( m_pTable
->getConnection()->getResources().getResourceStringWithSubstitution(
174 STR_COULD_NOT_LOAD_FILE
,
177 ::dbtools::throwGenericSQLException( sError
, *this );
181 return m_pFileStream
!= NULL
;
183 //------------------------------------------------------------------
184 OIndexIterator
* ODbaseIndex::createIterator(OBoolOperator
* pOp
,
185 const OOperand
* pOperand
)
188 return new OIndexIterator(this, pOp
, pOperand
);
190 //------------------------------------------------------------------
191 BOOL
ODbaseIndex::ConvertToKey(ONDXKey
* rKey
, sal_uInt32 nRec
, const ORowSetValue
& rValue
)
193 OSL_ENSURE(m_pFileStream
,"FileStream is not opened!");
194 // Sucht ein bestimmten Wert im Index
195 // Wenn der Index Unique ist, interssiert der Key nicht, sonst ja
198 if (m_aHeader
.db_keytype
== 0)
200 *rKey
= ONDXKey(rValue
.getString(), nRec
);
205 *rKey
= ONDXKey(rValue
.getDouble(), DataType::DOUBLE
, nRec
);
207 *rKey
= ONDXKey(rValue
.getDouble(), nRec
);
218 //------------------------------------------------------------------
219 BOOL
ODbaseIndex::Find(sal_uInt32 nRec
, const ORowSetValue
& rValue
)
222 OSL_ENSURE(m_pFileStream
,"FileStream is not opened!");
223 // Sucht ein bestimmten Wert im Index
224 // Wenn der Index Unique ist, interssiert der Key nicht, sonst ja
226 return ConvertToKey(&aKey
, nRec
, rValue
) && getRoot()->Find(aKey
);
229 //------------------------------------------------------------------
230 BOOL
ODbaseIndex::Insert(sal_uInt32 nRec
, const ORowSetValue
& rValue
)
233 OSL_ENSURE(m_pFileStream
,"FileStream is not opened!");
236 // Existiert der Wert bereits
237 // Find immer verwenden um das aktuelle Blatt zu bestimmen
238 if (!ConvertToKey(&aKey
, nRec
, rValue
) || (getRoot()->Find(aKey
) && isUnique()))
241 ONDXNode
aNewNode(aKey
);
243 // einfuegen in das aktuelle Blatt
244 if (!m_aCurLeaf
.Is())
247 BOOL bResult
= m_aCurLeaf
->Insert(aNewNode
);
253 //------------------------------------------------------------------
254 BOOL
ODbaseIndex::Update(sal_uInt32 nRec
, const ORowSetValue
& rOldValue
,
255 const ORowSetValue
& rNewValue
)
258 OSL_ENSURE(m_pFileStream
,"FileStream is not opened!");
260 if (!ConvertToKey(&aKey
, nRec
, rNewValue
) || (isUnique() && getRoot()->Find(aKey
)))
263 return Delete(nRec
, rOldValue
) && Insert(nRec
,rNewValue
);
266 //------------------------------------------------------------------
267 BOOL
ODbaseIndex::Delete(sal_uInt32 nRec
, const ORowSetValue
& rValue
)
270 OSL_ENSURE(m_pFileStream
,"FileStream is not opened!");
271 // Existiert der Wert bereits
272 // Find immer verwenden um das aktuelle Blatt zu bestimmen
274 if (!ConvertToKey(&aKey
, nRec
, rValue
) || !getRoot()->Find(aKey
))
277 ONDXNode
aNewNode(aKey
);
279 // einfuegen in das aktuelle Blatt
280 if (!m_aCurLeaf
.Is())
282 #if OSL_DEBUG_LEVEL > 1
283 m_aRoot
->PrintPage();
286 return m_aCurLeaf
->Delete(m_nCurNode
);
288 //------------------------------------------------------------------
289 void ODbaseIndex::Collect(ONDXPage
* pPage
)
292 m_aCollector
.push_back(pPage
);
294 //------------------------------------------------------------------
295 void ODbaseIndex::Release(BOOL bSave
)
297 // Freigeben der Indexressourcen
298 m_bUseCollector
= FALSE
;
302 m_aCurLeaf
->Release(bSave
);
309 m_aRoot
->Release(bSave
);
312 // alle Referenzen freigeben, bevor der FileStream geschlossen wird
313 for (ULONG i
= 0; i
< m_aCollector
.size(); i
++)
314 m_aCollector
[i
]->QueryDelete();
316 m_aCollector
.clear();
318 // Header modifiziert ?
319 if (bSave
&& (m_aHeader
.db_rootpage
!= m_nRootPage
||
320 m_aHeader
.db_pagecount
!= m_nPageCount
))
322 m_aHeader
.db_rootpage
= m_nRootPage
;
323 m_aHeader
.db_pagecount
= m_nPageCount
;
324 (*m_pFileStream
) << *this;
326 m_nRootPage
= m_nPageCount
= 0;
327 m_nCurNode
= NODE_NOTFOUND
;
331 // -----------------------------------------------------------------------------
332 void ODbaseIndex::closeImpl()
336 delete m_pFileStream
;
337 m_pFileStream
= NULL
;
340 //------------------------------------------------------------------
341 ONDXPage
* ODbaseIndex::CreatePage(sal_uInt32 nPagePos
, ONDXPage
* pParent
, BOOL bLoad
)
343 OSL_ENSURE(m_pFileStream
,"FileStream is not opened!");
346 if ( !m_aCollector
.empty() )
348 pPage
= *(m_aCollector
.rbegin());
349 m_aCollector
.pop_back();
350 pPage
->SetPagePos(nPagePos
);
351 pPage
->SetParent(pParent
);
354 pPage
= new ONDXPage(*this, nPagePos
, pParent
);
357 (*m_pFileStream
) >> *pPage
;
362 //------------------------------------------------------------------
363 SvStream
& connectivity::dbase::operator >> (SvStream
&rStream
, ODbaseIndex
& rIndex
)
366 rStream
.Read(&rIndex
.m_aHeader
,PAGE_SIZE
);
368 /* OJ: no longer needed
369 // Text convertierung
370 ByteString aText(rIndex.m_aHeader.db_name);
371 // aText.Convert(rIndex.m_pTable->getConnection()->GetCharacterSet(), m_pTable->getConnection()->getTextEncoding());
372 // aText.Convert(rIndex.m_pTable->getConnection()->GetCharacterSet(), m_pTable->getConnection()->getTextEncoding());
373 strcpy(rIndex.m_aHeader.db_name,aText.GetBuffer());
375 rIndex
.m_nRootPage
= rIndex
.m_aHeader
.db_rootpage
;
376 rIndex
.m_nPageCount
= rIndex
.m_aHeader
.db_pagecount
;
379 //------------------------------------------------------------------
380 SvStream
& connectivity::dbase::operator << (SvStream
&rStream
, ODbaseIndex
& rIndex
)
383 /* OJ: no longer needed
384 ByteString aText(rIndex.m_aHeader.db_name);
385 // aText.Convert(m_pTable->getConnection()->getTextEncoding(), rIndex.m_pTable->getConnection()->GetCharacterSet());
386 strcpy(rIndex.m_aHeader.db_name,aText.GetBuffer());
388 OSL_VERIFY_EQUALS( rStream
.Write(&rIndex
.m_aHeader
,PAGE_SIZE
), PAGE_SIZE
, "Write not successful: Wrong header size for dbase index!");
391 // -------------------------------------------------------------------------
392 ::rtl::OUString
ODbaseIndex::getCompletePath()
394 ::rtl::OUString sDir
= m_pTable
->getConnection()->getURL();
395 sDir
+= OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELIMITER
);
397 sDir
+= ::rtl::OUString::createFromAscii(".ndx");
400 //------------------------------------------------------------------
401 void ODbaseIndex::createINFEntry()
403 // inf Datei abgleichen
404 String sEntry
= m_Name
;
405 sEntry
+= String::CreateFromAscii(".ndx");
407 ::rtl::OUString
sCfgFile(m_pTable
->getConnection()->getURL());
408 sCfgFile
+= OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELIMITER
);
409 sCfgFile
+= m_pTable
->getName();
410 sCfgFile
+= ::rtl::OUString::createFromAscii(".inf");
412 String sPhysicalPath
;
413 LocalFileHelper::ConvertURLToPhysicalName(sCfgFile
,sPhysicalPath
);
415 Config
aInfFile(sPhysicalPath
);
416 aInfFile
.SetGroup(dBASE_III_GROUP
);
418 USHORT nSuffix
= aInfFile
.GetKeyCount();
419 ByteString aNewEntry
,aKeyName
;
420 BOOL bCase
= isCaseSensitive();
421 while (!aNewEntry
.Len())
424 aNewEntry
+= ByteString::CreateFromInt32(++nSuffix
);
425 for (USHORT i
= 0; i
< aInfFile
.GetKeyCount(); i
++)
427 aKeyName
= aInfFile
.GetKeyName(i
);
428 if (bCase
? aKeyName
== aNewEntry
: aKeyName
.EqualsIgnoreCaseAscii(aNewEntry
))
435 aInfFile
.WriteKey(aNewEntry
,ByteString(sEntry
,m_pTable
->getConnection()->getTextEncoding()));
437 // -------------------------------------------------------------------------
438 BOOL
ODbaseIndex::DropImpl()
442 ::rtl::OUString sPath
= getCompletePath();
443 if(UCBContentHelper::Exists(sPath
))
445 if(!UCBContentHelper::Kill(sPath
))
446 m_pTable
->getConnection()->throwGenericSQLException(STR_COULD_NOT_DELETE_INDEX
,*m_pTable
);
449 // InfDatei abgleichen
451 ::rtl::OUString
sCfgFile(m_pTable
->getConnection()->getURL());
452 sCfgFile
+= OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELIMITER
);
453 sCfgFile
+= m_pTable
->getName();
454 sCfgFile
+= ::rtl::OUString::createFromAscii(".inf");
456 String sPhysicalPath
;
457 String
sNDX(sCfgFile
);
458 OSL_VERIFY_RES( LocalFileHelper::ConvertURLToPhysicalName(sNDX
,sPhysicalPath
),"Can not convert Config Filename into Physical Name!");
460 Config
aInfFile(sPhysicalPath
);
461 aInfFile
.SetGroup(dBASE_III_GROUP
);
462 USHORT nKeyCnt
= aInfFile
.GetKeyCount();
464 String sEntry
= m_Name
;
465 sEntry
+= String::CreateFromAscii(".ndx");
467 // delete entries from the inf file
468 for (USHORT nKey
= 0; nKey
< nKeyCnt
; nKey
++)
470 // Verweist der Key auf ein Indexfile?...
471 aKeyName
= aInfFile
.GetKeyName( nKey
);
472 if (aKeyName
.Copy(0,3) == "NDX")
474 if(sEntry
== String(aInfFile
.ReadKey(aKeyName
),m_pTable
->getConnection()->getTextEncoding()))
476 aInfFile
.DeleteKey(aKeyName
);
483 // -------------------------------------------------------------------------
484 void ODbaseIndex::impl_killFileAndthrowError_throw(sal_uInt16 _nErrorId
,const ::rtl::OUString
& _sFile
)
487 if(UCBContentHelper::Exists(_sFile
))
488 UCBContentHelper::Kill(_sFile
);
489 m_pTable
->getConnection()->throwGenericSQLException(_nErrorId
,*this);
491 //------------------------------------------------------------------
492 BOOL
ODbaseIndex::CreateImpl()
495 const ::rtl::OUString sFile
= getCompletePath();
496 if(UCBContentHelper::Exists(sFile
))
498 const ::rtl::OUString
sError( m_pTable
->getConnection()->getResources().getResourceStringWithSubstitution(
499 STR_COULD_NOT_CREATE_INDEX_NAME
,
502 ::dbtools::throwGenericSQLException( sError
, *this );
504 // Index ist nur einstufig
505 if (m_pColumns
->getCount() > 1)
506 m_pTable
->getConnection()->throwGenericSQLException(STR_ONL_ONE_COLUMN_PER_INDEX
,*this);
508 Reference
<XFastPropertySet
> xCol(m_pColumns
->getByIndex(0),UNO_QUERY
);
510 // ist die Spalte schon indiziert ?
512 ::dbtools::throwFunctionSequenceException(*this);
513 // else if (pColumn && pColumn->IsIndexed())
515 // String aText = String(OResId(STR_STAT_INDEX_COLUMN_ALREADY_INDEXED));
516 // aText.SearchAndReplace(String::CreateFromAscii("#"),pColumn->GetName());
517 // aStatus.Set(SDB_STAT_ERROR,
518 // String::CreateFromAscii("01000"),
519 // aStatus.CreateErrorMessage(aText),
524 // create the index file
525 m_pFileStream
= OFileTable::createStream_simpleError(sFile
,STREAM_READWRITE
| STREAM_SHARE_DENYWRITE
| STREAM_TRUNC
);
528 const ::rtl::OUString
sError( m_pTable
->getConnection()->getResources().getResourceStringWithSubstitution(
529 STR_COULD_NOT_LOAD_FILE
,
532 ::dbtools::throwGenericSQLException( sError
, *this );
535 m_pFileStream
->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN
);
536 m_pFileStream
->SetBufferSize(PAGE_SIZE
);
537 m_pFileStream
->SetFiller('\0');
539 // Zunaechst muss das Ergebnis sortiert sein
540 utl::SharedUNOComponent
<XStatement
> xStmt
;
541 utl::SharedUNOComponent
<XResultSet
> xSet
;
545 xStmt
.set( m_pTable
->getConnection()->createStatement(), UNO_SET_THROW
);
547 aName
= getString(xCol
->getFastPropertyValue(PROPERTY_ID_NAME
));
549 const String
aQuote(m_pTable
->getConnection()->getMetaData()->getIdentifierQuoteString());
551 aStatement
.AssignAscii("SELECT ");
552 aStatement
+= aQuote
;
554 aStatement
+= aQuote
;
555 aStatement
.AppendAscii(" FROM ");
556 aStatement
+= aQuote
;
557 aStatement
+= m_pTable
->getName().getStr();
558 aStatement
+= aQuote
;
559 aStatement
.AppendAscii(" ORDER BY ");
560 aStatement
+= aQuote
;
562 aStatement
+= aQuote
;
564 // if (!m_IsUnique) // zusaetzlich sortierung mit der bookmarkspalte
566 // aStatement.AppendAscii(" ,");
567 // aStatement += aQuote;
568 // aStatement.AppendAscii("[BOOKMARK]"); // this is a special column
569 // aStatement += aQuote;
572 xSet
.set( xStmt
->executeQuery(aStatement
),UNO_SET_THROW
);
574 catch(const Exception
& )
576 impl_killFileAndthrowError_throw(STR_COULD_NOT_CREATE_INDEX
,sFile
);
580 impl_killFileAndthrowError_throw(STR_COULD_NOT_CREATE_INDEX
,sFile
);
583 // Setzen der Headerinfo
584 memset(&m_aHeader
,0,sizeof(m_aHeader
));
586 ::vos::ORef
<OSQLColumns
> aCols
= m_pTable
->getTableColumns();
587 const Reference
< XPropertySet
> xTableCol(*find(aCols
->get().begin(),aCols
->get().end(),aName
,::comphelper::UStringMixEqual(isCaseSensitive())));
589 xTableCol
->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE
)) >>= nType
;
591 m_aHeader
.db_keytype
= (nType
== DataType::VARCHAR
|| nType
== DataType::CHAR
) ? 0 : 1;
592 m_aHeader
.db_keylen
= (m_aHeader
.db_keytype
) ? 8 : (USHORT
)getINT32(xTableCol
->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION
)));
593 m_aHeader
.db_keylen
= (( m_aHeader
.db_keylen
- 1) / 4 + 1) * 4;
594 m_aHeader
.db_maxkeys
= (PAGE_SIZE
- 4) / (8 + m_aHeader
.db_keylen
);
595 if ( m_aHeader
.db_maxkeys
< 3 )
597 impl_killFileAndthrowError_throw(STR_COULD_NOT_CREATE_INDEX_KEYSIZE
,sFile
);
600 m_pFileStream
->SetStreamSize(PAGE_SIZE
);
602 ByteString
aCol(aName
,m_pTable
->getConnection()->getTextEncoding());
603 strncpy(m_aHeader
.db_name
,aCol
.GetBuffer(),std::min((USHORT
)sizeof(m_aHeader
.db_name
), aCol
.Len()));
604 m_aHeader
.db_unique
= m_IsUnique
? 1: 0;
605 m_aHeader
.db_keyrec
= m_aHeader
.db_keylen
+ 8;
607 // modifizierung am Header werden ueber Unterschiede zw. HeaderInfo und nRootPage
608 // bzw. nPageCout erkannt
613 // ODatabaseType eType = m_aHeader.db_keytype == 0 ? DataType::VARCHAR : DataType::DOUBLE;
614 m_aCurLeaf
= m_aRoot
= CreatePage(m_nRootPage
);
615 m_aRoot
->SetModified(TRUE
);
617 m_bUseCollector
= TRUE
;
619 // ULONG nRowsLeft = pCursor->RowCount();
620 sal_Int32 nRowsLeft
= 0;
621 Reference
<XRow
> xRow(xSet
,UNO_QUERY
);
625 Reference
< XUnoTunnel
> xTunnel(xSet
,UNO_QUERY
);
626 ODbaseResultSet
* pDbaseRes
= NULL
;
628 pDbaseRes
= reinterpret_cast< ODbaseResultSet
* >( xTunnel
->getSomething(ODbaseResultSet::getUnoTunnelImplementationId()) );
629 OSL_ENSURE(pDbaseRes
,"No dbase resultset found? What's going on here!");
630 Reference
<XRowLocate
> xRowLocate(xSet
,UNO_QUERY
);
631 nRowsLeft
= xSet
->getRow();
634 ORowSetValue atmpValue
=ORowSetValue();
635 ONDXKey
aKey(atmpValue
, nType
, 0);
636 ONDXKey
aInsertKey(atmpValue
, nType
, 0);
637 // Erzeugen der Indexstruktur
640 // ODbRow& rRow = *pCursor->GetRow();
641 ORowSetValue
aValue(m_aHeader
.db_keytype
? ORowSetValue(xRow
->getDouble(1)) : ORowSetValue(xRow
->getString(1)));
642 // ueberpruefen auf doppelten eintrag
643 if (m_IsUnique
&& m_nCurNode
!= NODE_NOTFOUND
)
645 aKey
.setValue(aValue
);
646 if (aKey
== (*m_aCurLeaf
)[m_nCurNode
].GetKey())
648 impl_killFileAndthrowError_throw(STR_COULD_NOT_CREATE_INDEX_NOT_UNIQUE
,sFile
);
651 aInsertKey
.setValue(aValue
);
652 aInsertKey
.setRecord(pDbaseRes
->getCurrentFilePos());
654 ONDXNode
aNewNode(aInsertKey
);
655 if (!m_aCurLeaf
->Insert(aNewNode
, --nRowsLeft
))
662 impl_killFileAndthrowError_throw(STR_COULD_NOT_CREATE_INDEX
,sFile
);
668 // -----------------------------------------------------------------------------
669 // -----------------------------------------------------------------------------
670 void SAL_CALL
ODbaseIndex::acquire() throw()
672 ODbaseIndex_BASE::acquire();
674 // -----------------------------------------------------------------------------
675 void SAL_CALL
ODbaseIndex::release() throw()
677 ODbaseIndex_BASE::release();
679 // -----------------------------------------------------------------------------