1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: poolio.hxx,v $
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 #include <svtools/brdcst.hxx>
34 #define DELETEZ(pPtr) { delete pPtr; pPtr = 0; }
38 struct SfxPoolVersion_Impl
41 USHORT _nStart
, _nEnd
;
44 SfxPoolVersion_Impl( USHORT nVer
, USHORT nStart
, USHORT nEnd
,
51 SfxPoolVersion_Impl( const SfxPoolVersion_Impl
&rOrig
)
52 : _nVer( rOrig
._nVer
),
53 _nStart( rOrig
._nStart
),
59 SV_DECL_PTRARR( SfxPoolItemArrayBase_Impl
, SfxPoolItem
*, 0, 5 )
60 SV_DECL_PTRARR_DEL( SfxPoolVersionArr_Impl
, SfxPoolVersion_Impl
*, 0, 2 )
62 struct SfxPoolItemArray_Impl
: public SfxPoolItemArrayBase_Impl
66 SfxPoolItemArray_Impl (USHORT nInitSize
= 0)
67 : SfxPoolItemArrayBase_Impl( nInitSize
),
72 class SfxStyleSheetIterator
;
74 struct SfxItemPool_Impl
77 SfxPoolItemArray_Impl
** ppPoolItems
;
78 SfxPoolVersionArr_Impl aVersions
;
80 USHORT nLoadingVersion
;
81 USHORT nInitRefCount
; // 1, beim Laden ggf. 2
82 USHORT nVerStart
, nVerEnd
; // WhichRange in Versions
83 USHORT nStoringStart
, nStoringEnd
; // zu speichernder Range
84 BYTE nMajorVer
, nMinorVer
; // Pool selbst
85 SfxMapUnit eDefMetric
;
87 FASTBOOL bStreaming
; // in Load() bzw. Store()
89 SfxItemPool_Impl( USHORT nStart
, USHORT nEnd
)
90 : ppPoolItems (new SfxPoolItemArray_Impl
*[ nEnd
- nStart
+ 1])
92 memset( ppPoolItems
, 0, sizeof( SfxPoolItemArray_Impl
* ) * ( nEnd
- nStart
+ 1) );
102 delete[] ppPoolItems
; ppPoolItems
= 0;
106 // -----------------------------------------------------------------------
108 // IBM-C-Set mag keine doppelten Defines
113 #if defined(DBG_UTIL) && defined(MSC)
114 #define SFX_TRACE(s,p) \
116 ByteString aPtr(RTL_CONSTASCII_STRINGPARAM("0x0000:0x0000")); \
117 _snprintf(const_cast< sal_Char *>(aPtr.GetBuffer()), aPtr.Len(), \
120 DbgTrace( aPtr.GetBuffer() ); \
124 #define SFX_TRACE(s,p)
128 #define CHECK_FILEFORMAT( rStream, nTag ) \
130 rStream >> nFileTag; \
131 if ( nTag != nFileTag ) \
133 DBG_ERROR( #nTag ); /*! s.u. */ \
134 /*! error-code setzen und auswerten! */ \
135 (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); \
136 pImp->bStreaming = FALSE; \
141 #define CHECK_FILEFORMAT_RELEASE( rStream, nTag, pPointer ) \
143 rStream >> nFileTag; \
144 if ( nTag != nFileTag ) \
146 DBG_ERROR( #nTag ); /*! s.u. */ \
147 /*! error-code setzen und auswerten! */ \
148 (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); \
149 pImp->bStreaming = FALSE; \
155 #define CHECK_FILEFORMAT2( rStream, nTag1, nTag2 ) \
157 rStream >> nFileTag; \
158 if ( nTag1 != nFileTag && nTag2 != nFileTag ) \
160 DBG_ERROR( #nTag1 ); /*! s.u. */ \
161 /*! error-code setzen und auswerten! */ \
162 (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); \
163 pImp->bStreaming = FALSE; \
168 #define SFX_ITEMPOOL_VER_MAJOR BYTE(2)
169 #define SFX_ITEMPOOL_VER_MINOR BYTE(0)
171 #define SFX_ITEMPOOL_TAG_STARTPOOL_4 USHORT(0x1111)
172 #define SFX_ITEMPOOL_TAG_STARTPOOL_5 USHORT(0xBBBB)
173 #define SFX_ITEMPOOL_TAG_ITEMPOOL USHORT(0xAAAA)
174 #define SFX_ITEMPOOL_TAG_ITEMS USHORT(0x2222)
175 #define SFX_ITEMPOOL_TAG_ITEM USHORT(0x7777)
176 #define SFX_ITEMPOOL_TAG_SIZES USHORT(0x3333)
177 #define SFX_ITEMPOOL_TAG_DEFAULTS USHORT(0x4444)
178 #define SFX_ITEMPOOL_TAG_VERSIONMAP USHORT(0x5555)
179 #define SFX_ITEMPOOL_TAG_HEADER USHORT(0x6666)
180 #define SFX_ITEMPOOL_TAG_ENDPOOL USHORT(0xEEEE)
181 #define SFX_ITEMPOOL_TAG_TRICK4OLD USHORT(0xFFFF)
183 #define SFX_ITEMPOOL_REC BYTE(0x01)
184 #define SFX_ITEMPOOL_REC_HEADER BYTE(0x10)
185 #define SFX_ITEMPOOL_REC_VERSIONMAP USHORT(0x0020)
186 #define SFX_ITEMPOOL_REC_WHICHIDS USHORT(0x0030)
187 #define SFX_ITEMPOOL_REC_ITEMS USHORT(0x0040)
188 #define SFX_ITEMPOOL_REC_DEFAULTS USHORT(0x0050)
190 #define SFX_ITEMSET_REC BYTE(0x02)
192 #define SFX_STYLES_REC BYTE(0x03)
193 #define SFX_STYLES_REC_HEADER USHORT(0x0010)
194 #define SFX_STYLES_REC_STYLES USHORT(0x0020)
196 //========================================================================
198 inline USHORT
SfxItemPool::GetIndex_Impl(USHORT nWhich
) const
200 DBG_CHKTHIS(SfxItemPool
, 0);
201 DBG_ASSERT(nWhich
>= nStart
&& nWhich
<= nEnd
, "Which-Id nicht im Pool-Bereich");
202 return nWhich
- nStart
;