From 28a48f2aab4aa32ce8a7d46b8b5e6f26b732afd3 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 31 Jul 2012 20:18:22 +0200 Subject: svarray.hxx: 'e's pining for the fjords... Change-Id: I3eeb257092a76744482ebd2d0eccaa29ead8a644 --- svl/Library_svl.mk | 1 - svl/Package_inc.mk | 1 - svl/inc/svl/svarray.hxx | 202 ---------------------------------------- svl/source/memtools/svarray.cxx | 97 ------------------- 4 files changed, 301 deletions(-) delete mode 100644 svl/inc/svl/svarray.hxx delete mode 100644 svl/source/memtools/svarray.cxx (limited to 'svl') diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk index 41f91b5d062d..768f2db56a0f 100644 --- a/svl/Library_svl.mk +++ b/svl/Library_svl.mk @@ -105,7 +105,6 @@ $(eval $(call gb_Library_add_exception_objects,svl,\ svl/source/items/szitem \ svl/source/items/visitem \ svl/source/items/whiter \ - svl/source/memtools/svarray \ svl/source/misc/PasswordHelper \ svl/source/misc/adrparse \ svl/source/misc/documentlockfile \ diff --git a/svl/Package_inc.mk b/svl/Package_inc.mk index 2cb35440f076..ae63792d471c 100644 --- a/svl/Package_inc.mk +++ b/svl/Package_inc.mk @@ -98,7 +98,6 @@ $(eval $(call gb_Package_add_file,svl_inc,inc/svl/strmadpt.hxx,svl/strmadpt.hxx) $(eval $(call gb_Package_add_file,svl_inc,inc/svl/style.hrc,svl/style.hrc)) $(eval $(call gb_Package_add_file,svl_inc,inc/svl/style.hxx,svl/style.hxx)) $(eval $(call gb_Package_add_file,svl_inc,inc/svl/stylepool.hxx,svl/stylepool.hxx)) -$(eval $(call gb_Package_add_file,svl_inc,inc/svl/svarray.hxx,svl/svarray.hxx)) $(eval $(call gb_Package_add_file,svl_inc,inc/svl/svdde.hxx,svl/svdde.hxx)) $(eval $(call gb_Package_add_file,svl_inc,inc/svl/svl.hrc,svl/svl.hrc)) $(eval $(call gb_Package_add_file,svl_inc,inc/svl/svldllapi.h,svl/svldllapi.h)) diff --git a/svl/inc/svl/svarray.hxx b/svl/inc/svl/svarray.hxx deleted file mode 100644 index 23e702b2248a..000000000000 --- a/svl/inc/svl/svarray.hxx +++ /dev/null @@ -1,202 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef _SVARRAY_HXX -#define _SVARRAY_HXX - -/*********************************************************************** -* -* Hier folgt die Beschreibung fuer die exportierten Makros: -* -* SV_DECL_PTRARR_SORT(nm, AE, IS, GS) -* SV_IMPL_OP_PTRARR_SORT( nm,AE ) -* defieniere/implementiere ein Sort-Array mit Pointern, das nach -* Objecten sortiert ist. Basiert auf einem PTRARR. -* Sortierung mit Hilfe der Object-operatoren "<" und "==" -* -***********************************************************************/ - -#include "svl/svldllapi.h" - -#include // USHRT_MAX -#include -#include -#include - -typedef void* VoidPtr; -class SVL_DLLPUBLIC SvPtrarr -{ -protected: - VoidPtr *pData; - sal_uInt16 nFree; - sal_uInt16 nA; - - void _resize(size_t n); - -public: - SvPtrarr( sal_uInt16= 0 ); - ~SvPtrarr() { rtl_freeMemory( pData ); } - - VoidPtr& operator[](sal_uInt16 nP) const { return *(pData+nP); } - - void Insert( const SvPtrarr * pI, sal_uInt16 nP, - sal_uInt16 nS = 0, sal_uInt16 nE = USHRT_MAX ); - - VoidPtr& GetObject(sal_uInt16 nP) const { return (*this)[nP]; } - - void Insert( const VoidPtr& aE, sal_uInt16 nP ); - void Insert( const VoidPtr *pE, sal_uInt16 nL, sal_uInt16 nP ); - void Remove( sal_uInt16 nP, sal_uInt16 nL = 1 ); - sal_uInt16 Count() const { return nA; } - const VoidPtr* GetData() const { return (const VoidPtr*)pData; } - sal_uInt16 GetPos( const VoidPtr & aE ) const; -}; - -// SORTARR - Begin - -#define _SV_IMPL_SORTAR_ALG(nm, AE)\ -sal_Bool nm::Insert( const AE & aE )\ -{\ - sal_uInt16 nP;\ - sal_Bool bExist;\ - bExist = Seek_Entry( aE, &nP );\ - if( ! bExist )\ - nm##_SAR::Insert( aE, nP );\ - return !bExist;\ -}\ -\ -void nm::Remove( sal_uInt16 nP, sal_uInt16 nL )\ -{\ - if( nL )\ - nm##_SAR::Remove( nP, nL);\ -} - -#define SV_DECL_PTRARR_SORT(nm, AE, IS)\ -class nm##_SAR: public SvPtrarr \ -{\ -public:\ - nm##_SAR( sal_uInt16 nIni=IS )\ - : SvPtrarr(nIni) {}\ - void Insert( const nm##_SAR *pI, sal_uInt16 nP, \ - sal_uInt16 nS = 0, sal_uInt16 nE = USHRT_MAX ) {\ - SvPtrarr::Insert((const SvPtrarr*)pI, nP, nS, nE);\ - }\ - void Insert( const AE & aE, sal_uInt16 nP ) {\ - SvPtrarr::Insert( (const VoidPtr &)aE, nP );\ - }\ - void Insert( const AE *pE, sal_uInt16 nL, sal_uInt16 nP ) {\ - SvPtrarr::Insert( (const VoidPtr*)pE, nL, nP );\ - }\ - void Remove( sal_uInt16 nP, sal_uInt16 nL = 1) {\ - SvPtrarr::Remove(nP,nL);\ - }\ - const AE* GetData() const {\ - return (const AE*)SvPtrarr::GetData();\ - }\ - AE operator[]( sal_uInt16 nP )const { \ - return (AE)SvPtrarr::operator[](nP); }\ - AE GetObject(sal_uInt16 nP) const { \ - return (AE)SvPtrarr::GetObject(nP); }\ - \ - sal_uInt16 GetPos( const AE & aE ) const { \ - return SvPtrarr::GetPos((const VoidPtr &)aE);\ - }\ - void DeleteAndDestroy( sal_uInt16 nP, sal_uInt16 nL=1 );\ -private:\ - nm##_SAR( const nm##_SAR& );\ - nm##_SAR& operator=( const nm##_SAR& );\ -};\ -\ -class nm : private nm##_SAR \ -{\ -public:\ - nm(sal_uInt16 nSize = IS)\ - : nm##_SAR(nSize) {}\ - sal_Bool Insert( const AE& aE );\ - void Remove( sal_uInt16 nP, sal_uInt16 nL = 1 );\ - sal_uInt16 Count() const { return nm##_SAR::Count(); }\ - const AE* GetData() const { return (const AE*)pData; }\ - AE operator[](sal_uInt16 nP) const {\ - return nm##_SAR::operator[]( nP );\ - }\ - AE GetObject(sal_uInt16 nP) const {\ - return nm##_SAR::GetObject( nP );\ - }\ - sal_Bool Seek_Entry( const AE aE, sal_uInt16* pP = 0 ) const;\ - void DeleteAndDestroy( sal_uInt16 nP, sal_uInt16 nL=1 ); \ - sal_uInt16 GetPos( const AE& aE ) const { \ - return SvPtrarr::GetPos((const VoidPtr&)aE);\ - }\ -private:\ - nm( const nm& );\ - nm& operator=( const nm& );\ -}; - -#define SV_IMPL_OP_PTRARR_SORT( nm,AE )\ -_SV_IMPL_SORTAR_ALG( nm,AE )\ -void nm::DeleteAndDestroy( sal_uInt16 nP, sal_uInt16 nL ) { \ - if( nL ) {\ - OSL_ENSURE( nP < nA && nP + nL <= nA, "ERR_VAR_DEL" );\ - for( sal_uInt16 n=nP; n < nP + nL; n++ ) \ - delete *((AE*)pData+n); \ - SvPtrarr::Remove( nP, nL ); \ - } \ -} \ -sal_Bool nm::Seek_Entry( const AE aE, sal_uInt16* pP ) const\ -{\ - register sal_uInt16 nO = nm##_SAR::Count(),\ - nM, \ - nU = 0;\ - if( nO > 0 )\ - {\ - nO--;\ - while( nU <= nO )\ - {\ - nM = nU + ( nO - nU ) / 2;\ - if( *(*((AE*)pData + nM)) == *(aE) )\ - {\ - if( pP ) *pP = nM;\ - return sal_True;\ - }\ - else if( *(*((AE*)pData + nM)) < *(aE) )\ - nU = nM + 1;\ - else if( nM == 0 )\ - {\ - if( pP ) *pP = nU;\ - return sal_False;\ - }\ - else\ - nO = nM - 1;\ - }\ - }\ - if( pP ) *pP = nU;\ - return sal_False;\ -} - - - -#if defined(ICC) || defined(GCC) || (defined(WNT) && _MSC_VER >= 1400) -#define C40_INSERT( c, p, n ) Insert( (c const *&) p, n ) -#else -#define C40_INSERT( c, p, n ) Insert( p, n ) -#endif - -#endif //_SVARRAY_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svl/source/memtools/svarray.cxx b/svl/source/memtools/svarray.cxx deleted file mode 100644 index 6f1f1cb0cb25..000000000000 --- a/svl/source/memtools/svarray.cxx +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include -#include // memmove() - -SvPtrarr::SvPtrarr( sal_uInt16 nInit ) - : pData (0), - nFree (nInit), - nA (0) -{ - if( nInit ) - { - pData = (VoidPtr*)(rtl_allocateMemory(sizeof(VoidPtr) * nInit)); - OSL_ENSURE( pData, "CTOR, allocate"); - } -} - -void SvPtrarr::_resize (size_t n) -{ - sal_uInt16 nL = ((n < USHRT_MAX) ? sal_uInt16(n) : USHRT_MAX); - VoidPtr* pE = (VoidPtr*)(rtl_reallocateMemory (pData, sizeof(VoidPtr) * nL)); - if ((pE != 0) || (nL == 0)) - { - pData = pE; - nFree = nL - nA; - } -} - -void SvPtrarr::Insert( const VoidPtr& aE, sal_uInt16 nP ) -{ - OSL_ENSURE(nP <= nA && nA < USHRT_MAX, "Ins 1"); - if (nFree < 1) - _resize (nA + ((nA > 1) ? nA : 1)); - if( pData && nP < nA ) - memmove( pData+nP+1, pData+nP, (nA-nP) * sizeof( VoidPtr )); - *(pData+nP) = (VoidPtr&)aE; - ++nA; --nFree; -} - -void SvPtrarr::Insert( const VoidPtr* pE, sal_uInt16 nL, sal_uInt16 nP ) -{ - OSL_ENSURE(nP<=nA && ((long)nA+nL) nL) ? nA : nL)); - if( pData && nP < nA ) - memmove( pData+nP+nL, pData+nP, (nA-nP) * sizeof( VoidPtr )); - if( pE ) - memcpy( pData+nP, pE, nL * sizeof( VoidPtr )); - nA = nA + nL; nFree = nFree - nL; -} - -void SvPtrarr::Insert( const SvPtrarr * pI, sal_uInt16 nP, - sal_uInt16 nS, sal_uInt16 nE ) -{ - if( USHRT_MAX == nE ) - nE = pI->nA; - if( nS < nE ) - Insert( (const VoidPtr*)pI->pData+nS, (sal_uInt16)nE-nS, nP ); -} - -void SvPtrarr::Remove( sal_uInt16 nP, sal_uInt16 nL ) -{ - if( !nL ) - return; - OSL_ENSURE( nP < nA && nP + nL <= nA,"Del"); - if( pData && nP+1 < nA ) - memmove( pData+nP, pData+nP+nL, (nA-nP-nL) * sizeof( VoidPtr )); - nA = nA - nL; nFree = nFree + nL; - if (nFree > nA) - _resize (nA); -} - -sal_uInt16 SvPtrarr::GetPos( const VoidPtr& aElement ) const -{ - sal_uInt16 n; - for( n=0; n < nA && *(GetData()+n) != aElement; ) n++; - return ( n >= nA ? USHRT_MAX : n ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit