diff --git a/cui/source/dialogs/querydialog.cxx b/cui/source/dialogs/querydialog.cxx index ee7dc109707b..2571e92fde2c 100644 --- a/cui/source/dialogs/querydialog.cxx +++ b/cui/source/dialogs/querydialog.cxx @@ -28,6 +28,8 @@ QueryDialog::QueryDialog(weld::Window* pParent, const OUString& sTitle, const OU , m_pQuestion(m_xBuilder->weld_label(u"lbQuestion"_ustr)) , m_pImage(m_xBuilder->weld_image(u"imQuery"_ustr)) , m_pCheckBox(m_xBuilder->weld_check_button(u"cbDontShowAgain"_ustr)) + , m_pYes(m_xBuilder->weld_button(u"btnYes"_ustr)) + , m_pNo(m_xBuilder->weld_button(u"btnNo"_ustr)) { m_pTitle->set_label(sTitle); m_pText->set_label(sText); diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index f9927251748e..34d735b8beb0 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -1617,6 +1617,8 @@ class AbstractQueryDialog_Impl final public: using AbstractDialogImpl_BASE::AbstractDialogImpl_BASE; bool ShowAgain() const override { return m_pDlg->ShowAgain(); } + void SetYesLabel(const OUString& sLabel) override { m_pDlg->SetYesLabel(sLabel); } + void SetNoLabel(const OUString& sLabel) override { m_pDlg->SetNoLabel(sLabel); } }; } diff --git a/cui/source/inc/querydialog.hxx b/cui/source/inc/querydialog.hxx index 0db70d8f6146..3b6629c50b09 100644 --- a/cui/source/inc/querydialog.hxx +++ b/cui/source/inc/querydialog.hxx @@ -28,11 +28,15 @@ private: std::unique_ptr m_pQuestion; std::unique_ptr m_pImage; std::unique_ptr m_pCheckBox; + std::unique_ptr m_pYes; + std::unique_ptr m_pNo; public: QueryDialog(weld::Window* pParent, const OUString& sTitle, const OUString& sText, const OUString& sQuestion, bool bShowAgain = true); bool ShowAgain() const { return m_pCheckBox->get_active(); } + void SetYesLabel(const OUString& sLabel) { m_pYes->set_label(sLabel); } + void SetNoLabel(const OUString& sLabel) { m_pNo->set_label(sLabel); } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/uiconfig/ui/querydialog.ui b/cui/uiconfig/ui/querydialog.ui index 4c40e9b53990..e80c3a6f3219 100644 --- a/cui/uiconfig/ui/querydialog.ui +++ b/cui/uiconfig/ui/querydialog.ui @@ -65,6 +65,7 @@ True False + True 0 @@ -85,10 +86,10 @@ True False - False + True True word-char - 40 + 50 0 @@ -106,7 +107,9 @@ True False start + True True + 50 0 diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc index dac3a61d6bb9..186d24646a5e 100644 --- a/include/sfx2/strings.hrc +++ b/include/sfx2/strings.hrc @@ -47,6 +47,12 @@ #define STR_HIDDENINFO_NOTES NC_("STR_HIDDENINFO_NOTES", "Notes") #define STR_HIDDENINFO_DOCVERSIONS NC_("STR_HIDDENINFO_DOCVERSIONS", "Document versions") #define STR_NEW_FILENAME_SAVE NC_("STR_NEW_FILENAME_SAVE", "If you do not want to overwrite the original document, you should save your work under a new filename.") +#define STR_QUERY_ALIENFORMAT_TTITLE NC_("STR_QUERY_ALIENFORMAT_TITLE", "Non-standard file format") +#define STR_QUERY_ALIENFORMAT_TEXT NC_("STR_QUERY_ALIENFORMAT_TEXT", "This document may contain formatting or content that cannot be saved in the currently selected file format “%FORMATNAME (*.%EXTENSION)”.") +#define STR_QUERY_ALIENFORMAT_QUESTION NC_("STR_QUERY_ALIENFORMAT_QUESTION", "Use the default ODF file format (*.%EXTENSION) to be sure that the document is saved correctly.") +#define STR_QUERY_ALIENFORMAT_YES NC_("STR_QUERY_ALIENFORMAT_YES", "Use %FORMATNAME Format") +#define STR_QUERY_ALIENFORMAT_NO NC_("STR_QUERY_ALIENFORMAT_No", "Use %DEFAULTEXTENSION Format") + // Used in the title of a shared document. #define STR_SHARED NC_("STR_SHARED", " (shared)") #define STR_XMLSEC_ODF12_EXPECTED NC_("STR_XMLSEC_ODF12_EXPECTED", "The document format version is set to ODF 1.1 (OpenOffice.org 2.x) in Tools-Options-Load/Save-General. Signing documents requires ODF 1.2 (OpenOffice.org 3.x).") diff --git a/include/vcl/abstdlg.hxx b/include/vcl/abstdlg.hxx index 659babc6aab6..a333a2252be6 100644 --- a/include/vcl/abstdlg.hxx +++ b/include/vcl/abstdlg.hxx @@ -163,6 +163,8 @@ protected: virtual ~AbstractQueryDialog() override = default; public: virtual bool ShowAgain() const = 0; + virtual void SetYesLabel(const OUString& sLabel) = 0; + virtual void SetNoLabel(const OUString& sLabel) = 0; }; class VCL_DLLPUBLIC VclAbstractDialogFactory diff --git a/sc/qa/uitest/calc_tests4/saveToCSV.py b/sc/qa/uitest/calc_tests4/saveToCSV.py index 09949b7d71e8..efd1329ccc43 100644 --- a/sc/qa/uitest/calc_tests4/saveToCSV.py +++ b/sc/qa/uitest/calc_tests4/saveToCSV.py @@ -46,7 +46,7 @@ class saveToCSV(UITestCase): with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="") as xWarnDialog: # CSV confirmation dialog is displayed - xSave = xWarnDialog.getChild("save") + xSave = xWarnDialog.getChild("btnYes") with self.ui_test.execute_dialog_through_action(xSave, "CLICK") as xCsvDialog: xFormulas = xCsvDialog.getChild("formulas") diff --git a/sc/qa/uitest/calc_tests7/save_readonly_with_password.py b/sc/qa/uitest/calc_tests7/save_readonly_with_password.py index c7d2f829e32c..13064432bc8f 100644 --- a/sc/qa/uitest/calc_tests7/save_readonly_with_password.py +++ b/sc/qa/uitest/calc_tests7/save_readonly_with_password.py @@ -44,7 +44,7 @@ class save_readonly_with_password(UITestCase): xOk = xPasswordDialog.getChild("ok") # XLSX confirmation dialog is displayed - with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"): + with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="btnYes"): pass with self.ui_test.load_file(systemPathToFileUrl(xFilePath), [PropertyValue(Name="Silent", Value=True)]) as document: diff --git a/sc/qa/uitest/calc_tests8/tdf147086.py b/sc/qa/uitest/calc_tests8/tdf147086.py index 1be3d6adb276..85c7eb42e408 100755 --- a/sc/qa/uitest/calc_tests8/tdf147086.py +++ b/sc/qa/uitest/calc_tests8/tdf147086.py @@ -42,7 +42,7 @@ class tdf147086(UITestCase): xOk = xPasswordDialog.getChild("ok") # XLSX confirmation dialog is displayed - with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"): + with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="btnYes"): pass with self.ui_test.load_file(systemPathToFileUrl(xFilePath), [PropertyValue(Name="Silent", Value=True)]) as document: diff --git a/sc/qa/uitest/calc_tests9/tdf144996.py b/sc/qa/uitest/calc_tests9/tdf144996.py index fcfb366feb8a..b40a9bb4df49 100644 --- a/sc/qa/uitest/calc_tests9/tdf144996.py +++ b/sc/qa/uitest/calc_tests9/tdf144996.py @@ -30,7 +30,7 @@ class tdf144996(UITestCase): self.assertFalse(document.isReadonly()) - with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="save"): + with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="btnYes"): # Confirm file format popup pass diff --git a/sd/qa/uitest/impress_tests/save_readonly_with_password.py b/sd/qa/uitest/impress_tests/save_readonly_with_password.py index 485dedde10f4..a2b9f2b9eb9e 100644 --- a/sd/qa/uitest/impress_tests/save_readonly_with_password.py +++ b/sd/qa/uitest/impress_tests/save_readonly_with_password.py @@ -48,7 +48,7 @@ class save_readonly_with_password(UITestCase): xOk = xPasswordDialog.getChild("ok") # PPTX confirmation dialog is displayed - with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"): + with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="btnYes"): pass with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index db88eaa72b40..a55494e38f00 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -172,7 +172,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/devtools/DocumentModelTreeHandler \ sfx2/source/devtools/ObjectInspectorTreeHandler \ sfx2/source/devtools/ObjectInspectorWidgets \ - sfx2/source/dialog/alienwarn \ sfx2/source/dialog/basedlgs \ sfx2/source/dialog/checkin \ sfx2/source/dialog/dialoghelper \ diff --git a/sfx2/UIConfig_sfx.mk b/sfx2/UIConfig_sfx.mk index 21410bc709c0..0f0492a4527d 100644 --- a/sfx2/UIConfig_sfx.mk +++ b/sfx2/UIConfig_sfx.mk @@ -10,7 +10,6 @@ $(eval $(call gb_UIConfig_UIConfig,sfx)) $(eval $(call gb_UIConfig_add_uifiles,sfx,\ - sfx2/uiconfig/ui/alienwarndialog \ sfx2/uiconfig/ui/addtargetdialog \ sfx2/uiconfig/ui/autoredactdialog \ sfx2/uiconfig/ui/bookmarkdialog \ diff --git a/sfx2/qa/unit/data/sfx2-dialogs-test.txt b/sfx2/qa/unit/data/sfx2-dialogs-test.txt index 18dcbacf6a00..71908657e067 100644 --- a/sfx2/qa/unit/data/sfx2-dialogs-test.txt +++ b/sfx2/qa/unit/data/sfx2-dialogs-test.txt @@ -62,7 +62,6 @@ sfx/ui/loadtemplatedialog.ui sfx/ui/templatedlg.ui sfx/ui/printeroptionsdialog.ui sfx/ui/searchdialog.ui -sfx/ui/alienwarndialog.ui sfx/ui/errorfindemaildialog.ui sfx/ui/querysavedialog.ui sfx/ui/floatingrecord.ui diff --git a/sfx2/source/dialog/alienwarn.cxx b/sfx2/source/dialog/alienwarn.cxx deleted file mode 100644 index 3e9be6970de8..000000000000 --- a/sfx2/source/dialog/alienwarn.cxx +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include -#include - -SfxAlienWarningDialog::SfxAlienWarningDialog(weld::Window* pParent, - std::u16string_view _rFormatName, - std::u16string_view _rExtension, - const OUString& _rDefaultExtension, - bool rDefaultIsAlien) - : MessageDialogController(pParent, u"sfx/ui/alienwarndialog.ui"_ustr, u"AlienWarnDialog"_ustr, - u"ask"_ustr) - , m_xKeepCurrentBtn(m_xBuilder->weld_button(u"save"_ustr)) - , m_xUseDefaultFormatBtn(m_xBuilder->weld_button(u"cancel"_ustr)) - , m_xWarningOnBox(m_xBuilder->weld_check_button(u"ask"_ustr)) -{ - OUString aExtension = u"ODF"_ustr; - - // replace formatname and extension (text) - OUString sInfoText = m_xDialog->get_primary_text(); - sInfoText = sInfoText.replaceAll("%FORMATNAME", _rFormatName); - sInfoText = sInfoText.replaceAll("%EXTENSION", _rExtension); - m_xDialog->set_primary_text(sInfoText); - - // replace formatname (button) - sInfoText = m_xKeepCurrentBtn->get_label(); - sInfoText = sInfoText.replaceAll("%FORMATNAME", _rFormatName); - m_xKeepCurrentBtn->set_label(sInfoText); - - // hide ODF explanation if default format is alien - // and set the proper extension in the button - if (rDefaultIsAlien) - { - m_xDialog->set_secondary_text(OUString()); - aExtension = _rDefaultExtension.toAsciiUpperCase(); - } - else - { - // replace extension (secondary-text) - sInfoText = m_xDialog->get_secondary_text(); - sInfoText = sInfoText.replaceAll("%EXTENSION", _rDefaultExtension); - m_xDialog->set_secondary_text(sInfoText); - } - - // replace defaultextension (button) - sInfoText = m_xUseDefaultFormatBtn->get_label(); - sInfoText = sInfoText.replaceAll("%DEFAULTEXTENSION", aExtension); - m_xUseDefaultFormatBtn->set_label(sInfoText); - - // load value of "warning on" checkbox from save options - m_xWarningOnBox->set_active(officecfg::Office::Common::Save::Document::WarnAlienFormat::get()); -} - -SfxAlienWarningDialog::~SfxAlienWarningDialog() -{ - try - { - // save value of "warning off" checkbox, if necessary - bool bChecked = m_xWarningOnBox->get_active(); - if (officecfg::Office::Common::Save::Document::WarnAlienFormat::get() != bChecked) - { - auto xChanges = comphelper::ConfigurationChanges::create(); - officecfg::Office::Common::Save::Document::WarnAlienFormat::set(bChecked, xChanges); - xChanges->commit(); - } - } - catch (...) - { - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 7e6be3b5ebab..2ddaff5955bb 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -89,7 +89,6 @@ #include #include #include -#include #include #include @@ -103,6 +102,8 @@ #include #include +#include + #ifdef _WIN32 #include #ifdef GetTempPath @@ -2100,9 +2101,31 @@ bool SfxStoringHelper::WarnUnacceptableFormat( const uno::Reference< frame::XMod return true; weld::Window* pWin = SfxStoringHelper::GetModelWindow(xModel); - SfxAlienWarningDialog aDlg(pWin, aOldUIName,aExtension, aDefExtension, bDefIsAlien); - return aDlg.run() == RET_OK; + OUString sInfoText = SfxResId(STR_QUERY_ALIENFORMAT_TEXT); + sInfoText = sInfoText.replaceAll("%FORMATNAME", aOldUIName); + sInfoText = sInfoText.replaceAll("%EXTENSION", aExtension); + + OUString sExtension = u"ODF"_ustr; + OUString sQuestion = ""; + if (bDefIsAlien) { + sExtension = aDefExtension.toAsciiUpperCase(); + } + else + { + sQuestion = SfxResId(STR_QUERY_ALIENFORMAT_QUESTION); + sQuestion = sQuestion.replaceAll("%EXTENSION", aDefExtension); + } + + VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create(); + auto pDlg = pFact->CreateQueryDialog(pWin, SfxResId(STR_QUERY_ALIENFORMAT_TTITLE), sInfoText, sQuestion, false); + pDlg->SetYesLabel(SfxResId(STR_QUERY_ALIENFORMAT_YES).replaceAll("%FORMATNAME", aOldUIName)); // "Use %FORMATNAME Format" + pDlg->SetNoLabel(SfxResId(STR_QUERY_ALIENFORMAT_NO).replaceAll("%DEFAULTEXTENSION", sExtension)); // "Use %DEFAULTEXTENSION _Format" + + sal_Int32 nResult = pDlg->Execute(); + pDlg->disposeOnce(); + + return nResult == RET_YES; } uno::Reference SfxStoringHelper::GetModelXWindow(const uno::Reference& xModel) diff --git a/sfx2/source/inc/alienwarn.hxx b/sfx2/source/inc/alienwarn.hxx deleted file mode 100644 index 29fab4f53892..000000000000 --- a/sfx2/source/inc/alienwarn.hxx +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX -#define INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX - -#include - -class SfxAlienWarningDialog final : public weld::MessageDialogController -{ -private: - std::unique_ptr m_xKeepCurrentBtn; - std::unique_ptr m_xUseDefaultFormatBtn; - std::unique_ptr m_xWarningOnBox; - -public: - SfxAlienWarningDialog(weld::Window* pParent, std::u16string_view _rFormatName, - std::u16string_view _rExtension, const OUString& _rDefaultExtension, - bool rDefaultIsAlien); - virtual ~SfxAlienWarningDialog() override; -}; - -#endif // INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/uiconfig/ui/alienwarndialog.ui b/sfx2/uiconfig/ui/alienwarndialog.ui deleted file mode 100644 index c0c913977b00..000000000000 --- a/sfx2/uiconfig/ui/alienwarndialog.ui +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - False - Confirm File Format - False - True - dialog - True - question - This document may contain formatting or content that cannot be saved in the currently selected file format “%FORMATNAME (*.%EXTENSION)”. - Use the default ODF file format (*.%EXTENSION) to be sure that the document is saved correctly. - - - False - vertical - 12 - - - False - - - Use %DEFAULTEXTENSION _Format - True - True - True - True - - - False - True - 0 - True - - - - - _Use %FORMATNAME Format - True - True - True - True - True - True - - - False - True - 1 - True - - - - - False - True - end - 0 - - - - - _Ask when not saving in ODF or default format - True - True - False - True - True - - - False - True - 2 - - - - - - cancel - save - - - diff --git a/static/CustomTarget_emscripten_fs_image.mk b/static/CustomTarget_emscripten_fs_image.mk index 145157a96669..90b76cd1f4ae 100644 --- a/static/CustomTarget_emscripten_fs_image.mk +++ b/static/CustomTarget_emscripten_fs_image.mk @@ -1101,7 +1101,6 @@ endif # !ENABLE_WASM_STRIP_CALC gb_emscripten_fs_image_files += \ $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/sfx/ui/addtargetdialog.ui \ - $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/sfx/ui/alienwarndialog.ui \ $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/sfx/ui/autoredactdialog.ui \ $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/sfx/ui/bookmarkdialog.ui \ $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/sfx/ui/bookmarkmenu.ui \ diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py b/sw/qa/uitest/writer_tests/trackedChanges.py index a256889a8a8b..1e21a3a703ff 100644 --- a/sw/qa/uitest/writer_tests/trackedChanges.py +++ b/sw/qa/uitest/writer_tests/trackedChanges.py @@ -393,7 +393,7 @@ class trackedchanges(UITestCase): xOpen = xDialog.getChild("open") # DOC confirmation dialog is displayed - with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="save"): + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="btnYes"): pass with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: diff --git a/sw/qa/uitest/writer_tests3/save_readonly_with_password.py b/sw/qa/uitest/writer_tests3/save_readonly_with_password.py index f14b74046d0f..546d05357010 100644 --- a/sw/qa/uitest/writer_tests3/save_readonly_with_password.py +++ b/sw/qa/uitest/writer_tests3/save_readonly_with_password.py @@ -44,7 +44,7 @@ class save_readonly_with_password(UITestCase): xOk = xPasswordDialog.getChild("ok") # DOCX confirmation dialog is displayed - with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"): + with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="btnYes"): pass with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: diff --git a/sw/qa/uitest/writer_tests7/tdf90401.py b/sw/qa/uitest/writer_tests7/tdf90401.py index 6c29269a5880..f5f3661453b3 100644 --- a/sw/qa/uitest/writer_tests7/tdf90401.py +++ b/sw/qa/uitest/writer_tests7/tdf90401.py @@ -108,7 +108,7 @@ class tdf90401(UITestCase): xOpen = xDialog.getChild("open") # DOCX confirmation dialog is displayed - with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="save"): + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="btnYes"): pass with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as writer_doc2: