LCOV - code coverage report
Current view: top level - desktop/source/splash - splash.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 309 0.0 %
Date: 2014-11-03 Functions: 0 25 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10