void EnhancedPathShape::saveOdf(KShapeSavingContext &context) const { if (isParametricShape()) { context.xmlWriter().startElement("draw:custom-shape"); saveOdfAttributes(context, OdfAllAttributes&~OdfSize); // save the right size so that when loading we fit the viewbox // to the right size without getting any wrong scaling // -> calculate the right size from the current size/viewbound ratio const QSizeF currentSize = outline().boundingRect().size(); context.xmlWriter().addAttributePt("svg:width", m_viewBox.width()*currentSize.width()/m_viewBound.width()); context.xmlWriter().addAttributePt("svg:height", m_viewBox.height()*currentSize.height()/m_viewBound.height()); if (parent()) parent()->saveOdfChildElements(context); context.xmlWriter().startElement("draw:enhanced-geometry"); context.xmlWriter().addAttribute("svg:viewBox", QString("%1 %2 %3 %4").arg(m_viewBox.x()).arg(m_viewBox.y()).arg(m_viewBox.width()).arg(m_viewBox.height())); if (m_mirrorHorizontally) { context.xmlWriter().addAttribute("draw:mirror-horizontal", "true"); } if (m_mirrorVertically) { context.xmlWriter().addAttribute("draw:mirror-vertical", "true"); } QString modifiers; foreach (qreal modifier, m_modifiers) modifiers += QString::number(modifier) + ' '; context.xmlWriter().addAttribute("draw:modifiers", modifiers.trimmed()); QString path; foreach (EnhancedPathCommand * c, m_commands) path += c->toString() + ' '; context.xmlWriter().addAttribute("draw:enhanced-path", path.trimmed()); FormulaStore::const_iterator i = m_formulae.constBegin(); for (; i != m_formulae.constEnd(); ++i) { context.xmlWriter().startElement("draw:equation"); context.xmlWriter().addAttribute("draw:name", i.key()); context.xmlWriter().addAttribute("draw:formula", i.value()->toString()); context.xmlWriter().endElement(); // draw:equation } foreach (EnhancedPathHandle * handle, m_enhancedHandles) handle->saveOdf(context); context.xmlWriter().endElement(); // draw:enhanced-geometry saveOdfCommonChildElements(context); context.xmlWriter().endElement(); // draw:custom-shape } else { KPathShape::saveOdf(context); } }
void KoEnhancedPathShape::saveOdf( KoShapeSavingContext & context ) const { if( isParametricShape() ) { context.xmlWriter().startElement("draw:custom-shape"); saveOdfAttributes( context, OdfAllAttributes ); context.xmlWriter().startElement("draw:enhanced-geometry"); context.xmlWriter().addAttribute("svg:viewBox", QString("%1 %2 %3 %4").arg( m_viewBox.x() ).arg( m_viewBox.y() ).arg( m_viewBox.width() ).arg( m_viewBox.height() ) ); QString modifiers; foreach( qreal modifier, m_modifiers ) modifiers += QString::number( modifier ) + ' '; context.xmlWriter().addAttribute("draw:modifiers", modifiers.trimmed() ); QString path; foreach( KoEnhancedPathCommand * c, m_commands ) path += c->toString() + ' '; context.xmlWriter().addAttribute("draw:enhanced-path", path.trimmed() ); FormulaStore::const_iterator i = m_formulae.constBegin(); for( ; i != m_formulae.constEnd(); ++i ) { context.xmlWriter().startElement("draw:equation"); context.xmlWriter().addAttribute("draw:name", i.key() ); context.xmlWriter().addAttribute("draw:formula", i.value()->toString() ); context.xmlWriter().endElement(); // draw:equation } foreach( KoEnhancedPathHandle * handle, m_enhancedHandles ) handle->saveOdf( context ); context.xmlWriter().endElement(); // draw:enhanced-geometry saveOdfCommonChildElements( context ); context.xmlWriter().endElement(); // draw:custom-shape } else KoPathShape::saveOdf( context ); }