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 <sal/config.h>
22 #include <scitems.hxx>
24 #include <comphelper/string.hxx>
25 #include <i18nutil/unicode.hxx>
26 #include <vcl/outdev.hxx>
27 #include <vcl/svapp.hxx>
28 #include <vcl/settings.hxx>
29 #include <svl/itemiter.hxx>
30 #include <svl/stritem.hxx>
31 #include <svx/algitem.hxx>
32 #include <editeng/boxitem.hxx>
33 #include <editeng/lineitem.hxx>
34 #include <editeng/brushitem.hxx>
35 #include <editeng/charreliefitem.hxx>
36 #include <editeng/contouritem.hxx>
37 #include <editeng/colritem.hxx>
38 #include <editeng/crossedoutitem.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/editrids.hrc>
47 #include <editeng/eerdll.hxx>
48 #include <editeng/langitem.hxx>
49 #include <editeng/lrspitem.hxx>
50 #include <svx/pageitem.hxx>
51 #include <editeng/pbinitem.hxx>
52 #include <editeng/postitem.hxx>
53 #include <svx/rotmodit.hxx>
54 #include <editeng/scriptspaceitem.hxx>
55 #include <editeng/shaditem.hxx>
56 #include <editeng/shdditem.hxx>
57 #include <editeng/sizeitem.hxx>
58 #include <editeng/udlnitem.hxx>
59 #include <editeng/ulspitem.hxx>
60 #include <editeng/wghtitem.hxx>
61 #include <editeng/wrlmitem.hxx>
62 #include <editeng/xmlcnitm.hxx>
63 #include <editeng/justifyitem.hxx>
65 #include <docpool.hxx>
68 #include <globstr.hrc>
69 #include <scresid.hxx>
73 // ATTR_FONT_TWOLINES (not used) was changed to ATTR_USERDEF (not saved in binary format) in 641c
77 SvxFontItem
* getDefaultFontItem(LanguageType eLang
, DefaultFontType nFontType
, sal_uInt16 nItemId
)
79 vcl::Font aDefFont
= OutputDevice::GetDefaultFont( nFontType
, eLang
, GetDefaultFontFlags::OnlyOne
);
80 SvxFontItem
* pNewItem
= new SvxFontItem( aDefFont
.GetFamilyType(), aDefFont
.GetFamilyName(), aDefFont
.GetStyleName(),
81 aDefFont
.GetPitch(), aDefFont
.GetCharSet(), nItemId
);
88 static ItemInfoPackage
& getItemInfoPackageScDocument()
90 class ItemInfoPackageScDocument
: public ItemInfoPackage
92 typedef std::array
<ItemInfoStatic
, ATTR_ENDINDEX
- ATTR_STARTINDEX
+ 1> ItemInfoArrayScDocument
;
93 ItemInfoArrayScDocument maItemInfos
{{
94 // m_nWhich, m_pItem, m_nSlotID, m_nItemInfoFlags
95 { ATTR_FONT
, nullptr, SID_ATTR_CHAR_FONT
, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
96 { ATTR_FONT_HEIGHT
, new SvxFontHeightItem( 200, 100, ATTR_FONT_HEIGHT
), SID_ATTR_CHAR_FONTHEIGHT
, SFX_ITEMINFOFLAG_NONE
},
97 { ATTR_FONT_WEIGHT
, new SvxWeightItem( WEIGHT_NORMAL
, ATTR_FONT_WEIGHT
), SID_ATTR_CHAR_WEIGHT
, SFX_ITEMINFOFLAG_NONE
},
98 { ATTR_FONT_POSTURE
, new SvxPostureItem( ITALIC_NONE
, ATTR_FONT_POSTURE
), SID_ATTR_CHAR_POSTURE
, SFX_ITEMINFOFLAG_NONE
},
99 { ATTR_FONT_UNDERLINE
, new SvxUnderlineItem( LINESTYLE_NONE
, ATTR_FONT_UNDERLINE
), SID_ATTR_CHAR_UNDERLINE
, SFX_ITEMINFOFLAG_NONE
},
100 { ATTR_FONT_OVERLINE
, new SvxOverlineItem( LINESTYLE_NONE
, ATTR_FONT_OVERLINE
), SID_ATTR_CHAR_OVERLINE
, SFX_ITEMINFOFLAG_NONE
},
101 { ATTR_FONT_CROSSEDOUT
, new SvxCrossedOutItem( STRIKEOUT_NONE
, ATTR_FONT_CROSSEDOUT
), SID_ATTR_CHAR_STRIKEOUT
, SFX_ITEMINFOFLAG_NONE
},
102 { ATTR_FONT_CONTOUR
, new SvxContourItem( false, ATTR_FONT_CONTOUR
), SID_ATTR_CHAR_CONTOUR
, SFX_ITEMINFOFLAG_NONE
},
103 { ATTR_FONT_SHADOWED
, new SvxShadowedItem( false, ATTR_FONT_SHADOWED
), SID_ATTR_CHAR_SHADOWED
, SFX_ITEMINFOFLAG_NONE
},
104 { ATTR_FONT_COLOR
, new SvxColorItem( COL_AUTO
, ATTR_FONT_COLOR
), SID_ATTR_CHAR_COLOR
, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
105 { ATTR_FONT_LANGUAGE
, new SvxLanguageItem( LANGUAGE_DONTKNOW
, ATTR_FONT_LANGUAGE
), SID_ATTR_CHAR_LANGUAGE
, SFX_ITEMINFOFLAG_NONE
},
106 { ATTR_CJK_FONT
, nullptr, SID_ATTR_CHAR_CJK_FONT
, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
107 { ATTR_CJK_FONT_HEIGHT
, new SvxFontHeightItem( 200, 100, ATTR_CJK_FONT_HEIGHT
), SID_ATTR_CHAR_CJK_FONTHEIGHT
, SFX_ITEMINFOFLAG_NONE
},
108 { ATTR_CJK_FONT_WEIGHT
, new SvxWeightItem( WEIGHT_NORMAL
, ATTR_CJK_FONT_WEIGHT
), SID_ATTR_CHAR_CJK_WEIGHT
, SFX_ITEMINFOFLAG_NONE
},
109 { ATTR_CJK_FONT_POSTURE
, new SvxPostureItem( ITALIC_NONE
, ATTR_CJK_FONT_POSTURE
), SID_ATTR_CHAR_CJK_POSTURE
, SFX_ITEMINFOFLAG_NONE
},
110 { ATTR_CJK_FONT_LANGUAGE
, new SvxLanguageItem( LANGUAGE_DONTKNOW
, ATTR_CJK_FONT_LANGUAGE
), SID_ATTR_CHAR_CJK_LANGUAGE
, SFX_ITEMINFOFLAG_NONE
},
111 { ATTR_CTL_FONT
, nullptr, SID_ATTR_CHAR_CTL_FONT
, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
112 { ATTR_CTL_FONT_HEIGHT
, new SvxFontHeightItem( 200, 100, ATTR_CTL_FONT_HEIGHT
), SID_ATTR_CHAR_CTL_FONTHEIGHT
, SFX_ITEMINFOFLAG_NONE
},
113 { ATTR_CTL_FONT_WEIGHT
, new SvxWeightItem( WEIGHT_NORMAL
, ATTR_CTL_FONT_WEIGHT
), SID_ATTR_CHAR_CTL_WEIGHT
, SFX_ITEMINFOFLAG_NONE
},
114 { ATTR_CTL_FONT_POSTURE
, new SvxPostureItem( ITALIC_NONE
, ATTR_CTL_FONT_POSTURE
), SID_ATTR_CHAR_CTL_POSTURE
, SFX_ITEMINFOFLAG_NONE
},
115 { ATTR_CTL_FONT_LANGUAGE
, new SvxLanguageItem( LANGUAGE_DONTKNOW
, ATTR_CTL_FONT_LANGUAGE
), SID_ATTR_CHAR_CTL_LANGUAGE
, SFX_ITEMINFOFLAG_NONE
},
116 { ATTR_FONT_EMPHASISMARK
, new SvxEmphasisMarkItem( FontEmphasisMark::NONE
, ATTR_FONT_EMPHASISMARK
), SID_ATTR_CHAR_EMPHASISMARK
, SFX_ITEMINFOFLAG_NONE
},
117 { ATTR_USERDEF
, new SvXMLAttrContainerItem( ATTR_USERDEF
), 0, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
118 { ATTR_FONT_WORDLINE
, new SvxWordLineModeItem(false, ATTR_FONT_WORDLINE
), SID_ATTR_CHAR_WORDLINEMODE
, SFX_ITEMINFOFLAG_NONE
},
119 { ATTR_FONT_RELIEF
, new SvxCharReliefItem( FontRelief::NONE
, ATTR_FONT_RELIEF
), SID_ATTR_CHAR_RELIEF
, SFX_ITEMINFOFLAG_NONE
},
120 { ATTR_HYPHENATE
, new ScHyphenateCell(), SID_ATTR_ALIGN_HYPHENATION
, SFX_ITEMINFOFLAG_NONE
},
121 { ATTR_SCRIPTSPACE
, new SvxScriptSpaceItem( false, ATTR_SCRIPTSPACE
), 0, SFX_ITEMINFOFLAG_NONE
},
122 { ATTR_HANGPUNCTUATION
, new SvxHangingPunctuationItem( false, ATTR_HANGPUNCTUATION
), 0, SFX_ITEMINFOFLAG_NONE
},
123 { ATTR_FORBIDDEN_RULES
, new SvxForbiddenRuleItem( false, ATTR_FORBIDDEN_RULES
), SID_ATTR_PARA_FORBIDDEN_RULES
, SFX_ITEMINFOFLAG_NONE
},
124 { ATTR_HOR_JUSTIFY
, new SvxHorJustifyItem( SvxCellHorJustify::Standard
, ATTR_HOR_JUSTIFY
), SID_ATTR_ALIGN_HOR_JUSTIFY
, SFX_ITEMINFOFLAG_NONE
},
125 { ATTR_HOR_JUSTIFY_METHOD
, new SvxJustifyMethodItem( SvxCellJustifyMethod::Auto
, ATTR_HOR_JUSTIFY_METHOD
), SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD
, SFX_ITEMINFOFLAG_NONE
},
126 { ATTR_INDENT
, new ScIndentItem( 0 ), SID_ATTR_ALIGN_INDENT
, SFX_ITEMINFOFLAG_NONE
},
127 { ATTR_VER_JUSTIFY
, new SvxVerJustifyItem( SvxCellVerJustify::Standard
, ATTR_VER_JUSTIFY
), SID_ATTR_ALIGN_VER_JUSTIFY
, SFX_ITEMINFOFLAG_NONE
},
128 { ATTR_VER_JUSTIFY_METHOD
, new SvxJustifyMethodItem( SvxCellJustifyMethod::Auto
, ATTR_VER_JUSTIFY_METHOD
), SID_ATTR_ALIGN_VER_JUSTIFY_METHOD
, SFX_ITEMINFOFLAG_NONE
},
129 { ATTR_STACKED
, new ScVerticalStackCell(false), SID_ATTR_ALIGN_STACKED
, SFX_ITEMINFOFLAG_NONE
},
130 { ATTR_ROTATE_VALUE
, new ScRotateValueItem( 0_deg100
), SID_ATTR_ALIGN_DEGREES
, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
131 { ATTR_ROTATE_MODE
, new SvxRotateModeItem( SVX_ROTATE_MODE_BOTTOM
, ATTR_ROTATE_MODE
), SID_ATTR_ALIGN_LOCKPOS
, SFX_ITEMINFOFLAG_NONE
},
132 { ATTR_VERTICAL_ASIAN
, new SfxBoolItem( ATTR_VERTICAL_ASIAN
), SID_ATTR_ALIGN_ASIANVERTICAL
, SFX_ITEMINFOFLAG_NONE
},
134 // The default for the ATTR_WRITINGDIR cell attribute must by SvxFrameDirection::Environment,
135 // so that value is returned when asking for a default cell's attributes.
136 // The value from the page style is set as DefaultHorizontalTextDirection for the EditEngine.
137 { ATTR_WRITINGDIR
, new SvxFrameDirectionItem( SvxFrameDirection::Environment
, ATTR_WRITINGDIR
), SID_ATTR_FRAMEDIRECTION
, SFX_ITEMINFOFLAG_NONE
},
139 { ATTR_LINEBREAK
, new ScLineBreakCell(), SID_ATTR_ALIGN_LINEBREAK
, SFX_ITEMINFOFLAG_NONE
},
140 { ATTR_SHRINKTOFIT
, new ScShrinkToFitCell(), SID_ATTR_ALIGN_SHRINKTOFIT
, SFX_ITEMINFOFLAG_NONE
},
141 { ATTR_BORDER_TLBR
, new SvxLineItem( ATTR_BORDER_TLBR
), SID_ATTR_BORDER_DIAG_TLBR
, SFX_ITEMINFOFLAG_NONE
},
142 { ATTR_BORDER_BLTR
, new SvxLineItem( ATTR_BORDER_BLTR
), SID_ATTR_BORDER_DIAG_BLTR
, SFX_ITEMINFOFLAG_NONE
},
143 { ATTR_MARGIN
, new SvxMarginItem( ATTR_MARGIN
), SID_ATTR_ALIGN_MARGIN
, SFX_ITEMINFOFLAG_NONE
},
144 { ATTR_MERGE
, new ScMergeAttr
, 0, SFX_ITEMINFOFLAG_NONE
},
145 { ATTR_MERGE_FLAG
, new ScMergeFlagAttr
, 0, SFX_ITEMINFOFLAG_NONE
},
146 { ATTR_VALUE_FORMAT
, new SfxUInt32Item( ATTR_VALUE_FORMAT
, 0 ), SID_ATTR_NUMBERFORMAT_VALUE
, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
147 { ATTR_LANGUAGE_FORMAT
, new SvxLanguageItem( ScGlobal::eLnge
, ATTR_LANGUAGE_FORMAT
), 0, SFX_ITEMINFOFLAG_NONE
},
148 { ATTR_BACKGROUND
, new SvxBrushItem( COL_TRANSPARENT
, ATTR_BACKGROUND
), SID_ATTR_BRUSH
, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
149 { ATTR_PROTECTION
, new ScProtectionAttr
, SID_SCATTR_PROTECTION
, SFX_ITEMINFOFLAG_NONE
},
150 { ATTR_BORDER
, new SvxBoxItem( ATTR_BORDER
), SID_ATTR_BORDER_OUTER
, SFX_ITEMINFOFLAG_NONE
},
151 { ATTR_BORDER_INNER
,nullptr, SID_ATTR_BORDER_INNER
, SFX_ITEMINFOFLAG_NONE
},
152 { ATTR_SHADOW
, new SvxShadowItem( ATTR_SHADOW
), SID_ATTR_BORDER_SHADOW
, SFX_ITEMINFOFLAG_NONE
},
153 { ATTR_VALIDDATA
, new SfxUInt32Item( ATTR_VALIDDATA
, 0 ), 0, SFX_ITEMINFOFLAG_NONE
},
154 { ATTR_CONDITIONAL
, new ScCondFormatItem
, 0, SFX_ITEMINFOFLAG_NONE
},
155 { ATTR_HYPERLINK
, new SfxStringItem( ATTR_HYPERLINK
, OUString() ) , 0, SFX_ITEMINFOFLAG_NONE
},
156 { ATTR_LRSPACE
, new SvxLRSpaceItem( ATTR_LRSPACE
), SID_ATTR_LRSPACE
, SFX_ITEMINFOFLAG_NONE
},
157 { ATTR_ULSPACE
, new SvxULSpaceItem( ATTR_ULSPACE
), SID_ATTR_ULSPACE
, SFX_ITEMINFOFLAG_NONE
},
158 { ATTR_PAGE
, new SvxPageItem( ATTR_PAGE
), SID_ATTR_PAGE
, SFX_ITEMINFOFLAG_NONE
},
159 { ATTR_PAGE_PAPERBIN
, new SvxPaperBinItem( ATTR_PAGE_PAPERBIN
), SID_ATTR_PAGE_PAPERBIN
, SFX_ITEMINFOFLAG_NONE
},
160 { ATTR_PAGE_SIZE
, new SvxSizeItem( ATTR_PAGE_SIZE
), SID_ATTR_PAGE_SIZE
, SFX_ITEMINFOFLAG_NONE
},
161 { ATTR_PAGE_HORCENTER
, new SfxBoolItem( ATTR_PAGE_HORCENTER
), SID_ATTR_PAGE_EXT1
, SFX_ITEMINFOFLAG_NONE
},
162 { ATTR_PAGE_VERCENTER
, new SfxBoolItem( ATTR_PAGE_VERCENTER
), SID_ATTR_PAGE_EXT2
, SFX_ITEMINFOFLAG_NONE
},
163 { ATTR_PAGE_ON
, new SfxBoolItem( ATTR_PAGE_ON
, true ), SID_ATTR_PAGE_ON
, SFX_ITEMINFOFLAG_NONE
},
164 { ATTR_PAGE_DYNAMIC
, new SfxBoolItem( ATTR_PAGE_DYNAMIC
, true ), SID_ATTR_PAGE_DYNAMIC
, SFX_ITEMINFOFLAG_NONE
},
165 { ATTR_PAGE_SHARED
, new SfxBoolItem( ATTR_PAGE_SHARED
, true ), SID_ATTR_PAGE_SHARED
, SFX_ITEMINFOFLAG_NONE
},
166 { ATTR_PAGE_SHARED_FIRST
, new SfxBoolItem( ATTR_PAGE_SHARED_FIRST
, true ), SID_ATTR_PAGE_SHARED_FIRST
, SFX_ITEMINFOFLAG_NONE
},
167 { ATTR_PAGE_NOTES
, new SfxBoolItem( ATTR_PAGE_NOTES
, false ), 0, SFX_ITEMINFOFLAG_NONE
},
168 { ATTR_PAGE_GRID
, new SfxBoolItem( ATTR_PAGE_GRID
, false ), 0, SFX_ITEMINFOFLAG_NONE
},
169 { ATTR_PAGE_HEADERS
, new SfxBoolItem( ATTR_PAGE_HEADERS
, false ), 0, SFX_ITEMINFOFLAG_NONE
},
170 { ATTR_PAGE_CHARTS
, new ScViewObjectModeItem( ATTR_PAGE_CHARTS
), 0, SFX_ITEMINFOFLAG_NONE
},
171 { ATTR_PAGE_OBJECTS
, new ScViewObjectModeItem( ATTR_PAGE_OBJECTS
), 0, SFX_ITEMINFOFLAG_NONE
},
172 { ATTR_PAGE_DRAWINGS
, new ScViewObjectModeItem( ATTR_PAGE_DRAWINGS
), 0, SFX_ITEMINFOFLAG_NONE
},
173 { ATTR_PAGE_TOPDOWN
, new SfxBoolItem( ATTR_PAGE_TOPDOWN
, true ), 0, SFX_ITEMINFOFLAG_NONE
},
174 { ATTR_PAGE_SCALE
, new SfxUInt16Item( ATTR_PAGE_SCALE
, 100 ), 0, SFX_ITEMINFOFLAG_NONE
},
175 { ATTR_PAGE_SCALETOPAGES
, new SfxUInt16Item( ATTR_PAGE_SCALETOPAGES
, 1 ), 0, SFX_ITEMINFOFLAG_NONE
},
176 { ATTR_PAGE_FIRSTPAGENO
, new SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO
, 1 ), 0, SFX_ITEMINFOFLAG_NONE
},
177 { ATTR_PAGE_HEADERLEFT
, new ScPageHFItem( ATTR_PAGE_HEADERLEFT
), 0, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
178 { ATTR_PAGE_FOOTERLEFT
, new ScPageHFItem( ATTR_PAGE_FOOTERLEFT
), 0, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
179 { ATTR_PAGE_HEADERRIGHT
, new ScPageHFItem( ATTR_PAGE_HEADERRIGHT
), 0, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
180 { ATTR_PAGE_FOOTERRIGHT
, new ScPageHFItem( ATTR_PAGE_FOOTERRIGHT
), 0, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
181 { ATTR_PAGE_HEADERFIRST
, new ScPageHFItem( ATTR_PAGE_HEADERFIRST
), 0, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
182 { ATTR_PAGE_FOOTERFIRST
, new ScPageHFItem( ATTR_PAGE_FOOTERFIRST
), 0, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
},
183 { ATTR_PAGE_HEADERSET
, nullptr, SID_ATTR_PAGE_HEADERSET
, SFX_ITEMINFOFLAG_NONE
},
184 { ATTR_PAGE_FOOTERSET
, nullptr, SID_ATTR_PAGE_FOOTERSET
, SFX_ITEMINFOFLAG_NONE
},
185 { ATTR_PAGE_FORMULAS
, new SfxBoolItem( ATTR_PAGE_FORMULAS
, false ), 0, SFX_ITEMINFOFLAG_NONE
},
186 { ATTR_PAGE_NULLVALS
, new SfxBoolItem( ATTR_PAGE_NULLVALS
, true ), 0, SFX_ITEMINFOFLAG_NONE
},
187 { ATTR_PAGE_SCALETO
, new ScPageScaleToItem( 1, 1 ), 0, SFX_ITEMINFOFLAG_NONE
},
188 { ATTR_HIDDEN
, new SfxBoolItem( ATTR_HIDDEN
, false ), 0, SFX_ITEMINFOFLAG_NONE
}
191 virtual const ItemInfoStatic
& getItemInfoStatic(size_t nIndex
) const override
{ return maItemInfos
[nIndex
]; }
194 ItemInfoPackageScDocument()
196 LanguageType nDefLang
, nCjkLang
, nCtlLang
;
197 ScModule::GetSpellSettings( nDefLang
, nCjkLang
, nCtlLang
);
199 // latin font from GetDefaultFonts is not used, DEFAULTFONT_LATIN_SPREADSHEET instead
200 SvxFontItem
* pStdFont
= getDefaultFontItem(nDefLang
, DefaultFontType::LATIN_SPREADSHEET
, ATTR_FONT
);
201 SvxFontItem
* pCjkFont
= getDefaultFontItem(nCjkLang
, DefaultFontType::CJK_SPREADSHEET
, ATTR_CJK_FONT
);
202 SvxFontItem
* pCtlFont
= getDefaultFontItem(nCtlLang
, DefaultFontType::CTL_SPREADSHEET
, ATTR_CTL_FONT
);
203 setItemAtItemInfoStatic(pStdFont
, maItemInfos
[ATTR_FONT
- ATTR_STARTINDEX
]);
204 setItemAtItemInfoStatic(pCjkFont
, maItemInfos
[ATTR_CJK_FONT
- ATTR_STARTINDEX
]);
205 setItemAtItemInfoStatic(pCtlFont
, maItemInfos
[ATTR_CTL_FONT
- ATTR_STARTINDEX
]);
207 SvxBoxInfoItem
* pGlobalBorderInnerAttr
= new SvxBoxInfoItem( ATTR_BORDER_INNER
);
208 pGlobalBorderInnerAttr
->SetLine(nullptr, SvxBoxInfoItemLine::HORI
);
209 pGlobalBorderInnerAttr
->SetLine(nullptr, SvxBoxInfoItemLine::VERT
);
210 pGlobalBorderInnerAttr
->SetTable(true);
211 pGlobalBorderInnerAttr
->SetDist(true);
212 pGlobalBorderInnerAttr
->SetMinDist(false);
213 setItemAtItemInfoStatic(pGlobalBorderInnerAttr
, maItemInfos
[ATTR_BORDER_INNER
- ATTR_STARTINDEX
]);
215 virtual size_t size() const override
{ return maItemInfos
.size(); }
216 virtual const ItemInfo
& getItemInfo(size_t nIndex
, SfxItemPool
& rPool
) override
218 const ItemInfo
& rRetval(maItemInfos
[nIndex
]);
220 // return immediately if we have the static entry and Item
221 if (nullptr != rRetval
.getItem())
224 if (ATTR_PAGE_HEADERSET
== rRetval
.getWhich())
226 SfxItemSet
aSetItemItemSet(rPool
,
228 ATTR_BACKGROUND
, ATTR_BACKGROUND
,
229 ATTR_BORDER
, ATTR_SHADOW
,
230 ATTR_LRSPACE
, ATTR_ULSPACE
,
231 ATTR_PAGE_SIZE
, ATTR_PAGE_SIZE
,
232 ATTR_PAGE_ON
, ATTR_PAGE_SHARED_FIRST
>);
233 return *new ItemInfoDynamic(rRetval
, new SvxSetItem(ATTR_PAGE_HEADERSET
, aSetItemItemSet
));
236 if (ATTR_PAGE_FOOTERSET
== rRetval
.getWhich())
238 SfxItemSet
aSetItemItemSet(rPool
,
240 ATTR_BACKGROUND
, ATTR_BACKGROUND
,
241 ATTR_BORDER
, ATTR_SHADOW
,
242 ATTR_LRSPACE
, ATTR_ULSPACE
,
243 ATTR_PAGE_SIZE
, ATTR_PAGE_SIZE
,
244 ATTR_PAGE_ON
, ATTR_PAGE_SHARED_FIRST
>);
245 return *new ItemInfoDynamic(rRetval
, new SvxSetItem(ATTR_PAGE_FOOTERSET
, aSetItemItemSet
));
248 // return in any case
253 static std::unique_ptr
<ItemInfoPackageScDocument
> g_aItemInfoPackageScDocument
;
254 if (!g_aItemInfoPackageScDocument
)
255 g_aItemInfoPackageScDocument
.reset(new ItemInfoPackageScDocument
);
256 return *g_aItemInfoPackageScDocument
;
259 ScDocumentPool::ScDocumentPool()
260 : SfxItemPool(u
"ScDocumentPool"_ustr
)
262 registerItemInfoPackage(getItemInfoPackageScDocument());
265 ScDocumentPool::~ScDocumentPool()
268 SetSecondaryPool(nullptr);
271 rtl::Reference
<SfxItemPool
> ScDocumentPool::Clone() const
273 return new SfxItemPool(*this);
276 static bool lcl_HFPresentation
278 const SfxPoolItem
& rItem
,
280 MapUnit ePresentationMetric
,
282 const IntlWrapper
& rIntl
285 const SfxItemSet
& rSet
= static_cast<const SfxSetItem
&>(rItem
).GetItemSet();
287 if ( const SfxBoolItem
* pItem
= rSet
.GetItemIfSet(ATTR_PAGE_ON
,false) )
289 if( !pItem
->GetValue() )
293 SfxItemIter
aIter( rSet
);
295 for (const SfxPoolItem
* pItem
= aIter
.GetCurItem(); pItem
; pItem
= aIter
.NextItem())
297 sal_uInt16 nWhich
= pItem
->Which();
304 case ATTR_PAGE_DYNAMIC
:
305 case ATTR_PAGE_SHARED
:
306 case ATTR_PAGE_SHARED_FIRST
:
311 const SvxLRSpaceItem
& rLRItem
= static_cast<const SvxLRSpaceItem
&>(*pItem
);
312 sal_uInt16 nPropLeftMargin
= rLRItem
.GetPropLeft();
313 sal_uInt16 nPropRightMargin
= rLRItem
.GetPropRight();
314 sal_uInt16 nLeftMargin
, nRightMargin
;
316 nTmp
= rLRItem
.ResolveLeft({});
317 nLeftMargin
= nTmp
< 0 ? 0 : sal_uInt16(nTmp
);
318 nTmp
= rLRItem
.ResolveRight({});
319 nRightMargin
= nTmp
< 0 ? 0 : sal_uInt16(nTmp
);
321 aText
= EditResId(RID_SVXITEMS_LRSPACE_LEFT
);
322 if ( 100 != nPropLeftMargin
)
324 aText
+= unicode::formatPercent(nPropLeftMargin
,
325 Application::GetSettings().GetUILanguageTag());
329 aText
+= GetMetricText( static_cast<tools::Long
>(nLeftMargin
),
330 eCoreMetric
, ePresentationMetric
, &rIntl
) +
331 " " + EditResId(GetMetricId(ePresentationMetric
));
334 // We don't have a nPropFirstLineOffset
335 EditResId(RID_SVXITEMS_LRSPACE_RIGHT
);
336 if ( 100 != nPropRightMargin
)
338 aText
+= unicode::formatPercent(nPropLeftMargin
,
339 Application::GetSettings().GetUILanguageTag());
343 aText
+= GetMetricText( static_cast<tools::Long
>(nRightMargin
),
344 eCoreMetric
, ePresentationMetric
, &rIntl
) +
345 " " + EditResId(GetMetricId(ePresentationMetric
));
351 pItem
->GetPresentation( SfxItemPresentation::Complete
, eCoreMetric
, ePresentationMetric
, aText
, rIntl
);
355 if ( aText
.getLength() )
357 rText
+= aText
+ " + ";
361 rText
= comphelper::string::stripEnd(rText
, ' ');
362 rText
= comphelper::string::stripEnd(rText
, '+');
363 rText
= comphelper::string::stripEnd(rText
, ' ');
367 bool ScDocumentPool::GetPresentation(
368 const SfxPoolItem
& rItem
,
369 MapUnit ePresentationMetric
,
371 const IntlWrapper
& rIntl
) const
373 sal_uInt16 nW
= rItem
.Which();
374 OUString
aStrYes ( ScResId(STR_YES
) );
375 OUString
aStrNo ( ScResId(STR_NO
) );
376 OUString
aStrSep(u
": "_ustr
);
378 bool ePresentationRet
= true;
381 case ATTR_PAGE_TOPDOWN
:
382 rText
= ScResId(STR_SCATTR_PAGE_PRINTDIR
) + aStrSep
;
383 rText
+= static_cast<const SfxBoolItem
&>(rItem
).GetValue() ?
384 ScResId(STR_SCATTR_PAGE_TOPDOWN
) :
385 ScResId(STR_SCATTR_PAGE_LEFTRIGHT
) ;
388 case ATTR_PAGE_HEADERS
:
389 rText
= ScResId(STR_SCATTR_PAGE_HEADERS
) + aStrSep
;
390 rText
+= static_cast<const SfxBoolItem
&>(rItem
).GetValue() ? aStrYes
: aStrNo
;
393 case ATTR_PAGE_NULLVALS
:
394 rText
= ScResId(STR_SCATTR_PAGE_NULLVALS
) + aStrSep
;
395 rText
+= static_cast<const SfxBoolItem
&>(rItem
).GetValue() ? aStrYes
: aStrNo
;
398 case ATTR_PAGE_FORMULAS
:
399 rText
= ScResId(STR_SCATTR_PAGE_FORMULAS
) + aStrSep
;
400 rText
+= static_cast<const SfxBoolItem
&>(rItem
).GetValue() ? aStrYes
: aStrNo
;
403 case ATTR_PAGE_NOTES
:
404 rText
= ScResId(STR_SCATTR_PAGE_NOTES
) + aStrSep
;
405 rText
+= static_cast<const SfxBoolItem
&>(rItem
).GetValue() ? aStrYes
: aStrNo
;
409 rText
= ScResId(STR_SCATTR_PAGE_GRID
) + aStrSep
;
410 rText
+= static_cast<const SfxBoolItem
&>(rItem
).GetValue() ? aStrYes
: aStrNo
;
413 case ATTR_PAGE_SCALETOPAGES
:
415 sal_uInt16 nPagNo
= static_cast<const SfxUInt16Item
&>(rItem
).GetValue();
419 rText
= ScResId( STR_SCATTR_PAGE_SCALETOPAGES
) + aStrSep
;
420 OUString
aPages(ScResId(STR_SCATTR_PAGE_SCALE_PAGES
, nPagNo
));
421 aPages
= aPages
.replaceFirst( "%1", OUString::number( nPagNo
) );
426 ePresentationRet
= false;
431 case ATTR_PAGE_FIRSTPAGENO
:
433 sal_uInt16 nPagNo
= static_cast<const SfxUInt16Item
&>(rItem
).GetValue();
437 rText
= ScResId(STR_SCATTR_PAGE_FIRSTPAGENO
) + aStrSep
;
438 rText
+= OUString::number( nPagNo
);
442 ePresentationRet
= false;
447 case ATTR_PAGE_SCALE
:
449 sal_uInt16 nPercent
= static_cast<const SfxUInt16Item
&>(rItem
).GetValue();
453 rText
= ScResId(STR_SCATTR_PAGE_SCALE
) + aStrSep
;
454 rText
+= unicode::formatPercent(nPercent
,
455 Application::GetSettings().GetUILanguageTag());
459 ePresentationRet
= false;
464 case ATTR_PAGE_HEADERSET
:
468 if( lcl_HFPresentation( rItem
, GetMetric( nW
), ePresentationMetric
, aBuffer
, rIntl
) )
470 rText
= ScResId(STR_HEADER
) + " ( " + aBuffer
+ " ) ";
475 case ATTR_PAGE_FOOTERSET
:
479 if( lcl_HFPresentation( rItem
, GetMetric( nW
), ePresentationMetric
, aBuffer
, rIntl
) )
481 rText
= ScResId(STR_FOOTER
) + " ( " + aBuffer
+ " ) ";
487 ePresentationRet
= rItem
.GetPresentation( SfxItemPresentation::Complete
, GetMetric( nW
), ePresentationMetric
, rText
, rIntl
);
491 return ePresentationRet
;
494 MapUnit
ScDocumentPool::GetMetric( sal_uInt16 nWhich
) const
496 // Own attributes in Twips, everything else in 1/100 mm
497 if ( nWhich
>= ATTR_STARTINDEX
&& nWhich
<= ATTR_ENDINDEX
)
498 return MapUnit::MapTwip
;
500 return MapUnit::Map100thMM
;
503 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */