summaryrefslogtreecommitdiffstats
path: root/drawinglayer/source/tools/emfpbrush.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'drawinglayer/source/tools/emfpbrush.cxx')
-rw-r--r--drawinglayer/source/tools/emfpbrush.cxx83
1 files changed, 32 insertions, 51 deletions
diff --git a/drawinglayer/source/tools/emfpbrush.cxx b/drawinglayer/source/tools/emfpbrush.cxx
index 4acc311345a8..c79b0ded0748 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,53 @@ 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)
+ // BrushDataPresetColors and BrushDataBlendFactorsH
+ if ((additionalFlags & 0x04) && (additionalFlags & 0x08))
{
- s.ReadInt32(blendPoints);
+ SAL_WARN("drawinglayer.emf", "EMF+\t Brush must not contain both BrushDataPresetColors and BrushDataBlendFactorsH");
+ return;
+ }
+ if (additionalFlags & 0x08) // BrushDataBlendFactorsH
+ {
+ 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 +250,33 @@ 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);
}
+ // BrushDataPresetColors and BrushDataBlendFactorsH
+ if ((additionalFlags & 0x04) && (additionalFlags & 0x08))
+ {
+ SAL_WARN("drawinglayer.emf", "EMF+\t Brush must not contain both BrushDataPresetColors and BrushDataBlendFactorsH");
+ return;
+ }
- 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 +285,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);