With this commit, things are pretty good replaying editting sessions.
However Lists still have issues. I need to implement some more change
record methods to deal with the various list notification records.
Cheers
Martin
On Tue, 2005-11-29 at 01:32 +0000, cvs@abisource.com wrote:
> Update of /cvsroot/abi/src/text/ptbl/xp
> In directory abiword.snt.utwente.nl:/tmp/cvs-serv8450/src/text/ptbl/xp
> 
> Modified Files:
> 	pd_Document.cpp pd_Document.h pt_PT_Undo.cpp pt_PieceTable.cpp 
> 	pt_PieceTable.h 
> Log Message:
> 
> Implement deleteStrux, deleteFmtMarks.
> 
> 
> Index: pt_PieceTable.h
> ===================================================================
> RCS file: /cvsroot/abi/src/text/ptbl/xp/pt_PieceTable.h,v
> retrieving revision 1.135
> retrieving revision 1.136
> diff -u -d -r1.135 -r1.136
> --- pt_PieceTable.h	8 Aug 2005 07:42:07 -0000	1.135
> +++ pt_PieceTable.h	29 Nov 2005 01:32:27 -0000	1.136
> @@ -223,6 +223,7 @@
>  												const char * pszParentID);
>      bool                    changeSectionAttsNoUpdate(pf_Frag_Strux * pfStrux, const char * attr, const char * attvalue);
>  	bool                    deleteStruxNoUpdate(PL_StruxDocHandle sdh);
> +	bool                    deleteStruxWithNotify(PL_StruxDocHandle sdh);
>  	bool                    insertStruxNoUpdateBefore(PL_StruxDocHandle sdh, PTStruxType pts,const XML_Char ** attributes );
>  	bool                    changeLastStruxFmtNoUndo(PT_DocPosition dpos, PTStruxType pts,
>  													 const XML_Char ** attrs, const XML_Char ** props,
> @@ -240,6 +241,8 @@
>  		{
>  			return _insertFmtMarkFragWithNotify(ptc,dpos,p_AttrProp);
>  		}
> +	bool                    deleteFmtMark(PT_DocPosition dpos);
> +
>  	// the append- methods are only available while importing
>  	// the document.
>  
> 
> Index: pt_PT_Undo.cpp
> ===================================================================
> RCS file: /cvsroot/abi/src/text/ptbl/xp/pt_PT_Undo.cpp,v
> retrieving revision 1.44
> retrieving revision 1.45
> diff -u -d -r1.44 -r1.45
> --- pt_PT_Undo.cpp	4 Oct 2005 07:19:07 -0000	1.44
> +++ pt_PT_Undo.cpp	29 Nov 2005 01:32:27 -0000	1.45
> @@ -403,7 +403,26 @@
>  
>  			// we backup one because we have zero length and getFragFromPosition()
>  			// returns the right-most thing with this document position.
> -			pf = pf->getPrev();
> +			if(pf->getType() != pf_Frag::PFT_FmtMark)
> +			  pf = pf->getPrev();
> +			if(pf->getType()==pf_Frag::PFT_Strux)
> +			{
> +			    if(pf->getNext() && pf->getNext()->getType() == pf_Frag::PFT_Strux)
> +			    {
> +				DONE();
> +				m_bDoingTheDo = false;
> +				return true;
> +			    }
> +			    if(pf->getNext() && pf->getNext()->getType() == pf_Frag::PFT_Text)
> +			    {
> +			        pf = pf->getNext();
> +			    
> +				if(pf->getNext() && pf->getNext()->getType() == pf_Frag::PFT_FmtMark)
> +				{
> +				    pf = pf->getNext();
> +				}
> +			    }
> +			}
>  
>  			UNDO_return_val_if_fail (pf->getType() == pf_Frag::PFT_FmtMark,false);
>  			UNDO_return_val_if_fail (fragOffset == 0,false);
> @@ -413,7 +432,7 @@
>  			UNDO_return_val_if_fail (bFoundStrux,false);
>  
>  			pf_Frag_FmtMark * pffm = static_cast<pf_Frag_FmtMark *> (pf);
> -			UNDO_return_val_if_fail (pffm->getIndexAP() == pcrFM->getIndexAP(),false);
> +			//			UNDO_return_val_if_fail (pffm->getIndexAP() == pcrFM->getIndexAP(),false);
>  			_deleteFmtMark(pffm,NULL,NULL);
>  
>  			DONE();
> @@ -435,8 +454,17 @@
>  
>  			// we backup one because we have zero length and getFragFromPosition()
>  			// returns the right-most thing with this document position.
> -			pf = pf->getPrev();
> -
> +			if(pf->getType() != pf_Frag::PFT_FmtMark)
> +			  pf = pf->getPrev();
> +			if(pf->getType()==pf_Frag::PFT_Strux)
> +			{
> +			    if(pf->getNext() && pf->getNext()->getType() == pf_Frag::PFT_Strux)
> +			    {
> +				DONE();
> +				m_bDoingTheDo = false;
> +				return true;
> +			    }
> +			}
>  			UNDO_return_val_if_fail (pf->getType() == pf_Frag::PFT_FmtMark,false);
>  			UNDO_return_val_if_fail (fragOffset == 0,false);
>  
> 
> Index: pt_PieceTable.cpp
> ===================================================================
> RCS file: /cvsroot/abi/src/text/ptbl/xp/pt_PieceTable.cpp,v
> retrieving revision 1.129
> retrieving revision 1.130
> diff -u -d -r1.129 -r1.130
> --- pt_PieceTable.cpp	4 Oct 2005 05:50:35 -0000	1.129
> +++ pt_PieceTable.cpp	29 Nov 2005 01:32:27 -0000	1.130
> @@ -112,6 +112,52 @@
>  }
>  
>  /*!
> + * Delete the single strux given in sdh and create and record a change record.
> + */
> +bool pt_PieceTable::deleteStruxWithNotify(PL_StruxDocHandle sdh)
> +{
> +	pf_Frag_Strux * pfs = static_cast<pf_Frag_Strux *>(const_cast<void *>(sdh));
> +	PT_DocPosition dpos = pfs->getPos();
> +	pf_Frag * pfEnd = NULL;
> +	UT_uint32 pfragOffsetEnd = 0;
> +	bool b = _deleteStruxWithNotify(dpos,pfs,&pfEnd,&pfragOffsetEnd,true);
> +	return b;
> +}
> +
> +/*!
> + * Delete The first FmtMark found at the position given.
> + */
> +bool pt_PieceTable::deleteFmtMark(PT_DocPosition dpos)
> +{
> +	pf_Frag * pf = NULL;
> +	PT_BlockOffset pOffset= 0;
> +	getFragFromPosition(dpos,&pf,&pOffset);
> +	pf_Frag_FmtMark * pfm = NULL;
> +	if(pf->getType() == pf_Frag::PFT_FmtMark)
> +	{
> +		pfm = static_cast<pf_Frag_FmtMark *>(pf);
> +	}
> +	if(pf->getPrev()->getType() == pf_Frag::PFT_FmtMark)
> +	{
> +		pfm = static_cast<pf_Frag_FmtMark *>(pf->getPrev());
> +	}
> +	if(pf->getNext()->getType() == pf_Frag::PFT_FmtMark)
> +	{
> +		pfm = static_cast<pf_Frag_FmtMark *>(pf->getNext());
> +	}
> +	if(pfm == NULL)
> +	{
> +		return false;
> +	}
> +	pf_Frag_Strux * pfs = NULL;
> +	if (!_getStruxFromFragSkip(pfm,&pfs))
> +		return false;
> +	pf_Frag * pfEnd = NULL;
> +	UT_uint32 fragOff = 0;
> +	bool b = _deleteFmtMarkWithNotify(dpos,pfm,pfs,&pfEnd,&fragOff);
> +	return b;
> +}
> +/*!
>   * This method inserts a strux of type pts immediately before the sdh given.
>   * Attributes of the strux can be optionally passed. This method does not throw
>   * a change record and should only be used under exceptional circumstances to 
> 
> Index: pd_Document.cpp
> ===================================================================
> RCS file: /cvsroot/abi/src/text/ptbl/xp/pd_Document.cpp,v
> retrieving revision 1.376
> retrieving revision 1.377
> diff -u -d -r1.376 -r1.377
> --- pd_Document.cpp	26 Sep 2005 22:23:05 -0000	1.376
> +++ pd_Document.cpp	29 Nov 2005 01:32:27 -0000	1.377
> @@ -1034,6 +1034,10 @@
>  	return m_pPieceTable->insertFmtMark(ptc, dpos, p_AttrProp);
>  }
>  
> +bool  PD_Document::deleteFmtMark( PT_DocPosition dpos)
> +{
> +	return m_pPieceTable->deleteFmtMark(dpos);
> +}
>  //////////////////////////////////////////////////////////////////
>  //////////////////////////////////////////////////////////////////
>  
> @@ -1466,6 +1470,44 @@
>  	return false;
>  }
>  
> +
> +/*!
> + * This method deletes a strux of the type specified at the position
> + * requested.
> + * if bRecordChange is fale no change record is recorded.
> + * This method was created soled for the use of AbiCollab.
> +  * Use with extreme care. Should only be needed by AbiCollab
> + */
> +bool PD_Document::deleteStrux(PT_DocPosition dpos,
> +							  PTStruxType pts,
> +							  bool bRecordChange)
> +{
> +	PT_BlockOffset pOffset;
> +	pf_Frag * pf = NULL;
> +	m_pPieceTable->getFragFromPosition(dpos,&pf,&pOffset);
> +	while(pf && pf->getLength() == 0)
> +		pf = pf->getPrev();
> +	if(pf == NULL)
> +		return false;
> +	PL_StruxDocHandle sdh = NULL;
> +	if(pf->getType() == pf_Frag::PFT_Strux)
> +	{
> +		pf_Frag_Strux * pfs = static_cast<pf_Frag_Strux *>(pf);
> +		sdh = static_cast<PL_StruxDocHandle>(pfs);
> +	}
> +	else
> +	{
> +		return false;
> +	}
> +	if(!bRecordChange)
> +	{
> +		return m_pPieceTable->deleteStruxNoUpdate(sdh);
> +	}
> +	if(getStruxPosition(sdh) != dpos)
> +		return false;
> +	return m_pPieceTable->deleteStruxWithNotify(sdh);
> +}
> +
>  /*!
>   * This method deletes a strux without throwing a change record.
>   * sdh is the StruxDocHandle that gets deleted..
> 
> Index: pd_Document.h
> ===================================================================
> RCS file: /cvsroot/abi/src/text/ptbl/xp/pd_Document.h,v
> retrieving revision 1.243
> retrieving revision 1.244
> diff -u -d -r1.243 -r1.244
> --- pd_Document.h	21 Oct 2005 16:09:19 -0000	1.243
> +++ pd_Document.h	29 Nov 2005 01:32:27 -0000	1.244
> @@ -216,12 +216,15 @@
>  									   const UT_UCSChar * p,
>  									   UT_uint32 length,
>  									   PP_AttrProp *p_AttrProp = NULL);
> +
>  	bool					deleteSpan(PT_DocPosition dpos1,
>  									   PT_DocPosition dpos2,
>  									   PP_AttrProp *p_AttrProp_Before,
>  									   UT_uint32 &iRealDeleteCount,
>  									   bool bDeleteTableStruxes = false);
>  
> +	bool                    deleteFmtMark( PT_DocPosition dpos);
> +
>  	bool					changeSpanFmt(PTChangeFmt ptc,
>  										  PT_DocPosition dpos1,
>  										  PT_DocPosition dpos2,
> @@ -230,6 +233,9 @@
>  
>  	bool					insertStrux(PT_DocPosition dpos,
>  										PTStruxType pts, pf_Frag_Strux ** ppfs_ret = 0);
> +	bool					deleteStrux(PT_DocPosition dpos,
> +										PTStruxType pts,
> +										bool bRecordChange);
>  
> 
>  	bool					insertStrux(PT_DocPosition dpos,
> 
> -----------------------------------------------
> To unsubscribe from this list, send a message to
> abisource-cvs-commit-request@abisource.com with the word
> unsubscribe in the message body.
Received on Tue Nov 29 02:37:49 2005
This archive was generated by hypermail 2.1.8 : Tue Nov 29 2005 - 02:37:50 CET