Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svx/dialmgr.hxx>
30 : : #include <svx/dialogs.hrc>
31 : : #include <tools/shl.hxx>
32 : : #include <i18npool/mslangid.hxx>
33 : : #include <svtools/valueset.hxx>
34 : : #include <svl/languageoptions.hxx>
35 : : #include <helpid.hrc>
36 : : #include <editeng/numitem.hxx>
37 : : #include <svl/eitem.hxx>
38 : : #include <vcl/svapp.hxx>
39 : : #include <svx/gallery.hxx>
40 : : #include <svl/urihelper.hxx>
41 : : #include <editeng/brshitem.hxx>
42 : : #include <svl/intitem.hxx>
43 : : #include <sfx2/objsh.hxx>
44 : : #include <vcl/graph.hxx>
45 : : #include <vcl/msgbox.hxx>
46 : : #include <editeng/flstitem.hxx>
47 : : #include <svx/dlgutil.hxx>
48 : : #include <svx/xtable.hxx>
49 : : #include <svx/drawitem.hxx>
50 : : #include <svx/numvset.hxx>
51 : : #include <svx/htmlmode.hxx>
52 : : #include <unotools/pathoptions.hxx>
53 : : #include <svtools/ctrltool.hxx>
54 : : #include <editeng/unolingu.hxx>
55 : : #include <com/sun/star/style/NumberingType.hpp>
56 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
57 : : #include <com/sun/star/container/XIndexAccess.hpp>
58 : : #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
59 : : #include <com/sun/star/text/XNumberingFormatter.hpp>
60 : : #include <com/sun/star/beans/PropertyValue.hpp>
61 : : #include <comphelper/processfactory.hxx>
62 : : #include <com/sun/star/text/XNumberingTypeInfo.hpp>
63 : :
64 : : #include <algorithm>
65 : : #include <sfx2/opengrf.hxx>
66 : :
67 : : using namespace com::sun::star::uno;
68 : : using namespace com::sun::star::beans;
69 : : using namespace com::sun::star::lang;
70 : : using namespace com::sun::star::i18n;
71 : : using namespace com::sun::star::text;
72 : : using namespace com::sun::star::container;
73 : : using namespace com::sun::star::style;
74 : : using rtl::OUString;
75 : :
76 : : #define C2U(cChar) OUString::createFromAscii(cChar)
77 : : #define NUM_PAGETYPE_BULLET 0
78 : : #define NUM_PAGETYPE_SINGLENUM 1
79 : : #define NUM_PAGETYPE_NUM 2
80 : : #define NUM_PAGETYPE_BMP 3
81 : :
82 : : static const sal_Char cNumberingType[] = "NumberingType";
83 : : static const sal_Char cValue[] = "Value";
84 : : static const sal_Char cParentNumbering[] = "ParentNumbering";
85 : : static const sal_Char cPrefix[] = "Prefix";
86 : : static const sal_Char cSuffix[] = "Suffix";
87 : : static const sal_Char cBulletChar[] = "BulletChar";
88 : : static const sal_Char cBulletFontName[] = "BulletFontName";
89 : :
90 : : // The selection of bullets from the star symbol
91 : : static const sal_Unicode aBulletTypes[] =
92 : : {
93 : : 0x2022,
94 : : 0x25cf,
95 : : 0xe00c,
96 : : 0xe00a,
97 : : 0x2794,
98 : : 0x27a2,
99 : : 0x2717,
100 : : 0x2714
101 : : };
102 : :
103 : 0 : static Font& lcl_GetDefaultBulletFont()
104 : : {
105 : : static sal_Bool bInit = 0;
106 : : static Font aDefBulletFont( rtl::OUString("StarSymbol"),
107 [ # # ][ # # ]: 0 : String(), Size( 0, 14 ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
108 [ # # ]: 0 : if(!bInit)
109 : : {
110 : 0 : aDefBulletFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
111 : 0 : aDefBulletFont.SetFamily( FAMILY_DONTKNOW );
112 : 0 : aDefBulletFont.SetPitch( PITCH_DONTKNOW );
113 : 0 : aDefBulletFont.SetWeight( WEIGHT_DONTKNOW );
114 : 0 : aDefBulletFont.SetTransparent( sal_True );
115 : 0 : bInit = sal_True;
116 : : }
117 : 0 : return aDefBulletFont;
118 : : }
119 : :
120 : 0 : static void lcl_PaintLevel(OutputDevice* pVDev, sal_Int16 nNumberingType,
121 : : const OUString& rBulletChar, const OUString& rText, const OUString& rFontName,
122 : : Point& rLeft, Font& rRuleFont, const Font& rTextFont)
123 : : {
124 : :
125 [ # # ]: 0 : if(NumberingType::CHAR_SPECIAL == nNumberingType )
126 : : {
127 [ # # ]: 0 : rRuleFont.SetStyleName(rFontName);
128 : 0 : pVDev->SetFont(rRuleFont);
129 [ # # ]: 0 : pVDev->DrawText(rLeft, rBulletChar);
130 [ # # ]: 0 : rLeft.X() += pVDev->GetTextWidth(rBulletChar);
131 : : }
132 : : else
133 : : {
134 : 0 : pVDev->SetFont(rTextFont);
135 [ # # ]: 0 : pVDev->DrawText(rLeft, rText);
136 [ # # ]: 0 : rLeft.X() += pVDev->GetTextWidth(rText);
137 : : }
138 : 0 : }
139 : 0 : void SvxNumValueSet::UserDraw( const UserDrawEvent& rUDEvt )
140 : : {
141 : : static sal_uInt16 aLinesArr[] =
142 : : {
143 : : 15, 10,
144 : : 20, 30,
145 : : 25, 50,
146 : : 30, 70,
147 : : 35, 90, // up to here line positions
148 : : 05, 10, // character positions
149 : : 10, 30,
150 : : 15, 50,
151 : : 20, 70,
152 : : 25, 90,
153 : : };
154 : :
155 : 0 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
156 : 0 : const Color aBackColor = rStyleSettings.GetFieldColor();
157 : 0 : const Color aTextColor = rStyleSettings.GetFieldTextColor();
158 : :
159 : 0 : OutputDevice* pDev = rUDEvt.GetDevice();
160 : 0 : Rectangle aRect = rUDEvt.GetRect();
161 : 0 : sal_uInt16 nItemId = rUDEvt.GetItemId();
162 [ # # ]: 0 : long nRectWidth = aRect.GetWidth();
163 [ # # ]: 0 : long nRectHeight = aRect.GetHeight();
164 [ # # ]: 0 : Size aRectSize(nRectWidth, aRect.GetHeight());
165 : 0 : Point aBLPos = aRect.TopLeft();
166 [ # # ]: 0 : Font aOldFont = pDev->GetFont();
167 : 0 : Color aOldColor = pDev->GetLineColor();
168 [ # # ]: 0 : pDev->SetLineColor(aTextColor);
169 : : Font aFont(OutputDevice::GetDefaultFont(
170 [ # # ][ # # ]: 0 : DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
171 : :
172 [ # # ]: 0 : Size aSize = aFont.GetSize();
173 : :
174 [ # # ][ # # ]: 0 : Font aRuleFont( lcl_GetDefaultBulletFont() );
175 : 0 : aSize.Height() = nRectHeight/6;
176 [ # # ]: 0 : aRuleFont.SetSize(aSize);
177 [ # # ]: 0 : aRuleFont.SetColor(aTextColor);
178 [ # # ]: 0 : aRuleFont.SetFillColor(aBackColor);
179 [ # # ]: 0 : if(nPageType == NUM_PAGETYPE_BULLET)
180 [ # # ]: 0 : aFont = aRuleFont;
181 [ # # ]: 0 : else if(nPageType == NUM_PAGETYPE_NUM)
182 : : {
183 : 0 : aSize.Height() = nRectHeight/8;
184 : : }
185 [ # # ]: 0 : aFont.SetColor(aTextColor);
186 [ # # ]: 0 : aFont.SetFillColor(aBackColor);
187 [ # # ]: 0 : aFont.SetSize( aSize );
188 [ # # ]: 0 : pDev->SetFont(aFont);
189 : :
190 [ # # ]: 0 : if(!pVDev)
191 : : {
192 : : // The lines are only one time in the virtual device, only the outline
193 : : // page is currently done
194 [ # # ][ # # ]: 0 : pVDev = new VirtualDevice(*pDev);
195 [ # # ]: 0 : pVDev->SetMapMode(pDev->GetMapMode());
196 [ # # ]: 0 : pVDev->EnableRTL( IsRTLEnabled() );
197 [ # # ]: 0 : pVDev->SetOutputSize( aRectSize );
198 : 0 : aOrgRect = aRect;
199 [ # # ]: 0 : pVDev->SetFillColor( aBackColor );
200 [ # # ]: 0 : pVDev->DrawRect(aOrgRect);
201 : :
202 [ # # ]: 0 : if(aBackColor == aLineColor)
203 [ # # ]: 0 : aLineColor.Invert();
204 [ # # ]: 0 : pVDev->SetLineColor(aLineColor);
205 : : // Draw line only once
206 [ # # ]: 0 : if(nPageType != NUM_PAGETYPE_NUM)
207 : : {
208 : 0 : Point aStart(aBLPos.X() + nRectWidth *25 / 100,0);
209 : 0 : Point aEnd(aBLPos.X() + nRectWidth * 9 / 10,0);
210 [ # # ]: 0 : for( sal_uInt16 i = 11; i < 100; i += 33)
211 : : {
212 : 0 : aStart.Y() = aEnd.Y() = aBLPos.Y() + nRectHeight * i / 100;
213 [ # # ]: 0 : pVDev->DrawLine(aStart, aEnd);
214 : 0 : aStart.Y() = aEnd.Y() = aBLPos.Y() + nRectHeight * (i + 11) / 100;
215 [ # # ]: 0 : pVDev->DrawLine(aStart, aEnd);
216 : : }
217 : : }
218 : : }
219 : : pDev->DrawOutDev( aRect.TopLeft(), aRectSize,
220 : 0 : aOrgRect.TopLeft(), aRectSize,
221 [ # # ]: 0 : *pVDev );
222 : : // Now comes the text
223 : 0 : const OUString sValue(C2U(cValue));
224 [ # # ][ # # ]: 0 : if( NUM_PAGETYPE_SINGLENUM == nPageType ||
225 : : NUM_PAGETYPE_BULLET == nPageType )
226 : : {
227 : 0 : Point aStart(aBLPos.X() + nRectWidth / 9,0);
228 [ # # ]: 0 : for( sal_uInt16 i = 0; i < 3; i++ )
229 : : {
230 : 0 : sal_uInt16 nY = 11 + i * 33;
231 : 0 : aStart.Y() = aBLPos.Y() + nRectHeight * nY / 100;
232 [ # # ]: 0 : String sText;
233 [ # # ]: 0 : if(nPageType == NUM_PAGETYPE_BULLET)
234 : : {
235 [ # # ]: 0 : sText = aBulletTypes[nItemId - 1];
236 [ # # ]: 0 : aStart.Y() -= pDev->GetTextHeight()/2;
237 : 0 : aStart.X() = aBLPos.X() + 5;
238 : : }
239 : : else
240 : : {
241 [ # # ][ # # ]: 0 : if(xFormatter.is() && aNumSettings.getLength() > nItemId - 1)
[ # # ]
242 : : {
243 [ # # ]: 0 : Sequence<PropertyValue> aLevel = aNumSettings.getConstArray()[nItemId - 1];
244 : : try
245 : : {
246 [ # # ]: 0 : aLevel.realloc(aLevel.getLength() + 1);
247 [ # # ]: 0 : PropertyValue& rValue = aLevel.getArray()[aLevel.getLength() - 1];
248 : 0 : rValue.Name = sValue;
249 [ # # ]: 0 : rValue.Value <<= (sal_Int32)(i + 1);
250 [ # # ][ # # ]: 0 : sText = xFormatter->makeNumberingString( aLevel, aLocale );
[ # # ][ # # ]
251 : : }
252 [ # # ]: 0 : catch(Exception&)
253 : : {
254 : : OSL_FAIL("Exception in DefaultNumberingProvider::makeNumberingString");
255 [ # # ]: 0 : }
256 : : }
257 : : // start just next to the left edge
258 : 0 : aStart.X() = aBLPos.X() + 2;
259 [ # # ]: 0 : aStart.Y() -= pDev->GetTextHeight()/2;
260 : : }
261 [ # # ]: 0 : pDev->DrawText(aStart, sText);
262 [ # # ]: 0 : }
263 : : }
264 [ # # ]: 0 : else if(NUM_PAGETYPE_NUM == nPageType )
265 : : {
266 : : // Outline numbering has to be painted into the virtual device
267 : : // to get correct lines
268 : : // has to be made again
269 [ # # ]: 0 : pVDev->DrawRect(aOrgRect);
270 : 0 : long nStartX = aOrgRect.TopLeft().X();
271 : 0 : long nStartY = aOrgRect.TopLeft().Y();
272 : :
273 [ # # ][ # # ]: 0 : if(xFormatter.is() && aOutlineSettings.getLength() > nItemId - 1)
[ # # ]
274 : : {
275 [ # # ]: 0 : Reference<XIndexAccess> xLevel = aOutlineSettings.getArray()[nItemId - 1];
276 : : try
277 : : {
278 [ # # ]: 0 : OUString sLevelTexts[5];
279 [ # # ]: 0 : OUString sFontNames[5];
280 [ # # ]: 0 : OUString sBulletChars[5];
281 : : sal_Int16 aNumberingTypes[5];
282 [ # # ]: 0 : OUString sPrefixes[5];
283 [ # # ]: 0 : OUString sSuffixes[5];
284 : : sal_Int16 aParentNumberings[5];
285 : :
286 [ # # ][ # # ]: 0 : sal_Int32 nLevelCount = xLevel->getCount();
287 [ # # ]: 0 : if(nLevelCount > 5)
288 : 0 : nLevelCount = 5;
289 [ # # ][ # # ]: 0 : for( sal_Int32 i = 0; i < nLevelCount && i < 5; i++)
[ # # ]
290 : : {
291 : 0 : long nTop = nStartY + nRectHeight * (aLinesArr[2 * i + 11])/100 ;
292 : 0 : Point aLeft(nStartX + nRectWidth * (aLinesArr[2 * i + 10])/ 100, nTop );
293 : :
294 [ # # ][ # # ]: 0 : Any aLevelAny = xLevel->getByIndex(i);
295 [ # # ]: 0 : Sequence<PropertyValue> aLevel;
296 [ # # ]: 0 : aLevelAny >>= aLevel;
297 : 0 : const PropertyValue* pValues = aLevel.getConstArray();
298 : 0 : aNumberingTypes[i] = 0;
299 [ # # ]: 0 : for(sal_Int32 nProperty = 0; nProperty < aLevel.getLength() - 1; nProperty++)
300 : : {
301 [ # # ]: 0 : if ( pValues[nProperty].Name == cNumberingType )
302 : 0 : pValues[nProperty].Value >>= aNumberingTypes[i];
303 [ # # ]: 0 : else if ( pValues[nProperty].Name == cBulletFontName )
304 : 0 : pValues[nProperty].Value >>= sFontNames[i];
305 [ # # ]: 0 : else if ( pValues[nProperty].Name == cBulletChar )
306 : 0 : pValues[nProperty].Value >>= sBulletChars[i];
307 [ # # ]: 0 : else if ( pValues[nProperty].Name == cPrefix )
308 : 0 : pValues[nProperty].Value >>= sPrefixes[i];
309 [ # # ]: 0 : else if ( pValues[nProperty].Name == cSuffix )
310 : 0 : pValues[nProperty].Value >>= sSuffixes[i];
311 [ # # ]: 0 : else if ( pValues[nProperty].Name == cParentNumbering )
312 : 0 : pValues[nProperty].Value >>= aParentNumberings[i];
313 : : }
314 [ # # ]: 0 : Sequence< PropertyValue > aProperties(2);
315 [ # # ]: 0 : PropertyValue* pProperties = aProperties.getArray();
316 [ # # ]: 0 : pProperties[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberingType"));
317 [ # # ]: 0 : pProperties[0].Value <<= aNumberingTypes[i];
318 [ # # ]: 0 : pProperties[1].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"));
319 [ # # # # ]: 0 : pProperties[1].Value <<= (sal_Int32)1;
320 : : try
321 : : {
322 [ # # ][ # # ]: 0 : sLevelTexts[i] = xFormatter->makeNumberingString( aProperties, aLocale );
323 : : }
324 [ # # ]: 0 : catch(Exception&)
325 : : {
326 : : OSL_FAIL("Exception in DefaultNumberingProvider::makeNumberingString");
327 : : }
328 : :
329 [ # # ]: 0 : aLeft.Y() -= (pDev->GetTextHeight()/2);
330 [ # # ][ # # : 0 : if(!sPrefixes[i].isEmpty() &&
# # # # ]
331 : 0 : !sPrefixes[i].equalsAsciiL(" ", 1) &&
332 : 0 : sPrefixes[i].getStr()[0] != 0)
333 : : {
334 [ # # ]: 0 : pVDev->SetFont(aFont);
335 [ # # ][ # # ]: 0 : pVDev->DrawText(aLeft, sPrefixes[i]);
[ # # ]
336 [ # # ][ # # ]: 0 : aLeft.X() += pDev->GetTextWidth(sPrefixes[i]);
[ # # ]
337 : : }
338 [ # # ]: 0 : if(aParentNumberings[i])
339 : : {
340 : : //insert old numberings here
341 [ # # ]: 0 : sal_Int32 nStartLevel = std::min((sal_Int32)aParentNumberings[i], i);
342 [ # # ]: 0 : for(sal_Int32 nParentLevel = i - nStartLevel; nParentLevel < i; nParentLevel++)
343 : : {
344 : 0 : OUString sTmp(sLevelTexts[nParentLevel]);
345 : 0 : sTmp += C2U(".");
346 : : lcl_PaintLevel(pVDev,
347 : 0 : aNumberingTypes[nParentLevel],
348 : : sBulletChars[nParentLevel],
349 : : sTmp,
350 : : sFontNames[nParentLevel],
351 : : aLeft,
352 : : aRuleFont,
353 [ # # ]: 0 : aFont);
354 : 0 : }
355 : : }
356 : : lcl_PaintLevel(pVDev,
357 : 0 : aNumberingTypes[i],
358 : 0 : sBulletChars[i],
359 : 0 : sLevelTexts[i],
360 : 0 : sFontNames[i],
361 : : aLeft,
362 : : aRuleFont,
363 [ # # ]: 0 : aFont);
364 [ # # # # : 0 : if(!sSuffixes[i].isEmpty()&&
# # ][ # # ]
365 : 0 : !sSuffixes[i].equalsAsciiL(" ", 1) &&
366 : 0 : sSuffixes[i].getStr()[0] != 0)
367 : : {
368 [ # # ]: 0 : pVDev->SetFont(aFont);
369 [ # # ][ # # ]: 0 : pVDev->DrawText(aLeft, sSuffixes[i]);
[ # # ]
370 [ # # ][ # # ]: 0 : aLeft.X() += pDev->GetTextWidth(sSuffixes[i]);
[ # # ]
371 : : }
372 : :
373 : 0 : long nLineTop = nStartY + nRectHeight * aLinesArr[2 * i + 1]/100 ;
374 : 0 : Point aLineLeft(aLeft.X(), nLineTop );
375 : 0 : Point aLineRight(nStartX + nRectWidth * 90 /100, nLineTop );
376 [ # # ]: 0 : pVDev->DrawLine(aLineLeft, aLineRight);
377 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # #
# # # #
# ]
378 : :
379 : : }
380 : : #ifdef DBG_UTIL
381 : : catch(Exception&)
382 : : {
383 : : static sal_Bool bAssert = sal_False;
384 : : if(!bAssert)
385 : : {
386 : : OSL_FAIL("exception in ::UserDraw");
387 : : bAssert = sal_True;
388 : : }
389 : : }
390 : : #else
391 [ # # ]: 0 : catch(Exception&)
392 : : {
393 : 0 : }
394 : : #endif
395 : : }
396 : : pDev->DrawOutDev( aRect.TopLeft(), aRectSize,
397 : 0 : aOrgRect.TopLeft(), aRectSize,
398 [ # # ]: 0 : *pVDev );
399 : : }
400 : :
401 [ # # ]: 0 : pDev->SetFont(aOldFont);
402 [ # # ][ # # ]: 0 : pDev->SetLineColor(aOldColor);
[ # # ][ # # ]
403 : 0 : }
404 : :
405 : 0 : SvxNumValueSet::SvxNumValueSet( Window* pParent, const ResId& rResId, sal_uInt16 nType ) :
406 : :
407 : : ValueSet( pParent, rResId ),
408 : :
409 : : aLineColor ( COL_LIGHTGRAY ),
410 : : nPageType ( nType ),
411 : : bHTMLMode ( sal_False ),
412 [ # # ][ # # ]: 0 : pVDev ( NULL )
[ # # ]
413 : : {
414 [ # # ]: 0 : SetColCount( 4 );
415 [ # # ]: 0 : SetLineCount( 2 );
416 [ # # ][ # # ]: 0 : SetStyle( GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
417 [ # # ]: 0 : if(NUM_PAGETYPE_BULLET == nType)
418 : : {
419 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < 8; i++ )
420 : : {
421 [ # # ]: 0 : InsertItem( i + 1, i );
422 [ # # ][ # # ]: 0 : SetItemText( i + 1, SVX_RESSTR( RID_SVXSTR_BULLET_DESCRIPTIONS + i ) );
[ # # ][ # # ]
[ # # ]
423 : : }
424 : : }
425 : 0 : }
426 : :
427 [ # # ][ # # ]: 0 : SvxNumValueSet::~SvxNumValueSet()
428 : : {
429 [ # # ][ # # ]: 0 : delete pVDev;
430 [ # # ]: 0 : }
431 : :
432 : 0 : void SvxNumValueSet::SetNumberingSettings(
433 : : const Sequence<Sequence<PropertyValue> >& aNum,
434 : : Reference<XNumberingFormatter>& xFormat,
435 : : const Locale& rLocale )
436 : : {
437 : 0 : aNumSettings = aNum;
438 : 0 : xFormatter = xFormat;
439 : 0 : aLocale = rLocale;
440 [ # # ]: 0 : if(aNum.getLength() > 8)
441 : 0 : SetStyle( GetStyle()|WB_VSCROLL);
442 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < aNum.getLength(); i++ )
443 : : {
444 : 0 : InsertItem( i + 1, i );
445 [ # # ]: 0 : if( i < 8 )
446 [ # # ][ # # ]: 0 : SetItemText( i + 1, SVX_RESSTR( RID_SVXSTR_SINGLENUM_DESCRIPTIONS + i ));
[ # # ][ # # ]
447 : : }
448 : 0 : }
449 : :
450 : 0 : void SvxNumValueSet::SetOutlineNumberingSettings(
451 : : Sequence<Reference<XIndexAccess> >& rOutline,
452 : : Reference<XNumberingFormatter>& xFormat,
453 : : const Locale& rLocale)
454 : : {
455 : 0 : aOutlineSettings = rOutline;
456 : 0 : xFormatter = xFormat;
457 : 0 : aLocale = rLocale;
458 [ # # ]: 0 : if(aOutlineSettings.getLength() > 8)
459 : 0 : SetStyle( GetStyle() | WB_VSCROLL );
460 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < aOutlineSettings.getLength(); i++ )
461 : : {
462 : 0 : InsertItem( i + 1, i );
463 [ # # ]: 0 : if( i < 8 )
464 [ # # ][ # # ]: 0 : SetItemText( i + 1, SVX_RESSTR( RID_SVXSTR_OUTLINENUM_DESCRIPTIONS + i ));
[ # # ][ # # ]
465 : : }
466 : 0 : }
467 : :
468 : 0 : SvxBmpNumValueSet::SvxBmpNumValueSet( Window* pParent, const ResId& rResId ) :
469 : :
470 : : SvxNumValueSet( pParent, rResId, NUM_PAGETYPE_BMP ),
471 [ # # ][ # # ]: 0 : bGrfNotFound( sal_False )
472 : :
473 : : {
474 [ # # ]: 0 : GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS);
475 [ # # ][ # # ]: 0 : SetStyle( GetStyle() | WB_VSCROLL );
476 [ # # ]: 0 : SetLineCount( 3 );
477 [ # # ]: 0 : aFormatTimer.SetTimeout(300);
478 [ # # ]: 0 : aFormatTimer.SetTimeoutHdl(LINK(this, SvxBmpNumValueSet, FormatHdl_Impl));
479 : 0 : }
480 : :
481 [ # # ][ # # ]: 0 : SvxBmpNumValueSet::~SvxBmpNumValueSet()
482 : : {
483 [ # # ]: 0 : GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS);
484 [ # # ]: 0 : aFormatTimer.Stop();
485 [ # # ]: 0 : }
486 : :
487 : 0 : void SvxBmpNumValueSet::UserDraw( const UserDrawEvent& rUDEvt )
488 : : {
489 [ # # ]: 0 : SvxNumValueSet::UserDraw(rUDEvt);
490 : :
491 : 0 : Rectangle aRect = rUDEvt.GetRect();
492 : 0 : OutputDevice* pDev = rUDEvt.GetDevice();
493 : 0 : sal_uInt16 nItemId = rUDEvt.GetItemId();
494 : 0 : Point aBLPos = aRect.TopLeft();
495 : :
496 [ # # ]: 0 : int nRectHeight = aRect.GetHeight();
497 : 0 : Size aSize(nRectHeight/8, nRectHeight/8);
498 : :
499 [ # # ]: 0 : Graphic aGraphic;
500 [ # # ]: 0 : if(!GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, nItemId - 1,
501 [ # # ]: 0 : &aGraphic, NULL))
502 : : {
503 : 0 : bGrfNotFound = sal_True;
504 : : }
505 : : else
506 : : {
507 : 0 : Point aPos(aBLPos.X() + 5, 0);
508 [ # # ]: 0 : for( sal_uInt16 i = 0; i < 3; i++ )
509 : : {
510 : 0 : sal_uInt16 nY = 11 + i * 33;
511 : 0 : aPos.Y() = aBLPos.Y() + nRectHeight * nY / 100;
512 [ # # ]: 0 : aGraphic.Draw( pDev, aPos, aSize );
513 : : }
514 [ # # ]: 0 : }
515 : 0 : }
516 : :
517 : 0 : IMPL_LINK_NOARG(SvxBmpNumValueSet, FormatHdl_Impl)
518 : : {
519 : : // only when a graphics was not there, it needs to be formatted
520 [ # # ]: 0 : if(bGrfNotFound)
521 : : {
522 : 0 : bGrfNotFound = sal_False;
523 : 0 : Format();
524 : : }
525 : 0 : Invalidate();
526 : 0 : return 0;
527 : : }
528 : :
529 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|