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