summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2013-05-08 09:43:02 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-15 16:47:23 +0100
commitff318ccb0cd5e87633a1bcc9c491702cba76e712 (patch)
treead61c84921bb275d7894922e0cbe38e197d72a4b
parent6daec0854455b50b7f4318dce2ec6afd92aad324 (diff)
Resolves: #i122246# Corrected three basic problems in the metafile breaker
(cherry picked from commit 00174b7aac9692e3b70b6134cc9b4a005f8bc701) Conflicts: svx/source/svdraw/svdfmtf.cxx Change-Id: I9d48357af135cff0aec7e5535ffca708af2e2f3f
-rw-r--r--svx/source/svdraw/svdfmtf.cxx98
1 files changed, 71 insertions, 27 deletions
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index f6c485859713..dbc4b5e444de 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -122,8 +122,18 @@ ImpSdrGDIMetaFileImport::~ImpSdrGDIMetaFileImport()
void ImpSdrGDIMetaFileImport::DoLoopActions(GDIMetaFile& rMtf, SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport)
{
- for( MetaAction* pAct = rMtf.FirstAction(); pAct; pAct = rMtf.NextAction() )
+ const sal_uLong nCount(rMtf.GetActionSize());
+
+ for(sal_uLong a(0); a < nCount; a++)
{
+ MetaAction* pAct = rMtf.GetAction(a);
+
+ if(!pAct)
+ {
+ OSL_ENSURE(false, "OOps, no action at valid position (!)");
+ pAct = rMtf.GetAction(0);
+ }
+
switch (pAct->GetType())
{
case META_PIXEL_ACTION : DoAction((MetaPixelAction &)*pAct); break;
@@ -507,10 +517,17 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
aTrans.scale(fLclScaleX, fLclScaleY);
aPixel.transform(aTrans);
+ const Size aOrigSizePixel(aBitmapEx.GetSizePixel());
+ const Point aClipTopLeft(
+ basegfx::fround(floor(std::max(0.0, aPixel.getMinX()))),
+ basegfx::fround(floor(std::max(0.0, aPixel.getMinY()))));
+ const Size aClipSize(
+ basegfx::fround(ceil(std::min((double)aOrigSizePixel.Width(), aPixel.getWidth()))),
+ basegfx::fround(ceil(std::min((double)aOrigSizePixel.Height(), aPixel.getHeight()))));
const BitmapEx aClippedBitmap(
aBitmapEx,
- Point(floor(std::max(0.0, aPixel.getMinX())), floor(std::max(0.0, aPixel.getMinY()))),
- Size(ceil(aPixel.getWidth()), ceil(aPixel.getHeight())));
+ aClipTopLeft,
+ aClipSize);
pObj->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
pObj->SetMergedItem(XFillBitmapItem(String(), Graphic(aClippedBitmap)));
@@ -999,6 +1016,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction& rAct)
Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel());
aRect.Right()++; aRect.Bottom()++;
SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
+
+ // This action is not creating line and fill, set directly, do not use SetAttributes(..)
+ pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
InsertObj(pGraf);
}
@@ -1007,6 +1028,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction& rAct)
Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
aRect.Right()++; aRect.Bottom()++;
SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
+
+ // This action is not creating line and fill, set directly, do not use SetAttributes(..)
+ pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
InsertObj(pGraf);
}
@@ -1015,6 +1040,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction& rAct)
Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel());
aRect.Right()++; aRect.Bottom()++;
SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
+
+ // This action is not creating line and fill, set directly, do not use SetAttributes(..)
+ pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
InsertObj(pGraf);
}
@@ -1023,6 +1052,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction& rAct)
Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
aRect.Right()++; aRect.Bottom()++;
SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
+
+ // This action is not creating line and fill, set directly, do not use SetAttributes(..)
+ pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
InsertObj(pGraf);
}
@@ -1146,22 +1179,18 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pM
aXGradient.SetEndIntens(rGrad.GetEndIntensity());
aXGradient.SetSteps(rGrad.GetSteps());
- if(maVD.IsLineColor())
- {
- // switch line off; if there was one, there will be a
- // META_POLYLINE_ACTION following creating another object
- const Color aLineColor(maVD.GetLineColor());
- maVD.SetLineColor();
- SetAttributes(pPath);
- maVD.SetLineColor(aLineColor);
- }
- else
- {
- SetAttributes(pPath);
- }
+ // no need to use SetAttributes(..) here since line and fill style
+ // need to be set individually
+ // SetAttributes(pPath);
+ // switch line off; if there was one there will be a
+ // META_POLYLINE_ACTION following creating another object
+ aGradAttr.Put(XLineStyleItem(XLINE_NONE));
+
+ // add detected gradient fillstyle
aGradAttr.Put(XFillStyleItem(XFILL_GRADIENT));
aGradAttr.Put(XFillGradientItem(aXGradient));
+
pPath->SetMergedItemSet(aGradAttr);
InsertObj(pPath);
@@ -1201,9 +1230,11 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScalePartAction& rAct)
aRect.Right()++;
aRect.Bottom()++;
aBitmap.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
-
SdrGrafObj* pGraf = new SdrGrafObj(aBitmap, aRect);
+ // This action is not creating line and fill, set directly, do not use SetAttributes(..)
+ pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
InsertObj(pGraf);
}
@@ -1215,9 +1246,11 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScalePartAction& rAct)
aRect.Right()++;
aRect.Bottom()++;
aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
-
SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
+ // This action is not creating line and fill, set directly, do not use SetAttributes(..)
+ pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
InsertObj(pGraf);
}
@@ -1226,11 +1259,12 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskAction& rAct)
Rectangle aRect(rAct.GetPoint(), rAct.GetBitmap().GetSizePixel());
BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
- aRect.Right()++;
- aRect.Bottom()++;
-
+ aRect.Right()++; aRect.Bottom()++;
SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
+ // This action is not creating line and fill, set directly, do not use SetAttributes(..)
+ pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
InsertObj(pGraf);
}
@@ -1239,11 +1273,12 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScaleAction& rAct)
Rectangle aRect(rAct.GetPoint(), rAct.GetSize());
BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
- aRect.Right()++;
- aRect.Bottom()++;
-
+ aRect.Right()++; aRect.Bottom()++;
SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
+ // This action is not creating line and fill, set directly, do not use SetAttributes(..)
+ pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
InsertObj(pGraf);
}
@@ -1252,12 +1287,13 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScalePartAction& rAct)
Rectangle aRect(rAct.GetDestPoint(), rAct.GetDestSize());
BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
- aRect.Right()++;
- aRect.Bottom()++;
+ aRect.Right()++; aRect.Bottom()++;
aBitmapEx.Crop(Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
-
SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
+ // This action is not creating line and fill, set directly, do not use SetAttributes(..)
+ pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
InsertObj(pGraf);
}
@@ -1404,6 +1440,9 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
{
const Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
+ Rectangle aHairline;
+ const Rectangle aBoundRect(rMtf.GetBoundRect(*Application::GetDefaultDevice(), &aHairline));
+
// convert metafile sub-content to BitmapEx
BitmapEx aBitmapEx(
convertMetafileToBitmapEx(
@@ -1572,6 +1611,11 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction& rAct)
// create and add object
SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
+ // for MetaFloatTransparentAction, do not use SetAttributes(...)
+ // since these metafile content is not used to draw line/fill
+ // dependent of these setting at the device content
+ pGraf->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pGraf->SetMergedItem(XFillStyleItem(XFILL_NONE));
InsertObj(pGraf);
}
}