1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include "scitems.hxx"
22 #include <comphelper/string.hxx>
23 #include <i18nutil/unicode.hxx>
24 #include <vcl/outdev.hxx>
25 #include <vcl/svapp.hxx>
26 #include <vcl/settings.hxx>
27 #include <svl/aeitem.hxx>
28 #include <svl/itemiter.hxx>
29 #include <svl/stritem.hxx>
30 #include <svx/algitem.hxx>
31 #include <editeng/boxitem.hxx>
32 #include <editeng/lineitem.hxx>
33 #include <editeng/brushitem.hxx>
34 #include <editeng/charreliefitem.hxx>
35 #include <editeng/contouritem.hxx>
36 #include <editeng/colritem.hxx>
37 #include <editeng/crossedoutitem.hxx>
38 #include <svx/dialmgr.hxx>
39 #include <editeng/emphasismarkitem.hxx>
40 #include <editeng/fhgtitem.hxx>
41 #include <editeng/fontitem.hxx>
42 #include <editeng/forbiddenruleitem.hxx>
43 #include <editeng/frmdiritem.hxx>
44 #include <editeng/hngpnctitem.hxx>
45 #include <editeng/itemtype.hxx>
46 #include <editeng/langitem.hxx>
47 #include <editeng/lrspitem.hxx>
48 #include <svx/pageitem.hxx>
49 #include <editeng/pbinitem.hxx>
50 #include <editeng/postitem.hxx>
51 #include <svx/rotmodit.hxx>
52 #include <editeng/scriptspaceitem.hxx>
53 #include <editeng/shaditem.hxx>
54 #include <editeng/shdditem.hxx>
55 #include <editeng/sizeitem.hxx>
56 #include <svx/svxitems.hrc>
57 #include <editeng/udlnitem.hxx>
58 #include <editeng/ulspitem.hxx>
59 #include <editeng/wghtitem.hxx>
60 #include <editeng/wrlmitem.hxx>
61 #include <editeng/xmlcnitm.hxx>
62 #include <editeng/justifyitem.hxx>
64 #include "docpool.hxx"
67 #include "patattr.hxx"
68 #include "globstr.hrc"
69 #include "document.hxx"
72 #define SC_MAX_POOLREF (SFX_ITEMS_OLD_MAXREF - 39)
73 #define SC_SAFE_POOLREF (SC_MAX_POOLREF + 20)
75 // STATIC DATA -----------------------------------------------------------
77 sal_uInt16
* ScDocumentPool::pVersionMap1
= 0;
78 sal_uInt16
* ScDocumentPool::pVersionMap2
= 0;
79 sal_uInt16
* ScDocumentPool::pVersionMap3
= 0;
80 sal_uInt16
* ScDocumentPool::pVersionMap4
= 0;
81 sal_uInt16
* ScDocumentPool::pVersionMap5
= 0;
82 sal_uInt16
* ScDocumentPool::pVersionMap6
= 0;
83 sal_uInt16
* ScDocumentPool::pVersionMap7
= 0;
84 sal_uInt16
* ScDocumentPool::pVersionMap8
= 0;
85 sal_uInt16
* ScDocumentPool::pVersionMap9
= 0;
86 sal_uInt16
* ScDocumentPool::pVersionMap10
= 0;
87 sal_uInt16
* ScDocumentPool::pVersionMap11
= 0;
88 sal_uInt16
* ScDocumentPool::pVersionMap12
= 0;
90 // ATTR_FONT_TWOLINES (not used) was changed to ATTR_USERDEF (not saved in binary format) in 641c
92 static SfxItemInfo
const aItemInfos
[] =
94 { SID_ATTR_CHAR_FONT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT
95 { SID_ATTR_CHAR_FONTHEIGHT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_HEIGHT
96 { SID_ATTR_CHAR_WEIGHT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_WEIGHT
97 { SID_ATTR_CHAR_POSTURE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_POSTURE
98 { SID_ATTR_CHAR_UNDERLINE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_UNDERLINE
99 { SID_ATTR_CHAR_OVERLINE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_OVERLINE
100 { SID_ATTR_CHAR_STRIKEOUT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_CROSSEDOUT
101 { SID_ATTR_CHAR_CONTOUR
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_CONTOUR
102 { SID_ATTR_CHAR_SHADOWED
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_SHADOWED
103 { SID_ATTR_CHAR_COLOR
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_COLOR
104 { SID_ATTR_CHAR_LANGUAGE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_LANGUAGE
105 { SID_ATTR_CHAR_CJK_FONT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_CJK_FONT from 614
106 { SID_ATTR_CHAR_CJK_FONTHEIGHT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_CJK_FONT_HEIGHT from 614
107 { SID_ATTR_CHAR_CJK_WEIGHT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_CJK_FONT_WEIGHT from 614
108 { SID_ATTR_CHAR_CJK_POSTURE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_CJK_FONT_POSTURE from 614
109 { SID_ATTR_CHAR_CJK_LANGUAGE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_CJK_FONT_LANGUAGE from 614
110 { SID_ATTR_CHAR_CTL_FONT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_CTL_FONT from 614
111 { SID_ATTR_CHAR_CTL_FONTHEIGHT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_CTL_FONT_HEIGHT from 614
112 { SID_ATTR_CHAR_CTL_WEIGHT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_CTL_FONT_WEIGHT from 614
113 { SID_ATTR_CHAR_CTL_POSTURE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_CTL_FONT_POSTURE from 614
114 { SID_ATTR_CHAR_CTL_LANGUAGE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_CTL_FONT_LANGUAGE from 614
115 { SID_ATTR_CHAR_EMPHASISMARK
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_EMPHASISMARK from 614
116 { 0, SfxItemPoolFlags::POOLABLE
}, // ATTR_USERDEF from 614 / 641c
117 { SID_ATTR_CHAR_WORDLINEMODE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_WORDLINE from 632b
118 { SID_ATTR_CHAR_RELIEF
, SfxItemPoolFlags::POOLABLE
}, // ATTR_FONT_RELIEF from 632b
119 { SID_ATTR_ALIGN_HYPHENATION
, SfxItemPoolFlags::POOLABLE
}, // ATTR_HYPHENATE from 632b
120 { 0, SfxItemPoolFlags::POOLABLE
}, // ATTR_SCRIPTSPACE from 614d
121 { 0, SfxItemPoolFlags::POOLABLE
}, // ATTR_HANGPUNCTUATION from 614d
122 { SID_ATTR_PARA_FORBIDDEN_RULES
,SfxItemPoolFlags::POOLABLE
}, // ATTR_FORBIDDEN_RULES from 614d
123 { SID_ATTR_ALIGN_HOR_JUSTIFY
, SfxItemPoolFlags::POOLABLE
}, // ATTR_HOR_JUSTIFY
124 { SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD
, SfxItemPoolFlags::POOLABLE
}, // ATTR_HOR_JUSTIFY_METHOD
125 { SID_ATTR_ALIGN_INDENT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_INDENT from 350
126 { SID_ATTR_ALIGN_VER_JUSTIFY
, SfxItemPoolFlags::POOLABLE
}, // ATTR_VER_JUSTIFY
127 { SID_ATTR_ALIGN_VER_JUSTIFY_METHOD
, SfxItemPoolFlags::POOLABLE
}, // ATTR_VER_JUSTIFY_METHOD
128 { SID_ATTR_ALIGN_STACKED
, SfxItemPoolFlags::POOLABLE
}, // ATTR_STACKED from 680/dr14 (replaces ATTR_ORIENTATION)
129 { SID_ATTR_ALIGN_DEGREES
, SfxItemPoolFlags::POOLABLE
}, // ATTR_ROTATE_VALUE from 367
130 { SID_ATTR_ALIGN_LOCKPOS
, SfxItemPoolFlags::POOLABLE
}, // ATTR_ROTATE_MODE from 367
131 { SID_ATTR_ALIGN_ASIANVERTICAL
, SfxItemPoolFlags::POOLABLE
}, // ATTR_VERTICAL_ASIAN from 642
132 { SID_ATTR_FRAMEDIRECTION
, SfxItemPoolFlags::POOLABLE
}, // ATTR_WRITINGDIR from 643
133 { SID_ATTR_ALIGN_LINEBREAK
, SfxItemPoolFlags::POOLABLE
}, // ATTR_LINEBREAK
134 { SID_ATTR_ALIGN_SHRINKTOFIT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_SHRINKTOFIT from 680/dr14
135 { SID_ATTR_BORDER_DIAG_TLBR
, SfxItemPoolFlags::POOLABLE
}, // ATTR_BORDER_TLBR from 680/dr14
136 { SID_ATTR_BORDER_DIAG_BLTR
, SfxItemPoolFlags::POOLABLE
}, // ATTR_BORDER_BLTR from 680/dr14
137 { SID_ATTR_ALIGN_MARGIN
, SfxItemPoolFlags::POOLABLE
}, // ATTR_MARGIN
138 { 0, SfxItemPoolFlags::POOLABLE
}, // ATTR_MERGE
139 { 0, SfxItemPoolFlags::POOLABLE
}, // ATTR_MERGE_FLAG
140 { SID_ATTR_NUMBERFORMAT_VALUE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_VALUE_FORMAT
141 { ATTR_LANGUAGE_FORMAT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_LANGUAGE_FORMAT from 329, is combined with SID_ATTR_NUMBERFORMAT_VALUE in the dialog
142 { SID_ATTR_BRUSH
, SfxItemPoolFlags::POOLABLE
}, // ATTR_BACKGROUND
143 { SID_SCATTR_PROTECTION
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PROTECTION
144 { SID_ATTR_BORDER_OUTER
, SfxItemPoolFlags::POOLABLE
}, // ATTR_BORDER
145 { SID_ATTR_BORDER_INNER
, SfxItemPoolFlags::POOLABLE
}, // ATTR_BORDER_INNER
146 { SID_ATTR_BORDER_SHADOW
, SfxItemPoolFlags::POOLABLE
}, // ATTR_SHADOW
147 { 0, SfxItemPoolFlags::POOLABLE
}, // ATTR_VALIDDATA
148 { 0, SfxItemPoolFlags::POOLABLE
}, // ATTR_CONDITIONAL
149 { 0, SfxItemPoolFlags::POOLABLE
}, // ATTR_HYPERLINK
150 { 0, SfxItemPoolFlags::POOLABLE
}, // ATTR_PATTERN
151 { SID_ATTR_LRSPACE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_LRSPACE
152 { SID_ATTR_ULSPACE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_ULSPACE
153 { SID_ATTR_PAGE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE
154 { 0, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_PAPERTRAY, since 303 just a dummy
155 { SID_ATTR_PAGE_PAPERBIN
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_PAPERBIN
156 { SID_ATTR_PAGE_SIZE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_SIZE
157 { SID_ATTR_PAGE_MAXSIZE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_MAXSIZE
158 { SID_ATTR_PAGE_EXT1
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_HORCENTER
159 { SID_ATTR_PAGE_EXT2
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_VERCENTER
160 { SID_ATTR_PAGE_ON
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_ON
161 { SID_ATTR_PAGE_DYNAMIC
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_DYNAMIC
162 { SID_ATTR_PAGE_SHARED
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_SHARED
163 { SID_SCATTR_PAGE_NOTES
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_NOTES
164 { SID_SCATTR_PAGE_GRID
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_GRID
165 { SID_SCATTR_PAGE_HEADERS
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_HEADERS
166 { SID_SCATTR_PAGE_CHARTS
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_CHARTS
167 { SID_SCATTR_PAGE_OBJECTS
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_OBJECTS
168 { SID_SCATTR_PAGE_DRAWINGS
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_DRAWINGS
169 { SID_SCATTR_PAGE_TOPDOWN
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_TOPDOWN
170 { SID_SCATTR_PAGE_SCALE
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_SCALE
171 { SID_SCATTR_PAGE_SCALETOPAGES
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_SCALETOPAGES
172 { SID_SCATTR_PAGE_FIRSTPAGENO
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_FIRSTPAGENO
173 { SID_SCATTR_PAGE_PRINTAREA
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_PRINTAREA
174 { SID_SCATTR_PAGE_REPEATROW
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_REPEATROW
175 { SID_SCATTR_PAGE_REPEATCOL
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_REPEATCOL
176 { SID_SCATTR_PAGE_PRINTTABLES
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_PRINTTABLES
177 { SID_SCATTR_PAGE_HEADERLEFT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_HEADERLEFT
178 { SID_SCATTR_PAGE_FOOTERLEFT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_FOOTERLEFT
179 { SID_SCATTR_PAGE_HEADERRIGHT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_HEADERRIGHT
180 { SID_SCATTR_PAGE_FOOTERRIGHT
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_FOOTERRIGHT
181 { SID_ATTR_PAGE_HEADERSET
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_HEADERSET
182 { SID_ATTR_PAGE_FOOTERSET
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_FOOTERSET
183 { SID_SCATTR_PAGE_FORMULAS
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_FORMULAS
184 { SID_SCATTR_PAGE_NULLVALS
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_NULLVALS
185 { SID_SCATTR_PAGE_SCALETO
, SfxItemPoolFlags::POOLABLE
}, // ATTR_PAGE_SCALETO
186 { 0, SfxItemPoolFlags::POOLABLE
} // ATTR_HIDDEN
189 SAL_N_ELEMENTS(aItemInfos
) == ATTR_ENDINDEX
- ATTR_STARTINDEX
+ 1, "these must match");
191 ScDocumentPool::ScDocumentPool( SfxItemPool
* pSecPool
)
193 : SfxItemPool ( OUString("ScDocumentPool"),
194 ATTR_STARTINDEX
, ATTR_ENDINDEX
,
195 aItemInfos
, NULL
, false/*bLoadRefCounts*/ ),
196 pSecondary ( pSecPool
)
198 // latin font from GetDefaultFonts is not used, DEFAULTFONT_LATIN_SPREADSHEET instead
199 vcl::Font aStdFont
= OutputDevice::GetDefaultFont( DefaultFontType::LATIN_SPREADSHEET
, LANGUAGE_ENGLISH_US
,
200 GetDefaultFontFlags::OnlyOne
);
201 SvxFontItem
* pStdFont
= new SvxFontItem( aStdFont
.GetFamily(),
202 aStdFont
.GetName(), aStdFont
.GetStyleName(),
203 aStdFont
.GetPitch(), aStdFont
.GetCharSet(),
206 SvxFontItem
* pCjkFont
= new SvxFontItem( ATTR_CJK_FONT
);
207 SvxFontItem
* pCtlFont
= new SvxFontItem( ATTR_CTL_FONT
);
208 SvxFontItem
aDummy( ATTR_FONT
);
209 GetDefaultFonts( aDummy
, *pCjkFont
, *pCtlFont
);
211 SvxBoxInfoItem
* pGlobalBorderInnerAttr
= new SvxBoxInfoItem( ATTR_BORDER_INNER
);
212 SfxItemSet
* pSet
= new SfxItemSet( *this, ATTR_PATTERN_START
, ATTR_PATTERN_END
);
213 SfxItemSet
aSetItemItemSet( *this,
214 ATTR_BACKGROUND
, ATTR_BACKGROUND
,
215 ATTR_BORDER
, ATTR_SHADOW
,
216 ATTR_LRSPACE
, ATTR_ULSPACE
,
217 ATTR_PAGE_SIZE
, ATTR_PAGE_SIZE
,
218 ATTR_PAGE_ON
, ATTR_PAGE_SHARED
,
221 pGlobalBorderInnerAttr
->SetLine(NULL
, SvxBoxInfoItemLine::HORI
);
222 pGlobalBorderInnerAttr
->SetLine(NULL
, SvxBoxInfoItemLine::VERT
);
223 pGlobalBorderInnerAttr
->SetTable(true);
224 pGlobalBorderInnerAttr
->SetDist(true);
225 pGlobalBorderInnerAttr
->SetMinDist(false);
227 ppPoolDefaults
= new SfxPoolItem
*[ATTR_ENDINDEX
-ATTR_STARTINDEX
+1];
229 ppPoolDefaults
[ ATTR_FONT
- ATTR_STARTINDEX
] = pStdFont
;
230 ppPoolDefaults
[ ATTR_FONT_HEIGHT
- ATTR_STARTINDEX
] = new SvxFontHeightItem( 200, 100, ATTR_FONT_HEIGHT
); // 10 pt;
231 ppPoolDefaults
[ ATTR_FONT_WEIGHT
- ATTR_STARTINDEX
] = new SvxWeightItem( WEIGHT_NORMAL
, ATTR_FONT_WEIGHT
);
232 ppPoolDefaults
[ ATTR_FONT_POSTURE
- ATTR_STARTINDEX
] = new SvxPostureItem( ITALIC_NONE
, ATTR_FONT_POSTURE
);
233 ppPoolDefaults
[ ATTR_FONT_UNDERLINE
- ATTR_STARTINDEX
] = new SvxUnderlineItem( UNDERLINE_NONE
, ATTR_FONT_UNDERLINE
);
234 ppPoolDefaults
[ ATTR_FONT_OVERLINE
- ATTR_STARTINDEX
] = new SvxOverlineItem( UNDERLINE_NONE
, ATTR_FONT_OVERLINE
);
235 ppPoolDefaults
[ ATTR_FONT_CROSSEDOUT
- ATTR_STARTINDEX
] = new SvxCrossedOutItem( STRIKEOUT_NONE
, ATTR_FONT_CROSSEDOUT
);
236 ppPoolDefaults
[ ATTR_FONT_CONTOUR
- ATTR_STARTINDEX
] = new SvxContourItem( false, ATTR_FONT_CONTOUR
);
237 ppPoolDefaults
[ ATTR_FONT_SHADOWED
- ATTR_STARTINDEX
] = new SvxShadowedItem( false, ATTR_FONT_SHADOWED
);
238 ppPoolDefaults
[ ATTR_FONT_COLOR
- ATTR_STARTINDEX
] = new SvxColorItem( Color(COL_AUTO
), ATTR_FONT_COLOR
);
239 ppPoolDefaults
[ ATTR_FONT_LANGUAGE
- ATTR_STARTINDEX
] = new SvxLanguageItem( LanguageType(LANGUAGE_DONTKNOW
), ATTR_FONT_LANGUAGE
);
240 ppPoolDefaults
[ ATTR_CJK_FONT
- ATTR_STARTINDEX
] = pCjkFont
;
241 ppPoolDefaults
[ ATTR_CJK_FONT_HEIGHT
- ATTR_STARTINDEX
] = new SvxFontHeightItem( 200, 100, ATTR_CJK_FONT_HEIGHT
);
242 ppPoolDefaults
[ ATTR_CJK_FONT_WEIGHT
- ATTR_STARTINDEX
] = new SvxWeightItem( WEIGHT_NORMAL
, ATTR_CJK_FONT_WEIGHT
);
243 ppPoolDefaults
[ ATTR_CJK_FONT_POSTURE
- ATTR_STARTINDEX
] = new SvxPostureItem( ITALIC_NONE
, ATTR_CJK_FONT_POSTURE
);
244 ppPoolDefaults
[ ATTR_CJK_FONT_LANGUAGE
-ATTR_STARTINDEX
] = new SvxLanguageItem( LanguageType(LANGUAGE_DONTKNOW
),
245 ATTR_CJK_FONT_LANGUAGE
);
246 ppPoolDefaults
[ ATTR_CTL_FONT
- ATTR_STARTINDEX
] = pCtlFont
;
247 ppPoolDefaults
[ ATTR_CTL_FONT_HEIGHT
- ATTR_STARTINDEX
] = new SvxFontHeightItem( 200, 100, ATTR_CTL_FONT_HEIGHT
);
248 ppPoolDefaults
[ ATTR_CTL_FONT_WEIGHT
- ATTR_STARTINDEX
] = new SvxWeightItem( WEIGHT_NORMAL
, ATTR_CTL_FONT_WEIGHT
);
249 ppPoolDefaults
[ ATTR_CTL_FONT_POSTURE
- ATTR_STARTINDEX
] = new SvxPostureItem( ITALIC_NONE
, ATTR_CTL_FONT_POSTURE
);
250 ppPoolDefaults
[ ATTR_CTL_FONT_LANGUAGE
-ATTR_STARTINDEX
] = new SvxLanguageItem( LanguageType(LANGUAGE_DONTKNOW
),
251 ATTR_CTL_FONT_LANGUAGE
);
252 ppPoolDefaults
[ ATTR_FONT_EMPHASISMARK
-ATTR_STARTINDEX
] = new SvxEmphasisMarkItem( EMPHASISMARK_NONE
, ATTR_FONT_EMPHASISMARK
);
253 ppPoolDefaults
[ ATTR_USERDEF
- ATTR_STARTINDEX
] = new SvXMLAttrContainerItem( ATTR_USERDEF
);
254 ppPoolDefaults
[ ATTR_FONT_WORDLINE
- ATTR_STARTINDEX
] = new SvxWordLineModeItem(false, ATTR_FONT_WORDLINE
);
255 ppPoolDefaults
[ ATTR_FONT_RELIEF
- ATTR_STARTINDEX
] = new SvxCharReliefItem( RELIEF_NONE
, ATTR_FONT_RELIEF
);
256 ppPoolDefaults
[ ATTR_HYPHENATE
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_HYPHENATE
);
257 ppPoolDefaults
[ ATTR_SCRIPTSPACE
- ATTR_STARTINDEX
] = new SvxScriptSpaceItem( false, ATTR_SCRIPTSPACE
);
258 ppPoolDefaults
[ ATTR_HANGPUNCTUATION
- ATTR_STARTINDEX
] = new SvxHangingPunctuationItem( false, ATTR_HANGPUNCTUATION
);
259 ppPoolDefaults
[ ATTR_FORBIDDEN_RULES
- ATTR_STARTINDEX
] = new SvxForbiddenRuleItem( false, ATTR_FORBIDDEN_RULES
);
260 ppPoolDefaults
[ ATTR_HOR_JUSTIFY
- ATTR_STARTINDEX
] = new SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD
, ATTR_HOR_JUSTIFY
);
261 ppPoolDefaults
[ ATTR_HOR_JUSTIFY_METHOD
- ATTR_STARTINDEX
] = new SvxJustifyMethodItem( SVX_JUSTIFY_METHOD_AUTO
, ATTR_HOR_JUSTIFY_METHOD
);
262 ppPoolDefaults
[ ATTR_INDENT
- ATTR_STARTINDEX
] = new SfxUInt16Item( ATTR_INDENT
, 0 );
263 ppPoolDefaults
[ ATTR_VER_JUSTIFY
- ATTR_STARTINDEX
] = new SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD
, ATTR_VER_JUSTIFY
);
264 ppPoolDefaults
[ ATTR_VER_JUSTIFY_METHOD
- ATTR_STARTINDEX
] = new SvxJustifyMethodItem( SVX_JUSTIFY_METHOD_AUTO
, ATTR_VER_JUSTIFY_METHOD
);
265 ppPoolDefaults
[ ATTR_STACKED
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_STACKED
, false );
266 ppPoolDefaults
[ ATTR_ROTATE_VALUE
- ATTR_STARTINDEX
] = new SfxInt32Item( ATTR_ROTATE_VALUE
, 0 );
267 ppPoolDefaults
[ ATTR_ROTATE_MODE
- ATTR_STARTINDEX
] = new SvxRotateModeItem( SVX_ROTATE_MODE_BOTTOM
, ATTR_ROTATE_MODE
);
268 ppPoolDefaults
[ ATTR_VERTICAL_ASIAN
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_VERTICAL_ASIAN
);
269 // The default for the ATTR_WRITINGDIR cell attribute must by FRMDIR_ENVIRONMENT,
270 // so that value is returned when asking for a default cell's attributes.
271 // The value from the page style is set as DefaultHorizontalTextDirection for the EditEngine.
272 ppPoolDefaults
[ ATTR_WRITINGDIR
- ATTR_STARTINDEX
] = new SvxFrameDirectionItem( FRMDIR_ENVIRONMENT
, ATTR_WRITINGDIR
);
273 ppPoolDefaults
[ ATTR_LINEBREAK
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_LINEBREAK
);
274 ppPoolDefaults
[ ATTR_SHRINKTOFIT
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_SHRINKTOFIT
);
275 ppPoolDefaults
[ ATTR_BORDER_TLBR
- ATTR_STARTINDEX
] = new SvxLineItem( ATTR_BORDER_TLBR
);
276 ppPoolDefaults
[ ATTR_BORDER_BLTR
- ATTR_STARTINDEX
] = new SvxLineItem( ATTR_BORDER_BLTR
);
277 ppPoolDefaults
[ ATTR_MARGIN
- ATTR_STARTINDEX
] = new SvxMarginItem( ATTR_MARGIN
);
278 ppPoolDefaults
[ ATTR_MERGE
- ATTR_STARTINDEX
] = new ScMergeAttr
;
279 ppPoolDefaults
[ ATTR_MERGE_FLAG
- ATTR_STARTINDEX
] = new ScMergeFlagAttr
;
280 ppPoolDefaults
[ ATTR_VALUE_FORMAT
- ATTR_STARTINDEX
] = new SfxUInt32Item( ATTR_VALUE_FORMAT
, 0 );
281 ppPoolDefaults
[ ATTR_LANGUAGE_FORMAT
- ATTR_STARTINDEX
] = new SvxLanguageItem( ScGlobal::eLnge
, ATTR_LANGUAGE_FORMAT
);
282 ppPoolDefaults
[ ATTR_BACKGROUND
- ATTR_STARTINDEX
] = new SvxBrushItem( Color(COL_TRANSPARENT
), ATTR_BACKGROUND
);
283 ppPoolDefaults
[ ATTR_PROTECTION
- ATTR_STARTINDEX
] = new ScProtectionAttr
;
284 ppPoolDefaults
[ ATTR_BORDER
- ATTR_STARTINDEX
] = new SvxBoxItem( ATTR_BORDER
);
285 ppPoolDefaults
[ ATTR_BORDER_INNER
- ATTR_STARTINDEX
] = pGlobalBorderInnerAttr
;
286 ppPoolDefaults
[ ATTR_SHADOW
- ATTR_STARTINDEX
] = new SvxShadowItem( ATTR_SHADOW
);
287 ppPoolDefaults
[ ATTR_VALIDDATA
- ATTR_STARTINDEX
] = new SfxUInt32Item( ATTR_VALIDDATA
, 0 );
288 ppPoolDefaults
[ ATTR_CONDITIONAL
- ATTR_STARTINDEX
] = new ScCondFormatItem
;
289 ppPoolDefaults
[ ATTR_HYPERLINK
- ATTR_STARTINDEX
] = new SfxStringItem( ATTR_HYPERLINK
, OUString() ) ;
291 // GetRscString only works after ScGlobal::Init (indicated by the EmptyBrushItem)
292 // TODO: Write additional method ScGlobal::IsInit() or somesuch
293 // or detect whether this is the Secondary Pool for a MessagePool
294 if ( ScGlobal::GetEmptyBrushItem() )
295 ppPoolDefaults
[ ATTR_PATTERN
- ATTR_STARTINDEX
] = new ScPatternAttr( pSet
, ScGlobal::GetRscString(STR_STYLENAME_STANDARD
) );
297 ppPoolDefaults
[ ATTR_PATTERN
- ATTR_STARTINDEX
] = new ScPatternAttr( pSet
,
298 OUString(STRING_STANDARD
) ); // FIXME: without name?
300 ppPoolDefaults
[ ATTR_LRSPACE
- ATTR_STARTINDEX
] = new SvxLRSpaceItem( ATTR_LRSPACE
);
301 ppPoolDefaults
[ ATTR_ULSPACE
- ATTR_STARTINDEX
] = new SvxULSpaceItem( ATTR_ULSPACE
);
302 ppPoolDefaults
[ ATTR_PAGE
- ATTR_STARTINDEX
] = new SvxPageItem( ATTR_PAGE
);
303 ppPoolDefaults
[ ATTR_PAGE_PAPERTRAY
- ATTR_STARTINDEX
] = new SfxAllEnumItem( ATTR_PAGE_PAPERTRAY
);
304 ppPoolDefaults
[ ATTR_PAGE_PAPERBIN
- ATTR_STARTINDEX
] = new SvxPaperBinItem( ATTR_PAGE_PAPERBIN
);
305 ppPoolDefaults
[ ATTR_PAGE_SIZE
- ATTR_STARTINDEX
] = new SvxSizeItem( ATTR_PAGE_SIZE
);
306 ppPoolDefaults
[ ATTR_PAGE_MAXSIZE
- ATTR_STARTINDEX
] = new SvxSizeItem( ATTR_PAGE_MAXSIZE
);
307 ppPoolDefaults
[ ATTR_PAGE_HORCENTER
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_PAGE_HORCENTER
);
308 ppPoolDefaults
[ ATTR_PAGE_VERCENTER
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_PAGE_VERCENTER
);
309 ppPoolDefaults
[ ATTR_PAGE_ON
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_PAGE_ON
, true );
310 ppPoolDefaults
[ ATTR_PAGE_DYNAMIC
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_PAGE_DYNAMIC
, true );
311 ppPoolDefaults
[ ATTR_PAGE_SHARED
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_PAGE_SHARED
, true );
312 ppPoolDefaults
[ ATTR_PAGE_NOTES
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_PAGE_NOTES
, false );
313 ppPoolDefaults
[ ATTR_PAGE_GRID
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_PAGE_GRID
, false );
314 ppPoolDefaults
[ ATTR_PAGE_HEADERS
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_PAGE_HEADERS
, false );
315 ppPoolDefaults
[ ATTR_PAGE_CHARTS
- ATTR_STARTINDEX
] = new ScViewObjectModeItem( ATTR_PAGE_CHARTS
);
316 ppPoolDefaults
[ ATTR_PAGE_OBJECTS
- ATTR_STARTINDEX
] = new ScViewObjectModeItem( ATTR_PAGE_OBJECTS
);
317 ppPoolDefaults
[ ATTR_PAGE_DRAWINGS
- ATTR_STARTINDEX
] = new ScViewObjectModeItem( ATTR_PAGE_DRAWINGS
);
318 ppPoolDefaults
[ ATTR_PAGE_TOPDOWN
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_PAGE_TOPDOWN
, true );
319 ppPoolDefaults
[ ATTR_PAGE_SCALE
- ATTR_STARTINDEX
] = new SfxUInt16Item( ATTR_PAGE_SCALE
, 100 );
320 ppPoolDefaults
[ ATTR_PAGE_SCALETOPAGES
-ATTR_STARTINDEX
] = new SfxUInt16Item( ATTR_PAGE_SCALETOPAGES
, 1 );
321 ppPoolDefaults
[ ATTR_PAGE_FIRSTPAGENO
- ATTR_STARTINDEX
] = new SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO
, 1 );
322 ppPoolDefaults
[ ATTR_PAGE_PRINTAREA
- ATTR_STARTINDEX
] = new ScRangeItem( ATTR_PAGE_PRINTAREA
);
323 ppPoolDefaults
[ ATTR_PAGE_REPEATROW
- ATTR_STARTINDEX
] = new ScRangeItem( ATTR_PAGE_REPEATROW
);
324 ppPoolDefaults
[ ATTR_PAGE_REPEATCOL
- ATTR_STARTINDEX
] = new ScRangeItem( ATTR_PAGE_REPEATCOL
);
325 ppPoolDefaults
[ ATTR_PAGE_PRINTTABLES
- ATTR_STARTINDEX
] = new ScTableListItem( ATTR_PAGE_PRINTTABLES
);
326 ppPoolDefaults
[ ATTR_PAGE_HEADERLEFT
- ATTR_STARTINDEX
] = new ScPageHFItem( ATTR_PAGE_HEADERLEFT
);
327 ppPoolDefaults
[ ATTR_PAGE_FOOTERLEFT
- ATTR_STARTINDEX
] = new ScPageHFItem( ATTR_PAGE_FOOTERLEFT
);
328 ppPoolDefaults
[ ATTR_PAGE_HEADERRIGHT
- ATTR_STARTINDEX
] = new ScPageHFItem( ATTR_PAGE_HEADERRIGHT
);
329 ppPoolDefaults
[ ATTR_PAGE_FOOTERRIGHT
- ATTR_STARTINDEX
] = new ScPageHFItem( ATTR_PAGE_FOOTERRIGHT
);
330 ppPoolDefaults
[ ATTR_PAGE_HEADERSET
- ATTR_STARTINDEX
] = new SvxSetItem( ATTR_PAGE_HEADERSET
, aSetItemItemSet
);
331 ppPoolDefaults
[ ATTR_PAGE_FOOTERSET
- ATTR_STARTINDEX
] = new SvxSetItem( ATTR_PAGE_FOOTERSET
, aSetItemItemSet
);
332 ppPoolDefaults
[ ATTR_PAGE_FORMULAS
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_PAGE_FORMULAS
, false );
333 ppPoolDefaults
[ ATTR_PAGE_NULLVALS
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_PAGE_NULLVALS
, true );
334 ppPoolDefaults
[ ATTR_PAGE_SCALETO
- ATTR_STARTINDEX
] = new ScPageScaleToItem( 1, 1 );
335 ppPoolDefaults
[ ATTR_HIDDEN
- ATTR_STARTINDEX
] = new SfxBoolItem( ATTR_HIDDEN
, false );
337 SetDefaults( ppPoolDefaults
);
340 SetSecondaryPool( pSecondary
);
342 // ATTR_LANGUAGE_FORMAT from sv329 inserted, VersionMap in _ScGlobal__Init
343 SetVersionMap( 1, 100, 157, pVersionMap1
);
345 // ATTR_VALIDDATA, ATTR_CONDITIONAL from 341
346 SetVersionMap( 2, 100, 158, pVersionMap2
);
348 // ATTR_INDENT from 350
349 SetVersionMap( 3, 100, 160, pVersionMap3
);
351 // ATTR_ROTATE_VALUE, ATTR_ROTATE_MODE from 367
352 SetVersionMap( 4, 100, 161, pVersionMap4
);
354 // CJK, CTL, EMPHASISMARK, TWOLINES from 614
355 SetVersionMap( 5, 100, 163, pVersionMap5
);
357 // ATTR_SCRIPTSPACE, ATTR_HANGPUNCTUATION, ATTR_FORBIDDEN_RULES from 614d
358 SetVersionMap( 6, 100, 175, pVersionMap6
);
360 // ATTR_FONT_WORDLINE, ATTR_FONT_RELIEF, ATTR_HYPHENATE from 632b
361 SetVersionMap( 7, 100, 178, pVersionMap7
);
363 // ATTR_VERTICAL_ASIAN from 642q
364 SetVersionMap( 8, 100, 181, pVersionMap8
);
366 // ATTR_WRITINGDIR from 643y
367 SetVersionMap( 9, 100, 182, pVersionMap9
);
369 // ATTR_PAGE_SCALETO added in 680/sab008
370 // new version map not required
372 // ATTR_SHRINKTOFIT, ATTR_BORDER_TL_BR, ATTR_BORDER_BL_TR added in 680/dr14
373 SetVersionMap( 10, 100, 184, pVersionMap10
);
375 // ATTR_FONT_OVERLINE added in DEV300/overline2
376 SetVersionMap( 11, 100, 187, pVersionMap11
);
377 // ATTR_HYERLINK added
378 SetVersionMap( 12, 100, 192, pVersionMap12
);
381 ScDocumentPool::~ScDocumentPool()
385 for ( sal_uInt16 i
=0; i
< ATTR_ENDINDEX
-ATTR_STARTINDEX
+1; i
++ )
387 SetRefCount( *ppPoolDefaults
[i
], 0 );
388 delete ppPoolDefaults
[i
];
391 delete[] ppPoolDefaults
;
392 SfxItemPool::Free(pSecondary
);
395 void ScDocumentPool::InitVersionMaps()
397 OSL_PRECOND( !pVersionMap1
&& !pVersionMap2
&&
398 !pVersionMap3
&& !pVersionMap4
&&
399 !pVersionMap5
&& !pVersionMap6
&&
400 !pVersionMap7
&& !pVersionMap8
&&
401 !pVersionMap9
&& !pVersionMap10
&&
402 !pVersionMap11
&& !pVersionMap12
, "InitVersionMaps call multiple times" );
405 // Do not count with ATTR_*, if they change again
407 // First Map: ATTR_LANGUAGE_FORMAT from sv329 inserted
409 const sal_uInt16 nMap1Start
= 100; // Old ATTR_STARTINDEX
410 const sal_uInt16 nMap1End
= 157; // Old ATTR_ENDINDEX
411 const sal_uInt16 nMap1Count
= nMap1End
- nMap1Start
+ 1;
412 const sal_uInt16 nMap1New
= 18; // ATTR_LANGUAGE_FORMAT - ATTR_STARTINDEX
413 pVersionMap1
= new sal_uInt16
[ nMap1Count
];
415 for ( i
=0, j
=nMap1Start
; i
< nMap1New
; i
++, j
++ )
417 // An entry inserted ...
418 for ( i
=nMap1New
, j
=nMap1Start
+nMap1New
+1; i
< nMap1Count
; i
++, j
++ )
421 // Second Map: ATTR_VALIDDATA and ATTR_CONDITIONAL from 341 inserted
423 const sal_uInt16 nMap2Start
= 100; // ATTR_STARTINDEX
424 const sal_uInt16 nMap2End
= 158; // ATTR_ENDINDEX
425 const sal_uInt16 nMap2Count
= nMap2End
- nMap2Start
+ 1;
426 const sal_uInt16 nMap2New
= 24; // ATTR_VALIDDATA - ATTR_STARTINDEX
427 pVersionMap2
= new sal_uInt16
[ nMap2Count
];
428 for ( i
=0, j
=nMap2Start
; i
< nMap2New
; i
++, j
++ )
430 // Two entries inserted ...
431 for ( i
=nMap2New
, j
=nMap2Start
+nMap2New
+2; i
< nMap2Count
; i
++, j
++ )
434 // Third Map: ATTR_INDENT from 350 inserted
436 const sal_uInt16 nMap3Start
= 100; // ATTR_STARTINDEX
437 const sal_uInt16 nMap3End
= 160; // ATTR_ENDINDEX
438 const sal_uInt16 nMap3Count
= nMap3End
- nMap3Start
+ 1;
439 const sal_uInt16 nMap3New
= 11; // ATTR_INDENT - ATTR_STARTINDEX
440 pVersionMap3
= new sal_uInt16
[ nMap3Count
];
441 for ( i
=0, j
=nMap3Start
; i
< nMap3New
; i
++, j
++ )
443 // An entry insterted ...
444 for ( i
=nMap3New
, j
=nMap3Start
+nMap3New
+1; i
< nMap3Count
; i
++, j
++ )
447 // Fourth Map: ATTR_ROTATE_VALUE and ATTR_ROTATE_MODE from 367 inserted
449 const sal_uInt16 nMap4Start
= 100; // ATTR_STARTINDEX
450 const sal_uInt16 nMap4End
= 161; // ATTR_ENDINDEX
451 const sal_uInt16 nMap4Count
= nMap4End
- nMap4Start
+ 1;
452 const sal_uInt16 nMap4New
= 14; // ATTR_ROTATE_VALUE - ATTR_STARTINDEX
453 pVersionMap4
= new sal_uInt16
[ nMap4Count
];
454 for ( i
=0, j
=nMap4Start
; i
< nMap4New
; i
++, j
++ )
456 // Two entries inserted ...
457 for ( i
=nMap4New
, j
=nMap4Start
+nMap4New
+2; i
< nMap4Count
; i
++, j
++ )
460 // fifth map: CJK..., CTL..., EMPHASISMARK, TWOLINES (12 items) added in 614
462 const sal_uInt16 nMap5Start
= 100; // ATTR_STARTINDEX
463 const sal_uInt16 nMap5End
= 163; // ATTR_ENDINDEX
464 const sal_uInt16 nMap5Count
= nMap5End
- nMap5Start
+ 1;
465 const sal_uInt16 nMap5New
= 10; // ATTR_CJK_FONT - ATTR_STARTINDEX
466 pVersionMap5
= new sal_uInt16
[ nMap5Count
];
467 for ( i
=0, j
=nMap5Start
; i
< nMap5New
; i
++, j
++ )
469 // 12 entries inserted
470 for ( i
=nMap5New
, j
=nMap5Start
+nMap5New
+12; i
< nMap5Count
; i
++, j
++ )
473 // sixth map: ATTR_SCRIPTSPACE, ATTR_HANGPUNCTUATION, ATTR_FORBIDDEN_RULES added in 614d
475 const sal_uInt16 nMap6Start
= 100; // ATTR_STARTINDEX
476 const sal_uInt16 nMap6End
= 175; // ATTR_ENDINDEX
477 const sal_uInt16 nMap6Count
= nMap6End
- nMap6Start
+ 1;
478 const sal_uInt16 nMap6New
= 22; // ATTR_SCRIPTSPACE - ATTR_STARTINDEX
479 pVersionMap6
= new sal_uInt16
[ nMap6Count
];
480 for ( i
=0, j
=nMap6Start
; i
< nMap6New
; i
++, j
++ )
482 // 3 entries inserted
483 for ( i
=nMap6New
, j
=nMap6Start
+nMap6New
+3; i
< nMap6Count
; i
++, j
++ )
486 // seventh map: ATTR_FONT_WORDLINE, ATTR_FONT_RELIEF, ATTR_HYPHENATE added in 632b
488 const sal_uInt16 nMap7Start
= 100; // ATTR_STARTINDEX
489 const sal_uInt16 nMap7End
= 178; // ATTR_ENDINDEX
490 const sal_uInt16 nMap7Count
= nMap7End
- nMap7Start
+ 1;
491 const sal_uInt16 nMap7New
= 22; // ATTR_FONT_WORDLINE - ATTR_STARTINDEX
492 pVersionMap7
= new sal_uInt16
[ nMap7Count
];
493 for ( i
=0, j
=nMap7Start
; i
< nMap7New
; i
++, j
++ )
495 // 3 entries inserted
496 for ( i
=nMap7New
, j
=nMap7Start
+nMap7New
+3; i
< nMap7Count
; i
++, j
++ )
499 // eighth map: ATTR_VERTICAL_ASIAN added in 642q
501 const sal_uInt16 nMap8Start
= 100; // ATTR_STARTINDEX
502 const sal_uInt16 nMap8End
= 181; // ATTR_ENDINDEX
503 const sal_uInt16 nMap8Count
= nMap8End
- nMap8Start
+ 1;
504 const sal_uInt16 nMap8New
= 34; // ATTR_VERTICAL_ASIAN - ATTR_STARTINDEX
505 pVersionMap8
= new sal_uInt16
[ nMap8Count
];
506 for ( i
=0, j
=nMap8Start
; i
< nMap8New
; i
++, j
++ )
509 for ( i
=nMap8New
, j
=nMap8Start
+nMap8New
+1; i
< nMap8Count
; i
++, j
++ )
512 // 9th map: ATTR_WRITINGDIR added in 643y
514 const sal_uInt16 nMap9Start
= 100; // ATTR_STARTINDEX
515 const sal_uInt16 nMap9End
= 182; // ATTR_ENDINDEX
516 const sal_uInt16 nMap9Count
= nMap9End
- nMap9Start
+ 1;
517 const sal_uInt16 nMap9New
= 35; // ATTR_WRITINGDIR - ATTR_STARTINDEX
518 pVersionMap9
= new sal_uInt16
[ nMap9Count
];
519 for ( i
=0, j
=nMap9Start
; i
< nMap9New
; i
++, j
++ )
522 for ( i
=nMap9New
, j
=nMap9Start
+nMap9New
+1; i
< nMap9Count
; i
++, j
++ )
525 // ATTR_PAGE_SCALETO added in 680/sab008
527 // 10th map: ATTR_SHRINKTOFIT, ATTR_BORDER_TL_BR, ATTR_BORDER_BL_TR added in 680/dr14
529 const sal_uInt16 nMap10Start
= 100; // ATTR_STARTINDEX
530 const sal_uInt16 nMap10End
= 184; // ATTR_ENDINDEX
531 const sal_uInt16 nMap10Count
= nMap10End
- nMap10Start
+ 1;
532 const sal_uInt16 nMap10New
= 37; // ATTR_SHRINKTOFIT - ATTR_STARTINDEX
533 pVersionMap10
= new sal_uInt16
[ nMap10Count
];
534 for ( i
=0, j
=nMap10Start
; i
< nMap10New
; i
++, j
++ )
535 pVersionMap10
[i
] = j
;
536 // 3 entries inserted
537 for ( i
=nMap10New
, j
=nMap10Start
+nMap10New
+3; i
< nMap10Count
; i
++, j
++ )
538 pVersionMap10
[i
] = j
;
540 // 11th map: ATTR_FONT_OVERLINE added in DEV300/overline2
542 const sal_uInt16 nMap11Start
= 100; // ATTR_STARTINDEX
543 const sal_uInt16 nMap11End
= 187; // ATTR_ENDINDEX
544 const sal_uInt16 nMap11Count
= nMap11End
- nMap11Start
+ 1;
545 const sal_uInt16 nMap11New
= 5; // ATTR_FONT_OVERLINE - ATTR_STARTINDEX
546 pVersionMap11
= new sal_uInt16
[ nMap11Count
];
547 for ( i
=0, j
=nMap11Start
; i
< nMap11New
; i
++, j
++ )
548 pVersionMap11
[i
] = j
;
550 for ( i
=nMap11New
, j
=nMap11Start
+nMap11New
+1; i
< nMap11Count
; i
++, j
++ )
551 pVersionMap11
[i
] = j
;
553 const sal_uInt16 nMap12Start
= 100; // ATTR_STARTINDEX
554 const sal_uInt16 nMap12End
= 192; // ATTR_ENDINDEX
555 const sal_uInt16 nMap12Count
= nMap12End
- nMap12Start
+ 1;
556 const sal_uInt16 nMap12New
= 55; // ATTR_HYPERLINK - ATTR_STARTINDEX
557 pVersionMap12
= new sal_uInt16
[ nMap12Count
];
558 for ( i
=0, j
=nMap12Start
; i
< nMap12New
; i
++, j
++ )
559 pVersionMap12
[i
] = j
;
561 for ( i
=nMap12New
, j
=nMap12Start
+nMap12New
+1; i
< nMap12Count
; i
++, j
++ )
562 pVersionMap12
[i
] = j
;
565 void ScDocumentPool::DeleteVersionMaps()
567 OSL_PRECOND( pVersionMap1
&& pVersionMap2
&&
568 pVersionMap3
&& pVersionMap4
&&
569 pVersionMap5
&& pVersionMap6
&&
570 pVersionMap7
&& pVersionMap8
&&
571 pVersionMap9
&& pVersionMap10
&&
572 pVersionMap11
&& pVersionMap12
, "DeleteVersionMaps without maps" );
574 delete[] pVersionMap12
;
576 delete[] pVersionMap11
;
578 delete[] pVersionMap10
;
580 delete[] pVersionMap9
;
582 delete[] pVersionMap8
;
584 delete[] pVersionMap7
;
586 delete[] pVersionMap6
;
588 delete[] pVersionMap5
;
590 delete[] pVersionMap4
;
592 delete[] pVersionMap3
;
594 delete[] pVersionMap2
;
596 delete[] pVersionMap1
;
601 * The sal_uInt16 RefCount can overflow easily for the pattern attributes (SetItems):
602 * E.g. Alternate formatting for 600 whole cells.
603 * The RefCount is kept at SC_MAX_POOLREF and not increased/decreased anymore.
604 * This RefCount is recalculated not until the next load.
605 * The difference between SC_MAX_POOLREF and SC_SAFE_POOLREF is a little larger than it needs
606 * to be, to allow for detecting accidental "normal" changes to the RefCount (assertions).
608 const SfxPoolItem
& ScDocumentPool::Put( const SfxPoolItem
& rItem
, sal_uInt16 nWhich
)
610 if ( rItem
.Which() != ATTR_PATTERN
) // Only Pattern is special
611 return SfxItemPool::Put( rItem
, nWhich
);
613 // Don't copy the default pattern of this Pool
614 if (&rItem
== ppPoolDefaults
[ ATTR_PATTERN
- ATTR_STARTINDEX
])
617 // Else Put must always happen, because it could be another Pool
618 const SfxPoolItem
& rNew
= SfxItemPool::Put( rItem
, nWhich
);
623 void ScDocumentPool::Remove( const SfxPoolItem
& rItem
)
625 if ( rItem
.Which() == ATTR_PATTERN
) // Only Pattern is 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; // Do not decrement
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 // At the Apply of the Cache we might increase by 2 (to MAX+1 or SAFE+2)
647 // We only decrease by 1 (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 void ScDocumentPool::StyleDeleted( ScStyleSheet
* pStyle
)
656 sal_uInt32 nCount
= GetItemCount2(ATTR_PATTERN
);
657 for (sal_uInt32 i
=0; i
<nCount
; i
++)
659 ScPatternAttr
* pPattern
= const_cast<ScPatternAttr
*>(static_cast<const ScPatternAttr
*>(GetItem2(ATTR_PATTERN
, i
)));
660 if ( pPattern
&& pPattern
->GetStyleSheet() == pStyle
)
661 pPattern
->StyleToName();
665 void ScDocumentPool::CellStyleCreated( const OUString
& rName
, ScDocument
* pDoc
)
667 // If a style was created, don't keep any pattern with its name string in the pool,
668 // because it would compare equal to a pattern with a pointer to the new style.
669 // Calling StyleSheetChanged isn't enough because the pool may still contain items
670 // for undo or clipboard content.
672 sal_uInt32 nCount
= GetItemCount2(ATTR_PATTERN
);
673 for (sal_uInt32 i
=0; i
<nCount
; i
++)
675 ScPatternAttr
*const pPattern
=
676 const_cast<ScPatternAttr
*>(
677 static_cast<ScPatternAttr
const*>(GetItem2(ATTR_PATTERN
, i
)));
678 if ( pPattern
&& pPattern
->GetStyleSheet() == NULL
)
680 const OUString
* pStyleName
= pPattern
->GetStyleName();
681 if ( pStyleName
&& *pStyleName
== rName
)
682 pPattern
->UpdateStyleSheet(pDoc
); // find and store style pointer
687 SfxItemPool
* ScDocumentPool::Clone() const
689 return new SfxItemPool (*this, true);
692 static bool lcl_HFPresentation
694 const SfxPoolItem
& rItem
,
695 SfxMapUnit eCoreMetric
,
696 SfxMapUnit ePresentationMetric
,
698 const IntlWrapper
* pIntl
701 const SfxItemSet
& rSet
= static_cast<const SfxSetItem
&>(rItem
).GetItemSet();
702 const SfxPoolItem
* pItem
;
704 if ( SfxItemState::SET
== rSet
.GetItemState(ATTR_PAGE_ON
,false,&pItem
) )
706 if( !static_cast<const SfxBoolItem
*>(pItem
)->GetValue() )
710 SfxItemIter
aIter( rSet
);
711 pItem
= aIter
.FirstItem();
713 OUString
aDel(" + ");
717 sal_uInt16 nWhich
= pItem
->Which();
724 case ATTR_PAGE_DYNAMIC
:
725 case ATTR_PAGE_SHARED
:
730 const SvxLRSpaceItem
& rLRItem
= static_cast<const SvxLRSpaceItem
&>(*pItem
);
731 sal_uInt16 nPropLeftMargin
= rLRItem
.GetPropLeft();
732 sal_uInt16 nPropRightMargin
= rLRItem
.GetPropRight();
733 sal_uInt16 nLeftMargin
, nRightMargin
;
735 nTmp
= rLRItem
.GetLeft();
736 nLeftMargin
= nTmp
< 0 ? 0 : sal_uInt16(nTmp
);
737 nTmp
= rLRItem
.GetRight();
738 nRightMargin
= nTmp
< 0 ? 0 : sal_uInt16(nTmp
);
740 aText
= EE_RESSTR(RID_SVXITEMS_LRSPACE_LEFT
);
741 if ( 100 != nPropLeftMargin
)
743 aText
= aText
+ unicode::formatPercent(nPropLeftMargin
,
744 Application::GetSettings().GetUILanguageTag());
748 aText
+= GetMetricText( (long)nLeftMargin
,
749 eCoreMetric
, ePresentationMetric
, pIntl
);
750 aText
+= " " + EE_RESSTR(GetMetricId(ePresentationMetric
));
754 // We don't have a nPropFirstLineOfst
755 aText
+= EE_RESSTR(RID_SVXITEMS_LRSPACE_RIGHT
);
756 if ( 100 != nPropRightMargin
)
758 aText
= aText
+ unicode::formatPercent(nPropLeftMargin
,
759 Application::GetSettings().GetUILanguageTag());
763 aText
+= GetMetricText( (long)nRightMargin
,
764 eCoreMetric
, ePresentationMetric
, pIntl
);
765 aText
+= " " + EE_RESSTR(GetMetricId(ePresentationMetric
));
772 pIntl
= ScGlobal::GetScIntlWrapper();
773 pItem
->GetPresentation( SFX_ITEM_PRESENTATION_COMPLETE
, eCoreMetric
, ePresentationMetric
, aText
, pIntl
);
777 if ( aText
.getLength() )
779 rText
= rText
+ aText
+ aDel
;
782 pItem
= aIter
.NextItem();
785 rText
= comphelper::string::stripEnd(rText
, ' ');
786 rText
= comphelper::string::stripEnd(rText
, '+');
787 rText
= comphelper::string::stripEnd(rText
, ' ');
791 bool ScDocumentPool::GetPresentation(
792 const SfxPoolItem
& rItem
,
793 SfxMapUnit ePresentationMetric
,
795 const IntlWrapper
* pIntl
) const
797 sal_uInt16 nW
= rItem
.Which();
798 OUString
aStrYes ( ScGlobal::GetRscString(STR_YES
) );
799 OUString
aStrNo ( ScGlobal::GetRscString(STR_NO
) );
800 OUString
aStrSep(": ");
802 bool ePresentationRet
= true;
805 case ATTR_PAGE_TOPDOWN
:
806 rText
= ScGlobal::GetRscString(STR_SCATTR_PAGE_PRINTDIR
) + aStrSep
;
807 rText
+= static_cast<const SfxBoolItem
&>(rItem
).GetValue() ?
808 ScGlobal::GetRscString(STR_SCATTR_PAGE_TOPDOWN
) :
809 ScGlobal::GetRscString(STR_SCATTR_PAGE_LEFTRIGHT
) ;
812 case ATTR_PAGE_HEADERS
:
813 rText
= ScGlobal::GetRscString(STR_SCATTR_PAGE_HEADERS
) + aStrSep
;
814 rText
+= static_cast<const SfxBoolItem
&>(rItem
).GetValue() ? aStrYes
: aStrNo
;
817 case ATTR_PAGE_NULLVALS
:
818 rText
= ScGlobal::GetRscString(STR_SCATTR_PAGE_NULLVALS
) + aStrSep
;
819 rText
+= static_cast<const SfxBoolItem
&>(rItem
).GetValue() ? aStrYes
: aStrNo
;
822 case ATTR_PAGE_FORMULAS
:
823 rText
= ScGlobal::GetRscString(STR_SCATTR_PAGE_FORMULAS
) + aStrSep
;
824 rText
+= static_cast<const SfxBoolItem
&>(rItem
).GetValue() ? aStrYes
: aStrNo
;
827 case ATTR_PAGE_NOTES
:
828 rText
= ScGlobal::GetRscString(STR_SCATTR_PAGE_NOTES
) + aStrSep
;
829 rText
+= static_cast<const SfxBoolItem
&>(rItem
).GetValue() ? aStrYes
: aStrNo
;
833 rText
= ScGlobal::GetRscString(STR_SCATTR_PAGE_GRID
) + aStrSep
;
834 rText
+= static_cast<const SfxBoolItem
&>(rItem
).GetValue() ? aStrYes
: aStrNo
;
837 case ATTR_PAGE_SCALETOPAGES
:
839 sal_uInt16 nPagNo
= static_cast<const SfxUInt16Item
&>(rItem
).GetValue();
843 rText
= ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALETOPAGES
) + aStrSep
;
844 OUString
aPages( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_PAGES
) );
845 aPages
= aPages
.replaceFirst( "%1", OUString::number( nPagNo
) );
850 ePresentationRet
= false;
855 case ATTR_PAGE_FIRSTPAGENO
:
857 sal_uInt16 nPagNo
= static_cast<const SfxUInt16Item
&>(rItem
).GetValue();
861 rText
= ScGlobal::GetRscString(STR_SCATTR_PAGE_FIRSTPAGENO
) + aStrSep
;
862 rText
+= OUString::number( nPagNo
);
866 ePresentationRet
= false;
871 case ATTR_PAGE_SCALE
:
873 sal_uInt16 nPercent
= static_cast<const SfxUInt16Item
&>(rItem
).GetValue();
877 rText
= ScGlobal::GetRscString(STR_SCATTR_PAGE_SCALE
) + aStrSep
;
878 rText
= rText
+ unicode::formatPercent(nPercent
,
879 Application::GetSettings().GetUILanguageTag());
883 ePresentationRet
= false;
888 case ATTR_PAGE_HEADERSET
:
892 if( lcl_HFPresentation( rItem
, GetMetric( nW
), ePresentationMetric
, aBuffer
, pIntl
) )
894 rText
= ScGlobal::GetRscString(STR_HEADER
) + " ( " + aBuffer
+ " ) ";
899 case ATTR_PAGE_FOOTERSET
:
903 if( lcl_HFPresentation( rItem
, GetMetric( nW
), ePresentationMetric
, aBuffer
, pIntl
) )
905 rText
= ScGlobal::GetRscString(STR_FOOTER
) + " ( " + aBuffer
+ " ) ";
912 pIntl
= ScGlobal::GetScIntlWrapper();
913 ePresentationRet
= rItem
.GetPresentation( SFX_ITEM_PRESENTATION_COMPLETE
, GetMetric( nW
), ePresentationMetric
, rText
, pIntl
);
917 return ePresentationRet
;
920 SfxMapUnit
ScDocumentPool::GetMetric( sal_uInt16 nWhich
) const
922 // Own attributes in Twips, everything else in 1/100 mm
923 if ( nWhich
>= ATTR_STARTINDEX
&& nWhich
<= ATTR_ENDINDEX
)
924 return SFX_MAPUNIT_TWIP
;
926 return SFX_MAPUNIT_100TH_MM
;
929 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */