diff options
author | Jan Holesovsky <kendy@suse.cz> | 2011-08-15 09:44:09 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-08-15 13:11:54 +0200 |
commit | fa77c78adaf0035000a0c107379ccd5abd348c91 (patch) | |
tree | f6ce568851b312917eb47959ff571fb5d0f33abc /sfx2 | |
parent | 099c219cf67e469c4177d41bfcdbfb70a9988931 (diff) |
callcatcher: Remove unused ByteArr class, and DECL_1BYTEARRAY define.
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/minarray.hxx | 65 | ||||
-rw-r--r-- | sfx2/source/bastyp/minarray.cxx | 232 |
2 files changed, 0 insertions, 297 deletions
diff --git a/sfx2/inc/sfx2/minarray.hxx b/sfx2/inc/sfx2/minarray.hxx index 9ed76ede6039..37c82cfe7c04 100644 --- a/sfx2/inc/sfx2/minarray.hxx +++ b/sfx2/inc/sfx2/minarray.hxx @@ -390,71 +390,6 @@ public:\ void Clear() { Remove( 0, Count() ); }\ }; -class ByteArr -{ -private: - char* pData; - sal_uInt16 nUsed; - sal_uInt8 nGrow; - sal_uInt8 nUnused; -public: - ByteArr( sal_uInt8 nInitSize = 0, sal_uInt8 nGrowSize = 8 ); - ByteArr( const ByteArr& rOrig ); - ~ByteArr(); - ByteArr& operator= ( const ByteArr& rOrig ); - char GetObject( sal_uInt16 nPos ) const { return operator[](nPos); } - char& GetObject( sal_uInt16 nPos ) { return operator[](nPos); } - void Insert( sal_uInt16 nPos, char rElem ); - void Append( char rElem ); - sal_Bool Remove( char rElem ); - sal_uInt16 Remove( sal_uInt16 nPos, sal_uInt16 nLen ); - sal_uInt16 Count() const { return nUsed; } - char* operator*(); - char operator[]( sal_uInt16 nPos ) const; - char& operator[]( sal_uInt16 nPos ); - sal_Bool Contains( const char rItem ) const; - void Clear() { Remove( 0, Count() ); } -}; - -inline char* ByteArr::operator*() -{ - return ( nUsed==0 ? 0 : pData ); -} - -#define DECL_1BYTEARRAY(ARR, T, nI, nG)\ -class ARR: public ByteArr\ -{\ -public:\ - ARR( sal_uInt8 nIni=nI, sal_uInt8 nGrow=nG ):\ - ByteArr(nIni,nGrow) \ - {}\ - ARR( const ARR& rOrig ):\ - ByteArr(rOrig) \ - {}\ - T GetObject( sal_uInt16 nPos ) const { return operator[](nPos); } \ - T& GetObject( sal_uInt16 nPos ) { return operator[](nPos); } \ - void Insert( sal_uInt16 nPos, T aElement ) {\ - ByteArr::Insert(nPos,(char)aElement);\ - }\ - void Append( T aElement ) {\ - ByteArr::Append((char)aElement);\ - }\ - void Remove( T aElement ) {\ - ByteArr::Remove((char)aElement);\ - }\ - void Remove( sal_uInt16 nPos, sal_uInt16 nLen = 1 ) {\ - ByteArr::Remove( nPos, nLen ); \ - }\ - T* operator *() {\ - return (T*) ByteArr::operator*();\ - }\ - T operator[]( sal_uInt16 nPos ) const { \ - return (T) ByteArr::operator[](nPos); } \ - T& operator[]( sal_uInt16 nPos ) { \ - return (T&) ByteArr::operator[](nPos); } \ - void Clear() { Remove( 0, Count() ); }\ -}; - class WordArr { private: diff --git a/sfx2/source/bastyp/minarray.cxx b/sfx2/source/bastyp/minarray.cxx index 4deae2555f0a..2137c625d70f 100644 --- a/sfx2/source/bastyp/minarray.cxx +++ b/sfx2/source/bastyp/minarray.cxx @@ -267,238 +267,6 @@ void SfxPtrArr::Insert( sal_uInt16 nPos, void* rElem ) nUnused -= 1; } -// class ByteArr --------------------------------------------------------- - -ByteArr::ByteArr( sal_uInt8 nInitSize, sal_uInt8 nGrowSize ): - nUsed( 0 ), - nGrow( nGrowSize ? nGrowSize : 1 ), - nUnused( nInitSize ) -{ - DBG_MEMTEST(); - sal_uInt16 nMSCBug = nInitSize; - - if ( nInitSize > 0 ) - pData = new char[nMSCBug]; - else - pData = 0; -} - -// ----------------------------------------------------------------------- - -ByteArr::ByteArr( const ByteArr& rOrig ) -{ - DBG_MEMTEST(); - nUsed = rOrig.nUsed; - nGrow = rOrig.nGrow; - nUnused = rOrig.nUnused; - - if ( rOrig.pData != 0 ) - { - pData = new char[nUsed+nUnused]; - memcpy( pData, rOrig.pData, nUsed*sizeof(char) ); - } - else - pData = 0; -} - -// ----------------------------------------------------------------------- - -ByteArr::~ByteArr() -{ - DBG_MEMTEST(); - delete [] pData; -} - -// ----------------------------------------------------------------------- - -ByteArr& ByteArr::operator=( const ByteArr& rOrig ) -{ - DBG_MEMTEST(); - - delete [] pData; - - nUsed = rOrig.nUsed; - nGrow = rOrig.nGrow; - nUnused = rOrig.nUnused; - - if ( rOrig.pData != 0 ) - { - pData = new char[nUsed+nUnused]; - memcpy( pData, rOrig.pData, nUsed*sizeof(char) ); - } - else - pData = 0; - return *this; -} - -// ----------------------------------------------------------------------- - -void ByteArr::Append( char aElem ) -{ - DBG_MEMTEST(); - // Does the Array have o be copied? - if ( nUnused == 0 ) - { - sal_uInt16 nNewSize = (nUsed == 1) ? (nGrow==1 ? 2 : nGrow) : nUsed+nGrow; - char* pNewData = new char[nNewSize]; - if ( pData ) - { - DBG_ASSERT( nUsed <= nNewSize, "" ); - memmove( pNewData, pData, sizeof(char)*nUsed ); - delete [] pData; - } - nUnused = sal::static_int_cast< sal_uInt8 >(nNewSize-nUsed); - pData = pNewData; - } - - // now write at the back in the open space - pData[nUsed] = aElem; - ++nUsed; - --nUnused; -} - -// ----------------------------------------------------------------------- - -sal_uInt16 ByteArr::Remove( sal_uInt16 nPos, sal_uInt16 nLen ) -{ - DBG_MEMTEST(); - // Adjust nLen, thus to avoid deleting beyond the end - nLen = Min( (sal_uInt16)(nUsed-nPos), nLen ); - - // simple problems require simple solutions! - if ( nLen == 0 ) - return 0; - - // Maybe no one will remain - if ( (nUsed-nLen) == 0 ) - { - delete [] pData; - pData = 0; - nUsed = 0; - nUnused = 0; - return nLen; - } - - // Determine whether the array has physically shrunk... - if ( (nUnused+nLen) >= nGrow ) - { - // reduce (rounded up) to the next Grow-border - sal_uInt16 nNewUsed = nUsed-nLen; - sal_uInt16 nNewSize = ((nNewUsed+nGrow-1)/nGrow) * nGrow; - DBG_ASSERT( nNewUsed <= nNewSize && nNewUsed+nGrow > nNewSize, - "shrink size computation failed" ); - char* pNewData = new char[nNewSize]; - if ( nPos > 0 ) - { - DBG_ASSERT( nPos <= nNewSize, "" ); - memmove( pNewData, pData, sizeof(char)*nPos ); - } - if ( nNewUsed != nPos ) - memmove( pNewData+nPos, pData+nPos+nLen, - sizeof(char)*(nNewUsed-nPos) ); - delete [] pData; - pData = pNewData; - nUsed = nNewUsed; - nUnused = sal::static_int_cast< sal_uInt8 >(nNewSize - nNewUsed); - return nLen; - } - - // in all other cases, only push together - if ( nUsed-nPos-nLen > 0 ) - memmove( pData+nPos, pData+nPos+nLen, (nUsed-nPos-nLen)*sizeof(char) ); - nUsed = nUsed - nLen; - nUnused = sal::static_int_cast< sal_uInt8 >(nUnused + nLen); - return nLen; -} - -// ----------------------------------------------------------------------- - -sal_Bool ByteArr::Remove( char aElem ) -{ - DBG_MEMTEST(); - // simple tasks ... - if ( nUsed == 0 ) - return sal_False; - - // backwards, since most of the last is first removed - char *pIter = pData + nUsed - 1; - for ( sal_uInt16 n = 0; n < nUsed; ++n, --pIter ) - if ( *pIter == aElem ) - { - Remove(nUsed-n-1, 1); - return sal_True; - } - return sal_False; -} - -// ----------------------------------------------------------------------- - -sal_Bool ByteArr::Contains( const char rItem ) const -{ - DBG_MEMTEST(); - if ( !nUsed ) - return sal_False; - - for ( sal_uInt16 n = 0; n < nUsed; ++n ) - { - char p = GetObject(n); - if ( p == rItem ) - return sal_True; - } - - return sal_False; -} - -// ----------------------------------------------------------------------- - -void ByteArr::Insert( sal_uInt16 nPos, char rElem ) -{ - DBG_MEMTEST(); - // Does the Array need to be copied? - if ( nUnused == 0 ) - { - // increase (rounded up) to the next Grow-border - sal_uInt16 nNewSize = nUsed+nGrow; - char* pNewData = new char[nNewSize]; - - if ( pData ) - { - DBG_ASSERT( nUsed < nNewSize, "" ); - memmove( pNewData, pData, sizeof(char)*nUsed ); - delete [] pData; - } - nUnused = sal::static_int_cast< sal_uInt8 >(nNewSize-nUsed); - pData = pNewData; - } - - // Now move the rear part - if ( nPos < nUsed ) - memmove( pData+nPos+1, pData+nPos, (nUsed-nPos)*sizeof(char) ); - - // now write at the back in the open space - memmove( pData+nPos, &rElem, sizeof(char) ); - nUsed += 1; - nUnused -= 1; -} - -// ----------------------------------------------------------------------- - -char ByteArr::operator[]( sal_uInt16 nPos ) const -{ - DBG_MEMTEST(); - DBG_ASSERT( nPos < nUsed, "" ); - return *(pData+nPos); -} - -// ----------------------------------------------------------------------- - -char& ByteArr::operator [] (sal_uInt16 nPos) -{ - DBG_MEMTEST(); - DBG_ASSERT( nPos < nUsed, "" ); - return *(pData+nPos); -} - // class WordArr --------------------------------------------------------- WordArr::WordArr( sal_uInt8 nInitSize, sal_uInt8 nGrowSize ): |