xref: /aoo41x/main/cui/source/options/optctl.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_cui.hxx"
30*cdf0e10cSrcweir #include "optctl.hxx"
31*cdf0e10cSrcweir #include <dialmgr.hxx>
32*cdf0e10cSrcweir #include "optctl.hrc"
33*cdf0e10cSrcweir #include <cuires.hrc>
34*cdf0e10cSrcweir #include <svl/ctloptions.hxx>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir // class SvxCTLOptionsPage -----------------------------------------------------
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir IMPL_LINK( SvxCTLOptionsPage, SequenceCheckingCB_Hdl, void*, EMPTYARG )
39*cdf0e10cSrcweir {
40*cdf0e10cSrcweir     sal_Bool bIsSequenceChecking = m_aSequenceCheckingCB.IsChecked();
41*cdf0e10cSrcweir     m_aRestrictedCB.Enable( bIsSequenceChecking );
42*cdf0e10cSrcweir     m_aTypeReplaceCB.Enable( bIsSequenceChecking );
43*cdf0e10cSrcweir     // #i48117#: by default restricted and type&replace have to be switched on
44*cdf0e10cSrcweir     if(bIsSequenceChecking)
45*cdf0e10cSrcweir     {
46*cdf0e10cSrcweir         m_aTypeReplaceCB.Check( sal_True );
47*cdf0e10cSrcweir         m_aRestrictedCB.Check( sal_True );
48*cdf0e10cSrcweir     }
49*cdf0e10cSrcweir     return 0;
50*cdf0e10cSrcweir }
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir SvxCTLOptionsPage::SvxCTLOptionsPage( Window* pParent, const SfxItemSet& rSet ) :
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 	SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_OPTIONS_CTL ), rSet ),
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 	m_aSequenceCheckingFL	( this, CUI_RES( FL_SEQUENCECHECKING ) ),
57*cdf0e10cSrcweir 	m_aSequenceCheckingCB	( this, CUI_RES( CB_SEQUENCECHECKING ) ),
58*cdf0e10cSrcweir 	m_aRestrictedCB			( this, CUI_RES( CB_RESTRICTED ) ),
59*cdf0e10cSrcweir     m_aTypeReplaceCB        ( this, CUI_RES( CB_TYPE_REPLACE ) ),
60*cdf0e10cSrcweir 	m_aCursorControlFL		( this, CUI_RES( FL_CURSORCONTROL ) ),
61*cdf0e10cSrcweir 	m_aMovementFT			( this, CUI_RES( FT_MOVEMENT ) ),
62*cdf0e10cSrcweir 	m_aMovementLogicalRB	( this, CUI_RES( RB_MOVEMENT_LOGICAL ) ),
63*cdf0e10cSrcweir 	m_aMovementVisualRB		( this, CUI_RES( RB_MOVEMENT_VISUAL ) ),
64*cdf0e10cSrcweir 	m_aGeneralFL			( this, CUI_RES( FL_GENERAL ) ),
65*cdf0e10cSrcweir 	m_aNumeralsFT			( this, CUI_RES( FT_NUMERALS ) ),
66*cdf0e10cSrcweir 	m_aNumeralsLB			( this, CUI_RES( LB_NUMERALS ) )
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir 	FreeResource();
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	m_aSequenceCheckingCB.SetClickHdl( LINK( this, SvxCTLOptionsPage, SequenceCheckingCB_Hdl ) );
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 	m_aNumeralsLB.SetDropDownLineCount( m_aNumeralsLB.GetEntryCount() );
74*cdf0e10cSrcweir }
75*cdf0e10cSrcweir // -----------------------------------------------------------------------------
76*cdf0e10cSrcweir SvxCTLOptionsPage::~SvxCTLOptionsPage()
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir }
79*cdf0e10cSrcweir // -----------------------------------------------------------------------------
80*cdf0e10cSrcweir SfxTabPage*	SvxCTLOptionsPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir 	return new SvxCTLOptionsPage( pParent, rAttrSet );
83*cdf0e10cSrcweir }
84*cdf0e10cSrcweir // -----------------------------------------------------------------------------
85*cdf0e10cSrcweir sal_Bool SvxCTLOptionsPage::FillItemSet( SfxItemSet& )
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir 	sal_Bool bModified = sal_False;
88*cdf0e10cSrcweir 	SvtCTLOptions aCTLOptions;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	// Sequence checking
91*cdf0e10cSrcweir 	sal_Bool bChecked = m_aSequenceCheckingCB.IsChecked();
92*cdf0e10cSrcweir 	if ( bChecked != m_aSequenceCheckingCB.GetSavedValue() )
93*cdf0e10cSrcweir     {
94*cdf0e10cSrcweir         aCTLOptions.SetCTLSequenceChecking( bChecked );
95*cdf0e10cSrcweir         bModified = sal_True;
96*cdf0e10cSrcweir     }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 	bChecked = m_aRestrictedCB.IsChecked();
99*cdf0e10cSrcweir 	if( bChecked != m_aRestrictedCB.GetSavedValue() )
100*cdf0e10cSrcweir     {
101*cdf0e10cSrcweir         aCTLOptions.SetCTLSequenceCheckingRestricted( bChecked );
102*cdf0e10cSrcweir         bModified = sal_True;
103*cdf0e10cSrcweir     }
104*cdf0e10cSrcweir     bChecked = m_aTypeReplaceCB.IsChecked();
105*cdf0e10cSrcweir     if( bChecked != m_aTypeReplaceCB.GetSavedValue())
106*cdf0e10cSrcweir     {
107*cdf0e10cSrcweir         aCTLOptions.SetCTLSequenceCheckingTypeAndReplace(bChecked);
108*cdf0e10cSrcweir         bModified = sal_True;
109*cdf0e10cSrcweir     }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	sal_Bool bLogicalChecked = m_aMovementLogicalRB.IsChecked();
112*cdf0e10cSrcweir 	sal_Bool bVisualChecked = m_aMovementVisualRB.IsChecked();
113*cdf0e10cSrcweir 	if ( bLogicalChecked != m_aMovementLogicalRB.GetSavedValue() ||
114*cdf0e10cSrcweir 		 bVisualChecked != m_aMovementVisualRB.GetSavedValue() )
115*cdf0e10cSrcweir     {
116*cdf0e10cSrcweir 		SvtCTLOptions::CursorMovement eMovement =
117*cdf0e10cSrcweir 			bLogicalChecked ? SvtCTLOptions::MOVEMENT_LOGICAL : SvtCTLOptions::MOVEMENT_VISUAL;
118*cdf0e10cSrcweir         aCTLOptions.SetCTLCursorMovement( eMovement );
119*cdf0e10cSrcweir         bModified = sal_True;
120*cdf0e10cSrcweir 	}
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 	sal_uInt16 nPos = m_aNumeralsLB.GetSelectEntryPos();
123*cdf0e10cSrcweir 	if ( nPos != m_aNumeralsLB.GetSavedValue() )
124*cdf0e10cSrcweir 	{
125*cdf0e10cSrcweir         aCTLOptions.SetCTLTextNumerals( (SvtCTLOptions::TextNumerals)nPos );
126*cdf0e10cSrcweir         bModified = sal_True;
127*cdf0e10cSrcweir 	}
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 	return bModified;
130*cdf0e10cSrcweir }
131*cdf0e10cSrcweir // -----------------------------------------------------------------------------
132*cdf0e10cSrcweir void SvxCTLOptionsPage::Reset( const SfxItemSet& )
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir 	SvtCTLOptions aCTLOptions;
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 	m_aSequenceCheckingCB.Check( aCTLOptions.IsCTLSequenceChecking() );
137*cdf0e10cSrcweir 	m_aRestrictedCB.Check( aCTLOptions.IsCTLSequenceCheckingRestricted() );
138*cdf0e10cSrcweir     m_aTypeReplaceCB.Check( aCTLOptions.IsCTLSequenceCheckingTypeAndReplace() );
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 	SvtCTLOptions::CursorMovement eMovement = aCTLOptions.GetCTLCursorMovement();
141*cdf0e10cSrcweir 	switch ( eMovement )
142*cdf0e10cSrcweir 	{
143*cdf0e10cSrcweir 		case SvtCTLOptions::MOVEMENT_LOGICAL :
144*cdf0e10cSrcweir 			m_aMovementLogicalRB.Check();
145*cdf0e10cSrcweir 			break;
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		case SvtCTLOptions::MOVEMENT_VISUAL :
148*cdf0e10cSrcweir 			m_aMovementVisualRB.Check();
149*cdf0e10cSrcweir 			break;
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 		default:
152*cdf0e10cSrcweir 			DBG_ERRORFILE( "SvxCTLOptionsPage::Reset(): invalid movement enum" );
153*cdf0e10cSrcweir 	}
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 	sal_uInt16 nPos = (sal_uInt16)aCTLOptions.GetCTLTextNumerals();
156*cdf0e10cSrcweir 	DBG_ASSERT( nPos < m_aNumeralsLB.GetEntryCount(), "SvxCTLOptionsPage::Reset(): invalid numerals enum" );
157*cdf0e10cSrcweir 	m_aNumeralsLB.SelectEntryPos( nPos );
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 	m_aSequenceCheckingCB.SaveValue();
160*cdf0e10cSrcweir 	m_aRestrictedCB.SaveValue();
161*cdf0e10cSrcweir     m_aTypeReplaceCB.SaveValue();
162*cdf0e10cSrcweir 	m_aMovementLogicalRB.SaveValue();
163*cdf0e10cSrcweir 	m_aMovementVisualRB.SaveValue();
164*cdf0e10cSrcweir 	m_aNumeralsLB.SaveValue();
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     sal_Bool bIsSequenceChecking = m_aSequenceCheckingCB.IsChecked();
167*cdf0e10cSrcweir     m_aRestrictedCB.Enable( bIsSequenceChecking );
168*cdf0e10cSrcweir     m_aTypeReplaceCB.Enable( bIsSequenceChecking );
169*cdf0e10cSrcweir }
170*cdf0e10cSrcweir 
171