[Libreoffice-commits] core.git: Branch 'libreoffice-7-2-5' - sw/qa sw/source

2021-12-28 Thread Vasily Melenchuk (via logerrit)
 sw/qa/extras/odfimport/data/tdf146257.odt |binary
 sw/qa/extras/odfimport/odfimport.cxx  |   32 ++
 sw/source/core/doc/number.cxx |   27 -
 3 files changed, 58 insertions(+), 1 deletion(-)

New commits:
commit b7f50e070fb21b8b4e444bb2cf12e500e615d7cf
Author: Vasily Melenchuk 
AuthorDate: Sun Dec 26 20:38:30 2021 +0300
Commit: Adolfo Jayme Barrientos 
CommitDate: Wed Dec 29 04:32:19 2021 +0100

tdf#146257: sw: better handling for list numbering = NONE

Previously during refactoring were lost some corner cases with
some level having disabled numbering. In this case LO should
strip useless delimiters up to next level.

For example, if second level has disabled numbering, third level
should look like "1.1", but not "1..1".

Change-Id: I259a16b456f51bc76d5c8360974d0acadfc36776
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127517
Tested-by: Jenkins
Reviewed-by: Vasily Melenchuk 
(cherry picked from commit bf2b46aa15665dde63ceff4e7686b99b3990354f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127570
Reviewed-by: Xisco Fauli 
(cherry picked from commit a732b9125af7fa3a960b6f16fe5ffe32f3788a2f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127573
Reviewed-by: Hossein 
Reviewed-by: Adolfo Jayme Barrientos 
Tested-by: Adolfo Jayme Barrientos 

diff --git a/sw/qa/extras/odfimport/data/tdf146257.odt 
b/sw/qa/extras/odfimport/data/tdf146257.odt
new file mode 100644
index ..2431fc0a8ff0
Binary files /dev/null and b/sw/qa/extras/odfimport/data/tdf146257.odt differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx 
b/sw/qa/extras/odfimport/odfimport.cxx
index 00c958ba1543..bd936937475d 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -1290,5 +1290,37 @@ CPPUNIT_TEST_FIXTURE(Test, 
testPageAnchorZIndexSecondPage)
 sal_Int32(3), getProperty(getShapeByName(u"Shape2"), 
"ZOrder"));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf146257)
+{
+load(mpTestDocumentPath, "tdf146257.odt");
+
+// First list should contain no labels
+{
+uno::Reference xPara(getParagraph(2), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xPara, 
"ListLabelString"));
+}
+{
+uno::Reference xPara(getParagraph(3), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xPara, 
"ListLabelString"));
+}
+{
+uno::Reference xPara(getParagraph(4), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xPara, 
"ListLabelString"));
+}
+// For second list ensure second level empty and thord level should not 
contain extra dots
+{
+uno::Reference xPara(getParagraph(6), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty(xPara, 
"ListLabelString"));
+}
+{
+uno::Reference xPara(getParagraph(7), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty(xPara, 
"ListLabelString"));
+}
+{
+uno::Reference xPara(getParagraph(8), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("1.1"), getProperty(xPara, 
"ListLabelString"));
+}
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index aae3d54e08d6..462910580782 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -661,6 +661,21 @@ OUString SwNumRule::MakeNumString( const 
SwNumberTree::tNumberVector & rNumVecto
 
 const SwNumFormat& rMyNFormat = Get( o3tl::narrowing(nLevel) );
 
+if (rMyNFormat.GetNumberingType() == SVX_NUM_NUMBER_NONE)
+{
+if (!rMyNFormat.HasListFormat())
+return OUString();
+
+// If numbering is disabled for this level we should emit just 
prefix/suffix
+// Remove everything between first %1% and last %n% (including markers)
+OUString sLevelFormat = rMyNFormat.GetListFormat(bInclStrings);
+sal_Int32 nFirstPosition = sLevelFormat.indexOf("%");
+sal_Int32 nLastPosition = sLevelFormat.lastIndexOf("%");
+if (nFirstPosition >= 0 && nLastPosition >= nFirstPosition)
+sLevelFormat = sLevelFormat.replaceAt(nFirstPosition, 
nLastPosition - nFirstPosition + 1, u"");
+return sLevelFormat;
+}
+
 css::lang::Locale aLocale( LanguageTag::convertToLocale(nLang));
 
 if (rMyNFormat.HasListFormat())
@@ -672,9 +687,19 @@ OUString SwNumRule::MakeNumString( const 
SwNumberTree::tNumberVector & rNumVecto
 for (SwNumberTree::tNumberVector::size_type i=0; i <= nLevel; ++i)
 {
 OUString sReplacement;
-if (rMyNFormat.GetNumberingType() == SVX_NUM_NUMBER_NONE)
+const SwNumFormat& rNFormat = Get(i);
+if (rNFormat.GetNumberingType() == SVX_NUM_NUMBER_NONE)
 {
   

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2-5' - sw/qa sw/source

2021-12-23 Thread Michael Stahl (via logerrit)
 sw/qa/extras/uiwriter/uiwriter2.cxx |   68 
 sw/source/core/txtnode/ndtxt.cxx|   20 +-
 2 files changed, 85 insertions(+), 3 deletions(-)

New commits:
commit 5f6b1a350685e2935bc69a9dc1e0b32ed171db6b
Author: Michael Stahl 
AuthorDate: Fri Dec 17 14:10:50 2021 +0100
Commit: Xisco Fauli 
CommitDate: Thu Dec 23 11:08:48 2021 +0100

tdf#137318 sw_redlinehide: fix JoinNext() if deleted node contains redlines

The GetRedlineMergeFlag() of the deleted node is None also if there are
deletions contained completely inside the node, but in this case the
merged node does need a MergedPara, so check if the deleted node had a
frame that has a MergedPara in addition to the flag (which remains as
an "optimization").

(regression from d258fc29560baa5ecae03ebc2740e11420643e27)

Change-Id: I44456f230374ec1de159106678e80fb4670c9f33
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127011
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 31f51598fd08c2b76583a1baad0c0d6d4b336664)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126979
Reviewed-by: Caolán McNamara 
(cherry picked from commit a82e1cf48b7e1d228f99a136b115bcb56a2e4bac)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127066
Reviewed-by: Thorsten Behrens 
Reviewed-by: Xisco Fauli 
Tested-by: Xisco Fauli 

diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index c2a32aebea90..700f0cbc9884 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -338,6 +338,74 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, 
testRedlineSplitContentNode)
 rUndoManager.Undo();
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf137318)
+{
+SwDoc* const pDoc = createSwDoc();
+SwWrtShell* const pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+pWrtShell->Insert("A");
+
+// enable redlining
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+// hide
+dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
+
+CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+   pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+CPPUNIT_ASSERT_MESSAGE(
+"redlines should be visible",
+
IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines());
+
+pWrtShell->DelLine();
+pWrtShell->StartOfSection(false);
+pWrtShell->SplitNode(true);
+pWrtShell->SplitNode(true);
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3);
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text", 0);
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text", 0);
+// not sure why there's an empty text portion here, but it's not a problem
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text", 1);
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1]", "nType", 
"PortionType::Para");
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[3]/Text[1][@Portion]", 0);
+
+pWrtShell->Undo();
+
+// the problem was that here the "A" showed up again
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[1]/body/txt", 2);
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text", 0);
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text", 1);
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1]", "nType", 
"PortionType::Para");
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/Text[1][@Portion]", 0);
+
+pWrtShell->Undo();
+
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[1]/body/txt", 1);
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text", 1);
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", 
"PortionType::Para");
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1][@Portion]", 0);
+
+pWrtShell->Undo();
+
+// now the "A" is no longer deleted
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[1]/body/txt", 1);
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text", 1);
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", 
"PortionType::Para");
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1][@Portion]", 1);
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nLength", "1");
+
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "A");
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf136704)
 {
 SwDoc* const pDoc(createSwDoc());
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 09c897478f50..0dc24c708ca2 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1014,6 +1014,22 @@ 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2-5' - sw/qa sw/source

2021-12-22 Thread Justin Luth (via logerrit)
 sw/qa/extras/uiwriter/uiwriter3.cxx |   19 +++
 sw/source/core/swg/SwXMLTextBlocks1.cxx |   16 +---
 2 files changed, 32 insertions(+), 3 deletions(-)

New commits:
commit 156f2e3bac9ba2cfe517ea14e7cce961bd0e7ceb
Author: Justin Luth 
AuthorDate: Fri Dec 17 18:45:42 2021 +0200
Commit: Michael Stahl 
CommitDate: Wed Dec 22 10:15:27 2021 +0100

tdf#144364 sw: Revert "Use FastParser in SwXMLTextBlocks"

This reverts 7.0 commit fd6feb4f538b0c5c9061529ff002be9f62a7239a.
Noel said this was just a performance fix, so just go ahead
and revert it.

It caused the regression documented in bug 144364.

Change-Id: I044c49e42873db120a94d93a00e9b35105778b9c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127012
Tested-by: Jenkins
Reviewed-by: Justin Luth 
(cherry picked from commit 1addd8c104f6ad390bdd0ca61cd5ce97b55ce218)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126982
Reviewed-by: Noel Grandin 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127147
(cherry picked from commit d8cf8482ae5ed72dc969d9adb47c113c442452be)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127168
Reviewed-by: Michael Stahl 
Tested-by: Michael Stahl 

diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 514a13e88ff1..b536692fc5a6 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -1689,6 +1689,25 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130629)
 CPPUNIT_ASSERT_EQUAL(1, getShapes());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf144364)
