summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/doc.hxx2
-rw-r--r--sw/source/core/doc/docdesc.cxx48
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);
}
/*