summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-05-14 14:21:26 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-03-15 23:43:01 +0000
commit33b4c9938ddcf5555b55088531cce3f2493c1459 (patch)
tree187b02fbff85a3b3bffd04a451c7b67cc962317f /svx
parente799a47983c6e9f0ff312124ebf8fbea1e336b66 (diff)
Resolves: #i119125# 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. Conflicts: svx/source/svdraw/svdxcgv.cxx vcl/source/gdi/impgraph.cxx Change-Id: Ic6ac9fb3132dd122e16a5cd8f9c5ddd155ec9882
Diffstat (limited to 'svx')
-rw-r--r--svx/inc/svx/svdpntv.hxx9
-rw-r--r--svx/source/svdraw/svdfmtf.cxx109
-rw-r--r--svx/source/svdraw/svdpntv.cxx30
-rw-r--r--svx/source/svdraw/svdxcgv.cxx36
4 files changed, 121 insertions, 63 deletions
diff --git a/svx/inc/svx/svdpntv.hxx b/svx/inc/svx/svdpntv.hxx
index eca5710fa8df..2e9bc2534adb 100644
--- a/svx/inc/svx/svdpntv.hxx
+++ b/svx/inc/svx/svdpntv.hxx
@@ -113,6 +113,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
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index 4d9af43b85a1..583e54c19300 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -65,8 +65,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>
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -513,6 +514,8 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
pObj->SetMergedItem(XFillBitmapItem(String(), Graphic(aClippedBitmap)));
+ pObj->SetMergedItem(XFillBmpTileItem(false));
+ pObj->SetMergedItem(XFillBmpStretchItem(true));
}
}
}
@@ -1399,21 +1402,16 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
if(rMtf.GetActionSize())
{
- Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
- aRect.Right()++; aRect.Bottom()++;
-
- // 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));
+ const Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
+
+ // 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();
@@ -1435,12 +1433,14 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
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))
{
@@ -1453,11 +1453,8 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
}
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
@@ -1474,11 +1471,18 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
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
@@ -1499,40 +1503,69 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
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()));
+ const double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor));
+ const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0));
- pNew->SetPixel(y, x, BitmapColor(aCombine > 255 ? 255 : sal_uInt8(aCombine)));
+ 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);
}
}
diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx
index 3f539233325a..6e9993ab7950 100644
--- a/svx/source/svdraw/svdpntv.cxx
+++ b/svx/source/svdraw/svdpntv.cxx
@@ -54,11 +54,11 @@
#include <vcl/svapp.hxx>
#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;
@@ -136,6 +136,32 @@ SvxViewHint::HintType SvxViewHint::GetHintType (void) const
////////////////////////////////////////////////////////////////////////////////////////////////////
+BitmapEx convertMetafileToBitmapEx(
+ const GDIMetaFile& rMtf,
+ const basegfx::B2DRange& rTargetRange,
+ const sal_uInt32 nMaximumQuadraticPixels)
+{
+ BitmapEx aBitmapEx;
+
+ if(rMtf.GetActionSize())
+ {
+ 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);
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
index 6256e237c8e1..a85b378cfa52 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -19,11 +19,12 @@
#include <vector>
#include <editeng/editeng.hxx>
-#include "svx/xexch.hxx"
+#include <rtl/strbuf.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>
@@ -42,16 +43,11 @@
#include <svl/itempool.hxx>
#include <tools/bigint.hxx>
#include <sot/formats.hxx>
-
-// #i13033#
#include <clonelist.hxx>
#include <vcl/virdev.hxx>
-
#include <svl/style.hxx>
-
-// #i72535#
-#include "fmobj.hxx"
-#include <rtl/strbuf.hxx>
+#include <fmobj.hxx>
+#include <vcl/svgdata.hxx>
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -442,8 +438,6 @@ void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Po
}
}
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const
{
BitmapEx aBmp;
@@ -475,18 +469,14 @@ BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const
if( !aBmp )
{
- const Graphic aGraphic(GetMarkedObjMetaFile(bNoVDevIfOneBmpMarked));
-
- // #i102089# support user's settings of AA and LineSnap when the MetaFile gets
- // raster-converted 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()));
}
}