+{
+SwDoc* const pDoc = createSwDoc();
+SwWrtShell* const pWrtSh = pDoc->GetDocShell()->GetWrtShell();
+CPPUNIT_ASSERT(pWrtSh);
+
+// expands autotext (via F3)
+pWrtSh->Insert("AR");
+
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_F3);
+Scheduler::ProcessEventsToIdle();
+
+// was ...'letter of '
+CPPUNIT_ASSERT_EQUAL(
+OUString("We hereby acknowledge the receipt of your letter of 
."),
+getParagraph(1)->getString());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf141613)
 {
 SwDoc* const pDoc = createSwDoc();
diff --git a/sw/source/core/swg/SwXMLTextBlocks1.cxx 
b/sw/source/core/swg/SwXMLTextBlocks1.cxx
index 0297d68fa442..589d4e192097 100644
--- a/sw/source/core/swg/SwXMLTextBlocks1.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks1.cxx
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -194,6 +195,9 @@ ErrCode SwXMLTextBlocks::GetMacroTable( sal_uInt16 nIdx,
 uno::Reference< uno::XComponentContext > xContext =
 comphelper::getProcessComponentContext();
 
+// get parser
+uno::Reference< xml::sax::XParser > xParser = 
xml::sax::Parser::create( xContext );
+
 // create descriptor and reference to it. Either
 // both or neither must be kept because of the
 // reference counting!
@@ -206,15 +210,21 @@ ErrCode SwXMLTextBlocks::GetMacroTable( sal_uInt16 nIdx,
 OUString sFilterComponent = bOasis
 ? 
OUString("com.sun.star.comp.Writer.XMLOasisAutotextEventsImporter")
 : OUString("com.sun.star.comp.Writer.XMLAutotextEventsImporter");
-uno::Reference< xml::sax::XFastParser > xFilter(
+uno::Reference< xml::sax::XDocumentHandler > xFilter(
 
xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
 sFilterComponent, aFilterArguments, xContext),
-UNO_QUERY_THROW );
+UNO_QUERY );
+OSL_ENSURE( xFilter.is(), "can't instantiate autotext-events filter");
+if ( !xFilter.is() )
+return ERR_SWG_READ_ERROR;
+
+// connect parser and filter
+xParser->setDocumentHandler( xFilter );
 
 // parse the stream
 try
 {
-xFilter->parseStream( aParserInput );
+xParser->parseStream( aParserInput );
 }
 catch( xml::sax::SAXParseException& )
 {