[Libreoffice-commits] core.git: sd/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 3 15:32:24 UTC 2020


 sd/source/core/sdpage.cxx |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 60797d61e4d8641a4177089b204c1af8c8a3b594
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Apr 3 16:40:18 2020 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Apr 3 17:31:37 2020 +0200

    Fix uses of MAX_PRESOBJS
    
    ...broken in 10055ff899ed8f9c205155cd15c6de81cba37471 "convert PresObjKind to
    scoped enum", causing CppunitTest_sd_import_tests to fail with
    
    > sd/source/core/sdpage.cxx:1462:68: runtime error: index 7 out of bounds for type 'PresObjKind const[7]'
    >  #0 in findAutoLayoutShapesImpl(SdPage&, (anonymous namespace)::LayoutDescriptor const&, std::__debug::array<SdrObject*, 7ul>&, bool, bool) at sd/source/core/sdpage.cxx:1462:68
    >  #1 in SdPage::SetAutoLayout(AutoLayout, bool, bool) at sd/source/core/sdpage.cxx:1639:5
    >  #2 in SdGenericDrawPage::setPropertyValue(rtl::OUString const&, com::sun::star::uno::Any const&) at sd/source/ui/unoidl/unopage.cxx:624:28
    [...]
    
    Change-Id: I04a0b87e952ff2a93f939221cc424d83a59df9a9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91644
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 8f697e1ec2f5..7f8178dea79f 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -1459,7 +1459,7 @@ static void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDe
     bool bMissing = false;
 
     // for each entry in the layoutdescriptor, arrange a presentation shape
-    for (int i = 0; (i <= static_cast<int>(PresObjKind::LAST)) && (rDescriptor.meKind[i] != PresObjKind::NONE); i++)
+    for (int i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PresObjKind::NONE); i++)
     {
         PresObjKind eKind = rDescriptor.meKind[i];
         SdrObject* pObj = nullptr;
@@ -1482,7 +1482,7 @@ static void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDe
         return;
 
     // for each entry in the layoutdescriptor, look for an alternative shape
-    for (int i = 0; (i <= static_cast<int>(PresObjKind::LAST)) && (rDescriptor.meKind[i] != PresObjKind::NONE); i++)
+    for (int i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PresObjKind::NONE); i++)
     {
         if( rShapes[i] )
             continue;
@@ -1639,7 +1639,7 @@ void SdPage::SetAutoLayout(AutoLayout eLayout, bool bInit, bool bCreate )
     findAutoLayoutShapesImpl( *this, aDescriptor, aLayoutShapes, bInit, bSwitchLayout );
 
     // for each entry in the layoutdescriptor, arrange a presentation shape
-    for (int i = 0; (i <= static_cast<int>(PresObjKind::LAST)) && (aDescriptor.meKind[i] != PresObjKind::NONE); i++)
+    for (int i = 0; (i < MAX_PRESOBJS) && (aDescriptor.meKind[i] != PresObjKind::NONE); i++)
     {
         PresObjKind eKind = aDescriptor.meKind[i];
         SdrObject* pObj = InsertAutoLayoutShape( aLayoutShapes[i], eKind, aDescriptor.mbVertical[i], aRectangle[i], bInit );


More information about the Libreoffice-commits mailing list