tdf#109285 sw numbering: RemoveLeadingWhiteSpace from all paras

Change-Id: Ie834b9c10c9a6cfd7971c7713c5684157477acc4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138807
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx
index bac97d6..94bb710 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -250,6 +250,7 @@ public:
    /** Removes any leading white space from the paragraph
    */
    virtual void RemoveLeadingWhiteSpace(const SwPosition & rPos ) = 0;
    virtual void RemoveLeadingWhiteSpace(SwPaM& rPaM) = 0;

protected:
    virtual ~IDocumentContentOperations() {};
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 8b66108..062fb0a 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -4587,15 +4587,20 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf97899)
    IDocumentContentOperations& rIDCO(pDoc->getIDocumentContentOperations());

    // Create an Ordered List
    rIDCO.InsertString(*pCursor, "a");
    rIDCO.InsertString(*pCursor, "\ta");
    pWrtShell->SplitNode();
    rIDCO.InsertString(*pCursor, "b");
    rIDCO.InsertString(*pCursor, "   b");
    pWrtShell->SplitNode();
    rIDCO.InsertString(*pCursor, "c");
    rIDCO.InsertString(*pCursor, "  \t  c");

    dispatchCommand(mxComponent, ".uno:SelectAll", {});
    dispatchCommand(mxComponent, ".uno:DefaultNumbering", {});

    // tdf#109285: RemoveLeadingWhiteSpace from all numbered paragraphs
    getParagraph(1, "a");
    getParagraph(2, "b");
    getParagraph(3, "c");

    // Save it as DOCX & load it again
    reload("Office Open XML Text", "tdf97899-tmp.docx");
    uno::Reference<container::XIndexAccess> xNumberingRules
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index d751ac3..59bfafb 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3616,6 +3616,17 @@ void DocumentContentOperationsManager::RemoveLeadingWhiteSpace(const SwPosition 
    }
}

void DocumentContentOperationsManager::RemoveLeadingWhiteSpace(SwPaM& rPaM )
{
    for (SwPaM& rSel :rPaM.GetRingContainer())
    {
        SwNodeOffset nStt = rSel.Start()->nNode.GetIndex();
        SwNodeOffset nEnd = rSel.End()->nNode.GetIndex();
        for (SwNodeOffset nPos = nStt; nPos<=nEnd; nPos++)
            RemoveLeadingWhiteSpace(SwPosition(rSel.GetBound().GetNodes(), nPos));
    }
}

// Copy method from SwDoc - "copy Flys in Flys"
/// note: rRg/rInsPos *exclude* a partially selected start text node;
///       pCopiedPaM *includes* a partially selected start text node
diff --git a/sw/source/core/inc/DocumentContentOperationsManager.hxx b/sw/source/core/inc/DocumentContentOperationsManager.hxx
index decc16c..6b45e6c 100644
--- a/sw/source/core/inc/DocumentContentOperationsManager.hxx
+++ b/sw/source/core/inc/DocumentContentOperationsManager.hxx
@@ -96,6 +96,7 @@ public:
        SwRootFrame const* pLayout = nullptr) override;

    void RemoveLeadingWhiteSpace(const SwPosition & rPos ) override;
    void RemoveLeadingWhiteSpace(SwPaM& rPaM) override;


    //Non-Interface methods
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 6606b65..5b664986 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -1549,7 +1549,7 @@ void SwWrtShell::NumOrBulletOn(bool bNum)
        const SwTwips nWidthOfTabs = pTextNode
                                     ? pTextNode->GetWidthOfLeadingTabs()
                                     : 0;
        GetDoc()->getIDocumentContentOperations().RemoveLeadingWhiteSpace( *GetCursor()->GetPoint() );
        GetDoc()->getIDocumentContentOperations().RemoveLeadingWhiteSpace(*GetCursor());

        const bool bHtml = dynamic_cast<SwWebDocShell*>( pDocSh ) !=  nullptr;
        const bool bRightToLeft = IsInRightToLeftText();