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