xref: /aoo41x/main/sc/source/core/data/docpool.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 
32 
33 #include "scitems.hxx"
34 #include <tools/shl.hxx>
35 #include <vcl/outdev.hxx>
36 #include <svl/aeitem.hxx>
37 #include <svl/itemiter.hxx>
38 #include <svx/algitem.hxx>
39 #include <editeng/boxitem.hxx>
40 #include <editeng/bolnitem.hxx>
41 #include <editeng/brshitem.hxx>
42 #include <editeng/charreliefitem.hxx>
43 #include <editeng/cntritem.hxx>
44 #include <editeng/colritem.hxx>
45 #include <editeng/crsditem.hxx>
46 #include <svx/dialmgr.hxx>
47 #include <editeng/emphitem.hxx>
48 #include <editeng/fhgtitem.hxx>
49 #include <editeng/fontitem.hxx>
50 #include <editeng/forbiddenruleitem.hxx>
51 #include <editeng/frmdiritem.hxx>
52 #include <editeng/hngpnctitem.hxx>
53 #include <editeng/itemtype.hxx>
54 #include <editeng/langitem.hxx>
55 #include <editeng/lrspitem.hxx>
56 #include <svx/pageitem.hxx>
57 #include <editeng/pbinitem.hxx>
58 #include <editeng/postitem.hxx>
59 #include <svx/rotmodit.hxx>
60 #include <editeng/scriptspaceitem.hxx>
61 #include <editeng/shaditem.hxx>
62 #include <editeng/shdditem.hxx>
63 #include <editeng/sizeitem.hxx>
64 #include <svx/svxitems.hrc>
65 #include <editeng/udlnitem.hxx>
66 #include <editeng/ulspitem.hxx>
67 #include <editeng/wghtitem.hxx>
68 #include <editeng/wrlmitem.hxx>
69 #include <editeng/xmlcnitm.hxx>
70 
71 #include "docpool.hxx"
72 #include "global.hxx"
73 #include "attrib.hxx"
74 #include "patattr.hxx"
75 #include "globstr.hrc"
76 #include "sc.hrc"			// Slot-IDs
77 
78 
79 #define SC_MAX_POOLREF		(SFX_ITEMS_OLD_MAXREF - 39)
80 #define SC_SAFE_POOLREF		(SC_MAX_POOLREF + 20)
81 
82 // STATIC DATA -----------------------------------------------------------
83 
84 sal_uInt16* ScDocumentPool::pVersionMap1 = 0;
85 sal_uInt16* ScDocumentPool::pVersionMap2 = 0;
86 sal_uInt16* ScDocumentPool::pVersionMap3 = 0;
87 sal_uInt16* ScDocumentPool::pVersionMap4 = 0;
88 sal_uInt16* ScDocumentPool::pVersionMap5 = 0;
89 sal_uInt16* ScDocumentPool::pVersionMap6 = 0;
90 sal_uInt16* ScDocumentPool::pVersionMap7 = 0;
91 sal_uInt16* ScDocumentPool::pVersionMap8 = 0;
92 sal_uInt16* ScDocumentPool::pVersionMap9 = 0;
93 sal_uInt16* ScDocumentPool::pVersionMap10 = 0;
94 sal_uInt16* ScDocumentPool::pVersionMap11 = 0;
95 
96 // ATTR_FONT_TWOLINES (not used) was changed to ATTR_USERDEF (not saved in binary format) in 641c
97 
98 static SfxItemInfo __READONLY_DATA  aItemInfos[] =
99 {
100 	{ SID_ATTR_CHAR_FONT,			SFX_ITEM_POOLABLE },	// ATTR_FONT
101 	{ SID_ATTR_CHAR_FONTHEIGHT,		SFX_ITEM_POOLABLE },	// ATTR_FONT_HEIGHT
102 	{ SID_ATTR_CHAR_WEIGHT,			SFX_ITEM_POOLABLE },	// ATTR_FONT_WEIGHT
103 	{ SID_ATTR_CHAR_POSTURE,		SFX_ITEM_POOLABLE },	// ATTR_FONT_POSTURE
104 	{ SID_ATTR_CHAR_UNDERLINE,		SFX_ITEM_POOLABLE },	// ATTR_FONT_UNDERLINE
105 	{ SID_ATTR_CHAR_OVERLINE,		SFX_ITEM_POOLABLE },	// ATTR_FONT_OVERLINE
106 	{ SID_ATTR_CHAR_STRIKEOUT,		SFX_ITEM_POOLABLE },	// ATTR_FONT_CROSSEDOUT
107 	{ SID_ATTR_CHAR_CONTOUR,		SFX_ITEM_POOLABLE },	// ATTR_FONT_CONTOUR
108 	{ SID_ATTR_CHAR_SHADOWED,		SFX_ITEM_POOLABLE },	// ATTR_FONT_SHADOWED
109 	{ SID_ATTR_CHAR_COLOR,			SFX_ITEM_POOLABLE },	// ATTR_FONT_COLOR
110 	{ SID_ATTR_CHAR_LANGUAGE,		SFX_ITEM_POOLABLE },	// ATTR_FONT_LANGUAGE
111 	{ SID_ATTR_CHAR_CJK_FONT,		SFX_ITEM_POOLABLE },	// ATTR_CJK_FONT			from 614
112 	{ SID_ATTR_CHAR_CJK_FONTHEIGHT,	SFX_ITEM_POOLABLE },	// ATTR_CJK_FONT_HEIGHT		from 614
113 	{ SID_ATTR_CHAR_CJK_WEIGHT,		SFX_ITEM_POOLABLE },	// ATTR_CJK_FONT_WEIGHT		from 614
114 	{ SID_ATTR_CHAR_CJK_POSTURE,	SFX_ITEM_POOLABLE },	// ATTR_CJK_FONT_POSTURE	from 614
115 	{ SID_ATTR_CHAR_CJK_LANGUAGE,	SFX_ITEM_POOLABLE },	// ATTR_CJK_FONT_LANGUAGE	from 614
116 	{ SID_ATTR_CHAR_CTL_FONT,		SFX_ITEM_POOLABLE },	// ATTR_CTL_FONT			from 614
117 	{ SID_ATTR_CHAR_CTL_FONTHEIGHT,	SFX_ITEM_POOLABLE },	// ATTR_CTL_FONT_HEIGHT		from 614
118 	{ SID_ATTR_CHAR_CTL_WEIGHT,		SFX_ITEM_POOLABLE },	// ATTR_CTL_FONT_WEIGHT		from 614
119 	{ SID_ATTR_CHAR_CTL_POSTURE,	SFX_ITEM_POOLABLE },	// ATTR_CTL_FONT_POSTURE	from 614
120 	{ SID_ATTR_CHAR_CTL_LANGUAGE,	SFX_ITEM_POOLABLE },	// ATTR_CTL_FONT_LANGUAGE	from 614
121 	{ SID_ATTR_CHAR_EMPHASISMARK,	SFX_ITEM_POOLABLE },	// ATTR_FONT_EMPHASISMARK	from 614
122 	{ 0,							SFX_ITEM_POOLABLE },	// ATTR_USERDEF				from 614 / 641c
123 	{ SID_ATTR_CHAR_WORDLINEMODE,	SFX_ITEM_POOLABLE },	// ATTR_FONT_WORDLINE		from 632b
124 	{ SID_ATTR_CHAR_RELIEF,			SFX_ITEM_POOLABLE },	// ATTR_FONT_RELIEF			from 632b
125 	{ SID_ATTR_ALIGN_HYPHENATION,	SFX_ITEM_POOLABLE },	// ATTR_HYPHENATE			from 632b
126 	{ 0,							SFX_ITEM_POOLABLE },	// ATTR_SCRIPTSPACE			from 614d
127 	{ 0,							SFX_ITEM_POOLABLE },	// ATTR_HANGPUNCTUATION		from 614d
128 	{ SID_ATTR_PARA_FORBIDDEN_RULES,SFX_ITEM_POOLABLE },	// ATTR_FORBIDDEN_RULES		from 614d
129 	{ SID_ATTR_ALIGN_HOR_JUSTIFY,	SFX_ITEM_POOLABLE },	// ATTR_HOR_JUSTIFY
130 	{ SID_ATTR_ALIGN_INDENT,		SFX_ITEM_POOLABLE },	// ATTR_INDENT			ab 350
131 	{ SID_ATTR_ALIGN_VER_JUSTIFY,	SFX_ITEM_POOLABLE },	// ATTR_VER_JUSTIFY
132     { SID_ATTR_ALIGN_STACKED,       SFX_ITEM_POOLABLE },    // ATTR_STACKED         from 680/dr14 (replaces ATTR_ORIENTATION)
133 	{ SID_ATTR_ALIGN_DEGREES,		SFX_ITEM_POOLABLE },	// ATTR_ROTATE_VALUE	ab 367
134 	{ SID_ATTR_ALIGN_LOCKPOS,		SFX_ITEM_POOLABLE },	// ATTR_ROTATE_MODE		ab 367
135     { SID_ATTR_ALIGN_ASIANVERTICAL, SFX_ITEM_POOLABLE },    // ATTR_VERTICAL_ASIAN  from 642
136 	{ SID_ATTR_FRAMEDIRECTION,		SFX_ITEM_POOLABLE },    // ATTR_WRITINGDIR		from 643
137 	{ SID_ATTR_ALIGN_LINEBREAK,		SFX_ITEM_POOLABLE },	// ATTR_LINEBREAK
138     { SID_ATTR_ALIGN_SHRINKTOFIT,   SFX_ITEM_POOLABLE },    // ATTR_SHRINKTOFIT     from 680/dr14
139     { SID_ATTR_BORDER_DIAG_TLBR,    SFX_ITEM_POOLABLE },    // ATTR_BORDER_TLBR     from 680/dr14
140     { SID_ATTR_BORDER_DIAG_BLTR,    SFX_ITEM_POOLABLE },    // ATTR_BORDER_BLTR     from 680/dr14
141 	{ SID_ATTR_ALIGN_MARGIN,		SFX_ITEM_POOLABLE },	// ATTR_MARGIN
142 	{ 0,							SFX_ITEM_POOLABLE },	// ATTR_MERGE
143 	{ 0,							SFX_ITEM_POOLABLE },	// ATTR_MERGE_FLAG
144 	{ SID_ATTR_NUMBERFORMAT_VALUE,	SFX_ITEM_POOLABLE },	// ATTR_VALUE_FORMAT
145 	{ ATTR_LANGUAGE_FORMAT,			SFX_ITEM_POOLABLE },	// ATTR_LANGUAGE_FORMAT ab 329, wird im Dialog mit SID_ATTR_NUMBERFORMAT_VALUE kombiniert
146 	{ SID_ATTR_BRUSH,				SFX_ITEM_POOLABLE },	// ATTR_BACKGROUND
147 	{ SID_SCATTR_PROTECTION,		SFX_ITEM_POOLABLE },	// ATTR_PROTECTION
148 	{ SID_ATTR_BORDER_OUTER,		SFX_ITEM_POOLABLE },	// ATTR_BORDER
149 	{ SID_ATTR_BORDER_INNER,		SFX_ITEM_POOLABLE },	// ATTR_BORDER_INNER
150 	{ SID_ATTR_BORDER_SHADOW,		SFX_ITEM_POOLABLE },	// ATTR_SHADOW
151 	{ 0,							SFX_ITEM_POOLABLE },	// ATTR_VALIDDATA
152 	{ 0,							SFX_ITEM_POOLABLE },	// ATTR_CONDITIONAL
153 	{ 0,							SFX_ITEM_POOLABLE },	// ATTR_PATTERN
154 	{ SID_ATTR_LRSPACE,				SFX_ITEM_POOLABLE },	// ATTR_LRSPACE
155 	{ SID_ATTR_ULSPACE,				SFX_ITEM_POOLABLE },	// ATTR_ULSPACE
156 	{ SID_ATTR_PAGE,				SFX_ITEM_POOLABLE },	// ATTR_PAGE
157 	{ 0,							SFX_ITEM_POOLABLE },	// ATTR_PAGE_PAPERTRAY, seit 303 nur noch dummy
158 	{ SID_ATTR_PAGE_PAPERBIN,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_PAPERBIN
159 	{ SID_ATTR_PAGE_SIZE,			SFX_ITEM_POOLABLE },	// ATTR_PAGE_SIZE
160 	{ SID_ATTR_PAGE_MAXSIZE,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_MAXSIZE
161 	{ SID_ATTR_PAGE_EXT1,			SFX_ITEM_POOLABLE },	// ATTR_PAGE_HORCENTER
162 	{ SID_ATTR_PAGE_EXT2,			SFX_ITEM_POOLABLE },	// ATTR_PAGE_VERCENTER
163 	{ SID_ATTR_PAGE_ON,				SFX_ITEM_POOLABLE },	// ATTR_PAGE_ON
164 	{ SID_ATTR_PAGE_DYNAMIC,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_DYNAMIC
165 	{ SID_ATTR_PAGE_SHARED,			SFX_ITEM_POOLABLE },	// ATTR_PAGE_SHARED
166 	{ SID_SCATTR_PAGE_NOTES,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_NOTES
167 	{ SID_SCATTR_PAGE_GRID,			SFX_ITEM_POOLABLE },	// ATTR_PAGE_GRID
168 	{ SID_SCATTR_PAGE_HEADERS,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_HEADERS
169 	{ SID_SCATTR_PAGE_CHARTS,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_CHARTS
170 	{ SID_SCATTR_PAGE_OBJECTS,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_OBJECTS
171 	{ SID_SCATTR_PAGE_DRAWINGS,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_DRAWINGS
172 	{ SID_SCATTR_PAGE_TOPDOWN,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_TOPDOWN
173 	{ SID_SCATTR_PAGE_SCALE,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_SCALE
174 	{ SID_SCATTR_PAGE_SCALETOPAGES,	SFX_ITEM_POOLABLE },	// ATTR_PAGE_SCALETOPAGES
175 	{ SID_SCATTR_PAGE_FIRSTPAGENO,	SFX_ITEM_POOLABLE },	// ATTR_PAGE_FIRSTPAGENO
176 	{ SID_SCATTR_PAGE_PRINTAREA,	SFX_ITEM_POOLABLE },	// ATTR_PAGE_PRINTAREA
177 	{ SID_SCATTR_PAGE_REPEATROW,	SFX_ITEM_POOLABLE },	// ATTR_PAGE_REPEATROW
178 	{ SID_SCATTR_PAGE_REPEATCOL,	SFX_ITEM_POOLABLE },	// ATTR_PAGE_REPEATCOL
179 	{ SID_SCATTR_PAGE_PRINTTABLES,	SFX_ITEM_POOLABLE },	// ATTR_PAGE_PRINTTABLES
180 	{ SID_SCATTR_PAGE_HEADERLEFT,	SFX_ITEM_POOLABLE },	// ATTR_PAGE_HEADERLEFT
181 	{ SID_SCATTR_PAGE_FOOTERLEFT,	SFX_ITEM_POOLABLE },	// ATTR_PAGE_FOOTERLEFT
182 	{ SID_SCATTR_PAGE_HEADERRIGHT,	SFX_ITEM_POOLABLE },	// ATTR_PAGE_HEADERRIGHT
183 	{ SID_SCATTR_PAGE_FOOTERRIGHT,	SFX_ITEM_POOLABLE },	// ATTR_PAGE_FOOTERRIGHT
184 	{ SID_ATTR_PAGE_HEADERSET,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_HEADERSET
185 	{ SID_ATTR_PAGE_FOOTERSET,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_FOOTERSET
186 	{ SID_SCATTR_PAGE_FORMULAS,		SFX_ITEM_POOLABLE },	// ATTR_PAGE_FORMULAS
187     { SID_SCATTR_PAGE_NULLVALS,     SFX_ITEM_POOLABLE },    // ATTR_PAGE_NULLVALS
188     { SID_SCATTR_PAGE_SCALETO,      SFX_ITEM_POOLABLE }     // ATTR_PAGE_SCALETO
189 };
190 
191 // -----------------------------------------------------------------------
192 
193 ScDocumentPool::ScDocumentPool( SfxItemPool* pSecPool, sal_Bool bLoadRefCounts )
194 
195 	:	SfxItemPool	( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScDocumentPool")),
196 						ATTR_STARTINDEX, ATTR_ENDINDEX,
197 						aItemInfos, NULL, bLoadRefCounts ),
198 		pSecondary	( pSecPool )
199 {
200 	//	latin font from GetDefaultFonts is not used, DEFAULTFONT_LATIN_SPREADSHEET instead
201 	Font aStdFont = OutputDevice::GetDefaultFont( DEFAULTFONT_LATIN_SPREADSHEET, LANGUAGE_ENGLISH_US,
202 													DEFAULTFONT_FLAGS_ONLYONE );
203 	SvxFontItem* pStdFont = new SvxFontItem( aStdFont.GetFamily(),
204 											aStdFont.GetName(), aStdFont.GetStyleName(),
205 											aStdFont.GetPitch(), aStdFont.GetCharSet(),
206 											ATTR_FONT );
207 
208 	SvxFontItem* pCjkFont = new SvxFontItem( ATTR_CJK_FONT );
209 	SvxFontItem* pCtlFont = new SvxFontItem( ATTR_CTL_FONT );
210     SvxFontItem aDummy( ATTR_FONT );
211 	GetDefaultFonts( aDummy, *pCjkFont, *pCtlFont );
212 
213 	SvxBoxInfoItem*	pGlobalBorderInnerAttr = new SvxBoxInfoItem( ATTR_BORDER_INNER );
214 	SfxItemSet*		pSet = new SfxItemSet( *this, ATTR_PATTERN_START, ATTR_PATTERN_END );
215 	SfxItemSet	 	aSetItemItemSet( *this,
216 									 ATTR_BACKGROUND, ATTR_BACKGROUND,
217 									 ATTR_BORDER,	  ATTR_SHADOW,
218 									 ATTR_LRSPACE,	  ATTR_ULSPACE,
219 									 ATTR_PAGE_SIZE,  ATTR_PAGE_SIZE,
220 									 ATTR_PAGE_ON,	  ATTR_PAGE_SHARED,
221 									 0 );
222 
223 	pGlobalBorderInnerAttr->SetLine(NULL, BOXINFO_LINE_HORI);
224 	pGlobalBorderInnerAttr->SetLine(NULL, BOXINFO_LINE_VERT);
225 	pGlobalBorderInnerAttr->SetTable(sal_True);
226     pGlobalBorderInnerAttr->SetDist(sal_True);
227     pGlobalBorderInnerAttr->SetMinDist(sal_False);
228 
229 	ppPoolDefaults = new SfxPoolItem*[ATTR_ENDINDEX-ATTR_STARTINDEX+1];
230 
231 	ppPoolDefaults[ ATTR_FONT			 - ATTR_STARTINDEX ] = pStdFont;
232     ppPoolDefaults[ ATTR_FONT_HEIGHT     - ATTR_STARTINDEX ] = new SvxFontHeightItem( 200, 100, ATTR_FONT_HEIGHT );       // 10 pt;
233     ppPoolDefaults[ ATTR_FONT_WEIGHT     - ATTR_STARTINDEX ] = new SvxWeightItem( WEIGHT_NORMAL, ATTR_FONT_WEIGHT );
234     ppPoolDefaults[ ATTR_FONT_POSTURE    - ATTR_STARTINDEX ] = new SvxPostureItem( ITALIC_NONE, ATTR_FONT_POSTURE );
235     ppPoolDefaults[ ATTR_FONT_UNDERLINE  - ATTR_STARTINDEX ] = new SvxUnderlineItem( UNDERLINE_NONE, ATTR_FONT_UNDERLINE );
236     ppPoolDefaults[ ATTR_FONT_OVERLINE   - ATTR_STARTINDEX ] = new SvxOverlineItem( UNDERLINE_NONE, ATTR_FONT_OVERLINE );
237     ppPoolDefaults[ ATTR_FONT_CROSSEDOUT - ATTR_STARTINDEX ] = new SvxCrossedOutItem( STRIKEOUT_NONE, ATTR_FONT_CROSSEDOUT );
238     ppPoolDefaults[ ATTR_FONT_CONTOUR    - ATTR_STARTINDEX ] = new SvxContourItem( sal_False, ATTR_FONT_CONTOUR );
239     ppPoolDefaults[ ATTR_FONT_SHADOWED   - ATTR_STARTINDEX ] = new SvxShadowedItem( sal_False, ATTR_FONT_SHADOWED );
240     ppPoolDefaults[ ATTR_FONT_COLOR      - ATTR_STARTINDEX ] = new SvxColorItem( Color(COL_AUTO), ATTR_FONT_COLOR );
241 	ppPoolDefaults[	ATTR_FONT_LANGUAGE	 - ATTR_STARTINDEX ] = new SvxLanguageItem(	LanguageType(LANGUAGE_DONTKNOW), ATTR_FONT_LANGUAGE );
242 	ppPoolDefaults[ ATTR_CJK_FONT		 - ATTR_STARTINDEX ] = pCjkFont;
243 	ppPoolDefaults[ ATTR_CJK_FONT_HEIGHT - ATTR_STARTINDEX ] = new SvxFontHeightItem( 200, 100, ATTR_CJK_FONT_HEIGHT );
244 	ppPoolDefaults[ ATTR_CJK_FONT_WEIGHT - ATTR_STARTINDEX ] = new SvxWeightItem( WEIGHT_NORMAL, ATTR_CJK_FONT_WEIGHT );
245 	ppPoolDefaults[ ATTR_CJK_FONT_POSTURE- ATTR_STARTINDEX ] = new SvxPostureItem( ITALIC_NONE, ATTR_CJK_FONT_POSTURE );
246 	ppPoolDefaults[	ATTR_CJK_FONT_LANGUAGE-ATTR_STARTINDEX ] = new SvxLanguageItem(	LanguageType(LANGUAGE_DONTKNOW),
247 																	ATTR_CJK_FONT_LANGUAGE );
248 	ppPoolDefaults[ ATTR_CTL_FONT		 - ATTR_STARTINDEX ] = pCtlFont;
249 	ppPoolDefaults[ ATTR_CTL_FONT_HEIGHT - ATTR_STARTINDEX ] = new SvxFontHeightItem( 200, 100, ATTR_CTL_FONT_HEIGHT );
250 	ppPoolDefaults[ ATTR_CTL_FONT_WEIGHT - ATTR_STARTINDEX ] = new SvxWeightItem( WEIGHT_NORMAL, ATTR_CTL_FONT_WEIGHT );
251 	ppPoolDefaults[ ATTR_CTL_FONT_POSTURE- ATTR_STARTINDEX ] = new SvxPostureItem( ITALIC_NONE, ATTR_CTL_FONT_POSTURE );
252 	ppPoolDefaults[	ATTR_CTL_FONT_LANGUAGE-ATTR_STARTINDEX ] = new SvxLanguageItem(	LanguageType(LANGUAGE_DONTKNOW),
253 																	ATTR_CTL_FONT_LANGUAGE );
254     ppPoolDefaults[ ATTR_FONT_EMPHASISMARK-ATTR_STARTINDEX ] = new SvxEmphasisMarkItem( EMPHASISMARK_NONE, ATTR_FONT_EMPHASISMARK );
255 	ppPoolDefaults[	ATTR_USERDEF		 - ATTR_STARTINDEX ] = new SvXMLAttrContainerItem( ATTR_USERDEF );
256     ppPoolDefaults[ ATTR_FONT_WORDLINE   - ATTR_STARTINDEX ] = new SvxWordLineModeItem(sal_False, ATTR_FONT_WORDLINE );
257     ppPoolDefaults[ ATTR_FONT_RELIEF     - ATTR_STARTINDEX ] = new SvxCharReliefItem( RELIEF_NONE, ATTR_FONT_RELIEF );
258 	ppPoolDefaults[	ATTR_HYPHENATE		 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_HYPHENATE );
259     ppPoolDefaults[ ATTR_SCRIPTSPACE     - ATTR_STARTINDEX ] = new SvxScriptSpaceItem( sal_False, ATTR_SCRIPTSPACE);
260     ppPoolDefaults[ ATTR_HANGPUNCTUATION - ATTR_STARTINDEX ] = new SvxHangingPunctuationItem( sal_False, ATTR_HANGPUNCTUATION);
261     ppPoolDefaults[ ATTR_FORBIDDEN_RULES - ATTR_STARTINDEX ] = new SvxForbiddenRuleItem( sal_False, ATTR_FORBIDDEN_RULES);
262     ppPoolDefaults[ ATTR_HOR_JUSTIFY     - ATTR_STARTINDEX ] = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY);
263 	ppPoolDefaults[	ATTR_INDENT			 - ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_INDENT, 0 );
264     ppPoolDefaults[ ATTR_VER_JUSTIFY     - ATTR_STARTINDEX ] = new SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD, ATTR_VER_JUSTIFY);
265     ppPoolDefaults[ ATTR_STACKED         - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_STACKED, sal_False );
266 	ppPoolDefaults[	ATTR_ROTATE_VALUE	 - ATTR_STARTINDEX ] = new SfxInt32Item( ATTR_ROTATE_VALUE, 0 );
267 	ppPoolDefaults[	ATTR_ROTATE_MODE	 - ATTR_STARTINDEX ] = new SvxRotateModeItem( SVX_ROTATE_MODE_BOTTOM, ATTR_ROTATE_MODE );
268 	ppPoolDefaults[	ATTR_VERTICAL_ASIAN	 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_VERTICAL_ASIAN );
269 	//	The default for the ATTR_WRITINGDIR cell attribute must by FRMDIR_ENVIRONMENT,
270 	//	so that value is returned when asking for a default cell's attributes.
271 	//	The value from the page style is set as DefaultHorizontalTextDirection for the EditEngine.
272 	ppPoolDefaults[	ATTR_WRITINGDIR		 - ATTR_STARTINDEX ] = new SvxFrameDirectionItem( FRMDIR_ENVIRONMENT, ATTR_WRITINGDIR );
273 	ppPoolDefaults[	ATTR_LINEBREAK		 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_LINEBREAK );
274     ppPoolDefaults[ ATTR_SHRINKTOFIT     - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_SHRINKTOFIT );
275     ppPoolDefaults[ ATTR_BORDER_TLBR     - ATTR_STARTINDEX ] = new SvxLineItem( ATTR_BORDER_TLBR );
276     ppPoolDefaults[ ATTR_BORDER_BLTR     - ATTR_STARTINDEX ] = new SvxLineItem( ATTR_BORDER_BLTR );
277     ppPoolDefaults[ ATTR_MARGIN          - ATTR_STARTINDEX ] = new SvxMarginItem( ATTR_MARGIN );
278 	ppPoolDefaults[	ATTR_MERGE			 - ATTR_STARTINDEX ] = new ScMergeAttr;
279 	ppPoolDefaults[	ATTR_MERGE_FLAG		 - ATTR_STARTINDEX ] = new ScMergeFlagAttr;
280 	ppPoolDefaults[	ATTR_VALUE_FORMAT	 - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_VALUE_FORMAT, 0 );
281 	ppPoolDefaults[	ATTR_LANGUAGE_FORMAT - ATTR_STARTINDEX ] = new SvxLanguageItem(	ScGlobal::eLnge, ATTR_LANGUAGE_FORMAT );
282 	ppPoolDefaults[	ATTR_BACKGROUND		 - ATTR_STARTINDEX ] = new SvxBrushItem( Color(COL_TRANSPARENT), ATTR_BACKGROUND );
283 	ppPoolDefaults[	ATTR_PROTECTION		 - ATTR_STARTINDEX ] = new ScProtectionAttr;
284 	ppPoolDefaults[	ATTR_BORDER			 - ATTR_STARTINDEX ] = new SvxBoxItem( ATTR_BORDER );
285 	ppPoolDefaults[ ATTR_BORDER_INNER	 - ATTR_STARTINDEX ] = pGlobalBorderInnerAttr;
286 	ppPoolDefaults[	ATTR_SHADOW			 - ATTR_STARTINDEX ] = new SvxShadowItem( ATTR_SHADOW );
287 	ppPoolDefaults[	ATTR_VALIDDATA		 - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_VALIDDATA, 0 );
288 	ppPoolDefaults[	ATTR_CONDITIONAL	 - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_CONDITIONAL, 0 );
289 
290 	//	GetRscString funktioniert erst nach ScGlobal::Init, zu erkennen am EmptyBrushItem
291 	//!	zusaetzliche Methode ScGlobal::IsInit() oder so...
292 	//!	oder erkennen, ob dies der Secondary-Pool fuer einen MessagePool ist
293 	if ( ScGlobal::GetEmptyBrushItem() )
294 		ppPoolDefaults[ ATTR_PATTERN	 - ATTR_STARTINDEX ] = new ScPatternAttr( pSet, ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
295 	else
296 		ppPoolDefaults[ ATTR_PATTERN	 - ATTR_STARTINDEX ] = new ScPatternAttr( pSet,
297 			String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(STRING_STANDARD)) );	//! without name?
298 
299 	ppPoolDefaults[	ATTR_LRSPACE		 - ATTR_STARTINDEX ] = new SvxLRSpaceItem( ATTR_LRSPACE );
300 	ppPoolDefaults[	ATTR_ULSPACE		 - ATTR_STARTINDEX ] = new SvxULSpaceItem( ATTR_ULSPACE );
301 	ppPoolDefaults[	ATTR_PAGE			 - ATTR_STARTINDEX ] = new SvxPageItem( ATTR_PAGE );
302 	ppPoolDefaults[	ATTR_PAGE_PAPERTRAY	 - ATTR_STARTINDEX ] = new SfxAllEnumItem( ATTR_PAGE_PAPERTRAY );
303 	ppPoolDefaults[	ATTR_PAGE_PAPERBIN	 - ATTR_STARTINDEX ] = new SvxPaperBinItem( ATTR_PAGE_PAPERBIN );
304 	ppPoolDefaults[	ATTR_PAGE_SIZE		 - ATTR_STARTINDEX ] = new SvxSizeItem( ATTR_PAGE_SIZE );
305 	ppPoolDefaults[	ATTR_PAGE_MAXSIZE	 - ATTR_STARTINDEX ] = new SvxSizeItem( ATTR_PAGE_MAXSIZE );
306 	ppPoolDefaults[	ATTR_PAGE_HORCENTER	 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_HORCENTER );
307 	ppPoolDefaults[	ATTR_PAGE_VERCENTER	 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_VERCENTER );
308 	ppPoolDefaults[	ATTR_PAGE_ON		 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_ON, sal_True );
309 	ppPoolDefaults[	ATTR_PAGE_DYNAMIC	 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_DYNAMIC, sal_True );
310 	ppPoolDefaults[	ATTR_PAGE_SHARED	 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_SHARED, sal_True );
311 	ppPoolDefaults[	ATTR_PAGE_NOTES		 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_NOTES, sal_False );
312 	ppPoolDefaults[	ATTR_PAGE_GRID		 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_GRID, sal_False );
313 	ppPoolDefaults[	ATTR_PAGE_HEADERS	 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_HEADERS, sal_False );
314 	ppPoolDefaults[	ATTR_PAGE_CHARTS	 - ATTR_STARTINDEX ] = new ScViewObjectModeItem( ATTR_PAGE_CHARTS );
315 	ppPoolDefaults[	ATTR_PAGE_OBJECTS	 - ATTR_STARTINDEX ] = new ScViewObjectModeItem( ATTR_PAGE_OBJECTS );
316 	ppPoolDefaults[	ATTR_PAGE_DRAWINGS	 - ATTR_STARTINDEX ] = new ScViewObjectModeItem( ATTR_PAGE_DRAWINGS );
317 	ppPoolDefaults[	ATTR_PAGE_TOPDOWN	 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_TOPDOWN, sal_True );
318 	ppPoolDefaults[	ATTR_PAGE_SCALE		 - ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_PAGE_SCALE, 100 );
319 	ppPoolDefaults[	ATTR_PAGE_SCALETOPAGES-ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, 1 );
320 	ppPoolDefaults[	ATTR_PAGE_FIRSTPAGENO- ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO, 1 );
321 	ppPoolDefaults[	ATTR_PAGE_PRINTAREA	 - ATTR_STARTINDEX ] = new ScRangeItem( ATTR_PAGE_PRINTAREA );
322 	ppPoolDefaults[	ATTR_PAGE_REPEATROW	 - ATTR_STARTINDEX ] = new ScRangeItem( ATTR_PAGE_REPEATROW );
323 	ppPoolDefaults[	ATTR_PAGE_REPEATCOL	 - ATTR_STARTINDEX ] = new ScRangeItem( ATTR_PAGE_REPEATCOL );
324 	ppPoolDefaults[	ATTR_PAGE_PRINTTABLES- ATTR_STARTINDEX ] = new ScTableListItem( ATTR_PAGE_PRINTTABLES );
325 	ppPoolDefaults[	ATTR_PAGE_HEADERLEFT - ATTR_STARTINDEX ] = new ScPageHFItem( ATTR_PAGE_HEADERLEFT );
326 	ppPoolDefaults[	ATTR_PAGE_FOOTERLEFT - ATTR_STARTINDEX ] = new ScPageHFItem( ATTR_PAGE_FOOTERLEFT );
327 	ppPoolDefaults[	ATTR_PAGE_HEADERRIGHT- ATTR_STARTINDEX ] = new ScPageHFItem( ATTR_PAGE_HEADERRIGHT );
328 	ppPoolDefaults[	ATTR_PAGE_FOOTERRIGHT- ATTR_STARTINDEX ] = new ScPageHFItem( ATTR_PAGE_FOOTERRIGHT );
329 	ppPoolDefaults[	ATTR_PAGE_HEADERSET	 - ATTR_STARTINDEX ] = new SvxSetItem( ATTR_PAGE_HEADERSET, aSetItemItemSet );
330 	ppPoolDefaults[	ATTR_PAGE_FOOTERSET	 - ATTR_STARTINDEX ] = new SvxSetItem( ATTR_PAGE_FOOTERSET, aSetItemItemSet );
331 	ppPoolDefaults[	ATTR_PAGE_FORMULAS	 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_FORMULAS, sal_False );
332 	ppPoolDefaults[	ATTR_PAGE_NULLVALS	 - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_NULLVALS, sal_True );
333     ppPoolDefaults[ ATTR_PAGE_SCALETO    - ATTR_STARTINDEX ] = new ScPageScaleToItem( 1, 1 );
334 //	ppPoolDefaults[	ATTR_ITEM_DOUBLE	 - ATTR_STARTINDEX ] = new ScDoubleItem( ATTR_ITEM_DOUBLE, 0 );
335 
336 	SetDefaults( ppPoolDefaults );
337 
338 	if ( pSecondary )
339 		SetSecondaryPool( pSecondary );
340 
341 	// ATTR_LANGUAGE_FORMAT ab sv329 eingefuegt, VersionMap in _ScGlobal__Init
342 	SetVersionMap( 1, 100, 157, pVersionMap1 );
343 
344 	// ATTR_VALIDDATA, ATTR_CONDITIONAL ab 341
345 	SetVersionMap( 2, 100, 158, pVersionMap2 );
346 
347 	// ATTR_INDENT ab 350
348 	SetVersionMap( 3, 100, 160, pVersionMap3 );
349 
350 	// ATTR_ROTATE_VALUE, ATTR_ROTATE_MODE ab 367
351 	SetVersionMap( 4, 100, 161, pVersionMap4 );
352 
353 	// CJK, CTL, EMPHASISMARK, TWOLINES from 614
354 	SetVersionMap( 5, 100, 163, pVersionMap5 );
355 
356 	// ATTR_SCRIPTSPACE, ATTR_HANGPUNCTUATION, ATTR_FORBIDDEN_RULES from 614d
357 	SetVersionMap( 6, 100, 175, pVersionMap6 );
358 
359 	// ATTR_FONT_WORDLINE, ATTR_FONT_RELIEF, ATTR_HYPHENATE from 632b
360 	SetVersionMap( 7, 100, 178, pVersionMap7 );
361 
362 	// ATTR_VERTICAL_ASIAN from 642q
363 	SetVersionMap( 8, 100, 181, pVersionMap8 );
364 
365 	// ATTR_WRITINGDIR from 643y
366 	SetVersionMap( 9, 100, 182, pVersionMap9 );
367 
368 	// ATTR_PAGE_SCALETO added in 680/sab008
369 	// new version map not required
370 
371     // ATTR_SHRINKTOFIT, ATTR_BORDER_TL_BR, ATTR_BORDER_BL_TR added in 680/dr14
372     SetVersionMap( 10, 100, 184, pVersionMap10 );
373 
374     // ATTR_FONT_OVERLINE added in DEV300/overline2
375     SetVersionMap( 11, 100, 187, pVersionMap11 );
376 }
377 
378 __EXPORT ScDocumentPool::~ScDocumentPool()
379 {
380 	Delete();
381 
382 	for ( sal_uInt16 i=0; i < ATTR_ENDINDEX-ATTR_STARTINDEX+1; i++ )
383 	{
384 		SetRefCount( *ppPoolDefaults[i], 0 );
385 		delete ppPoolDefaults[i];
386 	}
387 
388 	delete[] ppPoolDefaults;
389 	SfxItemPool::Free(pSecondary);
390 }
391 
392 void ScDocumentPool::InitVersionMaps()
393 {
394 	DBG_ASSERT( !pVersionMap1 && !pVersionMap2 &&
395 				!pVersionMap3 && !pVersionMap4 &&
396 				!pVersionMap5 && !pVersionMap6 &&
397 				!pVersionMap7 && !pVersionMap8 &&
398                 !pVersionMap9 && !pVersionMap10 &&
399                 !pVersionMap11, "InitVersionMaps call multiple times" );
400 
401 	// alte WhichId's mappen
402 	// nicht mit ATTR_* zaehlen, falls die sich nochmal aendern
403 
404 	//	erste Map: ATTR_LANGUAGE_FORMAT ab sv329 eingefuegt
405 
406 	const sal_uInt16 nMap1Start	= 100;	// alter ATTR_STARTINDEX
407 	const sal_uInt16 nMap1End	= 157;	// alter ATTR_ENDINDEX
408 	const sal_uInt16 nMap1Count = nMap1End - nMap1Start + 1;
409 	const sal_uInt16 nMap1New	= 18;	// ATTR_LANGUAGE_FORMAT - ATTR_STARTINDEX
410 	pVersionMap1 = new sal_uInt16 [ nMap1Count ];
411 	sal_uInt16 i, j;
412 	for ( i=0, j=nMap1Start; i < nMap1New; i++, j++ )
413 		pVersionMap1[i] = j;
414 	// ein Eintrag eingefuegt...
415 	for ( i=nMap1New, j=nMap1Start+nMap1New+1; i < nMap1Count; i++, j++ )
416 		pVersionMap1[i] = j;
417 
418 	//	zweite Map: ATTR_VALIDDATA und ATTR_CONDITIONAL ab 341 eingefuegt
419 
420 	const sal_uInt16 nMap2Start	= 100;	// ATTR_STARTINDEX
421 	const sal_uInt16 nMap2End	= 158;	// ATTR_ENDINDEX
422 	const sal_uInt16 nMap2Count = nMap2End - nMap2Start + 1;
423 	const sal_uInt16 nMap2New   = 24;	// ATTR_VALIDDATA - ATTR_STARTINDEX
424 	pVersionMap2 = new sal_uInt16 [ nMap2Count ];
425 	for ( i=0, j=nMap2Start; i < nMap2New; i++, j++ )
426 		pVersionMap2[i] = j;
427 	// zwei Eintraege eingefuegt...
428 	for ( i=nMap2New, j=nMap2Start+nMap2New+2; i < nMap2Count; i++, j++ )
429 		pVersionMap2[i] = j;
430 
431 	//	dritte Map: ATTR_INDENT ab 350 eingefuegt
432 
433 	const sal_uInt16 nMap3Start	= 100;	// ATTR_STARTINDEX
434 	const sal_uInt16 nMap3End	= 160;	// ATTR_ENDINDEX
435 	const sal_uInt16 nMap3Count = nMap3End - nMap3Start + 1;
436 	const sal_uInt16 nMap3New   = 11;	// ATTR_INDENT - ATTR_STARTINDEX
437 	pVersionMap3 = new sal_uInt16 [ nMap3Count ];
438 	for ( i=0, j=nMap3Start; i < nMap3New; i++, j++ )
439 		pVersionMap3[i] = j;
440 	// ein Eintrag eingefuegt...
441 	for ( i=nMap3New, j=nMap3Start+nMap3New+1; i < nMap3Count; i++, j++ )
442 		pVersionMap3[i] = j;
443 
444 	//	vierte Map: ATTR_ROTATE_VALUE und ATTR_ROTATE_MODE ab 367 eingefuegt
445 
446 	const sal_uInt16 nMap4Start	= 100;	// ATTR_STARTINDEX
447 	const sal_uInt16 nMap4End	= 161;	// ATTR_ENDINDEX
448 	const sal_uInt16 nMap4Count = nMap4End - nMap4Start + 1;
449 	const sal_uInt16 nMap4New   = 14;	// ATTR_ROTATE_VALUE - ATTR_STARTINDEX
450 	pVersionMap4 = new sal_uInt16 [ nMap4Count ];
451 	for ( i=0, j=nMap4Start; i < nMap4New; i++, j++ )
452 		pVersionMap4[i] = j;
453 	// zwei Eintraege eingefuegt...
454 	for ( i=nMap4New, j=nMap4Start+nMap4New+2; i < nMap4Count; i++, j++ )
455 		pVersionMap4[i] = j;
456 
457 	//	fifth map: CJK..., CTL..., EMPHASISMARK, TWOLINES (12 items) added in 614
458 
459 	const sal_uInt16 nMap5Start	= 100;	// ATTR_STARTINDEX
460 	const sal_uInt16 nMap5End	= 163;	// ATTR_ENDINDEX
461 	const sal_uInt16 nMap5Count = nMap5End - nMap5Start + 1;
462 	const sal_uInt16 nMap5New   = 10;	// ATTR_CJK_FONT - ATTR_STARTINDEX
463 	pVersionMap5 = new sal_uInt16 [ nMap5Count ];
464 	for ( i=0, j=nMap5Start; i < nMap5New; i++, j++ )
465 		pVersionMap5[i] = j;
466 	// 12 entries inserted
467 	for ( i=nMap5New, j=nMap5Start+nMap5New+12; i < nMap5Count; i++, j++ )
468 		pVersionMap5[i] = j;
469 
470 	// sixth map: ATTR_SCRIPTSPACE, ATTR_HANGPUNCTUATION, ATTR_FORBIDDEN_RULES added in 614d
471 
472 	const sal_uInt16 nMap6Start	= 100;	// ATTR_STARTINDEX
473 	const sal_uInt16 nMap6End	= 175;	// ATTR_ENDINDEX
474 	const sal_uInt16 nMap6Count = nMap6End - nMap6Start + 1;
475 	const sal_uInt16 nMap6New   = 22;	// ATTR_SCRIPTSPACE - ATTR_STARTINDEX
476 	pVersionMap6 = new sal_uInt16 [ nMap6Count ];
477 	for ( i=0, j=nMap6Start; i < nMap6New; i++, j++ )
478 		pVersionMap6[i] = j;
479 	// 3 entries inserted
480 	for ( i=nMap6New, j=nMap6Start+nMap6New+3; i < nMap6Count; i++, j++ )
481 		pVersionMap6[i] = j;
482 
483 	//	seventh map: ATTR_FONT_WORDLINE, ATTR_FONT_RELIEF, ATTR_HYPHENATE added in 632b
484 
485 	const sal_uInt16 nMap7Start	= 100;	// ATTR_STARTINDEX
486 	const sal_uInt16 nMap7End	= 178;	// ATTR_ENDINDEX
487 	const sal_uInt16 nMap7Count = nMap7End - nMap7Start + 1;
488 	const sal_uInt16 nMap7New   = 22;	// ATTR_FONT_WORDLINE - ATTR_STARTINDEX
489 	pVersionMap7 = new sal_uInt16 [ nMap7Count ];
490 	for ( i=0, j=nMap7Start; i < nMap7New; i++, j++ )
491 		pVersionMap7[i] = j;
492 	// 3 entries inserted
493 	for ( i=nMap7New, j=nMap7Start+nMap7New+3; i < nMap7Count; i++, j++ )
494 		pVersionMap7[i] = j;
495 
496 	//	eighth map: ATTR_VERTICAL_ASIAN added in 642q
497 
498 	const sal_uInt16 nMap8Start	= 100;	// ATTR_STARTINDEX
499 	const sal_uInt16 nMap8End	= 181;	// ATTR_ENDINDEX
500 	const sal_uInt16 nMap8Count = nMap8End - nMap8Start + 1;
501 	const sal_uInt16 nMap8New   = 34;	// ATTR_VERTICAL_ASIAN - ATTR_STARTINDEX
502 	pVersionMap8 = new sal_uInt16 [ nMap8Count ];
503 	for ( i=0, j=nMap8Start; i < nMap8New; i++, j++ )
504 		pVersionMap8[i] = j;
505 	// 1 entry inserted
506 	for ( i=nMap8New, j=nMap8Start+nMap8New+1; i < nMap8Count; i++, j++ )
507 		pVersionMap8[i] = j;
508 
509 	//	9th map: ATTR_WRITINGDIR added in 643y
510 
511 	const sal_uInt16 nMap9Start	= 100;	// ATTR_STARTINDEX
512 	const sal_uInt16 nMap9End	= 182;	// ATTR_ENDINDEX
513 	const sal_uInt16 nMap9Count = nMap9End - nMap9Start + 1;
514 	const sal_uInt16 nMap9New   = 35;	// ATTR_WRITINGDIR - ATTR_STARTINDEX
515 	pVersionMap9 = new sal_uInt16 [ nMap9Count ];
516 	for ( i=0, j=nMap9Start; i < nMap9New; i++, j++ )
517 		pVersionMap9[i] = j;
518 	// 1 entry inserted
519 	for ( i=nMap9New, j=nMap9Start+nMap9New+1; i < nMap9Count; i++, j++ )
520 		pVersionMap9[i] = j;
521 
522 	// ATTR_PAGE_SCALETO added in 680/sab008
523 
524     // 10th map: ATTR_SHRINKTOFIT, ATTR_BORDER_TL_BR, ATTR_BORDER_BL_TR added in 680/dr14
525 
526     const sal_uInt16 nMap10Start = 100;  // ATTR_STARTINDEX
527     const sal_uInt16 nMap10End   = 184;  // ATTR_ENDINDEX
528     const sal_uInt16 nMap10Count = nMap10End - nMap10Start + 1;
529     const sal_uInt16 nMap10New   = 37;   // ATTR_SHRINKTOFIT - ATTR_STARTINDEX
530     pVersionMap10 = new sal_uInt16 [ nMap10Count ];
531     for ( i=0, j=nMap10Start; i < nMap10New; i++, j++ )
532         pVersionMap10[i] = j;
533     // 3 entries inserted
534     for ( i=nMap10New, j=nMap10Start+nMap10New+3; i < nMap10Count; i++, j++ )
535         pVersionMap10[i] = j;
536 
537     // 11th map: ATTR_FONT_OVERLINE added in DEV300/overline2
538 
539     const sal_uInt16 nMap11Start = 100;  // ATTR_STARTINDEX
540     const sal_uInt16 nMap11End   = 187;  // ATTR_ENDINDEX
541     const sal_uInt16 nMap11Count = nMap11End - nMap11Start + 1;
542     const sal_uInt16 nMap11New   = 5;    // ATTR_FONT_OVERLINE - ATTR_STARTINDEX
543     pVersionMap11 = new sal_uInt16 [ nMap11Count ];
544     for ( i=0, j=nMap11Start; i < nMap11New; i++, j++ )
545         pVersionMap11[i] = j;
546     // 1 entry inserted
547     for ( i=nMap11New, j=nMap11Start+nMap11New+1; i < nMap11Count; i++, j++ )
548         pVersionMap11[i] = j;
549 }
550 
551 void ScDocumentPool::DeleteVersionMaps()
552 {
553 	DBG_ASSERT( pVersionMap1 && pVersionMap2 &&
554 				pVersionMap3 && pVersionMap4 &&
555 				pVersionMap5 && pVersionMap6 &&
556 				pVersionMap7 && pVersionMap8 &&
557                 pVersionMap9 && pVersionMap10 &&
558                 pVersionMap11, "DeleteVersionMaps without maps" );
559 
560     delete[] pVersionMap11;
561     pVersionMap11 = 0;
562     delete[] pVersionMap10;
563     pVersionMap10 = 0;
564 	delete[] pVersionMap9;
565 	pVersionMap9 = 0;
566 	delete[] pVersionMap8;
567 	pVersionMap8 = 0;
568 	delete[] pVersionMap7;
569 	pVersionMap7 = 0;
570 	delete[] pVersionMap6;
571 	pVersionMap6 = 0;
572 	delete[] pVersionMap5;
573 	pVersionMap5 = 0;
574 	delete[] pVersionMap4;
575 	pVersionMap4 = 0;
576 	delete[] pVersionMap3;
577 	pVersionMap3 = 0;
578 	delete[] pVersionMap2;
579 	pVersionMap2 = 0;
580 	delete[] pVersionMap1;
581 	pVersionMap1 = 0;
582 }
583 
584 // ----------------------------------------------------------------------------------------
585 //
586 //	Fuer die Pattern-Attribute (SetItems) kann der sal_uInt16 RefCount leicht ueberlaufen
587 //	(z.B. 600 ganze Zeilen abwechselnd formatieren).
588 //	Darum wird der RefCount bei SC_MAX_POOLREF festgehalten und nicht mehr hoch- oder
589 //	heruntergezaehlt. Dieser RefCount wird dann erst beim naechsten Laden neu gezaehlt.
590 //	Die Differenz zwischen SC_MAX_POOLREF und SC_SAFE_POOLREF ist ein wenig groesser
591 //	als noetig, um zu erkennen, wenn der RefCount aus Versehen doch "normal" veraendert
592 //	wird (Assertions).
593 //
594 
595 const SfxPoolItem& __EXPORT ScDocumentPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich )
596 {
597 	if ( rItem.Which() != ATTR_PATTERN )				// nur Pattern ist special
598 		return SfxItemPool::Put( rItem, nWhich );
599 
600 	//	das Default-Pattern dieses Pools nicht kopieren
601 	if (&rItem == ppPoolDefaults[ ATTR_PATTERN - ATTR_STARTINDEX ])
602 		return rItem;
603 
604 	//	ansonsten muss Put immer passieren, weil es ein anderer Pool sein kann
605 	const SfxPoolItem& rNew = SfxItemPool::Put( rItem, nWhich );
606 	CheckRef( rNew );
607 	return rNew;
608 }
609 
610 void __EXPORT ScDocumentPool::Remove( const SfxPoolItem& rItem )
611 {
612 	if ( rItem.Which() == ATTR_PATTERN )				// nur Pattern ist special
613 	{
614 		sal_uLong nRef = rItem.GetRefCount();
615 		if ( nRef >= (sal_uLong) SC_MAX_POOLREF && nRef <= (sal_uLong) SFX_ITEMS_OLD_MAXREF )
616 		{
617 			if ( nRef != (sal_uLong) SC_SAFE_POOLREF )
618 			{
619 				DBG_ERROR("Wer fummelt da an meinen Ref-Counts herum");
620 				SetRefCount( (SfxPoolItem&)rItem, (sal_uLong) SC_SAFE_POOLREF );
621 			}
622 			return;					// nicht herunterzaehlen
623 		}
624 	}
625 	SfxItemPool::Remove( rItem );
626 }
627 
628 void ScDocumentPool::CheckRef( const SfxPoolItem& rItem )	// static
629 {
630 	sal_uLong nRef = rItem.GetRefCount();
631 	if ( nRef >= (sal_uLong) SC_MAX_POOLREF && nRef <= (sal_uLong) SFX_ITEMS_OLD_MAXREF )
632 	{
633 		// beim Apply vom Cache wird evtl. um 2 hochgezaehlt (auf MAX+1 oder SAFE+2),
634 		// heruntergezaehlt wird nur einzeln (in LoadCompleted)
635 		DBG_ASSERT( nRef<=(sal_uLong)SC_MAX_POOLREF+1 || (nRef>=(sal_uLong)SC_SAFE_POOLREF-1 && nRef<=(sal_uLong)SC_SAFE_POOLREF+2),
636 				"ScDocumentPool::CheckRef" );
637 		SetRefCount( (SfxPoolItem&)rItem, (sal_uLong) SC_SAFE_POOLREF );
638 	}
639 }
640 
641 // ----------------------------------------------------------------------------------------
642 
643 void ScDocumentPool::StyleDeleted( ScStyleSheet* pStyle )
644 {
645 	sal_uInt32 nCount = GetItemCount2(ATTR_PATTERN);
646 	for (sal_uInt32 i=0; i<nCount; i++)
647 	{
648 		ScPatternAttr* pPattern = (ScPatternAttr*)GetItem2(ATTR_PATTERN, i);
649 		if ( pPattern && pPattern->GetStyleSheet() == pStyle )
650 			pPattern->StyleToName();
651 	}
652 }
653 
654 void ScDocumentPool::CellStyleCreated( const String& rName )
655 {
656     // If a style was created, don't keep any pattern with its name string in the pool,
657     // because it would compare equal to a pattern with a pointer to the new style.
658     // Calling StyleSheetChanged isn't enough because the pool may still contain items
659     // for undo or clipboard content.
660 
661     sal_uInt32 nCount = GetItemCount2(ATTR_PATTERN);
662     for (sal_uInt32 i=0; i<nCount; i++)
663     {
664         ScPatternAttr *const pPattern =
665             const_cast<ScPatternAttr*>(
666                 static_cast<ScPatternAttr const*>(GetItem2(ATTR_PATTERN, i)));
667         if ( pPattern && pPattern->GetStyleSheet() == NULL )
668         {
669             const String* pStyleName = pPattern->GetStyleName();
670             if ( pStyleName && *pStyleName == rName )
671                 pPattern->UpdateStyleSheet();           // find and store style pointer
672         }
673     }
674 }
675 
676 SfxItemPool* __EXPORT ScDocumentPool::Clone() const
677 {
678 	return new SfxItemPool (*this, sal_True);
679 }
680 
681 SfxItemPresentation lcl_HFPresentation
682 (
683 	const SfxPoolItem&	rItem,
684 	SfxItemPresentation ePresentation,
685 	SfxMapUnit			eCoreMetric,
686 	SfxMapUnit			ePresentationMetric,
687 	String&				rText,
688     const IntlWrapper* pIntl
689 )
690 {
691 	const SfxItemSet& rSet = ((const SfxSetItem&)rItem).GetItemSet();
692 	const SfxPoolItem* pItem;
693 
694 	if ( SFX_ITEM_SET == rSet.GetItemState(ATTR_PAGE_ON,sal_False,&pItem) )
695 	{
696 		if( sal_False == ((const SfxBoolItem*)pItem)->GetValue() )
697 			return SFX_ITEM_PRESENTATION_NONE;
698 	}
699 
700 	SfxItemIter	aIter( rSet );
701 	pItem = aIter.FirstItem();
702 	String	aText;
703 	String	aDel = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( " + " ));
704 
705 	while( pItem )
706 	{
707 		sal_uInt16 nWhich = pItem->Which();
708 
709 		aText.Erase();
710 
711 		switch( nWhich )
712 		{
713 			case ATTR_PAGE_ON:
714 			case ATTR_PAGE_DYNAMIC:
715 			case ATTR_PAGE_SHARED:
716 			break;
717 
718 			case ATTR_LRSPACE:
719 			{
720 				SvxLRSpaceItem& rLRItem = (SvxLRSpaceItem&)*pItem;
721 				sal_uInt16 nPropLeftMargin  = rLRItem.GetPropLeft();
722 				sal_uInt16 nPropRightMargin = rLRItem.GetPropRight();
723 				sal_uInt16 nLeftMargin, nRightMargin;
724 				long nTmp;
725 				nTmp = rLRItem.GetLeft();
726 				nLeftMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp);
727 				nTmp = rLRItem.GetRight();
728 				nRightMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp);
729 
730 				aText = EE_RESSTR(RID_SVXITEMS_LRSPACE_LEFT);
731 				if ( 100 != nPropLeftMargin )
732 				{
733 					aText += String::CreateFromInt32( nPropLeftMargin );
734 					aText += '%';
735 				}
736 				else
737 				{
738 					aText += GetMetricText( (long)nLeftMargin,
739                                            eCoreMetric, ePresentationMetric, pIntl );
740 					aText += EE_RESSTR(GetMetricId(ePresentationMetric));
741 				}
742 				aText += cpDelim;
743 
744 				// nPropFirstLineOfst haben wir nicht
745 
746 				aText += EE_RESSTR(RID_SVXITEMS_LRSPACE_RIGHT);
747 				if ( 100 != nPropRightMargin )
748 				{
749 					aText += String::CreateFromInt32( nPropRightMargin );
750 					aText += '%';
751 				}
752 				else
753 				{
754 					aText += GetMetricText( (long)nRightMargin,
755                                             eCoreMetric, ePresentationMetric, pIntl );
756 					aText += EE_RESSTR(GetMetricId(ePresentationMetric));
757 				}
758 			}
759 			break;
760 
761 			default:
762 				if ( !pIntl )
763                     pIntl = ScGlobal::GetScIntlWrapper();
764 				pItem->GetPresentation( ePresentation, eCoreMetric, ePresentationMetric, aText, pIntl );
765 
766 		}
767 
768 		if ( aText.Len() )
769 		{
770 			rText += aText;
771 			rText += aDel;
772 		}
773 
774 		pItem = aIter.NextItem();
775 	}
776 
777 	rText.EraseTrailingChars();
778 	rText.EraseTrailingChars( '+' );
779 	rText.EraseTrailingChars();
780 
781 	return ePresentation;
782 }
783 
784 SfxItemPresentation __EXPORT ScDocumentPool::GetPresentation(
785 	const SfxPoolItem&	rItem,
786 	SfxItemPresentation ePresentation,
787 	SfxMapUnit			ePresentationMetric,
788 	String&				rText,
789     const IntlWrapper* pIntl ) const
790 {
791 	sal_uInt16	nW = rItem.Which();
792 	String aStrYes	( ScGlobal::GetRscString(STR_YES) );
793 	String aStrNo	( ScGlobal::GetRscString(STR_NO) );
794 	String aStrSep = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(": "));
795 
796 	switch( nW )
797 	{
798 		case ATTR_PAGE_TOPDOWN:
799 		switch ( ePresentation )
800 		{
801 			case SFX_ITEM_PRESENTATION_COMPLETE:
802 			rText  = ScGlobal::GetRscString(STR_SCATTR_PAGE_PRINTDIR);
803 			rText += aStrSep;
804 //			break; // DURCHFALLEN!!!
805 			case SFX_ITEM_PRESENTATION_NAMELESS:
806 			rText += ((const SfxBoolItem&)rItem).GetValue() ?
807 				ScGlobal::GetRscString(STR_SCATTR_PAGE_TOPDOWN) :
808 				ScGlobal::GetRscString(STR_SCATTR_PAGE_LEFTRIGHT) ;
809 			break;
810             default:
811             {
812                 // added to avoid warnings
813             }
814 		}
815 		break;
816 
817 		case ATTR_PAGE_HEADERS:
818 		switch ( ePresentation )
819 		{
820 			case SFX_ITEM_PRESENTATION_COMPLETE:
821 			rText  = ScGlobal::GetRscString(STR_SCATTR_PAGE_HEADERS);
822 			rText += aStrSep;
823 //			break; // DURCHFALLEN!!!
824 			case SFX_ITEM_PRESENTATION_NAMELESS:
825 			rText += ((const SfxBoolItem&)rItem).GetValue() ? aStrYes : aStrNo ;
826 			break;
827             default:
828             {
829                 // added to avoid warnings
830             }
831 		}
832 		break;
833 
834 		case ATTR_PAGE_NULLVALS:
835 		switch ( ePresentation )
836 		{
837 			case SFX_ITEM_PRESENTATION_COMPLETE:
838 			rText  = ScGlobal::GetRscString(STR_SCATTR_PAGE_NULLVALS);
839 			rText += aStrSep;
840 //			break; // DURCHFALLEN!!!
841 			case SFX_ITEM_PRESENTATION_NAMELESS:
842 			rText += ((const SfxBoolItem&)rItem).GetValue() ? aStrYes : aStrNo ;
843 			break;
844             default:
845             {
846                 // added to avoid warnings
847             }
848 		}
849 		break;
850 
851 		case ATTR_PAGE_FORMULAS:
852 		switch ( ePresentation )
853 		{
854 			case SFX_ITEM_PRESENTATION_COMPLETE:
855             rText  = ScGlobal::GetRscString(STR_SCATTR_PAGE_FORMULAS);
856 			rText += aStrSep;
857 //			break; // DURCHFALLEN!!!
858 			case SFX_ITEM_PRESENTATION_NAMELESS:
859 			rText += ((const SfxBoolItem&)rItem).GetValue() ? aStrYes : aStrNo ;
860 			break;
861             default:
862             {
863                 // added to avoid warnings
864             }
865 		}
866 		break;
867 
868 		case ATTR_PAGE_NOTES:
869 		switch ( ePresentation )
870 		{
871 			case SFX_ITEM_PRESENTATION_COMPLETE:
872 			rText  = ScGlobal::GetRscString(STR_SCATTR_PAGE_NOTES);
873 			rText += aStrSep;
874 //			break; // DURCHFALLEN!!!
875 			case SFX_ITEM_PRESENTATION_NAMELESS:
876 			rText += ((const SfxBoolItem&)rItem).GetValue() ? aStrYes : aStrNo ;
877 			break;
878             default:
879             {
880                 // added to avoid warnings
881             }
882 		}
883 		break;
884 
885 		case ATTR_PAGE_GRID:
886 		switch ( ePresentation )
887 		{
888 			case SFX_ITEM_PRESENTATION_COMPLETE:
889 			rText  = ScGlobal::GetRscString(STR_SCATTR_PAGE_GRID);
890 			rText += aStrSep;
891 //			break; // DURCHFALLEN!!!
892 			case SFX_ITEM_PRESENTATION_NAMELESS:
893 			rText += ((const SfxBoolItem&)rItem).GetValue() ? aStrYes : aStrNo ;
894 			break;
895             default:
896             {
897                 // added to avoid warnings
898             }
899 		}
900 		break;
901 
902 		case ATTR_PAGE_SCALETOPAGES:
903 		{
904 			sal_uInt16	nPagNo = ((const SfxUInt16Item&)rItem).GetValue();
905 
906 			if( nPagNo )
907 			{
908 				switch ( ePresentation )
909 				{
910 					case SFX_ITEM_PRESENTATION_COMPLETE:
911                     {
912                         rText.Assign( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALETOPAGES ) ).Append( aStrSep );
913                     }
914 //					break; // DURCHFALLEN!!!
915 					case SFX_ITEM_PRESENTATION_NAMELESS:
916                     {
917                         String aPages( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_PAGES ) );
918                         aPages.SearchAndReplaceAscii( "%1", String::CreateFromInt32( nPagNo ) );
919                         rText.Append( aPages );
920                     }
921 					break;
922                     default:
923                     {
924                         // added to avoid warnings
925                     }
926 				}
927 			}
928 			else
929 			{
930 				ePresentation = SFX_ITEM_PRESENTATION_NONE;
931 			}
932 		}
933 		break;
934 
935 		case ATTR_PAGE_FIRSTPAGENO:
936 		{
937 			sal_uInt16	nPagNo = ((const SfxUInt16Item&)rItem).GetValue();
938 
939 			if( nPagNo )
940 			{
941 				switch ( ePresentation )
942 				{
943 					case SFX_ITEM_PRESENTATION_COMPLETE:
944 					rText  = ScGlobal::GetRscString(STR_SCATTR_PAGE_FIRSTPAGENO);
945 					rText += aStrSep;
946 //					break; // DURCHFALLEN!!!
947 					case SFX_ITEM_PRESENTATION_NAMELESS:
948 					rText += String::CreateFromInt32( nPagNo );
949 					break;
950                     default:
951                     {
952                         // added to avoid warnings
953                     }
954 				}
955 			}
956 			else
957 			{
958 				ePresentation = SFX_ITEM_PRESENTATION_NONE;
959 			}
960 		}
961 		break;
962 
963 		case ATTR_PAGE_SCALE:
964 		{
965 			sal_uInt16	nPercent = ((const SfxUInt16Item&)rItem).GetValue();
966 
967 			if( nPercent )
968 			{
969 				switch ( ePresentation )
970 				{
971 					case SFX_ITEM_PRESENTATION_COMPLETE:
972 					rText  = ScGlobal::GetRscString(STR_SCATTR_PAGE_SCALE);
973 					rText += aStrSep;
974 //					break; // DURCHFALLEN!!!
975 					case SFX_ITEM_PRESENTATION_NAMELESS:
976 					rText += String::CreateFromInt32( nPercent );
977 					rText += '%';
978 					break;
979                     default:
980                     {
981                         // added to avoid warnings
982                     }
983 				}
984 			}
985 			else
986 			{
987 				ePresentation = SFX_ITEM_PRESENTATION_NONE;
988 			}
989 		}
990 		break;
991 
992 		case ATTR_PAGE_HEADERSET:
993 		{
994 			String	aBuffer;
995 
996 			if( lcl_HFPresentation(	rItem, ePresentation, GetMetric( nW ), ePresentationMetric,	aBuffer, pIntl ) != SFX_ITEM_PRESENTATION_NONE )
997 			{
998 				rText  = ScGlobal::GetRscString(STR_HEADER);
999 				rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ( " ));
1000 				rText += aBuffer;
1001 				rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ) " ));
1002 			}
1003 		}
1004 		break;
1005 
1006 		case ATTR_PAGE_FOOTERSET:
1007 		{
1008 			String	aBuffer;
1009 
1010 			if( lcl_HFPresentation(	rItem, ePresentation, GetMetric( nW ), ePresentationMetric,	aBuffer, pIntl ) != SFX_ITEM_PRESENTATION_NONE )
1011 			{
1012 				rText  = ScGlobal::GetRscString(STR_FOOTER);
1013 				rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ( " ));
1014 				rText += aBuffer;
1015 				rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ) " ));
1016 			}
1017 		}
1018 		break;
1019 
1020 /*
1021 		case ATTR_PAGE_HEADERLEFT:
1022 		rText = "SID_SCATTR_PAGE_HEADERLEFT";
1023 		break;
1024 
1025 		case ATTR_PAGE_FOOTERLEFT:
1026 		rText = "SID_SCATTR_PAGE_FOOTERLEFT";
1027 		break;
1028 
1029 		case ATTR_PAGE_HEADERRIGHT:
1030 		rText = "SID_SCATTR_PAGE_HEADERRIGHT";
1031 		break;
1032 
1033 		case ATTR_PAGE_FOOTERRIGHT:
1034 		rText = "SID_SCATTR_PAGE_FOOTERRIGHT";
1035 		break;
1036 */
1037 
1038 		default:
1039 			if ( !pIntl )
1040                 pIntl = ScGlobal::GetScIntlWrapper();
1041 			ePresentation = rItem.GetPresentation( ePresentation, GetMetric( nW ), ePresentationMetric, rText, pIntl );
1042 		break;
1043 	}
1044 
1045 	return ePresentation;
1046 }
1047 
1048 SfxMapUnit __EXPORT ScDocumentPool::GetMetric( sal_uInt16 nWhich ) const
1049 {
1050 	//	eigene Attribute: Twips, alles andere 1/100 mm
1051 
1052 	if ( nWhich >= ATTR_STARTINDEX && nWhich <= ATTR_ENDINDEX )
1053 		return SFX_MAPUNIT_TWIP;
1054 	else
1055 		return SFX_MAPUNIT_100TH_MM;
1056 }
1057 
1058 
1059 
1060 
1061 
1062