oox/inc/drawingml/textbodycontext.hxx                   |    1 +
 oox/inc/drawingml/textparagraphpropertiescontext.hxx    |    1 +
 oox/source/drawingml/textbodycontext.cxx                |   10 ++++++----
 oox/source/drawingml/textparagraphpropertiescontext.cxx |    8 +++++++-
 4 files changed, 15 insertions(+), 5 deletions(-)

New commits:
commit 56cb2a301acd0443e777094bda32a8e0d9e802ca
Author:     Dr. David Alan Gilbert <[email protected]>
AuthorDate: Tue Oct 14 01:58:15 2025 +0100
Commit:     David Gilbert <[email protected]>
CommitDate: Thu Oct 30 16:01:25 2025 +0100

    tdf#168406: oox: Restart numbering after non-numbered element
    
    If we get a numbered list element, followed by a non-numbered element
    then another numbered element it looks like pptx expects
    the numbering to restart.
    
    There are two halfs to this:
    
    a) when we find ourselves in a numbered list (buAutoNum) we record
    it in the recently added tracking mask, and if it turns out we
    just entered the list trigger the numbering restart.
    
    b) We have to detect when we get a paragraph which isn't numbered -
    i.e. doesn't have buAutoNum (it turns out there are cases without
    buNone), and when we detect that update the list tracking mask.
    
    Change-Id: I9951147b3b7ec78009f2f87c93bbda9a17c0db28
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192414
    Reviewed-by: David Gilbert <[email protected]>
    Tested-by: Jenkins

diff --git a/oox/inc/drawingml/textparagraphpropertiescontext.hxx 
b/oox/inc/drawingml/textparagraphpropertiescontext.hxx
index d18febc09bbf..f0e120b2da75 100644
--- a/oox/inc/drawingml/textparagraphpropertiescontext.hxx
+++ b/oox/inc/drawingml/textparagraphpropertiescontext.hxx
@@ -53,6 +53,7 @@ private:
     // If bit 'n' is 1 then we're in a numbered list at that level
     // (n=0 is what pptx calls level 1)
     uint16_t*              mpListNumberingMask;
+    bool                   mbHaveNum;
 };
 
 }
diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx 
b/oox/source/drawingml/textparagraphpropertiescontext.cxx
index 6004e730a9b1..3cae4f89e6a5 100644
--- a/oox/source/drawingml/textparagraphpropertiescontext.cxx
+++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx
@@ -82,6 +82,7 @@ 
TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H
 , mrTextParagraphProperties( rTextParagraphProperties )
 , mrBulletList( rTextParagraphProperties.getBulletList() )
 , mpListNumberingMask( pListNumberingMask )
+, mbHaveNum( false )
 {
     OUString sValue;
 
@@ -191,6 +192,8 @@ 
TextParagraphPropertiesContext::~TextParagraphPropertiesContext()
         mrBulletList.setBulletAspectRatio( 
lclGetGraphicAspectRatio(mxBlipProps->mxFillGraphic) );
     }
 
+    if( !mbHaveNum )
+        markListUnnumbered();
     if( mrBulletList.is() )
         rPropertyMap.setProperty( PROP_IsNumbering, true);
     sal_Int16 nLevel = mrTextParagraphProperties.getLevel();
