Related: #i119125# Added MetaFloatTransparentAction handling...
...using primitive renderer Conflicts: svx/source/svdraw/svdedtv2.cxx svx/source/svdraw/svdfmtf.cxx svx/source/svdraw/svdfmtf.hxx svx/source/svdraw/svdograf.cxx Change-Id: I2223f86a63be80ecae91af0a6987ac587f07bc30
This commit is contained in:
parent
55dd17942c
commit
977a05ac71
8 changed files with 819 additions and 328 deletions
|
@ -2964,9 +2964,13 @@ namespace
|
|||
{
|
||||
/** CHECKED, WORKS WELL */
|
||||
const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*)pAction;
|
||||
const Rectangle aTargetRectangle(pA->GetPoint(), pA->GetSize());
|
||||
const basegfx::B2DRange aTargetRange(
|
||||
pA->GetPoint().X(),
|
||||
pA->GetPoint().Y(),
|
||||
pA->GetPoint().X() + pA->GetSize().Width(),
|
||||
pA->GetPoint().Y() + pA->GetSize().Height());
|
||||
|
||||
if(!aTargetRectangle.IsEmpty())
|
||||
if(!aTargetRange.isEmpty())
|
||||
{
|
||||
const GDIMetaFile& rContent = pA->GetGDIMetaFile();
|
||||
|
||||
|
@ -2987,6 +2991,32 @@ namespace
|
|||
|
||||
if(xSubContent.hasElements())
|
||||
{
|
||||
// create SourceRange
|
||||
const basegfx::B2DRange aSourceRange(
|
||||
rContent.GetPrefMapMode().GetOrigin().X(),
|
||||
rContent.GetPrefMapMode().GetOrigin().Y(),
|
||||
rContent.GetPrefMapMode().GetOrigin().X() + rContent.GetPrefSize().Width(),
|
||||
rContent.GetPrefMapMode().GetOrigin().Y() + rContent.GetPrefSize().Height());
|
||||
|
||||
// apply mapping if aTargetRange and aSourceRange are not equal
|
||||
if(!aSourceRange.equal(aTargetRange))
|
||||
{
|
||||
basegfx::B2DHomMatrix aTransform;
|
||||
|
||||
aTransform.translate(-aSourceRange.getMinX(), -aSourceRange.getMinY());
|
||||
aTransform.scale(
|
||||
aTargetRange.getWidth() / (basegfx::fTools::equalZero(aSourceRange.getWidth()) ? 1.0 : aSourceRange.getWidth()),
|
||||
aTargetRange.getHeight() / (basegfx::fTools::equalZero(aSourceRange.getHeight()) ? 1.0 : aSourceRange.getHeight()));
|
||||
aTransform.translate(aTargetRange.getMinX(), aTargetRange.getMinY());
|
||||
|
||||
const drawinglayer::primitive2d::Primitive2DReference aEmbeddedTransform(
|
||||
new drawinglayer::primitive2d::TransformPrimitive2D(
|
||||
aTransform,
|
||||
xSubContent));
|
||||
|
||||
xSubContent = drawinglayer::primitive2d::Primitive2DSequence(&aEmbeddedTransform, 1);
|
||||
}
|
||||
|
||||
// check if gradient is a real gradient
|
||||
const Gradient& rGradient = pA->GetGradient();
|
||||
const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient));
|
||||
|
@ -3002,9 +3032,7 @@ namespace
|
|||
else
|
||||
{
|
||||
// really a gradient. Create gradient sub-content (with correct scaling)
|
||||
basegfx::B2DRange aRange(
|
||||
aTargetRectangle.Left(), aTargetRectangle.Top(),
|
||||
aTargetRectangle.Right(), aTargetRectangle.Bottom());
|
||||
basegfx::B2DRange aRange(aTargetRange);
|
||||
aRange.transform(rPropertyHolders.Current().getTransformation());
|
||||
|
||||
// prepare gradient for transparent content
|
||||
|
|
|
@ -2014,8 +2014,7 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo)
|
|||
|
||||
if(pGraf->HasGDIMetaFile())
|
||||
{
|
||||
aMetaFile = pGraf->GetTransformedGraphic(
|
||||
SDRGRAFOBJ_TRANSFORMATTR_COLOR|SDRGRAFOBJ_TRANSFORMATTR_MIRROR).GetGDIMetaFile();
|
||||
aMetaFile = pGraf->GetTransformedGraphic(SDRGRAFOBJ_TRANSFORMATTR_COLOR|SDRGRAFOBJ_TRANSFORMATTR_MIRROR).GetGDIMetaFile();
|
||||
}
|
||||
else if(pGraf->isEmbeddedSvg())
|
||||
{
|
||||
|
@ -2024,23 +2023,16 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo)
|
|||
|
||||
if(aMetaFile.GetActionSize())
|
||||
{
|
||||
ImpSdrGDIMetaFileImport aFilter(*pMod);
|
||||
|
||||
aLogicRect = pGraf->GetLogicRect();
|
||||
aFilter.SetScaleRect(aLogicRect);
|
||||
aFilter.SetLayer(pObj->GetLayer());
|
||||
|
||||
ImpSdrGDIMetaFileImport aFilter(*pMod, pObj->GetLayer(), aLogicRect);
|
||||
nInsAnz = aFilter.DoImport(aMetaFile, *pOL, nInsPos, pProgrInfo);
|
||||
}
|
||||
}
|
||||
if ( pOle2!=NULL && pOle2->GetGraphic() )
|
||||
{
|
||||
ImpSdrGDIMetaFileImport aFilter(*pMod);
|
||||
|
||||
aLogicRect = pOle2->GetLogicRect();
|
||||
aFilter.SetScaleRect(aLogicRect);
|
||||
aFilter.SetLayer(pObj->GetLayer());
|
||||
nInsAnz=aFilter.DoImport(pOle2->GetGraphic()->GetGDIMetaFile(),*pOL,nInsPos,pProgrInfo);
|
||||
ImpSdrGDIMetaFileImport aFilter(*pMod, pObj->GetLayer(), aLogicRect);
|
||||
nInsAnz = aFilter.DoImport(pOle2->GetGraphic()->GetGDIMetaFile(), *pOL, nInsPos, pProgrInfo);
|
||||
}
|
||||
if (nInsAnz!=0)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -43,39 +43,38 @@ class SvdProgressInfo;
|
|||
class ImpSdrGDIMetaFileImport
|
||||
{
|
||||
protected:
|
||||
std::vector<SdrObject*> aTmpList;
|
||||
VirtualDevice aVD;
|
||||
Rectangle aScaleRect;
|
||||
size_t nMapScalingOfs; // from here on, not edited with MapScaling
|
||||
SfxItemSet* pLineAttr;
|
||||
SfxItemSet* pFillAttr;
|
||||
SfxItemSet* pTextAttr;
|
||||
SdrPage* pPage;
|
||||
SdrModel* pModel;
|
||||
SdrLayerID nLayer;
|
||||
Color aOldLineColor;
|
||||
sal_Int32 nLineWidth;
|
||||
::std::vector< SdrObject* > maTmpList;
|
||||
VirtualDevice maVD;
|
||||
Rectangle maScaleRect;
|
||||
size_t mnMapScalingOfs; // from here on, not edited with MapScaling
|
||||
SfxItemSet* mpLineAttr;
|
||||
SfxItemSet* mpFillAttr;
|
||||
SfxItemSet* mpTextAttr;
|
||||
SdrModel* mpModel;
|
||||
SdrLayerID mnLayer;
|
||||
Color maOldLineColor;
|
||||
sal_Int32 mnLineWidth;
|
||||
basegfx::B2DLineJoin maLineJoin;
|
||||
com::sun::star::drawing::LineCap maLineCap;
|
||||
XDash maDash;
|
||||
|
||||
sal_Bool bMov;
|
||||
sal_Bool bSize;
|
||||
Point aOfs;
|
||||
double fScaleX;
|
||||
double fScaleY;
|
||||
Fraction aScaleX;
|
||||
Fraction aScaleY;
|
||||
bool mbMov;
|
||||
bool mbSize;
|
||||
Point maOfs;
|
||||
double mfScaleX;
|
||||
double mfScaleY;
|
||||
Fraction maScaleX;
|
||||
Fraction maScaleY;
|
||||
|
||||
sal_Bool bFntDirty;
|
||||
bool mbFntDirty;
|
||||
|
||||
// to optimize (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> two-in-one
|
||||
sal_Bool bLastObjWasPolyWithoutLine;
|
||||
sal_Bool bNoLine;
|
||||
sal_Bool bNoFill;
|
||||
bool mbLastObjWasPolyWithoutLine;
|
||||
bool mbNoLine;
|
||||
bool mbNoFill;
|
||||
|
||||
// to optimize multiple lines into a Polyline
|
||||
sal_Bool bLastObjWasLine;
|
||||
bool mbLastObjWasLine;
|
||||
|
||||
// clipregion
|
||||
basegfx::B2DPolyPolygon maClip;
|
||||
|
@ -108,37 +107,63 @@ protected:
|
|||
void DoAction(MetaHatchAction & rAct);
|
||||
void DoAction(MetaLineColorAction & rAct);
|
||||
void DoAction(MetaMapModeAction & rAct);
|
||||
void DoAction(MetaFillColorAction & rAct) { rAct.Execute(&aVD); }
|
||||
void DoAction(MetaTextColorAction & rAct) { rAct.Execute(&aVD); }
|
||||
void DoAction(MetaTextFillColorAction & rAct) { rAct.Execute(&aVD); }
|
||||
void DoAction(MetaFontAction & rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
|
||||
void DoAction(MetaTextAlignAction & rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
|
||||
void DoAction(MetaClipRegionAction & rAct) { rAct.Execute(&aVD); checkClip(); }
|
||||
void DoAction(MetaRasterOpAction & rAct) { rAct.Execute(&aVD); }
|
||||
void DoAction(MetaPushAction & rAct) { rAct.Execute(&aVD); checkClip(); }
|
||||
void DoAction(MetaPopAction & rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; checkClip(); }
|
||||
void DoAction(MetaMoveClipRegionAction & rAct) { rAct.Execute(&aVD); checkClip(); }
|
||||
void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&aVD); checkClip(); }
|
||||
void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&aVD); checkClip(); }
|
||||
void DoAction(MetaFillColorAction & rAct) { rAct.Execute(&maVD); }
|
||||
void DoAction(MetaTextColorAction & rAct) { rAct.Execute(&maVD); }
|
||||
void DoAction(MetaTextFillColorAction & rAct) { rAct.Execute(&maVD); }
|
||||
void DoAction(MetaFontAction & rAct) { rAct.Execute(&maVD); mbFntDirty = true; }
|
||||
void DoAction(MetaTextAlignAction & rAct) { rAct.Execute(&maVD); mbFntDirty = true; }
|
||||
void DoAction(MetaClipRegionAction & rAct) { rAct.Execute(&maVD); checkClip(); }
|
||||
void DoAction(MetaRasterOpAction & rAct) { rAct.Execute(&maVD); }
|
||||
void DoAction(MetaPushAction & rAct) { rAct.Execute(&maVD); checkClip(); }
|
||||
void DoAction(MetaPopAction & rAct) { rAct.Execute(&maVD); mbFntDirty = true; checkClip(); }
|
||||
void DoAction(MetaMoveClipRegionAction & rAct) { rAct.Execute(&maVD); checkClip(); }
|
||||
void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&maVD); checkClip(); }
|
||||
void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&maVD); checkClip(); }
|
||||
void DoAction(MetaCommentAction& rAct, GDIMetaFile* pMtf);
|
||||
|
||||
void ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct );
|
||||
// missing actions added
|
||||
void DoAction(MetaTextRectAction& rAct);
|
||||
void DoAction(MetaBmpScalePartAction& rAct);
|
||||
void DoAction(MetaBmpExScalePartAction& rAct);
|
||||
void DoAction(MetaMaskAction& rAct);
|
||||
void DoAction(MetaMaskScaleAction& rAct);
|
||||
void DoAction(MetaMaskScalePartAction& rAct);
|
||||
void DoAction(MetaGradientAction& rAct);
|
||||
void DoAction(MetaWallpaperAction& rAct);
|
||||
void DoAction(MetaTransparentAction& rAct);
|
||||
void DoAction(MetaEPSAction& rAct);
|
||||
void DoAction(MetaRefPointAction& rAct) { rAct.Execute(&maVD); }
|
||||
void DoAction(MetaTextLineColorAction& rAct) { rAct.Execute(&maVD); mbFntDirty = true; }
|
||||
void DoAction(MetaTextLineAction& rAct);
|
||||
void DoAction(MetaFloatTransparentAction& rAct);
|
||||
void DoAction(MetaGradientExAction& rAct);
|
||||
void DoAction(MetaLayoutModeAction& rAct) { rAct.Execute(&maVD); mbFntDirty = true; }
|
||||
void DoAction(MetaTextLanguageAction& rAct) { rAct.Execute(&maVD); mbFntDirty = true; }
|
||||
void DoAction(MetaOverlineColorAction& rAct) { rAct.Execute(&maVD); mbFntDirty = true; }
|
||||
|
||||
void ImportText(const Point& rPos, const XubString& rStr, const MetaAction& rAct);
|
||||
void SetAttributes(SdrObject* pObj, bool bForceTextAttr = false);
|
||||
void InsertObj( SdrObject* pObj, sal_Bool bScale = sal_True );
|
||||
void InsertObj(SdrObject* pObj, bool bScale = true);
|
||||
void MapScaling();
|
||||
|
||||
// #i73407# reformulation to use new B2DPolygon classes
|
||||
bool CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly);
|
||||
bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
|
||||
|
||||
void DoLoopActions(GDIMetaFile& rMtf, SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport);
|
||||
|
||||
public:
|
||||
ImpSdrGDIMetaFileImport(SdrModel& rModel);
|
||||
ImpSdrGDIMetaFileImport(
|
||||
SdrModel& rModel,
|
||||
SdrLayerID nLay,
|
||||
const Rectangle& rRect);
|
||||
~ImpSdrGDIMetaFileImport();
|
||||
sal_uLong DoImport(const GDIMetaFile& rMtf, SdrObjList& rDestList, sal_uLong nInsPos=CONTAINER_APPEND, SvdProgressInfo *pProgrInfo = NULL);
|
||||
void SetLayer(SdrLayerID nLay) { nLayer=nLay; }
|
||||
SdrLayerID GetLayer() const { return nLayer; }
|
||||
void SetScaleRect(const Rectangle& rRect) { aScaleRect=rRect; }
|
||||
const Rectangle& GetScaleRect() const { return aScaleRect; }
|
||||
|
||||
sal_uInt32 DoImport(
|
||||
const GDIMetaFile& rMtf,
|
||||
SdrObjList& rDestList,
|
||||
sal_uInt32 nInsPos = CONTAINER_APPEND,
|
||||
SvdProgressInfo* pProgrInfo = 0);
|
||||
};
|
||||
|
||||
#endif //_SVDFMTF_HXX
|
||||
|
|
|
@ -1115,11 +1115,7 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText ) cons
|
|||
case GRAPHIC_GDIMETAFILE:
|
||||
{
|
||||
// Sort into group and return ONLY those objects that can be created from the MetaFile.
|
||||
ImpSdrGDIMetaFileImport aFilter(*GetModel());
|
||||
|
||||
aFilter.SetScaleRect(aRect);
|
||||
aFilter.SetLayer(GetLayer());
|
||||
|
||||
ImpSdrGDIMetaFileImport aFilter(*GetModel(), GetLayer(), aRect);
|
||||
SdrObjGroup* pGrp = new SdrObjGroup();
|
||||
sal_uInt32 nInsAnz = aFilter.DoImport(aMtf, *pGrp->GetSubList(), 0);
|
||||
|
||||
|
|
|
@ -34,6 +34,14 @@ typedef boost::shared_array< sal_uInt8 > SvgDataArray;
|
|||
typedef ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive2D > Primitive2DReference;
|
||||
typedef ::com::sun::star::uno::Sequence< Primitive2DReference > Primitive2DSequence;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// helper to convert any Primitive2DSequence to a good quality BitmapEx,
|
||||
// using default parameters and graphic::XPrimitive2DRenderer
|
||||
|
||||
BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
|
||||
const Primitive2DSequence& rSequence,
|
||||
const basegfx::B2DRange& rTargetRange);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VCL_DLLPUBLIC SvgData : private boost::noncopyable
|
||||
|
|
|
@ -3758,9 +3758,6 @@ MetaAction* MetaFloatTransparentAction::Clone()
|
|||
void MetaFloatTransparentAction::Move( long nHorzMove, long nVertMove )
|
||||
{
|
||||
maPoint.Move( nHorzMove, nVertMove );
|
||||
|
||||
// also neeed to move the content metafile
|
||||
maMtf.Move( nHorzMove, nVertMove );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
|
|
@ -35,11 +35,13 @@ using namespace ::com::sun::star;
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SvgData::ensureReplacement()
|
||||
BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
|
||||
const Primitive2DSequence& rSequence,
|
||||
const basegfx::B2DRange& rTargetRange)
|
||||
{
|
||||
ensureSequenceAndRange();
|
||||
BitmapEx aRetval;
|
||||
|
||||
if(maReplacement.IsEmpty() && maSequence.hasElements())
|
||||
if(rSequence.hasElements())
|
||||
{
|
||||
// create replacement graphic from maSequence
|
||||
// create XPrimitive2DRenderer
|
||||
|
@ -53,20 +55,19 @@ void SvgData::ensureReplacement()
|
|||
if(xPrimitive2DRenderer.is())
|
||||
{
|
||||
uno::Sequence< beans::PropertyValue > aViewParameters;
|
||||
const basegfx::B2DRange& rRange(getRange());
|
||||
geometry::RealRectangle2D aRealRect;
|
||||
|
||||
aRealRect.X1 = rRange.getMinX();
|
||||
aRealRect.Y1 = rRange.getMinY();
|
||||
aRealRect.X2 = rRange.getMaxX();
|
||||
aRealRect.Y2 = rRange.getMaxY();
|
||||
aRealRect.X1 = rTargetRange.getMinX();
|
||||
aRealRect.Y1 = rTargetRange.getMinY();
|
||||
aRealRect.X2 = rTargetRange.getMaxX();
|
||||
aRealRect.Y2 = rTargetRange.getMaxY();
|
||||
|
||||
// get system DPI
|
||||
const Size aDPI(Application::GetDefaultDevice()->LogicToPixel(Size(1, 1), MAP_INCH));
|
||||
|
||||
const uno::Reference< rendering::XBitmap > xBitmap(
|
||||
xPrimitive2DRenderer->rasterize(
|
||||
maSequence,
|
||||
rSequence,
|
||||
aViewParameters,
|
||||
aDPI.getWidth(),
|
||||
aDPI.getHeight(),
|
||||
|
@ -79,7 +80,7 @@ void SvgData::ensureReplacement()
|
|||
|
||||
if(xIntBmp.is())
|
||||
{
|
||||
maReplacement = vcl::unotools::bitmapExFromXBitmap(xIntBmp);
|
||||
aRetval = vcl::unotools::bitmapExFromXBitmap(xIntBmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +90,20 @@ void SvgData::ensureReplacement()
|
|||
OSL_ENSURE(sal_False, "Got no graphic::XPrimitive2DRenderer (!)" );
|
||||
}
|
||||
}
|
||||
|
||||
return aRetval;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SvgData::ensureReplacement()
|
||||
{
|
||||
ensureSequenceAndRange();
|
||||
|
||||
if(maReplacement.IsEmpty() && maSequence.hasElements())
|
||||
{
|
||||
maReplacement = convertPrimitive2DSequenceToBitmapEx(maSequence, getRange());
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in a new issue