Kaydet (Commit) 59c4bed2 authored tarafından Armin Le Grand's avatar Armin Le Grand

#119125# various actions implemented, clipping added. Esp hard was…

#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.
üst 6af6c804
...@@ -119,6 +119,15 @@ private: ...@@ -119,6 +119,15 @@ private:
class SdrPaintWindow; class SdrPaintWindow;
typedef ::std::vector< SdrPaintWindow* > SdrPaintWindowVector; 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 class SVX_DLLPUBLIC SdrPaintView : public SfxListener, public SfxRepeatTarget, public SfxBroadcaster, public ::utl::ConfigurationListener
......
...@@ -72,8 +72,9 @@ ...@@ -72,8 +72,9 @@
#include <svx/xbtmpit.hxx> #include <svx/xbtmpit.hxx>
#include <svx/xfltrit.hxx> #include <svx/xfltrit.hxx>
#include <vcl/bmpacc.hxx> #include <vcl/bmpacc.hxx>
#include <vcl/svgdata.hxx> #include <svx/xflbmtit.hxx>
#include <drawinglayer/primitive2d/metafileprimitive2d.hxx> #include <svx/xflbstit.hxx>
#include <svx/svdpntv.hxx>
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -521,6 +522,8 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale) ...@@ -521,6 +522,8 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP)); pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
pObj->SetMergedItem(XFillBitmapItem(String(), Graphic(aClippedBitmap))); pObj->SetMergedItem(XFillBitmapItem(String(), Graphic(aClippedBitmap)));
pObj->SetMergedItem(XFillBmpTileItem(false));
pObj->SetMergedItem(XFillBmpStretchItem(true));
} }
} }
} }
...@@ -1413,21 +1416,16 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct) ...@@ -1413,21 +1416,16 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
if(rMtf.GetActionCount()) if(rMtf.GetActionCount())
{ {
Rectangle aRect(rAct.GetPoint(),rAct.GetSize()); const Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
aRect.Right()++; aRect.Bottom()++;
// convert metafile sub-content to BitmapEx
// get metafile content as bitmap BitmapEx aBitmapEx(
const basegfx::B2DRange aTargetRange( convertMetafileToBitmapEx(
aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom()); rMtf,
const drawinglayer::primitive2d::Primitive2DReference aMtf( basegfx::B2DRange(
new drawinglayer::primitive2d::MetafilePrimitive2D( aRect.Left(), aRect.Top(),
basegfx::tools::createScaleTranslateB2DHomMatrix( aRect.Right(), aRect.Bottom()),
aTargetRange.getRange(), 125000));
aTargetRange.getMinimum()),
rMtf));
BitmapEx aBitmapEx(convertPrimitive2DSequenceToBitmapEx(
drawinglayer::primitive2d::Primitive2DSequence(&aMtf, 1),
aTargetRange));
// handle colors // handle colors
const Gradient& rGradient = rAct.GetGradient(); const Gradient& rGradient = rAct.GetGradient();
...@@ -1449,12 +1447,14 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct) ...@@ -1449,12 +1447,14 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
bool bCreateObject(true); bool bCreateObject(true);
bool bHasNewMask(false); bool bHasNewMask(false);
AlphaMask aNewMask; AlphaMask aNewMask;
double fTransparence(0.0);
bool bFixedTransparence(false);
if(bEqualColors || bNoSteps) if(bEqualColors || bNoSteps)
{ {
// single transparence // single transparence
const basegfx::BColor aMedium(basegfx::average(aStart, aEnd)); const basegfx::BColor aMedium(basegfx::average(aStart, aEnd));
const double fTransparence(aMedium.luminance()); fTransparence = aMedium.luminance();
if(basegfx::fTools::lessOrEqual(fTransparence, 0.0)) if(basegfx::fTools::lessOrEqual(fTransparence, 0.0))
{ {
...@@ -1467,11 +1467,8 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct) ...@@ -1467,11 +1467,8 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
} }
else else
{ {
// 0.0 < transparence < 1.0, apply // 0.0 < transparence < 1.0, apply fixed transparence
sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0)); bFixedTransparence = true;
aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha);
bHasNewMask = true;
} }
} }
else else
...@@ -1488,11 +1485,18 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct) ...@@ -1488,11 +1485,18 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
if(bCreateObject) if(bCreateObject)
{ {
if(bHasNewMask) if(bHasNewMask || bFixedTransparence)
{ {
if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent()) if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent())
{ {
// no transparence yet, apply new one // 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); aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask);
} }
else else
...@@ -1513,40 +1517,69 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct) ...@@ -1513,40 +1517,69 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
aOldMask = aBitmapEx.GetBitmap().CreateMask(aBitmapEx.GetTransparentColor()); aOldMask = aBitmapEx.GetBitmap().CreateMask(aBitmapEx.GetTransparentColor());
} }
BitmapReadAccess* pOld = aOldMask.AcquireReadAccess(); BitmapWriteAccess* pOld = aOldMask.AcquireWriteAccess();
BitmapWriteAccess* pNew = aNewMask.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 double fOpOld(1.0 - (pOld->GetPixel(y, x).GetIndex() * fFactor));
const BitmapColor aColNew(pNew->GetPixel(y, x)); const sal_uInt8 aCol(basegfx::fround((1.0 - (fOpOld * fOpNew)) * 255.0));
const sal_uInt16 aCombine(sal_uInt16(aColOld.GetIndex()) + sal_uInt16(aColNew.GetIndex()));
pNew->SetPixel(y, x, BitmapColor(aCombine > 255 ? 255 : sal_uInt8(aCombine))); pOld->SetPixel(y, x, BitmapColor(aCol));
} }
} }
} }
else 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); aOldMask.ReleaseAccess(pOld);
aNewMask.ReleaseAccess(pNew);
} }
else 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 // apply combined bitmap as mask
aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask); aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aOldMask);
} }
} }
......
...@@ -69,11 +69,11 @@ ...@@ -69,11 +69,11 @@
#include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/awt/PosSize.hpp> #include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/awt/XControl.hpp> #include <com/sun/star/awt/XControl.hpp>
// #i38135#
#include <svx/sdr/contact/objectcontact.hxx> #include <svx/sdr/contact/objectcontact.hxx>
#include <svx/sdr/animation/objectanimator.hxx> #include <svx/sdr/animation/objectanimator.hxx>
#include <svx/sdr/contact/viewcontact.hxx> #include <svx/sdr/contact/viewcontact.hxx>
#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
using namespace ::rtl; using namespace ::rtl;
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -207,6 +207,32 @@ SvxViewHint::HintType SvxViewHint::GetHintType (void) const ...@@ -207,6 +207,32 @@ SvxViewHint::HintType SvxViewHint::GetHintType (void) const
} }
////////////////////////////////////////////////////////////////////////////////////////////////////
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); TYPEINIT2(SdrPaintView,SfxListener,SfxRepeatTarget);
......
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
#include <vector> #include <vector>
#include <editeng/editeng.hxx> #include <editeng/editeng.hxx>
#include "svx/xexch.hxx" #include <svx/xexch.hxx>
#include <svx/xflclit.hxx> #include <svx/xflclit.hxx>
#include <svx/svdxcgv.hxx> #include <svx/svdxcgv.hxx>
#include <svx/svdoutl.hxx> #include <svx/svdoutl.hxx>
#include "svx/svditext.hxx" #include <svx/svditext.hxx>
#include <svx/svdetc.hxx> #include <svx/svdetc.hxx>
#include <svx/svdundo.hxx> #include <svx/svdundo.hxx>
#include <svx/svdograf.hxx> #include <svx/svdograf.hxx>
...@@ -49,16 +49,11 @@ ...@@ -49,16 +49,11 @@
#include <svl/itempool.hxx> #include <svl/itempool.hxx>
#include <tools/bigint.hxx> #include <tools/bigint.hxx>
#include <sot/formats.hxx> #include <sot/formats.hxx>
// #i13033#
#include <clonelist.hxx> #include <clonelist.hxx>
#include <vcl/virdev.hxx> #include <vcl/virdev.hxx>
// b4967543
#include <svl/style.hxx> #include <svl/style.hxx>
#include <fmobj.hxx>
// #i72535# #include <vcl/svgdata.hxx>
#include "fmobj.hxx"
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -527,8 +522,6 @@ void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Po ...@@ -527,8 +522,6 @@ void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Po
} }
} }
////////////////////////////////////////////////////////////////////////////////////////////////////
BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const
{ {
BitmapEx aBmp; BitmapEx aBmp;
...@@ -560,18 +553,14 @@ BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const ...@@ -560,18 +553,14 @@ BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const
if( !aBmp ) if( !aBmp )
{ {
const Graphic aGraphic(GetMarkedObjMetaFile(bNoVDevIfOneBmpMarked)); const GDIMetaFile aGDIMetaFile(GetMarkedObjMetaFile(bNoVDevIfOneBmpMarked));
const Rectangle aBound(GetMarkedObjBoundRect());
// #i102089# support user's settings of AA and LineSnap when the MetaFile gets
// rasterconverted to a bitmap aBmp = convertMetafileToBitmapEx(
const SvtOptionsDrawinglayer aDrawinglayerOpt; aGDIMetaFile,
const GraphicConversionParameters aParameters( basegfx::B2DRange(
Size(), aBound.Left(), aBound.Top(),
false, aBound.Right(), aBound.Bottom()));
aDrawinglayerOpt.IsAntiAliasing(),
aDrawinglayerOpt.IsSnapHorVerLinesToDiscrete());
aBmp = aGraphic.GetBitmapEx(aParameters);
} }
} }
...@@ -910,3 +899,5 @@ sal_Bool SdrExchangeView::Paste(Window* /*pWin*/, sal_uIntPtr /*nFormat*/) ...@@ -910,3 +899,5 @@ sal_Bool SdrExchangeView::Paste(Window* /*pWin*/, sal_uIntPtr /*nFormat*/)
DBG_ERROR( "SdrExchangeView::Paste: Not supported anymore" ); DBG_ERROR( "SdrExchangeView::Paste: Not supported anymore" );
return sal_False; return sal_False;
} }
// eof
...@@ -41,7 +41,8 @@ typedef ::com::sun::star::uno::Sequence< Primitive2DReference > Primitive2DSeque ...@@ -41,7 +41,8 @@ typedef ::com::sun::star::uno::Sequence< Primitive2DReference > Primitive2DSeque
BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx( BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
const Primitive2DSequence& rSequence, const Primitive2DSequence& rSequence,
const basegfx::B2DRange& rTargetRange); const basegfx::B2DRange& rTargetRange,
const sal_uInt32 nMaximumQuadraticPixels = 500000);
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
......
...@@ -28,12 +28,9 @@ ...@@ -28,12 +28,9 @@
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <ucbhelper/content.hxx> #include <ucbhelper/content.hxx>
#include <unotools/ucbstreamhelper.hxx> #include <unotools/ucbstreamhelper.hxx>
#include <unotools/tempfile.hxx> #include <unotools/tempfile.hxx>
#include <vcl/outdev.hxx> #include <vcl/outdev.hxx>
#include <vcl/virdev.hxx> #include <vcl/virdev.hxx>
#include <vcl/gfxlink.hxx> #include <vcl/gfxlink.hxx>
...@@ -41,9 +38,7 @@ ...@@ -41,9 +38,7 @@
#include <vcl/salbtype.hxx> #include <vcl/salbtype.hxx>
#include <vcl/graph.hxx> #include <vcl/graph.hxx>
#include <vcl/metaact.hxx> #include <vcl/metaact.hxx>
#include <impgraph.hxx> #include <impgraph.hxx>
#include <com/sun/star/ucb/CommandAbortedException.hpp> #include <com/sun/star/ucb/CommandAbortedException.hpp>
// ----------- // -----------
......
...@@ -41,7 +41,8 @@ using namespace ::com::sun::star; ...@@ -41,7 +41,8 @@ using namespace ::com::sun::star;
BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx( BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
const Primitive2DSequence& rSequence, const Primitive2DSequence& rSequence,
const basegfx::B2DRange& rTargetRange) const basegfx::B2DRange& rTargetRange,
const sal_uInt32 nMaximumQuadraticPixels)
{ {
BitmapEx aRetval; BitmapEx aRetval;
...@@ -76,7 +77,7 @@ BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx( ...@@ -76,7 +77,7 @@ BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
aDPI.getWidth(), aDPI.getWidth(),
aDPI.getHeight(), aDPI.getHeight(),
aRealRect, aRealRect,
500000)); nMaximumQuadraticPixels));
if(xBitmap.is()) if(xBitmap.is())
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment