1*8b851043SAndrew Rist /************************************************************** 2*8b851043SAndrew Rist * 3*8b851043SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*8b851043SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*8b851043SAndrew Rist * distributed with this work for additional information 6*8b851043SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*8b851043SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*8b851043SAndrew Rist * "License"); you may not use this file except in compliance 9*8b851043SAndrew Rist * with the License. You may obtain a copy of the License at 10*8b851043SAndrew Rist * 11*8b851043SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*8b851043SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*8b851043SAndrew Rist * software distributed under the License is distributed on an 15*8b851043SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*8b851043SAndrew Rist * KIND, either express or implied. See the License for the 17*8b851043SAndrew Rist * specific language governing permissions and limitations 18*8b851043SAndrew Rist * under the License. 19*8b851043SAndrew Rist * 20*8b851043SAndrew Rist *************************************************************/ 21*8b851043SAndrew Rist 22*8b851043SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _TOOLS_OWNLIST_HXX 25cdf0e10cSrcweir #define _TOOLS_OWNLIST_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _TOOLS_LIST_HXX //autogen 28cdf0e10cSrcweir #include <tools/list.hxx> 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir /************************************************************************* 31cdf0e10cSrcweir *************************************************************************/ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #define PRV_SV_DECL_OWNER_LIST(ClassName,Type) \ 34cdf0e10cSrcweir List aTypes; \ 35cdf0e10cSrcweir public: \ 36cdf0e10cSrcweir ClassName( sal_uInt16 nInitSize = 16, \ 37cdf0e10cSrcweir sal_uInt16 nReSize = 16 ) \ 38cdf0e10cSrcweir : aTypes( nInitSize, nReSize ) {} \ 39cdf0e10cSrcweir ClassName( const ClassName & rObj ) \ 40cdf0e10cSrcweir { *this = rObj; } \ 41cdf0e10cSrcweir ClassName & operator = ( const ClassName & ); \ 42cdf0e10cSrcweir ~ClassName() \ 43cdf0e10cSrcweir { Clear(); } \ 44cdf0e10cSrcweir void Clear(); \ 45cdf0e10cSrcweir void Remove() \ 46cdf0e10cSrcweir { delete (Type *)aTypes.Remove(); } \ 47cdf0e10cSrcweir void Remove( Type * pObj ) \ 48cdf0e10cSrcweir { delete (Type *)aTypes.Remove( pObj ); } \ 49cdf0e10cSrcweir void Remove( sal_uIntPtr nPos ) \ 50cdf0e10cSrcweir { delete (Type *)aTypes.Remove( nPos ); } \ 51cdf0e10cSrcweir Type & Insert( const Type &, sal_uIntPtr nPos ); \ 52cdf0e10cSrcweir Type & Insert( const Type & rType ) \ 53cdf0e10cSrcweir { return Insert( rType, aTypes.GetCurPos() ); } \ 54cdf0e10cSrcweir Type & Append( const Type & rType ) \ 55cdf0e10cSrcweir { return Insert( rType, LIST_APPEND ); } \ 56cdf0e10cSrcweir Type & GetObject( sal_uIntPtr nPos ) const \ 57cdf0e10cSrcweir { return *(Type *)aTypes.GetObject( nPos ); } \ 58cdf0e10cSrcweir Type & operator []( sal_uIntPtr nPos ) const \ 59cdf0e10cSrcweir { return *(Type *)aTypes.GetObject( nPos ); } \ 60cdf0e10cSrcweir sal_uIntPtr Count() const { return aTypes.Count(); } 61cdf0e10cSrcweir 62cdf0e10cSrcweir #define PRV_SV_IMPL_OWNER_LIST(ClassName,Type) \ 63cdf0e10cSrcweir ClassName & ClassName::operator = ( const ClassName & rObj ) \ 64cdf0e10cSrcweir { \ 65cdf0e10cSrcweir if( this != &rObj ) \ 66cdf0e10cSrcweir { \ 67cdf0e10cSrcweir Clear(); \ 68cdf0e10cSrcweir for( sal_uIntPtr i = 0; i < rObj.Count(); i++ ) \ 69cdf0e10cSrcweir Append( rObj.GetObject( i ) ); \ 70cdf0e10cSrcweir } \ 71cdf0e10cSrcweir return *this; \ 72cdf0e10cSrcweir } \ 73cdf0e10cSrcweir void ClassName::Clear() \ 74cdf0e10cSrcweir { \ 75cdf0e10cSrcweir Type * p = (Type *)aTypes.First(); \ 76cdf0e10cSrcweir while( p ) \ 77cdf0e10cSrcweir { \ 78cdf0e10cSrcweir delete p; \ 79cdf0e10cSrcweir p = (Type *)aTypes.Next(); \ 80cdf0e10cSrcweir } \ 81cdf0e10cSrcweir aTypes.Clear(); \ 82cdf0e10cSrcweir } \ 83cdf0e10cSrcweir Type & ClassName::Insert( const Type & rType, sal_uIntPtr nPos ) \ 84cdf0e10cSrcweir { \ 85cdf0e10cSrcweir Type * pType = new Type( rType ); \ 86cdf0e10cSrcweir aTypes.Insert( pType, nPos ); \ 87cdf0e10cSrcweir return *pType; \ 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir #endif // _TOOLS_OWNLIST_HXX 91