weld OSQLMessageBox
Change-Id: Idbdb07bc342a91695d15ea1a87d1863798ca34b0
Reviewed-on: https://gerrit.libreoffice.org/51676
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/dbaccess/source/ui/app/AppControllerDnD.cxx b/dbaccess/source/ui/app/AppControllerDnD.cxx
index 7012171d..342de47 100644
--- a/dbaccess/source/ui/app/AppControllerDnD.cxx
+++ b/dbaccess/source/ui/app/AppControllerDnD.cxx
@@ -120,7 +120,7 @@ void OApplicationController::deleteTables(const std::vector< OUString>& _rList)
sal_Int32 nResult = RET_YES;
if ( bConfirm )
nResult = ::dbaui::askForUserAction(getView(),STR_TITLE_CONFIRM_DELETION ,STR_QUERY_DELETE_TABLE,_rList.size() > 1 && (aIter+1) != _rList.end(),sTableName);
nResult = ::dbaui::askForUserAction(getFrameWeld(), STR_TITLE_CONFIRM_DELETION, STR_QUERY_DELETE_TABLE, _rList.size() > 1 && (aIter+1) != _rList.end(), sTableName);
bool bUserConfirmedDelete =
( RET_YES == nResult )
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx
index 65fded7..d6c6415 100644
--- a/dbaccess/source/ui/browser/brwctrlr.cxx
+++ b/dbaccess/source/ui/browser/brwctrlr.cxx
@@ -1259,8 +1259,8 @@ IMPL_LINK_NOARG( SbaXDataBrowserController, OnAsyncDisplayError, void*, void )
{
if ( m_aCurrentError.isValid() )
{
ScopedVclPtrInstance< OSQLMessageBox > aDlg( getBrowserView(), m_aCurrentError );
aDlg->Execute();
OSQLMessageBox aDlg(getFrameWeld(), m_aCurrentError);
aDlg.run();
}
}
diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.cxx b/dbaccess/source/ui/dlg/ConnectionHelper.cxx
index 50c3c9d..e2c0f4c 100644
--- a/dbaccess/source/ui/dlg/ConnectionHelper.cxx
+++ b/dbaccess/source/ui/dlg/ConnectionHelper.cxx
@@ -694,7 +694,8 @@ namespace dbaui
{
OUString sFile = DBA_RES( STR_FILE_DOES_NOT_EXIST );
sFile = sFile.replaceFirst("$file$", aTransformer.get(OFileNotation::N_SYSTEM));
ScopedVclPtrInstance<OSQLWarningBox>(this, sFile)->Execute();
OSQLWarningBox aWarning(GetFrameWeld(), sFile);
aWarning.run();
setURLNoPrefix(sOldPath);
SetRoadmapStateValue(false);
callModifiedHdl();
diff --git a/dbaccess/source/ui/dlg/ConnectionPage.cxx b/dbaccess/source/ui/dlg/ConnectionPage.cxx
index d0e72c7..670c399 100644
--- a/dbaccess/source/ui/dlg/ConnectionPage.cxx
+++ b/dbaccess/source/ui/dlg/ConnectionPage.cxx
@@ -306,9 +306,9 @@ namespace dbaui
#endif
const char* pMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
const OSQLMessageBox::MessageType mt = bSuccess ? OSQLMessageBox::Info : OSQLMessageBox::Error;
ScopedVclPtrInstance< OSQLMessageBox > aMsg( this, DBA_RES(pMessage), OUString(), MessBoxStyle::Ok | MessBoxStyle::DefaultOk, mt );
aMsg->Execute();
const MessageType mt = bSuccess ? MessageType::Info : MessageType::Error;
OSQLMessageBox aMsg(GetFrameWeld(), DBA_RES(pMessage), OUString(), MessBoxStyle::Ok | MessBoxStyle::DefaultOk, mt);
aMsg.run();
}
bool OConnectionTabPage::checkTestConnection()
{
diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
index 99a5d3a..4cdb117 100644
--- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
+++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
@@ -554,9 +554,9 @@ using namespace ::com::sun::star;
}
#endif
const char *pMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
const OSQLMessageBox::MessageType mt = bSuccess ? OSQLMessageBox::Info : OSQLMessageBox::Error;
ScopedVclPtrInstance<OSQLMessageBox> aMsg(this, DBA_RES(pMessage), OUString(), MessBoxStyle::Ok | MessBoxStyle::DefaultOk, mt);
aMsg->Execute();
const MessageType mt = bSuccess ? MessageType::Info : MessageType::Error;
OSQLMessageBox aMsg(GetFrameWeld(), DBA_RES(pMessage), OUString(), MessBoxStyle::Ok | MessBoxStyle::DefaultOk, mt);
aMsg.run();
}
void OGeneralSpecialJDBCConnectionPageSetup::callModifiedHdl(void* pControl)
@@ -675,8 +675,8 @@ using namespace ::com::sun::star;
}
#endif
const char* pMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
ScopedVclPtrInstance<OSQLMessageBox> aMsg(this, DBA_RES(pMessage), OUString());
aMsg->Execute();
OSQLMessageBox aMsg(GetFrameWeld(), DBA_RES(pMessage), OUString());
aMsg.run();
}
IMPL_LINK(OJDBCConnectionPageSetup, OnEditModified, Edit&, _rEdit, void)
diff --git a/dbaccess/source/ui/dlg/adminpages.cxx b/dbaccess/source/ui/dlg/adminpages.cxx
index 486a818..520045f 100644
--- a/dbaccess/source/ui/dlg/adminpages.cxx
+++ b/dbaccess/source/ui/dlg/adminpages.cxx
@@ -253,7 +253,7 @@ namespace dbaui
}
if ( bShowMessage )
{
OSQLMessageBox::MessageType eImage = OSQLMessageBox::Info;
MessageType eImage = MessageType::Info;
OUString aMessage,sTitle;
sTitle = DBA_RES(STR_CONNECTION_TEST);
if ( bSuccess )
@@ -262,11 +262,11 @@ namespace dbaui
}
else
{
eImage = OSQLMessageBox::Error;
eImage = MessageType::Error;
aMessage = DBA_RES(STR_CONNECTION_NO_SUCCESS);
}
ScopedVclPtrInstance< OSQLMessageBox > aMsg( this, sTitle, aMessage, MessBoxStyle::Ok, eImage );
aMsg->Execute();
OSQLMessageBox aMsg(GetFrameWeld(), sTitle, aMessage, MessBoxStyle::Ok, eImage);
aMsg.run();
}
if ( !bSuccess )
m_pAdminDialog->clearPassword();
diff --git a/dbaccess/source/ui/dlg/detailpages.cxx b/dbaccess/source/ui/dlg/detailpages.cxx
index db0e881..cc3fba2 100644
--- a/dbaccess/source/ui/dlg/detailpages.cxx
+++ b/dbaccess/source/ui/dlg/detailpages.cxx
@@ -540,10 +540,11 @@ namespace dbaui
}
#endif
const char* pMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
const OSQLMessageBox::MessageType mt = bSuccess ? OSQLMessageBox::Info : OSQLMessageBox::Error;
ScopedVclPtrInstance<OSQLMessageBox> aMsg(this, DBA_RES(pMessage), OUString(), MessBoxStyle::Ok | MessBoxStyle::DefaultOk, mt);
aMsg->Execute();
const MessageType mt = bSuccess ? MessageType::Info : MessageType::Error;
OSQLMessageBox aMsg(GetFrameWeld(), DBA_RES(pMessage), OUString(), MessBoxStyle::Ok | MessBoxStyle::DefaultOk, mt);
aMsg.run();
}
void OGeneralSpecialJDBCDetailsPage::callModifiedHdl(void* pControl)
{
if ( m_bUseClass && pControl == m_pEDDriverClass )
diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx
index f85b1b3..3df70af3 100644
--- a/dbaccess/source/ui/dlg/sqlmessage.cxx
+++ b/dbaccess/source/ui/dlg/sqlmessage.cxx
@@ -24,8 +24,11 @@
#include <bitmaps.hlst>
#include <com/sun/star/sdbc/SQLException.hpp>
#include <com/sun/star/sdb/SQLContext.hpp>
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>
#include <vcl/weld.hxx>
#include <vcl/svapp.hxx>
#include <osl/diagnose.h>
#include <svtools/treelistbox.hxx>
#include <svtools/treelistentry.hxx>
@@ -40,12 +43,6 @@
#define RET_MORE RET_RETRY + 1
#define DIALOG_WIDTH 220
#define OUTER_MARGIN 6
#define IMAGE_SIZE 20
#define INNER_PADDING 3
#define TEXT_POS_X ( OUTER_MARGIN + IMAGE_SIZE + INNER_PADDING )
using namespace dbtools;
using namespace com::sun::star::uno;
using namespace com::sun::star::sdb;
@@ -371,35 +368,47 @@ struct SQLMessageBox_Impl
namespace
{
void lcl_positionInAppFont( const vcl::Window& _rParent, vcl::Window& _rChild, long _nX, long _nY, long Width, long Height )
{
Point aPos = _rParent.LogicToPixel(Point(_nX, _nY), MapMode(MapUnit::MapAppFont));
Size aSize = _rParent.LogicToPixel(Size(Width, Height), MapMode(MapUnit::MapAppFont));
_rChild.SetPosSizePixel( aPos, aSize );
}
void lcl_addButton( ButtonDialog& _rDialog, StandardButtonType _eType, bool _bDefault )
void lcl_addButton(weld::MessageDialog* pDialog, StandardButtonType eType, bool bDefault)
{
sal_uInt16 nButtonID = 0;
switch ( _eType )
switch (eType)
{
case StandardButtonType::Yes: nButtonID = RET_YES; break;
case StandardButtonType::No: nButtonID = RET_NO; break;
case StandardButtonType::OK: nButtonID = RET_OK; break;
case StandardButtonType::Cancel: nButtonID = RET_CANCEL; break;
case StandardButtonType::Retry: nButtonID = RET_RETRY; break;
case StandardButtonType::Help: nButtonID = RET_HELP; break;
default:
OSL_FAIL( "lcl_addButton: invalid button id!" );
break;
case StandardButtonType::Yes:
nButtonID = RET_YES;
pDialog->add_button(Button::GetStandardText(StandardButtonType::Yes), nButtonID);
break;
case StandardButtonType::No:
nButtonID = RET_NO;
pDialog->add_button(Button::GetStandardText(StandardButtonType::No), nButtonID);
break;
case StandardButtonType::OK:
nButtonID = RET_OK;
pDialog->add_button(Button::GetStandardText(StandardButtonType::OK), nButtonID);
break;
case StandardButtonType::Cancel:
nButtonID = RET_CANCEL;
pDialog->add_button(Button::GetStandardText(StandardButtonType::Cancel), nButtonID);
break;
case StandardButtonType::Retry:
nButtonID = RET_RETRY;
pDialog->add_button(Button::GetStandardText(StandardButtonType::Retry), nButtonID);
break;
case StandardButtonType::Help:
nButtonID = RET_HELP;
pDialog->add_button(Button::GetStandardText(StandardButtonType::Help), nButtonID);
break;
default:
OSL_FAIL( "lcl_addButton: invalid button id!" );
break;
}
_rDialog.AddButton( _eType, nButtonID, _bDefault ? ButtonDialogFlags::Default | ButtonDialogFlags::Focus : ButtonDialogFlags::NONE );
if (bDefault)
pDialog->set_default_response(nButtonID);
}
}
void OSQLMessageBox::impl_positionControls()
void OSQLMessageBox::impl_fillMessages()
{
OSL_PRECOND( !m_pImpl->aDisplayInfo.empty(), "OSQLMessageBox::impl_positionControls: nothing to display at all?" );
OSL_PRECOND( !m_pImpl->aDisplayInfo.empty(), "OSQLMessageBox::impl_fillMessages: nothing to display at all?" );
if ( m_pImpl->aDisplayInfo.empty() )
return;
@@ -427,107 +436,44 @@ void OSQLMessageBox::impl_positionControls()
sSecondary = pSecondInfo->sMessage;
}
// image
lcl_positionInAppFont( *this, *m_aInfoImage.get(), OUTER_MARGIN, OUTER_MARGIN, IMAGE_SIZE, IMAGE_SIZE );
m_aInfoImage->Show();
// primary text
lcl_positionInAppFont( *this, *m_aTitle.get(), TEXT_POS_X, OUTER_MARGIN, DIALOG_WIDTH - TEXT_POS_X - 2 * OUTER_MARGIN, 16 );
sPrimary = lcl_stripOOoBaseVendor( sPrimary );
m_aTitle->SetText( sPrimary );
m_aTitle->Show();
tools::Rectangle aPrimaryRect( m_aTitle->GetPosPixel(), m_aTitle->GetSizePixel() );
m_xDialog->set_primary_text(lcl_stripOOoBaseVendor(sPrimary));
// secondary text (if applicable)
m_aMessage->SetStyle( m_aMessage->GetStyle() | WB_NOLABEL );
sSecondary = lcl_stripOOoBaseVendor( sSecondary );
m_aMessage->SetText( sSecondary );
lcl_positionInAppFont( *this, *m_aMessage.get(), TEXT_POS_X, OUTER_MARGIN + 16 + 3, DIALOG_WIDTH - TEXT_POS_X - 2 * OUTER_MARGIN, 8 );
tools::Rectangle aSecondaryRect( m_aMessage->GetPosPixel(), m_aMessage->GetSizePixel() );
bool bHaveSecondaryText = !sSecondary.isEmpty();
// determine which space the secondary text would occupy
if ( bHaveSecondaryText )
aSecondaryRect = GetTextRect( aSecondaryRect, sSecondary, DrawTextFlags::WordBreak | DrawTextFlags::MultiLine | DrawTextFlags::Left );
else
aSecondaryRect.SetBottom( aSecondaryRect.Top() - 1 );
// adjust secondary control height accordingly
m_aMessage->SetSizePixel( aSecondaryRect.GetSize() );
m_aMessage->Show( aSecondaryRect.GetHeight() > 0 );
// if there's no secondary text ...
if ( !bHaveSecondaryText )
{ // then give the primary text as much horizontal space as it needs
tools::Rectangle aSuggestedRect( GetTextRect( aPrimaryRect, sPrimary, DrawTextFlags::WordBreak | DrawTextFlags::MultiLine | DrawTextFlags::Center ) );
aPrimaryRect.SetRight( aPrimaryRect.Left() + aSuggestedRect.GetWidth() );
aPrimaryRect.SetBottom( aPrimaryRect.Top() + aSuggestedRect.GetHeight() );
// and center it horizontally
m_aTitle->SetStyle( ( m_aTitle->GetStyle() & ~WB_LEFT ) | WB_CENTER );
tools::Rectangle aInfoRect( m_aInfoImage->GetPosPixel(), m_aInfoImage->GetSizePixel() );
// also, if it's not as high as the image ...
if ( aPrimaryRect.GetHeight() < m_aInfoImage->GetSizePixel().Height() )
{ // ... make it fit the image height
aPrimaryRect.AdjustBottom(aInfoRect.GetHeight() - aPrimaryRect.GetHeight() );
// and center it vertically
m_aTitle->SetStyle( m_aTitle->GetStyle() | WB_VCENTER );
}
else
{ // ... otherwise, center the image vertically, relative to the primary text
aInfoRect.Move( 0, ( aPrimaryRect.GetHeight() - aInfoRect.GetHeight() ) / 2 );
m_aInfoImage->SetPosSizePixel( aInfoRect.TopLeft(), aInfoRect.GetSize() );
}
m_aTitle->SetPosSizePixel( aPrimaryRect.TopLeft(), aPrimaryRect.GetSize() );
}
// adjust dialog size accordingly
const tools::Rectangle& rBottomTextRect( bHaveSecondaryText ? aSecondaryRect : aPrimaryRect );
Size aBorderSize = LogicToPixel(Size(OUTER_MARGIN, OUTER_MARGIN), MapMode(MapUnit::MapAppFont));
Size aDialogSize( LogicToPixel(Size(DIALOG_WIDTH, 30), MapMode(MapUnit::MapAppFont)));
aDialogSize.setHeight( rBottomTextRect.Bottom() + aBorderSize.Height() );
aDialogSize.setWidth( aPrimaryRect.Right() + aBorderSize.Width() );
SetSizePixel( aDialogSize );
SetPageSizePixel( aDialogSize );
m_xDialog->set_secondary_text(lcl_stripOOoBaseVendor(sSecondary));
}
void OSQLMessageBox::impl_createStandardButtons( MessBoxStyle _nStyle )
{
if ( _nStyle & MessBoxStyle::YesNoCancel )
{
lcl_addButton( *this, StandardButtonType::Yes, bool(_nStyle & MessBoxStyle::DefaultYes) );
lcl_addButton( *this, StandardButtonType::No, bool( _nStyle & MessBoxStyle::DefaultNo ) );
lcl_addButton( *this, StandardButtonType::Cancel, bool( _nStyle & MessBoxStyle::DefaultCancel ) );
lcl_addButton(m_xDialog.get(), StandardButtonType::Yes, bool(_nStyle & MessBoxStyle::DefaultYes));
lcl_addButton(m_xDialog.get(), StandardButtonType::No, bool(_nStyle & MessBoxStyle::DefaultNo));
lcl_addButton(m_xDialog.get(), StandardButtonType::Cancel, bool(_nStyle & MessBoxStyle::DefaultCancel));
}
else if ( _nStyle & MessBoxStyle::OkCancel )
{
lcl_addButton( *this, StandardButtonType::OK, bool( _nStyle & MessBoxStyle::DefaultOk ) );
lcl_addButton( *this, StandardButtonType::Cancel, bool( _nStyle & MessBoxStyle::DefaultCancel ) );
lcl_addButton(m_xDialog.get(), StandardButtonType::OK, bool(_nStyle & MessBoxStyle::DefaultOk));
lcl_addButton(m_xDialog.get(), StandardButtonType::Cancel, bool(_nStyle & MessBoxStyle::DefaultCancel));
}
else if ( _nStyle & MessBoxStyle::YesNo )
{
lcl_addButton( *this, StandardButtonType::Yes, bool( _nStyle & MessBoxStyle::DefaultYes ) );
lcl_addButton( *this, StandardButtonType::No, bool( _nStyle & MessBoxStyle::DefaultNo ) );
lcl_addButton(m_xDialog.get(), StandardButtonType::Yes, bool(_nStyle & MessBoxStyle::DefaultYes));
lcl_addButton(m_xDialog.get(), StandardButtonType::No, bool(_nStyle & MessBoxStyle::DefaultNo));
}
else if ( _nStyle & MessBoxStyle::RetryCancel )
{
lcl_addButton( *this, StandardButtonType::Retry, bool( _nStyle & MessBoxStyle::DefaultRetry ) );
lcl_addButton( *this, StandardButtonType::Cancel, bool( _nStyle & MessBoxStyle::DefaultCancel ) );
lcl_addButton(m_xDialog.get(), StandardButtonType::Retry, bool(_nStyle & MessBoxStyle::DefaultRetry));
lcl_addButton(m_xDialog.get(), StandardButtonType::Cancel, bool(_nStyle & MessBoxStyle::DefaultCancel));
}
else
else if ( _nStyle & MessBoxStyle::Ok )
{
OSL_ENSURE( MessBoxStyle::Ok & _nStyle, "OSQLMessageBox::impl_createStandardButtons: unsupported dialog style requested!" );
AddButton( StandardButtonType::OK, RET_OK, ButtonDialogFlags::Default | ButtonDialogFlags::Focus );
lcl_addButton(m_xDialog.get(), StandardButtonType::OK, true);
}
if ( !m_sHelpURL.isEmpty() )
{
lcl_addButton( *this, StandardButtonType::Help, false );
lcl_addButton(m_xDialog.get(), StandardButtonType::Help, false);
OUString aTmp;
INetURLObject aHID( m_sHelpURL );
@@ -536,13 +482,13 @@ void OSQLMessageBox::impl_createStandardButtons( MessBoxStyle _nStyle )
else
aTmp = m_sHelpURL;
SetHelpId( OUStringToOString( aTmp, RTL_TEXTENCODING_UTF8 ) );
m_xDialog->set_help_id(OUStringToOString(aTmp, RTL_TEXTENCODING_UTF8));
}
}
void OSQLMessageBox::impl_addDetailsButton()
{
size_t nFirstPageVisible = m_aMessage->IsVisible() ? 2 : 1;
size_t nFirstPageVisible = m_xDialog->get_secondary_text().isEmpty() ? 1 : 2;
bool bMoreDetailsAvailable = m_pImpl->aDisplayInfo.size() > nFirstPageVisible;
if ( !bMoreDetailsAvailable )
@@ -561,20 +507,14 @@ void OSQLMessageBox::impl_addDetailsButton()
if ( bMoreDetailsAvailable )
{
AddButton( StandardButtonType::More, RET_MORE);
PushButton* pButton = GetPushButton( RET_MORE );
OSL_ENSURE( pButton, "OSQLMessageBox::impl_addDetailsButton: just added this button, why isn't it there?" );
pButton->SetClickHdl( LINK( this, OSQLMessageBox, ButtonClickHdl ) );
m_xDialog->add_button(Button::GetStandardText(StandardButtonType::More), RET_MORE);
m_xMoreButton.reset(m_xDialog->get_widget_for_response(RET_MORE));
m_xMoreButton->connect_clicked(LINK(this, OSQLMessageBox, ButtonClickHdl));
}
}
void OSQLMessageBox::Construct( MessBoxStyle _nStyle, MessageType _eImage )
void OSQLMessageBox::Construct(weld::Window* pParent, MessBoxStyle _nStyle, MessageType _eImage)
{
SetText( utl::ConfigManager::getProductName() + " Base" );
// position and size the controls and the dialog, depending on whether we have one or two texts to display
impl_positionControls();
// init the image
MessageType eType( _eImage );
if ( eType == AUTO )
@@ -587,87 +527,77 @@ void OSQLMessageBox::Construct( MessBoxStyle _nStyle, MessageType _eImage )
default: OSL_FAIL( "OSQLMessageBox::Construct: invalid type!" );
}
}
VclMessageType eMessageType;
switch (eType)
{
default:
OSL_FAIL( "OSQLMessageBox::impl_initImage: unsupported image type!" );
SAL_FALLTHROUGH;
case Info:
m_aInfoImage->SetImage(GetStandardInfoBoxImage());
eMessageType = VclMessageType::Info;
break;
case Warning:
m_aInfoImage->SetImage(GetStandardWarningBoxImage());
eMessageType = VclMessageType::Warning;
break;
case Error:
m_aInfoImage->SetImage(GetStandardErrorBoxImage());
eMessageType = VclMessageType::Error;
break;
case Query:
m_aInfoImage->SetImage(GetStandardQueryBoxImage());
eMessageType = VclMessageType::Question;
break;
}
m_xDialog.reset(Application::CreateMessageDialog(pParent, eMessageType, VclButtonsType::NONE, ""));
m_xDialog->set_title(utl::ConfigManager::getProductName() + " Base");
impl_fillMessages();
// create buttons
impl_createStandardButtons( _nStyle );
impl_addDetailsButton();
}
OSQLMessageBox::OSQLMessageBox(vcl::Window* _pParent, const SQLExceptionInfo& _rException, MessBoxStyle _nStyle, const OUString& _rHelpURL )
:ButtonDialog( _pParent, WB_HORZ | WB_STDDIALOG )
,m_aInfoImage( VclPtr<FixedImage>::Create(this) )
,m_aTitle( VclPtr<FixedText>::Create(this, WB_WORDBREAK | WB_LEFT) )
,m_aMessage( VclPtr<FixedText>::Create(this, WB_WORDBREAK | WB_LEFT) )
,m_sHelpURL( _rHelpURL )
,m_pImpl( new SQLMessageBox_Impl( _rException ) )
OSQLMessageBox::OSQLMessageBox(weld::Window* pParent, const SQLExceptionInfo& rException, MessBoxStyle nStyle, const OUString& rHelpURL)
: m_pImpl(new SQLMessageBox_Impl(rException))
, m_sHelpURL(rHelpURL)
{
Construct( _nStyle, AUTO );
Construct(pParent, nStyle, AUTO);
}
OSQLMessageBox::OSQLMessageBox( vcl::Window* _pParent, const OUString& _rTitle, const OUString& _rMessage, MessBoxStyle _nStyle, MessageType _eType, const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo )
:ButtonDialog( _pParent, WB_HORZ | WB_STDDIALOG )
,m_aInfoImage( VclPtr<FixedImage>::Create(this) )
,m_aTitle( VclPtr<FixedText>::Create(this, WB_WORDBREAK | WB_LEFT) )
,m_aMessage( VclPtr<FixedText>::Create(this, WB_WORDBREAK | WB_LEFT) )
OSQLMessageBox::OSQLMessageBox(weld::Window* pParent, const OUString& rTitle, const OUString& rMessage, MessBoxStyle nStyle, MessageType eType, const ::dbtools::SQLExceptionInfo* pAdditionalErrorInfo )
{
SQLContext aError;
aError.Message = _rTitle;
aError.Details = _rMessage;
if ( _pAdditionalErrorInfo )
aError.NextException = _pAdditionalErrorInfo->get();
aError.Message = rTitle;
aError.Details = rMessage;
if (pAdditionalErrorInfo)
aError.NextException = pAdditionalErrorInfo->get();
m_pImpl.reset( new SQLMessageBox_Impl( SQLExceptionInfo( aError ) ) );
m_pImpl.reset(new SQLMessageBox_Impl(SQLExceptionInfo(aError)));
Construct( _nStyle, _eType );
Construct(pParent, nStyle, eType);
}
OSQLMessageBox::~OSQLMessageBox()
{
disposeOnce();
}
void OSQLMessageBox::dispose()
IMPL_LINK_NOARG(OSQLMessageBox, ButtonClickHdl, weld::Button&, void)
{
m_aInfoImage.disposeAndClear();
m_aTitle.disposeAndClear();
m_aMessage.disposeAndClear();
ButtonDialog::dispose();
}
IMPL_LINK_NOARG( OSQLMessageBox, ButtonClickHdl, Button *, void )
{
OExceptionChainDialog aDlg(GetFrameWeld(), m_pImpl->aDisplayInfo);
OExceptionChainDialog aDlg(m_xDialog.get(), m_pImpl->aDisplayInfo);
aDlg.run();
}
// OSQLWarningBox
OSQLWarningBox::OSQLWarningBox( vcl::Window* _pParent, const OUString& _rMessage, MessBoxStyle _nStyle,
const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo )
:OSQLMessageBox( _pParent, DBA_RES( STR_EXCEPTION_WARNING ), _rMessage, _nStyle, OSQLMessageBox::Warning, _pAdditionalErrorInfo )
OSQLWarningBox::OSQLWarningBox(weld::Window* pParent, const OUString& rMessage, MessBoxStyle nStyle,
const ::dbtools::SQLExceptionInfo* pAdditionalErrorInfo )
: OSQLMessageBox(pParent, DBA_RES(STR_EXCEPTION_WARNING), rMessage, nStyle, MessageType::Warning, pAdditionalErrorInfo)
{
}
// OSQLErrorBox
OSQLErrorBox::OSQLErrorBox( vcl::Window* _pParent, const OUString& _rMessage )
:OSQLMessageBox( _pParent, DBA_RES( STR_EXCEPTION_ERROR ), _rMessage, MessBoxStyle::Ok | MessBoxStyle::DefaultOk, OSQLMessageBox::Error, nullptr )
OSQLErrorBox::OSQLErrorBox(weld::Window* pParent, const OUString& rMessage)
: OSQLMessageBox(pParent, DBA_RES(STR_EXCEPTION_ERROR), rMessage, MessBoxStyle::Ok | MessBoxStyle::DefaultOk,
MessageType::Error, nullptr)
{
}
diff --git a/dbaccess/source/ui/dlg/tablespage.cxx b/dbaccess/source/ui/dlg/tablespage.cxx
index b890c08..a6011aa 100644
--- a/dbaccess/source/ui/dlg/tablespage.cxx
+++ b/dbaccess/source/ui/dlg/tablespage.cxx
@@ -309,8 +309,9 @@ namespace dbaui
if (aErrorInfo.isValid())
{
// establishing the connection failed. Show an error window and exit.
ScopedVclPtrInstance< OSQLMessageBox > aMessageBox( GetParentDialog(), aErrorInfo );
aMessageBox->Execute();
vcl::Window *pParent = GetParentDialog();
OSQLMessageBox aMessageBox(pParent ? pParent->GetFrameWeld() : nullptr, aErrorInfo);
aMessageBox.run();
m_pTables->Enable(false);
m_pTablesList->Clear();
diff --git a/dbaccess/source/ui/inc/UITools.hxx b/dbaccess/source/ui/inc/UITools.hxx
index 114e2ad..cd8e5a8 100644
--- a/dbaccess/source/ui/inc/UITools.hxx
+++ b/dbaccess/source/ui/inc/UITools.hxx
@@ -200,16 +200,16 @@ namespace dbaui
SvxCellHorJustify& _eJustify,
bool _bHasFormat);
/** append a name to tablefilter of a datasource
@param _xConnection the connection is need to get the datasource
@param _sName the name which should be appended
@param _rxContext needed to check if datasource is available
@param _pParent needed when an error must be shown
@param xConnection the connection is need to get the datasource
@param rName the name which should be appended
@param rxContext needed to check if datasource is available
@param pParent needed when an error must be shown
@return false when datsource is not available otherwise true
*/
bool appendToFilter(const css::uno::Reference< css::sdbc::XConnection>& _xConnection,
const OUString& _sName,
const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
vcl::Window* _pParent);
bool appendToFilter(const css::uno::Reference< css::sdbc::XConnection>& xConnection,
const OUString& rName,
const css::uno::Reference< css::uno::XComponentContext >& rxContext,
weld::Window* pParent);
/** notifySystemWindow adds or remove the given window _pToRegister at the Systemwindow found when search _pWindow.
@param _pWindow
@@ -307,21 +307,21 @@ namespace dbaui
*/
/** returns the result of the user action when view the query dialog.
@param _pParent
@param pParent
The parent of the dialog
@param pTitle
A string resource id for the text which will be displayed as title.
@param pText
A string resource id for the text which will be displayed above the buttons.
When the string contains a #1. This will be replaced by the name.
@param _bAll
@param bAll
When set to <TRUE/>, the all button will be appended.
@param _sName
@param rName
The name of the object to ask for.
@return
RET_YES, RET_NO, RET_ALL
*/
sal_Int32 askForUserAction(vcl::Window* _pParent, const char* pTitle, const char* pText, bool _bAll, const OUString& _sName);
sal_Int32 askForUserAction(weld::Window* pParent, const char* pTitle, const char* pText, bool bAll, const OUString& rName);
/** creates a new view from a query or table
@param _sName
diff --git a/dbaccess/source/ui/inc/sqlmessage.hxx b/dbaccess/source/ui/inc/sqlmessage.hxx
index e070185..0f8bbe4 100644
--- a/dbaccess/source/ui/inc/sqlmessage.hxx
+++ b/dbaccess/source/ui/inc/sqlmessage.hxx
@@ -20,13 +20,8 @@
#ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_SQLMESSAGE_HXX
#define INCLUDED_DBACCESS_SOURCE_UI_INC_SQLMESSAGE_HXX
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
#include <vcl/btndlg.hxx>
#include <vcl/msgbox.hxx>
#include <connectivity/dbexception.hxx>
#include <vcl/weld.hxx>
#include <memory>
// some forwards
@@ -42,28 +37,51 @@ namespace com { namespace sun { namespace star {
namespace dbaui
{
enum MessageType
{
Info,
Error,
Warning,
Query,
AUTO
};
enum class MessBoxStyle {
NONE = 0x0000,
Ok = 0x0001,
OkCancel = 0x0002,
YesNo = 0x0004,
YesNoCancel = 0x0008,
RetryCancel = 0x0010,
DefaultOk = 0x0020,
DefaultCancel = 0x0040,
DefaultRetry = 0x0080,
DefaultYes = 0x0100,
DefaultNo = 0x0200,
AbortRetryIgnore = 0x1000,
DefaultIgnore = 0x2000,
};
}
namespace o3tl {
template<> struct typed_flags<dbaui::MessBoxStyle> : is_typed_flags<dbaui::MessBoxStyle, 0x3fff> {};
}
namespace dbaui
{
// OSQLMessageBox
struct SQLMessageBox_Impl;
class OSQLMessageBox : public ButtonDialog
class OSQLMessageBox : public weld::DialogController
{
VclPtr<FixedImage> m_aInfoImage;
VclPtr<FixedText> m_aTitle;
VclPtr<FixedText> m_aMessage;
std::unique_ptr<weld::MessageDialog> m_xDialog;
std::unique_ptr<weld::Button> m_xMoreButton;
std::unique_ptr<SQLMessageBox_Impl> m_pImpl;
OUString m_sHelpURL;
std::unique_ptr< SQLMessageBox_Impl > m_pImpl;
public:
enum MessageType
{
Info,
Error,
Warning,
Query,
AUTO
};
virtual weld::Dialog* getDialog() override { return m_xDialog.get(); }
public:
/** display an SQLException with auto-recognizing a main and a detailed message
@@ -71,7 +89,7 @@ public:
detailed field of an <type scope="css::sdb">SQLContext</type>).
*/
OSQLMessageBox(
vcl::Window* _pParent,
weld::Window* pParent,
const dbtools::SQLExceptionInfo& _rException,
MessBoxStyle _nStyle = MessBoxStyle::Ok | MessBoxStyle::DefaultOk,
const OUString& _rHelpURL = OUString()
@@ -83,23 +101,26 @@ public:
@param rMessage the detailed message to display
@param _eType determines the image to use. AUTO is disallowed in this constructor version
*/
OSQLMessageBox(vcl::Window* pParent,
OSQLMessageBox(weld::Window* pParent,
const OUString& rTitle,
const OUString& rMessage,
MessBoxStyle nStyle = MessBoxStyle::Ok | MessBoxStyle::DefaultOk,
MessageType _eType = Info,
const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo = nullptr );
void set_title(const OUString& rTitle) { m_xDialog->set_title(rTitle); }
void add_button(const OUString& rText, int nResponse, const OString& rHelpId = OString()) { m_xDialog->add_button(rText, nResponse, rHelpId); }
void set_default_response(int nResponse) { m_xDialog->set_default_response(nResponse); }
virtual ~OSQLMessageBox() override;
virtual void dispose() override;
private:
void Construct( MessBoxStyle nStyle, MessageType eImage );
void Construct(weld::Window* pParent, MessBoxStyle nStyle, MessageType eImage);
DECL_LINK(ButtonClickHdl, Button*, void );
DECL_LINK(ButtonClickHdl, weld::Button&, void);
private:
void impl_positionControls();
void impl_fillMessages();
void impl_createStandardButtons( MessBoxStyle _nStyle );
void impl_addDetailsButton();
};
@@ -108,7 +129,7 @@ private:
class OSQLWarningBox : public OSQLMessageBox
{
public:
OSQLWarningBox( vcl::Window* _pParent,
OSQLWarningBox( weld::Window* pParent,
const OUString& _rMessage,
MessBoxStyle _nStyle = MessBoxStyle::Ok | MessBoxStyle::DefaultOk,
const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo = nullptr );
@@ -118,7 +139,7 @@ public:
class OSQLErrorBox : public OSQLMessageBox
{
public:
OSQLErrorBox( vcl::Window* _pParent,
OSQLErrorBox( weld::Window* pParent,
const OUString& _rMessage );
};
diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx
index 7127e8b..0977612 100644
--- a/dbaccess/source/ui/misc/DExport.cxx
+++ b/dbaccess/source/ui/misc/DExport.cxx
@@ -748,9 +748,9 @@ void ODatabaseExport::showErrorDialog(const css::sdbc::SQLException& e)
OUString aMsg = e.Message
+ "\n"
+ DBA_RES( STR_QRY_CONTINUE );
ScopedVclPtrInstance< OSQLWarningBox > aBox( nullptr, aMsg, MessBoxStyle::YesNo | MessBoxStyle::DefaultNo );
OSQLWarningBox aBox(nullptr, aMsg, MessBoxStyle::YesNo | MessBoxStyle::DefaultNo);
if (aBox->Execute() == RET_YES)
if (aBox.run() == RET_YES)
m_bDontAskAgain = true;
else
m_bError = true;
diff --git a/dbaccess/source/ui/misc/RowSetDrop.cxx b/dbaccess/source/ui/misc/RowSetDrop.cxx
index efbd212..cdf4ecb 100644
--- a/dbaccess/source/ui/misc/RowSetDrop.cxx
+++ b/dbaccess/source/ui/misc/RowSetDrop.cxx
@@ -237,8 +237,8 @@ bool ORowSetImportExport::insertNewRow()
if(!m_bAlreadyAsked)
{
OUString sAskIfContinue = DBA_RES(STR_ERROR_OCCURRED_WHILE_COPYING);
ScopedVclPtrInstance< OSQLWarningBox > aDlg( m_pParent, sAskIfContinue, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes );
if(aDlg->Execute() == RET_YES)
OSQLWarningBox aDlg(m_pParent ? m_pParent->GetFrameWeld() : nullptr, sAskIfContinue, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes);
if (aDlg.run() == RET_YES)
m_bAlreadyAsked = true;
else
return false;
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
index ec6c9a1..41b0e91 100644
--- a/dbaccess/source/ui/misc/UITools.cxx
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -898,9 +898,9 @@ std::shared_ptr<const SfxFilter> getStandardDatabaseFilter()
}
bool appendToFilter(const Reference<XConnection>& _xConnection,
const OUString& _sName,
const Reference< XComponentContext >& _rxContext,
vcl::Window* _pParent)
const OUString& _sName,
const Reference< XComponentContext >& _rxContext,
weld::Window* pParent)
{
bool bRet = false;
Reference< XChild> xChild(_xConnection,UNO_QUERY);
@@ -931,7 +931,8 @@ bool appendToFilter(const Reference<XConnection>& _xConnection,
if(! ::dbaui::checkDataSourceAvailable(::comphelper::getString(xProp->getPropertyValue(PROPERTY_NAME)),_rxContext))
{
OUString aMessage(DBA_RES(STR_TABLEDESIGN_DATASOURCE_DELETED));
ScopedVclPtrInstance<OSQLWarningBox>(_pParent, aMessage)->Execute();
OSQLWarningBox aWarning(pParent, aMessage);
aWarning.run();
bRet = false;
}
else
@@ -1197,18 +1198,17 @@ TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rType
return pTypeInfo;
}
sal_Int32 askForUserAction(vcl::Window* _pParent, const char* pTitle, const char* pText, bool _bAll, const OUString& _sName)
sal_Int32 askForUserAction(weld::Window* pParent, const char* pTitle, const char* pText, bool _bAll, const OUString& _sName)
{
SolarMutexGuard aGuard;
OUString aMsg = DBA_RES(pText);
aMsg = aMsg.replaceFirst("%1", _sName);
ScopedVclPtrInstance<OSQLMessageBox> aAsk(_pParent, DBA_RES(pTitle), aMsg,MessBoxStyle::YesNo | MessBoxStyle::DefaultYes,OSQLMessageBox::Query);
OSQLMessageBox aAsk(pParent, DBA_RES(pTitle), aMsg, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, MessageType::Query);
if ( _bAll )
{
aAsk->AddButton(DBA_RES(STR_BUTTON_TEXT_ALL), RET_ALL);
aAsk->GetPushButton(RET_ALL)->SetHelpId(HID_CONFIRM_DROP_BUTTON_ALL);
aAsk.add_button(DBA_RES(STR_BUTTON_TEXT_ALL), RET_ALL, HID_CONFIRM_DROP_BUTTON_ALL);
}
return aAsk->Execute();
return aAsk.run();
}
namespace
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
index 544c33c..b989d3a 100644
--- a/dbaccess/source/ui/misc/WCopyTable.cxx
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -1242,7 +1242,7 @@ Reference< XPropertySet > OCopyTableWizard::createTable()
{
xSuppDestinationColumns.set( xTable, UNO_QUERY_THROW );
// insert new table name into table filter
::dbaui::appendToFilter( m_xDestConnection, m_sName, GetComponentContext(), this );
::dbaui::appendToFilter(m_xDestConnection, m_sName, GetComponentContext(), GetFrameWeld());
// copy ui settings
m_rSourceObject.copyUISettingsTo( xTable );
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index faa02741..b25c72a 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -618,7 +618,8 @@ bool OSelectionBrowseBox::fillColumnRef(const OUString& _sColumnName, const OUSt
{
OUString sErrorMsg(DBA_RES(RID_STR_FIELD_DOESNT_EXIST));
sErrorMsg = sErrorMsg.replaceFirst("$name$",_sColumnName);
ScopedVclPtrInstance<OSQLErrorBox>(this, sErrorMsg)->Execute();
OSQLErrorBox aWarning(GetFrameWeld(), sErrorMsg);
aWarning.run();
bError = true;
}
else
@@ -722,7 +723,8 @@ bool OSelectionBrowseBox::saveField(OUString& _sFieldName ,OTableFieldDescRef co
// something different which we have to check
OUString sErrorMessage( DBA_RES( STR_QRY_COLUMN_NOT_FOUND ) );
sErrorMessage = sErrorMessage.replaceFirst("$name$",_sFieldName);
ScopedVclPtrInstance<OSQLErrorBox>(this, sErrorMessage)->Execute();
OSQLErrorBox aWarning(GetFrameWeld(), sErrorMessage);
aWarning.run();
return true;
}
@@ -878,7 +880,8 @@ bool OSelectionBrowseBox::saveField(OUString& _sFieldName ,OTableFieldDescRef co
{ // the field could not be inserted
OUString sErrorMessage( DBA_RES( RID_STR_FIELD_DOESNT_EXIST ) );
sErrorMessage = sErrorMessage.replaceFirst("$name$",aSelEntry->GetField());
ScopedVclPtrInstance<OSQLErrorBox>(this, sErrorMessage)->Execute();
OSQLErrorBox aWarning(GetFrameWeld(), sErrorMessage);
aWarning.run();
bError = true;
}
}
@@ -1145,7 +1148,8 @@ bool OSelectionBrowseBox::SaveModified()
{
if ( !m_bDisableErrorBox )
{
ScopedVclPtrInstance<OSQLWarningBox>(this, aErrorMsg)->Execute();
OSQLWarningBox aWarning(GetFrameWeld(), aErrorMsg);
aWarning.run();
}
bError = true;
}
@@ -1154,7 +1158,8 @@ bool OSelectionBrowseBox::SaveModified()
{
if ( !m_bDisableErrorBox )
{
ScopedVclPtrInstance<OSQLWarningBox>(this, aErrorMsg)->Execute();
OSQLWarningBox aWarning(GetFrameWeld(), aErrorMsg);
aWarning.run();
}
bError = true;
}
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
index dfaefad..a73c986 100644
--- a/dbaccess/source/ui/querydesign/querycontroller.cxx
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -940,9 +940,8 @@ void OQueryController::impl_initialize()
{
OUString aTitle(DBA_RES(STR_QUERYDESIGN_NO_VIEW_SUPPORT));
OUString aMessage(DBA_RES(STR_QUERYDESIGN_NO_VIEW_ASK));
ODataView* pWindow = getView();
ScopedVclPtrInstance< OSQLMessageBox > aDlg( pWindow, aTitle, aMessage, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, OSQLMessageBox::Query );
bClose = aDlg->Execute() == RET_NO;
OSQLMessageBox aDlg(getFrameWeld(), aTitle, aMessage, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, MessageType::Query);
bClose = aDlg.run() == RET_NO;
}
if ( bClose )
throw VetoException();
@@ -1013,8 +1012,8 @@ void OQueryController::impl_initialize()
{
m_bGraphicalDesign = false;
getContainer()->initialize();
ODataView* pWindow = getView();
ScopedVclPtrInstance<OSQLMessageBox>(pWindow,e)->Execute();
OSQLMessageBox aBox(getFrameWeld(), e);
aBox.run();
}
throw;
}
@@ -1365,7 +1364,8 @@ bool OQueryController::doSaveAsDoc(bool _bSaveAs)
if ( !editingCommand() && !haveDataSource() )
{
OUString aMessage(DBA_RES(STR_DATASOURCE_DELETED));
ScopedVclPtrInstance<OSQLWarningBox>(getView(), aMessage)->Execute();
OSQLWarningBox aBox(getFrameWeld(), aMessage);
aBox.run();
return false;
}
@@ -1496,7 +1496,7 @@ bool OQueryController::doSaveAsDoc(bool _bSaveAs)
m_xAlterView.set( xElements->getByName( m_sName ), UNO_QUERY );
// now check if our datasource has set a tablefilter and if so, append the new table name to it
::dbaui::appendToFilter( getConnection(), m_sName, getORB(), getView() );
::dbaui::appendToFilter(getConnection(), m_sName, getORB(), getFrameWeld());
}
Reference< XTitleChangeListener> xEventListener(impl_getTitleHelper_throw(),UNO_QUERY);
if ( xEventListener.is() )
@@ -1854,8 +1854,8 @@ void OQueryController::impl_reset( const bool i_bForceCurrentControllerSettings
if ( !i_bForceCurrentControllerSettings && !editingView() )
{
OUString aTitle(DBA_RES(STR_SVT_SQL_SYNTAX_ERROR));
ScopedVclPtrInstance< OSQLMessageBox > aDlg(getView(),aTitle,aErrorMsg);
aDlg->Execute();
OSQLMessageBox aDlg(getFrameWeld(), aTitle, aErrorMsg);
aDlg.run();
}
bError = true;
}
diff --git a/dbaccess/source/ui/relationdesign/RelationController.cxx b/dbaccess/source/ui/relationdesign/RelationController.cxx
index 316080e..e5a401e 100644
--- a/dbaccess/source/ui/relationdesign/RelationController.cxx
+++ b/dbaccess/source/ui/relationdesign/RelationController.cxx
@@ -162,7 +162,8 @@ void ORelationController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue
if(!::dbaui::checkDataSourceAvailable(::comphelper::getString(getDataSource()->getPropertyValue(PROPERTY_NAME)), getORB()))
{
OUString aMessage(DBA_RES(STR_DATASOURCE_DELETED));
ScopedVclPtrInstance<OSQLWarningBox>(getView(), aMessage)->Execute();
OSQLWarningBox aWarning(getFrameWeld(), aMessage);
aWarning.run();
}
else
{
@@ -207,8 +208,8 @@ void ORelationController::impl_initialize()
{
OUString sTitle(DBA_RES(STR_RELATIONDESIGN));
sTitle = sTitle.copy(3);
ScopedVclPtrInstance< OSQLMessageBox > aDlg(nullptr,sTitle,DBA_RES(STR_RELATIONDESIGN_NOT_AVAILABLE));
aDlg->Execute();
OSQLMessageBox aDlg(getFrameWeld(), sTitle, DBA_RES(STR_RELATIONDESIGN_NOT_AVAILABLE));
aDlg.run();
}
disconnect();
throw SQLException();
diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx
index 006b803..7c98274 100644
--- a/dbaccess/source/ui/relationdesign/RelationTableView.cxx
+++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx
@@ -323,8 +323,8 @@ void ORelationTableView::AddTabWin(const OUString& _rComposedName, const OUStrin
void ORelationTableView::RemoveTabWin( OTableWindow* pTabWin )
{
ScopedVclPtrInstance< OSQLWarningBox > aDlg( this, DBA_RES( STR_QUERY_REL_DELETE_WINDOW ), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes );
if ( m_bInRemove || aDlg->Execute() == RET_YES )
OSQLWarningBox aDlg(GetFrameWeld(), DBA_RES(STR_QUERY_REL_DELETE_WINDOW), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes);
if (m_bInRemove || aDlg.run() == RET_YES)
{
m_pView->getController().ClearUndoManager();
OJoinTableView::RemoveTabWin( pTabWin );
@@ -341,14 +341,14 @@ void ORelationTableView::lookForUiActivities()
{
OUString sTitle(DBA_RES(STR_RELATIONDESIGN));
sTitle = sTitle.copy(3);
ScopedVclPtrInstance< OSQLMessageBox > aDlg(this,DBA_RES(STR_QUERY_REL_EDIT_RELATION),OUString(),MessBoxStyle::NONE);
aDlg->SetText(sTitle);
aDlg->RemoveButton(aDlg->GetButtonId(0));
aDlg->AddButton( DBA_RES(STR_QUERY_REL_EDIT), RET_OK, ButtonDialogFlags::Default | ButtonDialogFlags::Focus);
aDlg->AddButton( DBA_RES(STR_QUERY_REL_CREATE), RET_YES);
aDlg->AddButton( StandardButtonType::Cancel,RET_CANCEL);
sal_uInt16 nRet = aDlg->Execute();
if( nRet == RET_CANCEL)
OSQLMessageBox aDlg(GetFrameWeld(), DBA_RES(STR_QUERY_REL_EDIT_RELATION), OUString(), MessBoxStyle::NONE);
aDlg.set_title(sTitle);
aDlg.add_button(DBA_RES(STR_QUERY_REL_EDIT), RET_OK);
aDlg.set_default_response(RET_OK);
aDlg.add_button(DBA_RES(STR_QUERY_REL_CREATE), RET_YES);
aDlg.add_button(Button::GetStandardText(StandardButtonType::Cancel), RET_CANCEL);
sal_uInt16 nRet = aDlg.run();
if (nRet == RET_CANCEL)
{
m_pCurrentlyTabConnData.reset();
}
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index 56509b1..93b08c0 100644
--- a/dbaccess/source/ui/tabledesign/TableController.cxx
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -274,7 +274,8 @@ bool OTableController::doSaveDoc(bool _bSaveAs)
if (!xTablesSup.is())
{
OUString aMessage(DBA_RES(STR_TABLEDESIGN_CONNECTION_MISSING));
ScopedVclPtrInstance<OSQLWarningBox>(getView(), aMessage )->Execute();
OSQLWarningBox aWarning(getFrameWeld(), aMessage);
aWarning.run();
return false;
}
@@ -372,7 +373,7 @@ bool OTableController::doSaveDoc(bool _bSaveAs)
assignTable();
}
// now check if our datasource has set a tablefilter and if append the new table name to it
::dbaui::appendToFilter(getConnection(),m_sName,getORB(),getView()); // we are not interessted in the return value
::dbaui::appendToFilter(getConnection(), m_sName, getORB(), getFrameWeld()); // we are not interessted in the return value
Reference< frame::XTitleChangeListener> xEventListener(impl_getTitleHelper_throw(),UNO_QUERY);
if ( xEventListener.is() )
{
@@ -404,9 +405,8 @@ bool OTableController::doSaveDoc(bool _bSaveAs)
{
OUString sText( DBA_RES( STR_NAME_ALREADY_EXISTS ) );
sText = sText.replaceFirst( "#" , m_sName);
ScopedVclPtrInstance< OSQLMessageBox > aDlg( getView(), DBA_RES( STR_ERROR_DURING_CREATION ), sText, MessBoxStyle::Ok, OSQLMessageBox::Error );
aDlg->Execute();
OSQLMessageBox aDlg(getFrameWeld(), DBA_RES( STR_ERROR_DURING_CREATION ), sText, MessBoxStyle::Ok, MessageType::Error);
aDlg.run();
bError = true;
}
catch( const Exception& )
@@ -513,7 +513,8 @@ void OTableController::impl_initialize()
}
catch(const SQLException&)
{
ScopedVclPtrInstance<OSQLWarningBox>(getView(), DBA_RES( STR_NO_TYPE_INFO_AVAILABLE ))->Execute();
OSQLWarningBox aWarning(getFrameWeld(), DBA_RES( STR_NO_TYPE_INFO_AVAILABLE));
aWarning.run();
throw;
}
try
@@ -914,7 +915,8 @@ bool OTableController::checkColumns(bool _bNew)
{
OUString strMessage = DBA_RES(STR_TABLEDESIGN_DUPLICATE_NAME);
strMessage = strMessage.replaceFirst("$column$", pFieldDesc->GetName());
ScopedVclPtrInstance<OSQLWarningBox>(getView(), strMessage)->Execute();
OSQLWarningBox aWarning(getFrameWeld(), strMessage);
aWarning.run();
return false;
}
}
@@ -924,9 +926,9 @@ bool OTableController::checkColumns(bool _bNew)
{
OUString sTitle(DBA_RES(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD));
OUString sMsg(DBA_RES(STR_TABLEDESIGN_NO_PRIM_KEY));
ScopedVclPtrInstance< OSQLMessageBox > aBox(getView(), sTitle,sMsg, MessBoxStyle::YesNoCancel | MessBoxStyle::DefaultYes);
OSQLMessageBox aBox(getFrameWeld(), sTitle,sMsg, MessBoxStyle::YesNoCancel | MessBoxStyle::DefaultYes);
switch ( aBox->Execute() )
switch (aBox.run())
{
case RET_YES:
{
@@ -1055,8 +1057,8 @@ void OTableController::alterColumns()
aMessage = aMessage.replaceFirst( "$column$", pField->GetName() );
SQLExceptionInfo aError( ::cppu::getCaughtException() );
ScopedVclPtrInstance< OSQLWarningBox > aMsg( getView(), aMessage, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes , &aError );
bNotOk = aMsg->Execute() == RET_YES;
OSQLWarningBox aMsg(getFrameWeld(), aMessage, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes , &aError);
bNotOk = aMsg.run() == RET_YES;
}
else
throw;
@@ -1112,8 +1114,8 @@ void OTableController::alterColumns()
{
OUString aMessage(DBA_RES(STR_TABLEDESIGN_ALTER_ERROR));
aMessage = aMessage.replaceFirst("$column$",pField->GetName());
ScopedVclPtrInstance< OSQLWarningBox > aMsg( getView(), aMessage, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, &aError);
if ( aMsg->Execute() != RET_YES )
OSQLWarningBox aMsg(getFrameWeld(), aMessage, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, &aError);
if (aMsg.run() != RET_YES)
{
Reference<XPropertySet> xNewColumn(xIdxColumns->getByIndex(nPos),UNO_QUERY_THROW);
OUString sName;
@@ -1175,8 +1177,8 @@ void OTableController::alterColumns()
OUString aMsgT(DBA_RES(STR_TBL_COLUMN_IS_KEYCOLUMN));
aMsgT = aMsgT.replaceFirst("$column$",rColumnName);
OUString aTitle(DBA_RES(STR_TBL_COLUMN_IS_KEYCOLUMN_TITLE));
ScopedVclPtrInstance< OSQLMessageBox > aMsg(getView(),aTitle,aMsgT,MessBoxStyle::YesNo| MessBoxStyle::DefaultYes);
if(aMsg->Execute() == RET_YES)
OSQLMessageBox aMsg(getFrameWeld(), aTitle, aMsgT, MessBoxStyle::YesNo| MessBoxStyle::DefaultYes);
if (aMsg.run() == RET_YES)
{
xKeyColumns = nullptr;
dropPrimaryKey();
diff --git a/dbaccess/source/ui/uno/dbinteraction.cxx b/dbaccess/source/ui/uno/dbinteraction.cxx
index af79952..62704b5 100644
--- a/dbaccess/source/ui/uno/dbinteraction.cxx
+++ b/dbaccess/source/ui/uno/dbinteraction.cxx
@@ -180,9 +180,9 @@ namespace dbaui
}
// execute the dialog
ScopedVclPtrInstance< OSQLMessageBox > aDialog(nullptr, _rSqlInfo, nDialogStyle);
OSQLMessageBox aDialog(nullptr, _rSqlInfo, nDialogStyle);
// TODO: need a way to specify the parent window
sal_Int16 nResult = aDialog->Execute();
sal_Int16 nResult = aDialog.run();
try
{
switch (nResult)
diff --git a/dbaccess/source/ui/uno/unosqlmessage.cxx b/dbaccess/source/ui/uno/unosqlmessage.cxx
index 7b81588..c5b849b 100644
--- a/dbaccess/source/ui/uno/unosqlmessage.cxx
+++ b/dbaccess/source/ui/uno/unosqlmessage.cxx
@@ -27,6 +27,7 @@
#include <comphelper/propertysequence.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <connectivity/dbexception.hxx>
#include <vcl/dialog.hxx>
using namespace dbaui;
using namespace dbtools;
@@ -145,11 +146,12 @@ Reference<XPropertySetInfo> SAL_CALL OSQLMessageDialog::getPropertySetInfo()
svt::OGenericUnoDialog::Dialog OSQLMessageDialog::createDialog(vcl::Window* _pParent)
{
weld::Window* pParent = _pParent ? _pParent->GetFrameWeld() : nullptr;
if ( m_aException.hasValue() )
return svt::OGenericUnoDialog::Dialog(VclPtr<OSQLMessageBox>::Create(_pParent, SQLExceptionInfo(m_aException), MessBoxStyle::Ok | MessBoxStyle::DefaultOk, m_sHelpURL));
return svt::OGenericUnoDialog::Dialog(new OSQLMessageBox(pParent, SQLExceptionInfo(m_aException), MessBoxStyle::Ok | MessBoxStyle::DefaultOk, m_sHelpURL));
OSL_FAIL("OSQLMessageDialog::createDialog : You should use the SQLException property to specify the error to display!");
return svt::OGenericUnoDialog::Dialog(VclPtr<OSQLMessageBox>::Create(_pParent, SQLException()));
return svt::OGenericUnoDialog::Dialog(new OSQLMessageBox(pParent, SQLException()));
}
} // namespace dbaui