LibreOffice Module cui (master) 1
optctl.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "optctl.hxx"
21#include <svl/ctloptions.hxx>
22#include <sal/log.hxx>
23#include <tools/debug.hxx>
24
25// class SvxCTLOptionsPage -----------------------------------------------------
26
27IMPL_LINK_NOARG(SvxCTLOptionsPage, SequenceCheckingCB_Hdl, weld::Toggleable&, void)
28{
29 bool bIsSequenceChecking = m_xSequenceCheckingCB->get_active();
30 m_xRestrictedCB->set_sensitive( bIsSequenceChecking );
31 m_xTypeReplaceCB->set_sensitive( bIsSequenceChecking );
32 // #i48117#: by default restricted and type&replace have to be switched on
33 if (bIsSequenceChecking)
34 {
35 m_xTypeReplaceCB->set_active(true);
36 m_xRestrictedCB->set_active(true);
37 }
38}
39
41 : SfxTabPage(pPage, pController, "cui/ui/optctlpage.ui", "OptCTLPage", &rSet)
42 , m_xSequenceCheckingCB(m_xBuilder->weld_check_button("sequencechecking"))
43 , m_xRestrictedCB(m_xBuilder->weld_check_button("restricted"))
44 , m_xTypeReplaceCB(m_xBuilder->weld_check_button("typeandreplace"))
45 , m_xMovementLogicalRB(m_xBuilder->weld_radio_button("movementlogical"))
46 , m_xMovementVisualRB(m_xBuilder->weld_radio_button("movementvisual"))
47 , m_xNumeralsLB(m_xBuilder->weld_combo_box("numerals"))
48{
49 m_xSequenceCheckingCB->connect_toggled(LINK(this, SvxCTLOptionsPage, SequenceCheckingCB_Hdl));
50}
51
53{
54}
55
56std::unique_ptr<SfxTabPage> SvxCTLOptionsPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
57{
58 return std::make_unique<SvxCTLOptionsPage>( pPage, pController, *rAttrSet );
59}
60
62{
63 bool bModified = false;
64 SvtCTLOptions aCTLOptions;
65
66 // Sequence checking
67 bool bChecked = m_xSequenceCheckingCB->get_active();
68 if ( m_xSequenceCheckingCB->get_state_changed_from_saved() )
69 {
70 aCTLOptions.SetCTLSequenceChecking( bChecked );
71 bModified = true;
72 }
73
74 bChecked = m_xRestrictedCB->get_active();
75 if( m_xRestrictedCB->get_state_changed_from_saved() )
76 {
77 aCTLOptions.SetCTLSequenceCheckingRestricted( bChecked );
78 bModified = true;
79 }
80 bChecked = m_xTypeReplaceCB->get_active();
81 if( m_xTypeReplaceCB->get_state_changed_from_saved())
82 {
83 aCTLOptions.SetCTLSequenceCheckingTypeAndReplace(bChecked);
84 bModified = true;
85 }
86
87 bool bLogicalChecked = m_xMovementLogicalRB->get_active();
88 if ( m_xMovementLogicalRB->get_state_changed_from_saved() ||
89 m_xMovementVisualRB->get_state_changed_from_saved() )
90 {
93 aCTLOptions.SetCTLCursorMovement( eMovement );
94 bModified = true;
95 }
96
97 if (m_xNumeralsLB->get_value_changed_from_saved())
98 {
99 const sal_Int32 nPos = m_xNumeralsLB->get_active();
100 aCTLOptions.SetCTLTextNumerals( static_cast<SvtCTLOptions::TextNumerals>(nPos) );
101 bModified = true;
102 }
103
104 return bModified;
105}
106
108{
112
114 switch ( eMovement )
115 {
117 m_xMovementLogicalRB->set_active(true);
118 break;
119
121 m_xMovementVisualRB->set_active(true);
122 break;
123
124 default:
125 SAL_WARN( "cui.options", "SvxCTLOptionsPage::Reset(): invalid movement enum" );
126 }
127
128 sal_uInt16 nPos = static_cast<sal_uInt16>(SvtCTLOptions::GetCTLTextNumerals());
129 DBG_ASSERT( nPos < m_xNumeralsLB->get_count(), "SvxCTLOptionsPage::Reset(): invalid numerals enum" );
130 m_xNumeralsLB->set_active(nPos);
131
132 m_xSequenceCheckingCB->save_state();
133 m_xRestrictedCB->save_state();
134 m_xTypeReplaceCB->save_state();
135 m_xMovementLogicalRB->save_state();
136 m_xMovementVisualRB->save_state();
137 m_xNumeralsLB->save_value();
138
139 bool bIsSequenceChecking = m_xSequenceCheckingCB->get_active();
140 m_xRestrictedCB->set_sensitive( bIsSequenceChecking );
141 m_xTypeReplaceCB->set_sensitive( bIsSequenceChecking );
142}
143
144/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetCTLTextNumerals(TextNumerals _eNumerals)
void SetCTLSequenceCheckingTypeAndReplace(bool _bEnable)
static bool IsCTLSequenceCheckingTypeAndReplace()
void SetCTLCursorMovement(CursorMovement _eMovement)
static CursorMovement GetCTLCursorMovement()
static TextNumerals GetCTLTextNumerals()
static bool IsCTLSequenceChecking()
static bool IsCTLSequenceCheckingRestricted()
void SetCTLSequenceChecking(bool _bEnabled)
void SetCTLSequenceCheckingRestricted(bool _bEnable)
SvxCTLOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: optctl.cxx:40
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optctl.cxx:61
virtual void Reset(const SfxItemSet *rSet) override
Definition: optctl.cxx:107
virtual ~SvxCTLOptionsPage() override
Definition: optctl.cxx:52
std::unique_ptr< weld::ComboBox > m_xNumeralsLB
Definition: optctl.hxx:33
std::unique_ptr< weld::CheckButton > m_xSequenceCheckingCB
Definition: optctl.hxx:28
std::unique_ptr< weld::CheckButton > m_xTypeReplaceCB
Definition: optctl.hxx:30
std::unique_ptr< weld::RadioButton > m_xMovementVisualRB
Definition: optctl.hxx:32
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optctl.cxx:56
std::unique_ptr< weld::CheckButton > m_xRestrictedCB
Definition: optctl.hxx:29
std::unique_ptr< weld::RadioButton > m_xMovementLogicalRB
Definition: optctl.hxx:31
#define DBG_ASSERT(sCon, aError)
sal_uInt16 nPos
#define SAL_WARN(area, stream)
IMPL_LINK_NOARG(SvxCTLOptionsPage, SequenceCheckingCB_Hdl, weld::Toggleable &, void)
Definition: optctl.cxx:27
static SfxItemSet & rSet