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 RectangleShape::saveOdf(KoShapeSavingContext & context) const { if (isParametricShape()) { context.xmlWriter().startElement("draw:rect"); saveOdfAttributes(context, OdfAllAttributes); if (m_cornerRadiusX > 0 && m_cornerRadiusY > 0) { context.xmlWriter().addAttributePt("svg:rx", m_cornerRadiusX * (0.5*size().width()) / 100.0); context.xmlWriter().addAttributePt("svg:ry", m_cornerRadiusY * (0.5*size().height()) / 100.0); } saveOdfCommonChildElements(context); saveText(context); context.xmlWriter().endElement(); } else { KoPathShape::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 ); }
void KoConnectionShape::shapeChanged(ChangeType type, KoShape *shape) { Q_D(KoConnectionShape); KoTosContainer::shapeChanged(type, shape); // check if we are during a forced update const bool updateIsActive = d->forceUpdate; switch (type) { case PositionChanged: case RotationChanged: case ShearChanged: case ScaleChanged: case GenericMatrixChange: case ParameterChanged: if (isParametricShape() && shape == 0) d->forceUpdate = true; break; case Deleted: if (shape != d->shape1 && shape != d->shape2) return; if (shape == d->shape1) connectFirst(0, -1); if (shape == d->shape2) connectSecond(0, -1); break; case ConnectionPointChanged: if (shape == d->shape1 && !shape->hasConnectionPoint(d->connectionPointId1)) { connectFirst(0, -1); } else if ( shape == d->shape2 && !shape->hasConnectionPoint(d->connectionPointId2)){ connectSecond(0, -1); } else { d->forceUpdate = true; } break; case BackgroundChanged: { // connection shape should not have a background // KoShapeBackground *fill = background(); // if (fill) { // if (fill->deref()) { // delete fill; // fill = 0; //} // setBackground(0); // } return; } default: return; } // the connection was moved while it is connected to some other shapes const bool connectionChanged = !shape && (d->shape1 || d->shape2); // one of the connected shape has moved const bool connectedShapeChanged = shape && (shape == d->shape1 || shape == d->shape2); if (!updateIsActive && (connectionChanged || connectedShapeChanged) && isParametricShape()) updateConnections(); // reset the forced update flag d->forceUpdate = false; }