1efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5efeef26fSAndrew Rist * distributed with this work for additional information 6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10efeef26fSAndrew Rist * 11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12efeef26fSAndrew Rist * 13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14efeef26fSAndrew Rist * software distributed under the License is distributed on an 15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17efeef26fSAndrew Rist * specific language governing permissions and limitations 18efeef26fSAndrew Rist * under the License. 19efeef26fSAndrew Rist * 20efeef26fSAndrew Rist *************************************************************/ 21efeef26fSAndrew Rist 22efeef26fSAndrew 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 Action()35cdf0e10cSrcweirvoid NumEditAction::Action() 36cdf0e10cSrcweir { 37cdf0e10cSrcweir aActionLink.Call( this ); 38cdf0e10cSrcweir } 39cdf0e10cSrcweir 40cdf0e10cSrcweir Notify(NotifyEvent & rNEvt)41cdf0e10cSrcweirlong 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 NoSpaceEdit(Window * pParent,const ResId & rResId)67cdf0e10cSrcweirNoSpaceEdit::NoSpaceEdit( Window* pParent, const ResId& rResId) 68cdf0e10cSrcweir : Edit(pParent, rResId), 69cdf0e10cSrcweir sForbiddenChars(String::CreateFromAscii(" ")) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir } 72cdf0e10cSrcweir ~NoSpaceEdit()73cdf0e10cSrcweirNoSpaceEdit::~NoSpaceEdit() 74cdf0e10cSrcweir { 75cdf0e10cSrcweir } 76cdf0e10cSrcweir KeyInput(const KeyEvent & rEvt)77cdf0e10cSrcweirvoid 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 ---------------------------------------------------------------------------*/ Modify()92cdf0e10cSrcweirvoid 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 } 108*ca62e2c2SSteve Yin Edit::Modify(); 109*ca62e2c2SSteve Yin /* 110cdf0e10cSrcweir if(GetModifyHdl().IsSet()) 111cdf0e10cSrcweir GetModifyHdl().Call(this); 112*ca62e2c2SSteve Yin */ 113cdf0e10cSrcweir } 114cdf0e10cSrcweir /* -----------------25.06.2003 15:57----------------- 115cdf0e10cSrcweir 116cdf0e10cSrcweir --------------------------------------------------*/ ~ReturnActionEdit()117cdf0e10cSrcweirReturnActionEdit::~ReturnActionEdit() 118cdf0e10cSrcweir { 119cdf0e10cSrcweir } 120cdf0e10cSrcweir /* -----------------25.06.2003 15:58----------------- 121cdf0e10cSrcweir 122cdf0e10cSrcweir --------------------------------------------------*/ KeyInput(const KeyEvent & rEvt)123cdf0e10cSrcweirvoid ReturnActionEdit::KeyInput( const KeyEvent& rEvt) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir const KeyCode aKeyCode = rEvt.GetKeyCode(); 126cdf0e10cSrcweir const sal_uInt16 nModifier = aKeyCode.GetModifier(); 127cdf0e10cSrcweir if( aKeyCode.GetCode() == KEY_RETURN && 128cdf0e10cSrcweir !nModifier) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir if(aReturnActionLink.IsSet()) 131cdf0e10cSrcweir aReturnActionLink.Call(this); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir else 134cdf0e10cSrcweir Edit::KeyInput(rEvt); 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir 138