summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2010-03-16 11:28:33 +0100
committerMichael Stahl <mst@openoffice.org>2010-03-16 11:28:33 +0100
commit709b61c242c5e76d9d71512fc334df60447616a4 (patch)
treeb74e050dfd033b46a73e15b0e86ad631e0c6d062 /sw/source
parentb214ab9fe52eb4944dd50978b6ad19af95047bdf (diff)
odfmetadata4: #i109599#: clean up SwUndoChgSection, and move it to unsect.cxx
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/docnode/ndsect.cxx4
-rw-r--r--sw/source/core/undo/unsect.cxx69
2 files changed, 48 insertions, 25 deletions
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 91a642be21b3..004b2b20be60 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -655,7 +655,7 @@ void SwDoc::UpdateSection(sal_uInt16 const nPos, SwSectionData & rNewData,
if( DoesUndo() )
{
ClearRedo();
- AppendUndo( new SwUndoChgSection( *pFmt, TRUE ) );
+ AppendUndo( MakeUndoUpdateSection( *pFmt, true ) );
// --> FME 2004-10-13 #i32968#
// Inserting columns in the section causes MakeFrmFmt to put two
// objects of type SwUndoFrmFmt on the undo stack. We don't want them.
@@ -696,7 +696,7 @@ void SwDoc::UpdateSection(sal_uInt16 const nPos, SwSectionData & rNewData,
if( DoesUndo() )
{
ClearRedo();
- AppendUndo( new SwUndoChgSection( *pFmt, FALSE ) );
+ AppendUndo( MakeUndoUpdateSection( *pFmt, false ) );
// --> FME 2004-10-13 #i32968#
// Inserting columns in the section causes MakeFrmFmt to put two
// objects of type SwUndoFrmFmt on the undo stack. We don't want them.
diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx
index aeb7d9da0cfe..21f4fd331879 100644
--- a/sw/source/core/undo/unsect.cxx
+++ b/sw/source/core/undo/unsect.cxx
@@ -393,46 +393,69 @@ void SwUndoDelSection::Redo( SwUndoIter& rUndoIter )
////////////////////////////////////////////////////////////////////////////
-SwUndoChgSection::SwUndoChgSection( const SwSectionFmt& rFmt, BOOL bOnlyAttr )
- : SwUndo( UNDO_CHGSECTION ), bOnlyAttrChgd( bOnlyAttr )
+class SwUndoUpdateSection
+ : public SwUndo
{
- const SwSection& rSect = *rFmt.GetSection();
-
- m_pSectionData.reset( new SwSectionData(rSect) );
+private:
+ ::std::auto_ptr<SwSectionData> m_pSectionData;
+ ::std::auto_ptr<SfxItemSet> m_pAttrSet;
+ ULONG const m_nStartNode;
+ bool const m_bOnlyAttrChanged;
- pAttr = ::lcl_GetAttrSet( rSect );
+public:
+ SwUndoUpdateSection(
+ SwSection const&, SwNodeIndex const*const, bool const bOnlyAttr);
+ virtual ~SwUndoUpdateSection();
+ virtual void Undo( SwUndoIter& );
+ virtual void Redo( SwUndoIter& );
+ OUT_UNDOBJ( SwUndoUpdateSection )
+};
- nSttNd = rFmt.GetCntnt().GetCntntIdx()->GetIndex();
+SW_DLLPRIVATE SwUndo *
+MakeUndoUpdateSection(SwSectionFmt const& rFormat, bool const bOnlyAttr)
+{
+ return new SwUndoUpdateSection(*rFormat.GetSection(),
+ rFormat.GetCntnt().GetCntntIdx(), bOnlyAttr);
}
-
-SwUndoChgSection::~SwUndoChgSection()
+SwUndoUpdateSection::SwUndoUpdateSection(
+ SwSection const& rSection, SwNodeIndex const*const pIndex,
+ bool const bOnlyAttr)
+ : SwUndo( UNDO_CHGSECTION )
+ , m_pSectionData( new SwSectionData(rSection) )
+ , m_pAttrSet( ::lcl_GetAttrSet(rSection) )
+ , m_nStartNode( pIndex->GetIndex() )
+ , m_bOnlyAttrChanged( bOnlyAttr )
{
- delete pAttr;
}
+SwUndoUpdateSection::~SwUndoUpdateSection()
+{
+}
-void SwUndoChgSection::Undo( SwUndoIter& rUndoIter )
+void SwUndoUpdateSection::Undo( SwUndoIter& rUndoIter )
{
SwDoc& rDoc = rUndoIter.GetDoc();
- SwSectionNode* pSectNd = rDoc.GetNodes()[ nSttNd ]->GetSectionNode();
+ SwSectionNode *const pSectNd =
+ rDoc.GetNodes()[ m_nStartNode ]->GetSectionNode();
ASSERT( pSectNd, "wo ist mein SectionNode?" );
SwSection& rNdSect = pSectNd->GetSection();
SwFmt* pFmt = rNdSect.GetFmt();
SfxItemSet* pCur = ::lcl_GetAttrSet( rNdSect );
- if( pAttr )
+ if (m_pAttrSet.get())
{
// das Content- und Protect-Item muss bestehen bleiben
const SfxPoolItem* pItem;
- pAttr->Put( pFmt->GetFmtAttr( RES_CNTNT ));
+ m_pAttrSet->Put( pFmt->GetFmtAttr( RES_CNTNT ));
if( SFX_ITEM_SET == pFmt->GetItemState( RES_PROTECT, TRUE, &pItem ))
- pAttr->Put( *pItem );
- pFmt->DelDiffs( *pAttr );
- pAttr->ClearItem( RES_CNTNT );
- pFmt->SetFmtAttr( *pAttr );
- delete pAttr;
+ {
+ m_pAttrSet->Put( *pItem );
+ }
+ pFmt->DelDiffs( *m_pAttrSet );
+ m_pAttrSet->ClearItem( RES_CNTNT );
+ pFmt->SetFmtAttr( *m_pAttrSet );
}
else
{
@@ -441,9 +464,9 @@ void SwUndoChgSection::Undo( SwUndoIter& rUndoIter )
pFmt->ResetFmtAttr( RES_HEADER, RES_OPAQUE );
pFmt->ResetFmtAttr( RES_SURROUND, RES_FRMATR_END-1 );
}
- pAttr = pCur;
+ m_pAttrSet.reset(pCur);
- if( !bOnlyAttrChgd )
+ if (!m_bOnlyAttrChanged)
{
const bool bUpdate =
(!rNdSect.IsLinkType() && m_pSectionData->IsLinkType())
@@ -466,8 +489,8 @@ void SwUndoChgSection::Undo( SwUndoIter& rUndoIter )
}
}
-
-void SwUndoChgSection::Redo( SwUndoIter& rUndoIter )
+void SwUndoUpdateSection::Redo( SwUndoIter& rUndoIter )
{
Undo( rUndoIter );
}
+