1*2722ceddSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2722ceddSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2722ceddSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2722ceddSAndrew Rist * distributed with this work for additional information 6*2722ceddSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2722ceddSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2722ceddSAndrew Rist * "License"); you may not use this file except in compliance 9*2722ceddSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2722ceddSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2722ceddSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2722ceddSAndrew Rist * software distributed under the License is distributed on an 15*2722ceddSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2722ceddSAndrew Rist * KIND, either express or implied. See the License for the 17*2722ceddSAndrew Rist * specific language governing permissions and limitations 18*2722ceddSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2722ceddSAndrew Rist *************************************************************/ 21*2722ceddSAndrew Rist 22*2722ceddSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_desktop.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <introbmpnames.hxx> 28cdf0e10cSrcweir #include "splash.hxx" 29cdf0e10cSrcweir #include <stdio.h> 30cdf0e10cSrcweir #include <unotools/bootstrap.hxx> 31cdf0e10cSrcweir #include <vos/process.hxx> 32cdf0e10cSrcweir #include <tools/urlobj.hxx> 33cdf0e10cSrcweir #include <tools/stream.hxx> 34cdf0e10cSrcweir #include <sfx2/sfx.hrc> 35cdf0e10cSrcweir #include <vcl/svapp.hxx> 36cdf0e10cSrcweir #include <vcl/salnativewidgets.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp> 39cdf0e10cSrcweir #include <rtl/bootstrap.hxx> 40cdf0e10cSrcweir #include <rtl/logfile.hxx> 41cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 42cdf0e10cSrcweir #include <rtl/math.hxx> 43cdf0e10cSrcweir #include <vcl/graph.hxx> 44cdf0e10cSrcweir #include <svtools/filter.hxx> 45cdf0e10cSrcweir 46cdf0e10cSrcweir #define NOT_LOADED ((long)-1) 47cdf0e10cSrcweir 48cdf0e10cSrcweir using namespace ::rtl; 49cdf0e10cSrcweir using namespace ::com::sun::star::registry; 50cdf0e10cSrcweir 51cdf0e10cSrcweir namespace desktop 52cdf0e10cSrcweir { 53cdf0e10cSrcweir 54cdf0e10cSrcweir SplashScreen::SplashScreen(const Reference< XMultiServiceFactory >& rSMgr) 55cdf0e10cSrcweir : IntroWindow() 56cdf0e10cSrcweir , _vdev(*((IntroWindow*)this)) 57cdf0e10cSrcweir , _cProgressFrameColor(sal::static_int_cast< ColorData >(NOT_LOADED)) 58cdf0e10cSrcweir , _cProgressBarColor(sal::static_int_cast< ColorData >(NOT_LOADED)) 59cdf0e10cSrcweir , _bNativeProgress(true) 60cdf0e10cSrcweir , _iMax(100) 61cdf0e10cSrcweir , _iProgress(0) 62cdf0e10cSrcweir , _eBitmapMode(BM_DEFAULTMODE) 63cdf0e10cSrcweir , _bPaintBitmap(sal_True) 64cdf0e10cSrcweir , _bPaintProgress(sal_False) 65cdf0e10cSrcweir , _bShowLogo(sal_True) 66cdf0e10cSrcweir , _bFullScreenSplash(sal_False) 67cdf0e10cSrcweir , _bProgressEnd(sal_False) 68cdf0e10cSrcweir , _tlx(NOT_LOADED) 69cdf0e10cSrcweir , _tly(NOT_LOADED) 70cdf0e10cSrcweir , _barwidth(NOT_LOADED) 71cdf0e10cSrcweir , _barheight(NOT_LOADED) 72cdf0e10cSrcweir , _barspace(2) 73cdf0e10cSrcweir , _fXPos(-1.0) 74cdf0e10cSrcweir , _fYPos(-1.0) 75cdf0e10cSrcweir , _fWidth(-1.0) 76cdf0e10cSrcweir , _fHeight(-1.0) 77cdf0e10cSrcweir , _xoffset(12) 78cdf0e10cSrcweir , _yoffset(18) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir _rFactory = rSMgr; 81cdf0e10cSrcweir 82cdf0e10cSrcweir loadConfig(); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir SplashScreen::~SplashScreen() 86cdf0e10cSrcweir { 87cdf0e10cSrcweir Application::RemoveEventListener( 88cdf0e10cSrcweir LINK( this, SplashScreen, AppEventListenerHdl ) ); 89cdf0e10cSrcweir Hide(); 90cdf0e10cSrcweir 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir void SAL_CALL SplashScreen::start(const OUString&, sal_Int32 nRange) 94cdf0e10cSrcweir throw (RuntimeException) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir _iMax = nRange; 97cdf0e10cSrcweir if (_bVisible) { 98cdf0e10cSrcweir _bProgressEnd = sal_False; 99cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 100cdf0e10cSrcweir if ( _eBitmapMode == BM_FULLSCREEN ) 101cdf0e10cSrcweir ShowFullScreenMode( sal_True ); 102cdf0e10cSrcweir Show(); 103cdf0e10cSrcweir Paint(Rectangle()); 104cdf0e10cSrcweir Flush(); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir void SAL_CALL SplashScreen::end() 109cdf0e10cSrcweir throw (RuntimeException) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir _iProgress = _iMax; 112cdf0e10cSrcweir if (_bVisible ) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir if ( _eBitmapMode == BM_FULLSCREEN ) 115cdf0e10cSrcweir EndFullScreenMode(); 116cdf0e10cSrcweir Hide(); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir _bProgressEnd = sal_True; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir void SAL_CALL SplashScreen::reset() 122cdf0e10cSrcweir throw (RuntimeException) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir _iProgress = 0; 125cdf0e10cSrcweir if (_bVisible && !_bProgressEnd ) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir if ( _eBitmapMode == BM_FULLSCREEN ) 128cdf0e10cSrcweir ShowFullScreenMode( sal_True ); 129cdf0e10cSrcweir Show(); 130cdf0e10cSrcweir updateStatus(); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir void SAL_CALL SplashScreen::setText(const OUString& rText) 135cdf0e10cSrcweir throw (RuntimeException) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 138cdf0e10cSrcweir if ( _sProgressText != rText ) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir _sProgressText = rText; 141cdf0e10cSrcweir 142cdf0e10cSrcweir if (_bVisible && !_bProgressEnd) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir if ( _eBitmapMode == BM_FULLSCREEN ) 145cdf0e10cSrcweir ShowFullScreenMode( sal_True ); 146cdf0e10cSrcweir Show(); 147cdf0e10cSrcweir updateStatus(); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir } 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir void SAL_CALL SplashScreen::setValue(sal_Int32 nValue) 153cdf0e10cSrcweir throw (RuntimeException) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "::SplashScreen::setValue (lo119109)" ); 156cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_TRACE1( aLog, "value=%d", nValue ); 157cdf0e10cSrcweir 158cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 159cdf0e10cSrcweir if (_bVisible && !_bProgressEnd) { 160cdf0e10cSrcweir if ( _eBitmapMode == BM_FULLSCREEN ) 161cdf0e10cSrcweir ShowFullScreenMode( sal_True ); 162cdf0e10cSrcweir Show(); 163cdf0e10cSrcweir if (nValue >= _iMax) _iProgress = _iMax; 164cdf0e10cSrcweir else _iProgress = nValue; 165cdf0e10cSrcweir updateStatus(); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir // XInitialize 170cdf0e10cSrcweir void SAL_CALL 171cdf0e10cSrcweir SplashScreen::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& aArguments ) 172cdf0e10cSrcweir throw (RuntimeException) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( _aMutex ); 175cdf0e10cSrcweir if (aArguments.getLength() > 0) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir aArguments[0] >>= _bVisible; 178cdf0e10cSrcweir if (aArguments.getLength() > 1 ) 179cdf0e10cSrcweir aArguments[1] >>= _sAppName; 180cdf0e10cSrcweir 181cdf0e10cSrcweir // start to determine bitmap and all other required value 182cdf0e10cSrcweir initBitmap(); 183cdf0e10cSrcweir Size aSize = _aIntroBmp.GetSizePixel(); 184cdf0e10cSrcweir SetOutputSizePixel( aSize ); 185cdf0e10cSrcweir _vdev.SetOutputSizePixel( aSize ); 186cdf0e10cSrcweir _height = aSize.Height(); 187cdf0e10cSrcweir _width = aSize.Width(); 188cdf0e10cSrcweir if (_width > 500) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir Point xtopleft(212,216); 191cdf0e10cSrcweir if ( NOT_LOADED == _tlx || NOT_LOADED == _tly ) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir _tlx = xtopleft.X(); // top-left x 194cdf0e10cSrcweir _tly = xtopleft.Y(); // top-left y 195cdf0e10cSrcweir } 196cdf0e10cSrcweir if ( NOT_LOADED == _barwidth ) 197cdf0e10cSrcweir _barwidth = 263; 198cdf0e10cSrcweir if ( NOT_LOADED == _barheight ) 199cdf0e10cSrcweir _barheight = 8; 200cdf0e10cSrcweir if (( _eBitmapMode == BM_FULLSCREEN ) && 201cdf0e10cSrcweir _bFullScreenSplash ) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir if( ( _fXPos >= 0.0 ) && ( _fYPos >= 0.0 )) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir _tlx = sal_Int32( double( aSize.Width() ) * _fXPos ); 206cdf0e10cSrcweir _tly = sal_Int32( double( aSize.Height() ) * _fYPos ); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir if ( _fWidth >= 0.0 ) 209cdf0e10cSrcweir _barwidth = sal_Int32( double( aSize.Width() ) * _fWidth ); 210cdf0e10cSrcweir if ( _fHeight >= 0.0 ) 211cdf0e10cSrcweir _barheight = sal_Int32( double( aSize.Width() ) * _fHeight ); 212cdf0e10cSrcweir } 213cdf0e10cSrcweir } 214cdf0e10cSrcweir else 215cdf0e10cSrcweir { 216cdf0e10cSrcweir if ( NOT_LOADED == _barwidth ) 217cdf0e10cSrcweir _barwidth = _width - (2 * _xoffset); 218cdf0e10cSrcweir if ( NOT_LOADED == _barheight ) 219cdf0e10cSrcweir _barheight = 6; 220cdf0e10cSrcweir if ( NOT_LOADED == _tlx || NOT_LOADED == _tly ) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir _tlx = _xoffset; // top-left x 223cdf0e10cSrcweir _tly = _height - _yoffset; // top-left y 224cdf0e10cSrcweir } 225cdf0e10cSrcweir } 226cdf0e10cSrcweir 227cdf0e10cSrcweir if ( sal::static_int_cast< ColorData >(NOT_LOADED) == 228cdf0e10cSrcweir _cProgressFrameColor.GetColor() ) 229cdf0e10cSrcweir _cProgressFrameColor = Color( COL_LIGHTGRAY ); 230cdf0e10cSrcweir 231cdf0e10cSrcweir if ( sal::static_int_cast< ColorData >(NOT_LOADED) == 232cdf0e10cSrcweir _cProgressBarColor.GetColor() ) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir // progress bar: new color only for big bitmap format 235cdf0e10cSrcweir if ( _width > 500 ) 236cdf0e10cSrcweir _cProgressBarColor = Color( 157, 202, 18 ); 237cdf0e10cSrcweir else 238cdf0e10cSrcweir _cProgressBarColor = Color( COL_BLUE ); 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir Application::AddEventListener( 242cdf0e10cSrcweir LINK( this, SplashScreen, AppEventListenerHdl ) ); 243cdf0e10cSrcweir 244cdf0e10cSrcweir SetBackgroundBitmap( _aIntroBmp ); 245cdf0e10cSrcweir } 246cdf0e10cSrcweir } 247cdf0e10cSrcweir 248cdf0e10cSrcweir void SplashScreen::updateStatus() 249cdf0e10cSrcweir { 250cdf0e10cSrcweir if (!_bVisible || _bProgressEnd) return; 251cdf0e10cSrcweir if (!_bPaintProgress) _bPaintProgress = sal_True; 252cdf0e10cSrcweir //_bPaintBitmap=sal_False; 253cdf0e10cSrcweir Paint(Rectangle()); 254cdf0e10cSrcweir //_bPaintBitmap=sal_True; 255cdf0e10cSrcweir Flush(); 256cdf0e10cSrcweir } 257cdf0e10cSrcweir 258cdf0e10cSrcweir // internal private methods 259cdf0e10cSrcweir IMPL_LINK( SplashScreen, AppEventListenerHdl, VclWindowEvent *, inEvent ) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir if ( inEvent != 0 ) 262cdf0e10cSrcweir { 263cdf0e10cSrcweir // Paint( Rectangle() ); 264cdf0e10cSrcweir switch ( inEvent->GetId() ) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir case VCLEVENT_WINDOW_SHOW: 267cdf0e10cSrcweir Paint( Rectangle() ); 268cdf0e10cSrcweir break; 269cdf0e10cSrcweir default: 270cdf0e10cSrcweir break; 271cdf0e10cSrcweir } 272cdf0e10cSrcweir } 273cdf0e10cSrcweir return 0; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir 276cdf0e10cSrcweir // Read keys from edition/edition.ini or soffice{.ini|rc}: 277cdf0e10cSrcweir OUString implReadBootstrapKey( const OUString& _rKey ) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir OUString sValue( 280cdf0e10cSrcweir rtl::OUString( 281cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 282cdf0e10cSrcweir "${.override:${BRAND_BASE_DIR}/program/edition/edition.ini:")) + 283cdf0e10cSrcweir _rKey + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("}"))); 284cdf0e10cSrcweir rtl::Bootstrap::expandMacros(sValue); 285cdf0e10cSrcweir return sValue; 286cdf0e10cSrcweir } 287cdf0e10cSrcweir 288cdf0e10cSrcweir void SplashScreen::loadConfig() 289cdf0e10cSrcweir { 290cdf0e10cSrcweir _bShowLogo = !implReadBootstrapKey( 291cdf0e10cSrcweir rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Logo"))). 292cdf0e10cSrcweir equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("0")); 293cdf0e10cSrcweir 294cdf0e10cSrcweir OUString sProgressFrameColor = implReadBootstrapKey( 295cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressFrameColor" ) ) ); 296cdf0e10cSrcweir OUString sProgressBarColor = implReadBootstrapKey( 297cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressBarColor" ) ) ); 298cdf0e10cSrcweir OUString sSize = implReadBootstrapKey( 299cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressSize" ) ) ); 300cdf0e10cSrcweir OUString sPosition = implReadBootstrapKey( 301cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressPosition" ) ) ); 302cdf0e10cSrcweir OUString sFullScreenSplash = implReadBootstrapKey( 303cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "FullScreenSplash" ) ) ); 304cdf0e10cSrcweir OUString sNativeProgress = implReadBootstrapKey( 305cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "NativeProgress" ) ) ); 306cdf0e10cSrcweir 307cdf0e10cSrcweir 308cdf0e10cSrcweir // Determine full screen splash mode 309cdf0e10cSrcweir _bFullScreenSplash = (( sFullScreenSplash.getLength() > 0 ) && 310cdf0e10cSrcweir ( !sFullScreenSplash.equalsAsciiL( "0", 1 ))); 311cdf0e10cSrcweir 312cdf0e10cSrcweir // Try to retrieve the relative values for the progress bar. The current 313cdf0e10cSrcweir // schema uses the screen ratio to retrieve the associated values. 314cdf0e10cSrcweir if ( _bFullScreenSplash ) 315cdf0e10cSrcweir determineProgressRatioValues( _fXPos, _fYPos, _fWidth, _fHeight ); 316cdf0e10cSrcweir 317cdf0e10cSrcweir if ( sProgressFrameColor.getLength() ) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir sal_uInt8 nRed = 0; 320cdf0e10cSrcweir sal_uInt8 nGreen = 0; 321cdf0e10cSrcweir sal_uInt8 nBlue = 0; 322cdf0e10cSrcweir sal_Int32 idx = 0; 323cdf0e10cSrcweir sal_Int32 temp = sProgressFrameColor.getToken( 0, ',', idx ).toInt32(); 324cdf0e10cSrcweir if ( idx != -1 ) 325cdf0e10cSrcweir { 326cdf0e10cSrcweir nRed = static_cast< sal_uInt8 >( temp ); 327cdf0e10cSrcweir temp = sProgressFrameColor.getToken( 0, ',', idx ).toInt32(); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir if ( idx != -1 ) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir nGreen = static_cast< sal_uInt8 >( temp ); 332cdf0e10cSrcweir nBlue = static_cast< sal_uInt8 >( sProgressFrameColor.getToken( 0, ',', idx ).toInt32() ); 333cdf0e10cSrcweir _cProgressFrameColor = Color( nRed, nGreen, nBlue ); 334cdf0e10cSrcweir } 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir if ( sProgressBarColor.getLength() ) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir sal_uInt8 nRed = 0; 340cdf0e10cSrcweir sal_uInt8 nGreen = 0; 341cdf0e10cSrcweir sal_uInt8 nBlue = 0; 342cdf0e10cSrcweir sal_Int32 idx = 0; 343cdf0e10cSrcweir sal_Int32 temp = sProgressBarColor.getToken( 0, ',', idx ).toInt32(); 344cdf0e10cSrcweir if ( idx != -1 ) 345cdf0e10cSrcweir { 346cdf0e10cSrcweir nRed = static_cast< sal_uInt8 >( temp ); 347cdf0e10cSrcweir temp = sProgressBarColor.getToken( 0, ',', idx ).toInt32(); 348cdf0e10cSrcweir } 349cdf0e10cSrcweir if ( idx != -1 ) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir nGreen = static_cast< sal_uInt8 >( temp ); 352cdf0e10cSrcweir nBlue = static_cast< sal_uInt8 >( sProgressBarColor.getToken( 0, ',', idx ).toInt32() ); 353cdf0e10cSrcweir _cProgressBarColor = Color( nRed, nGreen, nBlue ); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir } 356cdf0e10cSrcweir 357cdf0e10cSrcweir if( sNativeProgress.getLength() ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir _bNativeProgress = sNativeProgress.toBoolean(); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir if ( sSize.getLength() ) 363cdf0e10cSrcweir { 364cdf0e10cSrcweir sal_Int32 idx = 0; 365cdf0e10cSrcweir sal_Int32 temp = sSize.getToken( 0, ',', idx ).toInt32(); 366cdf0e10cSrcweir if ( idx != -1 ) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir _barwidth = temp; 369cdf0e10cSrcweir _barheight = sSize.getToken( 0, ',', idx ).toInt32(); 370cdf0e10cSrcweir } 371cdf0e10cSrcweir } 372cdf0e10cSrcweir 373cdf0e10cSrcweir if ( _barheight >= 10 ) 374cdf0e10cSrcweir _barspace = 3; // more space between frame and bar 375cdf0e10cSrcweir 376cdf0e10cSrcweir if ( sPosition.getLength() ) 377cdf0e10cSrcweir { 378cdf0e10cSrcweir sal_Int32 idx = 0; 379cdf0e10cSrcweir sal_Int32 temp = sPosition.getToken( 0, ',', idx ).toInt32(); 380cdf0e10cSrcweir if ( idx != -1 ) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir _tlx = temp; 383cdf0e10cSrcweir _tly = sPosition.getToken( 0, ',', idx ).toInt32(); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir } 386cdf0e10cSrcweir } 387cdf0e10cSrcweir 388cdf0e10cSrcweir void SplashScreen::initBitmap() 389cdf0e10cSrcweir { 390cdf0e10cSrcweir if ( _bShowLogo ) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir OUString sExecutePath; 393cdf0e10cSrcweir ::rtl::Bootstrap::get( 394cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "BRAND_BASE_DIR" ) ), 395cdf0e10cSrcweir sExecutePath ); 396cdf0e10cSrcweir sExecutePath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/program/" ) ); 397cdf0e10cSrcweir 398cdf0e10cSrcweir bool haveBitmap = false; 399cdf0e10cSrcweir 400cdf0e10cSrcweir // Try all bitmaps in INTRO_BITMAP_NAMES 401cdf0e10cSrcweir sal_Int32 nIndex = 0; 402cdf0e10cSrcweir OUString aIntroBitmapFiles( RTL_CONSTASCII_USTRINGPARAM( INTRO_BITMAP_STRINGLIST )); 403cdf0e10cSrcweir do 404cdf0e10cSrcweir { 405cdf0e10cSrcweir haveBitmap = loadBitmap( sExecutePath, aIntroBitmapFiles.getToken( 0, ',', nIndex ) ); 406cdf0e10cSrcweir } 407cdf0e10cSrcweir while ( !haveBitmap && ( nIndex >= 0 ) ); 408cdf0e10cSrcweir 409cdf0e10cSrcweir if (!haveBitmap) { 410cdf0e10cSrcweir rtl::OUString edition( 411cdf0e10cSrcweir rtl::OUString( 412cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 413cdf0e10cSrcweir "${BRAND_BASE_DIR}/program/edition"))); 414cdf0e10cSrcweir rtl::Bootstrap::expandMacros(edition); 415cdf0e10cSrcweir haveBitmap = findBitmap(edition); 416cdf0e10cSrcweir } 417cdf0e10cSrcweir if (!haveBitmap) { 418cdf0e10cSrcweir findBitmap(sExecutePath); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir } 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir bool SplashScreen::loadBitmap( 424cdf0e10cSrcweir rtl::OUString const & path, const rtl::OUString &rBmpFileName ) 425cdf0e10cSrcweir { 426cdf0e10cSrcweir if ( rBmpFileName.getLength() == 0 ) 427cdf0e10cSrcweir return false; 428cdf0e10cSrcweir 429cdf0e10cSrcweir INetURLObject aObj( path, INET_PROT_FILE ); 430cdf0e10cSrcweir aObj.insertName( rBmpFileName ); 431cdf0e10cSrcweir 432cdf0e10cSrcweir SvFileStream aStrm( aObj.PathToFileName(), STREAM_STD_READ ); 433cdf0e10cSrcweir if ( !aStrm.GetError() ) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir // Use graphic class to also support more graphic formats (bmp,png,...) 436cdf0e10cSrcweir Graphic aGraphic; 437cdf0e10cSrcweir 438cdf0e10cSrcweir GraphicFilter* pGF = GraphicFilter::GetGraphicFilter(); 439cdf0e10cSrcweir pGF->ImportGraphic( aGraphic, String(), aStrm, GRFILTER_FORMAT_DONTKNOW ); 440cdf0e10cSrcweir 441cdf0e10cSrcweir // Default case, we load the intro bitmap from a seperate file 442cdf0e10cSrcweir // (e.g. staroffice_intro.bmp or starsuite_intro.bmp) 443cdf0e10cSrcweir _aIntroBmp = aGraphic.GetBitmapEx(); 444cdf0e10cSrcweir return true; 445cdf0e10cSrcweir } 446cdf0e10cSrcweir 447cdf0e10cSrcweir return false; 448cdf0e10cSrcweir } 449cdf0e10cSrcweir 450cdf0e10cSrcweir bool SplashScreen::findBitmap(rtl::OUString const & path) { 451cdf0e10cSrcweir bool haveBitmap = false; 452cdf0e10cSrcweir if ( _bFullScreenSplash ) 453cdf0e10cSrcweir { 454cdf0e10cSrcweir haveBitmap = findScreenBitmap(path); 455cdf0e10cSrcweir if ( haveBitmap ) 456cdf0e10cSrcweir _eBitmapMode = BM_FULLSCREEN; 457cdf0e10cSrcweir else 458cdf0e10cSrcweir haveBitmap = findAppBitmap(path); 459cdf0e10cSrcweir } 460cdf0e10cSrcweir if ( !haveBitmap ) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir haveBitmap = loadBitmap( 463cdf0e10cSrcweir path, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("intro.png"))); 464cdf0e10cSrcweir if ( !haveBitmap ) 465cdf0e10cSrcweir haveBitmap = loadBitmap( 466cdf0e10cSrcweir path, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("intro.bmp"))); 467cdf0e10cSrcweir } 468cdf0e10cSrcweir 469cdf0e10cSrcweir return haveBitmap; 470cdf0e10cSrcweir } 471cdf0e10cSrcweir 472cdf0e10cSrcweir bool SplashScreen::findScreenBitmap(rtl::OUString const & path) 473cdf0e10cSrcweir { 474cdf0e10cSrcweir sal_Int32 nWidth( 0 ); 475cdf0e10cSrcweir sal_Int32 nHeight( 0 ); 476cdf0e10cSrcweir 477cdf0e10cSrcweir // determine desktop resolution 478cdf0e10cSrcweir sal_uInt32 nCount = Application::GetScreenCount(); 479cdf0e10cSrcweir if ( nCount > 0 ) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir // retrieve size from first screen 482cdf0e10cSrcweir Rectangle aScreenArea = Application::GetScreenPosSizePixel((unsigned int)0); 483cdf0e10cSrcweir nWidth = aScreenArea.GetWidth(); 484cdf0e10cSrcweir nHeight = aScreenArea.GetHeight(); 485cdf0e10cSrcweir } 486cdf0e10cSrcweir 487cdf0e10cSrcweir // create file name from screen resolution information 488cdf0e10cSrcweir OUStringBuffer aStrBuf( 128 ); 489cdf0e10cSrcweir aStrBuf.appendAscii( "intro_" ); 490cdf0e10cSrcweir if ( _sAppName.getLength() > 0 ) 491cdf0e10cSrcweir { 492cdf0e10cSrcweir aStrBuf.append( _sAppName ); 493cdf0e10cSrcweir aStrBuf.appendAscii( "_" ); 494cdf0e10cSrcweir } 495cdf0e10cSrcweir aStrBuf.append( OUString::valueOf( nWidth )); 496cdf0e10cSrcweir aStrBuf.appendAscii( "x" ); 497cdf0e10cSrcweir aStrBuf.append( OUString::valueOf( nHeight )); 498cdf0e10cSrcweir 499cdf0e10cSrcweir OUString aRootIntroFileName = aStrBuf.makeStringAndClear(); 500cdf0e10cSrcweir OUString aBmpFileName = aRootIntroFileName + OUString::createFromAscii(".png"); 501cdf0e10cSrcweir 502cdf0e10cSrcweir bool haveBitmap = loadBitmap( path, aBmpFileName ); 503cdf0e10cSrcweir if ( !haveBitmap ) 504cdf0e10cSrcweir { 505cdf0e10cSrcweir aBmpFileName = aRootIntroFileName + OUString::createFromAscii(".bmp"); 506cdf0e10cSrcweir haveBitmap = loadBitmap( path, aBmpFileName ); 507cdf0e10cSrcweir } 508cdf0e10cSrcweir 509cdf0e10cSrcweir if ( !haveBitmap ) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir aStrBuf.appendAscii( "intro_" ); 512cdf0e10cSrcweir aStrBuf.appendAscii( "_" ); 513cdf0e10cSrcweir aStrBuf.append( OUString::valueOf( nWidth )); 514cdf0e10cSrcweir aStrBuf.appendAscii( "x" ); 515cdf0e10cSrcweir aStrBuf.append( OUString::valueOf( nHeight )); 516cdf0e10cSrcweir 517cdf0e10cSrcweir aRootIntroFileName = aStrBuf.makeStringAndClear(); 518cdf0e10cSrcweir aBmpFileName = aRootIntroFileName + OUString::createFromAscii(".png"); 519cdf0e10cSrcweir 520cdf0e10cSrcweir haveBitmap = loadBitmap( path, aBmpFileName ); 521cdf0e10cSrcweir if ( !haveBitmap ) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir aBmpFileName = aRootIntroFileName + OUString::createFromAscii(".bmp"); 524cdf0e10cSrcweir haveBitmap = loadBitmap( path, aBmpFileName ); 525cdf0e10cSrcweir } 526cdf0e10cSrcweir } 527cdf0e10cSrcweir return haveBitmap; 528cdf0e10cSrcweir } 529cdf0e10cSrcweir 530cdf0e10cSrcweir bool SplashScreen::findAppBitmap(rtl::OUString const & path) 531cdf0e10cSrcweir { 532cdf0e10cSrcweir bool haveBitmap = false; 533cdf0e10cSrcweir 534cdf0e10cSrcweir if ( _sAppName.getLength() > 0 ) 535cdf0e10cSrcweir { 536cdf0e10cSrcweir OUStringBuffer aStrBuf( 128 ); 537cdf0e10cSrcweir aStrBuf.appendAscii( "intro_" ); 538cdf0e10cSrcweir aStrBuf.appendAscii( "_" ); 539cdf0e10cSrcweir aStrBuf.append( _sAppName ); 540cdf0e10cSrcweir 541cdf0e10cSrcweir OUString aRootIntroFileName = aStrBuf.makeStringAndClear(); 542cdf0e10cSrcweir 543cdf0e10cSrcweir OUString aBmpFileName = aRootIntroFileName + OUString::createFromAscii( ".png" ); 544cdf0e10cSrcweir haveBitmap = loadBitmap( path, aBmpFileName ); 545cdf0e10cSrcweir if ( !haveBitmap ) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir aBmpFileName = aRootIntroFileName + OUString::createFromAscii( ".bmp" ); 548cdf0e10cSrcweir haveBitmap = loadBitmap( path, aBmpFileName ); 549cdf0e10cSrcweir } 550cdf0e10cSrcweir } 551cdf0e10cSrcweir return haveBitmap; 552cdf0e10cSrcweir } 553cdf0e10cSrcweir 554cdf0e10cSrcweir void SplashScreen::determineProgressRatioValues( 555cdf0e10cSrcweir double& rXRelPos, double& rYRelPos, 556cdf0e10cSrcweir double& rRelWidth, double& rRelHeight ) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir sal_Int32 nWidth( 0 ); 559cdf0e10cSrcweir sal_Int32 nHeight( 0 ); 560cdf0e10cSrcweir sal_Int32 nScreenRatio( 0 ); 561cdf0e10cSrcweir 562cdf0e10cSrcweir // determine desktop resolution 563cdf0e10cSrcweir sal_uInt32 nCount = Application::GetScreenCount(); 564cdf0e10cSrcweir if ( nCount > 0 ) 565cdf0e10cSrcweir { 566cdf0e10cSrcweir // retrieve size from first screen 567cdf0e10cSrcweir Rectangle aScreenArea = Application::GetScreenPosSizePixel((unsigned int)0); 568cdf0e10cSrcweir nWidth = aScreenArea.GetWidth(); 569cdf0e10cSrcweir nHeight = aScreenArea.GetHeight(); 570cdf0e10cSrcweir nScreenRatio = sal_Int32( math::round( double( nWidth ) / double( nHeight ), 2 ) * 100 ); 571cdf0e10cSrcweir } 572cdf0e10cSrcweir 573cdf0e10cSrcweir char szFullScreenProgressRatio[] = "FullScreenProgressRatio0"; 574cdf0e10cSrcweir char szFullScreenProgressPos[] = "FullScreenProgressPos0"; 575cdf0e10cSrcweir char szFullScreenProgressSize[] = "FullScreenProgressSize0"; 576cdf0e10cSrcweir for ( sal_Int32 i = 0; i <= 9; i++ ) 577cdf0e10cSrcweir { 578cdf0e10cSrcweir char cNum = '0' + char( i ); 579cdf0e10cSrcweir szFullScreenProgressRatio[23] = cNum; 580cdf0e10cSrcweir szFullScreenProgressPos[21] = cNum; 581cdf0e10cSrcweir szFullScreenProgressSize[22] = cNum; 582cdf0e10cSrcweir 583cdf0e10cSrcweir OUString sFullScreenProgressRatio = implReadBootstrapKey( 584cdf0e10cSrcweir OUString::createFromAscii( szFullScreenProgressRatio ) ); 585cdf0e10cSrcweir 586cdf0e10cSrcweir if ( sFullScreenProgressRatio.getLength() > 0 ) 587cdf0e10cSrcweir { 588cdf0e10cSrcweir double fRatio = sFullScreenProgressRatio.toDouble(); 589cdf0e10cSrcweir sal_Int32 nRatio = sal_Int32( math::round( fRatio, 2 ) * 100 ); 590cdf0e10cSrcweir if ( nRatio == nScreenRatio ) 591cdf0e10cSrcweir { 592cdf0e10cSrcweir OUString sFullScreenProgressPos = implReadBootstrapKey( 593cdf0e10cSrcweir OUString::createFromAscii( szFullScreenProgressPos ) ); 594cdf0e10cSrcweir OUString sFullScreenProgressSize = implReadBootstrapKey( 595cdf0e10cSrcweir OUString::createFromAscii( szFullScreenProgressSize ) ); 596cdf0e10cSrcweir 597cdf0e10cSrcweir if ( sFullScreenProgressPos.getLength() ) 598cdf0e10cSrcweir { 599cdf0e10cSrcweir sal_Int32 idx = 0; 600cdf0e10cSrcweir double temp = sFullScreenProgressPos.getToken( 0, ',', idx ).toDouble(); 601cdf0e10cSrcweir if ( idx != -1 ) 602cdf0e10cSrcweir { 603cdf0e10cSrcweir rXRelPos = temp; 604cdf0e10cSrcweir rYRelPos = sFullScreenProgressPos.getToken( 0, ',', idx ).toDouble(); 605cdf0e10cSrcweir } 606cdf0e10cSrcweir } 607cdf0e10cSrcweir 608cdf0e10cSrcweir if ( sFullScreenProgressSize.getLength() ) 609cdf0e10cSrcweir { 610cdf0e10cSrcweir sal_Int32 idx = 0; 611cdf0e10cSrcweir double temp = sFullScreenProgressSize.getToken( 0, ',', idx ).toDouble(); 612cdf0e10cSrcweir if ( idx != -1 ) 613cdf0e10cSrcweir { 614cdf0e10cSrcweir rRelWidth = temp; 615cdf0e10cSrcweir rRelHeight = sFullScreenProgressSize.getToken( 0, ',', idx ).toDouble(); 616cdf0e10cSrcweir } 617cdf0e10cSrcweir } 618cdf0e10cSrcweir } 619cdf0e10cSrcweir } 620cdf0e10cSrcweir else 621cdf0e10cSrcweir break; 622cdf0e10cSrcweir } 623cdf0e10cSrcweir } 624cdf0e10cSrcweir 625cdf0e10cSrcweir void SplashScreen::Paint( const Rectangle&) 626cdf0e10cSrcweir { 627cdf0e10cSrcweir if(!_bVisible) return; 628cdf0e10cSrcweir 629cdf0e10cSrcweir //native drawing 630cdf0e10cSrcweir sal_Bool bNativeOK = sal_False; 631cdf0e10cSrcweir 632cdf0e10cSrcweir // in case of native controls we need to draw directly to the window 633cdf0e10cSrcweir if( _bNativeProgress && IsNativeControlSupported( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL ) ) 634cdf0e10cSrcweir { 635cdf0e10cSrcweir DrawBitmapEx( Point(), _aIntroBmp ); 636cdf0e10cSrcweir 637cdf0e10cSrcweir ImplControlValue aValue( _iProgress * _barwidth / _iMax); 638cdf0e10cSrcweir Rectangle aDrawRect( Point(_tlx, _tly), Size( _barwidth, _barheight ) ); 639cdf0e10cSrcweir Rectangle aNativeControlRegion, aNativeContentRegion; 640cdf0e10cSrcweir 641cdf0e10cSrcweir if( GetNativeControlRegion( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect, 642cdf0e10cSrcweir CTRL_STATE_ENABLED, aValue, rtl::OUString(), 643cdf0e10cSrcweir aNativeControlRegion, aNativeContentRegion ) ) 644cdf0e10cSrcweir { 645cdf0e10cSrcweir long nProgressHeight = aNativeControlRegion.GetHeight(); 646cdf0e10cSrcweir aDrawRect.Top() -= (nProgressHeight - _barheight)/2; 647cdf0e10cSrcweir aDrawRect.Bottom() += (nProgressHeight - _barheight)/2; 648cdf0e10cSrcweir } 649cdf0e10cSrcweir 650cdf0e10cSrcweir if( (bNativeOK = DrawNativeControl( CTRL_INTROPROGRESS, PART_ENTIRE_CONTROL, aDrawRect, 651cdf0e10cSrcweir CTRL_STATE_ENABLED, aValue, _sProgressText )) != sal_False ) 652cdf0e10cSrcweir { 653cdf0e10cSrcweir return; 654cdf0e10cSrcweir } 655cdf0e10cSrcweir } 656cdf0e10cSrcweir //non native drawing 657cdf0e10cSrcweir // draw bitmap 658cdf0e10cSrcweir if (_bPaintBitmap) 659cdf0e10cSrcweir _vdev.DrawBitmapEx( Point(), _aIntroBmp ); 660cdf0e10cSrcweir 661cdf0e10cSrcweir if (_bPaintProgress) { 662cdf0e10cSrcweir // draw progress... 663cdf0e10cSrcweir long length = (_iProgress * _barwidth / _iMax) - (2 * _barspace); 664cdf0e10cSrcweir if (length < 0) length = 0; 665cdf0e10cSrcweir 666cdf0e10cSrcweir // border 667cdf0e10cSrcweir _vdev.SetFillColor(); 668cdf0e10cSrcweir _vdev.SetLineColor( _cProgressFrameColor ); 669cdf0e10cSrcweir _vdev.DrawRect(Rectangle(_tlx, _tly, _tlx+_barwidth, _tly+_barheight)); 670cdf0e10cSrcweir _vdev.SetFillColor( _cProgressBarColor ); 671cdf0e10cSrcweir _vdev.SetLineColor(); 672cdf0e10cSrcweir _vdev.DrawRect(Rectangle(_tlx+_barspace, _tly+_barspace, _tlx+_barspace+length, _tly+_barheight-_barspace)); 673cdf0e10cSrcweir _vdev.DrawText( Rectangle(_tlx, _tly+_barheight+5, _tlx+_barwidth, _tly+_barheight+5+20), _sProgressText, TEXT_DRAW_CENTER ); 674cdf0e10cSrcweir } 675cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 676cdf0e10cSrcweir Size bSize = _vdev.GetOutputSizePixel(); 677cdf0e10cSrcweir //_vdev.Flush(); 678cdf0e10cSrcweir //_vdev.DrawOutDev(Point(), GetOutputSize(), Point(), GetOutputSize(), *((IntroWindow*)this) ); 679cdf0e10cSrcweir DrawOutDev(Point(), GetOutputSizePixel(), Point(), _vdev.GetOutputSizePixel(), _vdev ); 680cdf0e10cSrcweir //Flush(); 681cdf0e10cSrcweir } 682cdf0e10cSrcweir 683cdf0e10cSrcweir 684cdf0e10cSrcweir // get service instance... 685cdf0e10cSrcweir SplashScreen *SplashScreen::_pINSTANCE = NULL; 686cdf0e10cSrcweir osl::Mutex SplashScreen::_aMutex; 687cdf0e10cSrcweir 688cdf0e10cSrcweir Reference< XInterface > SplashScreen::getInstance(const Reference< XMultiServiceFactory >& rSMgr) 689cdf0e10cSrcweir { 690cdf0e10cSrcweir if ( _pINSTANCE == 0 ) 691cdf0e10cSrcweir { 692cdf0e10cSrcweir osl::MutexGuard guard(_aMutex); 693cdf0e10cSrcweir if (_pINSTANCE == 0) 694cdf0e10cSrcweir return (XComponent*)new SplashScreen(rSMgr); 695cdf0e10cSrcweir } 696cdf0e10cSrcweir 697cdf0e10cSrcweir return (XComponent*)0; 698cdf0e10cSrcweir } 699cdf0e10cSrcweir 700cdf0e10cSrcweir // static service info... 701cdf0e10cSrcweir const char* SplashScreen::interfaces[] = 702cdf0e10cSrcweir { 703cdf0e10cSrcweir "com.sun.star.task.XStartusIndicator", 704cdf0e10cSrcweir "com.sun.star.lang.XInitialization", 705cdf0e10cSrcweir NULL, 706cdf0e10cSrcweir }; 707cdf0e10cSrcweir const sal_Char *SplashScreen::serviceName = "com.sun.star.office.SplashScreen"; 708cdf0e10cSrcweir const sal_Char *SplashScreen::implementationName = "com.sun.star.office.comp.SplashScreen"; 709cdf0e10cSrcweir const sal_Char *SplashScreen::supportedServiceNames[] = {"com.sun.star.office.SplashScreen", NULL}; 710cdf0e10cSrcweir 711cdf0e10cSrcweir } 712