Kaydet (Commit) 873b1e16 authored tarafından Caolán McNamara's avatar Caolán McNamara

cppcheck: zerodivcond gold, address preview crash on key input

which never happened in practice because the entry never got
the keyboard events.

fix the col/row logic and let it get keyboard input, pass
unhandled events up the chain as normal.

Change-Id: I9fdf73808ef516284edb81f3cd04ccb1a24b8fe5
üst 24d62e2a
......@@ -197,7 +197,7 @@ SwAddressPreview::SwAddressPreview(vcl::Window* pParent, WinBits nStyle)
extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeSwAddressPreview(vcl::Window *pParent, VclBuilder::stringmap &rMap)
{
WinBits nWinStyle = WB_DIALOGCONTROL;
WinBits nWinStyle = WB_TABSTOP;
OString sBorder = VclBuilder::extractCustomProperty(rMap);
if (!sBorder.isEmpty())
nWinStyle |= WB_BORDER;
......@@ -378,28 +378,33 @@ void SwAddressPreview::MouseButtonDown( const MouseEvent& rMEvt )
void SwAddressPreview::KeyInput( const KeyEvent& rKEvt )
{
sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode();
if(pImpl->nRows || pImpl->nColumns)
bool bHandled = false;
if (pImpl->nRows && pImpl->nColumns)
{
sal_uInt32 nSelectedRow = (pImpl->nSelectedAddress + 1)/ pImpl->nColumns;
sal_uInt32 nSelectedColumn = pImpl->nSelectedAddress % nSelectedRow;
sal_uInt32 nSelectedRow = pImpl->nSelectedAddress / pImpl->nColumns;
sal_uInt32 nSelectedColumn = pImpl->nSelectedAddress - (nSelectedRow * pImpl->nColumns);
switch(nKey)
{
case KEY_UP:
if(nSelectedRow)
--nSelectedRow;
bHandled = true;
break;
case KEY_DOWN:
if(pImpl->aAddresses.size() > sal_uInt32(pImpl->nSelectedAddress + pImpl->nColumns))
++nSelectedRow;
bHandled = true;
break;
case KEY_LEFT:
if(nSelectedColumn)
--nSelectedColumn;
bHandled = true;
break;
case KEY_RIGHT:
if(nSelectedColumn < sal_uInt32(pImpl->nColumns - 1) &&
pImpl->aAddresses.size() - 1 > pImpl->nSelectedAddress )
++nSelectedColumn;
bHandled = true;
break;
}
sal_uInt32 nSelect = nSelectedRow * pImpl->nColumns + nSelectedColumn;
......@@ -411,7 +416,7 @@ void SwAddressPreview::KeyInput( const KeyEvent& rKEvt )
Invalidate();
}
}
else
if (!bHandled)
Window::KeyInput(rKEvt);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment