Commit 4e03f450 authored by Thorsten Zachmann's avatar Thorsten Zachmann

o save event-listeres

  this is merged togeter with saving of connection points which still
  needs to be done.

svn path=/trunk/koffice/; revision=817593
parent 11419d66
......@@ -89,7 +89,7 @@ void KoConnectionShape::saveOdf( KoShapeSavingContext & context ) const
bool KoConnectionShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContext &context )
{
loadOdfAttributes( element, context, OdfMandatories );
loadOdfAttributes( element, context, OdfMandatories | OdfCommonChildElements );
QString type = element.attributeNS( KoXmlNS::draw, "type", "standard" );
if( type == "lines" )
......
......@@ -68,12 +68,13 @@ void KoPathShape::saveOdf( KoShapeSavingContext & context ) const
context.xmlWriter().addAttribute( "svg:d", toString( QMatrix() ) );
saveOdfCommonChildElements( context );
context.xmlWriter().endElement();
}
bool KoPathShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContext &context )
{
loadOdfAttributes( element, context, OdfMandatories | OdfAdditionalAttributes );
loadOdfAttributes( element, context, OdfMandatories | OdfAdditionalAttributes | OdfCommonChildElements );
// first clear the path data from the default path
clear();
......
......@@ -38,6 +38,8 @@
#include "ShapeDeleter_p.h"
#include "KoShapeStyleWriter.h"
#include "KoShapeShadow.h"
#include "KoEventAction.h"
#include "KoEventActionRegistry.h"
#include <KoXmlReader.h>
#include <KoXmlWriter.h>
......@@ -94,6 +96,7 @@ public:
}
if( shadow && shadow->removeUser() == 0 )
delete shadow;
qDeleteAll( eventActions );
}
void shapeChanged(ChangeType type) {
......@@ -131,6 +134,7 @@ public:
QList<KoShape*> dependees; ///< list of shape dependent on this shape
KoShapeShadow * shadow; ///< the current shape shadow
QMap<QByteArray, QString> additionalAttributes;
QList<KoEventAction *> eventActions; ///< list of event actions the shape has
};
KoShape::KoShape()
......@@ -698,11 +702,6 @@ bool KoShape::isEditable() const {
}
// loading & saving methods
void KoShape::saveOdfConnections(KoShapeSavingContext &context) const {
// TODO save "draw-glue-point" elements (9.2.19)
Q_UNUSED( context );
}
QString KoShape::saveStyle( KoGenStyle &style, KoShapeSavingContext &context ) const
{
// and fill the style
......@@ -801,6 +800,14 @@ bool KoShape::loadOdfAttributes( const KoXmlElement & element, KoShapeLoadingCon
}
}
if ( attributes & OdfCommonChildElements ) {
const KoXmlElement eventActionsElement( KoXml::namedItemNS( element, KoXmlNS::office, "event-listeners" ) );
if ( !eventActionsElement.isNull() ) {
d->eventActions = KoEventActionRegistry::instance()->createEventActionsFromOdf( eventActionsElement, context );
}
// load glue points (connection points)
}
return true;
}
......@@ -1041,6 +1048,20 @@ void KoShape::saveOdfAttributes(KoShapeSavingContext &context, int attributes) c
}
}
void KoShape::saveOdfCommonChildElements( KoShapeSavingContext &context ) const
{
// save event listeners see ODF 9.2.21 Event Listeners
if ( d->eventActions.size() > 0 ) {
context.xmlWriter().startElement( "office:event-listeners" );
foreach ( KoEventAction * action, d->eventActions ) {
action->saveOdf( context );
}
context.xmlWriter().endElement();
}
// save glue points see ODF 9.2.19 Glue Points
}
// end loading & saving methods
......
......@@ -183,6 +183,13 @@ public:
*/
void saveOdfAttributes( KoShapeSavingContext &context, int attributes ) const;
/**
* This method can be used while saving the shape as Odf to add common child elements
*
* The office:event-listeners and draw:glue-point are saved.
*/
void saveOdfCommonChildElements( KoShapeSavingContext &context ) const;
/**
* After the shape has been created this method is called so it can get access to any DataCenter it
* might want.
......@@ -730,11 +737,12 @@ protected:
enum OdfAttribute {
OdfTransformation = 1, ///< Store transformation information
OdfSize = 2, ///< Store size information
OdfAdditionalAttributes = 4, ///< Store position of shape
OdfAdditionalAttributes = 4, ///< Store additional attributes of shape
OdfMandatories = 8, ///< Id, z-index, layer and style
OdfCommonChildElements = 16, ///< event actions and connection points
/// A mask for all the attributes
OdfAllAttributes = OdfTransformation | OdfSize | OdfAdditionalAttributes | OdfMandatories
OdfAllAttributes = OdfTransformation | OdfSize | OdfAdditionalAttributes | OdfMandatories | OdfCommonChildElements
};
/**
......@@ -753,11 +761,6 @@ protected:
*/
QMatrix parseOdfTransform( const QString &transform );
/**
* Add a new draw-glue-point element for each connections() present on this shape.
*/
void saveOdfConnections( KoShapeSavingContext &context ) const;
/**
* @brief Saves the style used for the shape
*
......
......@@ -63,12 +63,12 @@ void KoShapeGroup::saveOdf( KoShapeSavingContext & context ) const {
shape->saveOdf(context);
}
saveOdfConnections(context);
saveOdfCommonChildElements( context );
context.xmlWriter().endElement();
}
bool KoShapeGroup::loadOdf( const KoXmlElement & element, KoShapeLoadingContext &context ) {
loadOdfAttributes( element, context, OdfMandatories | OdfAdditionalAttributes );
loadOdfAttributes( element, context, OdfMandatories | OdfAdditionalAttributes | OdfCommonChildElements);
KoXmlElement child;
forEachElement( child, element )
......
......@@ -117,8 +117,8 @@ void MusicShape::saveOdf( KoShapeSavingContext & context ) const
MusicXmlWriter().writeSheet( writer, m_sheet, false );
saveOdfCommonChildElements( context );
writer.endElement();
saveOdfConnections(context);
}
bool MusicShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContext &context ) {
......
......@@ -74,8 +74,8 @@ void KoEllipseShape::saveOdf( KoShapeSavingContext & context ) const
context.xmlWriter().addAttribute( "draw:kind", kind );
context.xmlWriter().addAttribute( "draw:start-angle", m_startAngle );
context.xmlWriter().addAttribute( "draw:end-angle", m_endAngle );
saveOdfCommonChildElements( context );
context.xmlWriter().endElement();
saveOdfConnections(context);
}
else
KoPathShape::saveOdf( context );
......@@ -123,7 +123,7 @@ bool KoEllipseShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContex
setStartAngle( element.attributeNS( KoXmlNS::draw, "start-angle", "0" ).toDouble() );
setEndAngle( element.attributeNS( KoXmlNS::draw, "end-angle", "360" ).toDouble() );
loadOdfAttributes( element, context, OdfMandatories | OdfTransformation | OdfAdditionalAttributes );
loadOdfAttributes( element, context, OdfMandatories | OdfTransformation | OdfAdditionalAttributes | OdfCommonChildElements );
return true;
}
......
......@@ -362,8 +362,8 @@ void KoEnhancedPathShape::saveOdf( KoShapeSavingContext & context ) const
handle->saveOdf( context );
context.xmlWriter().endElement(); // draw:enhanced-geometry
saveOdfCommonChildElements( context );
context.xmlWriter().endElement(); // draw:custom-shape
saveOdfConnections(context);
}
else
KoPathShape::saveOdf( context );
......@@ -435,7 +435,7 @@ bool KoEnhancedPathShape::loadOdf( const KoXmlElement & element, KoShapeLoadingC
setSize( size );
loadOdfAttributes( element, context, OdfMandatories | OdfTransformation | OdfAdditionalAttributes );
loadOdfAttributes( element, context, OdfMandatories | OdfTransformation | OdfAdditionalAttributes | OdfCommonChildElements );
return true;
}
......
......@@ -47,7 +47,7 @@ KoRectangleShape::~KoRectangleShape()
bool KoRectangleShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContext & context )
{
loadOdfAttributes( element, context, OdfMandatories | OdfSize | OdfAdditionalAttributes );
loadOdfAttributes( element, context, OdfMandatories | OdfSize | OdfAdditionalAttributes | OdfCommonChildElements );
if( element.hasAttributeNS( KoXmlNS::svg, "rx" ) && element.hasAttributeNS( KoXmlNS::svg, "ry" ) )
{
......@@ -83,8 +83,8 @@ void KoRectangleShape::saveOdf( KoShapeSavingContext & context ) const
saveOdfAttributes( context, OdfAllAttributes );
context.xmlWriter().addAttribute( "svg:rx", m_cornerRadiusX * (0.5*size().width()) / 100.0 );
context.xmlWriter().addAttribute( "svg:ry", m_cornerRadiusY * (0.5*size().height()) / 100.0 );
saveOdfCommonChildElements( context );
context.xmlWriter().endElement();
saveOdfConnections(context);
}
else
KoPathShape::saveOdf( context );
......
......@@ -313,8 +313,8 @@ void KoStarShape::saveOdf( KoShapeSavingContext & context ) const
double percent = (m_radius[tip]-m_radius[base]) / m_radius[tip] * 100.0;
context.xmlWriter().addAttribute( "draw:sharpness", QString("%1%" ).arg( percent ) );
}
saveOdfCommonChildElements( context );
context.xmlWriter().endElement();
saveOdfConnections(context);
}
else
KoPathShape::saveOdf( context );
......
......@@ -82,6 +82,7 @@ void PictureShape::saveOdf( KoShapeSavingContext & context ) const
writer.addAttribute("xlink:actuate", "onLoad");
writer.addAttribute("xlink:href", name);
writer.endElement(); // draw:image
saveOdfCommonChildElements( context );
writer.endElement(); // draw:frame
}
......
......@@ -83,9 +83,8 @@ void SimpleTextShape::saveOdf(KoShapeSavingContext &context) const
context.xmlWriter().addAttribute( "draw:engine", "svg:text" );
context.xmlWriter().addAttribute( "draw:data", "" );
saveOdfCommonChildElements( context );
context.xmlWriter().endElement(); // draw:custom-shape
saveOdfConnections(context);
}
bool SimpleTextShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContext & context )
......
......@@ -241,6 +241,7 @@ void TextShape::saveOdf(KoShapeSavingContext & context) const
writer.startElement( "draw:text-box" );
m_textShapeData->saveOdf(context);
writer.endElement(); // draw:text-box
saveOdfCommonChildElements( context );
writer.endElement(); // draw:frame
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment