[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/shapes/pathshapes/ellipse
From:       Thorsten Zachmann <t.zachmann () zagge ! de>
Date:       2007-02-28 20:35:35
Message-ID: 1172694935.418648.11877.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 638101 by zachmann:

o save ellipse


 M  +52 -10    KoEllipseShape.cpp  
 M  +6 -1      KoEllipseShape.h  


--- trunk/koffice/shapes/pathshapes/ellipse/KoEllipseShape.cpp #638100:638101
@@ -1,5 +1,5 @@
 /* This file is part of the KDE project
-   Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
+   Copyright (C) 2006-2007 Thorsten Zachmann <zachmann@kde.org>
    Copyright (C) 2006 Jan Hambrecht <jaham@gmx.net>
 
    This library is free software; you can redistribute it and/or
@@ -24,6 +24,9 @@
 #include <QPainter>
 #include <math.h>
 
+#include <KoShapeSavingContext.h>
+#include <KoXmlWriter.h>
+
 KoEllipseShape::KoEllipseShape()
 : m_startAngle( 0 )
 , m_endAngle( 0 )
@@ -43,6 +46,39 @@
 {
 }
 
+bool KoEllipseShape::saveOdfData( KoShapeSavingContext & context ) const
+{
+    saveOdfSizeAndPosition( context );
+
+    char * kind = "full";
+    switch ( m_type )
+    {
+        case Arc:
+            if ( sweepAngle() != 360 )
+            {
+                kind = "arc";
+            }
+            break;
+        case Pie:
+            kind = "section";
+            break;
+        case Chord:
+            kind = "cut";
+            break;
+    }
+    context.xmlWriter().addAttribute( "draw:kind", kind );
+
+    context.xmlWriter().addAttribute( "draw:start-angle", m_startAngle );
+    context.xmlWriter().addAttribute( "draw:end-angle", m_endAngle );
+
+    return true;
+}
+
+const char * KoEllipseShape::odfTagName() const
+{
+    return "draw:ellipse";
+}
+
 void KoEllipseShape::resize( const QSizeF &newSize )
 {
     QSizeF oldSize = size();
@@ -127,16 +163,9 @@
     QPointF startpoint( m_handles[0] );
 
     QPointF curvePoints[12];
-    double sweepAngle =  m_endAngle - m_startAngle;
-    // treat also as full circle
-    if ( sweepAngle == 0 || sweepAngle == -360 )
-        sweepAngle = 360;
-    if ( m_startAngle > m_endAngle )
-    {
-        sweepAngle = 360 - m_startAngle + m_endAngle;
-    }
-    int pointCnt = arcToCurve( m_radii.x(), m_radii.y(), m_startAngle, sweepAngle , \
startpoint, curvePoints );  
+    int pointCnt = arcToCurve( m_radii.x(), m_radii.y(), m_startAngle, sweepAngle() \
, startpoint, curvePoints ); +
     int cp = 0;
     m_points[cp]->setPoint( startpoint );
     m_points[cp]->unsetProperty( KoPathPoint::HasControlPoint1 );
@@ -209,6 +238,19 @@
    }
 }
 
+double KoEllipseShape::sweepAngle() const
+{
+    double sAngle =  m_endAngle - m_startAngle;
+    // treat also as full circle
+    if ( sAngle == 0 || sAngle == -360 )
+        sAngle = 360;
+    if ( m_startAngle > m_endAngle )
+    {
+        sAngle = 360 - m_startAngle + m_endAngle;
+    }
+    return sAngle;
+}
+
 void KoEllipseShape::setType( KoEllipseType type )
 {
     m_type = type;
--- trunk/koffice/shapes/pathshapes/ellipse/KoEllipseShape.h #638100:638101
@@ -1,5 +1,5 @@
 /* This file is part of the KDE project
-   Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
+   Copyright (C) 2006-2007 Thorsten Zachmann <zachmann@kde.org>
    Copyright (C) 2006 Jan Hambrecht <jaham@gmx.net>
 
    This library is free software; you can redistribute it and/or
@@ -76,11 +76,16 @@
     double endAngle() const;
 
 protected:
+    const char * odfTagName() const;
+
+    bool saveOdfData( KoShapeSavingContext & context ) const;
+
     void moveHandleAction( int handleId, const QPointF & point, \
Qt::KeyboardModifiers modifiers = Qt::NoModifier );  void updatePath( const QSizeF \
&size );  void createPath( const QSizeF &size );
 
 private:
+    double sweepAngle() const;
 
     void updateKindHandle();
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic