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