diff options
Diffstat (limited to 'uui/source/iahndl.cxx')
-rw-r--r-- | uui/source/iahndl.cxx | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx index d136f047c3f3..7bee920262cf 100644 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -961,11 +961,35 @@ executeMessageBox( vcl::Window * pParent, OUString const & rTitle, OUString const & rMessage, - MessBoxStyle nButtonMask ) + MessBoxStyle nButtonMask, + Dialog::InitFlag eInitFlag) { SolarMutexGuard aGuard; + WinBits nStyle(0); - ScopedVclPtrInstance< MessBox > xBox(pParent, nButtonMask, rTitle, rMessage); + ScopedVclPtrInstance< MessBox > xBox(pParent, nButtonMask, nStyle, rTitle, rMessage, eInitFlag); + + if (Dialog::InitFlag::NoParentCentered == eInitFlag) + { + vcl::Window* pDefaultParent = Dialog::GetDefaultParent(nStyle); + + if (pDefaultParent) + { + // need to 'Show' to have the following tasks do someting, does + // not work without and may even stumble on nullptrs/errors + xBox->Show(); + + // center on parent window + const Point aP(pDefaultParent->GetPosPixel()); + const Size aS(pDefaultParent->GetSizePixel()); + const Size aMySize(xBox->GetSizePixel()); + + xBox->SetPosPixel( + Point( + aP.X() + ((aS.Width() - aMySize.Width()) >> 1), + aP.Y() + ((aS.Height() - aMySize.Height()) >> 1))); + } + } sal_uInt16 aMessResult = xBox->Execute(); DialogMask aResult = DialogMask::NONE; @@ -1110,7 +1134,7 @@ UUIInteractionHelper::handleGenericErrorRequest( aTitle += aErrTitle; executeMessageBox( - getParentProperty(), aTitle, aErrorString, MessBoxStyle::Ok ); + getParentProperty(), aTitle, aErrorString, MessBoxStyle::Ok, Dialog::InitFlag::NoParentCentered); } else ErrorHandler::HandleError(nErrorCode); @@ -1226,7 +1250,7 @@ UUIInteractionHelper::handleBrokenPackageRequest( utl::ConfigManager::getProductVersion() ); switch ( - executeMessageBox( getParentProperty(), title, aMessage, nButtonMask ) ) + executeMessageBox( getParentProperty(), title, aMessage, nButtonMask, Dialog::InitFlag::NoParentCentered) ) { case DialogMask::ButtonsOk: OSL_ENSURE( xAbort.is(), "unexpected situation" ); |