bump product version to 4.1.6.2
[LibreOffice.git] / include / svl / itemset.hxx
bloba38398ac1ce7957342371b828f674f93c2818d5b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _SFXITEMSET_HXX
20 #define _SFXITEMSET_HXX
22 #include "svl/svldllapi.h"
24 #include <cstdarg> // std::va_list and friends
25 #include <svl/poolitem.hxx>
26 #include <tools/rtti.hxx>
27 #include <tools/solar.h>
29 class SfxItemPool;
30 class SfxPoolItem;
31 class SvStream;
33 typedef SfxPoolItem const** SfxItemArray;
35 #define USHORT_ARG int
37 #ifdef DBG
38 #undef DBG
39 #endif
40 #define DBG(s)
42 //========================================================================
44 #define SFX_ITEMSET_GET( rSet, pItem, ItemType, nSlotId, bDeep ) \
45 const ItemType *pItem = (const ItemType*) \
46 (rSet).GetItem( nSlotId, bDeep, TYPE(ItemType) )
48 //========================================================================
50 class SVL_DLLPUBLIC SfxItemSet
52 friend class SfxItemIter;
54 SfxItemPool* _pPool; // der verwendete Pool
55 const SfxItemSet* _pParent; // Ableitung
56 SfxItemArray _aItems; // Item-Feld
57 sal_uInt16* _pWhichRanges; // Array von Which-Bereichen
58 sal_uInt16 _nCount; // Anzahl Items
60 //---------------------------------------------------------------------
61 #ifndef _SFXITEMS_HXX
63 friend class SfxItemPoolCache;
64 friend class SfxAllItemSet;
65 friend const char *DbgCheckItemSet( const void* );
67 private:
68 SVL_DLLPRIVATE void InitRanges_Impl(const sal_uInt16 *nWhichPairTable);
69 SVL_DLLPRIVATE void InitRanges_Impl(va_list pWhich, sal_uInt16 n1, sal_uInt16 n2, sal_uInt16 n3);
70 SVL_DLLPRIVATE void InitRanges_Impl(sal_uInt16 nWh1, sal_uInt16 nWh2);
72 public:
73 SfxItemArray GetItems_Impl() const { return _aItems; }
75 #endif
76 //---------------------------------------------------------------------
78 private:
79 const SfxItemSet& operator=(const SfxItemSet &); // n.i.!!
81 protected:
82 // Notification-Callback
83 virtual void Changed( const SfxPoolItem& rOld, const SfxPoolItem& rNew );
85 // direkte Put-Methode
86 int PutDirect(const SfxPoolItem &rItem);
88 public:
89 SfxItemSet( const SfxItemSet& );
91 SfxItemSet( SfxItemPool&, sal_Bool bTotalPoolRanges = sal_False );
92 SfxItemSet( SfxItemPool&, sal_uInt16 nWhich1, sal_uInt16 nWhich2 );
93 SfxItemSet( SfxItemPool&, USHORT_ARG nWh1, USHORT_ARG nWh2, USHORT_ARG nNull, ... );
94 SfxItemSet( SfxItemPool&, const sal_uInt16* nWhichPairTable );
95 virtual ~SfxItemSet();
97 virtual SfxItemSet * Clone(sal_Bool bItems = sal_True, SfxItemPool *pToPool = 0) const;
99 // Items erfragen
100 sal_uInt16 Count() const { return _nCount; }
101 sal_uInt16 TotalCount() const;
103 virtual const SfxPoolItem& Get( sal_uInt16 nWhich, sal_Bool bSrchInParent = sal_True ) const;
104 const SfxPoolItem* GetItem( sal_uInt16 nWhich, sal_Bool bSrchInParent = sal_True,
105 TypeId aItemType = 0 ) const;
107 // Which-Wert des Items an der Position nPos erfragen
108 sal_uInt16 GetWhichByPos(sal_uInt16 nPos) const;
110 // Item-Status erfragen
111 SfxItemState GetItemState( sal_uInt16 nWhich,
112 sal_Bool bSrchInParent = sal_True,
113 const SfxPoolItem **ppItem = 0 ) const;
115 bool HasItem(sal_uInt16 nWhich, const SfxPoolItem** ppItem = NULL) const;
117 virtual void DisableItem(sal_uInt16 nWhich);
118 virtual void InvalidateItem( sal_uInt16 nWhich );
119 virtual sal_uInt16 ClearItem( sal_uInt16 nWhich = 0);
120 virtual void ClearInvalidItems( sal_Bool bHardDefault = sal_False );
121 void InvalidateAllItems(); // HACK(via nWhich = 0) ???
123 inline void SetParent( const SfxItemSet* pNew );
125 // Items hinzufuegen, loeschen etc.
126 virtual const SfxPoolItem* Put( const SfxPoolItem&, sal_uInt16 nWhich );
127 const SfxPoolItem* Put( const SfxPoolItem& rItem )
128 { return Put(rItem, rItem.Which()); }
129 virtual int Put( const SfxItemSet&,
130 sal_Bool bInvalidAsDefault = sal_True );
131 void PutExtended( const SfxItemSet&,
132 SfxItemState eDontCareAs = SFX_ITEM_UNKNOWN,
133 SfxItemState eDefaultAs = SFX_ITEM_UNKNOWN );
135 virtual int Set( const SfxItemSet&, sal_Bool bDeep = sal_True );
137 virtual void Intersect( const SfxItemSet& rSet );
138 virtual void MergeValues( const SfxItemSet& rSet, sal_Bool bOverwriteDefaults = sal_False );
139 virtual void Differentiate( const SfxItemSet& rSet );
140 virtual void MergeValue( const SfxPoolItem& rItem, sal_Bool bOverwriteDefaults = sal_False );
142 SfxItemPool* GetPool() const { return _pPool; }
143 const sal_uInt16* GetRanges() const { return _pWhichRanges; }
144 void SetRanges( const sal_uInt16 *pRanges );
145 void MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo );
146 const SfxItemSet* GetParent() const { return _pParent; }
148 virtual SvStream & Load( SvStream &, bool bDirect = false,
149 const SfxItemPool *pRefPool = 0 );
150 virtual SvStream & Store( SvStream &, bool bDirect = false ) const;
152 virtual int operator==(const SfxItemSet &) const;
155 // --------------- Inline Implementierungen ------------------------
157 inline void SfxItemSet::SetParent( const SfxItemSet* pNew )
159 DBG( if (_pParent) --*_pChildCount(_pParent) );
160 _pParent = pNew;
161 DBG( if (_pParent) ++*_pChildCount(_pParent) );
164 //========================================================================
166 class SVL_DLLPUBLIC SfxAllItemSet: public SfxItemSet
168 /* versteht alle Ranges; werden durch das Putten der Items
169 automatisch angepasst
173 SfxVoidItem aDefault;
174 sal_uInt16 nFree;
176 public:
177 SfxAllItemSet( SfxItemPool &rPool );
178 SfxAllItemSet( const SfxItemSet & );
179 SfxAllItemSet( const SfxAllItemSet & );
181 virtual SfxItemSet * Clone( sal_Bool bItems = sal_True, SfxItemPool *pToPool = 0 ) const;
182 virtual const SfxPoolItem* Put( const SfxPoolItem&, sal_uInt16 nWhich );
183 const SfxPoolItem* Put( const SfxPoolItem& rItem )
184 { return Put(rItem, rItem.Which()); }
185 virtual int Put( const SfxItemSet&,
186 sal_Bool bInvalidAsDefault = sal_True );
189 #endif // #ifndef _SFXITEMSET_HXX
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */