Resolves tdf#89781 - Better warning when saving multiple sheets

* Replaced ScOnlyActiveSheetSavedDlg by QueryDialog
* Pimped the QueryDialog with SetTypeWarn showing a different
  image and hiding the No button

Change-Id: Id134c8d4f6e27df5918d1b53141b45bc0439651c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207209
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
This commit is contained in:
Heiko Tietze
2026-06-24 12:32:20 +02:00
committed by Heiko Tietze
parent 446f1fe0ae
commit f3d3e12be5
13 changed files with 30 additions and 245 deletions
+1
View File
@@ -90,5 +90,6 @@ inline constexpr OUString RID_SVXBMP_TOTD_IMPRESS = u"res/tipoftheday_i.png"_ust
inline constexpr OUString RID_SVXBMP_TOTD_SOFFICE = u"res/tipoftheday.png"_ustr;
inline constexpr OUString RID_CUIBMP_QUERY = u"res/query.png"_ustr;
inline constexpr OUString RID_CUIBMP_WARN = u"res/warn.png"_ustr;
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
+5 -1
View File
@@ -53,6 +53,10 @@ void QueryDialog::SetYesLabel(const OUString& rLabel)
void QueryDialog::SetNoLabel(const OUString& rLabel)
{
m_pNoLarge->set_label(rLabel);
m_pNoLarge->set_visible(true);
m_pNoLarge->set_visible(!rLabel.isEmpty());
m_pNo->set_visible(false);
}
void QueryDialog::SetTypeWarn() { m_pImage->set_from_icon_name(RID_CUIBMP_WARN); }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+1
View File
@@ -1560,6 +1560,7 @@ public:
bool DontShowAgain() const override { return m_pDlg->DontShowAgain(); }
void SetYesLabel(const OUString& sLabel) override { m_pDlg->SetYesLabel(sLabel); }
void SetNoLabel(const OUString& sLabel) override { m_pDlg->SetNoLabel(sLabel); }
void SetTypeWarn() override { m_pDlg->SetTypeWarn(); }
};
}
+2 -1
View File
@@ -43,7 +43,8 @@ public:
const OUString& sQuestion, bool bHideShowAgain = false);
bool DontShowAgain() const { return m_pCheckBox->get_active(); }
void SetYesLabel(const OUString& rLabel);
void SetNoLabel(const OUString& rLabel);
void SetNoLabel(const OUString& rLabel); //empty to hide the button
void SetTypeWarn();
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

+1
View File
@@ -165,6 +165,7 @@ public:
virtual bool DontShowAgain() const = 0;
virtual void SetYesLabel(const OUString& sLabel) = 0;
virtual void SetNoLabel(const OUString& sLabel) = 0;
virtual void SetTypeWarn() = 0;
};
class VCL_DLLPUBLIC VclAbstractDialogFactory
-1
View File
@@ -513,7 +513,6 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/miscdlgs/datatableview \
sc/source/ui/miscdlgs/highred \
sc/source/ui/miscdlgs/mergecellsdialog \
sc/source/ui/miscdlgs/onlyactivesheetsaveddlg \
sc/source/ui/miscdlgs/optsolver \
sc/source/ui/miscdlgs/protectiondlg \
sc/source/ui/miscdlgs/duplicaterecordsdlg \
-1
View File
@@ -189,7 +189,6 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/multipleoperationsdialog \
sc/uiconfig/scalc/ui/navigatorpanel \
sc/uiconfig/scalc/ui/nosolutiondialog \
sc/uiconfig/scalc/ui/onlyactivesheetsaveddialog \
sc/uiconfig/scalc/ui/optcalculatepage \
sc/uiconfig/scalc/ui/optchangespage \
sc/uiconfig/scalc/ui/optcompatibilitypage \
+5
View File
@@ -607,6 +607,11 @@
#define STR_SHEET_VIEW_DEFAULT_VIEW_NAME NC_("STR_SHEET_VIEW_DEFAULT_VIEW_NAME", "Default View")
#define STR_SHEET_VIEW_TEMPORARY_NAME_TEMPLATE NC_("STR_SHEET_VIEW_TEMPORARY_NAME_TEMPLATE", "Temporary View %1")
#define STR_WARN_ONLYACTIVESHEET_TITLE NC_("STR_WARN_ONLYACTIVESHEET_TITLE", "Warning")
#define STR_WARN_ONLYACTIVESHEET_TEXT NC_("STR_WARN_ONLYACTIVESHEET_TEXT", "Only the active sheet was saved.")
#define STR_WARN_ONLYACTIVESHEET_QUEST NC_("STR_WARN_ONLYACTIVESHEET_QUEST", "Your are saving in the CSV text format, which means multiple sheets cannot be handled.")
#define STR_WARN_ONLYACTIVESHEET_BUTTON NC_("STR_WARN_ONLYACTIVESHEET_BUTTON", "Okay")
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -1,38 +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 .
*/
#pragma once
#include <vcl/weld/CheckButton.hxx>
#include <vcl/weld/DialogController.hxx>
#include <vcl/weld/Window.hxx>
class ScOnlyActiveSheetSavedDlg : public weld::GenericDialogController
{
private:
std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
public:
ScOnlyActiveSheetSavedDlg(weld::Window* pParent);
/** Opens dialog if IsDialogEnabled() returns true.
@descr If after executing the dialog the checkbox "Do not show again" is set,
the method DisableDialog() will be called. */
virtual short run() override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -1,53 +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 <onlyactivesheetsaveddlg.hxx>
#include <scmod.hxx>
#include <inputopt.hxx>
#include <vcl/vclenum.hxx>
#include <vcl/weld/Builder.hxx>
#include <vcl/weld/Dialog.hxx>
ScOnlyActiveSheetSavedDlg::ScOnlyActiveSheetSavedDlg(weld::Window* pParent)
: GenericDialogController(pParent, u"modules/scalc/ui/onlyactivesheetsaveddialog.ui"_ustr,
u"OnlyActiveSheetSavedDialog"_ustr)
, m_xWarningOnBox(m_xBuilder->weld_check_button("cbShow"))
{
m_xDialog->set_default_response(RET_YES);
}
short ScOnlyActiveSheetSavedDlg::run()
{
short nRet = RET_YES;
ScModule* pScMod = ScModule::get();
assert(pScMod);
if (pScMod->GetInputOptions().GetWarnActiveSheet())
{
m_xDialog->run();
if (!m_xWarningOnBox->get_active())
{
ScInputOptions aInputOpt(pScMod->GetInputOptions());
aInputOpt.SetWarnActiveSheet(false);
pScMod->SetInputOptions(aInputOpt);
}
}
return nRet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+14 -3
View File
@@ -28,16 +28,18 @@
#include <basic/sbxcore.hxx>
#include <svl/stritem.hxx>
#include <svl/whiter.hxx>
#include <vcl/abstdlg.hxx>
#include <vcl/svapp.hxx>
#include <osl/diagnose.h>
#include <tabvwsh.hxx>
#include <document.hxx>
#include <globstr.hrc>
#include <sc.hrc>
#include <scresid.hxx>
#include <drwlayer.hxx>
#include <retypepassdlg.hxx>
#include <tabprotection.hxx>
#include <onlyactivesheetsaveddlg.hxx>
#include <com/sun/star/embed/EmbedVerbs.hpp>
@@ -263,8 +265,17 @@ bool ScTabViewShell::ExecuteRetypePassDlg(ScPasswordHash eDesiredHash)
void ScTabViewShell::ExecuteOnlyActiveSheetSavedDlg()
{
ScOnlyActiveSheetSavedDlg aDlg(GetFrameWeld());
aDlg.run();
VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
auto pDlg(pFact->CreateQueryDialog(
GetFrameWeld(), ScResId(STR_WARN_ONLYACTIVESHEET_TITLE),
ScResId(STR_WARN_ONLYACTIVESHEET_TEXT), ScResId(STR_WARN_ONLYACTIVESHEET_QUEST), true));
OUString sLabel;
sLabel.clear();
pDlg->SetNoLabel(sLabel); //empty to hide the button
sLabel = ScResId(STR_WARN_ONLYACTIVESHEET_BUTTON);
pDlg->SetYesLabel(sLabel);
pDlg->SetTypeWarn();
pDlg->Execute();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -1,146 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface domain="sc">
<requires lib="gtk+" version="3.24"/>
<object class="GtkDialog" id="OnlyActiveSheetSavedDialog">
<property name="can-focus">False</property>
<property name="border-width">12</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="type-hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="layout-style">end</property>
<child>
<object class="GtkCheckButton" id="cbShow">
<property name="label" translatable="yes" context="onlyactivesheetsaveddialog|checkbox">_Show this message again</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="secondary">True</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btnOk">
<property name="label" translatable="yes" context="onlyactivesheetsaveddialog|button">_OK</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="has-focus">True</property>
<property name="receives-default">True</property>
<property name="use-underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=3 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel" id="lbTitle">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">12</property>
<property name="label" translatable="yes" context="onlyactivesheetsaveddialog|title">Warning</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.5"/>
</attributes>
<child internal-child="accessible">
<object class="AtkObject" id="lbTitle-atkobject">
<property name="AtkObject::accessible-role">static</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbText">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="vexpand">True</property>
<property name="label" translatable="yes" context="onlyactivesheetsaveddialog|text">Only the active sheet was saved.</property>
<child internal-child="accessible">
<object class="AtkObject" id="lbText-atkobject">
<property name="AtkObject::accessible-role">static</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="imWarning">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin-end">12</property>
<property name="icon-name">help/warning_large.png</property>
<child internal-child="accessible">
<object class="AtkObject" id="imWarning-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="onlyactivesheetsaveddialog|image">Warning image</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
<property name="height">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-5">btnOk</action-widget>
</action-widgets>
</object>
</interface>