#include <pp_Revision.h>
PP_RevisionAttr is class that represent a revision attribute; it is initialized by an attribute string:
some text</> ^^^^^^^^^^^^^^
R1, etc., conform to the following syntax (items in square brackets are optional):
[+]n[{props}[{atrrs}]] -- addition with optional properties and attributes; props and attrs are formed as `name:value' -n -- deletion !n{props} -- formating change only
where n is a numerical id of the revision and props is regular property string, for instance
font-family:Times New Roman
revoval of property/attribute is indicated by setting to -/-, e.g.,
font-family:-/-
(the revision attribute parser in the class translates that into "")
The class provides methods for adding and removing individual revisions and evaluating how a particular revised fragment should be displayed in the document
PP_RevisionAttr::PP_RevisionAttr | ( | ) | [inline] |
PP_RevisionAttr::PP_RevisionAttr | ( | const gchar * | r | ) |
create class instance from an XML attribute string
References _init().
PP_RevisionAttr::PP_RevisionAttr | ( | UT_uint32 | iId, | |
PP_RevisionType | eType, | |||
const PP_PropertyVector & | attrs, | |||
const PP_PropertyVector & | props | |||
) |
create class instance from a single revision data
References UT_GenericVector< T >::addItem(), and m_vRev.
PP_RevisionAttr::~PP_RevisionAttr | ( | ) |
References _clear().
void PP_RevisionAttr::_clear | ( | ) | [private] |
destroys all internal data
References UT_GenericVector< T >::clear(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), m_bDirty, m_pLastRevision, and m_vRev.
Referenced by addRevision(), mergeAll(), setRevision(), and ~PP_RevisionAttr().
void PP_RevisionAttr::_init | ( | const gchar * | r | ) | [private] |
parse given XML attribute string and fill the instance with the data
References UT_GenericVector< T >::addItem(), FREEP, gchar, m_bDirty, m_iSuperfluous, m_pLastRevision, m_vRev, PP_REVISION_ADDITION, PP_REVISION_DELETION, PP_REVISION_FMT_CHANGE, s, and UT_DEBUGMSG.
Referenced by PP_RevisionAttr(), and setRevision().
void PP_RevisionAttr::_refreshString | ( | ) | const [private] |
create XML string from our vector
References UT_String::clear(), UT_String::empty(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), m_bDirty, m_sXMLstring, m_vRev, and PP_Revision::toString().
Referenced by getXMLstring().
void PP_RevisionAttr::addRevision | ( | UT_uint32 | iId, | |
PP_RevisionType | eType, | |||
const PP_PropertyVector & | pAttrs, | |||
const PP_PropertyVector & | pProps | |||
) |
adds id to the revision vector handling the special cases where id is already present in this attribute.
References UT_GenericVector< T >::addItem(), UT_GenericVector< T >::deleteNthItem(), gchar, PP_Revision::getId(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), PP_Revision::getType(), m_bDirty, m_iSuperfluous, m_pLastRevision, m_vRev, PP_REVISION_ADDITION, PP_REVISION_ADDITION_AND_FMT, PP_REVISION_DELETION, PP_REVISION_FMT_CHANGE, PP_Revision::setAttributes(), and PP_AttrProp::setProperties().
Referenced by pt_PieceTable::_fixHdrFtrReferences(), pt_PieceTable::_translateRevisionAttribute(), addRevision(), pt_PieceTable::changeSpanFmt(), pt_PieceTable::changeStruxFmt(), pt_PieceTable::deleteSpan(), and mergeAttr().
void PP_RevisionAttr::addRevision | ( | UT_uint32 | iId, | |
PP_RevisionType | eType | |||
) |
Logically Performs addRevision( iId, eType, 0, 0 ).
This method is mainly useful for loading an ODT+GCT file where you want to add and delete revisions but don't actually care about the attrs/props for that action.
References addRevision().
void PP_RevisionAttr::addRevision | ( | const PP_Revision * | r | ) |
bool PP_RevisionAttr::changeRevisionType | ( | UT_uint32 | iId, | |
PP_RevisionType | eType | |||
) |
changes the type of revision with id iId to eType; if revision with that id is not present, returns false
References PP_Revision::getId(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), m_bDirty, m_vRev, and PP_Revision::setType().
bool PP_RevisionAttr::empty | ( | ) | const [inline] |
void PP_RevisionAttr::forceDirty | ( | ) | [inline] |
Referenced by pt_PieceTable::_fixHdrFtrReferences().
const PP_Revision * PP_RevisionAttr::getGreatestLesserOrEqualRevision | ( | UT_uint32 | id, | |
const PP_Revision ** | ppR | |||
) | const |
References PP_Revision::getId(), UT_GenericVector< T >::getItemCount(), getLastRevision(), UT_GenericVector< T >::getNthItem(), PP_Revision::getType(), m_vRev, s_add, and s_del.
Referenced by PD_Document::acceptRejectRevision(), pt_PieceTable::deleteSpan(), getType(), hasProperty(), and isVisible().
UT_uint32 PP_RevisionAttr::getHighestId | ( | ) | const |
UT_uint32 PP_RevisionAttr::getHighestRevisionNumberWithAttribute | ( | const gchar * | pName | ) | const |
References getNthRevision(), getRevisionsCount(), and UT_getAttribute().
const PP_Revision * PP_RevisionAttr::getLastRevision | ( | ) | const |
finds the highest revision number in this attribute
References PP_Revision::getId(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), m_pLastRevision, and m_vRev.
Referenced by pt_PieceTable::_translateRevisionAttribute(), getGreatestLesserOrEqualRevision(), getType(), and hasProperty().
const PP_Revision * PP_RevisionAttr::getLowestDeletionRevision | ( | ) | const |
References getNthRevision(), getRevisionsCount(), and PP_Revision::getType().
const PP_Revision * PP_RevisionAttr::getLowestGreaterOrEqualRevision | ( | UT_uint32 | id | ) | const |
References PP_Revision::getId(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), and m_vRev.
Referenced by PD_Document::rejectAllHigherRevisions().
const PP_Revision* PP_RevisionAttr::getNthRevision | ( | UT_uint32 | n | ) | const [inline] |
UT_uint32 PP_RevisionAttr::getRevisionsCount | ( | ) | const [inline] |
const PP_Revision * PP_RevisionAttr::getRevisionWithId | ( | UT_uint32 | iId, | |
UT_uint32 & | minId | |||
) | const |
find revision with id == iId; if revision is not found minId contains the smallest id in this set greater than iId; if return value is and minId is PD_MAX_REVISION then there are revisions preset
References PP_Revision::getId(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), and m_vRev.
Referenced by pt_PieceTable::_fixHdrFtrReferences().
PP_RevisionType PP_RevisionAttr::getType | ( | UT_uint32 | iId | ) | const |
returns the type of cumulative revision up to iId represented by this attribute
References getGreatestLesserOrEqualRevision(), PP_Revision::getType(), and s.
PP_RevisionType PP_RevisionAttr::getType | ( | void | ) | const |
returns the type of overall cumulative revision represented by this attribute
References getLastRevision(), and PP_Revision::getType().
const gchar * PP_RevisionAttr::getXMLstring | ( | ) | const |
get an gchar string representation of this revision
References _refreshString(), UT_String::c_str(), gchar, m_bDirty, and m_sXMLstring.
Referenced by PD_Document::_acceptRejectRevision(), pt_PieceTable::_fixHdrFtrReferences(), pt_PieceTable::_translateRevisionAttribute(), addRevision(), pt_PieceTable::changeSpanFmt(), pt_PieceTable::changeStruxFmt(), pt_PieceTable::deleteSpan(), getXMLstringUpTo(), and mergeAll().
std::string PP_RevisionAttr::getXMLstringUpTo | ( | UT_uint32 | iId | ) | const |
References getXMLstring(), removeAllHigherOrEqualIds(), setRevision(), and UT_DEBUGMSG.
bool PP_RevisionAttr::hasProperty | ( | UT_uint32 | iId, | |
const gchar * | pName, | |||
const gchar *& | pValue | |||
) | const |
returns true if after revision iId this fragment carries revised property pName, the value of which will be stored in pValue; see notes on PP_Revision::hasProperty(...)
References getGreatestLesserOrEqualRevision(), PP_AttrProp::getProperty(), and s.
bool PP_RevisionAttr::hasProperty | ( | const gchar * | pName, | |
const gchar *& | pValue | |||
) | const |
returns true if after the last revision this fragment carries revised property pName, the value of which will be stored in pValue; see notes on PP_Revision::hasProperty(...)
References getLastRevision(), and PP_AttrProp::getProperty().
bool PP_RevisionAttr::isFragmentSuperfluous | ( | ) | const |
returns true if the fragment marked by this attribute is superfluous, i.e, it was created in the process of the present revision but the editor has later changed his/her mind and decided it should go away
References UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), m_iSuperfluous, m_vRev, and UT_return_val_if_fail.
bool PP_RevisionAttr::isVisible | ( | UT_uint32 | id | ) | const |
please note that the following are convenience functions; if you need to make repeated enqueries, it is better to call getGreatestLesserOrEqualRevision() or getLastRevision() and query the returned PP_Revision object.
given revision level id, this function returns true if given segment of text is to be visible, false if it is to be hidden
References getGreatestLesserOrEqualRevision(), PP_Revision::getType(), PP_REVISION_ADDITION, and PP_REVISION_ADDITION_AND_FMT.
void PP_RevisionAttr::mergeAll | ( | const PP_RevisionAttr & | ra | ) |
References _clear(), DEBUG_MERGEALL, PP_Revision::getAttrsString(), PP_Revision::getId(), PP_Revision::getPropsString(), PP_Revision::getType(), getXMLstring(), mergeAPStrings(), PP_REVISION_DELETION, setRevision(), toIndex(), PP_Revision::toString(), UT_DEBUGMSG, and UT_map_delete_all_second().
Referenced by mergeAttr().
void PP_RevisionAttr::mergeAttr | ( | UT_uint32 | iId, | |
PP_RevisionType | t, | |||
const gchar * | pzName, | |||
const gchar * | pzValue | |||
) |
References addRevision(), and mergeAll().
Referenced by mergeAttrIfNotAlreadyThere().
void PP_RevisionAttr::mergeAttrIfNotAlreadyThere | ( | UT_uint32 | iId, | |
PP_RevisionType | t, | |||
const gchar * | pzName, | |||
const gchar * | pzValue | |||
) |
Do not replace the attribute/value if it exists in the given revision already.
References gchar, PP_Revision::getAttrsString(), PP_Revision::getId(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), PP_Revision::getType(), m_vRev, mergeAttr(), and PP_REVISION_NONE.
Referenced by pt_PieceTable::deleteSpan().
bool PP_RevisionAttr::operator== | ( | const PP_RevisionAttr & | op2 | ) | const |
References UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), and m_vRev.
void PP_RevisionAttr::pruneForCumulativeResult | ( | PD_Document * | pDoc | ) |
this function removes any revisions that no-longer contribute to the cumulative effect it is used in full-history mode when transfering attrs and props from the revision attribute into the main attrs and props
References UT_GenericVector< T >::deleteNthItem(), PP_AttrProp::explodeStyle(), gchar, PP_AttrProp::getAttribute(), PP_AttrProp::getAttributes(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), PP_AttrProp::getProperties(), PP_Revision::getType(), m_bDirty, m_vRev, PP_AttrProp::prune(), PP_AttrProp::setAttribute(), PP_Revision::setAttributes(), PP_AttrProp::setProperties(), UT_ASSERT_HARMLESS, and UT_return_if_fail.
Referenced by pt_PieceTable::_translateRevisionAttribute(), and PD_Document::acceptAllRevisions().
void PP_RevisionAttr::removeAllHigherOrEqualIds | ( | UT_uint32 | iId | ) |
removes all IDs from the attribute whose value is higher or equal the given id
References UT_GenericVector< T >::deleteNthItem(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), m_bDirty, m_pLastRevision, and m_vRev.
Referenced by PD_Document::_acceptRejectRevision(), and getXMLstringUpTo().
void PP_RevisionAttr::removeAllLesserOrEqualIds | ( | UT_uint32 | iId | ) |
removes all IDs from the attribute whose value is lesser or equal the given id
References UT_GenericVector< T >::deleteNthItem(), PP_Revision::getId(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), m_bDirty, m_pLastRevision, and m_vRev.
void PP_RevisionAttr::removeRevision | ( | const PP_Revision * | pRev | ) |
removes pRev unconditionally from the attribute
References UT_GenericVector< T >::deleteNthItem(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), m_bDirty, m_pLastRevision, and m_vRev.
void PP_RevisionAttr::removeRevisionIdTypeless | ( | UT_uint32 | iId | ) |
removes id from the attribute disregarding sign, i.e., if given 5 it will remove both -5 and +5
References UT_GenericVector< T >::deleteNthItem(), PP_Revision::getId(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), m_bDirty, m_pLastRevision, and m_vRev.
void PP_RevisionAttr::removeRevisionIdWithType | ( | UT_uint32 | iId, | |
PP_RevisionType | eType | |||
) |
removes id from this revision, respecting the sign, i.e., it will not remove -5 if given 5
References UT_GenericVector< T >::deleteNthItem(), PP_Revision::getId(), UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), PP_Revision::getType(), m_bDirty, m_pLastRevision, and m_vRev.
void PP_RevisionAttr::setRevision | ( | std::string & | r | ) |
References setRevision().
void PP_RevisionAttr::setRevision | ( | const gchar * | r | ) |
initialize instance with XML attribute string
References _clear(), and _init().
Referenced by pt_PieceTable::_translateRevisionAttribute(), addRevision(), getXMLstringUpTo(), mergeAll(), and setRevision().
bool PP_RevisionAttr::m_bDirty [mutable, private] |
UT_uint32 PP_RevisionAttr::m_iSuperfluous [private] |
Referenced by _init(), addRevision(), and isFragmentSuperfluous().
const PP_Revision* PP_RevisionAttr::m_pLastRevision [mutable, private] |
UT_String PP_RevisionAttr::m_sXMLstring [mutable, private] |
Referenced by _refreshString(), and getXMLstring().
UT_Vector PP_RevisionAttr::m_vRev [private] |
Referenced by _clear(), _init(), _refreshString(), addRevision(), changeRevisionId(), changeRevisionType(), getGreatestLesserOrEqualRevision(), getHighestId(), getLastRevision(), getLowestGreaterOrEqualRevision(), getRevisionWithId(), isFragmentSuperfluous(), mergeAttrIfNotAlreadyThere(), operator==(), PP_RevisionAttr(), pruneForCumulativeResult(), removeAllHigherOrEqualIds(), removeAllLesserOrEqualIds(), removeRevision(), removeRevisionIdTypeless(), and removeRevisionIdWithType().