当前位置: 首页>>代码示例>>C++>>正文


C++ TagStack::getTopTagWithCharStyle方法代码示例

本文整理汇总了C++中TagStack::getTopTagWithCharStyle方法的典型用法代码示例。如果您正苦于以下问题:C++ TagStack::getTopTagWithCharStyle方法的具体用法?C++ TagStack::getTopTagWithCharStyle怎么用?C++ TagStack::getTopTagWithCharStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TagStack的用法示例。


在下文中一共展示了TagStack::getTopTagWithCharStyle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: tag_start

void RTFGenParser::tag_start(const QString &tagName, const list<QString> &attrs)
{
    CharStyle parentStyle, style;
    {
        Tag* pParentTag = m_tags.getTopTagWithCharStyle();
        if (pParentTag != NULL)
        {
            parentStyle = *(pParentTag->pCharStyle);
        }
    }
    style = parentStyle;

    if (tagName == "b"){
        style.bold = true;
    }
    else if (tagName == "i"){
        style.italic = true;
    }
    else if (tagName == "u"){
        style.underline = true;
    }
    else if (tagName == "font"){
        for (list<QString>::const_iterator it = attrs.begin(); it != attrs.end(); it++){
            QString name = (*it);
            ++it;
            QString value = (*it);
            if (name == "color")
            {
                style.colorIdx = getColorIdx(value);
            }
            else if (name == "face")
            {
                style.faceIdx = getFontFaceIdx(value);
            }
            else if (name == "size")
            {
                int logicalSize = value.toInt();
                if (value[0] == '+' || value[0] == '-')
                    logicalSize += 3;
                if (logicalSize < 1)
                    logicalSize = 1;
                else if (logicalSize > 7)
                    logicalSize = 7;
                style.sizePt = htmlFontSizeToPt(logicalSize);
            }
        }
    }
    else if (tagName == "p"){
        m_paragraphDir = DirUnknown;
        m_lastParagraphPos = res.length();
        m_bSpace = true;
        for (list<QString>::const_iterator it = attrs.begin(); it != attrs.end(); ++it){
            QString name = (*it).lower();
            ++it;
            QString value = (*it);
            if (name == "dir")
            {
                QString dir = value.lower();
                if (dir == "ltr")
                {
                    res += "\\ltrpar";
                    m_paragraphDir = DirLTR;
                }
                if (dir == "rtl")
                {
                    res += "\\rtlpar";
                    m_paragraphDir = DirRTL;
                }
            }
        }

    }
    else if (tagName == "br"){
        res += "\\line";
        m_bSpace = true;
    }
    else if (tagName == "img"){
        QString src;
        for (list<QString>::const_iterator it = attrs.begin(); it != attrs.end(); ++it){
            QString name = (*it);
            ++it;
            QString value = (*it);
            if (name == "src"){
                src = value;
                break;
            }
        }
        if (src.left(10) != "icon:smile")
            return;
        bool bOK;
        unsigned nSmile = src.mid(10).toUInt(&bOK, 16);
        if (!bOK)
            return;
        if (nSmile < 16){
            res += "<##icqimage000";
            if (nSmile < 10){
                res += (char)(nSmile + '0');
            }else{
                res += (char)(nSmile - 10 + 'A');
            }
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例2: tag_end

void RTFGenParser::tag_end(const QString &tagName)
{
    if (m_res_size)
        return;
    if ((tagName == "b") || (tagName == "i") || (tagName == "u") ||
            (tagName == "font") || (tagName == "p") || (tagName == "span")) {
        while (!tags.empty()) {
            QString tag = tags.top();
            tags.pop();
            options.pop();
            if (tag == tagName)
                break;
        }
    }

    // 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;
            }
        }
    }
}
开发者ID:,项目名称:,代码行数:66,代码来源:


注:本文中的TagStack::getTopTagWithCharStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。