Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <comphelper/string.hxx>
31 : : #include "actctrl.hxx"
32 : :
33 : 0 : void NumEditAction::Action()
34 : : {
35 : 0 : aActionLink.Call( this );
36 : 0 : }
37 : :
38 : :
39 : 0 : long NumEditAction::Notify( NotifyEvent& rNEvt )
40 : : {
41 : 0 : long nHandled = 0;
42 : :
43 [ # # ]: 0 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
44 : : {
45 [ # # ]: 0 : const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
46 : 0 : const KeyCode aKeyCode = pKEvt->GetKeyCode();
47 : 0 : const sal_uInt16 nModifier = aKeyCode.GetModifier();
48 [ # # ][ # # ]: 0 : if( aKeyCode.GetCode() == KEY_RETURN &&
[ # # ]
49 : : !nModifier)
50 : : {
51 [ # # ]: 0 : Action();
52 : 0 : nHandled = 1;
53 : : }
54 : :
55 : : }
56 [ # # ]: 0 : if(!nHandled)
57 : 0 : NumericField::Notify( rNEvt );
58 : 0 : return nHandled;
59 : : }
60 : :
61 : 0 : NoSpaceEdit::NoSpaceEdit( Window* pParent, const ResId& rResId)
62 : : : Edit(pParent, rResId),
63 [ # # ]: 0 : sForbiddenChars(rtl::OUString(" "))
64 : : {
65 : 0 : }
66 : :
67 [ # # ]: 0 : NoSpaceEdit::~NoSpaceEdit()
68 : : {
69 [ # # ]: 0 : }
70 : :
71 : 0 : void NoSpaceEdit::KeyInput(const KeyEvent& rEvt)
72 : : {
73 : 0 : sal_Bool bCallParent = sal_True;
74 [ # # ]: 0 : if(rEvt.GetCharCode())
75 : : {
76 : 0 : rtl::OUString sKey(rEvt.GetCharCode());
77 [ # # ][ # # ]: 0 : if( STRING_NOTFOUND != sForbiddenChars.Search(sKey))
[ # # ][ # # ]
78 : 0 : bCallParent = sal_False;
79 : : }
80 [ # # ]: 0 : if(bCallParent)
81 : 0 : Edit::KeyInput(rEvt);
82 : 0 : }
83 : :
84 : 0 : void NoSpaceEdit::Modify()
85 : : {
86 [ # # ]: 0 : Selection aSel = GetSelection();
87 [ # # ]: 0 : String sTemp = GetText();
88 [ # # ]: 0 : for(sal_uInt16 i = 0; i < sForbiddenChars.Len(); i++)
89 : : {
90 [ # # ][ # # ]: 0 : sTemp = comphelper::string::remove(sTemp, sForbiddenChars.GetChar(i));
91 : : }
92 [ # # ][ # # ]: 0 : sal_uInt16 nDiff = GetText().Len() - sTemp.Len();
93 [ # # ]: 0 : if(nDiff)
94 : : {
95 : 0 : aSel.setMin(aSel.getMin() - nDiff);
96 : 0 : aSel.setMax(aSel.getMin());
97 [ # # ]: 0 : SetText(sTemp);
98 [ # # ]: 0 : SetSelection(aSel);
99 : : }
100 [ # # ][ # # ]: 0 : if(GetModifyHdl().IsSet())
[ # # ]
101 [ # # ][ # # ]: 0 : GetModifyHdl().Call(this);
[ # # ]
102 : 0 : }
103 : :
104 : 0 : ReturnActionEdit::~ReturnActionEdit()
105 : : {
106 [ # # ]: 0 : }
107 : :
108 : 0 : void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
109 : : {
110 : 0 : const KeyCode aKeyCode = rEvt.GetKeyCode();
111 : 0 : const sal_uInt16 nModifier = aKeyCode.GetModifier();
112 [ # # ][ # # ]: 0 : if( aKeyCode.GetCode() == KEY_RETURN &&
[ # # ]
113 : : !nModifier)
114 : : {
115 [ # # ][ # # ]: 0 : if(aReturnActionLink.IsSet())
116 [ # # ]: 0 : aReturnActionLink.Call(this);
117 : : }
118 : : else
119 [ # # ]: 0 : Edit::KeyInput(rEvt);
120 : 0 : }
121 : :
122 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|