summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/doctxm.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/doc/doctxm.cxx')
-rw-r--r--sw/source/core/doc/doctxm.cxx61
1 files changed, 26 insertions, 35 deletions
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index 0f095068a991..13aaf3c1c1a0 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -366,26 +366,23 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( const SwPosition& rPos,
{
StartUndo( UNDO_INSTOX, NULL );
- SwTOXBaseSection* pNew = new SwTOXBaseSection( rTOX );
String sSectNm( rTOX.GetTOXName() );
sSectNm = GetUniqueTOXBaseName( *rTOX.GetTOXType(), &sSectNm );
- pNew->SetTOXName(sSectNm);
- pNew->SwSection::SetName(sSectNm);
SwPaM aPam( rPos );
- SwSection* pSect = InsertSwSection( aPam, *pNew, pSet, false );
- if( pSect )
+ SwSection aSection( TOX_CONTENT_SECTION, sSectNm );
+ SwTOXBaseSection *const pNewSection = dynamic_cast<SwTOXBaseSection *>(
+ InsertSwSection( aPam, aSection, & rTOX, pSet, false ));
+ if (pNewSection)
{
- SwSectionNode* pSectNd = pSect->GetFmt()->GetSectionNode();
- SwSection* pCl = pNew;
- pSect->GetFmt()->Add( pCl );
- pSectNd->SetNewSection( pNew );
+ SwSectionNode *const pSectNd = pNewSection->GetFmt()->GetSectionNode();
+ pNewSection->SetTOXName(sSectNm); // rTOX may have had no name...
if( bExpand )
{
// OD 19.03.2003 #106329# - add value for 2nd parameter = true to
// indicate, that a creation of a new table of content has to be performed.
// Value of 1st parameter = default value.
- pNew->Update( 0, true );
+ pNewSection->Update( 0, true );
}
else if( 1 == rTOX.GetTitle().Len() && IsInReading() )
// insert title of TOX
@@ -396,7 +393,7 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( const SwPosition& rPos,
SwTxtNode* pHeadNd = GetNodes().MakeTxtNode( aIdx,
GetTxtCollFromPool( RES_POOLCOLL_STANDARD ) );
- String sNm( pNew->GetTOXName() );
+ String sNm( pNewSection->GetTOXName() );
// ??Resource
sNm.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "_Head" ));
@@ -404,16 +401,14 @@ sNm.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "_Head" ));
SwNodeIndex aStt( *pHeadNd ); aIdx--;
SwSectionFmt* pSectFmt = MakeSectionFmt( 0 );
- GetNodes().InsertSection( aStt, *pSectFmt, aSect, &aIdx,
- TRUE, FALSE );
+ GetNodes().InsertTextSection(
+ aStt, *pSectFmt, aSect, 0, &aIdx, true, false);
}
}
- else
- delete pNew, pNew = 0;
EndUndo( UNDO_INSTOX, NULL );
- return pNew;
+ return pNewSection;
}
@@ -433,13 +428,10 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( ULONG nSttNd, ULONG nEndNd,
pSectNd = pSectNd->StartOfSectionNode()->FindSectionNode();
}
- // create SectionNode around the Nodes
- SwTOXBaseSection* pNew = new SwTOXBaseSection( rTOX );
-
String sSectNm( rTOX.GetTOXName() );
sSectNm = GetUniqueTOXBaseName(*rTOX.GetTOXType(), &sSectNm);
- pNew->SetTOXName(sSectNm);
- pNew->SwSection::SetName(sSectNm);
+
+ SwSection aSection(TOX_CONTENT_SECTION, sSectNm);
SwNodeIndex aStt( GetNodes(), nSttNd ), aEnd( GetNodes(), nEndNd );
SwSectionFmt* pFmt = MakeSectionFmt( 0 );
@@ -448,20 +440,18 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( ULONG nSttNd, ULONG nEndNd,
// --aEnd; // im InsertSection ist Ende inclusive
- pSectNd = GetNodes().InsertSection( aStt, *pFmt, *pNew, &aEnd );
- if( pSectNd )
+ SwSectionNode *const pNewSectionNode =
+ GetNodes().InsertTextSection(aStt, *pFmt, aSection, &rTOX, &aEnd);
+ if (!pNewSectionNode)
{
- SwSection* pCl = pNew;
- pFmt->Add( pCl );
- pSectNd->SetNewSection( pNew );
- }
- else
- {
- delete pNew, pNew = 0;
DelSectionFmt( pFmt );
+ return 0;
}
- return pNew;
+ SwTOXBaseSection *const pNewSection(
+ dynamic_cast<SwTOXBaseSection*>(& pNewSectionNode->GetSection()));
+ pNewSection->SetTOXName(sSectNm); // rTOX may have had no name...
+ return pNewSection;
}
/*--------------------------------------------------------------------
@@ -776,8 +766,9 @@ const SwTxtNode* lcl_FindChapterNode( const SwNode& rNd, BYTE nLvl = 0 )
Beschreibung: Verzeichnis-Klasse
--------------------------------------------------------------------*/
-SwTOXBaseSection::SwTOXBaseSection( const SwTOXBase& rBase )
- : SwTOXBase( rBase ), SwSection( TOX_CONTENT_SECTION, aEmptyStr )
+SwTOXBaseSection::SwTOXBaseSection(SwTOXBase const& rBase, SwSectionFmt & rFmt)
+ : SwTOXBase( rBase )
+ , SwSection( TOX_CONTENT_SECTION, aEmptyStr, & rFmt )
{
SetProtect( rBase.IsProtected() );
SwSection::SetName( GetTOXName() );
@@ -966,8 +957,8 @@ sNm.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "_Head" ));
SwNodeIndex aStt( *pHeadNd ); aIdx--;
SwSectionFmt* pSectFmt = pDoc->MakeSectionFmt( 0 );
- pDoc->GetNodes().InsertSection( aStt, *pSectFmt, aSect, &aIdx,
- TRUE, FALSE );
+ pDoc->GetNodes().InsertTextSection(
+ aStt, *pSectFmt, aSect, 0, &aIdx, true, false);
}
// jetzt waere ein prima Zeitpunkt, um die Numerierung zu updaten