Update ooo320-m1
[ooovba.git] / sw / source / ui / cctrl / actctrl.cxx
blob2122bc9b4602076d520768d6bc90a1c461171aad
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: actctrl.cxx,v $
10 * $Revision: 1.9 $
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_sw.hxx"
37 #include <tools/list.hxx>
38 #include "actctrl.hxx"
42 void NumEditAction::Action()
44 aActionLink.Call( this );
48 long NumEditAction::Notify( NotifyEvent& rNEvt )
50 long nHandled = 0;
52 if ( rNEvt.GetType() == EVENT_KEYINPUT )
54 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
55 const KeyCode aKeyCode = pKEvt->GetKeyCode();
56 const USHORT nModifier = aKeyCode.GetModifier();
57 if( aKeyCode.GetCode() == KEY_RETURN &&
58 !nModifier)
60 Action();
61 nHandled = 1;
65 if(!nHandled)
66 NumericField::Notify( rNEvt );
67 return nHandled;
70 /*------------------------------------------------------------------------
71 Beschreibung: KeyInput fuer ShortName - Edits ohne Spaces
72 ------------------------------------------------------------------------*/
74 NoSpaceEdit::NoSpaceEdit( Window* pParent, const ResId& rResId)
75 : Edit(pParent, rResId),
76 sForbiddenChars(String::CreateFromAscii(" "))
80 NoSpaceEdit::~NoSpaceEdit()
84 void NoSpaceEdit::KeyInput(const KeyEvent& rEvt)
86 BOOL bCallParent = TRUE;
87 if(rEvt.GetCharCode())
89 String sKey = rEvt.GetCharCode();
90 if( STRING_NOTFOUND != sForbiddenChars.Search(sKey))
91 bCallParent = FALSE;
93 if(bCallParent)
94 Edit::KeyInput(rEvt);
96 /* -----------------------------11.02.00 15:28--------------------------------
98 ---------------------------------------------------------------------------*/
99 void NoSpaceEdit::Modify()
101 Selection aSel = GetSelection();
102 String sTemp = GetText();
103 for(USHORT i = 0; i < sForbiddenChars.Len(); i++)
105 sTemp.EraseAllChars( sForbiddenChars.GetChar(i) );
107 USHORT nDiff = GetText().Len() - sTemp.Len();
108 if(nDiff)
110 aSel.setMin(aSel.getMin() - nDiff);
111 aSel.setMax(aSel.getMin());
112 SetText(sTemp);
113 SetSelection(aSel);
115 if(GetModifyHdl().IsSet())
116 GetModifyHdl().Call(this);
118 /* -----------------25.06.2003 15:57-----------------
120 --------------------------------------------------*/
121 ReturnActionEdit::~ReturnActionEdit()
124 /* -----------------25.06.2003 15:58-----------------
126 --------------------------------------------------*/
127 void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
129 const KeyCode aKeyCode = rEvt.GetKeyCode();
130 const USHORT nModifier = aKeyCode.GetModifier();
131 if( aKeyCode.GetCode() == KEY_RETURN &&
132 !nModifier)
134 if(aReturnActionLink.IsSet())
135 aReturnActionLink.Call(this);
137 else
138 Edit::KeyInput(rEvt);