Line data Source code
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 :
21 : #include "splash.hxx"
22 : #include <stdio.h>
23 : #include <unotools/bootstrap.hxx>
24 : #include <tools/stream.hxx>
25 : #include <vcl/svapp.hxx>
26 : #include <vcl/salnativewidgets.hxx>
27 :
28 : #include <com/sun/star/lang/XInitialization.hpp>
29 : #include <com/sun/star/registry/XRegistryKey.hpp>
30 : #include <com/sun/star/task/XStatusIndicator.hpp>
31 : #include <cppuhelper/implbase2.hxx>
32 : #include <rtl/bootstrap.hxx>
33 : #include <rtl/strbuf.hxx>
34 : #include <rtl/math.hxx>
35 : #include <vcl/introwin.hxx>
36 : #include <vcl/virdev.hxx>
37 :
38 : #define NOT_LOADED ((long)-1)
39 :
40 : using namespace ::rtl;
41 : using namespace ::com::sun::star::lang;
42 : using namespace ::com::sun::star::registry;
43 : using namespace ::com::sun::star::task;
44 : using namespace ::com::sun::star::uno;
45 :
46 : namespace {
47 :
48 : class SplashScreen
49 : : public ::cppu::WeakImplHelper2< XStatusIndicator, XInitialization >
50 : , public IntroWindow
51 : {
52 : private:
53 : enum BitmapMode { BM_FULLSCREEN, BM_DEFAULTMODE };
54 :
55 : DECL_LINK( AppEventListenerHdl, VclWindowEvent * );
56 : virtual ~SplashScreen();
57 : void loadConfig();
58 : void updateStatus();
59 : void SetScreenBitmap(BitmapEx &rBitmap);
60 : void determineProgressRatioValues( double& rXRelPos, double& rYRelPos, double& rRelWidth, double& rRelHeight );
61 :
62 : static osl::Mutex _aMutex;
63 :
64 : VirtualDevice _vdev;
65 : BitmapEx _aIntroBmp;
66 : Color _cProgressFrameColor;
67 : Color _cProgressBarColor;
68 : Color _cProgressTextColor;
69 : bool _bNativeProgress;
70 : OUString _sAppName;
71 : OUString _sProgressText;
72 :
73 : sal_Int32 _iMax;
74 : sal_Int32 _iProgress;
75 : BitmapMode _eBitmapMode;
76 : sal_Bool _bPaintBitmap;
77 : sal_Bool _bPaintProgress;
78 : sal_Bool _bVisible;
79 : sal_Bool _bShowLogo;
80 : sal_Bool _bFullScreenSplash;
81 : sal_Bool _bProgressEnd;
82 : long _height, _width, _tlx, _tly, _barwidth;
83 : long _barheight, _barspace, _textBaseline;
84 : double _fXPos, _fYPos;
85 : double _fWidth, _fHeight;
86 : const long _xoffset, _yoffset;
87 :
88 : public:
89 : SplashScreen();
90 :
91 : // XStatusIndicator
92 : virtual void SAL_CALL end() throw ( RuntimeException );
93 : virtual void SAL_CALL reset() throw ( RuntimeException );
94 : virtual void SAL_CALL setText(const OUString& aText) throw ( RuntimeException );
95 : virtual void SAL_CALL setValue(sal_Int32 nValue) throw ( RuntimeException );
96 : virtual void SAL_CALL start(const OUString& aText, sal_Int32 nRange) throw ( RuntimeException );
97 :
98 : // XInitialize
99 : virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& aArguments )
100 : throw ( RuntimeException );
101 :
102 : // workwindow
103 : virtual void Paint( const Rectangle& );
104 :
105 : };
106 :
107 0 : SplashScreen::SplashScreen()
108 : : IntroWindow()
109 : , _vdev(*((IntroWindow*)this))
110 : , _cProgressFrameColor(sal::static_int_cast< ColorData >(NOT_LOADED))
111 : , _cProgressBarColor(sal::static_int_cast< ColorData >(NOT_LOADED))
112 : , _cProgressTextColor(sal::static_int_cast< ColorData >(NOT_LOADED))
113 : , _bNativeProgress(true)
114 : , _iMax(100)
115 : , _iProgress(0)
116 : , _eBitmapMode(BM_DEFAULTMODE)
117 : , _bPaintBitmap(sal_True)
118 : , _bPaintProgress(sal_False)
119 : , _bShowLogo(sal_True)
120 : , _bFullScreenSplash(sal_False)
121 : , _bProgressEnd(sal_False)
122 : , _tlx(NOT_LOADED)
123 : , _tly(NOT_LOADED)
124 : , _barwidth(NOT_LOADED)
125 : , _barheight(NOT_LOADED)
126 : , _barspace(2)
127 : , _textBaseline(NOT_LOADED)
128 : , _fXPos(-1.0)
129 : , _fYPos(-1.0)
130 : , _fWidth(-1.0)
131 : , _fHeight(-1.0)
132 : , _xoffset(12)
133 0 : , _yoffset(18)
134 : {
135 0 : loadConfig();
136 0 : _vdev.EnableRTL(IsRTLEnabled());
137 0 : }
138 :
139 0 : SplashScreen::~SplashScreen()
140 : {
141 : Application::RemoveEventListener(
142 0 : LINK( this, SplashScreen, AppEventListenerHdl ) );
143 0 : Hide();
144 :
145 0 : }
146 :
147 0 : void SAL_CALL SplashScreen::start(const OUString&, sal_Int32 nRange)
148 : throw (RuntimeException)
149 : {
150 0 : _iMax = nRange;
151 0 : if (_bVisible) {
152 0 : _bProgressEnd = sal_False;
153 0 : SolarMutexGuard aSolarGuard;
154 0 : if ( _eBitmapMode == BM_FULLSCREEN )
155 0 : ShowFullScreenMode( sal_True );
156 0 : Show();
157 0 : Paint(Rectangle());
158 0 : Flush();
159 : }
160 0 : }
161 :
162 0 : void SAL_CALL SplashScreen::end()
163 : throw (RuntimeException)
164 : {
165 0 : _iProgress = _iMax;
166 0 : if (_bVisible )
167 : {
168 0 : if ( _eBitmapMode == BM_FULLSCREEN )
169 0 : EndFullScreenMode();
170 0 : Hide();
171 : }
172 0 : _bProgressEnd = sal_True;
173 0 : }
174 :
175 0 : void SAL_CALL SplashScreen::reset()
176 : throw (RuntimeException)
177 : {
178 0 : _iProgress = 0;
179 0 : if (_bVisible && !_bProgressEnd )
180 : {
181 0 : if ( _eBitmapMode == BM_FULLSCREEN )
182 0 : ShowFullScreenMode( sal_True );
183 0 : Show();
184 0 : updateStatus();
185 : }
186 0 : }
187 :
188 0 : void SAL_CALL SplashScreen::setText(const OUString& rText)
189 : throw (RuntimeException)
190 : {
191 0 : SolarMutexGuard aSolarGuard;
192 0 : if ( _sProgressText != rText )
193 : {
194 0 : _sProgressText = rText;
195 :
196 0 : if (_bVisible && !_bProgressEnd)
197 : {
198 0 : if ( _eBitmapMode == BM_FULLSCREEN )
199 0 : ShowFullScreenMode( sal_True );
200 0 : Show();
201 0 : updateStatus();
202 : }
203 0 : }
204 0 : }
205 :
206 0 : void SAL_CALL SplashScreen::setValue(sal_Int32 nValue)
207 : throw (RuntimeException)
208 : {
209 : SAL_INFO( "desktop.splash", "::SplashScreen::setValue (lo119109)" );
210 : SAL_INFO( "desktop.splash", "value=" << nValue );
211 :
212 0 : SolarMutexGuard aSolarGuard;
213 0 : if (_bVisible && !_bProgressEnd) {
214 0 : if ( _eBitmapMode == BM_FULLSCREEN )
215 0 : ShowFullScreenMode( sal_True );
216 0 : Show();
217 0 : if (nValue >= _iMax) _iProgress = _iMax;
218 0 : else _iProgress = nValue;
219 0 : updateStatus();
220 0 : }
221 0 : }
222 :
223 : // XInitialize
224 : void SAL_CALL
225 0 : SplashScreen::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& aArguments )
226 : throw (RuntimeException)
227 : {
228 0 : ::osl::ClearableMutexGuard aGuard( _aMutex );
229 0 : if (aArguments.getLength() > 0)
230 : {
231 0 : aArguments[0] >>= _bVisible;
232 0 : if (aArguments.getLength() > 1 )
233 0 : aArguments[1] >>= _sAppName;
234 :
235 : // start to determine bitmap and all other required value
236 0 : if ( _bShowLogo )
237 0 : SetScreenBitmap (_aIntroBmp);
238 0 : Size aSize = _aIntroBmp.GetSizePixel();
239 0 : SetOutputSizePixel( aSize );
240 0 : _vdev.SetOutputSizePixel( aSize );
241 0 : _height = aSize.Height();
242 0 : _width = aSize.Width();
243 0 : if (_width > 500)
244 : {
245 0 : Point xtopleft(212,216);
246 0 : if ( NOT_LOADED == _tlx || NOT_LOADED == _tly )
247 : {
248 0 : _tlx = xtopleft.X(); // top-left x
249 0 : _tly = xtopleft.Y(); // top-left y
250 : }
251 0 : if ( NOT_LOADED == _barwidth )
252 0 : _barwidth = 263;
253 0 : if ( NOT_LOADED == _barheight )
254 0 : _barheight = 8;
255 0 : if (( _eBitmapMode == BM_FULLSCREEN ) &&
256 : _bFullScreenSplash )
257 : {
258 0 : if( ( _fXPos >= 0.0 ) && ( _fYPos >= 0.0 ))
259 : {
260 0 : _tlx = sal_Int32( double( aSize.Width() ) * _fXPos );
261 0 : _tly = sal_Int32( double( aSize.Height() ) * _fYPos );
262 : }
263 0 : if ( _fWidth >= 0.0 )
264 0 : _barwidth = sal_Int32( double( aSize.Width() ) * _fWidth );
265 0 : if ( _fHeight >= 0.0 )
266 0 : _barheight = sal_Int32( double( aSize.Width() ) * _fHeight );
267 : }
268 : }
269 : else
270 : {
271 0 : if ( NOT_LOADED == _barwidth )
272 0 : _barwidth = _width - (2 * _xoffset);
273 0 : if ( NOT_LOADED == _barheight )
274 0 : _barheight = 6;
275 0 : if ( NOT_LOADED == _tlx || NOT_LOADED == _tly )
276 : {
277 0 : _tlx = _xoffset; // top-left x
278 0 : _tly = _height - _yoffset; // top-left y
279 : }
280 : }
281 :
282 0 : if ( NOT_LOADED == _textBaseline )
283 0 : _textBaseline = _height;
284 :
285 0 : if ( sal::static_int_cast< ColorData >(NOT_LOADED) ==
286 0 : _cProgressFrameColor.GetColor() )
287 0 : _cProgressFrameColor = Color( COL_LIGHTGRAY );
288 :
289 0 : if ( sal::static_int_cast< ColorData >(NOT_LOADED) ==
290 0 : _cProgressBarColor.GetColor() )
291 : {
292 : // progress bar: new color only for big bitmap format
293 0 : if ( _width > 500 )
294 0 : _cProgressBarColor = Color( 157, 202, 18 );
295 : else
296 0 : _cProgressBarColor = Color( COL_BLUE );
297 : }
298 :
299 0 : if ( sal::static_int_cast< ColorData >(NOT_LOADED) ==
300 0 : _cProgressTextColor.GetColor() )
301 0 : _cProgressTextColor = Color( COL_BLACK );
302 :
303 : Application::AddEventListener(
304 0 : LINK( this, SplashScreen, AppEventListenerHdl ) );
305 0 : }
306 0 : }
307 :
308 0 : void SplashScreen::updateStatus()
309 : {
310 0 : if (!_bVisible || _bProgressEnd) return;
311 0 : if (!_bPaintProgress) _bPaintProgress = sal_True;
312 0 : Paint(Rectangle());
313 0 : Flush();
314 : }
315 :
316 : // internal private methods
317 0 : IMPL_LINK( SplashScreen, AppEventListenerHdl, VclWindowEvent *, inEvent )
318 : {
319 0 : if ( inEvent != 0 )
320 : {
321 0 : switch ( inEvent->GetId() )
322 : {
323 : case VCLEVENT_WINDOW_SHOW:
324 0 : Paint( Rectangle() );
325 0 : break;
326 : default:
327 0 : break;
328 : }
329 : }
330 0 : return 0;
331 : }
332 :
333 : // Read keys from soffice{.ini|rc}:
334 0 : OUString implReadBootstrapKey( const OUString& _rKey )
335 : {
336 0 : OUString sValue;
337 0 : rtl::Bootstrap::get(_rKey, sValue);
338 0 : return sValue;
339 : }
340 :
341 0 : void SplashScreen::loadConfig()
342 : {
343 0 : _bShowLogo = implReadBootstrapKey( "Logo" ) != "0";
344 :
345 0 : OUString sProgressFrameColor = implReadBootstrapKey( "ProgressFrameColor" );
346 0 : OUString sProgressBarColor = implReadBootstrapKey( "ProgressBarColor" );
347 0 : OUString sProgressTextColor = implReadBootstrapKey( "ProgressTextColor" );
348 0 : OUString sProgressTextBaseline = implReadBootstrapKey( "ProgressTextBaseline" );
349 0 : OUString sSize = implReadBootstrapKey( "ProgressSize" );
350 0 : OUString sPosition = implReadBootstrapKey( "ProgressPosition" );
351 0 : OUString sFullScreenSplash = implReadBootstrapKey( "FullScreenSplash" );
352 0 : OUString sNativeProgress = implReadBootstrapKey( "NativeProgress" );
353 :
354 :
355 : // Determine full screen splash mode
356 0 : _bFullScreenSplash = (( !sFullScreenSplash.isEmpty() ) &&
357 0 : ( !sFullScreenSplash.equals( "0" )));
358 :
359 : // Try to retrieve the relative values for the progress bar. The current
360 : // schema uses the screen ratio to retrieve the associated values.
361 0 : if ( _bFullScreenSplash )
362 0 : determineProgressRatioValues( _fXPos, _fYPos, _fWidth, _fHeight );
363 :
364 0 : if ( !sProgressFrameColor.isEmpty() )
365 : {
366 0 : sal_uInt8 nRed = 0;
367 0 : sal_Int32 idx = 0;
368 0 : sal_Int32 temp = sProgressFrameColor.getToken( 0, ',', idx ).toInt32();
369 0 : if ( idx != -1 )
370 : {
371 0 : nRed = static_cast< sal_uInt8 >( temp );
372 0 : temp = sProgressFrameColor.getToken( 0, ',', idx ).toInt32();
373 : }
374 0 : if ( idx != -1 )
375 : {
376 0 : sal_uInt8 nGreen = static_cast< sal_uInt8 >( temp );
377 0 : sal_uInt8 nBlue = static_cast< sal_uInt8 >( sProgressFrameColor.getToken( 0, ',', idx ).toInt32() );
378 0 : _cProgressFrameColor = Color( nRed, nGreen, nBlue );
379 : }
380 : }
381 :
382 0 : if ( !sProgressBarColor.isEmpty() )
383 : {
384 0 : sal_uInt8 nRed = 0;
385 0 : sal_Int32 idx = 0;
386 0 : sal_Int32 temp = sProgressBarColor.getToken( 0, ',', idx ).toInt32();
387 0 : if ( idx != -1 )
388 : {
389 0 : nRed = static_cast< sal_uInt8 >( temp );
390 0 : temp = sProgressBarColor.getToken( 0, ',', idx ).toInt32();
391 : }
392 0 : if ( idx != -1 )
393 : {
394 0 : sal_uInt8 nGreen = static_cast< sal_uInt8 >( temp );
395 0 : sal_uInt8 nBlue = static_cast< sal_uInt8 >( sProgressBarColor.getToken( 0, ',', idx ).toInt32() );
396 0 : _cProgressBarColor = Color( nRed, nGreen, nBlue );
397 : }
398 : }
399 :
400 0 : if ( !sProgressTextColor.isEmpty() )
401 : {
402 0 : sal_uInt8 nRed = 0;
403 0 : sal_Int32 idx = 0;
404 0 : sal_Int32 temp = sProgressTextColor.getToken( 0, ',', idx ).toInt32();
405 0 : if ( idx != -1 )
406 : {
407 0 : nRed = static_cast< sal_uInt8 >( temp );
408 0 : temp = sProgressTextColor.getToken( 0, ',', idx ).toInt32();
409 : }
410 0 : if ( idx != -1 )
411 : {
412 0 : sal_uInt8 nGreen = static_cast< sal_uInt8 >( temp );
413 0 : sal_uInt8 nBlue = static_cast< sal_uInt8 >( sProgressTextColor.getToken( 0, ',', idx ).toInt32() );
414 0 : _cProgressTextColor = Color( nRed, nGreen, nBlue );
415 : }
416 : }
417 :
418 0 : if ( !sProgressTextBaseline.isEmpty() )
419 : {
420 0 : _textBaseline = sProgressTextBaseline.toInt32();
421 : }
422 :
423 0 : if( !sNativeProgress.isEmpty() )
424 : {
425 0 : _bNativeProgress = sNativeProgress.toBoolean();
426 : }
427 :
428 0 : if ( !sSize.isEmpty() )
429 : {
430 0 : sal_Int32 idx = 0;
431 0 : sal_Int32 temp = sSize.getToken( 0, ',', idx ).toInt32();
432 0 : if ( idx != -1 )
433 : {
434 0 : _barwidth = temp;
435 0 : _barheight = sSize.getToken( 0, ',', idx ).toInt32();
436 : }
437 : }
438 :
439 0 : if ( _barheight >= 10 )
440 0 : _barspace = 3; // more space between frame and bar
441 :
442 0 : if ( !sPosition.isEmpty() )
443 : {
444 0 : sal_Int32 idx = 0;
445 0 : sal_Int32 temp = sPosition.getToken( 0, ',', idx ).toInt32();
446 0 : if ( idx != -1 )
447 : {
448 0 : _tlx = temp;
449 0 : _tly = sPosition.getToken( 0, ',', idx ).toInt32();
450 : }
451 0 : }
452 0 : }
453 :
454 0 : void SplashScreen::SetScreenBitmap(BitmapEx &rBitmap)
455 : {
456 0 : sal_Int32 nWidth( 0 );
457 0 : sal_Int32 nHeight( 0 );
458 :
459 : // determine desktop resolution
460 0 : sal_uInt32 nCount = Application::GetScreenCount();
461 0 : if ( nCount > 0 )
462 : {
463 : // retrieve size from first screen
464 0 : Rectangle aScreenArea = Application::GetScreenPosSizePixel((unsigned int)0);
465 0 : nWidth = aScreenArea.GetWidth();
466 0 : nHeight = aScreenArea.GetHeight();
467 : }
468 :
469 : // create file name from screen resolution information
470 0 : OStringBuffer aStrBuf( 128 );
471 0 : OStringBuffer aResBuf( 32 );
472 0 : aStrBuf.append( "intro_" );
473 0 : if ( !_sAppName.isEmpty() )
474 : {
475 0 : aStrBuf.append( OUStringToOString(_sAppName, RTL_TEXTENCODING_UTF8) );
476 0 : aStrBuf.append( "_" );
477 : }
478 0 : aResBuf.append( OString::valueOf( nWidth ));
479 0 : aResBuf.append( "x" );
480 0 : aResBuf.append( OString::valueOf( nHeight ));
481 :
482 0 : aStrBuf.append( aResBuf.getStr() );
483 0 : if (Application::LoadBrandBitmap (aStrBuf.makeStringAndClear().getStr(), rBitmap))
484 0 : return;
485 :
486 0 : aStrBuf.append( "intro_" );
487 0 : aStrBuf.append( aResBuf.getStr() );
488 0 : if (Application::LoadBrandBitmap (aResBuf.makeStringAndClear().getStr(), rBitmap))
489 0 : return;
490 :
491 0 : Application::LoadBrandBitmap ("intro", rBitmap);
492 : }
493 :
494 0 : void SplashScreen::determineProgressRatioValues(
495 : double& rXRelPos, double& rYRelPos,
496 : double& rRelWidth, double& rRelHeight )
497 : {
498 0 : sal_Int32 nWidth( 0 );
499 0 : sal_Int32 nHeight( 0 );
500 0 : sal_Int32 nScreenRatio( 0 );
501 :
502 : // determine desktop resolution
503 0 : sal_uInt32 nCount = Application::GetScreenCount();
504 0 : if ( nCount > 0 )
505 : {
506 : // retrieve size from first screen
507 0 : Rectangle aScreenArea = Application::GetScreenPosSizePixel((unsigned int)0);
508 0 : nWidth = aScreenArea.GetWidth();
509 0 : nHeight = aScreenArea.GetHeight();
510 0 : nScreenRatio = sal_Int32( math::round( double( nWidth ) / double( nHeight ), 2 ) * 100 );
511 : }
512 :
513 0 : char szFullScreenProgressRatio[] = "FullScreenProgressRatio0";
514 0 : char szFullScreenProgressPos[] = "FullScreenProgressPos0";
515 0 : char szFullScreenProgressSize[] = "FullScreenProgressSize0";
516 0 : for ( sal_Int32 i = 0; i <= 9; i++ )
517 : {
518 0 : char cNum = '0' + char( i );
519 0 : szFullScreenProgressRatio[23] = cNum;
520 0 : szFullScreenProgressPos[21] = cNum;
521 0 : szFullScreenProgressSize[22] = cNum;
522 :
523 : OUString sFullScreenProgressRatio = implReadBootstrapKey(
524 0 : OUString::createFromAscii( szFullScreenProgressRatio ) );
525 :
526 0 : if ( !sFullScreenProgressRatio.isEmpty() )
527 : {
528 0 : double fRatio = sFullScreenProgressRatio.toDouble();
529 0 : sal_Int32 nRatio = sal_Int32( math::round( fRatio, 2 ) * 100 );
530 0 : if ( nRatio == nScreenRatio )
531 : {
532 : OUString sFullScreenProgressPos = implReadBootstrapKey(
533 0 : OUString::createFromAscii( szFullScreenProgressPos ) );
534 : OUString sFullScreenProgressSize = implReadBootstrapKey(
535 0 : OUString::createFromAscii( szFullScreenProgressSize ) );
536 :
537 0 : if ( !sFullScreenProgressPos.isEmpty() )
538 : {
539 0 : sal_Int32 idx = 0;
540 0 : double temp = sFullScreenProgressPos.getToken( 0, ',', idx ).toDouble();
541 0 : if ( idx != -1 )
542 : {
543 0 : rXRelPos = temp;
544 0 : rYRelPos = sFullScreenProgressPos.getToken( 0, ',', idx ).toDouble();
545 : }
546 : }
547 :
548 0 : if ( !sFullScreenProgressSize.isEmpty() )
549 : {
550 0 : sal_Int32 idx = 0;
551 0 : double temp = sFullScreenProgressSize.getToken( 0, ',', idx ).toDouble();
552 0 : if ( idx != -1 )
553 : {
554 0 : rRelWidth = temp;
555 0 : rRelHeight = sFullScreenProgressSize.getToken( 0, ',', idx ).toDouble();
556 : }
557 0 : }
558 : }
559 : }
560 : else
561 0 : break;
562 0 : }
563 0 : }
564 :
565 0 : void SplashScreen::Paint( const Rectangle&)
566 : {
567 0 : if(!_bVisible) return;
568 :
569 : //native drawing
570 0 : sal_Bool bNativeOK = sal_False;
571 :
572 : // in case of native controls we need to draw directly to the window
573 0 : if( _bNativeProgress && IsNativeControlSupported( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL ) )
574 : {
575 0 : DrawBitmapEx( Point(), _aIntroBmp );
576 :
577 0 : ImplControlValue aValue( _iProgress * _barwidth / _iMax);
578 0 : Rectangle aDrawRect( Point(_tlx, _tly), Size( _barwidth, _barheight ) );
579 0 : Rectangle aNativeControlRegion, aNativeContentRegion;
580 :
581 0 : if( GetNativeControlRegion( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect,
582 : CTRL_STATE_ENABLED, aValue, OUString(),
583 0 : aNativeControlRegion, aNativeContentRegion ) )
584 : {
585 0 : long nProgressHeight = aNativeControlRegion.GetHeight();
586 0 : aDrawRect.Top() -= (nProgressHeight - _barheight)/2;
587 0 : aDrawRect.Bottom() += (nProgressHeight - _barheight)/2;
588 : }
589 :
590 0 : if( (bNativeOK = DrawNativeControl( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect,
591 0 : CTRL_STATE_ENABLED, aValue, _sProgressText )) != sal_False )
592 : {
593 0 : return;
594 0 : }
595 : }
596 : //non native drawing
597 : // draw bitmap
598 0 : if (_bPaintBitmap)
599 0 : _vdev.DrawBitmapEx( Point(), _aIntroBmp );
600 :
601 0 : if (_bPaintProgress) {
602 : // draw progress...
603 0 : long length = (_iProgress * _barwidth / _iMax) - (2 * _barspace);
604 0 : if (length < 0) length = 0;
605 :
606 : // border
607 0 : _vdev.SetFillColor();
608 0 : _vdev.SetLineColor( _cProgressFrameColor );
609 0 : _vdev.DrawRect(Rectangle(_tlx, _tly, _tlx+_barwidth, _tly+_barheight));
610 0 : _vdev.SetFillColor( _cProgressBarColor );
611 0 : _vdev.SetLineColor();
612 0 : _vdev.DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace));
613 0 : Font aFont;
614 0 : aFont.SetSize(Size(0, 12));
615 0 : aFont.SetAlign(ALIGN_BASELINE);
616 0 : _vdev.SetFont(aFont);
617 0 : _vdev.SetTextColor(_cProgressTextColor);
618 0 : _vdev.DrawText(Point(_tlx, _textBaseline), _sProgressText);
619 : }
620 0 : DrawOutDev(Point(), GetOutputSizePixel(), Point(), _vdev.GetOutputSizePixel(), _vdev );
621 : }
622 :
623 :
624 : // get service instance...
625 0 : osl::Mutex SplashScreen::_aMutex;
626 :
627 : }
628 :
629 0 : css::uno::Reference< css::uno::XInterface > desktop::splash::create(
630 : css::uno::Reference< css::uno::XComponentContext > const &)
631 : {
632 0 : return static_cast< cppu::OWeakObject * >(new SplashScreen);
633 : }
634 :
635 0 : OUString desktop::splash::getImplementationName() {
636 0 : return OUString("com.sun.star.office.comp.SplashScreen");
637 : }
638 :
639 0 : css::uno::Sequence< OUString > desktop::splash::getSupportedServiceNames() {
640 0 : OUString name("com.sun.star.office.SplashScreen");
641 0 : return css::uno::Sequence< OUString >(&name, 1);
642 0 : }
643 :
644 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|