1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <svl/ctloptions.hxx>
22 #include <sal/log.hxx>
23 #include <tools/debug.hxx>
25 // class SvxCTLOptionsPage -----------------------------------------------------
27 IMPL_LINK_NOARG(SvxCTLOptionsPage
, SequenceCheckingCB_Hdl
, weld::Toggleable
&, void)
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
)
35 m_xTypeReplaceCB
->set_active(true);
36 m_xRestrictedCB
->set_active(true);
40 SvxCTLOptionsPage::SvxCTLOptionsPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
)
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"))
49 m_xSequenceCheckingCB
->connect_toggled(LINK(this, SvxCTLOptionsPage
, SequenceCheckingCB_Hdl
));
52 SvxCTLOptionsPage::~SvxCTLOptionsPage()
56 std::unique_ptr
<SfxTabPage
> SvxCTLOptionsPage::Create( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rAttrSet
)
58 return std::make_unique
<SvxCTLOptionsPage
>( pPage
, pController
, *rAttrSet
);
61 bool SvxCTLOptionsPage::FillItemSet( SfxItemSet
* )
63 bool bModified
= false;
64 SvtCTLOptions aCTLOptions
;
67 bool bChecked
= m_xSequenceCheckingCB
->get_active();
68 if ( m_xSequenceCheckingCB
->get_state_changed_from_saved() )
70 aCTLOptions
.SetCTLSequenceChecking( bChecked
);
74 bChecked
= m_xRestrictedCB
->get_active();
75 if( m_xRestrictedCB
->get_state_changed_from_saved() )
77 aCTLOptions
.SetCTLSequenceCheckingRestricted( bChecked
);
80 bChecked
= m_xTypeReplaceCB
->get_active();
81 if( m_xTypeReplaceCB
->get_state_changed_from_saved())
83 aCTLOptions
.SetCTLSequenceCheckingTypeAndReplace(bChecked
);
87 bool bLogicalChecked
= m_xMovementLogicalRB
->get_active();
88 if ( m_xMovementLogicalRB
->get_state_changed_from_saved() ||
89 m_xMovementVisualRB
->get_state_changed_from_saved() )
91 SvtCTLOptions::CursorMovement eMovement
=
92 bLogicalChecked
? SvtCTLOptions::MOVEMENT_LOGICAL
: SvtCTLOptions::MOVEMENT_VISUAL
;
93 aCTLOptions
.SetCTLCursorMovement( eMovement
);
97 if (m_xNumeralsLB
->get_value_changed_from_saved())
99 const sal_Int32 nPos
= m_xNumeralsLB
->get_active();
100 aCTLOptions
.SetCTLTextNumerals( static_cast<SvtCTLOptions::TextNumerals
>(nPos
) );
107 void SvxCTLOptionsPage::Reset( const SfxItemSet
* )
109 m_xSequenceCheckingCB
->set_active( SvtCTLOptions::IsCTLSequenceChecking() );
110 m_xRestrictedCB
->set_active( SvtCTLOptions::IsCTLSequenceCheckingRestricted() );
111 m_xTypeReplaceCB
->set_active( SvtCTLOptions::IsCTLSequenceCheckingTypeAndReplace() );
113 SvtCTLOptions::CursorMovement eMovement
= SvtCTLOptions::GetCTLCursorMovement();
116 case SvtCTLOptions::MOVEMENT_LOGICAL
:
117 m_xMovementLogicalRB
->set_active(true);
120 case SvtCTLOptions::MOVEMENT_VISUAL
:
121 m_xMovementVisualRB
->set_active(true);
125 SAL_WARN( "cui.options", "SvxCTLOptionsPage::Reset(): invalid movement enum" );
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
);
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();
139 bool bIsSequenceChecking
= m_xSequenceCheckingCB
->get_active();
140 m_xRestrictedCB
->set_sensitive( bIsSequenceChecking
);
141 m_xTypeReplaceCB
->set_sensitive( bIsSequenceChecking
);
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */