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


C++ dom::Element类代码示例

本文整理汇总了C++中dom::Element的典型用法代码示例。如果您正苦于以下问题:C++ Element类的具体用法?C++ Element怎么用?C++ Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: parseNode

void KHTMLReader::parseNode(DOM::Node node)
{

    // check if this is a text node.
    DOM::Text t = node;
    if (!t.isNull()) {
        _writer->addText(state()->paragraph, t.data().string(), 1, state()->in_pre_mode);
        return; // no children anymore...
    }

    // is this really needed ? it can't do harm anyway.
    state()->format = _writer->currentFormat(state()->paragraph, true);
    state()->layout = _writer->currentLayout(state()->paragraph);
    pushNewState();

    DOM::Element e = node;

    bool go_recursive = true;

    if (!e.isNull()) {
        // get the CSS information
        parseStyle(e);
        // get the tag information
        go_recursive = parseTag(e);
    }
    if (go_recursive) {
        for (DOM::Node q = node.firstChild(); !q.isNull(); q = q.nextSibling()) {
            parseNode(q);
        }
    }
    popState();


}
开发者ID:KDE,项目名称:koffice,代码行数:34,代码来源:khtmlreader.cpp

示例2: initializeOptionsFromNode

void DOMTreeView::initializeOptionsFromNode(const DOM::Node &node)
{
  infoNode = node;

  nodeName->clear();
  nodeType->clear();
  nodeNamespace->clear();
  nodeValue->clear();

  if (node.isNull()) {
    nodeInfoStack->raiseWidget(EmptyPanel);
    return;
  }

  nodeName->setText(node.nodeName().string());
  nodeType->setText(QString::number(node.nodeType()));
  nodeNamespace->setText(node.namespaceURI().string());
//   nodeValue->setText(node.value().string());

  DOM::Element element = node;
  if (!element.isNull()) {
    initializeOptionsFromElement(element);
    return;
  }

  DOM::CharacterData cdata = node;
  if (!cdata.isNull()) {
    initializeOptionsFromCData(cdata);
    return;
  }

  // Fallback
  nodeInfoStack->raiseWidget(EmptyPanel);
}
开发者ID:iegor,项目名称:kdesktop,代码行数:34,代码来源:domtreeview.cpp

示例3: parse_font

bool KHTMLReader::parse_font(DOM::Element e)
{
    // fixme don't hardcode 12 font size ...
    QString face = e.getAttribute("face").string();
    QColor color = parsecolor("#000000");
    if (!e.getAttribute("color").string().isEmpty())
        color = parsecolor(e.getAttribute("color").string());
    QString size = e.getAttribute("size").string();
    int isize = -1;
    if (size.startsWith('+'))
        isize = 12 + size.right(size.length() - 1).toInt();
    else if (size.startsWith('-'))
        isize = 12 - size.right(size.length() - 1).toInt();
    else
        isize = 12 + size.toInt();

    _writer->formatAttribute(state()->paragraph, "FONT", "name", face);
    if ((isize >= 0) && (isize != 12))
        _writer->formatAttribute(state()->paragraph, "SIZE", "value", QString("%1").arg(isize));

    _writer->formatAttribute(state()->paragraph, "COLOR", "red", QString("%1").arg(color.red()));
    _writer->formatAttribute(state()->paragraph, "COLOR", "green", QString("%1").arg(color.green()));
    _writer->formatAttribute(state()->paragraph, "COLOR", "blue", QString("%1").arg(color.blue()));
    return true;
}
开发者ID:KDE,项目名称:koffice,代码行数:25,代码来源:khtmlreader.cpp

示例4: slotItemRenamed

void DOMTreeView::slotItemRenamed(QListViewItem *lvi, const QString &str, int col)
{
  AttributeListItem *item = static_cast<AttributeListItem *>(lvi);

  DOM::Element element = infoNode;
  if (element.isNull()) return; // Should never happen

  switch (col) {
    case 0: {
      ManipulationCommand *cmd;
//       kdDebug(90180) << k_funcinfo << "col 0: " << element.nodeName() << " isNew: " << item->isNew() << endl;
      if (item->isNew()) {
        cmd = new AddAttributeCommand(element, str, item->text(1));
	item->setNew(false);
      } else
        cmd = new RenameAttributeCommand(element, item->text(0), str);

      mainWindow()->executeAndAddCommand(cmd);
      break;
    }
    case 1: {
      if (item->isNew()) { lvi->setText(1, QString()); break; }

      ChangeAttributeValueCommand *cmd = new ChangeAttributeValueCommand(
      			  element, item->text(0), str);
      mainWindow()->executeAndAddCommand(cmd);
      break;
    }
  }
}
开发者ID:iegor,项目名称:kdesktop,代码行数:30,代码来源:domtreeview.cpp

