Index: sw/inc/doc.hxx =================================================================== --- sw/inc/doc.hxx (revision 1343140) +++ sw/inc/doc.hxx (working copy) @@ -183,6 +183,8 @@ class SwTxtFmtColl; class SwTxtFmtColls; class SwURLStateChanged; +class SwUndoJoinNode; +class SwUndoSplitNode; class SwUnoCrsr; class SwUnoCrsrTbl; class ViewShell; @@ -333,6 +335,9 @@ SwFldTypes *pFldTypes; // Feldtypen SwNewDBMgr *pNewDBMgr; // Pointer auf den neuen DBMgr fuer // Evaluierung der DB-Fields + SwUndoJoinNode* pUndoJoinForInsDoc; + SwUndoSplitNode* pUndoSplitForInsDoc; + bool mbNeedUndoForInsDoc; VirtualDevice *pVirDev; // can be used for formatting SfxPrinter *pPrt; // can be used for formatting @@ -408,7 +413,15 @@ bool operator()( const SwNodeNum* pNodeNumOne, const SwNodeNum* pNodeNumTwo ) const; }; + bool IsNeedUndoForInsDoc() {return mbNeedUndoForInsDoc;} + void SetNeedUndoForInsDoc(bool bPara) {mbNeedUndoForInsDoc = bPara;} + SwUndoJoinNode* GetUndoJoinForInsDoc() {return pUndoJoinForInsDoc;} + void SetUndoJoinForInsDoc(SwPaM& rPam) ; + void ClearUndoJoinForInsDoc(bool bDelUndo) ; + SwUndoSplitNode* GetUndoSplitForInsDoc() {return pUndoSplitForInsDoc;} + void SetUndoSplitForInsDoc(const SwPosition & rPos,bool bChkTableStart) ; + void ClearUndoSplitForInsDoc(bool bDelUndo) ; typedef ::std::set< const SwNodeNum*, lessThanNodeNum > tImplSortedNodeNumList; private: tImplSortedNodeNumList* mpListItemsList; Index: sw/inc/swundo.hxx =================================================================== --- sw/inc/swundo.hxx (revision 1343140) +++ sw/inc/swundo.hxx (working copy) @@ -154,6 +154,7 @@ UNDO_COL_DELETE, // 108 UNDO_ROW_DELETE, // 109 UNDO_RENAME_PAGEDESC, // 110 + UNDO_JOINNODE, UNDO_NUMDOWN, // 111 // --> OD 2009-07-16 #i73249# UNDO_FLYFRMFMT_TITLE, // 112 Index: sw/source/core/doc/docnew.cxx =================================================================== --- sw/source/core/doc/docnew.cxx (revision 1343140) +++ sw/source/core/doc/docnew.cxx (working copy) @@ -299,6 +299,9 @@ n32DummyCompatabilityOptions1(0), n32DummyCompatabilityOptions2(0), mbStartIdleTimer(sal_False), + pUndoJoinForInsDoc(NULL), + pUndoSplitForInsDoc(NULL), + mbNeedUndoForInsDoc(false), mbSetDrawDefaults(false) { RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDoc::SwDoc" ); @@ -699,6 +702,10 @@ delete pVirDev; SfxItemPool::Free(mpAttrPool); + if (pUndoJoinForInsDoc) + ClearUndoJoinForInsDoc(sal_True); + if (pUndoSplitForInsDoc) + ClearUndoSplitForInsDoc(sal_True); } //--------------------------------------------------- Index: sw/source/core/inc/UndoSplitMove.hxx =================================================================== --- sw/source/core/inc/UndoSplitMove.hxx (revision 1343140) +++ sw/source/core/inc/UndoSplitMove.hxx (working copy) @@ -37,8 +37,7 @@ sal_Bool bChkTblStt : 1; public: - SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos, sal_Bool bChkTbl ); - + SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos, sal_Bool bChkTbl, sal_Bool bForJoin = sal_False); virtual ~SwUndoSplitNode(); virtual void UndoImpl( ::sw::UndoRedoContext & ); @@ -49,6 +48,18 @@ }; +//Add a join node correspond undo action, which is a reverse undo action of split node +class SwUndoJoinNode: public SwUndoSplitNode +{ +public: + SwUndoJoinNode( SwDoc* pDoc, const SwPosition& rPos, sal_Bool bChkTbl ); + virtual ~SwUndoJoinNode(); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + void SetTblFlag() {SwUndoSplitNode::SetTblFlag(); } +}; + class SwUndoMove : public SwUndo, private SwUndRng, private SwUndoSaveCntnt { // nDest.. - destination range of move (after move!) Index: sw/source/core/undo/unspnd.cxx =================================================================== --- sw/source/core/undo/unspnd.cxx (revision 1343140) +++ sw/source/core/undo/unspnd.cxx (working copy) @@ -45,10 +45,10 @@ // SPLITNODE - +//Add a parameter for inherited undo action class... SwUndoSplitNode::SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos, - sal_Bool bChkTable ) - : SwUndo( UNDO_SPLITNODE ), pHistory( 0 ), pRedlData( 0 ), nNode( rPos.nNode.GetIndex() ), + sal_Bool bChkTable, sal_Bool bForJoin ) + : SwUndo( bForJoin?UNDO_JOINNODE:UNDO_SPLITNODE ), pHistory( 0 ), pRedlData( 0 ), nNode( rPos.nNode.GetIndex() ), nCntnt( rPos.nContent.GetIndex() ), bTblFlag( sal_False ), bChkTblStt( bChkTable ) { @@ -198,3 +198,65 @@ *rContext.GetRepeatPaM().GetPoint(), bChkTblStt ); } +void SwDoc::SetUndoSplitForInsDoc(const SwPosition & rPos,bool bChkTableStart) +{ + if (pUndoSplitForInsDoc) + delete pUndoSplitForInsDoc; + + pUndoSplitForInsDoc = new SwUndoSplitNode( this, rPos, bChkTableStart ); +} + +void SwDoc::ClearUndoSplitForInsDoc(bool bDelUndo) +{ + if (bDelUndo && pUndoJoinForInsDoc) + { + delete pUndoSplitForInsDoc; + } + + pUndoSplitForInsDoc = NULL; +} + + +//Add a join node correspond undo action, which is a reverse undo action of split node +SwUndoJoinNode::SwUndoJoinNode( SwDoc* pDoc, const SwPosition& rPos, + sal_Bool bChkTable ) + :SwUndoSplitNode(pDoc,rPos,bChkTable,sal_True) +{ +} + +SwUndoJoinNode::~SwUndoJoinNode() +{ +} + +void SwUndoJoinNode::UndoImpl( ::sw::UndoRedoContext & rUndoRedoContext) +{ + SwUndoSplitNode::RedoImpl(rUndoRedoContext); +} + +void SwUndoJoinNode::RedoImpl( ::sw::UndoRedoContext& rUndoRedoContext) +{ + SwUndoSplitNode::UndoImpl(rUndoRedoContext); +} + +void SwUndoJoinNode::RepeatImpl( ::sw::RepeatContext& ) +{ + return; +} + +void SwDoc::SetUndoJoinForInsDoc(SwPaM& rPam) +{ + if (pUndoJoinForInsDoc) + delete pUndoJoinForInsDoc; + + pUndoJoinForInsDoc = new SwUndoJoinNode(this,*rPam.Start(),false); +} + +void SwDoc::ClearUndoJoinForInsDoc(bool bDelUndo) +{ + if (bDelUndo && pUndoJoinForInsDoc) + { + delete pUndoJoinForInsDoc; + } + + pUndoJoinForInsDoc = NULL; +} Index: sw/source/filter/basflt/shellio.cxx =================================================================== --- sw/source/filter/basflt/shellio.cxx (revision 1343140) +++ sw/source/filter/basflt/shellio.cxx (working copy) @@ -144,6 +144,7 @@ pDoc->GetIDocumentUndoRedo().ClearRedo(); pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_INSDOKUMENT, NULL ); } + pDoc->SetNeedUndoForInsDoc(sal_True); } pDoc->GetIDocumentUndoRedo().DoUndo(false); @@ -159,6 +160,14 @@ while( sal_True ) { + if (pDoc->GetUndoJoinForInsDoc()) + { + pDoc->ClearUndoJoinForInsDoc(sal_True); + } + if (pDoc->GetUndoSplitForInsDoc()) + { + pDoc->ClearUndoSplitForInsDoc(sal_True); + } if( bSaveUndo ) pUndo = new SwUndoInsDoc( *pPam ); @@ -312,14 +321,41 @@ if( bSaveUndo ) { pDoc->SetRedlineMode_intern( eOld ); + + if (pDoc->GetUndoSplitForInsDoc()) + { + pDoc->GetIDocumentUndoRedo().AppendUndo((SwUndo*)pDoc->GetUndoSplitForInsDoc()); + pDoc->ClearUndoSplitForInsDoc(sal_False); + } + if (pDoc->GetUndoJoinForInsDoc()) + { + pUndoPam->End()->nNode++; + pUndoPam->End()->nContent = 0; + } + pUndo->SetInsertRange( *pUndoPam, sal_False ); // UGLY: temp. enable undo pDoc->GetIDocumentUndoRedo().DoUndo(true); pDoc->GetIDocumentUndoRedo().AppendUndo( pUndo ); - pDoc->GetIDocumentUndoRedo().DoUndo(false); + + if (pDoc->GetUndoJoinForInsDoc()) + { + pDoc->GetIDocumentUndoRedo().AppendUndo((SwUndo*)pDoc->GetUndoJoinForInsDoc()); + pDoc->ClearUndoJoinForInsDoc(sal_False); + } + pDoc->GetIDocumentUndoRedo().DoUndo(false); pDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_IGNORE ); } + if (pDoc->GetUndoJoinForInsDoc()) + { + pDoc->ClearUndoJoinForInsDoc(sal_True); + } + if (pDoc->GetUndoSplitForInsDoc()) + { + pDoc->ClearUndoSplitForInsDoc(sal_True); + } + delete pUndoPam; pPam = (SwPaM *) pPam->GetNext(); @@ -349,6 +385,8 @@ pDoc->UpdateNumRule(); pDoc->ChkCondColls(); pDoc->SetAllUniqueFlyNames(); + if (bSaveUndo) + pDoc->SetNeedUndoForInsDoc(sal_False); pDoc->SetLoaded( true ); pDoc->GetIDocumentUndoRedo().DoUndo(bDocUndo); Index: sw/source/filter/ww8/ww8par.cxx =================================================================== --- sw/source/filter/ww8/ww8par.cxx (revision 1343140) +++ sw/source/filter/ww8/ww8par.cxx (working copy) @@ -82,6 +82,7 @@ #include #include // fuer SwPam #include +#include #include // class SwTxtNode #include // class SwPageDesc #include @@ -3046,7 +3047,8 @@ EndSpecial(); } -bool SwWW8ImplReader::ReadText(long nStartCp, long nTextLen, ManTypes nType) +//Add a parameter for verify whether need record a join node undo... +bool SwWW8ImplReader::ReadText(long nStartCp, long nTextLen, ManTypes nType, bool bAtEndofCnt) { sw::log::Environment eContext = sw::log::eMainText; if (nType == MAN_MAINTEXT) @@ -3221,7 +3223,7 @@ AppendTxtNode(*pPaM->GetPoint()); if (!bInHyperlink) - bJoined = JoinNode(*pPaM); + bJoined = JoinNode(*pPaM,false,bAtEndofCnt); CloseAttrEnds(); @@ -4032,6 +4034,8 @@ { // EinfuegePos nicht am Ende der Zeile rDoc.SplitNode( *pPos, false ); // neue Zeile pPaM->Move( fnMoveBackward ); // gehe in leere Zeile + if (!mbNewDoc && !rDoc.GetIDocumentUndoRedo().DoesUndo() && rDoc.IsNeedUndoForInsDoc()) + rDoc.SetUndoSplitForInsDoc(*pPos,false); } // verhinder das Einlesen von Tabellen in Fussnoten / Tabellen @@ -4070,7 +4074,7 @@ } else //ordinary case { - ReadText(0, pWwFib->ccpText, MAN_MAINTEXT); + ReadText(0, pWwFib->ccpText, MAN_MAINTEXT, true); } ::SetProgressState(nProgress, mpDocShell); // Update Index: sw/source/filter/ww8/ww8par.hxx =================================================================== --- sw/source/filter/ww8/ww8par.hxx (revision 1343140) +++ sw/source/filter/ww8/ww8par.hxx (working copy) @@ -1139,7 +1139,8 @@ long ReadTextAttr(WW8_CP& rTxtPos, bool& rbStartLine); void ReadAttrs(WW8_CP& rNext, WW8_CP& rTxtPos, bool& rbStartLine); void CloseAttrEnds(); - bool ReadText(long nStartCp, long nTextLen, ManTypes nType); + //Add a parameter for verify whether need record a join node undo... + bool ReadText(long nStartCp, long nTextLen, ManTypes nType, bool bAtEndofCnt = false); void ReadRevMarkAuthorStrTabl( SvStream& rStrm, sal_Int32 nTblPos, sal_Int32 nTblSiz, SwDoc& rDoc ); @@ -1165,7 +1166,8 @@ void ResetCJKCharSetVars(); const SfxPoolItem* GetFmtAttr( sal_uInt16 nWhich ); - bool JoinNode(SwPaM &rPam, bool bStealAttr = false); + //Add a parameter for verify whether need record a join node undo... + bool JoinNode(SwPaM &rPam, bool bStealAttr = false, bool bAtEndofCnt = false); bool IsBorder(const WW8_BRC* pbrc, bool bChkBtwn = false) const; Index: sw/source/filter/ww8/ww8par6.cxx =================================================================== --- sw/source/filter/ww8/ww8par6.cxx (revision 1343140) +++ sw/source/filter/ww8/ww8par6.cxx (working copy) @@ -79,6 +79,7 @@ #include // SwTxtNode, siehe unten: JoinNode() #include // fuer SwPam #include +#include #include // class SwPageDesc #include #include @@ -2533,12 +2534,14 @@ maSegments.back().maStart = SwNodeIndex(rNode); } -bool SwWW8ImplReader::JoinNode(SwPaM &rPam, bool bStealAttr) +//Add a parameter for verify whether need record a join node undo... +bool SwWW8ImplReader::JoinNode(SwPaM &rPam, bool bStealAttr, bool bAtEndofCnt) { bool bRet = false; rPam.GetPoint()->nContent = 0; // an den Anfang der Zeile gehen SwNodeIndex aPref(rPam.GetPoint()->nNode, -1); + SwPaM aUndoPaM(aPref,0,rPam.GetPoint()->nNode,0); if (SwTxtNode* pNode = aPref.GetNode().GetTxtNode()) { @@ -2547,6 +2550,12 @@ rPam.GetPoint()->nContent.Assign(pNode, pNode->GetTxt().Len()); if (bStealAttr) pCtrlStck->StealAttr(rPam.GetPoint()); + if (aUndoPaM.GetMark()->nNode == aPref) + aUndoPaM.GetMark()->nContent.Assign(pNode, pNode->GetTxt().Len()); + else if (aUndoPaM.GetPoint()->nNode == aPref) + aUndoPaM.GetPoint()->nContent.Assign(pNode, pNode->GetTxt().Len()); + if (bAtEndofCnt && !mbNewDoc && !rDoc.GetIDocumentUndoRedo().DoesUndo() && rDoc.IsNeedUndoForInsDoc()) + rDoc.SetUndoJoinForInsDoc(aUndoPaM); pNode->JoinNext();