diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-12-08 11:20:15 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-12-10 09:22:20 +0000 |
commit | 993dae8a904b07b6db2b8854feae353f42836c5a (patch) | |
tree | 3a20307d7724ad6d05e6e564c9d161890b2c39b6 /svtools/source | |
parent | sw: unused SwRTFParser (diff) | |
download | core-993dae8a904b07b6db2b8854feae353f42836c5a.tar.gz core-993dae8a904b07b6db2b8854feae353f42836c5a.zip |
guard against div by 0
Change-Id: I7dbdc374246130acafb0f3ea1a4e91ec93c4473c
Diffstat (limited to 'svtools/source')
-rw-r--r-- | svtools/source/filter/wmf/emfwr.cxx | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/svtools/source/filter/wmf/emfwr.cxx b/svtools/source/filter/wmf/emfwr.cxx index 39e33c078909..bb2f2404c27d 100644 --- a/svtools/source/filter/wmf/emfwr.cxx +++ b/svtools/source/filter/wmf/emfwr.cxx @@ -284,14 +284,25 @@ void EMFWriter::ImplPlusRecord( sal_uInt16 nType, sal_uInt16 nFlags ) void EMFWriter::WriteEMFPlusHeader( const Size &rMtfSizePix, const Size &rMtfSizeLog ) { ImplBeginCommentRecord( WIN_EMR_COMMENT_EMFPLUS ); + + sal_Int32 nDPIX = rMtfSizePix.Width()*25; + sal_Int32 nDivX = rMtfSizeLog.Width()/100; + if (nDivX) + nDPIX /= nDivX; // DPI X + + sal_Int32 nDPIY = rMtfSizePix.Height()*25; + sal_Int32 nDivY = rMtfSizeLog.Height()/100; + if (nDivY) + nDPIY /= nDivY; // DPI Y + m_rStm<< (sal_Int16) EmfPlusHeader; m_rStm<< (sal_Int16) 0x01 // Flags - Dual Mode // TODO: Check this << (sal_Int32) 0x1C // Size << (sal_Int32) 0x10 // Data Size << (sal_Int32) 0xdbc01002 // (lower 12bits) 1-> v1 2-> v1.1 // TODO: Check this << (sal_Int32) 0x01 // Video display - << (sal_Int32) ( rMtfSizePix.Width()*25 / (rMtfSizeLog.Width()/100) ) // DPI X - << (sal_Int32) ( rMtfSizePix.Height()*25 / (rMtfSizeLog.Height()/100) ); // DPI Y + << nDPIX + << nDPIY; ImplEndCommentRecord(); // Write more properties |