diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2007-04-11 19:14:09 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2007-04-11 19:14:09 +0000 |
commit | 74b3acd4fab8a31f3c364340c459fe88c32ff68a (patch) | |
tree | 0b9342187ca64b74261bbedf890838f7607e0348 | |
parent | 6d7686370b8bf5e267c2761e73d6adeb7a20fe1b (diff) |
INTEGRATION: CWS hedaburemove01 (1.1.2); FILE ADDED
2006/12/12 16:24:48 vg 1.1.2.1: #i72503# gathered global includes in one place
-rw-r--r-- | tools/inc/tools/line.hxx | 88 | ||||
-rw-r--r-- | tools/inc/tools/link.hxx | 177 | ||||
-rw-r--r-- | tools/inc/tools/list.hxx | 156 | ||||
-rw-r--r-- | tools/inc/tools/mempool.hxx | 133 |
4 files changed, 554 insertions, 0 deletions
diff --git a/tools/inc/tools/line.hxx b/tools/inc/tools/line.hxx new file mode 100644 index 000000000000..95e2422f2b3e --- /dev/null +++ b/tools/inc/tools/line.hxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: line.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2007-04-11 20:13:40 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef _LINE_HXX +#define _LINE_HXX + +#ifndef INCLUDED_TOOLSDLLAPI_H +#include "tools/toolsdllapi.h" +#endif + +#ifndef _GEN_HXX +#include <tools/gen.hxx> +#endif + +class Link; + +// -------- +// - Line - +// -------- + +class TOOLS_DLLPUBLIC Line +{ +private: + + Point maStart; + Point maEnd; + +public: + Line() {}; + Line( const Point& rStartPt, const Point& rEndPt ) : maStart( rStartPt ), maEnd( rEndPt ) {} + + void SetStart( const Point& rStartPt ) { maStart = rStartPt; } + const Point& GetStart() const { return maStart; } + + void SetEnd( const Point& rEndPt ) { maEnd = rEndPt; } + const Point& GetEnd() const { return maEnd; } + + long Left() const { return ( maStart.X() < maEnd.X() ) ? maStart.X() : maEnd.X(); } + long Top() const { return ( maStart.Y() < maEnd.Y() ) ? maStart.Y() : maEnd.Y(); } + long Right() const { return ( maStart.X() > maEnd.X() ) ? maStart.X() : maEnd.X(); } + long Bottom() const { return ( maStart.Y() > maEnd.Y() ) ? maStart.Y() : maEnd.Y(); } + + double GetLength() const; + + BOOL Intersection( const Line& rLine, double& rIntersectionX, double& rIntersectionY ) const; + BOOL Intersection( const Line& rLine, Point& rIntersection ) const; + BOOL Intersection( const Rectangle& rRect, Line& rIntersection ) const; + + double GetDistance( const double& rPtX, const double& rPtY ) const; + double GetDistance( const Point& rPoint ) const { return( GetDistance( rPoint.X(), rPoint.Y() ) ); } + + Point NearestPoint( const Point& rPoint ) const; + + void Enum( const Link& rEnumLink ); +}; + +#endif // _SV_LINE_HXX diff --git a/tools/inc/tools/link.hxx b/tools/inc/tools/link.hxx new file mode 100644 index 000000000000..9e7e4fd87ddf --- /dev/null +++ b/tools/inc/tools/link.hxx @@ -0,0 +1,177 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: link.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2007-04-11 20:13:49 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef _LINK_HXX +#define _LINK_HXX + +#ifndef INCLUDED_TOOLSDLLAPI_H +#include "tools/toolsdllapi.h" +#endif + +#ifndef _SAL_CONFIG_H_ +#include "sal/config.h" +#endif + +#ifndef _SAL_TYPES_H_ +#include "sal/types.h" +#endif + +#ifndef _SOLAR_H +#include <tools/solar.h> +#endif + +// --------------- +// - Link-Makros - +// --------------- + +typedef long (*PSTUB)( void*, void* ); + +#define DECL_LINK( Method, ArgType ) \ + long Method( ArgType ); \ + static long LinkStub##Method( void* pThis, void* ) + +#define DECL_STATIC_LINK( Class, Method, ArgType ) \ + static long Method( Class*, ArgType ) + +#define DECL_DLLPRIVATE_LINK(Method, ArgType) \ + SAL_DLLPRIVATE long Method(ArgType); \ + SAL_DLLPRIVATE static long LinkStub##Method(void * pThis, void *) + +#define DECL_DLLPRIVATE_STATIC_LINK(Class, Method, ArgType) \ + SAL_DLLPRIVATE static long Method(Class *, ArgType) + +#define IMPL_METHOD( Class, Method, ArgType, ArgName ) \ + long Class::Method( ArgType ArgName ) + +#define IMPL_STUB(Class, Method, ArgType) \ + long __EXPORT Class::LinkStub##Method( void* pThis, void* pCaller) \ + { \ + return ((Class*)pThis )->Method( (ArgType)pCaller ); \ + } + +#define IMPL_STATIC_LINK( Class, Method, ArgType, ArgName ) \ + long __EXPORT Class::Method( Class* pThis, ArgType ArgName ) + +#define IMPL_STATIC_LINK_NOINSTANCE( Class, Method, ArgType, ArgName ) \ + long __EXPORT Class::Method( Class*, ArgType ArgName ) + +#define LINK( Inst, Class, Member ) \ + Link( (Class*)Inst, (PSTUB)&Class::LinkStub##Member ) + +#define STATIC_LINK( Inst, Class, Member ) \ + Link( (Class*)Inst, (PSTUB)&Class::Member ) + +#define IMPL_LINK( Class, Method, ArgType, ArgName ) \ + IMPL_STUB( Class, Method, ArgType ) \ + long Class::Method( ArgType ArgName ) + +#if defined GCC && defined NO_OPTIMIZE +#define IMPL_LINK_INLINE_START( Class, Method, ArgType, ArgName ) \ + IMPL_LINK( Class, Method, ArgType, ArgName ) + +#define IMPL_LINK_INLINE_END( Class, Method, ArgType, ArgName ) +#else +#define IMPL_LINK_INLINE_START( Class, Method, ArgType, ArgName ) \ + inline long Class::Method( ArgType ArgName ) + +#define IMPL_LINK_INLINE_END( Class, Method, ArgType, ArgName ) \ + IMPL_STUB( Class, Method, ArgType ) +#endif + +#define IMPL_LINK_INLINE( Class, Method, ArgType, ArgName, Body ) \ + long Class::Method( ArgType ArgName ) \ + Body \ + IMPL_STUB( Class, Method, ArgType ) + +#define EMPTYARG + +// -------- +// - Link - +// -------- + +class TOOLS_DLLPUBLIC Link +{ + void* pInst; + PSTUB pFunc; + +public: + Link(); + Link( void* pLinkHdl, PSTUB pMemFunc ); + + long Call( void* pCaller ) const; + + BOOL IsSet() const; + BOOL operator !() const; + + BOOL operator==( const Link& rLink ) const; + BOOL operator!=( const Link& rLink ) const + { return !(Link::operator==( rLink )); } + BOOL operator<( const Link& rLink ) const + { return ((ULONG)rLink.pFunc < (ULONG)pFunc); } +}; + +inline Link::Link() +{ + pInst = 0; + pFunc = 0; +} + +inline Link::Link( void* pLinkHdl, PSTUB pMemFunc ) +{ + pInst = pLinkHdl; + pFunc = pMemFunc; +} + +inline long Link::Call(void *pCaller) const +{ + return pFunc ? (*pFunc)(pInst, pCaller) : 0; +} + +inline BOOL Link::IsSet() const +{ + if ( pFunc ) + return TRUE; + else + return FALSE; +} + +inline BOOL Link::operator !() const +{ + if ( !pFunc ) + return TRUE; + else + return FALSE; +} + +#endif // _LINK_HXX diff --git a/tools/inc/tools/list.hxx b/tools/inc/tools/list.hxx new file mode 100644 index 000000000000..e41a3f20e905 --- /dev/null +++ b/tools/inc/tools/list.hxx @@ -0,0 +1,156 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: list.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2007-04-11 20:13:59 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _LIST_HXX +#define _LIST_HXX + +#ifndef _SOLAR_H +#include <tools/solar.h> +#endif + +#ifndef _CONTNR_HXX +#include <tools/contnr.hxx> +#endif + +// -------- +// - List - +// -------- + +#define LIST_APPEND CONTAINER_APPEND +#define LIST_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND + +class List : private Container +{ +public: + using Container::Insert; + using Container::Remove; + using Container::Replace; + using Container::Clear; + using Container::Count; + using Container::GetCurObject; + using Container::GetCurPos; + using Container::GetObject; + using Container::GetPos; + using Container::Seek; + using Container::First; + using Container::Last; + using Container::Next; + using Container::Prev; + + List( USHORT _nInitSize = 16, USHORT _nReSize = 16 ) : + Container( 1024, _nInitSize, _nReSize ) {} + List( USHORT _nBlockSize, USHORT _nInitSize, USHORT _nReSize ) : + Container( _nBlockSize, _nInitSize, _nReSize ) {} + List( const List& rList ) : Container( rList ) {} + + List& operator =( const List& rList ) + { Container::operator =( rList ); return *this; } + + BOOL operator ==( const List& rList ) const + { return Container::operator ==( rList ); } + BOOL operator !=( const List& rList ) const + { return Container::operator !=( rList ); } +}; + +// ---------------- +// - DECLARE_LIST - +// ---------------- + +#define DECLARE_LIST( ClassName, Type ) \ +class ClassName : private List \ +{ \ +public: \ + using List::Clear; \ + using List::Count; \ + using List::GetCurPos; \ + \ + ClassName( USHORT _nInitSize = 16, \ + USHORT _nReSize = 16 ) : \ + List( _nInitSize, _nReSize ) {} \ + ClassName( USHORT _nBlockSize, USHORT _nInitSize, \ + USHORT _nReSize ) : \ + List( _nBlockSize, _nInitSize, _nReSize ) {} \ + ClassName( const ClassName& rClassName ) : \ + List( rClassName ) {} \ + \ + void Insert( Type p, ULONG nIndex ) \ + { List::Insert( (void*)p, nIndex ); } \ + void Insert( Type p ) \ + { List::Insert( (void*)p ); } \ + void Insert( Type pNew, Type pOld ) \ + { List::Insert( (void*)pNew, (void*)pOld ); } \ + Type Remove() \ + { return (Type)List::Remove(); } \ + Type Remove( ULONG nIndex ) \ + { return (Type)List::Remove( nIndex ); } \ + Type Remove( Type p ) \ + { return (Type)List::Remove( (void*)p ); } \ + Type Replace( Type p ) \ + { return (Type)List::Replace( (void*)p ); } \ + Type Replace( Type p, ULONG nIndex ) \ + { return (Type)List::Replace( (void*)p, nIndex ); } \ + Type Replace( Type pNew, Type pOld ) \ + { return (Type)List::Replace( (void*)pNew, \ + (void*)pOld ); } \ + \ + Type GetCurObject() const \ + { return (Type)List::GetCurObject(); } \ + Type GetObject( ULONG nIndex ) const \ + { return (Type)List::GetObject( nIndex ); } \ + ULONG GetPos( const Type p ) const \ + { return List::GetPos( (const void*)p ); } \ + ULONG GetPos( const Type p, ULONG nStartIndex, \ + BOOL bForward = TRUE ) const \ + { return List::GetPos( (const void*)p, nStartIndex, \ + bForward ); } \ + \ + Type Seek( ULONG nIndex ) \ + { return (Type)List::Seek( nIndex ); } \ + Type Seek( void* p ) { return (Type)List::Seek( p ); } \ + Type First() { return (Type)List::First(); } \ + Type Last() { return (Type)List::Last(); } \ + Type Next() { return (Type)List::Next(); } \ + Type Prev() { return (Type)List::Prev(); } \ + \ + ClassName& operator =( const ClassName& rClassName ) \ + { List::operator =( rClassName ); return *this; } \ + \ + BOOL operator ==( const ClassName& rList ) const \ + { return List::operator ==( rList ); } \ + BOOL operator !=( const ClassName& rList ) const \ + { return List::operator !=( rList ); } \ +}; + +#endif // _LIST_HXX diff --git a/tools/inc/tools/mempool.hxx b/tools/inc/tools/mempool.hxx new file mode 100644 index 000000000000..5988766881fb --- /dev/null +++ b/tools/inc/tools/mempool.hxx @@ -0,0 +1,133 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: mempool.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2007-04-11 20:14:09 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef _SVMEMPOOL_HXX +#define _SVMEMPOOL_HXX + +#ifndef INCLUDED_TOOLSDLLAPI_H +#include "tools/toolsdllapi.h" +#endif + +#ifndef _SOLAR_H +#include <tools/solar.h> +#endif + +// ---------------- +// - FixedMemPool - +// ---------------- + +struct FixedMemPool_Impl; + +class TOOLS_DLLPUBLIC FixedMemPool +{ + FixedMemPool_Impl * m_pImpl; + +public: + FixedMemPool( USHORT nTypeSize, + USHORT nInitSize = 512, + USHORT nGrowSize = 256 ); + ~FixedMemPool(); + + void* Alloc(); + void Free( void* p ); +}; + +// ---------------------------- +// - DECL_FIXEDMEMPOOL_NEWDEL - +// ---------------------------- + +#define DECL_FIXEDMEMPOOL_NEW_DECL() \ +static void * operator new( size_t n ) + +#define DECL_FIXEDMEMPOOL_NEW_IMPL( Class ) \ +void * Class::operator new( size_t n ) + +#define IMPL_FIXEDMEMPOOL_NEW_BODY( Class, aPool ) \ +{ \ + if ( n == sizeof( Class ) ) \ + return (aPool).Alloc(); \ + else \ + return ::operator new(n); \ +} + +#define DECL_FIXEDMEMPOOL_NEW_INLINE( Class, aPool ) \ +DECL_FIXEDMEMPOOL_NEW_DECL() \ +IMPL_FIXEDMEMPOOL_NEW_BODY( Class, aPool ) + +#define DECL_FIXEDMEMPOOL_DEL_DECL() \ +static void operator delete( void * p, size_t n ) + +#define DECL_FIXEDMEMPOOL_DEL_IMPL( Class ) \ +void Class::operator delete( void * p, size_t n ) + +#define IMPL_FIXEDMEMPOOL_DEL_BODY( Class, aPool ) \ +{ \ + if ( n == sizeof( Class ) ) \ + (aPool).Free(p); \ + else \ + ::operator delete(p); \ +} + +#define DECL_FIXEDMEMPOOL_DEL_INLINE( Class, aPool ) \ +DECL_FIXEDMEMPOOL_DEL_DECL() \ +IMPL_FIXEDMEMPOOL_DEL_BODY( Class, aPool ) + +#define DECL_FIXEDMEMPOOL_NEWDEL( Class ) \ + private: \ + static FixedMemPool aPool; \ + public: \ + DECL_FIXEDMEMPOOL_NEW_INLINE( Class, aPool ) \ + DECL_FIXEDMEMPOOL_DEL_INLINE( Class, aPool ) + +#define IMPL_FIXEDMEMPOOL_NEWDEL( Class, InitSize, GrowSize) \ + FixedMemPool Class::aPool( sizeof( Class ), (InitSize), (GrowSize) ); + +#define DECL_FIXEDMEMPOOL_NEWDEL_DLL( Class ) \ + private: \ + static FixedMemPool aPool; \ + public: \ + DECL_FIXEDMEMPOOL_NEW_DECL(); \ + DECL_FIXEDMEMPOOL_DEL_DECL(); + +#define IMPL_FIXEDMEMPOOL_NEWDEL_DLL( Class, InitSize, GrowSize) \ + FixedMemPool Class::aPool( sizeof( Class ), (InitSize), (GrowSize) ); \ + DECL_FIXEDMEMPOOL_NEW_IMPL( Class ) \ + IMPL_FIXEDMEMPOOL_NEW_BODY( Class, aPool ) \ + DECL_FIXEDMEMPOOL_DEL_IMPL( Class ) \ + IMPL_FIXEDMEMPOOL_DEL_BODY( Class, aPool ) + +#define INIT_FIXEDMEMPOOL_NEWDEL_DLL( class, aPool, InitSize, GrowSize ) \ + aPool( sizeof( class ), InitSize, GrowSize ) + +#endif // _SVMEMPOOL_HXX |