[Libreoffice-commits] core.git: 2 commits - sw/inc sw/source
Caolán McNamara
caolanm at redhat.com
Wed Jan 7 05:14:49 PST 2015
sw/inc/doc.hxx | 18 +--
sw/inc/pagedesc.hxx | 2
sw/source/core/doc/DocumentTimerManager.cxx | 6 -
sw/source/core/doc/docdesc.cxx | 147 ++++++++++++++--------------
sw/source/core/doc/docfmt.cxx | 27 +----
sw/source/core/doc/docnew.cxx | 7 -
sw/source/core/layout/pagedesc.cxx | 6 -
7 files changed, 94 insertions(+), 119 deletions(-)
New commits:
commit fd0577e6b65cfd948b2fbe16fa1bd06fe0c635b9
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jan 7 13:13:12 2015 +0000
Resolves: fdo#73165 don't restart timer if already running
If the timer is already running and you restart it then it starts counting down
again so the timeout occasion just keeps getting pushed out indefinitely.
Change-Id: I964beb0c4756c7bce1e29bdf06cbe9a593ba79cf
diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx
index 5c97d2c..a2ed9c4 100644
--- a/sw/source/core/doc/DocumentTimerManager.cxx
+++ b/sw/source/core/doc/DocumentTimerManager.cxx
@@ -72,9 +72,11 @@ void DocumentTimerManager::UnblockIdling()
maIdle.Start();
}
-void DocumentTimerManager::StartBackgroundJobs() {
+void DocumentTimerManager::StartBackgroundJobs()
+{
// Trigger DoIdleJobs(), asynchronously.
- maIdle.Start();
+ if (!maIdle.IsActive()) //fdo#73165 if the timer is already running don't restart from 0
+ maIdle.Start();
}
IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer *, pTimer )
commit 28b61d7a2839aebc7458312d312dc6cdb03a8b3f
Author: Michaël Lefèvre <lefevre00 at yahoo.fr>
Date: Mon Dec 8 17:28:23 2014 +0100
fdo#75757 remove inheritance to std::vector
Conflicts:
sw/source/core/doc/docnew.cxx
Change-Id: I4ba20e689b77e75bea75e5a60f50ff40577183e8
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index bcc89ea..6efdfd49 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -237,13 +237,7 @@ namespace sfx2 {
class LinkManager;
}
-// PageDescriptor-interface, Array because of inlines.
-class SwPageDescs : public std::vector<SwPageDesc*>
-{
-public:
- // the destructor will free all objects still in the vector
- ~SwPageDescs();
-};
+typedef boost::ptr_vector<SwPageDesc> SwPageDescs;
// forward declaration
void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem );
@@ -953,9 +947,9 @@ public:
// PageDescriptor interface.
sal_uInt16 GetPageDescCnt() const { return maPageDescs.size(); }
- const SwPageDesc& GetPageDesc( const sal_uInt16 i ) const { return *maPageDescs[i]; }
- SwPageDesc& GetPageDesc( sal_uInt16 i ) { return *maPageDescs[i]; }
- SwPageDesc* FindPageDesc(const OUString& rName, sal_uInt16* pPos = NULL) const;
+ const SwPageDesc& GetPageDesc( const sal_uInt16 i ) const { return maPageDescs[i]; }
+ SwPageDesc& GetPageDesc( sal_uInt16 i ) { return maPageDescs[i]; }
+ SwPageDesc* FindPageDesc(const OUString& rName, sal_uInt16* pPos = NULL);
/** Copy the complete PageDesc - beyond document and "deep"!
Optionally copying of PoolFmtId, -HlpId can be prevented. */
@@ -1680,9 +1674,9 @@ public:
private:
// Copies master header to left / first one, if necessary - used by ChgPageDesc().
- void CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc *pDesc, bool bLeft, bool bFirst);
+ void CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc &pDesc, bool bLeft, bool bFirst);
// Copies master footer to left / first one, if necessary - used by ChgPageDesc().
- void CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft, bool bFirst);
+ void CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc &pDesc, bool bLeft, bool bFirst);
};
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index b556e9b..c4af052 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -162,7 +162,7 @@ protected:
public:
OUString GetName() const { return aDescName; }
- bool HasName( const OUString& rThisName ) { return aDescName == rThisName; }
+ bool HasName( const OUString& rThisName ) const { return aDescName == rThisName; }
void SetName( const OUString& rNewName ) { aDescName = rNewName; }
bool GetLandscape() const { return bLandscape; }
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index a6a2a4a..4f3801d 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -212,24 +212,24 @@ static void lcl_DescSetAttr( const SwFrmFmt &rSource, SwFrmFmt &rDest,
rDest.SetPoolHlpFileId( rSource.GetPoolHlpFileId() );
}
-void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc *pDesc, bool bLeft, bool bFirst)
+void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc &rDesc, bool bLeft, bool bFirst)
{
assert(bLeft || bFirst);
SwFrmFmt& rDescFrmFmt = (bFirst)
- ? (bLeft) ? pDesc->GetFirstLeft() : pDesc->GetFirstMaster()
- : pDesc->GetLeft();
+ ? (bLeft) ? rDesc.GetFirstLeft() : rDesc.GetFirstMaster()
+ : rDesc.GetLeft();
if (bFirst && bLeft)
{
// special case: always shared with something
rDescFrmFmt.SetFmtAttr( rChged.IsFirstShared()
- ? pDesc->GetLeft().GetHeader()
- : pDesc->GetFirstMaster().GetHeader());
+ ? rDesc.GetLeft().GetHeader()
+ : rDesc.GetFirstMaster().GetHeader());
}
else if ((bFirst ? rChged.IsFirstShared() : rChged.IsHeaderShared())
|| !rHead.IsActive())
{
// Left or first shares the header with the Master.
- rDescFrmFmt.SetFmtAttr( pDesc->GetMaster().GetHeader() );
+ rDescFrmFmt.SetFmtAttr( rDesc.GetMaster().GetHeader() );
}
else if ( rHead.IsActive() )
{ // Left or first gets its own header if the Format doesn't alrady have one.
@@ -261,7 +261,7 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
// The CntntIdx is _always_ different when called from
// SwDocStyleSheet::SetItemSet, because it deep-copies the
// PageDesc. So check if it was previously shared.
- ((bFirst) ? pDesc->IsFirstShared() : pDesc->IsHeaderShared()))
+ ((bFirst) ? rDesc.IsFirstShared() : rDesc.IsHeaderShared()))
{
SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(),
(bFirst) ? "First header" : "Left header",
@@ -289,24 +289,24 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
}
}
-void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft, bool bFirst)
+void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc &rDesc, bool bLeft, bool bFirst)
{
assert(bLeft || bFirst);
SwFrmFmt& rDescFrmFmt = (bFirst)
- ? (bLeft) ? pDesc->GetFirstLeft() : pDesc->GetFirstMaster()
- : pDesc->GetLeft();
+ ? (bLeft) ? rDesc.GetFirstLeft() : rDesc.GetFirstMaster()
+ : rDesc.GetLeft();
if (bFirst && bLeft)
{
// special case: always shared with something
rDescFrmFmt.SetFmtAttr( rChged.IsFirstShared()
- ? pDesc->GetLeft().GetFooter()
- : pDesc->GetFirstMaster().GetFooter());
+ ? rDesc.GetLeft().GetFooter()
+ : rDesc.GetFirstMaster().GetFooter());
}
else if ((bFirst ? rChged.IsFirstShared() : rChged.IsFooterShared())
|| !rFoot.IsActive())
{
// Left or first shares the Header with the Master.
- rDescFrmFmt.SetFmtAttr( pDesc->GetMaster().GetFooter() );
+ rDescFrmFmt.SetFmtAttr( rDesc.GetMaster().GetFooter() );
}
else if ( rFoot.IsActive() )
{ // Left or first gets its own Footer if the Format does not already have one.
@@ -337,7 +337,7 @@ void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot,
// The CntntIdx is _always_ different when called from
// SwDocStyleSheet::SetItemSet, because it deep-copies the
// PageDesc. So check if it was previously shared.
- ((bFirst) ? pDesc->IsFirstShared() : pDesc->IsFooterShared()))
+ ((bFirst) ? rDesc.IsFirstShared() : rDesc.IsFooterShared()))
{
SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(),
(bFirst) ? "First footer" : "Left footer",
@@ -369,12 +369,12 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
{
OSL_ENSURE( i < maPageDescs.size(), "PageDescs is out of range." );
- SwPageDesc *pDesc = maPageDescs[i];
+ SwPageDesc& rDesc = maPageDescs[i];
SwRootFrm* pTmpRoot = getIDocumentLayoutAccess().GetCurrentLayout();
if (GetIDocumentUndoRedo().DoesUndo())
{
- SwUndo *const pUndo(new SwUndoPageDesc(*pDesc, rChged, this));
+ SwUndo *const pUndo(new SwUndoPageDesc(rDesc, rChged, this));
GetIDocumentUndoRedo().AppendUndo(pUndo);
}
::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
@@ -394,9 +394,9 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
const_cast<SwPageDesc&>(rChged).GetFirstLeft());
// Take over NumType.
- if( rChged.GetNumType().GetNumberingType() != pDesc->GetNumType().GetNumberingType() )
+ if( rChged.GetNumType().GetNumberingType() != rDesc.GetNumType().GetNumberingType() )
{
- pDesc->SetNumType( rChged.GetNumType() );
+ rDesc.SetNumType( rChged.GetNumType() );
// Notify page number fields that NumFormat has changed
getIDocumentFieldsAccess().GetSysFldType( RES_PAGENUMBERFLD )->UpdateFlds();
getIDocumentFieldsAccess().GetSysFldType( RES_REFPAGEGETFLD )->UpdateFlds();
@@ -413,7 +413,7 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
}
// Take over orientation
- pDesc->SetLandscape( rChged.GetLandscape() );
+ rDesc.SetLandscape( rChged.GetLandscape() );
// #i46909# no undo if header or footer changed
bool bHeaderFooterChanged = false;
@@ -424,17 +424,17 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
{
// #i46909# no undo if header or footer changed
// Did something change in the nodes?
- const SwFmtHeader &rOldHead = pDesc->GetMaster().GetHeader();
+ const SwFmtHeader &rOldHead = rDesc.GetMaster().GetHeader();
bHeaderFooterChanged |=
( rHead.IsActive() != rOldHead.IsActive() ||
- rChged.IsHeaderShared() != pDesc->IsHeaderShared() ||
- rChged.IsFirstShared() != pDesc->IsFirstShared() );
+ rChged.IsHeaderShared() != rDesc.IsHeaderShared() ||
+ rChged.IsFirstShared() != rDesc.IsFirstShared() );
}
- pDesc->GetMaster().SetFmtAttr( rHead );
- CopyMasterHeader(rChged, rHead, pDesc, true, false); // Copy left header
- CopyMasterHeader(rChged, rHead, pDesc, false, true); // Copy first master
- CopyMasterHeader(rChged, rHead, pDesc, true, true); // Copy first left
- pDesc->ChgHeaderShare( rChged.IsHeaderShared() );
+ rDesc.GetMaster().SetFmtAttr( rHead );
+ CopyMasterHeader(rChged, rHead, rDesc, true, false); // Copy left header
+ CopyMasterHeader(rChged, rHead, rDesc, false, true); // Copy first master
+ CopyMasterHeader(rChged, rHead, rDesc, true, true); // Copy first left
+ rDesc.ChgHeaderShare( rChged.IsHeaderShared() );
// Synch Footer.
const SwFmtFooter &rFoot = rChged.GetMaster().GetFooter();
@@ -442,41 +442,41 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
{
// #i46909# no undo if header or footer changed
// Did something change in the Nodes?
- const SwFmtFooter &rOldFoot = pDesc->GetMaster().GetFooter();
+ const SwFmtFooter &rOldFoot = rDesc.GetMaster().GetFooter();
bHeaderFooterChanged |=
( rFoot.IsActive() != rOldFoot.IsActive() ||
- rChged.IsFooterShared() != pDesc->IsFooterShared() );
+ rChged.IsFooterShared() != rDesc.IsFooterShared() );
}
- pDesc->GetMaster().SetFmtAttr( rFoot );
- CopyMasterFooter(rChged, rFoot, pDesc, true, false); // Copy left footer
- CopyMasterFooter(rChged, rFoot, pDesc, false, true); // Copy first master
- CopyMasterFooter(rChged, rFoot, pDesc, true, true); // Copy first left
- pDesc->ChgFooterShare( rChged.IsFooterShared() );
+ rDesc.GetMaster().SetFmtAttr( rFoot );
+ CopyMasterFooter(rChged, rFoot, rDesc, true, false); // Copy left footer
+ CopyMasterFooter(rChged, rFoot, rDesc, false, true); // Copy first master
+ CopyMasterFooter(rChged, rFoot, rDesc, true, true); // Copy first left
+ rDesc.ChgFooterShare( rChged.IsFooterShared() );
// there is just one first shared flag for both header and footer?
- pDesc->ChgFirstShare( rChged.IsFirstShared() );
+ rDesc.ChgFirstShare( rChged.IsFirstShared() );
- if ( pDesc->GetName() != rChged.GetName() )
- pDesc->SetName( rChged.GetName() );
+ if ( rDesc.GetName() != rChged.GetName() )
+ rDesc.SetName( rChged.GetName() );
// A RegisterChange is triggered, if necessary
- pDesc->SetRegisterFmtColl( rChged.GetRegisterFmtColl() );
+ rDesc.SetRegisterFmtColl( rChged.GetRegisterFmtColl() );
// If UseOn or the Follow change, the paragraphs need to know about it.
bool bUseOn = false;
bool bFollow = false;
- if ( pDesc->GetUseOn() != rChged.GetUseOn() )
- { pDesc->SetUseOn( rChged.GetUseOn() );
+ if ( rDesc.GetUseOn() != rChged.GetUseOn() )
+ { rDesc.SetUseOn( rChged.GetUseOn() );
bUseOn = true;
}
- if ( pDesc->GetFollow() != rChged.GetFollow() )
+ if ( rDesc.GetFollow() != rChged.GetFollow() )
{ if ( rChged.GetFollow() == &rChged )
- { if ( pDesc->GetFollow() != pDesc )
- { pDesc->SetFollow( pDesc );
+ { if ( rDesc.GetFollow() != &rDesc )
+ { rDesc.SetFollow( &rDesc );
bFollow = true;
}
}
else
- { pDesc->SetFollow( rChged.pFollow );
+ { rDesc.SetFollow( rChged.pFollow );
bFollow = true;
}
}
@@ -489,27 +489,27 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
}
// Take over the page attributes.
- ::lcl_DescSetAttr( rChged.GetMaster(), pDesc->GetMaster() );
- ::lcl_DescSetAttr( rChged.GetLeft(), pDesc->GetLeft() );
- ::lcl_DescSetAttr( rChged.GetFirstMaster(), pDesc->GetFirstMaster() );
- ::lcl_DescSetAttr( rChged.GetFirstLeft(), pDesc->GetFirstLeft() );
+ ::lcl_DescSetAttr( rChged.GetMaster(), rDesc.GetMaster() );
+ ::lcl_DescSetAttr( rChged.GetLeft(), rDesc.GetLeft() );
+ ::lcl_DescSetAttr( rChged.GetFirstMaster(), rDesc.GetFirstMaster() );
+ ::lcl_DescSetAttr( rChged.GetFirstLeft(), rDesc.GetFirstLeft() );
// If the FootnoteInfo changes, the pages are triggered.
- if( !(pDesc->GetFtnInfo() == rChged.GetFtnInfo()) )
+ if( !(rDesc.GetFtnInfo() == rChged.GetFtnInfo()) )
{
- pDesc->SetFtnInfo( rChged.GetFtnInfo() );
+ rDesc.SetFtnInfo( rChged.GetFtnInfo() );
SwMsgPoolItem aInfo( RES_PAGEDESC_FTNINFO );
{
- pDesc->GetMaster().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
+ rDesc.GetMaster().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
}
{
- pDesc->GetLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
+ rDesc.GetLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
}
{
- pDesc->GetFirstMaster().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
+ rDesc.GetFirstMaster().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
}
{
- pDesc->GetFirstLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
+ rDesc.GetFirstLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
}
}
getIDocumentState().SetModified();
@@ -532,12 +532,12 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
}
//h/f of first-left page must not be unique but same as first master or left
- assert((pDesc->IsFirstShared())
- ? pDesc->GetFirstLeft().GetHeader().GetHeaderFmt() == pDesc->GetLeft().GetHeader().GetHeaderFmt()
- : pDesc->GetFirstLeft().GetHeader().GetHeaderFmt() == pDesc->GetFirstMaster().GetHeader().GetHeaderFmt());
- assert((pDesc->IsFirstShared())
- ? pDesc->GetFirstLeft().GetFooter().GetFooterFmt() == pDesc->GetLeft().GetFooter().GetFooterFmt()
- : pDesc->GetFirstLeft().GetFooter().GetFooterFmt() == pDesc->GetFirstMaster().GetFooter().GetFooterFmt());
+ assert((rDesc.IsFirstShared())
+ ? rDesc.GetFirstLeft().GetHeader().GetHeaderFmt() == rDesc.GetLeft().GetHeader().GetHeaderFmt()
+ : rDesc.GetFirstLeft().GetHeader().GetHeaderFmt() == rDesc.GetFirstMaster().GetHeader().GetHeaderFmt());
+ assert((rDesc.IsFirstShared())
+ ? rDesc.GetFirstLeft().GetFooter().GetFooterFmt() == rDesc.GetLeft().GetFooter().GetFooterFmt()
+ : rDesc.GetFirstLeft().GetFooter().GetFooterFmt() == rDesc.GetFirstMaster().GetFooter().GetFooterFmt());
}
/// All descriptors whose Follow point to the to-be-deleted have to be adapted.
@@ -548,13 +548,13 @@ void SwDoc::PreDelPageDesc(SwPageDesc * pDel)
return;
// mba: test iteration as clients are removed while iteration
- SwPageDescHint aHint( maPageDescs[0] );
+ SwPageDescHint aHint( &maPageDescs[0] );
pDel->CallSwClientNotify( aHint );
bool bHasLayout = getIDocumentLayoutAccess().HasLayout();
if ( mpFtnInfo->DependsOn( pDel ) )
{
- mpFtnInfo->ChgPageDesc( maPageDescs[0] );
+ mpFtnInfo->ChgPageDesc( &maPageDescs[0] );
if ( bHasLayout )
{
std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
@@ -563,7 +563,7 @@ void SwDoc::PreDelPageDesc(SwPageDesc * pDel)
}
else if ( mpEndNoteInfo->DependsOn( pDel ) )
{
- mpEndNoteInfo->ChgPageDesc( maPageDescs[0] );
+ mpEndNoteInfo->ChgPageDesc( &maPageDescs[0] );
if ( bHasLayout )
{
std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
@@ -573,9 +573,9 @@ void SwDoc::PreDelPageDesc(SwPageDesc * pDel)
for ( sal_uInt16 j = 0; j < maPageDescs.size(); ++j )
{
- if ( maPageDescs[j]->GetFollow() == pDel )
+ if ( maPageDescs[j].GetFollow() == pDel )
{
- maPageDescs[j]->SetFollow( 0 );
+ maPageDescs[j].SetFollow( 0 );
if( bHasLayout )
{
std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
@@ -610,22 +610,21 @@ void SwDoc::DelPageDesc( sal_uInt16 i, bool bBroadcast )
if ( i == 0 )
return;
- SwPageDesc *pDel = maPageDescs[i];
+ SwPageDesc &rDel = maPageDescs[i];
if (bBroadcast)
- BroadcastStyleOperation(pDel->GetName(), SFX_STYLE_FAMILY_PAGE,
+ BroadcastStyleOperation(rDel.GetName(), SFX_STYLE_FAMILY_PAGE,
SFX_STYLESHEET_ERASED);
if (GetIDocumentUndoRedo().DoesUndo())
{
- SwUndo *const pUndo(new SwUndoPageDescDelete(*pDel, this));
+ SwUndo *const pUndo(new SwUndoPageDescDelete(rDel, this));
GetIDocumentUndoRedo().AppendUndo(pUndo);
}
- PreDelPageDesc(pDel); // #i7983#
+ PreDelPageDesc(&rDel); // #i7983#
maPageDescs.erase( maPageDescs.begin() + i );
- delete pDel;
getIDocumentState().SetModified();
}
@@ -674,19 +673,21 @@ SwPageDesc* SwDoc::MakePageDesc(const OUString &rName, const SwPageDesc *pCpy,
return pNew;
}
-SwPageDesc* SwDoc::FindPageDesc(const OUString& rName, sal_uInt16* pPos) const
+SwPageDesc* SwDoc::FindPageDesc(const OUString& rName, sal_uInt16* pPos)
{
SwPageDesc* pRet = NULL;
if( pPos ) *pPos = USHRT_MAX;
for( sal_uInt16 n = 0, nEnd = maPageDescs.size(); n < nEnd; ++n )
- if( maPageDescs[ n ]->HasName( rName ) )
+ {
+ if( maPageDescs[ n ].HasName( rName ) )
{
- pRet = maPageDescs[ n ];
+ pRet = &maPageDescs[ n ];
if( pPos )
*pPos = n;
break;
}
+ }
return pRet;
}
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 54beda7..89437a9 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1236,17 +1236,6 @@ SwGrfFmtColl* SwDoc::CopyGrfColl( const SwGrfFmtColl& rColl )
return pNewColl;
}
-static SwPageDesc* lcl_FindPageDesc( const SwPageDescs& rArr, const OUString& rName )
-{
- for( sal_uInt16 n = rArr.size(); n; )
- {
- SwPageDesc* pDesc = rArr[ --n ];
- if( pDesc->GetName() == rName )
- return pDesc;
- }
- return 0;
-}
-
void SwDoc::CopyFmtArr( const SwFmtsBase& rSourceArr,
SwFmtsBase& rDestArr,
FNCopyFmt fnCopyFmt,
@@ -1292,7 +1281,7 @@ void SwDoc::CopyFmtArr( const SwFmtsBase& rSourceArr,
{
SwFmtPageDesc aPageDesc( *static_cast<const SwFmtPageDesc*>(pItem) );
const OUString& rNm = aPageDesc.GetPageDesc()->GetName();
- SwPageDesc* pPageDesc = ::lcl_FindPageDesc( maPageDescs, rNm );
+ SwPageDesc* pPageDesc = FindPageDesc( rNm );
if( !pPageDesc )
{
pPageDesc = MakePageDesc(rNm);
@@ -1419,8 +1408,7 @@ void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc,
if( rSrcDesc.GetFollow() != &rSrcDesc )
{
- SwPageDesc* pFollow = ::lcl_FindPageDesc( maPageDescs,
- rSrcDesc.GetFollow()->GetName() );
+ SwPageDesc* pFollow = FindPageDesc( rSrcDesc.GetFollow()->GetName() );
if( !pFollow )
{
// copy
@@ -1556,16 +1544,17 @@ void SwDoc::ReplaceStyles( const SwDoc& rSource, bool bIncludePageStyles )
// 1st step: Create all formats (skip the 0th - it's the default!)
while( nCnt )
{
- SwPageDesc *pSrc = rSource.maPageDescs[ --nCnt ];
- if( 0 == ::lcl_FindPageDesc( maPageDescs, pSrc->GetName() ) )
- MakePageDesc( pSrc->GetName() );
+ const SwPageDesc &rSrc = rSource.maPageDescs[ --nCnt ];
+ if( 0 == FindPageDesc( rSrc.GetName() ) )
+ MakePageDesc( rSrc.GetName() );
}
// 2nd step: Copy all attributes, set the right parents
for( nCnt = rSource.maPageDescs.size(); nCnt; )
{
- SwPageDesc *pSrc = rSource.maPageDescs[ --nCnt ];
- CopyPageDesc( *pSrc, *::lcl_FindPageDesc( maPageDescs, pSrc->GetName() ));
+ const SwPageDesc &rSrc = rSource.maPageDescs[ --nCnt ];
+ SwPageDesc* pDesc = FindPageDesc( rSrc.GetName() );
+ CopyPageDesc( rSrc, *pDesc);
}
}
}
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index f7c4028..0f6d0d8 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -517,8 +517,6 @@ SwDoc::~SwDoc()
// Destroy these only after destroying the FmtIndices, because the content
// of headers/footers has to be deleted as well. If in the headers/footers
// there are still Flys registered at that point, we have a problem.
- for(SwPageDesc *pPageDesc : maPageDescs)
- delete pPageDesc;
maPageDescs.clear();
// Delete content selections.
@@ -722,10 +720,7 @@ void SwDoc::ClearDoc()
// remove the dummy pagedesc from the array and delete all the old ones
sal_uInt16 nDummyPgDsc = 0;
if (FindPageDesc(pDummyPgDsc->GetName(), &nDummyPgDsc))
- maPageDescs.erase(maPageDescs.begin() + nDummyPgDsc);
-
- for( SwPageDesc *pPageDesc : maPageDescs )
- delete pPageDesc;
+ pDummyPgDsc = maPageDescs.release(maPageDescs.begin() + nDummyPgDsc).release();
maPageDescs.clear();
// Delete for Collections
diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx
index 47c945a..6b79713 100644
--- a/sw/source/core/layout/pagedesc.cxx
+++ b/sw/source/core/layout/pagedesc.cxx
@@ -460,10 +460,4 @@ SwPageDescExt::operator SwPageDesc() const
return aResult;
}
-SwPageDescs::~SwPageDescs()
-{
- for(const_iterator it = begin(); it != end(); ++it)
- delete *it;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list