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

Generated by: LCOV version 1.10