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 : :
30 : : #include <tools/debug.hxx>
31 : : #include <tools/rc.h>
32 : :
33 : : #include <vcl/event.hxx>
34 : : #include <vcl/decoview.hxx>
35 : : #include <vcl/svapp.hxx>
36 : : #include <vcl/help.hxx>
37 : : #include <vcl/status.hxx>
38 : : #include <vcl/virdev.hxx>
39 : :
40 : : #include <svdata.hxx>
41 : : #include <window.h>
42 : :
43 : : // =======================================================================
44 : :
45 : : #define STATUSBAR_OFFSET_X STATUSBAR_OFFSET
46 : : #define STATUSBAR_OFFSET_Y 2
47 : : #define STATUSBAR_OFFSET_TEXTY 3
48 : :
49 : : #define STATUSBAR_PRGS_OFFSET 3
50 : : #define STATUSBAR_PRGS_COUNT 100
51 : : #define STATUSBAR_PRGS_MIN 5
52 : :
53 : : // -----------------------------------------------------------------------
54 : :
55 : : class StatusBar::ImplData
56 : : {
57 : : public:
58 : : ImplData();
59 : : ~ImplData();
60 : :
61 : : VirtualDevice* mpVirDev;
62 : : long mnItemBorderWidth;
63 : : bool mbDrawItemFrames:1;
64 : : };
65 : :
66 : 3488 : StatusBar::ImplData::ImplData()
67 : : {
68 : 3488 : mpVirDev = NULL;
69 : 3488 : mbDrawItemFrames = false;
70 : 3488 : mnItemBorderWidth = 0;
71 : 3488 : }
72 : :
73 : 3397 : StatusBar::ImplData::~ImplData()
74 : : {
75 : 3397 : }
76 : :
77 [ + - ][ + - ]: 24678 : struct ImplStatusItem
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
78 : : {
79 : : sal_uInt16 mnId;
80 : : StatusBarItemBits mnBits;
81 : : long mnWidth;
82 : : long mnOffset;
83 : : long mnExtraWidth;
84 : : long mnX;
85 : : XubString maText;
86 : : XubString maHelpText;
87 : : XubString maQuickHelpText;
88 : : rtl::OString maHelpId;
89 : : void* mpUserData;
90 : : sal_Bool mbVisible;
91 : : XubString maAccessibleName;
92 : : XubString maCommand;
93 : : };
94 : :
95 : : // =======================================================================
96 : :
97 : 71405 : inline long ImplCalcProgessWidth( sal_uInt16 nMax, long nSize )
98 : : {
99 : 71405 : return ((nMax*(nSize+(nSize/2)))-(nSize/2)+(STATUSBAR_PRGS_OFFSET*2));
100 : : }
101 : :
102 : : // -----------------------------------------------------------------------
103 : :
104 : 27845 : static Point ImplGetItemTextPos( const Size& rRectSize, const Size& rTextSize,
105 : : sal_uInt16 nStyle )
106 : : {
107 : : long nX;
108 : : long nY;
109 : 27845 : long delta = (rTextSize.Height()/4) + 1;
110 [ + + ]: 27845 : if( delta + rTextSize.Width() > rRectSize.Width() )
111 : 43 : delta = 0;
112 : :
113 [ + + ]: 27845 : if ( nStyle & SIB_LEFT )
114 : 10821 : nX = delta;
115 [ - + ]: 17024 : else if ( nStyle & SIB_RIGHT )
116 : 0 : nX = rRectSize.Width()-rTextSize.Width()-delta;
117 : : else // SIB_CENTER
118 : 17024 : nX = (rRectSize.Width()-rTextSize.Width())/2;
119 : 27845 : nY = (rRectSize.Height()-rTextSize.Height())/2 + 1;
120 : 27845 : return Point( nX, nY );
121 : : }
122 : :
123 : : // -----------------------------------------------------------------------
124 : :
125 : 30719 : sal_Bool StatusBar::ImplIsItemUpdate()
126 : : {
127 [ + - ][ + - ]: 30719 : if ( !mbProgressMode && mbVisibleItems && IsReallyVisible() && IsUpdateMode() )
[ + + ][ + - ]
[ + + ]
128 : 5295 : return sal_True;
129 : : else
130 : 30719 : return sal_False;
131 : : }
132 : :
133 : : // -----------------------------------------------------------------------
134 : :
135 : 3488 : void StatusBar::ImplInit( Window* pParent, WinBits nStyle )
136 : : {
137 [ + - ]: 3488 : mpImplData = new ImplData;
138 : :
139 : : // Default ist RightAlign
140 [ - + ]: 3488 : if ( !(nStyle & (WB_LEFT | WB_RIGHT)) )
141 : 0 : nStyle |= WB_RIGHT;
142 : :
143 : 3488 : Window::ImplInit( pParent, nStyle & ~WB_BORDER, NULL );
144 : :
145 : : // WinBits merken
146 [ + - ]: 3488 : mpItemList = new ImplStatusItemList;
147 [ + - ]: 3488 : mpImplData->mpVirDev = new VirtualDevice( *this );
148 : 3488 : mnCurItemId = 0;
149 : 3488 : mbFormat = sal_True;
150 : 3488 : mbVisibleItems = sal_True;
151 : 3488 : mbProgressMode = sal_False;
152 : 3488 : mbInUserDraw = sal_False;
153 : 3488 : mnItemsWidth = STATUSBAR_OFFSET_X;
154 : 3488 : mnDX = 0;
155 : 3488 : mnDY = 0;
156 : 3488 : mnCalcHeight = 0;
157 : 3488 : mnItemY = STATUSBAR_OFFSET_Y;
158 : 3488 : mnTextY = STATUSBAR_OFFSET_TEXTY;
159 : :
160 : 3488 : ImplInitSettings( sal_True, sal_True, sal_True );
161 : 3488 : SetLineColor();
162 : :
163 [ + - ]: 3488 : SetOutputSizePixel( CalcWindowSizePixel() );
164 : 3488 : }
165 : :
166 : : // -----------------------------------------------------------------------
167 : :
168 : 3488 : StatusBar::StatusBar( Window* pParent, WinBits nStyle ) :
169 [ + - ][ + - ]: 3488 : Window( WINDOW_STATUSBAR )
[ + - ][ + - ]
170 : : {
171 [ + - ]: 3488 : ImplInit( pParent, nStyle );
172 : 3488 : }
173 : :
174 : : // -----------------------------------------------------------------------
175 : :
176 [ + - ]: 3397 : StatusBar::~StatusBar()
177 : : {
178 : : // Alle Items loeschen
179 [ + + ]: 15736 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) {
180 [ + - ][ + - ]: 12339 : delete (*mpItemList)[ i ];
181 : : }
182 [ + - ]: 3397 : delete mpItemList;
183 : :
184 : : // VirtualDevice loeschen
185 [ + - ][ + - ]: 3397 : delete mpImplData->mpVirDev;
186 [ + - ][ + - ]: 3397 : delete mpImplData;
187 [ - + ]: 5144 : }
188 : :
189 : : // -----------------------------------------------------------------------
190 : :
191 : 3488 : void StatusBar::ImplInitSettings( sal_Bool bFont,
192 : : sal_Bool bForeground, sal_Bool bBackground )
193 : : {
194 : 3488 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
195 : :
196 [ + - ]: 3488 : if ( bFont )
197 : : {
198 [ + - ]: 3488 : Font aFont = rStyleSettings.GetToolFont();
199 [ + - ][ - + ]: 3488 : if ( IsControlFont() )
200 [ # # ][ # # ]: 0 : aFont.Merge( GetControlFont() );
[ # # ]
201 [ + - ][ + - ]: 3488 : SetZoomedPointFont( aFont );
202 : : }
203 : :
204 [ - + ][ # # ]: 3488 : if ( bForeground || bFont )
205 : : {
206 : 3488 : Color aColor;
207 [ - + ][ + - ]: 3488 : if ( IsControlForeground() )
208 [ # # ]: 0 : aColor = GetControlForeground();
209 [ + - ][ + - ]: 3488 : else if ( GetStyle() & WB_3DLOOK )
210 : 3488 : aColor = rStyleSettings.GetButtonTextColor();
211 : : else
212 : 0 : aColor = rStyleSettings.GetWindowTextColor();
213 [ + - ]: 3488 : SetTextColor( aColor );
214 [ + - ]: 3488 : SetTextFillColor();
215 : :
216 [ + - ]: 3488 : mpImplData->mpVirDev->SetFont( GetFont() );
217 [ + - ]: 3488 : mpImplData->mpVirDev->SetTextColor( GetTextColor() );
218 [ + - ][ + - ]: 3488 : mpImplData->mpVirDev->SetTextAlign( GetTextAlign() );
219 [ + - ]: 3488 : mpImplData->mpVirDev->SetTextFillColor();
220 : : }
221 : :
222 [ + - ]: 3488 : if ( bBackground )
223 : : {
224 : 3488 : Color aColor;
225 [ - + ][ + - ]: 3488 : if ( IsControlBackground() )
226 [ # # ]: 0 : aColor = GetControlBackground();
227 [ + - ][ + - ]: 3488 : else if ( GetStyle() & WB_3DLOOK )
228 : 3488 : aColor = rStyleSettings.GetFaceColor();
229 : : else
230 : 0 : aColor = rStyleSettings.GetWindowColor();
231 [ + - ][ + - ]: 3488 : SetBackground( aColor );
[ + - ]
232 [ + - ]: 3488 : mpImplData->mpVirDev->SetBackground( GetBackground() );
233 : :
234 : : // NWF background
235 [ + - ][ + - ]: 6976 : if( ! IsControlBackground() &&
[ - + ][ - + ]
236 [ + - ]: 3488 : IsNativeControlSupported( CTRL_WINDOW_BACKGROUND, PART_BACKGROUND_WINDOW ) )
237 : : {
238 : 0 : ImplGetWindowImpl()->mnNativeBackground = PART_BACKGROUND_WINDOW;
239 [ # # ]: 3488 : EnableChildTransparentMode( sal_True );
240 : : }
241 : : }
242 : 3488 : }
243 : :
244 : : // -----------------------------------------------------------------------
245 : :
246 : 7774 : void StatusBar::ImplFormat()
247 : : {
248 : : ImplStatusItem* pItem;
249 : : long nExtraWidth;
250 : : long nExtraWidth2;
251 : : long nX;
252 : 7774 : sal_uInt16 nAutoSizeItems = 0;
253 : :
254 : : // Breiten zusammenrechnen
255 : 7774 : mnItemsWidth = STATUSBAR_OFFSET_X;
256 : 7774 : long nOffset = 0;
257 [ + + ]: 82197 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) {
258 : 74423 : pItem = (*mpItemList)[ i ];
259 [ + - ]: 74423 : if ( pItem->mbVisible )
260 : : {
261 [ + + ]: 74423 : if ( pItem->mnBits & SIB_AUTOSIZE ) {
262 : 29605 : nAutoSizeItems++;
263 : : }
264 : :
265 : 74423 : mnItemsWidth += pItem->mnWidth + nOffset;
266 : 74423 : nOffset = pItem->mnOffset;
267 : : }
268 : : }
269 : :
270 [ - + ]: 7774 : if ( GetStyle() & WB_RIGHT )
271 : : {
272 : : // Bei rechtsbuendiger Ausrichtung wird kein AutoSize ausgewertet,
273 : : // da wir links den Text anzeigen, der mit SetText gesetzt wird
274 : 0 : nX = mnDX - mnItemsWidth;
275 : 0 : nExtraWidth = 0;
276 : 0 : nExtraWidth2 = 0;
277 : : }
278 : : else
279 : : {
280 : 7774 : mnItemsWidth += STATUSBAR_OFFSET_X;
281 : :
282 : : // Bei linksbuendiger Ausrichtung muessen wir gegebenenfalls noch
283 : : // AutoSize auswerten
284 [ + + ][ + + ]: 7774 : if ( nAutoSizeItems && (mnDX > (mnItemsWidth - STATUSBAR_OFFSET)) )
285 : : {
286 : 1123 : nExtraWidth = (mnDX - mnItemsWidth - 1) / nAutoSizeItems;
287 : 1123 : nExtraWidth2 = (mnDX - mnItemsWidth - 1) % nAutoSizeItems;
288 : : }
289 : : else
290 : : {
291 : 6651 : nExtraWidth = 0;
292 : 6651 : nExtraWidth2 = 0;
293 : : }
294 : 7774 : nX = STATUSBAR_OFFSET_X;
295 [ - + ][ # # ]: 7774 : if( ImplHasMirroredGraphics() && IsRTLEnabled() )
[ - + ]
296 : 0 : nX += ImplGetSVData()->maNWFData.mnStatusBarLowerRightOffset;
297 : : }
298 : :
299 [ + + ]: 82197 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) {
300 : 74423 : pItem = (*mpItemList)[ i ];
301 [ + - ]: 74423 : if ( pItem->mbVisible ) {
302 [ + + ]: 74423 : if ( pItem->mnBits & SIB_AUTOSIZE ) {
303 : 29605 : pItem->mnExtraWidth = nExtraWidth;
304 [ + + ]: 29605 : if ( nExtraWidth2 ) {
305 : 3333 : pItem->mnExtraWidth++;
306 : 3333 : nExtraWidth2--;
307 : : }
308 : : } else {
309 : 44818 : pItem->mnExtraWidth = 0;
310 : : }
311 : :
312 : 74423 : pItem->mnX = nX;
313 : 74423 : nX += pItem->mnWidth + pItem->mnExtraWidth + pItem->mnOffset;
314 : : }
315 : : }
316 : :
317 : 7774 : mbFormat = sal_False;
318 : 7774 : }
319 : :
320 : : // -----------------------------------------------------------------------
321 : :
322 : 45012 : Rectangle StatusBar::ImplGetItemRectPos( sal_uInt16 nPos ) const
323 : : {
324 : 45012 : Rectangle aRect;
325 : : ImplStatusItem* pItem;
326 [ + - ]: 45012 : pItem = ( nPos < mpItemList->size() ) ? (*mpItemList)[ nPos ] : NULL;
327 [ + - ]: 45012 : if ( pItem )
328 : : {
329 [ + - ]: 45012 : if ( pItem->mbVisible )
330 : : {
331 : 45012 : aRect.Left() = pItem->mnX;
332 : 45012 : aRect.Right() = aRect.Left() + pItem->mnWidth + pItem->mnExtraWidth;
333 : 45012 : aRect.Top() = mnItemY;
334 : 45012 : aRect.Bottom() = mnCalcHeight - STATUSBAR_OFFSET_Y;
335 : : }
336 : : }
337 : :
338 : 45012 : return aRect;
339 : : }
340 : :
341 : : // -----------------------------------------------------------------------
342 : :
343 : 23135 : sal_uInt16 StatusBar::ImplGetFirstVisiblePos() const
344 : : {
345 : : ImplStatusItem* pItem;
346 : :
347 [ + - ]: 23135 : for( size_t nPos = 0; nPos < mpItemList->size(); nPos++ )
348 : : {
349 : 23135 : pItem = (*mpItemList)[ nPos ];
350 [ + - ]: 23135 : if ( pItem )
351 : : {
352 [ + - ]: 23135 : if ( pItem->mbVisible )
353 : 23135 : return sal_uInt16(nPos);
354 : : }
355 : : }
356 : :
357 : 23135 : return ~0;
358 : : }
359 : :
360 : : // -----------------------------------------------------------------------
361 : :
362 : 0 : void StatusBar::ImplDrawText( sal_Bool bOffScreen, long nOldTextWidth )
363 : : {
364 : : // Das ueberschreiben der Item-Box verhindern
365 [ # # ]: 0 : Rectangle aTextRect;
366 : 0 : aTextRect.Left() = STATUSBAR_OFFSET_X+1;
367 : 0 : aTextRect.Top() = mnTextY;
368 [ # # ][ # # ]: 0 : if ( mbVisibleItems && (GetStyle() & WB_RIGHT) )
[ # # ][ # # ]
369 : 0 : aTextRect.Right() = mnDX - mnItemsWidth - 1;
370 : : else
371 : 0 : aTextRect.Right() = mnDX - 1;
372 [ # # ]: 0 : if ( aTextRect.Right() > aTextRect.Left() )
373 : : {
374 : : // Position ermitteln
375 [ # # ]: 0 : XubString aStr = GetText();
376 [ # # ]: 0 : sal_uInt16 nPos = aStr.Search( _LF );
377 [ # # ]: 0 : if ( nPos != STRING_NOTFOUND )
378 [ # # ]: 0 : aStr.Erase( nPos );
379 : :
380 [ # # ]: 0 : aTextRect.Bottom() = aTextRect.Top()+GetTextHeight()+1;
381 : :
382 [ # # ]: 0 : if ( bOffScreen )
383 : : {
384 [ # # ]: 0 : long nMaxWidth = Max( nOldTextWidth, GetTextWidth( aStr ) );
385 [ # # ]: 0 : Size aVirDevSize( nMaxWidth, aTextRect.GetHeight() );
386 [ # # ]: 0 : mpImplData->mpVirDev->SetOutputSizePixel( aVirDevSize );
387 : 0 : Rectangle aTempRect = aTextRect;
388 : 0 : aTempRect.SetPos( Point( 0, 0 ) );
389 [ # # ]: 0 : mpImplData->mpVirDev->DrawText( aTempRect, aStr, TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_CLIP | TEXT_DRAW_ENDELLIPSIS );
390 [ # # ]: 0 : DrawOutDev( aTextRect.TopLeft(), aVirDevSize, Point(), aVirDevSize, *mpImplData->mpVirDev );
391 : : }
392 : : else
393 [ # # ][ # # ]: 0 : DrawText( aTextRect, aStr, TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_CLIP | TEXT_DRAW_ENDELLIPSIS );
394 : : }
395 : 0 : }
396 : :
397 : : // -----------------------------------------------------------------------
398 : :
399 : 28430 : void StatusBar::ImplDrawItem( sal_Bool bOffScreen, sal_uInt16 nPos, sal_Bool bDrawText, sal_Bool bDrawFrame )
400 : : {
401 [ + - ]: 28430 : Rectangle aRect = ImplGetItemRectPos( nPos );
402 : :
403 [ + - ][ + - ]: 28430 : if ( aRect.IsEmpty() )
404 : 28430 : return;
405 : :
406 : : // Ausgabebereich berechnen
407 : 28430 : ImplStatusItem* pItem = (*mpItemList)[ nPos ];
408 : 28430 : long nW = mpImplData->mnItemBorderWidth + 1;
409 : 28430 : Rectangle aTextRect( aRect.Left()+nW, aRect.Top()+nW,
410 [ + - ]: 56860 : aRect.Right()-nW, aRect.Bottom()-nW );
411 [ + - ]: 28430 : Size aTextRectSize( aTextRect.GetSize() );
412 : :
413 [ + + ]: 28430 : if ( bOffScreen )
414 [ + - ]: 5295 : mpImplData->mpVirDev->SetOutputSizePixel( aTextRectSize );
415 : : else
416 : : {
417 [ + - ]: 23135 : Region aRegion( aTextRect );
418 [ + - ][ + - ]: 23135 : SetClipRegion( aRegion );
419 : : }
420 : :
421 : : // Text ausgeben
422 [ + + ]: 28430 : if ( bDrawText )
423 : : {
424 [ + - ][ + - ]: 24010 : Size aTextSize( GetTextWidth( pItem->maText ), GetTextHeight() );
425 : 24010 : Point aTextPos = ImplGetItemTextPos( aTextRectSize, aTextSize, pItem->mnBits );
426 [ + + ]: 24010 : if ( bOffScreen )
427 [ + - ]: 875 : mpImplData->mpVirDev->DrawText( aTextPos, pItem->maText );
428 : : else
429 : : {
430 : 23135 : aTextPos.X() += aTextRect.Left();
431 : 23135 : aTextPos.Y() += aTextRect.Top();
432 [ + - ]: 24010 : DrawText( aTextPos, pItem->maText );
433 : : }
434 : : }
435 : :
436 : : // Gegebenenfalls auch DrawItem aufrufen
437 [ + + ]: 28430 : if ( pItem->mnBits & SIB_USERDRAW )
438 : : {
439 [ + + ]: 16169 : if ( bOffScreen )
440 : : {
441 : 4468 : mbInUserDraw = sal_True;
442 [ + - ]: 4468 : mpImplData->mpVirDev->EnableRTL( IsRTLEnabled() );
443 [ + - ][ + - ]: 4468 : UserDrawEvent aODEvt( mpImplData->mpVirDev, Rectangle( Point(), aTextRectSize ), pItem->mnId );
444 [ + - ]: 4468 : UserDraw( aODEvt );
445 [ + - ]: 4468 : mpImplData->mpVirDev->EnableRTL( sal_False );
446 : 4468 : mbInUserDraw = sal_False;
447 : : }
448 : : else
449 : : {
450 [ + - ]: 11701 : UserDrawEvent aODEvt( this, aTextRect, pItem->mnId );
451 [ + - ]: 11701 : UserDraw( aODEvt );
452 : : }
453 : : }
454 : :
455 [ + + ]: 28430 : if ( bOffScreen )
456 [ + - ]: 5295 : DrawOutDev( aTextRect.TopLeft(), aTextRectSize, Point(), aTextRectSize, *mpImplData->mpVirDev );
457 : : else
458 [ + - ]: 23135 : SetClipRegion();
459 : :
460 : : // Frame ausgeben
461 [ + + ]: 28430 : if ( bDrawFrame )
462 : : {
463 [ - + ]: 23135 : if( mpImplData->mbDrawItemFrames )
464 : : {
465 [ # # ]: 0 : if( !(pItem->mnBits & SIB_FLAT) )
466 : : {
467 : : sal_uInt16 nStyle;
468 : :
469 [ # # ]: 0 : if ( pItem->mnBits & SIB_IN )
470 : 0 : nStyle = FRAME_DRAW_IN;
471 : : else
472 : 0 : nStyle = FRAME_DRAW_OUT;
473 : :
474 : 0 : DecorationView aDecoView( this );
475 [ # # ]: 0 : aDecoView.DrawFrame( aRect, nStyle );
476 : : }
477 : : }
478 [ + - ][ + + ]: 23135 : else if( nPos != ImplGetFirstVisiblePos() )
479 : : {
480 : : // draw separator
481 : 21047 : Point aFrom( aRect.TopLeft() );
482 : 21047 : aFrom.X()--;
483 : 21047 : aFrom.Y()++;
484 [ + - ]: 21047 : Point aTo( aRect.BottomLeft() );
485 : 21047 : aTo.X()--;
486 : 21047 : aTo.Y()--;
487 : :
488 : 21047 : DecorationView aDecoView( this );
489 [ + - ]: 21047 : aDecoView.DrawSeparator( aFrom, aTo );
490 : : }
491 : : }
492 : :
493 [ + - ][ + + ]: 28430 : if ( !ImplIsRecordLayout() )
494 [ + - ]: 28430 : ImplCallEventListeners( VCLEVENT_STATUSBAR_DRAWITEM, (void*) sal_IntPtr(pItem->mnId) );
495 : : }
496 : :
497 : : // -----------------------------------------------------------------------
498 : :
499 : 14342 : void DrawProgress( Window* pWindow, const Point& rPos,
500 : : long nOffset, long nPrgsWidth, long nPrgsHeight,
501 : : sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
502 : : const Rectangle& rFramePosSize
503 : : )
504 : : {
505 [ - + ]: 14342 : if( pWindow->IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) )
506 : : {
507 [ # # ]: 0 : bool bNeedErase = ImplGetSVData()->maNWFData.mbProgressNeedsErase;
508 : :
509 : 0 : long nFullWidth = (nPrgsWidth + nOffset) * (10000 / nPercentCount);
510 [ # # ]: 0 : long nPerc = (nPercent2 > 10000) ? 10000 : nPercent2;
511 : 0 : ImplControlValue aValue( nFullWidth * (long)nPerc / 10000 );
512 [ # # ]: 0 : Rectangle aDrawRect( rPos, Size( nFullWidth, nPrgsHeight ) );
513 : 0 : Rectangle aControlRegion( aDrawRect );
514 [ # # ]: 0 : if( bNeedErase )
515 : : {
516 : 0 : Window* pEraseWindow = pWindow;
517 [ # # ]: 0 : while( pEraseWindow->IsPaintTransparent() &&
[ # # # # ]
[ # # ]
518 : 0 : ! pEraseWindow->ImplGetWindowImpl()->mbFrame )
519 : : {
520 : 0 : pEraseWindow = pEraseWindow->ImplGetWindowImpl()->mpParent;
521 : : }
522 [ # # ]: 0 : if( pEraseWindow == pWindow )
523 : : // restore background of pWindow
524 [ # # ]: 0 : pEraseWindow->Erase( rFramePosSize );
525 : : else
526 : : {
527 : : // restore transparent background
528 [ # # ]: 0 : Point aTL( pWindow->OutputToAbsoluteScreenPixel( rFramePosSize.TopLeft() ) );
529 [ # # ]: 0 : aTL = pEraseWindow->AbsoluteScreenToOutputPixel( aTL );
530 [ # # ][ # # ]: 0 : Rectangle aRect( aTL, rFramePosSize.GetSize() );
531 : : pEraseWindow->Invalidate( aRect, INVALIDATE_NOCHILDREN |
532 : : INVALIDATE_NOCLIPCHILDREN |
533 [ # # ]: 0 : INVALIDATE_TRANSPARENT );
534 [ # # ]: 0 : pEraseWindow->Update();
535 : : }
536 [ # # ]: 0 : pWindow->Push( PUSH_CLIPREGION );
537 [ # # ]: 0 : pWindow->IntersectClipRegion( rFramePosSize );
538 : : }
539 : : sal_Bool bNativeOK = pWindow->DrawNativeControl( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion,
540 [ # # ]: 0 : CTRL_STATE_ENABLED, aValue, rtl::OUString() );
541 [ # # ]: 0 : if( bNeedErase )
542 [ # # ]: 0 : pWindow->Pop();
543 [ # # ]: 0 : if( bNativeOK )
544 : : {
545 [ # # ]: 0 : pWindow->Flush();
546 : 14342 : return;
547 [ # # ][ # # ]: 0 : }
548 : : }
549 : :
550 : : // Werte vorberechnen
551 : 14342 : sal_uInt16 nPerc1 = nPercent1 / nPercentCount;
552 : 14342 : sal_uInt16 nPerc2 = nPercent2 / nPercentCount;
553 : :
554 [ + + ]: 14342 : if ( nPerc1 > nPerc2 )
555 : : {
556 : : // Support progress that can also decrease
557 : :
558 : : // Rechteck berechnen
559 : 131 : long nDX = nPrgsWidth + nOffset;
560 : 131 : long nLeft = rPos.X()+((nPerc1-1)*nDX);
561 [ + - ]: 131 : Rectangle aRect( nLeft, rPos.Y(), nLeft+nPrgsWidth, rPos.Y()+nPrgsHeight );
562 : :
563 [ + + ]: 5240 : do
564 : : {
565 [ + - ]: 5240 : pWindow->Erase( aRect );
566 : 5240 : aRect.Left() -= nDX;
567 : 5240 : aRect.Right() -= nDX;
568 : 5240 : nPerc1--;
569 : : }
570 : : while ( nPerc1 > nPerc2 );
571 : :
572 [ + - ]: 131 : pWindow->Flush();
573 : : }
574 [ + + ]: 14211 : else if ( nPerc1 < nPerc2 )
575 : : {
576 : : // Percent-Rechtecke malen
577 : : // Wenn Percent2 ueber 100%, Werte anpassen
578 [ - + ]: 6855 : if ( nPercent2 > 10000 )
579 : : {
580 : 0 : nPerc2 = 10000 / nPercentCount;
581 [ # # ]: 0 : if ( nPerc1 >= nPerc2 )
582 : 0 : nPerc1 = nPerc2-1;
583 : : }
584 : :
585 : : // Rechteck berechnen
586 : 6855 : long nDX = nPrgsWidth + nOffset;
587 : 6855 : long nLeft = rPos.X()+(nPerc1*nDX);
588 [ + - ]: 6855 : Rectangle aRect( nLeft, rPos.Y(), nLeft+nPrgsWidth, rPos.Y()+nPrgsHeight );
589 : :
590 [ + + ]: 24056 : do
591 : : {
592 [ + - ]: 24056 : pWindow->DrawRect( aRect );
593 : 24056 : aRect.Left() += nDX;
594 : 24056 : aRect.Right() += nDX;
595 : 24056 : nPerc1++;
596 : : }
597 : : while ( nPerc1 < nPerc2 );
598 : :
599 : : // Bei mehr als 100%, lassen wir das Rechteck blinken
600 [ - + ]: 6855 : if ( nPercent2 > 10000 )
601 : : {
602 : : // an/aus-Status festlegen
603 [ # # ]: 0 : if ( ((nPercent2 / nPercentCount) & 0x01) == (nPercentCount & 0x01) )
604 : : {
605 : 0 : aRect.Left() -= nDX;
606 : 0 : aRect.Right() -= nDX;
607 [ # # ]: 0 : pWindow->Erase( aRect );
608 : : }
609 : : }
610 : :
611 [ + - ]: 6855 : pWindow->Flush();
612 : : }
613 : : }
614 : :
615 : : // -----------------------------------------------------------------------
616 : :
617 : 14342 : void StatusBar::ImplDrawProgress( sal_Bool bPaint,
618 : : sal_uInt16 nPercent1, sal_uInt16 nPercent2 )
619 : : {
620 [ + - ]: 14342 : bool bNative = IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL );
621 : : // bPaint: draw text also, else only update progress
622 [ + + ]: 14342 : if ( bPaint )
623 : : {
624 [ + - ]: 606 : DrawText( maPrgsTxtPos, maPrgsTxt );
625 [ + - ]: 606 : if( ! bNative )
626 : : {
627 : 606 : DecorationView aDecoView( this );
628 [ + - ]: 606 : aDecoView.DrawFrame( maPrgsFrameRect, FRAME_DRAW_IN );
629 : : }
630 : : }
631 : :
632 : 14342 : Point aPos( maPrgsFrameRect.Left()+STATUSBAR_PRGS_OFFSET,
633 : 28684 : maPrgsFrameRect.Top()+STATUSBAR_PRGS_OFFSET );
634 : 14342 : long nPrgsHeight = mnPrgsSize;
635 [ - + ]: 14342 : if( bNative )
636 : : {
637 : 0 : aPos = maPrgsFrameRect.TopLeft();
638 [ # # ]: 0 : nPrgsHeight = maPrgsFrameRect.GetHeight();
639 : : }
640 : : DrawProgress( this, aPos, mnPrgsSize/2, mnPrgsSize, nPrgsHeight,
641 [ + - ]: 14342 : nPercent1*100, nPercent2*100, mnPercentCount, maPrgsFrameRect );
642 : 14342 : }
643 : :
644 : : // -----------------------------------------------------------------------
645 : :
646 : 945 : void StatusBar::ImplCalcProgressRect()
647 : : {
648 : : // calculate text size
649 [ + - ][ + - ]: 945 : Size aPrgsTxtSize( GetTextWidth( maPrgsTxt ), GetTextHeight() );
650 : 945 : maPrgsTxtPos.X() = STATUSBAR_OFFSET_X+1;
651 : :
652 : : // calculate progress frame
653 : 945 : maPrgsFrameRect.Left() = maPrgsTxtPos.X()+aPrgsTxtSize.Width()+STATUSBAR_OFFSET;
654 : 945 : maPrgsFrameRect.Top() = mnItemY;
655 : 945 : maPrgsFrameRect.Bottom() = mnCalcHeight - STATUSBAR_OFFSET_Y;
656 : :
657 : : // calculate size of progress rects
658 : 945 : mnPrgsSize = maPrgsFrameRect.Bottom()-maPrgsFrameRect.Top()-(STATUSBAR_PRGS_OFFSET*2);
659 : 945 : sal_uInt16 nMaxPercent = STATUSBAR_PRGS_COUNT;
660 : :
661 : 945 : long nMaxWidth = mnDX-STATUSBAR_OFFSET-1;
662 : :
663 : : // make smaller if there are too many rects
664 [ + + ]: 70460 : while ( maPrgsFrameRect.Left()+ImplCalcProgessWidth( nMaxPercent, mnPrgsSize ) > nMaxWidth )
665 : : {
666 : 69937 : nMaxPercent--;
667 [ + + ]: 69937 : if ( nMaxPercent <= STATUSBAR_PRGS_MIN )
668 : 422 : break;
669 : : }
670 : 945 : maPrgsFrameRect.Right() = maPrgsFrameRect.Left() + ImplCalcProgessWidth( nMaxPercent, mnPrgsSize );
671 : :
672 : : // save the divisor for later
673 : 945 : mnPercentCount = 10000 / nMaxPercent;
674 : 945 : sal_Bool bNativeOK = sal_False;
675 [ - + ][ + - ]: 945 : if( IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) )
676 : : {
677 : 0 : ImplControlValue aValue;
678 [ # # ][ # # ]: 0 : Rectangle aControlRegion( Rectangle( (const Point&)Point(), maPrgsFrameRect.GetSize() ) );
679 [ # # ][ # # ]: 0 : Rectangle aNativeControlRegion, aNativeContentRegion;
680 [ # # # # ]: 0 : if( (bNativeOK = GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion,
681 : : CTRL_STATE_ENABLED, aValue, rtl::OUString(),
682 : 0 : aNativeControlRegion, aNativeContentRegion ) ) != sal_False )
683 : : {
684 [ # # ]: 0 : long nProgressHeight = aNativeControlRegion.GetHeight();
685 [ # # ][ # # ]: 0 : if( nProgressHeight > maPrgsFrameRect.GetHeight() )
686 : : {
687 [ # # ]: 0 : long nDelta = nProgressHeight - maPrgsFrameRect.GetHeight();
688 : 0 : maPrgsFrameRect.Top() -= (nDelta - nDelta/2);
689 : 0 : maPrgsFrameRect.Bottom() += nDelta/2;
690 : : }
691 [ # # ]: 0 : maPrgsTxtPos.Y() = maPrgsFrameRect.Top() + (nProgressHeight - GetTextHeight())/2;
692 [ # # ]: 0 : }
693 : : }
694 [ + - ]: 945 : if( ! bNativeOK )
695 : 945 : maPrgsTxtPos.Y() = mnTextY;
696 : 945 : }
697 : :
698 : : // -----------------------------------------------------------------------
699 : :
700 : 0 : void StatusBar::MouseButtonDown( const MouseEvent& rMEvt )
701 : : {
702 : : // Nur bei linker Maustaste ToolBox ausloesen
703 [ # # ]: 0 : if ( rMEvt.IsLeft() )
704 : : {
705 [ # # ]: 0 : if ( mbVisibleItems )
706 : : {
707 : 0 : Point aMousePos = rMEvt.GetPosPixel();
708 : :
709 : : // Item suchen, das geklickt wurde
710 [ # # ]: 0 : for ( size_t i = 0; i < mpItemList->size(); ++i )
711 : : {
712 : 0 : ImplStatusItem* pItem = (*mpItemList)[ i ];
713 : : // Ist es dieses Item
714 [ # # ][ # # ]: 0 : if ( ImplGetItemRectPos( sal_uInt16(i) ).IsInside( aMousePos ) )
[ # # ]
715 : : {
716 : 0 : mnCurItemId = pItem->mnId;
717 [ # # ]: 0 : if ( rMEvt.GetClicks() == 2 )
718 [ # # ]: 0 : DoubleClick();
719 : : else
720 [ # # ]: 0 : Click();
721 : 0 : mnCurItemId = 0;
722 : :
723 : : // Item wurde gefunden
724 : 0 : return;
725 : : }
726 : : }
727 : : }
728 : :
729 : : // Kein Item, dann nur Click oder DoubleClick
730 [ # # ]: 0 : if ( rMEvt.GetClicks() == 2 )
731 : 0 : DoubleClick();
732 : : else
733 : 0 : Click();
734 : : }
735 : : }
736 : :
737 : : // -----------------------------------------------------------------------
738 : :
739 : 3871 : void StatusBar::Paint( const Rectangle& )
740 : : {
741 [ + + ]: 3871 : if ( mbFormat )
742 : 1855 : ImplFormat();
743 : :
744 : 3871 : sal_uInt16 nItemCount = sal_uInt16( mpItemList->size() );
745 : :
746 [ + + ]: 3871 : if ( mbProgressMode )
747 : 606 : ImplDrawProgress( sal_True, 0, mnPercent );
748 : : else
749 : : {
750 : : // Text zeichen
751 [ + - ][ - + ]: 3265 : if ( !mbVisibleItems || (GetStyle() & WB_RIGHT) )
[ - + ]
752 : 0 : ImplDrawText( sal_False, 0 );
753 : :
754 : : // Items zeichnen
755 [ + - ]: 3265 : if ( mbVisibleItems )
756 : : {
757 : : // Items zeichnen
758 [ + + ]: 26400 : for ( sal_uInt16 i = 0; i < nItemCount; i++ )
759 : 23135 : ImplDrawItem( sal_False, i, sal_True, sal_True );
760 : : }
761 : : }
762 : :
763 : : // draw line at the top of the status bar (to visually distinguish it from
764 : : // shell / docking area)
765 : 3871 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
766 : 3871 : SetLineColor( rStyleSettings.GetShadowColor() );
767 [ + - ]: 3871 : DrawLine( Point( 0, 0 ), Point( mnDX-1, 0 ) );
768 : 3871 : }
769 : :
770 : : // -----------------------------------------------------------------------
771 : :
772 : 4232 : void StatusBar::Move()
773 : : {
774 : 4232 : Window::Move();
775 : 4232 : }
776 : :
777 : : // -----------------------------------------------------------------------
778 : :
779 : 4669 : void StatusBar::Resize()
780 : : {
781 : : // Breite und Hoehe abfragen und merken
782 : 4669 : Size aSize = GetOutputSizePixel();
783 [ + - ]: 4669 : mnDX = aSize.Width() - ImplGetSVData()->maNWFData.mnStatusBarLowerRightOffset;
784 : 4669 : mnDY = aSize.Height();
785 : 4669 : mnCalcHeight = mnDY;
786 : :
787 : 4669 : mnItemY = STATUSBAR_OFFSET_Y;
788 [ + - ]: 4669 : mnTextY = (mnCalcHeight-GetTextHeight())/2;
789 : :
790 : : // Formatierung neu ausloesen
791 : 4669 : mbFormat = sal_True;
792 : :
793 [ + + ]: 4669 : if ( mbProgressMode )
794 [ + - ]: 351 : ImplCalcProgressRect();
795 : :
796 [ + - ]: 4669 : Invalidate();
797 : 4669 : }
798 : :
799 : : // -----------------------------------------------------------------------
800 : :
801 : 0 : void StatusBar::RequestHelp( const HelpEvent& rHEvt )
802 : : {
803 : : // no keyboard help in status bar
804 [ # # ]: 0 : if( rHEvt.KeyboardActivated() )
805 : 0 : return;
806 : :
807 [ # # ]: 0 : sal_uInt16 nItemId = GetItemId( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
808 : :
809 [ # # ]: 0 : if ( nItemId )
810 : : {
811 [ # # ]: 0 : Rectangle aItemRect = GetItemRect( nItemId );
812 [ # # ]: 0 : Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
813 : 0 : aItemRect.Left() = aPt.X();
814 : 0 : aItemRect.Top() = aPt.Y();
815 [ # # ][ # # ]: 0 : aPt = OutputToScreenPixel( aItemRect.BottomRight() );
816 : 0 : aItemRect.Right() = aPt.X();
817 : 0 : aItemRect.Bottom() = aPt.Y();
818 : :
819 [ # # ]: 0 : if ( rHEvt.GetMode() & HELPMODE_BALLOON )
820 : : {
821 [ # # ][ # # ]: 0 : XubString aStr = GetHelpText( nItemId );
822 [ # # ][ # # ]: 0 : Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aStr );
823 [ # # ]: 0 : return;
824 : : }
825 [ # # ]: 0 : else if ( rHEvt.GetMode() & HELPMODE_QUICK )
826 : : {
827 [ # # ][ # # ]: 0 : XubString aStr = GetQuickHelpText( nItemId );
828 : : // Show quickhelp if available
829 [ # # ]: 0 : if( aStr.Len() )
830 : : {
831 [ # # ]: 0 : Help::ShowQuickHelp( this, aItemRect, aStr );
832 : : return;
833 : : }
834 [ # # ][ # # ]: 0 : aStr = GetItemText( nItemId );
835 : : // show a quick help if item text doesn't fit
836 [ # # ][ # # ]: 0 : if ( GetTextWidth( aStr ) > aItemRect.GetWidth() )
[ # # ]
837 : : {
838 [ # # ]: 0 : Help::ShowQuickHelp( this, aItemRect, aStr );
839 : : return;
840 [ # # ][ # # ]: 0 : }
841 : : }
842 [ # # ]: 0 : else if ( rHEvt.GetMode() & HELPMODE_EXTENDED )
843 : : {
844 [ # # ][ # # ]: 0 : String aCommand = GetItemCommand( nItemId );
845 [ # # ]: 0 : rtl::OString aHelpId( GetHelpId( nItemId ) );
846 : :
847 [ # # ][ # # ]: 0 : if ( aCommand.Len() || !aHelpId.isEmpty() )
[ # # ]
848 : : {
849 : : // Wenn eine Hilfe existiert, dann ausloesen
850 [ # # ]: 0 : Help* pHelp = Application::GetHelp();
851 [ # # ]: 0 : if ( pHelp )
852 : : {
853 [ # # ]: 0 : if ( aCommand.Len() )
854 [ # # ]: 0 : pHelp->Start( aCommand, this );
855 [ # # ]: 0 : else if ( !aHelpId.isEmpty() )
856 [ # # ][ # # ]: 0 : pHelp->Start( rtl::OStringToOUString( aHelpId, RTL_TEXTENCODING_UTF8 ), this );
[ # # ][ # # ]
857 : : }
858 : : return;
859 [ # # ][ # # ]: 0 : }
[ # # ]
860 : : }
861 : : }
862 : :
863 : 0 : Window::RequestHelp( rHEvt );
864 : : }
865 : :
866 : : // -----------------------------------------------------------------------
867 : :
868 : 1427 : void StatusBar::StateChanged( StateChangedType nType )
869 : : {
870 : 1427 : Window::StateChanged( nType );
871 : :
872 [ + + ]: 1427 : if ( nType == STATE_CHANGE_INITSHOW )
873 : 411 : ImplFormat();
874 [ + + ]: 1016 : else if ( nType == STATE_CHANGE_UPDATEMODE )
875 : 194 : Invalidate();
876 [ + - ][ - + ]: 822 : else if ( (nType == STATE_CHANGE_ZOOM) ||
877 : : (nType == STATE_CHANGE_CONTROLFONT) )
878 : : {
879 : 0 : mbFormat = sal_True;
880 : 0 : ImplInitSettings( sal_True, sal_False, sal_False );
881 : 0 : Invalidate();
882 : : }
883 [ - + ]: 822 : else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
884 : : {
885 : 0 : ImplInitSettings( sal_False, sal_True, sal_False );
886 : 0 : Invalidate();
887 : : }
888 [ - + ]: 822 : else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
889 : : {
890 : 0 : ImplInitSettings( sal_False, sal_False, sal_True );
891 : 0 : Invalidate();
892 : : }
893 : 1427 : }
894 : :
895 : : // -----------------------------------------------------------------------
896 : :
897 : 6 : void StatusBar::DataChanged( const DataChangedEvent& rDCEvt )
898 : : {
899 : 6 : Window::DataChanged( rDCEvt );
900 : :
901 [ - + ][ + - : 30 : if ( (rDCEvt.GetType() == DATACHANGED_DISPLAY )
+ - + - +
- - + ]
902 : 6 : || (rDCEvt.GetType() == DATACHANGED_FONTS )
903 : 6 : || (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION)
904 : 6 : || ( (rDCEvt.GetType() == DATACHANGED_SETTINGS)
905 : 6 : && (rDCEvt.GetFlags() & SETTINGS_STYLE )
906 : : )
907 : : )
908 : : {
909 : 0 : mbFormat = sal_True;
910 [ # # ]: 0 : ImplInitSettings( sal_True, sal_True, sal_True );
911 [ # # ]: 0 : long nFudge = GetTextHeight() / 4;
912 [ # # ]: 0 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i )
913 : : {
914 : 0 : ImplStatusItem* pItem = (*mpItemList)[ i ];
915 [ # # ]: 0 : long nWidth = GetTextWidth( pItem->maText ) + nFudge;
916 [ # # ]: 0 : if( nWidth > pItem->mnWidth + STATUSBAR_OFFSET )
917 : 0 : pItem->mnWidth = nWidth + STATUSBAR_OFFSET;
918 : : }
919 [ # # ]: 0 : Size aSize = GetSizePixel();
920 : : // do not disturb current width, since
921 : : // CalcWindowSizePixel calculates a minimum width
922 [ # # ]: 0 : aSize.Height() = CalcWindowSizePixel().Height();
923 [ # # ]: 0 : SetSizePixel( aSize );
924 [ # # ]: 0 : Invalidate();
925 : : }
926 : 6 : }
927 : :
928 : : // -----------------------------------------------------------------------
929 : :
930 : 0 : void StatusBar::Click()
931 : : {
932 : 0 : ImplCallEventListeners( VCLEVENT_STATUSBAR_CLICK );
933 : 0 : maClickHdl.Call( this );
934 : 0 : }
935 : :
936 : : // -----------------------------------------------------------------------
937 : :
938 : 0 : void StatusBar::DoubleClick()
939 : : {
940 : 0 : ImplCallEventListeners( VCLEVENT_STATUSBAR_DOUBLECLICK );
941 : 0 : maDoubleClickHdl.Call( this );
942 : 0 : }
943 : :
944 : : // -----------------------------------------------------------------------
945 : :
946 : 0 : void StatusBar::UserDraw( const UserDrawEvent& )
947 : : {
948 : 0 : }
949 : :
950 : : // -----------------------------------------------------------------------
951 : :
952 : 12339 : void StatusBar::InsertItem( sal_uInt16 nItemId, sal_uLong nWidth,
953 : : StatusBarItemBits nBits,
954 : : long nOffset, sal_uInt16 nPos )
955 : : {
956 : : DBG_ASSERT( nItemId, "StatusBar::InsertItem(): ItemId == 0" );
957 : : DBG_ASSERT( GetItemPos( nItemId ) == STATUSBAR_ITEM_NOTFOUND,
958 : : "StatusBar::InsertItem(): ItemId already exists" );
959 : :
960 : : // IN und CENTER sind Default
961 [ - + ]: 12339 : if ( !(nBits & (SIB_IN | SIB_OUT | SIB_FLAT)) )
962 : 0 : nBits |= SIB_IN;
963 [ - + ]: 12339 : if ( !(nBits & (SIB_LEFT | SIB_RIGHT | SIB_CENTER)) )
964 : 0 : nBits |= SIB_CENTER;
965 : :
966 : : // Item anlegen
967 [ + - ]: 12339 : long nFudge = GetTextHeight()/4;
968 [ + - ][ + - ]: 12339 : ImplStatusItem* pItem = new ImplStatusItem;
969 : 12339 : pItem->mnId = nItemId;
970 : 12339 : pItem->mnBits = nBits;
971 : 12339 : pItem->mnWidth = (long)nWidth+nFudge+STATUSBAR_OFFSET;
972 : 12339 : pItem->mnOffset = nOffset;
973 : 12339 : pItem->mpUserData = 0;
974 : 12339 : pItem->mbVisible = sal_True;
975 : :
976 : : // Item in die Liste einfuegen
977 [ - + ]: 12339 : if ( nPos < mpItemList->size() ) {
978 [ # # ][ # # ]: 0 : mpItemList->insert( mpItemList->begin() + nPos, pItem );
979 : : } else {
980 [ + - ]: 12339 : mpItemList->push_back( pItem );
981 : : }
982 : :
983 : 12339 : mbFormat = sal_True;
984 [ + - ][ - + ]: 12339 : if ( ImplIsItemUpdate() )
985 [ # # ]: 0 : Invalidate();
986 : :
987 [ + - ]: 12339 : ImplCallEventListeners( VCLEVENT_STATUSBAR_ITEMADDED, (void*) sal_IntPtr(nItemId) );
988 : 12339 : }
989 : :
990 : : // -----------------------------------------------------------------------
991 : :
992 : 4 : sal_Bool StatusBar::IsItemVisible( sal_uInt16 nItemId ) const
993 : : {
994 : 4 : sal_uInt16 nPos = GetItemPos( nItemId );
995 : :
996 [ + - ]: 4 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
997 : 4 : return (*mpItemList)[ nPos ]->mbVisible;
998 : : else
999 : 4 : return sal_False;
1000 : : }
1001 : :
1002 : : // -----------------------------------------------------------------------
1003 : :
1004 : 1177 : void StatusBar::Clear()
1005 : : {
1006 : : // Alle Item loeschen
1007 [ - + ]: 1177 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) {
1008 [ # # ]: 0 : delete (*mpItemList)[ i ];
1009 : : }
1010 : 1177 : mpItemList->clear();
1011 : :
1012 : 1177 : mbFormat = sal_True;
1013 [ - + ]: 1177 : if ( ImplIsItemUpdate() )
1014 : 0 : Invalidate();
1015 : :
1016 : 1177 : ImplCallEventListeners( VCLEVENT_STATUSBAR_ALLITEMSREMOVED );
1017 : 1177 : }
1018 : :
1019 : : // -----------------------------------------------------------------------
1020 : :
1021 : 13518 : sal_uInt16 StatusBar::GetItemCount() const
1022 : : {
1023 : 13518 : return (sal_uInt16)mpItemList->size();
1024 : : }
1025 : :
1026 : : // -----------------------------------------------------------------------
1027 : :
1028 : 12343 : sal_uInt16 StatusBar::GetItemId( sal_uInt16 nPos ) const
1029 : : {
1030 [ + - ]: 12343 : if ( nPos < mpItemList->size() )
1031 : 12343 : return (*mpItemList)[ nPos ]->mnId;
1032 : 12343 : return 0;
1033 : : }
1034 : :
1035 : : // -----------------------------------------------------------------------
1036 : :
1037 : 115841 : sal_uInt16 StatusBar::GetItemPos( sal_uInt16 nItemId ) const
1038 : : {
1039 [ + + ]: 835493 : for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) {
1040 [ + + ]: 823952 : if ( (*mpItemList)[ i ]->mnId == nItemId ) {
1041 : 104300 : return sal_uInt16( i );
1042 : : }
1043 : : }
1044 : :
1045 : 115841 : return STATUSBAR_ITEM_NOTFOUND;
1046 : : }
1047 : :
1048 : : // -----------------------------------------------------------------------
1049 : :
1050 : 0 : sal_uInt16 StatusBar::GetItemId( const Point& rPos ) const
1051 : : {
1052 [ # # ][ # # ]: 0 : if ( AreItemsVisible() && !mbFormat )
[ # # ]
1053 : : {
1054 : 0 : sal_uInt16 nItemCount = GetItemCount();
1055 : : sal_uInt16 nPos;
1056 [ # # ]: 0 : for ( nPos = 0; nPos < nItemCount; nPos++ )
1057 : : {
1058 : : // Rechteck holen
1059 [ # # ]: 0 : Rectangle aRect = ImplGetItemRectPos( nPos );
1060 [ # # ][ # # ]: 0 : if ( aRect.IsInside( rPos ) )
1061 : 0 : return (*mpItemList)[ nPos ]->mnId;
1062 : : }
1063 : : }
1064 : :
1065 : 0 : return 0;
1066 : : }
1067 : :
1068 : : // -----------------------------------------------------------------------
1069 : :
1070 : 12774 : Rectangle StatusBar::GetItemRect( sal_uInt16 nItemId ) const
1071 : : {
1072 : 12774 : Rectangle aRect;
1073 : :
1074 [ + + ][ + + ]: 12774 : if ( AreItemsVisible() && !mbFormat )
[ + - ]
1075 : : {
1076 : 12747 : sal_uInt16 nPos = GetItemPos( nItemId );
1077 [ + - ]: 12747 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1078 : : {
1079 : : // Rechteck holen und Rahmen abziehen
1080 : 12747 : aRect = ImplGetItemRectPos( nPos );
1081 : 12747 : long nW = mpImplData->mnItemBorderWidth+1;
1082 : 12747 : aRect.Top() += nW-1;
1083 : 12747 : aRect.Bottom() -= nW-1;
1084 : 12747 : aRect.Left() += nW;
1085 : 12747 : aRect.Right() -= nW;
1086 : 12747 : return aRect;
1087 : : }
1088 : : }
1089 : :
1090 : 12774 : return aRect;
1091 : : }
1092 : :
1093 : : // -----------------------------------------------------------------------
1094 : :
1095 : 3835 : Point StatusBar::GetItemTextPos( sal_uInt16 nItemId ) const
1096 : : {
1097 [ + - ]: 3835 : if ( !mbFormat )
1098 : : {
1099 : 3835 : sal_uInt16 nPos = GetItemPos( nItemId );
1100 [ + - ]: 3835 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1101 : : {
1102 : : // Rechteck holen
1103 : 3835 : ImplStatusItem* pItem = (*mpItemList)[ nPos ];
1104 [ + - ]: 3835 : Rectangle aRect = ImplGetItemRectPos( nPos );
1105 : 3835 : long nW = mpImplData->mnItemBorderWidth + 1;
1106 : 3835 : Rectangle aTextRect( aRect.Left()+nW, aRect.Top()+nW,
1107 [ + - ]: 7670 : aRect.Right()-nW, aRect.Bottom()-nW );
1108 : : Point aPos = ImplGetItemTextPos( aTextRect.GetSize(),
1109 : : Size( GetTextWidth( pItem->maText ), GetTextHeight() ),
1110 [ + - ][ + - ]: 3835 : pItem->mnBits );
[ + - ]
1111 [ + + ]: 3835 : if ( !mbInUserDraw )
1112 : : {
1113 : 2021 : aPos.X() += aTextRect.Left();
1114 : 2021 : aPos.Y() += aTextRect.Top();
1115 : : }
1116 : 3835 : return aPos;
1117 : : }
1118 : : }
1119 : :
1120 : 3835 : return Point();
1121 : : }
1122 : :
1123 : : // -----------------------------------------------------------------------
1124 : :
1125 : 23333 : void StatusBar::SetItemText( sal_uInt16 nItemId, const XubString& rText )
1126 : : {
1127 : 23333 : sal_uInt16 nPos = GetItemPos( nItemId );
1128 : :
1129 [ + - ]: 23333 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1130 : : {
1131 : 23333 : ImplStatusItem* pItem = (*mpItemList)[ nPos ];
1132 : :
1133 [ + + ]: 23333 : if ( pItem->maText != rText )
1134 : : {
1135 : 6713 : pItem->maText = rText;
1136 : :
1137 : : // adjust item width - see also DataChanged()
1138 : 6713 : long nFudge = GetTextHeight()/4;
1139 : 6713 : long nWidth = GetTextWidth( pItem->maText ) + nFudge;
1140 [ + + ][ + + ]: 6713 : if( (nWidth > pItem->mnWidth + STATUSBAR_OFFSET) ||
[ + + ]
1141 : : ((nWidth < pItem->mnWidth) && (mnDX - STATUSBAR_OFFSET) < mnItemsWidth ))
1142 : : {
1143 : 5508 : pItem->mnWidth = nWidth + STATUSBAR_OFFSET;
1144 : 5508 : ImplFormat();
1145 : 5508 : Invalidate();
1146 : : }
1147 : :
1148 : : // Item neu Zeichen, wenn StatusBar sichtbar und
1149 : : // UpdateMode gesetzt ist
1150 [ + - ][ + + ]: 6713 : if ( pItem->mbVisible && !mbFormat && ImplIsItemUpdate() )
[ + + ][ + + ]
1151 : : {
1152 : 875 : Update();
1153 : 875 : ImplDrawItem( sal_True, nPos, sal_True, sal_False );
1154 : 875 : Flush();
1155 : : }
1156 : : }
1157 : : }
1158 : 23333 : }
1159 : :
1160 : : // -----------------------------------------------------------------------
1161 : :
1162 : 0 : const XubString& StatusBar::GetItemText( sal_uInt16 nItemId ) const
1163 : : {
1164 : 0 : sal_uInt16 nPos = GetItemPos( nItemId );
1165 : :
1166 [ # # ]: 0 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1167 : 0 : return (*mpItemList)[ nPos ]->maText;
1168 : :
1169 : 0 : return ImplGetSVEmptyStr();
1170 : : }
1171 : :
1172 : : // -----------------------------------------------------------------------
1173 : :
1174 : 12339 : void StatusBar::SetItemCommand( sal_uInt16 nItemId, const XubString& rCommand )
1175 : : {
1176 : 12339 : sal_uInt16 nPos = GetItemPos( nItemId );
1177 : :
1178 [ + - ]: 12339 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1179 : : {
1180 : 12339 : ImplStatusItem* pItem = (*mpItemList)[ nPos ];
1181 : :
1182 [ + - ]: 12339 : if ( pItem->maCommand != rCommand )
1183 : 12339 : pItem->maCommand = rCommand;
1184 : : }
1185 : 12339 : }
1186 : :
1187 : : // -----------------------------------------------------------------------
1188 : :
1189 : 12339 : const XubString& StatusBar::GetItemCommand( sal_uInt16 nItemId )
1190 : : {
1191 : 12339 : sal_uInt16 nPos = GetItemPos( nItemId );
1192 : :
1193 [ + - ]: 12339 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1194 : 12339 : return (*mpItemList)[ nPos ]->maCommand;
1195 : :
1196 : 12339 : return ImplGetSVEmptyStr();
1197 : : }
1198 : :
1199 : : // -----------------------------------------------------------------------
1200 : :
1201 : 12066 : void StatusBar::SetItemData( sal_uInt16 nItemId, void* pNewData )
1202 : : {
1203 : 12066 : sal_uInt16 nPos = GetItemPos( nItemId );
1204 : :
1205 [ + - ]: 12066 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1206 : : {
1207 : 12066 : ImplStatusItem* pItem = (*mpItemList)[ nPos ];
1208 : 12066 : pItem->mpUserData = pNewData;
1209 : :
1210 : : // Wenn es ein User-Item ist, DrawItem-Aufrufen
1211 [ + - ]: 23533 : if ( (pItem->mnBits & SIB_USERDRAW) && pItem->mbVisible &&
[ + + + + ]
[ + + ][ + - ]
1212 : 11467 : !mbFormat && ImplIsItemUpdate() )
1213 : : {
1214 : 4420 : Update();
1215 : 4420 : ImplDrawItem( sal_True, nPos, sal_False, sal_False );
1216 : 4420 : Flush();
1217 : : }
1218 : : }
1219 : 12066 : }
1220 : :
1221 : : // -----------------------------------------------------------------------
1222 : :
1223 : 5244 : void StatusBar::SetHelpText( sal_uInt16 nItemId, const XubString& rText )
1224 : : {
1225 : 5244 : sal_uInt16 nPos = GetItemPos( nItemId );
1226 : :
1227 [ + - ]: 5244 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1228 : 5244 : (*mpItemList)[ nPos ]->maHelpText = rText;
1229 : 5244 : }
1230 : :
1231 : : // -----------------------------------------------------------------------
1232 : :
1233 : 0 : const XubString& StatusBar::GetHelpText( sal_uInt16 nItemId ) const
1234 : : {
1235 : 0 : sal_uInt16 nPos = GetItemPos( nItemId );
1236 : :
1237 [ # # ]: 0 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1238 : : {
1239 : 0 : ImplStatusItem* pItem = (*mpItemList)[ nPos ];
1240 [ # # ][ # # ]: 0 : if ( !pItem->maHelpText.Len() && ( !pItem->maHelpId.isEmpty() || pItem->maCommand.Len() ))
[ # # ][ # # ]
1241 : : {
1242 : 0 : Help* pHelp = Application::GetHelp();
1243 [ # # ]: 0 : if ( pHelp )
1244 : : {
1245 [ # # ]: 0 : if ( pItem->maCommand.Len() )
1246 [ # # ]: 0 : pItem->maHelpText = pHelp->GetHelpText( pItem->maCommand, this );
1247 [ # # ][ # # ]: 0 : if ( !pItem->maHelpText.Len() && !pItem->maHelpId.isEmpty() )
[ # # ]
1248 [ # # ][ # # ]: 0 : pItem->maHelpText = pHelp->GetHelpText( rtl::OStringToOUString( pItem->maHelpId, RTL_TEXTENCODING_UTF8 ), this );
[ # # ][ # # ]
[ # # ]
1249 : : }
1250 : : }
1251 : :
1252 : 0 : return pItem->maHelpText;
1253 : : }
1254 : : else
1255 : 0 : return ImplGetSVEmptyStr();
1256 : : }
1257 : :
1258 : : // -----------------------------------------------------------------------
1259 : :
1260 : 6529 : void StatusBar::SetQuickHelpText( sal_uInt16 nItemId, const XubString& rText )
1261 : : {
1262 : 6529 : sal_uInt16 nPos = GetItemPos( nItemId );
1263 : :
1264 [ + - ]: 6529 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1265 : 6529 : (*mpItemList)[ nPos ]->maQuickHelpText = rText;
1266 : 6529 : }
1267 : :
1268 : : // -----------------------------------------------------------------------
1269 : :
1270 : 0 : const XubString& StatusBar::GetQuickHelpText( sal_uInt16 nItemId ) const
1271 : : {
1272 : 0 : sal_uInt16 nPos = GetItemPos( nItemId );
1273 : :
1274 [ # # ]: 0 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1275 : : {
1276 : 0 : ImplStatusItem* pItem = (*mpItemList)[ nPos ];
1277 : 0 : return pItem->maQuickHelpText;
1278 : : }
1279 : :
1280 : 0 : return ImplGetSVEmptyStr();
1281 : : }
1282 : :
1283 : : // -----------------------------------------------------------------------
1284 : :
1285 : 15062 : void StatusBar::SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId )
1286 : : {
1287 : 15062 : sal_uInt16 nPos = GetItemPos( nItemId );
1288 : :
1289 [ + + ]: 15062 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1290 : 3521 : (*mpItemList)[ nPos ]->maHelpId = rHelpId;
1291 : 15062 : }
1292 : :
1293 : : // -----------------------------------------------------------------------
1294 : :
1295 : 0 : rtl::OString StatusBar::GetHelpId( sal_uInt16 nItemId ) const
1296 : : {
1297 : 0 : sal_uInt16 nPos = GetItemPos( nItemId );
1298 : :
1299 : 0 : rtl::OString aRet;
1300 [ # # ]: 0 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1301 : : {
1302 : 0 : ImplStatusItem* pItem = (*mpItemList)[ nPos ];
1303 [ # # ]: 0 : if ( !pItem->maHelpId.isEmpty() )
1304 : 0 : aRet = pItem->maHelpId;
1305 : : else
1306 [ # # ][ # # ]: 0 : aRet = ::rtl::OUStringToOString( pItem->maCommand, RTL_TEXTENCODING_UTF8 );
1307 : : }
1308 : :
1309 : 0 : return aRet;
1310 : : }
1311 : :
1312 : 594 : void StatusBar::StartProgressMode( const XubString& rText )
1313 : : {
1314 : : DBG_ASSERT( !mbProgressMode, "StatusBar::StartProgressMode(): progress mode is active" );
1315 : :
1316 : 594 : mbProgressMode = sal_True;
1317 : 594 : mnPercent = 0;
1318 [ + - ]: 594 : maPrgsTxt = rText;
1319 : :
1320 : : // Groessen berechnen
1321 [ + - ]: 594 : ImplCalcProgressRect();
1322 : :
1323 : : // Paint ausloesen (dort wird der Text und der Frame gemalt)
1324 : 594 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1325 : 594 : Color aPrgsColor = rStyleSettings.GetHighlightColor();
1326 [ - + ]: 594 : if ( aPrgsColor == rStyleSettings.GetFaceColor() )
1327 : 0 : aPrgsColor = rStyleSettings.GetDarkShadowColor();
1328 [ + - ]: 594 : SetLineColor();
1329 [ + - ]: 594 : SetFillColor( aPrgsColor );
1330 [ + - ][ + - ]: 594 : if ( IsReallyVisible() )
1331 : : {
1332 [ + - ]: 594 : Invalidate();
1333 [ + - ]: 594 : Update();
1334 [ + - ]: 594 : Flush();
1335 : : }
1336 : 594 : }
1337 : :
1338 : : // -----------------------------------------------------------------------
1339 : :
1340 : 13736 : void StatusBar::SetProgressValue( sal_uInt16 nNewPercent )
1341 : : {
1342 : : DBG_ASSERT( mbProgressMode, "StatusBar::SetProgressValue(): no progrss mode" );
1343 : : DBG_ASSERTWARNING( nNewPercent <= 100, "StatusBar::SetProgressValue(): nPercent > 100" );
1344 : :
1345 [ + - + - ]: 27472 : if ( mbProgressMode
[ + + ][ + - ]
[ + - ]
1346 : 13736 : && IsReallyVisible()
1347 : 13736 : && (!mnPercent || (mnPercent != nNewPercent)) )
1348 : : {
1349 : 13736 : Update();
1350 : 13736 : SetLineColor();
1351 : 13736 : ImplDrawProgress( sal_False, mnPercent, nNewPercent );
1352 : 13736 : Flush();
1353 : : }
1354 : 13736 : mnPercent = nNewPercent;
1355 : 13736 : }
1356 : :
1357 : : // -----------------------------------------------------------------------
1358 : :
1359 : 594 : void StatusBar::EndProgressMode()
1360 : : {
1361 : : DBG_ASSERT( mbProgressMode, "StatusBar::EndProgressMode(): no progress mode" );
1362 : :
1363 : 594 : mbProgressMode = sal_False;
1364 : 594 : maPrgsTxt.Erase();
1365 : :
1366 : : // Paint neu ausloesen um StatusBar wieder herzustellen
1367 : 594 : SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
1368 [ + - ]: 594 : if ( IsReallyVisible() )
1369 : : {
1370 : 594 : Invalidate();
1371 : 594 : Update();
1372 : 594 : Flush();
1373 : : }
1374 : 594 : }
1375 : :
1376 : : // -----------------------------------------------------------------------
1377 : :
1378 : 0 : void StatusBar::SetText( const XubString& rText )
1379 : : {
1380 [ # # ][ # # ]: 0 : if ( (!mbVisibleItems || (GetStyle() & WB_RIGHT)) && !mbProgressMode &&
[ # # # #
# # ][ # # ]
1381 : 0 : IsReallyVisible() && IsUpdateMode() )
1382 : : {
1383 [ # # ]: 0 : if ( mbFormat )
1384 : : {
1385 : 0 : Invalidate();
1386 : 0 : Window::SetText( rText );
1387 : : }
1388 : : else
1389 : : {
1390 : 0 : Update();
1391 [ # # ]: 0 : long nOldTextWidth = GetTextWidth( GetText() );
1392 : 0 : Window::SetText( rText );
1393 : 0 : ImplDrawText( sal_True, nOldTextWidth );
1394 : 0 : Flush();
1395 : : }
1396 : : }
1397 [ # # ]: 0 : else if ( mbProgressMode )
1398 : : {
1399 : 0 : maPrgsTxt = rText;
1400 [ # # ]: 0 : if ( IsReallyVisible() )
1401 : : {
1402 : 0 : Invalidate();
1403 : 0 : Update();
1404 : 0 : Flush();
1405 : : }
1406 : : }
1407 : : else
1408 : 0 : Window::SetText( rText );
1409 : 0 : }
1410 : :
1411 : : // -----------------------------------------------------------------------
1412 : :
1413 : 5229 : Size StatusBar::CalcWindowSizePixel() const
1414 : : {
1415 : 5229 : size_t i = 0;
1416 : 5229 : size_t nCount = mpItemList->size();
1417 : 5229 : long nOffset = 0;
1418 : 5229 : long nCalcWidth = (STATUSBAR_OFFSET_X*2);
1419 : : long nCalcHeight;
1420 : :
1421 [ - + ]: 5229 : while ( i < nCount )
1422 : : {
1423 : 0 : ImplStatusItem* pItem = (*mpItemList)[ i ];
1424 : 0 : nCalcWidth += pItem->mnWidth + nOffset;
1425 : 0 : nOffset = pItem->mnOffset;
1426 : 0 : i++;
1427 : : }
1428 : :
1429 : 5229 : long nMinHeight = GetTextHeight();
1430 : 5229 : const long nBarTextOffset = STATUSBAR_OFFSET_TEXTY*2;
1431 : 5229 : long nProgressHeight = nMinHeight + nBarTextOffset;
1432 : : // FIXME: IsNativeControlSupported and GetNativeControlRegion should be const ?
1433 : 5229 : StatusBar* pThis = const_cast<StatusBar*>( this );
1434 [ - + ]: 5229 : if( pThis->IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) )
1435 : : {
1436 : 0 : ImplControlValue aValue;
1437 [ # # ]: 0 : Rectangle aControlRegion( (const Point&)Point(), Size( nCalcWidth, nMinHeight ) );
1438 [ # # ][ # # ]: 0 : Rectangle aNativeControlRegion, aNativeContentRegion;
1439 [ # # ]: 0 : if( pThis->GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion,
1440 : : CTRL_STATE_ENABLED, aValue, rtl::OUString(),
1441 [ # # ]: 0 : aNativeControlRegion, aNativeContentRegion ) )
1442 : : {
1443 [ # # ]: 0 : nProgressHeight = aNativeControlRegion.GetHeight();
1444 [ # # ]: 0 : }
1445 : : }
1446 : :
1447 [ - + # # ]: 5229 : if( mpImplData->mbDrawItemFrames &&
[ - + ]
1448 : 0 : pThis->IsNativeControlSupported( CTRL_FRAME, PART_BORDER ) )
1449 : : {
1450 : 0 : ImplControlValue aControlValue( FRAME_DRAW_NODRAW );
1451 [ # # ][ # # ]: 0 : Rectangle aBound, aContent;
1452 [ # # ]: 0 : Rectangle aNatRgn( Point( 0, 0 ), Size( 150, 50 ) );
1453 [ # # ]: 0 : if( pThis->GetNativeControlRegion(CTRL_FRAME, PART_BORDER,
1454 [ # # ]: 0 : aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) )
1455 : : {
1456 : : mpImplData->mnItemBorderWidth =
1457 [ # # ][ # # ]: 0 : ( aBound.GetHeight() - aContent.GetHeight() ) / 2;
1458 [ # # ]: 0 : }
1459 : : }
1460 : :
1461 : 5229 : nCalcHeight = nMinHeight+nBarTextOffset + 2*mpImplData->mnItemBorderWidth;
1462 [ + - ]: 5229 : if( nCalcHeight < nProgressHeight+2 )
1463 : 5229 : nCalcHeight = nProgressHeight+2;
1464 : :
1465 : 5229 : return Size( nCalcWidth, nCalcHeight );
1466 : : }
1467 : :
1468 : :
1469 : : // -----------------------------------------------------------------------
1470 : :
1471 : 12339 : void StatusBar::SetAccessibleName( sal_uInt16 nItemId, const XubString& rName )
1472 : : {
1473 : 12339 : sal_uInt16 nPos = GetItemPos( nItemId );
1474 : :
1475 [ + - ]: 12339 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1476 : : {
1477 : 12339 : ImplStatusItem* pItem = (*mpItemList)[ nPos ];
1478 : :
1479 [ + + ]: 12339 : if ( pItem->maAccessibleName != rName )
1480 : : {
1481 : 9710 : pItem->maAccessibleName = rName;
1482 : 9710 : ImplCallEventListeners( VCLEVENT_STATUSBAR_NAMECHANGED, (void*) sal_IntPtr(pItem->mnId) );
1483 : : }
1484 : : }
1485 : 12339 : }
1486 : :
1487 : : // -----------------------------------------------------------------------
1488 : :
1489 : 4 : const XubString& StatusBar::GetAccessibleName( sal_uInt16 nItemId ) const
1490 : : {
1491 : 4 : sal_uInt16 nPos = GetItemPos( nItemId );
1492 : :
1493 [ + - ]: 4 : if ( nPos != STATUSBAR_ITEM_NOTFOUND )
1494 : 4 : return (*mpItemList)[ nPos ]->maAccessibleName;
1495 : :
1496 : 4 : return ImplGetSVEmptyStr();
1497 : : }
1498 : :
1499 : : // -----------------------------------------------------------------------
1500 : :
1501 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|