summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2022-04-22 18:26:49 +0200
committerBartosz Kosiorek <gang65@poczta.onet.pl>2022-04-24 13:01:05 +0200
commit8202df1815ed692df371e6d07a3b0f29a329f6ed (patch)
tree2a6e90cec086751e45c1f16e6cd7ff0cde90b02e
parenteaab20c304882d26b9593edab402d64cc55c2df3 (diff)
tdf#103859 EMF+ Use variable types according to EMFPLUS documentation
With this commit, the types of variable for Brush and Pen were aligned to documentation: [MS-EMFPLUS] - Enhanced Metafile Format Plus Extensions As a side effect the code was simplified a bit Change-Id: Ibabad628d0aaef510f61ee8b3d881c3f024cebef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133327 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
-rw-r--r--drawinglayer/source/tools/emfpbrush.cxx71
-rw-r--r--drawinglayer/source/tools/emfpbrush.hxx6
-rw-r--r--drawinglayer/source/tools/emfphelperdata.cxx4
-rw-r--r--drawinglayer/source/tools/emfppen.cxx27
-rw-r--r--drawinglayer/source/tools/emfppen.hxx4
5 files changed, 35 insertions, 77 deletions
diff --git a/drawinglayer/source/tools/emfpbrush.cxx b/drawinglayer/source/tools/emfpbrush.cxx
index 4acc311345a8..7d6204a5da9e 100644
--- a/drawinglayer/source/tools/emfpbrush.cxx
+++ b/drawinglayer/source/tools/emfpbrush.cxx
@@ -113,17 +113,12 @@ namespace emfplushelper
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tCenter color: 0x" << std::hex << color << std::dec);
s.ReadFloat(firstPointX).ReadFloat(firstPointY);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tCenter point: " << firstPointX << "," << firstPointY);
- s.ReadInt32(surroundColorsNumber);
+ s.ReadUInt32(surroundColorsNumber);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\t number of surround colors: " << surroundColorsNumber);
- if (surroundColorsNumber<0 || o3tl::make_unsigned(surroundColorsNumber)>SAL_MAX_INT32 / sizeof(::Color))
- {
- surroundColorsNumber = SAL_MAX_INT32 / sizeof(::Color);
- }
-
surroundColors.reset( new ::Color[surroundColorsNumber] );
- for (int i = 0; i < surroundColorsNumber; i++)
+ for (sal_uInt32 i = 0; i < surroundColorsNumber; i++)
{
s.ReadUInt32(color);
surroundColors[i] = ::Color(ColorAlpha, (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
@@ -132,7 +127,7 @@ namespace emfplushelper
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tSurround color[" << i << "]: 0x" << std::hex << color << std::dec);
}
- if (additionalFlags & 0x01)
+ if (additionalFlags & 0x01) // BrushDataPath
{
sal_Int32 pathLength;
@@ -180,60 +175,47 @@ namespace emfplushelper
<< aBounds.getWidth() << "x" << aBounds.getHeight());
}
- if (additionalFlags & 0x02)
+ if (additionalFlags & 0x02) // BrushDataTransform
{
EmfPlusHelperData::readXForm(s, brush_transformation);
hasTransformation = true;
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tUse brush transformation: " << brush_transformation);
}
- if (additionalFlags & 0x08)
+ if (additionalFlags & 0x08) // BrushDataBlendFactorsH
{
- s.ReadInt32(blendPoints);
+ s.ReadUInt32(blendPoints);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tuse blend, points: " << blendPoints);
- if (blendPoints<0 || o3tl::make_unsigned(blendPoints)>SAL_MAX_INT32 / (2 * sizeof(float)))
- blendPoints = SAL_MAX_INT32 / (2 * sizeof(float));
blendPositions.reset( new float[2 * blendPoints] );
blendFactors = blendPositions.get() + blendPoints;
- for (int i = 0; i < blendPoints; i++)
+ for (sal_uInt32 i = 0; i < blendPoints; i++)
{
s.ReadFloat(blendPositions[i]);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tposition[" << i << "]: " << blendPositions[i]);
}
- for (int i = 0; i < blendPoints; i++)
+ for (sal_uInt32 i = 0; i < blendPoints; i++)
{
s.ReadFloat(blendFactors[i]);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tFactor[" << i << "]: " << blendFactors[i]);
}
}
- if (additionalFlags & 0x04)
+ if (additionalFlags & 0x04) // BrushDataPresetColors
{
- s.ReadInt32(colorblendPoints);
+ s.ReadUInt32(colorblendPoints);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tUse color blend, points: " << colorblendPoints);
-
- if (colorblendPoints<0 || o3tl::make_unsigned(colorblendPoints)>SAL_MAX_INT32 / sizeof(float))
- {
- colorblendPoints = SAL_MAX_INT32 / sizeof(float);
- }
-
- if (o3tl::make_unsigned(colorblendPoints) > SAL_MAX_INT32 / sizeof(::Color))
- {
- colorblendPoints = SAL_MAX_INT32 / sizeof(::Color);
- }
-
colorblendPositions.reset( new float[colorblendPoints] );
colorblendColors.reset( new ::Color[colorblendPoints] );
- for (int i = 0; i < colorblendPoints; i++)
+ for (sal_uInt32 i = 0; i < colorblendPoints; i++)
{
s.ReadFloat(colorblendPositions[i]);
SAL_INFO("drawinglayer.emf", "EMF+\tposition[" << i << "]: " << colorblendPositions[i]);
}
- for (int i = 0; i < colorblendPoints; i++)
+ for (sal_uInt32 i = 0; i < colorblendPoints; i++)
{
s.ReadUInt32(color);
colorblendColors[i] = ::Color(ColorAlpha, (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
@@ -262,29 +244,27 @@ namespace emfplushelper
s.ReadUInt32(color);
s.ReadUInt32(color);
- if (additionalFlags & 0x02)
+ if (additionalFlags & 0x02) //BrushDataTransform
{
EmfPlusHelperData::readXForm(s, brush_transformation);
hasTransformation = true;
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tUse brush transformation: " << brush_transformation);
}
- if (additionalFlags & 0x08)
+ if (additionalFlags & 0x08) // BrushDataBlendFactorsH
{
- s.ReadInt32(blendPoints);
+ s.ReadUInt32(blendPoints);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tUse blend, points: " << blendPoints);
- if (blendPoints<0 || o3tl::make_unsigned(blendPoints)>SAL_MAX_INT32 / (2 * sizeof(float)))
- blendPoints = SAL_MAX_INT32 / (2 * sizeof(float));
blendPositions.reset( new float[2 * blendPoints] );
blendFactors = blendPositions.get() + blendPoints;
- for (int i = 0; i < blendPoints; i++)
+ for (sal_uInt32 i = 0; i < blendPoints; i++)
{
s.ReadFloat(blendPositions[i]);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tPosition[" << i << "]: " << blendPositions[i]);
}
- for (int i = 0; i < blendPoints; i++)
+ for (sal_uInt32 i = 0; i < blendPoints; i++)
{
s.ReadFloat(blendFactors[i]);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tFactor[" << i << "]: " << blendFactors[i]);
@@ -293,29 +273,18 @@ namespace emfplushelper
if (additionalFlags & 0x04)
{
- s.ReadInt32(colorblendPoints);
+ s.ReadUInt32(colorblendPoints);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tUse color blend, points: " << colorblendPoints);
-
- if (colorblendPoints<0 || o3tl::make_unsigned(colorblendPoints)>SAL_MAX_INT32 / sizeof(float))
- {
- colorblendPoints = SAL_MAX_INT32 / sizeof(float);
- }
-
- if (o3tl::make_unsigned(colorblendPoints) > SAL_MAX_INT32 / sizeof(::Color))
- {
- colorblendPoints = sal_uInt32(SAL_MAX_INT32) / sizeof(::Color);
- }
-
colorblendPositions.reset( new float[colorblendPoints] );
colorblendColors.reset( new ::Color[colorblendPoints] );
- for (int i = 0; i < colorblendPoints; i++)
+ for (sal_uInt32 i = 0; i < colorblendPoints; i++)
{
s.ReadFloat(colorblendPositions[i]);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tPosition[" << i << "]: " << colorblendPositions[i]);
}
- for (int i = 0; i < colorblendPoints; i++)
+ for (sal_uInt32 i = 0; i < colorblendPoints; i++)
{
s.ReadUInt32(color);
colorblendColors[i] = ::Color(ColorAlpha, (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
diff --git a/drawinglayer/source/tools/emfpbrush.hxx b/drawinglayer/source/tools/emfpbrush.hxx
index ec4ab11732f2..5f272a63ac9c 100644
--- a/drawinglayer/source/tools/emfpbrush.hxx
+++ b/drawinglayer/source/tools/emfpbrush.hxx
@@ -104,13 +104,13 @@ namespace emfplushelper
::Color secondColor; // first color is stored in solidColor;
basegfx::B2DHomMatrix brush_transformation;
bool hasTransformation;
- sal_Int32 blendPoints;
+ sal_uInt32 blendPoints;
std::unique_ptr<float[]> blendPositions;
float* blendFactors;
- sal_Int32 colorblendPoints;
+ sal_uInt32 colorblendPoints;
std::unique_ptr<float[]> colorblendPositions;
std::unique_ptr<::Color[]> colorblendColors;
- sal_Int32 surroundColorsNumber;
+ sal_uInt32 surroundColorsNumber;
std::unique_ptr<::Color[]> surroundColors;
std::unique_ptr<EMFPPath> path;
EmfPlusHatchStyle hatchStyle;
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index a7f809373e09..c405a4c4876b 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -796,7 +796,7 @@ namespace emfplushelper
SAL_INFO("drawinglayer.emf", "EMF+\t\tUse blend");
// store the blendpoints in the vector
- for (int i = 0; i < brush->blendPoints; i++)
+ for (sal_uInt32 i = 0; i < brush->blendPoints; i++)
{
double aBlendPoint;
basegfx::BColor aColor;
@@ -821,7 +821,7 @@ namespace emfplushelper
SAL_INFO("drawinglayer.emf", "EMF+\t\tUse color blend");
// store the colorBlends in the vector
- for (int i = 0; i < brush->colorblendPoints; i++)
+ for (sal_uInt32 i = 0; i < brush->colorblendPoints; i++)
{
double aBlendPoint;
basegfx::BColor aColor;
diff --git a/drawinglayer/source/tools/emfppen.cxx b/drawinglayer/source/tools/emfppen.cxx
index f348391b0519..7d999d61cc8b 100644
--- a/drawinglayer/source/tools/emfppen.cxx
+++ b/drawinglayer/source/tools/emfppen.cxx
@@ -247,7 +247,6 @@ namespace emfplushelper
void EMFPPen::Read(SvStream& s, EmfPlusHelperData const & rR)
{
sal_uInt32 graphicsVersion, penType;
- int i;
s.ReadUInt32(graphicsVersion).ReadUInt32(penType).ReadUInt32(penDataFlags).ReadUInt32(penUnit).ReadFloat(penWidth);
SAL_INFO("drawinglayer.emf", "EMF+\t\tGraphics version: 0x" << std::hex << graphicsVersion);
SAL_INFO("drawinglayer.emf", "EMF+\t\tType: " << penType);
@@ -341,19 +340,14 @@ namespace emfplushelper
if (penDataFlags & PenDataDashedLine)
{
dashStyle = EmfPlusLineStyleCustom;
- sal_Int32 dashPatternLen;
+ sal_uInt32 dashPatternLen;
- s.ReadInt32(dashPatternLen);
+ s.ReadUInt32(dashPatternLen);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\tdashPatternLen: " << dashPatternLen);
- if (dashPatternLen<0 || o3tl::make_unsigned(dashPatternLen)>SAL_MAX_INT32 / sizeof(float))
- {
- dashPatternLen = SAL_MAX_INT32 / sizeof(float);
- }
-
dashPattern.resize( dashPatternLen );
- for (i = 0; i < dashPatternLen; i++)
+ for (sal_uInt32 i = 0; i < dashPatternLen; i++)
{
s.ReadFloat(dashPattern[i]);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tdashPattern[" << i << "]: " << dashPattern[i]);
@@ -373,17 +367,12 @@ namespace emfplushelper
if (penDataFlags & PenDataCompoundLine)
{
SAL_WARN("drawinglayer.emf", "EMF+\t\t\tTODO PenDataCompoundLine");
- sal_Int32 compoundArrayLen;
- s.ReadInt32(compoundArrayLen);
-
- if (compoundArrayLen<0 || o3tl::make_unsigned(compoundArrayLen)>SAL_MAX_INT32 / sizeof(float))
- {
- compoundArrayLen = SAL_MAX_INT32 / sizeof(float);
- }
+ sal_uInt32 compoundArrayLen;
+ s.ReadUInt32(compoundArrayLen);
compoundArray.resize(compoundArrayLen);
- for (i = 0; i < compoundArrayLen; i++)
+ for (sal_uInt32 i = 0; i < compoundArrayLen; i++)
{
s.ReadFloat(compoundArray[i]);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\t\tcompoundArray[" << i << "]: " << compoundArray[i]);
@@ -392,7 +381,7 @@ namespace emfplushelper
if (penDataFlags & PenDataCustomStartCap)
{
- s.ReadInt32(customStartCapLen);
+ s.ReadUInt32(customStartCapLen);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\tcustomStartCapLen: " << customStartCapLen);
sal_uInt64 const pos = s.Tell();
@@ -409,7 +398,7 @@ namespace emfplushelper
if (penDataFlags & PenDataCustomEndCap)
{
- s.ReadInt32(customEndCapLen);
+ s.ReadUInt32(customEndCapLen);
SAL_INFO("drawinglayer.emf", "EMF+\t\t\tcustomEndCapLen: " << customEndCapLen);
sal_uInt64 const pos = s.Tell();
diff --git a/drawinglayer/source/tools/emfppen.hxx b/drawinglayer/source/tools/emfppen.hxx
index 29ece63ecf5d..a22ae14fc247 100644
--- a/drawinglayer/source/tools/emfppen.hxx
+++ b/drawinglayer/source/tools/emfppen.hxx
@@ -112,9 +112,9 @@ namespace emfplushelper
std::vector<float> dashPattern;
sal_Int32 alignment;
std::vector<float> compoundArray;
- sal_Int32 customStartCapLen;
+ sal_uInt32 customStartCapLen;
std::unique_ptr<EMFPCustomLineCap> customStartCap;
- sal_Int32 customEndCapLen;
+ sal_uInt32 customEndCapLen;
std::unique_ptr<EMFPCustomLineCap> customEndCap;
EMFPPen();