sw/inc/IDocumentContentOperations.hxx | 1 + sw/qa/extras/uiwriter/uiwriter3.cxx | 11 ++++++++--- sw/source/core/doc/DocumentContentOperationsManager.cxx | 11 +++++++++++ sw/source/core/inc/DocumentContentOperationsManager.hxx | 1 + sw/source/uibase/wrtsh/wrtsh1.cxx | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-)
New commits: commit 3e3328987b69a2a549d24c79ee71b353b9a3e288 Author: Justin Luth <jl...@mail.com> AuthorDate: Thu Aug 25 05:51:11 2022 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Thu Aug 25 21:04:38 2022 +0200 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 <jl...@mail.com> diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx index bac97d685927..94bb7102dee0 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 8b661082e8ba..062fb0acc195 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 d751ac3d19f9..59bfafb5d313 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 decc16c14648..6b45e6ca01ae 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 6606b65ff49f..5b6649861a74 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();