summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-11-12 13:23:20 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2018-11-14 18:42:15 +0100
commitbcddccbfe0d864c6276d70a71ecd72a9bc32c032 (patch)
tree5d26ff27b414c5c3b284e7521b1ab0c2d7105c4a
parentaa4558459eed805a56d97ef95216e72d6727e58c (diff)
sw: prefix members of SwDocUpdateField & trivial cleanups
Change-Id: Ied1e89279e3071e0c6c1b414bb23044e6439258c
-rw-r--r--sw/source/core/doc/DocumentFieldsManager.cxx37
-rw-r--r--sw/source/core/doc/docfld.cxx54
-rw-r--r--sw/source/core/inc/docfld.hxx30
3 files changed, 63 insertions, 58 deletions
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
index efb42e357632..0a3a8a47a8c3 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -146,7 +146,7 @@ namespace sw
DocumentFieldsManager::DocumentFieldsManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ),
mbNewFieldLst(true),
- mpUpdateFields( new SwDocUpdateField( &m_rDoc ) ),
+ mpUpdateFields(new SwDocUpdateField(m_rDoc)),
mpFieldTypes( new SwFieldTypes ),
mnLockExpField( 0 )
{
@@ -849,7 +849,7 @@ void DocumentFieldsManager::UpdateExpFields( SwTextField* pUpdateField, bool bUp
mpUpdateFields->MakeFieldList( m_rDoc, true, GETFLD_ALL );
mbNewFieldLst = false;
- if( mpUpdateFields->GetSortLst()->empty() )
+ if (mpUpdateFields->GetSortList()->empty())
{
if( bUpdRefFields )
UpdateRefFields();
@@ -927,9 +927,9 @@ void DocumentFieldsManager::UpdateExpFields( SwTextField* pUpdateField, bool bUp
std::unordered_map<SwSetExpFieldType const*, SwTextNode const*> SetExpOutlineNodeMap;
- for( SetGetExpFields::const_iterator it = mpUpdateFields->GetSortLst()->begin(); it != mpUpdateFields->GetSortLst()->end(); ++it )
+ for (std::unique_ptr<SetGetExpField> const& it : *mpUpdateFields->GetSortList())
{
- SwSection* pSect = const_cast<SwSection*>((*it)->GetSection());
+ SwSection* pSect = const_cast<SwSection*>(it->GetSection());
if( pSect )
{
SwSbxValue aValue = aCalc.Calculate(
@@ -960,7 +960,7 @@ void DocumentFieldsManager::UpdateExpFields( SwTextField* pUpdateField, bool bUp
continue;
}
- SwTextField* pTextField = const_cast<SwTextField*>((*it)->GetTextField());
+ SwTextField* pTextField = const_cast<SwTextField*>(it->GetTextField());
if( !pTextField )
{
OSL_ENSURE( false, "what's wrong now'" );
@@ -1126,7 +1126,7 @@ void DocumentFieldsManager::UpdateExpFields( SwTextField* pUpdateField, bool bUp
if( MAXLEVEL > nLvl )
{
// test if the Number needs to be updated
- pSeqNd = m_rDoc.GetNodes()[ (*it)->GetNode() ];
+ pSeqNd = m_rDoc.GetNodes()[ it->GetNode() ];
const SwTextNode* pOutlNd = pSeqNd->
FindOutlineNodeOfLevel( nLvl );
@@ -1211,13 +1211,12 @@ sal_Int32 DocumentFieldsManager::GetRecordsPerDocument() const
sal_Int32 nRecords = 1;
mpUpdateFields->MakeFieldList( m_rDoc, true, GETFLD_ALL );
- if( mpUpdateFields->GetSortLst()->empty() )
+ if (mpUpdateFields->GetSortList()->empty())
return nRecords;
- for( SetGetExpFields::const_iterator it = mpUpdateFields->GetSortLst()->begin();
- it != mpUpdateFields->GetSortLst()->end(); ++it )
+ for (std::unique_ptr<SetGetExpField> const& it : *mpUpdateFields->GetSortList())
{
- const SwTextField *pTextField = (*it)->GetTextField();
+ const SwTextField *pTextField = it->GetTextField();
if( !pTextField )
continue;
@@ -1443,13 +1442,15 @@ void DocumentFieldsManager::FieldsToCalc( SwCalc& rCalc, const SetGetExpField& r
pMgr->CloseAll(false);
#endif
- if( !mpUpdateFields->GetSortLst()->empty() )
+ if (!mpUpdateFields->GetSortList()->empty())
{
SetGetExpFields::const_iterator const itLast =
- mpUpdateFields->GetSortLst()->upper_bound(
+ mpUpdateFields->GetSortList()->upper_bound(
&rToThisField);
- for( SetGetExpFields::const_iterator it = mpUpdateFields->GetSortLst()->begin(); it != itLast; ++it )
+ for (auto it = mpUpdateFields->GetSortList()->begin(); it != itLast; ++it)
+ {
lcl_CalcField( m_rDoc, rCalc, **it, pMgr );
+ }
}
#if HAVE_FEATURE_DBCONNECTIVITY
pMgr->CloseAll(false);
@@ -1469,8 +1470,8 @@ void DocumentFieldsManager::FieldsToCalc( SwCalc& rCalc, sal_uLong nLastNd, sal_
pMgr->CloseAll(false);
#endif
- for( SetGetExpFields::const_iterator it = mpUpdateFields->GetSortLst()->begin();
- it != mpUpdateFields->GetSortLst()->end() &&
+ for(auto it = mpUpdateFields->GetSortList()->begin();
+ it != mpUpdateFields->GetSortList()->end() &&
( (*it)->GetNode() < nLastNd ||
( (*it)->GetNode() == nLastNd && (*it)->GetContent() <= nLastCnt )
);
@@ -1493,13 +1494,13 @@ void DocumentFieldsManager::FieldsToExpand( SwHashTable<HashStr> & rHashTable,
// Hash table for all string replacements is filled on-the-fly.
// Try to fabricate an uneven number.
- sal_uInt16 nTableSize = (( mpUpdateFields->GetSortLst()->size() / 7 ) + 1 ) * 7;
+ sal_uInt16 nTableSize = ((mpUpdateFields->GetSortList()->size() / 7) + 1) * 7;
rHashTable.resize(nTableSize);
SetGetExpFields::const_iterator const itLast =
- mpUpdateFields->GetSortLst()->upper_bound(&rToThisField);
+ mpUpdateFields->GetSortList()->upper_bound(&rToThisField);
- for( SetGetExpFields::const_iterator it = mpUpdateFields->GetSortLst()->begin(); it != itLast; ++it )
+ for (auto it = mpUpdateFields->GetSortList()->begin(); it != itLast; ++it)
{
const SwTextField* pTextField = (*it)->GetTextField();
if( !pTextField )
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 3affc7cdd901..4a7a80d23129 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -775,11 +775,11 @@ void SwDocUpdateField::InsDelFieldInFieldLst( bool bIns, const SwTextField& rFie
}
SetFieldsDirty( true );
- if( !pFieldSortLst )
+ if (!m_pFieldSortList)
{
if( !bIns ) // if list is present and deleted
return; // don't do a thing
- pFieldSortLst.reset(new SetGetExpFields);
+ m_pFieldSortList.reset(new SetGetExpFields);
}
if( bIns ) // insert anew:
@@ -788,26 +788,30 @@ void SwDocUpdateField::InsDelFieldInFieldLst( bool bIns, const SwTextField& rFie
{
// look up via the pTextField pointer. It is a sorted list, but it's sorted by node
// position. Until this is found, the search for the pointer is already done.
- for( SetGetExpFields::size_type n = 0; n < pFieldSortLst->size(); ++n )
- if( &rField == (*pFieldSortLst)[ n ]->GetPointer() )
+ for (SetGetExpFields::size_type n = 0; n < m_pFieldSortList->size(); ++n)
+ {
+ if (&rField == (*m_pFieldSortList)[n]->GetPointer())
{
- pFieldSortLst->erase(n);
+ m_pFieldSortList->erase(n);
n--; // one field can occur multiple times
}
+ }
}
}
void SwDocUpdateField::MakeFieldList( SwDoc& rDoc, bool bAll, int eGetMode )
{
- if( !pFieldSortLst || bAll || !( eGetMode & nFieldLstGetMode ) ||
- rDoc.GetNodes().Count() != nNodes )
+ if (!m_pFieldSortList || bAll || !(eGetMode & m_nFieldListGetMode)
+ || rDoc.GetNodes().Count() != m_nNodes)
+ {
MakeFieldList_( rDoc, eGetMode );
+ }
}
void SwDocUpdateField::MakeFieldList_( SwDoc& rDoc, int eGetMode )
{
// new version: walk all fields of the attribute pool
- pFieldSortLst.reset(new SetGetExpFields);
+ m_pFieldSortList.reset(new SetGetExpFields);
// consider and unhide sections
// with hide condition, only in mode GETFLD_ALL (<eGetMode == GETFLD_ALL>)
@@ -820,7 +824,7 @@ void SwDocUpdateField::MakeFieldList_( SwDoc& rDoc, int eGetMode )
// the hide conditions of section have to be updated.
// For correct updating the hide condition of a section, its position
// have to be known in order to insert the hide condition as a new
- // expression field into the sorted field list (<pFieldSortLst>).
+ // expression field into the sorted field list (<m_pFieldSortList>).
if ( eGetMode == GETFLD_ALL )
// Collect the sections first. Supply sections that are hidden by condition
// with frames so that the contained fields are sorted properly.
@@ -985,8 +989,8 @@ void SwDocUpdateField::MakeFieldList_( SwDoc& rDoc, int eGetMode )
GetBodyNode( *pTextField, nWhich );
}
}
- nFieldLstGetMode = static_cast<sal_uInt8>( eGetMode );
- nNodes = rDoc.GetNodes().Count();
+ m_nFieldListGetMode = eGetMode;
+ m_nNodes = rDoc.GetNodes().Count();
}
void SwDocUpdateField::GetBodyNode( const SwTextField& rTField, SwFieldIds nFieldWhich )
@@ -1039,7 +1043,7 @@ void SwDocUpdateField::GetBodyNode( const SwTextField& rTField, SwFieldIds nFiel
}
#endif
if( pNew != nullptr )
- pFieldSortLst->insert( std::move(pNew) );
+ m_pFieldSortList->insert( std::move(pNew) );
}
void SwDocUpdateField::GetBodyNode( const SwSectionNode& rSectNd )
@@ -1078,7 +1082,7 @@ void SwDocUpdateField::GetBodyNode( const SwSectionNode& rSectNd )
if( !pNew )
pNew.reset(new SetGetExpField( rSectNd ));
- pFieldSortLst->insert( std::move(pNew) );
+ m_pFieldSortList->insert( std::move(pNew) );
}
void SwDocUpdateField::InsertFieldType( const SwFieldType& rType )
@@ -1108,8 +1112,8 @@ void SwDocUpdateField::InsertFieldType( const SwFieldType& rType )
if( !pFnd )
{
SwCalcFieldType* pNew = new SwCalcFieldType( sFieldName, &rType );
- pNew->pNext.reset( aFieldTypeTable[ n ].release() );
- aFieldTypeTable[ n ].reset(pNew);
+ pNew->pNext.reset( m_FieldTypeTable[n].release() );
+ m_FieldTypeTable[n].reset(pNew);
}
}
}
@@ -1138,13 +1142,13 @@ void SwDocUpdateField::RemoveFieldType( const SwFieldType& rType )
SwCalcFieldType* pFnd = GetFieldTypeTable().Find( sFieldName, &n );
if( pFnd )
{
- if( aFieldTypeTable[ n ].get() == pFnd )
+ if (m_FieldTypeTable[n].get() == pFnd)
{
- aFieldTypeTable[ n ].reset(static_cast<SwCalcFieldType*>(pFnd->pNext.release()));
+ m_FieldTypeTable[n].reset(static_cast<SwCalcFieldType*>(pFnd->pNext.release()));
}
else
{
- SwHash* pPrev = aFieldTypeTable[ n ].get();
+ SwHash* pPrev = m_FieldTypeTable[n].get();
while( pPrev->pNext.get() != pFnd )
pPrev = pPrev->pNext.get();
pPrev->pNext = std::move(pFnd->pNext);
@@ -1154,13 +1158,13 @@ void SwDocUpdateField::RemoveFieldType( const SwFieldType& rType )
}
}
-SwDocUpdateField::SwDocUpdateField(SwDoc* pDoc)
- : aFieldTypeTable(TBLSZ)
- , nNodes(0)
- , nFieldLstGetMode(0)
- , pDocument(pDoc)
- , bInUpdateFields(false)
- , bFieldsDirty(false)
+SwDocUpdateField::SwDocUpdateField(SwDoc& rDoc)
+ : m_FieldTypeTable(TBLSZ)
+ , m_nNodes(0)
+ , m_nFieldListGetMode(0)
+ , m_rDoc(rDoc)
+ , m_bInUpdateFields(false)
+ , m_bFieldsDirty(false)
{
}
diff --git a/sw/source/core/inc/docfld.hxx b/sw/source/core/inc/docfld.hxx
index 17704c22448b..c9d5fba43048 100644
--- a/sw/source/core/inc/docfld.hxx
+++ b/sw/source/core/inc/docfld.hxx
@@ -131,25 +131,25 @@ const int GETFLD_EXPAND = 2;
class SwDocUpdateField
{
- std::unique_ptr<SetGetExpFields> pFieldSortLst; // current field list for calculation
- SwHashTable<SwCalcFieldType> aFieldTypeTable;
+ std::unique_ptr<SetGetExpFields> m_pFieldSortList; ///< current field list for calculation
+ SwHashTable<SwCalcFieldType> m_FieldTypeTable;
- sal_uLong nNodes; // if the node count is different
- sal_uInt8 nFieldLstGetMode;
- SwDoc* pDocument;
+ sal_uLong m_nNodes; ///< to check if the node count changed
+ int m_nFieldListGetMode;
+ SwDoc& m_rDoc;
- bool bInUpdateFields : 1; // currently there is an UpdateFields
- bool bFieldsDirty : 1; // some fields are invalid
+ bool m_bInUpdateFields : 1; ///< currently in an UpdateFields call
+ bool m_bFieldsDirty : 1; ///< some fields are invalid
void MakeFieldList_( SwDoc& pDoc, int eGetMode );
void GetBodyNode( const SwTextField& , SwFieldIds nFieldWhich );
void GetBodyNode( const SwSectionNode&);
public:
- SwDocUpdateField(SwDoc* pDocument);
+ SwDocUpdateField(SwDoc& rDocument);
~SwDocUpdateField();
- const SetGetExpFields* GetSortLst() const { return pFieldSortLst.get(); }
+ const SetGetExpFields* GetSortList() const { return m_pFieldSortList.get(); }
void MakeFieldList( SwDoc& rDoc, bool bAll, int eGetMode );
@@ -158,21 +158,21 @@ public:
void InsertFieldType( const SwFieldType& rType );
void RemoveFieldType( const SwFieldType& rType );
- bool IsInUpdateFields() const { return bInUpdateFields; }
- void SetInUpdateFields( bool b ) { bInUpdateFields = b; }
+ bool IsInUpdateFields() const { return m_bInUpdateFields; }
+ void SetInUpdateFields( bool b ) { m_bInUpdateFields = b; }
- bool IsFieldsDirty() const { return bFieldsDirty; }
+ bool IsFieldsDirty() const { return m_bFieldsDirty; }
void SetFieldsDirty( bool b )
{
- bFieldsDirty = b;
+ m_bFieldsDirty = b;
if (b)
{
- pDocument->getIDocumentTimerAccess().StartIdling();
+ m_rDoc.getIDocumentTimerAccess().StartIdling();
}
}
- SwHashTable<SwCalcFieldType> const & GetFieldTypeTable() const { return aFieldTypeTable; }
+ SwHashTable<SwCalcFieldType> const& GetFieldTypeTable() const { return m_FieldTypeTable; }
};
#endif