26#include <com/sun/star/lang/XInitialization.hpp>
27#include <com/sun/star/lang/XServiceInfo.hpp>
28#include <com/sun/star/task/XStatusIndicator.hpp>
32#include <rtl/bootstrap.hxx>
33#include <rtl/strbuf.hxx>
34#include <rtl/math.hxx>
41#define NOT_LOADED (tools::Long(-1))
42#define NOT_LOADED_COLOR (Color(ColorTransparency, 0xffffffff))
52class SplashScreenWindow :
public IntroWindow
57 explicit SplashScreenWindow(SplashScreen *);
58 virtual ~SplashScreenWindow()
override { disposeOnce(); }
59 virtual void dispose()
override;
67 :
public ::cppu::WeakImplHelper< XStatusIndicator, XInitialization, XServiceInfo >
69 friend class SplashScreenWindow;
74 virtual ~SplashScreen()
override;
77 void SetScreenBitmap(
BitmapEx &rBitmap);
78 static void determineProgressRatioValues(
double& rXRelPos,
double& rYRelPos,
double& rRelWidth,
double& rRelHeight );
81 Color _cProgressFrameColor;
82 Color _cProgressBarColor;
83 Color _cProgressTextColor;
84 bool _bNativeProgress;
86 OUString _sProgressText;
93 bool _bFullScreenSplash;
97 double _fXPos, _fYPos;
98 double _fWidth, _fHeight;
99 static constexpr tools::Long _xoffset = 12, _yoffset = 18;
105 virtual void SAL_CALL
end()
override;
106 virtual void SAL_CALL reset()
override;
107 virtual void SAL_CALL setText(
const OUString& aText)
override;
109 virtual void SAL_CALL
start(
const OUString& aText, sal_Int32 nRange)
override;
112 virtual void SAL_CALL initialize(
const css::uno::Sequence< css::uno::Any>&
aArguments )
override;
115 {
return "com.sun.star.office.comp.SplashScreen"; }
121 {
return {
"com.sun.star.office.SplashScreen" }; }
124SplashScreenWindow::SplashScreenWindow(SplashScreen *pSplash)
128 _vdev->EnableRTL(IsRTLEnabled());
131void SplashScreenWindow::dispose()
134 IntroWindow::dispose();
137void SplashScreenWindow::Redraw()
143 GetOutDev()->Flush();
146SplashScreen::SplashScreen()
151 , _bNativeProgress(
true)
154 , _bPaintProgress(
false)
157 , _bFullScreenSplash(
false)
158 , _bProgressEnd(
false)
175SplashScreen::~SplashScreen()
178 LINK(
this, SplashScreen, AppEventListenerHdl ) );
180 pWindow.disposeAndClear();
183void SAL_CALL SplashScreen::start(
const OUString&, sal_Int32 nRange)
187 _bProgressEnd =
false;
194void SAL_CALL SplashScreen::end()
201 _bProgressEnd =
true;
204void SAL_CALL SplashScreen::reset()
207 if (_bVisible && !_bProgressEnd )
214void SAL_CALL SplashScreen::setText(
const OUString& rText)
217 if ( _sProgressText != rText )
219 _sProgressText = rText;
221 if (_bVisible && !_bProgressEnd)
229void SAL_CALL SplashScreen::setValue(sal_Int32
nValue)
234 if (_bVisible && !_bProgressEnd) {
246SplashScreen::initialize(
const css::uno::Sequence< css::uno::Any>&
aArguments )
249 std::lock_guard aGuard(
aMutex );
259 SetScreenBitmap (_aIntroBmp);
260 Size aSize = _aIntroBmp.GetSizePixel();
261 pWindow->SetOutputSizePixel( aSize );
262 pWindow->_vdev->SetOutputSizePixel( aSize );
264 _width = aSize.
Width();
267 Point xtopleft(212,216);
281 _barwidth = _width - (2 * _xoffset);
287 _tly = _height - _yoffset;
292 _textBaseline = _height;
301 _cProgressBarColor =
Color( 157, 202, 18 );
310 LINK(
this, SplashScreen, AppEventListenerHdl ) );
313void SplashScreen::updateStatus()
315 if (!_bVisible || _bProgressEnd)
317 if (!_bPaintProgress)
318 _bPaintProgress =
true;
327 switch ( inEvent.GetId() )
329 case VclEventId::WindowShow:
339OUString implReadBootstrapKey(
const OUString& _rKey )
342 rtl::Bootstrap::get(_rKey, sValue);
346void SplashScreen::loadConfig()
348 _bShowLogo = implReadBootstrapKey(
"Logo" ) !=
"0";
350 OUString sProgressFrameColor = implReadBootstrapKey(
"ProgressFrameColor" );
351 OUString sProgressBarColor = implReadBootstrapKey(
"ProgressBarColor" );
352 OUString sProgressTextColor = implReadBootstrapKey(
"ProgressTextColor" );
353 OUString sProgressTextBaseline = implReadBootstrapKey(
"ProgressTextBaseline" );
354 OUString sSize = implReadBootstrapKey(
"ProgressSize" );
355 OUString sPosition = implReadBootstrapKey(
"ProgressPosition" );
356 OUString sFullScreenSplash = implReadBootstrapKey(
"FullScreenSplash" );
357 OUString sNativeProgress = implReadBootstrapKey(
"NativeProgress" );
361 _bFullScreenSplash = (( !sFullScreenSplash.isEmpty() ) &&
362 ( sFullScreenSplash !=
"0" ));
366 if ( _bFullScreenSplash )
367 determineProgressRatioValues( _fXPos, _fYPos, _fWidth, _fHeight );
369 if ( !sProgressFrameColor.isEmpty() )
383 _cProgressFrameColor =
Color( nRed, nGreen, nBlue );
387 if ( !sProgressBarColor.isEmpty() )
401 _cProgressBarColor =
Color( nRed, nGreen, nBlue );
405 if ( !sProgressTextColor.isEmpty() )
419 _cProgressTextColor =
Color( nRed, nGreen, nBlue );
423 if ( !sProgressTextBaseline.isEmpty() )
425 _textBaseline = sProgressTextBaseline.toInt32();
428 if( !sNativeProgress.isEmpty() )
430 _bNativeProgress = sNativeProgress.toBoolean();
433 if ( !sSize.isEmpty() )
444 if ( _barheight >= 10 )
447 if ( !sPosition.isEmpty() )
459void SplashScreen::SetScreenBitmap(
BitmapEx &rBitmap)
461 sal_Int32 nWidth( 0 );
462 sal_Int32 nHeight( 0 );
475 OUString aResBuf =
"_" + OUString::number(nWidth) +
"x" + OUString::number(nHeight);
476 if ( !_sAppName.isEmpty() )
486void SplashScreen::determineProgressRatioValues(
487 double& rXRelPos,
double& rYRelPos,
488 double& rRelWidth,
double& rRelHeight )
490 sal_Int32 nScreenRatio( 0 );
498 sal_Int32 nWidth = aScreenArea.
GetWidth();
499 sal_Int32 nHeight = aScreenArea.
GetHeight();
500 nScreenRatio = nHeight ? sal_Int32( rtl::math::round(
double( nWidth ) /
double( nHeight ), 2 ) * 100 ) : 0;
503 char szFullScreenProgressRatio[] =
"FullScreenProgressRatio0";
504 char szFullScreenProgressPos[] =
"FullScreenProgressPos0";
505 char szFullScreenProgressSize[] =
"FullScreenProgressSize0";
506 for ( sal_Int32
i = 0;
i <= 9;
i++ )
508 char cNum =
'0' + char(
i );
509 szFullScreenProgressRatio[23] = cNum;
510 szFullScreenProgressPos[21] = cNum;
511 szFullScreenProgressSize[22] = cNum;
513 OUString sFullScreenProgressRatio = implReadBootstrapKey(
514 OUString::createFromAscii( szFullScreenProgressRatio ) );
516 if ( !sFullScreenProgressRatio.isEmpty() )
518 double fRatio = sFullScreenProgressRatio.toDouble();
519 sal_Int32 nRatio = sal_Int32( rtl::math::round( fRatio, 2 ) * 100 );
520 if ( nRatio == nScreenRatio )
522 OUString sFullScreenProgressPos = implReadBootstrapKey(
523 OUString::createFromAscii( szFullScreenProgressPos ) );
524 OUString sFullScreenProgressSize = implReadBootstrapKey(
525 OUString::createFromAscii( szFullScreenProgressSize ) );
527 if ( !sFullScreenProgressPos.isEmpty() )
538 if ( !sFullScreenProgressSize.isEmpty() )
557 if (!pSpl || !pSpl->_bVisible)
562 if (pSpl->_bNativeProgress && rRenderContext.
IsNativeControlSupported(ControlType::IntroProgress, ControlPart::Entire))
571 ControlState::ENABLED, aValue,
572 aNativeControlRegion, aNativeContentRegion))
575 aDrawRect.
AdjustTop( -((nProgressHeight - pSpl->_barheight)/2) );
576 aDrawRect.
AdjustBottom((nProgressHeight - pSpl->_barheight)/2 );
579 if (rRenderContext.
DrawNativeControl(ControlType::IntroProgress, ControlPart::Entire, aDrawRect,
580 ControlState::ENABLED, aValue, pSpl->_sProgressText))
588 _vdev->DrawBitmapEx(
Point(), pSpl->_aIntroBmp);
590 if (pSpl->_bPaintProgress) {
592 tools::Long length = (pSpl->_iProgress * pSpl->_barwidth / pSpl->_iMax) - (2 * pSpl->_barspace);
596 _vdev->SetFillColor();
597 _vdev->SetLineColor( pSpl->_cProgressFrameColor );
598 _vdev->DrawRect(
tools::Rectangle(pSpl->_tlx, pSpl->_tly, pSpl->_tlx+pSpl->_barwidth, pSpl->_tly+pSpl->_barheight));
599 _vdev->SetFillColor( pSpl->_cProgressBarColor );
600 _vdev->SetLineColor();
601 _vdev->DrawRect(
tools::Rectangle(pSpl->_tlx+pSpl->_barspace, pSpl->_tly+pSpl->_barspace, pSpl->_tlx+pSpl->_barspace+
length, pSpl->_tly+pSpl->_barheight-pSpl->_barspace));
605 _vdev->SetFont(aFont);
606 _vdev->SetTextColor(pSpl->_cProgressTextColor);
607 _vdev->DrawText(
Point(pSpl->_tlx, pSpl->_textBaseline), pSpl->_sProgressText);
609 rRenderContext.
DrawOutDev(
Point(), GetOutputSizePixel(),
Point(), _vdev->GetOutputSizePixel(), *_vdev);
614extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
616 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any>
const&)
618 return cppu::acquire(
new SplashScreen());
static void AddEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
static unsigned int GetScreenCount()
static bool LoadBrandBitmap(std::u16string_view pName, BitmapEx &rBitmap)
static tools::Rectangle GetScreenPosSizePixel(unsigned int nScreen)
static void RemoveEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor=COL_AUTO)
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
constexpr tools::Long Y() const
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetFontSize(const Size &)
void SetAlignment(TextAlign)
constexpr ::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
constexpr ::Color COL_BLUE(0x00, 0x00, 0x80)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
Sequence< PropertyValue > aArguments
#define LINK(Instance, Class, Member)
#define SAL_INFO(area, stream)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
IMPL_LINK(ExtMgrDialog, startProgress, void *, _bLockInterface, void)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
double toDouble(std::u16string_view str)
RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey, rtl_uString *keyName, RegValueType valueType, RegValue pData, sal_uInt32 valueSize)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * desktop_SplashScreen_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)