Kaydet (Commit) 5adc8ee3 authored tarafından Michael Stahl's avatar Michael Stahl

sw: fix newly created document being modified

After the document is created, an event is dispatched on the main loop
that calls SfxPickList::Notify(), which modifies document properties.

It tries to prevent setting the document to modified by calling
SfxObjectShell::EnableSetModified(false), but Writer cunningly outwits
it by simply having its own independent(?) modified flag that is set
unconditionally in DocumentStatisticsManager::DocInfoChgd().

Let's assume that if the modified flag shouldn't be modified in
SfxObjectShell, it shouldn't be modified in DocumentStatisticsManager.

Somehow in 4.4 and 4.3 the same thing was going on, but it didn't result
in a visibly enabled Save icon in the UI, but with 5.0 it does - cannot
easily bisect why that changed due to tdf#91383.

Change-Id: Id30fd831eb29910c9fb44ed3031bf8da23586bea
üst 4ff00325
...@@ -31,7 +31,7 @@ public: ...@@ -31,7 +31,7 @@ public:
/** DocInfo has changed (notify via DocShell): /** DocInfo has changed (notify via DocShell):
make required fields update. make required fields update.
*/ */
virtual void DocInfoChgd() = 0; virtual void DocInfoChgd(bool isEnableSetModified) = 0;
/** Document - Statistics /** Document - Statistics
*/ */
......
...@@ -77,11 +77,14 @@ DocumentStatisticsManager::DocumentStatisticsManager( SwDoc& i_rSwdoc ) : m_rDoc ...@@ -77,11 +77,14 @@ DocumentStatisticsManager::DocumentStatisticsManager( SwDoc& i_rSwdoc ) : m_rDoc
maStatsUpdateTimer.SetTimeoutHdl( LINK( this, DocumentStatisticsManager, DoIdleStatsUpdate ) ); maStatsUpdateTimer.SetTimeoutHdl( LINK( this, DocumentStatisticsManager, DoIdleStatsUpdate ) );
} }
void DocumentStatisticsManager::DocInfoChgd( ) void DocumentStatisticsManager::DocInfoChgd(bool const isEnableSetModified)
{ {
m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( RES_DOCINFOFLD )->UpdateFields(); m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( RES_DOCINFOFLD )->UpdateFields();
m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( RES_TEMPLNAMEFLD )->UpdateFields(); m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( RES_TEMPLNAMEFLD )->UpdateFields();
m_rDoc.getIDocumentState().SetModified(); if (isEnableSetModified)
{
m_rDoc.getIDocumentState().SetModified();
}
} }
const SwDocStat& DocumentStatisticsManager::GetDocStat() const const SwDocStat& DocumentStatisticsManager::GetDocStat() const
......
...@@ -37,7 +37,7 @@ public: ...@@ -37,7 +37,7 @@ public:
DocumentStatisticsManager( SwDoc& i_rSwdoc ); DocumentStatisticsManager( SwDoc& i_rSwdoc );
void DocInfoChgd() SAL_OVERRIDE; void DocInfoChgd(bool isEnableSetModified) SAL_OVERRIDE;
const SwDocStat &GetDocStat() const SAL_OVERRIDE; const SwDocStat &GetDocStat() const SAL_OVERRIDE;
SwDocStat & GetDocStat(); //Non const version of the above, not part of the interface. SwDocStat & GetDocStat(); //Non const version of the above, not part of the interface.
const SwDocStat &GetUpdatedDocStat(bool bCompleteAsync = false, bool bFields = true) SAL_OVERRIDE; const SwDocStat &GetUpdatedDocStat(bool bCompleteAsync = false, bool bFields = true) SAL_OVERRIDE;
......
...@@ -202,7 +202,7 @@ void SwDocShell::DoFlushDocInfo() ...@@ -202,7 +202,7 @@ void SwDocShell::DoFlushDocInfo()
m_pWrtShell->StartAllAction(); m_pWrtShell->StartAllAction();
} }
m_pDoc->getIDocumentStatistics().DocInfoChgd(); m_pDoc->getIDocumentStatistics().DocInfoChgd(IsEnableSetModified());
if (m_pWrtShell) if (m_pWrtShell)
{ {
...@@ -291,8 +291,9 @@ void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) ...@@ -291,8 +291,9 @@ void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
EnableSetModified( false ); EnableSetModified( false );
// #i41679# // #i41679#
const bool bIsDocModified = m_pDoc->getIDocumentState().IsModified(); const bool bIsDocModified = m_pDoc->getIDocumentState().IsModified();
// TODO: is the ResetModified() below because of only the direct call from DocInfoChgd, or does UpdateFields() set it too?
m_pDoc->getIDocumentStatistics().DocInfoChgd( ); m_pDoc->getIDocumentStatistics().DocInfoChgd(false);
// #i41679# // #i41679#
if ( !bIsDocModified ) if ( !bIsDocModified )
......
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