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