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