示例5: parse_ul

bool KHTMLReader::parse_ul(DOM::Element e)
{
    _list_depth++;
    bool popstateneeded = false;
    for (DOM::Node items = e.firstChild();!items.isNull();items = items.nextSibling()) {
        if (items.nodeName().string().toLower() == "li") {
            if (popstateneeded) {
                popState();
                //popstateneeded = false;
            }
            pushNewState();
            startNewLayout();
            popstateneeded = true;
            _writer->layoutAttribute(state()->paragraph, "COUNTER", "numberingtype", "1");
            _writer->layoutAttribute(state()->paragraph, "COUNTER", "righttext", ".");
            if (e.tagName().string().toLower() == "ol") {
                _writer->layoutAttribute(state()->paragraph, "COUNTER", "type", "1");
                _writer->layoutAttribute(state()->paragraph, "COUNTER", "numberingtype", "1");
                _writer->layoutAttribute(state()->paragraph, "COUNTER", "righttext", ".");
            } else {
                _writer->layoutAttribute(state()->paragraph, "COUNTER", "type", "10");
                _writer->layoutAttribute(state()->paragraph, "COUNTER", "numberingtype", "");
                _writer->layoutAttribute(state()->paragraph, "COUNTER", "righttext", "");
            }
            _writer->layoutAttribute(state()->paragraph, "COUNTER", "depth", QString("%1").arg(_list_depth - 1));
        }
        parseNode(items);
    }
    if (popstateneeded)
        popState();
    _list_depth--;
    return false;
}
开发者ID:KDE,项目名称:koffice,代码行数:33,代码来源:khtmlreader.cpp

示例6: showRecursive

void DOMTreeView::showRecursive(const DOM::Node &pNode, const DOM::Node &node, uint depth)
{
  DOMListViewItem *cur_item;
  DOMListViewItem *parent_item = m_itemdict.value(pNode.handle(), 0);

  if (depth > m_maxDepth) {
    m_maxDepth = depth;
  }

  if (depth == 0) {
    cur_item = new DOMListViewItem(node, m_listView);
    m_document = pNode.ownerDocument();
  } else {
    cur_item = new DOMListViewItem(node, parent_item);
  }

  //kDebug(90180) << node.nodeName().string() << " [" << depth << "]";
  cur_item = addElement (node, cur_item, false);
  m_listView->setItemExpanded(cur_item, depth < m_expansionDepth);

  if(node.handle()) {
    m_itemdict.insert(node.handle(), cur_item);
  }

  DOM::Node child = node.firstChild();
  if (child.isNull()) {
    DOM::HTMLFrameElement frame = node;
    if (!frame.isNull()) {
      child = frame.contentDocument().documentElement();
    } else {
      DOM::HTMLIFrameElement iframe = node;
      if (!iframe.isNull())
        child = iframe.contentDocument().documentElement();
    }
  }
  while(!child.isNull()) {
    showRecursive(node, child, depth + 1);
    child = child.nextSibling();
  }

  const DOM::Element element = node;
  if (!m_bPure) {
    if (!element.isNull() && !element.firstChild().isNull()) {
      if(depth == 0) {
	cur_item = new DOMListViewItem(node, m_listView, cur_item);
	m_document = pNode.ownerDocument();
      } else {
	cur_item = new DOMListViewItem(node, parent_item, cur_item);
      }
      //kDebug(90180) << "</" << node.nodeName().string() << ">";
      cur_item = addElement(element, cur_item, true);
//       m_listView->setItemExpanded(cur_item, depth < m_expansionDepth);
    }
  }
}
开发者ID:blue-shell,项目名称:folderview,代码行数:55,代码来源:domtreeview.cpp

示例7: do_start_element

  void do_start_element(const std::string& qName,
                        const std::string& namespaceURI,
                        const SAX::Attributes<std::string>& atts)
  {
    indent();
    DOM::Element<std::string> elem = document().createElementNS(namespaceURI, qName);
    current().appendChild(elem);

    // attributes here
    for(int i = 0; i < atts.getLength(); ++i)
      elem.setAttributeNS(atts.getURI(i), atts.getQName(i), atts.getValue(i));

    current_ = elem;
  } // do_start_element
开发者ID:KITSVictorGubin,项目名称:jornal,代码行数:14,代码来源:xslt_sink.hpp

示例8: remove

