xref: /aoo42x/main/sw/source/ui/cctrl/actctrl.cxx (revision 4d7c9de0)
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 
Action()35 void NumEditAction::Action()
36 {
37 	aActionLink.Call( this );
38 }
39 
40 
Notify(NotifyEvent & rNEvt)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 
NoSpaceEdit(Window * pParent,const ResId & rResId)67 NoSpaceEdit::NoSpaceEdit( Window* pParent, const ResId& rResId)
68     : Edit(pParent, rResId),
69     sForbiddenChars(String::CreateFromAscii(" "))
70 {
71 }
72 
~NoSpaceEdit()73 NoSpaceEdit::~NoSpaceEdit()
74 {
75 }
76 
KeyInput(const KeyEvent & rEvt)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  ---------------------------------------------------------------------------*/
Modify()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 	Edit::Modify();
109 	/*
110 	if(GetModifyHdl().IsSet())
111 		GetModifyHdl().Call(this);
112 		*/
113 }
114 /* -----------------25.06.2003 15:57-----------------
115 
116  --------------------------------------------------*/
~ReturnActionEdit()117 ReturnActionEdit::~ReturnActionEdit()
118 {
119 }
120 /* -----------------25.06.2003 15:58-----------------
121 
122  --------------------------------------------------*/
KeyInput(const KeyEvent & rEvt)123 void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
124 {
125     const KeyCode aKeyCode = rEvt.GetKeyCode();
126     const sal_uInt16 nModifier = aKeyCode.GetModifier();
127     if( aKeyCode.GetCode() == KEY_RETURN &&
128             !nModifier)
129     {
130         if(aReturnActionLink.IsSet())
131             aReturnActionLink.Call(this);
132     }
133     else
134         Edit::KeyInput(rEvt);
135 }
136 
137 
138