summaryrefslogtreecommitdiff
path: root/emfio/source/reader/emfreader.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'emfio/source/reader/emfreader.cxx')
-rw-r--r--emfio/source/reader/emfreader.cxx47
1 files changed, 25 insertions, 22 deletions
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx
index 4c0859bbff5a..1d1adc2f49aa 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -329,41 +329,44 @@ SvStream& operator>>(SvStream& rInStream, BLENDFUNCTION& rBlendFun)
bool ImplReadRegion( tools::PolyPolygon& rPolyPoly, SvStream& rStream, sal_uInt32 nLen )
{
- if (nLen == 0)
+ if (nLen < 32) // 32 bytes - Size of RegionDataHeader
return false;
- sal_uInt32 nHdSize, nType, nCount, nRgnSize, i;
+ sal_uInt32 nHdSize, nType, nCountRects, nRgnSize, i;
rStream.ReadUInt32(nHdSize);
rStream.ReadUInt32(nType);
- rStream.ReadUInt32(nCount);
+ rStream.ReadUInt32(nCountRects);
rStream.ReadUInt32(nRgnSize);
- if (!rStream.good() || nCount == 0 || nType != RDH_RECTANGLES)
+ if (!rStream.good() || nCountRects == 0 || nType != RDH_RECTANGLES)
return false;
+ //bounds of the region
+ sal_Int32 nLeft, nTop, nRight, nBottom;
+ rStream.ReadInt32(nLeft);
+ rStream.ReadInt32(nTop);
+ rStream.ReadInt32(nRight);
+ rStream.ReadInt32(nBottom);
+ SAL_INFO("emfio", "\t\tLeft: " << nLeft << ", top: " << nTop << ", right: " << nRight << ", bottom: " << nBottom);
+
sal_uInt32 nSize;
- if (o3tl::checked_multiply<sal_uInt32>(nCount, 16, nSize))
+ if (o3tl::checked_multiply<sal_uInt32>(nCountRects, 16, nSize))
return false;
if (o3tl::checked_add<sal_uInt32>(nSize, nHdSize - 16, nSize))
return false;
if (nLen < nSize)
return false;
- sal_Int32 nx1, ny1, nx2, ny2;
- for (i = 0; i < nCount; i++)
+ for (i = 0; i < nCountRects; i++)
{
- rStream.ReadInt32(nx1);
- rStream.ReadInt32(ny1);
- rStream.ReadInt32(nx2);
- rStream.ReadInt32(ny2);
-
- tools::Rectangle aRectangle(Point(nx1, ny1), Point(nx2, ny2));
-
- tools::Polygon aPolygon(aRectangle);
- tools::PolyPolygon aPolyPolyOr1(aPolygon);
- tools::PolyPolygon aPolyPolyOr2(rPolyPoly);
- rPolyPoly.GetUnion(aPolyPolyOr1, aPolyPolyOr2);
- rPolyPoly = aPolyPolyOr2;
+ rStream.ReadInt32(nLeft);
+ rStream.ReadInt32(nTop);
+ rStream.ReadInt32(nRight);
+ rStream.ReadInt32(nBottom);
+
+ SAL_INFO("emfio", "\t\tLeft: " << nLeft << ", top: " << nTop << ", right: " << nRight << ", bottom: " << nBottom);
+ tools::PolyPolygon aPolyPolyOr1(tools::Polygon(tools::Rectangle(nLeft, nTop, nRight, nBottom)));
+ rPolyPoly.GetUnion(aPolyPolyOr1, rPolyPoly);
}
return true;
}
@@ -1906,10 +1909,10 @@ namespace emfio
case EMR_FILLRGN :
{
- sal_uInt32 nLen;
+ sal_uInt32 nRgnDataSize;
tools::PolyPolygon aPolyPoly;
- mpInputStream->SeekRel( 0x10 );
- mpInputStream->ReadUInt32( nLen ).ReadUInt32( nIndex );
+ mpInputStream->SeekRel( 0x10 ); // RectL bounds
+ mpInputStream->ReadUInt32( nRgnDataSize ).ReadUInt32( nIndex );
if ( ImplReadRegion( aPolyPoly, *mpInputStream, nRecSize ) )
{