Skip to content

Commit 7f4901d

Browse files
HeikoTietzeHeiko Tietze
authored and
Heiko Tietze
committed
More appealing design for alientformat warn dialog
Change-Id: I575f24e6b8f9dd08bd8797343a86ac25b49f19b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180713 Reviewed-by: Heiko Tietze <[email protected]> Tested-by: Jenkins
1 parent 7a9e303 commit 7f4901d

File tree

22 files changed

+55
-231
lines changed

22 files changed

+55
-231
lines changed

cui/source/dialogs/querydialog.cxx

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ QueryDialog::QueryDialog(weld::Window* pParent, const OUString& sTitle, const OU
2828
, m_pQuestion(m_xBuilder->weld_label(u"lbQuestion"_ustr))
2929
, m_pImage(m_xBuilder->weld_image(u"imQuery"_ustr))
3030
, m_pCheckBox(m_xBuilder->weld_check_button(u"cbDontShowAgain"_ustr))
31+
, m_pYes(m_xBuilder->weld_button(u"btnYes"_ustr))
32+
, m_pNo(m_xBuilder->weld_button(u"btnNo"_ustr))
3133
{
3234
m_pTitle->set_label(sTitle);
3335
m_pText->set_label(sText);

cui/source/factory/dlgfact.cxx

+2
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,8 @@ class AbstractQueryDialog_Impl final
16171617
public:
16181618
using AbstractDialogImpl_BASE::AbstractDialogImpl_BASE;
16191619
bool ShowAgain() const override { return m_pDlg->ShowAgain(); }
1620+
void SetYesLabel(const OUString& sLabel) override { m_pDlg->SetYesLabel(sLabel); }
1621+
void SetNoLabel(const OUString& sLabel) override { m_pDlg->SetNoLabel(sLabel); }
16201622
};
16211623
}
16221624

cui/source/inc/querydialog.hxx

+4
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ private:
2828
std::unique_ptr<weld::Label> m_pQuestion;
2929
std::unique_ptr<weld::Image> m_pImage;
3030
std::unique_ptr<weld::CheckButton> m_pCheckBox;
31+
std::unique_ptr<weld::Button> m_pYes;
32+
std::unique_ptr<weld::Button> m_pNo;
3133

3234
public:
3335
QueryDialog(weld::Window* pParent, const OUString& sTitle, const OUString& sText,
3436
const OUString& sQuestion, bool bShowAgain = true);
3537
bool ShowAgain() const { return m_pCheckBox->get_active(); }
38+
void SetYesLabel(const OUString& sLabel) { m_pYes->set_label(sLabel); }
39+
void SetNoLabel(const OUString& sLabel) { m_pNo->set_label(sLabel); }
3640
};
3741

3842
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

cui/uiconfig/ui/querydialog.ui

+5-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<object class="GtkLabel" id="lbTitle">
6666
<property name="visible">True</property>
6767
<property name="can-focus">False</property>
68+
<property name="hexpand">True</property>
6869
<property name="xalign">0</property>
6970
<attributes>
7071
<attribute name="weight" value="bold"/>
@@ -85,10 +86,10 @@
8586
<object class="GtkLabel" id="lbText">
8687
<property name="visible">True</property>
8788
<property name="can-focus">False</property>
88-
<property name="hexpand">False</property>
89+
<property name="hexpand">True</property>
8990
<property name="wrap">True</property>
9091
<property name="wrap-mode">word-char</property>
91-
<property name="max-width-chars">40</property>
92+
<property name="max-width-chars">50</property>
9293
<property name="xalign">0</property>
9394
<child internal-child="accessible">
9495
<object class="AtkObject" id="lbText-atkobject">
@@ -106,7 +107,9 @@
106107
<property name="visible">True</property>
107108
<property name="can-focus">False</property>
108109
<property name="valign">start</property>
110+
<property name="hexpand">True</property>
109111
<property name="wrap">True</property>
112+
<property name="max-width-chars">50</property>
110113
<property name="xalign">0</property>
111114
<child internal-child="accessible">
112115
<object class="AtkObject" id="lbQuestion-atkobject">

include/sfx2/strings.hrc

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
#define STR_HIDDENINFO_NOTES NC_("STR_HIDDENINFO_NOTES", "Notes")
4848
#define STR_HIDDENINFO_DOCVERSIONS NC_("STR_HIDDENINFO_DOCVERSIONS", "Document versions")
4949
#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.")
50+
#define STR_QUERY_ALIENFORMAT_TTITLE NC_("STR_QUERY_ALIENFORMAT_TITLE", "Non-standard file format")
51+
#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)”.")
52+
#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.")
53+
#define STR_QUERY_ALIENFORMAT_YES NC_("STR_QUERY_ALIENFORMAT_YES", "Use %FORMATNAME Format")
54+
#define STR_QUERY_ALIENFORMAT_NO NC_("STR_QUERY_ALIENFORMAT_No", "Use %DEFAULTEXTENSION Format")
55+
5056
// Used in the title of a shared document.
5157
#define STR_SHARED NC_("STR_SHARED", " (shared)")
5258
#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).")

include/vcl/abstdlg.hxx

+2
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ protected:
163163
virtual ~AbstractQueryDialog() override = default;
164164
public:
165165
virtual bool ShowAgain() const = 0;
166+
virtual void SetYesLabel(const OUString& sLabel) = 0;
167+
virtual void SetNoLabel(const OUString& sLabel) = 0;
166168
};
167169

168170
class VCL_DLLPUBLIC VclAbstractDialogFactory

sc/qa/uitest/calc_tests4/saveToCSV.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_saveToCSVDialog(self):
4646

4747
with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="") as xWarnDialog:
4848
# CSV confirmation dialog is displayed
49-
xSave = xWarnDialog.getChild("save")
49+
xSave = xWarnDialog.getChild("btnYes")
5050

5151
with self.ui_test.execute_dialog_through_action(xSave, "CLICK") as xCsvDialog:
5252
xFormulas = xCsvDialog.getChild("formulas")

sc/qa/uitest/calc_tests7/save_readonly_with_password.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_save_to_xlsx(self):
4444

4545
xOk = xPasswordDialog.getChild("ok")
4646
# XLSX confirmation dialog is displayed
47-
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"):
47+
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="btnYes"):
4848
pass
4949

5050
with self.ui_test.load_file(systemPathToFileUrl(xFilePath), [PropertyValue(Name="Silent", Value=True)]) as document:

sc/qa/uitest/calc_tests8/tdf147086.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_tdf147086(self):
4242

4343
xOk = xPasswordDialog.getChild("ok")
4444
# XLSX confirmation dialog is displayed
45-
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"):
45+
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="btnYes"):
4646
pass
4747

4848
with self.ui_test.load_file(systemPathToFileUrl(xFilePath), [PropertyValue(Name="Silent", Value=True)]) as document:

sc/qa/uitest/calc_tests9/tdf144996.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_tdf144996(self):
3030

3131
self.assertFalse(document.isReadonly())
3232

33-
with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="save"):
33+
with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="btnYes"):
3434
# Confirm file format popup
3535
pass
3636

sd/qa/uitest/impress_tests/save_readonly_with_password.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_save_to_pptx(self):
4848

4949
xOk = xPasswordDialog.getChild("ok")
5050
# PPTX confirmation dialog is displayed
51-
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"):
51+
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="btnYes"):
5252
pass
5353

5454
with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document:

sfx2/Library_sfx.mk

-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
172172
sfx2/source/devtools/DocumentModelTreeHandler \
173173
sfx2/source/devtools/ObjectInspectorTreeHandler \
174174
sfx2/source/devtools/ObjectInspectorWidgets \
175-
sfx2/source/dialog/alienwarn \
176175
sfx2/source/dialog/basedlgs \
177176
sfx2/source/dialog/checkin \
178177
sfx2/source/dialog/dialoghelper \

sfx2/UIConfig_sfx.mk

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
$(eval $(call gb_UIConfig_UIConfig,sfx))
1111

1212
$(eval $(call gb_UIConfig_add_uifiles,sfx,\
13-
sfx2/uiconfig/ui/alienwarndialog \
1413
sfx2/uiconfig/ui/addtargetdialog \
1514
sfx2/uiconfig/ui/autoredactdialog \
1615
sfx2/uiconfig/ui/bookmarkdialog \

sfx2/qa/unit/data/sfx2-dialogs-test.txt

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ sfx/ui/loadtemplatedialog.ui
6262
sfx/ui/templatedlg.ui
6363
sfx/ui/printeroptionsdialog.ui
6464
sfx/ui/searchdialog.ui
65-
sfx/ui/alienwarndialog.ui
6665
sfx/ui/errorfindemaildialog.ui
6766
sfx/ui/querysavedialog.ui
6867
sfx/ui/floatingrecord.ui

sfx2/source/dialog/alienwarn.cxx

-89
This file was deleted.

sfx2/source/doc/guisaveas.cxx

+26-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
#include <sfx2/sfxuno.hxx>
9090
#include <sfx2/viewsh.hxx>
9191
#include <sfx2/bindings.hxx>
92-
#include <alienwarn.hxx>
9392

9493
#include <memory>
9594
#include <string_view>
@@ -103,6 +102,8 @@
103102
#include <osl/file.hxx>
104103
#include <svl/cryptosign.hxx>
105104

105+
#include <vcl/abstdlg.hxx>
106+
106107
#ifdef _WIN32
107108
#include <Shlobj.h>
108109
#ifdef GetTempPath
@@ -2100,9 +2101,31 @@ bool SfxStoringHelper::WarnUnacceptableFormat( const uno::Reference< frame::XMod
21002101
return true;
21012102

21022103
weld::Window* pWin = SfxStoringHelper::GetModelWindow(xModel);
2103-
SfxAlienWarningDialog aDlg(pWin, aOldUIName,aExtension, aDefExtension, bDefIsAlien);
21042104

2105-
return aDlg.run() == RET_OK;
2105+
OUString sInfoText = SfxResId(STR_QUERY_ALIENFORMAT_TEXT);
2106+
sInfoText = sInfoText.replaceAll("%FORMATNAME", aOldUIName);
2107+
sInfoText = sInfoText.replaceAll("%EXTENSION", aExtension);
2108+
2109+
OUString sExtension = u"ODF"_ustr;
2110+
OUString sQuestion = "";
2111+
if (bDefIsAlien) {
2112+
sExtension = aDefExtension.toAsciiUpperCase();
2113+
}
2114+
else
2115+
{
2116+
sQuestion = SfxResId(STR_QUERY_ALIENFORMAT_QUESTION);
2117+
sQuestion = sQuestion.replaceAll("%EXTENSION", aDefExtension);
2118+
}
2119+
2120+
VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
2121+
auto pDlg = pFact->CreateQueryDialog(pWin, SfxResId(STR_QUERY_ALIENFORMAT_TTITLE), sInfoText, sQuestion, false);
2122+
pDlg->SetYesLabel(SfxResId(STR_QUERY_ALIENFORMAT_YES).replaceAll("%FORMATNAME", aOldUIName)); // "Use %FORMATNAME Format"
2123+
pDlg->SetNoLabel(SfxResId(STR_QUERY_ALIENFORMAT_NO).replaceAll("%DEFAULTEXTENSION", sExtension)); // "Use %DEFAULTEXTENSION _Format"
2124+
2125+
sal_Int32 nResult = pDlg->Execute();
2126+
pDlg->disposeOnce();
2127+
2128+
return nResult == RET_YES;
21062129
}
21072130

21082131
uno::Reference<awt::XWindow> SfxStoringHelper::GetModelXWindow(const uno::Reference<frame::XModel>& xModel)

sfx2/source/inc/alienwarn.hxx

-40
This file was deleted.

0 commit comments

Comments
 (0)