diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-06-21 14:46:35 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-07-15 11:01:30 +0200 |
commit | 63bc9be68e6d7a0e681516b5a04953388644101a (patch) | |
tree | fc395c2cccd9106f6dd1c1aa5171a10225aacabd /drawinglayer/source | |
parent | 044dc9fcca4df6ca21df790bdb14660f951e4598 (diff) |
emfplus: some cleanup/streamlining
Change-Id: Ia931ca356fb079b9cb2395ba2311b91d2481e2d4
Diffstat (limited to 'drawinglayer/source')
-rw-r--r-- | drawinglayer/source/tools/emfpbrush.cxx | 4 | ||||
-rw-r--r-- | drawinglayer/source/tools/emfphelperdata.cxx | 439 | ||||
-rw-r--r-- | drawinglayer/source/tools/emfphelperdata.hxx | 294 | ||||
-rw-r--r-- | drawinglayer/source/tools/emfplushelper.cxx | 12 | ||||
-rw-r--r-- | drawinglayer/source/tools/emfppen.cxx | 6 | ||||
-rw-r--r-- | drawinglayer/source/tools/emfppen.hxx | 2 | ||||
-rw-r--r-- | drawinglayer/source/tools/wmfemfhelper.cxx | 8 |
7 files changed, 391 insertions, 374 deletions
diff --git a/drawinglayer/source/tools/emfpbrush.cxx b/drawinglayer/source/tools/emfpbrush.cxx index d552bdfd5cd4..c093a5682572 100644 --- a/drawinglayer/source/tools/emfpbrush.cxx +++ b/drawinglayer/source/tools/emfpbrush.cxx @@ -200,7 +200,7 @@ namespace emfplushelper if (additionalFlags & 0x02) { SAL_INFO("cppcanvas.emf", "EMF+\tuse transformation"); - readXForm(s, brush_transformation); + rR.readXForm(s, brush_transformation); hasTransformation = true; SAL_INFO("cppcanvas.emf", "EMF+\tm11: " << brush_transformation.get(0,0) << " m12: " << brush_transformation.get(1,0) << @@ -273,7 +273,7 @@ namespace emfplushelper if (additionalFlags & 0x02) { SAL_INFO("cppcanvas.emf", "EMF+\tuse transformation"); - readXForm(s, brush_transformation); + rR.readXForm(s, brush_transformation); hasTransformation = true; SAL_INFO("cppcanvas.emf", "EMF+\tm11: " << brush_transformation.get(0,0) << " m12: " << brush_transformation.get(1,0) << diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index cbce6d32efb0..fcab2bbd7a44 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -80,78 +80,43 @@ namespace emfplushelper { } - bool readXForm(SvStream& rIn, basegfx::B2DHomMatrix& rTarget) - { - rTarget.identity(); - - if (sizeof(float) != 4) - { - OSL_FAIL("EnhWMFReader::sizeof( float ) != 4"); - return false; - } - else - { - float eM11(0.0); - float eM12(0.0); - float eM21(0.0); - float eM22(0.0); - float eDx(0.0); - float eDy(0.0); -#ifdef OSL_BIGENDIAN - eM11 = GetSwapFloat(rIn); - eM12 = GetSwapFloat(rIn); - eM21 = GetSwapFloat(rIn); - eM22 = GetSwapFloat(rIn); - eDx = GetSwapFloat(rIn); - eDy = GetSwapFloat(rIn); -#else - rIn.ReadFloat(eM11).ReadFloat(eM12).ReadFloat(eM21).ReadFloat(eM22).ReadFloat(eDx).ReadFloat(eDy); -#endif - rTarget = basegfx::B2DHomMatrix( - eM11, eM21, eDx, - eM12, eM22, eDy); - } - - return true; - } - - OutDevState::OutDevState() : - clip(), - clipRect(), - xClipPoly(), - - lineColor(), - fillColor(), - textColor(), - textFillColor(), - textLineColor(), - - xFont(), - transform(), - mapModeTransform(), - fontRotation(0.0), - - textEmphasisMarkStyle(FontEmphasisMark::NONE), - pushFlags(PushFlags::ALL), - textDirection(css::rendering::TextDirection::WEAK_LEFT_TO_RIGHT), - textAlignment(0), // TODO(Q2): Synchronize with implrenderer - // and possibly new rendering::TextAlignment - textReliefStyle(FontRelief::NONE), - textOverlineStyle(LINESTYLE_NONE), - textUnderlineStyle(LINESTYLE_NONE), - textStrikeoutStyle(STRIKEOUT_NONE), - textReferencePoint(ALIGN_BASELINE), - - isTextOutlineModeSet(false), - isTextEffectShadowSet(false), - isTextWordUnderlineSet(false), - - isLineColorSet(false), - isFillColorSet(false), - isTextFillColorSet(false), - isTextLineColorSet(false) - { - } +// OutDevState::OutDevState() : +// clip(), +// clipRect(), +// xClipPoly(), +// +// lineColor(), +// fillColor(), +// textColor(), +// textFillColor(), +// textLineColor(), +// +// xFont(), +// transform(), +// mapModeTransform(), +// fontRotation(0.0), +// +// textEmphasisMarkStyle(FontEmphasisMark::NONE), +// pushFlags(PushFlags::ALL), +// textDirection(css::rendering::TextDirection::WEAK_LEFT_TO_RIGHT), +// textAlignment(0), // TODO(Q2): Synchronize with implrenderer +// // and possibly new rendering::TextAlignment +// textReliefStyle(FontRelief::NONE), +// textOverlineStyle(LINESTYLE_NONE), +// textUnderlineStyle(LINESTYLE_NONE), +// textStrikeoutStyle(STRIKEOUT_NONE), +// textReferencePoint(ALIGN_BASELINE), +// +// isTextOutlineModeSet(false), +// isTextEffectShadowSet(false), +// isTextWordUnderlineSet(false), +// +// isLineColorSet(false), +// isFillColorSet(false), +// isTextFillColorSet(false), +// isTextLineColorSet(false) +// { +// } void EmfPlusHelperData::processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_uInt32 dataSize, bool bUseWholeStream) { @@ -159,28 +124,24 @@ namespace emfplushelper SAL_INFO("cppcanvas.emf", "EMF+ Object slot: " << (flags & 0xff) << " flags: " << (flags & 0xff00)); index = flags & 0xff; - if (aObjects[index] != nullptr) + switch (flags & 0x7f00) { - delete aObjects[index]; - aObjects[index] = nullptr; - } - - switch (flags & 0x7f00) { case EmfPlusObjectTypeBrush: { EMFPBrush *brush; - aObjects[index] = brush = new EMFPBrush(); + aObjects[index].reset(brush = new EMFPBrush()); brush->Read(rObjectStream, *this); break; } case EmfPlusObjectTypePen: { EMFPPen *pen; - aObjects[index] = pen = new EMFPPen(); + aObjects[index].reset(pen = new EMFPPen()); pen->Read(rObjectStream, *this); break; } case EmfPlusObjectTypePath: + { sal_uInt32 header, pathFlags; sal_Int32 points; @@ -188,19 +149,21 @@ namespace emfplushelper SAL_INFO("cppcanvas.emf", "EMF+\tpath"); SAL_INFO("cppcanvas.emf", "EMF+\theader: 0x" << std::hex << header << " points: " << std::dec << points << " additional flags: 0x" << std::hex << pathFlags << std::dec); EMFPPath *path; - aObjects[index] = path = new EMFPPath(points); + aObjects[index].reset(path = new EMFPPath(points)); path->Read(rObjectStream, pathFlags, *this); break; - case EmfPlusObjectTypeRegion: { + } + case EmfPlusObjectTypeRegion: + { EMFPRegion *region; - aObjects[index] = region = new EMFPRegion(); + aObjects[index].reset(region = new EMFPRegion()); region->Read(rObjectStream); break; } case EmfPlusObjectTypeImage: { EMFPImage *image; - aObjects[index] = image = new EMFPImage; + aObjects[index].reset(image = new EMFPImage); image->type = 0; image->width = 0; image->height = 0; @@ -212,7 +175,7 @@ namespace emfplushelper case EmfPlusObjectTypeFont: { EMFPFont *font; - aObjects[index] = font = new EMFPFont; + aObjects[index].reset(font = new EMFPFont); font->emSize = 0; font->sizeUnit = 0; font->fontFlags = 0; @@ -222,7 +185,7 @@ namespace emfplushelper case EmfPlusObjectTypeStringFormat: { EMFPStringFormat *stringFormat; - aObjects[index] = stringFormat = new EMFPStringFormat(); + aObjects[index].reset(stringFormat = new EMFPStringFormat()); stringFormat->Read(rObjectStream); break; } @@ -286,6 +249,41 @@ namespace emfplushelper } } + bool EmfPlusHelperData::readXForm(SvStream& rIn, basegfx::B2DHomMatrix& rTarget) + { + rTarget.identity(); + + if (sizeof(float) != 4) + { + OSL_FAIL("EnhWMFReader::sizeof( float ) != 4"); + return false; + } + else + { + float eM11(0.0); + float eM12(0.0); + float eM21(0.0); + float eM22(0.0); + float eDx(0.0); + float eDy(0.0); +#ifdef OSL_BIGENDIAN + eM11 = GetSwapFloat(rIn); + eM12 = GetSwapFloat(rIn); + eM21 = GetSwapFloat(rIn); + eM22 = GetSwapFloat(rIn); + eDx = GetSwapFloat(rIn); + eDy = GetSwapFloat(rIn); +#else + rIn.ReadFloat(eM11).ReadFloat(eM12).ReadFloat(eM21).ReadFloat(eM22).ReadFloat(eDx).ReadFloat(eDy); +#endif + rTarget = basegfx::B2DHomMatrix( + eM11, eM21, eDx, + eM12, eM22, eDy); + } + + return true; + } + void EmfPlusHelperData::MapToDevice(double& x, double& y) { // TODO: other units @@ -326,8 +324,11 @@ namespace emfplushelper return ::basegfx::B2DSize(w, h); } - EmfPlusHelperData::EmfPlusHelperData(SvMemoryStream& rMS) - : aBaseTransform(), + EmfPlusHelperData::EmfPlusHelperData( + SvMemoryStream& rMS, + wmfemfhelper::TargetHolders& rTargetHolders, + wmfemfhelper::PropertyHolders& rPropertyHolders) + : aBaseTransform(), aWorldTransform(), aObjects(), fPageScale(0.0), @@ -346,13 +347,11 @@ namespace emfplushelper mbMultipart(false), mMFlags(0), mMStream(), - mGSStack(), - mGSContainerStack(), - mpTargetHolders(nullptr), - mpPropertyHolders(nullptr) +// mGSStack(), +// mGSContainerStack(), + mrTargetHolders(rTargetHolders), + mrPropertyHolders(rPropertyHolders) { - memset(aObjects, 0, sizeof(aObjects)); - rMS.ReadInt32(mnFrameLeft).ReadInt32(mnFrameTop).ReadInt32(mnFrameRight).ReadInt32(mnFrameBottom); SAL_INFO("cppcanvas.emf", "EMF+ picture frame: " << mnFrameLeft << "," << mnFrameTop << " - " << mnFrameRight << "," << mnFrameBottom); rMS.ReadInt32(mnPixX).ReadInt32(mnPixY).ReadInt32(mnMmX).ReadInt32(mnMmY); @@ -360,6 +359,10 @@ namespace emfplushelper readXForm(rMS, aBaseTransform); } + EmfPlusHelperData::~EmfPlusHelperData() + { + } + void EmfPlusHelperData::processEmfPlusData( SvMemoryStream& rMS, const drawinglayer::geometry::ViewInformation2D& rViewInformation) @@ -426,26 +429,33 @@ namespace emfplushelper if (type != EmfPlusRecordTypeObject || !(flags & 0x8000)) { - switch (type) { + switch (type) + { case EmfPlusRecordTypeHeader: + { sal_uInt32 header, version; rMS.ReadUInt32(header).ReadUInt32(version).ReadInt32(nHDPI).ReadInt32(nVDPI); - SAL_INFO("cppcanvas.emf", "EMF+ Header"); SAL_INFO("cppcanvas.emf", "EMF+\theader: 0x" << std::hex << header << " version: " << std::dec << version << " horizontal DPI: " << nHDPI << " vertical DPI: " << nVDPI << " dual: " << (flags & 1)); - break; + } case EmfPlusRecordTypeEndOfFile: + { SAL_INFO("cppcanvas.emf", "EMF+ EndOfFile"); break; + } case EmfPlusRecordTypeGetDC: + { SAL_INFO("cppcanvas.emf", "EMF+ GetDC"); SAL_INFO("cppcanvas.emf", "EMF+\talready used in svtools wmf/emf filter parser"); break; + } case EmfPlusRecordTypeObject: + { processObjectRecord(rMS, flags, dataSize); break; + } case EmfPlusRecordTypeFillPie: case EmfPlusRecordTypeDrawPie: case EmfPlusRecordTypeDrawArc: @@ -468,36 +478,42 @@ namespace emfplushelper { SAL_INFO("cppcanvas.emf", "EMF+ DrawArc"); } - rMS.ReadFloat(startAngle).ReadFloat(sweepAngle); + rMS.ReadFloat(startAngle).ReadFloat(sweepAngle); float dx, dy, dw, dh; - ReadRectangle(rMS, dx, dy, dw, dh, bool(flags & 0x4000)); - SAL_INFO("cppcanvas.emf", "EMF+\t RectData: " << dx << "," << dy << " " << dw << "x" << dh); - startAngle = 2 * M_PI*startAngle / 360; sweepAngle = 2 * M_PI*sweepAngle / 360; - ::basegfx::B2DPoint mappedCenter(Map(dx + dw / 2, dy + dh / 2)); ::basegfx::B2DSize mappedSize(MapSize(dw / 2, dh / 2)); - float endAngle = startAngle + sweepAngle; startAngle = fmodf(startAngle, static_cast<float>(M_PI * 2)); - if (startAngle < 0) - startAngle += static_cast<float>(M_PI * 2); - endAngle = fmodf(endAngle, static_cast<float>(M_PI * 2)); - if (endAngle < 0) - endAngle += static_cast<float>(M_PI * 2); + + if (startAngle < 0.0) + { + startAngle += static_cast<float>(M_PI * 2.0); + } + + endAngle = fmodf(endAngle, static_cast<float>(M_PI * 2.0)); + + if (endAngle < 0.0) + { + endAngle += static_cast<float>(M_PI * 2.0); + } if (sweepAngle < 0) + { std::swap(endAngle, startAngle); + } SAL_INFO("cppcanvas.emf", "EMF+\t adjusted angles: start " << (360.0*startAngle / M_PI) << ", end: " << (360.0*endAngle / M_PI) << " startAngle: " << startAngle << " sweepAngle: " << sweepAngle); - ::basegfx::B2DPolygon polygon = basegfx::tools::createPolygonFromEllipseSegment(mappedCenter, mappedSize.getX(), mappedSize.getY(), startAngle, endAngle); + ::basegfx::B2DPolygon polygon = basegfx::tools::createPolygonFromEllipseSegment( + mappedCenter, mappedSize.getX(), mappedSize.getY(), startAngle, endAngle); + if (type != EmfPlusRecordTypeDrawArc) { polygon.append(mappedCenter); @@ -517,9 +533,7 @@ namespace emfplushelper { sal_uInt32 index = flags & 0xff; sal_uInt32 brushIndexOrColor; - rMS.ReadUInt32(brushIndexOrColor); - SAL_INFO("cppcanvas.emf", "EMF+ FillPath slot: " << index); // EMFPPlusFillPolygon(static_cast<EMFPPath*>(aObjects[index])->GetPolygon(*this), rFactoryParms, rState, rCanvas, flags & 0x8000, brushIndexOrColor); @@ -534,19 +548,19 @@ namespace emfplushelper sal_uInt32 brushIndexOrColor = 1234567; if (type == EmfPlusRecordTypeFillEllipse) + { rMS.ReadUInt32(brushIndexOrColor); + } SAL_INFO("cppcanvas.emf", "EMF+ " << (type == EmfPlusRecordTypeFillEllipse ? "Fill" : "Draw") << "Ellipse slot: " << (flags & 0xff)); - float dx, dy, dw, dh; - ReadRectangle(rMS, dx, dy, dw, dh, bool(flags & 0x4000)); - SAL_INFO("cppcanvas.emf", "EMF+ RectData: " << dx << "," << dy << " " << dw << "x" << dh); - ::basegfx::B2DPoint mappedCenter(Map(dx + dw / 2, dy + dh / 2)); ::basegfx::B2DSize mappedSize(MapSize(dw / 2, dh / 2)); - ::basegfx::B2DPolyPolygon polyPolygon(::basegfx::B2DPolygon(::basegfx::tools::createPolygonFromEllipse(mappedCenter, mappedSize.getX(), mappedSize.getY()))); + ::basegfx::B2DPolyPolygon polyPolygon( + ::basegfx::B2DPolygon( + ::basegfx::tools::createPolygonFromEllipse(mappedCenter, mappedSize.getX(), mappedSize.getY()))); // if (type == EmfPlusRecordTypeFillEllipse) // EMFPPlusFillPolygon(polyPolygon, @@ -565,7 +579,7 @@ namespace emfplushelper bool isColor = (flags & 0x8000); ::basegfx::B2DPolygon polygon; - if (type == EmfPlusRecordTypeFillRects) + if (EmfPlusRecordTypeFillRects == type) { SAL_INFO("cppcanvas.emf", "EMF+ FillRects"); rMS.ReadUInt32(brushIndexOrColor); @@ -578,7 +592,8 @@ namespace emfplushelper rMS.ReadInt32(rectangles); - for (int i = 0; i < rectangles; i++) { + for (int i = 0; i < rectangles; i++) + { float x, y, width, height; ReadRectangle(rMS, x, y, width, height, bool(flags & 0x4000)); @@ -608,7 +623,6 @@ namespace emfplushelper rMS.ReadUInt32(brushIndexOrColor); rMS.ReadInt32(points); - SAL_INFO("cppcanvas.emf", "EMF+ FillPolygon in slot: " << +index << " points: " << points); SAL_INFO("cppcanvas.emf", "EMF+\t: " << ((flags & 0x8000) ? "color" : "brush index") << " 0x" << std::hex << brushIndexOrColor << std::dec); @@ -622,11 +636,8 @@ namespace emfplushelper case EmfPlusRecordTypeDrawLines: { sal_uInt32 points; - rMS.ReadUInt32(points); - SAL_INFO("cppcanvas.emf", "EMF+ DrawLines in slot: " << (flags & 0xff) << " points: " << points); - EMFPPath path(points, true); path.Read(rMS, flags, *this); @@ -639,13 +650,10 @@ namespace emfplushelper case EmfPlusRecordTypeDrawPath: { sal_uInt32 penIndex; - rMS.ReadUInt32(penIndex); - SAL_INFO("cppcanvas.emf", "EMF+ DrawPath"); SAL_INFO("cppcanvas.emf", "EMF+\tpen: " << penIndex); - - EMFPPath* path = static_cast<EMFPPath*>(aObjects[flags & 0xff]); + EMFPPath* path = static_cast<EMFPPath*>(aObjects[flags & 0xff].get()); SAL_WARN_IF(!path, "cppcanvas.emf", "EmfPlusRecordTypeDrawPath missing path"); // EMFPPlusDrawPolygon(path->GetPolygon(*this), rFactoryParms, rState, rCanvas, penIndex); @@ -659,9 +667,7 @@ namespace emfplushelper ::basegfx::B2DPoint aStartPoint, aControlPointA, aControlPointB, aEndPoint; ::basegfx::B2DPolygon aPolygon; rMS.ReadUInt32(aCount); - SAL_INFO("cppcanvas.emf", "EMF+ DrawBeziers slot: " << (flags & 0xff) << "Number of points: " << aCount); - SAL_WARN_IF((aCount - 1) % 3 != 0, "cppcanvas.emf", "EMF+\t Bezier Draw not support number of points other than 4, 7, 10, 13, 16..."); if (aCount < 4) @@ -703,30 +709,30 @@ namespace emfplushelper { sal_uInt32 attrIndex; sal_Int32 sourceUnit; - rMS.ReadUInt32(attrIndex).ReadInt32(sourceUnit); - SAL_INFO("cppcanvas.emf", "EMF+ " << (type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage") << "attributes index: " << attrIndex << "source unit: " << sourceUnit); SAL_INFO("cppcanvas.emf", "EMF+\tTODO: use image attributes"); - if (sourceUnit == 2 && aObjects[flags & 0xff]) { // we handle only GraphicsUnit.Pixel now - EMFPImage& image = *static_cast<EMFPImage *>(aObjects[flags & 0xff]); + if (sourceUnit == 2 && aObjects[flags & 0xff].get()) + { + // we handle only GraphicsUnit.Pixel now + EMFPImage& image = *static_cast<EMFPImage *>(aObjects[flags & 0xff].get()); float sx, sy, sw, sh; sal_Int32 aCount; - ReadRectangle(rMS, sx, sy, sw, sh); ::tools::Rectangle aSource(Point(sx, sy), Size(sw, sh)); - SAL_INFO("cppcanvas.emf", "EMF+ " << (type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage") << " source rectangle: " << sx << "," << sy << " " << sw << "x" << sh); - ::basegfx::B2DPoint aDstPoint; ::basegfx::B2DSize aDstSize; bool bValid = false; - if (type == EmfPlusRecordTypeDrawImagePoints) { + if (type == EmfPlusRecordTypeDrawImagePoints) + { rMS.ReadInt32(aCount); - if (aCount == 3) { // TODO: now that we now that this value is count we should support it better + if (aCount == 3) + { + // TODO: now that we now that this value is count we should support it better float x1, y1, x2, y2, x3, y3; ReadPoint(rMS, x1, y1, flags); @@ -742,26 +748,24 @@ namespace emfplushelper bValid = true; } } - else if (type == EmfPlusRecordTypeDrawImage) { + else if (type == EmfPlusRecordTypeDrawImage) + { float dx, dy, dw, dh; - ReadRectangle(rMS, dx, dy, dw, dh, bool(flags & 0x4000)); - SAL_INFO("cppcanvas.emf", "EMF+ destination rectangle: " << dx << "," << dy << " " << dw << "x" << dh); - aDstPoint = Map(dx, dy); aDstSize = MapSize(dw, dh); - bValid = true; } - if (bValid) { + if (bValid) + { BitmapEx aBmp(image.graphic.GetBitmapEx()); aBmp.Crop(aSource); - Size aSize(aBmp.GetSizePixel()); SAL_INFO("cppcanvas.emf", "EMF+ bitmap size: " << aSize.Width() << "x" << aSize.Height()); - if (aSize.Width() > 0 && aSize.Height() > 0) { + if (aSize.Width() > 0 && aSize.Height() > 0) + { // ActionSharedPtr pBmpAction( // internal::BitmapActionFactory::createBitmapAction( // aBmp, @@ -777,15 +781,18 @@ namespace emfplushelper // rFactoryParms.mrCurrActionIndex += pBmpAction->getActionCount() - 1; // } } - else { + else + { SAL_INFO("cppcanvas.emf", "EMF+ warning: empty bitmap"); } } - else { + else + { SAL_WARN("cppcanvas.emf", "EMF+ DrawImage(Points) TODO (fixme)"); } } - else { + else + { SAL_WARN("cppcanvas.emf", "EMF+ DrawImage(Points) TODO (fixme) - possibly unsupported source units for crop rectangle"); } break; @@ -793,31 +800,28 @@ namespace emfplushelper case EmfPlusRecordTypeDrawString: { SAL_INFO("cppcanvas.emf", "EMF+ DrawString"); - sal_uInt32 brushId; sal_uInt32 formatId; sal_uInt32 stringLength; - rMS.ReadUInt32(brushId).ReadUInt32(formatId).ReadUInt32(stringLength); SAL_INFO("cppcanvas.emf", "EMF+ DrawString brushId: " << brushId << " formatId: " << formatId << " length: " << stringLength); - if (flags & 0x8000) { + if (flags & 0x8000) + { float lx, ly, lw, lh; - rMS.ReadFloat(lx).ReadFloat(ly).ReadFloat(lw).ReadFloat(lh); - SAL_INFO("cppcanvas.emf", "EMF+ DrawString layoutRect: " << lx << "," << ly << " - " << lw << "x" << lh); - OUString text = read_uInt16s_ToOUString(rMS, stringLength); - - EMFPStringFormat *stringFormat = static_cast< EMFPStringFormat* >(aObjects[formatId & 0xff]); + EMFPStringFormat *stringFormat = static_cast< EMFPStringFormat* >(aObjects[formatId & 0xff].get()); css::rendering::FontRequest aFontRequest; + if (stringFormat) { LanguageTag aLanguageTag(static_cast< LanguageType >(stringFormat->language)); aFontRequest.Locale = aLanguageTag.getLocale(false); SAL_INFO("cppcanvas.emf", "EMF+\t\t Font locale, Country:" << aLanguageTag.getCountry() << " Language:" << aLanguageTag.getLanguage()); } + SAL_INFO("cppcanvas.emf", "EMF+\t\t TODO Use all string formatting attributes during drawing"); // double cellSize = setFont(aFontRequest, flags & 0xff, rFactoryParms, rState); @@ -855,59 +859,70 @@ namespace emfplushelper // rFactoryParms.mrCurrActionIndex += pTextAction->getActionCount() - 1; // } } - else { + else + { SAL_WARN("cppcanvas.emf", "EMF+ DrawString TODO - drawing with brush not yet supported"); } + break; } - break; - case EmfPlusRecordTypeSetPageTransform: { rMS.ReadFloat(fPageScale); - SAL_INFO("cppcanvas.emf", "EMF+ SetPageTransform"); SAL_INFO("cppcanvas.emf", "EMF+\tscale: " << fPageScale << " unit: " << flags); if (flags != UnitTypePixel) + { SAL_WARN("cppcanvas.emf", "EMF+\t TODO Only UnitTypePixel is supported. "); + } else { mnMmX *= fPageScale; mnMmY *= fPageScale; } + break; } - break; case EmfPlusRecordTypeSetRenderingOrigin: + { rMS.ReadInt32(nOriginX).ReadInt32(nOriginY); SAL_INFO("cppcanvas.emf", "EMF+ SetRenderingOrigin"); SAL_INFO("cppcanvas.emf", "EMF+\torigin [x,y]: " << nOriginX << "," << nOriginY); break; + } case EmfPlusRecordTypeSetTextRenderingHint: + { SAL_INFO("cppcanvas.emf", "EMF+ SetTextRenderingHint"); SAL_INFO("cppcanvas.emf", "EMF+\tTODO"); break; + } case EmfPlusRecordTypeSetAntiAliasMode: + { SAL_INFO("cppcanvas.emf", "EMF+ SetAntiAliasMode"); SAL_INFO("cppcanvas.emf", "EMF+\tTODO"); break; + } case EmfPlusRecordTypeSetInterpolationMode: + { SAL_INFO("cppcanvas.emf", "EMF+ InterpolationMode"); SAL_INFO("cppcanvas.emf", "EMF+\tTODO"); break; + } case EmfPlusRecordTypeSetPixelOffsetMode: + { SAL_INFO("cppcanvas.emf", "EMF+ SetPixelOffsetMode"); SAL_INFO("cppcanvas.emf", "EMF+\tTODO"); break; + } case EmfPlusRecordTypeSetCompositingQuality: + { SAL_INFO("cppcanvas.emf", "EMF+ SetCompositingQuality"); SAL_INFO("cppcanvas.emf", "EMF+\tTODO"); break; + } case EmfPlusRecordTypeSave: { sal_uInt32 stackIndex; - rMS.ReadUInt32(stackIndex); - SAL_INFO("cppcanvas.emf", "EMF+ Save stack index: " << stackIndex); // GraphicStatePush(mGSStack, stackIndex, rState); @@ -917,9 +932,7 @@ namespace emfplushelper case EmfPlusRecordTypeRestore: { sal_uInt32 stackIndex; - rMS.ReadUInt32(stackIndex); - SAL_INFO("cppcanvas.emf", "EMF+ Restore stack index: " << stackIndex); // GraphicStatePop(mGSStack, stackIndex, rState); @@ -929,26 +942,23 @@ namespace emfplushelper case EmfPlusRecordTypeBeginContainerNoParams: { sal_uInt32 stackIndex; - rMS.ReadUInt32(stackIndex); - SAL_INFO("cppcanvas.emf", "EMF+ Begin Container No Params stack index: " << stackIndex); // GraphicStatePush(mGSContainerStack, stackIndex, rState); + break; } - break; case EmfPlusRecordTypeEndContainer: { sal_uInt32 stackIndex; - rMS.ReadUInt32(stackIndex); - SAL_INFO("cppcanvas.emf", "EMF+ End Container stack index: " << stackIndex); // GraphicStatePop(mGSContainerStack, stackIndex, rState); + break; } - break; - case EmfPlusRecordTypeSetWorldTransform: { + case EmfPlusRecordTypeSetWorldTransform: + { SAL_INFO("cppcanvas.emf", "EMF+ SetWorldTransform"); basegfx::B2DHomMatrix transform; readXForm(rMS, transform); @@ -960,10 +970,13 @@ namespace emfplushelper break; } case EmfPlusRecordTypeResetWorldTransform: + { SAL_INFO("cppcanvas.emf", "EMF+ ResetWorldTransform"); aWorldTransform.identity(); break; - case EmfPlusRecordTypeMultiplyWorldTransform: { + } + case EmfPlusRecordTypeMultiplyWorldTransform: + { SAL_INFO("cppcanvas.emf", "EMF+ MultiplyWorldTransform"); basegfx::B2DHomMatrix transform; readXForm(rMS, transform); @@ -997,7 +1010,6 @@ namespace emfplushelper basegfx::B2DHomMatrix transform; float eDx, eDy; - rMS.ReadFloat(eDx).ReadFloat(eDy); transform.set(0, 2, eDx); transform.set(1, 2, eDy); @@ -1029,13 +1041,11 @@ namespace emfplushelper { basegfx::B2DHomMatrix transform; float eM11, eM22; - rMS.ReadFloat(eM11).ReadFloat(eM22); transform.set(0, 0, eM11); transform.set(1, 1, eM22); SAL_INFO("cppcanvas.emf", "EMF+ ScaleWorldTransform Sx: " << transform.get(0,0) << " Sy: " << transform.get(1,1)); - SAL_INFO("cppcanvas.emf", "EMF+\t m11: " << aWorldTransform.get(0,0) << ", m12: " << aWorldTransform.get(0,1) << "EMF+\t m21: " << aWorldTransform.get(1,0) << ", m22: " << aWorldTransform.get(1,1) << @@ -1071,93 +1081,100 @@ namespace emfplushelper #endif float dx, dy, dw, dh; - ReadRectangle(rMS, dx, dy, dw, dh); - SAL_INFO("cppcanvas.emf", "EMF+ RectData: " << dx << "," << dy << " " << dw << "x" << dh); - ::basegfx::B2DPoint mappedPoint(Map(dx, dy)); ::basegfx::B2DSize mappedSize(MapSize(dw, dh)); - ::basegfx::B2DPolyPolygon polyPolygon(::basegfx::B2DPolygon(::basegfx::tools::createPolygonFromRect(::basegfx::B2DRectangle(mappedPoint.getX(), mappedPoint.getY(), - mappedPoint.getX() + mappedSize.getX(), - mappedPoint.getY() + mappedSize.getY())))); + ::basegfx::B2DPolyPolygon polyPolygon( + ::basegfx::B2DPolygon( + ::basegfx::tools::createPolygonFromRect(::basegfx::B2DRectangle( + mappedPoint.getX(), + mappedPoint.getY(), + mappedPoint.getX() + mappedSize.getX(), + mappedPoint.getY() + mappedSize.getY())))); // polyPolygon.transform(rState.mapModeTransform); // // updateClipping(polyPolygon, rFactoryParms, combineMode == 1); - break; } case EmfPlusRecordTypeSetClipPath: { int combineMode = (flags >> 8) & 0xf; - SAL_INFO("cppcanvas.emf", "EMF+ SetClipPath combine mode: " << combineMode); SAL_INFO("cppcanvas.emf", "EMF+\tpath in slot: " << (flags & 0xff)); - EMFPPath& path = *static_cast<EMFPPath*>(aObjects[flags & 0xff]); + EMFPPath& path = *static_cast<EMFPPath*>(aObjects[flags & 0xff].get()); ::basegfx::B2DPolyPolygon& clipPoly(path.GetPolygon(*this)); - // clipPoly.transform(rState.mapModeTransform); + switch (combineMode) { - case EmfPlusCombineModeReplace: - case EmfPlusCombineModeIntersect: - case EmfPlusCombineModeUnion: // Is this, EmfPlusCombineModeXOR and EmfPlusCombineModeComplement correct? - case EmfPlusCombineModeXOR: - case EmfPlusCombineModeComplement: -// updateClipping(clipPoly, rFactoryParms, combineMode == 1); - break; - case EmfPlusCombineModeExclude: - // Not doing anything is better then including exactly what we wanted to exclude. - break; + case EmfPlusCombineModeReplace: + case EmfPlusCombineModeIntersect: + case EmfPlusCombineModeUnion: // Is this, EmfPlusCombineModeXOR and EmfPlusCombineModeComplement correct? + case EmfPlusCombineModeXOR: + case EmfPlusCombineModeComplement: + { + // updateClipping(clipPoly, rFactoryParms, combineMode == 1); + break; + } + case EmfPlusCombineModeExclude: + { + // Not doing anything is better then including exactly what we wanted to exclude. + break; + } } break; } - case EmfPlusRecordTypeSetClipRegion: { + case EmfPlusRecordTypeSetClipRegion: + { int combineMode = (flags >> 8) & 0xf; - SAL_INFO("cppcanvas.emf", "EMF+ SetClipRegion"); SAL_INFO("cppcanvas.emf", "EMF+\tregion in slot: " << (flags & 0xff) << " combine mode: " << combineMode); - EMFPRegion *region = static_cast<EMFPRegion*>(aObjects[flags & 0xff]); + EMFPRegion *region = static_cast<EMFPRegion*>(aObjects[flags & 0xff].get()); // reset clip - if (region && region->parts == 0 && region->initialState == EmfPlusRegionInitialStateInfinite) { + if (region && region->parts == 0 && region->initialState == EmfPlusRegionInitialStateInfinite) + { // updateClipping(::basegfx::B2DPolyPolygon(), rFactoryParms, combineMode == 1); } - else { + else + { SAL_INFO("cppcanvas.emf", "EMF+\tTODO"); } break; } - case EmfPlusRecordTypeDrawDriverString: { + case EmfPlusRecordTypeDrawDriverString: + { SAL_INFO("cppcanvas.emf", "EMF+ DrawDriverString, flags: 0x" << std::hex << flags << std::dec); sal_uInt32 brushIndexOrColor; sal_uInt32 optionFlags; sal_uInt32 hasMatrix; sal_uInt32 glyphsCount; - rMS.ReadUInt32(brushIndexOrColor).ReadUInt32(optionFlags).ReadUInt32(hasMatrix).ReadUInt32(glyphsCount); - SAL_INFO("cppcanvas.emf", "EMF+\t: " << ((flags & 0x8000) ? "color" : "brush index") << " 0x" << std::hex << brushIndexOrColor << std::dec); SAL_INFO("cppcanvas.emf", "EMF+\toption flags: 0x" << std::hex << optionFlags << std::dec); SAL_INFO("cppcanvas.emf", "EMF+\thas matrix: " << hasMatrix); SAL_INFO("cppcanvas.emf", "EMF+\tglyphs: " << glyphsCount); - if ((optionFlags & 1) && glyphsCount > 0) { + if ((optionFlags & 1) && glyphsCount > 0) + { std::unique_ptr<float[]> charsPosX(new float[glyphsCount]); std::unique_ptr<float[]> charsPosY(new float[glyphsCount]); - OUString text = read_uInt16s_ToOUString(rMS, glyphsCount); - for (sal_uInt32 i = 0; i<glyphsCount; i++) { + for (sal_uInt32 i = 0; i<glyphsCount; i++) + { rMS.ReadFloat(charsPosX[i]).ReadFloat(charsPosY[i]); SAL_INFO("cppcanvas.emf", "EMF+\tglyphPosition[" << i << "]: " << charsPosX[i] << "," << charsPosY[i]); } basegfx::B2DHomMatrix transform; - if (hasMatrix) { + + if (hasMatrix) + { readXForm(rMS, transform); SAL_INFO("cppcanvas.emf", "EMF+\tmatrix: " << transform.get(0,0) << ", " << transform.get(1,0) << ", " << transform.get(0,1) << ", " << transform.get(1,1) << @@ -1202,15 +1219,17 @@ namespace emfplushelper // rFactoryParms.mrCurrActionIndex += pTextAction->getActionCount() - 1; // } } - else { + else + { SAL_WARN("cppcanvas.emf", "EMF+\tTODO: fonts (non-unicode glyphs chars)"); } - break; } default: + { SAL_WARN("cppcanvas.emf", "EMF+ TODO unhandled record type: 0x" << std::hex << type << std::dec); } + } } rMS.Seek(next); diff --git a/drawinglayer/source/tools/emfphelperdata.hxx b/drawinglayer/source/tools/emfphelperdata.hxx index 6b9084cbdd9d..f4920fb9d3e5 100644 --- a/drawinglayer/source/tools/emfphelperdata.hxx +++ b/drawinglayer/source/tools/emfphelperdata.hxx @@ -21,83 +21,82 @@ #define INCLUDED_DRAWINGLAYER_SOURCE_TOOLS_EMFPHELPERDATA_HXX #include <emfplushelper.hxx> -#include <com/sun/star/rendering/XCanvasFont.hpp> -#include <com/sun/star/rendering/TextDirection.hpp> -//#include <emfpbrush.hxx> +//#include <com/sun/star/rendering/XCanvasFont.hpp> +//#include <com/sun/star/rendering/TextDirection.hpp> namespace emfplushelper { - // EMF+ commands -#define EmfPlusRecordTypeHeader 0x4001 -#define EmfPlusRecordTypeEndOfFile 0x4002 - //TODO EmfPlusRecordTypeComment 0x4003 -#define EmfPlusRecordTypeGetDC 0x4004 - //TODO EmfPlusRecordTypeMultiFormatStart 0x4005 - //TODO EmfPlusRecordTypeMultiFormatSection 0x4006 - //TODO EmfPlusRecordTypeMultiFormatEnd 0x4007 -#define EmfPlusRecordTypeObject 0x4008 - //TODO EmfPlusRecordTypeClear 0x4009 -#define EmfPlusRecordTypeFillRects 0x400A -#define EmfPlusRecordTypeDrawRects 0x400B -#define EmfPlusRecordTypeFillPolygon 0x400C -#define EmfPlusRecordTypeDrawLines 0x400D -#define EmfPlusRecordTypeFillEllipse 0x400E -#define EmfPlusRecordTypeDrawEllipse 0x400F -#define EmfPlusRecordTypeFillPie 0x4010 -#define EmfPlusRecordTypeDrawPie 0x4011 -#define EmfPlusRecordTypeDrawArc 0x4012 - //TODO EmfPlusRecordTypeFillRegion 0x4013 -#define EmfPlusRecordTypeFillPath 0x4014 -#define EmfPlusRecordTypeDrawPath 0x4015 - //TODO EmfPlusRecordTypeFillClosedCurve 0x4016 - //TODO EmfPlusRecordTypeDrawClosedCurve 0x4017 - //TODO EmfPlusRecordTypeDrawCurve 0x4018 -#define EmfPlusRecordTypeDrawBeziers 0x4019 -#define EmfPlusRecordTypeDrawImage 0x401A -#define EmfPlusRecordTypeDrawImagePoints 0x401B -#define EmfPlusRecordTypeDrawString 0x401C -#define EmfPlusRecordTypeSetRenderingOrigin 0x401D -#define EmfPlusRecordTypeSetAntiAliasMode 0x401E -#define EmfPlusRecordTypeSetTextRenderingHint 0x401F -#define EmfPlusRecordTypeSetInterpolationMode 0x4021 -#define EmfPlusRecordTypeSetPixelOffsetMode 0x4022 - //TODO EmfPlusRecordTypeSetCompositingMode 0x4023 -#define EmfPlusRecordTypeSetCompositingQuality 0x4024 -#define EmfPlusRecordTypeSave 0x4025 -#define EmfPlusRecordTypeRestore 0x4026 - //TODO EmfPlusRecordTypeBeginContainer 0x4027 -#define EmfPlusRecordTypeBeginContainerNoParams 0x4028 -#define EmfPlusRecordTypeEndContainer 0x4029 -#define EmfPlusRecordTypeSetWorldTransform 0x402A -#define EmfPlusRecordTypeResetWorldTransform 0x402B -#define EmfPlusRecordTypeMultiplyWorldTransform 0x402C -#define EmfPlusRecordTypeTranslateWorldTransform 0x402D -#define EmfPlusRecordTypeScaleWorldTransform 0x402E - //TODO EmfPlusRecordTypeRotateWorldTransform 0x402F -#define EmfPlusRecordTypeSetPageTransform 0x4030 - //TODO EmfPlusRecordTypeResetClip 0x4031 -#define EmfPlusRecordTypeSetClipRect 0x4032 -#define EmfPlusRecordTypeSetClipPath 0x4033 -#define EmfPlusRecordTypeSetClipRegion 0x4034 - //TODO EmfPlusRecordTypeOffsetClip 0x4035 -#define EmfPlusRecordTypeDrawDriverString 0x4036 - //TODO EmfPlusRecordTypeStrokeFillPath 0x4037 - //TODO EmfPlusRecordTypeSerializableObject 0x4038 - //TODO EmfPlusRecordTypeSetTSGraphics 0x4039 - //TODO EmfPlusRecordTypeSetTSClip 0x403A - - // EMF+object types -#define EmfPlusObjectTypeBrush 0x100 -#define EmfPlusObjectTypePen 0x200 -#define EmfPlusObjectTypePath 0x300 -#define EmfPlusObjectTypeRegion 0x400 -#define EmfPlusObjectTypeImage 0x500 -#define EmfPlusObjectTypeFont 0x600 -#define EmfPlusObjectTypeStringFormat 0x700 -#define EmfPlusObjectTypeImageAttributes 0x800 -#define EmfPlusObjectTypeCustomLineCap 0x900 - -#define EmfPlusRegionInitialStateInfinite 0x10000003 + // EMF+ commands + #define EmfPlusRecordTypeHeader 0x4001 + #define EmfPlusRecordTypeEndOfFile 0x4002 + //TODO EmfPlusRecordTypeComment 0x4003 + #define EmfPlusRecordTypeGetDC 0x4004 + //TODO EmfPlusRecordTypeMultiFormatStart 0x4005 + //TODO EmfPlusRecordTypeMultiFormatSection 0x4006 + //TODO EmfPlusRecordTypeMultiFormatEnd 0x4007 + #define EmfPlusRecordTypeObject 0x4008 + //TODO EmfPlusRecordTypeClear 0x4009 + #define EmfPlusRecordTypeFillRects 0x400A + #define EmfPlusRecordTypeDrawRects 0x400B + #define EmfPlusRecordTypeFillPolygon 0x400C + #define EmfPlusRecordTypeDrawLines 0x400D + #define EmfPlusRecordTypeFillEllipse 0x400E + #define EmfPlusRecordTypeDrawEllipse 0x400F + #define EmfPlusRecordTypeFillPie 0x4010 + #define EmfPlusRecordTypeDrawPie 0x4011 + #define EmfPlusRecordTypeDrawArc 0x4012 + //TODO EmfPlusRecordTypeFillRegion 0x4013 + #define EmfPlusRecordTypeFillPath 0x4014 + #define EmfPlusRecordTypeDrawPath 0x4015 + //TODO EmfPlusRecordTypeFillClosedCurve 0x4016 + //TODO EmfPlusRecordTypeDrawClosedCurve 0x4017 + //TODO EmfPlusRecordTypeDrawCurve 0x4018 + #define EmfPlusRecordTypeDrawBeziers 0x4019 + #define EmfPlusRecordTypeDrawImage 0x401A + #define EmfPlusRecordTypeDrawImagePoints 0x401B + #define EmfPlusRecordTypeDrawString 0x401C + #define EmfPlusRecordTypeSetRenderingOrigin 0x401D + #define EmfPlusRecordTypeSetAntiAliasMode 0x401E + #define EmfPlusRecordTypeSetTextRenderingHint 0x401F + #define EmfPlusRecordTypeSetInterpolationMode 0x4021 + #define EmfPlusRecordTypeSetPixelOffsetMode 0x4022 + //TODO EmfPlusRecordTypeSetCompositingMode 0x4023 + #define EmfPlusRecordTypeSetCompositingQuality 0x4024 + #define EmfPlusRecordTypeSave 0x4025 + #define EmfPlusRecordTypeRestore 0x4026 + //TODO EmfPlusRecordTypeBeginContainer 0x4027 + #define EmfPlusRecordTypeBeginContainerNoParams 0x4028 + #define EmfPlusRecordTypeEndContainer 0x4029 + #define EmfPlusRecordTypeSetWorldTransform 0x402A + #define EmfPlusRecordTypeResetWorldTransform 0x402B + #define EmfPlusRecordTypeMultiplyWorldTransform 0x402C + #define EmfPlusRecordTypeTranslateWorldTransform 0x402D + #define EmfPlusRecordTypeScaleWorldTransform 0x402E + //TODO EmfPlusRecordTypeRotateWorldTransform 0x402F + #define EmfPlusRecordTypeSetPageTransform 0x4030 + //TODO EmfPlusRecordTypeResetClip 0x4031 + #define EmfPlusRecordTypeSetClipRect 0x4032 + #define EmfPlusRecordTypeSetClipPath 0x4033 + #define EmfPlusRecordTypeSetClipRegion 0x4034 + //TODO EmfPlusRecordTypeOffsetClip 0x4035 + #define EmfPlusRecordTypeDrawDriverString 0x4036 + //TODO EmfPlusRecordTypeStrokeFillPath 0x4037 + //TODO EmfPlusRecordTypeSerializableObject 0x4038 + //TODO EmfPlusRecordTypeSetTSGraphics 0x4039 + //TODO EmfPlusRecordTypeSetTSClip 0x403A + + // EMF+object types + #define EmfPlusObjectTypeBrush 0x100 + #define EmfPlusObjectTypePen 0x200 + #define EmfPlusObjectTypePath 0x300 + #define EmfPlusObjectTypeRegion 0x400 + #define EmfPlusObjectTypeImage 0x500 + #define EmfPlusObjectTypeFont 0x600 + #define EmfPlusObjectTypeStringFormat 0x700 + #define EmfPlusObjectTypeImageAttributes 0x800 + #define EmfPlusObjectTypeCustomLineCap 0x900 + + #define EmfPlusRegionInitialStateInfinite 0x10000003 enum UnitType { @@ -126,71 +125,65 @@ namespace emfplushelper virtual ~EMFPObject(); }; - bool readXForm(SvStream& rIn, basegfx::B2DHomMatrix& rTarget); - void readRectangle(SvStream& s, float& x, float& y, float &width, float& height, bool bCompressed); - - struct OutDevState - { - OutDevState(); - - ::basegfx::B2DPolyPolygon clip; - ::tools::Rectangle clipRect; - css::uno::Reference< css::rendering::XPolyPolygon2D > xClipPoly; - - css::uno::Sequence< double > lineColor; - css::uno::Sequence< double > fillColor; - css::uno::Sequence< double > textColor; - css::uno::Sequence< double > textFillColor; - css::uno::Sequence< double > textLineColor; - - /** Current font. - - @attention Beware, this member can be NULL, and - nevertheless text output is generated. - */ - css::uno::Reference< css::rendering::XCanvasFont > xFont; - ::basegfx::B2DHomMatrix transform; - ::basegfx::B2DHomMatrix mapModeTransform; - double fontRotation; - - FontEmphasisMark textEmphasisMarkStyle; - PushFlags pushFlags; - sal_Int8 textDirection; - sal_Int8 textAlignment; - FontRelief textReliefStyle; - sal_Int8 textOverlineStyle; - sal_Int8 textUnderlineStyle; - sal_Int8 textStrikeoutStyle; - TextAlign textReferencePoint; - - bool isTextOutlineModeSet; - bool isTextEffectShadowSet; - bool isTextWordUnderlineSet; - - bool isLineColorSet; - bool isFillColorSet; - bool isTextFillColorSet; - bool isTextLineColorSet; - }; - - typedef struct - { - basegfx::B2DHomMatrix aWorldTransform; - OutDevState aDevState; - } EmfPlusGraphicState; - - typedef std::map<int, EmfPlusGraphicState> GraphicStateMap; +// struct OutDevState +// { +// OutDevState(); +// +// ::basegfx::B2DPolyPolygon clip; +// ::tools::Rectangle clipRect; +// css::uno::Reference< css::rendering::XPolyPolygon2D > xClipPoly; +// +// css::uno::Sequence< double > lineColor; +// css::uno::Sequence< double > fillColor; +// css::uno::Sequence< double > textColor; +// css::uno::Sequence< double > textFillColor; +// css::uno::Sequence< double > textLineColor; +// +// /** Current font. +// +// @attention Beware, this member can be NULL, and +// nevertheless text output is generated. +// */ +// css::uno::Reference< css::rendering::XCanvasFont > xFont; +// ::basegfx::B2DHomMatrix transform; +// ::basegfx::B2DHomMatrix mapModeTransform; +// double fontRotation; +// +// FontEmphasisMark textEmphasisMarkStyle; +// PushFlags pushFlags; +// sal_Int8 textDirection; +// sal_Int8 textAlignment; +// FontRelief textReliefStyle; +// sal_Int8 textOverlineStyle; +// sal_Int8 textUnderlineStyle; +// sal_Int8 textStrikeoutStyle; +// TextAlign textReferencePoint; +// +// bool isTextOutlineModeSet; +// bool isTextEffectShadowSet; +// bool isTextWordUnderlineSet; +// +// bool isLineColorSet; +// bool isFillColorSet; +// bool isTextFillColorSet; +// bool isTextLineColorSet; +// }; + +// typedef struct +// { +// basegfx::B2DHomMatrix aWorldTransform; +// OutDevState aDevState; +// } EmfPlusGraphicState; +// +// typedef std::map<int, EmfPlusGraphicState> GraphicStateMap; struct EmfPlusHelperData { private: - // allow setTargetHolders/setPropertyHolders call from there - friend class EmfPlusHelper; - /* EMF+ */ basegfx::B2DHomMatrix aBaseTransform; basegfx::B2DHomMatrix aWorldTransform; - EMFPObject* aObjects[256]; + std::unique_ptr<EMFPObject> aObjects[256]; float fPageScale; sal_Int32 nOriginX; sal_Int32 nOriginY; @@ -213,37 +206,42 @@ namespace emfplushelper SvMemoryStream mMStream; /* emf+ graphic state stack */ - GraphicStateMap mGSStack; - GraphicStateMap mGSContainerStack; +// GraphicStateMap mGSStack; +// GraphicStateMap mGSContainerStack; /// data holders - wmfemfhelper::TargetHolders* mpTargetHolders; - wmfemfhelper::PropertyHolders* mpPropertyHolders; + wmfemfhelper::TargetHolders& mrTargetHolders; + wmfemfhelper::PropertyHolders& mrPropertyHolders; + // readers void processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_uInt32 dataSize, bool bUseWholeStream = false); void ReadPoint(SvStream& s, float& x, float& y, sal_uInt32 flags); - void ReadRectangle(SvStream& s, float& x, float& y, float &width, float& height, bool bCompressed = false); + // internal mapper void MapToDevice(double& x, double& y); - public: - ::basegfx::B2DPoint Map(double ix, double iy); - ::basegfx::B2DSize MapSize(double iwidth, double iheight); - private: - - // to set data holders from EmfPlusHelper - void setTargetHolders(wmfemfhelper::TargetHolders& rTargetHolders) { mpTargetHolders = &rTargetHolders; } - void setPropertyHolders(wmfemfhelper::PropertyHolders& rPropertyHolders) { mpPropertyHolders = &rPropertyHolders; } public: - EmfPlusHelperData(SvMemoryStream& rMS); + EmfPlusHelperData( + SvMemoryStream& rMS, + wmfemfhelper::TargetHolders& rTargetHolders, + wmfemfhelper::PropertyHolders& rPropertyHolders); + ~EmfPlusHelperData(); void processEmfPlusData( SvMemoryStream& rMS, const drawinglayer::geometry::ViewInformation2D& rViewInformation); + // mappers + ::basegfx::B2DPoint Map(double ix, double iy); + ::basegfx::B2DSize MapSize(double iwidth, double iheight); + + // readers + void ReadRectangle(SvStream& s, float& x, float& y, float &width, float& height, bool bCompressed = false); + bool readXForm(SvStream& rIn, basegfx::B2DHomMatrix& rTarget); + /// data holders access - wmfemfhelper::TargetHolders& getTargetHolders() const { return *mpTargetHolders; } - wmfemfhelper::PropertyHolders& getPropertyHolders() const { return *mpPropertyHolders; } +// wmfemfhelper::TargetHolders& getTargetHolders() const { return mrTargetHolders; } +// wmfemfhelper::PropertyHolders& getPropertyHolders() const { return mrPropertyHolders; } }; } diff --git a/drawinglayer/source/tools/emfplushelper.cxx b/drawinglayer/source/tools/emfplushelper.cxx index c6c472cf7b30..a587bf09e27d 100644 --- a/drawinglayer/source/tools/emfplushelper.cxx +++ b/drawinglayer/source/tools/emfplushelper.cxx @@ -22,24 +22,22 @@ namespace emfplushelper { - EmfPlusHelper::EmfPlusHelper(SvMemoryStream& rMS) - : mpD(new EmfPlusHelperData(rMS)) + EmfPlusHelper::EmfPlusHelper( + SvMemoryStream& rMS, + wmfemfhelper::TargetHolders& rTargetHolders, + wmfemfhelper::PropertyHolders& rPropertyHolders) + : mpD(new EmfPlusHelperData(rMS, rTargetHolders, rPropertyHolders)) { } EmfPlusHelper::~EmfPlusHelper() { - delete mpD; } void EmfPlusHelper::processEmfPlusData( SvMemoryStream& rMS, - wmfemfhelper::TargetHolders& rTargetHolders, - wmfemfhelper::PropertyHolders& rPropertyHolders, const drawinglayer::geometry::ViewInformation2D& rViewInformation) { - mpD->setTargetHolders(rTargetHolders); - mpD->setPropertyHolders(rPropertyHolders); mpD->processEmfPlusData(rMS, rViewInformation); } } diff --git a/drawinglayer/source/tools/emfppen.cxx b/drawinglayer/source/tools/emfppen.cxx index ef037b0d3157..d60f10e360f4 100644 --- a/drawinglayer/source/tools/emfppen.cxx +++ b/drawinglayer/source/tools/emfppen.cxx @@ -97,11 +97,11 @@ namespace emfplushelper delete customEndCap; } - void EMFPPen::SetStrokeWidth(rendering::StrokeAttributes& rStrokeAttributes, EmfPlusHelperData& rR, const OutDevState& rState) + void EMFPPen::SetStrokeWidth(rendering::StrokeAttributes& rStrokeAttributes, EmfPlusHelperData& rR, const ::basegfx::B2DHomMatrix& mapModeTransform) { // If a zero width is specified, a minimum value is used, which is determined by the units. //TODO Add support for other units than Pixel - rStrokeAttributes.StrokeWidth = fabs((rState.mapModeTransform * rR.MapSize(penWidth == 0.0 ? 0.05 : penWidth, 0)).getLength()); + rStrokeAttributes.StrokeWidth = fabs((mapModeTransform * rR.MapSize(penWidth == 0.0 ? 0.05 : penWidth, 0)).getLength()); // tdf#31814 Based on observation of different EMF+ files (eg. exported by ChemDraw), // there is minimal value of line width @@ -183,7 +183,7 @@ namespace emfplushelper " pen data flags: 0x" << penDataFlags << " unit: " << penUnit << " width: " << std::dec << penWidth); if (penDataFlags & PenDataTransform) - readXForm(s, pen_transformation); + rR.readXForm(s, pen_transformation); if (penDataFlags & PenDataStartCap) { diff --git a/drawinglayer/source/tools/emfppen.hxx b/drawinglayer/source/tools/emfppen.hxx index 4e2dc6d38156..c4a260f6e4a3 100644 --- a/drawinglayer/source/tools/emfppen.hxx +++ b/drawinglayer/source/tools/emfppen.hxx @@ -60,7 +60,7 @@ namespace emfplushelper virtual ~EMFPPen() override; - void SetStrokeWidth(com::sun::star::rendering::StrokeAttributes& rStrokeAttributes, EmfPlusHelperData& rR, const OutDevState& rState); + void SetStrokeWidth(com::sun::star::rendering::StrokeAttributes& rStrokeAttributes, EmfPlusHelperData& rR, const ::basegfx::B2DHomMatrix& mapModeTransform); void SetStrokeAttributes(com::sun::star::rendering::StrokeAttributes& rStrokeAttributes); diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx b/drawinglayer/source/tools/wmfemfhelper.cxx index f2231a1879fe..b272f4a51eb3 100644 --- a/drawinglayer/source/tools/wmfemfhelper.cxx +++ b/drawinglayer/source/tools/wmfemfhelper.cxx @@ -3028,7 +3028,11 @@ namespace wmfemfhelper SAL_INFO("cppcanvas.emf", "EMF+ passed to canvas mtf renderer - header info, size: " << pA->GetDataSize()); SvMemoryStream aMemoryStream(const_cast<sal_uInt8 *>(pA->GetData()), pA->GetDataSize(), StreamMode::READ); - aEMFPlus.reset(new emfplushelper::EmfPlusHelper(aMemoryStream)); + aEMFPlus.reset( + new emfplushelper::EmfPlusHelper( + aMemoryStream, + rTargetHolders, + rPropertyHolders)); } } else if (pA->GetComment().equalsIgnoreAsciiCase("EMF_PLUS")) @@ -3061,8 +3065,6 @@ namespace wmfemfhelper aEMFPlus->processEmfPlusData( aMemoryStream, - rTargetHolders, - rPropertyHolders, rViewInformation); } |