Kaydet (Commit) 5f153436 authored tarafından Bartosz Kosiorek's avatar Bartosz Kosiorek

EMF+ Fix variable types according to specification

Change-Id: I03b949abbe53a4f34bba72a23f941ebea443f737
Reviewed-on: https://gerrit.libreoffice.org/52627Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarBartosz Kosiorek <gang65@poczta.onet.pl>
üst 79383148
...@@ -96,13 +96,6 @@ namespace emfplushelper ...@@ -96,13 +96,6 @@ namespace emfplushelper
return ""; return "";
} }
typedef enum
{
ImageDataTypeUnknown = 0x00000000,
ImageDataTypeBitmap = 0x00000001,
ImageDataTypeMetafile = 0x00000002
} ImageDataType;
EMFPObject::~EMFPObject() EMFPObject::~EMFPObject()
{ {
} }
...@@ -1145,10 +1138,10 @@ namespace emfplushelper ...@@ -1145,10 +1138,10 @@ namespace emfplushelper
case EmfPlusRecordTypeDrawImage: case EmfPlusRecordTypeDrawImage:
case EmfPlusRecordTypeDrawImagePoints: case EmfPlusRecordTypeDrawImagePoints:
{ {
sal_uInt32 attrIndex; sal_uInt32 imageAttributesId;
sal_Int32 sourceUnit; sal_Int32 sourceUnit;
rMS.ReadUInt32(attrIndex).ReadInt32(sourceUnit); rMS.ReadUInt32(imageAttributesId).ReadInt32(sourceUnit);
SAL_INFO("drawinglayer", "EMF+ " << (type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage") << "attributes index: " << attrIndex << "source unit: " << sourceUnit); SAL_INFO("drawinglayer", "EMF+ " << (type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage") << " image attributes Id: " << imageAttributesId << " source unit: " << sourceUnit);
SAL_INFO("drawinglayer", "EMF+\tTODO: use image attributes"); SAL_INFO("drawinglayer", "EMF+\tTODO: use image attributes");
// For DrawImage and DrawImagePoints, source unit of measurement type must be 1 pixel // For DrawImage and DrawImagePoints, source unit of measurement type must be 1 pixel
...@@ -1164,8 +1157,8 @@ namespace emfplushelper ...@@ -1164,8 +1157,8 @@ namespace emfplushelper
if (type == EmfPlusRecordTypeDrawImagePoints) if (type == EmfPlusRecordTypeDrawImagePoints)
{ {
sal_Int32 aCount; sal_uInt32 aCount;
rMS.ReadInt32(aCount); rMS.ReadUInt32(aCount);
// Number of points used by DrawImagePoints. Exactly 3 points must be specified. // Number of points used by DrawImagePoints. Exactly 3 points must be specified.
if(aCount == 3) if(aCount == 3)
...@@ -1176,15 +1169,15 @@ namespace emfplushelper ...@@ -1176,15 +1169,15 @@ namespace emfplushelper
ReadPoint(rMS, x2, y2, flags); ReadPoint(rMS, x2, y2, flags);
ReadPoint(rMS, x3, y3, flags); ReadPoint(rMS, x3, y3, flags);
SAL_INFO("drawinglayer", "EMF+ destination points: " << x1 << "," << y1 << " " << x2 << "," << y2 << " " << x3 << "," << y3); SAL_INFO("drawinglayer", "EMF+\t destination points: " << x1 << "," << y1 << " " << x2 << "," << y2 << " " << x3 << "," << y3);
SAL_INFO("drawinglayer", "EMF+ destination rectangle: " << x1 << "," << y1 << " " << x2 - x1 << "x" << y3 - y1); SAL_INFO("drawinglayer", "EMF+\t destination rectangle: " << x1 << "," << y1 << " " << x2 - x1 << "x" << y3 - y1);
aDstPoint = Map(x1, y1); aDstPoint = Map(x1, y1);
aDstSize = MapSize(x2 - x1, y3 - y1); aDstSize = MapSize(x2 - x1, y3 - y1);
} }
else else
{ {
SAL_WARN("drawinglayer", "EMF+ DrawImagePoints Wrong EMF+ file. Expected 3 points, received: "<< aCount); SAL_WARN("drawinglayer", "EMF+\t DrawImagePoints Wrong EMF+ file. Expected 3 points, received: "<< aCount);
break; break;
} }
} }
...@@ -1192,7 +1185,7 @@ namespace emfplushelper ...@@ -1192,7 +1185,7 @@ namespace emfplushelper
{ {
float dx, dy, dw, dh; float dx, dy, dw, dh;
ReadRectangle(rMS, dx, dy, dw, dh, bool(flags & 0x4000)); ReadRectangle(rMS, dx, dy, dw, dh, bool(flags & 0x4000));
SAL_INFO("drawinglayer", "EMF+ destination rectangle: " << dx << "," << dy << " " << dw << "x" << dh); SAL_INFO("drawinglayer", "EMF+\t destination rectangle: " << dx << "," << dy << " " << dw << "x" << dh);
aDstPoint = Map(dx, dy); aDstPoint = Map(dx, dy);
aDstSize = MapSize(dw, dh); aDstSize = MapSize(dw, dh);
} }
...@@ -1209,7 +1202,7 @@ namespace emfplushelper ...@@ -1209,7 +1202,7 @@ namespace emfplushelper
BitmapEx aBmp(image.graphic.GetBitmapEx()); BitmapEx aBmp(image.graphic.GetBitmapEx());
aBmp.Crop(aSource); aBmp.Crop(aSource);
Size aSize(aBmp.GetSizePixel()); Size aSize(aBmp.GetSizePixel());
SAL_INFO("drawinglayer", "EMF+ bitmap size: " << aSize.Width() << "x" << aSize.Height()); SAL_INFO("drawinglayer", "EMF+\t bitmap size: " << aSize.Width() << "x" << aSize.Height());
if (aSize.Width() > 0 && aSize.Height() > 0) if (aSize.Width() > 0 && aSize.Height() > 0)
{ {
mrTargetHolders.Current().append( mrTargetHolders.Current().append(
...@@ -1217,7 +1210,7 @@ namespace emfplushelper ...@@ -1217,7 +1210,7 @@ namespace emfplushelper
} }
else else
{ {
SAL_INFO("drawinglayer", "EMF+ warning: empty bitmap"); SAL_INFO("drawinglayer", "EMF+\t warning: empty bitmap");
} }
} }
else if (image.type == ImageDataTypeMetafile) else if (image.type == ImageDataTypeMetafile)
......
...@@ -132,58 +132,6 @@ namespace emfplushelper ...@@ -132,58 +132,6 @@ namespace emfplushelper
virtual ~EMFPObject(); virtual ~EMFPObject();
}; };
// 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 maWorldTransform;
// OutDevState aDevState;
// } EmfPlusGraphicState;
//
// typedef std::map<int, EmfPlusGraphicState> GraphicStateMap;
typedef std::map<int, wmfemfhelper::PropertyHolder> GraphicStateMap; typedef std::map<int, wmfemfhelper::PropertyHolder> GraphicStateMap;
struct EmfPlusHelperData struct EmfPlusHelperData
...@@ -264,6 +212,6 @@ namespace emfplushelper ...@@ -264,6 +212,6 @@ namespace emfplushelper
}; };
} }
#endif // INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_EMFPBRUSH_HXX #endif // INCLUDED_DRAWINGLAYER_SOURCE_TOOLS_EMFPHELPERDATA_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -16,25 +16,6 @@ ...@@ -16,25 +16,6 @@
* except in compliance with the License. You may obtain a copy of * except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <com/sun/star/rendering/PathCapType.hpp>
#include <com/sun/star/rendering/PathJoinType.hpp>
#include <com/sun/star/rendering/TexturingMode.hpp>
#include <com/sun/star/rendering/XCanvas.hpp>
#include <basegfx/utils/canvastools.hxx>
#include <basegfx/utils/gradienttools.hxx>
#include <basegfx/utils/tools.hxx>
#include <basegfx/numeric/ftools.hxx>
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/vector/b2dsize.hxx>
#include <basegfx/range/b2drange.hxx>
#include <basegfx/range/b2drectangle.hxx>
#include <basegfx/polygon/b2dlinegeometry.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <vcl/canvastools.hxx>
#include <vcl/graphicfilter.hxx> #include <vcl/graphicfilter.hxx>
#include "emfpimage.hxx" #include "emfpimage.hxx"
...@@ -46,11 +27,11 @@ namespace emfplushelper ...@@ -46,11 +27,11 @@ namespace emfplushelper
s.ReadUInt32(header).ReadUInt32(type); s.ReadUInt32(header).ReadUInt32(type);
SAL_INFO("drawinglayer", "EMF+\timage\nEMF+\theader: 0x" << std::hex << header << " type: " << type << std::dec); SAL_INFO("drawinglayer", "EMF+\timage\nEMF+\theader: 0x" << std::hex << header << " type: " << type << std::dec);
if (1 == type) if (ImageDataTypeBitmap == type)
{ {
// bitmap // bitmap
s.ReadInt32(width).ReadInt32(height).ReadInt32(stride).ReadInt32(pixelFormat).ReadUInt32(bitmapType); s.ReadInt32(width).ReadInt32(height).ReadInt32(stride).ReadUInt32(pixelFormat).ReadUInt32(bitmapType);
SAL_INFO("drawinglayer", "EMF+\tbitmap width: " << width << " height: " << height << " stride: " << stride << " pixelFormat: 0x" << std::hex << pixelFormat << std::dec); SAL_INFO("drawinglayer", "EMF+\tbitmap width: " << width << " height: " << height << " stride: " << stride << " pixelFormat: 0x" << std::hex << pixelFormat << " bitmapType: 0x" << bitmapType << std::dec);
if ((bitmapType != 0) || (width == 0)) if ((bitmapType != 0) || (width == 0))
{ {
...@@ -60,11 +41,11 @@ namespace emfplushelper ...@@ -60,11 +41,11 @@ namespace emfplushelper
SAL_INFO("drawinglayer", "EMF+\tbitmap width: " << graphic.GetBitmap().GetSizePixel().Width() << " height: " << graphic.GetBitmap().GetSizePixel().Height()); SAL_INFO("drawinglayer", "EMF+\tbitmap width: " << graphic.GetBitmap().GetSizePixel().Width() << " height: " << graphic.GetBitmap().GetSizePixel().Height());
} }
} }
else if (2 == type) else if (ImageDataTypeMetafile == type)
{ {
// metafile // metafile
sal_Int32 mfType, mfSize; sal_uInt32 mfType, mfSize;
s.ReadInt32(mfType).ReadInt32(mfSize); s.ReadUInt32(mfType).ReadUInt32(mfSize);
if (bUseWholeStream) if (bUseWholeStream)
dataSize = s.remainingSize(); dataSize = s.remainingSize();
......
...@@ -25,13 +25,21 @@ ...@@ -25,13 +25,21 @@
namespace emfplushelper namespace emfplushelper
{ {
typedef enum
{
ImageDataTypeUnknown = 0x00000000,
ImageDataTypeBitmap = 0x00000001,
ImageDataTypeMetafile = 0x00000002
} ImageDataType;
struct EMFPImage : public EMFPObject struct EMFPImage : public EMFPObject
{ {
sal_uInt32 type; sal_uInt32 type;
sal_Int32 width; sal_Int32 width;
sal_Int32 height; sal_Int32 height;
sal_Int32 stride; sal_Int32 stride;
sal_Int32 pixelFormat; sal_uInt32 pixelFormat;
Graphic graphic; Graphic graphic;
void Read(SvMemoryStream &s, sal_uInt32 dataSize, bool bUseWholeStream); void Read(SvMemoryStream &s, sal_uInt32 dataSize, bool bUseWholeStream);
......
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