summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-05-09 15:38:17 +0200
committerStephan Bergmann <sbergman@redhat.com>2018-05-09 21:00:32 +0200
commitc330f795ae1e2515e5663e70426334659c2d8506 (patch)
treeb60c24bf9a6bcfc734a121396d91ebda29c8ec9a /sd
parent1c0035230c410f948a4dad718f2a942cdd7d20fe (diff)
Avoid division by zero
...as happens during CppunitTest_sd_export_tests: > sd/source/filter/eppt/epptso.cxx:118:76: runtime error: division by zero > #0 in PPTExBulletProvider::GetId(Graphic const&, Size&) at sd/source/filter/eppt/epptso.cxx:118:76 (instdir/program/libsdfiltlo.so +0x38e7e7) > #1 in ParagraphObj::ImplGetNumberingLevel(PPTExBulletProvider*, short, bool, bool) at sd/source/filter/eppt/pptx-text.cxx:897:46 (instdir/program/libsdfiltlo.so +0x55464d) > #2 in ParagraphObj::ImplGetParagraphValues(PPTExBulletProvider*, bool) at sd/source/filter/eppt/pptx-text.cxx:1114:5 (instdir/program/libsdfiltlo.so +0x54c01d) > #3 in ParagraphObj::ParagraphObj(com::sun::star::uno::Reference<com::sun::star::text::XTextContent> const&, ParaFlags, FontCollection&, PPTExBulletProvider&) at sd/source/filter/eppt/pptx-text.cxx:741:9 (instdir/program/libsdfiltlo.so +0x54e373) > #4 in TextObj::TextObj(com::sun::star::uno::Reference<com::sun::star::text::XSimpleText> const&, int, FontCollection&, PPTExBulletProvider&) at sd/source/filter/eppt/pptx-text.cxx:1313:47 (instdir/program/libsdfiltlo.so +0x5574a4) > #5 in TextObjBinary::TextObjBinary(com::sun::star::uno::Reference<com::sun::star::text::XSimpleText> const&, int, FontCollection&, PPTExBulletProvider&) at sd/source/filter/eppt/eppt.hxx:141:101 (instdir/program/libsdfiltlo.so +0x4068e7) > #6 in PPTWriter::ImplWritePage(PHLayout const&, EscherSolverContainer&, PageType, bool, int) at sd/source/filter/eppt/epptso.cxx:2367:39 (instdir/program/libsdfiltlo.so +0x3dc5bb) > #7 in PPTWriter::ImplWriteSlide(unsigned int, unsigned int, unsigned short, bool, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) at sd/source/filter/eppt/eppt.cxx:312:5 (instdir/program/libsdfiltlo.so +0x327239) > #8 in PPTWriterBase::CreateSlide(unsigned int) at sd/source/filter/eppt/pptx-epptbase.cxx:399:5 (instdir/program/libsdfiltlo.so +0x49896a) > #9 in PPTWriterBase::exportPPT(std::__debug::vector<com::sun::star::beans::PropertyValue, std::allocator<com::sun::star::beans::PropertyValue> > const&) at sd/source/filter/eppt/pptx-epptbase.cxx:233:15 (instdir/program/libsdfiltlo.so +0x48ff5e) > #10 in ExportPPT at sd/source/filter/eppt/eppt.cxx:1451:17 (instdir/program/libsdfiltlo.so +0x34dfdc) > #11 in SdPPTFilter::Export() at sd/source/filter/sdpptwrp.cxx:173:24 (instdir/program/libsdlo.so +0x26b070d) > #12 in sd::DrawDocShell::ConvertTo(SfxMedium&) at sd/source/ui/docshell/docshel4.cxx:662:29 (instdir/program/libsdlo.so +0x2c454b7) > #13 in SfxObjectShell::SaveTo_Impl(SfxMedium&, SfxItemSet const*) at sfx2/source/doc/objstor.cxx:1508:19 (instdir/program/libsfxlo.so +0x2baa19d) > #14 in SfxObjectShell::PreDoSaveAs_Impl(rtl::OUString const&, rtl::OUString const&, SfxItemSet const&) at sfx2/source/doc/objstor.cxx:2792:39 (instdir/program/libsfxlo.so +0x2bcdc17) > #15 in SfxObjectShell::CommonSaveAs_Impl(INetURLObject const&, rtl::OUString const&, SfxItemSet&) at sfx2/source/doc/objstor.cxx:2650:9 (instdir/program/libsfxlo.so +0x2bc86cf) > #16 in SfxObjectShell::APISaveAs_Impl(rtl::OUString const&, SfxItemSet&) at sfx2/source/doc/objserv.cxx:302:19 (instdir/program/libsfxlo.so +0x2b69519) > #17 in SfxBaseModel::impl_store(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, bool) at sfx2/source/doc/sfxbasemodel.cxx:2959:46 (instdir/program/libsfxlo.so +0x2cbd740) > #18 in SfxBaseModel::storeToURL(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at sfx2/source/doc/sfxbasemodel.cxx:1638:13 (instdir/program/libsfxlo.so +0x2cc26b5) > #19 in SdExportTest::testBulletsAsImage() at sd/qa/unit/export-tests.cxx:934:20 (workdir/LinkTarget/CppunitTest/libtest_sd_export_tests.so +0x8988c) Change-Id: I516bb2367d6a7fae23e2d474e63ab50af925208b Reviewed-on: https://gerrit.libreoffice.org/54034 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/filter/eppt/epptso.cxx47
1 files changed, 31 insertions, 16 deletions
diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx
index 7ca401b50dff..d3a017236c72 100644
--- a/sd/source/filter/eppt/epptso.cxx
+++ b/sd/source/filter/eppt/epptso.cxx
@@ -115,26 +115,41 @@ sal_uInt16 PPTExBulletProvider::GetId(Graphic const & rGraphic, Size& rGraphicSi
if ( rGraphicSize.Width() && rGraphicSize.Height() )
{
- double fQ1 = ( static_cast<double>(aPrefSize.Width()) / static_cast<double>(aPrefSize.Height()) );
- double fQ2 = ( static_cast<double>(rGraphicSize.Width()) / static_cast<double>(rGraphicSize.Height()) );
- double fXScale = 1;
- double fYScale = 1;
+ Size aNewSize;
+ bool changed = false;
+ if (aPrefSize.Width() == 0 || aPrefSize.Height() == 0)
+ {
+ aBmpEx.Scale(aPrefSize);
+ aNewSize = aPrefSize;
+ changed = true;
+ }
+ else
+ {
+ double fQ1 = ( static_cast<double>(aPrefSize.Width()) / static_cast<double>(aPrefSize.Height()) );
+ double fQ2 = ( static_cast<double>(rGraphicSize.Width()) / static_cast<double>(rGraphicSize.Height()) );
+ double fXScale = 1;
+ double fYScale = 1;
- if ( fQ1 > fQ2 )
- fYScale = fQ1 / fQ2;
- else if ( fQ1 < fQ2 )
- fXScale = fQ2 / fQ1;
+ if ( fQ1 > fQ2 )
+ fYScale = fQ1 / fQ2;
+ else if ( fQ1 < fQ2 )
+ fXScale = fQ2 / fQ1;
- if ( ( fXScale != 1.0 ) || ( fYScale != 1.0 ) )
- {
- aBmpEx.Scale( fXScale, fYScale );
- Size aNewSize( static_cast<sal_Int32>(static_cast<double>(rGraphicSize.Width()) / fXScale + 0.5 ),
- static_cast<sal_Int32>(static_cast<double>(rGraphicSize.Height()) / fYScale + 0.5 ) );
+ if ( ( fXScale != 1.0 ) || ( fYScale != 1.0 ) )
+ {
+ aBmpEx.Scale( fXScale, fYScale );
+ aNewSize = Size( static_cast<sal_Int32>(static_cast<double>(rGraphicSize.Width()) / fXScale + 0.5 ),
+ static_cast<sal_Int32>(static_cast<double>(rGraphicSize.Height()) / fYScale + 0.5 ) );
+ changed = true;
+ }
- rGraphicSize = aNewSize;
+ if (changed)
+ {
+ rGraphicSize = aNewSize;
- aMappedGraphic = Graphic( aBmpEx );
- xGraphicObject.reset(new GraphicObject(aMappedGraphic));
+ aMappedGraphic = Graphic( aBmpEx );
+ xGraphicObject.reset(new GraphicObject(aMappedGraphic));
+ }
}
}
sal_uInt32 nId = pGraphicProv->GetBlibID(aBuExPictureStream, *xGraphicObject.get());