incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1338254 - in /incubator/ooo/trunk/main: svx/inc/svx/svdpntv.hxx svx/source/svdraw/svdfmtf.cxx svx/source/svdraw/svdpntv.cxx svx/source/svdraw/svdxcgv.cxx vcl/inc/vcl/svgdata.hxx vcl/source/gdi/impgraph.cxx vcl/source/gdi/svgdata.cxx
Date Mon, 14 May 2012 15:21:26 GMT
Author: alg
Date: Mon May 14 15:21:26 2012
New Revision: 1338254

URL: http://svn.apache.org/viewvc?rev=1338254&view=rev
Log:
#119125# various actions implemented, clipping added. Esp hard was ImpSdrGDIMetaFileImport,
but working now. Needed to hand-craft alpha addition for alpha in Metafile content and gradient
of action. Also added better BitmapEx creation for convert to bitmap for draw objects.

Modified:
    incubator/ooo/trunk/main/svx/inc/svx/svdpntv.hxx
    incubator/ooo/trunk/main/svx/source/svdraw/svdfmtf.cxx
    incubator/ooo/trunk/main/svx/source/svdraw/svdpntv.cxx
    incubator/ooo/trunk/main/svx/source/svdraw/svdxcgv.cxx
    incubator/ooo/trunk/main/vcl/inc/vcl/svgdata.hxx
    incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx
    incubator/ooo/trunk/main/vcl/source/gdi/svgdata.cxx

Modified: incubator/ooo/trunk/main/svx/inc/svx/svdpntv.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/inc/svx/svdpntv.hxx?rev=1338254&r1=1338253&r2=1338254&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/inc/svx/svdpntv.hxx (original)
+++ incubator/ooo/trunk/main/svx/inc/svx/svdpntv.hxx Mon May 14 15:21:26 2012
@@ -119,6 +119,15 @@ private:
 class SdrPaintWindow;
 typedef ::std::vector< SdrPaintWindow* > SdrPaintWindowVector;
 
+//////////////////////////////////////////////////////////////////////////////
+// helper to convert any GDIMetaFile to a good quality BitmapEx,
+// using default parameters and graphic::XPrimitive2DRenderer
+
+BitmapEx SVX_DLLPUBLIC convertMetafileToBitmapEx(
+    const GDIMetaFile& rMtf,
+    const basegfx::B2DRange& rTargetRange,
+    const sal_uInt32 nMaximumQuadraticPixels = 500000);
+
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
 class SVX_DLLPUBLIC SdrPaintView : public SfxListener, public SfxRepeatTarget, public SfxBroadcaster,
public ::utl::ConfigurationListener

Modified: incubator/ooo/trunk/main/svx/source/svdraw/svdfmtf.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/svdraw/svdfmtf.cxx?rev=1338254&r1=1338253&r2=1338254&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/svdraw/svdfmtf.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/svdraw/svdfmtf.cxx Mon May 14 15:21:26 2012
@@ -72,8 +72,9 @@
 #include <svx/xbtmpit.hxx>
 #include <svx/xfltrit.hxx>
 #include <vcl/bmpacc.hxx>
-#include <vcl/svgdata.hxx>
-#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
+#include <svx/xflbmtit.hxx>
+#include <svx/xflbstit.hxx>
+#include <svx/svdpntv.hxx>
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -521,6 +522,8 @@ void ImpSdrGDIMetaFileImport::InsertObj(
 
                     pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
                     pObj->SetMergedItem(XFillBitmapItem(String(), Graphic(aClippedBitmap)));
+                    pObj->SetMergedItem(XFillBmpTileItem(false));
+                    pObj->SetMergedItem(XFillBmpStretchItem(true));
                 }
             }
         }
@@ -1294,11 +1297,11 @@ void ImpSdrGDIMetaFileImport::DoAction(M
 
         switch(rGradient.GetStyle())
         {
-            case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break;
-            case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break;
-            case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break;
-            case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break;
-            case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break;
+            case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break;
+            case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break;
+            case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break;
+            case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break;
+            case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break;
             case GRADIENT_RECT: aXGradientStyle = XGRAD_RECT; break;
         }
             
@@ -1375,11 +1378,11 @@ void ImpSdrGDIMetaFileImport::DoAction(M
 
             switch(rGradient.GetStyle())
             {
-                case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break;
-                case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break;
-                case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break;
-                case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break;
-                case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break;
+                case GRADIENT_LINEAR: aXGradientStyle = XGRAD_LINEAR; break;
+                case GRADIENT_AXIAL: aXGradientStyle = XGRAD_AXIAL; break;
+                case GRADIENT_RADIAL: aXGradientStyle = XGRAD_RADIAL; break;
+                case GRADIENT_ELLIPTICAL: aXGradientStyle = XGRAD_ELLIPTICAL; break;
+                case GRADIENT_SQUARE: aXGradientStyle = XGRAD_SQUARE; break;
                 case GRADIENT_RECT: aXGradientStyle = XGRAD_RECT; break;
             }
             
@@ -1413,21 +1416,16 @@ void ImpSdrGDIMetaFileImport::DoAction(M
 
     if(rMtf.GetActionCount())
     {
-	    Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
-	    aRect.Right()++; aRect.Bottom()++;
+	    const Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
 
-        // get metafile content as bitmap
-        const basegfx::B2DRange aTargetRange(
-            aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom());
-		const drawinglayer::primitive2d::Primitive2DReference aMtf(
-			new drawinglayer::primitive2d::MetafilePrimitive2D(
-				basegfx::tools::createScaleTranslateB2DHomMatrix(
-                    aTargetRange.getRange(),
-                    aTargetRange.getMinimum()),
-				rMtf));
-        BitmapEx aBitmapEx(convertPrimitive2DSequenceToBitmapEx(
-    		drawinglayer::primitive2d::Primitive2DSequence(&aMtf, 1),
-            aTargetRange));
+        // convert metafile sub-content to BitmapEx
+        BitmapEx aBitmapEx(
+            convertMetafileToBitmapEx(
+                rMtf,
+                basegfx::B2DRange(
+                    aRect.Left(), aRect.Top(), 
+                    aRect.Right(), aRect.Bottom()),
+                125000));
 
         // handle colors
         const Gradient& rGradient = rAct.GetGradient();
@@ -1449,12 +1447,14 @@ void ImpSdrGDIMetaFileImport::DoAction(M
         bool bCreateObject(true);
         bool bHasNewMask(false);
         AlphaMask aNewMask;
+        double fTransparence(0.0);
+        bool bFixedTransparence(false);
 
         if(bEqualColors || bNoSteps)
         {
             // single transparence
             const basegfx::BColor aMedium(basegfx::average(aStart, aEnd));
-            const double fTransparence(aMedium.luminance());
+            fTransparence = aMedium.luminance();
 
             if(basegfx::fTools::lessOrEqual(fTransparence, 0.0))
             {
@@ -1467,11 +1467,8 @@ void ImpSdrGDIMetaFileImport::DoAction(M
             }
             else
             {
-                // 0.0 < transparence < 1.0, apply
-                sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0));
-
-                aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha);
-                bHasNewMask = true;
+                // 0.0 < transparence < 1.0, apply fixed transparence
+                bFixedTransparence = true;
             }
         }
         else
@@ -1488,11 +1485,18 @@ void ImpSdrGDIMetaFileImport::DoAction(M
 
         if(bCreateObject)
         {
-            if(bHasNewMask)
+            if(bHasNewMask || bFixedTransparence)
             {
                 if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent())
                 {
                     // no transparence yet, apply new one
+                    if(bFixedTransparence)
+                    {
+                        sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0));
+
+                        aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha);
+                    }
+
                     aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask);
                 }
                 else
@@ -1513,40 +1517,69 @@ void ImpSdrGDIMetaFileImport::DoAction(M
                         aOldMask = aBitmapEx.GetBitmap().CreateMask(aBitmapEx.GetTransparentColor());
                     }
 
-                    BitmapReadAccess* pOld = aOldMask.AcquireReadAccess();
-                    BitmapWriteAccess* pNew = aNewMask.AcquireWriteAccess();
+                    BitmapWriteAccess* pOld = aOldMask.AcquireWriteAccess();
 
-                    if(pOld && pNew)
+                    if(pOld)
                     {
-                        if(pOld->Width() == pNew->Width() && pOld->Height()
== pNew->Height())
+                        const double fFactor(1.0 / 255.0);
+                        
+                        if(bFixedTransparence)
                         {
-                            for(sal_uInt32 y(0); y < pNew->Height(); y++)
+                            const double fOpNew(1.0 - fTransparence);
+                            
+                            for(sal_uInt32 y(0); y < pOld->Height(); y++)
                             {
-                                for(sal_uInt32 x(0); x < pNew->Width(); x++)
+                                for(sal_uInt32 x(0); x < pOld->Width(); x++)
                                 {
-                                    const BitmapColor aColOld(pOld->GetPixel(y, x));
-                                    const BitmapColor aColNew(pNew->GetPixel(y, x));
-                                    const sal_uInt16 aCombine(sal_uInt16(aColOld.GetIndex())
+ sal_uInt16(aColNew.GetIndex()));
-                                    
-                                    pNew->SetPixel(y, x, BitmapColor(aCombine > 255
? 255 : sal_uInt8(aCombine)));
+                                    const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex()
* fFactor));
+                                    const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld *
fOpNew)) * 255.0));
+
+                                    pOld->SetPixel(y, x, BitmapColor(aCol));
                                 }
                             }
                         }
                         else
                         {
-                            OSL_ENSURE(false, "Alpha masks have different sizes (!)");
-                        }
+                            BitmapReadAccess* pNew = aNewMask.AcquireReadAccess();
+
+                            if(pNew)
+                            {
+                                if(pOld->Width() == pNew->Width() && pOld->Height()
== pNew->Height())
+                                {
+                                    for(sal_uInt32 y(0); y < pOld->Height(); y++)
+                                    {
+                                        for(sal_uInt32 x(0); x < pOld->Width(); x++)
+                                        {
+                                            const double fOpOld(1.0 - (pOld->GetPixel(y,
x).GetIndex() * fFactor));
+                                            const double fOpNew(1.0 - (pNew->GetPixel(y,
x).GetIndex() * fFactor));
+                                            const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld
* fOpNew)) * 255.0));
+
+                                            pOld->SetPixel(y, x, BitmapColor(aCol));
+                                        }
+                                    }
+                                }
+                                else
+                                {
+                                    OSL_ENSURE(false, "Alpha masks have different sizes (!)");
+                                }
         
