[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/source

2021-08-30 Thread Caolán McNamara (via logerrit)
 emfio/source/reader/emfreader.cxx |   15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

New commits:
commit e40da04c6fa28a23aa838b05c976527c5dd3b57e
Author: Caolán McNamara 
AuthorDate: Sat Aug 28 21:48:21 2021 +0100
Commit: Xisco Fauli 
CommitDate: Mon Aug 30 14:11:13 2021 +0200

ofz: MemorySanitizer: use-of-uninitialized-value

Change-Id: I4a34981e6597743f9f3a9ad6ca063cb347a68d14
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121213
Reviewed-by: Michael Stahl 
Tested-by: Jenkins

diff --git a/emfio/source/reader/emfreader.cxx 
b/emfio/source/reader/emfreader.cxx
index 144cab9f0021..772f9c695fa3 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -1359,12 +1359,17 @@ namespace emfio
 {
 sal_uInt32 nStartX, nStartY, nEndX, nEndY;
 mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 
).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY 
).ReadUInt32( nEndX ).ReadUInt32( nEndY );
-tools::Polygon aPoly( ReadRectangle( nX32, nY32, nx32, 
ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), PolyStyle::Arc );
-aPoly.Optimize( PolyOptimizeFlags::EDGES );
-if ( nRecType == EMR_CHORD )
-DrawPolygon( aPoly, mbRecordPath );
+if (!mpInputStream->good())
+bStatus = false;
 else
-DrawPolyLine( aPoly, nRecType == EMR_ARCTO, 
mbRecordPath );
+{
+tools::Polygon aPoly( ReadRectangle( nX32, nY32, 
nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), PolyStyle::Arc 
);
+aPoly.Optimize( PolyOptimizeFlags::EDGES );
+if ( nRecType == EMR_CHORD )
+DrawPolygon( aPoly, mbRecordPath );
+else
+DrawPolyLine( aPoly, nRecType == EMR_ARCTO, 
mbRecordPath );
+}
 }
 break;
 


[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/source

2021-07-08 Thread Caolán McNamara (via logerrit)
 emfio/source/reader/mtftools.cxx |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 3d1e59d9882d1146be303dafff937a51ba4e1867
Author: Caolán McNamara 
AuthorDate: Thu Feb 25 15:06:50 2021 +
Commit: Michael Stahl 
CommitDate: Thu Jul 8 10:42:56 2021 +0200

ofz#31370 Divide-by-zero

Change-Id: If581d61b678616f8a80f8ad2d2dea5ecbf10d8fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111557
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit da457f41f8f0a14014ff9f122467f3a26eb1ac20)

and...

cid#1473321 Division or modulo by float zero

and

cid#1473322 Division or modulo by float zero

where oss-fuzz also found a reproducer as ofz#31370 Divide-by-zero

Change-Id: I0facd2e794384515891dbf040f4fe43530478d3d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111601
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 28e022c258682dc030668fed7879d9d3f078b720)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118595
Reviewed-by: Michael Stahl 

diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 0d918af72dc0..53564c34f82b 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -385,10 +385,13 @@ namespace emfio
 // calculate measured TextLength
 const vcl::Font& 
rFontCandidate(maCurrentMetaFontAction->GetFont());
 pTempVirtualDevice->SetFont(rFontCandidate);
-const tools::Long 
nMeasuredTextLength(pTempVirtualDevice->GetTextWidth(rText));
+tools::Long 
nMeasuredTextLength(pTempVirtualDevice->GetTextWidth(rText));
+// on failure, use original length
+if (!nMeasuredTextLength)
+nMeasuredTextLength = nImportedTextLength;
 
 // compare expected and imported TextLengths
-if(nImportedTextLength != nMeasuredTextLength)
+if (nImportedTextLength != nMeasuredTextLength)
 {
 const double 
fFactorText(static_cast(nImportedTextLength) / 
static_cast(nMeasuredTextLength));
 const double fFactorTextPercent(fabs(1.0 - fFactorText) * 
100.0);
@@ -417,6 +420,9 @@ namespace emfio
 
rFontCandidate2.SetAverageFontWidth(static_cast(fCorrectedAverageFontWidth));
 pTempVirtualDevice->SetFont(rFontCandidate2);
 nCorrectedTextLength = 
pTempVirtualDevice->GetTextWidth(rText);
+// on failure, use original length
+if (!nCorrectedTextLength)
+nCorrectedTextLength = nImportedTextLength;
 }
 
 const double 
fFactorCorrectedText(static_cast(nImportedTextLength) / 
static_cast(nCorrectedTextLength));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/source

2021-06-11 Thread Bartosz Kosiorek (via logerrit)
 emfio/source/reader/emfreader.cxx |   33 -
 1 file changed, 20 insertions(+), 13 deletions(-)

New commits:
commit b20b7339f1786d27fec3787f3567c234757d3959
Author: Bartosz Kosiorek 
AuthorDate: Thu Jun 10 15:54:38 2021 +0200
Commit: Xisco Fauli 
CommitDate: Fri Jun 11 11:05:36 2021 +0200

EMF tdf#142745 Improve performance of FILLRGN, PAINTRGN, EXTSELECTCLIPRGN

With previous implementation, during reading of rectangles
the optimizations were made after reading every single
rectangle. This was causing performance issues, with many
rectangles (eg. 2500 rectangles).

With this commit, the optimization is made after reading all
rectangles. It is improving performance of FILLRGN, PAINTRGN and
 EXTSELECTCLIPRGN records.

Change-Id: I1b8b844efddd08e9bf6f6726c3fdf213a629883f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116996
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117022

diff --git a/emfio/source/reader/emfreader.cxx 
b/emfio/source/reader/emfreader.cxx
index 2ef29fd98dcc..144cab9f0021 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -16,7 +16,8 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
-
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -327,7 +328,7 @@ SvStream& operator>>(SvStream& rInStream, BLENDFUNCTION& 
rBlendFun)
 return rInStream;
 }
 
-bool ImplReadRegion( tools::PolyPolygon& rPolyPoly, SvStream& rStream, 
sal_uInt32 nLen )
+bool ImplReadRegion( basegfx::B2DPolyPolygon& rPolyPoly, SvStream& rStream, 
sal_uInt32 nLen )
 {
 if (nLen < 32) // 32 bytes - Size of RegionDataHeader
 return false;
@@ -348,7 +349,7 @@ bool ImplReadRegion( tools::PolyPolygon& rPolyPoly, 
SvStream& rStream, sal_uInt3
 if (!rStream.good() || nCountRects == 0 || nType != RDH_RECTANGLES)
 return false;
 
-SAL_INFO("emfio", "\t\tLeft: " << nLeft << ", top: " << nTop << ", right: 
" << nRight << ", bottom: " << nBottom);
+SAL_INFO("emfio", "\t\tBounds Left: " << nLeft << ", top: " << nTop << ", 
right: " << nRight << ", bottom: " << nBottom);
 
 nLen -= 32;
 
@@ -364,11 +365,12 @@ bool ImplReadRegion( tools::PolyPolygon& rPolyPoly, 
SvStream& rStream, sal_uInt3
 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);
+rPolyPoly.append( basegfx::utils::createPolygonFromRect( 
::basegfx::B2DRectangle( nLeft, nTop, nRight, nBottom ) ) );
+SAL_INFO("emfio", "\t\t" << i << " Left: " << nLeft << ", top: " << 
nTop << ", right: " << nRight << ", bottom: " << nBottom);
 }
+rPolyPoly = basegfx::utils::solveCrossovers(rPolyPoly);
+rPolyPoly = basegfx::utils::stripNeutralPolygons(rPolyPoly);
+rPolyPoly = basegfx::utils::stripDispensablePolygons(rPolyPoly);
 return true;
 }
 
@@ -1453,10 +1455,11 @@ namespace emfio
 }
 else
 {
-tools::PolyPolygon aPolyPoly;
+basegfx::B2DPolyPolygon aPolyPoly;
 if (cbRgnData)
 ImplReadRegion(aPolyPoly, *mpInputStream, 
nRemainingRecSize);
-SetClipPath(aPolyPoly, nClippingMode, false);
+const tools::PolyPolygon 
aPolyPolygon(aPolyPoly);
+SetClipPath(aPolyPolygon, nClippingMode, 
false);
 }
 }
 }
