tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / optdlg / tpcompatibility.cxx
blob7df3547b53eb3fdffe574451cfb8ffae60825ecb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #undef SC_DLLIMPLEMENTATION
12 #include <svl/intitem.hxx>
13 #include <svl/eitem.hxx>
14 #include <officecfg/Office/Calc.hxx>
16 #include <tpcompatibility.hxx>
17 #include <sc.hrc>
18 #include <optutil.hxx>
20 ScTpCompatOptions::ScTpCompatOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rCoreAttrs)
21 : SfxTabPage(pPage, pController, u"modules/scalc/ui/optcompatibilitypage.ui"_ustr, u"OptCompatibilityPage"_ustr, &rCoreAttrs)
22 , m_xLbKeyBindings(m_xBuilder->weld_combo_box(u"keybindings"_ustr))
23 , m_xLbKeyBindingsImg(m_xBuilder->weld_widget(u"lockkeybindings"_ustr))
24 , m_xBtnLink(m_xBuilder->weld_check_button(u"cellLinkCB"_ustr))
25 , m_xBtnLinkImg(m_xBuilder->weld_widget(u"lockcellLinkCB"_ustr))
29 ScTpCompatOptions::~ScTpCompatOptions()
33 std::unique_ptr<SfxTabPage> ScTpCompatOptions::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rCoreAttrs)
35 return std::make_unique<ScTpCompatOptions>(pPage, pController, *rCoreAttrs);
38 OUString ScTpCompatOptions::GetAllStrings()
40 OUString sAllStrings;
41 OUString labels[] = { u"label1"_ustr, u"label2"_ustr };
43 for (const auto& label : labels)
45 if (const auto pString = m_xBuilder->weld_label(label))
46 sAllStrings += pString->get_label() + " ";
49 // id "keybindings" GtkComboBoxText is not included
51 return sAllStrings.replaceAll("_", "");
54 bool ScTpCompatOptions::FillItemSet(SfxItemSet *rCoreAttrs)
56 bool bRet = false;
57 if (m_xLbKeyBindings->get_value_changed_from_saved())
59 rCoreAttrs->Put(
60 SfxUInt16Item(
61 SID_SC_OPT_KEY_BINDING_COMPAT, m_xLbKeyBindings->get_active()));
62 bRet = true;
64 if (m_xBtnLink->get_state_changed_from_saved())
66 rCoreAttrs->Put(SfxBoolItem(SID_SC_OPT_LINKS, m_xBtnLink->get_active()));
67 bRet = true;
70 return bRet;
73 void ScTpCompatOptions::Reset(const SfxItemSet *rCoreAttrs)
75 if (const SfxUInt16Item* p16Item = rCoreAttrs->GetItemIfSet(SID_SC_OPT_KEY_BINDING_COMPAT))
77 ScOptionsUtil::KeyBindingType eKeyB =
78 static_cast<ScOptionsUtil::KeyBindingType>(p16Item->GetValue());
80 switch (eKeyB)
82 case ScOptionsUtil::KEY_DEFAULT:
83 m_xLbKeyBindings->set_active(0);
84 break;
85 case ScOptionsUtil::KEY_OOO_LEGACY:
86 m_xLbKeyBindings->set_active(1);
87 break;
88 default:
92 m_xLbKeyBindings->set_sensitive(!officecfg::Office::Calc::Compatibility::KeyBindings::BaseGroup::isReadOnly());
93 m_xLbKeyBindingsImg->set_visible(officecfg::Office::Calc::Compatibility::KeyBindings::BaseGroup::isReadOnly());
94 m_xLbKeyBindings->save_value();
96 if (const SfxBoolItem* pbItem = rCoreAttrs->GetItemIfSet(SID_SC_OPT_LINKS))
98 m_xBtnLink->set_active(pbItem->GetValue());
100 m_xBtnLink->set_sensitive(!officecfg::Office::Calc::Compatibility::Links::isReadOnly());
101 m_xBtnLinkImg->set_visible(officecfg::Office::Calc::Compatibility::Links::isReadOnly());
102 m_xBtnLink->save_state();
105 DeactivateRC ScTpCompatOptions::DeactivatePage(SfxItemSet* /*pSet*/)
107 return DeactivateRC::KeepPage;
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */