Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / core / data / docpool.cxx
blob1f8b8724192830d73ad7452332cd8c42865f2fca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "scitems.hxx"
22 #include <comphelper/string.hxx>
23 #include <tools/shl.hxx>
24 #include <vcl/outdev.hxx>
25 #include <svl/aeitem.hxx>
26 #include <svl/itemiter.hxx>
27 #include <svl/stritem.hxx>
28 #include <svx/algitem.hxx>
29 #include <editeng/boxitem.hxx>
30 #include <editeng/lineitem.hxx>
31 #include <editeng/brushitem.hxx>
32 #include <editeng/charreliefitem.hxx>
33 #include <editeng/contouritem.hxx>
34 #include <editeng/colritem.hxx>
35 #include <editeng/crossedoutitem.hxx>
36 #include <svx/dialmgr.hxx>
37 #include <editeng/emphasismarkitem.hxx>
38 #include <editeng/fhgtitem.hxx>
39 #include <editeng/fontitem.hxx>
40 #include <editeng/forbiddenruleitem.hxx>
41 #include <editeng/frmdiritem.hxx>
42 #include <editeng/hngpnctitem.hxx>
43 #include <editeng/itemtype.hxx>
44 #include <editeng/langitem.hxx>
45 #include <editeng/lrspitem.hxx>
46 #include <svx/pageitem.hxx>
47 #include <editeng/pbinitem.hxx>
48 #include <editeng/postitem.hxx>
49 #include <svx/rotmodit.hxx>
50 #include <editeng/scriptspaceitem.hxx>
51 #include <editeng/shaditem.hxx>
52 #include <editeng/shdditem.hxx>
53 #include <editeng/sizeitem.hxx>
54 #include <svx/svxitems.hrc>
55 #include <editeng/udlnitem.hxx>
56 #include <editeng/ulspitem.hxx>
57 #include <editeng/wghtitem.hxx>
58 #include <editeng/wrlmitem.hxx>
59 #include <editeng/xmlcnitm.hxx>
60 #include <editeng/justifyitem.hxx>
62 #include "docpool.hxx"
63 #include "global.hxx"
64 #include "attrib.hxx"
65 #include "patattr.hxx"
66 #include "globstr.hrc"
67 #include "sc.hrc"
69 #define SC_MAX_POOLREF (SFX_ITEMS_OLD_MAXREF - 39)
70 #define SC_SAFE_POOLREF (SC_MAX_POOLREF + 20)
72 // STATIC DATA -----------------------------------------------------------
74 sal_uInt16* ScDocumentPool::pVersionMap1 = 0;
75 sal_uInt16* ScDocumentPool::pVersionMap2 = 0;
76 sal_uInt16* ScDocumentPool::pVersionMap3 = 0;
77 sal_uInt16* ScDocumentPool::pVersionMap4 = 0;
78 sal_uInt16* ScDocumentPool::pVersionMap5 = 0;
79 sal_uInt16* ScDocumentPool::pVersionMap6 = 0;
80 sal_uInt16* ScDocumentPool::pVersionMap7 = 0;
81 sal_uInt16* ScDocumentPool::pVersionMap8 = 0;
82 sal_uInt16* ScDocumentPool::pVersionMap9 = 0;
83 sal_uInt16* ScDocumentPool::pVersionMap10 = 0;
84 sal_uInt16* ScDocumentPool::pVersionMap11 = 0;
85 sal_uInt16* ScDocumentPool::pVersionMap12 = 0;
87 // ATTR_FONT_TWOLINES (not used) was changed to ATTR_USERDEF (not saved in binary format) in 641c
89 static SfxItemInfo const aItemInfos[] =
91 { SID_ATTR_CHAR_FONT, SFX_ITEM_POOLABLE }, // ATTR_FONT
92 { SID_ATTR_CHAR_FONTHEIGHT, SFX_ITEM_POOLABLE }, // ATTR_FONT_HEIGHT
93 { SID_ATTR_CHAR_WEIGHT, SFX_ITEM_POOLABLE }, // ATTR_FONT_WEIGHT
94 { SID_ATTR_CHAR_POSTURE, SFX_ITEM_POOLABLE }, // ATTR_FONT_POSTURE
95 { SID_ATTR_CHAR_UNDERLINE, SFX_ITEM_POOLABLE }, // ATTR_FONT_UNDERLINE
96 { SID_ATTR_CHAR_OVERLINE, SFX_ITEM_POOLABLE }, // ATTR_FONT_OVERLINE
97 { SID_ATTR_CHAR_STRIKEOUT, SFX_ITEM_POOLABLE }, // ATTR_FONT_CROSSEDOUT
98 { SID_ATTR_CHAR_CONTOUR, SFX_ITEM_POOLABLE }, // ATTR_FONT_CONTOUR
99 { SID_ATTR_CHAR_SHADOWED, SFX_ITEM_POOLABLE }, // ATTR_FONT_SHADOWED
100 { SID_ATTR_CHAR_COLOR, SFX_ITEM_POOLABLE }, // ATTR_FONT_COLOR
101 { SID_ATTR_CHAR_LANGUAGE, SFX_ITEM_POOLABLE }, // ATTR_FONT_LANGUAGE
102 { SID_ATTR_CHAR_CJK_FONT, SFX_ITEM_POOLABLE }, // ATTR_CJK_FONT from 614
103 { SID_ATTR_CHAR_CJK_FONTHEIGHT, SFX_ITEM_POOLABLE }, // ATTR_CJK_FONT_HEIGHT from 614
104 { SID_ATTR_CHAR_CJK_WEIGHT, SFX_ITEM_POOLABLE }, // ATTR_CJK_FONT_WEIGHT from 614
105 { SID_ATTR_CHAR_CJK_POSTURE, SFX_ITEM_POOLABLE }, // ATTR_CJK_FONT_POSTURE from 614
106 { SID_ATTR_CHAR_CJK_LANGUAGE, SFX_ITEM_POOLABLE }, // ATTR_CJK_FONT_LANGUAGE from 614
107 { SID_ATTR_CHAR_CTL_FONT, SFX_ITEM_POOLABLE }, // ATTR_CTL_FONT from 614
108 { SID_ATTR_CHAR_CTL_FONTHEIGHT, SFX_ITEM_POOLABLE }, // ATTR_CTL_FONT_HEIGHT from 614
109 { SID_ATTR_CHAR_CTL_WEIGHT, SFX_ITEM_POOLABLE }, // ATTR_CTL_FONT_WEIGHT from 614
110 { SID_ATTR_CHAR_CTL_POSTURE, SFX_ITEM_POOLABLE }, // ATTR_CTL_FONT_POSTURE from 614
111 { SID_ATTR_CHAR_CTL_LANGUAGE, SFX_ITEM_POOLABLE }, // ATTR_CTL_FONT_LANGUAGE from 614
112 { SID_ATTR_CHAR_EMPHASISMARK, SFX_ITEM_POOLABLE }, // ATTR_FONT_EMPHASISMARK from 614
113 { 0, SFX_ITEM_POOLABLE }, // ATTR_USERDEF from 614 / 641c
114 { SID_ATTR_CHAR_WORDLINEMODE, SFX_ITEM_POOLABLE }, // ATTR_FONT_WORDLINE from 632b
115 { SID_ATTR_CHAR_RELIEF, SFX_ITEM_POOLABLE }, // ATTR_FONT_RELIEF from 632b
116 { SID_ATTR_ALIGN_HYPHENATION, SFX_ITEM_POOLABLE }, // ATTR_HYPHENATE from 632b
117 { 0, SFX_ITEM_POOLABLE }, // ATTR_SCRIPTSPACE from 614d
118 { 0, SFX_ITEM_POOLABLE }, // ATTR_HANGPUNCTUATION from 614d
119 { SID_ATTR_PARA_FORBIDDEN_RULES,SFX_ITEM_POOLABLE }, // ATTR_FORBIDDEN_RULES from 614d
120 { SID_ATTR_ALIGN_HOR_JUSTIFY, SFX_ITEM_POOLABLE }, // ATTR_HOR_JUSTIFY
121 { SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD, SFX_ITEM_POOLABLE }, // ATTR_HOR_JUSTIFY_METHOD
122 { SID_ATTR_ALIGN_INDENT, SFX_ITEM_POOLABLE }, // ATTR_INDENT ab 350
123 { SID_ATTR_ALIGN_VER_JUSTIFY, SFX_ITEM_POOLABLE }, // ATTR_VER_JUSTIFY
124 { SID_ATTR_ALIGN_VER_JUSTIFY_METHOD, SFX_ITEM_POOLABLE }, // ATTR_VER_JUSTIFY_METHOD
125 { SID_ATTR_ALIGN_STACKED, SFX_ITEM_POOLABLE }, // ATTR_STACKED from 680/dr14 (replaces ATTR_ORIENTATION)
126 { SID_ATTR_ALIGN_DEGREES, SFX_ITEM_POOLABLE }, // ATTR_ROTATE_VALUE ab 367
127 { SID_ATTR_ALIGN_LOCKPOS, SFX_ITEM_POOLABLE }, // ATTR_ROTATE_MODE ab 367
128 { SID_ATTR_ALIGN_ASIANVERTICAL, SFX_ITEM_POOLABLE }, // ATTR_VERTICAL_ASIAN from 642
129 { SID_ATTR_FRAMEDIRECTION, SFX_ITEM_POOLABLE }, // ATTR_WRITINGDIR from 643
130 { SID_ATTR_ALIGN_LINEBREAK, SFX_ITEM_POOLABLE }, // ATTR_LINEBREAK
131 { SID_ATTR_ALIGN_SHRINKTOFIT, SFX_ITEM_POOLABLE }, // ATTR_SHRINKTOFIT from 680/dr14
132 { SID_ATTR_BORDER_DIAG_TLBR, SFX_ITEM_POOLABLE }, // ATTR_BORDER_TLBR from 680/dr14
133 { SID_ATTR_BORDER_DIAG_BLTR, SFX_ITEM_POOLABLE }, // ATTR_BORDER_BLTR from 680/dr14
134 { SID_ATTR_ALIGN_MARGIN, SFX_ITEM_POOLABLE }, // ATTR_MARGIN
135 { 0, SFX_ITEM_POOLABLE }, // ATTR_MERGE
136 { 0, SFX_ITEM_POOLABLE }, // ATTR_MERGE_FLAG
137 { SID_ATTR_NUMBERFORMAT_VALUE, SFX_ITEM_POOLABLE }, // ATTR_VALUE_FORMAT
138 { ATTR_LANGUAGE_FORMAT, SFX_ITEM_POOLABLE }, // ATTR_LANGUAGE_FORMAT ab 329, wird im Dialog mit SID_ATTR_NUMBERFORMAT_VALUE kombiniert
139 { SID_ATTR_BRUSH, SFX_ITEM_POOLABLE }, // ATTR_BACKGROUND
140 { SID_SCATTR_PROTECTION, SFX_ITEM_POOLABLE }, // ATTR_PROTECTION
141 { SID_ATTR_BORDER_OUTER, SFX_ITEM_POOLABLE }, // ATTR_BORDER
142 { SID_ATTR_BORDER_INNER, SFX_ITEM_POOLABLE }, // ATTR_BORDER_INNER
143 { SID_ATTR_BORDER_SHADOW, SFX_ITEM_POOLABLE }, // ATTR_SHADOW
144 { 0, SFX_ITEM_POOLABLE }, // ATTR_VALIDDATA
145 { 0, SFX_ITEM_POOLABLE }, // ATTR_CONDITIONAL
146 { 0, SFX_ITEM_POOLABLE }, // ATTR_HYPERLINK
147 { 0, SFX_ITEM_POOLABLE }, // ATTR_PATTERN
148 { SID_ATTR_LRSPACE, SFX_ITEM_POOLABLE }, // ATTR_LRSPACE
149 { SID_ATTR_ULSPACE, SFX_ITEM_POOLABLE }, // ATTR_ULSPACE
150 { SID_ATTR_PAGE, SFX_ITEM_POOLABLE }, // ATTR_PAGE
151 { 0, SFX_ITEM_POOLABLE }, // ATTR_PAGE_PAPERTRAY, seit 303 nur noch dummy
152 { SID_ATTR_PAGE_PAPERBIN, SFX_ITEM_POOLABLE }, // ATTR_PAGE_PAPERBIN
153 { SID_ATTR_PAGE_SIZE, SFX_ITEM_POOLABLE }, // ATTR_PAGE_SIZE
154 { SID_ATTR_PAGE_MAXSIZE, SFX_ITEM_POOLABLE }, // ATTR_PAGE_MAXSIZE
155 { SID_ATTR_PAGE_EXT1, SFX_ITEM_POOLABLE }, // ATTR_PAGE_HORCENTER
156 { SID_ATTR_PAGE_EXT2, SFX_ITEM_POOLABLE }, // ATTR_PAGE_VERCENTER
157 { SID_ATTR_PAGE_ON, SFX_ITEM_POOLABLE }, // ATTR_PAGE_ON
158 { SID_ATTR_PAGE_DYNAMIC, SFX_ITEM_POOLABLE }, // ATTR_PAGE_DYNAMIC
159 { SID_ATTR_PAGE_SHARED, SFX_ITEM_POOLABLE }, // ATTR_PAGE_SHARED
160 { SID_SCATTR_PAGE_NOTES, SFX_ITEM_POOLABLE }, // ATTR_PAGE_NOTES
161 { SID_SCATTR_PAGE_GRID, SFX_ITEM_POOLABLE }, // ATTR_PAGE_GRID
162 { SID_SCATTR_PAGE_HEADERS, SFX_ITEM_POOLABLE }, // ATTR_PAGE_HEADERS
163 { SID_SCATTR_PAGE_CHARTS, SFX_ITEM_POOLABLE }, // ATTR_PAGE_CHARTS
164 { SID_SCATTR_PAGE_OBJECTS, SFX_ITEM_POOLABLE }, // ATTR_PAGE_OBJECTS
165 { SID_SCATTR_PAGE_DRAWINGS, SFX_ITEM_POOLABLE }, // ATTR_PAGE_DRAWINGS
166 { SID_SCATTR_PAGE_TOPDOWN, SFX_ITEM_POOLABLE }, // ATTR_PAGE_TOPDOWN
167 { SID_SCATTR_PAGE_SCALE, SFX_ITEM_POOLABLE }, // ATTR_PAGE_SCALE
168 { SID_SCATTR_PAGE_SCALETOPAGES, SFX_ITEM_POOLABLE }, // ATTR_PAGE_SCALETOPAGES
169 { SID_SCATTR_PAGE_FIRSTPAGENO, SFX_ITEM_POOLABLE }, // ATTR_PAGE_FIRSTPAGENO
170 { SID_SCATTR_PAGE_PRINTAREA, SFX_ITEM_POOLABLE }, // ATTR_PAGE_PRINTAREA
171 { SID_SCATTR_PAGE_REPEATROW, SFX_ITEM_POOLABLE }, // ATTR_PAGE_REPEATROW
172 { SID_SCATTR_PAGE_REPEATCOL, SFX_ITEM_POOLABLE }, // ATTR_PAGE_REPEATCOL
173 { SID_SCATTR_PAGE_PRINTTABLES, SFX_ITEM_POOLABLE }, // ATTR_PAGE_PRINTTABLES
174 { SID_SCATTR_PAGE_HEADERLEFT, SFX_ITEM_POOLABLE }, // ATTR_PAGE_HEADERLEFT
175 { SID_SCATTR_PAGE_FOOTERLEFT, SFX_ITEM_POOLABLE }, // ATTR_PAGE_FOOTERLEFT
176 { SID_SCATTR_PAGE_HEADERRIGHT, SFX_ITEM_POOLABLE }, // ATTR_PAGE_HEADERRIGHT
177 { SID_SCATTR_PAGE_FOOTERRIGHT, SFX_ITEM_POOLABLE }, // ATTR_PAGE_FOOTERRIGHT
178 { SID_ATTR_PAGE_HEADERSET, SFX_ITEM_POOLABLE }, // ATTR_PAGE_HEADERSET
179 { SID_ATTR_PAGE_FOOTERSET, SFX_ITEM_POOLABLE }, // ATTR_PAGE_FOOTERSET
180 { SID_SCATTR_PAGE_FORMULAS, SFX_ITEM_POOLABLE }, // ATTR_PAGE_FORMULAS
181 { SID_SCATTR_PAGE_NULLVALS, SFX_ITEM_POOLABLE }, // ATTR_PAGE_NULLVALS
182 { SID_SCATTR_PAGE_SCALETO, SFX_ITEM_POOLABLE }, // ATTR_PAGE_SCALETO
183 { SID_SCGRIDSHOW, SFX_ITEM_POOLABLE }
186 // -----------------------------------------------------------------------
188 ScDocumentPool::ScDocumentPool( SfxItemPool* pSecPool, sal_Bool bLoadRefCounts )
190 : SfxItemPool ( OUString("ScDocumentPool"),
191 ATTR_STARTINDEX, ATTR_ENDINDEX,
192 aItemInfos, NULL, bLoadRefCounts ),
193 pSecondary ( pSecPool )
195 // latin font from GetDefaultFonts is not used, DEFAULTFONT_LATIN_SPREADSHEET instead
196 Font aStdFont = OutputDevice::GetDefaultFont( DEFAULTFONT_LATIN_SPREADSHEET, LANGUAGE_ENGLISH_US,
197 DEFAULTFONT_FLAGS_ONLYONE );
198 SvxFontItem* pStdFont = new SvxFontItem( aStdFont.GetFamily(),
199 aStdFont.GetName(), aStdFont.GetStyleName(),
200 aStdFont.GetPitch(), aStdFont.GetCharSet(),
201 ATTR_FONT );
203 SvxFontItem* pCjkFont = new SvxFontItem( ATTR_CJK_FONT );
204 SvxFontItem* pCtlFont = new SvxFontItem( ATTR_CTL_FONT );
205 SvxFontItem aDummy( ATTR_FONT );
206 GetDefaultFonts( aDummy, *pCjkFont, *pCtlFont );
208 SvxBoxInfoItem* pGlobalBorderInnerAttr = new SvxBoxInfoItem( ATTR_BORDER_INNER );
209 SfxItemSet* pSet = new SfxItemSet( *this, ATTR_PATTERN_START, ATTR_PATTERN_END );
210 SfxItemSet aSetItemItemSet( *this,
211 ATTR_BACKGROUND, ATTR_BACKGROUND,
212 ATTR_BORDER, ATTR_SHADOW,
213 ATTR_LRSPACE, ATTR_ULSPACE,
214 ATTR_PAGE_SIZE, ATTR_PAGE_SIZE,
215 ATTR_PAGE_ON, ATTR_PAGE_SHARED,
216 0 );
218 pGlobalBorderInnerAttr->SetLine(NULL, BOXINFO_LINE_HORI);
219 pGlobalBorderInnerAttr->SetLine(NULL, BOXINFO_LINE_VERT);
220 pGlobalBorderInnerAttr->SetTable(sal_True);
221 pGlobalBorderInnerAttr->SetDist(sal_True);
222 pGlobalBorderInnerAttr->SetMinDist(false);
224 ppPoolDefaults = new SfxPoolItem*[ATTR_ENDINDEX-ATTR_STARTINDEX+1];
226 ppPoolDefaults[ ATTR_FONT - ATTR_STARTINDEX ] = pStdFont;
227 ppPoolDefaults[ ATTR_FONT_HEIGHT - ATTR_STARTINDEX ] = new SvxFontHeightItem( 200, 100, ATTR_FONT_HEIGHT ); // 10 pt;
228 ppPoolDefaults[ ATTR_FONT_WEIGHT - ATTR_STARTINDEX ] = new SvxWeightItem( WEIGHT_NORMAL, ATTR_FONT_WEIGHT );
229 ppPoolDefaults[ ATTR_FONT_POSTURE - ATTR_STARTINDEX ] = new SvxPostureItem( ITALIC_NONE, ATTR_FONT_POSTURE );
230 ppPoolDefaults[ ATTR_FONT_UNDERLINE - ATTR_STARTINDEX ] = new SvxUnderlineItem( UNDERLINE_NONE, ATTR_FONT_UNDERLINE );
231 ppPoolDefaults[ ATTR_FONT_OVERLINE - ATTR_STARTINDEX ] = new SvxOverlineItem( UNDERLINE_NONE, ATTR_FONT_OVERLINE );
232 ppPoolDefaults[ ATTR_FONT_CROSSEDOUT - ATTR_STARTINDEX ] = new SvxCrossedOutItem( STRIKEOUT_NONE, ATTR_FONT_CROSSEDOUT );
233 ppPoolDefaults[ ATTR_FONT_CONTOUR - ATTR_STARTINDEX ] = new SvxContourItem( false, ATTR_FONT_CONTOUR );
234 ppPoolDefaults[ ATTR_FONT_SHADOWED - ATTR_STARTINDEX ] = new SvxShadowedItem( false, ATTR_FONT_SHADOWED );
235 ppPoolDefaults[ ATTR_FONT_COLOR - ATTR_STARTINDEX ] = new SvxColorItem( Color(COL_AUTO), ATTR_FONT_COLOR );
236 ppPoolDefaults[ ATTR_FONT_LANGUAGE - ATTR_STARTINDEX ] = new SvxLanguageItem( LanguageType(LANGUAGE_DONTKNOW), ATTR_FONT_LANGUAGE );
237 ppPoolDefaults[ ATTR_CJK_FONT - ATTR_STARTINDEX ] = pCjkFont;
238 ppPoolDefaults[ ATTR_CJK_FONT_HEIGHT - ATTR_STARTINDEX ] = new SvxFontHeightItem( 200, 100, ATTR_CJK_FONT_HEIGHT );
239 ppPoolDefaults[ ATTR_CJK_FONT_WEIGHT - ATTR_STARTINDEX ] = new SvxWeightItem( WEIGHT_NORMAL, ATTR_CJK_FONT_WEIGHT );
240 ppPoolDefaults[ ATTR_CJK_FONT_POSTURE- ATTR_STARTINDEX ] = new SvxPostureItem( ITALIC_NONE, ATTR_CJK_FONT_POSTURE );
241 ppPoolDefaults[ ATTR_CJK_FONT_LANGUAGE-ATTR_STARTINDEX ] = new SvxLanguageItem( LanguageType(LANGUAGE_DONTKNOW),
242 ATTR_CJK_FONT_LANGUAGE );
243 ppPoolDefaults[ ATTR_CTL_FONT - ATTR_STARTINDEX ] = pCtlFont;
244 ppPoolDefaults[ ATTR_CTL_FONT_HEIGHT - ATTR_STARTINDEX ] = new SvxFontHeightItem( 200, 100, ATTR_CTL_FONT_HEIGHT );
245 ppPoolDefaults[ ATTR_CTL_FONT_WEIGHT - ATTR_STARTINDEX ] = new SvxWeightItem( WEIGHT_NORMAL, ATTR_CTL_FONT_WEIGHT );
246 ppPoolDefaults[ ATTR_CTL_FONT_POSTURE- ATTR_STARTINDEX ] = new SvxPostureItem( ITALIC_NONE, ATTR_CTL_FONT_POSTURE );
247 ppPoolDefaults[ ATTR_CTL_FONT_LANGUAGE-ATTR_STARTINDEX ] = new SvxLanguageItem( LanguageType(LANGUAGE_DONTKNOW),
248 ATTR_CTL_FONT_LANGUAGE );
249 ppPoolDefaults[ ATTR_FONT_EMPHASISMARK-ATTR_STARTINDEX ] = new SvxEmphasisMarkItem( EMPHASISMARK_NONE, ATTR_FONT_EMPHASISMARK );
250 ppPoolDefaults[ ATTR_USERDEF - ATTR_STARTINDEX ] = new SvXMLAttrContainerItem( ATTR_USERDEF );
251 ppPoolDefaults[ ATTR_FONT_WORDLINE - ATTR_STARTINDEX ] = new SvxWordLineModeItem(false, ATTR_FONT_WORDLINE );
252 ppPoolDefaults[ ATTR_FONT_RELIEF - ATTR_STARTINDEX ] = new SvxCharReliefItem( RELIEF_NONE, ATTR_FONT_RELIEF );
253 ppPoolDefaults[ ATTR_HYPHENATE - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_HYPHENATE );
254 ppPoolDefaults[ ATTR_SCRIPTSPACE - ATTR_STARTINDEX ] = new SvxScriptSpaceItem( false, ATTR_SCRIPTSPACE);
255 ppPoolDefaults[ ATTR_HANGPUNCTUATION - ATTR_STARTINDEX ] = new SvxHangingPunctuationItem( false, ATTR_HANGPUNCTUATION);
256 ppPoolDefaults[ ATTR_FORBIDDEN_RULES - ATTR_STARTINDEX ] = new SvxForbiddenRuleItem( false, ATTR_FORBIDDEN_RULES);
257 ppPoolDefaults[ ATTR_HOR_JUSTIFY - ATTR_STARTINDEX ] = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY);
258 ppPoolDefaults[ ATTR_HOR_JUSTIFY_METHOD - ATTR_STARTINDEX ] = new SvxJustifyMethodItem( SVX_JUSTIFY_METHOD_AUTO, ATTR_HOR_JUSTIFY_METHOD);
259 ppPoolDefaults[ ATTR_INDENT - ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_INDENT, 0 );
260 ppPoolDefaults[ ATTR_VER_JUSTIFY - ATTR_STARTINDEX ] = new SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD, ATTR_VER_JUSTIFY);
261 ppPoolDefaults[ ATTR_VER_JUSTIFY_METHOD - ATTR_STARTINDEX ] = new SvxJustifyMethodItem( SVX_JUSTIFY_METHOD_AUTO, ATTR_VER_JUSTIFY_METHOD);
262 ppPoolDefaults[ ATTR_STACKED - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_STACKED, 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 ScCondFormatItem;
286 ppPoolDefaults[ ATTR_HYPERLINK - ATTR_STARTINDEX ] = new SfxStringItem( ATTR_HYPERLINK, OUString() ) ;
288 // GetRscString funktioniert erst nach ScGlobal::Init, zu erkennen am EmptyBrushItem
289 //! zusaetzliche Methode ScGlobal::IsInit() oder so...
290 //! oder erkennen, ob dies der Secondary-Pool fuer einen MessagePool ist
291 if ( ScGlobal::GetEmptyBrushItem() )
292 ppPoolDefaults[ ATTR_PATTERN - ATTR_STARTINDEX ] = new ScPatternAttr( pSet, ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
293 else
294 ppPoolDefaults[ ATTR_PATTERN - ATTR_STARTINDEX ] = new ScPatternAttr( pSet,
295 OUString(STRING_STANDARD) ); //! without name?
297 ppPoolDefaults[ ATTR_LRSPACE - ATTR_STARTINDEX ] = new SvxLRSpaceItem( ATTR_LRSPACE );
298 ppPoolDefaults[ ATTR_ULSPACE - ATTR_STARTINDEX ] = new SvxULSpaceItem( ATTR_ULSPACE );
299 ppPoolDefaults[ ATTR_PAGE - ATTR_STARTINDEX ] = new SvxPageItem( ATTR_PAGE );
300 ppPoolDefaults[ ATTR_PAGE_PAPERTRAY - ATTR_STARTINDEX ] = new SfxAllEnumItem( ATTR_PAGE_PAPERTRAY );
301 ppPoolDefaults[ ATTR_PAGE_PAPERBIN - ATTR_STARTINDEX ] = new SvxPaperBinItem( ATTR_PAGE_PAPERBIN );
302 ppPoolDefaults[ ATTR_PAGE_SIZE - ATTR_STARTINDEX ] = new SvxSizeItem( ATTR_PAGE_SIZE );
303 ppPoolDefaults[ ATTR_PAGE_MAXSIZE - ATTR_STARTINDEX ] = new SvxSizeItem( ATTR_PAGE_MAXSIZE );
304 ppPoolDefaults[ ATTR_PAGE_HORCENTER - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_HORCENTER );
305 ppPoolDefaults[ ATTR_PAGE_VERCENTER - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_VERCENTER );
306 ppPoolDefaults[ ATTR_PAGE_ON - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_ON, sal_True );
307 ppPoolDefaults[ ATTR_PAGE_DYNAMIC - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_DYNAMIC, sal_True );
308 ppPoolDefaults[ ATTR_PAGE_SHARED - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_SHARED, sal_True );
309 ppPoolDefaults[ ATTR_PAGE_NOTES - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_NOTES, false );
310 ppPoolDefaults[ ATTR_PAGE_GRID - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_GRID, false );
311 ppPoolDefaults[ ATTR_PAGE_HEADERS - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_HEADERS, false );
312 ppPoolDefaults[ ATTR_PAGE_CHARTS - ATTR_STARTINDEX ] = new ScViewObjectModeItem( ATTR_PAGE_CHARTS );
313 ppPoolDefaults[ ATTR_PAGE_OBJECTS - ATTR_STARTINDEX ] = new ScViewObjectModeItem( ATTR_PAGE_OBJECTS );
314 ppPoolDefaults[ ATTR_PAGE_DRAWINGS - ATTR_STARTINDEX ] = new ScViewObjectModeItem( ATTR_PAGE_DRAWINGS );
315 ppPoolDefaults[ ATTR_PAGE_TOPDOWN - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_TOPDOWN, sal_True );
316 ppPoolDefaults[ ATTR_PAGE_SCALE - ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_PAGE_SCALE, 100 );
317 ppPoolDefaults[ ATTR_PAGE_SCALETOPAGES-ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, 1 );
318 ppPoolDefaults[ ATTR_PAGE_FIRSTPAGENO- ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO, 1 );
319 ppPoolDefaults[ ATTR_PAGE_PRINTAREA - ATTR_STARTINDEX ] = new ScRangeItem( ATTR_PAGE_PRINTAREA );
320 ppPoolDefaults[ ATTR_PAGE_REPEATROW - ATTR_STARTINDEX ] = new ScRangeItem( ATTR_PAGE_REPEATROW );
321 ppPoolDefaults[ ATTR_PAGE_REPEATCOL - ATTR_STARTINDEX ] = new ScRangeItem( ATTR_PAGE_REPEATCOL );
322 ppPoolDefaults[ ATTR_PAGE_PRINTTABLES- ATTR_STARTINDEX ] = new ScTableListItem( ATTR_PAGE_PRINTTABLES );
323 ppPoolDefaults[ ATTR_PAGE_HEADERLEFT - ATTR_STARTINDEX ] = new ScPageHFItem( ATTR_PAGE_HEADERLEFT );
324 ppPoolDefaults[ ATTR_PAGE_FOOTERLEFT - ATTR_STARTINDEX ] = new ScPageHFItem( ATTR_PAGE_FOOTERLEFT );
325 ppPoolDefaults[ ATTR_PAGE_HEADERRIGHT- ATTR_STARTINDEX ] = new ScPageHFItem( ATTR_PAGE_HEADERRIGHT );
326 ppPoolDefaults[ ATTR_PAGE_FOOTERRIGHT- ATTR_STARTINDEX ] = new ScPageHFItem( ATTR_PAGE_FOOTERRIGHT );
327 ppPoolDefaults[ ATTR_PAGE_HEADERSET - ATTR_STARTINDEX ] = new SvxSetItem( ATTR_PAGE_HEADERSET, aSetItemItemSet );
328 ppPoolDefaults[ ATTR_PAGE_FOOTERSET - ATTR_STARTINDEX ] = new SvxSetItem( ATTR_PAGE_FOOTERSET, aSetItemItemSet );
329 ppPoolDefaults[ ATTR_PAGE_FORMULAS - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_FORMULAS, false );
330 ppPoolDefaults[ ATTR_PAGE_NULLVALS - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_PAGE_NULLVALS, sal_True );
331 ppPoolDefaults[ ATTR_PAGE_SCALETO - ATTR_STARTINDEX ] = new ScPageScaleToItem( 1, 1 );
332 ppPoolDefaults[ ATTR_HIDDEN - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_HIDDEN, sal_False );
334 SetDefaults( ppPoolDefaults );
336 if ( pSecondary )
337 SetSecondaryPool( pSecondary );
339 // ATTR_LANGUAGE_FORMAT ab sv329 eingefuegt, VersionMap in _ScGlobal__Init
340 SetVersionMap( 1, 100, 157, pVersionMap1 );
342 // ATTR_VALIDDATA, ATTR_CONDITIONAL ab 341
343 SetVersionMap( 2, 100, 158, pVersionMap2 );
345 // ATTR_INDENT ab 350
346 SetVersionMap( 3, 100, 160, pVersionMap3 );
348 // ATTR_ROTATE_VALUE, ATTR_ROTATE_MODE ab 367
349 SetVersionMap( 4, 100, 161, pVersionMap4 );
351 // CJK, CTL, EMPHASISMARK, TWOLINES from 614
352 SetVersionMap( 5, 100, 163, pVersionMap5 );
354 // ATTR_SCRIPTSPACE, ATTR_HANGPUNCTUATION, ATTR_FORBIDDEN_RULES from 614d
355 SetVersionMap( 6, 100, 175, pVersionMap6 );
357 // ATTR_FONT_WORDLINE, ATTR_FONT_RELIEF, ATTR_HYPHENATE from 632b
358 SetVersionMap( 7, 100, 178, pVersionMap7 );
360 // ATTR_VERTICAL_ASIAN from 642q
361 SetVersionMap( 8, 100, 181, pVersionMap8 );
363 // ATTR_WRITINGDIR from 643y
364 SetVersionMap( 9, 100, 182, pVersionMap9 );
366 // ATTR_PAGE_SCALETO added in 680/sab008
367 // new version map not required
369 // ATTR_SHRINKTOFIT, ATTR_BORDER_TL_BR, ATTR_BORDER_BL_TR added in 680/dr14
370 SetVersionMap( 10, 100, 184, pVersionMap10 );
372 // ATTR_FONT_OVERLINE added in DEV300/overline2
373 SetVersionMap( 11, 100, 187, pVersionMap11 );
374 // ATTR_HYERLINK added
375 SetVersionMap( 12, 100, 192, pVersionMap12 );
378 ScDocumentPool::~ScDocumentPool()
380 Delete();
382 for ( sal_uInt16 i=0; i < ATTR_ENDINDEX-ATTR_STARTINDEX+1; i++ )
384 SetRefCount( *ppPoolDefaults[i], 0 );
385 delete ppPoolDefaults[i];
388 delete[] ppPoolDefaults;
389 SfxItemPool::Free(pSecondary);
392 void ScDocumentPool::InitVersionMaps()
394 OSL_PRECOND( !pVersionMap1 && !pVersionMap2 &&
395 !pVersionMap3 && !pVersionMap4 &&
396 !pVersionMap5 && !pVersionMap6 &&
397 !pVersionMap7 && !pVersionMap8 &&
398 !pVersionMap9 && !pVersionMap10 &&
399 !pVersionMap11 && !pVersionMap12 , "InitVersionMaps call multiple times" );
401 // alte WhichId's mappen
402 // nicht mit ATTR_* zaehlen, falls die sich nochmal aendern
404 // erste Map: ATTR_LANGUAGE_FORMAT ab sv329 eingefuegt
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;
418 // zweite Map: ATTR_VALIDDATA und ATTR_CONDITIONAL ab 341 eingefuegt
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;
431 // dritte Map: ATTR_INDENT ab 350 eingefuegt
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;
444 // vierte Map: ATTR_ROTATE_VALUE und ATTR_ROTATE_MODE ab 367 eingefuegt
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;
457 // fifth map: CJK..., CTL..., EMPHASISMARK, TWOLINES (12 items) added in 614
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;
470 // sixth map: ATTR_SCRIPTSPACE, ATTR_HANGPUNCTUATION, ATTR_FORBIDDEN_RULES added in 614d
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;
483 // seventh map: ATTR_FONT_WORDLINE, ATTR_FONT_RELIEF, ATTR_HYPHENATE added in 632b
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;
496 // eighth map: ATTR_VERTICAL_ASIAN added in 642q
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;
509 // 9th map: ATTR_WRITINGDIR added in 643y
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;
522 // ATTR_PAGE_SCALETO added in 680/sab008
524 // 10th map: ATTR_SHRINKTOFIT, ATTR_BORDER_TL_BR, ATTR_BORDER_BL_TR added in 680/dr14
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;
537 // 11th map: ATTR_FONT_OVERLINE added in DEV300/overline2
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;
550 const sal_uInt16 nMap12Start = 100; // ATTR_STARTINDEX
551 const sal_uInt16 nMap12End = 192; // ATTR_ENDINDEX
552 const sal_uInt16 nMap12Count = nMap12End - nMap12Start + 1;
553 const sal_uInt16 nMap12New = 55; // ATTR_HYPERLINK - ATTR_STARTINDEX
554 pVersionMap12 = new sal_uInt16 [ nMap12Count ];
555 for ( i=0, j=nMap12Start; i < nMap12New; i++, j++ )
556 pVersionMap12[i] = j;
557 // 1 entry inserted
558 for ( i=nMap12New, j=nMap12Start+nMap12New+1; i < nMap12Count; i++, j++ )
559 pVersionMap12[i] = j;
562 void ScDocumentPool::DeleteVersionMaps()
564 OSL_PRECOND( pVersionMap1 && pVersionMap2 &&
565 pVersionMap3 && pVersionMap4 &&
566 pVersionMap5 && pVersionMap6 &&
567 pVersionMap7 && pVersionMap8 &&
568 pVersionMap9 && pVersionMap10 &&
569 pVersionMap11 && pVersionMap12 , "DeleteVersionMaps without maps" );
571 delete[] pVersionMap12;
572 pVersionMap12 = 0;
573 delete[] pVersionMap11;
574 pVersionMap11 = 0;
575 delete[] pVersionMap10;
576 pVersionMap10 = 0;
577 delete[] pVersionMap9;
578 pVersionMap9 = 0;
579 delete[] pVersionMap8;
580 pVersionMap8 = 0;
581 delete[] pVersionMap7;
582 pVersionMap7 = 0;
583 delete[] pVersionMap6;
584 pVersionMap6 = 0;
585 delete[] pVersionMap5;
586 pVersionMap5 = 0;
587 delete[] pVersionMap4;
588 pVersionMap4 = 0;
589 delete[] pVersionMap3;
590 pVersionMap3 = 0;
591 delete[] pVersionMap2;
592 pVersionMap2 = 0;
593 delete[] pVersionMap1;
594 pVersionMap1 = 0;
597 // ----------------------------------------------------------------------------------------
599 // Fuer die Pattern-Attribute (SetItems) kann der sal_uInt16 RefCount leicht ueberlaufen
600 // (z.B. 600 ganze Zeilen abwechselnd formatieren).
601 // Darum wird der RefCount bei SC_MAX_POOLREF festgehalten und nicht mehr hoch- oder
602 // heruntergezaehlt. Dieser RefCount wird dann erst beim naechsten Laden neu gezaehlt.
603 // Die Differenz zwischen SC_MAX_POOLREF und SC_SAFE_POOLREF ist ein wenig groesser
604 // als noetig, um zu erkennen, wenn der RefCount aus Versehen doch "normal" veraendert
605 // wird (Assertions).
608 const SfxPoolItem& ScDocumentPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich )
610 if ( rItem.Which() != ATTR_PATTERN ) // nur Pattern ist special
611 return SfxItemPool::Put( rItem, nWhich );
613 // das Default-Pattern dieses Pools nicht kopieren
614 if (&rItem == ppPoolDefaults[ ATTR_PATTERN - ATTR_STARTINDEX ])
615 return rItem;
617 // ansonsten muss Put immer passieren, weil es ein anderer Pool sein kann
618 const SfxPoolItem& rNew = SfxItemPool::Put( rItem, nWhich );
619 CheckRef( rNew );
620 return rNew;
623 void ScDocumentPool::Remove( const SfxPoolItem& rItem )
625 if ( rItem.Which() == ATTR_PATTERN ) // nur Pattern ist special
627 sal_uLong nRef = rItem.GetRefCount();
628 if ( nRef >= (sal_uLong) SC_MAX_POOLREF && nRef <= (sal_uLong) SFX_ITEMS_OLD_MAXREF )
630 if ( nRef != (sal_uLong) SC_SAFE_POOLREF )
632 OSL_FAIL("Who fiddles with my ref counts?");
633 SetRefCount( (SfxPoolItem&)rItem, (sal_uLong) SC_SAFE_POOLREF );
635 return; // nicht herunterzaehlen
638 SfxItemPool::Remove( rItem );
641 void ScDocumentPool::CheckRef( const SfxPoolItem& rItem )
643 sal_uLong nRef = rItem.GetRefCount();
644 if ( nRef >= (sal_uLong) SC_MAX_POOLREF && nRef <= (sal_uLong) SFX_ITEMS_OLD_MAXREF )
646 // beim Apply vom Cache wird evtl. um 2 hochgezaehlt (auf MAX+1 oder SAFE+2),
647 // heruntergezaehlt wird nur einzeln (in LoadCompleted)
648 OSL_ENSURE( nRef<=(sal_uLong)SC_MAX_POOLREF+1 || (nRef>=(sal_uLong)SC_SAFE_POOLREF-1 && nRef<=(sal_uLong)SC_SAFE_POOLREF+2),
649 "ScDocumentPool::CheckRef" );
650 SetRefCount( (SfxPoolItem&)rItem, (sal_uLong) SC_SAFE_POOLREF );
654 // ----------------------------------------------------------------------------------------
656 void ScDocumentPool::StyleDeleted( ScStyleSheet* pStyle )
658 sal_uInt32 nCount = GetItemCount2(ATTR_PATTERN);
659 for (sal_uInt32 i=0; i<nCount; i++)
661 ScPatternAttr* pPattern = (ScPatternAttr*)GetItem2(ATTR_PATTERN, i);
662 if ( pPattern && pPattern->GetStyleSheet() == pStyle )
663 pPattern->StyleToName();
667 void ScDocumentPool::CellStyleCreated( const OUString& rName )
669 // If a style was created, don't keep any pattern with its name string in the pool,
670 // because it would compare equal to a pattern with a pointer to the new style.
671 // Calling StyleSheetChanged isn't enough because the pool may still contain items
672 // for undo or clipboard content.
674 sal_uInt32 nCount = GetItemCount2(ATTR_PATTERN);
675 for (sal_uInt32 i=0; i<nCount; i++)
677 ScPatternAttr *const pPattern =
678 const_cast<ScPatternAttr*>(
679 static_cast<ScPatternAttr const*>(GetItem2(ATTR_PATTERN, i)));
680 if ( pPattern && pPattern->GetStyleSheet() == NULL )
682 const OUString* pStyleName = pPattern->GetStyleName();
683 if ( pStyleName && *pStyleName == rName )
684 pPattern->UpdateStyleSheet(); // find and store style pointer
689 SfxItemPool* ScDocumentPool::Clone() const
691 return new SfxItemPool (*this, sal_True);
694 static SfxItemPresentation lcl_HFPresentation
696 const SfxPoolItem& rItem,
697 SfxItemPresentation ePresentation,
698 SfxMapUnit eCoreMetric,
699 SfxMapUnit ePresentationMetric,
700 OUString& rText,
701 const IntlWrapper* pIntl
704 const SfxItemSet& rSet = ((const SfxSetItem&)rItem).GetItemSet();
705 const SfxPoolItem* pItem;
707 if ( SFX_ITEM_SET == rSet.GetItemState(ATTR_PAGE_ON,false,&pItem) )
709 if( false == ((const SfxBoolItem*)pItem)->GetValue() )
710 return SFX_ITEM_PRESENTATION_NONE;
713 SfxItemIter aIter( rSet );
714 pItem = aIter.FirstItem();
715 OUString aText;
716 OUString aDel(" + ");
718 while( pItem )
720 sal_uInt16 nWhich = pItem->Which();
722 aText = "";
724 switch( nWhich )
726 case ATTR_PAGE_ON:
727 case ATTR_PAGE_DYNAMIC:
728 case ATTR_PAGE_SHARED:
729 break;
731 case ATTR_LRSPACE:
733 SvxLRSpaceItem& rLRItem = (SvxLRSpaceItem&)*pItem;
734 sal_uInt16 nPropLeftMargin = rLRItem.GetPropLeft();
735 sal_uInt16 nPropRightMargin = rLRItem.GetPropRight();
736 sal_uInt16 nLeftMargin, nRightMargin;
737 long nTmp;
738 nTmp = rLRItem.GetLeft();
739 nLeftMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp);
740 nTmp = rLRItem.GetRight();
741 nRightMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp);
743 aText = EE_RESSTR(RID_SVXITEMS_LRSPACE_LEFT);
744 if ( 100 != nPropLeftMargin )
746 aText = aText + OUString::number( nPropLeftMargin ) + "%";
748 else
750 aText += GetMetricText( (long)nLeftMargin,
751 eCoreMetric, ePresentationMetric, pIntl );
752 aText += EE_RESSTR(GetMetricId(ePresentationMetric));
754 aText += cpDelim;
756 // nPropFirstLineOfst haben wir nicht
758 aText += EE_RESSTR(RID_SVXITEMS_LRSPACE_RIGHT);
759 if ( 100 != nPropRightMargin )
761 aText = aText + OUString::number( nPropLeftMargin ) + "%";
763 else
765 aText += GetMetricText( (long)nRightMargin,
766 eCoreMetric, ePresentationMetric, pIntl );
767 aText += EE_RESSTR(GetMetricId(ePresentationMetric));
770 break;
772 default:
773 if ( !pIntl )
774 pIntl = ScGlobal::GetScIntlWrapper();
775 pItem->GetPresentation( ePresentation, eCoreMetric, ePresentationMetric, aText, pIntl );
779 if ( aText.getLength() )
781 rText = rText + aText + aDel;
784 pItem = aIter.NextItem();
787 rText = comphelper::string::stripEnd(rText, ' ');
788 rText = comphelper::string::stripEnd(rText, '+');
789 rText = comphelper::string::stripEnd(rText, ' ');
790 return ePresentation;
793 SfxItemPresentation ScDocumentPool::GetPresentation(
794 const SfxPoolItem& rItem,
795 SfxItemPresentation ePresentation,
796 SfxMapUnit ePresentationMetric,
797 OUString& rText,
798 const IntlWrapper* pIntl ) const
800 sal_uInt16 nW = rItem.Which();
801 OUString aStrYes ( ScGlobal::GetRscString(STR_YES) );
802 OUString aStrNo ( ScGlobal::GetRscString(STR_NO) );
803 OUString aStrSep(": ");
805 switch( nW )
807 case ATTR_PAGE_TOPDOWN:
808 switch ( ePresentation )
810 case SFX_ITEM_PRESENTATION_COMPLETE:
811 rText = ScGlobal::GetRscString(STR_SCATTR_PAGE_PRINTDIR) + aStrSep;
812 // break; // DURCHFALLEN!!!
813 case SFX_ITEM_PRESENTATION_NAMELESS:
814 rText += ((const SfxBoolItem&)rItem).GetValue() ?
815 ScGlobal::GetRscString(STR_SCATTR_PAGE_TOPDOWN) :
816 ScGlobal::GetRscString(STR_SCATTR_PAGE_LEFTRIGHT) ;
817 break;
818 default:
820 // added to avoid warnings
823 break;
825 case ATTR_PAGE_HEADERS:
826 switch ( ePresentation )
828 case SFX_ITEM_PRESENTATION_COMPLETE:
829 rText = ScGlobal::GetRscString(STR_SCATTR_PAGE_HEADERS) + aStrSep;
830 // break; // DURCHFALLEN!!!
831 case SFX_ITEM_PRESENTATION_NAMELESS:
832 rText += ((const SfxBoolItem&)rItem).GetValue() ? aStrYes : aStrNo ;
833 break;
834 default:
836 // added to avoid warnings
839 break;
841 case ATTR_PAGE_NULLVALS:
842 switch ( ePresentation )
844 case SFX_ITEM_PRESENTATION_COMPLETE:
845 rText = ScGlobal::GetRscString(STR_SCATTR_PAGE_NULLVALS) + aStrSep;
846 // break; // DURCHFALLEN!!!
847 case SFX_ITEM_PRESENTATION_NAMELESS:
848 rText += ((const SfxBoolItem&)rItem).GetValue() ? aStrYes : aStrNo ;
849 break;
850 default:
852 // added to avoid warnings
855 break;
857 case ATTR_PAGE_FORMULAS:
858 switch ( ePresentation )
860 case SFX_ITEM_PRESENTATION_COMPLETE:
861 rText = ScGlobal::GetRscString(STR_SCATTR_PAGE_FORMULAS) + aStrSep;
862 // break; // DURCHFALLEN!!!
863 case SFX_ITEM_PRESENTATION_NAMELESS:
864 rText += ((const SfxBoolItem&)rItem).GetValue() ? aStrYes : aStrNo ;
865 break;
866 default:
868 // added to avoid warnings
871 break;
873 case ATTR_PAGE_NOTES:
874 switch ( ePresentation )
876 case SFX_ITEM_PRESENTATION_COMPLETE:
877 rText = ScGlobal::GetRscString(STR_SCATTR_PAGE_NOTES) + aStrSep;
878 // break; // DURCHFALLEN!!!
879 case SFX_ITEM_PRESENTATION_NAMELESS:
880 rText += ((const SfxBoolItem&)rItem).GetValue() ? aStrYes : aStrNo ;
881 break;
882 default:
884 // added to avoid warnings
887 break;
889 case ATTR_PAGE_GRID:
890 switch ( ePresentation )
892 case SFX_ITEM_PRESENTATION_COMPLETE:
893 rText = ScGlobal::GetRscString(STR_SCATTR_PAGE_GRID) + aStrSep;
894 // break; // DURCHFALLEN!!!
895 case SFX_ITEM_PRESENTATION_NAMELESS:
896 rText += ((const SfxBoolItem&)rItem).GetValue() ? aStrYes : aStrNo ;
897 break;
898 default:
900 // added to avoid warnings
903 break;
905 case ATTR_PAGE_SCALETOPAGES:
907 sal_uInt16 nPagNo = ((const SfxUInt16Item&)rItem).GetValue();
909 if( nPagNo )
911 switch ( ePresentation )
913 case SFX_ITEM_PRESENTATION_COMPLETE:
915 rText = ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALETOPAGES ) + aStrSep;
917 // break; // DURCHFALLEN!!!
918 case SFX_ITEM_PRESENTATION_NAMELESS:
920 OUString aPages( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_PAGES ) );
921 aPages = aPages.replaceFirst( "%1", OUString::number( nPagNo ) );
922 rText += aPages;
924 break;
925 default:
927 // added to avoid warnings
931 else
933 ePresentation = SFX_ITEM_PRESENTATION_NONE;
936 break;
938 case ATTR_PAGE_FIRSTPAGENO:
940 sal_uInt16 nPagNo = ((const SfxUInt16Item&)rItem).GetValue();
942 if( nPagNo )
944 switch ( ePresentation )
946 case SFX_ITEM_PRESENTATION_COMPLETE:
947 rText = ScGlobal::GetRscString(STR_SCATTR_PAGE_FIRSTPAGENO) + aStrSep;
948 // break; // DURCHFALLEN!!!
949 case SFX_ITEM_PRESENTATION_NAMELESS:
950 rText += OUString::number( nPagNo );
951 break;
952 default:
954 // added to avoid warnings
958 else
960 ePresentation = SFX_ITEM_PRESENTATION_NONE;
963 break;
965 case ATTR_PAGE_SCALE:
967 sal_uInt16 nPercent = ((const SfxUInt16Item&)rItem).GetValue();
969 if( nPercent )
971 switch ( ePresentation )
973 case SFX_ITEM_PRESENTATION_COMPLETE:
974 rText = ScGlobal::GetRscString(STR_SCATTR_PAGE_SCALE) + aStrSep;
975 // break; // DURCHFALLEN!!!
976 case SFX_ITEM_PRESENTATION_NAMELESS:
977 rText = rText + OUString::number( nPercent ) + "%";
978 break;
979 default:
981 // added to avoid warnings
985 else
987 ePresentation = SFX_ITEM_PRESENTATION_NONE;
990 break;
992 case ATTR_PAGE_HEADERSET:
994 OUString aBuffer;
996 if( lcl_HFPresentation( rItem, ePresentation, GetMetric( nW ), ePresentationMetric, aBuffer, pIntl ) != SFX_ITEM_PRESENTATION_NONE )
998 rText = ScGlobal::GetRscString(STR_HEADER) + " ( " + aBuffer + " ) ";
1001 break;
1003 case ATTR_PAGE_FOOTERSET:
1005 OUString aBuffer;
1007 if( lcl_HFPresentation( rItem, ePresentation, GetMetric( nW ), ePresentationMetric, aBuffer, pIntl ) != SFX_ITEM_PRESENTATION_NONE )
1009 rText = ScGlobal::GetRscString(STR_FOOTER) + " ( " + aBuffer + " ) ";
1012 break;
1014 default:
1015 if ( !pIntl )
1016 pIntl = ScGlobal::GetScIntlWrapper();
1017 ePresentation = rItem.GetPresentation( ePresentation, GetMetric( nW ), ePresentationMetric, rText, pIntl );
1018 break;
1021 return ePresentation;
1024 SfxMapUnit ScDocumentPool::GetMetric( sal_uInt16 nWhich ) const
1026 // eigene Attribute: Twips, alles andere 1/100 mm
1028 if ( nWhich >= ATTR_STARTINDEX && nWhich <= ATTR_ENDINDEX )
1029 return SFX_MAPUNIT_TWIP;
1030 else
1031 return SFX_MAPUNIT_100TH_MM;
1034 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */