bool KoEnhancedPathShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContext &context ) { reset(); KoXmlElement child; forEachElement( child, element ) { if( child.localName() == "enhanced-geometry" && child.namespaceURI() == KoXmlNS::draw ) { // load the viewbox QRectF viewBox = loadOdfViewbox( child ); if( ! viewBox.isEmpty() ) m_viewBox = viewBox; // load the modifiers QString modifiers = child.attributeNS( KoXmlNS::draw, "modifiers", "" ); if( ! modifiers.isEmpty() ) { addModifiers( modifiers ); } KoXmlElement grandChild; forEachElement( grandChild, child ) { if( grandChild.namespaceURI() != KoXmlNS::draw ) continue; if( grandChild.localName() == "equation" ) { QString name = grandChild.attributeNS( KoXmlNS::draw, "name" ); QString formula = grandChild.attributeNS( KoXmlNS::draw, "formula" ); addFormula( name, formula ); } else if( grandChild.localName() == "handle" ) { KoEnhancedPathHandle * handle = new KoEnhancedPathHandle( this ); if( handle->loadOdf( grandChild ) ) { m_enhancedHandles.append( handle ); evaluateHandles(); } else delete handle; } } // load the enhanced path data QString path = child.attributeNS( KoXmlNS::draw, "enhanced-path", "" ); #ifndef NWORKAROUND_ODF_BUGS KoOdfWorkaround::fixEnhancedPath(path, child, context); #endif if ( !path.isEmpty() ) { parsePathData( path ); } } }
bool EnhancedPathShape::loadOdf(const KXmlElement & element, KShapeLoadingContext &context) { reset(); loadOdfAttributes(element, context, OdfAdditionalAttributes | OdfCommonChildElements); const KXmlElement enhancedGeometry(KoXml::namedItemNS(element, KOdfXmlNS::draw, "enhanced-geometry" ) ); if (!enhancedGeometry.isNull()) { // load the modifiers QString modifiers = enhancedGeometry.attributeNS(KOdfXmlNS::draw, "modifiers"); if (!modifiers.isEmpty()) { addModifiers(modifiers); } KXmlElement grandChild; forEachElement(grandChild, enhancedGeometry) { if (grandChild.namespaceURI() != KOdfXmlNS::draw) continue; if (grandChild.localName() == "equation") { QString name = grandChild.attributeNS(KOdfXmlNS::draw, "name"); QString formula = grandChild.attributeNS(KOdfXmlNS::draw, "formula"); addFormula(name, formula); } else if (grandChild.localName() == "handle") { EnhancedPathHandle * handle = new EnhancedPathHandle(this); if (handle->loadOdf(grandChild, context)) { m_enhancedHandles.append(handle); evaluateHandles(); } else { delete handle; } } } setMirrorHorizontally(enhancedGeometry.attributeNS(KOdfXmlNS::draw, "mirror-horizontal") == "true"); setMirrorVertically(enhancedGeometry.attributeNS(KOdfXmlNS::draw, "mirror-vertical") == "true"); // load the enhanced path data QString path = enhancedGeometry.attributeNS(KOdfXmlNS::draw, "enhanced-path"); #ifndef NWORKAROUND_ODF_BUGS KOdfWorkaround::fixEnhancedPath(path, enhancedGeometry, context); #endif if (!path.isEmpty()) { parsePathData(path); } // load the viewbox QRectF viewBox = loadOdfViewbox(enhancedGeometry); if (! viewBox.isEmpty()) { m_viewBox = viewBox; } else { // if there is no view box defined make it is big as the path. m_viewBox = m_viewBound; } QString gluePoints(enhancedGeometry.attributeNS(KOdfXmlNS::draw, "glue-points")); if (!gluePoints.isEmpty()) { qreal x = -1; foreach (const QString &token, gluePoints.split(' ')) { if (x == -1) { // processing 'x' x = token.toInt(); } else { addConnectionPoint(QPointF(x, token.toInt())); x = -1; } } }