Kaydet (Commit) 7a5272dc authored tarafından pkoroau pkoroau's avatar pkoroau pkoroau Kaydeden (comit) Luboš Luňák

fdo#38837: Timers must end eventually [Writer idle timer]

Change-Id: I36c6c56d7277b9b3853b846c86c1f4dd47ebdb08
Signed-off-by: 's avatarLuboš Luňák <l.lunak@suse.cz>
üst 4241ef23
...@@ -20,31 +20,41 @@ ...@@ -20,31 +20,41 @@
#ifndef IDOCUMENTTIMERACCESS_HXX_INCLUDED #ifndef IDOCUMENTTIMERACCESS_HXX_INCLUDED
#define IDOCUMENTTIMERACCESS_HXX_INCLUDED #define IDOCUMENTTIMERACCESS_HXX_INCLUDED
/** Get information about the current document state /** Manipulate background jobs of the document. It starts with a mode of
'started' and a block count of 0.
*/ */
class IDocumentTimerAccess class IDocumentTimerAccess
{ {
public: public:
/** /**
Set modus to start, i.e. start timer if block count == 0 Set modus to 'start'.
*/ */
virtual void StartIdling() = 0; virtual void StartIdling() = 0;
/** /**
Set modus to stopped, i.e. stop timer if running Set mode to 'stopped'.
*/ */
virtual void StopIdling() = 0; virtual void StopIdling() = 0;
/** /**
Increment block count, stop timer if running Increment block count.
*/ */
virtual void BlockIdling() = 0; virtual void BlockIdling() = 0;
/** /**
Decrement block count, start timer if block count == 0 AND modus == start Decrement block count.
*/ */
virtual void UnblockIdling() = 0; virtual void UnblockIdling() = 0;
/**
Do these jobs asynchronously: do grammar checking,
do layout, and update fields.
They will be delayed until mode is start AND block count == 0.
The implementation might delay them further, for example
it might wait until the application is idle.
*/
virtual void StartBackgroundJobs() = 0;
protected: protected:
virtual ~IDocumentTimerAccess() {}; virtual ~IDocumentTimerAccess() {};
}; };
......
...@@ -965,6 +965,7 @@ public: ...@@ -965,6 +965,7 @@ public:
virtual void StopIdling(); virtual void StopIdling();
virtual void BlockIdling(); virtual void BlockIdling();
virtual void UnblockIdling(); virtual void UnblockIdling();
virtual void StartBackgroundJobs();
/** IDocumentChartDataProviderAccess /** IDocumentChartDataProviderAccess
*/ */
......
...@@ -2555,8 +2555,8 @@ void SwDocUpdtFld::RemoveFldType( const SwFieldType& rType ) ...@@ -2555,8 +2555,8 @@ void SwDocUpdtFld::RemoveFldType( const SwFieldType& rType )
} }
} }
SwDocUpdtFld::SwDocUpdtFld() SwDocUpdtFld::SwDocUpdtFld(SwDoc* pDoc)
: pFldSortLst(0), nFldLstGetMode(0) : pFldSortLst(0), nFldLstGetMode(0), pDocument(pDoc)
{ {
bInUpdateFlds = bFldsDirty = sal_False; bInUpdateFlds = bFldsDirty = sal_False;
memset( aFldTypeTable, 0, sizeof( aFldTypeTable ) ); memset( aFldTypeTable, 0, sizeof( aFldTypeTable ) );
......
...@@ -1817,6 +1817,11 @@ void SwDoc::UnblockIdling() ...@@ -1817,6 +1817,11 @@ void SwDoc::UnblockIdling()
aIdleTimer.Start(); aIdleTimer.Start();
} }
void SwDoc::StartBackgroundJobs() {
// Trigger DoIdleJobs(), asynchronously.
aIdleTimer.Start();
}
/************************************************************************* /*************************************************************************
|* |*
|* SwDoc::DoIdleJobs() |* SwDoc::DoIdleJobs()
...@@ -1839,8 +1844,7 @@ IMPL_LINK( SwDoc, DoIdleJobs, Timer *, pTimer ) ...@@ -1839,8 +1844,7 @@ IMPL_LINK( SwDoc, DoIdleJobs, Timer *, pTimer )
do { do {
if( pSh->ActionPend() ) if( pSh->ActionPend() )
{ {
if( pTimer ) pTimer->Start();
pTimer->Start();
return 0; return 0;
} }
pSh = (ViewShell*)pSh->GetNext(); pSh = (ViewShell*)pSh->GetNext();
...@@ -1856,7 +1860,6 @@ IMPL_LINK( SwDoc, DoIdleJobs, Timer *, pTimer ) ...@@ -1856,7 +1860,6 @@ IMPL_LINK( SwDoc, DoIdleJobs, Timer *, pTimer )
if (bIsOnlineSpell && bIsAutoGrammar) if (bIsOnlineSpell && bIsAutoGrammar)
StartGrammarChecking( *this ); StartGrammarChecking( *this );
} }
SwFldUpdateFlags nFldUpdFlag;
std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();//swmod 080320 std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();//swmod 080320
std::set<SwRootFrm*>::iterator pLayIter = aAllLayouts.begin(); std::set<SwRootFrm*>::iterator pLayIter = aAllLayouts.begin();
for ( ;pLayIter != aAllLayouts.end();++pLayIter ) for ( ;pLayIter != aAllLayouts.end();++pLayIter )
...@@ -1864,20 +1867,28 @@ IMPL_LINK( SwDoc, DoIdleJobs, Timer *, pTimer ) ...@@ -1864,20 +1867,28 @@ IMPL_LINK( SwDoc, DoIdleJobs, Timer *, pTimer )
if ((*pLayIter)->IsIdleFormat()) if ((*pLayIter)->IsIdleFormat())
{ {
(*pLayIter)->GetCurrShell()->LayoutIdle(); (*pLayIter)->GetCurrShell()->LayoutIdle();
break;
// Defer the remaining work.
pTimer->Start();
return 0;
} }
} }
bool bAllValid = pLayIter == aAllLayouts.end() ? 1 : 0;
if( bAllValid && ( AUTOUPD_FIELD_ONLY == SwFldUpdateFlags nFldUpdFlag = getFieldUpdateFlags(true);
( nFldUpdFlag = getFieldUpdateFlags(true) ) if( ( AUTOUPD_FIELD_ONLY == nFldUpdFlag
|| AUTOUPD_FIELD_AND_CHARTS == nFldUpdFlag ) && || AUTOUPD_FIELD_AND_CHARTS == nFldUpdFlag ) &&
GetUpdtFlds().IsFieldsDirty() && GetUpdtFlds().IsFieldsDirty()
!GetUpdtFlds().IsInUpdateFlds() &&
!IsExpFldsLocked()
// If we switch the field name the Fields are not updated. // If we switch the field name the Fields are not updated.
// So the "backgorund update" should always be carried out // So the "backgorund update" should always be carried out
/* && !pStartSh->GetViewOptions()->IsFldName()*/ ) /* && !pStartSh->GetViewOptions()->IsFldName()*/ )
{ {
if ( GetUpdtFlds().IsInUpdateFlds() ||
IsExpFldsLocked() )
{
pTimer->Start();
return 0;
}
// Action brackets! // Action brackets!
GetUpdtFlds().SetInUpdateFlds( true ); GetUpdtFlds().SetInUpdateFlds( true );
...@@ -1904,8 +1915,6 @@ IMPL_LINK( SwDoc, DoIdleJobs, Timer *, pTimer ) ...@@ -1904,8 +1915,6 @@ IMPL_LINK( SwDoc, DoIdleJobs, Timer *, pTimer )
if( pModLogFile && 1 != (long)pModLogFile ) if( pModLogFile && 1 != (long)pModLogFile )
delete pModLogFile, ((long&)pModLogFile) = 1; delete pModLogFile, ((long&)pModLogFile) = 1;
#endif #endif
if( pTimer )
pTimer->Start();
return 0; return 0;
} }
......
...@@ -211,7 +211,7 @@ SwDoc::SwDoc() ...@@ -211,7 +211,7 @@ SwDoc::SwDoc()
pDefTOXBases( new SwDefTOXBase_Impl() ), pDefTOXBases( new SwDefTOXBase_Impl() ),
pCurrentView( 0 ), //swmod 071225 pCurrentView( 0 ), //swmod 071225
pDrawModel( 0 ), pDrawModel( 0 ),
pUpdtFlds( new SwDocUpdtFld() ), pUpdtFlds( new SwDocUpdtFld( this ) ),
pFldTypes( new SwFldTypes() ), pFldTypes( new SwFldTypes() ),
pVirDev( 0 ), pVirDev( 0 ),
pPrt( 0 ), pPrt( 0 ),
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define _DOCFLD_HXX #define _DOCFLD_HXX
#include <calc.hxx> #include <calc.hxx>
#include <doc.hxx>
#include <o3tl/sorted_vector.hxx> #include <o3tl/sorted_vector.hxx>
class SwTxtFld; class SwTxtFld;
...@@ -146,6 +147,7 @@ class SwDocUpdtFld ...@@ -146,6 +147,7 @@ class SwDocUpdtFld
sal_uLong nNodes; // if the node count is different sal_uLong nNodes; // if the node count is different
sal_uInt8 nFldLstGetMode; sal_uInt8 nFldLstGetMode;
SwDoc* pDocument;
bool bInUpdateFlds : 1; // currently there is an UpdateFlds bool bInUpdateFlds : 1; // currently there is an UpdateFlds
bool bFldsDirty : 1; // some fields are invalid bool bFldsDirty : 1; // some fields are invalid
...@@ -155,7 +157,7 @@ class SwDocUpdtFld ...@@ -155,7 +157,7 @@ class SwDocUpdtFld
void GetBodyNode( const SwSectionNode&); void GetBodyNode( const SwSectionNode&);
public: public:
SwDocUpdtFld(); SwDocUpdtFld(SwDoc* pDocument);
~SwDocUpdtFld(); ~SwDocUpdtFld();
const _SetGetExpFlds* GetSortLst() const { return pFldSortLst; } const _SetGetExpFlds* GetSortLst() const { return pFldSortLst; }
...@@ -171,7 +173,15 @@ public: ...@@ -171,7 +173,15 @@ public:
void SetInUpdateFlds( bool b ) { bInUpdateFlds = b; } void SetInUpdateFlds( bool b ) { bInUpdateFlds = b; }
bool IsFieldsDirty() const { return bFldsDirty; } bool IsFieldsDirty() const { return bFldsDirty; }
void SetFieldsDirty( bool b ) { bFldsDirty = b; } void SetFieldsDirty( bool b )
{
bFldsDirty = b;
if (b)
{
pDocument->StartBackgroundJobs();
}
}
SwHash** GetFldTypeTable() const { return (SwHash**)aFldTypeTable; } SwHash** GetFldTypeTable() const { return (SwHash**)aFldTypeTable; }
}; };
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#define SW_ROOTFRM_HXX #define SW_ROOTFRM_HXX
#include "layfrm.hxx" #include "layfrm.hxx"
#include <viewsh.hxx>
#include <doc.hxx>
class SwCntntFrm; class SwCntntFrm;
class ViewShell; class ViewShell;
...@@ -203,12 +205,33 @@ public: ...@@ -203,12 +205,33 @@ public:
virtual Size ChgSize( const Size& aNewSize ); virtual Size ChgSize( const Size& aNewSize );
void SetIdleFlags() { bIdleFormat = sal_True; } void SetIdleFlags()
{
bIdleFormat = sal_True;
ViewShell* lcl_pCurrShell = GetCurrShell();
// May be NULL if called from SfxBaseModel::dispose
// (this happens in the build test 'rtfexport').
if (lcl_pCurrShell != NULL)
lcl_pCurrShell->GetDoc()->StartBackgroundJobs();
}
sal_Bool IsIdleFormat() const { return bIdleFormat; } sal_Bool IsIdleFormat() const { return bIdleFormat; }
void ResetIdleFormat() { bIdleFormat = sal_False; } void ResetIdleFormat() { bIdleFormat = sal_False; }
bool IsNeedGrammarCheck() const { return mbNeedGrammarCheck; } bool IsNeedGrammarCheck() const { return mbNeedGrammarCheck; }
void SetNeedGrammarCheck( bool bVal ) { mbNeedGrammarCheck = bVal; } void SetNeedGrammarCheck( bool bVal )
{
mbNeedGrammarCheck = bVal;
if ( bVal )
{
ViewShell* lcl_pCurrShell = GetCurrShell();
// May be NULL if called from SfxBaseModel::dispose
// (this happens in the build test 'rtfexport').
if (lcl_pCurrShell != NULL)
lcl_pCurrShell->GetDoc()->StartBackgroundJobs();
}
}
//Sorgt dafuer, dass alle gewuenschten Seitengebunden Flys eine Seite finden //Sorgt dafuer, dass alle gewuenschten Seitengebunden Flys eine Seite finden
void SetAssertFlyPages() { bAssertFlyPages = sal_True; } void SetAssertFlyPages() { bAssertFlyPages = sal_True; }
......
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