1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: optctl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
38 #include <svx/dialmgr.hxx>
40 #ifndef _SVX_OPTCTL_HRC
43 #ifndef _SVX_DIALOGS_HRC
44 #include <svx/dialogs.hrc>
46 #include <svtools/ctloptions.hxx>
48 // class SvxCTLOptionsPage -----------------------------------------------------
50 IMPL_LINK( SvxCTLOptionsPage
, SequenceCheckingCB_Hdl
, void*, EMPTYARG
)
52 sal_Bool bIsSequenceChecking
= m_aSequenceCheckingCB
.IsChecked();
53 m_aRestrictedCB
.Enable( bIsSequenceChecking
);
54 m_aTypeReplaceCB
.Enable( bIsSequenceChecking
);
55 // #i48117#: by default restricted and type&replace have to be switched on
56 if(bIsSequenceChecking
)
58 m_aTypeReplaceCB
.Check( sal_True
);
59 m_aRestrictedCB
.Check( sal_True
);
64 SvxCTLOptionsPage::SvxCTLOptionsPage( Window
* pParent
, const SfxItemSet
& rSet
) :
66 SfxTabPage( pParent
, SVX_RES( RID_SVXPAGE_OPTIONS_CTL
), rSet
),
68 m_aSequenceCheckingFL ( this, SVX_RES( FL_SEQUENCECHECKING
) ),
69 m_aSequenceCheckingCB ( this, SVX_RES( CB_SEQUENCECHECKING
) ),
70 m_aRestrictedCB ( this, SVX_RES( CB_RESTRICTED
) ),
71 m_aTypeReplaceCB ( this, SVX_RES( CB_TYPE_REPLACE
) ),
72 m_aCursorControlFL ( this, SVX_RES( FL_CURSORCONTROL
) ),
73 m_aMovementFT ( this, SVX_RES( FT_MOVEMENT
) ),
74 m_aMovementLogicalRB ( this, SVX_RES( RB_MOVEMENT_LOGICAL
) ),
75 m_aMovementVisualRB ( this, SVX_RES( RB_MOVEMENT_VISUAL
) ),
76 m_aGeneralFL ( this, SVX_RES( FL_GENERAL
) ),
77 m_aNumeralsFT ( this, SVX_RES( FT_NUMERALS
) ),
78 m_aNumeralsLB ( this, SVX_RES( LB_NUMERALS
) )
83 m_aSequenceCheckingCB
.SetClickHdl( LINK( this, SvxCTLOptionsPage
, SequenceCheckingCB_Hdl
) );
85 m_aNumeralsLB
.SetDropDownLineCount( m_aNumeralsLB
.GetEntryCount() );
87 // -----------------------------------------------------------------------------
88 SvxCTLOptionsPage::~SvxCTLOptionsPage()
91 // -----------------------------------------------------------------------------
92 SfxTabPage
* SvxCTLOptionsPage::Create( Window
* pParent
, const SfxItemSet
& rAttrSet
)
94 return new SvxCTLOptionsPage( pParent
, rAttrSet
);
96 // -----------------------------------------------------------------------------
97 BOOL
SvxCTLOptionsPage::FillItemSet( SfxItemSet
& )
99 BOOL bModified
= FALSE
;
100 SvtCTLOptions aCTLOptions
;
103 BOOL bChecked
= m_aSequenceCheckingCB
.IsChecked();
104 if ( bChecked
!= m_aSequenceCheckingCB
.GetSavedValue() )
106 aCTLOptions
.SetCTLSequenceChecking( bChecked
);
110 bChecked
= m_aRestrictedCB
.IsChecked();
111 if( bChecked
!= m_aRestrictedCB
.GetSavedValue() )
113 aCTLOptions
.SetCTLSequenceCheckingRestricted( bChecked
);
116 bChecked
= m_aTypeReplaceCB
.IsChecked();
117 if( bChecked
!= m_aTypeReplaceCB
.GetSavedValue())
119 aCTLOptions
.SetCTLSequenceCheckingTypeAndReplace(bChecked
);
123 BOOL bLogicalChecked
= m_aMovementLogicalRB
.IsChecked();
124 BOOL bVisualChecked
= m_aMovementVisualRB
.IsChecked();
125 if ( bLogicalChecked
!= m_aMovementLogicalRB
.GetSavedValue() ||
126 bVisualChecked
!= m_aMovementVisualRB
.GetSavedValue() )
128 SvtCTLOptions::CursorMovement eMovement
=
129 bLogicalChecked
? SvtCTLOptions::MOVEMENT_LOGICAL
: SvtCTLOptions::MOVEMENT_VISUAL
;
130 aCTLOptions
.SetCTLCursorMovement( eMovement
);
134 USHORT nPos
= m_aNumeralsLB
.GetSelectEntryPos();
135 if ( nPos
!= m_aNumeralsLB
.GetSavedValue() )
137 aCTLOptions
.SetCTLTextNumerals( (SvtCTLOptions::TextNumerals
)nPos
);
143 // -----------------------------------------------------------------------------
144 void SvxCTLOptionsPage::Reset( const SfxItemSet
& )
146 SvtCTLOptions aCTLOptions
;
148 m_aSequenceCheckingCB
.Check( aCTLOptions
.IsCTLSequenceChecking() );
149 m_aRestrictedCB
.Check( aCTLOptions
.IsCTLSequenceCheckingRestricted() );
150 m_aTypeReplaceCB
.Check( aCTLOptions
.IsCTLSequenceCheckingTypeAndReplace() );
152 SvtCTLOptions::CursorMovement eMovement
= aCTLOptions
.GetCTLCursorMovement();
155 case SvtCTLOptions::MOVEMENT_LOGICAL
:
156 m_aMovementLogicalRB
.Check();
159 case SvtCTLOptions::MOVEMENT_VISUAL
:
160 m_aMovementVisualRB
.Check();
164 DBG_ERRORFILE( "SvxCTLOptionsPage::Reset(): invalid movement enum" );
167 USHORT nPos
= (USHORT
)aCTLOptions
.GetCTLTextNumerals();
168 DBG_ASSERT( nPos
< m_aNumeralsLB
.GetEntryCount(), "SvxCTLOptionsPage::Reset(): invalid numerals enum" );
169 m_aNumeralsLB
.SelectEntryPos( nPos
);
171 m_aSequenceCheckingCB
.SaveValue();
172 m_aRestrictedCB
.SaveValue();
173 m_aTypeReplaceCB
.SaveValue();
174 m_aMovementLogicalRB
.SaveValue();
175 m_aMovementVisualRB
.SaveValue();
176 m_aNumeralsLB
.SaveValue();
178 sal_Bool bIsSequenceChecking
= m_aSequenceCheckingCB
.IsChecked();
179 m_aRestrictedCB
.Enable( bIsSequenceChecking
);
180 m_aTypeReplaceCB
.Enable( bIsSequenceChecking
);