void RTFGenParser::tag_end(const QString &tagName) { // Roll back until we find our tag. bool found = false; for(Tag* pTag = m_tags.peek(); pTag != NULL && !found; pTag = m_tags.peek()) { if (pTag->name == tagName) { found = true; } if (pTag->hasCharStyle()) { CharStyle style = *(pTag->pCharStyle); // We must pop here, so that getTopTagWithCharStyle will find a parent tag. m_tags.pop(); pTag = NULL; // to avoid confusion Tag* pParentTag = m_tags.getTopTagWithCharStyle(); if (pParentTag != NULL) { if (pParentTag->hasCharStyle()) { CharStyle* pParentStyle = pParentTag->pCharStyle; // Roll back the character style. This is regardless of whether // we found the closed tag; we just collapse all styles on our way. QString rtf = pParentStyle->getDiffRTF(style); if (!rtf.isEmpty()) { res += rtf.utf8(); m_bSpace = true; } } } } else // if this tag has no char style attached { m_tags.pop(); // just pop the tag out pTag = NULL; // to avoid confusion } if (found) { if (tagName.lower() == "p") { res += "\\par"; m_bSpace = true; } } } }