diff options
-rw-r--r-- | sw/source/uibase/inc/wrtsh.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/select.cxx | 66 |
2 files changed, 48 insertions, 20 deletions
diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx index 58f3865827a1..395aa4b36c82 100644 --- a/sw/source/uibase/inc/wrtsh.hxx +++ b/sw/source/uibase/inc/wrtsh.hxx @@ -640,6 +640,8 @@ private: bool bSelect, bool bDontMoveRegion = false); bool GoEnd(bool KeepArea = false, const bool * = nullptr); + SAL_DLLPRIVATE void ImplSetInsMode(bool bOn); + enum BookMarkMove { BOOKMARK_INDEX, diff --git a/sw/source/uibase/wrtsh/select.cxx b/sw/source/uibase/wrtsh/select.cxx index 404ee207e5c6..fdac5dc57cb3 100644 --- a/sw/source/uibase/wrtsh/select.cxx +++ b/sw/source/uibase/wrtsh/select.cxx @@ -713,27 +713,8 @@ void SwWrtShell::LeaveBlockMode() // Insert mode -void SwWrtShell::SetInsMode( bool bOn ) +void SwWrtShell::ImplSetInsMode(bool bOn) { - const bool bDoAsk = officecfg::Office::Common::Misc::QuerySetInsMode::get(); - if (!bOn && bDoAsk) { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetView().GetFrameWeld(), u"cui/ui/querysetinsmodedialog.ui"_ustr)); - std::unique_ptr<weld::Dialog> xQuery(xBuilder->weld_dialog(u"SetInsModeDialog"_ustr)); - std::unique_ptr<weld::Image> xImage(xBuilder->weld_image(u"imSetInsMode"_ustr)); - std::unique_ptr<weld::CheckButton> xCheckBox(xBuilder->weld_check_button(u"cbDontShowAgain"_ustr)); - - xImage->set_from_icon_name(RID_BMP_QUERYINSMODE); - - const int nResult = xQuery->run(); - - std::shared_ptr<comphelper::ConfigurationChanges> xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::QuerySetInsMode::set(!xCheckBox->get_active(), xChanges); - xChanges->commit(); - - if ( nResult == static_cast<int>(RET_NO) ) - return; - } m_bIns = bOn; SwCursorShell::SetOverwriteCursor( !m_bIns ); const SfxBoolItem aTmp( SID_ATTR_INSERT, m_bIns ); @@ -742,6 +723,51 @@ void SwWrtShell::SetInsMode( bool bOn ) EndAction(); Invalidate(); } + +namespace +{ + class QuerySetInsModeDialog : public weld::GenericDialogController + { + std::unique_ptr<weld::Image> m_xImage; + std::unique_ptr<weld::CheckButton> m_xCheckBox; + public: + QuerySetInsModeDialog(weld::Window* pParent) + : GenericDialogController(pParent, u"cui/ui/querysetinsmodedialog.ui"_ustr, u"SetInsModeDialog"_ustr) + , m_xImage(m_xBuilder->weld_image(u"imSetInsMode"_ustr)) + , m_xCheckBox(m_xBuilder->weld_check_button(u"cbDontShowAgain"_ustr)) + { + m_xImage->set_from_icon_name(RID_BMP_QUERYINSMODE); + } + bool GetDoNotShowAgain() const + { + return m_xCheckBox->get_active(); + } + }; +} + +void SwWrtShell::SetInsMode( bool bOn ) +{ + const bool bDoAsk = officecfg::Office::Common::Misc::QuerySetInsMode::get(); + if (!bOn && bDoAsk) + { + auto xDialog = std::make_shared<QuerySetInsModeDialog>(GetView().GetFrameWeld()); + weld::DialogController::runAsync(xDialog, [this, bOn, xDialog](sal_Int32 nResult){ + + std::shared_ptr<comphelper::ConfigurationChanges> xChanges( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Misc::QuerySetInsMode::set(!xDialog->GetDoNotShowAgain(), xChanges); + xChanges->commit(); + + if ( nResult == static_cast<int>(RET_NO) ) + return; + + ImplSetInsMode(bOn); + }); + return; + } + ImplSetInsMode(bOn); +} + //Overwrite mode is incompatible with red-lining void SwWrtShell::SetRedlineFlagsAndCheckInsMode( RedlineFlags eMode ) { |