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

Generated by: LCOV version 1.11