1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10*efeef26fSAndrew Rist * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*efeef26fSAndrew Rist * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19*efeef26fSAndrew Rist * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <tools/list.hxx> 31cdf0e10cSrcweir #include "actctrl.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir 34cdf0e10cSrcweir 35cdf0e10cSrcweir void NumEditAction::Action() 36cdf0e10cSrcweir { 37cdf0e10cSrcweir aActionLink.Call( this ); 38cdf0e10cSrcweir } 39cdf0e10cSrcweir 40cdf0e10cSrcweir 41cdf0e10cSrcweir long NumEditAction::Notify( NotifyEvent& rNEvt ) 42cdf0e10cSrcweir { 43cdf0e10cSrcweir long nHandled = 0; 44cdf0e10cSrcweir 45cdf0e10cSrcweir if ( rNEvt.GetType() == EVENT_KEYINPUT ) 46cdf0e10cSrcweir { 47cdf0e10cSrcweir const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 48cdf0e10cSrcweir const KeyCode aKeyCode = pKEvt->GetKeyCode(); 49cdf0e10cSrcweir const sal_uInt16 nModifier = aKeyCode.GetModifier(); 50cdf0e10cSrcweir if( aKeyCode.GetCode() == KEY_RETURN && 51cdf0e10cSrcweir !nModifier) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir Action(); 54cdf0e10cSrcweir nHandled = 1; 55cdf0e10cSrcweir } 56cdf0e10cSrcweir 57cdf0e10cSrcweir } 58cdf0e10cSrcweir if(!nHandled) 59cdf0e10cSrcweir NumericField::Notify( rNEvt ); 60cdf0e10cSrcweir return nHandled; 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir /*------------------------------------------------------------------------ 64cdf0e10cSrcweir Beschreibung: KeyInput fuer ShortName - Edits ohne Spaces 65cdf0e10cSrcweir ------------------------------------------------------------------------*/ 66cdf0e10cSrcweir 67cdf0e10cSrcweir NoSpaceEdit::NoSpaceEdit( Window* pParent, const ResId& rResId) 68cdf0e10cSrcweir : Edit(pParent, rResId), 69cdf0e10cSrcweir sForbiddenChars(String::CreateFromAscii(" ")) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir NoSpaceEdit::~NoSpaceEdit() 74cdf0e10cSrcweir { 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir void NoSpaceEdit::KeyInput(const KeyEvent& rEvt) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir sal_Bool bCallParent = sal_True; 80cdf0e10cSrcweir if(rEvt.GetCharCode()) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir String sKey = rEvt.GetCharCode(); 83cdf0e10cSrcweir if( STRING_NOTFOUND != sForbiddenChars.Search(sKey)) 84cdf0e10cSrcweir bCallParent = sal_False; 85cdf0e10cSrcweir } 86cdf0e10cSrcweir if(bCallParent) 87cdf0e10cSrcweir Edit::KeyInput(rEvt); 88cdf0e10cSrcweir } 89cdf0e10cSrcweir /* -----------------------------11.02.00 15:28-------------------------------- 90cdf0e10cSrcweir 91cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 92cdf0e10cSrcweir void NoSpaceEdit::Modify() 93cdf0e10cSrcweir { 94cdf0e10cSrcweir Selection aSel = GetSelection(); 95cdf0e10cSrcweir String sTemp = GetText(); 96cdf0e10cSrcweir for(sal_uInt16 i = 0; i < sForbiddenChars.Len(); i++) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir sTemp.EraseAllChars( sForbiddenChars.GetChar(i) ); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir sal_uInt16 nDiff = GetText().Len() - sTemp.Len(); 101cdf0e10cSrcweir if(nDiff) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir aSel.setMin(aSel.getMin() - nDiff); 104cdf0e10cSrcweir aSel.setMax(aSel.getMin()); 105cdf0e10cSrcweir SetText(sTemp); 106cdf0e10cSrcweir SetSelection(aSel); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir if(GetModifyHdl().IsSet()) 109cdf0e10cSrcweir GetModifyHdl().Call(this); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir /* -----------------25.06.2003 15:57----------------- 112cdf0e10cSrcweir 113cdf0e10cSrcweir --------------------------------------------------*/ 114cdf0e10cSrcweir ReturnActionEdit::~ReturnActionEdit() 115cdf0e10cSrcweir { 116cdf0e10cSrcweir } 117cdf0e10cSrcweir /* -----------------25.06.2003 15:58----------------- 118cdf0e10cSrcweir 119cdf0e10cSrcweir --------------------------------------------------*/ 120cdf0e10cSrcweir void ReturnActionEdit::KeyInput( const KeyEvent& rEvt) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir const KeyCode aKeyCode = rEvt.GetKeyCode(); 123cdf0e10cSrcweir const sal_uInt16 nModifier = aKeyCode.GetModifier(); 124cdf0e10cSrcweir if( aKeyCode.GetCode() == KEY_RETURN && 125cdf0e10cSrcweir !nModifier) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir if(aReturnActionLink.IsSet()) 128cdf0e10cSrcweir aReturnActionLink.Call(this); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir else 131cdf0e10cSrcweir Edit::KeyInput(rEvt); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir 135