@@ -289,10 +292,13 @@ ContextHandlerRef 
TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl
             break;
         case A_TOKEN( buAutoNum ):      // CT_TextAutonumberBullet
         {
+            bool bStartingNumList = markListNumbered();
+            mbHaveNum = true;
+
             try {
                 sal_Int32 nType = rAttribs.getToken( XML_type, 0 );
                 sal_Int32 nStartAt = rAttribs.getInteger( XML_startAt, -1 );
-                if( nStartAt >= 0 )
+                if( nStartAt >= 0 || bStartingNumList )
                 {
                     mrTextParagraphProperties.setRestartNumbering(true);
                 }
commit faa921bfe2344a5247376b10c2f54b017762ba0e
Author:     Dr. David Alan Gilbert <[email protected]>
AuthorDate: Tue Oct 14 21:27:13 2025 +0100
Commit:     David Gilbert <[email protected]>
CommitDate: Thu Oct 30 16:01:16 2025 +0100

    tdf#168406: oox: Track numbered list state in Text body
    
    Use the newly added numbered list tracking in TextBodyContext.
    This is the normal case of a list on a slide.
    
    Change-Id: I3968c2c561cc49bac82871c1432508ee5ee49218
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192413
    Tested-by: Jenkins
    Reviewed-by: David Gilbert <[email protected]>

diff --git a/oox/inc/drawingml/textbodycontext.hxx 
b/oox/inc/drawingml/textbodycontext.hxx
index e5d41122ee8f..36a2e1d9791d 100644
--- a/oox/inc/drawingml/textbodycontext.hxx
+++ b/oox/inc/drawingml/textbodycontext.hxx
@@ -37,6 +37,7 @@ public:
 private:
     TextBody&           mrTextBody;
     ShapePtr            mpShapePtr;
+    uint16_t            mListNumberingMask;
 };
 
 // CT_RegularTextRun
diff --git a/oox/source/drawingml/textbodycontext.cxx 
b/oox/source/drawingml/textbodycontext.cxx
index ce8de24a09be..17a02b8b2a61 100644
--- a/oox/source/drawingml/textbodycontext.cxx
+++ b/oox/source/drawingml/textbodycontext.cxx
@@ -49,19 +49,21 @@ namespace {
 class TextParagraphContext : public ContextHandler2
 {
 public:
-    TextParagraphContext( ContextHandler2Helper const & rParent, 
TextParagraph& rPara );
+    TextParagraphContext( ContextHandler2Helper const & rParent, 
TextParagraph& rPara, uint16_t& rListNumberingMask );
 
     virtual ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const 
AttributeList& rAttribs ) override;
 
 protected:
     TextParagraph& mrParagraph;
+    uint16_t& mrListNumberingMask;
 };
 
 }
 
-TextParagraphContext::TextParagraphContext( ContextHandler2Helper const & 
rParent, TextParagraph& rPara )
+TextParagraphContext::TextParagraphContext( ContextHandler2Helper const & 
rParent, TextParagraph& rPara, uint16_t& rListNumberingMask )
 : ContextHandler2( rParent )
 , mrParagraph( rPara )
+, mrListNumberingMask( rListNumberingMask )
 {
     mbEnableTrimSpace = false;
 }
@@ -94,7 +96,7 @@ ContextHandlerRef TextParagraphContext::onCreateContext( 
sal_Int32 aElementToken
         case A_TOKEN( pPr ):
         case W_TOKEN( pPr ):
             mrParagraph.setHasProperties();
-            return new TextParagraphPropertiesContext( *this, rAttribs, 
mrParagraph.getProperties() );
+            return new TextParagraphPropertiesContext( *this, rAttribs, 
mrParagraph.getProperties(), &mrListNumberingMask );
         case A_TOKEN( endParaRPr ):
             return new TextCharacterPropertiesContext( *this, rAttribs, 
mrParagraph.getEndProperties() );
         case W_TOKEN( sdt ):
@@ -201,7 +203,7 @@ ContextHandlerRef TextBodyContext::onCreateContext( 
sal_Int32 aElementToken, con
             return new TextListStyleContext( *this, 
mrTextBody.getTextListStyle() );
         case A_TOKEN( p ):          // CT_TextParagraph
         case W_TOKEN( p ):
-            return new TextParagraphContext( *this, mrTextBody.addParagraph() 
);
+            return new TextParagraphContext( *this, mrTextBody.addParagraph(), 
mListNumberingMask );
         case W_TOKEN( sdt ):
         case W_TOKEN( sdtContent ):
             return this;

Reply via email to