Commit 036c0059 authored by Thorsten Zachmann's avatar Thorsten Zachmann

o remove OdfPosition as it was no longer used

o rename FrameAttributes -> OdfAllAttributes
o added OdfAdditionalAttributes
o save additional attributes

svn path=/trunk/koffice/; revision=803725
parent a328e51e
......@@ -70,7 +70,7 @@ KoShape * KoPathShape::cloneShape() const
void KoPathShape::saveOdf( KoShapeSavingContext & context ) const
{
context.xmlWriter().startElement( "draw:path" );
saveOdfAttributes( context, OdfMandatories | OdfSize | OdfPosition | OdfTransformation );
saveOdfAttributes( context, OdfAllAttributes );
context.xmlWriter().addAttribute( "svg:d", toString( QMatrix() ) );
......@@ -79,7 +79,7 @@ void KoPathShape::saveOdf( KoShapeSavingContext & context ) const
bool KoPathShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContext &context )
{
loadOdfAttributes( element, context, OdfMandatories );
loadOdfAttributes( element, context, OdfMandatories | OdfAdditionalAttributes );
// first clear the path data from the default path
clear();
......
......@@ -53,6 +53,7 @@
#include <QPainterPath>
#include <QList>
#include <QMap>
#include <QByteArray>
#include <kdebug.h>
......@@ -127,7 +128,7 @@ public:
KoShape *me;
QList<KoShape*> dependees; ///< list of shape dependent on this shape
KoShapeShadow * shadow; ///< the current shape shadow
QMap<QString,QString> additionalAttributes;
QMap<QByteArray, QString> additionalAttributes;
};
KoShape::KoShape()
......@@ -920,7 +921,7 @@ QMatrix KoShape::parseOdfTransform( const QString &transform )
}
void KoShape::saveOdfFrameAttributes(KoShapeSavingContext &context) const {
saveOdfAttributes(context, FrameAttributes);
saveOdfAttributes( context, OdfAdditionalAttributes );
context.addOption(KoShapeSavingContext::FrameOpened);
}
......@@ -1018,6 +1019,13 @@ void KoShape::saveOdfAttributes(KoShapeSavingContext &context, int attributes) c
context.xmlWriter().addAttribute( "draw:transform", m );
}
}
if ( attributes & OdfAdditionalAttributes ) {
QMap<QByteArray, QString>::const_iterator it( d->additionalAttributes.constBegin() );
for ( ; it != d->additionalAttributes.constEnd(); ++it ) {
context.xmlWriter().addAttribute( it.key(), it.value() );
}
}
}
// end loading & saving methods
......@@ -1075,22 +1083,22 @@ KoSnapData KoShape::snapData() const
return KoSnapData();
}
void KoShape::setAddtionalAttribute( const QString & name, const QString & value )
void KoShape::setAddtionalAttribute( const char * name, const QString & value )
{
d->additionalAttributes.insert( name, value );
}
void KoShape::removeAddtionalAttribute( const QString & name )
void KoShape::removeAddtionalAttribute( const char * name )
{
d->additionalAttributes.remove( name );
}
bool KoShape::hasAdditionalAttribute( const QString & name )
bool KoShape::hasAdditionalAttribute( const char * name )
{
return d->additionalAttributes.contains( name );
}
QString KoShape::addtionalAttribute( const QString & name )
QString KoShape::additionalAttribute( const char * name )
{
return d->additionalAttributes.value( name );
}
......@@ -701,14 +701,14 @@ public:
* @param name The name of the attribute in the following form prefix:tag e.g. presentation:placeholder
* @param value The value of the attribute
*/
void setAddtionalAttribute( const QString & name, const QString & value );
void setAddtionalAttribute( const char * name, const QString & value );
/**
* Remove additional attribute
*
* @param name The name of the attribute in the following form prefix:tag e.g. presentation:placeholder
*/
void removeAddtionalAttribute( const QString & name );
void removeAddtionalAttribute( const char * name );
/**
* Check if additional attribute is set
......@@ -717,7 +717,7 @@ public:
*
* @return true if there is a attribute with prefix:tag set, false otherwise
*/
bool hasAdditionalAttribute( const QString & name );
bool hasAdditionalAttribute( const char * name );
/**
* Get additional attribute
......@@ -726,20 +726,20 @@ public:
*
* @return The value of the attribute if it exists or a null string if not found.
*/
QString addtionalAttribute( const QString & name );
QString additionalAttribute( const char * name );
protected:
/* ** loading saving helper methods */
/// attributes from ODF 1.1 chapter 9.2.15 Common Drawing Shape Attributes
enum OdfAttribute {
OdfTransformation = 1, ///< Store transformation information
OdfSize = 2, ///< Store size information
OdfPosition = 4, ///< Store position of shape
OdfMandatories = 8, ///< Id, z-index, layer and style
OdfTransformation = 1, ///< Store transformation information
OdfSize = 2, ///< Store size information
OdfAdditionalAttributes = 4, ///< Store position of shape
OdfMandatories = 8, ///< Id, z-index, layer and style
/// A mask for all the attributes a 'draw:frame' requires
FrameAttributes = OdfMandatories | OdfSize | OdfPosition | OdfTransformation
/// A mask for all the attributes
OdfAllAttributes = OdfTransformation | OdfSize | OdfAdditionalAttributes | OdfMandatories
};
/**
......
......@@ -59,7 +59,7 @@ void KoShapeGroup::childCountChanged() {
void KoShapeGroup::saveOdf( KoShapeSavingContext & context ) const {
context.xmlWriter().startElement( "draw:g" );
saveOdfAttributes(context, OdfMandatories);
saveOdfAttributes( context, OdfMandatories | OdfAdditionalAttributes );
context.xmlWriter().addAttributePt( "svg:y", position().y() );
QList<KoShape*> shapes = iterator();
......@@ -84,7 +84,7 @@ bool KoShapeGroup::loadOdf( const KoXmlElement & element, KoShapeLoadingContext
}
}
loadOdfAttributes( element, context, OdfMandatories );
loadOdfAttributes( element, context, OdfMandatories | OdfAdditionalAttributes );
QRectF bound;
bool boundInitialized = false;
......
......@@ -52,7 +52,7 @@ public:
virtual bool loadOdf( const KoXmlElement & element, KoShapeLoadingContext &context )
{
loadOdfAttributes( element, context, FrameAttributes );
loadOdfAttributes( element, context, OdfAllAttributes );
return true;
};
virtual void saveOdf( KoShapeSavingContext & context ) const
......
......@@ -119,7 +119,7 @@ void MusicShape::saveOdf( KoShapeSavingContext & context ) const
KoXmlWriter& writer = context.xmlWriter();
writer.startElement("music:shape");
writer.addAttribute("xmlns:music", "http://www.koffice.org/music");
saveOdfAttributes(context, OdfMandatories | OdfSize | OdfPosition | OdfTransformation);
saveOdfAttributes( context, OdfAllAttributes );
MusicXmlWriter().writeSheet( writer, m_sheet, false );
......@@ -128,7 +128,7 @@ void MusicShape::saveOdf( KoShapeSavingContext & context ) const
}
bool MusicShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContext &context ) {
loadOdfAttributes( element, context, OdfMandatories | OdfSize | OdfPosition | OdfTransformation );
loadOdfAttributes( element, context, OdfAllAttributes );
KoXmlElement score = KoXml::namedItemNS(element, "http://www.koffice.org/music", "score-partwise");
if (score.isNull()) {
......
......@@ -53,7 +53,7 @@ void KoEllipseShape::saveOdf( KoShapeSavingContext & context ) const
if( isParametricShape() )
{
context.xmlWriter().startElement("draw:ellipse");
saveOdfAttributes(context, OdfMandatories | OdfSize | OdfPosition | OdfTransformation);
saveOdfAttributes( context, OdfAllAttributes );
char * kind = "full";
switch ( m_type )
......@@ -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 );
loadOdfAttributes( element, context, OdfMandatories | OdfTransformation | OdfAdditionalAttributes );
return true;
}
......
......@@ -334,7 +334,7 @@ void KoEnhancedPathShape::saveOdf( KoShapeSavingContext & context ) const
if( isParametricShape() )
{
context.xmlWriter().startElement("draw:custom-shape");
saveOdfAttributes(context, OdfMandatories | OdfSize | OdfPosition | OdfTransformation);
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() ) );
......@@ -435,7 +435,7 @@ bool KoEnhancedPathShape::loadOdf( const KoXmlElement & element, KoShapeLoadingC
setSize( size );
loadOdfAttributes( element, context, OdfMandatories | OdfTransformation );
loadOdfAttributes( element, context, OdfMandatories | OdfTransformation | OdfAdditionalAttributes );
return true;
}
......
......@@ -47,7 +47,7 @@ KoRectangleShape::~KoRectangleShape()
bool KoRectangleShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContext & context )
{
loadOdfAttributes( element, context, OdfMandatories | OdfSize );
loadOdfAttributes( element, context, OdfMandatories | OdfSize | OdfAdditionalAttributes );
if( element.hasAttributeNS( KoXmlNS::svg, "rx" ) && element.hasAttributeNS( KoXmlNS::svg, "ry" ) )
{
......@@ -80,7 +80,7 @@ void KoRectangleShape::saveOdf( KoShapeSavingContext & context ) const
if( isParametricShape() )
{
context.xmlWriter().startElement("draw:rect");
saveOdfAttributes(context, OdfMandatories | OdfSize | OdfPosition | OdfTransformation);
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 );
context.xmlWriter().endElement();
......
......@@ -259,7 +259,7 @@ QPointF KoStarShape::computeCenter() const
bool KoStarShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContext & context )
{
loadOdfAttributes( element, context, OdfMandatories | OdfSize | OdfTransformation );
loadOdfAttributes( element, context, OdfAllAttributes );
QString corners = element.attributeNS( KoXmlNS::draw, "corners", "" );
if( ! corners.isEmpty() )
......@@ -301,7 +301,7 @@ void KoStarShape::saveOdf( KoShapeSavingContext & context ) const
if( isParametricShape() )
{
context.xmlWriter().startElement("draw:regular-polygon");
saveOdfAttributes(context, OdfMandatories | OdfTransformation | OdfSize );
saveOdfAttributes( context, OdfAllAttributes );
context.xmlWriter().addAttribute( "draw:corners", m_cornerCount );
context.xmlWriter().addAttribute( "draw:concave", m_convex ? "false" : "true" );
// TODO saving the offset angle as rotation applied to the transformation
......
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