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

List:       kde-commits
Subject:    koffice/kchart/shape
From:       Johannes Simon <johannes.simon () gmail ! com>
Date:       2008-07-31 21:20:45
Message-ID: 1217539245.920493.11899.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 840322 by jsimon:

Load plot area wall from ODF

 M  +60 -2     Surface.cpp  
 M  +1 -1      Surface.h  


--- trunk/koffice/kchart/shape/Surface.cpp #840321:840322
@@ -33,7 +33,16 @@
 #include <KoXmlWriter.h>
 #include <KoXmlNS.h>
 #include <KoOdfStylesReader.h>
+#include <KoShapeLoadingContext.h>
+#include <KoOdfLoadingContext.h>
+#include <KoStyleStack.h>
+#include <KoOdfGraphicStyles.h>
 
+// KDChart
+#include <KDChartAbstractCoordinatePlane>
+#include <KDChartBackgroundAttributes>
+#include <KDChartFrameAttributes>
+
 using namespace KChart;
 
 class Surface::Private
@@ -43,6 +52,8 @@
     ~Private();
 
     PlotArea *plotArea;
+    
+    KDChart::AbstractCoordinatePlane *kdPlane;
 
     QPointF position;
     int width;
@@ -62,7 +73,11 @@
 Surface::Surface( PlotArea *parent )
     : d( new Private )
 {
+    Q_ASSERT( parent );
+    
     d->plotArea = parent;
+    d->kdPlane = d->plotArea->kdPlane();
+    Q_ASSERT( d->kdPlane );
 }
 
 Surface::~Surface()
@@ -110,8 +125,51 @@
     d->framePen = pen;
 }
 
-bool Surface::loadOdf( const KoXmlElement &surfaceElement, const KoOdfStylesReader \
&stylesReader ) +bool Surface::loadOdf( const KoXmlElement &surfaceElement, \
KoShapeLoadingContext &context )  {
-    qDebug() << "Surface::loadOdf()";
+    KoStyleStack &styleStack = context.odfLoadingContext().styleStack();
+    styleStack.save();
+    
+    if ( surfaceElement.hasAttributeNS( KoXmlNS::chart, "style-name" ) )
+    {
+        KDChart::BackgroundAttributes backgroundAttributes = \
d->kdPlane->backgroundAttributes(); +        KDChart::FrameAttributes frameAttributes \
= d->kdPlane->frameAttributes(); +        
+        context.odfLoadingContext().fillStyleStack( surfaceElement, KoXmlNS::chart, \
"style-name", "chart" ); +        
+        styleStack.setTypeProperties( "graphic" );
+        
+        if ( styleStack.hasProperty( KoXmlNS::draw, "stroke" ) )
+        {
+            frameAttributes.setVisible( true );
+            QString stroke = styleStack.property( KoXmlNS::draw, "stroke" );
+            if( stroke == "solid" || stroke == "dash" )
+            {
+                QPen pen = KoOdfGraphicStyles::loadOasisStrokeStyle( styleStack, \
stroke, context.odfLoadingContext().stylesReader() ); +                \
frameAttributes.setPen( pen ); +            }
+        }
+        
+        if ( styleStack.hasProperty( KoXmlNS::draw, "fill" ) )
+        {
+            backgroundAttributes.setVisible( true );
+            QBrush brush;
+            QString fill = styleStack.property( KoXmlNS::draw, "fill" );
+            if ( fill == "solid" || fill == "hatch" )
+                brush = KoOdfGraphicStyles::loadOasisFillStyle( styleStack, fill, \
context.odfLoadingContext().stylesReader() ); +            else if ( fill == \
"gradient" ) +            {
+                brush = KoOdfGraphicStyles::loadOasisGradientStyle( styleStack, \
context.odfLoadingContext().stylesReader(), QSizeF( 5.0, 60.0 ) ); +                \
qDebug() << brush; +            }
+            else if ( fill == "bitmap" )
+                brush = KoOdfGraphicStyles::loadOasisPatternStyle( styleStack, \
context.odfLoadingContext(), QSizeF( 5.0, 60.0 ) ); +            \
backgroundAttributes.setBrush( brush ); +        }
+        
+        d->kdPlane->setBackgroundAttributes( backgroundAttributes );
+        d->kdPlane->setFrameAttributes( frameAttributes );
+    }
+    
     return true;
 }
--- trunk/koffice/kchart/shape/Surface.h #840321:840322
@@ -42,7 +42,7 @@
     void setBrush( const QBrush &brush );
     void setFramePen( const QPen &pen );
     
-    bool loadOdf( const KoXmlElement &surfaceElement, const KoOdfStylesReader \
&stylesReader ); +    bool loadOdf( const KoXmlElement &surfaceElement, \
KoShapeLoadingContext &context );  
 private:
     class Private;


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

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