merge the formfield patch from ooo-build
[ooovba.git] / binfilter / inc / bf_svtools / itemset.hxx
blob2c80372403c6bf9ba4d39d75b17ddf759b11255b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: itemset.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SFXITEMSET_HXX
31 #define _SFXITEMSET_HXX
33 #if STLPORT_VERSION<321
34 #include <stdarg.h>
35 #else
36 #include <cstdarg> // std::va_list and friends
37 #endif
39 #ifndef _SFXPOOLITEM_HXX //autogen
40 #include <bf_svtools/poolitem.hxx>
41 #endif
42 #ifndef _RTTI_HXX //autogen
43 #include <tools/rtti.hxx>
44 #endif
45 #ifndef _SOLAR_H
46 #include <tools/solar.h>
47 #endif
49 class SvStream;
51 namespace binfilter
54 class SfxItemPool;
55 class SfxPoolItem;
57 typedef SfxPoolItem const** SfxItemArray;
59 #define USHORT_ARG int
61 #ifdef MI_HATS_REPARIERT
62 #ifndef DBG
63 #ifdef DBG_UTILx
64 #define DBG(s) s
65 #define _pChildCount(THIS) ( *(USHORT**)SfxPointerServer::GetServer()->GetPointer(THIS) )
66 #define _pChildCountCtor ( (*(USHORT**)SfxPointerServer::GetServer()->CreatePointer(this)) = new USHORT )
67 #define _pChildCountDtor ( SfxPointerServer::GetServer()->ReleasePointer(this) )
68 #else
69 #define DBG(s)
70 #endif
71 #endif
72 #else
73 #ifdef DBG
74 #undef DBG
75 #endif
76 #define DBG(s)
77 #endif
79 //========================================================================
81 #define SFX_ITEMSET_GET( rSet, pItem, ItemType, nSlotId, bDeep ) \
82 const ItemType *pItem = (const ItemType*) \
83 (rSet).GetItem( nSlotId, bDeep, TYPE(ItemType) )
85 //========================================================================
87 class SfxItemSet
89 friend class SfxItemIter;
91 SfxItemPool* _pPool; // der verwendete Pool
92 const SfxItemSet* _pParent; // Ableitung
93 SfxItemArray _aItems; // Item-Feld
94 USHORT* _pWhichRanges; // Array von Which-Bereichen
95 USHORT _nCount; // Anzahl Items
97 //---------------------------------------------------------------------
98 #ifndef _SFXITEMS_HXX
100 friend class SfxItemPoolCache;
101 friend class SfxAllItemSet;
102 friend const char *DbgCheckItemSet( const void* );
104 private:
105 void InitRanges_Impl(const USHORT *nWhichPairTable);
106 void InitRanges_Impl(va_list pWhich, USHORT n1, USHORT n2, USHORT n3);
107 void InitRanges_Impl(USHORT nWh1, USHORT nWh2);
109 public:
110 SfxItemArray GetItems_Impl() const { return _aItems; }
112 #endif
113 //---------------------------------------------------------------------
115 private:
116 const SfxItemSet& operator=(const SfxItemSet &); // n.i.!!
118 protected:
119 // Notification-Callback
120 virtual void Changed( const SfxPoolItem& rOld, const SfxPoolItem& rNew );
122 // direkte Put-Methode
123 int PutDirect(const SfxPoolItem &rItem);
125 public:
126 SfxItemSet( const SfxItemSet& );
128 SfxItemSet( SfxItemPool&, BOOL bTotalPoolRanges = FALSE );
129 SfxItemSet( SfxItemPool&, USHORT nWhich1, USHORT nWhich2 );
130 SfxItemSet( SfxItemPool&, USHORT_ARG nWh1, USHORT_ARG nWh2, USHORT_ARG nNull, ... );
131 SfxItemSet( SfxItemPool&, const USHORT* nWhichPairTable );
132 virtual ~SfxItemSet();
134 virtual SfxItemSet * Clone(BOOL bItems = TRUE, SfxItemPool *pToPool = 0) const;
136 // Items erfragen
137 USHORT Count() const { return _nCount; }
138 USHORT TotalCount() const;
140 virtual const SfxPoolItem& Get( USHORT nWhich, BOOL bSrchInParent = TRUE ) const;
141 const SfxPoolItem* GetItem( USHORT nWhich, BOOL bSrchInParent = TRUE,
142 TypeId aItemType = 0 ) const;
144 // Which-Wert des Items an der Position nPos erfragen
145 USHORT GetWhichByPos(USHORT nPos) const;
147 // Item-Status erfragen
148 SfxItemState GetItemState( USHORT nWhich,
149 BOOL bSrchInParent = TRUE,
150 const SfxPoolItem **ppItem = 0 ) const;
152 virtual void DisableItem(USHORT nWhich);
153 virtual void InvalidateItem( USHORT nWhich );
154 virtual USHORT ClearItem( USHORT nWhich = 0);
155 virtual void ClearInvalidItems( BOOL bHardDefault = FALSE );
156 void InvalidateAllItems(); HACK(via nWhich = 0)
158 inline void SetParent( const SfxItemSet* pNew );
160 // Items hinzufuegen, loeschen etc.
161 virtual const SfxPoolItem* Put( const SfxPoolItem&, USHORT nWhich );
162 const SfxPoolItem* Put( const SfxPoolItem& rItem )
163 { return Put(rItem, rItem.Which()); }
164 virtual int Put( const SfxItemSet&,
165 BOOL bInvalidAsDefault = TRUE );
166 void PutExtended( const SfxItemSet&,
167 SfxItemState eDontCareAs = SFX_ITEM_UNKNOWN,
168 SfxItemState eDefaultAs = SFX_ITEM_UNKNOWN );
170 virtual int Set( const SfxItemSet&, BOOL bDeep = TRUE );
172 virtual void Intersect( const SfxItemSet& rSet );
173 virtual void MergeValues( const SfxItemSet& rSet, BOOL bOverwriteDefaults = FALSE );
174 virtual void Differentiate( const SfxItemSet& rSet );
175 virtual void MergeValue( const SfxPoolItem& rItem, BOOL bOverwriteDefaults = FALSE );
177 SfxItemPool* GetPool() const { return _pPool; }
178 const USHORT* GetRanges() const { return _pWhichRanges; }
179 const SfxItemSet* GetParent() const { return _pParent; }
181 virtual SvStream & Load( SvStream &, FASTBOOL bDirect = FALSE,
182 const SfxItemPool *pRefPool = 0 );
183 virtual SvStream & Store( SvStream &, FASTBOOL bDirect = FALSE ) const;
185 virtual int operator==(const SfxItemSet &) const;
188 // --------------- Inline Implementierungen ------------------------
190 inline void SfxItemSet::SetParent( const SfxItemSet* pNew )
192 DBG( if (_pParent) --*_pChildCount(_pParent) );
193 _pParent = pNew;
194 DBG( if (_pParent) ++*_pChildCount(_pParent) );
197 //========================================================================
199 class SfxAllItemSet: public SfxItemSet
201 /* versteht alle Ranges; werden durch das Putten der Items
202 automatisch angepasst
206 SfxVoidItem aDefault;
207 USHORT nFree;
209 public:
210 SfxAllItemSet( SfxItemPool &rPool );
211 SfxAllItemSet( const SfxItemSet & );
212 SfxAllItemSet( const SfxAllItemSet & );
214 virtual SfxItemSet * Clone( BOOL bItems = TRUE, SfxItemPool *pToPool = 0 ) const;
215 virtual const SfxPoolItem* Put( const SfxPoolItem&, USHORT nWhich );
216 const SfxPoolItem* Put( const SfxPoolItem& rItem )
217 { return Put(rItem, rItem.Which()); }
218 virtual int Put( const SfxItemSet&,
219 BOOL bInvalidAsDefault = TRUE );
224 #endif // #ifndef _SFXITEMSET_HXX