diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2014-07-22 12:39:51 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2014-09-30 09:56:33 +0200 |
commit | 868a72a9392789f78cd1bc5842d3847e803e5235 (patch) | |
tree | 1ba761d5e6f5c5fd29c21079f65c15d04dd899d2 | |
parent | 234fbca684c4e355908cfa083eddf2be3d081cd1 (diff) |
Introduce SwDoc::DelPageDescP and ChgPageDescP
Variants of DelPageDesc and ChgPageDesc, which work with the
SwPageDesc pointers instead of the names.
This moves all the code from the "name" to the "pointer" functions
and just adds a FindPageDescByName to the old functions before
calling the pointer variants.
(cherry picked from commit 41f386877a4c71295c3264720cbefd51d9bb7266)
Conflicts:
sw/inc/doc.hxx
sw/source/core/doc/docdesc.cxx
Change-Id: Ife03986ec2a3897273edd64b8136474441b6b771
-rw-r--r-- | sw/inc/doc.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docdesc.cxx | 48 |
2 files changed, 28 insertions, 22 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index d9628a93abc2..3de7ef178816 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1371,8 +1371,10 @@ public: { CopyPageDescHeaderFooterImpl( false, rSrcFmt, rDestFmt ); } //For Reader. + void ChgPageDescP( const SwPageDesc &, SwPageDesc *pDesc = NULL ); void ChgPageDesc( const String & rName, const SwPageDesc& ); void ChgPageDesc( sal_uInt16 i, const SwPageDesc& ); + void DelPageDescP( SwPageDesc *pDel, bool bBroadcast = false ); void DelPageDesc( const String & rName, bool bBroadcast = false); void DelPageDesc( sal_uInt16 i, bool bBroadcast = false ); void PreDelPageDesc(SwPageDesc * pDel); diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx index 184ae52cc8a7..9b79b7366ce5 100644 --- a/sw/source/core/doc/docdesc.cxx +++ b/sw/source/core/doc/docdesc.cxx @@ -321,11 +321,10 @@ void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, } } -void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged ) +void SwDoc::ChgPageDescP( const SwPageDesc &rChged, SwPageDesc *pDesc ) { - OSL_ENSURE( i < maPageDescs.size(), "PageDescs is out of range." ); - - SwPageDesc *pDesc = maPageDescs[i]; + if (!pDesc) + pDesc = const_cast<SwPageDesc*>( &rChged ); SwRootFrm* pTmpRoot = GetCurrentLayout(); if (GetIDocumentUndoRedo().DoesUndo()) @@ -496,12 +495,17 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged ) : pDesc->GetFirstLeft().GetFooter().GetFooterFmt() == pDesc->GetFirstMaster().GetFooter().GetFooterFmt()); } +void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged ) +{ + OSL_ENSURE( i < maPageDescs.size(), "PageDescs is out of range." ); + ChgPageDescP( rChged, maPageDescs[i] ); +} + /// All descriptors whose Follow point to the to-be-deleted have to be adapted. // #i7983# void SwDoc::PreDelPageDesc(SwPageDesc * pDel) { - if (0 == pDel) - return; + OSL_ENSURE( NULL != pDel, "PageDesc pointer is invalid." ); // mba: test iteration as clients are removed while iteration SwPageDescHint aHint( maPageDescs[0] ); @@ -559,14 +563,10 @@ void SwDoc::BroadcastStyleOperation(String rName, SfxStyleFamily eFamily, } } -void SwDoc::DelPageDesc( sal_uInt16 i, bool bBroadcast ) +void SwDoc::DelPageDescP( SwPageDesc *pDel, bool bBroadcast ) { - OSL_ENSURE( i < maPageDescs.size(), "PageDescs is out of range." ); - OSL_ENSURE( i != 0, "You cannot delete the default Pagedesc."); - if ( i == 0 ) - return; - - SwPageDesc *pDel = maPageDescs[i]; + OSL_ENSURE( pDel != NULL, "Don't try to delete a NULL pointer." ); + OSL_ENSURE( pDel != maPageDescs[0], "You cannot delete the default Pagedesc." ); if (bBroadcast) BroadcastStyleOperation(pDel->GetName(), SFX_STYLE_FAMILY_PAGE, @@ -580,11 +580,17 @@ void SwDoc::DelPageDesc( sal_uInt16 i, bool bBroadcast ) PreDelPageDesc(pDel); // #i7983# - maPageDescs.erase( maPageDescs.begin() + i ); + maPageDescs.erase( pDel ); delete pDel; SetModified(); } +void SwDoc::DelPageDesc( sal_uInt16 i, bool bBroadcast ) +{ + OSL_ENSURE( i < maPageDescs.size(), "PageDescs is out of range." ); + DelPageDescP( maPageDescs[ i ], bBroadcast ); +} + SwPageDesc* SwDoc::MakePageDesc( const String &rName, const SwPageDesc *pCpy, bool bRegardLanguage, bool bBroadcast) { @@ -850,18 +856,16 @@ SwPageDesc* SwDoc::FindPageDescByName( const OUString & rName, sal_uInt16* pPos void SwDoc::DelPageDesc( const String & rName, bool bBroadcast ) { - sal_uInt16 nI; - - if (FindPageDescByName(rName, &nI)) - DelPageDesc(nI, bBroadcast); + SwPageDesc *pd = FindPageDescByName(rName); + if (pd) + DelPageDescP(pd, bBroadcast); } void SwDoc::ChgPageDesc( const String & rName, const SwPageDesc & rDesc) { - sal_uInt16 nI; - - if (FindPageDescByName(rName, &nI)) - ChgPageDesc(nI, rDesc); + SwPageDesc *pd = FindPageDescByName(rName); + if (pd) + ChgPageDescP(rDesc, pd); } /* |