+ wxHtmlTextPieces& pieces = *m_TextPieces;
+ size_t piecesCnt = pieces.GetCount();
+
+ while (begin_pos < end_pos)
+ {
+ while (m_CurTag && m_CurTag->GetBeginPos() < begin_pos)
+ m_CurTag = m_CurTag->GetNextTag();
+ while (m_CurTextPiece < piecesCnt &&
+ pieces[m_CurTextPiece].m_pos < begin_pos)
+ m_CurTextPiece++;
+
+ if (m_CurTextPiece < piecesCnt &&
+ (!m_CurTag ||
+ pieces[m_CurTextPiece].m_pos < m_CurTag->GetBeginPos()))
+ {
+ // Add text:
+ AddText(GetEntitiesParser()->Parse(
+ m_Source.Mid(pieces[m_CurTextPiece].m_pos,
+ pieces[m_CurTextPiece].m_lng)));
+ begin_pos = pieces[m_CurTextPiece].m_pos +
+ pieces[m_CurTextPiece].m_lng;
+ m_CurTextPiece++;
+ }
+ else if (m_CurTag)
+ {
+ // Add tag:
+ if (m_CurTag)
+ {
+ if (m_CurTag->HasEnding())
+ begin_pos = m_CurTag->GetEndPos2();
+ else
+ begin_pos = m_CurTag->GetBeginPos();
+ }
+ wxHtmlTag *t = m_CurTag;
+ m_CurTag = m_CurTag->GetNextTag();
+ AddTag(*t);
+ }
+ else break;