xref: /aoo42x/main/desktop/source/splash/splash.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_desktop.hxx"
30 
31 #include <introbmpnames.hxx>
32 #include "splash.hxx"
33 #include <stdio.h>
34 #include <unotools/bootstrap.hxx>
35 #include <vos/process.hxx>
36 #include <tools/urlobj.hxx>
37 #include <tools/stream.hxx>
38 #include <sfx2/sfx.hrc>
39 #include <vcl/svapp.hxx>
40 #include <vcl/salnativewidgets.hxx>
41 
42 #include <com/sun/star/registry/XRegistryKey.hpp>
43 #include <rtl/bootstrap.hxx>
44 #include <rtl/logfile.hxx>
45 #include <rtl/ustrbuf.hxx>
46 #include <rtl/math.hxx>
47 #include <vcl/graph.hxx>
48 #include <svtools/filter.hxx>
49 
50 #define NOT_LOADED  ((long)-1)
51 
52 using namespace ::rtl;
53 using namespace ::com::sun::star::registry;
54 
55 namespace desktop
56 {
57 
58 SplashScreen::SplashScreen(const Reference< XMultiServiceFactory >& rSMgr)
59     : IntroWindow()
60     , _vdev(*((IntroWindow*)this))
61     , _cProgressFrameColor(sal::static_int_cast< ColorData >(NOT_LOADED))
62     , _cProgressBarColor(sal::static_int_cast< ColorData >(NOT_LOADED))
63     , _bNativeProgress(true)
64 	, _iMax(100)
65 	, _iProgress(0)
66     , _eBitmapMode(BM_DEFAULTMODE)
67 	, _bPaintBitmap(sal_True)
68 	, _bPaintProgress(sal_False)
69     , _bShowLogo(sal_True)
70     , _bFullScreenSplash(sal_False)
71     , _bProgressEnd(sal_False)
72     , _tlx(NOT_LOADED)
73     , _tly(NOT_LOADED)
74     , _barwidth(NOT_LOADED)
75     , _barheight(NOT_LOADED)
76     , _barspace(2)
77     , _fXPos(-1.0)
78     , _fYPos(-1.0)
79     , _fWidth(-1.0)
80     , _fHeight(-1.0)
81     , _xoffset(12)
82 	, _yoffset(18)
83 {
84 	_rFactory = rSMgr;
85 
86     loadConfig();
87 }
88 
89 SplashScreen::~SplashScreen()
90 {
91 	Application::RemoveEventListener(
92 		LINK( this, SplashScreen, AppEventListenerHdl ) );
93 	Hide();
94 
95 }
96 
97 void SAL_CALL SplashScreen::start(const OUString&, sal_Int32 nRange)
98 	throw (RuntimeException)
99 {
100     _iMax = nRange;
101     if (_bVisible) {
102         _bProgressEnd = sal_False;
103         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
104         if ( _eBitmapMode == BM_FULLSCREEN )
105             ShowFullScreenMode( sal_True );
106         Show();
107         Paint(Rectangle());
108         Flush();
109     }
110 }
111 
112 void SAL_CALL SplashScreen::end()
113 	throw (RuntimeException)
114 {
115     _iProgress = _iMax;
116     if (_bVisible )
117     {
118         if ( _eBitmapMode == BM_FULLSCREEN )
119             EndFullScreenMode();
120         Hide();
121     }
122     _bProgressEnd = sal_True;
123 }
124 
125 void SAL_CALL SplashScreen::reset()
126 	throw (RuntimeException)
127 {
128     _iProgress = 0;
129     if (_bVisible && !_bProgressEnd )
130     {
131         if ( _eBitmapMode == BM_FULLSCREEN )
132             ShowFullScreenMode( sal_True );
133         Show();
134         updateStatus();
135     }
136 }
137 
138 void SAL_CALL SplashScreen::setText(const OUString& rText)
139 	throw (RuntimeException)
140 {
141     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
142     if ( _sProgressText != rText )
143     {
144         _sProgressText = rText;
145 
146         if (_bVisible && !_bProgressEnd)
147         {
148             if ( _eBitmapMode == BM_FULLSCREEN )
149                 ShowFullScreenMode( sal_True );
150             Show();
151             updateStatus();
152         }
153     }
154 }
155 
156 void SAL_CALL SplashScreen::setValue(sal_Int32 nValue)
157 	throw (RuntimeException)
158 {
159     RTL_LOGFILE_CONTEXT( aLog, "::SplashScreen::setValue (lo119109)" );
160     RTL_LOGFILE_CONTEXT_TRACE1( aLog, "value=%d", nValue );
161 
162     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
163     if (_bVisible && !_bProgressEnd) {
164         if ( _eBitmapMode == BM_FULLSCREEN )
165             ShowFullScreenMode( sal_True );
166         Show();
167         if (nValue >= _iMax) _iProgress = _iMax;
168 	else _iProgress = nValue;
169 	updateStatus();
170     }
171 }
172 
173 // XInitialize
174 void SAL_CALL
175 SplashScreen::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& aArguments )
176 	throw (RuntimeException)
177 {
178 	::osl::ClearableMutexGuard	aGuard(	_aMutex );
179 	if (aArguments.getLength() > 0)
180     {
181         aArguments[0] >>= _bVisible;
182         if (aArguments.getLength() > 1 )
183             aArguments[1] >>= _sAppName;
184 
185         // start to determine bitmap and all other required value
186         initBitmap();
187 	    Size aSize = _aIntroBmp.GetSizePixel();
188 	    SetOutputSizePixel( aSize );
189         _vdev.SetOutputSizePixel( aSize );
190 	    _height = aSize.Height();
191 	    _width = aSize.Width();
192         if (_width > 500)
193         {
194             Point xtopleft(212,216);
195             if ( NOT_LOADED == _tlx || NOT_LOADED == _tly )
196             {
197                 _tlx = xtopleft.X();    // top-left x
198                 _tly = xtopleft.Y();    // top-left y
199             }
200             if ( NOT_LOADED == _barwidth )
201                 _barwidth = 263;
202             if ( NOT_LOADED == _barheight )
203                 _barheight = 8;
204             if (( _eBitmapMode == BM_FULLSCREEN ) &&
205                 _bFullScreenSplash )
206             {
207                 if( ( _fXPos >= 0.0 ) && ( _fYPos >= 0.0 ))
208                 {
209                     _tlx = sal_Int32( double( aSize.Width() ) * _fXPos );
210                     _tly = sal_Int32( double( aSize.Height() ) * _fYPos );
211                 }
212                 if ( _fWidth >= 0.0 )
213                     _barwidth  = sal_Int32( double( aSize.Width() ) * _fWidth );
214                 if ( _fHeight >= 0.0 )
215                     _barheight = sal_Int32( double( aSize.Width() ) * _fHeight );
216             }
217         }
218         else
219         {
220             if ( NOT_LOADED == _barwidth )
221                 _barwidth  = _width - (2 * _xoffset);
222             if ( NOT_LOADED == _barheight )
223                 _barheight = 6;
224             if ( NOT_LOADED == _tlx || NOT_LOADED == _tly )
225             {
226                 _tlx = _xoffset;           // top-left x
227                 _tly = _height - _yoffset; // top-left y
228             }
229         }
230 
231         if ( sal::static_int_cast< ColorData >(NOT_LOADED) ==
232              _cProgressFrameColor.GetColor() )
233             _cProgressFrameColor = Color( COL_LIGHTGRAY );
234 
235         if ( sal::static_int_cast< ColorData >(NOT_LOADED) ==
236              _cProgressBarColor.GetColor() )
237         {
238             // progress bar: new color only for big bitmap format
239             if ( _width > 500 )
240                 _cProgressBarColor = Color( 157, 202, 18 );
241             else
242                 _cProgressBarColor = Color( COL_BLUE );
243         }
244 
245         Application::AddEventListener(
246 		    LINK( this, SplashScreen, AppEventListenerHdl ) );
247 
248         SetBackgroundBitmap( _aIntroBmp );
249     }
250 }
251 
252 void SplashScreen::updateStatus()
253 {
254 	if (!_bVisible || _bProgressEnd) return;
255 	if (!_bPaintProgress) _bPaintProgress = sal_True;
256 	//_bPaintBitmap=sal_False;
257 	Paint(Rectangle());
258 	//_bPaintBitmap=sal_True;
259     Flush();
260 }
261 
262 // internal private methods
263 IMPL_LINK( SplashScreen, AppEventListenerHdl, VclWindowEvent *, inEvent )
264 {
265 	if ( inEvent != 0 )
266 	{
267         // Paint( Rectangle() );
268 		switch ( inEvent->GetId() )
269 		{
270 			case VCLEVENT_WINDOW_SHOW:
271 				Paint( Rectangle() );
272 				break;
273 			default:
274 				break;
275 		}
276 	}
277 	return 0;
278 }
279 
280 // Read keys from edition/edition.ini or soffice{.ini|rc}:
281 OUString implReadBootstrapKey( const OUString& _rKey )
282 {
283     OUString sValue(
284         rtl::OUString(
285             RTL_CONSTASCII_USTRINGPARAM(
286                 "${.override:${BRAND_BASE_DIR}/program/edition/edition.ini:")) +
287         _rKey + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("}")));
288     rtl::Bootstrap::expandMacros(sValue);
289     return sValue;
290 }
291 
292 void SplashScreen::loadConfig()
293 {
294     _bShowLogo = !implReadBootstrapKey(
295         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Logo"))).
296         equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("0"));
297 
298     OUString sProgressFrameColor = implReadBootstrapKey(
299         OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressFrameColor" ) ) );
300     OUString sProgressBarColor = implReadBootstrapKey(
301         OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressBarColor" ) ) );
302     OUString sSize = implReadBootstrapKey(
303         OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressSize" ) ) );
304     OUString sPosition = implReadBootstrapKey(
305         OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressPosition" ) ) );
306     OUString sFullScreenSplash = implReadBootstrapKey(
307         OUString( RTL_CONSTASCII_USTRINGPARAM( "FullScreenSplash" ) ) );
308     OUString sNativeProgress = implReadBootstrapKey(
309         OUString( RTL_CONSTASCII_USTRINGPARAM( "NativeProgress" ) ) );
310 
311 
312     // Determine full screen splash mode
313     _bFullScreenSplash = (( sFullScreenSplash.getLength() > 0 ) &&
314                           ( !sFullScreenSplash.equalsAsciiL( "0", 1 )));
315 
316     // Try to retrieve the relative values for the progress bar. The current
317     // schema uses the screen ratio to retrieve the associated values.
318     if ( _bFullScreenSplash )
319         determineProgressRatioValues( _fXPos, _fYPos, _fWidth, _fHeight );
320 
321     if ( sProgressFrameColor.getLength() )
322     {
323         sal_uInt8 nRed = 0;
324         sal_uInt8 nGreen = 0;
325         sal_uInt8 nBlue = 0;
326         sal_Int32 idx = 0;
327         sal_Int32 temp = sProgressFrameColor.getToken( 0, ',', idx ).toInt32();
328         if ( idx != -1 )
329         {
330             nRed = static_cast< sal_uInt8 >( temp );
331             temp = sProgressFrameColor.getToken( 0, ',', idx ).toInt32();
332         }
333         if ( idx != -1 )
334         {
335             nGreen = static_cast< sal_uInt8 >( temp );
336             nBlue = static_cast< sal_uInt8 >( sProgressFrameColor.getToken( 0, ',', idx ).toInt32() );
337             _cProgressFrameColor = Color( nRed, nGreen, nBlue );
338         }
339     }
340 
341     if ( sProgressBarColor.getLength() )
342     {
343         sal_uInt8 nRed = 0;
344         sal_uInt8 nGreen = 0;
345         sal_uInt8 nBlue = 0;
346         sal_Int32 idx = 0;
347         sal_Int32 temp = sProgressBarColor.getToken( 0, ',', idx ).toInt32();
348         if ( idx != -1 )
349         {
350             nRed = static_cast< sal_uInt8 >( temp );
351             temp = sProgressBarColor.getToken( 0, ',', idx ).toInt32();
352         }
353         if ( idx != -1 )
354         {
355             nGreen = static_cast< sal_uInt8 >( temp );
356             nBlue = static_cast< sal_uInt8 >( sProgressBarColor.getToken( 0, ',', idx ).toInt32() );
357             _cProgressBarColor = Color( nRed, nGreen, nBlue );
358         }
359     }
360 
361     if( sNativeProgress.getLength() )
362     {
363         _bNativeProgress = sNativeProgress.toBoolean();
364     }
365 
366     if ( sSize.getLength() )
367     {
368         sal_Int32 idx = 0;
369         sal_Int32 temp = sSize.getToken( 0, ',', idx ).toInt32();
370         if ( idx != -1 )
371         {
372             _barwidth = temp;
373             _barheight = sSize.getToken( 0, ',', idx ).toInt32();
374         }
375     }
376 
377     if ( _barheight >= 10 )
378         _barspace = 3;  // more space between frame and bar
379 
380     if ( sPosition.getLength() )
381     {
382         sal_Int32 idx = 0;
383         sal_Int32 temp = sPosition.getToken( 0, ',', idx ).toInt32();
384         if ( idx != -1 )
385         {
386             _tlx = temp;
387             _tly = sPosition.getToken( 0, ',', idx ).toInt32();
388         }
389     }
390 }
391 
392 void SplashScreen::initBitmap()
393 {
394     if ( _bShowLogo )
395     {
396         OUString sExecutePath;
397         ::rtl::Bootstrap::get(
398             OUString( RTL_CONSTASCII_USTRINGPARAM( "BRAND_BASE_DIR" ) ),
399             sExecutePath );
400         sExecutePath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/program/" ) );
401 
402         bool haveBitmap = false;
403 
404         // Try all bitmaps in INTRO_BITMAP_NAMES
405         sal_Int32 nIndex = 0;
406         OUString  aIntroBitmapFiles( RTL_CONSTASCII_USTRINGPARAM( INTRO_BITMAP_STRINGLIST ));
407         do
408         {
409             haveBitmap = loadBitmap( sExecutePath, aIntroBitmapFiles.getToken( 0, ',', nIndex ) );
410         }
411         while ( !haveBitmap && ( nIndex >= 0 ) );
412 
413         if (!haveBitmap) {
414             rtl::OUString edition(
415                 rtl::OUString(
416                     RTL_CONSTASCII_USTRINGPARAM(
417                         "${BRAND_BASE_DIR}/program/edition")));
418             rtl::Bootstrap::expandMacros(edition);
419             haveBitmap = findBitmap(edition);
420         }
421         if (!haveBitmap) {
422             findBitmap(sExecutePath);
423         }
424     }
425 }
426 
427 bool SplashScreen::loadBitmap(
428     rtl::OUString const & path, const rtl::OUString &rBmpFileName )
429 {
430     if ( rBmpFileName.getLength() == 0 )
431         return false;
432 
433     INetURLObject aObj( path, INET_PROT_FILE );
434     aObj.insertName( rBmpFileName );
435 
436     SvFileStream aStrm( aObj.PathToFileName(), STREAM_STD_READ );
437     if ( !aStrm.GetError() )
438     {
439         // Use graphic class to also support more graphic formats (bmp,png,...)
440         Graphic aGraphic;
441 
442         GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
443         pGF->ImportGraphic( aGraphic, String(), aStrm, GRFILTER_FORMAT_DONTKNOW );
444 
445         // Default case, we load the intro bitmap from a seperate file
446         // (e.g. staroffice_intro.bmp or starsuite_intro.bmp)
447         _aIntroBmp = aGraphic.GetBitmapEx();
448         return true;
449     }
450 
451     return false;
452 }
453 
454 bool SplashScreen::findBitmap(rtl::OUString const & path) {
455     bool haveBitmap = false;
456     if ( _bFullScreenSplash )
457     {
458         haveBitmap = findScreenBitmap(path);
459         if ( haveBitmap )
460             _eBitmapMode = BM_FULLSCREEN;
461         else
462             haveBitmap = findAppBitmap(path);
463     }
464     if ( !haveBitmap )
465     {
466         haveBitmap = loadBitmap(
467             path, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("intro.png")));
468         if ( !haveBitmap )
469             haveBitmap = loadBitmap(
470                 path, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("intro.bmp")));
471     }
472 
473     return haveBitmap;
474 }
475 
476 bool SplashScreen::findScreenBitmap(rtl::OUString const & path)
477 {
478     sal_Int32 nWidth( 0 );
479     sal_Int32 nHeight( 0 );
480 
481     // determine desktop resolution
482     sal_uInt32 nCount = Application::GetScreenCount();
483     if ( nCount > 0 )
484     {
485         // retrieve size from first screen
486         Rectangle aScreenArea = Application::GetScreenPosSizePixel((unsigned int)0);
487         nWidth  = aScreenArea.GetWidth();
488         nHeight = aScreenArea.GetHeight();
489     }
490 
491     // create file name from screen resolution information
492     OUStringBuffer aStrBuf( 128 );
493     aStrBuf.appendAscii( "intro_" );
494     if ( _sAppName.getLength() > 0 )
495     {
496         aStrBuf.append( _sAppName );
497         aStrBuf.appendAscii( "_" );
498     }
499     aStrBuf.append( OUString::valueOf( nWidth ));
500     aStrBuf.appendAscii( "x" );
501     aStrBuf.append( OUString::valueOf( nHeight ));
502 
503     OUString aRootIntroFileName = aStrBuf.makeStringAndClear();
504     OUString aBmpFileName       = aRootIntroFileName + OUString::createFromAscii(".png");
505 
506     bool haveBitmap = loadBitmap( path, aBmpFileName );
507     if ( !haveBitmap )
508     {
509         aBmpFileName = aRootIntroFileName + OUString::createFromAscii(".bmp");
510         haveBitmap   = loadBitmap( path, aBmpFileName );
511     }
512 
513     if ( !haveBitmap )
514     {
515         aStrBuf.appendAscii( "intro_" );
516         aStrBuf.appendAscii( "_" );
517         aStrBuf.append( OUString::valueOf( nWidth ));
518         aStrBuf.appendAscii( "x" );
519         aStrBuf.append( OUString::valueOf( nHeight ));
520 
521         aRootIntroFileName = aStrBuf.makeStringAndClear();
522         aBmpFileName = aRootIntroFileName + OUString::createFromAscii(".png");
523 
524         haveBitmap = loadBitmap( path, aBmpFileName );
525         if ( !haveBitmap )
526         {
527             aBmpFileName = aRootIntroFileName + OUString::createFromAscii(".bmp");
528             haveBitmap   = loadBitmap( path, aBmpFileName );
529         }
530     }
531     return haveBitmap;
532 }
533 
534 bool SplashScreen::findAppBitmap(rtl::OUString const & path)
535 {
536     bool haveBitmap = false;
537 
538     if ( _sAppName.getLength() > 0 )
539     {
540         OUStringBuffer aStrBuf( 128 );
541         aStrBuf.appendAscii( "intro_" );
542         aStrBuf.appendAscii( "_" );
543         aStrBuf.append( _sAppName );
544 
545         OUString aRootIntroFileName = aStrBuf.makeStringAndClear();
546 
547         OUString aBmpFileName = aRootIntroFileName + OUString::createFromAscii( ".png" );
548         haveBitmap = loadBitmap( path, aBmpFileName );
549         if ( !haveBitmap )
550         {
551             aBmpFileName = aRootIntroFileName + OUString::createFromAscii( ".bmp" );
552             haveBitmap = loadBitmap( path, aBmpFileName );
553         }
554     }
555     return haveBitmap;
556 }
557 
558 void SplashScreen::determineProgressRatioValues(
559     double& rXRelPos, double& rYRelPos,
560     double& rRelWidth, double& rRelHeight )
561 {
562     sal_Int32 nWidth( 0 );
563     sal_Int32 nHeight( 0 );
564     sal_Int32 nScreenRatio( 0 );
565 
566     // determine desktop resolution
567     sal_uInt32 nCount = Application::GetScreenCount();
568     if ( nCount > 0 )
569     {
570         // retrieve size from first screen
571         Rectangle aScreenArea = Application::GetScreenPosSizePixel((unsigned int)0);
572         nWidth  = aScreenArea.GetWidth();
573         nHeight = aScreenArea.GetHeight();
574         nScreenRatio  = sal_Int32( math::round( double( nWidth ) / double( nHeight ), 2 ) * 100 );
575     }
576 
577     char szFullScreenProgressRatio[] = "FullScreenProgressRatio0";
578     char szFullScreenProgressPos[]   = "FullScreenProgressPos0";
579     char szFullScreenProgressSize[]  = "FullScreenProgressSize0";
580     for ( sal_Int32 i = 0; i <= 9; i++ )
581     {
582         char cNum = '0' + char( i );
583         szFullScreenProgressRatio[23] = cNum;
584         szFullScreenProgressPos[21]   = cNum;
585         szFullScreenProgressSize[22]  = cNum;
586 
587         OUString sFullScreenProgressRatio = implReadBootstrapKey(
588             OUString::createFromAscii( szFullScreenProgressRatio ) );
589 
590         if ( sFullScreenProgressRatio.getLength() > 0 )
591         {
592             double fRatio = sFullScreenProgressRatio.toDouble();
593             sal_Int32 nRatio = sal_Int32( math::round( fRatio, 2 ) * 100 );
594             if ( nRatio == nScreenRatio )
595             {
596                 OUString sFullScreenProgressPos = implReadBootstrapKey(
597                     OUString::createFromAscii( szFullScreenProgressPos ) );
598                 OUString sFullScreenProgressSize = implReadBootstrapKey(
599                     OUString::createFromAscii( szFullScreenProgressSize ) );
600 
601                 if ( sFullScreenProgressPos.getLength() )
602                 {
603                     sal_Int32 idx = 0;
604                     double temp = sFullScreenProgressPos.getToken( 0, ',', idx ).toDouble();
605                     if ( idx != -1 )
606                     {
607                         rXRelPos = temp;
608                         rYRelPos = sFullScreenProgressPos.getToken( 0, ',', idx ).toDouble();
609                     }
610                 }
611 
612                 if ( sFullScreenProgressSize.getLength() )
613                 {
614                     sal_Int32 idx = 0;
615                     double temp = sFullScreenProgressSize.getToken( 0, ',', idx ).toDouble();
616                     if ( idx != -1 )
617                     {
618                         rRelWidth  = temp;
619                         rRelHeight = sFullScreenProgressSize.getToken( 0, ',', idx ).toDouble();
620                     }
621                 }
622             }
623         }
624         else
625             break;
626     }
627 }
628 
629 void SplashScreen::Paint( const Rectangle&)
630 {
631 	if(!_bVisible) return;
632 
633     //native drawing
634     sal_Bool bNativeOK = sal_False;
635 
636     // in case of native controls we need to draw directly to the window
637     if( _bNativeProgress && IsNativeControlSupported( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL ) )
638     {
639         DrawBitmapEx( Point(), _aIntroBmp );
640 
641         ImplControlValue aValue( _iProgress * _barwidth / _iMax);
642         Rectangle aDrawRect( Point(_tlx, _tly), Size( _barwidth, _barheight ) );
643         Rectangle aNativeControlRegion, aNativeContentRegion;
644 
645         if( GetNativeControlRegion( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect,
646                                              CTRL_STATE_ENABLED, aValue, rtl::OUString(),
647                                              aNativeControlRegion, aNativeContentRegion ) )
648         {
649               long nProgressHeight = aNativeControlRegion.GetHeight();
650               aDrawRect.Top() -= (nProgressHeight - _barheight)/2;
651               aDrawRect.Bottom() += (nProgressHeight - _barheight)/2;
652         }
653 
654         if( (bNativeOK = DrawNativeControl( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect,
655                                             CTRL_STATE_ENABLED, aValue, _sProgressText )) != sal_False )
656         {
657             return;
658         }
659     }
660     //non native drawing
661 	// draw bitmap
662 	if (_bPaintBitmap)
663 		_vdev.DrawBitmapEx( Point(), _aIntroBmp );
664 
665 	if (_bPaintProgress) {
666 		// draw progress...
667 		long length = (_iProgress * _barwidth / _iMax) - (2 * _barspace);
668 		if (length < 0) length = 0;
669 
670 		// border
671 		_vdev.SetFillColor();
672 		_vdev.SetLineColor( _cProgressFrameColor );
673 		_vdev.DrawRect(Rectangle(_tlx, _tly, _tlx+_barwidth, _tly+_barheight));
674 		_vdev.SetFillColor( _cProgressBarColor );
675 		_vdev.SetLineColor();
676 		_vdev.DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace));
677         _vdev.DrawText( Rectangle(_tlx, _tly+_barheight+5, _tlx+_barwidth, _tly+_barheight+5+20), _sProgressText, TEXT_DRAW_CENTER );
678 	}
679     Size aSize =  GetOutputSizePixel();
680     Size bSize =  _vdev.GetOutputSizePixel();
681     //_vdev.Flush();
682     //_vdev.DrawOutDev(Point(), GetOutputSize(), Point(), GetOutputSize(), *((IntroWindow*)this) );
683     DrawOutDev(Point(), GetOutputSizePixel(), Point(), _vdev.GetOutputSizePixel(), _vdev );
684 	//Flush();
685 }
686 
687 
688 // get service instance...
689 SplashScreen *SplashScreen::_pINSTANCE = NULL;
690 osl::Mutex SplashScreen::_aMutex;
691 
692 Reference< XInterface > SplashScreen::getInstance(const Reference< XMultiServiceFactory >& rSMgr)
693 {
694 	if ( _pINSTANCE == 0 )
695 	{
696 		osl::MutexGuard guard(_aMutex);
697 		if (_pINSTANCE == 0)
698 			return (XComponent*)new SplashScreen(rSMgr);
699 	}
700 
701 	return (XComponent*)0;
702 }
703 
704 // static service info...
705 const char* SplashScreen::interfaces[] =
706 {
707     "com.sun.star.task.XStartusIndicator",
708     "com.sun.star.lang.XInitialization",
709     NULL,
710 };
711 const sal_Char *SplashScreen::serviceName = "com.sun.star.office.SplashScreen";
712 const sal_Char *SplashScreen::implementationName = "com.sun.star.office.comp.SplashScreen";
713 const sal_Char *SplashScreen::supportedServiceNames[] = {"com.sun.star.office.SplashScreen", NULL};
714 
715 }
716