merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / drivers / dbase / DNoException.cxx
blob3554efc4d2f4e6d7c931c0e0e06c16e1dc757750
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: DNoException.cxx,v $
10 * $Revision: 1.20 $
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/DTable.hxx"
34 #include "dbase/DIndex.hxx"
35 #include "dbase/dindexnode.hxx"
36 #include <tools/debug.hxx>
37 #include "diagnose_ex.h"
39 #include <sal/types.h>
40 #include <algorithm>
41 #include <rtl/logfile.hxx>
43 using namespace connectivity;
44 using namespace connectivity::dbase;
45 using namespace com::sun::star::uno;
46 using namespace com::sun::star::sdbc;
47 //------------------------------------------------------------------
48 sal_Bool ODbaseTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos)
50 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::seekRow" );
51 // ----------------------------------------------------------
52 // Positionierung vorbereiten:
53 OSL_ENSURE(m_pFileStream,"ODbaseTable::seekRow: FileStream is NULL!");
55 sal_uInt32 nNumberOfRecords = (sal_uInt32)m_aHeader.db_anz;
56 sal_uInt32 nTempPos = m_nFilePos;
57 m_nFilePos = nCurPos;
59 switch(eCursorPosition)
61 case IResultSetHelper::NEXT:
62 ++m_nFilePos;
63 break;
64 case IResultSetHelper::PRIOR:
65 if (m_nFilePos > 0)
66 --m_nFilePos;
67 break;
68 case IResultSetHelper::FIRST:
69 m_nFilePos = 1;
70 break;
71 case IResultSetHelper::LAST:
72 m_nFilePos = nNumberOfRecords;
73 break;
74 case IResultSetHelper::RELATIVE:
75 m_nFilePos = (((sal_Int32)m_nFilePos) + nOffset < 0) ? 0L
76 : (sal_uInt32)(((sal_Int32)m_nFilePos) + nOffset);
77 break;
78 case IResultSetHelper::ABSOLUTE:
79 case IResultSetHelper::BOOKMARK:
80 m_nFilePos = (sal_uInt32)nOffset;
81 break;
84 if (m_nFilePos > (sal_Int32)nNumberOfRecords)
85 m_nFilePos = (sal_Int32)nNumberOfRecords + 1;
87 if (m_nFilePos == 0 || m_nFilePos == (sal_Int32)nNumberOfRecords + 1)
88 goto Error;
89 else
91 sal_uInt16 nEntryLen = m_aHeader.db_slng;
93 OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position");
94 sal_Int32 nPos = m_aHeader.db_kopf + (sal_Int32)(m_nFilePos-1) * nEntryLen;
96 ULONG nLen = m_pFileStream->Seek(nPos);
97 if (m_pFileStream->GetError() != ERRCODE_NONE)
98 goto Error;
100 nLen = m_pFileStream->Read((char*)m_pBuffer, nEntryLen);
101 if (m_pFileStream->GetError() != ERRCODE_NONE)
102 goto Error;
104 goto End;
106 Error:
107 switch(eCursorPosition)
109 case IResultSetHelper::PRIOR:
110 case IResultSetHelper::FIRST:
111 m_nFilePos = 0;
112 break;
113 case IResultSetHelper::LAST:
114 case IResultSetHelper::NEXT:
115 case IResultSetHelper::ABSOLUTE:
116 case IResultSetHelper::RELATIVE:
117 if (nOffset > 0)
118 m_nFilePos = nNumberOfRecords + 1;
119 else if (nOffset < 0)
120 m_nFilePos = 0;
121 break;
122 case IResultSetHelper::BOOKMARK:
123 m_nFilePos = nTempPos; // vorherige Position
125 // aStatus.Set(SDB_STAT_NO_DATA_FOUND);
126 return sal_False;
128 End:
129 nCurPos = m_nFilePos;
130 return sal_True;
132 // -----------------------------------------------------------------------------
133 BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable)
135 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::ReadMemo" );
136 BOOL bIsText = TRUE;
137 // SdbConnection* pConnection = GetConnection();
139 m_pMemoStream->Seek(nBlockNo * m_aMemoHeader.db_size);
140 switch (m_aMemoHeader.db_typ)
142 case MemodBaseIII: // dBase III-Memofeld, endet mit Ctrl-Z
144 const char cEOF = (char) 0x1a;
145 ByteString aBStr;
146 static char aBuf[514];
147 aBuf[512] = 0; // sonst kann der Zufall uebel mitspielen
148 BOOL bReady = sal_False;
152 m_pMemoStream->Read(&aBuf,512);
154 USHORT i = 0;
155 while (aBuf[i] != cEOF && ++i < 512)
157 bReady = aBuf[i] == cEOF;
159 aBuf[i] = 0;
160 aBStr += aBuf;
162 } while (!bReady && !m_pMemoStream->IsEof() && aBStr.Len() < STRING_MAXLEN);
164 ::rtl::OUString aStr(aBStr.GetBuffer(), aBStr.Len(),getConnection()->getTextEncoding());
165 aVariable = aStr;
167 } break;
168 case MemoFoxPro:
169 case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe
171 char sHeader[4];
172 m_pMemoStream->Read(sHeader,4);
173 // Foxpro stores text and binary data
174 if (m_aMemoHeader.db_typ == MemoFoxPro)
176 if (((BYTE)sHeader[0]) != 0 || ((BYTE)sHeader[1]) != 0 || ((BYTE)sHeader[2]) != 0)
178 // String aText = String(SdbResId(STR_STAT_IResultSetHelper::INVALID));
179 // aText.SearchAndReplace(String::CreateFromAscii("%%d"),m_pMemoStream->GetFileName());
180 // aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO));
181 // aStatus.Set(SDB_STAT_ERROR,
182 // String::CreateFromAscii("01000"),
183 // aStatus.CreateErrorMessage(aText),
184 // 0, String() );
185 return sal_False;
188 bIsText = sHeader[3] != 0;
190 else if (((BYTE)sHeader[0]) != 0xFF || ((BYTE)sHeader[1]) != 0xFF || ((BYTE)sHeader[2]) != 0x08)
192 // String aText = String(SdbResId(STR_STAT_IResultSetHelper::INVALID));
193 // aText.SearchAndReplace(String::CreateFromAscii("%%d"),m_pMemoStream->GetFileName());
194 // aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO));
195 // aStatus.Set(SDB_STAT_ERROR,
196 // String::CreateFromAscii("01000"),
197 // aStatus.CreateErrorMessage(aText),
198 // 0, String() );
199 return sal_False;
202 sal_uInt32 nLength;
203 (*m_pMemoStream) >> nLength;
205 if (m_aMemoHeader.db_typ == MemodBaseIV)
206 nLength -= 8;
208 // char cChar;
209 ::rtl::OUString aStr;
210 while ( nLength > STRING_MAXLEN )
212 ByteString aBStr;
213 aBStr.Expand(STRING_MAXLEN);
214 m_pMemoStream->Read(aBStr.AllocBuffer(STRING_MAXLEN),STRING_MAXLEN);
215 aStr += ::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), getConnection()->getTextEncoding());
216 nLength -= STRING_MAXLEN;
218 if ( nLength > 0 )
220 ByteString aBStr;
221 aBStr.Expand(static_cast<xub_StrLen>(nLength));
222 m_pMemoStream->Read(aBStr.AllocBuffer(static_cast<xub_StrLen>(nLength)),nLength);
223 // aBStr.ReleaseBufferAccess();
225 aStr += ::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), getConnection()->getTextEncoding());
228 if ( aStr.getLength() )
229 aVariable = aStr;
232 return sal_True;
234 // -----------------------------------------------------------------------------
235 void ODbaseTable::AllocBuffer()
237 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::AllocBuffer" );
238 UINT16 nSize = m_aHeader.db_slng;
239 OSL_ENSURE(nSize > 0, "Size too small");
241 if (m_nBufferSize != nSize)
243 delete[] m_pBuffer;
244 m_pBuffer = NULL;
247 // Falls noch kein Puffer vorhanden: allozieren:
248 if (m_pBuffer == NULL && nSize)
250 m_nBufferSize = nSize;
251 m_pBuffer = new BYTE[m_nBufferSize+1];
254 // -----------------------------------------------------------------------------
255 BOOL ODbaseTable::WriteBuffer()
257 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::WriteBuffer" );
258 OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position");
260 // Auf gewuenschten Record positionieren:
261 long nPos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng;
262 m_pFileStream->Seek(nPos);
263 return m_pFileStream->Write((char*) m_pBuffer, m_aHeader.db_slng) > 0;
265 // -----------------------------------------------------------------------------
266 sal_Int32 ODbaseTable::getCurrentLastPos() const
268 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::getCurrentLastPos" );
269 return m_aHeader.db_anz;
271 // -----------------------------------------------------------------------------
272 //==================================================================
273 // ONDXNode
274 //==================================================================
276 //------------------------------------------------------------------
277 void ONDXNode::Read(SvStream &rStream, ODbaseIndex& rIndex)
279 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXNode::Read" );
280 rStream >> aKey.nRecord; // schluessel
282 if (rIndex.getHeader().db_keytype)
284 double aDbl;
285 rStream >> aDbl;
286 aKey = ONDXKey(aDbl,aKey.nRecord);
288 else
290 ByteString aBuf;
291 USHORT nLen = rIndex.getHeader().db_keylen;
292 char* pStr = aBuf.AllocBuffer(nLen+1);
294 rStream.Read(pStr,nLen);
295 pStr[nLen] = 0;
296 aBuf.ReleaseBufferAccess();
297 aBuf.EraseTrailingChars();
299 // aKey = ONDXKey((aBuf,rIndex.GetDBFConnection()->GetCharacterSet()) ,aKey.nRecord);
300 aKey = ONDXKey(::rtl::OUString(aBuf.GetBuffer(),aBuf.Len(),rIndex.m_pTable->getConnection()->getTextEncoding()) ,aKey.nRecord);
302 rStream >> aChild;
305 union
307 double aDbl;
308 char aData[128];
309 } aNodeData;
310 //------------------------------------------------------------------
311 void ONDXNode::Write(SvStream &rStream, const ONDXPage& rPage) const
313 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXNode::Write" );
314 const ODbaseIndex& rIndex = rPage.GetIndex();
315 if (!rIndex.isUnique() || rPage.IsLeaf())
316 rStream << (sal_uInt32)aKey.nRecord; // schluessel
317 else
318 rStream << (sal_uInt32)0; // schluessel
320 if (rIndex.getHeader().db_keytype) // double
322 if (aKey.getValue().isNull())
324 memset(aNodeData.aData,0,rIndex.getHeader().db_keylen);
325 rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen);
327 else
328 rStream << (double) aKey.getValue();
330 else
332 memset(aNodeData.aData,0x20,rIndex.getHeader().db_keylen);
333 if (!aKey.getValue().isNull())
335 ::rtl::OUString sValue = aKey.getValue();
336 ByteString aText(sValue.getStr(), rIndex.m_pTable->getConnection()->getTextEncoding());
337 strncpy(aNodeData.aData,aText.GetBuffer(),std::min(rIndex.getHeader().db_keylen, aText.Len()));
339 rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen);
341 rStream << aChild;
345 //------------------------------------------------------------------
346 ONDXPagePtr& ONDXNode::GetChild(ODbaseIndex* pIndex, ONDXPage* pParent)
348 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXNode::GetChild" );
349 if (!aChild.Is() && pIndex)
351 aChild = pIndex->CreatePage(aChild.GetPagePos(),pParent,aChild.HasPage());
353 return aChild;
356 //==================================================================
357 // ONDXKey
358 //==================================================================
359 //------------------------------------------------------------------
360 BOOL ONDXKey::IsText(sal_Int32 eType)
362 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXKey::IsText" );
363 return eType == DataType::VARCHAR || eType == DataType::CHAR;
366 //------------------------------------------------------------------
367 StringCompare ONDXKey::Compare(const ONDXKey& rKey) const
369 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXKey::Compare" );
370 // DBG_ASSERT(is(), "Falscher Indexzugriff");
371 StringCompare eResult;
373 if (getValue().isNull())
375 if (rKey.getValue().isNull() || (rKey.IsText(getDBType()) && !rKey.getValue().getString().getLength()))
376 eResult = COMPARE_EQUAL;
377 else
378 eResult = COMPARE_LESS;
380 else if (rKey.getValue().isNull())
382 if (getValue().isNull() || (IsText(getDBType()) && !getValue().getString().getLength()))
383 eResult = COMPARE_EQUAL;
384 else
385 eResult = COMPARE_GREATER;
387 else if (IsText(getDBType()))
389 INT32 nRes = getValue().getString().compareTo(rKey.getValue());
390 eResult = (nRes > 0) ? COMPARE_GREATER : (nRes == 0) ? COMPARE_EQUAL : COMPARE_LESS;
392 else
394 double m = getValue(),n = rKey.getValue();
395 eResult = (m > n) ? COMPARE_GREATER : (n == m) ? COMPARE_EQUAL : COMPARE_LESS;
398 // Record vergleich, wenn Index !Unique
399 if (eResult == COMPARE_EQUAL && nRecord && rKey.nRecord)
400 eResult = (nRecord > rKey.nRecord) ? COMPARE_GREATER :
401 (nRecord == rKey.nRecord) ? COMPARE_EQUAL : COMPARE_LESS;
403 return eResult;
405 // -----------------------------------------------------------------------------
406 void ONDXKey::setValue(const ORowSetValue& _rVal)
408 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXKey::setValue" );
409 xValue = _rVal;
411 // -----------------------------------------------------------------------------
412 const ORowSetValue& ONDXKey::getValue() const
414 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXKey::getValue" );
415 return xValue;
417 // -----------------------------------------------------------------------------
418 SvStream& connectivity::dbase::operator >> (SvStream &rStream, ONDXPagePtr& rPage)
420 rStream >> rPage.nPagePos;
421 return rStream;
423 // -----------------------------------------------------------------------------
424 SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPagePtr& rPage)
426 rStream << rPage.nPagePos;
427 return rStream;
429 // -----------------------------------------------------------------------------
430 //==================================================================
431 // ONDXPagePtr
432 //==================================================================
433 //------------------------------------------------------------------
434 ONDXPagePtr::ONDXPagePtr(const ONDXPagePtr& rRef)
435 :ONDXPageRef(rRef)
436 ,nPagePos(rRef.nPagePos)
438 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPagePtr::ONDXPagePtr" );
441 //------------------------------------------------------------------
442 ONDXPagePtr::ONDXPagePtr(ONDXPage* pRefPage)
443 :ONDXPageRef(pRefPage)
444 ,nPagePos(0)
446 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPagePtr::ONDXPagePtr" );
447 if (pRefPage)
448 nPagePos = pRefPage->GetPagePos();
450 //------------------------------------------------------------------
451 ONDXPagePtr& ONDXPagePtr::operator=(const ONDXPagePtr& rRef)
453 ONDXPageRef::operator=(rRef);
454 nPagePos = rRef.nPagePos;
455 return *this;
458 //------------------------------------------------------------------
459 ONDXPagePtr& ONDXPagePtr::operator= (ONDXPage* pRef)
461 ONDXPageRef::operator=(pRef);
462 nPagePos = (pRef) ? pRef->GetPagePos() : 0;
463 return *this;
465 // -----------------------------------------------------------------------------
466 static UINT32 nValue;
467 //------------------------------------------------------------------
468 SvStream& connectivity::dbase::operator >> (SvStream &rStream, ONDXPage& rPage)
470 rStream.Seek(rPage.GetPagePos() * 512);
471 rStream >> nValue >> rPage.aChild;
472 rPage.nCount = USHORT(nValue);
474 // DBG_ASSERT(rPage.nCount && rPage.nCount < rPage.GetIndex().GetMaxNodes(), "Falscher Count");
475 for (USHORT i = 0; i < rPage.nCount; i++)
476 rPage[i].Read(rStream, rPage.GetIndex());
477 return rStream;
480 //------------------------------------------------------------------
481 SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& rPage)
483 // Seite existiert noch nicht
484 ULONG nSize = (rPage.GetPagePos() + 1) * 512;
485 if (nSize > rStream.Seek(STREAM_SEEK_TO_END))
487 rStream.SetStreamSize(nSize);
488 rStream.Seek(rPage.GetPagePos() * 512);
490 char aEmptyData[512];
491 memset(aEmptyData,0x00,512);
492 rStream.Write((BYTE*)aEmptyData,512);
494 ULONG nCurrentPos = rStream.Seek(rPage.GetPagePos() * 512);
495 OSL_UNUSED( nCurrentPos );
497 nValue = rPage.nCount;
498 rStream << nValue << rPage.aChild;
500 USHORT i = 0;
501 for (; i < rPage.nCount; i++)
502 rPage[i].Write(rStream, rPage);
504 // check if we have to fill the stream with '\0'
505 if(i < rPage.rIndex.getHeader().db_maxkeys)
507 ULONG nTell = rStream.Tell() % 512;
508 USHORT nBufferSize = rStream.GetBufferSize();
509 ULONG nSize = nBufferSize - nTell;
510 char* pEmptyData = new char[nSize];
511 memset(pEmptyData,0x00,nSize);
512 rStream.Write((BYTE*)pEmptyData,nSize);
513 rStream.Seek(nTell);
514 delete [] pEmptyData;
516 return rStream;
518 // -----------------------------------------------------------------------------
519 #if OSL_DEBUG_LEVEL > 1
520 //------------------------------------------------------------------
521 void ONDXPage::PrintPage()
523 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPage::PrintPage" );
524 DBG_TRACE4("\nSDB: -----------Page: %d Parent: %d Count: %d Child: %d-----",
525 nPagePos, HasParent() ? aParent->GetPagePos() : 0 ,nCount, aChild.GetPagePos());
527 for (USHORT i = 0; i < nCount; i++)
529 ONDXNode rNode = (*this)[i];
530 ONDXKey& rKey = rNode.GetKey();
531 if (!IsLeaf())
532 rNode.GetChild(&rIndex, this);
534 if (rKey.getValue().isNull())
536 DBG_TRACE2("SDB: [%d,NULL,%d]",rKey.GetRecord(), rNode.GetChild().GetPagePos());
538 else if (rIndex.getHeader().db_keytype)
540 DBG_TRACE3("SDB: [%d,%f,%d]",rKey.GetRecord(), rKey.getValue().getDouble(),rNode.GetChild().GetPagePos());
542 else
544 DBG_TRACE3("SDB: [%d,%s,%d]",rKey.GetRecord(), (const char* )ByteString(rKey.getValue().getString().getStr(), rIndex.m_pTable->getConnection()->getTextEncoding()).GetBuffer(),rNode.GetChild().GetPagePos());
547 DBG_TRACE("SDB: -----------------------------------------------\n");
548 if (!IsLeaf())
550 #if OSL_DEBUG_LEVEL > 1
551 GetChild(&rIndex)->PrintPage();
552 for (USHORT i = 0; i < nCount; i++)
554 ONDXNode rNode = (*this)[i];
555 rNode.GetChild(&rIndex,this)->PrintPage();
557 #endif
559 DBG_TRACE("SDB: ===============================================\n");
561 #endif
562 // -----------------------------------------------------------------------------
563 BOOL ONDXPage::IsFull() const
565 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPage::IsFull" );
566 return Count() == rIndex.getHeader().db_maxkeys;
568 // -----------------------------------------------------------------------------
569 //------------------------------------------------------------------
570 USHORT ONDXPage::Search(const ONDXKey& rSearch)
572 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPage::Search" );
573 // binare Suche spaeter
574 USHORT i = 0xFFFF;
575 while (++i < Count())
576 if ((*this)[i].GetKey() == rSearch)
577 break;
579 return (i < Count()) ? i : NODE_NOTFOUND;
582 //------------------------------------------------------------------
583 USHORT ONDXPage::Search(const ONDXPage* pPage)
585 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPage::Search" );
586 USHORT i = 0xFFFF;
587 while (++i < Count())
588 if (((*this)[i]).GetChild() == pPage)
589 break;
591 // wenn nicht gefunden, dann wird davon ausgegangen, dass die Seite selbst
592 // auf die Page zeigt
593 return (i < Count()) ? i : NODE_NOTFOUND;
595 // -----------------------------------------------------------------------------
596 // laeuft rekursiv
597 void ONDXPage::SearchAndReplace(const ONDXKey& rSearch,
598 ONDXKey& rReplace)
600 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPage::SearchAndReplace" );
601 OSL_ENSURE(rSearch != rReplace,"Invalid here:rSearch == rReplace");
602 if (rSearch != rReplace)
604 USHORT nPos = NODE_NOTFOUND;
605 ONDXPage* pPage = this;
607 while (pPage && (nPos = pPage->Search(rSearch)) == NODE_NOTFOUND)
608 pPage = pPage->aParent;
610 if (pPage)
612 (*pPage)[nPos].GetKey() = rReplace;
613 pPage->SetModified(TRUE);
617 // -----------------------------------------------------------------------------
618 ONDXNode& ONDXPage::operator[] (USHORT nPos)
620 DBG_ASSERT(nCount > nPos, "falscher Indexzugriff");
621 return ppNodes[nPos];
624 //------------------------------------------------------------------
625 const ONDXNode& ONDXPage::operator[] (USHORT nPos) const
627 DBG_ASSERT(nCount > nPos, "falscher Indexzugriff");
628 return ppNodes[nPos];
630 // -----------------------------------------------------------------------------
631 void ONDXPage::Remove(USHORT nPos)
633 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPage::Remove" );
634 DBG_ASSERT(nCount > nPos, "falscher Indexzugriff");
636 for (USHORT i = nPos; i < (nCount-1); i++)
637 (*this)[i] = (*this)[i+1];
639 nCount--;
640 bModified = TRUE;
642 // -----------------------------------------------------------------------------