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