/src/libreoffice/svx/source/dialog/svxbmpnumvalueset.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <sal/config.h> |
21 | | |
22 | | #include <svx/dialmgr.hxx> |
23 | | #include <svx/strings.hrc> |
24 | | #include <comphelper/diagnose_ex.hxx> |
25 | | #include <i18nlangtag/mslangid.hxx> |
26 | | #include <svtools/valueset.hxx> |
27 | | #include <unotools/fontdefs.hxx> |
28 | | #include <editeng/numitem.hxx> |
29 | | #include <officecfg/Office/Common.hxx> |
30 | | #include <svx/gallery.hxx> |
31 | | #include <vcl/event.hxx> |
32 | | #include <vcl/graph.hxx> |
33 | | #include <vcl/rendercontext/GetDefaultFontFlags.hxx> |
34 | | #include <vcl/virdev.hxx> |
35 | | #include <vcl/weld/ScrolledWindow.hxx> |
36 | | #include <svx/numvset.hxx> |
37 | | #include <com/sun/star/style/NumberingType.hpp> |
38 | | #include <com/sun/star/container/XIndexAccess.hpp> |
39 | | #include <com/sun/star/text/XNumberingFormatter.hpp> |
40 | | #include <com/sun/star/beans/PropertyValue.hpp> |
41 | | |
42 | | #include <algorithm> |
43 | | |
44 | | #include <uiobject.hxx> |
45 | | |
46 | | using namespace com::sun::star::uno; |
47 | | using namespace com::sun::star::beans; |
48 | | using namespace com::sun::star::lang; |
49 | | using namespace com::sun::star::text; |
50 | | using namespace com::sun::star::container; |
51 | | using namespace com::sun::star::style; |
52 | | |
53 | | static vcl::Font& lcl_GetDefaultBulletFont() |
54 | 0 | { |
55 | 0 | static vcl::Font aDefBulletFont = []() |
56 | 0 | { |
57 | 0 | static vcl::Font tmp(u"OpenSymbol"_ustr, u""_ustr, Size(0, 14)); |
58 | 0 | tmp.SetCharSet( RTL_TEXTENCODING_SYMBOL ); |
59 | 0 | tmp.SetFamily( FAMILY_DONTKNOW ); |
60 | 0 | tmp.SetPitch( PITCH_DONTKNOW ); |
61 | 0 | tmp.SetWeight( WEIGHT_DONTKNOW ); |
62 | 0 | tmp.SetTransparent( true ); |
63 | 0 | return tmp; |
64 | 0 | }(); |
65 | 0 | return aDefBulletFont; |
66 | 0 | } |
67 | | |
68 | | static void lcl_PaintLevel(OutputDevice* pVDev, sal_Int16 nNumberingType, |
69 | | const OUString& rBulletChar, const OUString& rText, const OUString& rFontName, |
70 | | Point& rLeft, vcl::Font& rRuleFont, const vcl::Font& rTextFont) |
71 | 0 | { |
72 | |
|
73 | 0 | if(NumberingType::CHAR_SPECIAL == nNumberingType ) |
74 | 0 | { |
75 | 0 | rRuleFont.SetStyleName(rFontName); |
76 | 0 | pVDev->SetFont(rRuleFont); |
77 | 0 | pVDev->DrawText(rLeft, rBulletChar); |
78 | 0 | rLeft.AdjustX(pVDev->GetTextWidth(rBulletChar) ); |
79 | 0 | } |
80 | 0 | else |
81 | 0 | { |
82 | 0 | pVDev->SetFont(rTextFont); |
83 | 0 | pVDev->DrawText(rLeft, rText); |
84 | 0 | rLeft.AdjustX(pVDev->GetTextWidth(rText) ); |
85 | 0 | } |
86 | 0 | } |
87 | | |
88 | | const TranslateId RID_SVXSTR_SINGLENUM_DESCRIPTIONS[] = |
89 | | { |
90 | | RID_SVXSTR_SINGLENUM_DESCRIPTION_0, |
91 | | RID_SVXSTR_SINGLENUM_DESCRIPTION_1, |
92 | | RID_SVXSTR_SINGLENUM_DESCRIPTION_2, |
93 | | RID_SVXSTR_SINGLENUM_DESCRIPTION_3, |
94 | | RID_SVXSTR_SINGLENUM_DESCRIPTION_4, |
95 | | RID_SVXSTR_SINGLENUM_DESCRIPTION_5, |
96 | | RID_SVXSTR_SINGLENUM_DESCRIPTION_6, |
97 | | RID_SVXSTR_SINGLENUM_DESCRIPTION_7 |
98 | | }; |
99 | | |
100 | | const TranslateId RID_SVXSTR_OUTLINENUM_DESCRIPTIONS[] = |
101 | | { |
102 | | RID_SVXSTR_OUTLINENUM_DESCRIPTION_0, |
103 | | RID_SVXSTR_OUTLINENUM_DESCRIPTION_1, |
104 | | RID_SVXSTR_OUTLINENUM_DESCRIPTION_2, |
105 | | RID_SVXSTR_OUTLINENUM_DESCRIPTION_3, |
106 | | RID_SVXSTR_OUTLINENUM_DESCRIPTION_4, |
107 | | RID_SVXSTR_OUTLINENUM_DESCRIPTION_5, |
108 | | RID_SVXSTR_OUTLINENUM_DESCRIPTION_6, |
109 | | RID_SVXSTR_OUTLINENUM_DESCRIPTION_7 |
110 | | }; |
111 | | |
112 | | void SvxNumValueSet::UserDraw( const UserDrawEvent& rUDEvt ) |
113 | 0 | { |
114 | 0 | static const sal_uInt16 aLinesArr[] = |
115 | 0 | { |
116 | 0 | 15, 10, |
117 | 0 | 20, 30, |
118 | 0 | 25, 50, |
119 | 0 | 30, 70, |
120 | 0 | 35, 90, // up to here line positions |
121 | 0 | 5, 10, // character positions |
122 | 0 | 10, 30, |
123 | 0 | 15, 50, |
124 | 0 | 20, 70, |
125 | 0 | 25, 90, |
126 | 0 | }; |
127 | |
|
128 | 0 | const Color aBackColor(COL_WHITE); |
129 | 0 | const Color aTextColor(COL_BLACK); |
130 | |
|
131 | 0 | vcl::RenderContext* pDev = rUDEvt.GetRenderContext(); |
132 | 0 | tools::Rectangle aRect = rUDEvt.GetRect(); |
133 | 0 | sal_uInt16 nIndex = rUDEvt.GetItemId() - 1; |
134 | | |
135 | |
|
136 | 0 | tools::Long nRectWidth = aRect.GetWidth(); |
137 | 0 | tools::Long nRectHeight = aRect.GetHeight(); |
138 | 0 | Size aRectSize(nRectWidth, aRect.GetHeight()); |
139 | 0 | Point aBLPos = aRect.TopLeft(); |
140 | 0 | vcl::Font aOldFont = pDev->GetFont(); |
141 | 0 | Color aOldColor = pDev->GetLineColor(); |
142 | 0 | pDev->SetLineColor(aTextColor); |
143 | 0 | vcl::Font aFont(OutputDevice::GetDefaultFont( |
144 | 0 | DefaultFontType::UI_SANS, MsLangId::getConfiguredSystemLanguage(), GetDefaultFontFlags::OnlyOne)); |
145 | |
|
146 | 0 | Size aSize = aFont.GetFontSize(); |
147 | |
|
148 | 0 | vcl::Font aRuleFont( lcl_GetDefaultBulletFont() ); |
149 | 0 | aSize.setHeight( nRectHeight/6 ); |
150 | 0 | aRuleFont.SetFontSize(aSize); |
151 | 0 | aRuleFont.SetColor(aTextColor); |
152 | 0 | aRuleFont.SetFillColor(aBackColor); |
153 | 0 | css::uno::Sequence< OUString > aBulletSymbols; |
154 | |
|
155 | 0 | if(mePageType == NumberingPageType::BULLET || mePageType == NumberingPageType::DOCBULLET) |
156 | 0 | { |
157 | 0 | aBulletSymbols = officecfg::Office::Common::BulletsNumbering::DefaultBullets::get(); |
158 | 0 | css::uno::Sequence< OUString > aBulletFonts(officecfg::Office::Common::BulletsNumbering::DefaultBulletsFonts::get()); |
159 | 0 | aRuleFont.SetFamilyName(aBulletFonts[nIndex]); |
160 | 0 | aFont = aRuleFont; |
161 | 0 | } |
162 | 0 | else if (mePageType == NumberingPageType::DOCBULLET) |
163 | 0 | { |
164 | 0 | aRuleFont.SetFamilyName(maCustomBullets[nIndex].second); |
165 | 0 | aFont = aRuleFont; |
166 | 0 | } |
167 | 0 | else if(mePageType == NumberingPageType::OUTLINE) |
168 | 0 | { |
169 | 0 | aSize.setHeight( nRectHeight/8 ); |
170 | 0 | } |
171 | 0 | aFont.SetColor(aTextColor); |
172 | 0 | aFont.SetFillColor(aBackColor); |
173 | 0 | aFont.SetFontSize( aSize ); |
174 | 0 | pDev->SetFont(aFont); |
175 | |
|
176 | 0 | if(!mpVDev) |
177 | 0 | { |
178 | | // The lines are only one time in the virtual device, only the outline |
179 | | // page is currently done |
180 | 0 | mpVDev = VclPtr<VirtualDevice>::Create(*pDev); |
181 | 0 | mpVDev->SetMapMode(pDev->GetMapMode()); |
182 | 0 | mpVDev->EnableRTL( IsRTLEnabled() ); |
183 | 0 | mpVDev->SetOutputSize( aRectSize ); |
184 | 0 | maOrgRect = aRect; |
185 | 0 | mpVDev->SetFillColor( aBackColor ); |
186 | 0 | mpVDev->SetLineColor(COL_LIGHTGRAY); |
187 | | // Draw line only once |
188 | 0 | if(mePageType != NumberingPageType::OUTLINE) |
189 | 0 | { |
190 | 0 | Point aStart(aBLPos.X() + nRectWidth *25 / 100,0); |
191 | 0 | Point aEnd(aBLPos.X() + nRectWidth * 9 / 10,0); |
192 | 0 | for( sal_uInt16 i = 11; i < 100; i += 33) |
193 | 0 | { |
194 | 0 | aStart.setY( aBLPos.Y() + nRectHeight * i / 100 ); |
195 | 0 | aEnd.setY( aStart.Y() ); |
196 | 0 | mpVDev->DrawLine(aStart, aEnd); |
197 | 0 | aStart.setY( aBLPos.Y() + nRectHeight * (i + 11) / 100 ); |
198 | 0 | aEnd.setY( aStart.Y() ); |
199 | 0 | mpVDev->DrawLine(aStart, aEnd); |
200 | 0 | } |
201 | 0 | } |
202 | 0 | } |
203 | 0 | pDev->DrawOutDev( aRect.TopLeft(), aRectSize, |
204 | 0 | maOrgRect.TopLeft(), aRectSize, |
205 | 0 | *mpVDev ); |
206 | | // Now comes the text |
207 | 0 | static constexpr OUStringLiteral sValue(u"Value"); |
208 | 0 | if( NumberingPageType::SINGLENUM == mePageType || |
209 | 0 | NumberingPageType::BULLET == mePageType || |
210 | 0 | NumberingPageType::DOCBULLET == mePageType) |
211 | 0 | { |
212 | 0 | Point aStart(aBLPos.X() + nRectWidth / 9,0); |
213 | 0 | for( sal_uInt16 i = 0; i < 3; i++ ) |
214 | 0 | { |
215 | 0 | sal_uInt16 nY = 11 + i * 33; |
216 | 0 | aStart.setY( aBLPos.Y() + nRectHeight * nY / 100 ); |
217 | 0 | OUString sText; |
218 | 0 | if(mePageType == NumberingPageType::BULLET) |
219 | 0 | { |
220 | 0 | sText = aBulletSymbols[nIndex]; |
221 | 0 | aStart.AdjustY( -(pDev->GetTextHeight()/2) ); |
222 | 0 | aStart.setX( aBLPos.X() + 5 ); |
223 | 0 | } |
224 | 0 | else if (mePageType == NumberingPageType::DOCBULLET) |
225 | 0 | { |
226 | 0 | sText = maCustomBullets[nIndex].first; |
227 | 0 | aStart.AdjustY( -(pDev->GetTextHeight()/2) ); |
228 | 0 | aStart.setX( aBLPos.X() + 5 ); |
229 | 0 | } |
230 | 0 | else |
231 | 0 | { |
232 | 0 | if(mxFormatter.is() && maNumSettings.getLength() > nIndex) |
233 | 0 | { |
234 | 0 | Sequence<PropertyValue> aLevel = maNumSettings.getConstArray()[nIndex]; |
235 | 0 | try |
236 | 0 | { |
237 | 0 | aLevel.realloc(aLevel.getLength() + 1); |
238 | 0 | PropertyValue& rValue = aLevel.getArray()[aLevel.getLength() - 1]; |
239 | 0 | rValue.Name = sValue; |
240 | 0 | rValue.Value <<= static_cast<sal_Int32>(i + 1); |
241 | 0 | sText = mxFormatter->makeNumberingString( aLevel, maLocale ); |
242 | 0 | } |
243 | 0 | catch(Exception&) |
244 | 0 | { |
245 | 0 | TOOLS_WARN_EXCEPTION("svx.dialog", ""); |
246 | 0 | } |
247 | 0 | } |
248 | | // start just next to the left edge |
249 | 0 | aStart.setX( aBLPos.X() + 2 ); |
250 | 0 | aStart.AdjustY( -(pDev->GetTextHeight()/2) ); |
251 | 0 | } |
252 | 0 | pDev->DrawText(aStart, sText); |
253 | 0 | } |
254 | 0 | } |
255 | 0 | else if(NumberingPageType::OUTLINE == mePageType ) |
256 | 0 | { |
257 | | // Outline numbering has to be painted into the virtual device |
258 | | // to get correct lines |
259 | | // has to be made again |
260 | 0 | mpVDev->SetLineColor(aBackColor); |
261 | 0 | mpVDev->DrawRect(maOrgRect); |
262 | 0 | tools::Long nStartX = maOrgRect.Left(); |
263 | 0 | tools::Long nStartY = maOrgRect.Top(); |
264 | |
|
265 | 0 | if(mxFormatter.is() && maOutlineSettings.getLength() > nIndex) |
266 | 0 | { |
267 | 0 | Reference<XIndexAccess> xLevel = maOutlineSettings.getArray()[nIndex]; |
268 | 0 | try |
269 | 0 | { |
270 | 0 | OUString sLevelTexts[5]; |
271 | 0 | OUString sFontNames[5]; |
272 | 0 | OUString sBulletChars[5]; |
273 | 0 | sal_Int16 aNumberingTypes[5]; |
274 | 0 | OUString sPrefixes[5]; |
275 | 0 | OUString sSuffixes[5]; |
276 | 0 | sal_Int16 aParentNumberings[5]; |
277 | |
|
278 | 0 | sal_Int32 nLevelCount = xLevel->getCount(); |
279 | 0 | if(nLevelCount > 5) |
280 | 0 | nLevelCount = 5; |
281 | 0 | for( sal_Int32 i = 0; i < nLevelCount; i++) |
282 | 0 | { |
283 | 0 | tools::Long nTop = nStartY + nRectHeight * (aLinesArr[2 * i + 11])/100 ; |
284 | 0 | Point aLeft(nStartX + nRectWidth * (aLinesArr[2 * i + 10])/ 100, nTop ); |
285 | |
|
286 | 0 | Any aLevelAny = xLevel->getByIndex(i); |
287 | 0 | Sequence<PropertyValue> aLevel; |
288 | 0 | aLevelAny >>= aLevel; |
289 | 0 | aNumberingTypes[i] = 0; |
290 | 0 | aParentNumberings[i] = 0; |
291 | 0 | for (const PropertyValue& rProp : aLevel) |
292 | 0 | { |
293 | 0 | if ( rProp.Name == "NumberingType" ) |
294 | 0 | rProp.Value >>= aNumberingTypes[i]; |
295 | 0 | else if ( rProp.Name == "BulletFontName" ) |
296 | 0 | rProp.Value >>= sFontNames[i]; |
297 | 0 | else if ( rProp.Name == "BulletChar" ) |
298 | 0 | rProp.Value >>= sBulletChars[i]; |
299 | 0 | else if ( rProp.Name == "Prefix" ) |
300 | 0 | rProp.Value >>= sPrefixes[i]; |
301 | 0 | else if ( rProp.Name == "Suffix" ) |
302 | 0 | rProp.Value >>= sSuffixes[i]; |
303 | 0 | else if ( rProp.Name == "ParentNumbering" ) |
304 | 0 | rProp.Value >>= aParentNumberings[i]; |
305 | 0 | } |
306 | 0 | Sequence< PropertyValue > aProperties(2); |
307 | 0 | PropertyValue* pProperties = aProperties.getArray(); |
308 | 0 | pProperties[0].Name = "NumberingType"; |
309 | 0 | pProperties[0].Value <<= aNumberingTypes[i]; |
310 | 0 | pProperties[1].Name = "Value"; |
311 | 0 | pProperties[1].Value <<= sal_Int32(1); |
312 | 0 | try |
313 | 0 | { |
314 | 0 | sLevelTexts[i] = mxFormatter->makeNumberingString( aProperties, maLocale ); |
315 | 0 | } |
316 | 0 | catch(Exception&) |
317 | 0 | { |
318 | 0 | TOOLS_WARN_EXCEPTION("svx.dialog", ""); |
319 | 0 | } |
320 | | |
321 | 0 | aLeft.AdjustY( -(pDev->GetTextHeight()/2) ); |
322 | 0 | if(!sPrefixes[i].isEmpty() && |
323 | 0 | sPrefixes[i] != " ") |
324 | 0 | { |
325 | 0 | mpVDev->SetFont(aFont); |
326 | 0 | mpVDev->DrawText(aLeft, sPrefixes[i]); |
327 | 0 | aLeft.AdjustX(pDev->GetTextWidth(sPrefixes[i]) ); |
328 | 0 | } |
329 | 0 | if(aParentNumberings[i]) |
330 | 0 | { |
331 | | //insert old numberings here |
332 | 0 | sal_Int32 nStartLevel = std::min(static_cast<sal_Int32>(aParentNumberings[i]), i); |
333 | 0 | for(sal_Int32 nParentLevel = i - nStartLevel; nParentLevel < i; nParentLevel++) |
334 | 0 | { |
335 | 0 | OUString sTmp = sLevelTexts[nParentLevel] + "."; |
336 | 0 | lcl_PaintLevel(mpVDev, |
337 | 0 | aNumberingTypes[nParentLevel], |
338 | 0 | sBulletChars[nParentLevel], |
339 | 0 | sTmp, |
340 | 0 | sFontNames[nParentLevel], |
341 | 0 | aLeft, |
342 | 0 | aRuleFont, |
343 | 0 | aFont); |
344 | 0 | } |
345 | 0 | } |
346 | 0 | lcl_PaintLevel(mpVDev, |
347 | 0 | aNumberingTypes[i], |
348 | 0 | sBulletChars[i], |
349 | 0 | sLevelTexts[i], |
350 | 0 | sFontNames[i], |
351 | 0 | aLeft, |
352 | 0 | aRuleFont, |
353 | 0 | aFont); |
354 | 0 | if(!sSuffixes[i].isEmpty() && |
355 | 0 | !sSuffixes[i].startsWith(" ")) |
356 | 0 | { |
357 | 0 | mpVDev->SetFont(aFont); |
358 | 0 | mpVDev->DrawText(aLeft, sSuffixes[i]); |
359 | 0 | aLeft.AdjustX(pDev->GetTextWidth(sSuffixes[i]) ); |
360 | 0 | } |
361 | |
|
362 | 0 | tools::Long nLineTop = nStartY + nRectHeight * aLinesArr[2 * i + 1]/100 ; |
363 | 0 | Point aLineLeft(aLeft.X(), nLineTop ); |
364 | 0 | Point aLineRight(nStartX + nRectWidth * 90 /100, nLineTop ); |
365 | 0 | mpVDev->SetLineColor(COL_LIGHTGRAY); |
366 | 0 | mpVDev->DrawLine(aLineLeft, aLineRight); |
367 | 0 | } |
368 | |
|
369 | 0 | } |
370 | | #ifdef DBG_UTIL |
371 | | catch(Exception&) |
372 | | { |
373 | | static bool bAssert = false; |
374 | | if(!bAssert) |
375 | | { |
376 | | TOOLS_WARN_EXCEPTION("svx.dialog", ""); |
377 | | bAssert = true; |
378 | | } |
379 | | } |
380 | | #else |
381 | 0 | catch(Exception&) |
382 | 0 | { |
383 | 0 | } |
384 | 0 | #endif |
385 | 0 | } |
386 | 0 | pDev->DrawOutDev( aRect.TopLeft(), aRectSize, |
387 | 0 | maOrgRect.TopLeft(), aRectSize, |
388 | 0 | *mpVDev ); |
389 | 0 | } |
390 | | |
391 | 0 | pDev->SetFont(aOldFont); |
392 | 0 | pDev->SetLineColor(aOldColor); |
393 | 0 | } |
394 | | |
395 | | SvxNumValueSet::SvxNumValueSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow) |
396 | 0 | : ValueSet(std::move(pScrolledWindow)) |
397 | 0 | , mePageType(NumberingPageType::BULLET) |
398 | 0 | , mpVDev(nullptr) |
399 | 0 | { |
400 | 0 | } |
401 | | |
402 | | FactoryFunction SvxNumValueSet::GetUITestFactory() const |
403 | 0 | { |
404 | 0 | return SvxNumValueSetUIObject::create; |
405 | 0 | } |
406 | | |
407 | | void SvxNumValueSet::init(NumberingPageType eType) |
408 | 0 | { |
409 | 0 | mePageType = eType; |
410 | 0 | mpVDev.disposeAndClear(); |
411 | |
|
412 | 0 | SetColCount( 4 ); |
413 | 0 | SetLineCount( 2 ); |
414 | 0 | SetStyle( GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER ); |
415 | 0 | if(NumberingPageType::BULLET == eType) |
416 | 0 | { |
417 | 0 | for ( sal_uInt16 i = 0; i < 8; i++ ) |
418 | 0 | { |
419 | 0 | InsertItem( i + 1, i ); |
420 | 0 | } |
421 | 0 | } |
422 | 0 | } |
423 | | |
424 | | SvxNumValueSet::~SvxNumValueSet() |
425 | 0 | { |
426 | 0 | } |
427 | | |
428 | | void SvxNumValueSet::SetNumberingSettings( |
429 | | const Sequence<Sequence<PropertyValue> >& aNum, |
430 | | Reference<XNumberingFormatter> const & xFormat, |
431 | | const Locale& rLocale ) |
432 | 0 | { |
433 | 0 | maNumSettings = aNum; |
434 | 0 | mxFormatter = xFormat; |
435 | 0 | maLocale = rLocale; |
436 | 0 | if(aNum.getLength() > 8) |
437 | 0 | SetStyle( GetStyle()|WB_VSCROLL); |
438 | 0 | for ( sal_Int32 i = 0; i < aNum.getLength(); i++ ) |
439 | 0 | { |
440 | 0 | InsertItem(i + 1, i); |
441 | 0 | if (i < 8) |
442 | 0 | SetItemText(i + 1, SvxResId(RID_SVXSTR_SINGLENUM_DESCRIPTIONS[i])); |
443 | 0 | } |
444 | 0 | } |
445 | | |
446 | | void SvxNumValueSet::SetOutlineNumberingSettings( |
447 | | Sequence<Reference<XIndexAccess> > const & rOutline, |
448 | | Reference<XNumberingFormatter> const & xFormat, |
449 | | const Locale& rLocale) |
450 | 0 | { |
451 | 0 | maOutlineSettings = rOutline; |
452 | 0 | mxFormatter = xFormat; |
453 | 0 | maLocale = rLocale; |
454 | 0 | if(maOutlineSettings.getLength() > 8) |
455 | 0 | SetStyle( GetStyle() | WB_VSCROLL ); |
456 | 0 | for ( sal_Int32 i = 0; i < maOutlineSettings.getLength(); i++ ) |
457 | 0 | { |
458 | 0 | InsertItem( i + 1, i ); |
459 | 0 | if( i < 8 ) |
460 | 0 | SetItemText(i + 1, SvxResId(RID_SVXSTR_OUTLINENUM_DESCRIPTIONS[i])); |
461 | 0 | } |
462 | 0 | } |
463 | | |
464 | | void SvxNumValueSet::SetCustomBullets(const std::vector<std::pair<OUString, OUString>>& rCustomBullets) |
465 | 0 | { |
466 | 0 | Clear(); |
467 | 0 | maCustomBullets = rCustomBullets; |
468 | 0 | for (size_t i = 0; i < rCustomBullets.size(); i++) |
469 | 0 | { |
470 | 0 | InsertItem(i + 1, i); |
471 | 0 | } |
472 | 0 | } |
473 | | |
474 | | SvxBmpNumValueSet::SvxBmpNumValueSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow) |
475 | 0 | : SvxNumValueSet(std::move(pScrolledWindow)) |
476 | 0 | , m_aFormatIdle("SvxBmpNumValueSet FormatIdle") |
477 | 0 | , m_bGrfNotFound(false) |
478 | 0 | { |
479 | 0 | } |
480 | | |
481 | | void SvxBmpNumValueSet::init() |
482 | 0 | { |
483 | 0 | SvxNumValueSet::init(NumberingPageType::BITMAP); |
484 | 0 | m_bGrfNotFound = false; |
485 | 0 | GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS); |
486 | 0 | SetStyle( GetStyle() | WB_VSCROLL ); |
487 | 0 | SetLineCount( 3 ); |
488 | 0 | m_aFormatIdle.SetPriority(TaskPriority::LOWEST); |
489 | 0 | m_aFormatIdle.SetInvokeHandler(LINK(this, SvxBmpNumValueSet, FormatHdl_Impl)); |
490 | 0 | } |
491 | | |
492 | | |
493 | | SvxBmpNumValueSet::~SvxBmpNumValueSet() |
494 | 0 | { |
495 | 0 | GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS); |
496 | 0 | m_aFormatIdle.Stop(); |
497 | 0 | } |
498 | | |
499 | | void SvxBmpNumValueSet::UserDraw(const UserDrawEvent& rUDEvt) |
500 | 0 | { |
501 | 0 | SvxNumValueSet::UserDraw(rUDEvt); |
502 | |
|
503 | 0 | tools::Rectangle aRect = rUDEvt.GetRect(); |
504 | 0 | vcl::RenderContext* pDev = rUDEvt.GetRenderContext(); |
505 | 0 | sal_uInt16 nItemId = rUDEvt.GetItemId(); |
506 | 0 | Point aBLPos = aRect.TopLeft(); |
507 | |
|
508 | 0 | tools::Long nRectHeight = aRect.GetHeight(); |
509 | 0 | Size aSize(nRectHeight/8, nRectHeight/8); |
510 | |
|
511 | 0 | Graphic aGraphic; |
512 | 0 | if(!GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, nItemId - 1, |
513 | 0 | &aGraphic)) |
514 | 0 | { |
515 | 0 | m_bGrfNotFound = true; |
516 | 0 | } |
517 | 0 | else |
518 | 0 | { |
519 | 0 | Point aPos(aBLPos.X() + 5, 0); |
520 | 0 | for( sal_uInt16 i = 0; i < 3; i++ ) |
521 | 0 | { |
522 | 0 | sal_uInt16 nY = 11 + i * 33; |
523 | 0 | aPos.setY( aBLPos.Y() + nRectHeight * nY / 100 ); |
524 | 0 | aGraphic.Draw(*pDev, aPos, aSize); |
525 | 0 | } |
526 | 0 | } |
527 | 0 | } |
528 | | |
529 | | IMPL_LINK_NOARG(SvxBmpNumValueSet, FormatHdl_Impl, Timer *, void) |
530 | 0 | { |
531 | | // only when a graphics was not there, it needs to be formatted |
532 | 0 | if (m_bGrfNotFound) |
533 | 0 | { |
534 | 0 | SetFormat(); |
535 | 0 | m_bGrfNotFound = false; |
536 | 0 | } |
537 | 0 | Invalidate(); |
538 | 0 | } |
539 | | |
540 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |