cui/inc/strings.hrc                                        |    1 
 cui/source/inc/autocdlg.hxx                                |    1 
 cui/source/tabpages/autocdlg.cxx                           |    8 ++
 editeng/source/misc/acorrcfg.cxx                           |    3 
 editeng/source/misc/swafopt.cxx                            |    1 
 include/editeng/swafopt.hxx                                |    1 
 officecfg/registry/schema/org/openoffice/Office/Writer.xcs |    8 ++
 sw/inc/editsh.hxx                                          |    2 
 sw/qa/core/doc/doc.cxx                                     |   51 +++++++++++++
 sw/qa/uitest/writer_tests/tdf156165.py                     |    4 -
 sw/source/core/edit/autofmt.cxx                            |   46 ++++++++---
 sw/source/uibase/docvw/edtwin.cxx                          |   15 +++
 sw/source/uibase/shells/textsh1.cxx                        |    4 -
 13 files changed, 129 insertions(+), 16 deletions(-)

New commits:
commit c4fc18308074634e9578ad12d94d937f259aa22a
Author:     Darshan-upadhyay1110 <darshan.upadh...@collabora.com>
AuthorDate: Fri Sep 1 16:08:58 2023 +0530
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Thu Sep 7 09:18:50 2023 +0200

    Autocorrect: Add option for autoformat bulleted lists after space
    
    Enable option in Autocoorect => bulleted lists after pressing space
    Example: press * or - and space will change into bullets
    
    Change-Id: I9741ad4c3eb4123074f06b762b58fe7ffdb44613
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156616
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc
index ffcf10e73556..29126053d968 100644
--- a/cui/inc/strings.hrc
+++ b/cui/inc/strings.hrc
@@ -334,6 +334,7 @@
 // To translators: %1 will be replaced with a percentage, e.g. "10%"
 #define RID_CUISTR_RIGHT_MARGIN                     
NC_("RID_SVXSTR_RIGHT_MARGIN", "Combine single line paragraphs if length 
greater than %1")
 #define RID_CUISTR_NUM                              NC_("RID_SVXSTR_NUM", 
"Bulleted and numbered lists. Bullet symbol: %1")
+#define RID_SVXSTR_NUM_FORMAT_AFTER_SPACE           
NC_("RID_SVXSTR_NUM_FORMAT_AFTER_SPACE", "Bulleted and numbered lists immediate 
after pressing space")
 #define RID_CUISTR_BORDER                           NC_("RID_SVXSTR_BORDER", 
"Apply border")
 #define RID_CUISTR_CREATE_TABLE                     
NC_("RID_SVXSTR_CREATE_TABLE", "Create table")
 #define RID_CUISTR_REPLACE_TEMPLATES                
NC_("RID_SVXSTR_REPLACE_TEMPLATES", "Apply Styles")
diff --git a/cui/source/inc/autocdlg.hxx b/cui/source/inc/autocdlg.hxx
index 2357677ef65f..2677b8535ebe 100644
--- a/cui/source/inc/autocdlg.hxx
+++ b/cui/source/inc/autocdlg.hxx
@@ -97,6 +97,7 @@ class OfaSwAutoFmtOptionsPage : public SfxTabPage
     OUString        sDash;
     OUString        sRightMargin;
     OUString        sNum;
+    OUString        sBulletsAfterSpace;
     OUString        sBorder;
     OUString        sTable;
     OUString        sReplaceTemplates;
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index a23fc2015ebf..282e8b5405a1 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -344,6 +344,7 @@ enum OfaAutoFmtOptions
     IGNORE_DBLSPACE,
     CORRECT_CAPS_LOCK,
     APPLY_NUMBERING,
+    APPLY_NUMBERING_AFTER_SPACE,
     INSERT_BORDER,
     CREATE_TABLE,
     REPLACE_STYLES,
@@ -372,6 +373,7 @@ 
OfaSwAutoFmtOptionsPage::OfaSwAutoFmtOptionsPage(weld::Container* pPage, weld::D
     , sDash(CuiResId(RID_CUISTR_DASH))
     , sRightMargin(CuiResId(RID_CUISTR_RIGHT_MARGIN))
     , sNum(CuiResId(RID_CUISTR_NUM))
+    , sBulletsAfterSpace(CuiResId(RID_SVXSTR_NUM_FORMAT_AFTER_SPACE))
     , sBorder(CuiResId(RID_CUISTR_BORDER))
     , sTable(CuiResId(RID_CUISTR_CREATE_TABLE))
     , sReplaceTemplates(CuiResId(RID_CUISTR_REPLACE_TEMPLATES))
@@ -498,6 +500,10 @@ bool OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet*  )
     bModified |= pOpt->bSetNumRule != bCheck;
     pOpt->bSetNumRule = bCheck;
 
+    bCheck = m_xCheckLB->get_toggle(APPLY_NUMBERING_AFTER_SPACE, CBCOL_SECOND) 
== TRISTATE_TRUE;
+    bModified |= pOpt->bSetNumRuleAfterSpace != bCheck;
+    pOpt->bSetNumRuleAfterSpace = bCheck;
+
     bCheck = m_xCheckLB->get_toggle(INSERT_BORDER, CBCOL_SECOND) == 
TRISTATE_TRUE;
     bModified |= pOpt->bSetBorder != bCheck;
     pOpt->bSetBorder = bCheck;
@@ -578,6 +584,7 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* )
     CreateEntry(sNoDblSpaces,       CBCOL_SECOND);
     CreateEntry(sCorrectCapsLock,   CBCOL_SECOND);
     CreateEntry(sNum.replaceFirst("%1", sBulletChar), CBCOL_SECOND);
+    CreateEntry(sBulletsAfterSpace,  CBCOL_SECOND);
     CreateEntry(sBorder,            CBCOL_SECOND);
     CreateEntry(sTable,             CBCOL_SECOND);
     CreateEntry(sReplaceTemplates,  CBCOL_SECOND);
@@ -607,6 +614,7 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* )
     m_xCheckLB->set_toggle(IGNORE_DBLSPACE, bool(nFlags & 
ACFlags::IgnoreDoubleSpace) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
     m_xCheckLB->set_toggle(CORRECT_CAPS_LOCK, bool(nFlags & 
ACFlags::CorrectCapsLock) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
     m_xCheckLB->set_toggle(APPLY_NUMBERING, pOpt->bSetNumRule ? TRISTATE_TRUE 
: TRISTATE_FALSE, CBCOL_SECOND);
+    m_xCheckLB->set_toggle(APPLY_NUMBERING_AFTER_SPACE, 
pOpt->bSetNumRuleAfterSpace ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
     m_xCheckLB->set_toggle(INSERT_BORDER, pOpt->bSetBorder ? TRISTATE_TRUE : 
TRISTATE_FALSE, CBCOL_SECOND);
     m_xCheckLB->set_toggle(CREATE_TABLE, pOpt->bCreateTable ? TRISTATE_TRUE : 
TRISTATE_FALSE, CBCOL_SECOND);
     m_xCheckLB->set_toggle(REPLACE_STYLES, pOpt->bReplaceStyles ? 
TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
diff --git a/editeng/source/misc/acorrcfg.cxx b/editeng/source/misc/acorrcfg.cxx
index d07dbf0caa30..47f634d4347f 100644
--- a/editeng/source/misc/acorrcfg.cxx
+++ b/editeng/source/misc/acorrcfg.cxx
@@ -421,6 +421,7 @@ Sequence<OUString>  SvxSwAutoCorrCfg::GetPropertyNames()
         "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset",   //45
         "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch",     //46
         "Format/Option/SetDOIAttribute",                                //47
+        "Format/ByInput/ApplyNumberingAfterSpace",                      //48
     };
     const int nCount = 48;
     Sequence<OUString> aNames(nCount);
@@ -573,6 +574,7 @@ void SvxSwAutoCorrCfg::Load(bool bInit)
                 }
                 break;// 
"Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch",
                 case   47: rSwFlags.bSetDOIAttr = 
*o3tl::doAccess<bool>(pValues[nProp]); break; // 
"Format/Option/SetDOIAttribute",
+                case 48 : rSwFlags.bSetNumRuleAfterSpace = 
*o3tl::doAccess<bool>(pValues[nProp]); break; // 
"Format/ByInput/ApplyNumberingAfterSpace",
             }
         }
     }
@@ -643,6 +645,7 @@ void SvxSwAutoCorrCfg::ImplCommit()
          css::uno::Any(rParent.bAutoFmtByInput), // "Format/ByInput/Enable"
          css::uno::Any(rSwFlags.bChgToEnEmDash), // "Format/ByInput/ChangeDash"
          css::uno::Any(rSwFlags.bSetNumRule),
+         css::uno::Any(rSwFlags.bSetNumRuleAfterSpace),
             // "Format/ByInput/ApplyNumbering/Enable"
          css::uno::Any(rSwFlags.bSetBorder), // 
"Format/ByInput/ChangeToBorders"
          css::uno::Any(rSwFlags.bCreateTable), // 
"Format/ByInput/ChangeToTable"
diff --git a/editeng/source/misc/swafopt.cxx b/editeng/source/misc/swafopt.cxx
index f5f79a45be97..25f3b1b466cc 100644
--- a/editeng/source/misc/swafopt.cxx
+++ b/editeng/source/misc/swafopt.cxx
@@ -46,6 +46,7 @@ SvxSwAutoFormatFlags::SvxSwAutoFormatFlags()
     bDelEmptyNode =
     bWithRedlining =
     bAutoCmpltEndless =
+    bSetNumRuleAfterSpace =
     bAutoCmpltAppendBlank = false;
 
     bAutoCmpltShowAsTip =
diff --git a/include/editeng/swafopt.hxx b/include/editeng/swafopt.hxx
index 8a4ca5aeaa62..217cb3dd95f0 100644
--- a/include/editeng/swafopt.hxx
+++ b/include/editeng/swafopt.hxx
@@ -102,6 +102,7 @@ struct EDITENG_DLLPUBLIC SvxSwAutoFormatFlags
     bool bAFormatByInput : 1;
     bool bDelEmptyNode : 1;
     bool bSetNumRule : 1;
+    bool bSetNumRuleAfterSpace : 1;
 
     bool bChgOrdinalNumber : 1;
     bool bChgToEnEmDash : 1;
diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
index ad2f1497a561..028552cca820 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
@@ -4385,6 +4385,14 @@
               <label>Delete Blanks and Tabs between lineend and -begin</label>
             </info>
             <value>true</value>
+          </prop>
+           <prop oor:name="ApplyBulletsAfterSpace" oor:type="xs:boolean" 
oor:nillable="false">
+            <!-- UIHints: Tools  AutoCorrect/AutoFormat  Options  Apply styles 
-->
+            <info>
+              <desc>Specifies whether a numbered or bulleted text is created 
automatically while typing * or - and then space</desc>
+              <label>Bulleted and numbered lists immediate after pressing 
space</label>
+            </info>
+            <value>false</value>
           </prop>
           <group oor:name="ApplyNumbering">
             <info>
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 766e504b4072..8fc1afb9483a 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -843,7 +843,7 @@ public:
     std::vector<OUString> GetChunkForAutoText();
 
     /// Set our styles according to the respective rules.
-    void AutoFormat( const SvxSwAutoFormatFlags* pAFlags );
+    void AutoFormat( const SvxSwAutoFormatFlags* pAFlags, bool 
bCurrentParagraphOnly );
 
     static SvxSwAutoFormatFlags* GetAutoFormatFlags();
     static void SetAutoFormatFlags(SvxSwAutoFormatFlags const *);
diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx
index f8faee3a1bcd..2a9870660830 100644
--- a/sw/qa/core/doc/doc.cxx
+++ b/sw/qa/core/doc/doc.cxx
@@ -14,7 +14,9 @@
 #include <comphelper/classids.hxx>
 #include <tools/globname.hxx>
 #include <svtools/embedhlp.hxx>
+#include <editeng/acorrcfg.hxx>
 #include <editeng/frmdiritem.hxx>
+#include <editeng/svxacorr.hxx>
 #include <vcl/errinf.hxx>
 #include <vcl/event.hxx>
 #include <editeng/langitem.hxx>
@@ -113,6 +115,55 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testNumDownIndent)
     ErrorRegistry::Reset();
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testBulletsOnSpaceOff)
+{
+    SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
+    pAutoCorrect->GetSwFlags().bSetNumRule = false;
+    pAutoCorrect->GetSwFlags().bSetNumRuleAfterSpace = false;
+
+    createSwDoc();
+    SwDoc* pDoc = getSwDoc();
+    SwDocShell* pDocShell = pDoc->GetDocShell();
+    SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+    pWrtShell->Down(/*bSelect=*/false);
+    SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
+    KeyEvent aKeyEvent('-', 0);
+    rEditWin.KeyInput(aKeyEvent);
+    KeyEvent aKeyEvent2(' ', KEY_SPACE);
+    rEditWin.KeyInput(aKeyEvent2);
+    KeyEvent aKeyEvent3('a', 0);
+    rEditWin.KeyInput(aKeyEvent3);
+    SwTextNode* pTextNode = 
pWrtShell->GetCursor()->GetPointNode().GetTextNode();
+
+    CPPUNIT_ASSERT_EQUAL(OUString("- a"), pTextNode->GetText());
+    ErrorRegistry::Reset();
+}
+
+CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testBulletsOnSpace)
+{
+    SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
+    pAutoCorrect->GetSwFlags().bSetNumRule = true;
+    pAutoCorrect->GetSwFlags().bSetNumRuleAfterSpace = true;
+
+    createSwDoc();
+    SwDoc* pDoc = getSwDoc();
+    SwDocShell* pDocShell = pDoc->GetDocShell();
+    SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+    pWrtShell->Down(/*bSelect=*/false);
+    SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
+    KeyEvent aKeyEvent('-', 0);
+    rEditWin.KeyInput(aKeyEvent);
+    KeyEvent aKeyEvent2(' ', KEY_SPACE);
+    rEditWin.KeyInput(aKeyEvent2);
+    KeyEvent aKeyEvent3('a', 0);
+    rEditWin.KeyInput(aKeyEvent3);
+    SwTextNode* pTextNode = 
pWrtShell->GetCursor()->GetPointNode().GetTextNode();
+
+    // '- ' was converted into bullet
+    CPPUNIT_ASSERT_EQUAL(OUString("a"), pTextNode->GetText());
+    ErrorRegistry::Reset();
+}
+
 CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testLocaleIndependentTemplate)
 {
     createSwDoc("locale-independent-template.odt");
diff --git a/sw/qa/uitest/writer_tests/tdf156165.py 
b/sw/qa/uitest/writer_tests/tdf156165.py
index de6a5713a826..de90eebdd54b 100644
--- a/sw/qa/uitest/writer_tests/tdf156165.py
+++ b/sw/qa/uitest/writer_tests/tdf156165.py
@@ -25,7 +25,7 @@ class tdf156165(UITestCase):
                 xTabs = xDialog.getChild("tabcontrol")
                 select_pos(xTabs, "2")
                 options=xDialog.getChild('list')
-                checkbox=options.getChild("16")
+                checkbox=options.getChild("17")
                 self.assertEqual("Replace Custom Styles", 
get_state_as_dict(checkbox)["Text"])
 
                 # Replace Custom Styles is default to be false
@@ -51,7 +51,7 @@ class tdf156165(UITestCase):
                 xTabs = xDialog.getChild("tabcontrol")
                 select_pos(xTabs, "2")
                 options=xDialog.getChild('list')
-                checkbox=options.getChild("16")
+                checkbox=options.getChild("17")
                 self.assertEqual("Replace Custom Styles", 
get_state_as_dict(checkbox)["Text"])
 
                 # set Replace Custom Styles to True
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index b7991e7f237b..555eec327a5d 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -388,13 +388,15 @@ bool SwAutoFormat::IsFastFullLine(const SwTextFrame & 
rFrame) const
 bool SwAutoFormat::IsEnumericChar(const SwTextFrame& rFrame) const
 {
     const OUString& rText = rFrame.GetText();
+    bool bIsShortBullet = rText == "* " || rText == "- ";
+    sal_uInt16 nMinLen = bIsShortBullet ? 1 : 2;
     TextFrameIndex nBlanks(GetLeadingBlanks(rText));
     const TextFrameIndex nLen = TextFrameIndex(rText.getLength()) - nBlanks;
     if( !nLen )
         return false;
 
     // -, +, * separated by blank ??
-    if (TextFrameIndex(2) < nLen && IsSpace(rText[sal_Int32(nBlanks) + 1]))
+    if (TextFrameIndex(nMinLen) < nLen && IsSpace(rText[sal_Int32(nBlanks) + 
1]))
     {
         if (StrChr(pBulletChar, rText[sal_Int32(nBlanks)]))
             return true;
@@ -1488,6 +1490,11 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, 
sal_uInt16 nDigitLevel )
                 || IsBlanksInString(*m_pCurTextFrame)
                 || IsSentenceAtEnd(*m_pCurTextFrame);
     bool bRTL = m_pEditShell->IsInRightToLeftText();
+
+    const OUString sStrWithTrailingBlanks = 
DelLeadingBlanks(m_pCurTextFrame->GetText());
+    bool bIsShortBullet = sStrWithTrailingBlanks == "* " || 
sStrWithTrailingBlanks == "- ";
+    sal_uInt16 nMinLen = bIsShortBullet ? 1 : 2;
+
     DeleteLeadingTrailingBlanks();
 
     bool bChgBullet = false, bChgEnum = false;
@@ -1509,16 +1516,16 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, 
sal_uInt16 nDigitLevel )
     }
 
     // replace bullet character with defined one
-    const OUString& rStr = m_pCurTextFrame->GetText();
+    const OUString& rStr = bIsShortBullet ? sStrWithTrailingBlanks : 
m_pCurTextFrame->GetText();
     TextFrameIndex nTextStt(0);
     const sal_Unicode* pFndBulletChr = nullptr;
-    if (m_aFlags.bChgEnumNum && 2 < rStr.getLength())
+    if (m_aFlags.bChgEnumNum && nMinLen < rStr.getLength())
         pFndBulletChr = StrChr(pBulletChar, rStr[sal_Int32(nTextStt)]);
     if (nullptr != pFndBulletChr && IsSpace(rStr[sal_Int32(nTextStt) + 1]))
     {
         if( m_aFlags.bAFormatByInput )
         {
-            if( m_aFlags.bSetNumRule )
+            if( m_aFlags.bSetNumRule)
             {
                 SwCharFormat* pCFormat = 
m_pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool(
                                             RES_POOLCHR_BULLET_LEVEL );
@@ -1691,9 +1698,11 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, 
sal_uInt16 nDigitLevel )
             {
                 m_aDelPam.SetMark();
                 SwTextFrame const*const pNextFrame = GetNextNode(false);
-                assert(pNextFrame);
-                m_aDelPam.GetMark()->Assign( 
*pNextFrame->GetTextNodeForParaProps() );
-                m_aDelPam.GetMarkNode().GetTextNode()->SetAttrListLevel( nLvl 
);
+                if (pNextFrame)
+                {
+                    m_aDelPam.GetMark()->Assign( 
*pNextFrame->GetTextNodeForParaProps() );
+                    m_aDelPam.GetMarkNode().GetTextNode()->SetAttrListLevel( 
nLvl );
+                }
             }
 
             
const_cast<SwTextNode*>(m_pCurTextFrame->GetTextNodeForParaProps())->SetAttrListLevel(nLvl);
@@ -1712,9 +1721,9 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 
nDigitLevel )
         m_aDelPam.SetMark();
 
         if ( bChgBullet )
-            nTextStt += TextFrameIndex(2);
+            nTextStt += TextFrameIndex(bIsShortBullet ? 1 : 2);
 
-        while (nTextStt < TextFrameIndex(rStr.getLength()) && 
IsSpace(rStr[sal_Int32(nTextStt)]))
+        while (!bIsShortBullet && nTextStt < TextFrameIndex(rStr.getLength()) 
&& IsSpace(rStr[sal_Int32(nTextStt)]))
             nTextStt++;
 
         *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(nTextStt);
@@ -2315,7 +2324,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, 
SvxSwAutoFormatFlags aFlags,
     {
         READ_NEXT_PARA, // -> ISEND, TST_EMPTY_LINE
         TST_EMPTY_LINE, // -> READ_NEXT_PARA, TST_ALPHA_LINE
-        TST_ALPHA_LINE, // -> READ_NEXT_PARA, GET_ALL_INFO, IS_END
+        TST_ALPHA_LINE, // -> READ_NEXT_PARA, GET_ALL_INFO, TST_ENUMERIC, 
IS_END
         GET_ALL_INFO,   // -> READ_NEXT_PARA, IS_ONE_LINE, TST_ENUMERIC, 
HAS_FMTCOLL
         IS_ONE_LINE,    // -> READ_NEXT_PARA, TST_ENUMERIC
         TST_ENUMERIC,   // -> READ_NEXT_PARA, TST_IDENT, TST_NEG_IDENT
@@ -2375,6 +2384,15 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, 
SvxSwAutoFormatFlags aFlags,
                     break;
                 }
 
+                const OUString& rStr = m_pCurTextFrame->GetText();
+                SvxAutoCorrect* pACorr = 
SvxAutoCorrCfg::Get().GetAutoCorrect();
+                SvxSwAutoFormatFlags& rFlags = pACorr->GetSwFlags();
+                if (rFlags.bChgEnumNum && (rStr == "- " || rStr == "* "))
+                {
+                    eStat = TST_ENUMERIC;
+                    break;
+                }
+
                 // Check for 3 "---" or "===". In this case, the previous 
paragraph should be
                 // underlined and the current be deleted!
                 if( !DoUnderline() && bReplaceStyles )
@@ -2711,7 +2729,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, 
SvxSwAutoFormatFlags aFlags,
         ::EndProgress( m_pDoc->GetDocShell() );
 }
 
-void SwEditShell::AutoFormat( const SvxSwAutoFormatFlags* pAFlags )
+void SwEditShell::AutoFormat( const SvxSwAutoFormatFlags* pAFlags, bool 
bCurrentParagraphOnly )
 {
     std::optional<SwWait> oWait;
 
@@ -2740,6 +2758,12 @@ void SwEditShell::AutoFormat( const 
SvxSwAutoFormatFlags* pAFlags )
             }
         }
     }
+    else if (bCurrentParagraphOnly)
+    {
+        pCursor->SetMark();
+        SwAutoFormat aFormat( this, std::move(aAFFlags), 
&pCursor->GetMark()->GetNode(),
+                                &pCursor->GetPoint()->GetNode() );
+    }
     else
     {
         SwAutoFormat( this, std::move(aAFFlags) );
diff --git a/sw/source/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index ba05f034cafd..ee728bd6d20c 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -2502,6 +2502,7 @@ KEYINPUT_CHECKTABLE_INSDEL:
             aCh = '\t';
             [[fallthrough]];
         case SwKeyState::InsChar:
+        {
             if (rSh.CursorInsideContentControl())
             {
                 const SwPosition* pStart = rSh.GetCursor()->Start();
@@ -2606,6 +2607,20 @@ KEYINPUT_CHECKTABLE_INSDEL:
                 rSh.InfoReadOnlyDialog(true);
                 eKeyState = SwKeyState::End;
             }
+
+            bool bIsSpace = (aCh == ' ');
+            if (bIsSpace && pACorr && pACfg)
+            {
+                // do the formatting only for few starting characters (for "* 
" or "- " conversion)
+                SwPosition aPos(*rSh.GetCursor()->GetPoint());
+                if (aPos.nContent < 3)
+                {
+                    SvxSwAutoFormatFlags& rFlags = pACorr->GetSwFlags();
+                    if(pACfg->IsAutoFormatByInput() && rFlags.bSetNumRule && 
rFlags.bSetNumRuleAfterSpace)
+                        rSh.AutoFormat(&rFlags, true);
+                }
+            }
+        }
         break;
 
         case SwKeyState::CheckAutoCorrect:
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index 5ba3d0a25c32..f65e6953ce0e 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1234,7 +1234,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
             // This must always be false for the postprocessing.
             aFlags.bAFormatByInput = false;
             aFlags.bWithRedlining = true;
-            rWrtSh.AutoFormat( &aFlags );
+            rWrtSh.AutoFormat( &aFlags, false );
             aFlags.bWithRedlining = false;
 
             SfxViewFrame& rVFrame = GetView().GetViewFrame();
@@ -1254,7 +1254,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
             SvxSwAutoFormatFlags 
aFlags(SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags());
             // This must always be false for the postprocessing.
             aFlags.bAFormatByInput = false;
-            rWrtSh.AutoFormat( &aFlags );
+            rWrtSh.AutoFormat( &aFlags, false );
             rReq.Done();
         }
         break;

Reply via email to