diff options
author | Heiko Tietze <tietze.heiko@gmail.com> | 2024-09-11 17:43:58 +0200 |
---|---|---|
committer | Heiko Tietze <heiko.tietze@documentfoundation.org> | 2024-09-14 12:08:26 +0200 |
commit | dbd851c35720ac6f0ebea8a212fa54e79259e36c (patch) | |
tree | 5eaa6d744c12067383a3bbc7fd214e1468cf79b0 /sc/source/ui | |
parent | 6227476c81a4f2e53259d7ff32fd4cd9e81ee6b5 (diff) |
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>
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/app/scmod.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 11 | ||||
-rw-r--r-- | sc/source/ui/inc/onlyactivesheetsaveddlg.hxx | 36 | ||||
-rw-r--r-- | sc/source/ui/inc/tabvwsh.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/tpview.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/onlyactivesheetsaveddlg.cxx | 49 | ||||
-rw-r--r-- | sc/source/ui/optdlg/tpview.cxx | 19 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshh.cxx | 7 |
8 files changed, 130 insertions, 5 deletions
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 7a0db5dc45c7..94843dd1f3a0 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -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() ) ); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 5ece608a0766..d30a0d7d51d2 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -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; } diff --git a/sc/source/ui/inc/onlyactivesheetsaveddlg.hxx b/sc/source/ui/inc/onlyactivesheetsaveddlg.hxx new file mode 100644 index 000000000000..7b4578343f12 --- /dev/null +++ b/sc/source/ui/inc/onlyactivesheetsaveddlg.hxx @@ -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: */ diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index a3c0d728f90f..d0bc51455ae4 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -410,6 +410,7 @@ public: bool HasAccessibilityObjects() const; bool ExecuteRetypePassDlg(ScPasswordHash eDesiredHash); + void ExecuteOnlyActiveSheetSavedDlg(); void FinishProtectTable(); void ExecProtectTable( SfxRequest& rReq ); diff --git a/sc/source/ui/inc/tpview.hxx b/sc/source/ui/inc/tpview.hxx index 7d5bf5d7a699..3ed12e498982 100644 --- a/sc/source/ui/inc/tpview.hxx +++ b/sc/source/ui/inc/tpview.hxx @@ -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 ); diff --git a/sc/source/ui/miscdlgs/onlyactivesheetsaveddlg.cxx b/sc/source/ui/miscdlgs/onlyactivesheetsaveddlg.cxx new file mode 100644 index 000000000000..6941616309ce --- /dev/null +++ b/sc/source/ui/miscdlgs/onlyactivesheetsaveddlg.cxx @@ -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: */ diff --git a/sc/source/ui/optdlg/tpview.cxx b/sc/source/ui/optdlg/tpview.cxx index c7722e931cde..db7a921811e2 100644 --- a/sc/source/ui/optdlg/tpview.cxx +++ b/sc/source/ui/optdlg/tpview.cxx @@ -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); diff --git a/sc/source/ui/view/tabvwshh.cxx b/sc/source/ui/view/tabvwshh.cxx index cb835e62e317..d82be8b084bc 100644 --- a/sc/source/ui/view/tabvwshh.cxx +++ b/sc/source/ui/view/tabvwshh.cxx @@ -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: */ |