Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SVL_ITEMSET_HXX
20 : #define INCLUDED_SVL_ITEMSET_HXX
21 :
22 : #include <svl/svldllapi.h>
23 :
24 : #include <cstdarg>
25 : #include <svl/poolitem.hxx>
26 : #include <tools/rtti.hxx>
27 :
28 : class SfxItemPool;
29 : class SfxPoolItem;
30 : class SvStream;
31 :
32 : typedef SfxPoolItem const** SfxItemArray;
33 :
34 : #define USHORT_ARG int
35 :
36 : #define SFX_ITEMSET_GET( rSet, pItem, ItemType, nSlotId, bDeep ) \
37 : const ItemType *pItem = static_cast<const ItemType*>( \
38 : (rSet).GetItem( nSlotId, bDeep, TYPE(ItemType) ) )
39 :
40 : class SVL_DLLPUBLIC SfxItemSet
41 : {
42 : friend class SfxItemIter;
43 :
44 : SfxItemPool* _pPool; // pool, which is used
45 : const SfxItemSet* _pParent; // derivation
46 : SfxItemArray _aItems; // field of items
47 : sal_uInt16* _pWhichRanges; // array of Which Ranges
48 : sal_uInt16 _nCount; // number of items
49 :
50 : friend class SfxItemPoolCache;
51 : friend class SfxAllItemSet;
52 : friend const char *DbgCheckItemSet( const void* );
53 :
54 : private:
55 : SVL_DLLPRIVATE void InitRanges_Impl(const sal_uInt16 *nWhichPairTable);
56 : SVL_DLLPRIVATE void InitRanges_Impl(va_list pWhich, sal_uInt16 n1, sal_uInt16 n2, sal_uInt16 n3);
57 : SVL_DLLPRIVATE void InitRanges_Impl(sal_uInt16 nWh1, sal_uInt16 nWh2);
58 :
59 : public:
60 5679862 : SfxItemArray GetItems_Impl() const { return _aItems; }
61 :
62 : private:
63 : const SfxItemSet& operator=(const SfxItemSet &); // n.i.!!
64 :
65 : protected:
66 : // Notification-Callback
67 : virtual void Changed( const SfxPoolItem& rOld, const SfxPoolItem& rNew );
68 :
69 : int PutDirect(const SfxPoolItem &rItem);
70 :
71 : public:
72 : SfxItemSet( const SfxItemSet& );
73 :
74 : SfxItemSet( SfxItemPool&, bool bTotalPoolRanges = false );
75 : SfxItemSet( SfxItemPool&, sal_uInt16 nWhich1, sal_uInt16 nWhich2 );
76 : SfxItemSet( SfxItemPool&, USHORT_ARG nWh1, USHORT_ARG nWh2, USHORT_ARG nNull, ... );
77 : SfxItemSet( SfxItemPool&, const sal_uInt16* nWhichPairTable );
78 : virtual ~SfxItemSet();
79 :
80 : virtual SfxItemSet * Clone(bool bItems = true, SfxItemPool *pToPool = 0) const;
81 :
82 : // Get number of items
83 302683171 : sal_uInt16 Count() const { return _nCount; }
84 : sal_uInt16 TotalCount() const;
85 :
86 : virtual const SfxPoolItem& Get( sal_uInt16 nWhich, bool bSrchInParent = true ) const;
87 : const SfxPoolItem* GetItem( sal_uInt16 nWhich, bool bSrchInParent = true,
88 : TypeId aItemType = 0 ) const;
89 :
90 : // Get Which-value of the item at position nPos
91 : sal_uInt16 GetWhichByPos(sal_uInt16 nPos) const;
92 :
93 : // Get item-status
94 : SfxItemState GetItemState( sal_uInt16 nWhich,
95 : bool bSrchInParent = true,
96 : const SfxPoolItem **ppItem = 0 ) const;
97 :
98 : bool HasItem(sal_uInt16 nWhich, const SfxPoolItem** ppItem = NULL) const;
99 :
100 : virtual void DisableItem(sal_uInt16 nWhich);
101 : virtual void InvalidateItem( sal_uInt16 nWhich );
102 : virtual sal_uInt16 ClearItem( sal_uInt16 nWhich = 0);
103 : virtual void ClearInvalidItems( bool bHardDefault = false );
104 : void InvalidateAllItems(); // HACK(via nWhich = 0) ???
105 : void InvalidateDefaultItems();
106 :
107 : inline void SetParent( const SfxItemSet* pNew );
108 :
109 : // add, delete items, work on items
110 : virtual const SfxPoolItem* Put( const SfxPoolItem&, sal_uInt16 nWhich );
111 11467329 : const SfxPoolItem* Put( const SfxPoolItem& rItem )
112 11467329 : { return Put(rItem, rItem.Which()); }
113 : bool Put( const SfxItemSet&,
114 : bool bInvalidAsDefault = true );
115 : void PutExtended( const SfxItemSet&,
116 : SfxItemState eDontCareAs = SfxItemState::UNKNOWN,
117 : SfxItemState eDefaultAs = SfxItemState::UNKNOWN );
118 :
119 : virtual bool Set( const SfxItemSet&, bool bDeep = true );
120 :
121 : virtual void Intersect( const SfxItemSet& rSet );
122 : virtual void MergeValues( const SfxItemSet& rSet, bool bOverwriteDefaults = false );
123 : virtual void Differentiate( const SfxItemSet& rSet );
124 : virtual void MergeValue( const SfxPoolItem& rItem, bool bOverwriteDefaults = false );
125 :
126 24462801 : SfxItemPool* GetPool() const { return _pPool; }
127 11871185 : const sal_uInt16* GetRanges() const { return _pWhichRanges; }
128 : void SetRanges( const sal_uInt16 *pRanges );
129 : void MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo );
130 1156270 : const SfxItemSet* GetParent() const { return _pParent; }
131 :
132 : virtual SvStream & Load( SvStream &, bool bDirect = false,
133 : const SfxItemPool *pRefPool = 0 );
134 : virtual SvStream & Store( SvStream &, bool bDirect = false ) const;
135 :
136 : bool operator==(const SfxItemSet &) const;
137 : sal_Int32 getHash() const;
138 : OString stringify() const;
139 : };
140 :
141 2457102 : inline void SfxItemSet::SetParent( const SfxItemSet* pNew )
142 : {
143 2457102 : _pParent = pNew;
144 2457102 : }
145 :
146 93899 : class SVL_DLLPUBLIC SfxAllItemSet: public SfxItemSet
147 :
148 : // Handles all Ranges. Ranges are automatically modified by puting items.
149 :
150 : {
151 : SfxVoidItem aDefault;
152 : sal_uInt16 nFree;
153 :
154 : public:
155 : SfxAllItemSet( SfxItemPool &rPool );
156 : SfxAllItemSet( const SfxItemSet & );
157 : SfxAllItemSet( const SfxAllItemSet & );
158 :
159 : virtual SfxItemSet * Clone( bool bItems = true, SfxItemPool *pToPool = 0 ) const SAL_OVERRIDE;
160 : virtual const SfxPoolItem* Put( const SfxPoolItem&, sal_uInt16 nWhich ) SAL_OVERRIDE;
161 : using SfxItemSet::Put;
162 : };
163 :
164 : #endif // INCLUDED_SVL_ITEMSET_HXX
165 :
166 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|