1*39a19a47SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*39a19a47SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*39a19a47SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*39a19a47SAndrew Rist * distributed with this work for additional information
6*39a19a47SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*39a19a47SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*39a19a47SAndrew Rist * "License"); you may not use this file except in compliance
9*39a19a47SAndrew Rist * with the License. You may obtain a copy of the License at
10*39a19a47SAndrew Rist *
11*39a19a47SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*39a19a47SAndrew Rist *
13*39a19a47SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*39a19a47SAndrew Rist * software distributed under the License is distributed on an
15*39a19a47SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*39a19a47SAndrew Rist * KIND, either express or implied. See the License for the
17*39a19a47SAndrew Rist * specific language governing permissions and limitations
18*39a19a47SAndrew Rist * under the License.
19*39a19a47SAndrew Rist *
20*39a19a47SAndrew Rist *************************************************************/
21*39a19a47SAndrew Rist
22*39a19a47SAndrew Rist
23cdf0e10cSrcweir #include <svl/brdcst.hxx>
24cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
25cdf0e10cSrcweir #include <deque>
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifndef DELETEZ
28cdf0e10cSrcweir #define DELETEZ(pPtr) { delete pPtr; pPtr = 0; }
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir
31cdf0e10cSrcweir
32cdf0e10cSrcweir struct SfxPoolVersion_Impl
33cdf0e10cSrcweir {
34cdf0e10cSrcweir sal_uInt16 _nVer;
35cdf0e10cSrcweir sal_uInt16 _nStart, _nEnd;
36cdf0e10cSrcweir sal_uInt16* _pMap;
37cdf0e10cSrcweir
SfxPoolVersion_ImplSfxPoolVersion_Impl38cdf0e10cSrcweir SfxPoolVersion_Impl( sal_uInt16 nVer, sal_uInt16 nStart, sal_uInt16 nEnd,
39cdf0e10cSrcweir sal_uInt16 *pMap )
40cdf0e10cSrcweir : _nVer( nVer ),
41cdf0e10cSrcweir _nStart( nStart ),
42cdf0e10cSrcweir _nEnd( nEnd ),
43cdf0e10cSrcweir _pMap( pMap )
44cdf0e10cSrcweir {}
SfxPoolVersion_ImplSfxPoolVersion_Impl45cdf0e10cSrcweir SfxPoolVersion_Impl( const SfxPoolVersion_Impl &rOrig )
46cdf0e10cSrcweir : _nVer( rOrig._nVer ),
47cdf0e10cSrcweir _nStart( rOrig._nStart ),
48cdf0e10cSrcweir _nEnd( rOrig._nEnd ),
49cdf0e10cSrcweir _pMap( rOrig._pMap )
50cdf0e10cSrcweir {}
51cdf0e10cSrcweir };
52cdf0e10cSrcweir
53cdf0e10cSrcweir typedef std::deque<SfxPoolItem*> SfxPoolItemArrayBase_Impl;
54cdf0e10cSrcweir
55cdf0e10cSrcweir typedef boost::shared_ptr< SfxPoolVersion_Impl > SfxPoolVersion_ImplPtr;
56cdf0e10cSrcweir typedef std::deque< SfxPoolVersion_ImplPtr > SfxPoolVersionArr_Impl;
57cdf0e10cSrcweir
58cdf0e10cSrcweir struct SfxPoolItemArray_Impl: public SfxPoolItemArrayBase_Impl
59cdf0e10cSrcweir {
60cdf0e10cSrcweir size_t nFirstFree;
61cdf0e10cSrcweir
SfxPoolItemArray_ImplSfxPoolItemArray_Impl62cdf0e10cSrcweir SfxPoolItemArray_Impl ()
63cdf0e10cSrcweir : nFirstFree( 0 )
64cdf0e10cSrcweir {}
65cdf0e10cSrcweir };
66cdf0e10cSrcweir
67cdf0e10cSrcweir class SfxStyleSheetIterator;
68cdf0e10cSrcweir
69cdf0e10cSrcweir struct SfxItemPool_Impl
70cdf0e10cSrcweir {
71cdf0e10cSrcweir SfxBroadcaster aBC;
72cdf0e10cSrcweir SfxPoolItemArray_Impl** ppPoolItems;
73cdf0e10cSrcweir SfxPoolVersionArr_Impl aVersions;
74cdf0e10cSrcweir sal_uInt16 nVersion;
75cdf0e10cSrcweir sal_uInt16 nLoadingVersion;
76cdf0e10cSrcweir sal_uInt16 nInitRefCount; // 1, beim Laden ggf. 2
77cdf0e10cSrcweir sal_uInt16 nVerStart, nVerEnd; // WhichRange in Versions
78cdf0e10cSrcweir sal_uInt16 nStoringStart, nStoringEnd; // zu speichernder Range
79cdf0e10cSrcweir sal_uInt8 nMajorVer, nMinorVer; // Pool selbst
80cdf0e10cSrcweir SfxMapUnit eDefMetric;
81cdf0e10cSrcweir FASTBOOL bInSetItem;
82cdf0e10cSrcweir FASTBOOL bStreaming; // in Load() bzw. Store()
83cdf0e10cSrcweir
SfxItemPool_ImplSfxItemPool_Impl84cdf0e10cSrcweir SfxItemPool_Impl( sal_uInt16 nStart, sal_uInt16 nEnd )
85cdf0e10cSrcweir : ppPoolItems (new SfxPoolItemArray_Impl*[ nEnd - nStart + 1])
866fb30688SEike Rathke , nLoadingVersion(0)
876fb30688SEike Rathke , nInitRefCount(0)
886fb30688SEike Rathke , nVerStart(0)
896fb30688SEike Rathke , nVerEnd(0)
906fb30688SEike Rathke , nStoringStart(0)
916fb30688SEike Rathke , nStoringEnd(0)
926fb30688SEike Rathke , nMajorVer(0)
936fb30688SEike Rathke , nMinorVer(0)
946fb30688SEike Rathke , bInSetItem(false)
956fb30688SEike Rathke , bStreaming(false)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir memset( ppPoolItems, 0, sizeof( SfxPoolItemArray_Impl* ) * ( nEnd - nStart + 1) );
98cdf0e10cSrcweir }
99cdf0e10cSrcweir
~SfxItemPool_ImplSfxItemPool_Impl100cdf0e10cSrcweir ~SfxItemPool_Impl()
101cdf0e10cSrcweir {
102cdf0e10cSrcweir delete[] ppPoolItems;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
DeleteItemsSfxItemPool_Impl105cdf0e10cSrcweir void DeleteItems()
106cdf0e10cSrcweir {
107cdf0e10cSrcweir delete[] ppPoolItems;
108cdf0e10cSrcweir ppPoolItems = 0;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir };
111cdf0e10cSrcweir
112cdf0e10cSrcweir // -----------------------------------------------------------------------
113cdf0e10cSrcweir
114cdf0e10cSrcweir // IBM-C-Set mag keine doppelten Defines
115cdf0e10cSrcweir #ifdef DBG
116cdf0e10cSrcweir # undef DBG
117cdf0e10cSrcweir #endif
118cdf0e10cSrcweir
119cdf0e10cSrcweir #if defined(DBG_UTIL) && defined(MSC)
120cdf0e10cSrcweir #define SFX_TRACE(s,p) \
121cdf0e10cSrcweir { \
122cdf0e10cSrcweir ByteString aPtr(RTL_CONSTASCII_STRINGPARAM("0x0000:0x0000")); \
123cdf0e10cSrcweir _snprintf(const_cast< sal_Char *>(aPtr.GetBuffer()), aPtr.Len(), \
124cdf0e10cSrcweir "%lp", p ); \
125cdf0e10cSrcweir aPtr.Insert(s, 0); \
126cdf0e10cSrcweir DbgTrace( aPtr.GetBuffer() ); \
127cdf0e10cSrcweir }
128cdf0e10cSrcweir #define DBG(x) x
129cdf0e10cSrcweir #else
130cdf0e10cSrcweir #define SFX_TRACE(s,p)
131cdf0e10cSrcweir #define DBG(x)
132cdf0e10cSrcweir #endif
133cdf0e10cSrcweir
134cdf0e10cSrcweir #define CHECK_FILEFORMAT( rStream, nTag ) \
135cdf0e10cSrcweir { sal_uInt16 nFileTag; \
136cdf0e10cSrcweir rStream >> nFileTag; \
137cdf0e10cSrcweir if ( nTag != nFileTag ) \
138cdf0e10cSrcweir { \
139cdf0e10cSrcweir DBG_ERROR( #nTag ); /*! s.u. */ \
140cdf0e10cSrcweir /*! error-code setzen und auswerten! */ \
141cdf0e10cSrcweir (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); \
142cdf0e10cSrcweir pImp->bStreaming = sal_False; \
143cdf0e10cSrcweir return rStream; \
144cdf0e10cSrcweir } \
145cdf0e10cSrcweir }
146cdf0e10cSrcweir
147cdf0e10cSrcweir #define CHECK_FILEFORMAT_RELEASE( rStream, nTag, pPointer ) \
148cdf0e10cSrcweir { sal_uInt16 nFileTag; \
149cdf0e10cSrcweir rStream >> nFileTag; \
150cdf0e10cSrcweir if ( nTag != nFileTag ) \
151cdf0e10cSrcweir { \
152cdf0e10cSrcweir DBG_ERROR( #nTag ); /*! s.u. */ \
153cdf0e10cSrcweir /*! error-code setzen und auswerten! */ \
154cdf0e10cSrcweir (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); \
155cdf0e10cSrcweir pImp->bStreaming = sal_False; \
156cdf0e10cSrcweir delete pPointer; \
157cdf0e10cSrcweir return rStream; \
158cdf0e10cSrcweir } \
159cdf0e10cSrcweir }
160cdf0e10cSrcweir
161cdf0e10cSrcweir #define CHECK_FILEFORMAT2( rStream, nTag1, nTag2 ) \
162cdf0e10cSrcweir { sal_uInt16 nFileTag; \
163cdf0e10cSrcweir rStream >> nFileTag; \
164cdf0e10cSrcweir if ( nTag1 != nFileTag && nTag2 != nFileTag ) \
165cdf0e10cSrcweir { \
166cdf0e10cSrcweir DBG_ERROR( #nTag1 ); /*! s.u. */ \
167cdf0e10cSrcweir /*! error-code setzen und auswerten! */ \
168cdf0e10cSrcweir (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); \
169cdf0e10cSrcweir pImp->bStreaming = sal_False; \
170cdf0e10cSrcweir return rStream; \
171cdf0e10cSrcweir } \
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174cdf0e10cSrcweir #define SFX_ITEMPOOL_VER_MAJOR sal_uInt8(2)
175cdf0e10cSrcweir #define SFX_ITEMPOOL_VER_MINOR sal_uInt8(0)
176cdf0e10cSrcweir
177cdf0e10cSrcweir #define SFX_ITEMPOOL_TAG_STARTPOOL_4 sal_uInt16(0x1111)
178cdf0e10cSrcweir #define SFX_ITEMPOOL_TAG_STARTPOOL_5 sal_uInt16(0xBBBB)
179cdf0e10cSrcweir #define SFX_ITEMPOOL_TAG_ITEMPOOL sal_uInt16(0xAAAA)
180cdf0e10cSrcweir #define SFX_ITEMPOOL_TAG_ITEMS sal_uInt16(0x2222)
181cdf0e10cSrcweir #define SFX_ITEMPOOL_TAG_ITEM sal_uInt16(0x7777)
182cdf0e10cSrcweir #define SFX_ITEMPOOL_TAG_SIZES sal_uInt16(0x3333)
183cdf0e10cSrcweir #define SFX_ITEMPOOL_TAG_DEFAULTS sal_uInt16(0x4444)
184cdf0e10cSrcweir #define SFX_ITEMPOOL_TAG_VERSIONMAP sal_uInt16(0x5555)
185cdf0e10cSrcweir #define SFX_ITEMPOOL_TAG_HEADER sal_uInt16(0x6666)
186cdf0e10cSrcweir #define SFX_ITEMPOOL_TAG_ENDPOOL sal_uInt16(0xEEEE)
187cdf0e10cSrcweir #define SFX_ITEMPOOL_TAG_TRICK4OLD sal_uInt16(0xFFFF)
188cdf0e10cSrcweir
189cdf0e10cSrcweir #define SFX_ITEMPOOL_REC sal_uInt8(0x01)
190cdf0e10cSrcweir #define SFX_ITEMPOOL_REC_HEADER sal_uInt8(0x10)
191cdf0e10cSrcweir #define SFX_ITEMPOOL_REC_VERSIONMAP sal_uInt16(0x0020)
192cdf0e10cSrcweir #define SFX_ITEMPOOL_REC_WHICHIDS sal_uInt16(0x0030)
193cdf0e10cSrcweir #define SFX_ITEMPOOL_REC_ITEMS sal_uInt16(0x0040)
194cdf0e10cSrcweir #define SFX_ITEMPOOL_REC_DEFAULTS sal_uInt16(0x0050)
195cdf0e10cSrcweir
196cdf0e10cSrcweir #define SFX_ITEMSET_REC sal_uInt8(0x02)
197cdf0e10cSrcweir
198cdf0e10cSrcweir #define SFX_STYLES_REC sal_uInt8(0x03)
199cdf0e10cSrcweir #define SFX_STYLES_REC_HEADER sal_uInt16(0x0010)
200cdf0e10cSrcweir #define SFX_STYLES_REC_STYLES sal_uInt16(0x0020)
201cdf0e10cSrcweir
202cdf0e10cSrcweir //========================================================================
203cdf0e10cSrcweir
GetIndex_Impl(sal_uInt16 nWhich) const204cdf0e10cSrcweir inline sal_uInt16 SfxItemPool::GetIndex_Impl(sal_uInt16 nWhich) const
205cdf0e10cSrcweir {
206cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0);
207cdf0e10cSrcweir DBG_ASSERT(nWhich >= nStart && nWhich <= nEnd, "Which-Id nicht im Pool-Bereich");
208cdf0e10cSrcweir return nWhich - nStart;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211