void Textual::remove(const Index& index) {
  DOM::HTMLDocument document = htmlDocument();
  if(index.atVariationStart()) {
    DOM::Element vc = document.getElementById("vc_"+index);
    if(!vc.isNull()) {
      /* remove a number? */
      DOM::Element comm(vc.previousSibling());
      DOM::Element mvnum(vc.nextSibling());
      if(!mvnum.isNull() && mvnum.getAttribute("id").string().startsWith("nm_") &&
            !comm.isNull() && comm.getAttribute("id").string().startsWith("cm_"))
      {
        DOM::Element move(mvnum.nextSibling());
        int mv_num = move.getAttribute("mvnum").string().toInt();
        int sub_mv_num = move.getAttribute("submvnum").string().toInt();
        if(!(mv_num>0 && (sub_mv_num==0 && (mv_num%2 || m_layout_style))))
          mvnum.parentNode().removeChild(mvnum);
      }
      vc.parentNode().removeChild(vc);
    }
  }
  else {
    DOM::Element rm = document.getElementById("nm_"+index);
    if(rm.isNull())
      rm = document.getElementById("mv_"+index);
    if(!rm.isNull())
      clear_from(rm);
  }
  if(m_curr_selected >= index)
    m_curr_selected = Index(-1);
}
开发者ID:Axure,项目名称:tagua,代码行数:30,代码来源:movelist_textual.cpp

示例9: parse_a

bool KHTMLReader::parse_a(DOM::Element e)
{
    QString url = e.getAttribute("href").string();
    if (!url.isEmpty()) {
        QString linkName;
        DOM::Text t = e.firstChild();
        if (t.isNull()) {
            /* Link without text -> just drop it*/
            return false; /* stop parsing recursively */
        }
        linkName = t.data().string().simplified();
        t.setData(DOM::DOMString("#")); // replace with '#'
        _writer->createLink(state()->paragraph, linkName, url);
    }
    return true; /* stop parsing recursively */
}
开发者ID:KDE,项目名称:koffice,代码行数:16,代码来源:khtmlreader.cpp

示例10: parse_CommonAttributes

bool KHTMLReader::parse_CommonAttributes(DOM::Element e)
{
    kDebug(30503) << "entering KHTMLReader::parse_CommonAttributes";
    kDebug(30503) << "tagName is" << e.tagName().string();
    QString s = e.getAttribute("align").string();
    if (!s.isEmpty()) {
        _writer->formatAttribute(state()->paragraph, "FLOW", "align", s);
    }
    QRegExp rx("h[0-9]+");
    if (0 == rx.search(e.getAttribute("class").string()))
        // example: <p class="h1" style="text-align:left; ">
    {
        _writer->layoutAttribute(state()->paragraph, "NAME", "value", e.getAttribute("class").string());
    }
    return true;
}
开发者ID:KDE,项目名称:koffice,代码行数:16,代码来源:khtmlreader.cpp

示例11: parseStyle

void KHTMLReader::parseStyle(DOM::Element e)
{
    // styles are broken broken broken broken broken broken.
    // FIXME: use getComputedStyle - note: it only returns 0, but works nevertheless
    kDebug(30503) << "entering parseStyle";
    DOM::CSSStyleDeclaration s1 = e.style();
    DOM::Document doc = _html->document();
    DOM::CSSStyleDeclaration s2 = doc.defaultView().getComputedStyle(e, "");

    kDebug(30503) << "font-weight=" << s1.getPropertyValue("font-weight").string();
    if (s1.getPropertyValue("font-weight").string() == "bolder") {
        _writer->formatAttribute(state()->paragraph, "WEIGHT", "value", "75");
    }
    if (s1.getPropertyValue("font-weight").string() == "bold") {
        _writer->formatAttribute(state()->paragraph, "WEIGHT", "value", "75");
    }

    // process e.g. <style="color: #ffffff">
    if (! s1.getPropertyValue("color").string().isEmpty()) {
        QColor c = parsecolor(s1.getPropertyValue("color").string());
        _writer->formatAttribute(state()->paragraph, "COLOR", "red", QString::number(c.red()));
        _writer->formatAttribute(state()->paragraph, "COLOR", "green", QString::number(c.green()));
        _writer->formatAttribute(state()->paragraph, "COLOR", "blue", QString::number(c.blue()));
    } // done
    // process e.g. <style="font-size: 42">
    if (! s1.getPropertyValue("font-size").string().isEmpty()) {
        QString size = s1.getPropertyValue("font-size").string();
        if (size.endsWith("pt")) {
            size = size.left(size.length() - 2);
        }
        _writer->formatAttribute(state()->paragraph, "SIZE", "value", size);
    }
    // done
    // process e.g. <style="text-align: center">this is in the center</style>
    if (! s1.getPropertyValue("text-align").string().isEmpty()) {
        state()->layout = _writer->setLayout(state()->paragraph, state()->layout);
        _writer->layoutAttribute(state()->paragraph, "FLOW", "align", s1.getPropertyValue("text-align").string());
    }
    // done

    /*if (DOM::PROPV("font-weight") == "bolder")
    _writer->formatAttribute(state()->paragraph,"WEIGHT","value","75");
    */
    /*
         // debugging code.
         kDebug(30503) <<"e.style()";
         for (unsigned int i=0;i<s1.length();i++) {
            kDebug(30503) << QString("%1: %2").arg(s1.item(i).string()).arg(s1.getPropertyValue(s1.item(i)).string());
         }
         kDebug(30503) <<"override style";
         for (unsigned int i=0;i<s2.length();i++) {
            kDebug(30503) << QString("%1: %2").arg(s2.item(i).string()).arg(s2.getPropertyValue(s2.item(i)).string());
         }
    */
}
开发者ID:KDE,项目名称:koffice,代码行数:55,代码来源:khtmlreader.cpp

