26 #include <com/sun/star/lang/XInitialization.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/task/XStatusIndicator.hpp>
31 #include <rtl/bootstrap.hxx>
32 #include <rtl/strbuf.hxx>
33 #include <rtl/math.hxx>
37 #define NOT_LOADED (tools::Long(-1))
38 #define NOT_LOADED_COLOR (Color(ColorTransparency, 0xffffffff))
48 class SplashScreenWindow :
public IntroWindow
53 explicit SplashScreenWindow(SplashScreen *);
54 virtual ~SplashScreenWindow()
override { disposeOnce(); }
55 virtual void dispose()
override;
63 :
public ::cppu::WeakImplHelper< XStatusIndicator, XInitialization, XServiceInfo >
65 friend class SplashScreenWindow;
70 virtual ~SplashScreen()
override;
73 void SetScreenBitmap(
BitmapEx &rBitmap);
74 static void determineProgressRatioValues(
double& rXRelPos,
double& rYRelPos,
double& rRelWidth,
double& rRelHeight );
76 static osl::Mutex _aMutex;
79 Color _cProgressFrameColor;
80 Color _cProgressBarColor;
81 Color _cProgressTextColor;
82 bool _bNativeProgress;
84 OUString _sProgressText;
91 bool _bFullScreenSplash;
95 double _fXPos, _fYPos;
96 double _fWidth, _fHeight;
97 static constexpr
tools::Long _xoffset = 12, _yoffset = 18;
103 virtual void SAL_CALL
end()
override;
104 virtual void SAL_CALL reset()
override;
105 virtual void SAL_CALL setText(
const OUString& aText)
override;
107 virtual void SAL_CALL start(
const OUString& aText, sal_Int32 nRange)
override;
110 virtual void SAL_CALL initialize(
const css::uno::Sequence< css::uno::Any>&
aArguments )
override;
113 {
return "com.sun.star.office.comp.SplashScreen"; }
119 {
return {
"com.sun.star.office.SplashScreen" }; }
122 SplashScreenWindow::SplashScreenWindow(SplashScreen *pSplash)
127 _vdev->EnableRTL(IsRTLEnabled());
130 void SplashScreenWindow::dispose()
133 IntroWindow::dispose();
136 void SplashScreenWindow::Redraw()
145 SplashScreen::SplashScreen()
150 , _bNativeProgress(
true)
153 , _bPaintProgress(
false)
156 , _bFullScreenSplash(
false)
157 , _bProgressEnd(
false)
174 SplashScreen::~SplashScreen()
177 LINK(
this, SplashScreen, AppEventListenerHdl ) );
179 pWindow.disposeAndClear();
182 void SAL_CALL SplashScreen::start(
const OUString&, sal_Int32 nRange)
186 _bProgressEnd =
false;
193 void SAL_CALL SplashScreen::end()
200 _bProgressEnd =
true;
203 void SAL_CALL SplashScreen::reset()
206 if (_bVisible && !_bProgressEnd )
213 void SAL_CALL SplashScreen::setText(
const OUString& rText)
216 if ( _sProgressText != rText )
218 _sProgressText = rText;
220 if (_bVisible && !_bProgressEnd)
228 void SAL_CALL SplashScreen::setValue(sal_Int32
nValue)
230 SAL_INFO(
"desktop.splash",
"setValue: " << nValue );
233 if (_bVisible && !_bProgressEnd) {
245 SplashScreen::initialize(
const css::uno::Sequence< css::uno::Any>&
aArguments )
247 osl::MutexGuard aGuard( _aMutex );
248 if (!aArguments.hasElements())
251 aArguments[0] >>= _bVisible;
252 if (aArguments.getLength() > 1 )
253 aArguments[1] >>= _sAppName;
257 SetScreenBitmap (_aIntroBmp);
258 Size aSize = _aIntroBmp.GetSizePixel();
259 pWindow->SetOutputSizePixel( aSize );
260 pWindow->_vdev->SetOutputSizePixel( aSize );
262 _width = aSize.
Width();
265 Point xtopleft(212,216);
279 _barwidth = _width - (2 * _xoffset);
285 _tly = _height - _yoffset;
290 _textBaseline = _height;
299 _cProgressBarColor =
Color( 157, 202, 18 );
308 LINK(
this, SplashScreen, AppEventListenerHdl ) );
311 void SplashScreen::updateStatus()
313 if (!_bVisible || _bProgressEnd)
315 if (!_bPaintProgress)
316 _bPaintProgress =
true;
323 if (static_cast<VclWindowEvent&>(inEvent).GetWindow() == pWindow)
325 switch ( inEvent.GetId() )
327 case VclEventId::WindowShow:
337 OUString implReadBootstrapKey(
const OUString& _rKey )
340 rtl::Bootstrap::get(_rKey, sValue);
344 void SplashScreen::loadConfig()
346 _bShowLogo = implReadBootstrapKey(
"Logo" ) !=
"0";
348 OUString sProgressFrameColor = implReadBootstrapKey(
"ProgressFrameColor" );
349 OUString sProgressBarColor = implReadBootstrapKey(
"ProgressBarColor" );
350 OUString sProgressTextColor = implReadBootstrapKey(
"ProgressTextColor" );
351 OUString sProgressTextBaseline = implReadBootstrapKey(
"ProgressTextBaseline" );
352 OUString sSize = implReadBootstrapKey(
"ProgressSize" );
353 OUString sPosition = implReadBootstrapKey(
"ProgressPosition" );
354 OUString sFullScreenSplash = implReadBootstrapKey(
"FullScreenSplash" );
355 OUString sNativeProgress = implReadBootstrapKey(
"NativeProgress" );
359 _bFullScreenSplash = (( !sFullScreenSplash.isEmpty() ) &&
360 ( sFullScreenSplash !=
"0" ));
364 if ( _bFullScreenSplash )
365 determineProgressRatioValues( _fXPos, _fYPos, _fWidth, _fHeight );
367 if ( !sProgressFrameColor.isEmpty() )
371 sal_Int32 temp = sProgressFrameColor.getToken( 0,
',', idx ).toInt32();
375 temp = sProgressFrameColor.getToken( 0,
',', idx ).toInt32();
380 sal_uInt8 nBlue =
static_cast< sal_uInt8 >( sProgressFrameColor.getToken( 0,
',', idx ).toInt32() );
381 _cProgressFrameColor =
Color( nRed, nGreen, nBlue );
385 if ( !sProgressBarColor.isEmpty() )
389 sal_Int32 temp = sProgressBarColor.getToken( 0,
',', idx ).toInt32();
393 temp = sProgressBarColor.getToken( 0,
',', idx ).toInt32();
398 sal_uInt8 nBlue =
static_cast< sal_uInt8 >( sProgressBarColor.getToken( 0,
',', idx ).toInt32() );
399 _cProgressBarColor =
Color( nRed, nGreen, nBlue );
403 if ( !sProgressTextColor.isEmpty() )
407 sal_Int32 temp = sProgressTextColor.getToken( 0,
',', idx ).toInt32();
411 temp = sProgressTextColor.getToken( 0,
',', idx ).toInt32();
416 sal_uInt8 nBlue =
static_cast< sal_uInt8 >( sProgressTextColor.getToken( 0,
',', idx ).toInt32() );
417 _cProgressTextColor =
Color( nRed, nGreen, nBlue );
421 if ( !sProgressTextBaseline.isEmpty() )
423 _textBaseline = sProgressTextBaseline.toInt32();
426 if( !sNativeProgress.isEmpty() )
428 _bNativeProgress = sNativeProgress.toBoolean();
431 if ( !sSize.isEmpty() )
434 sal_Int32 temp = sSize.getToken( 0,
',', idx ).toInt32();
438 _barheight = sSize.getToken( 0,
',', idx ).toInt32();
442 if ( _barheight >= 10 )
445 if ( !sPosition.isEmpty() )
448 sal_Int32 temp = sPosition.getToken( 0,
',', idx ).toInt32();
452 _tly = sPosition.getToken( 0,
',', idx ).toInt32();
457 void SplashScreen::SetScreenBitmap(
BitmapEx &rBitmap)
459 sal_Int32 nWidth( 0 );
460 sal_Int32 nHeight( 0 );
473 OStringBuffer aStrBuf( 128 );
474 aStrBuf.append(
"intro_" );
475 if ( !_sAppName.isEmpty() )
478 aStrBuf.append(
"_" );
480 OString aResBuf = OString::number( nWidth ) +
"x" + OString::number( nHeight );
482 aStrBuf.append( aResBuf.getStr() );
486 aStrBuf.append(
"intro_" );
487 aStrBuf.append( aResBuf.getStr() );
494 void SplashScreen::determineProgressRatioValues(
495 double& rXRelPos,
double& rYRelPos,
496 double& rRelWidth,
double& rRelHeight )
498 sal_Int32 nScreenRatio( 0 );
506 sal_Int32 nWidth = aScreenArea.
GetWidth();
507 sal_Int32 nHeight = aScreenArea.
GetHeight();
508 nScreenRatio = nHeight ? sal_Int32( rtl::math::round(
double( nWidth ) /
double( nHeight ), 2 ) * 100 ) : 0;
511 char szFullScreenProgressRatio[] =
"FullScreenProgressRatio0";
512 char szFullScreenProgressPos[] =
"FullScreenProgressPos0";
513 char szFullScreenProgressSize[] =
"FullScreenProgressSize0";
514 for ( sal_Int32
i = 0;
i <= 9;
i++ )
516 char cNum =
'0' + char(
i );
517 szFullScreenProgressRatio[23] = cNum;
518 szFullScreenProgressPos[21] = cNum;
519 szFullScreenProgressSize[22] = cNum;
521 OUString sFullScreenProgressRatio = implReadBootstrapKey(
522 OUString::createFromAscii( szFullScreenProgressRatio ) );
524 if ( !sFullScreenProgressRatio.isEmpty() )
526 double fRatio = sFullScreenProgressRatio.toDouble();
527 sal_Int32 nRatio = sal_Int32( rtl::math::round( fRatio, 2 ) * 100 );
528 if ( nRatio == nScreenRatio )
530 OUString sFullScreenProgressPos = implReadBootstrapKey(
531 OUString::createFromAscii( szFullScreenProgressPos ) );
532 OUString sFullScreenProgressSize = implReadBootstrapKey(
533 OUString::createFromAscii( szFullScreenProgressSize ) );
535 if ( !sFullScreenProgressPos.isEmpty() )
538 double temp = sFullScreenProgressPos.getToken( 0,
',', idx ).toDouble();
542 rYRelPos = sFullScreenProgressPos.getToken( 0,
',', idx ).toDouble();
546 if ( !sFullScreenProgressSize.isEmpty() )
549 double temp = sFullScreenProgressSize.getToken( 0,
',', idx ).toDouble();
553 rRelHeight = sFullScreenProgressSize.getToken( 0,
',', idx ).toDouble();
565 if (!pSpl || !pSpl->_bVisible)
570 if (pSpl->_bNativeProgress && rRenderContext.
IsNativeControlSupported(ControlType::IntroProgress, ControlPart::Entire))
579 ControlState::ENABLED, aValue,
580 aNativeControlRegion, aNativeContentRegion))
583 aDrawRect.
AdjustTop( -((nProgressHeight - pSpl->_barheight)/2) );
584 aDrawRect.
AdjustBottom((nProgressHeight - pSpl->_barheight)/2 );
587 if (rRenderContext.
DrawNativeControl(ControlType::IntroProgress, ControlPart::Entire, aDrawRect,
588 ControlState::ENABLED, aValue, pSpl->_sProgressText))
596 _vdev->DrawBitmapEx(
Point(), pSpl->_aIntroBmp);
598 if (pSpl->_bPaintProgress) {
600 tools::Long length = (pSpl->_iProgress * pSpl->_barwidth / pSpl->_iMax) - (2 * pSpl->_barspace);
601 if (length < 0) length = 0;
604 _vdev->SetFillColor();
605 _vdev->SetLineColor( pSpl->_cProgressFrameColor );
606 _vdev->DrawRect(
tools::Rectangle(pSpl->_tlx, pSpl->_tly, pSpl->_tlx+pSpl->_barwidth, pSpl->_tly+pSpl->_barheight));
607 _vdev->SetFillColor( pSpl->_cProgressBarColor );
608 _vdev->SetLineColor();
609 _vdev->DrawRect(
tools::Rectangle(pSpl->_tlx+pSpl->_barspace, pSpl->_tly+pSpl->_barspace, pSpl->_tlx+pSpl->_barspace+length, pSpl->_tly+pSpl->_barheight-pSpl->_barspace));
613 _vdev->SetFont(aFont);
614 _vdev->SetTextColor(pSpl->_cProgressTextColor);
615 _vdev->DrawText(
Point(pSpl->_tlx, pSpl->_textBaseline), pSpl->_sProgressText);
617 rRenderContext.
DrawOutDev(
Point(), GetOutputSizePixel(),
Point(), _vdev->GetOutputSizePixel(), *_vdev);
622 osl::Mutex SplashScreen::_aMutex;
626 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
628 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any>
const&)
630 return cppu::acquire(
new SplashScreen());
RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey, rtl_uString *keyName, RegValueType valueType, RegValue pData, sal_uInt32 valueSize)
#define LINK(Instance, Class, Member)
void SetFontSize(const Size &)
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
#define DECL_LINK(Member, ArgType, RetType)
static void RemoveEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
static void AddEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Sequence< PropertyValue > aArguments
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
void SetAlignment(FontAlign)
static tools::Rectangle GetScreenPosSizePixel(unsigned int nScreen)
tools::Long Width() const
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor=COL_AUTO)
static unsigned int GetScreenCount()
enumrange< T >::Iterator end(enumrange< T >)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * desktop_SplashScreen_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
#define SAL_INFO(area, stream)
tools::Long Height() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
constexpr::Color COL_BLUE(0x00, 0x00, 0x80)
static bool LoadBrandBitmap(const char *pName, BitmapEx &rBitmap)
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
IMPL_LINK(ExtMgrDialog, startProgress, void *, _bLockInterface, void)