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 <cuires.hrc>
23 : #include <svl/ctloptions.hxx>
24 :
25 : // class SvxCTLOptionsPage -----------------------------------------------------
26 :
27 0 : IMPL_LINK_NOARG(SvxCTLOptionsPage, SequenceCheckingCB_Hdl)
28 : {
29 0 : bool bIsSequenceChecking = m_pSequenceCheckingCB->IsChecked();
30 0 : m_pRestrictedCB->Enable( bIsSequenceChecking );
31 0 : m_pTypeReplaceCB->Enable( bIsSequenceChecking );
32 : // #i48117#: by default restricted and type&replace have to be switched on
33 0 : if(bIsSequenceChecking)
34 : {
35 0 : m_pTypeReplaceCB->Check( true );
36 0 : m_pRestrictedCB->Check( true );
37 : }
38 0 : return 0;
39 : }
40 :
41 0 : SvxCTLOptionsPage::SvxCTLOptionsPage( vcl::Window* pParent, const SfxItemSet& rSet ) :
42 :
43 0 : SfxTabPage( pParent, "OptCTLPage", "cui/ui/optctlpage.ui", &rSet )
44 :
45 : {
46 0 : get( m_pSequenceCheckingCB, "sequencechecking");
47 0 : get( m_pRestrictedCB, "restricted");
48 0 : get( m_pTypeReplaceCB, "typeandreplace");
49 :
50 0 : get( m_pMovementLogicalRB, "movementlogical");
51 0 : get( m_pMovementVisualRB, "movementvisual");
52 :
53 0 : get( m_pNumeralsLB, "numerals");
54 :
55 0 : m_pSequenceCheckingCB->SetClickHdl( LINK( this, SvxCTLOptionsPage, SequenceCheckingCB_Hdl ) );
56 :
57 0 : m_pNumeralsLB->SetDropDownLineCount( m_pNumeralsLB->GetEntryCount() );
58 0 : }
59 :
60 0 : SvxCTLOptionsPage::~SvxCTLOptionsPage()
61 : {
62 0 : disposeOnce();
63 0 : }
64 :
65 0 : void SvxCTLOptionsPage::dispose()
66 : {
67 0 : m_pSequenceCheckingCB.clear();
68 0 : m_pRestrictedCB.clear();
69 0 : m_pTypeReplaceCB.clear();
70 0 : m_pMovementLogicalRB.clear();
71 0 : m_pMovementVisualRB.clear();
72 0 : m_pNumeralsLB.clear();
73 0 : SfxTabPage::dispose();
74 0 : }
75 :
76 0 : VclPtr<SfxTabPage> SvxCTLOptionsPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
77 : {
78 0 : return VclPtr<SvxCTLOptionsPage>::Create( pParent, *rAttrSet );
79 : }
80 :
81 0 : bool SvxCTLOptionsPage::FillItemSet( SfxItemSet* )
82 : {
83 0 : bool bModified = false;
84 0 : SvtCTLOptions aCTLOptions;
85 :
86 : // Sequence checking
87 0 : bool bChecked = m_pSequenceCheckingCB->IsChecked();
88 0 : if ( m_pSequenceCheckingCB->IsValueChangedFromSaved() )
89 : {
90 0 : aCTLOptions.SetCTLSequenceChecking( bChecked );
91 0 : bModified = true;
92 : }
93 :
94 0 : bChecked = m_pRestrictedCB->IsChecked();
95 0 : if( m_pRestrictedCB->IsValueChangedFromSaved() )
96 : {
97 0 : aCTLOptions.SetCTLSequenceCheckingRestricted( bChecked );
98 0 : bModified = true;
99 : }
100 0 : bChecked = m_pTypeReplaceCB->IsChecked();
101 0 : if( m_pTypeReplaceCB->IsValueChangedFromSaved())
102 : {
103 0 : aCTLOptions.SetCTLSequenceCheckingTypeAndReplace(bChecked);
104 0 : bModified = true;
105 : }
106 :
107 0 : bool bLogicalChecked = m_pMovementLogicalRB->IsChecked();
108 0 : if ( m_pMovementLogicalRB->IsValueChangedFromSaved() ||
109 0 : m_pMovementVisualRB->IsValueChangedFromSaved() )
110 : {
111 : SvtCTLOptions::CursorMovement eMovement =
112 0 : bLogicalChecked ? SvtCTLOptions::MOVEMENT_LOGICAL : SvtCTLOptions::MOVEMENT_VISUAL;
113 0 : aCTLOptions.SetCTLCursorMovement( eMovement );
114 0 : bModified = true;
115 : }
116 :
117 0 : if ( m_pNumeralsLB->IsValueChangedFromSaved() )
118 : {
119 0 : sal_uInt16 nPos = m_pNumeralsLB->GetSelectEntryPos();
120 0 : aCTLOptions.SetCTLTextNumerals( (SvtCTLOptions::TextNumerals)nPos );
121 0 : bModified = true;
122 : }
123 :
124 0 : return bModified;
125 : }
126 :
127 0 : void SvxCTLOptionsPage::Reset( const SfxItemSet* )
128 : {
129 0 : SvtCTLOptions aCTLOptions;
130 :
131 0 : m_pSequenceCheckingCB->Check( aCTLOptions.IsCTLSequenceChecking() );
132 0 : m_pRestrictedCB->Check( aCTLOptions.IsCTLSequenceCheckingRestricted() );
133 0 : m_pTypeReplaceCB->Check( aCTLOptions.IsCTLSequenceCheckingTypeAndReplace() );
134 :
135 0 : SvtCTLOptions::CursorMovement eMovement = aCTLOptions.GetCTLCursorMovement();
136 0 : switch ( eMovement )
137 : {
138 : case SvtCTLOptions::MOVEMENT_LOGICAL :
139 0 : m_pMovementLogicalRB->Check();
140 0 : break;
141 :
142 : case SvtCTLOptions::MOVEMENT_VISUAL :
143 0 : m_pMovementVisualRB->Check();
144 0 : break;
145 :
146 : default:
147 : SAL_WARN( "cui.options", "SvxCTLOptionsPage::Reset(): invalid movement enum" );
148 : }
149 :
150 0 : sal_uInt16 nPos = (sal_uInt16)aCTLOptions.GetCTLTextNumerals();
151 : DBG_ASSERT( nPos < m_pNumeralsLB->GetEntryCount(), "SvxCTLOptionsPage::Reset(): invalid numerals enum" );
152 0 : m_pNumeralsLB->SelectEntryPos( nPos );
153 :
154 0 : m_pSequenceCheckingCB->SaveValue();
155 0 : m_pRestrictedCB->SaveValue();
156 0 : m_pTypeReplaceCB->SaveValue();
157 0 : m_pMovementLogicalRB->SaveValue();
158 0 : m_pMovementVisualRB->SaveValue();
159 0 : m_pNumeralsLB->SaveValue();
160 :
161 0 : bool bIsSequenceChecking = m_pSequenceCheckingCB->IsChecked();
162 0 : m_pRestrictedCB->Enable( bIsSequenceChecking );
163 0 : m_pTypeReplaceCB->Enable( bIsSequenceChecking );
164 0 : }
165 :
166 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|