summaryrefslogtreecommitdiff
path: root/sc/source/ui/app
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2016-11-02 16:43:02 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2017-01-17 16:08:47 +0100
commit1531152eff8061d63be5d98641fcafaa1da05167 (patch)
tree9fa0c657e42b1510b4b9acccc0b76889ddc4b9e5 /sc/source/ui/app
parentfdc612619c1c133353026166206cea18c48089a6 (diff)
Add sensible timer handling for Calc input
There is no need to destroy and recreate the timer object. Simply stop and start the timer as required. Change-Id: I2885fef8bdb90c379dc2e9b9caf986d250face5c
Diffstat (limited to 'sc/source/ui/app')
-rw-r--r--sc/source/ui/app/inputhdl.cxx79
1 files changed, 31 insertions, 48 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index e2c96c62b02c..2f1c901eaca2 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -645,6 +645,10 @@ ScInputHandler::ScInputHandler()
pActiveViewSh = nullptr;
// Bindings (only still used for Invalidate) are retrieved if needed on demand
+
+ pDelayTimer = new Timer( "ScInputHandlerDelay timer" );
+ pDelayTimer->SetTimeout( 500 ); // 500 ms delay
+ pDelayTimer->SetTimeoutHdl( LINK( this, ScInputHandler, DelayTimer ) );
}
ScInputHandler::~ScInputHandler()
@@ -3722,36 +3726,23 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
{
if ( !pInputWin->IsEnabled())
{
+ pDelayTimer->Stop();
pInputWin->Enable();
- if(pDelayTimer )
- {
- DELETEZ( pDelayTimer );
- }
}
}
else if(pScMod->IsRefDialogOpen())
{ // Because every document has its own InputWin,
// we should start Timer again, because the input line may
// still be active
- if ( !pDelayTimer )
- {
- pDelayTimer = new Timer("Restart ScInputHandlerDelay timer");
- pDelayTimer->SetTimeout( 500 ); // 500 ms delay
- pDelayTimer->SetTimeoutHdl( LINK( this, ScInputHandler, DelayTimer ) );
+ if ( !pDelayTimer->IsActive() )
pDelayTimer->Start();
- }
}
}
}
else // !pState || !pActiveViewSh
{
- if ( !pDelayTimer )
- {
- pDelayTimer = new Timer("ScInputHandlerDelay timer");
- pDelayTimer->SetTimeout( 500 ); // 500 ms delay
- pDelayTimer->SetTimeoutHdl( LINK( this, ScInputHandler, DelayTimer ) );
+ if ( !pDelayTimer->IsActive() )
pDelayTimer->Start();
- }
}
HideTip();
@@ -3767,50 +3758,42 @@ void ScInputHandler::UpdateCellAdjust( SvxCellHorJustify eJust )
void ScInputHandler::ResetDelayTimer()
{
- if(pDelayTimer!=nullptr)
+ if( pDelayTimer->IsActive() )
{
- DELETEZ( pDelayTimer );
-
- if ( pInputWin)
- {
+ pDelayTimer->Stop();
+ if ( pInputWin )
pInputWin->Enable();
- }
}
}
-IMPL_LINK( ScInputHandler, DelayTimer, Timer*, pTimer, void )
+IMPL_LINK_NOARG( ScInputHandler, DelayTimer, Timer*, void )
{
- if ( pTimer == pDelayTimer )
+ if ( nullptr == pLastState || SC_MOD()->IsFormulaMode() || SC_MOD()->IsRefDialogOpen())
{
- DELETEZ( pDelayTimer );
-
- if ( nullptr == pLastState || SC_MOD()->IsFormulaMode() || SC_MOD()->IsRefDialogOpen())
+ //! New method at ScModule to query if function autopilot is open
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if ( pViewFrm && pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) )
{
- //! New method at ScModule to query if function autopilot is open
- SfxViewFrame* pViewFrm = SfxViewFrame::Current();
- if ( pViewFrm && pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) )
+ if ( pInputWin)
{
- if ( pInputWin)
- {
- pInputWin->EnableButtons( false );
- pInputWin->Disable();
- }
+ pInputWin->EnableButtons( false );
+ pInputWin->Disable();
}
- else if ( !bFormulaMode ) // Keep formula e.g. for help
- {
- bInOwnChange = true; // disable ModifyHdl (reset below)
-
- pActiveViewSh = nullptr;
- mpEditEngine->SetText( EMPTY_OUSTRING );
- if ( pInputWin )
- {
- pInputWin->SetPosString( EMPTY_OUSTRING );
- pInputWin->SetTextString( EMPTY_OUSTRING );
- pInputWin->Disable();
- }
+ }
+ else if ( !bFormulaMode ) // Keep formula e.g. for help
+ {
+ bInOwnChange = true; // disable ModifyHdl (reset below)
- bInOwnChange = false;
+ pActiveViewSh = nullptr;
+ mpEditEngine->SetText( EMPTY_OUSTRING );
+ if ( pInputWin )
+ {
+ pInputWin->SetPosString( EMPTY_OUSTRING );
+ pInputWin->SetTextString( EMPTY_OUSTRING );
+ pInputWin->Disable();
}
+
+ bInOwnChange = false;
}
}
}