Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / cui / source / options / optctl.cxx
blob1a62bb79e6736600bb9b68327b324e9be4a8fae8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include "optctl.hxx"
21 #include <dialmgr.hxx>
22 #include "optctl.hrc"
23 #include <cuires.hrc>
24 #include <svl/ctloptions.hxx>
26 // class SvxCTLOptionsPage -----------------------------------------------------
28 IMPL_LINK_NOARG(SvxCTLOptionsPage, SequenceCheckingCB_Hdl)
30 sal_Bool bIsSequenceChecking = m_aSequenceCheckingCB.IsChecked();
31 m_aRestrictedCB.Enable( bIsSequenceChecking );
32 m_aTypeReplaceCB.Enable( bIsSequenceChecking );
33 // #i48117#: by default restricted and type&replace have to be switched on
34 if(bIsSequenceChecking)
36 m_aTypeReplaceCB.Check( sal_True );
37 m_aRestrictedCB.Check( sal_True );
39 return 0;
42 SvxCTLOptionsPage::SvxCTLOptionsPage( Window* pParent, const SfxItemSet& rSet ) :
44 SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_OPTIONS_CTL ), rSet ),
46 m_aSequenceCheckingFL ( this, CUI_RES( FL_SEQUENCECHECKING ) ),
47 m_aSequenceCheckingCB ( this, CUI_RES( CB_SEQUENCECHECKING ) ),
48 m_aRestrictedCB ( this, CUI_RES( CB_RESTRICTED ) ),
49 m_aTypeReplaceCB ( this, CUI_RES( CB_TYPE_REPLACE ) ),
50 m_aCursorControlFL ( this, CUI_RES( FL_CURSORCONTROL ) ),
51 m_aMovementFT ( this, CUI_RES( FT_MOVEMENT ) ),
52 m_aMovementLogicalRB ( this, CUI_RES( RB_MOVEMENT_LOGICAL ) ),
53 m_aMovementVisualRB ( this, CUI_RES( RB_MOVEMENT_VISUAL ) ),
54 m_aGeneralFL ( this, CUI_RES( FL_GENERAL ) ),
55 m_aNumeralsFT ( this, CUI_RES( FT_NUMERALS ) ),
56 m_aNumeralsLB ( this, CUI_RES( LB_NUMERALS ) )
59 FreeResource();
61 m_aSequenceCheckingCB.SetClickHdl( LINK( this, SvxCTLOptionsPage, SequenceCheckingCB_Hdl ) );
63 m_aNumeralsLB.SetDropDownLineCount( m_aNumeralsLB.GetEntryCount() );
65 // -----------------------------------------------------------------------------
66 SvxCTLOptionsPage::~SvxCTLOptionsPage()
69 // -----------------------------------------------------------------------------
70 SfxTabPage* SvxCTLOptionsPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
72 return new SvxCTLOptionsPage( pParent, rAttrSet );
74 // -----------------------------------------------------------------------------
75 sal_Bool SvxCTLOptionsPage::FillItemSet( SfxItemSet& )
77 sal_Bool bModified = sal_False;
78 SvtCTLOptions aCTLOptions;
80 // Sequence checking
81 sal_Bool bChecked = m_aSequenceCheckingCB.IsChecked();
82 if ( bChecked != m_aSequenceCheckingCB.GetSavedValue() )
84 aCTLOptions.SetCTLSequenceChecking( bChecked );
85 bModified = sal_True;
88 bChecked = m_aRestrictedCB.IsChecked();
89 if( bChecked != m_aRestrictedCB.GetSavedValue() )
91 aCTLOptions.SetCTLSequenceCheckingRestricted( bChecked );
92 bModified = sal_True;
94 bChecked = m_aTypeReplaceCB.IsChecked();
95 if( bChecked != m_aTypeReplaceCB.GetSavedValue())
97 aCTLOptions.SetCTLSequenceCheckingTypeAndReplace(bChecked);
98 bModified = sal_True;
101 sal_Bool bLogicalChecked = m_aMovementLogicalRB.IsChecked();
102 sal_Bool bVisualChecked = m_aMovementVisualRB.IsChecked();
103 if ( bLogicalChecked != m_aMovementLogicalRB.GetSavedValue() ||
104 bVisualChecked != m_aMovementVisualRB.GetSavedValue() )
106 SvtCTLOptions::CursorMovement eMovement =
107 bLogicalChecked ? SvtCTLOptions::MOVEMENT_LOGICAL : SvtCTLOptions::MOVEMENT_VISUAL;
108 aCTLOptions.SetCTLCursorMovement( eMovement );
109 bModified = sal_True;
112 sal_uInt16 nPos = m_aNumeralsLB.GetSelectEntryPos();
113 if ( nPos != m_aNumeralsLB.GetSavedValue() )
115 aCTLOptions.SetCTLTextNumerals( (SvtCTLOptions::TextNumerals)nPos );
116 bModified = sal_True;
119 return bModified;
121 // -----------------------------------------------------------------------------
122 void SvxCTLOptionsPage::Reset( const SfxItemSet& )
124 SvtCTLOptions aCTLOptions;
126 m_aSequenceCheckingCB.Check( aCTLOptions.IsCTLSequenceChecking() );
127 m_aRestrictedCB.Check( aCTLOptions.IsCTLSequenceCheckingRestricted() );
128 m_aTypeReplaceCB.Check( aCTLOptions.IsCTLSequenceCheckingTypeAndReplace() );
130 SvtCTLOptions::CursorMovement eMovement = aCTLOptions.GetCTLCursorMovement();
131 switch ( eMovement )
133 case SvtCTLOptions::MOVEMENT_LOGICAL :
134 m_aMovementLogicalRB.Check();
135 break;
137 case SvtCTLOptions::MOVEMENT_VISUAL :
138 m_aMovementVisualRB.Check();
139 break;
141 default:
142 SAL_WARN( "cui.options", "SvxCTLOptionsPage::Reset(): invalid movement enum" );
145 sal_uInt16 nPos = (sal_uInt16)aCTLOptions.GetCTLTextNumerals();
146 DBG_ASSERT( nPos < m_aNumeralsLB.GetEntryCount(), "SvxCTLOptionsPage::Reset(): invalid numerals enum" );
147 m_aNumeralsLB.SelectEntryPos( nPos );
149 m_aSequenceCheckingCB.SaveValue();
150 m_aRestrictedCB.SaveValue();
151 m_aTypeReplaceCB.SaveValue();
152 m_aMovementLogicalRB.SaveValue();
153 m_aMovementVisualRB.SaveValue();
154 m_aNumeralsLB.SaveValue();
156 sal_Bool bIsSequenceChecking = m_aSequenceCheckingCB.IsChecked();
157 m_aRestrictedCB.Enable( bIsSequenceChecking );
158 m_aTypeReplaceCB.Enable( bIsSequenceChecking );
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */