binfilter/bf_starmath/source/starmath_register.cxx | 2 binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx | 1 binfilter/bf_svtools/source/items/svt_macitem.cxx | 1 binfilter/bf_svtools/source/memtools/makefile.mk | 1 binfilter/bf_svtools/source/memtools/tl_contnr.cxx | 81 ++++ binfilter/bf_svtools/source/memtools/tl_table.cxx | 363 ++++++++++++++++++ binfilter/bf_svtools/source/misc/svt_imap.cxx | 1 binfilter/bf_svtools/source/misc/svt_urihelper.cxx | 1 binfilter/bf_svtools/source/misc1/svt_inettype.cxx | 2 binfilter/bf_svtools/source/uno/svt_unoevent.cxx | 1 binfilter/bf_svtools/source/uno/svt_unoimap.cxx | 1 binfilter/bf_svx/source/editeng/editdoc.hxx | 1 binfilter/bf_sw/source/core/text/inftxt.hxx | 2 binfilter/inc/bf_sc/chgtrack.hxx | 2 binfilter/inc/bf_sch/schopt.hxx | 2 binfilter/inc/bf_sfx2/objsh.hxx | 2 binfilter/inc/bf_svtools/macitem.hxx | 2 binfilter/inc/bf_svtools/zforlist.hxx | 2 binfilter/inc/bf_svx/forbiddencharacterstable.hxx | 2 binfilter/inc/bf_svx/svdmodel.hxx | 2 binfilter/inc/bf_svx/xtable.hxx | 1 binfilter/inc/bf_sw/hints.hxx | 2 binfilter/inc/bf_tools/contnr.hxx | 9 binfilter/inc/bf_tools/table.hxx | 153 +++++++ 24 files changed, 617 insertions(+), 20 deletions(-)
New commits: commit 319d686449ecf259763137d98e7ac2ce16701a28 Author: Michael Stahl <mst...@redhat.com> Date: Wed Apr 18 16:23:24 2012 +0200 move tools/table.hxx to binfilter diff --git a/binfilter/bf_starmath/source/starmath_register.cxx b/binfilter/bf_starmath/source/starmath_register.cxx index d2461ed..1f32129 100644 --- a/binfilter/bf_starmath/source/starmath_register.cxx +++ b/binfilter/bf_starmath/source/starmath_register.cxx @@ -35,8 +35,6 @@ #include <cppuhelper/factory.hxx> -#include <tools/table.hxx> - namespace binfilter { using namespace ::rtl; diff --git a/binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx b/binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx index 92e47a0..f109375 100644 --- a/binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx +++ b/binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx @@ -40,7 +40,6 @@ #include <sot/object.hxx> #include <boost/shared_ptr.hpp> #include <tools/debug.hxx> -#include <tools/table.hxx> #include <vcl/graph.hxx> #include <vcl/virdev.hxx> #include <tools/poly.hxx> diff --git a/binfilter/bf_svtools/source/items/svt_macitem.cxx b/binfilter/bf_svtools/source/items/svt_macitem.cxx index 3b2a7f6..8244278 100644 --- a/binfilter/bf_svtools/source/items/svt_macitem.cxx +++ b/binfilter/bf_svtools/source/items/svt_macitem.cxx @@ -27,7 +27,6 @@ ************************************************************************/ #include <tools/stream.hxx> -#include <tools/table.hxx> #include <bf_svtools/macitem.hxx> diff --git a/binfilter/bf_svtools/source/memtools/makefile.mk b/binfilter/bf_svtools/source/memtools/makefile.mk index 24aaa10..112b16b 100644 --- a/binfilter/bf_svtools/source/memtools/makefile.mk +++ b/binfilter/bf_svtools/source/memtools/makefile.mk @@ -40,6 +40,7 @@ INC+= -I$(PRJ)$/inc$/bf_svtools SLOFILES=\ $(SLO)$/svt_svarray.obj \ $(SLO)$/tl_contnr.obj \ + $(SLO)$/tl_table.obj \ $(SLO)$/tl_unqidx.obj # --- Targets ------------------------------------------------------- diff --git a/binfilter/bf_svtools/source/memtools/tl_table.cxx b/binfilter/bf_svtools/source/memtools/tl_table.cxx new file mode 100644 index 0000000..2b9d27f --- /dev/null +++ b/binfilter/bf_svtools/source/memtools/tl_table.cxx @@ -0,0 +1,363 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#define _TOOLS_TABLE_CXX + +// ----------------------------------------------------------------------- +#include <tools/debug.hxx> +#include <bf_tools/impcont.hxx> +#include <bf_tools/table.hxx> + +namespace binfilter +{ + +// ======================================================================= + +sal_uIntPtr Table::ImplGetIndex( sal_uIntPtr nKey, sal_uIntPtr* pIndex ) const +{ + // Abpruefen, ob der erste Key groesser als der Vergleichskey ist + if ( !nCount || (nKey < (sal_uIntPtr)Container::ImpGetObject(0)) ) + return TABLE_ENTRY_NOTFOUND; + + sal_uIntPtr nLow; + sal_uIntPtr nHigh; + sal_uIntPtr nMid; + sal_uIntPtr nCompareKey; + void** pNodes = Container::ImpGetOnlyNodes(); + + // Binaeres Suchen + nLow = 0; + nHigh = nCount-1; + if ( pNodes ) + { + do + { + nMid = (nLow + nHigh) / 2; + nCompareKey = (sal_uIntPtr)pNodes[nMid*2]; + if ( nKey < nCompareKey ) + nHigh = nMid-1; + else + { + if ( nKey > nCompareKey ) + nLow = nMid + 1; + else + return nMid*2; + } + } + while ( nLow <= nHigh ); + } + else + { + do + { + nMid = (nLow + nHigh) / 2; + nCompareKey = (sal_uIntPtr)Container::ImpGetObject( nMid*2 ); + if ( nKey < nCompareKey ) + nHigh = nMid-1; + else + { + if ( nKey > nCompareKey ) + nLow = nMid + 1; + else + return nMid*2; + } + } + while ( nLow <= nHigh ); + } + + if ( pIndex ) + { + if ( nKey > nCompareKey ) + *pIndex = (nMid+1)*2; + else + *pIndex = nMid*2; + } + + return TABLE_ENTRY_NOTFOUND; +} + +// ======================================================================= + +Table::Table( sal_uInt16 _nInitSize, sal_uInt16 _nReSize ) : + Container( CONTAINER_MAXBLOCKSIZE, _nInitSize*2, _nReSize*2 ) +{ + DBG_ASSERT( _nInitSize <= 32767, "Table::Table(): InitSize > 32767" ); + DBG_ASSERT( _nReSize <= 32767, "Table::Table(): ReSize > 32767" ); + nCount = 0; +} + +// ----------------------------------------------------------------------- + +sal_Bool Table::Insert( sal_uIntPtr nKey, void* p ) +{ + // Tabellenelement einsortieren + sal_uIntPtr i; + if ( nCount ) + { + if ( nCount <= 24 ) + { + sal_uInt16 nTempCount = (sal_uInt16)nCount * 2; + + if( void** pNodes = Container::ImpGetOnlyNodes() ) + { + sal_uInt16 n = 0; + sal_uIntPtr nCompareKey = (sal_uIntPtr)(*pNodes); + while ( nKey > nCompareKey ) + { + n += 2; + pNodes += 2; + if ( n < nTempCount ) + nCompareKey = (sal_uIntPtr)(*pNodes); + else + { + nCompareKey = 0; + break; + } + } + + // Testen, ob sich der Key schon in der Tabelle befindet + if ( nKey == nCompareKey ) + return sal_False; + + i = n; + } + else + { + i = 0; + if ( ImplGetIndex( nKey, &i ) != TABLE_ENTRY_NOTFOUND ) + return sal_False; + } + } + else + { + i = 0; + if ( ImplGetIndex( nKey, &i ) != TABLE_ENTRY_NOTFOUND ) + return sal_False; + } + } + else + i = 0; + + // Eintrag einfuegen (Key vor Pointer) + Container::Insert( (void*)nKey, i ); + Container::Insert( p, i+1 ); + + // Ein neuer Eintrag + nCount++; + + return sal_True; +} + +// ----------------------------------------------------------------------- + +void* Table::Remove( sal_uIntPtr nKey ) +{ + // Index besorgen + sal_uIntPtr nIndex = ImplGetIndex( nKey ); + + // Testen, ob sich der Key in der Tabelle befindet + if ( nIndex == TABLE_ENTRY_NOTFOUND ) + return NULL; + + // Itemanzahl erniedrigen + nCount--; + + // Key entfernen + Container::Remove( nIndex ); + + // Pointer entfernen und zurueckgeben + return Container::Remove( nIndex ); +} + +// ----------------------------------------------------------------------- + +void* Table::Replace( sal_uIntPtr nKey, void* p ) +{ + // Index abfragen + sal_uIntPtr nIndex = ImplGetIndex( nKey ); + + // Existiert kein Eintrag mit dem Schluessel + if ( nIndex == TABLE_ENTRY_NOTFOUND ) + return NULL; + else + return Container::Replace( p, nIndex+1 ); +} + +// ----------------------------------------------------------------------- + +void* Table::Get( sal_uIntPtr nKey ) const +{ + // Index besorgen + sal_uIntPtr nIndex = ImplGetIndex( nKey ); + + // Testen, ob sich der Key in der Tabelle befindet + if ( nIndex == TABLE_ENTRY_NOTFOUND ) + return NULL; + else + return Container::ImpGetObject( nIndex+1 ); +} + +// ----------------------------------------------------------------------- + +void* Table::GetCurObject() const +{ + return Container::ImpGetObject( Container::GetCurPos()+1 ); +} + +// ----------------------------------------------------------------------- + +sal_uIntPtr Table::GetKey( const void* p ) const +{ + sal_uIntPtr nIndex = 0; + + // Solange noch Eintraege Vorhanden sind + while ( nIndex < nCount ) + { + // Stimmt der Pointer ueberein, wird der Key zurueckgegeben + if ( p == Container::ImpGetObject( (nIndex*2)+1 ) ) + return (sal_uIntPtr)Container::ImpGetObject( nIndex*2 ); + + nIndex++; + } + + return TABLE_ENTRY_NOTFOUND; +} + +// ----------------------------------------------------------------------- + +sal_Bool Table::IsKeyValid( sal_uIntPtr nKey ) const +{ + return (ImplGetIndex( nKey ) != TABLE_ENTRY_NOTFOUND) ? sal_True : sal_False; +} + +// ----------------------------------------------------------------------- + +sal_uIntPtr Table::SearchKey( sal_uIntPtr nKey, sal_uIntPtr* pPos ) const +{ + *pPos = 0; + sal_uIntPtr nPos = ImplGetIndex( nKey, pPos ); + if ( nPos != TABLE_ENTRY_NOTFOUND ) + { + nPos /= 2; + *pPos = nPos; + } + else + *pPos /= 2; + return nPos; +} + +// ----------------------------------------------------------------------- + +void* Table::Seek( sal_uIntPtr nKey ) +{ + // Testen, ob ein Eintrag vorhanden ist + if ( nCount ) + { + sal_uIntPtr nIndex = ImplGetIndex( nKey ); + + // Ist Key nicht enthalten + if ( nIndex == TABLE_ENTRY_NOTFOUND ) + return NULL; + else + { + // Index setzen + Container::Seek( nIndex ); + + // Pointer zurueckgeben + return Container::ImpGetObject( Container::GetCurPos() + 1 ); + } + } + else + return NULL; +} + +void* Table::First() +{ + // Testen, ob ein Eintrag vorhanden ist + if ( nCount ) + { + // Auf ersten Eintag setzen + Container::First(); + + // Pointer zurueckgeben + return Container::ImpGetObject( 1 ); + } + else + return NULL; +} + +// ----------------------------------------------------------------------- + +void* Table::Last() +{ + // Testen, ob ein Eintrag vorhanden ist + if ( nCount ) + { + // Last auf letzten Eintrag setzen + void* p = Container::Last(); + Container::Prev(); + + // Pointer zurueckgeben + return p; + } + else + return NULL; +} + +// ----------------------------------------------------------------------- + +void* Table::Next() +{ + // Ueber den Pointer weiterschalten + Container::Next(); + + // Nachsten Eintag + Container::Next(); + + // Pointer vom naechsten Key zurueckgeben + return Container::ImpGetObject( Container::GetCurPos() + 1 ); +} + +// ----------------------------------------------------------------------- + +void* Table::Prev() +{ + // Ueber den Pointer weiterschalten + void* p = Container::Prev(); + + // Nachsten Eintag + Container::Prev(); + + // Pointer vom vorherigen Key zurueckgeben + return p; +} + +} // namespace binfilter + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svtools/source/misc/svt_imap.cxx b/binfilter/bf_svtools/source/misc/svt_imap.cxx index 49b76e9..32ea4cb 100644 --- a/binfilter/bf_svtools/source/misc/svt_imap.cxx +++ b/binfilter/bf_svtools/source/misc/svt_imap.cxx @@ -26,7 +26,6 @@ * ************************************************************************/ -#include <tools/table.hxx> #include <string.h> #include <math.h> #include <tools/urlobj.hxx> diff --git a/binfilter/bf_svtools/source/misc/svt_urihelper.cxx b/binfilter/bf_svtools/source/misc/svt_urihelper.cxx index 0ba6f92..0fb3982 100644 --- a/binfilter/bf_svtools/source/misc/svt_urihelper.cxx +++ b/binfilter/bf_svtools/source/misc/svt_urihelper.cxx @@ -27,7 +27,6 @@ ************************************************************************/ #include <tools/urlobj.hxx> -#include <tools/table.hxx> #include <urihelper.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" diff --git a/binfilter/bf_svtools/source/misc1/svt_inettype.cxx b/binfilter/bf_svtools/source/misc1/svt_inettype.cxx index a4419af..4f5e865 100644 --- a/binfilter/bf_svtools/source/misc1/svt_inettype.cxx +++ b/binfilter/bf_svtools/source/misc1/svt_inettype.cxx @@ -26,7 +26,7 @@ * ************************************************************************/ -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include <tools/wldcrd.hxx> #include <bf_svtools/inettype.hxx> diff --git a/binfilter/bf_svtools/source/uno/svt_unoevent.cxx b/binfilter/bf_svtools/source/uno/svt_unoevent.cxx index 223ef9a..8c0b5d2 100644 --- a/binfilter/bf_svtools/source/uno/svt_unoevent.cxx +++ b/binfilter/bf_svtools/source/uno/svt_unoevent.cxx @@ -26,7 +26,6 @@ * ************************************************************************/ -#include <tools/table.hxx> #include <bf_tools/string.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <rtl/ustrbuf.hxx> diff --git a/binfilter/bf_svtools/source/uno/svt_unoimap.cxx b/binfilter/bf_svtools/source/uno/svt_unoimap.cxx index 58d5eb7..5446f01 100644 --- a/binfilter/bf_svtools/source/uno/svt_unoimap.cxx +++ b/binfilter/bf_svtools/source/uno/svt_unoimap.cxx @@ -44,7 +44,6 @@ #include <cppuhelper/weakagg.hxx> #include <cppuhelper/implbase3.hxx> -#include <tools/table.hxx> #include <list> #include <rtl/uuid.h> diff --git a/binfilter/bf_svx/source/editeng/editdoc.hxx b/binfilter/bf_svx/source/editeng/editdoc.hxx index a4af2c9..f7bb1d1 100644 --- a/binfilter/bf_svx/source/editeng/editdoc.hxx +++ b/binfilter/bf_svx/source/editeng/editdoc.hxx @@ -38,7 +38,6 @@ #include <bf_svtools/itempool.hxx> -#include <tools/table.hxx> namespace binfilter { class ImpEditEngine; diff --git a/binfilter/bf_sw/source/core/text/inftxt.hxx b/binfilter/bf_sw/source/core/text/inftxt.hxx index b4e8767..6fe228d 100644 --- a/binfilter/bf_sw/source/core/text/inftxt.hxx +++ b/binfilter/bf_sw/source/core/text/inftxt.hxx @@ -32,7 +32,7 @@ #include <com/sun/star/linguistic2/XHyphenatedWord.hpp> #include <com/sun/star/beans/PropertyValues.hpp> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include "swtypes.hxx" #include "txttypes.hxx" diff --git a/binfilter/inc/bf_sc/chgtrack.hxx b/binfilter/inc/bf_sc/chgtrack.hxx index 6c860b7..ba14f2b 100644 --- a/binfilter/inc/bf_sc/chgtrack.hxx +++ b/binfilter/inc/bf_sc/chgtrack.hxx @@ -35,7 +35,7 @@ #include <tools/datetime.hxx> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include <tools/mempool.hxx> #include <bf_tools/stack.hxx> #include <bf_svtools/lstner.hxx> diff --git a/binfilter/inc/bf_sch/schopt.hxx b/binfilter/inc/bf_sch/schopt.hxx index 7664774..29296bc 100644 --- a/binfilter/inc/bf_sch/schopt.hxx +++ b/binfilter/inc/bf_sch/schopt.hxx @@ -40,7 +40,7 @@ // header for Color #include <tools/color.hxx> // header for Table -#include <tools/table.hxx> +#include <bf_tools/table.hxx> // header for XColorEntry #include <bf_svx/xtable.hxx> namespace binfilter { diff --git a/binfilter/inc/bf_sfx2/objsh.hxx b/binfilter/inc/bf_sfx2/objsh.hxx index 2aacaf0..62e29ea 100644 --- a/binfilter/inc/bf_sfx2/objsh.hxx +++ b/binfilter/inc/bf_sfx2/objsh.hxx @@ -46,7 +46,7 @@ #include <bf_so3/persist.hxx> #include <bf_so3/so2defs.hxx> #include <bf_so3/svstor.hxx> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include <vcl/timer.hxx> #include <vcl/bitmap.hxx> diff --git a/binfilter/inc/bf_svtools/macitem.hxx b/binfilter/inc/bf_svtools/macitem.hxx index d26ead3..3c90735 100644 --- a/binfilter/inc/bf_svtools/macitem.hxx +++ b/binfilter/inc/bf_svtools/macitem.hxx @@ -42,7 +42,7 @@ #include <bf_tools/string.hxx> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> class SvStream; diff --git a/binfilter/inc/bf_svtools/zforlist.hxx b/binfilter/inc/bf_svtools/zforlist.hxx index 5477e63..88ab125 100644 --- a/binfilter/inc/bf_svtools/zforlist.hxx +++ b/binfilter/inc/bf_svtools/zforlist.hxx @@ -33,7 +33,7 @@ #include "bf_svtools/svtdllapi.h" #include <bf_tools/string.hxx> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include <i18npool/lang.h> #include <bf_svtools/svarray.hxx> #include <com/sun/star/uno/Reference.hxx> diff --git a/binfilter/inc/bf_svx/forbiddencharacterstable.hxx b/binfilter/inc/bf_svx/forbiddencharacterstable.hxx index bb09b52..c07b483 100644 --- a/binfilter/inc/bf_svx/forbiddencharacterstable.hxx +++ b/binfilter/inc/bf_svx/forbiddencharacterstable.hxx @@ -31,7 +31,7 @@ #include <bf_svtools/bf_solar.h> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include <salhelper/simplereferenceobject.hxx> diff --git a/binfilter/inc/bf_svx/svdmodel.hxx b/binfilter/inc/bf_svx/svdmodel.hxx index 370bb13..60c4a5a 100644 --- a/binfilter/inc/bf_svx/svdmodel.hxx +++ b/binfilter/inc/bf_svx/svdmodel.hxx @@ -36,7 +36,7 @@ #include <bf_so3/svstor.hxx> #include <tools/link.hxx> -#include <tools/contnr.hxx> +#include <bf_tools/contnr.hxx> #include <vcl/mapmod.hxx> #include <bf_svtools/brdcst.hxx> #include <bf_tools/string.hxx> diff --git a/binfilter/inc/bf_svx/xtable.hxx b/binfilter/inc/bf_svx/xtable.hxx index aa6f3d0..0d8bf2a 100644 --- a/binfilter/inc/bf_svx/xtable.hxx +++ b/binfilter/inc/bf_svx/xtable.hxx @@ -44,7 +44,6 @@ #include <bf_tools/string.hxx> -#include <tools/table.hxx> class Color; class Bitmap; class VirtualDevice; diff --git a/binfilter/inc/bf_sw/hints.hxx b/binfilter/inc/bf_sw/hints.hxx index 4e7d8c6..2737491 100644 --- a/binfilter/inc/bf_sw/hints.hxx +++ b/binfilter/inc/bf_sw/hints.hxx @@ -30,7 +30,7 @@ #include <bf_svtools/bf_solar.h> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include <swatrset.hxx> class OutputDevice; namespace binfilter { diff --git a/binfilter/inc/bf_tools/table.hxx b/binfilter/inc/bf_tools/table.hxx new file mode 100644 index 0000000..e39b334 --- /dev/null +++ b/binfilter/inc/bf_tools/table.hxx @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _TOOLS_TABLE_HXX +#define _TOOLS_TABLE_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> +#include <bf_tools/contnr.hxx> + +namespace binfilter +{ + +// --------- +// - Table - +// --------- + +#define TABLE_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND + +class TOOLS_DLLPUBLIC Table : private Container +{ +private: + sal_uIntPtr nCount; + TOOLS_DLLPRIVATE sal_uIntPtr ImplGetIndex( sal_uIntPtr nKey, sal_uIntPtr* pIndex = NULL ) const; +public: + Table( sal_uInt16 nInitSize = 16, sal_uInt16 nReSize = 16 ); + Table( const Table& rTable ) : Container( rTable ) + { nCount = rTable.nCount; } + + sal_Bool Insert( sal_uIntPtr nKey, void* p ); + void* Remove( sal_uIntPtr nKey ); + void* Replace( sal_uIntPtr nKey, void* p ); + void* Get( sal_uIntPtr nKey ) const; + + void Clear() { Container::Clear(); nCount = 0; } + sal_uIntPtr Count() const { return( nCount ); } + + void* GetCurObject() const; + sal_uIntPtr GetCurKey() const { return (sal_uIntPtr)Container::GetCurObject(); } + sal_uIntPtr GetKey( const void* p ) const; + sal_Bool IsKeyValid( sal_uIntPtr nKey ) const; + + void* GetObject( sal_uIntPtr nPos ) const + { return Container::GetObject( (nPos*2)+1 ); } + sal_uIntPtr GetObjectKey( sal_uIntPtr nPos ) const + { return (sal_uIntPtr)Container::GetObject( nPos*2 ); } + sal_uIntPtr SearchKey( sal_uIntPtr nKey, sal_uIntPtr* pPos = NULL ) const; + + void* Seek( sal_uIntPtr nKey ); + void* First(); + void* Last(); + void* Next(); + void* Prev(); + + Table& operator =( const Table& rTable ); + + sal_Bool operator ==( const Table& rTable ) const + { return Container::operator ==( rTable ); } + sal_Bool operator !=( const Table& rTable ) const + { return Container::operator !=( rTable ); } +}; + +inline Table& Table::operator =( const Table& r ) +{ + Container::operator =( r ); + nCount = r.nCount; + return *this; +} + +// ----------------- +// - DECLARE_TABLE - +// ----------------- + +#define DECLARE_TABLE( ClassName, Type ) \ +class ClassName : private Table \ +{ \ +public: \ + using Table::Clear; \ + using Table::Count; \ + using Table::GetCurKey; \ + using Table::GetObjectKey; \ + using Table::SearchKey; \ + using Table::IsKeyValid; \ + \ + ClassName( sal_uInt16 _nInitSize = 16, \ + sal_uInt16 _nReSize = 16 ) : \ + Table( _nInitSize, _nReSize ) {} \ + ClassName( const ClassName& rClassName ) : \ + Table( rClassName ) {} \ + \ + sal_Bool Insert( sal_uIntPtr nKey, Type p ) \ + { return Table::Insert( nKey, (void*)p ); } \ + Type Remove( sal_uIntPtr nKey ) \ + { return (Type)Table::Remove( nKey ); } \ + Type Replace( sal_uIntPtr nKey, Type p ) \ + { return (Type)Table::Replace( nKey, (void*)p ); } \ + Type Get( sal_uIntPtr nKey ) const \ + { return (Type)Table::Get( nKey ); } \ + \ + Type GetCurObject() const \ + { return (Type)Table::GetCurObject(); } \ + sal_uIntPtr GetKey( const Type p ) const \ + { return Table::GetKey( (const void*)p ); } \ + \ + Type GetObject( sal_uIntPtr nPos ) const \ + { return (Type)Table::GetObject( nPos ); } \ + \ + Type Seek( sal_uIntPtr nKey ) \ + { return (Type)Table::Seek( nKey ); } \ + Type First() { return (Type)Table::First(); } \ + Type Last() { return (Type)Table::Last(); } \ + Type Next() { return (Type)Table::Next(); } \ + Type Prev() { return (Type)Table::Prev(); } \ + \ + ClassName& operator =( const ClassName& rClassName ) \ + { Table::operator =( rClassName ); \ + return *this; } \ + \ + sal_Bool operator ==( const ClassName& rTable ) const \ + { return Table::operator ==( rTable ); } \ + sal_Bool operator !=( const ClassName& rTable ) const \ + { return Table::operator !=( rTable ); } \ +}; + +} // namespace binfilter + +#endif // _TOOLS_TABLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 5b339c5537bb2a882621ca31e2fada391b16d217 Author: Michael Stahl <mst...@redhat.com> Date: Wed Apr 18 16:28:22 2012 +0200 partially revert 271e19336e594195ac6e40dd01ba62d2592f24e8 Turns out this stuff is used by Table diff --git a/binfilter/bf_svtools/source/memtools/tl_contnr.cxx b/binfilter/bf_svtools/source/memtools/tl_contnr.cxx index f0b48a9..e548d00 100644 --- a/binfilter/bf_svtools/source/memtools/tl_contnr.cxx +++ b/binfilter/bf_svtools/source/memtools/tl_contnr.cxx @@ -788,6 +788,17 @@ void Container::ImpInsert( void* p, CBlock* pBlock, sal_uInt16 nIndex ) |* *************************************************************************/ +void Container::Insert( void* p ) +{ + ImpInsert( p, pCurBlock, nCurIndex ); +} + +/************************************************************************* +|* +|* Container::Insert() +|* +*************************************************************************/ + void Container::Insert( void* p, sal_uIntPtr nIndex ) { if ( nCount <= nIndex ) @@ -892,6 +903,21 @@ void* Container::ImpRemove( CBlock* pBlock, sal_uInt16 nIndex ) |* *************************************************************************/ +void* Container::Remove() +{ + // Wenn kein Item vorhanden ist, NULL zurueckgeben + if ( !nCount ) + return NULL; + else + return ImpRemove( pCurBlock, nCurIndex ); +} + +/************************************************************************* +|* +|* Container::Remove() +|* +*************************************************************************/ + void* Container::Remove( sal_uIntPtr nIndex ) { // Ist Index nicht innerhalb des Containers, dann NULL zurueckgeben @@ -1107,6 +1133,23 @@ void Container::Clear() /************************************************************************* |* +|* Container::GetCurObject() +|* +*************************************************************************/ + +void* Container::GetCurObject() const +{ + DBG_CHKTHIS( Container, DbgCheckContainer ); + + // NULL, wenn Container leer + if ( !nCount ) + return NULL; + else + return pCurBlock->GetObject( nCurIndex ); +} + +/************************************************************************* +|* |* Container::GetCurPos() |* *************************************************************************/ @@ -1163,6 +1206,44 @@ void* Container::GetObject( sal_uIntPtr nIndex ) const /************************************************************************* |* +|* Container::GetPos() +|* +*************************************************************************/ + +sal_uIntPtr Container::GetPos( const void* p ) const +{ + DBG_CHKTHIS( Container, DbgCheckContainer ); + + void** pNodes; + CBlock* pTemp; + sal_uIntPtr nTemp; + sal_uInt16 nBlockCount; + sal_uInt16 i; + + // Block suchen + pTemp = pFirstBlock; + nTemp = 0; + while ( pTemp ) + { + pNodes = pTemp->GetNodes(); + i = 0; + nBlockCount = pTemp->Count(); + while ( i < nBlockCount ) + { + if ( p == *pNodes ) + return nTemp+i; + pNodes++; + i++; + } + nTemp += nBlockCount; + pTemp = pTemp->GetNextBlock(); + } + + return CONTAINER_ENTRY_NOTFOUND; +} + +/************************************************************************* +|* |* Container::Seek() |* *************************************************************************/ diff --git a/binfilter/inc/bf_tools/contnr.hxx b/binfilter/inc/bf_tools/contnr.hxx index 99b9bc6..6d7e70f 100644 --- a/binfilter/inc/bf_tools/contnr.hxx +++ b/binfilter/inc/bf_tools/contnr.hxx @@ -79,11 +79,17 @@ public: Container( const Container& rContainer ); ~Container(); + void Insert( void* p ); void Insert( void* p, sal_uIntPtr nIndex ); + void* Remove(); void* Remove( sal_uIntPtr nIndex ); + void* Remove( void* p ) + { return Remove( GetPos( p ) ); } void* Replace( void* p, sal_uIntPtr nIndex ); + void* Replace( void* pNew, void* pOld ) + { return Replace( pNew, GetPos( pOld ) ); } void SetSize( sal_uIntPtr nNewSize ); sal_uIntPtr GetSize() const { return nCount; } @@ -91,10 +97,13 @@ public: sal_uIntPtr Count() const { return nCount; } void Clear(); + void* GetCurObject() const; sal_uIntPtr GetCurPos() const; void* GetObject( sal_uIntPtr nIndex ) const; + sal_uIntPtr GetPos( const void* p ) const; void* Seek( sal_uIntPtr nIndex ); + void* Seek( void* p ) { return Seek( GetPos( p ) ); } void* First(); void* Last(); _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits