Resolves tdf#33714 - Option to disable "only active sheet"

Based on work by Martin van Zijl in I5f5b65b132d91beb24aa6e9282390dead235d849

Change-Id: Ie4543a2fc4b52715b5d87783a57e982c20274114
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173220
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
This commit is contained in:
Heiko Tietze
2024-09-11 17:43:58 +02:00
committed by Heiko Tietze
parent 6227476c81
commit dbd851c357
17 changed files with 332 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -706,6 +706,14 @@
</info>
<value>true</value>
</prop>
<prop oor:name="WarnActiveSheet" oor:type="xs:boolean" oor:nillable="false">
<!-- UIHints: Tools - Options - Spreadsheet - General - [Section] Input settings -->
<info>
<desc>Specifies whether a warning is shown if saving a document works only for the active sheet, eg. in case of CSV.</desc>
<label>Warn when saving only the active sheet</label>
</info>
<value>true</value>
</prop>
<prop oor:name="UseScrollLock" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Toggles the scroll lock behavior allowing to disable it for special keyboards</desc>

View File

@@ -496,6 +496,7 @@ $(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/redcom \

View File

@@ -186,6 +186,7 @@ $(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 \

View File

@@ -38,6 +38,7 @@ private:
bool bReplCellsWarn;
bool bLegacyCellSelection;
bool bEnterPasteMode;
bool bWarnActiveSheet;
public:
ScInputOptions();
@@ -70,6 +71,8 @@ public:
bool GetLegacyCellSelection() const { return bLegacyCellSelection; }
void SetEnterPasteMode(bool bSet) { bEnterPasteMode = bSet; }
bool GetEnterPasteMode() const { return bEnterPasteMode; }
void SetWarnActiveSheet(bool bSet) { bWarnActiveSheet = bSet; }
bool GetWarnActiveSheet() const { return bWarnActiveSheet; }
};
// CfgItem for input options

View File

@@ -110,6 +110,7 @@ class SvxZoomSliderItem;
// misc:
#define SID_LINKS (SC_VIEW_START + 60)
#define SID_SC_INPUT_WARNACTIVESHEET TypedWhichId<SfxBoolItem>(SC_VIEW_START + 61)
#define SID_INSERT_SMATH (SC_VIEW_START + 63)
// Put this here since all available slots for "SC_INPUT" are taken
#define SID_SC_INPUT_ENTER_PASTE_MODE TypedWhichId<SfxBoolItem>(SC_VIEW_START + 64)
@@ -167,7 +168,7 @@ class SvxZoomSliderItem;
#define SID_SC_OPT_KEY_BINDING_COMPAT TypedWhichId<SfxUInt16Item>(SC_VIEW_START + 99)
// NOTE: last valid ID is (SC_VIEW_START + 99)
// NOTE: last valid ID is (SC_VIEW_START + 100)
// messages

View File

@@ -44,6 +44,7 @@ ScInputOptions::ScInputOptions()
, bReplCellsWarn(true)
, bLegacyCellSelection(false)
, bEnterPasteMode(false)
, bWarnActiveSheet(true)
{
}
@@ -63,6 +64,7 @@ constexpr OUStringLiteral CFGPATH_INPUT = u"Office.Calc/Input";
#define SCINPUTOPT_REPLCELLSWARN 9
#define SCINPUTOPT_LEGACY_CELL_SELECTION 10
#define SCINPUTOPT_ENTER_PASTE_MODE 11
#define SCINPUTOPT_WARNACTIVESHEET 12
Sequence<OUString> ScInputCfg::GetPropertyNames()
{
@@ -77,7 +79,8 @@ Sequence<OUString> ScInputCfg::GetPropertyNames()
u"UseTabCol"_ustr, // SCINPUTOPT_USETABCOL
u"ReplaceCellsWarning"_ustr, // SCINPUTOPT_REPLCELLSWARN
u"LegacyCellSelection"_ustr, // SCINPUTOPT_LEGACY_CELL_SELECTION
u"EnterPasteMode"_ustr}; // SCINPUTOPT_ENTER_PASTE_MODE
u"EnterPasteMode"_ustr, // SCINPUTOPT_ENTER_PASTE_MODE
u"WarnActiveSheet"_ustr}; // SCINPUTOPT_WARNACTIVESHEET
}
ScInputCfg::ScInputCfg() :
@@ -120,6 +123,8 @@ void ScInputCfg::ReadCfg()
SetLegacyCellSelection(bVal);
if (bool bVal; aValues[SCINPUTOPT_ENTER_PASTE_MODE] >>= bVal)
SetEnterPasteMode(bVal);
if (bool bVal; aValues[SCINPUTOPT_WARNACTIVESHEET] >>= bVal)
SetWarnActiveSheet(bVal);
}
void ScInputCfg::ImplCommit()
@@ -140,6 +145,7 @@ void ScInputCfg::ImplCommit()
pValues[SCINPUTOPT_REPLCELLSWARN] <<= GetReplaceCellsWarn();
pValues[SCINPUTOPT_LEGACY_CELL_SELECTION] <<= GetLegacyCellSelection();
pValues[SCINPUTOPT_ENTER_PASTE_MODE] <<= GetEnterPasteMode();
pValues[SCINPUTOPT_WARNACTIVESHEET] <<= GetWarnActiveSheet();
PutProperties(aNames, aValues);
}

View File

@@ -1265,6 +1265,12 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
bSaveInputOptions = true;
}
if( const SfxBoolItem* pItem = rOptSet.GetItemIfSet( SID_SC_INPUT_WARNACTIVESHEET ) )
{
aInputOptions.SetWarnActiveSheet( pItem->GetValue() );
bSaveInputOptions = true;
}
// PrintOptions
if ( const ScTpPrintItem* pItem = rOptSet.GetItemIfSet(SID_SCPRINTOPTIONS) )
{
@@ -1980,7 +1986,7 @@ std::optional<SfxItemSet> ScModule::CreateItemSet( sal_uInt16 nId )
// TP_VIEW, TP_CALC:
SID_SCVIEWOPTIONS, SID_SCDOCOPTIONS,
// TP_INPUT:
SID_SC_INPUT_ENTER_PASTE_MODE, SID_SC_INPUT_ENTER_PASTE_MODE,
SID_SC_INPUT_WARNACTIVESHEET, SID_SC_INPUT_ENTER_PASTE_MODE,
// TP_PRINT:
SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS,
// TP_INPUT:
@@ -2045,6 +2051,8 @@ std::optional<SfxItemSet> ScModule::CreateItemSet( sal_uInt16 nId )
rInpOpt.GetLegacyCellSelection() ) );
pRet->Put( SfxBoolItem( SID_SC_INPUT_ENTER_PASTE_MODE,
rInpOpt.GetEnterPasteMode() ) );
pRet->Put( SfxBoolItem( SID_SC_INPUT_WARNACTIVESHEET,
rInpOpt.GetWarnActiveSheet() ) );
// RID_SC_TP_PRINT
pRet->Put( ScTpPrintItem( GetPrintOptions() ) );

View File

@@ -84,6 +84,7 @@
#include <svx/svdpage.hxx>
#include <docmodel/theme/Theme.hxx>
#include <inputopt.hxx>
#include <formulacell.hxx>
#include <global.hxx>
#include <filter.hxx>
@@ -2636,8 +2637,11 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
bRet = true;
if (m_pDocument->GetTableCount() > 1)
if (!rMed.GetErrorIgnoreWarning())
rMed.SetError(SCWARN_EXPORT_ASCII);
if (!rMed.GetErrorIgnoreWarning() && SC_MOD()->GetInputOptions().GetWarnActiveSheet())
{
ScTabViewShell* pViewShell = GetBestViewShell();
pViewShell->ExecuteOnlyActiveSheetSavedDlg();
}
}
}
}
@@ -2735,7 +2739,7 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
bRet = true;
if (m_pDocument->GetTableCount() > 1)
if (!rMed.GetErrorIgnoreWarning())
if (!rMed.GetErrorIgnoreWarning() && SC_MOD()->GetInputOptions().GetWarnActiveSheet())
rMed.SetError(SCWARN_EXPORT_ASCII);
}
}
@@ -2785,6 +2789,7 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed )
if (GetErrorIgnoreWarning())
SetError(SCERR_IMPORT_NI);
}
return bRet;
}

View File

@@ -0,0 +1,36 @@
/* -*- 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.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: */

View File

@@ -410,6 +410,7 @@ public:
bool HasAccessibilityObjects() const;
bool ExecuteRetypePassDlg(ScPasswordHash eDesiredHash);
void ExecuteOnlyActiveSheetSavedDlg();
void FinishProtectTable();
void ExecProtectTable( SfxRequest& rReq );

View File

@@ -135,6 +135,8 @@ class ScTpLayoutOptions : public SfxTabPage
std::unique_ptr<weld::Widget> m_xLegacyCellSelectionImg;
std::unique_ptr<weld::CheckButton> m_xEnterPasteModeCB;
std::unique_ptr<weld::Widget> m_xEnterPasteModeImg;
std::unique_ptr<weld::CheckButton> m_xWarnActiveSheetCB;
std::unique_ptr<weld::Widget> m_xWarnActiveSheetImg;
DECL_LINK(MetricHdl, weld::ComboBox&, void );
DECL_LINK( AlignHdl, weld::Toggleable&, void );

View File

@@ -0,0 +1,49 @@
/* -*- 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>
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 = SC_MOD();
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: */

View File

@@ -484,6 +484,8 @@ ScTpLayoutOptions::ScTpLayoutOptions(weld::Container* pPage, weld::DialogControl
, m_xLegacyCellSelectionImg(m_xBuilder->weld_widget(u"locklegacy_cell"_ustr))
, m_xEnterPasteModeCB(m_xBuilder->weld_check_button(u"enter_paste_mode_cb"_ustr))
, m_xEnterPasteModeImg(m_xBuilder->weld_widget(u"lockenter_paste"_ustr))
, m_xWarnActiveSheetCB(m_xBuilder->weld_check_button(u"warnactivesheet_cb"_ustr))
, m_xWarnActiveSheetImg(m_xBuilder->weld_widget(u"lockwarnactivesheet"_ustr))
{
SetExchangeSupport();
@@ -543,7 +545,8 @@ OUString ScTpLayoutOptions::GetAllStrings()
OUString checkButton[] = { u"aligncb"_ustr, u"editmodecb"_ustr, u"enter_paste_mode_cb"_ustr,
u"formatcb"_ustr, u"exprefcb"_ustr, u"sortrefupdatecb"_ustr,
u"markhdrcb"_ustr, u"replwarncb"_ustr, u"legacy_cell_selection_cb"_ustr };
u"markhdrcb"_ustr, u"replwarncb"_ustr, u"legacy_cell_selection_cb"_ustr,
u"warnactivesheet_cb"_ustr };
for (const auto& check : checkButton)
{
@@ -661,6 +664,12 @@ bool ScTpLayoutOptions::FillItemSet( SfxItemSet* rCoreSet )
bRet = true;
}
if (m_xWarnActiveSheetCB->get_state_changed_from_saved())
{
rCoreSet->Put( SfxBoolItem( SID_SC_INPUT_WARNACTIVESHEET, m_xWarnActiveSheetCB->get_active() ) );
bRet = true;
}
return bRet;
}
@@ -813,6 +822,13 @@ void ScTpLayoutOptions::Reset( const SfxItemSet* rCoreSet )
m_xEnterPasteModeCB->set_sensitive(!bReadOnly);
m_xEnterPasteModeImg->set_visible(bReadOnly);
if( const SfxBoolItem* pWarnActiveSheetItem = rCoreSet->GetItemIfSet( SID_SC_INPUT_WARNACTIVESHEET, false ) )
m_xWarnActiveSheetCB->set_active( pWarnActiveSheetItem->GetValue() );
bReadOnly = officecfg::Office::Calc::Input::WarnActiveSheet::isReadOnly();
m_xWarnActiveSheetCB->set_sensitive(!bReadOnly);
m_xWarnActiveSheetImg->set_visible(bReadOnly);
m_xAlignCB->save_state();
m_xAlignLB->save_value();
m_xEditModeCB->save_state();
@@ -825,6 +841,7 @@ void ScTpLayoutOptions::Reset( const SfxItemSet* rCoreSet )
m_xLegacyCellSelectionCB->save_state();
m_xEnterPasteModeCB->save_state();
m_xWarnActiveSheetCB->save_state();
AlignHdl(*m_xAlignCB);

View File

@@ -37,6 +37,7 @@
#include <drwlayer.hxx>
#include <retypepassdlg.hxx>
#include <tabprotection.hxx>
#include <onlyactivesheetsaveddlg.hxx>
#include <com/sun/star/embed/EmbedVerbs.hpp>
@@ -260,4 +261,10 @@ bool ScTabViewShell::ExecuteRetypePassDlg(ScPasswordHash eDesiredHash)
return true;
}
void ScTabViewShell::ExecuteOnlyActiveSheetSavedDlg()
{
ScOnlyActiveSheetSavedDlg aDlg(GetFrameWeld());
aDlg.run();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface domain="sc">
<requires lib="gtk+" version="3.20"/>
<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>

View File

@@ -262,7 +262,7 @@
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<!-- n-columns=3 n-rows=9 -->
<!-- n-columns=3 n-rows=10 -->
<object class="GtkGrid" id="grid3">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -574,6 +574,39 @@
<property name="top-attach">8</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lockwarnactivesheet">
<property name="can-focus">False</property>
<property name="no-show-all">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">res/lock.png</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="warnactivesheet_cb">
<property name="label" translatable="yes" context="scgeneralpage|warnactivesheet_cb">Warn when saving only the active sheet</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="draw-indicator">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="warnactivesheet_cb-atkobject">
<property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|legacy_cell_selection_cb">Specifies whether a warning box informs when saving was applied to only the active sheet.</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">9</property>
<property name="width">2</property>
</packing>
</child>
</object>
</child>
</object>