+                                aNewMask.ReleaseAccess(pNew);
+                            }
+                            else
+                            {
+                                OSL_ENSURE(false, "Got no access to new alpha mask (!)");
+                            }
+                        }
+
                         aOldMask.ReleaseAccess(pOld);
-                        aNewMask.ReleaseAccess(pNew);
                     }
                     else
                     {
-                        OSL_ENSURE(false, "Got no access to alpha bitmaps (!)");
+                        OSL_ENSURE(false, "Got no access to old alpha mask (!)");
                     }
 
                     // apply combined bitmap as mask
-                    aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask);
+                    aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aOldMask);
                 }
             }
 

Modified: incubator/ooo/trunk/main/svx/source/svdraw/svdpntv.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/svdraw/svdpntv.cxx?rev=1338254&r1=1338253&r2=1338254&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/svdraw/svdpntv.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/svdraw/svdpntv.cxx Mon May 14 15:21:26 2012
@@ -69,11 +69,11 @@
 #include <com/sun/star/awt/XWindow.hpp>
 #include <com/sun/star/awt/PosSize.hpp>
 #include <com/sun/star/awt/XControl.hpp>
-
-// #i38135#
 #include <svx/sdr/contact/objectcontact.hxx>
 #include <svx/sdr/animation/objectanimator.hxx>
 #include <svx/sdr/contact/viewcontact.hxx>
+#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
 
 using namespace ::rtl;
 using namespace ::com::sun::star;
@@ -209,6 +209,32 @@ SvxViewHint::HintType SvxViewHint::GetHi
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
+BitmapEx convertMetafileToBitmapEx(
+    const GDIMetaFile& rMtf, 
+    const basegfx::B2DRange& rTargetRange,
+    const sal_uInt32 nMaximumQuadraticPixels)
+{
+    BitmapEx aBitmapEx;
+
+    if(rMtf.GetActionCount())
+    {
+		const drawinglayer::primitive2d::Primitive2DReference aMtf(
+			new drawinglayer::primitive2d::MetafilePrimitive2D(
+				basegfx::tools::createScaleTranslateB2DHomMatrix(
+                    rTargetRange.getRange(),
+                    rTargetRange.getMinimum()),
+				rMtf));
+        aBitmapEx = convertPrimitive2DSequenceToBitmapEx(
+    		drawinglayer::primitive2d::Primitive2DSequence(&aMtf, 1),
+            rTargetRange,
+            nMaximumQuadraticPixels);
+    }
+
+    return aBitmapEx;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
 TYPEINIT2(SdrPaintView,SfxListener,SfxRepeatTarget);
 
 DBG_NAME(SdrPaintView);

Modified: incubator/ooo/trunk/main/svx/source/svdraw/svdxcgv.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/svdraw/svdxcgv.cxx?rev=1338254&r1=1338253&r2=1338254&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/svdraw/svdxcgv.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/svdraw/svdxcgv.cxx Mon May 14 15:21:26 2012
@@ -26,11 +26,11 @@
 
 #include <vector>
 #include <editeng/editeng.hxx>
-#include "svx/xexch.hxx"
+#include <svx/xexch.hxx>
 #include <svx/xflclit.hxx>
 #include <svx/svdxcgv.hxx>
 #include <svx/svdoutl.hxx>
-#include "svx/svditext.hxx"
+#include <svx/svditext.hxx>
 #include <svx/svdetc.hxx>
 #include <svx/svdundo.hxx>
 #include <svx/svdograf.hxx>
@@ -49,16 +49,11 @@
 #include <svl/itempool.hxx>
 #include <tools/bigint.hxx>
 #include <sot/formats.hxx>
-
-// #i13033#
 #include <clonelist.hxx>
 #include <vcl/virdev.hxx>
-
-// b4967543
 #include <svl/style.hxx>
-
-// #i72535#
-#include "fmobj.hxx"
+#include <fmobj.hxx>
+#include <vcl/svgdata.hxx>
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -527,8 +522,6 @@ void SdrExchangeView::ImpPasteObject(Sdr
 	}
 }
 
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
 BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const
 {
 	BitmapEx aBmp;
@@ -560,18 +553,14 @@ BitmapEx SdrExchangeView::GetMarkedObjBi
 
 		if( !aBmp )
 		{
-			const Graphic aGraphic(GetMarkedObjMetaFile(bNoVDevIfOneBmpMarked));
-            
-            // #i102089# support user's settings of AA and LineSnap when the MetaFile gets
-            // rasterconverted to a bitmap
-            const SvtOptionsDrawinglayer aDrawinglayerOpt;
-            const GraphicConversionParameters aParameters(
-                Size(),
-                false,
-                aDrawinglayerOpt.IsAntiAliasing(),
-                aDrawinglayerOpt.IsSnapHorVerLinesToDiscrete());
-
-            aBmp = aGraphic.GetBitmapEx(aParameters);
+            const GDIMetaFile aGDIMetaFile(GetMarkedObjMetaFile(bNoVDevIfOneBmpMarked));
+    		const Rectangle aBound(GetMarkedObjBoundRect());
+           
+            aBmp = convertMetafileToBitmapEx(
+                aGDIMetaFile,
+                basegfx::B2DRange(
+                    aBound.Left(), aBound.Top(),
+                    aBound.Right(), aBound.Bottom()));
 		}
 	}
 
