src/svg/qsvghandler.cpp
changeset 30 5dc02b23752f
parent 22 79de32ba3296
child 37 758a864f9613
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
  2960     if (nrx > bounds.width()/2)
  2960     if (nrx > bounds.width()/2)
  2961         nrx = bounds.width()/2;
  2961         nrx = bounds.width()/2;
  2962     if (nry > bounds.height()/2)
  2962     if (nry > bounds.height()/2)
  2963         nry = bounds.height()/2;
  2963         nry = bounds.height()/2;
  2964 
  2964 
  2965     if (nrx && !nry)
  2965     if (!rx.isEmpty() && ry.isEmpty())
  2966         nry = nrx;
  2966         nry = nrx;
  2967     else if (nry && !nrx)
  2967     else if (!ry.isEmpty() && rx.isEmpty())
  2968         nrx = nry;
  2968         nrx = nry;
  2969 
  2969 
  2970     //we draw rounded rect from 0...99
  2970     //we draw rounded rect from 0...99
  2971     //svg from 0...bounds.width()/2 so we're adjusting the
  2971     //svg from 0...bounds.width()/2 so we're adjusting the
  2972     //coordinates
  2972     //coordinates
  3523             // but also http://www.w3.org/2000/svg-20000303-stylable
  3523             // but also http://www.w3.org/2000/svg-20000303-stylable
  3524             // And if the document uses an external dtd, the reported
  3524             // And if the document uses an external dtd, the reported
  3525             // namespaceUri is empty. The only possible strategy at
  3525             // namespaceUri is empty. The only possible strategy at
  3526             // this point is to do what everyone else seems to do and
  3526             // this point is to do what everyone else seems to do and
  3527             // ignore the reported namespaceUri completely.
  3527             // ignore the reported namespaceUri completely.
  3528             startElement(xml->name().toString(), xml->attributes());
  3528             if (!startElement(xml->name().toString(), xml->attributes())) {
       
  3529                 delete m_doc;
       
  3530                 m_doc = 0;
       
  3531                 return;
       
  3532             }
  3529             break;
  3533             break;
  3530         case QXmlStreamReader::EndElement:
  3534         case QXmlStreamReader::EndElement:
  3531             endElement(xml->name());
  3535             endElement(xml->name());
  3532             // if we are using somebody else's qxmlstreamreader
  3536             // if we are using somebody else's qxmlstreamreader
  3533             // we should not read until the end of the stream
  3537             // we should not read until the end of the stream
  3567     } else {
  3571     } else {
  3568         qWarning() << QString::fromLatin1("\"%1\" is an invalid value for attribute xml:space. "
  3572         qWarning() << QString::fromLatin1("\"%1\" is an invalid value for attribute xml:space. "
  3569                                           "Valid values are \"preserve\" and \"default\".").arg(xmlSpace.toString());
  3573                                           "Valid values are \"preserve\" and \"default\".").arg(xmlSpace.toString());
  3570         m_whitespaceMode.push(QSvgText::Default);
  3574         m_whitespaceMode.push(QSvgText::Default);
  3571     }
  3575     }
       
  3576 
       
  3577     if (!m_doc && localName != QLatin1String("svg"))
       
  3578         return false;
  3572 
  3579 
  3573     if (FactoryMethod method = findGroupFactory(localName)) {
  3580     if (FactoryMethod method = findGroupFactory(localName)) {
  3574         //group
  3581         //group
  3575         node = method(m_doc ? m_nodes.top() : 0, attributes, this);
  3582         node = method(m_doc ? m_nodes.top() : 0, attributes, this);
  3576         Q_ASSERT(node);
  3583         Q_ASSERT(node);
  3742         QString css = str.toString();
  3749         QString css = str.toString();
  3743         QCss::StyleSheet sheet;
  3750         QCss::StyleSheet sheet;
  3744         QCss::Parser(css).parse(&sheet);
  3751         QCss::Parser(css).parse(&sheet);
  3745         m_selector->styleSheets.append(sheet);
  3752         m_selector->styleSheets.append(sheet);
  3746         return true;
  3753         return true;
  3747     } else if (m_skipNodes.isEmpty() || m_skipNodes.top() == Unknown)
  3754     } else if (m_skipNodes.isEmpty() || m_skipNodes.top() == Unknown || m_nodes.isEmpty())
  3748         return true;
  3755         return true;
  3749 
  3756 
  3750     if (m_nodes.top()->type() == QSvgNode::TEXT || m_nodes.top()->type() == QSvgNode::TEXTAREA) {
  3757     if (m_nodes.top()->type() == QSvgNode::TEXT || m_nodes.top()->type() == QSvgNode::TEXTAREA) {
  3751         static_cast<QSvgText*>(m_nodes.top())->addText(str.toString());
  3758         static_cast<QSvgText*>(m_nodes.top())->addText(str.toString());
  3752     } else if (m_nodes.top()->type() == QSvgNode::TSPAN) {
  3759     } else if (m_nodes.top()->type() == QSvgNode::TSPAN) {