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

List:       kde-commits
Subject:    koffice/plugins/pictureshape
From:       Carlos Licea <carlos_licea () hotmail ! com>
Date:       2010-05-05 4:43:21
Message-ID: 20100505044321.56A54AC8AB () svn ! kde ! org
[Download RAW message or body]

SVN commit 1122942 by clicea:

Add the Grayscale and Mono filter effects. Saving is still TODO.

 M  +2 -0      CMakeLists.txt  
 A             GreyscaleFilterEffect.cpp   [License: GPL (v3+)]
 A             GreyscaleFilterEffect.h   [License: GPL (v3+)]
 A             MonoFilterEffect.cpp   [License: GPL (v3+)]
 A             MonoFilterEffect.h   [License: GPL (v3+)]
 M  +37 -21    PictureShape.cpp  


--- trunk/koffice/plugins/pictureshape/CMakeLists.txt #1122941:1122942
@@ -10,6 +10,8 @@
     Plugin.cpp
     PictureShapeConfigWidget.cpp
     ChangeImageCommand.cpp
+    GreyscaleFilterEffect.cpp
+    MonoFilterEffect.cpp
 )
 
 kde4_add_plugin(pictureshape ${pictureshape_LIB_SRCS})
--- trunk/koffice/plugins/pictureshape/PictureShape.cpp #1122941:1122942
@@ -36,6 +36,9 @@
 #include <QTimer>
 #include <QPixmapCache>
 #include <kdebug.h>
+#include <KoFilterEffectStack.h>
+#include "GreyscaleFilterEffect.h"
+#include "MonoFilterEffect.h"
 
 QString generate_key(qint64 key, const QSize & size)
 {
@@ -64,9 +67,11 @@
 PictureShape::PictureShape()
     : KoFrameShape(KoXmlNS::draw, "image"),
     m_imageCollection(0),
-    m_renderQueue(new RenderQueue(this))
+    m_renderQueue(new RenderQueue(this)),
+    m_mode(Standard)
 {
     setKeepAspectRatio(true);
+    setFilterEffectStack(new KoFilterEffectStack());
 }
 
 PictureShape::~PictureShape()
@@ -200,6 +205,7 @@
 
 bool PictureShape::loadOdf(const KoXmlElement &element, KoShapeLoadingContext \
&context)  {
+    loadOdfColorTransformations(element, context);
     loadOdfAttributes(element, context, OdfAllAttributes);
     return loadOdfFrame(element, context);
 }
@@ -236,29 +242,25 @@
 
 bool PictureShape::loadOdfColorTransformations(const KoXmlElement& element, \
KoShapeLoadingContext& context)  {
-//     KoStyleStack &styleStack = context.odfLoadingContext().styleStack();
-//     styleStack.save();
-//     context.odfLoadingContext().fillStyleStack(element, KoXmlNS::draw, \
"style-name", "graphic"); +    KoStyleStack &styleStack = \
context.odfLoadingContext().styleStack(); +    styleStack.save();
+    context.odfLoadingContext().fillStyleStack(element, KoXmlNS::draw, "style-name", \
"graphic");  //     styleStack.setTypeProperties("graphic");
-// 
-//     //FIXME: are there other applicable properties?
-//     if( styleStack.hasProperty(KoXmlNS::draw, "color-mode") ) {
-//         QString colorMode = styleStack.property(KoXmlNS::draw, "color-mode");
-//         KoFilterEffect* colorModeEffect = 0;
-//         if( colorMode == "greyscale" ) {
-//             ColorMatrixEffect* colorMatrixEfect = new ColorMatrixEffect();
-//             colorMatrixEfect->setSaturate(0);
-//             colorModeEffect = colorMatrixEfect;
-//         }
-//         else if( colorMode == "mono" )
-//             ;
+
+    //FIXME: are there other applicable properties?
+    if( styleStack.hasProperty(KoXmlNS::draw, "color-mode") ) {
+        QString colorMode = styleStack.property(KoXmlNS::draw, "color-mode");
+        if( colorMode == "greyscale" ) {
+            setMode(Greyscale);
+        }
+        else if( colorMode == "mono" ) {
+            setMode(Mono);
+        }
 //         else if( colorMode == "watermark" )
 //             ;
-//         if( colorModeEffect );
-//             filterEffectStack()->appendFilterEffect(colorModeEffect);
-//     }
-//
-//     styleStack.restore();
+    }
+
+    styleStack.restore();
     return true;
 }
 
@@ -271,6 +273,20 @@
 {
     if( mode != m_mode ) {
         m_mode = mode;
+        KoFilterEffect* filterMode = filterEffectStack()->takeFilterEffect(0);
+        delete filterMode;
+        switch( mode ) {
+            case Greyscale:
+                filterMode = new GreyscaleFilterEffect();
+                break;
+            case Mono:
+                filterMode = new MonoFilterEffect();
+                break;
+            default:
+                break;
+        }
+        if( filterMode )
+            filterEffectStack()->appendFilterEffect(filterMode);
         update();
     }
 }


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

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