@@ -910,3 +899,5 @@ sal_Bool SdrExchangeView::Paste(Window* 
     DBG_ERROR( "SdrExchangeView::Paste: Not supported anymore" );
     return sal_False;
 }
+
+// eof

Modified: incubator/ooo/trunk/main/vcl/inc/vcl/svgdata.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/inc/vcl/svgdata.hxx?rev=1338254&r1=1338253&r2=1338254&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/inc/vcl/svgdata.hxx (original)
+++ incubator/ooo/trunk/main/vcl/inc/vcl/svgdata.hxx Mon May 14 15:21:26 2012
@@ -41,7 +41,8 @@ typedef ::com::sun::star::uno::Sequence<
 
 BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
     const Primitive2DSequence& rSequence,
-    const basegfx::B2DRange& rTargetRange);
+    const basegfx::B2DRange& rTargetRange,
+    const sal_uInt32 nMaximumQuadraticPixels = 500000);
 
 //////////////////////////////////////////////////////////////////////////////
 

Modified: incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx?rev=1338254&r1=1338253&r2=1338254&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx (original)
+++ incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx Mon May 14 15:21:26 2012
@@ -28,12 +28,9 @@
 #include <tools/urlobj.hxx>
 #include <tools/debug.hxx>
 #include <tools/stream.hxx>
-
 #include <ucbhelper/content.hxx>
-
 #include <unotools/ucbstreamhelper.hxx>
 #include <unotools/tempfile.hxx>
-
 #include <vcl/outdev.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/gfxlink.hxx>
@@ -41,9 +38,7 @@
 #include <vcl/salbtype.hxx>
 #include <vcl/graph.hxx>
 #include <vcl/metaact.hxx>
-
 #include <impgraph.hxx>
-
 #include <com/sun/star/ucb/CommandAbortedException.hpp>
 
 // -----------

Modified: incubator/ooo/trunk/main/vcl/source/gdi/svgdata.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/source/gdi/svgdata.cxx?rev=1338254&r1=1338253&r2=1338254&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/source/gdi/svgdata.cxx (original)
+++ incubator/ooo/trunk/main/vcl/source/gdi/svgdata.cxx Mon May 14 15:21:26 2012
@@ -41,7 +41,8 @@ using namespace ::com::sun::star;
 
 BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
     const Primitive2DSequence& rSequence,
-    const basegfx::B2DRange& rTargetRange)
+    const basegfx::B2DRange& rTargetRange,
+    const sal_uInt32 nMaximumQuadraticPixels)
 {
     BitmapEx aRetval;
 
@@ -76,7 +77,7 @@ BitmapEx VCL_DLLPUBLIC convertPrimitive2
                         aDPI.getWidth(), 
                         aDPI.getHeight(), 
                         aRealRect, 
-                        500000));
+                        nMaximumQuadraticPixels));
 
                 if(xBitmap.is())
                 {



Mime
View raw message