Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "optctl.hxx"
21 : #include <dialmgr.hxx>
22 : #include "optctl.hrc"
23 : #include <cuires.hrc>
24 : #include <svl/ctloptions.hxx>
25 :
26 : // class SvxCTLOptionsPage -----------------------------------------------------
27 :
28 0 : IMPL_LINK_NOARG(SvxCTLOptionsPage, SequenceCheckingCB_Hdl)
29 : {
30 0 : sal_Bool bIsSequenceChecking = m_aSequenceCheckingCB.IsChecked();
31 0 : m_aRestrictedCB.Enable( bIsSequenceChecking );
32 0 : m_aTypeReplaceCB.Enable( bIsSequenceChecking );
33 : // #i48117#: by default restricted and type&replace have to be switched on
34 0 : if(bIsSequenceChecking)
35 : {
36 0 : m_aTypeReplaceCB.Check( sal_True );
37 0 : m_aRestrictedCB.Check( sal_True );
38 : }
39 0 : return 0;
40 : }
41 :
42 0 : SvxCTLOptionsPage::SvxCTLOptionsPage( Window* pParent, const SfxItemSet& rSet ) :
43 :
44 0 : SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_OPTIONS_CTL ), rSet ),
45 :
46 0 : m_aSequenceCheckingFL ( this, CUI_RES( FL_SEQUENCECHECKING ) ),
47 0 : m_aSequenceCheckingCB ( this, CUI_RES( CB_SEQUENCECHECKING ) ),
48 0 : m_aRestrictedCB ( this, CUI_RES( CB_RESTRICTED ) ),
49 0 : m_aTypeReplaceCB ( this, CUI_RES( CB_TYPE_REPLACE ) ),
50 0 : m_aCursorControlFL ( this, CUI_RES( FL_CURSORCONTROL ) ),
51 0 : m_aMovementFT ( this, CUI_RES( FT_MOVEMENT ) ),
52 0 : m_aMovementLogicalRB ( this, CUI_RES( RB_MOVEMENT_LOGICAL ) ),
53 0 : m_aMovementVisualRB ( this, CUI_RES( RB_MOVEMENT_VISUAL ) ),
54 0 : m_aGeneralFL ( this, CUI_RES( FL_GENERAL ) ),
55 0 : m_aNumeralsFT ( this, CUI_RES( FT_NUMERALS ) ),
56 0 : m_aNumeralsLB ( this, CUI_RES( LB_NUMERALS ) )
57 :
58 : {
59 0 : FreeResource();
60 :
61 0 : m_aSequenceCheckingCB.SetClickHdl( LINK( this, SvxCTLOptionsPage, SequenceCheckingCB_Hdl ) );
62 :
63 0 : m_aNumeralsLB.SetDropDownLineCount( m_aNumeralsLB.GetEntryCount() );
64 0 : }
65 : // -----------------------------------------------------------------------------
66 0 : SvxCTLOptionsPage::~SvxCTLOptionsPage()
67 : {
68 0 : }
69 : // -----------------------------------------------------------------------------
70 0 : SfxTabPage* SvxCTLOptionsPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
71 : {
72 0 : return new SvxCTLOptionsPage( pParent, rAttrSet );
73 : }
74 : // -----------------------------------------------------------------------------
75 0 : sal_Bool SvxCTLOptionsPage::FillItemSet( SfxItemSet& )
76 : {
77 0 : sal_Bool bModified = sal_False;
78 0 : SvtCTLOptions aCTLOptions;
79 :
80 : // Sequence checking
81 0 : sal_Bool bChecked = m_aSequenceCheckingCB.IsChecked();
82 0 : if ( bChecked != m_aSequenceCheckingCB.GetSavedValue() )
83 : {
84 0 : aCTLOptions.SetCTLSequenceChecking( bChecked );
85 0 : bModified = sal_True;
86 : }
87 :
88 0 : bChecked = m_aRestrictedCB.IsChecked();
89 0 : if( bChecked != m_aRestrictedCB.GetSavedValue() )
90 : {
91 0 : aCTLOptions.SetCTLSequenceCheckingRestricted( bChecked );
92 0 : bModified = sal_True;
93 : }
94 0 : bChecked = m_aTypeReplaceCB.IsChecked();
95 0 : if( bChecked != m_aTypeReplaceCB.GetSavedValue())
96 : {
97 0 : aCTLOptions.SetCTLSequenceCheckingTypeAndReplace(bChecked);
98 0 : bModified = sal_True;
99 : }
100 :
101 0 : sal_Bool bLogicalChecked = m_aMovementLogicalRB.IsChecked();
102 0 : sal_Bool bVisualChecked = m_aMovementVisualRB.IsChecked();
103 0 : if ( bLogicalChecked != m_aMovementLogicalRB.GetSavedValue() ||
104 0 : bVisualChecked != m_aMovementVisualRB.GetSavedValue() )
105 : {
106 : SvtCTLOptions::CursorMovement eMovement =
107 0 : bLogicalChecked ? SvtCTLOptions::MOVEMENT_LOGICAL : SvtCTLOptions::MOVEMENT_VISUAL;
108 0 : aCTLOptions.SetCTLCursorMovement( eMovement );
109 0 : bModified = sal_True;
110 : }
111 :
112 0 : sal_uInt16 nPos = m_aNumeralsLB.GetSelectEntryPos();
113 0 : if ( nPos != m_aNumeralsLB.GetSavedValue() )
114 : {
115 0 : aCTLOptions.SetCTLTextNumerals( (SvtCTLOptions::TextNumerals)nPos );
116 0 : bModified = sal_True;
117 : }
118 :
119 0 : return bModified;
120 : }
121 : // -----------------------------------------------------------------------------
122 0 : void SvxCTLOptionsPage::Reset( const SfxItemSet& )
123 : {
124 0 : SvtCTLOptions aCTLOptions;
125 :
126 0 : m_aSequenceCheckingCB.Check( aCTLOptions.IsCTLSequenceChecking() );
127 0 : m_aRestrictedCB.Check( aCTLOptions.IsCTLSequenceCheckingRestricted() );
128 0 : m_aTypeReplaceCB.Check( aCTLOptions.IsCTLSequenceCheckingTypeAndReplace() );
129 :
130 0 : SvtCTLOptions::CursorMovement eMovement = aCTLOptions.GetCTLCursorMovement();
131 0 : switch ( eMovement )
132 : {
133 : case SvtCTLOptions::MOVEMENT_LOGICAL :
134 0 : m_aMovementLogicalRB.Check();
135 0 : break;
136 :
137 : case SvtCTLOptions::MOVEMENT_VISUAL :
138 0 : m_aMovementVisualRB.Check();
139 0 : break;
140 :
141 : default:
142 : SAL_WARN( "cui.options", "SvxCTLOptionsPage::Reset(): invalid movement enum" );
143 : }
144 :
145 0 : sal_uInt16 nPos = (sal_uInt16)aCTLOptions.GetCTLTextNumerals();
146 : DBG_ASSERT( nPos < m_aNumeralsLB.GetEntryCount(), "SvxCTLOptionsPage::Reset(): invalid numerals enum" );
147 0 : m_aNumeralsLB.SelectEntryPos( nPos );
148 :
149 0 : m_aSequenceCheckingCB.SaveValue();
150 0 : m_aRestrictedCB.SaveValue();
151 0 : m_aTypeReplaceCB.SaveValue();
152 0 : m_aMovementLogicalRB.SaveValue();
153 0 : m_aMovementVisualRB.SaveValue();
154 0 : m_aNumeralsLB.SaveValue();
155 :
156 0 : sal_Bool bIsSequenceChecking = m_aSequenceCheckingCB.IsChecked();
157 0 : m_aRestrictedCB.Enable( bIsSequenceChecking );
158 0 : m_aTypeReplaceCB.Enable( bIsSequenceChecking );
159 3 : }
160 :
161 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|