summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-06-24 13:09:14 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2014-08-20 10:12:20 +0200
commit55ed342c133fc117899be0d8bd288c66498fa448 (patch)
tree758717476c37130d00c5495c336a7b6d86780048
parenta2e757810a6afa10c3041c2c577a3b34f8904bb8 (diff)
pagedesc: It's better when MakePageDesc returns a pointer.
This removes many uses of GetPageDesc(sal_uInt16). (cherry picked from commit f246ac13bd1a12e11eba03cbe3c62ea77293e02e) Conflicts: sw/inc/doc.hxx sw/source/core/doc/docdesc.cxx sw/source/core/doc/poolfmt.cxx sw/source/filter/ww1/fltshell.cxx sw/source/filter/ww8/ww8par.cxx sw/source/uibase/app/docstyle.cxx sw/source/uibase/dbui/dbmgr.cxx Change-Id: I9660e30d7fccd4336422ba03b19087321a7ae973
-rw-r--r--sw/inc/doc.hxx2
-rw-r--r--sw/source/core/attr/swatrset.cxx3
-rw-r--r--sw/source/core/doc/docdesc.cxx4
-rw-r--r--sw/source/core/doc/docfmt.cxx5
-rw-r--r--sw/source/core/doc/docnew.cxx10
-rw-r--r--sw/source/core/doc/poolfmt.cxx3
-rw-r--r--sw/source/filter/ww1/fltshell.cxx4
-rw-r--r--sw/source/filter/ww8/ww8par.cxx3
-rw-r--r--sw/source/ui/app/docstyle.cxx3
-rw-r--r--sw/source/ui/dbui/dbmgr.cxx11
10 files changed, 21 insertions, 27 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index ff372aa7ac5c..23791acdd33c 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1371,7 +1371,7 @@ public:
void DelPageDesc( const String & rName, bool bBroadcast = false);
void DelPageDesc( sal_uInt16 i, bool bBroadcast = false );
void PreDelPageDesc(SwPageDesc * pDel);
- sal_uInt16 MakePageDesc( const String &rName, const SwPageDesc* pCpy = 0,
+ SwPageDesc* MakePageDesc( const String &rName, const SwPageDesc* pCpy = 0,
bool bRegardLanguage = true,
bool bBroadcast = false);
void BroadcastStyleOperation(String rName, SfxStyleFamily eFamily,
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx
index bdf8b003e7a7..f190cb483b6e 100644
--- a/sw/source/core/attr/swatrset.cxx
+++ b/sw/source/core/attr/swatrset.cxx
@@ -311,8 +311,7 @@ void SwAttrSet::CopyToModify( SwModify& rMod ) const
pPgDesc->GetName() );
if( !pDstPgDesc )
{
- pDstPgDesc = &pDstDoc->GetPageDesc(
- pDstDoc->MakePageDesc( pPgDesc->GetName() ));
+ pDstPgDesc = pDstDoc->MakePageDesc(pPgDesc->GetName());
pDstDoc->CopyPageDesc( *pPgDesc, *pDstPgDesc );
}
SwFmtPageDesc aDesc( pDstPgDesc );
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 9694337f1b2f..2a755697f9aa 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -585,7 +585,7 @@ void SwDoc::DelPageDesc( sal_uInt16 i, bool bBroadcast )
SetModified();
}
-sal_uInt16 SwDoc::MakePageDesc( const String &rName, const SwPageDesc *pCpy,
+SwPageDesc* SwDoc::MakePageDesc( const String &rName, const SwPageDesc *pCpy,
bool bRegardLanguage, bool bBroadcast)
{
SwPageDesc *pNew;
@@ -627,7 +627,7 @@ sal_uInt16 SwDoc::MakePageDesc( const String &rName, const SwPageDesc *pCpy,
}
SetModified();
- return (maPageDescs.size()-1);
+ return pNew;
}
SwPageDesc* SwDoc::FindPageDescByName( const String& rName, sal_uInt16* pPos ) const
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 78e347bcc957..dde916a0060e 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1993,7 +1993,7 @@ void SwDoc::CopyFmtArr( const SwFmtsBase& rSourceArr,
SwPageDesc* pPageDesc = ::lcl_FindPageDesc( maPageDescs, rNm );
if( !pPageDesc )
{
- pPageDesc = maPageDescs[ MakePageDesc( rNm ) ];
+ pPageDesc = MakePageDesc(rNm);
}
aPageDesc.RegisterToPageDesc( *pPageDesc );
SwAttrSet aTmpAttrSet( pSrc->GetAttrSet() );
@@ -2122,8 +2122,7 @@ void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc,
if( !pFollow )
{
// copy
- sal_uInt16 nPos = MakePageDesc( rSrcDesc.GetFollow()->GetName() );
- pFollow = maPageDescs[ nPos ];
+ pFollow = MakePageDesc(rSrcDesc.GetFollow()->GetName());
CopyPageDesc( *rSrcDesc.GetFollow(), *pFollow );
}
rDstDesc.SetFollow( pFollow );
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 91aa23b2ad9e..3d62e4f8a2cc 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -804,8 +804,7 @@ void SwDoc::ClearDoc()
InitTOXTypes();
// create a dummy pagedesc for the layout
- sal_uInt16 nDummyPgDsc = MakePageDesc(OUString("?DUMMY?"));
- SwPageDesc* pDummyPgDsc = maPageDescs[ nDummyPgDsc ];
+ SwPageDesc* pDummyPgDsc = MakePageDesc(OUString("?DUMMY?"));
SwNodeIndex aSttIdx( *GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
// create the first one over and over again (without attributes/style etc.
@@ -853,8 +852,11 @@ void SwDoc::ClearDoc()
// Counting of phantoms depends on <IsOldNumbering()>
mpOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) );
- // remove the dummy pagedec from the array and delete all the old ones
- maPageDescs.erase( maPageDescs.begin() + nDummyPgDsc );
+ // 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);
+
BOOST_FOREACH(SwPageDesc *pPageDesc, maPageDescs)
delete pPageDesc;
maPageDescs.clear();
diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx
index b6494f558c08..50dd2df7688a 100644
--- a/sw/source/core/doc/poolfmt.cxx
+++ b/sw/source/core/doc/poolfmt.cxx
@@ -1446,10 +1446,9 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
{
::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
- n = MakePageDesc( aNm, 0, bRegardLanguage );
+ pNewPgDsc = MakePageDesc(aNm, 0, bRegardLanguage);
}
- pNewPgDsc = maPageDescs[ n ];
pNewPgDsc->SetPoolFmtId( nId );
if( !bIsModified )
ResetModified();
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index 634d4bc9ff21..ecd6279b46c9 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -2098,17 +2098,15 @@ SwPageDesc* SwFltShell::MakePageDesc(SwPageDesc* pFirstPageDesc)
bool bFollow = (pFirstPageDesc != 0);
SwPageDesc* pNewPD;
- sal_uInt16 nPos;
if (bFollow && pFirstPageDesc->GetFollow() != pFirstPageDesc)
return pFirstPageDesc; // Fehler: hat schon Follow
// Erkennung doppelter Namen fehlt noch (Wahrscheinlichkeit
// fuer dopp. Namen ist gering)
- nPos = GetDoc().MakePageDesc( ViewShell::GetShellRes()->GetPageDescName(
+ pNewPD = GetDoc().MakePageDesc( ViewShell::GetShellRes()->GetPageDescName(
GetDoc().GetPageDescCnt(), bFollow ? ShellResource::FOLLOW_PAGE : ShellResource::NORMAL_PAGE),
pFirstPageDesc, false );
- pNewPD = &GetDoc().GetPageDesc(nPos);
if (bFollow)
{ // Dieser ist der folgende von pPageDesc
pFirstPageDesc->SetFollow(pNewPD);
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 645d2466e7f4..5801a4baf8c3 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -3959,10 +3959,9 @@ SwFmtPageDesc wwSectionManager::SetSwFmtPageDesc(mySegIter &rIter,
}
else
{
- sal_uInt16 nPos = mrReader.rDoc.MakePageDesc(
+ rIter->mpPage = mrReader.rDoc.MakePageDesc(
ViewShell::GetShellRes()->GetPageDescName(mnDesc, ShellResource::NORMAL_PAGE),
0, false);
- rIter->mpPage = &mrReader.rDoc.GetPageDesc(nPos);
}
OSL_ENSURE(rIter->mpPage, "no page!");
if (!rIter->mpPage)
diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx
index b0f1701e267b..927f8eaff7e2 100644
--- a/sw/source/ui/app/docstyle.cxx
+++ b/sw/source/ui/app/docstyle.cxx
@@ -1761,8 +1761,7 @@ void SwDocStyleSheet::Create()
pDesc = lcl_FindPageDesc( rDoc, aName );
if( !pDesc )
{
- sal_uInt16 nId = rDoc.MakePageDesc(aName);
- pDesc = &rDoc.GetPageDesc(nId);
+ pDesc = rDoc.MakePageDesc(aName);
}
break;
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index 36bbfaf49f96..926237d0591e 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -794,13 +794,12 @@ static void lcl_CopyFollowPageDesc(
{
SwDoc* pTargetDoc = rTargetShell.GetDoc();
String sNewFollowPageDesc = lcl_FindUniqueName(&rTargetShell, sFollowPageDesc, nDocNo );
- sal_uInt16 nNewDesc = pTargetDoc->MakePageDesc( sNewFollowPageDesc );
- SwPageDesc& rTargetFollowPageDesc = pTargetDoc->GetPageDesc( nNewDesc );
+ SwPageDesc* pTargetFollowPageDesc = pTargetDoc->MakePageDesc(sNewFollowPageDesc);
- pTargetDoc->CopyPageDesc( *pFollowPageDesc, rTargetFollowPageDesc, false );
- SwPageDesc aDesc( rTargetPageDesc );
- aDesc.SetFollow( &rTargetFollowPageDesc );
- pTargetDoc->ChgPageDesc( rTargetPageDesc.GetName(), aDesc );
+ pTargetDoc->CopyPageDesc(*pFollowPageDesc, *pTargetFollowPageDesc, false);
+ SwPageDesc aDesc(rTargetPageDesc);
+ aDesc.SetFollow(pTargetFollowPageDesc);
+ pTargetDoc->ChgPageDesc(rTargetPageDesc.GetName(), aDesc);
}
}