Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / cui / source / options / optaccessibility.cxx
blobd0a3694a3c73cb2756d54b71df5a3e24f04820b3
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "optaccessibility.hxx"
21 #include <vcl/settings.hxx>
22 #include <vcl/svapp.hxx>
23 #include <officecfg/Office/Common.hxx>
25 SvxAccessibilityOptionsTabPage::SvxAccessibilityOptionsTabPage(weld::Container* pPage, weld::DialogController* pController,
26 const SfxItemSet& rSet)
27 : SfxTabPage(pPage, pController, "cui/ui/optaccessibilitypage.ui", "OptAccessibilityPage", &rSet)
28 , m_xAccessibilityTool(m_xBuilder->weld_check_button("acctool"))
29 , m_xTextSelectionInReadonly(m_xBuilder->weld_check_button("textselinreadonly"))
30 , m_xAnimatedGraphics(m_xBuilder->weld_check_button("animatedgraphics"))
31 , m_xAnimatedTexts(m_xBuilder->weld_check_button("animatedtext"))
32 , m_xHighContrast(m_xBuilder->weld_combo_box("highcontrast"))
33 , m_xAutomaticFontColor(m_xBuilder->weld_check_button("autofontcolor"))
34 , m_xPagePreviews(m_xBuilder->weld_check_button("systempagepreviewcolor"))
36 #ifdef UNX
37 // UNIX: read the gconf2 setting instead to use the checkbox
38 m_xAccessibilityTool->hide();
39 #endif
42 SvxAccessibilityOptionsTabPage::~SvxAccessibilityOptionsTabPage()
46 std::unique_ptr<SfxTabPage> SvxAccessibilityOptionsTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
48 return std::make_unique<SvxAccessibilityOptionsTabPage>(pPage, pController, *rAttrSet);
51 bool SvxAccessibilityOptionsTabPage::FillItemSet( SfxItemSet* )
53 std::shared_ptr<comphelper::ConfigurationChanges> batch( comphelper::ConfigurationChanges::create() );
54 if ( !officecfg::Office::Common::Accessibility::IsForPagePreviews::isReadOnly() )
55 officecfg::Office::Common::Accessibility::IsForPagePreviews::set(m_xPagePreviews->get_active(), batch);
56 if ( !officecfg::Office::Common::Accessibility::IsAllowAnimatedGraphics::isReadOnly() )
57 officecfg::Office::Common::Accessibility::IsAllowAnimatedGraphics::set(m_xAnimatedGraphics->get_active(), batch);
58 if ( !officecfg::Office::Common::Accessibility::IsAllowAnimatedText::isReadOnly() )
59 officecfg::Office::Common::Accessibility::IsAllowAnimatedText::set(m_xAnimatedTexts->get_active(), batch);
60 if ( !officecfg::Office::Common::Accessibility::IsAutomaticFontColor::isReadOnly() )
61 officecfg::Office::Common::Accessibility::IsAutomaticFontColor::set(m_xAutomaticFontColor->get_active(), batch);
62 if ( !officecfg::Office::Common::Accessibility::IsSelectionInReadonly::isReadOnly() )
63 officecfg::Office::Common::Accessibility::IsSelectionInReadonly::set(m_xTextSelectionInReadonly->get_active(), batch);
64 if ( !officecfg::Office::Common::Accessibility::HighContrast::isReadOnly() )
65 officecfg::Office::Common::Accessibility::HighContrast::set(m_xHighContrast->get_active(), batch);
66 batch->commit();
68 AllSettings aAllSettings = Application::GetSettings();
69 MiscSettings aMiscSettings = aAllSettings.GetMiscSettings();
70 #ifndef UNX
71 aMiscSettings.SetEnableATToolSupport(m_xAccessibilityTool->get_active());
72 #endif
73 aAllSettings.SetMiscSettings(aMiscSettings);
74 Application::MergeSystemSettings( aAllSettings );
75 Application::SetSettings(aAllSettings);
77 return false;
80 void SvxAccessibilityOptionsTabPage::Reset( const SfxItemSet* )
82 m_xPagePreviews->set_active( officecfg::Office::Common::Accessibility::IsForPagePreviews::get() );
83 if( officecfg::Office::Common::Accessibility::IsForPagePreviews::isReadOnly() )
84 m_xPagePreviews->set_sensitive(false);
86 m_xAnimatedGraphics->set_active( officecfg::Office::Common::Accessibility::IsAllowAnimatedGraphics::get() );
87 if( officecfg::Office::Common::Accessibility::IsAllowAnimatedGraphics::isReadOnly() )
88 m_xAnimatedGraphics->set_sensitive(false);
90 m_xAnimatedTexts->set_active( officecfg::Office::Common::Accessibility::IsAllowAnimatedText::get() );
91 if( officecfg::Office::Common::Accessibility::IsAllowAnimatedText::isReadOnly() )
92 m_xAnimatedTexts->set_sensitive(false);
94 m_xAutomaticFontColor->set_active( officecfg::Office::Common::Accessibility::IsAutomaticFontColor::get() );
95 if( officecfg::Office::Common::Accessibility::IsAutomaticFontColor::isReadOnly() )
96 m_xAutomaticFontColor->set_sensitive(false);
98 m_xTextSelectionInReadonly->set_active( officecfg::Office::Common::Accessibility::IsSelectionInReadonly::get() );
99 if( officecfg::Office::Common::Accessibility::IsSelectionInReadonly::isReadOnly() )
100 m_xTextSelectionInReadonly->set_sensitive(false);
102 m_xHighContrast->set_active( officecfg::Office::Common::Accessibility::HighContrast::get() );
103 if( officecfg::Office::Common::Accessibility::HighContrast::isReadOnly() )
104 m_xHighContrast->set_sensitive(false);
106 AllSettings aAllSettings = Application::GetSettings();
107 const MiscSettings& aMiscSettings = aAllSettings.GetMiscSettings();
108 m_xAccessibilityTool->set_active(aMiscSettings.GetEnableATToolSupport());
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */