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