summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-02-23 09:35:08 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-02-26 15:27:09 +0000
commit942f05996bc287923cdbcae12c64e57adf8ec975 (patch)
tree7005380763a9ecb93f5f27c28174633b9774abb7 /sfx2
parentc410a3dcfeb68ba2247c0d879727afe4ca8ed3da (diff)
convert remaining ErrorBox to weld::MessageDialog
and convert remaining QueryBox to weld::MessageDialog Change-Id: Ifb4c316dee8eabf57c4940c44e29c65a2781aa6c
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/linkmgr2.cxx12
-rw-r--r--sfx2/source/bastyp/fltfnc.cxx9
-rw-r--r--sfx2/source/dialog/alienwarn.cxx52
-rw-r--r--sfx2/source/dialog/recfloat.cxx14
-rw-r--r--sfx2/source/doc/guisaveas.cxx4
-rw-r--r--sfx2/source/doc/querytemplate.cxx2
-rw-r--r--sfx2/source/inc/alienwarn.hxx22
-rw-r--r--sfx2/source/view/viewfrm.cxx38
8 files changed, 82 insertions, 71 deletions
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index b6d5d4eb91fb..9ca22e8256e1 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -28,7 +28,8 @@
#include <tools/urlobj.hxx>
#include <sot/exchange.hxx>
#include <tools/debug.hxx>
-#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/weld.hxx>
#include <sfx2/lnkbase.hxx>
#include <sfx2/app.hxx>
#include <vcl/graph.hxx>
@@ -271,7 +272,7 @@ bool LinkManager::GetDisplayNames( const SvBaseLink * pLink,
void LinkManager::UpdateAllLinks(
bool bAskUpdate,
bool bUpdateGrfLinks,
- vcl::Window* pParentWin )
+ weld::Window* pParentWin )
{
// First make a copy of the array in order to update links
// links in ... no contact between them!
@@ -308,7 +309,12 @@ void LinkManager::UpdateAllLinks(
if( bAskUpdate )
{
- int nRet = ScopedVclPtrInstance<QueryBox>(pParentWin, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, SfxResId( STR_QUERY_UPDATE_LINKS ))->Execute();
+ std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pParentWin,
+ VclMessageType::Question, VclButtonsType::YesNo,
+ SfxResId(STR_QUERY_UPDATE_LINKS)));
+ xQueryBox->set_default_response(RET_YES);
+
+ int nRet = xQueryBox->run();
if( RET_YES != nRet )
{
SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx
index d28c4ca27dad..5bbdfed0b7eb 100644
--- a/sfx2/source/bastyp/fltfnc.cxx
+++ b/sfx2/source/bastyp/fltfnc.cxx
@@ -36,7 +36,6 @@
#include <basic/sbxobj.hxx>
#include <basic/sbxmeth.hxx>
#include <basic/sbxcore.hxx>
-#include <vcl/msgbox.hxx>
#include <vcl/weld.hxx>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
@@ -485,8 +484,12 @@ bool SfxFilterMatcher::IsFilterInstalled_Impl( const std::shared_ptr<const SfxFi
// Here could a re-installation be offered
OUString aText( SfxResId(STR_FILTER_NOT_INSTALLED) );
aText = aText.replaceFirst( "$(FILTER)", pFilter->GetUIName() );
- ScopedVclPtrInstance< QueryBox > aQuery(nullptr, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, aText);
- short nRet = aQuery->Execute();
+ std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr,
+ VclMessageType::Question, VclButtonsType::YesNo,
+ aText));
+ xQueryBox->set_default_response(RET_YES);
+
+ short nRet = xQueryBox->run();
if ( nRet == RET_YES )
{
#ifdef DBG_UTIL
diff --git a/sfx2/source/dialog/alienwarn.cxx b/sfx2/source/dialog/alienwarn.cxx
index 66c9424067be..dd88541fbb29 100644
--- a/sfx2/source/dialog/alienwarn.cxx
+++ b/sfx2/source/dialog/alienwarn.cxx
@@ -22,66 +22,62 @@
#include <sfx2/sfxresid.hxx>
#include <sfx2/sfxuno.hxx>
#include <unotools/saveopt.hxx>
-#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
#include <alienwarn.hxx>
-SfxAlienWarningDialog::SfxAlienWarningDialog(vcl::Window* pParent, const OUString& _rFormatName,
+SfxAlienWarningDialog::SfxAlienWarningDialog(weld::Window* pParent, const OUString& _rFormatName,
const OUString& _rDefaultExtension, bool rDefaultIsAlien)
- : MessageDialog(pParent, "AlienWarnDialog", "sfx/ui/alienwarndialog.ui")
+ : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/alienwarndialog.ui"))
+ , m_xDialog(m_xBuilder->weld_message_dialog("AlienWarnDialog"))
+ , m_xKeepCurrentBtn(m_xBuilder->weld_button("save"))
+ , m_xUseDefaultFormatBtn(m_xBuilder->weld_button("cancel"))
+ , m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
+ , m_xOrigParent(m_xWarningOnBox->weld_parent())
+ , m_xContentArea(m_xDialog->weld_message_area())
{
- get(m_pWarningOnBox, "ask");
//fdo#75121, a bit tricky because the widgets we want to align with
//don't actually exist in the ui description, they're implied
- m_pWarningOnBox->set_margin_left(QueryBox::GetStandardImage().GetSizePixel().Width() + 12);
-
- get(m_pKeepCurrentBtn, "save");
- get(m_pUseDefaultFormatBtn, "cancel");
+ m_xOrigParent->remove(m_xWarningOnBox.get());
+ m_xContentArea->add(m_xWarningOnBox.get());
OUString aExtension = "ODF";
// replace formatname (text)
- OUString sInfoText = get_primary_text();
+ OUString sInfoText = m_xDialog->get_primary_text();
sInfoText = sInfoText.replaceAll( "%FORMATNAME", _rFormatName );
- set_primary_text(sInfoText);
+ m_xDialog->set_primary_text(sInfoText);
// replace formatname (button)
- sInfoText = m_pKeepCurrentBtn->GetText();
+ sInfoText = m_xKeepCurrentBtn->get_label();
sInfoText = sInfoText.replaceAll( "%FORMATNAME", _rFormatName );
- m_pKeepCurrentBtn->SetText( sInfoText );
+ m_xKeepCurrentBtn->set_label(sInfoText);
// hide ODF explanation if default format is alien
// and set the proper extension in the button
if( rDefaultIsAlien )
{
- set_secondary_text(OUString());
+ m_xDialog->set_secondary_text(OUString());
aExtension = _rDefaultExtension.toAsciiUpperCase();
}
// replace defaultextension (button)
- sInfoText = m_pUseDefaultFormatBtn->GetText();
+ sInfoText = m_xUseDefaultFormatBtn->get_label();
sInfoText = sInfoText.replaceAll( "%DEFAULTEXTENSION", aExtension );
- m_pUseDefaultFormatBtn->SetText( sInfoText );
+ m_xUseDefaultFormatBtn->set_label(sInfoText);
// load value of "warning on" checkbox from save options
- m_pWarningOnBox->Check( SvtSaveOptions().IsWarnAlienFormat() );
+ m_xWarningOnBox->set_active(SvtSaveOptions().IsWarnAlienFormat());
}
SfxAlienWarningDialog::~SfxAlienWarningDialog()
{
- disposeOnce();
-}
-
-void SfxAlienWarningDialog::dispose()
-{
+ m_xContentArea->remove(m_xWarningOnBox.get());
+ m_xOrigParent->add(m_xWarningOnBox.get());
// save value of "warning off" checkbox, if necessary
SvtSaveOptions aSaveOpt;
- bool bChecked = m_pWarningOnBox->IsChecked();
- if ( aSaveOpt.IsWarnAlienFormat() != bChecked )
- aSaveOpt.SetWarnAlienFormat( bChecked );
- m_pKeepCurrentBtn.clear();
- m_pUseDefaultFormatBtn.clear();
- m_pWarningOnBox.clear();
- MessageDialog::dispose();
+ bool bChecked = m_xWarningOnBox->get_active();
+ if (aSaveOpt.IsWarnAlienFormat() != bChecked)
+ aSaveOpt.SetWarnAlienFormat(bChecked);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx
index 09fbdce65552..d023348f4548 100644
--- a/sfx2/source/dialog/recfloat.cxx
+++ b/sfx2/source/dialog/recfloat.cxx
@@ -18,7 +18,8 @@
*/
#include <svl/eitem.hxx>
-#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/weld.hxx>
#include <recfloat.hxx>
#include <sfx2/strings.hrc>
@@ -59,9 +60,14 @@ bool SfxRecordingFloatWrapper_Impl::QueryClose()
css::uno::Reference< css::frame::XDispatchRecorder > xRecorder = pBindings->GetRecorder();
if ( xRecorder.is() && !xRecorder->getRecordedMacro().isEmpty() )
{
- ScopedVclPtrInstance< QueryBox > aBox(GetWindow(), MessBoxStyle::YesNo | MessBoxStyle::DefaultNo , SfxResId(STR_MACRO_LOSS));
- aBox->SetText( SfxResId(STR_CANCEL_RECORDING) );
- bRet = ( aBox->Execute() == RET_YES );
+ vcl::Window* pWin = GetWindow();
+ std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr,
+ VclMessageType::Question, VclButtonsType::YesNo,
+ SfxResId(STR_MACRO_LOSS)));
+ xQueryBox->set_default_response(RET_NO);
+
+ xQueryBox->set_title(SfxResId(STR_CANCEL_RECORDING));
+ bRet = (xQueryBox->run() == RET_YES);
}
return bRet;
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 824f8598f3cc..cbdde2efbb52 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -1803,9 +1803,9 @@ bool SfxStoringHelper::WarnUnacceptableFormat( const uno::Reference< frame::XMod
return true;
vcl::Window* pWin = SfxStoringHelper::GetModelWindow( xModel );
- ScopedVclPtrInstance< SfxAlienWarningDialog > aDlg( pWin, aOldUIName, aDefExtension, bDefIsAlien );
+ SfxAlienWarningDialog aDlg(pWin ? pWin->GetFrameWeld() : nullptr, aOldUIName, aDefExtension, bDefIsAlien);
- return aDlg->Execute() == RET_OK;
+ return aDlg.run() == RET_OK;
}
vcl::Window* SfxStoringHelper::GetModelWindow( const uno::Reference< frame::XModel >& xModel )
diff --git a/sfx2/source/doc/querytemplate.cxx b/sfx2/source/doc/querytemplate.cxx
index 9eef613c96e5..bc9ff49bf977 100644
--- a/sfx2/source/doc/querytemplate.cxx
+++ b/sfx2/source/doc/querytemplate.cxx
@@ -30,7 +30,7 @@ namespace sfx2
QueryTemplateBox::QueryTemplateBox( vcl::Window* pParent, const OUString& rMessage ) :
MessBox ( pParent, MessBoxStyle::NONE, 0, Application::GetDisplayName(), rMessage )
{
- SetImage( QueryBox::GetStandardImage() );
+ SetImage(GetStandardQueryBoxImage());
SetHelpId( HID_QUERY_LOAD_TEMPLATE );
AddButton( SfxResId( STR_QRYTEMPL_UPDATE_BTN ), RET_YES,
diff --git a/sfx2/source/inc/alienwarn.hxx b/sfx2/source/inc/alienwarn.hxx
index 7d2414aad8bc..05f5a3835aee 100644
--- a/sfx2/source/inc/alienwarn.hxx
+++ b/sfx2/source/inc/alienwarn.hxx
@@ -19,21 +19,25 @@
#ifndef INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX
#define INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX
-#include <vcl/button.hxx>
-#include <vcl/messagedialog.hxx>
+#include <vcl/weld.hxx>
-class SfxAlienWarningDialog : public MessageDialog
+class SfxAlienWarningDialog
{
private:
- VclPtr<PushButton> m_pKeepCurrentBtn;
- VclPtr<PushButton> m_pUseDefaultFormatBtn;
- VclPtr<CheckBox> m_pWarningOnBox;
+ std::unique_ptr<weld::Builder> m_xBuilder;
+ std::unique_ptr<weld::MessageDialog> m_xDialog;
+ std::unique_ptr<weld::Button> m_xKeepCurrentBtn;
+ std::unique_ptr<weld::Button> m_xUseDefaultFormatBtn;
+ std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
+
+ std::unique_ptr<weld::Container> m_xOrigParent;
+ std::unique_ptr<weld::Container> m_xContentArea;
public:
- SfxAlienWarningDialog(vcl::Window* pParent, const OUString& _rFormatName,
+ SfxAlienWarningDialog(weld::Window* pParent, const OUString& _rFormatName,
const OUString& _rDefaultExtension, bool rDefaultIsAlien);
- virtual ~SfxAlienWarningDialog() override;
- virtual void dispose() override;
+ short run() { return m_xDialog->run(); }
+ ~SfxAlienWarningDialog();
};
#endif // INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 33978818fa44..c72f6a47a4a1 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -134,7 +134,8 @@ using ::com::sun::star::container::XIndexContainer;
#include <sfx2/minfitem.hxx>
#include <sfx2/strings.hrc>
#include "impviewframe.hxx"
-#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/weld.hxx>
#define SfxViewFrame
#include <sfxslots.hxx>
@@ -175,28 +176,23 @@ SfxEditDocumentDialog::SfxEditDocumentDialog(weld::Widget* pParent)
{
}
-class SfxQueryOpenAsTemplate : public QueryBox
+class SfxQueryOpenAsTemplate
{
+private:
+ std::unique_ptr<weld::MessageDialog> m_xQueryBox;
public:
- SfxQueryOpenAsTemplate(vcl::Window* pParent, MessBoxStyle nStyle, bool bAllowIgnoreLock);
-};
-
-SfxQueryOpenAsTemplate::SfxQueryOpenAsTemplate(vcl::Window* pParent, MessBoxStyle nStyle, bool bAllowIgnoreLock)
- : QueryBox(pParent, nStyle, SfxResId(bAllowIgnoreLock ? STR_QUERY_OPENASTEMPLATE_ALLOW_IGNORE : STR_QUERY_OPENASTEMPLATE))
-{
- AddButton(SfxResId(STR_QUERY_OPENASTEMPLATE_OPENCOPY_BTN), RET_YES,
- ButtonDialogFlags::Default | ButtonDialogFlags::OK | ButtonDialogFlags::Focus);
- SetButtonHelpText(RET_YES, OUString());
-
- if (bAllowIgnoreLock)
+ SfxQueryOpenAsTemplate(weld::Window* pParent, bool bAllowIgnoreLock)
+ : m_xQueryBox(Application::CreateMessageDialog(pParent, VclMessageType::Question, VclButtonsType::NONE,
+ SfxResId(bAllowIgnoreLock ? STR_QUERY_OPENASTEMPLATE_ALLOW_IGNORE : STR_QUERY_OPENASTEMPLATE)))
{
- AddButton(SfxResId(STR_QUERY_OPENASTEMPLATE_OPEN_BTN), RET_IGNORE);
- SetButtonHelpText(RET_IGNORE, OUString());
+ m_xQueryBox->add_button(SfxResId(STR_QUERY_OPENASTEMPLATE_OPENCOPY_BTN), RET_YES);
+ if (bAllowIgnoreLock)
+ m_xQueryBox->add_button(SfxResId(STR_QUERY_OPENASTEMPLATE_OPEN_BTN), RET_IGNORE);
+ m_xQueryBox->add_button(Button::GetStandardText( StandardButtonType::Cancel ), RET_CANCEL);
+ m_xQueryBox->set_default_response(RET_YES);
}
-
- AddButton(StandardButtonType::Cancel, RET_CANCEL);
- SetButtonHelpText(RET_CANCEL, OUString());
-}
+ short run() { return m_xQueryBox->run(); }
+};
/// Is this read-only object shell opened via .uno:SignPDF?
bool IsSignPDF(const SfxObjectShellRef& xObjSh)
@@ -463,9 +459,9 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
if (nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI())
{
// css::sdbcx::User offering to open it as a template
- ScopedVclPtrInstance<SfxQueryOpenAsTemplate> aBox(&GetWindow(), MessBoxStyle::NONE, bRetryIgnoringLock);
+ SfxQueryOpenAsTemplate aBox(GetWindow().GetFrameWeld(), bRetryIgnoringLock);
- short nUserAnswer = aBox->Execute();
+ short nUserAnswer = aBox.run();
bOpenTemplate = RET_YES == nUserAnswer;
// Always reset this here to avoid infinite loop
bRetryIgnoringLock = RET_IGNORE == nUserAnswer;