diff options
-rw-r--r-- | sw/inc/IDocumentUndoRedo.hxx | 11 | ||||
-rw-r--r-- | sw/inc/doc.hxx | 2 | ||||
-rw-r--r-- | sw/inc/ndarr.hxx | 2 | ||||
-rw-r--r-- | sw/inc/shellio.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/docnode/ndsect.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/docnode/nodes.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/inc/UndoManager.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/undo/docundo.cxx | 30 | ||||
-rw-r--r-- | sw/source/core/undo/undel.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/undo/undobj.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/undo/undobj1.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/writer/writer.cxx | 6 |
14 files changed, 66 insertions, 53 deletions
diff --git a/sw/inc/IDocumentUndoRedo.hxx b/sw/inc/IDocumentUndoRedo.hxx index 4bea595be4c5..2d48da01b92f 100644 --- a/sw/inc/IDocumentUndoRedo.hxx +++ b/sw/inc/IDocumentUndoRedo.hxx @@ -144,13 +144,6 @@ public: virtual SwUndoId GetUndoIds(String *const o_pStr, SwUndoIds *const o_pUndoIds) const = 0; - /* @@@MAINTAINABILITY-HORROR@@@ - Implementation details made public. - die drei folgenden Methoden werden beim Undo und nur dort - benoetigt. Sollten sonst nicht aufgerufen werden. - */ - virtual const SwNodes* GetUndoNds() const = 0; - virtual SwUndo* RemoveLastUndo(SwUndoId const eUndoId) = 0; /** 2002-05-31 dvo, #95884#: To prevent an undo array overflow when @@ -200,6 +193,10 @@ public: */ virtual void ClearRedo() = 0; + /* Is the given nodes array the Undo nodes array? + */ + virtual bool IsUndoNodes(SwNodes const& rNodes) const = 0; + protected: virtual ~IDocumentUndoRedo() {}; }; diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 55a1225b6e10..82d75fbec82e 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -288,7 +288,6 @@ class SW_DLLPUBLIC SwDoc : // ------------------------------------------------------------------- // die Objecte SwNodes aNodes; // Inhalt des Dokumentes - SwNodes aUndoNodes; // Inhalt fuer das Undo SwAttrPool* mpAttrPool; // der Attribut Pool SwPageDescs aPageDescs; // PageDescriptoren Link aOle2Link; // OLE 2.0-Benachrichtigung @@ -798,7 +797,6 @@ public: */ IDocumentUndoRedo & GetIDocumentUndoRedo(); IDocumentUndoRedo const& GetIDocumentUndoRedo() const; - virtual SwNodes const* GetUndoNds() const; /** abfragen/setzen der Anzahl von wiederherstellbaren Undo-Actions */ static sal_uInt16 GetUndoActionCount(); diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index dd822a11dfdd..db22f73b2238 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -129,7 +129,7 @@ class SW_DLLPUBLIC SwNodes: private BigPtrArray BOOL bNewFrms = TRUE, BOOL bTblInsDummyNode = FALSE ) const; void _DelDummyNodes( const SwNodeRange& rRg ); -protected: +public: SwNodes( SwDoc* pDoc ); public: diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index 0e52ce256754..54055242fb03 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -516,8 +516,8 @@ public: SvPtrarr& rArr ); // lege einen neuen PaM an der Position an - static SwPaM* NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, - BOOL bNodesArray = TRUE ); + static SwPaM * NewSwPaM(SwDoc & rDoc, + ULONG const nStartIdx, ULONG const nEndIdx); // kopiere ggfs. eine lokale Datei ins Internet BOOL CopyLocalFileToINet( String& rFileNm ); diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 8886b4e339ed..1114f2fa47b9 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -220,7 +220,6 @@ BOOL lcl_DelFmtIndizes( const SwFrmFmtPtr& rpFmt, void* ) SwDoc::SwDoc() : aNodes( this ), - aUndoNodes( this ), mpAttrPool(new SwAttrPool(this)), pMarkManager(new ::sw::mark::MarkManager(*this)), m_pMetaFieldManager(new ::sw::MetaFieldManager()), @@ -428,7 +427,9 @@ SwDoc::SwDoc() : pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) ); // <-- - new SwTxtNode( SwNodeIndex( aUndoNodes.GetEndOfContent() ), pDfltTxtFmtColl ); + new SwTxtNode( + SwNodeIndex(GetUndoManager().GetUndoNodes().GetEndOfContent()), + pDfltTxtFmtColl ); new SwTxtNode( SwNodeIndex( aNodes.GetEndOfContent() ), GetTxtCollFromPool( RES_POOLCOLL_STANDARD )); @@ -546,7 +547,8 @@ SwDoc::~SwDoc() // die KapitelNummern / Nummern muessen vor den Vorlage geloescht werden // ansonsten wird noch staendig geupdatet !!! aNodes.pOutlineNds->Remove( USHORT(0), aNodes.pOutlineNds->Count() ); - aUndoNodes.pOutlineNds->Remove( USHORT(0), aUndoNodes.pOutlineNds->Count() ); + SwNodes & rUndoNodes( GetUndoManager().GetUndoNodes() ); + rUndoNodes.pOutlineNds->Remove(USHORT(0), rUndoNodes.pOutlineNds->Count()); pFtnIdxs->Remove( USHORT(0), pFtnIdxs->Count() ); @@ -595,7 +597,7 @@ SwDoc::~SwDoc() // nicht erst durch den SwNodes-DTOR, damit Formate // keine Abhaengigen mehr haben. aNodes.DelNodes( SwNodeIndex( aNodes ), aNodes.Count() ); - aUndoNodes.DelNodes( SwNodeIndex( aUndoNodes ), aUndoNodes.Count() ); + rUndoNodes.DelNodes( SwNodeIndex( rUndoNodes ), rUndoNodes.Count() ); // Formate loeschen, spaeter mal permanent machen. diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index 5ea2f9da1959..3ae133ab86b1 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -1342,7 +1342,8 @@ SwSectionNode* SwSectionNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) c : CREATE_NONE ); // falls als Server aus dem Undo kopiert wird, wieder eintragen - if (m_pSection->IsServer() && (pDoc->GetUndoNds() == &rNds)) + if (m_pSection->IsServer() + && pDoc->GetIDocumentUndoRedo().IsUndoNodes(rNds)) { pNewSect->SetRefObject( m_pSection->GetObject() ); pDoc->GetLinkManager().InsertServer( pNewSect->GetObject() ); diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 5fbbdd45e7ed..6392f4af045d 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -228,8 +228,8 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, } else { - int bSavePersData = GetDoc()->GetUndoNds() == &rNds; - int bRestPersData = GetDoc()->GetUndoNds() == this; + bool bSavePersData(GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(rNds)); + bool bRestPersData(GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(*this)); SwDoc* pDestDoc = rNds.GetDoc() != GetDoc() ? rNds.GetDoc() : 0; if( !bRestPersData && !bSavePersData && pDestDoc ) bSavePersData = bRestPersData = TRUE; @@ -660,7 +660,8 @@ BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, } } - if( GetDoc()->GetUndoNds() == &rNodes ) + if (GetDoc()->GetIDocumentUndoRedo().IsUndoNodes( + rNodes)) { SwFrmFmt* pTblFmt = pTblNd->GetTable().GetFrmFmt(); SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, @@ -697,8 +698,8 @@ BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, // noch den EndNode erzeugen new SwEndNode( aIdx, *pTmp ); } - else if( (const SwNodes*)&rNodes == - GetDoc()->GetUndoNds() ) + else if (GetDoc()->GetIDocumentUndoRedo().IsUndoNodes( + rNodes)) { // im UndoNodes-Array spendieren wir einen // Platzhalter @@ -764,7 +765,7 @@ BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, case ND_SECTIONNODE: if( !nLevel && - ( (const SwNodes*)&rNodes == GetDoc()->GetUndoNds() ) ) + GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(rNodes)) { // dann muss an der akt. InsPos ein SectionDummyNode // eingefuegt werden @@ -891,7 +892,7 @@ BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, break; case ND_SECTIONDUMMY: - if( (const SwNodes*)this == GetDoc()->GetUndoNds() ) + if (GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(*this)) { if( &rNodes == this ) // innerhalb vom UndoNodesArray { @@ -2208,7 +2209,7 @@ void SwNodes::_CopyNodes( const SwNodeRange& rRange, break; case ND_SECTIONDUMMY: - if( (const SwNodes*)this == GetDoc()->GetUndoNds() ) + if (GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(*this)) { // dann muss an der akt. InsPos auch ein SectionNode // (Start/Ende) stehen; dann diesen ueberspringen. diff --git a/sw/source/core/inc/UndoManager.hxx b/sw/source/core/inc/UndoManager.hxx index 5ec02212f84c..a82a8ff7633d 100644 --- a/sw/source/core/inc/UndoManager.hxx +++ b/sw/source/core/inc/UndoManager.hxx @@ -67,7 +67,6 @@ public: virtual void DelAllUndoObj(); virtual SwUndoId GetUndoIds(String *const o_pStr, SwUndoIds *const o_pUndoIds) const; - virtual const SwNodes* GetUndoNds() const; virtual SwUndo* RemoveLastUndo(SwUndoId const eUndoId); virtual bool HasTooManyUndos() const; virtual bool Redo(SwUndoIter & rUndoIter); @@ -77,6 +76,7 @@ public: virtual SwUndoId GetRepeatIds(String *const o_pStr) const; virtual void AppendUndo(SwUndo *const pUndo); virtual void ClearRedo(); + virtual bool IsUndoNodes(SwNodes const& rNodes) const; SwUndo* GetLastUndo(); @@ -85,10 +85,15 @@ public: void SetNoDrawUndoObj( bool const bFlag ) { mbNoDrawUndoObj = bFlag; } sal_Bool RestoreInvisibleContent(); + SwNodes const& GetUndoNodes() const; + SwNodes & GetUndoNodes(); private: SwDoc & m_rDoc; + /// Undo nodes array: content not currently in document + ::std::auto_ptr<SwNodes> m_pUndoNodes; + ::std::auto_ptr<SwUndos> pUndos; // Undo/Redo History sal_uInt16 nUndoPos; // current Undo-InsertPosition (beyond: Redo) diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index d6a6dfb045ac..defb97b89d13 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -64,6 +64,7 @@ #include <charfmt.hxx> #include <ndtxt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <pam.hxx> // fuer SwPosition #include <fldbas.hxx> @@ -1628,7 +1629,8 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, } } - const bool bUndoNodes = !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + bool const bUndoNodes = !pOtherDoc + && GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(GetNodes()); // Ende erst jetzt holen, weil beim Kopieren in sich selbst der // Start-Index und alle Attribute vorher aktualisiert werden. @@ -2098,8 +2100,8 @@ void SwTxtNode::CutImpl( SwTxtNode * const pDest, const SwIndex & rDestStart, const xub_StrLen nEnd = rStart.GetIndex() + nLen; SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) ? pDest->GetDoc() : 0; - const bool bUndoNodes = - !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + bool const bUndoNodes = !pOtherDoc + && GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(GetNodes()); ASSERT(!pOtherDoc, "mst: entering dead and bitrotted code; fasten your seatbelts!"); @@ -5084,7 +5086,7 @@ bool SwTxtNode::IsInClipboard() const bool SwTxtNode::IsInUndo() const { - return &GetNodes() == GetDoc()->GetUndoNds(); + return GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(GetNodes()); } bool SwTxtNode::IsInContent() const diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx index afee73194cba..0e058ce1b37d 100644 --- a/sw/source/core/undo/docundo.cxx +++ b/sw/source/core/undo/docundo.cxx @@ -30,10 +30,12 @@ #include <UndoManager.hxx> +#include <vcl/wrkwin.hxx> + #include <svx/svdmodel.hxx> -#include <vcl/wrkwin.hxx> #include <doc.hxx> +#include <ndarr.hxx> #include <pam.hxx> #include <ndtxt.hxx> #include <swundo.hxx> // fuer die UndoIds @@ -100,11 +102,6 @@ void UndoArrStatus::Paint( const Rectangle& ) // SwDoc methods ///////////////////////////////////////////////////////// -const SwNodes* SwDoc::GetUndoNds() const -{ - return &aUndoNodes; -} - bool SwDoc::IsNoDrawUndoObj() const { return GetUndoManager().IsNoDrawUndoObj(); @@ -146,6 +143,7 @@ void UndoManager::SetUndoActionCount( sal_uInt16 nNew ) UndoManager::UndoManager(SwDoc & rDoc) : m_rDoc(rDoc) + , m_pUndoNodes( new SwNodes(&rDoc) ) , pUndos( new SwUndos( 0, 20 ) ) , nUndoPos(0) , nUndoSavePos(0) @@ -158,9 +156,19 @@ UndoManager::UndoManager(SwDoc & rDoc) { } -const SwNodes* UndoManager::GetUndoNds() const +SwNodes const& UndoManager::GetUndoNodes() const +{ + return *m_pUndoNodes; +} + +SwNodes & UndoManager::GetUndoNodes() +{ + return *m_pUndoNodes; +} + +bool UndoManager::IsUndoNodes(SwNodes const& rNodes) const { - return m_rDoc.GetUndoNds(); + return & rNodes == m_pUndoNodes.get(); } void UndoManager::DoUndo(bool const bDoUndo) @@ -268,7 +276,7 @@ void UndoManager::AppendUndo(SwUndo *const pUndo) // zur Anzeige der aktuellen Undo-Groessen if( !pUndoMsgWin ) pUndoMsgWin = new UndoArrStatus; - pUndoMsgWin->Set( pUndos->Count(), m_rDoc.GetUndoNds()->Count() ); + pUndoMsgWin->Set( pUndos->Count(), GetUndoNodes()->Count() ); #endif // noch eine offene Klammerung, kann man sich den Rest schenken @@ -313,7 +321,7 @@ void UndoManager::AppendUndo(SwUndo *const pUndo) { USHORT nUndosCnt = nUndoCnt; // immer 1/10 loeschen bis der "Ausloeser" behoben ist - while (nEnde < m_rDoc.GetUndoNds()->Count()) + while (nEnde < GetUndoNodes().Count()) { DelUndoObj( nUndosCnt / 10 ); } @@ -615,7 +623,7 @@ UndoManager::EndUndo(SwUndoId const i_eUndoId, SwRewriter const*const pRewriter) USHORT nEnde = USHRT_MAX - 1000; USHORT nUndosCnt = nUndoCnt; // immer 1/10 loeschen bis der "Ausloeser" behoben ist - while (nEnde < m_rDoc.GetUndoNds()->Count()) + while (nEnde < GetUndoNodes().Count()) { DelUndoObj( nUndosCnt / 10 ); } diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 4b7e572b7bd9..b06ca115935b 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -36,7 +36,7 @@ #include <frmfmt.hxx> #include <fmtanchr.hxx> #include <doc.hxx> -#include <IDocumentUndoRedo.hxx> +#include <UndoManager.hxx> #include <swtable.hxx> #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> @@ -219,7 +219,7 @@ SwUndoDelete::SwUndoDelete( SwPaM& rPam, BOOL bFullPara, BOOL bCalledByTblCpy ) if( bMoveNds ) // sind noch Nodes zu verschieben ? { - SwNodes& rNds = (SwNodes&)*pDoc->GetUndoNds(); + SwNodes& rNds = pDoc->GetUndoManager().GetUndoNodes(); SwNodes& rDocNds = pDoc->GetNodes(); SwNodeRange aRg( rDocNds, nSttNode - nNdDiff, rDocNds, nEndNode - nNdDiff ); @@ -680,7 +680,6 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) else pInsNd = 0; // Node nicht loeschen !! - SwNodes* pUNds = (SwNodes*)pDoc->GetUndoNds(); BOOL bNodeMove = 0 != nNode; if( pEndStr ) @@ -757,7 +756,7 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) { SwNodeRange aRange( *pMvStt, 0, *pMvStt, nNode ); SwNodeIndex aCopyIndex( aPos.nNode, -1 ); - pUNds->_Copy( aRange, aPos.nNode ); + pDoc->GetUndoManager().GetUndoNodes()._Copy( aRange, aPos.nNode ); if( nReplaceDummy ) { diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index 66e048de6a39..59c6efebd4b4 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -34,7 +34,7 @@ #include <ftnidx.hxx> #include <frmfmt.hxx> #include <doc.hxx> -#include <IDocumentUndoRedo.hxx> +#include <UndoManager.hxx> #include <docary.hxx> #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> @@ -291,7 +291,7 @@ void SwUndoSaveCntnt::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx, SwNoTxtNode* pCpyNd = rPaM.GetNode()->GetNoTxtNode(); // jetzt kommt das eigentliche Loeschen(Verschieben) - SwNodes& rNds = (SwNodes&)*rDoc.GetUndoNds(); + SwNodes & rNds = rDoc.GetUndoManager().GetUndoNodes(); SwPosition aPos( pEndNdIdx ? rNds.GetEndOfPostIts() : rNds.GetEndOfExtras() ); aPos.nNode--; @@ -374,7 +374,7 @@ void SwUndoSaveCntnt::MoveFromUndoNds( SwDoc& rDoc, ULONG nNodeIdx, ULONG* pEndNdIdx, xub_StrLen* pEndCntIdx ) { // jetzt kommt das wiederherstellen - SwNodes& rNds = (SwNodes&)*rDoc.GetUndoNds(); + SwNodes & rNds = rDoc.GetUndoManager().GetUndoNodes(); if( nNodeIdx == rNds.GetEndOfPostIts().GetIndex() ) return; // nichts gespeichert diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index a0ba635549ac..c8b670967bb6 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -394,7 +394,7 @@ SwUndoDelLayFmt::SwUndoDelLayFmt( SwFrmFmt* pFormat ) SwNodeIndex* pIdx = GetMvSttIdx(); SwNode* pNd; if( 1 == GetMvNodeCnt() && pIdx && - ( pNd = (*pDoc->GetUndoNds())[ *pIdx ] )->IsNoTxtNode() ) + ( pNd = & pIdx->GetNode() )->IsNoTxtNode() ) { // dann setze eine andere Undo-ID; Grafik oder OLE if( pNd->IsGrfNode() ) @@ -418,7 +418,7 @@ SwRewriter SwUndoDelLayFmt::GetRewriter() const SwNodeIndex* pIdx = GetMvSttIdx(); if( 1 == GetMvNodeCnt() && pIdx) { - SwNode * pNd = (*pDoc->GetUndoNds())[ *pIdx ]; + SwNode *const pNd = & pIdx->GetNode(); if ( pNd->IsNoTxtNode() && pNd->IsOLENode()) { diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index 2a77d47dd65b..f11cbd751c8e 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -223,10 +223,10 @@ sal_Int32 Writer::FindPos_Bkmk(const SwPosition& rPos) const } -SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, - BOOL bNodesArray ) +SwPaM * +Writer::NewSwPaM(SwDoc & rDoc, ULONG const nStartIdx, ULONG const nEndIdx) { - SwNodes* pNds = bNodesArray ? &rDoc.GetNodes() : (SwNodes*)rDoc.GetUndoNds(); + SwNodes *const pNds = &rDoc.GetNodes(); SwNodeIndex aStt( *pNds, nStartIdx ); SwCntntNode* pCNode = aStt.GetNode().GetCntntNode(); |