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 <dialmgr.hxx>
23 #include <svl/ctloptions.hxx>
25 // class SvxCTLOptionsPage -----------------------------------------------------
27 IMPL_LINK_NOARG(SvxCTLOptionsPage
, SequenceCheckingCB_Hdl
)
29 bool bIsSequenceChecking
= m_pSequenceCheckingCB
->IsChecked();
30 m_pRestrictedCB
->Enable( bIsSequenceChecking
);
31 m_pTypeReplaceCB
->Enable( bIsSequenceChecking
);
32 // #i48117#: by default restricted and type&replace have to be switched on
33 if(bIsSequenceChecking
)
35 m_pTypeReplaceCB
->Check( true );
36 m_pRestrictedCB
->Check( true );
41 SvxCTLOptionsPage::SvxCTLOptionsPage( vcl::Window
* pParent
, const SfxItemSet
& rSet
) :
43 SfxTabPage( pParent
, "OptCTLPage", "cui/ui/optctlpage.ui", &rSet
)
46 get( m_pSequenceCheckingCB
, "sequencechecking");
47 get( m_pRestrictedCB
, "restricted");
48 get( m_pTypeReplaceCB
, "typeandreplace");
50 get( m_pMovementLogicalRB
, "movementlogical");
51 get( m_pMovementVisualRB
, "movementvisual");
53 get( m_pNumeralsLB
, "numerals");
55 m_pSequenceCheckingCB
->SetClickHdl( LINK( this, SvxCTLOptionsPage
, SequenceCheckingCB_Hdl
) );
57 m_pNumeralsLB
->SetDropDownLineCount( m_pNumeralsLB
->GetEntryCount() );
60 SvxCTLOptionsPage::~SvxCTLOptionsPage()
65 void SvxCTLOptionsPage::dispose()
67 m_pSequenceCheckingCB
.clear();
68 m_pRestrictedCB
.clear();
69 m_pTypeReplaceCB
.clear();
70 m_pMovementLogicalRB
.clear();
71 m_pMovementVisualRB
.clear();
72 m_pNumeralsLB
.clear();
73 SfxTabPage::dispose();
76 VclPtr
<SfxTabPage
> SvxCTLOptionsPage::Create( vcl::Window
* pParent
, const SfxItemSet
* rAttrSet
)
78 return VclPtr
<SvxCTLOptionsPage
>::Create( pParent
, *rAttrSet
);
81 bool SvxCTLOptionsPage::FillItemSet( SfxItemSet
* )
83 bool bModified
= false;
84 SvtCTLOptions aCTLOptions
;
87 bool bChecked
= m_pSequenceCheckingCB
->IsChecked();
88 if ( m_pSequenceCheckingCB
->IsValueChangedFromSaved() )
90 aCTLOptions
.SetCTLSequenceChecking( bChecked
);
94 bChecked
= m_pRestrictedCB
->IsChecked();
95 if( m_pRestrictedCB
->IsValueChangedFromSaved() )
97 aCTLOptions
.SetCTLSequenceCheckingRestricted( bChecked
);
100 bChecked
= m_pTypeReplaceCB
->IsChecked();
101 if( m_pTypeReplaceCB
->IsValueChangedFromSaved())
103 aCTLOptions
.SetCTLSequenceCheckingTypeAndReplace(bChecked
);
107 bool bLogicalChecked
= m_pMovementLogicalRB
->IsChecked();
108 if ( m_pMovementLogicalRB
->IsValueChangedFromSaved() ||
109 m_pMovementVisualRB
->IsValueChangedFromSaved() )
111 SvtCTLOptions::CursorMovement eMovement
=
112 bLogicalChecked
? SvtCTLOptions::MOVEMENT_LOGICAL
: SvtCTLOptions::MOVEMENT_VISUAL
;
113 aCTLOptions
.SetCTLCursorMovement( eMovement
);
117 if ( m_pNumeralsLB
->IsValueChangedFromSaved() )
119 sal_uInt16 nPos
= m_pNumeralsLB
->GetSelectEntryPos();
120 aCTLOptions
.SetCTLTextNumerals( (SvtCTLOptions::TextNumerals
)nPos
);
127 void SvxCTLOptionsPage::Reset( const SfxItemSet
* )
129 SvtCTLOptions aCTLOptions
;
131 m_pSequenceCheckingCB
->Check( aCTLOptions
.IsCTLSequenceChecking() );
132 m_pRestrictedCB
->Check( aCTLOptions
.IsCTLSequenceCheckingRestricted() );
133 m_pTypeReplaceCB
->Check( aCTLOptions
.IsCTLSequenceCheckingTypeAndReplace() );
135 SvtCTLOptions::CursorMovement eMovement
= aCTLOptions
.GetCTLCursorMovement();
138 case SvtCTLOptions::MOVEMENT_LOGICAL
:
139 m_pMovementLogicalRB
->Check();
142 case SvtCTLOptions::MOVEMENT_VISUAL
:
143 m_pMovementVisualRB
->Check();
147 SAL_WARN( "cui.options", "SvxCTLOptionsPage::Reset(): invalid movement enum" );
150 sal_uInt16 nPos
= (sal_uInt16
)aCTLOptions
.GetCTLTextNumerals();
151 DBG_ASSERT( nPos
< m_pNumeralsLB
->GetEntryCount(), "SvxCTLOptionsPage::Reset(): invalid numerals enum" );
152 m_pNumeralsLB
->SelectEntryPos( nPos
);
154 m_pSequenceCheckingCB
->SaveValue();
155 m_pRestrictedCB
->SaveValue();
156 m_pTypeReplaceCB
->SaveValue();
157 m_pMovementLogicalRB
->SaveValue();
158 m_pMovementVisualRB
->SaveValue();
159 m_pNumeralsLB
->SaveValue();
161 bool bIsSequenceChecking
= m_pSequenceCheckingCB
->IsChecked();
162 m_pRestrictedCB
->Enable( bIsSequenceChecking
);
163 m_pTypeReplaceCB
->Enable( bIsSequenceChecking
);
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */