2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:15:01 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 16:55:43 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2005-11-16 08:48:14 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2005-11-16 08:48:14 +00:00
|
|
|
*
|
2008-04-10 16:55:43 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 16:55:43 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 16:55:43 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 16:55:43 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 16:55:43 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 21:37:06 +00:00
|
|
|
|
2011-11-18 21:03:31 +00:00
|
|
|
#include <comphelper/string.hxx>
|
2012-09-19 22:01:49 +01:00
|
|
|
#include <vcl/builder.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#include "actctrl.hxx"
|
|
|
|
|
|
|
|
void NumEditAction::Action()
|
|
|
|
{
|
|
|
|
aActionLink.Call( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long NumEditAction::Notify( NotifyEvent& rNEvt )
|
|
|
|
{
|
|
|
|
long nHandled = 0;
|
|
|
|
|
|
|
|
if ( rNEvt.GetType() == EVENT_KEYINPUT )
|
|
|
|
{
|
|
|
|
const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
|
|
|
|
const KeyCode aKeyCode = pKEvt->GetKeyCode();
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_uInt16 nModifier = aKeyCode.GetModifier();
|
2000-09-18 16:15:01 +00:00
|
|
|
if( aKeyCode.GetCode() == KEY_RETURN &&
|
|
|
|
!nModifier)
|
|
|
|
{
|
|
|
|
Action();
|
|
|
|
nHandled = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if(!nHandled)
|
|
|
|
NumericField::Notify( rNEvt );
|
|
|
|
return nHandled;
|
|
|
|
}
|
|
|
|
|
2009-09-11 09:17:29 +00:00
|
|
|
NoSpaceEdit::NoSpaceEdit( Window* pParent, const ResId& rResId)
|
|
|
|
: Edit(pParent, rResId),
|
2012-07-02 16:02:38 +01:00
|
|
|
sForbiddenChars(rtl::OUString(" "))
|
2009-09-11 09:17:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-04 16:49:42 +01:00
|
|
|
NoSpaceEdit::NoSpaceEdit(Window* pParent)
|
|
|
|
: Edit(pParent),
|
2012-09-27 15:06:29 +01:00
|
|
|
sForbiddenChars(rtl::OUString(" "))
|
2012-09-04 16:49:42 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-09-11 09:17:29 +00:00
|
|
|
NoSpaceEdit::~NoSpaceEdit()
|
|
|
|
{
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
void NoSpaceEdit::KeyInput(const KeyEvent& rEvt)
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bCallParent = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
if(rEvt.GetCharCode())
|
|
|
|
{
|
2012-07-04 23:58:05 +01:00
|
|
|
rtl::OUString sKey(rEvt.GetCharCode());
|
2000-09-18 16:15:01 +00:00
|
|
|
if( STRING_NOTFOUND != sForbiddenChars.Search(sKey))
|
2011-01-17 15:06:54 +01:00
|
|
|
bCallParent = sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
if(bCallParent)
|
|
|
|
Edit::KeyInput(rEvt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NoSpaceEdit::Modify()
|
|
|
|
{
|
|
|
|
Selection aSel = GetSelection();
|
|
|
|
String sTemp = GetText();
|
2011-01-17 15:06:54 +01:00
|
|
|
for(sal_uInt16 i = 0; i < sForbiddenChars.Len(); i++)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2011-11-18 21:03:31 +00:00
|
|
|
sTemp = comphelper::string::remove(sTemp, sForbiddenChars.GetChar(i));
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nDiff = GetText().Len() - sTemp.Len();
|
2000-09-18 16:15:01 +00:00
|
|
|
if(nDiff)
|
|
|
|
{
|
|
|
|
aSel.setMin(aSel.getMin() - nDiff);
|
|
|
|
aSel.setMax(aSel.getMin());
|
|
|
|
SetText(sTemp);
|
|
|
|
SetSelection(aSel);
|
|
|
|
}
|
|
|
|
if(GetModifyHdl().IsSet())
|
|
|
|
GetModifyHdl().Call(this);
|
|
|
|
}
|
|
|
|
|
2003-06-30 14:55:02 +00:00
|
|
|
ReturnActionEdit::~ReturnActionEdit()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReturnActionEdit::KeyInput( const KeyEvent& rEvt)
|
|
|
|
{
|
|
|
|
const KeyCode aKeyCode = rEvt.GetKeyCode();
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_uInt16 nModifier = aKeyCode.GetModifier();
|
2003-06-30 14:55:02 +00:00
|
|
|
if( aKeyCode.GetCode() == KEY_RETURN &&
|
|
|
|
!nModifier)
|
|
|
|
{
|
|
|
|
if(aReturnActionLink.IsSet())
|
|
|
|
aReturnActionLink.Call(this);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Edit::KeyInput(rEvt);
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-09-19 22:01:49 +01:00
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeTableNameEdit(Window *pParent, VclBuilder::stringmap &)
|
2012-09-04 16:49:42 +01:00
|
|
|
{
|
|
|
|
TableNameEdit* pTableNameEdit = new TableNameEdit(pParent);
|
2012-10-26 09:15:43 +01:00
|
|
|
pTableNameEdit->SetWidthInChars(25);
|
2012-09-04 16:49:42 +01:00
|
|
|
return pTableNameEdit;
|
|
|
|
}
|
|
|
|
|
2012-09-19 22:01:49 +01:00
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeNoSpaceEdit(Window *pParent, VclBuilder::stringmap &)
|
2012-09-04 16:49:42 +01:00
|
|
|
{
|
|
|
|
return new NoSpaceEdit(pParent);
|
|
|
|
}
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|