1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #ifndef _SFXITEMPOOL_HXX
21 #define _SFXITEMPOOL_HXX
23 #include "svl/svldllapi.h"
26 #include <tools/solar.h>
27 #include <tools/string.hxx>
28 #include <svl/poolitem.hxx>
33 struct SfxItemPool_Impl
;
35 #define SFX_WHICH_MAX 4999
37 DBG_NAMEEX(SfxItemPool
)
39 //====================================================================
41 #define SFX_ITEM_POOLABLE 0x0001
42 #define SFX_ITEM_NOT_POOLABLE 0x0002
44 #define SFX_ITEM_USERFLAG0 0x0100
45 #define SFX_ITEM_USERFLAG1 0x0200
46 #define SFX_ITEM_USERFLAG2 0x0400
47 #define SFX_ITEM_USERFLAG3 0x0800
48 #define SFX_ITEM_USERFLAG4 0x1000
49 #define SFX_ITEM_USERFLAG5 0x2000
50 #define SFX_ITEM_USERFLAG6 0x4000
51 #define SFX_ITEM_USERFLAG7 0x8000
52 #define SFX_ITEM_USERFLAG8 0x0010
53 #define SFX_ITEM_USERFLAG9 0x0020
54 #define SFX_ITEM_USERFLAGA 0x0040
55 #define SFX_ITEM_USERFLAGB 0x0080
57 //====================================================================
65 //====================================================================
67 class SfxStyleSheetIterator
;
68 struct SfxPoolItemArray_Impl
;
71 class SVL_DLLPUBLIC SfxItemPoolUser
74 virtual void ObjectInDestruction(const SfxItemPool
& rSfxItemPool
) = 0;
80 class SVL_DLLPUBLIC SfxItemPool
84 Die von dieser Klasse abgeleiteten Klassen dienen der Bereitstellung von
85 Defaults von SfxPoolItems und halten konkrete (konstante) Instanzen, die
86 dann von mehreren Stellen (i.d.R. eines Dokuments) referenziert werden
89 Dadurch ist jeder Wert nur einmalig gespeichert, was zu wenig Konstruktor
90 und Destruktor-Aufrufen f�hrt, Vergleiche zwischen Items eines Dokuments
91 beschleunigt und ein einfaches Laden und Speichern von Attributen
96 friend struct SfxItemPool_Impl
;
98 const SfxItemInfo
* pItemInfos
;
99 SfxItemPool_Impl
* pImp
;
102 void AddSfxItemPoolUser(SfxItemPoolUser
& rNewUser
);
103 void RemoveSfxItemPoolUser(SfxItemPoolUser
& rOldUser
);
105 //---------------------------------------------------------------------
106 #ifndef _SFXITEMS_HXX
109 sal_uInt16
GetIndex_Impl(sal_uInt16 nWhich
) const;
110 sal_uInt16
GetSize_Impl() const;
112 SVL_DLLPRIVATE SvStream
& Load1_Impl( SvStream
&rStream
);
113 SVL_DLLPRIVATE
bool IsItemFlag_Impl( sal_uInt16 nWhich
, sal_uInt16 nFlag
) const;
116 // fuer dflt. SfxItemSet::CTOR, setze dflt. WhichRanges
117 void FillItemIdRanges_Impl( sal_uInt16
*& pWhichRanges
) const;
118 const sal_uInt16
* GetFrozenIdRanges() const;
121 //---------------------------------------------------------------------
124 static inline void SetRefCount( SfxPoolItem
& rItem
, sal_uLong n
);
125 static inline sal_uLong
AddRef( const SfxPoolItem
& rItem
, sal_uLong n
= 1 );
126 static inline sal_uLong
ReleaseRef( const SfxPoolItem
& rItem
, sal_uLong n
= 1);
127 static inline void SetKind( SfxPoolItem
& rItem
, sal_uInt16 nRef
);
130 SfxItemPool( const SfxItemPool
&rPool
,
131 sal_Bool bCloneStaticDefaults
= sal_False
);
132 SfxItemPool( const OUString
&rName
,
133 sal_uInt16 nStart
, sal_uInt16 nEnd
,
134 const SfxItemInfo
*pItemInfos
,
135 SfxPoolItem
**pDefaults
= 0,
136 bool bLoadRefCounts
= true );
138 virtual ~SfxItemPool();
140 static void Free(SfxItemPool
* pPool
);
142 SfxBroadcaster
& BC();
144 void SetPoolDefaultItem( const SfxPoolItem
& );
145 const SfxPoolItem
* GetPoolDefaultItem( sal_uInt16 nWhich
) const;
146 void ResetPoolDefaultItem( sal_uInt16 nWhich
);
148 void SetDefaults( SfxPoolItem
**pDefaults
);
149 void ReleaseDefaults( sal_Bool bDelete
= sal_False
);
150 static void ReleaseDefaults( SfxPoolItem
**pDefaults
, sal_uInt16 nCount
, sal_Bool bDelete
= sal_False
);
152 virtual SfxMapUnit
GetMetric( sal_uInt16 nWhich
) const;
153 void SetDefaultMetric( SfxMapUnit eNewMetric
);
154 virtual SfxItemPresentation
GetPresentation( const SfxPoolItem
& rItem
,
155 SfxItemPresentation ePresentation
,
156 SfxMapUnit ePresentationMetric
,
158 const IntlWrapper
* pIntlWrapper
160 virtual SfxItemPool
* Clone() const;
161 const OUString
& GetName() const;
163 virtual const SfxPoolItem
& Put( const SfxPoolItem
&, sal_uInt16 nWhich
= 0 );
164 virtual void Remove( const SfxPoolItem
& );
165 virtual const SfxPoolItem
& GetDefaultItem( sal_uInt16 nWhich
) const;
167 const SfxPoolItem
* LoadItem( SvStream
&rStream
,
168 bool bDirect
= false,
169 const SfxItemPool
*pRefPool
= 0 );
170 bool StoreItem( SvStream
&rStream
,
171 const SfxPoolItem
&rItem
,
172 bool bDirect
= false ) const;
174 sal_uInt32
GetSurrogate(const SfxPoolItem
*) const;
175 const SfxPoolItem
* GetItem2(sal_uInt16 nWhich
, sal_uInt32 nSurrogate
) const;
176 sal_uInt32
GetItemCount2(sal_uInt16 nWhich
) const;
177 const SfxPoolItem
* LoadSurrogate(SvStream
& rStream
,
178 sal_uInt16
&rWhich
, sal_uInt16 nSlotId
,
179 const SfxItemPool
* pRefPool
= 0 );
180 bool StoreSurrogate(SvStream
& rStream
,
181 const SfxPoolItem
*pItem
) const;
183 virtual SvStream
& Load(SvStream
&);
184 virtual SvStream
& Store(SvStream
&) const;
185 bool HasPersistentRefCounts() const;
186 void LoadCompleted();
188 sal_uInt16
GetFirstWhich() const;
189 sal_uInt16
GetLastWhich() const;
190 bool IsInRange( sal_uInt16 nWhich
) const;
191 bool IsInVersionsRange( sal_uInt16 nWhich
) const;
192 bool IsInStoringRange( sal_uInt16 nWhich
) const;
193 void SetStoringRange( sal_uInt16 nFrom
, sal_uInt16 nTo
);
194 void SetSecondaryPool( SfxItemPool
*pPool
);
195 SfxItemPool
* GetSecondaryPool() const;
196 SfxItemPool
* GetMasterPool() const;
197 void FreezeIdRanges();
201 bool IsItemFlag( sal_uInt16 nWhich
, sal_uInt16 nFlag
) const;
202 bool IsItemFlag( const SfxPoolItem
&rItem
, sal_uInt16 nFlag
) const
203 { return IsItemFlag( rItem
.Which(), nFlag
); }
204 void SetItemInfos( const SfxItemInfo
*pInfos
)
205 { pItemInfos
= pInfos
; }
206 sal_uInt16
GetWhich( sal_uInt16 nSlot
, sal_Bool bDeep
= sal_True
) const;
207 sal_uInt16
GetSlotId( sal_uInt16 nWhich
, sal_Bool bDeep
= sal_True
) const;
208 sal_uInt16
GetTrueWhich( sal_uInt16 nSlot
, sal_Bool bDeep
= sal_True
) const;
209 sal_uInt16
GetTrueSlotId( sal_uInt16 nWhich
, sal_Bool bDeep
= sal_True
) const;
211 void SetVersionMap( sal_uInt16 nVer
,
212 sal_uInt16 nOldStart
, sal_uInt16 nOldEnd
,
213 const sal_uInt16
*pWhichIdTab
);
214 sal_uInt16
GetNewWhich( sal_uInt16 nOldWhich
) const;
215 sal_uInt16
GetVersion() const;
216 void SetFileFormatVersion( sal_uInt16 nFileFormatVersion
);
217 bool IsCurrentVersionLoading() const;
219 static int IsWhich(sal_uInt16 nId
) {
220 return nId
&& nId
<= SFX_WHICH_MAX
; }
221 static int IsSlot(sal_uInt16 nId
) {
222 return nId
&& nId
> SFX_WHICH_MAX
; }
224 static const SfxItemPool
* GetStoringPool();
227 const SfxItemPool
& operator=(const SfxItemPool
&); // n.i.!!
229 static const SfxItemPool
* pStoringPool_
;
232 // --------------- Inline Implementierungen ------------------------------
234 // nur der Pool darf den Referenz-Zaehler manipulieren !!!
235 inline void SfxItemPool::SetRefCount( SfxPoolItem
& rItem
, sal_uLong n
)
237 rItem
.SetRefCount(n
);
240 // nur der Pool darf den Referenz-Zaehler manipulieren !!!
241 inline sal_uLong
SfxItemPool::AddRef( const SfxPoolItem
& rItem
, sal_uLong n
)
243 return rItem
.AddRef(n
);
246 // nur der Pool darf den Referenz-Zaehler manipulieren !!!
247 inline sal_uLong
SfxItemPool::ReleaseRef( const SfxPoolItem
& rItem
, sal_uLong n
)
249 return rItem
.ReleaseRef(n
);
252 inline void SfxItemPool::SetKind( SfxPoolItem
& rItem
, sal_uInt16 nRef
)
254 rItem
.SetKind( nRef
);
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */