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