示例12: KUrl

LinkItem::LinkItem( DOM::Element link )
    : m_valid( false )
{
    DOM::NamedNodeMap attrs = link.attributes();
    DOM::Node href = attrs.getNamedItem( "href" );

    // Load source address of images too
    DOM::Node src = attrs.getNamedItem( "src" );
    if ( href.nodeValue().string().isEmpty() && !src.nodeValue().string().isEmpty() )
      href = src;

    // qDebug("*** href: %s", href.nodeValue().string().latin1() );

    QString urlString = link.ownerDocument().completeURL( href.nodeValue() ).string();
    if ( urlString.isEmpty() )
        return;

    url = KUrl( urlString );
    if ( !KProtocolManager::supportsReading( url ) )
        return;

    // somehow getElementsByTagName("#text") doesn't work :(
    DOM::NodeList children = link.childNodes();
    for ( uint i = 0; i < children.length(); i++ )
    {
        DOM::Node node = children.item( i );
        if ( node.nodeType() == DOM::Node::TEXT_NODE )
            text.append( node.nodeValue().string() );
    }

    // force "local file" mimetype determination
    KMimeType::Ptr mt = KMimeType::findByUrl( url, 0, true, true);
    icon = mt->iconName();
    mimeType = mt->comment();

    m_valid = true;
}
开发者ID:mfuchs,项目名称:kget-gsoc,代码行数:37,代码来源:links.cpp

示例13: parseTag

bool KHTMLReader::parseTag(DOM::Element e)
{
    _PP(a);
    _PP(p);
    _PP(br);
    _PP(table);
    _PP(pre);
    _PP(ul);
    _PP(ol);
    _PP(font);
    _PP(hr);

    // FIXME we can get rid of these, make things tons more simple
    // when khtml finally implements getComputedStyle
    _PF(b, WEIGHT, value, 75);
    _PF(strong, WEIGHT, value, 75);
    _PF(u, UNDERLINE, value, 1);
    _PF(i, ITALIC, value, 1);

    _PL(center, FLOW, align, center);
    _PL(right, FLOW, align, right);
    _PL(left, FLOW, align, left);

    _PL(h1, NAME, value, h1);
    _PL(h2, NAME, value, h2);
    _PL(h3, NAME, value, h3);
    _PL(h4, NAME, value, h4);
    _PL(h5, NAME, value, h5);
    _PL(h6, NAME, value, h6);

    // Don't handle the content of comment- or script-nodes.
    if (e.nodeType() == DOM::Node::COMMENT_NODE || e.tagName().lower() == "script") {
        return false;
    }

    return true;
}
开发者ID:KDE,项目名称:koffice,代码行数:37,代码来源:khtmlreader.cpp

示例14: parse_head

void KHTMLReader::parse_head(DOM::Element e)
{
    for (DOM::Element items = e.firstChild();!items.isNull();items = items.nextSibling()) {
        if (items.tagName().string().lower() == "title") {
            DOM::Text t = items.firstChild();
            if (!t.isNull()) {
                _writer->createDocInfo("HTML import filter", t.data().string());
            }
        }
    }
}
开发者ID:KDE,项目名称:koffice,代码行数:11,代码来源:khtmlreader.cpp

示例15: select

void Textual::select(const Index& index) {
  if(index == m_curr_selected)
    return;
  DOM::HTMLDocument document = htmlDocument();
  DOM::Element currs = document.getElementById("mv_"+m_curr_selected);
  DOM::Element news = document.getElementById("mv_"+index);
  if(!currs.isNull())
    currs.style().removeProperty("background-color");
  if(!news.isNull())
    news.style().setProperty("background-color", "#C0E0FF", "important");
  m_curr_selected = index;
}
开发者ID:Axure,项目名称:tagua,代码行数:12,代码来源:movelist_textual.cpp


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