1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cui.hxx"
26 #include "optctl.hxx"
27 #include <dialmgr.hxx>
28 #include "optctl.hrc"
29 #include <cuires.hrc>
30 #include <svl/ctloptions.hxx>
31
32 // class SvxCTLOptionsPage -----------------------------------------------------
33
IMPL_LINK(SvxCTLOptionsPage,SequenceCheckingCB_Hdl,void *,EMPTYARG)34 IMPL_LINK( SvxCTLOptionsPage, SequenceCheckingCB_Hdl, void*, EMPTYARG )
35 {
36 sal_Bool bIsSequenceChecking = m_aSequenceCheckingCB.IsChecked();
37 m_aRestrictedCB.Enable( bIsSequenceChecking );
38 m_aTypeReplaceCB.Enable( bIsSequenceChecking );
39 // #i48117#: by default restricted and type&replace have to be switched on
40 if(bIsSequenceChecking)
41 {
42 m_aTypeReplaceCB.Check( sal_True );
43 m_aRestrictedCB.Check( sal_True );
44 }
45 return 0;
46 }
47
SvxCTLOptionsPage(Window * pParent,const SfxItemSet & rSet)48 SvxCTLOptionsPage::SvxCTLOptionsPage( Window* pParent, const SfxItemSet& rSet ) :
49
50 SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_OPTIONS_CTL ), rSet ),
51
52 m_aSequenceCheckingFL ( this, CUI_RES( FL_SEQUENCECHECKING ) ),
53 m_aSequenceCheckingCB ( this, CUI_RES( CB_SEQUENCECHECKING ) ),
54 m_aRestrictedCB ( this, CUI_RES( CB_RESTRICTED ) ),
55 m_aTypeReplaceCB ( this, CUI_RES( CB_TYPE_REPLACE ) ),
56 m_aCursorControlFL ( this, CUI_RES( FL_CURSORCONTROL ) ),
57 m_aMovementFT ( this, CUI_RES( FT_MOVEMENT ) ),
58 m_aMovementLogicalRB ( this, CUI_RES( RB_MOVEMENT_LOGICAL ) ),
59 m_aMovementVisualRB ( this, CUI_RES( RB_MOVEMENT_VISUAL ) ),
60 m_aGeneralFL ( this, CUI_RES( FL_GENERAL ) ),
61 m_aNumeralsFT ( this, CUI_RES( FT_NUMERALS ) ),
62 m_aNumeralsLB ( this, CUI_RES( LB_NUMERALS ) )
63
64 {
65 FreeResource();
66
67 m_aSequenceCheckingCB.SetClickHdl( LINK( this, SvxCTLOptionsPage, SequenceCheckingCB_Hdl ) );
68
69 m_aNumeralsLB.SetDropDownLineCount( m_aNumeralsLB.GetEntryCount() );
70 }
71 // -----------------------------------------------------------------------------
~SvxCTLOptionsPage()72 SvxCTLOptionsPage::~SvxCTLOptionsPage()
73 {
74 }
75 // -----------------------------------------------------------------------------
Create(Window * pParent,const SfxItemSet & rAttrSet)76 SfxTabPage* SvxCTLOptionsPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
77 {
78 return new SvxCTLOptionsPage( pParent, rAttrSet );
79 }
80 // -----------------------------------------------------------------------------
FillItemSet(SfxItemSet &)81 sal_Bool SvxCTLOptionsPage::FillItemSet( SfxItemSet& )
82 {
83 sal_Bool bModified = sal_False;
84 SvtCTLOptions aCTLOptions;
85
86 // Sequence checking
87 sal_Bool bChecked = m_aSequenceCheckingCB.IsChecked();
88 if ( bChecked != m_aSequenceCheckingCB.GetSavedValue() )
89 {
90 aCTLOptions.SetCTLSequenceChecking( bChecked );
91 bModified = sal_True;
92 }
93
94 bChecked = m_aRestrictedCB.IsChecked();
95 if( bChecked != m_aRestrictedCB.GetSavedValue() )
96 {
97 aCTLOptions.SetCTLSequenceCheckingRestricted( bChecked );
98 bModified = sal_True;
99 }
100 bChecked = m_aTypeReplaceCB.IsChecked();
101 if( bChecked != m_aTypeReplaceCB.GetSavedValue())
102 {
103 aCTLOptions.SetCTLSequenceCheckingTypeAndReplace(bChecked);
104 bModified = sal_True;
105 }
106
107 sal_Bool bLogicalChecked = m_aMovementLogicalRB.IsChecked();
108 sal_Bool bVisualChecked = m_aMovementVisualRB.IsChecked();
109 if ( bLogicalChecked != m_aMovementLogicalRB.GetSavedValue() ||
110 bVisualChecked != m_aMovementVisualRB.GetSavedValue() )
111 {
112 SvtCTLOptions::CursorMovement eMovement =
113 bLogicalChecked ? SvtCTLOptions::MOVEMENT_LOGICAL : SvtCTLOptions::MOVEMENT_VISUAL;
114 aCTLOptions.SetCTLCursorMovement( eMovement );
115 bModified = sal_True;
116 }
117
118 sal_uInt16 nPos = m_aNumeralsLB.GetSelectEntryPos();
119 if ( nPos != m_aNumeralsLB.GetSavedValue() )
120 {
121 aCTLOptions.SetCTLTextNumerals( (SvtCTLOptions::TextNumerals)nPos );
122 bModified = sal_True;
123 }
124
125 return bModified;
126 }
127 // -----------------------------------------------------------------------------
Reset(const SfxItemSet &)128 void SvxCTLOptionsPage::Reset( const SfxItemSet& )
129 {
130 SvtCTLOptions aCTLOptions;
131
132 m_aSequenceCheckingCB.Check( aCTLOptions.IsCTLSequenceChecking() );
133 m_aRestrictedCB.Check( aCTLOptions.IsCTLSequenceCheckingRestricted() );
134 m_aTypeReplaceCB.Check( aCTLOptions.IsCTLSequenceCheckingTypeAndReplace() );
135
136 SvtCTLOptions::CursorMovement eMovement = aCTLOptions.GetCTLCursorMovement();
137 switch ( eMovement )
138 {
139 case SvtCTLOptions::MOVEMENT_LOGICAL :
140 m_aMovementLogicalRB.Check();
141 break;
142
143 case SvtCTLOptions::MOVEMENT_VISUAL :
144 m_aMovementVisualRB.Check();
145 break;
146
147 default:
148 DBG_ERRORFILE( "SvxCTLOptionsPage::Reset(): invalid movement enum" );
149 }
150
151 sal_uInt16 nPos = (sal_uInt16)aCTLOptions.GetCTLTextNumerals();
152 DBG_ASSERT( nPos < m_aNumeralsLB.GetEntryCount(), "SvxCTLOptionsPage::Reset(): invalid numerals enum" );
153 m_aNumeralsLB.SelectEntryPos( nPos );
154
155 m_aSequenceCheckingCB.SaveValue();
156 m_aRestrictedCB.SaveValue();
157 m_aTypeReplaceCB.SaveValue();
158 m_aMovementLogicalRB.SaveValue();
159 m_aMovementVisualRB.SaveValue();
160 m_aNumeralsLB.SaveValue();
161
162 sal_Bool bIsSequenceChecking = m_aSequenceCheckingCB.IsChecked();
163 m_aRestrictedCB.Enable( bIsSequenceChecking );
164 m_aTypeReplaceCB.Enable( bIsSequenceChecking );
165 }
166
167