Hi Andreas
I have modified my code like below
/**************************************************************************/
BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
const SwNodeIndex& aIndex, BOOL bNewFrms )
{
......
SwNodeRange aRg( aRange );
aRg.aStart--;
if( ND_STARTNODE == (pAktNode = &aRg.aStart.GetNode())-> GetNodeType() )
{
aRg.aEnd--;
SwNode * pTmpAktNode = &aRg.aEnd.GetNode();
if( bNewFrms && ((SwCntntNode*)pTmpAktNode)-> GetDepends() )
{
GetDoc()-> AppendTxtNode( SwPosition( *pAktNode ) );
aRg.aStart++;
}
aRg.aEnd++;
}
aRg.aStart++;
while( ND_STARTNODE == (pAktNode = &aRg.aStart.GetNode())-> GetNodeType()
|| ( pAktNode-> IsEndNode() &&
!pAktNode-> pStartOfSection-> IsSectionNode() ) )
aRg.aStart++;
aRg.aStart--;
.........
}
/*************************************************************************/
add many code mark as RED,this can fix the second problem that you told me(like
below)
> new document
> insert a word
> insert a frame
> undo
> undo => crash
but cann't fix the first.
I guess I need update the aRange after append one node,but aRange has been
declared as const like below.
BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,const
SwNodeIndex& aIndex, BOOL bNewFrms )
so I need change the declare of aRange,but I think it's dangerous.
so,I wanna add some code before call _MoveNodes(...) in the
SwUndoDelete::SwUndoDelete( SwPaM& rPam, BOOL bFullPara, BOOL bCalledByTblCpy )
function of sw\source\core\undo\undel.cxx,the objects are below:
1.Check if the range is last section of this document
2.If 1 is true,then append one node to this range
3.Update the range
What do you think about this plan?
Awaiting your reply:)
Best Regards
Talen
> Hi Talen,
>
> 章华军 wrote:
> [..]
> > In this case,I think OOo just create one page,after I rejected the
> > insertion and accepted the deletion I got an empty
page,if we set this page as superfluous and delete it,there is no page in this
document,I think maybe this is why we got
NULL from "(SwPageFrm*)GetPrev()".
> >
> Writer crashes because the last remaining page gets empty and is
> removed. This should not happen, but the bug is not that an empty page
> is removed. The bug is that there is no visible paragraph left. Writer
> relies on the fact that at least one paragraph is visible. This last
> paragraph must not be deleted. And if there is one paragraph there is at
> least one page which is not empty and Writer will not crash.
> [..]
> > I agree with you,but how(or when) can we ramain at least one
> > paragraph(empty or not) in design?I have tried to avoid set
the page as superfluous,but OOo will crash while do
SwCrsrShell::UpdateCrsrPos() because after do "SwCntntFrm *pFrm =
pCNode ?
> > pCNode-> GetFrm( &pCurCrsr-> GetPtPos(), pCurCrsr-> GetPoint() ) :0;"
> > the pFrm still be NULL(pCNode from this
sentence"SwCntntNode *pCNode = pCurCrsr-> GetCntntNode();"),that is why I have
this question.
> >
> This is too late, we have to avoid the removing of the last SwTxtNode
> from the nodes array. The SwTxtFrm needs a corresponding SwTxtNode. If
> you do not remove the last node, at least one SwFrm will stay and the
> page will not be marked as superfluous. The patch with the AppendTxtNode
> is not that bad because it tries to avoid the complete removing of nodes
> but it has side effects (undo, see below).
> > > > 3.What can I do to fix this issue?Now,I add AppenTxtNode function
> > > > befor delete last SectionNode to create one new
SwFrm
> > > >
> > and can avoid this issue,but I don't think it's right or complete method
> > for fixing this issue.
> >
> > > >
> > > >
> > > Yes, this fix would assert that at least one paragraph will remain. But
> > > this fix would have side-effects, e.g. I imagine that undo would run
> > > into trouble afterwards.
> > >
> > I have checked AppendTxtNode function,it will append this operation to
> > UNDO list,and I have tested this change,UNDO or
REDO is normal.
> >
> My first notice with the patch was the following:
> opening first document
> compare with second document
> reject the insertion
> accept the deletion
> => the document is empty
> undo
> redo
> => there is one paragraph with content visible (from the accepted deletion)
>
> Ok, this may be better than the crash but it shows a potential problem.
> But I detected another problem:
> new document
> insert a word
> insert a frame
> undo
> undo => crash
>
> [..]
> > > I propose to have a look into the insertion of the change tracks
> > > (SwDoc::AppendRedline()). It is not allowed that the change tracking
> > > area covers the whole document. At least one empty paragraph has to be
> > > outside these change tracks.
> > >
> > I will investigate this function and try to correct my fixing.
> >
> My assumption is that AppendRedline() is fine but the calling function
> should not span the deletion redline so widely.
> [..]
> > Thanks for your reply again,and awaiting your next reply:)
> >
> > Best Regards
> > Talen
> >
> Best regards
> Andreas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>