@@ -1934,7 +1937,7 @@ namespace emfio
 else
 {
 sal_uInt32 nRgnDataSize;
-tools::PolyPolygon aPolyPoly;
+basegfx::B2DPolyPolygon aPolyPoly;
 mpInputStream->SeekRel(16);  // RectL bounds
 mpInputStream->ReadUInt32( nRgnDataSize 
).ReadUInt32( nIndex );
 nRemainingRecSize -= 24;
@@ -1943,7 +1946,8 @@ namespace emfio
 {
 Push();
 SelectObject( nIndex );
-DrawPolyPolygon( aPolyPoly );
+tools::PolyPolygon aPolyPolygon(aPolyPoly);
+DrawPolyPolygon( aPolyPolygon );
 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/source

2021-04-06 Thread Caolán McNamara (via logerrit)
 emfio/source/reader/emfreader.cxx |   97 +++---
 1 file changed, 59 insertions(+), 38 deletions(-)

New commits:
commit a7029df783809d19a814a1552b360d6664c2efd1
Author: Caolán McNamara 
AuthorDate: Sat Apr 3 19:49:24 2021 +0100
Commit: Xisco Fauli 
CommitDate: Tue Apr 6 10:17:14 2021 +0200

pass ImplReadRegion the remaining len of record available for consumption

not the total which includes consumed part

Change-Id: I63b01013a31e6a3f1dcfe895c02a4fa049bb8fe6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113562
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/emfio/source/reader/emfreader.cxx 
b/emfio/source/reader/emfreader.cxx
index 24fcf9095e3e..fd73e77fe19b 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -332,32 +332,33 @@ bool ImplReadRegion( tools::PolyPolygon& rPolyPoly, 
SvStream& rStream, sal_uInt3
 if (nLen < 32) // 32 bytes - Size of RegionDataHeader
 return false;
 
-sal_uInt32 nHdSize, nType, nCountRects, nRgnSize, i;
+sal_uInt32 nHdSize, nType, nCountRects, nRgnSize;
 rStream.ReadUInt32(nHdSize);
 rStream.ReadUInt32(nType);
 rStream.ReadUInt32(nCountRects);
 rStream.ReadUInt32(nRgnSize);
 
-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);
+
+if (!rStream.good() || nCountRects == 0 || nType != RDH_RECTANGLES)
+return false;
+
 SAL_INFO("emfio", "\t\tLeft: " << nLeft << ", top: " << nTop << ", right: 
" << nRight << ", bottom: " << nBottom);
 
+nLen -= 32;
+
 sal_uInt32 nSize;
 if (o3tl::checked_multiply(nCountRects, 16, nSize))
 return false;
-if (o3tl::checked_add(nSize, nHdSize - 16, nSize))
-return false;
 if (nLen < nSize)
 return false;
 
-for (i = 0; i < nCountRects; i++)
+for (sal_uInt32 i = 0; i < nCountRects; ++i)
 {
 rStream.ReadInt32(nLeft);
 rStream.ReadInt32(nTop);
@@ -1422,24 +1423,30 @@ namespace emfio
 
 case EMR_EXTSELECTCLIPRGN :
 {
-sal_Int32 nClippingMode(0), cbRgnData(0);
-mpInputStream->ReadInt32(cbRgnData);
-mpInputStream->ReadInt32(nClippingMode);
-
-// This record's region data should be ignored if mode
-// is RGN_COPY - see EMF spec section 2.3.2.2
-if (nClippingMode == RGN_COPY)
-{
-SetDefaultClipPath();
-}
+sal_uInt32 nRemainingRecSize = nRecSize - 8;
+if (nRemainingRecSize < 8)
+bStatus = false;
 else
 {
-tools::PolyPolygon aPolyPoly;
-if (cbRgnData)
-ImplReadRegion(aPolyPoly, *mpInputStream, 
nRecSize);
-SetClipPath(aPolyPoly, nClippingMode, false);
+sal_Int32 nClippingMode(0), cbRgnData(0);
+mpInputStream->ReadInt32(cbRgnData);
+mpInputStream->ReadInt32(nClippingMode);
+nRemainingRecSize -= 8;
+
+// This record's region data should be ignored if 
mode
+// is RGN_COPY - see EMF spec section 2.3.2.2
+if (nClippingMode == RGN_COPY)
+{
+SetDefaultClipPath();
+}
+else
+{
+tools::PolyPolygon aPolyPoly;
+if (cbRgnData)
+ImplReadRegion(aPolyPoly, *mpInputStream, 
nRemainingRecSize);
+SetClipPath(aPolyPoly, nClippingMode, false);
+}
 }
-
 }
 break;
 
@@ -1909,30 +1916,44 @@ namespace emfio
 
 case EMR_FILLRGN :
 {
-sal_uInt32 nRgnDataSize;
-tools::PolyPolygon aPolyPoly;
-mpInputStream->SeekRel( 0x10 );  // RectL bounds
-mpInputStream->ReadUInt32( nRgnDataSize ).ReadUInt32( 
nIndex );
-
-if ( ImplReadRegion( aPolyPoly, *mpInputStream, 
nRecSize ) )
+sal_uInt32 nRemainingRecSize = nRecSize - 8;
+if (nRemainingRecSize < 24)
+ 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/source

2021-04-04 Thread Bartosz Kosiorek (via logerrit)
 emfio/source/reader/emfreader.cxx |   13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

New commits:
commit 642501ecb94cef11592ecc49b7a13ba5bdbb8d62
Author: Bartosz Kosiorek 
AuthorDate: Thu Apr 1 16:42:34 2021 +0200
Commit: Bartosz Kosiorek 
CommitDate: Sun Apr 4 14:49:22 2021 +0200

tdf#55058 EMF: Implement PAINTRGN record

The EMR_PAINTRGN record paints the specified region by using the brush
currently selected into the playback device context.

After implement support for PAINTRGN record, the reference image
is displayed correctly:
https://sourceforge.net/projects/libuemf/

Change-Id: I761779713d1200e6079ff798e9c3c9aaba57ad4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113461
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113561

diff --git a/emfio/source/reader/emfreader.cxx 
b/emfio/source/reader/emfreader.cxx
index 1d1adc2f49aa..24fcf9095e3e 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -1924,6 +1924,18 @@ namespace emfio
 }
 break;
 
+case EMR_PAINTRGN :
+{
+sal_uInt32 nRgnDataSize;
+tools::PolyPolygon aPolyPoly;
+mpInputStream->SeekRel( 0x10 ); // Skipping RectL 
bounds
+mpInputStream->ReadUInt32( nRgnDataSize );
+
+if ( ImplReadRegion( aPolyPoly, *mpInputStream, 
nRecSize ) )
+DrawPolyPolygon( aPolyPoly );
+}
+break;
+
 case EMR_CREATEDIBPATTERNBRUSHPT :
 {
 sal_uInt32  nStart = mpInputStream->Tell() - 8;
@@ -1977,7 +1989,6 @@ namespace emfio
 case EMR_SETDIBITSTODEVICE :SAL_WARN("emfio", "not 
implemented 'SetDIBitsToDevice'"); break;
 case EMR_FRAMERGN : SAL_WARN("emfio", "not 
implemented 'FrameRgn'");  break;
 case EMR_INVERTRGN :SAL_WARN("emfio", "not 
implemented 'InvertRgn'"); break;
-case EMR_PAINTRGN : SAL_WARN("emfio", "not 
implemented 'PaintRgn'");  break;
 case EMR_FLATTENPATH :  SAL_WARN("emfio", "not 
implemented 'FlattenPath'");   break;
 case EMR_WIDENPATH :SAL_WARN("emfio", "not 
implemented 'WidenPath'"); break;
 case EMR_POLYDRAW : SAL_WARN("emfio", "not 
implemented 'Polydraw'");  break;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/source include/vcl vcl/inc vcl/source

2021-03-10 Thread Armin Le Grand (Allotropia) (via logerrit)
 emfio/source/reader/mtftools.cxx |   20 ++-
 include/vcl/font.hxx |3 ++
 vcl/inc/impfont.hxx  |   21 +++
 vcl/source/filter/wmf/emfwr.cxx  |   27 +++--
 vcl/source/font/font.cxx |   41 +++
 5 files changed, 108 insertions(+), 4 deletions(-)

New commits:
commit 125efab4d8573fda1882a542f6fb669c7fc12b56
Author: Armin Le Grand (Allotropia) 
AuthorDate: Tue Feb 16 18:20:32 2021 +0100
Commit: Armin Le Grand 
CommitDate: Wed Mar 10 09:41:39 2021 +0100

tdf#127471 correct EMF/WMF im/export for scaled font

If FontScaling is used, system-dependent data is held at
vcl::Font Width(). Already if not scaled, we have three
definitions: Width is zero, Width is equal to Height (unx)
or - on Windows - Width equals avgFontWidth.
If used it is W!=H where on unx Width equals Height multiplied
with the scale factor. On Windows, this is Width multiplied
with the only there existing avgFontWidth.
Unfortunately that is ex/imported (since ever) undetected
to EMF/WMF thus making EMF/WMF files containing FontScaling
system-dependent - on which system was LO running when
creating the file? The error can be seen when loading such
a EMF/WMF on the vice-versa system, the FontScale is very
ugly and wrong.
Since EMF/WMF *are* Windows-specific formats the Windows-like
definition is the correct one. This change makes all other
systems export that now, and adapt on import to their system-
specific definition (assuming coming from Windows).
As can be seen, the difficulty is that these adaptions are
necessary on non-Windows plattforms, but these do not have
that avgFontWidth available. Thus I made a deep-dive
investigation and multiple experiments to create a as
similar as possible value to apply the needed calculations.
For details and discussion refer to the bug description.

Change-Id: I983fb6d882e2e8fccf9c8460f01509201d8157f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111000
Tested-by: Jenkins
Reviewed-by: Armin Le Grand 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112089

diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 778adeb429ba..7a462cc659dd 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -277,8 +277,26 @@ namespace emfio
 
 // Convert height to positive
 aFontSize.setHeight( std::abs(aFontSize.Height()) );
-
 aFont.SetFontSize(aFontSize);
+
+// tdf#127471 adapt nFontWidth from Windows-like notation to
+// NormedFontScaling if used for text scaling
+#ifndef _WIN32
+const bool bFontScaledHorizontally(aFontSize.Width() != 0 && 
aFontSize.Width() != aFontSize.Height());
+
+if(bFontScaledHorizontally)
+{
+// tdf#127471 nFontWidth is the Windows FontScaling, need to 
convert to
+// Non-Windowslike notation relative to FontHeight.
+const tools::Long 
nAverageFontWidth(aFont.GetOrCalculateAverageFontWidth());
+
+if(nAverageFontWidth > 0)
+{
+const double 
fScaleFactor(static_cast(aFontSize.Height()) / 
static_cast(nAverageFontWidth));
+
aFont.SetAverageFontWidth(static_cast(static_cast(aFontSize.Width())
 * fScaleFactor));
+}
+}
+#endif
 };
 
 Color MtfTools::ReadColor()
diff --git a/include/vcl/font.hxx b/include/vcl/font.hxx
index 2d437c5b3da0..3147f57aba14 100644
--- a/include/vcl/font.hxx
+++ b/include/vcl/font.hxx
@@ -113,6 +113,9 @@ public:
 voidSetAverageFontWidth( tools::Long nWidth );
 tools::LongGetAverageFontWidth() const;
 
+// tdf#127471 for corrections on EMF/WMF we need the AvgFontWidth in 
Windows-specific notation
+tools::Long GetOrCalculateAverageFontWidth() const;
+
 // Prefer LanguageTag over LanguageType
 voidSetLanguageTag( const LanguageTag & );
 const LanguageTag&  GetLanguageTag() const;
diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx
index ba1ea3683926..14a2189d3921 100644
--- a/vcl/inc/impfont.hxx
+++ b/vcl/inc/impfont.hxx
@@ -62,7 +62,18 @@ public:
 voidSetWidthType( const FontWidth eWidthType )  { 
meWidthType = eWidthType; }
 voidSetAlignment( const TextAlign eAlignment )  { 
meAlign = eAlignment; }
 voidSetCharSet( const rtl_TextEncoding eCharSet )   { 
meCharSet = eCharSet; }
-voidSetFontSize( const Size& rSize ) { 
maAverageFontSize = rSize; }
+voidSetFontSize( const Size& rSize )
+{
+#ifndef _WIN32
+if(rSize.Height() != maAverageFontSize.Height())
+{
+// reset evtl. buffered calculated AverageFontSize, it depends
+// on 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/source

2020-12-07 Thread Caolán McNamara (via logerrit)
 emfio/source/reader/mtftools.cxx |   50 +++
 1 file changed, 40 insertions(+), 10 deletions(-)

New commits:
commit 943dce614a796801e84b83e3cacc17e5432e8aa4
Author: Caolán McNamara 
AuthorDate: Fri Dec 4 09:42:15 2020 +
Commit: Caolán McNamara 
CommitDate: Mon Dec 7 09:41:06 2020 +0100

ofz#28271 divide-by-zero

Change-Id: Ib3f47dcb0a5e327f5385ccff328f410a15b2cc91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107202
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 9ad212b17dfa..778adeb429ba 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -322,8 +322,14 @@ namespace emfio
 fY2  = mnWinOrgY-fY2;
 fX2 *= HUNDREDTH_MILLIMETERS_PER_MILLIINCH * 10;
 fY2 *= HUNDREDTH_MILLIMETERS_PER_MILLIINCH * 10;
-fX2 += mnDevOrgX * static_cast(mnMillX) * 
100.0 / static_cast(mnPixX);
-fY2 += mnDevOrgY * static_cast(mnMillY) * 
100.0 / static_cast(mnPixY);
+double nDevOrgX = mnDevOrgX;
+if (mnPixX)
+nDevOrgX *= static_cast(mnMillX) * 100.0 / 
static_cast(mnPixX);
+fX2 += nDevOrgX;
+double nDevOrgY = mnDevOrgY;
+if (mnPixY)
+nDevOrgY *= static_cast(mnMillY) * 100.0 / 
static_cast(mnPixY);
+fY2 += nDevOrgY;
 }
 break;
 case MM_HIENGLISH :
@@ -332,8 +338,14 @@ namespace emfio
 fY2  = mnWinOrgY-fY2;
 fX2 *= HUNDREDTH_MILLIMETERS_PER_MILLIINCH;
 fY2 *= HUNDREDTH_MILLIMETERS_PER_MILLIINCH;
-fX2 += mnDevOrgX * static_cast(mnMillX) * 
100.0 / static_cast(mnPixX);
-fY2 += mnDevOrgY * static_cast(mnMillY) * 
100.0 / static_cast(mnPixY);
+double nDevOrgX = mnDevOrgX;
+if (mnPixX)
+nDevOrgX *= static_cast(mnMillX) * 100.0 / 
static_cast(mnPixX);
+fX2 += nDevOrgX;
+double nDevOrgY = mnDevOrgY;
+if (mnPixY)
+nDevOrgY *= static_cast(mnMillY) * 100.0 / 
static_cast(mnPixY);
+fY2 += nDevOrgY;
 }
 break;
 case MM_TWIPS:
@@ -342,8 +354,14 @@ namespace emfio
 fY2  = mnWinOrgY-fY2;
 fX2 *= HUNDREDTH_MILLIMETERS_PER_MILLIINCH / 
MILLIINCH_PER_TWIPS;
 fY2 *= HUNDREDTH_MILLIMETERS_PER_MILLIINCH / 
MILLIINCH_PER_TWIPS;
-fX2 += mnDevOrgX * static_cast(mnMillX) * 
100.0 / static_cast(mnPixX);
-fY2 += mnDevOrgY * static_cast(mnMillY) * 
100.0 / static_cast(mnPixY);
+double nDevOrgX = mnDevOrgX;
+if (mnPixX)
+nDevOrgX *= static_cast(mnMillX) * 100.0 / 
static_cast(mnPixX);
+fX2 += nDevOrgX;
+double nDevOrgY = mnDevOrgY;
+if (mnPixY)
+nDevOrgY *= static_cast(mnMillY) * 100.0 / 
static_cast(mnPixY);
+fY2 += nDevOrgY;
 }
 break;
 case MM_LOMETRIC :
@@ -352,16 +370,28 @@ namespace emfio
 fY2  = mnWinOrgY-fY2;
 fX2 *= 10;
 fY2 *= 10;
-fX2 += mnDevOrgX * static_cast(mnMillX) * 
100.0 / static_cast(mnPixX);
-fY2 += mnDevOrgY * static_cast(mnMillY) * 
100.0 / static_cast(mnPixY);
+double nDevOrgX = mnDevOrgX;
+if (mnPixX)
+nDevOrgX *= static_cast(mnMillX) * 100.0 / 
static_cast(mnPixX);
+fX2 += nDevOrgX;
+double nDevOrgY = mnDevOrgY;
+if (mnPixY)
+nDevOrgY *= static_cast(mnMillY) * 100.0 / 
static_cast(mnPixY);
+fY2 += nDevOrgY;
 }
 break;
 case MM_HIMETRIC : // in hundredth of a millimeter
 {
 fX2 -= mnWinOrgX;
 fY2  = mnWinOrgY-fY2;
-fX2 += mnDevOrgX * static_cast(mnMillX) * 
100.0 / static_cast(mnPixX);
-fY2 += mnDevOrgY * static_cast(mnMillY) * 
100.0 / static_cast(mnPixY);
+double nDevOrgX = mnDevOrgX;
+