[Libreoffice-commits] core.git: sw/qa sw/source

2023-12-05 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/floattable-wrapped-by-table.docx |binary
 sw/qa/core/layout/tabfrm.cxx|   30 
 sw/source/core/layout/tabfrm.cxx|   22 +++
 3 files changed, 51 insertions(+), 1 deletion(-)

New commits:
commit 868140fcc1311259b9d5f37b33d226511a53
Author: Miklos Vajna 
AuthorDate: Tue Dec 5 08:39:10 2023 +0100
Commit: Miklos Vajna 
CommitDate: Tue Dec 5 10:15:52 2023 +0100

tdf#60558 sw floattable: allow wrap of table on the right of a floattable

The bugdoc shows that Word wraps inline tables around floating tables if
they have enough space, but Writer didn't do this.

Table frames may wrap fly frames by adding some top, left or right
margin to the table at a layout level, this is calculated in
SwTabFrame::CalcFlyOffsets(). There we currently decide the give a top
margin to such tables, which fixes the overlap problem, but the bugdoc
is now of 2 pages instead of 1 page, since we don't wrap.

Fix the problem by improving the "shift down" case by checking if
shifting to the right would also work (has enough space). If so, do that
in case the fly frame is a split fly.

Note that this could be done for all flys as well, but that would have
to be conditional on some Word compat flag and that's not needed to fix
the bugdoc, so leave that for later.

Change-Id: Idb45413257758fd0334b17ef348ba28010a52316
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160331
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-wrapped-by-table.docx 
b/sw/qa/core/layout/data/floattable-wrapped-by-table.docx
new file mode 100644
index ..a53f652183ea
Binary files /dev/null and 
b/sw/qa/core/layout/data/floattable-wrapped-by-table.docx differ
diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx
index e83767992aa6..091b78cd2478 100644
--- a/sw/qa/core/layout/tabfrm.cxx
+++ b/sw/qa/core/layout/tabfrm.cxx
@@ -169,6 +169,36 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyTableJoin)
 CPPUNIT_ASSERT(pFly->GetPrecede());
 CPPUNIT_ASSERT(!pFly->HasFollow());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWrappedByTable)
+{
+// Given a document with a floating table, wrapped by an inline table:
+// When laying out the document:
+createSwDoc("floattable-wrapped-by-table.docx");
+
+// Then make sure the inline table wraps around the floating table:
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage);
+// Get the top of the inline table, ignoring margins:
+CPPUNIT_ASSERT(pPage->GetSortedObjs());
+SwSortedObjs& rPageObjs = *pPage->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size());
+auto pFly = rPageObjs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame();
+CPPUNIT_ASSERT(pFly);
+// Get the bottom of of the floating table, ignoring margins:
+SwTwips nFloatingBottom = pFly->getFrameArea().Top() + 
pFly->getFramePrintArea().Height();
+SwFrame* pBody = pPage->FindBodyCont();
+auto pTab = pBody->GetLower()->GetNext()->DynCastTabFrame();
+SwTwips nInlineTop = pTab->getFrameArea().Top() + 
pTab->getFramePrintArea().Top();
+// Make sure the inline table is on the right of the floating one, not 
below it:
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected less than: 7287
+// - Actual  : 7287
+// i.e. the inline table was under the floating one, not on the right of 
it.
+CPPUNIT_ASSERT_LESS(nFloatingBottom, nInlineTop);
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 4367d86255a2..c1acc0c9e9fe 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -3179,6 +3179,7 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper,
 nSurround = text::WrapTextMode_PARALLEL;
 
 bool bShiftDown = css::text::WrapTextMode_NONE == nSurround;
+bool bSplitFly = pFly->IsFlySplitAllowed();
 if (!bShiftDown && bAddVerticalFlyOffsets)
 {
 if (nSurround == text::WrapTextMode_PARALLEL && 
isHoriOrientShiftDown)
@@ -3201,6 +3202,18 @@ bool SwTabFrame::CalcFlyOffsets( SwTwips& rUpper,
 // normally an SwFlyPortion is created instead that increases 
the height
 // of the first table row.
 bShiftDown = aTabRange.overlaps(aFlyRange);
+
+if (bSplitFly && pFly->GetAnchorFrame()->GetUpper() == 
GetUpper())
+{
+// Split fly followed by an inline table. Check if we have 
enough space to shift
+// to the right instead.
+SwTwips nShift

[Libreoffice-commits] core.git: sw/qa sw/source

2023-12-04 Thread László Németh (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf158436.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx   |6 ++
 sw/source/core/text/guess.cxx|5 -
 3 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 7059a1858ddb044c5f3f0c8e0386d3e1d9dd2b5f
Author: László Németh 
AuthorDate: Mon Dec 4 15:33:14 2023 +0100
Commit: László Németh 
CommitDate: Mon Dec 4 21:41:04 2023 +0100

tdf#119908 tdf#158439 sw smart justify: fix freezing with NBSP

Stop shrinking during underflow, because it resulted
endless layout loop, e.g. when a very short word followed
by a no-break space.

Regression from commit 7d08767b890e723cd502b1c61d250924f695eb98
"tdf#130088 tdf#119908 smart justify: fix DOCX line count + compat opt."

Change-Id: Id832b7fdbc01453a30067995e14e5430b0a15232
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160316
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf158436.docx 
b/sw/qa/extras/ooxmlexport/data/tdf158436.docx
new file mode 100644
index ..8cdcd21b4c1a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf158436.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index d9ef6b8a48d0..0656bb868795 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1408,6 +1408,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf130088, "tdf130088.docx")
 CPPUNIT_ASSERT_EQUAL(1, getPages());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf158436, "tdf158436.docx")
+{
+// This resulted freezing
+CPPUNIT_ASSERT_EQUAL(1, getPages());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testHyphenationAuto)
 {
 loadAndReload("hyphenation.odt");
diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index 5e66b366c63f..37a2147d0987 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -82,7 +82,10 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, 
SwTextFormatInfo &rInf,
 
 // allow shrinking, i.e. more text in justified lines, depending on the 
justification algorithm
 if ( rAdjust == SvxAdjust::Block && 
rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(
-DocumentSettingId::JUSTIFY_LINES_WITH_SHRINKING))
+DocumentSettingId::JUSTIFY_LINES_WITH_SHRINKING) &&
+ // tdf#158436 avoid shrinking at underflow, e.g. no-break space
+ // after a very short word resulted endless loop
+ !rInf.IsUnderflow() )
 {
 // allow up to 2% shrinking of the line
 nLineWidth = nLineWidth / 0.98 + rInf.X() / 0.98 - rInf.X();


[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/qa writerfilter/source

2023-11-30 Thread Tomaž Vajngerl (via logerrit)
 sw/qa/core/header_footer/HeaderFooterTest.cxx  |   74 -
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx |3 
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx  |   13 
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx  |4 
 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx  |9 
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx  |4 
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx   |3 
 sw/qa/extras/rtfexport/rtfexport.cxx   |3 
 sw/qa/extras/rtfexport/rtfexport2.cxx  |6 
 sw/qa/extras/rtfexport/rtfexport3.cxx  |   35 
 sw/qa/extras/rtfexport/rtfexport5.cxx  |2 
 sw/qa/extras/rtfimport/rtfimport.cxx   |   18 
 sw/source/filter/ww8/rtfexport.cxx |9 
 writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx |1 
 writerfilter/qa/cppunittests/dmapper/PropertyMap.cxx   |3 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |  214 +++-
 writerfilter/source/dmapper/DomainMapper_Impl.hxx  |   60 -
 writerfilter/source/dmapper/PropertyIds.cxx|3 
 writerfilter/source/dmapper/PropertyIds.hxx|3 
 writerfilter/source/dmapper/PropertyMap.cxx|  663 ++---
 writerfilter/source/dmapper/PropertyMap.hxx|   83 +
 21 files changed, 711 insertions(+), 502 deletions(-)

New commits:
commit 4b0fa253a4540f5461397815d290586f9ddabe61
Author: Tomaž Vajngerl 
AuthorDate: Tue Nov 28 13:46:21 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Dec 1 08:26:38 2023 +0100

tdf#136472 adjust ooxml import to handle first header/footer

Previously the ooxml import added a new page style when the first
header or footer was detected. Since then we gained support to add
first page header/footer in an existing page style so we don't need
to import it like that anymore.
This changes the import code so that the old complication to add
"First Page" page style is removed and it always just uses the
"Standard" page style for all 3 cases: first, left and right headers
and footers.

This also adjusts the existing tests to align with this change.

Change-Id: Ibf69597e6990499ac520ea9e323a5f73f429800b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157860
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sw/qa/core/header_footer/HeaderFooterTest.cxx 
b/sw/qa/core/header_footer/HeaderFooterTest.cxx
index b411632884e1..d67e874df0ec 100644
--- a/sw/qa/core/header_footer/HeaderFooterTest.cxx
+++ b/sw/qa/core/header_footer/HeaderFooterTest.cxx
@@ -96,8 +96,11 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, 
testNonFirstHeaderIsDisabled)
 
 createSwDoc("tdf127778.docx");
 
-xmlDocUniquePtr pLayout = parseLayoutDump();
-assertXPath(pLayout, "//page[2]/header"_ostr, 0);
+// TODO
+
+// Header can only be enabled or disabled, but can't be disbaled just for 
first, left or right page.
+// If a header is enabled but empty, the header still takes space in LO, 
but not in MSO, where it acts the same as
+// if it is disabled.
 }
 
 // Check for correct header/footer with special first page with TOC inside
@@ -113,8 +116,10 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, 
testHeaderFooterWithSpecialFirstPage_OOXM
 {
 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
 // check first page
-assertXPath(pXmlDoc, "/root/page[1]/header"_ostr, 0);
-assertXPath(pXmlDoc, "/root/page[1]/footer"_ostr, 0);
+assertXPath(pXmlDoc, "/root/page[1]/header"_ostr);
+assertXPath(pXmlDoc, "/root/page[1]/footer"_ostr);
+assertXPath(pXmlDoc, "/root/page[1]/header/txt/text()"_ostr, 0);
+assertXPath(pXmlDoc, "/root/page[1]/footer/txt/text()"_ostr, 0);
 // check second page in the same way
 assertXPath(pXmlDoc, "/root/page[2]/header"_ostr);
 assertXPath(pXmlDoc, "/root/page[2]/footer"_ostr);
@@ -463,7 +468,9 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, testTdf112694)
 uno::Any aPageStyle = getStyles("PageStyles")->getByName("Standard");
 // Header was on when header for file was for explicit first pages only
 // (marked via ).
-CPPUNIT_ASSERT(!getProperty(aPageStyle, "HeaderIsOn"));
+//CPPUNIT_ASSERT(!getProperty(aPageStyle, "HeaderIsOn"));
+// TODO - can't disable headers/footers selectively (only fo first 
page)
+CPPUNIT_ASSERT(getProperty(aPageStyle, "HeaderIsOn"));
 };
 
 createSwDoc("tdf112694.docx");
@@ -664,7 +671,10 @@ CPPUNIT_TEST_FIXTURE(HeaderFooterTest, 
testFirstPageFooterEnabled)
 // Footer shouldn't be enabled on first page, but then on the other pages
 auto verify = [this]() {
 xmlDocUniquePtr pXmlDoc = parseLayoutDump();
-assertXPath(pXmlDoc, "/root/page[1]/footer/txt"_ostr, 

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-30 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/uiwriter/data/tdf158459_tracked_changes_across_nodes.fodt |   45 
++
 sw/qa/extras/uiwriter/uiwriter8.cxx|   27 
++
 sw/source/core/doc/DocumentContentOperationsManager.cxx|9 
+-
 3 files changed, 79 insertions(+), 2 deletions(-)

New commits:
commit 9c22a72a2fc92146d24c6b673d9c07b1e6ff83f2
Author: Mike Kaganski 
AuthorDate: Thu Nov 30 17:53:26 2023 +0300
Commit: Mike Kaganski 
CommitDate: Thu Nov 30 17:35:50 2023 +0100

tdf#158459: call DeleteAndJoin in strict reverse order

The crash was caused by removal of a paragraph break (pointed to by a
PaM returned by pDelPam->GetNext()), that resulted in merge of the node
pDelPam pointed to, with the previous node. The destructin of the node
made pDelPam dangle. In debug builds, an assertion failed in destructor
of SwContentIndexReg. I.e., since the code always called DeleteAndJoin
on pDelPam->GetNext(), the processing went from second-to-last deletion
towards the begin of the document, and the last deletion (represented
by pDelPam) was handled last, when GetNext call wrapped.

This change makes sure that the order is strict, from last to first.

Change-Id: I5cb7fe2f06d4138d3c445eeca8220f0a87a82626
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160158
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git 
a/sw/qa/extras/uiwriter/data/tdf158459_tracked_changes_across_nodes.fodt 
b/sw/qa/extras/uiwriter/data/tdf158459_tracked_changes_across_nodes.fodt
new file mode 100644
index ..bdd03bc0be70
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf158459_tracked_changes_across_nodes.fodt
@@ -0,0 +1,45 @@
+
+
+http://purl.org/dc/elements/1.1/"; 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ 
+  
+   
+
+ 
+  
+   x
+   2000-01-01
+  
+ 
+
+
+ 
+  
+   x
+   2000-01-02
+  
+ 
+
+
+ 
+  
+   x
+   2000-01-03
+  
+ 
+
+
+ 
+  
+   x
+   2000-01-04
+  
+ 
+
+   
+   
+   a
+   bcdef
+  
+ 
+
\ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 0fbb8e9fae81..641797b2c7b0 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -2817,6 +2817,33 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf156560)
 dispatchCommand(mxComponent, ".uno:InsertHeader", {});
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf158459)
+{
+createSwDoc("tdf158459_tracked_changes_across_nodes.fodt");
+SwDoc* pDoc = getSwDoc();
+
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+CPPUNIT_ASSERT(pWrtShell);
+pWrtShell->FwdPara(); // Skip first paragraph
+pWrtShell->EndOfSection(true); // Select everything to the end
+
+SwDoc aClipboard;
+pWrtShell->Copy(aClipboard); // This must not crash
+
+pWrtShell->SelAll();
+pWrtShell->Delete();
+pWrtShell->Paste(aClipboard); // Replace everything with the copied stuff
+
+SwNodes& rNodes = pDoc->GetNodes();
+SwNodeIndex aIdx(rNodes.GetEndOfExtras());
+SwContentNode* pContentNode = rNodes.GoNext(&aIdx);
+CPPUNIT_ASSERT(pContentNode);
+SwTextNode* pTextNode = pContentNode->GetTextNode();
+CPPUNIT_ASSERT(pTextNode);
+// Check that deleted parts (paragraph break, "c", "e") haven't been pasted
+CPPUNIT_ASSERT_EQUAL(OUString("abdf"), pTextNode->GetText());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index d7d15d279776..09e0a1233e5d 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -440,11 +440,16 @@ namespace
 
 ::sw::UndoGuard const undoGuard(rDestDoc.GetIDocumentUndoRedo());
 
+// At this point, pDelPam points to the last of maybe several disjoint 
selections, organized
+// in reverse order in document (so every GetNext() returns a PaM 
closer to document start,
+// until wrap to pDelPam). Removal of the selections must be from last 
in document to first,
+// to avoid situations when another PaM in chain points into the node 
that will be destroyed
+// (joined to previous) by removal of the currently processed PaM.
 do {
-rDestDoc.getIDocumentContentOperations().DeleteAndJoin( 
*pDelPam->GetNext() );
+rDestDoc.getIDocumentContentOperations().DeleteAndJoin(*pDelPam);
 if( !pDelPam->IsMultiSelection() )
 break;
-delete pDelPam->GetNext();
+pDelPam.reset(pDelPam->GetNext());
 } while( true );

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-29 Thread Stephan Bergmann (via logerrit)
 sw/qa/extras/tiledrendering/tiledrendering.cxx |2 
 sw/source/core/doc/docredln.cxx|8 -
 sw/source/core/text/txtfrm.cxx |6 -
 sw/source/filter/html/css1atr.cxx  |6 -
 sw/source/filter/html/htmlatr.cxx  |   28 +++---
 sw/source/filter/html/htmlflywriter.cxx|   12 +-
 sw/source/filter/html/htmlforw.cxx |   18 ++--
 sw/source/filter/html/htmlnumwriter.cxx|4 
 sw/source/filter/html/htmlreqifreader.cxx  |4 
 sw/source/filter/html/wrthtml.cxx  |4 
 sw/source/filter/ww8/docxattributeoutput.cxx   |  106 -
 sw/source/filter/ww8/rtfattributeoutput.cxx|8 -
 sw/source/filter/ww8/wrtw8sty.cxx  |2 
 13 files changed, 104 insertions(+), 104 deletions(-)

New commits:
commit 2c1e01b22514ec86ec120cb1ea3dd458a544fbdb
Author: Stephan Bergmann 
AuthorDate: Wed Nov 29 14:38:32 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Nov 29 19:13:13 2023 +0100

Extended loplugin:ostr: sw

Change-Id: Ie3ceb8d4b939a652d09cc9cf02b78e65093c8fcf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160099
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 271e30e47a93..36431f83856f 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -3309,7 +3309,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDropDownFormFieldButtonEditing)
 OString sSelected( 
aTree.get_child("params").get_child("selected").get_value() );
 CPPUNIT_ASSERT_EQUAL("1"_ostr, sSelected);
 }
-m_aFormFieldButton = "";
+m_aFormFieldButton = ""_ostr;
 
 // Trigger a form field event to select a different item.
 vcl::ITiledRenderable::StringMap aArguments;
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 8ef699787b3f..3b0f8d7b9f53 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1352,16 +1352,16 @@ void SwRedlineData::dumpAsXml(xmlTextWriterPtr pWriter) 
const
 switch (GetType())
 {
 case RedlineType::Insert:
-sRedlineType = "REDLINE_INSERT";
+sRedlineType = "REDLINE_INSERT"_ostr;
 break;
 case RedlineType::Delete:
-sRedlineType = "REDLINE_DELETE";
+sRedlineType = "REDLINE_DELETE"_ostr;
 break;
 case RedlineType::Format:
-sRedlineType = "REDLINE_FORMAT";
+sRedlineType = "REDLINE_FORMAT"_ostr;
 break;
 default:
-sRedlineType = "UNKNOWN";
+sRedlineType = "UNKNOWN"_ostr;
 break;
 }
 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), 
BAD_CAST(sRedlineType.getStr()));
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 88f79aff22e5..18eb78db8348 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -803,15 +803,15 @@ void SwTextFrame::dumpAsXmlAttributes(xmlTextWriterPtr 
writer) const
 OString aMode = "Horizontal"_ostr;
 if (IsVertLRBT())
 {
-aMode = "VertBTLR";
+aMode = "VertBTLR"_ostr;
 }
 else if (IsVertLR())
 {
-aMode = "VertLR";
+aMode = "VertLR"_ostr;
 }
 else if (IsVertical())
 {
-aMode = "Vertical";
+aMode = "Vertical"_ostr;
 }
 (void)xmlTextWriterWriteAttribute(writer, BAD_CAST("WritingMode"), 
BAD_CAST(aMode.getStr()));
 }
diff --git a/sw/source/filter/html/css1atr.cxx 
b/sw/source/filter/html/css1atr.cxx
index deaaa5ea8a66..30ba8d3c0a75 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -777,16 +777,16 @@ sal_uInt16 SwHTMLWriter::GetCSS1Selector( const SwFormat 
*pFormat, OString& rTok
 if( pPseudo )
 {
 rToken = OOO_STRING_SVTOOLS_HTML_tabledata " "
- OOO_STRING_SVTOOLS_HTML_parabreak;
+ OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
 }
 else
-rToken = OOO_STRING_SVTOOLS_HTML_parabreak;
+rToken = OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
 break;
 case RES_POOLCOLL_TABLE_HDLN:
 if( pPseudo )
 {
 rToken = OOO_STRING_SVTOOLS_HTML_tableheader " "
- OOO_STRING_SVTOOLS_HTML_parabreak;
+ OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
 }
 else
 rToken = OOO_STRING_SVTOOLS_HTML_parabreak ""_ostr;
diff --git a/sw/source/filter/html/htmlatr.cxx 
b/sw/source/filter/html/htmlatr.cxx
index b4ed5c567cff..9f67d1ee0304 100644
--- a/sw/source/filter/html

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-29 Thread László Németh (via logerrit)
 sw/qa/core/text/text.cxx   |   12 ++--
 sw/source/core/text/porexp.cxx |5 +
 2 files changed, 7 insertions(+), 10 deletions(-)

New commits:
commit 78872cc81bf4b1377c9cae8f9040a2443d0690c0
Author: László Németh 
AuthorDate: Tue Nov 28 19:39:16 2023 +0100
Commit: László Németh 
CommitDate: Wed Nov 29 10:16:28 2023 +0100

tdf#157768 sw: fix lost character background of NBSP

Regression from commit 28675af84ae8e2342bd78be3696dc09de6ce5cc5
"tdf#41652: Variable width NBSP".

Change-Id: I066ecadac8961b182f8580147b197f13dd0daae4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160054
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index 8951b9fb6a82..7340a151d1f4 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -1263,9 +1263,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, 
testTdf41652NBSPWidth)
 xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile);
 
 nSectionAfterNBSPX_legacy_leftAligned
-= getXPath(pXmlDoc, "//textarray[3]"_ostr, "x"_ostr).toInt32();
+= getXPath(pXmlDoc, "//textarray[4]"_ostr, "x"_ostr).toInt32();
 nSectionAfterNBSPX_legacy_justified
-= getXPath(pXmlDoc, "//textarray[8]"_ostr, "x"_ostr).toInt32();
+= getXPath(pXmlDoc, "//textarray[10]"_ostr, "x"_ostr).toInt32();
 }
 
 // Measure the X of sections after NBSPs in a file with the option enabled
@@ -1278,9 +1278,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, 
testTdf41652NBSPWidth)
 xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile);
 
 nSectionAfterNBSPX_optionDisabled_leftAligned
-= getXPath(pXmlDoc, "//textarray[3]"_ostr, "x"_ostr).toInt32();
+= getXPath(pXmlDoc, "//textarray[4]"_ostr, "x"_ostr).toInt32();
 nSectionAfterNBSPX_optionDisabled_justified
-= getXPath(pXmlDoc, "//textarray[8]"_ostr, "x"_ostr).toInt32();
+= getXPath(pXmlDoc, "//textarray[10]"_ostr, "x"_ostr).toInt32();
 }
 
 // Measure the X of the sections after NBSPs in a file with the option 
enabled
@@ -1293,9 +1293,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, 
testTdf41652NBSPWidth)
 xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile);
 
 nSectionAfterNBSPX_optionEnabled_leftAligned
-= getXPath(pXmlDoc, "//textarray[3]"_ostr, "x"_ostr).toInt32();
+= getXPath(pXmlDoc, "//textarray[4]"_ostr, "x"_ostr).toInt32();
 nSectionAfterNBSPX_optionEnabled_justified
-= getXPath(pXmlDoc, "//textarray[8]"_ostr, "x"_ostr).toInt32();
+= getXPath(pXmlDoc, "//textarray[10]"_ostr, "x"_ostr).toInt32();
 }
 
 // Assert left aligned NBSP for the legacy file is larger than zero
diff --git a/sw/source/core/text/porexp.cxx b/sw/source/core/text/porexp.cxx
index 56e3d7c34265..0884db6fce76 100644
--- a/sw/source/core/text/porexp.cxx
+++ b/sw/source/core/text/porexp.cxx
@@ -211,6 +211,7 @@ void SwBlankPortion::Paint( const SwTextPaintInfo &rInf ) 
const
 // Draw field shade (can be disabled individually)
 if (!m_bMulti) // No gray background for multiportion brackets
 rInf.DrawViewOpt(*this, PortionType::Blank);
+SwExpandPortion::Paint(rInf);
 
 if (m_cChar == CHAR_HARDBLANK)
 {
@@ -242,10 +243,6 @@ void SwBlankPortion::Paint( const SwTextPaintInfo &rInf ) 
const
 aInf.GetFont()->SetColor(colorBackup);
 }
 }
-else
-{
-SwExpandPortion::Paint(rInf);
-}
 }
 
 bool SwBlankPortion::GetExpText( const SwTextSizeInfo& rInf, OUString &rText ) 
const


[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-28 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/htmlexport/data/image_anchored_to_paragraph_no_wrap.fodt |   20 +
 sw/qa/extras/htmlexport/htmlexport.cxx|   16 +
 sw/source/filter/html/htmlflywriter.cxx   |  112 
+-
 3 files changed, 95 insertions(+), 53 deletions(-)

New commits:
commit 1f2d30093c12de22a04bc16969e027446ded5205
Author: Mike Kaganski 
AuthorDate: Mon Nov 27 16:01:11 2023 +0300
Commit: Mike Kaganski 
CommitDate: Wed Nov 29 06:46:33 2023 +0100

Don't emit 'br clear=...' for graphics wrap in ReqIF export

Change-Id: I7684c78c9b98fe63c2281bf3b2a2186d125e0ba4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159994
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git 
a/sw/qa/extras/htmlexport/data/image_anchored_to_paragraph_no_wrap.fodt 
b/sw/qa/extras/htmlexport/data/image_anchored_to_paragraph_no_wrap.fodt
new file mode 100644
index ..f1080724307e
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/image_anchored_to_paragraph_no_wrap.fodt
@@ -0,0 +1,20 @@
+
+
+
+ 
+  
+   
+  
+ 
+ 
+  
+   
+  
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0
+   cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDIw
+   IDIwIiBzdHJva2U9ImJsYWNrIj4KPHBhdGggZD0iTTEsMUwxOSwxOSIvPgo8L3N2Zz4=
+  
+ 
+
+  
+ 
+
\ No newline at end of file
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx 
b/sw/qa/extras/htmlexport/htmlexport.cxx
index 161357ffbdba..96bdfab66b60 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -3016,6 +3016,22 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, 
testReqIF_ExportFormulasAsPDF)
  xTypeDetection->queryTypeByDescriptor(descr, true));
 }
 
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_NoBrClearForImageWrap)
+{
+// Given a document with a paragraph-anchored image with "none" wrap:
+createSwDoc("image_anchored_to_paragraph_no_wrap.fodt");
+// When exporting to reqif:
+ExportToReqif();
+// Make sure that there's no 'br' elements in the 'object' (used to 
represent the wrapping
+// in HTML export, using 'clear' attribute):
+xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile();
+assertXPath(pXmlDoc, 
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p/reqif-xhtml:object"_ostr);
+assertXPath(
+pXmlDoc,
+
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p/reqif-xhtml:object/reqif-xhtml:br"_ostr,
+0);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlflywriter.cxx 
b/sw/source/filter/html/htmlflywriter.cxx
index 9976124b3adc..a0627effdc2b 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -704,68 +704,71 @@ OString SwHTMLWriter::OutFrameFormatOptions( const 
SwFrameFormat &rFrameFormat,
 sOut.setLength(0);
 }
 
-// Insert wrap for graphics that are anchored to a paragraph as
-//  in the string
-const SwFormatSurround* pSurround;
-if( (nFrameOpts & HtmlFrmOpts::BrClear) &&
-((RndStdIds::FLY_AT_PARA == rFrameFormat.GetAnchor().GetAnchorId()) ||
- (RndStdIds::FLY_AT_CHAR == rFrameFormat.GetAnchor().GetAnchorId())) &&
-(pSurround = rItemSet.GetItemIfSet( RES_SURROUND )) )
-{
-sal_Int16 eHoriOri =rFrameFormat.GetHoriOrient().GetHoriOrient();
-pStr = nullptr;
-css::text::WrapTextMode eSurround = pSurround->GetSurround();
-bool bAnchorOnly = pSurround->IsAnchorOnly();
-switch( eHoriOri )
+if (!mbReqIF)
+{
+// Insert wrap for graphics that are anchored to a paragraph as
+//  in the string
+const SwFormatSurround* pSurround;
+if( (nFrameOpts & HtmlFrmOpts::BrClear) &&
+((RndStdIds::FLY_AT_PARA == 
rFrameFormat.GetAnchor().GetAnchorId()) ||
+ (RndStdIds::FLY_AT_CHAR == 
rFrameFormat.GetAnchor().GetAnchorId())) &&
+(pSurround = rItemSet.GetItemIfSet( RES_SURROUND )) )
 {
-case text::HoriOrientation::RIGHT:
+sal_Int16 eHoriOri =
rFrameFormat.GetHoriOrient().GetHoriOrient();
+pStr = nullptr;
+css::text::WrapTextMode eSurround = pSurround->GetSurround();
+bool bAnchorOnly = pSurround->IsAnchorOnly();
+switch( eHoriOri )
 {
-switch( eSurround )
+case text::HoriOrientation::RIGHT:
 {
-case css::text::WrapTextMode_NONE:
-case css::text::WrapTextMode_RIGHT:
-pStr = OOO_STRING_SVTOOLS_HTML_AL_right;
-break;
-case css::text::WrapTextMode_LEFT:
-case css::text::WrapTextMode_PARALLEL:
-if( bAnchorOnly )
-m_bClearRight = true;
-break;
-

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-28 Thread László Németh (via logerrit)
 sw/qa/extras/layout/layout3.cxx |   48 +++-
 sw/source/core/text/itrcrsr.cxx |4 +--
 sw/source/core/text/porlay.hxx  |7 -
 3 files changed, 45 insertions(+), 14 deletions(-)

New commits:
commit 20cbe88ce5610fd8ee302e5780a4c0821ddb3db4
Author: László Németh 
AuthorDate: Tue Nov 28 15:09:52 2023 +0100
Commit: László Németh 
CommitDate: Wed Nov 29 00:16:08 2023 +0100

tdf#119908 tdf#158419 sw smart justify: fix cursor position

Text cursor didn't follow the new word positions yet, because
of unsigned casting of the negative shrinking value.

Revert the temporary change of GetLLSpaceAdd() added by
commit 17eaebee279772b6062ae3448012133897fc71bb
"tdf#119908 sw smart justify: fix justification by shrinking".

Follow-up to commit 53de98b29548ded88e0a44c80256fc5e340d551e
"tdf#158333 sw smart justify: fix multiple text portions".

Change-Id: I82cb395fc5af800d8da67d27c16c5ed6837df695
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160050
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index dc70bf41b6f8..843712e62221 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -237,6 +237,48 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf158333)
 "consequat arcu ut diam tempor luctus. Cum sociis natoque 
penatibus et magnis ");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf158419)
+{
+createSwDoc("tdf130088.docx");
+SwDoc* pDoc = getSwDoc();
+SwDocShell* pShell = pDoc->GetDocShell();
+
+// Ensure that all text portions are calculated before testing.
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+SwViewShell* pViewShell
+= 
pTextDoc->GetDocShell()->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell();
+CPPUNIT_ASSERT(pViewShell);
+pViewShell->Reformat();
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+// second paragraph.
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+SwWrtShell* pWrtShell = pShell->GetWrtShell();
+SwPosition aPosition(*pWrtShell->GetCursor()->Start());
+SwTwips nSecondParaLeft
+= getXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds"_ostr, 
"left"_ostr).toInt32();
+SwTwips nSecondParaWidth
+= getXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds"_ostr, 
"width"_ostr).toInt32();
+SwTwips nSecondParaTop
+= getXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds"_ostr, 
"top"_ostr).toInt32();
+SwTwips nSecondParaHeight
+= getXPath(pXmlDoc, "/root/page/body/txt[2]/infos/bounds"_ostr, 
"height"_ostr).toInt32();
+Point aPoint;
+
+// click at the end of the second line of the second paragraph
+// (a line shrunk by the new justification)
+
+aPoint.setX(nSecondParaLeft + nSecondParaWidth);
+aPoint.setY(nSecondParaTop + (nSecondParaHeight / 6) * 1.5);
+SwCursorMoveState aState(CursorMoveState::NONE);
+pLayout->GetModelPositionForViewPoint(&aPosition, aPoint, &aState);
+// Without the accompanying fix in place, this test would have failed: 
character position was 155,
+// i.e. cursor was before the end of the paragraph.
+CPPUNIT_ASSERT_EQUAL(static_cast(156), 
aPosition.GetContentIndex());
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf106234)
 {
 createSwDoc("tdf106234.fodt");
@@ -822,12 +864,6 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testAbi11870)
 createSwDoc("abi11870-2.odt");
 }
 
-CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testOfz64109)
-{
-//just care it doesn't assert
-createSwDoc("ofz64109-1.fodt");
-}
-
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf118719)
 {
 // Insert a page break.
diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index 7a7024d97a09..1770361c19de 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -1371,7 +1371,7 @@ TextFrameIndex 
SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con
 if ( pPor->InSpaceGrp() && nSpaceAdd )
 {
 const_cast(GetInfo()).SetIdx( nCurrStart );
-nWidth = nWidth + sal_uInt16( pPor->CalcSpacing( nSpaceAdd, 
GetInfo() ) );
+nWidth = nWidth + sal_Int16( pPor->CalcSpacing( nSpaceAdd, 
GetInfo() ) );
 }
 if( ( pPor->InFixMargGrp() && ! pPor->IsMarginPortion() ) ||
 ( pPor->IsMultiPortion() && 
static_cast(pPor)->HasTabulator() )
@@ -1415,7 +1415,7 @@ TextFrameIndex 
SwTextCursor::GetModelPositionForViewPoint( SwPosition *pPos, con
 if ( pPor->InSpaceGrp() && nSpaceAdd )
 {
 const_cast(GetInfo()).SetIdx( nCurrStart );
-nWidth = nWidth + sal_uInt16( pPor->CalcSpacing( nSpaceAdd, 
GetInfo() ) );
+nWidth = nWidth + sal_Int16( pPor->CalcSpacing

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-27 Thread Jim Raykowski (via logerrit)
 sw/qa/uitest/navigator/tdf40427.py |   22 +++-
 sw/source/uibase/inc/content.hxx   |4 
 sw/source/uibase/inc/conttree.hxx  |1 
 sw/source/uibase/utlui/content.cxx |  188 ++---
 4 files changed, 174 insertions(+), 41 deletions(-)

New commits:
commit 468c5110226c7f5b3079852a27adde45dc32dc76
Author: Jim Raykowski 
AuthorDate: Wed Nov 22 00:00:57 2023 -0900
Commit: Jim Raykowski 
CommitDate: Mon Nov 27 18:56:38 2023 +0100

tdf#158103 Enhancement to display Sections as an expandable/

collapsible hierarchy in the Writer Navigator

Change-Id: I86bc17d11b4c5bf0ca0496e4ab62a0d77ddb625f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159812
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
Reviewed-by: Jim Raykowski 

diff --git a/sw/qa/uitest/navigator/tdf40427.py 
b/sw/qa/uitest/navigator/tdf40427.py
index f394bf37aa06..aaab63ffdd4d 100644
--- a/sw/qa/uitest/navigator/tdf40427.py
+++ b/sw/qa/uitest/navigator/tdf40427.py
@@ -19,6 +19,20 @@ class tdf40427(UITestCase):
 if name == get_state_as_dict(xItem)['Text']:
 return xItem
 
+  def expand_all(self, xTreeItem):
+count = len(xTreeItem.getChildren())
+for i in xTreeItem.getChildren():
+xTreeItem.getChild(i).executeAction("EXPAND", ())
+count += self.expand_all(xTreeItem.getChild(i))
+return count
+
+  def get_names(self, xTreeItem):
+names = []
+for i in xTreeItem.getChildren():
+names.append(get_state_as_dict(xTreeItem.getChild(str(i)))['Text'])
+names += self.get_names(xTreeItem.getChild(i))
+return names
+
   def test_tdf40427(self):
 with 
self.ui_test.load_file(get_url_for_data_file("tdf40427_SectionPositions.odt")) 
as document:
 xMainWindow = self.xUITest.getTopFocusWindow()
@@ -53,6 +67,7 @@ class tdf40427(UITestCase):
 xSections = self.get_item(xContentTree, 'Sections')
 self.assertEqual('Sections', get_state_as_dict(xSections)['Text'])
 xSections.executeAction("EXPAND", ())
+totalSectionsCount = self.expand_all(xSections)
 
 refSectionNames = [
   'SectionZ',
@@ -69,11 +84,10 @@ class tdf40427(UITestCase):
   'SectionB', # High on screen, but late in list because it's on 
second page
   'SectionC',
 ]
-self.assertEqual(len(refSectionNames), len(xSections.getChildren()))
+self.assertEqual(len(refSectionNames), totalSectionsCount)
+
+actSectionNames = self.get_names(xSections)
 
-actSectionNames = []
-for i in range(len(refSectionNames)):
-  
actSectionNames.append(get_state_as_dict(xSections.getChild(str(i)))['Text'])
 # Without the fix in place, this would fail with
 #   AssertionError: Lists differ: ['SectionZ', 'SectionY', 
'SectionT3', 'SectionT1', 'SectionT2'[100 chars]onC'] != ['SectionZ', 
'SectionB', 'SectionF3', 'SectionFinF3', 'Section[100 chars]onA']
 self.assertEqual(refSectionNames, actSectionNames)
diff --git a/sw/source/uibase/inc/content.hxx b/sw/source/uibase/inc/content.hxx
index c2a922189894..77cb156b744c 100644
--- a/sw/source/uibase/inc/content.hxx
+++ b/sw/source/uibase/inc/content.hxx
@@ -212,8 +212,8 @@ public:
 Invalidate();
 }
 
-bool GetSortType() const {return m_bAlphabeticSort;}
-void SetSortType(bool bAlphabetic) {m_bAlphabeticSort = bAlphabetic;}
+bool IsAlphabeticSort() const {return m_bAlphabeticSort;}
+void SetAlphabeticSort(bool bAlphabetic) {m_bAlphabeticSort = 
bAlphabetic;}
 
 voidInvalidate(); // only nMemberCount is read again
 
diff --git a/sw/source/uibase/inc/conttree.hxx 
b/sw/source/uibase/inc/conttree.hxx
index 9c6db5b5a5eb..a8094c40303a 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -107,6 +107,7 @@ class SwContentTree final : public SfxListener
 SwNavigationConfig* m_pConfig;
 
 std::map< void*, bool > mOutLineNodeMap;
+std::map m_aRegionNodeExpandMap; // stores expand state 
of nodes with children
 
 sal_Int32   m_nActiveBlock; // used to restore content 
types/categories expand state
 sal_Int32   m_nHiddenBlock;
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 770f8b41e705..07fd64dc3bf9 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -217,6 +217,11 @@ namespace
 rPos = *pPos;
 }
 }
+
+bool lcl_IsLowerRegionContent(const weld::TreeIter& rEntry, const 
weld::TreeView& rTreeView, sal_uInt8 nLevel)
+{
+return weld::fromId(rTreeView.get_id(rEntry))->GetRegionLevel() < nLevel;
+}
 }
 
 // Content, contains names and reference at the content type.
@@ -1727,7 +1732,7 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, 
rCEvt, bool)
 && nContentType != Cont

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-27 Thread László Németh (via logerrit)
 sw/qa/extras/layout/layout3.cxx |   36 
 sw/source/core/text/guess.cxx   |2 +-
 sw/source/core/text/porlin.cxx  |4 ++--
 sw/source/core/text/portxt.cxx  |3 ++-
 4 files changed, 41 insertions(+), 4 deletions(-)

New commits:
commit 53de98b29548ded88e0a44c80256fc5e340d551e
Author: László Németh 
AuthorDate: Thu Nov 23 14:01:10 2023 +0100
Commit: László Németh 
CommitDate: Mon Nov 27 14:48:19 2023 +0100

tdf#158333 sw smart justify: fix multiple text portions

Multiple text portions, e.g. if some part of a line
contains direct character formatting breaks DOCX
interoperability of justified paragraphs.

Follow-up to commit 17eaebee279772b6062ae3448012133897fc71bb
"tdf#119908 sw smart justify: fix justification by shrinking".

Change-Id: Ia53e763fdba89bb733bde088874e641b25d733f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159862
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 797b41fc7baf..dc70bf41b6f8 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -201,6 +201,42 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf119908)
 CPPUNIT_ASSERT_GREATER(sal_Int32(5840), nPortionWidth);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf158333)
+{
+createSwDoc("tdf130088.docx");
+// Ensure that all text portions are calculated before testing.
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+SwViewShell* pViewShell
+= 
pTextDoc->GetDocShell()->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell();
+CPPUNIT_ASSERT(pViewShell);
+pViewShell->Reformat();
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+// shrink line 2
+assertXPath(
+pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout[2]", 
"portion",
+"viverra odio. Donec auctor molestie sem, sit amet tristique lectus 
hendrerit sed. ");
+
+// shrink line 7
+assertXPath(
+pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout[7]", 
"portion",
+// This was "...diam ", not "...diam tempor "
+"laoreet vel leo nec, volutpat facilisis eros. Donec consequat arcu ut 
diam tempor ");
+
+// shrink line 2 of paragraph 2
+assertXPath(
+pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[2]", 
"portion",
+// This was "...Cras ", not "...Cras sodales "
+"Donec auctor molestie sem, sit amet tristique lectus hendrerit sed. 
Cras sodales ");
+
+// shrink line 2 of paragraph 4
+assertXPath(pXmlDoc, 
"/root/page/body/txt[4]/SwParaPortion/SwLineLayout[2]", "portion",
+// This was "...et ", not "...et magnis "
+"consequat arcu ut diam tempor luctus. Cum sociis natoque 
penatibus et magnis ");
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf106234)
 {
 createSwDoc("tdf106234.fodt");
diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index 6d92b64d9fce..5e66b366c63f 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -85,7 +85,7 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, 
SwTextFormatInfo &rInf,
 DocumentSettingId::JUSTIFY_LINES_WITH_SHRINKING))
 {
 // allow up to 2% shrinking of the line
-nLineWidth /= 0.98;
+nLineWidth = nLineWidth / 0.98 + rInf.X() / 0.98 - rInf.X();
 }
 
 // tdf#104668 space chars at the end should be cut if the compatibility 
option is enabled
diff --git a/sw/source/core/text/porlin.cxx b/sw/source/core/text/porlin.cxx
index fdd0ffba53b9..6d0992f1abf6 100644
--- a/sw/source/core/text/porlin.cxx
+++ b/sw/source/core/text/porlin.cxx
@@ -276,9 +276,9 @@ void SwLinePortion::Move(SwTextPaintInfo & rInf) const
 bool bCounterDir = ( ! bFrameDir && DIR_RIGHT2LEFT == rInf.GetDirection() 
) ||
(   bFrameDir && DIR_LEFT2RIGHT == rInf.GetDirection() 
);
 
-if ( InSpaceGrp() && rInf.GetSpaceAdd() )
+if ( InSpaceGrp() && rInf.GetSpaceAdd(/*bShrink=*/true) )
 {
-SwTwips nTmp = PrtWidth() + CalcSpacing( rInf.GetSpaceAdd(), rInf );
+SwTwips nTmp = PrtWidth() + CalcSpacing( 
rInf.GetSpaceAdd(/*bShrink=*/true), rInf );
 if( rInf.IsRotated() )
 rInf.Y( rInf.Y() + ( bB2T ? -nTmp : nTmp ) );
 else if ( bCounterDir )
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index 1e2f8d1823d0..ff6d40cd4d95 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -668,7 +668,8 @@ tools::Long SwTextPortion::CalcSpacing( tools::Long 
nSpaceAdd, const SwTextSizeI
 }
 }
 
-return sal_Int32(nCnt) * nSpaceAdd / SPACING_PRECISION_FACTOR;
+return sal_Int32(nCnt) * (nSpaceAdd > LONG_MAX/2 ? LONG_MAX/2 - nSpaceAdd 
: nSpaceAdd)
+ / SPACING_PRECISION_F

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-27 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/flycnt.cxx |   42 +++
 sw/source/core/layout/flycnt.cxx |7 ++
 2 files changed, 49 insertions(+)

New commits:
commit 272c3548c4d2362eb737947c8cbb017e2d55aae1
Author: Miklos Vajna 
AuthorDate: Mon Nov 27 08:36:37 2023 +0100
Commit: Miklos Vajna 
CommitDate: Mon Nov 27 10:35:15 2023 +0100

sw floattable, per-frame wrap-on-all-pages mode: add layout

The anchor text of a floating table is normally wrapped around the table
only on the last page of the table. This property requests to wrap on
all pages instead for this frame.

Commit 7d7ca347fafa7a06094b00e8fb0d0452c4c81366 (sw floattable, wrap on
all pages: add layout, 2023-10-13) already arranged the layout code to
go via the per-frame SwFlyAtContentFrame::IsWrapOnAllPages(), so only
that needs updating.

Instead of always deciding this at a per-doc level, first check if the
frame itself requests the on-all-pages behavior. Otherwise keep deciding
this on a per-doc level. This is meant to please what the OASIS/ODT
proposal wants and also keeps the Word-style per-doc setting.

The ODT filter still needs doing.

Change-Id: Ibf10b5f016d70e6fe948d5273cc1fb1d98495586
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159981
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 6c508a5f87e7..6b84ca3fb16d 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace
 {
@@ -1221,6 +1222,47 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWrapOnAllPages)
 CPPUNIT_ASSERT(!pPage2Anchor->GetFollow());
 CPPUNIT_ASSERT_EQUAL(OUString("didn't bode well."), aAnchor2Text);
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyPerFrameWrapOnAllPages)
+{
+// Given a document where we want to wrap on all pages, around a split 
floating table:
+createSwDoc("floattable-wrap-on-all-pages.docx");
+SwDoc* pDoc = getSwDoc();
+sw::SpzFrameFormats& rFlys = *pDoc->GetSpzFrameFormats();
+sw::SpzFrameFormat* pFly = rFlys[0];
+SfxItemSet aSet(pFly->GetAttrSet());
+SwFormatWrapTextAtFlyStart aItem(true);
+aSet.Put(aItem);
+pDoc->SetFlyFrameAttr(*pFly, aSet);
+
+// When formatting that document:
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+pWrtShell->Reformat();
+
+// Then make sure that the anchor text is also split between page 1 and 
page 2:
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+auto pPage1Anchor = pPage1->FindLastBodyContent()->DynCastTextFrame();
+CPPUNIT_ASSERT(pPage1Anchor);
+OUString aAnchor1Text(pPage1Anchor->GetText().subView(
+static_cast(pPage1Anchor->GetOffset()),
+static_cast(pPage1Anchor->GetFollow()->GetOffset()
+   - pPage1Anchor->GetOffset(;
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: He heard quiet steps behind him. That
+// - Actual  :
+// i.e. the first page had no anchor text, only the second.
+CPPUNIT_ASSERT_EQUAL(OUString("He heard quiet steps behind him. That "), 
aAnchor1Text);
+auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage2);
+auto pPage2Anchor = pPage2->FindLastBodyContent()->DynCastTextFrame();
+CPPUNIT_ASSERT(pPage2Anchor);
+OUString aAnchor2Text(
+
pPage2Anchor->GetText().subView(static_cast(pPage2Anchor->GetOffset(;
+CPPUNIT_ASSERT(!pPage2Anchor->GetFollow());
+CPPUNIT_ASSERT_EQUAL(OUString("didn't bode well."), aAnchor2Text);
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index c07201f49f43..a53b8841f84a 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -52,6 +52,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 
@@ -1786,6 +1787,12 @@ void SwFlyAtContentFrame::DelEmpty()
 
 bool SwFlyAtContentFrame::IsWrapOnAllPages() const
 {
+const SwFormatWrapTextAtFlyStart& rWrapTextAtFlyStart = 
GetFormat()->GetWrapTextAtFlyStart();
+if (rWrapTextAtFlyStart.GetValue())
+{
+return true;
+}
+
 const SwRootFrame* pRootFrame = getRootFrame();
 if (!pRootFrame)
 {


[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-22 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/floattable-table-join.docx |binary
 sw/qa/core/layout/tabfrm.cxx  |   60 ++
 sw/source/core/layout/tabfrm.cxx  |   14 -
 3 files changed, 73 insertions(+), 1 deletion(-)

New commits:
commit 223d2fac61e061478721a7a4a89b1362f5037d8f
Author: Miklos Vajna 
AuthorDate: Wed Nov 22 08:31:17 2023 +0100
Commit: Miklos Vajna 
CommitDate: Wed Nov 22 09:57:04 2023 +0100

sw floattable: fix crash by trying harder to split tables

Regression from commit 60e2fdf1d7e8346e5a3835369c47e582c737ce20 (sw
floattable: maintain the invariant that fly height is at least MINFLY,
2023-09-28), the bugdoc crashed on load in SwTabFrame::MakeAll(),
because the tab frame's HasFollowFlowLine() was true, but
GetFollow()->GetFirstNonHeadlineRow() was nullptr and the invarint is
that these are always in sync.

Digging deeper, what happens is that the master table has a split row at
the end, so the follow table has a "follow flow line". We remove that
when we try to split the master table (split either moves rows to the
follow or creates a new follow), so the follow table only has a
"headline row" remaining. Then Split() is called with bTryToSplit set to
true, this fails (because only a single line would fit the master, but
orphan/widow control rejects that) and then we join the follow table
(because it only has headline rows), so a split with bTryToSplit set to
false (don't split the row itself) never happens. This at the end leads
to a strange table frame with only headline rows and gets deleted, which
is odd to happen during the initial layout.

Fix the problem by remembering if we just removed the follow flow line,
and in case we tried to split the rows itself and table split failed,
then don't join the follow table, so a next split can be invoked with
bTryToSplit set to false, which leads to the correct layout. This means
not only the crash is fixed, but also no layout loop happens and result
matches Word.

Limit this to tables in split flys, at least for this bugdoc the inline
table case would not have this problem as widow/orphan control is
disabled inside inline tables.

Change-Id: I172e38be11baf6f73df722a4c6c035a6a283d727
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159802
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-table-join.docx 
b/sw/qa/core/layout/data/floattable-table-join.docx
new file mode 100644
index ..807b4cfa8c11
Binary files /dev/null and b/sw/qa/core/layout/data/floattable-table-join.docx 
differ
diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx
index cfad007cebcd..e83767992aa6 100644
--- a/sw/qa/core/layout/tabfrm.cxx
+++ b/sw/qa/core/layout/tabfrm.cxx
@@ -13,6 +13,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 namespace
 {
@@ -109,6 +113,62 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNestedRowSpan)
 // Then make sure the resulting page count matches Word:
 CPPUNIT_ASSERT_EQUAL(6, getPages());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyTableJoin)
+{
+// Given a document with a multi-page floating table:
+// When loading this document:
+createSwDoc("floattable-table-join.docx");
+
+// Then make sure this document doesn't crash the layout and has a 
floating table split on 4
+// pages:
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+CPPUNIT_ASSERT(pPage1->GetSortedObjs());
+{
+SwSortedObjs& rPageObjs = *pPage1->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size());
+auto pFly = 
rPageObjs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame();
+CPPUNIT_ASSERT(pFly);
+// Start of the chain.
+CPPUNIT_ASSERT(!pFly->GetPrecede());
+CPPUNIT_ASSERT(pFly->HasFollow());
+}
+auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage2);
+CPPUNIT_ASSERT(pPage2->GetSortedObjs());
+{
+SwSortedObjs& rPageObjs = *pPage2->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size());
+auto pFly = 
rPageObjs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame();
+CPPUNIT_ASSERT(pFly);
+CPPUNIT_ASSERT(pFly->GetPrecede());
+CPPUNIT_ASSERT(pFly->HasFollow());
+}
+auto pPage3 = pPage2->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage3);
+CPPUNIT_ASSERT(pPage3->GetSortedObjs());
+{
+SwSortedObjs& rPageObjs = *pPage3->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs.size());
+auto pFly = 
rPageObjs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame();
+CPPUNIT_ASSERT(pFly)

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-21 Thread Andreas Heinisch (via logerrit)
 sw/qa/uitest/writer_tests5/tdf115871.py |   87 
 sw/source/ui/chrdlg/numpara.cxx |6 +-
 2 files changed, 92 insertions(+), 1 deletion(-)

New commits:
commit c95f406fcde65e383cff90842ff66e55bfabfc79
Author: Andreas Heinisch 
AuthorDate: Tue Nov 21 15:45:22 2023 +0100
Commit: Andreas Heinisch 
CommitDate: Tue Nov 21 16:55:59 2023 +0100

tdf#115871 - Reset outline and list options to parent settings

Added the various items of the controls in the outline and list options
tab to the range container. Otherwise, the main dialog does not have any
knowledge about the options to reset to the parent settings.

Change-Id: Icc9f862e741eb0457cfb1c74e64324809c143ab3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159787
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sw/qa/uitest/writer_tests5/tdf115871.py 
b/sw/qa/uitest/writer_tests5/tdf115871.py
new file mode 100755
index ..1f8639b64586
--- /dev/null
+++ b/sw/qa/uitest/writer_tests5/tdf115871.py
@@ -0,0 +1,87 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from uitest.framework import UITestCase
+from uitest.uihelper.common import type_text
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.common import get_state_as_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class tdf115871(UITestCase):
+
+   def test_tdf115871_reset_outline_list_options_parent(self):
+
+with self.ui_test.create_doc_in_start_center("writer"):
+
+# Create new style from selection
+with 
self.ui_test.execute_dialog_through_command(".uno:StyleNewByExample") as 
xDialog:
+xStyleName = xDialog.getChild("stylename")
+type_text(xStyleName, "Custom Heading 1")
+
+# Modify the created style to inherit paragraph attributes from 
Heading 1
+with self.ui_test.execute_dialog_through_command(".uno:EditStyle") 
as xDialog:
+xTabs = xDialog.getChild("tabcontrol")
+select_pos(xTabs, "0")
+xLinkedWith = xTabs.getChild("linkedwith")
+xLinkedWith.executeAction("SELECT", mkPropertyValues({"TEXT": 
"Heading 1"}))
+
self.assertEqual(get_state_as_dict(xLinkedWith)["SelectEntryText"], "Heading 1")
+
+# Modify outline & list settings of the created style
+with self.ui_test.execute_dialog_through_command(".uno:EditStyle") 
as xDialog:
+xTabs = xDialog.getChild("tabcontrol")
+select_pos(xTabs, "15")
+
+# Outline level
+xOutlineLevel = xTabs.getChild("comboLB_OUTLINE_LEVEL")
+xOutlineLevel.executeAction("SELECT", 
mkPropertyValues({"TEXT": "Level 5"}))
+
self.assertEqual(get_state_as_dict(xOutlineLevel)["SelectEntryText"], "Level 5")
+
+# List style
+xListStyle = xTabs.getChild("comboLB_NUMBER_STYLE")
+xListStyle.executeAction("SELECT", mkPropertyValues({"TEXT": 
"Numbering 123"}))
+
self.assertEqual(get_state_as_dict(xListStyle)["SelectEntryText"], "Numbering 
123")
+
+# Line numbering including start with
+xRestartAtParagraph = 
xTabs.getChild("checkCB_RESTART_PARACOUNT")
+xRestartAtParagraph.executeAction("CLICK", tuple())
+
self.assertEqual(get_state_as_dict(xRestartAtParagraph)["Selected"], "true")
+xStartWith = xTabs.getChild("spinNF_RESTART_PARA")
+xStartWith.executeAction("UP", tuple())
+self.assertEqual(get_state_as_dict(xStartWith)["Text"], "2")
+
+# Open the paragraph style dialog and reset dialog to parent 
settings
+with self.ui_test.execute_dialog_through_command(".uno:EditStyle") 
as xDialog:
+xTabs = xDialog.getChild("tabcontrol")
+select_pos(xTabs, "15")
+
+xStandardButton = xDialog.getChild("standard")
+xStandardButton.executeAction("CLICK", tuple())
+
+xOutlineLevel = xTabs.getChild("comboLB_OUTLINE_LEVEL")
+# Without the fix in place, this test would have failed with
+# AssertionError: 'Level 5' != 'Level 1'
+
self.assertEqual(get_state_as_dict(xOutlineLevel)["SelectEntryText"], "Level 1")
+
+xListStyle = xTabs.getChild("comboLB_NUMBER_STYLE")
+# Without the fix in place, this test would have failed with
+# AssertionError: 'Numbering 123' != 'Heading Numbering'
+
self.assertEqual(get_state_as_d

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-20 Thread Caolán McNamara (via logerrit)
 sw/qa/extras/layout/data/ofz64109-1.fodt |binary
 sw/qa/extras/layout/layout3.cxx  |6 ++
 sw/source/core/text/porfld.cxx   |   10 ++
 3 files changed, 16 insertions(+)

New commits:
commit 72928fa459f8e67c30a2e2357424ab75d3105a26
Author: Caolán McNamara 
AuthorDate: Sat Nov 18 21:56:51 2023 +
Commit: Caolán McNamara 
CommitDate: Mon Nov 20 12:36:27 2023 +0100

ofz#64109 crash in CharClass::isLetterNumeric

there appears to be an extra portion created, because HookChar is
set, but there doesn't seem to be a reason for the HookChar so we
get an unwanted trailing portion.

It seems that the HookChar is set when processing the field, presumably
when we restore the SwTextFormatInfo text, idx and len we should also
restore its original HookChar state.

At least for this ruby text case there the field contents are drawn over
the body text, unlike others where the contents are drawn inline with
the body text, where we appear to need to keep the hook char.

Change-Id: Id48a3ef09cd10dcc91048f8c08207d2d105839d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159642
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sw/qa/extras/layout/data/ofz64109-1.fodt 
b/sw/qa/extras/layout/data/ofz64109-1.fodt
new file mode 100644
index ..26a4bbbf63cf
Binary files /dev/null and b/sw/qa/extras/layout/data/ofz64109-1.fodt differ
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 11b9aec05ad2..797b41fc7baf 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -786,6 +786,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testAbi11870)
 createSwDoc("abi11870-2.odt");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testOfz64109)
+{
+//just care it doesn't assert
+createSwDoc("ofz64109-1.fodt");
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf118719)
 {
 // Insert a page break.
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index 580b4a2635a7..1a30a4ecd7d1 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -145,6 +145,7 @@ class SwFieldSlot
 OUString aText;
 TextFrameIndex nIdx;
 TextFrameIndex nLen;
+sal_Unicode nOrigHookChar;
 SwTextFormatInfo *pInf;
 bool bOn;
 public:
@@ -158,6 +159,7 @@ SwFieldSlot::SwFieldSlot( const SwTextFormatInfo* pNew, 
const SwFieldPortion *pP
 : pOldText(nullptr)
 , nIdx(0)
 , nLen(0)
+, nOrigHookChar(0)
 , pInf(nullptr)
 {
 bOn = pPor->GetExpText( *pNew, aText );
@@ -170,6 +172,7 @@ SwFieldSlot::SwFieldSlot( const SwTextFormatInfo* pNew, 
const SwFieldPortion *pP
 nIdx = pInf->GetIdx();
 nLen = pInf->GetLen();
 pOldText = &(pInf->GetText());
+nOrigHookChar = pInf->GetHookChar();
 m_pOldCachedVclData = pInf->GetCachedVclData();
 pInf->SetLen(TextFrameIndex(aText.getLength()));
 pInf->SetCachedVclData(nullptr);
@@ -200,6 +203,13 @@ SwFieldSlot::~SwFieldSlot()
 {
 pInf->SetCachedVclData(m_pOldCachedVclData);
 pInf->SetText( *pOldText );
+// ofz#64109 at last for ruby-text when we restore the original text to
+// continue laying out the 'body' text of the ruby, then a tab or other
+// 'hook char' in the text drawn above it shouldn't affect the 'body'
+// While there are other cases, such as tdf#148360, where the tab in an
+// inline expanded field, that should affect the body.
+if (pInf->IsRuby())
+pInf->SetHookChar(nOrigHookChar);
 pInf->SetIdx( nIdx );
 pInf->SetLen( nLen );
 pInf->SetFakeLineStart( false );


[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-20 Thread Jaume Pujantell (via logerrit)
 sw/qa/core/unocore/data/tdf108272-1-minimal.docx |binary
 sw/qa/core/unocore/unocore.cxx   |6 ++
 sw/source/core/unocore/unotext.cxx   |1 +
 3 files changed, 7 insertions(+)

New commits:
commit 43868de0ddabba952b923f6189d1fefeddb70bcf
Author: Jaume Pujantell 
AuthorDate: Mon Nov 20 10:24:18 2023 +0100
Commit: Jaume Pujantell 
CommitDate: Mon Nov 20 12:18:23 2023 +0100

fix a regression crash

Fixes a crash introduced by commit 5082d50.

Change-Id: Id33c49165c4d345d652a546db14df98ee0ff754a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159736
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/core/unocore/data/tdf108272-1-minimal.docx 
b/sw/qa/core/unocore/data/tdf108272-1-minimal.docx
new file mode 100644
index ..28efdf65b9af
Binary files /dev/null and b/sw/qa/core/unocore/data/tdf108272-1-minimal.docx 
differ
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index fd5c139e979a..00c61a042b77 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -1025,6 +1025,12 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testTdf149555)
 CPPUNIT_ASSERT_EQUAL(OUString("HEADER 2"), xHeaderText->getString());
 }
 
+// just care that it doesn't crash/assert
+CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testTdf108272Crash)
+{
+createSwDoc("tdf108272-1-minimal.docx");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unotext.cxx 
b/sw/source/core/unocore/unotext.cxx
index 5fef89f3ffde..f959d6a6104c 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1579,6 +1579,7 @@ SwXText::convertToTextFrame(
 (pStartStartNode != GetStartNode()))
 {
 // if not - remove the additional paragraphs and throw
+oAnchorCheckPam.reset(); // clear SwIndex before deleting nodes
 if (bParaBeforeInserted)
 {
 SwCursor aDelete(*pStartPam->GetPoint(), nullptr);


[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-20 Thread Miklos Vajna (via logerrit)
 sw/qa/core/frmedt/frmedt.cxx |   12 
 sw/source/core/frmedt/fefly1.cxx |   22 --
 2 files changed, 32 insertions(+), 2 deletions(-)

New commits:
commit 45a4ed02281a7a8ca52fccf626c792e417c8ef1c
Author: Miklos Vajna 
AuthorDate: Mon Nov 20 08:35:57 2023 +0100
Commit: Miklos Vajna 
CommitDate: Mon Nov 20 10:19:22 2023 +0100

sw floattable, delete UI: fix undo/redo

Pressing the unfloat context menu item for a frame resulted in 2 undo
actions and trying to undo both even crashed.

One problem was that no SwNode was left in the TextFrame and then it was
deleted; but undo created a TextFrame with an empty SwNode in it.

Fix this by inserting an empty text node at the end of the TextFrame and
only then moving content from it.

The other trouble was that in case the new text node has no matching
frame during MoveNodeRange(), then the fly frame will be deleted twice:
once during MoveNodeRange() (because it has become empty) and once more
during DelLayoutFormat(). This can be avoided by moving AppendTextNode()
to its own layout action. Finally also group the (now) 3 undo actions
together, because it was a single action on the UI.

Change-Id: I95ce0abbab79a293ecb209579c105f96d284a1c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159730
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/frmedt/frmedt.cxx b/sw/qa/core/frmedt/frmedt.cxx
index 618fe7fb574f..b2a53e60db27 100644
--- a/sw/qa/core/frmedt/frmedt.cxx
+++ b/sw/qa/core/frmedt/frmedt.cxx
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /// Covers sw/source/core/frmedt/ fixes.
 class SwCoreFrmedtTest : public SwModelTestBase
@@ -204,6 +205,8 @@ CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, testSplitFlyUnfloat)
 // Given a document with a floating table:
 createSwDoc();
 SwDoc* pDoc = getSwDocShell()->GetDoc();
+CPPUNIT_ASSERT(pDoc->GetUndoManager().IsUndoEnabled());
+pDoc->GetUndoManager().EnableUndo(false);
 sw::FrameFormats& rFlyFormats = 
*pDoc->GetSpzFrameFormats();
 CPPUNIT_ASSERT(rFlyFormats.empty());
 // Insert a table:
@@ -226,6 +229,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, testSplitFlyUnfloat)
 pWrtShell->EndAllAction();
 CPPUNIT_ASSERT(!rFlyFormats.empty());
 CPPUNIT_ASSERT_EQUAL(static_cast(1), 
pDoc->GetTableFrameFormatCount(/*bUsed=*/true));
+pDoc->GetUndoManager().EnableUndo(true);
 
 // When marking that frame and unfloating it:
 selectShape(1);
@@ -236,6 +240,14 @@ CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, testSplitFlyUnfloat)
 // have failed, the frame was not removed.
 CPPUNIT_ASSERT(rFlyFormats.empty());
 CPPUNIT_ASSERT_EQUAL(static_cast(1), 
pDoc->GetTableFrameFormatCount(/*bUsed=*/true));
+
+// When undoing the conversion to inline:
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
pDoc->GetUndoManager().GetUndoActionCount());
+pDoc->GetUndoManager().Undo();
+
+// Then the undo stack had 2 undo actions and undo-all crashed.
+CPPUNIT_ASSERT(!rFlyFormats.empty());
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
pDoc->GetTableFrameFormatCount(/*bUsed=*/true));
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index d9a620122b07..9e2fedcc3827 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -275,6 +276,10 @@ void SwFEShell::SelectFlyFrame( SwFlyFrame& rFrame )
 
 void SwFEShell::UnfloatFlyFrame()
 {
+GetIDocumentUndoRedo().StartUndo(SwUndoId::DELLAYFMT, nullptr);
+comphelper::ScopeGuard g([this]
+ { 
GetIDocumentUndoRedo().EndUndo(SwUndoId::DELLAYFMT, nullptr); });
+
 SwFlyFrame* pFly = GetSelectedFlyFrame();
 if (!pFly)
 {
@@ -295,7 +300,21 @@ void SwFEShell::UnfloatFlyFrame()
 return;
 }
 
-SwNodeRange aRange(pFlyStart->GetNode(), SwNodeOffset(1), *pFlyEnd, 
SwNodeOffset(0));
+// Create an empty paragraph after the table, so the frame's SwNodes 
section is non-empty after
+// MoveNodeRange(). Undo would ensure it's non-empty and then node offsets 
won't match.
+IDocumentContentOperations& rIDCO = 
GetDoc()->getIDocumentContentOperations();
+{
+SwNodeIndex aInsertIndex(*pFlyEnd);
+--aInsertIndex;
+SwPosition aInsertPos(aInsertIndex);
+StartAllAction();
+rIDCO.AppendTextNode(aInsertPos);
+// Make sure that a layout frame is created for the node, so the fly 
frame is not deleted,
+// during MoveNodeRange(), either.
+EndAllAction();
+}
+
+SwNodeRange aRange(pFlyStart->GetNode(), SwNodeOffset(1), *pFlyEnd, 
SwNodeOffset(-1));
 const SwFormatAnchor& rAnchor = rFlyFormat.GetAnchor();
 SwNode* pAnchor = rAnchor.GetAnchorNode();
 if (!pAnchor)
@@ -305,7 +324,6 

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-17 Thread Michael Stahl (via logerrit)
 sw/qa/extras/layout/layout.cxx|3 ---
 sw/source/core/inc/objectformatter.hxx|3 ++-
 sw/source/core/layout/fly.cxx |6 --
 sw/source/core/layout/objectformatter.cxx |5 +++--
 4 files changed, 9 insertions(+), 8 deletions(-)

New commits:
commit 191babee4f0ec643b80e96b0cd98c2d04ff96e4e
Author: Michael Stahl 
AuthorDate: Thu Nov 16 19:45:05 2023 +0100
Commit: Michael Stahl 
CommitDate: Fri Nov 17 09:09:20 2023 +0100

sw: fix layout crash in SwObjectFormatterTextFrame::DoFormatObj()

Since commit 15b886f460919ea3dce425a621dc017c2992a96b this is happening
in testForcepoint93, but only on WNT.

The crash is in SwObjectFormatterTextFrame::DoFormatObj() calling
SwObjectFormatterTextFrame::InvalidateFollowObjs() and the mrPageFrame
has been deleted; there is also the m_bAgain flag set in the SwLayAction
up the stack, but the SwObjectFormatter::mpLayAction is null so
DoFormatObj() cannot check this condition.

In the caller CalcContent(), get the SwLayAction from the SwViewShell
and pass it to the SwObjectFormatter, which appears to fix the problem.

Change-Id: Ib3dc34ce39b4aad723251271c24bdd7a6598ab1c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159518
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 83cbf0757c96..47f2eddbc42d 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3480,15 +3480,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint91) 
{ createSwWebDoc("forcepo
 //just care it doesn't crash/assert
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint92) { 
createSwDoc("forcepoint92.doc"); }
 
-#ifndef _MSC_VER
-//FIXME: crashes only on WNT with RTF import changes - debug next week
 //just care it doesn't crash/assert
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint93)
 {
 createSwDoc("forcepoint93-1.rtf");
 createSwDoc("forcepoint93-2.rtf");
 }
-#endif
 
 //just care it doesn't crash/assert
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint94) { 
createSwWebDoc("forcepoint94.html"); }
diff --git a/sw/source/core/inc/objectformatter.hxx 
b/sw/source/core/inc/objectformatter.hxx
index 99d8644f2c29..f85c12dc5f2d 100644
--- a/sw/source/core/inc/objectformatter.hxx
+++ b/sw/source/core/inc/objectformatter.hxx
@@ -166,7 +166,8 @@ class SwObjectFormatter
 */
 static bool FormatObj( SwAnchoredObject& _rAnchoredObj,
SwFrame* _pAnchorFrame = nullptr,
-   const SwPageFrame* _pPageFrame = nullptr );
+   const SwPageFrame* _pPageFrame = nullptr,
+   SwLayAction* pLayAction = nullptr );
 };
 
 #endif
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 33880623a481..8dad5a5ad047 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -1566,7 +1566,8 @@ void SwFlyFrame::Format( vcl::RenderContext* 
/*pRenderContext*/, const SwBorderA
 //  Thus,  no longer used by 
.
 void CalcContent( SwLayoutFrame *pLay, bool bNoColl )
 {
-vcl::RenderContext* pRenderContext = 
pLay->getRootFrame()->GetCurrShell()->GetOut();
+SwViewShell & rShell(*pLay->getRootFrame()->GetCurrShell());
+vcl::RenderContext* pRenderContext = rShell.GetOut();
 SwSectionFrame* pSect;
 bool bCollect = false;
 if( pLay->IsSctFrame() )
@@ -1727,7 +1728,8 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl )
 }
 }
 
-if ( !SwObjectFormatter::FormatObj( *pAnchoredObj, 
pAnchorFrame, pAnchorPageFrame ) )
+if (!SwObjectFormatter::FormatObj(*pAnchoredObj, 
pAnchorFrame, pAnchorPageFrame,
+rShell.Imp()->IsAction() ? 
&rShell.Imp()->GetLayAction() : nullptr))
 {
 bRestartLayoutProcess = true;
 break;
diff --git a/sw/source/core/layout/objectformatter.cxx 
b/sw/source/core/layout/objectformatter.cxx
index b99da6a0fe4b..6395d2f9e3a8 100644
--- a/sw/source/core/layout/objectformatter.cxx
+++ b/sw/source/core/layout/objectformatter.cxx
@@ -167,7 +167,8 @@ bool SwObjectFormatter::FormatObjsAtFrame( SwFrame& 
_rAnchorFrame,
 */
 bool SwObjectFormatter::FormatObj( SwAnchoredObject& _rAnchoredObj,
SwFrame* _pAnchorFrame,
-   const SwPageFrame* _pPageFrame )
+   const SwPageFrame* _pPageFrame,
+   SwLayAction * pLayAction)
 {
 bool bSuccess( true );
 
@@ -181,7 +182,7 @@ bool SwObjectFormatter::FormatObj( SwAnchoredObject& 
_rAnchoredObj,
 
 // create corresponding object formatter
 std::unique_ptr pObjFormatter =
-SwObj

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-16 Thread László Németh (via logerrit)
 sw/qa/core/text/frmform.cxx |4 +---
 sw/source/core/inc/drawfont.hxx |6 +-
 sw/source/core/text/inftxt.cxx  |2 +-
 sw/source/core/text/inftxt.hxx  |6 --
 sw/source/core/text/itradj.cxx  |   13 -
 sw/source/core/text/porlay.hxx  |7 ++-
 sw/source/core/text/portxt.cxx  |7 +--
 7 files changed, 30 insertions(+), 15 deletions(-)

New commits:
commit 17eaebee279772b6062ae3448012133897fc71bb
Author: László Németh 
AuthorDate: Wed Nov 15 23:31:12 2023 +0100
Commit: László Németh 
CommitDate: Thu Nov 16 16:21:06 2023 +0100

tdf#119908 sw smart justify: fix justification by shrinking

Shrink the exceeding lines by shrinking the spaces
between the words.

Because the negative spacing values are used
for the extra space between the characters in the main
data structure of the justified line layout, and not for
the space between the words, like the positive values,
the negative space values for shrinking are stored over
LONG_MAX/2 as absolute values to avoid of bigger changes
of the data structure before designing a better
justification algorithm, where it's possible to mix
different methods for the more visible text layout.

Note: the text cursor doesn't follow the new word
positions yet.

Follow-up to commit 7d08767b890e723cd502b1c61d250924f695eb98
"tdf#130088 tdf#119908 smart justify: fix DOCX line count + compat opt."

Change-Id: I9a63b5a93d6bce230e963ebc88ea2d0f9aa8fffb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159511
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/sw/qa/core/text/frmform.cxx b/sw/qa/core/text/frmform.cxx
index b321fca51cee..3d43bde6aa9c 100644
--- a/sw/qa/core/text/frmform.cxx
+++ b/sw/qa/core/text/frmform.cxx
@@ -63,9 +63,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableNegativeVertOffset)
 CPPUNIT_ASSERT_LESS(pPara2->getFrameArea().Top(), rFlyRect.Bottom());
 }
 
-// FIXME: because breaking the lines at the right place, this test
-// became obsolete: proposed fix is to modify compatibilityMode to "14"
-// in the DOCX test file to use the old justification algorithm
+// FIXME: because breaking the lines at the right place, test document became 
obsolete
 #if 0
 CPPUNIT_TEST_FIXTURE(Test, testFloattableAvoidManipOfst)
 {
diff --git a/sw/source/core/inc/drawfont.hxx b/sw/source/core/inc/drawfont.hxx
index 3d58f5fcd09d..fe6a44264759 100644
--- a/sw/source/core/inc/drawfont.hxx
+++ b/sw/source/core/inc/drawfont.hxx
@@ -544,7 +544,11 @@ public:
 }
 else
 {
-m_nSpace = nNew;
+// negative space (shrinking) stored over LONG_MAX/2
+if ( nNew < LONG_MAX/2 )
+m_nSpace = nNew;
+else
+m_nSpace = LONG_MAX/2 - nNew;
 m_nCharacterSpacing = 0;
 }
 #ifdef DBG_UTIL
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 82bbf9d879bf..129234c8a4cf 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -634,7 +634,7 @@ void SwTextPaintInfo::DrawText_( const OUString &rText, 
const SwLinePortion &rPo
 aDrawInf.SetUnderFnt( m_pUnderFnt );
 
 const tools::Long nSpaceAdd = ( rPor.IsBlankPortion() || 
rPor.IsDropPortion() ||
- rPor.InNumberGrp() ) ? 0 : GetSpaceAdd();
+ rPor.InNumberGrp() ) ? 0 : 
GetSpaceAdd(/*bShrink=*/true);
 if ( nSpaceAdd )
 {
 TextFrameIndex nCharCnt(0);
diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx
index 62cca26ac08f..f2f6d146136e 100644
--- a/sw/source/core/text/inftxt.hxx
+++ b/sw/source/core/text/inftxt.hxx
@@ -443,8 +443,10 @@ public:
 void SetSpaceIdx( sal_uInt16 nNew ) { m_nSpaceIdx = nNew; }
 void IncSpaceIdx() { ++m_nSpaceIdx; }
 void RemoveFirstSpaceAdd() { m_pSpaceAdd->erase( m_pSpaceAdd->begin() ); }
-tools::Long GetSpaceAdd() const
-{ return ( m_pSpaceAdd && m_nSpaceIdx < m_pSpaceAdd->size() )
+tools::Long GetSpaceAdd( bool bShrink = false ) const
+{ return ( m_pSpaceAdd && m_nSpaceIdx < m_pSpaceAdd->size() &&
+   // get shrink data only if asked explicitly, otherwise zero 
it
+   ( bShrink || (*m_pSpaceAdd)[m_nSpaceIdx] < LONG_MAX/2 ) )
? (*m_pSpaceAdd)[m_nSpaceIdx] : 0; }
 
 void SetpSpaceAdd( std::vector* pNew ){ m_pSpaceAdd = pNew; }
diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx
index b72a8d59f5f7..4dcaf03df1f8 100644
--- a/sw/source/core/text/itradj.cxx
+++ b/sw/source/core/text/itradj.cxx
@@ -290,6 +290,8 @@ void SwTextAdjuster::CalcNewBlock( SwLineLayout *pCurrent,
 bool bDoNotJustifyTab = false;
 
 SwLinePortion *pPos = pCurrent->GetNextPortion();
+// calculate real text width for shrinking
+tools::Long nBreakWidth = 0;
 
 while( pPos )
 {
@@ -367,6 +369

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-15 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/split-table-merged-border.odt |binary
 sw/qa/core/layout/paintfrm.cxx   |   49 +++
 sw/source/core/layout/paintfrm.cxx   |   24 +
 3 files changed, 63 insertions(+), 10 deletions(-)

New commits:
commit 47d824dd167eb34b08e5aec7141d2d9e6e996b34
Author: Miklos Vajna 
AuthorDate: Wed Nov 15 08:24:39 2023 +0100
Commit: Miklos Vajna 
CommitDate: Wed Nov 15 10:14:25 2023 +0100

tdf#157911 sw floattable: fix inconsistent inferred bottom border on split

The bugdoc has a split table between page 1 and page 2. The last row of
page 1 has a half bottom border: it starts on the left of the table,
but finishes earlier than the right of the table. This is since commit
08aea5526c75ff4c5385e960bd940f10ffa19cd5 (tdf#156351 sw floattable: fix
missing bottom border in master table, 2023-08-21).

The trouble is that Writer table borders are really at a cell-level (and
not at row or table level), the current partial border happens because
the first row has merged cells and the last row on page 1 doesn't have
merged cells, so the layout can't do a 1:1 mapping between the first row
and last row cells. It's also far from clear if the fixed result should
be no bottom border or a table-width bottom border:

- Word documents can have cell-level borders (where no inferred border
  is wanted) and table-level borders (where inferred borders are
  wanted), see the tdf#156351 bugdoc for a case where such inferring is
  wanted

- In case only cell-level borders are defined, then Word doesn't do such
  inferring

Fix the problem by always inferring such borders, because:

- Writer already did this in some cases for a long time, see commit
  a4da71fb824f2d4ecc7c01f4deb2865ba52f5f4c (INTEGRATION: CWS fmebugs04
  (1.115.46); FILE MERGED 2008/05/13 13:56:19 fme 1.115.46.2: #i9860# Top
  border for tables - correction 2008/05/13 13:49:23 fme 1.115.46.1:
  #i9860# Top border for tables, 2008-06-06)

- The Word UI creates table borders by default, so the majority of the
  DOCX documents also want this inferring

An alternative could be to only do such inferring for Word documents
with a compat flag, but that looks poor, given that Word doesn't always
do such inferring itself, either.

Change-Id: I052e4591e99d066c3109e8ab8b590e97c8aebd36
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159429
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/split-table-merged-border.odt 
b/sw/qa/core/layout/data/split-table-merged-border.odt
new file mode 100644
index ..122bfd473c7c
Binary files /dev/null and 
b/sw/qa/core/layout/data/split-table-merged-border.odt differ
diff --git a/sw/qa/core/layout/paintfrm.cxx b/sw/qa/core/layout/paintfrm.cxx
index ad09405fe3fb..baa858020acf 100644
--- a/sw/qa/core/layout/paintfrm.cxx
+++ b/sw/qa/core/layout/paintfrm.cxx
@@ -109,6 +109,55 @@ CPPUNIT_TEST_FIXTURE(Test, testRTLBorderMerge)
 // i.e. the 2nd and 5th vertical border was missing.
 CPPUNIT_ASSERT_EQUAL(6, nVerticalBorders);
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitTableMergedBorder)
+{
+// Given a document with a split table, first row in frame 1 has merged 
cells:
+createSwDoc("split-table-merged-border.odt");
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+SwDocShell* pShell = pTextDoc->GetDocShell();
+
+// When rendering that document:
+std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile();
+
+// Then make sure that the master table has a bottom border with the 
correct widths:
+MetafileXmlDump aDumper;
+xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile);
+xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, 
"//polyline[@style='solid']/point");
+xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
+std::set aHorizontalBorderStarts;
+std::set aHorizontalBorderEnds;
+// Collect the horizontal borders:
+for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); i += 2)
+{
+xmlNodePtr pStart = pXmlNodes->nodeTab[i];
+xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1];
+xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y"));
+xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y"));
+sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast(pStartY));
+sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast(pEndY));
+if (nStartY != nEndY)
+{
+// Vertical border.
+continue;
+}
+
+xmlChar* pStartX = xmlGetProp(pStart, BAD_CAST("x"));
+xmlChar* pEndX = xmlGetProp(pEnd, BAD_CAST("x"));
+sal_Int32 nStartX = o3tl::toInt32(reinterpret_cast(pStartX));
+sal_Int32 nEndX = o3tl::toInt32(reinterpret_cast(pEndX));
+aHorizontalBorderStarts.insert(nStartX);
+aHorizontalBorderEnds

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-14 Thread Miklos Vajna (via logerrit)
 sw/qa/uitest/ui/frmdlg/frmdlg.py   |5 +
 sw/source/uibase/frmdlg/frmmgr.cxx |4 
 sw/source/uibase/shells/textsh.cxx |   15 ---
 3 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit c1a535ee2db757b2e40683dc918cbad8b7429cfa
Author: Miklos Vajna 
AuthorDate: Tue Nov 14 08:20:47 2023 +0100
Commit: Miklos Vajna 
CommitDate: Tue Nov 14 09:34:10 2023 +0100

sw floattable, insert UI: fix unexpected border and spacing

Select an inline table (make sure the whole table is selected), insert a
frame, then the frame width is already calculated from the table width,
but an unexpected second frame border / spacing is also added. Given
that the table already has its own border, adding a second border by
default makes no sense.

It's possible to disable default borders in SetFrameSizeFromTable(), but
in case the borders are unchanged, the dialog's output item set will
still contain no border info, so we will still get the default borders.

Fix the problem by making this explicit: if the dialog's input item set
had border info and the output item set had none, then still copy over
the border info from the input to the output in
SwTextShell::ExecInsert().

This automatically fixes the unwanted border spacing as well, so the
default frame properties are on par with the ones created by Word import
filters.

Change-Id: I4c9f165dad7a8bb70cfcfadaea4466a8d174b46e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159399
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/uitest/ui/frmdlg/frmdlg.py b/sw/qa/uitest/ui/frmdlg/frmdlg.py
index bbb9d9a270dd..51b6f6e53199 100644
--- a/sw/qa/uitest/ui/frmdlg/frmdlg.py
+++ b/sw/qa/uitest/ui/frmdlg/frmdlg.py
@@ -98,6 +98,11 @@ class Test(UITestCase):
 # inserted first, only then it could be marked as "split allowed".
 self.assertEqual(fly_split_visible, True)
 
+# Without the accompanying fix in place, this test would have 
failed with:
+# AssertionError: 2 != 0
+# i.e. the frame had a border by default when the table already 
had its own border.
+
self.assertEqual(xComponent.TextFrames.Frame1.LeftBorder.LineWidth, 0)
+
 def test_insert_simple_frame(self):
 # Given a Writer document:
 with self.ui_test.create_doc_in_start_center("writer") as xComponent:
diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx 
b/sw/source/uibase/frmdlg/frmmgr.cxx
index eb38c1c803f7..cdfeb267b990 100644
--- a/sw/source/uibase/frmdlg/frmmgr.cxx
+++ b/sw/source/uibase/frmdlg/frmmgr.cxx
@@ -666,6 +666,10 @@ void SwFlyFrameAttrMgr::SetFrameSizeFromTable()
 // The whole table is selected: default fly width should be the table width
 // in this case.
 m_aSet.Put(pTableFormat->GetFrameSize());
+
+// The table can have its own border already, so an additional fly border 
makes no sense.
+SvxBoxItem aBoxItem(RES_BOX);
+m_aSet.Put(aBoxItem);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/shells/textsh.cxx 
b/sw/source/uibase/shells/textsh.cxx
index d0c9aabc979f..0924935b3d7e 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -531,7 +531,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
   GetView().GetViewFrame(),
   GetView().GetFrameWeld(),
   aSet));
-pDlg->StartExecuteAsync([pDlg, nSlot, this](sal_Int32 nResult) {
+pDlg->StartExecuteAsync([aSet, pDlg, nSlot, this](sal_Int32 
nResult) {
 if (nResult == RET_OK && pDlg->GetOutputItemSet())
 {
 SwFlyFrameAttrMgr aAttrMgr( true, GetShellPtr(), 
Frmmgr_Type::TEXT, nullptr );
@@ -541,8 +541,17 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
 rShell.StartAllAction();
 rShell.StartUndo(SwUndoId::INSERT);
 
-const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
-aAttrMgr.SetAttrSet(*pOutSet);
+SfxItemSet aOutSet(*pDlg->GetOutputItemSet());
+const SvxBoxItem* pBox = aSet.GetItem(RES_BOX);
+if (pBox && !aOutSet.HasItem(RES_BOX))
+{
+// The input set had border info but the output set 
not, then copy it over
+// to not lose the custom border info. This can happen 
when a whole table
+// is selected and that case has its own defaults, not 
matching the frame
+// style.
+aOutSet.Put(*pBox);
+}
+aAttrMgr.SetAttrSet(aOutSet);
 
 // At first delete the selection at the ClickTo

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-13 Thread Miklos Vajna (via logerrit)
 sw/qa/core/doc/doc.cxx|   43 ++
 sw/source/core/doc/doclay.cxx |   13 
 2 files changed, 48 insertions(+), 8 deletions(-)

New commits:
commit 6c761fa3b40d296444681d8d2f991e5a6b7e5b71
Author: Miklos Vajna 
AuthorDate: Mon Nov 13 08:49:43 2023 +0100
Commit: Miklos Vajna 
CommitDate: Mon Nov 13 10:24:26 2023 +0100

sw floattable, insert UI: fix missing undo/redo

There were 3 problems here:

1) SwDoc::MakeFlyAndMove() declared that inserting fly frames is broken
   anyway, so just deleted the whole undo stack. Remove the
   DelAllUndoObj() call, so the underlying problem is visible.

2) MoveNodeRange() had a flag to create undo objects, but this flag
   wasn't used.

3) The empty text node after the table in the just created fly was
   removed using a call to SwNodes::Delete(), which is not undo-aware,
   so the table was inserted after the anchor (and not before the anchor)
   on undo. Fix this by going via sw::DocumentContentOperationsManager that
   knows how to delete while working with the undo.

Do this unconditionally, because the 2 callers of this function is just
SwFEShell::NewFlyFrame() (UI) and SwXFrame::attachToRange() (UNO API,
mostly the DOCX import), probably both want proper undo support.

Change-Id: I50011bf969ff5636c76a8a0b280193ac6d2b90dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159354
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx
index 2a9870660830..2fad46194174 100644
--- a/sw/qa/core/doc/doc.cxx
+++ b/sw/qa/core/doc/doc.cxx
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /// Covers sw/source/core/doc/ fixes.
 class SwCoreDocTest : public SwModelTestBase
@@ -566,6 +567,48 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, 
testSplitExpandGlossary)
 CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size());
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testSplitFlyInsertUndo)
+{
+// Given a document with an inline table, which is then turned into a 
floating one:
+createSwDoc();
+SwDoc* pDoc = getSwDocShell()->GetDoc();
+sw::FrameFormats& rFlyFormats = 
*pDoc->GetSpzFrameFormats();
+CPPUNIT_ASSERT(rFlyFormats.empty());
+// Insert a table:
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0);
+pWrtShell->InsertTable(aTableOptions, /*nRows=*/2, /*nCols=*/1);
+pWrtShell->MoveTable(GotoPrevTable, fnTableStart);
+pWrtShell->GoPrevCell();
+pWrtShell->Insert("A1");
+pWrtShell->GoNextCell();
+pWrtShell->Insert("A2");
+// Select cell:
+pWrtShell->SelAll();
+// Select table:
+pWrtShell->SelAll();
+// Wrap the table in a text frame:
+SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr);
+pWrtShell->StartAllAction();
+aMgr.InsertFlyFrame(RndStdIds::FLY_AT_PARA, aMgr.GetPos(), aMgr.GetSize());
+pWrtShell->EndAllAction();
+CPPUNIT_ASSERT(!rFlyFormats.empty());
+
+// When undoing the conversion to floating table:
+pDoc->GetUndoManager().Undo();
+
+// Then make sure we don't have a frame anymore:
+// Without the accompanying fix in place, this test would have failed, 
there was no undo action
+// to execute.
+CPPUNIT_ASSERT(rFlyFormats.empty());
+
+// And when redoing the conversion:
+pDoc->GetUndoManager().Redo();
+
+// Then make sure we again have a frame:
+CPPUNIT_ASSERT(!rFlyFormats.empty());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 516d15aed8ec..2ecea30dc3be 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -389,7 +389,8 @@ SwFlyFrameFormat* SwDoc::MakeFlyAndMove( const SwPaM& rPam, 
const SfxItemSet& rS
 GetNodes().MakeTextNode( aRg.aStart.GetNode(),
 GetDfltTextFormatColl() );
 
-getIDocumentContentOperations().MoveNodeRange( aRg, 
oPos->GetNode(), SwMoveFlags::DEFAULT );
+// Create undo actions if undo is enabled.
+getIDocumentContentOperations().MoveNodeRange( aRg, 
oPos->GetNode(), SwMoveFlags::CREATEUNDOOBJ );
 }
 else
 {
@@ -404,13 +405,9 @@ SwFlyFrameFormat* SwDoc::MakeFlyAndMove( const SwPaM& 
rPam, const SfxItemSet& rS
 OSL_ENSURE( aIndex.GetNode().GetTextNode(),
 "a TextNode should be here" );
 oPos.reset();   // Deregister index!
-GetNodes().Delete( aIndex );
-
-// This is a hack: whilst FlyFrames/Headers/Footers are not 
undoable we delete all Undo objects
-if( GetIDocumentUndoRedo().DoesUndo

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-10 Thread Miklos Vajna (via logerrit)
 sw/qa/uitest/ui/frmdlg/frmdlg.py   |   12 
 sw/source/ui/frmdlg/frmpage.cxx|1 -
 sw/source/uibase/shells/textsh.cxx |6 ++
 3 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 8d973c5b9405bfa6964d3dfebd0017fd60ec3eca
Author: Miklos Vajna 
AuthorDate: Fri Nov 10 10:17:16 2023 +0100
Commit: Miklos Vajna 
CommitDate: Fri Nov 10 13:49:10 2023 +0100

sw floattable, insert UI: default to at-char for non-split flys

Inserting new images defaulted to the at-char anchor type, but inserting
a new frame defaulted to at-para, which is inconsistent. This is now more
visible, since LOK exposes the insert frame dialog.

An additional problem is that the LOK case hides anything other than
at-char and as-char in the frame properties dialog since commit
4154d281fbecaadf6cd118c00cc6cff929e339a4 (sw lok: hide UI to set
Word-incompatible anchor types, 2019-07-05), which was intended for
images, but also affects text frames as well. But floating tables want
to-para anchored frames to be able to split.

Fix the problem by defaulting to at-char anchoring, unless we deal with
floating tables.

And show the to-para anchor widget in the LOK case again, given that all
of to-para, to-char and as-char have their use-cases, even when editing
Word documents.

Change-Id: I89b0973183a750d86f56e0cccd7b0fbcb3dc070d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159261
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/uitest/ui/frmdlg/frmdlg.py b/sw/qa/uitest/ui/frmdlg/frmdlg.py
index 4a438895572b..bbb9d9a270dd 100644
--- a/sw/qa/uitest/ui/frmdlg/frmdlg.py
+++ b/sw/qa/uitest/ui/frmdlg/frmdlg.py
@@ -98,4 +98,16 @@ class Test(UITestCase):
 # inserted first, only then it could be marked as "split allowed".
 self.assertEqual(fly_split_visible, True)
 
+def test_insert_simple_frame(self):
+# Given a Writer document:
+with self.ui_test.create_doc_in_start_center("writer") as xComponent:
+# When inserting a simple text frame (not a floating table):
+with 
self.ui_test.execute_dialog_through_command(".uno:InsertFrame") as xDialog:
+to_char = xDialog.getChild("tochar")
+to_char_enabled = get_state_as_dict(to_char)["Checked"] == 
"true"
+# Then make sure the anchor type is to-char, matching the default 
anchor for images:
+# This failed, text frames defaulted to to-para, images defaulted 
to to-char, which was
+# inconsistent.
+self.assertTrue(to_char_enabled)
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index 911df55f66d7..bdf1c90291ff 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -721,7 +721,6 @@ SwFramePage::SwFramePage(weld::Container* pPage, 
weld::DialogController* pContro
 if (comphelper::LibreOfficeKit::isActive())
 {
 m_xAnchorAtPageRB->hide();
-m_xAnchorAtParaRB->hide();
 m_xAnchorAtFrameRB->hide();
 }
 }
diff --git a/sw/source/uibase/shells/textsh.cxx 
b/sw/source/uibase/shells/textsh.cxx
index c9e0e8a4d6f9..d0c9aabc979f 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -918,6 +918,12 @@ SfxItemSet 
SwTextShell::CreateInsertFrameItemSet(SwFlyFrameAttrMgr& rMgr)
 aBoxInfo.SetDefDist(rBox.GetDistance(SvxBoxItemLine::LEFT));
 aSet.Put(aBoxInfo);
 
+if (!SwFlyFrameAttrMgr::SingleTableSelected(GetShell()))
+{
+SwFormatAnchor aAnchor(RndStdIds::FLY_AT_CHAR);
+aSet.Put(aAnchor);
+}
+
 return aSet;
 }
 


[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-09 Thread Miklos Vajna (via logerrit)
 sw/qa/uitest/ui/frmdlg/frmdlg.py   |   20 +++-
 sw/source/ui/frmdlg/frmpage.cxx|   16 +++-
 sw/source/uibase/frmdlg/frmmgr.cxx |   25 ++---
 sw/source/uibase/inc/frmmgr.hxx|2 ++
 4 files changed, 54 insertions(+), 9 deletions(-)

New commits:
commit e306352b9ddd8bddfc37f0cfaac078d9260650d6
Author: Miklos Vajna 
AuthorDate: Thu Nov 9 08:51:59 2023 +0100
Commit: Miklos Vajna 
CommitDate: Thu Nov 9 11:37:33 2023 +0100

sw floattable, insert UI: allow direct creation of floating tables

The frame insert UI could move a table into a new fly, and then the
frame properties allowed marking this fly as a split fly, but not in one
step.

This happened because the "split fly" checkbox is only visible when we
have a fly that has exactly 1 table, but the "new frame" dialog has no
fly as it still has to be created.

Fix the problem by showing the "split fly" checkbox if we don't have a
fly, but a single table is selected, because we know
SwDoc::MakeFlyAndMove() will create a fly that has exactly one table in
it.

Extract the common code to a new
SwFlyFrameAttrMgr::SingleTableSelected() to avoid copy&paste.

Change-Id: I24129e3fb4cb6231fb10b0adda53c205dfd90d62
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159201
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/uitest/ui/frmdlg/frmdlg.py b/sw/qa/uitest/ui/frmdlg/frmdlg.py
index e30b67ff5313..4a438895572b 100644
--- a/sw/qa/uitest/ui/frmdlg/frmdlg.py
+++ b/sw/qa/uitest/ui/frmdlg/frmdlg.py
@@ -17,7 +17,7 @@ from uitest.uihelper.common import get_url_for_data_file
 
 
 class Test(UITestCase):
-def test_content_control_dialog(self):
+def test_uno_frame_dialog(self):
 with self.ui_test.create_doc_in_start_center("writer") as xComponent:
 # Given a document with a floating table:
 args = {
@@ -80,4 +80,22 @@ class Test(UITestCase):
 # i.e. the width was empty instead of the size from the UI.
 self.assertEqual(xComponent.TextFrames.Frame1.Size.Width, 
expected_mm100)
 
+def test_insert_floating_table(self):
+with self.ui_test.create_doc_in_start_center("writer") as xComponent:
+# Given a Writer document with a selected (inline) table:
+args = {
+"Columns": 1,
+"Rows": 1,
+}
+self.xUITest.executeCommandWithParameters(".uno:InsertTable", 
mkPropertyValues(args))
+self.xUITest.executeCommand(".uno:SelectAll")
+# When converting it to a split fly:
+with 
self.ui_test.execute_dialog_through_command(".uno:InsertFrame") as xDialog:
+xFlySplit = xDialog.getChild("flysplit")
+fly_split_visible = get_state_as_dict(xFlySplit)["Visible"] == 
"true"
+# Then make sure the inserted fly can be marked as "split allowed":
+# Without the accompanying fix in place, this test would have 
failed, the fly had to be
+# inserted first, only then it could be marked as "split allowed".
+self.assertEqual(fly_split_visible, True)
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index b38ac22d0d11..911df55f66d7 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -1050,9 +1050,23 @@ void SwFramePage::Reset( const SfxItemSet *rSet )
 const SwFrameFormat* pFlyFormat = pSh->GetFlyFrameFormat();
 if (!pFlyFormat || !ContainsSingleTable(*pFlyFormat) || 
ContainsChain(*pFlyFormat))
 {
+bool bSingleTable = false;
+if (!pFlyFormat && m_bNew)
+{
+// No fly is selected: check if a whole table is selected. If so, 
allow moving that into
+// a split fly.
+if (SwFlyFrameAttrMgr::SingleTableSelected(*pSh))
+{
+bSingleTable = true;
+}
+}
+
 // Only allow fly split if the frame contains a single table, 
otherwise it would be hard to
 // save the resulting model to Word formats.
-m_xFlySplitCB->hide();
+if (!bSingleTable)
+{
+m_xFlySplitCB->hide();
+}
 }
 
 Init(*rSet);
diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx 
b/sw/source/uibase/frmdlg/frmmgr.cxx
index a71b7ef3fb0a..eb38c1c803f7 100644
--- a/sw/source/uibase/frmdlg/frmmgr.cxx
+++ b/sw/source/uibase/frmdlg/frmmgr.cxx
@@ -625,36 +625,47 @@ void SwFlyFrameAttrMgr::SetAttrSet(const SfxItemSet& rSet)
 m_aSet.Put( rSet );
 }
 
-void SwFlyFrameAttrMgr::SetFrameSizeFromTable()
+const SwTableFormat* SwFlyFrameAttrMgr::SingleTableSelected(SwWrtShell& 
rWrtShell)
 {
-if (!m_pOwnSh->IsTableMode())
+if (!rWrtShell.IsTableMode())
 {
-return;
+return nullptr;
 }
 
 // We have a table selection

[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-08 Thread Miklos Vajna (via logerrit)
 sw/qa/uibase/frmdlg/frmdlg.cxx |   45 +
 sw/source/uibase/frmdlg/frmmgr.cxx |   35 
 sw/source/uibase/inc/frmmgr.hxx|1 
 3 files changed, 81 insertions(+)

New commits:
commit 0ecb69d53864b582eb59533729ada01d85d383e6
Author: Miklos Vajna 
AuthorDate: Wed Nov 8 08:25:23 2023 +0100
Commit: Miklos Vajna 
CommitDate: Wed Nov 8 10:17:09 2023 +0100

sw floattable, insert UI: inherit fly width from selected table width

Inline table width defaults to the body frame width, so a hardcoded 2cm
default for the fly width is a bit poor.

Leave the normal fly insert case unchanged, but if an entire table is
selected, then change the default to the table width.

Check for the table selection like SwFEShell::NewFlyFrame() does it, and
determine if the entire table is selected like SwDoc::MakeFlyAndMove()
does it.

With this, a default table with a default frame keeps its width on frame
insert.

Change-Id: Iaf954395a4799222074acd83b5eae52ca75ae0ae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159104
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/uibase/frmdlg/frmdlg.cxx b/sw/qa/uibase/frmdlg/frmdlg.cxx
index f6b7653de824..81a7746170c1 100644
--- a/sw/qa/uibase/frmdlg/frmdlg.cxx
+++ b/sw/qa/uibase/frmdlg/frmdlg.cxx
@@ -13,6 +13,11 @@
 
 #include 
 
+#include 
+#include 
+#include 
+#include 
+
 /// Covers sw/source/uibase/frmdlg/ fixes.
 class SwUibaseFrmdlgTest : public SwModelTestBase
 {
@@ -60,6 +65,46 @@ CPPUNIT_TEST_FIXTURE(SwUibaseFrmdlgTest, 
testAnchorTypeFromStyle)
 CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, eActual);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseFrmdlgTest, testInsertFrameWidth)
+{
+// Given a document with an inline table, its width is set to 6000 twips:
+createSwDoc();
+// Insert a table:
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0);
+pWrtShell->InsertTable(aTableOptions, /*nRows=*/1, /*nCols=*/1);
+pWrtShell->MoveTable(GotoPrevTable, fnTableStart);
+SwTwips nExpectedWidth = 6000;
+{
+SfxItemSetFixed 
aSet(pWrtShell->GetAttrPool());
+SwFormatFrameSize aSize(SwFrameSize::Variable, nExpectedWidth);
+aSet.Put(aSize);
+pWrtShell->SetTableAttr(aSet);
+}
+pWrtShell->GoPrevCell();
+pWrtShell->Insert("A1");
+SwFormatFrameSize aRowSize(SwFrameSize::Minimum);
+pWrtShell->SetRowHeight(aRowSize);
+pWrtShell->GoNextCell();
+pWrtShell->Insert("A2");
+pWrtShell->SetRowHeight(aRowSize);
+// Select cell:
+pWrtShell->SelAll();
+// Select table:
+pWrtShell->SelAll();
+
+// When converting that table to a floating table:
+SwFlyFrameAttrMgr aMgr(/*bNew=*/true, pWrtShell, Frmmgr_Type::TEXT, 
nullptr);
+
+// Then make sure that the fly width will be based on the table width:
+const SwFormatFrameSize* pFrameSize = 
aMgr.GetAttrSet().GetItem(RES_FRM_SIZE);
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 6000 (nExpectedWidth)
+// - Actual  : 1134 (2cm)
+// i.e. the fly width was the default, not inherited from the selected 
table.
+CPPUNIT_ASSERT_EQUAL(nExpectedWidth, pFrameSize->GetWidth());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx 
b/sw/source/uibase/frmdlg/frmmgr.cxx
index 729892398997..a71b7ef3fb0a 100644
--- a/sw/source/uibase/frmdlg/frmmgr.cxx
+++ b/sw/source/uibase/frmdlg/frmmgr.cxx
@@ -84,6 +84,9 @@ SwFlyFrameAttrMgr::SwFlyFrameAttrMgr( bool bNew, SwWrtShell* 
pSh, Frmmgr_Type nT
 }
 m_aSet.SetParent( &m_pOwnSh->GetFormatFromPool( nId )->GetAttrSet());
 m_aSet.Put( SwFormatFrameSize( SwFrameSize::Minimum, DFLT_WIDTH, 
DFLT_HEIGHT ));
+
+SetFrameSizeFromTable();
+
 if ( 0 != ::GetHtmlMode(pSh->GetView().GetDocShell()) )
 m_aSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT, 
text::RelOrientation::PRINT_AREA ) );
 
@@ -622,4 +625,36 @@ void SwFlyFrameAttrMgr::SetAttrSet(const SfxItemSet& rSet)
 m_aSet.Put( rSet );
 }
 
+void SwFlyFrameAttrMgr::SetFrameSizeFromTable()
+{
+if (!m_pOwnSh->IsTableMode())
+{
+return;
+}
+
+// We have a table selection.
+SwSelBoxes aBoxes;
+GetTableSel(*m_pOwnSh, aBoxes);
+if (aBoxes.empty())
+{
+return;
+}
+
+auto pTableNd = 
const_cast(aBoxes[0]->GetSttNd()->FindTableNode());
+if (!pTableNd)
+{
+return;
+}
+
+SwTable& rTable = pTableNd->GetTable();
+if (aBoxes.size() != rTable.GetTabSortBoxes().size())
+{
+return;
+}
+
+// The whole table is selected: default fly width should be the table width
+// in this case.
+m_aSet.Put(rTable.GetFrameForm

[Libreoffice-commits] core.git: sw/qa sw/source sw/UITest_sw_ui_frmdlg.mk

2023-11-07 Thread Miklos Vajna (via logerrit)
 sw/UITest_sw_ui_frmdlg.mk|2 ++
 sw/qa/uitest/ui/frmdlg/frmdlg.py |   18 ++
 sw/source/ui/frmdlg/frmpage.cxx  |8 +++-
 3 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit 4f1121255ebac035a439d242b47c2f81124418c3
Author: Miklos Vajna 
AuthorDate: Tue Nov 7 08:31:29 2023 +0100
Commit: Miklos Vajna 
CommitDate: Tue Nov 7 09:52:50 2023 +0100

sw floattable, insert UI: fix default frame width when inserting a new one

Insert -> Frame -> Frame presented a dialog which stated the width of
the new frame will be 2cm, but the width was ~zero.

This is a regression from commit
9da7b1592e010928c26c43ee93b91cdd66403985 (sw: remove all uses of MM50
with (added) o3tl::toTwip, 2021-07-23). Previously the code worked
because the 2cm was speficified as MM50*4 (283*4=1132 twips), and we
compared this to the 2cm from the UI, which had no rounding errors
(283.46456692913387*4=1134 twips), and this 1132 vs 1134 meant the
dialog put the unchanged size to the output item set.  Now we don't have
rounding errors anymore, so we have 1134 everywhere, which means the
dialog doesn't specify a default size, but no other code would do it,
resulting in a frame with minimal width, which is clearly not wanted.

Fix the problem by checking if this will be a new frame, and if so, the
dialog should send the default size to the caller, even if the user
didn't customize the size.  This restores the lost 2cm default width
while keeping the rounding improvements.

This requires running the test in its own process, because the
measurement unit is only loaded once from the config and the rounding
error is not hit with the default inches.

Change-Id: I9a5945fdd0e5cd64ff8bd84f95f11be5277b8d18
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159050
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/UITest_sw_ui_frmdlg.mk b/sw/UITest_sw_ui_frmdlg.mk
index 0fae8bf25f1d..219a72ddfae3 100644
--- a/sw/UITest_sw_ui_frmdlg.mk
+++ b/sw/UITest_sw_ui_frmdlg.mk
@@ -15,4 +15,6 @@ $(eval $(call gb_UITest_set_defs,sw_ui_frmdlg, \
 TDOC="$(SRCDIR)/sw/qa/uitest/data" \
 ))
 
+$(eval $(call gb_UITest_avoid_oneprocess,sw_ui_frmdlg))
+
 # vim: set noet sw=4 ts=4:
diff --git a/sw/qa/uitest/ui/frmdlg/frmdlg.py b/sw/qa/uitest/ui/frmdlg/frmdlg.py
index e3aeb67c569c..e30b67ff5313 100644
--- a/sw/qa/uitest/ui/frmdlg/frmdlg.py
+++ b/sw/qa/uitest/ui/frmdlg/frmdlg.py
@@ -62,4 +62,22 @@ class Test(UITestCase):
 # and floating tables.
 self.assertEqual(get_state_as_dict(xFlysplit)['Visible'], 
"false")
 
+def test_insert_frame_dialog(self):
+# Change from inch to cm to hit the rounding error. 2 means 
Centimeter, see
+# officecfg/registry/schema/org/openoffice/Office/Writer.xcs.
+with 
self.ui_test.set_config('/org.openoffice.Office.Writer/Layout/Other/MeasureUnit',
 2):
+# Given a Writer document:
+with self.ui_test.create_doc_in_start_center("writer") as 
xComponent:
+# When inserting a new frame with the default width:
+with 
self.ui_test.execute_dialog_through_command(".uno:InsertFrame") as xDialog:
+xWidth = xDialog.getChild("width")
+frame_width = float(get_state_as_dict(xWidth)["Value"])
+# Then make sure the width is not zero:
+# cm -> mm100
+expected_mm100 = frame_width * 1000
+# Without the accompanying fix in place, this test would have 
failed with:
+# AssertionError: 0 != 2000.0
+# i.e. the width was empty instead of the size from the UI.
+self.assertEqual(xComponent.TextFrames.Frame1.Size.Width, 
expected_mm100)
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index 352dc15df463..b38ac22d0d11 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -1264,7 +1264,13 @@ bool SwFramePage::FillItemSet(SfxItemSet *rSet)
 
 pOldItem = GetOldItem(*rSet, RES_FRM_SIZE);
 
-if ((pOldItem && aSz != *pOldItem) || (!pOldItem && !m_bFormat) ||
+bool bSizeChanged = pOldItem && aSz != *pOldItem;
+if (!bSizeChanged && m_bNew)
+{
+// If no custom size is provided, always set a size for a new frame, 
to avoid ~zero width.
+bSizeChanged = true;
+}
+if (bSizeChanged || (!pOldItem && !m_bFormat) ||
 (m_bFormat &&
 (aSz.GetWidth() > 0 || aSz.GetWidthPercent() > 0) &&
 (aSz.GetHeight() > 0 || aSz.GetHeightPercent() > 0)))


[Libreoffice-commits] core.git: sw/qa sw/source

2023-11-02 Thread László Németh (via logerrit)
 sw/qa/extras/uiwriter/uiwriter6.cxx |   55 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   36 +++---
 2 files changed, 80 insertions(+), 11 deletions(-)

New commits:
commit 3e266d5902439f34bc5559d6871f8c9fd6e579bb
Author: László Németh 
AuthorDate: Thu Nov 2 13:15:52 2023 +0100
Commit: László Németh 
CommitDate: Fri Nov 3 00:53:49 2023 +0100

tdf#158039 sw track changes: fix cycle case of selected sentences

Previous tracked changes of cycle case weren't removed, if
the selection doesn't end in a tracked change, i.e. sentences
with punctuation, or selections end in a capitalized word etc.

Fix also lost selection of multiple selected nodes.

Follow up to commit 4cf8de89bad9143a5b2dd3d6351080bf62b76029
"tdf#157667 sw track changes: fix cycle case on multiple words",
commit dc748d7dbd114fbf663752258dbaf003af2926c3
"tdf#141198 sw: fix cycle case with change tracking" and
commit 79435eb55ef226fb0e3507aabdc2f8af062680f6
"tdf#157988 sw track changes: fix cycle case on a selected word".

Change-Id: I24476c359200a25ca9bcd467c33b0ebeb1afb037
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158804
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index 8e6b91043b0b..30c449a597ac 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -796,7 +796,62 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157667)
 "Integer sodalesINTEGER SODALES tincidunt tristique."));
 
 dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt tristique."));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith(
+"Integer sodalesSodales tinciduntTincidunt tristique."));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt tristique."));
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf158039)
+{
+createSwDoc("tdf130088.docx");
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+// select the first sentence
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 26, 
/*bBasicCall=*/false);
+
+// enable redlining
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+   pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+// show changes
+CPPUNIT_ASSERT_MESSAGE(
+"redlines should be visible",
+
IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+// cycle case with change tracking
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith(
+"Integer sodalesSodales tinciduntTincidunt tristique."));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+// This was false (missing revert of the tracked change)
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt tristique."));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith(
+"Integer sodalesINTEGER SODALES tincidunt tristique."));
+
 dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith(
+"Integer sodalesSodales tinciduntTincidunt tristique."));
+
 dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
 
 CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt tristique."));
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index d51565c5eaee..d36ee7a8b31a 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3055,17 +3055,27 @@ void 
DocumentContentOperationsManager::TransliterateText(
 if ( IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) 
&&
 pEnd->GetContentIndex() > 0 )
 {
-SwPosition aPos(*pEnd->GetContentNode(), pEnd->GetContentIndex() - 
1);
-SwRedlineTable::size_type n = 0;
+// search all own redlines within the selected area
+SwRedlineTable::size_type n = SwRedlineTable::npos;
+const SwRedlineTable& aRedlineTable = rIDRA.GetRedlineTable();
+for( SwRedlineTable::size_type m = 0; m < aRedlineTable.size(); 
++

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-31 Thread László Németh (via logerrit)
 sw/qa/extras/uiwriter/uiwriter6.cxx |   43 ++
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   68 
 2 files changed, 96 insertions(+), 15 deletions(-)

New commits:
commit 4cf8de89bad9143a5b2dd3d6351080bf62b76029
Author: László Németh 
AuthorDate: Tue Oct 31 15:51:09 2023 +0100
Commit: László Németh 
CommitDate: Tue Oct 31 23:07:01 2023 +0100

tdf#157667 sw track changes: fix cycle case on multiple words

Fix tracked cycle case on multiple selected words.

Follow up to commit dc748d7dbd114fbf663752258dbaf003af2926c3
"tdf#141198 sw: fix cycle case with change tracking" and
commit 79435eb55ef226fb0e3507aabdc2f8af062680f6
"tdf#157988 sw track changes: fix cycle case on a selected word".

Change-Id: I81566f8be0cf6f4af6ed4af031116bd19e3884d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158732
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index 83bc43f6d866..8e6b91043b0b 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -759,6 +759,49 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157988)
 CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt"));
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157667)
+{
+createSwDoc("tdf130088.docx");
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+// select the first three words
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 25, 
/*bBasicCall=*/false);
+
+// enable redlining
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+   pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+// show changes
+CPPUNIT_ASSERT_MESSAGE(
+"redlines should be visible",
+
IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+// cycle case with change tracking
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith(
+"Integer sodalesSodales tinciduntTincidunt tristique."));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+// This was false (missing revert of the tracked change)
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt tristique."));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith(
+"Integer sodalesINTEGER SODALES tincidunt tristique."));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt tristique."));
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf108048)
 {
 createSwDoc();
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 54b29b9b766c..d51565c5eaee 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -2984,7 +2984,8 @@ void DocumentContentOperationsManager::TransliterateText(
 sal_Int32 nEndCnt = pEnd->GetContentIndex();
 
 SwTextNode* pTNd = pStt->GetNode().GetTextNode();
-if( (pStt == pEnd) && pTNd )  // no selection?
+bool bNoSelection = (pStt == pEnd) && pTNd;  // no selection?
+if ( bNoSelection )
 {
 /* Check if cursor is inside of a word */
 assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
@@ -3061,27 +3062,52 @@ void 
DocumentContentOperationsManager::TransliterateText(
 rIDRA.GetRedlineTable().FindAtPosition( aPos, 
n );
 if ( pFnd && RedlineType::Insert == pFnd->GetType() && n > 0 )
 {
-const SwRangeRedline* pFnd2 = rIDRA.GetRedlineTable()[n-1];
-if ( RedlineType::Delete == pFnd2->GetType() &&
-  m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell() 
&&
-  *pFnd2->End() == *pFnd->Start() &&
-  pFnd->GetAuthor() == pFnd2->GetAuthor() )
+SwWrtShell *pWrtShell = dynamic_cast(
+
m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell());
+
+sal_Int32 nRejectedCharacters = 0;
+SwRangeRedline* pFnd2 = rIDRA.GetRedlineTable()[--n];
+// loop on all redlines of a case changing, and reject them
+while ( ( ( RedlineType::Insert == pFnd->GetType() &&
+RedlineType::Delete == pFnd2->GetType() ) 

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-30 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/htmlexport/data/embedded_formula.fodt |   30 +++
 sw/qa/extras/htmlexport/htmlexport.cxx |   63 ---
 sw/source/filter/html/htmlplug.cxx |  184 +
 sw/source/filter/html/wrthtml.cxx  |6 
 sw/source/filter/html/wrthtml.hxx  |3 
 5 files changed, 201 insertions(+), 85 deletions(-)

New commits:
commit 2ecd5da533f8fc4229bb8a38167eb147c1213fa8
Author: Mike Kaganski 
AuthorDate: Mon Oct 30 17:14:47 2023 +0300
Commit: Mike Kaganski 
CommitDate: Tue Oct 31 05:54:03 2023 +0100

ReqIF: introduce ExportFormulasAsPDF HTML export filter option

Change-Id: Id400bd5571d0a192d854620abe83d862e0512434
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158663
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/qa/extras/htmlexport/data/embedded_formula.fodt 
b/sw/qa/extras/htmlexport/data/embedded_formula.fodt
new file mode 100644
index ..46e5391223c0
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/embedded_formula.fodt
@@ -0,0 +1,30 @@
+
+
+
+ 
+  
+   Formula:
+   
+  http://www.w3.org/1998/Math/MathML"; display="block">
+   
+
+ 
+  e
+  
+   i
+   π
+  
+ 
+ +
+ 1
+ =
+ 0
+
+{ func e ^ { i %pi } + 1 } = 
0
+   
+  
+ 
+
+  
+ 
+
\ No newline at end of file
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx 
b/sw/qa/extras/htmlexport/htmlexport.cxx
index a106dd53bf14..b4d3bfaaf10a 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -13,6 +13,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -215,9 +216,10 @@ public:
 {
 }
 
+OUString GetObjectPath(const OUString& ext);
 /// Get the .ole path, assuming maTempFile is an XHTML export result.
-OUString GetOlePath();
-OUString GetPngPath();
+OUString GetOlePath() { return GetObjectPath(u".ole"_ustr); }
+OUString GetPngPath() { return GetObjectPath(u".png"_ustr); }
 /// Parse the ole1 data out of an RTF fragment URL.
 void ParseOle1FromRtfUrl(const OUString& rRtfUrl, SvMemoryStream& rOle1);
 /// Export using the C++ HTML export filter, with xhtmlns=reqif-xhtml.
@@ -228,29 +230,16 @@ public:
 void ExportToHTML();
 };
 
-OUString SwHtmlDomExportTest::GetOlePath()
+OUString SwHtmlDomExportTest::GetObjectPath(const OUString& ext)
 {
+assert(ext.startsWith("."));
 xmlDocUniquePtr pDoc = WrapReqifFromTempFile();
 OUString aOlePath = getXPath(
 pDoc, 
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p/reqif-xhtml:object", "data");
-OUString aOleSuffix(".ole");
-CPPUNIT_ASSERT(aOlePath.endsWith(aOleSuffix));
+CPPUNIT_ASSERT(aOlePath.endsWith(ext));
 INetURLObject aUrl(maTempFile.GetURL());
-aUrl.setBase(aOlePath.subView(0, aOlePath.getLength() - 
aOleSuffix.getLength()));
-aUrl.setExtension(u"ole");
-return aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE);
-}
-
-OUString SwHtmlDomExportTest::GetPngPath()
-{
-xmlDocUniquePtr pDoc = WrapReqifFromTempFile();
-OUString aPngPath = getXPath(
-pDoc, 
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p/reqif-xhtml:object", "data");
-OUString aPngSuffix(".png");
-CPPUNIT_ASSERT(aPngPath.endsWith(aPngSuffix));
-INetURLObject aUrl(maTempFile.GetURL());
-aUrl.setBase(aPngPath.subView(0, aPngPath.getLength() - 
aPngSuffix.getLength()));
-aUrl.setExtension(u"png");
+aUrl.setBase(aOlePath.subView(0, aOlePath.getLength() - ext.getLength()));
+aUrl.setExtension(ext.subView(1));
 return aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE);
 }
 
@@ -2823,6 +2812,40 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, 
testReqIF_PreserveSpaces)
 CPPUNIT_ASSERT_EQUAL(paraText, getParagraph(1)->getString());
 }
 
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_ExportFormulasAsPDF)
+{
+// Given a document with a formula:
+createSwDoc("embedded_formula.fodt");
+
+// When exporting to reqif with ExportFormulasAsPDF=true:
+uno::Reference xStorable(mxComponent, 
uno::UNO_QUERY_THROW);
+uno::Sequence aStoreProperties = {
+comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML 
(StarWriter)"_ustr),
+comphelper::makePropertyValue(u"FilterOptions"_ustr, 
u"xhtmlns=reqif-xhtml"_ustr),
+comphelper::makePropertyValue(u"ExportFormulasAsPDF"_ustr, true),
+};
+xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties);
+
+// Make sure that the formula is exported as PDF:
+xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile();
+assertXPath(pXmlDoc,
+
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p[2]/reqif-xhtml:object"_ostr,
+"type"_ostr, u"application/pdf"_ustr);
+
+css::uno::Sequence descr{
+comphelper::makePropertyValue(u"URL"_ustr, 
GetObjectPath(u".

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-30 Thread László Németh (via logerrit)
 sw/qa/extras/uiwriter/uiwriter6.cxx |   69 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   38 
 2 files changed, 107 insertions(+)

New commits:
commit 79435eb55ef226fb0e3507aabdc2f8af062680f6
Author: László Németh 
AuthorDate: Mon Oct 30 14:42:34 2023 +0100
Commit: László Németh 
CommitDate: Mon Oct 30 21:54:07 2023 +0100

tdf#157988 sw track changes: fix cycle case on a selected word

Cycle case didn't work on a selected word, only on the
word under the cursor without selection.

Add unit test also for tdf#141198.

Follow up to commit dc748d7dbd114fbf663752258dbaf003af2926c3
"tdf#141198 sw: fix cycle case with change tracking".

Change-Id: I0c1361c78d09e9b8743192a47dcdfa6f6da52e38
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158666
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index 53f6dce1a56a..83bc43f6d866 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -690,6 +690,75 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157937)
 dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157988)
+{
+createSwDoc("tdf130088.docx");
+SwDoc* pDoc = getSwDoc();
+
+// select the second word
+dispatchCommand(mxComponent, ".uno:GoToNextWord", {});
+dispatchCommand(mxComponent, ".uno:SelectWord", {});
+
+// enable redlining
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+   pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+// show changes
+CPPUNIT_ASSERT_MESSAGE(
+"redlines should be visible",
+
IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+// cycle case with change tracking
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer 
sodalesSodales"));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+// This was false (missing revert of the tracked change)
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt"));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer 
sodalesSODALES"));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt"));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer 
sodalesSodales"));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt"));
+
+// tdf#141198 cycle case without selection: the word under the cursor
+
+dispatchCommand(mxComponent, ".uno:Escape", {});
+
+dispatchCommand(mxComponent, ".uno:GoRight", {});
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer 
sodalesSODALES"));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt"));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer 
sodalesSodales"));
+
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt"));
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf108048)
 {
 createSwDoc();
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 3f4c99a8f487..54b29b9b766c 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3047,6 +3047,44 @@ void DocumentContentOperationsManager::TransliterateText(
 return;
 }
 }
+else
+{
+bool bHasTrackedChange = false;
+IDocumentRedlineAccess& rIDRA = m_rDoc.getIDocumentRedlineAccess();
+if ( IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) 
&&
+pEnd->GetContentIndex() > 0 )
+{
+SwPosition aPos(*pEnd->GetContentNode(), pEnd->GetContentIndex() - 
1);
+SwRedlineTable::size_type n = 0;
+
+const SwRangeRedline* pFnd =
+rIDRA.GetRedlineTable().FindAtPosition( aPos, 
n );
+if ( pFnd && RedlineType::Insert == pFnd->GetType() && n > 

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-27 Thread László Németh (via logerrit)
 sw/qa/extras/uiwriter/data/tdf130088.docx |binary
 sw/qa/extras/uiwriter/uiwriter6.cxx   |   27 +++
 sw/source/core/txtnode/txtedt.cxx |9 -
 3 files changed, 35 insertions(+), 1 deletion(-)

New commits:
commit e079bb35429603988d2fd4ddf18b0f501a847a2c
Author: László Németh 
AuthorDate: Fri Oct 27 09:43:44 2023 +0200
Commit: László Németh 
CommitDate: Fri Oct 27 15:10:33 2023 +0200

tdf#157937 sw: fix freezing of cycle case on tracked changes

Add loop control to avoid never-ending iteration on selected
text with tracked changes, where transliteration can result
empty strings.

Regression since commit 2d3c77e9b10f20091ef338e262ba7756eb280ce9
"tdf#109266 sw change tracking: track transliteration".

Change-Id: Ia5f92adfdda33562b4d1abe72c51134be8304639
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158525
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/uiwriter/data/tdf130088.docx 
b/sw/qa/extras/uiwriter/data/tdf130088.docx
new file mode 100644
index ..8d5a7a604b5e
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf130088.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index dd0b1d6f468c..53f6dce1a56a 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -663,6 +663,33 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf113790)
 CPPUNIT_ASSERT(dynamic_cast(mxComponent.get()));
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157937)
+{
+createSwDoc("tdf130088.docx");
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+// select paragraph
+pWrtShell->SelPara(nullptr);
+
+// enable redlining
+dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+   pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+// show changes
+CPPUNIT_ASSERT_MESSAGE(
+"redlines should be visible",
+
IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+// cycle case with change tracking
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+// This resulted freezing
+dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf108048)
 {
 createSwDoc();
diff --git a/sw/source/core/txtnode/txtedt.cxx 
b/sw/source/core/txtnode/txtedt.cxx
index 71ee1fd93a24..2f3e7aa6db86 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -1973,6 +1973,7 @@ void SwTextNode::TransliterateText(
 
 sal_Int32 nEndPos = 0;
 LanguageType nLang = LANGUAGE_NONE;
+sal_Int32 nLoopControlRuns = 0;
 do {
 if( pIter )
 {
@@ -2005,7 +2006,13 @@ void SwTextNode::TransliterateText(
 }
 
 nStt = nEndPos;
-} while( nEndPos < nEnd && pIter && pIter->Next() );
+
+// tdf#157937 selection containing tracked changes needs loop 
control:
+// stop looping, if there are too much empty transliterations
+if ( sChgd.isEmpty() )
+++nLoopControlRuns;
+
+} while( nEndPos < nEnd && pIter && pIter->Next() && nLoopControlRuns 
< 100 );
 }
 
 if (aChanges.empty())


[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-25 Thread Xisco Fauli (via logerrit)
 sw/qa/extras/uiwriter/data/tdf157132.odt |binary
 sw/qa/extras/uiwriter/uiwriter8.cxx  |   42 +++
 sw/source/core/table/swtable.cxx |2 +
 3 files changed, 44 insertions(+)

New commits:
commit 0c008ab081aa5bbf53f8562e95e547deae5afc2e
Author: Xisco Fauli 
AuthorDate: Wed Oct 25 18:07:18 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Oct 26 08:48:23 2023 +0200

tdf#157132: restore behaviour for TBL_RELBOXNAME

Regression from 8a3dc12a13a3b9e99dbd5000ca6a1d541cf472f7
"8a3dc12a13a3b9e99dbd5000ca6a1d541cf472f7"
TBL_RELBOXNAME was no longer calling ToRelBoxNm

Change-Id: I296d84ab955b4415bf9173ccf72b4d51e55152f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158454
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/uiwriter/data/tdf157132.odt 
b/sw/qa/extras/uiwriter/data/tdf157132.odt
new file mode 100644
index ..ddb9522bf835
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf157132.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 8e4869c5d694..7cef16f032bf 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -1480,6 +1480,48 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf146573)
 CPPUNIT_ASSERT_EQUAL(OUString("204"), xCellA4->getString());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf157132)
+{
+createSwDoc("tdf157132.odt");
+
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+// Go to cell A2
+pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1);
+
+// Select A2 and A3 and copy
+pWrtShell->Down(/*bSelect=*/true, /*nCount=*/1);
+
+dispatchCommand(mxComponent, ".uno:Copy", {});
+
+// Go to A4 and paste
+pWrtShell->Down(/*bSelect=*/false, /*nCount=*/1);
+
+dispatchCommand(mxComponent, ".uno:Paste", {});
+
+uno::Reference xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTextTablesSupplier->getTextTables(),
+uno::UNO_QUERY);
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+
+uno::Reference xTextTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+
+uno::Reference xCellA2(xTextTable->getCellByName("A2"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("2"), xCellA2->getString());
+uno::Reference xCellA3(xTextTable->getCellByName("A3"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("3"), xCellA3->getString());
+uno::Reference xCellA4(xTextTable->getCellByName("A4"), 
uno::UNO_QUERY);
+
+// Without the fix in place, this test would have failed with
+// - Expected: 6
+// - Actual  : 2
+CPPUNIT_ASSERT_EQUAL(OUString("6"), xCellA4->getString());
+uno::Reference xCellA5(xTextTable->getCellByName("A5"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("7"), xCellA5->getString());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf147938)
 {
 createSwDoc("tdf147938.fodt");
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 3d53ef518903..d50c493079a2 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1727,6 +1727,8 @@ void SwTable::UpdateFields(TableFormulaUpdateFlags eFlags)
 {
 if(eFlags == TBL_BOXPTR)
 pBoxFormula->TryBoxNmToPtr();
+else if(eFlags == TBL_RELBOXNAME)
+pBoxFormula->ToRelBoxNm(this);
 else
 pBoxFormula->ChangeState();
 }


[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-20 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   10 +-
 sw/source/core/doc/DocumentRedlineManager.cxx  |4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 113c4566933b798e3de4daf9e276ce24cdb8e773
Author: Mike Kaganski 
AuthorDate: Fri Oct 20 14:35:51 2023 +0300
Commit: Mike Kaganski 
CommitDate: Fri Oct 20 19:05:55 2023 +0200

Avoid double notifications for deletion case

Follow-up to commit 34ac12dca3f5af50fddfb7c77e2943897980b815
When old redline is own Insert, and the new one is Delete, it means
that it was already handled in DocumentRedlineManager::DeleteRedline.

This also reverts the unit test change done in the mentioned commit.

Change-Id: I77e59dceb1c880fc6ec10ad98867be3bf5282f70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158253
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index a280c0473843..4ed5f3af6cdb 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -1652,9 +1652,9 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testRedlineUpdateCallback)
 m_nRedlineTableEntryModified = 0;
 pWrtShell->DelLeft();
 
-// Assert that we get exactly two notification about the redline update.
+// Assert that we get exactly one notification about the redline update.
 // This was 0, as LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED wasn't sent.
-CPPUNIT_ASSERT_EQUAL(2, m_nRedlineTableEntryModified);
+CPPUNIT_ASSERT_EQUAL(1, m_nRedlineTableEntryModified);
 
 // Turn off the change tracking mode, make some modification to left of the
 // redline so that its position changes
@@ -1663,18 +1663,18 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testRedlineUpdateCallback)
 pWrtShell->Insert("This text is left of the redline");
 
 // Position of the redline has changed => Modify callback
-CPPUNIT_ASSERT_EQUAL(3, m_nRedlineTableEntryModified);
+CPPUNIT_ASSERT_EQUAL(2, m_nRedlineTableEntryModified);
 
 pWrtShell->DelLeft();
 // Deletion also emits Modify callback
-CPPUNIT_ASSERT_EQUAL(4, m_nRedlineTableEntryModified);
+CPPUNIT_ASSERT_EQUAL(3, m_nRedlineTableEntryModified);
 
 // Make changes to the right of the redline => no position change in 
redline
 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 100/*Go 
enough right */, /*bBasicCall=*/false);
 pWrtShell->Insert("This text is right of the redline");
 
 // No Modify callbacks
-CPPUNIT_ASSERT_EQUAL(4, m_nRedlineTableEntryModified);
+CPPUNIT_ASSERT_EQUAL(3, m_nRedlineTableEntryModified);
 }
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testGetViewRenderState)
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index 7a9af1ee8891..5ac574b54858 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -1842,8 +1842,8 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* 
pNewRedl, bool const bCall
 delete pNewRedl;
 pNewRedl = nullptr;
 
-if (!bDec)
-MaybeNotifyRedlineModification(*pRedl, m_rDoc);
+// No need to call MaybeNotifyRedlineModification, 
because a notification
+// was already sent in 
DocumentRedlineManager::DeleteRedline
 break;
 
 case SwComparePosition::Outside:


[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-20 Thread Stephan Bergmann (via logerrit)
 sw/qa/core/test_ToxLinkProcessor.cxx|   24 +--
 sw/qa/core/uwriter.cxx  |   20 -
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx   |4 -
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx|2 
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx   |2 
 sw/qa/extras/tiledrendering/tiledrendering.cxx  |8 +--
 sw/qa/extras/uiwriter/uiwriter.cxx  |   16 +++
 sw/qa/extras/uiwriter/uiwriter6.cxx |4 -
 sw/qa/extras/unowriter/unowriter.cxx|   12 ++---
 sw/source/core/access/accdoc.cxx|2 
 sw/source/core/access/accpara.cxx   |4 -
 sw/source/core/crsr/crossrefbookmark.cxx|2 
 sw/source/core/crsr/findtxt.cxx |2 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |2 
 sw/source/core/doc/docbm.cxx|2 
 sw/source/core/doc/docfld.cxx   |4 -
 sw/source/core/doc/doclay.cxx   |2 
 sw/source/core/doc/tblafmt.cxx  |2 
 sw/source/core/edit/edfcol.cxx  |   34 
 sw/source/core/swg/SwXMLTextBlocks1.cxx |2 
 sw/source/core/text/EnhancedPDFExportHelper.cxx |   10 ++--
 sw/source/core/txtnode/attrcontentcontrol.cxx   |2 
 sw/source/core/unocore/unodraw.cxx  |8 +--
 sw/source/core/unocore/unofield.cxx |2 
 sw/source/core/unocore/unoidx.cxx   |2 
 sw/source/core/unocore/unosett.cxx  |2 
 sw/source/core/unocore/unotext.cxx  |2 
 sw/source/core/view/printdata.cxx   |4 -
 sw/source/filter/ascii/wrtasc.cxx   |2 
 sw/source/filter/docx/swdocxreader.cxx  |2 
 sw/source/filter/html/swhtml.cxx|4 -
 sw/source/filter/html/wrthtml.cxx   |2 
 sw/source/filter/ww8/docxexport.cxx |2 
 sw/source/filter/ww8/rtfexport.cxx  |2 
 sw/source/filter/ww8/ww8par5.cxx|2 
 sw/source/filter/ww8/ww8toolbar.cxx |2 
 sw/source/filter/xml/XMLRedlineImportHelper.cxx |6 +-
 sw/source/filter/xml/swxml.cxx  |   12 ++---
 sw/source/filter/xml/xmlexp.cxx |4 -
 sw/source/filter/xml/xmlimp.cxx |   10 ++--
 sw/source/filter/xml/xmltexte.cxx   |2 
 sw/source/ui/vba/vbalisthelper.cxx  |   22 +-
 sw/source/ui/vba/vbaparagraphformat.cxx |2 
 sw/source/uibase/app/applab.cxx |2 
 sw/source/uibase/app/docstyle.cxx   |2 
 sw/source/uibase/config/uinums.cxx  |2 
 sw/source/uibase/dbui/mmconfigitem.cxx  |2 
 sw/source/uibase/shells/grfsh.cxx   |2 
 sw/source/uibase/shells/langhelper.cxx  |6 +-
 sw/source/uibase/shells/textsh1.cxx |   10 ++--
 sw/source/uibase/sidebar/PageMarginControl.cxx  |   10 ++--
 sw/source/uibase/uno/SwXFilterOptions.cxx   |2 
 sw/source/uibase/uno/unomailmerge.cxx   |2 
 sw/source/uibase/uno/unotxdoc.cxx   |2 
 54 files changed, 150 insertions(+), 150 deletions(-)

New commits:
commit a841ac096f2794405408ef64189de2c77971c3e6
Author: Stephan Bergmann 
AuthorDate: Thu Oct 19 10:30:32 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Oct 20 15:28:25 2023 +0200

Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: sw

Change-Id: I85fff7ed6932c5fc196e18f24fa01074ba4837e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158241
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sw/qa/core/test_ToxLinkProcessor.cxx 
b/sw/qa/core/test_ToxLinkProcessor.cxx
index e493320eae90..a47762912c6c 100644
--- a/sw/qa/core/test_ToxLinkProcessor.cxx
+++ b/sw/qa/core/test_ToxLinkProcessor.cxx
@@ -40,12 +40,12 @@ public:
 SwGlobals::ensure();
 }
 
-static constexpr OUStringLiteral STYLE_NAME_1 = u"anyStyle1";
-static constexpr OUStringLiteral STYLE_NAME_2 = u"anyStyle2";
+static constexpr OUString STYLE_NAME_1 = u"anyStyle1"_ustr;
+static constexpr OUString STYLE_NAME_2 = u"anyStyle2"_ustr;
 static const sal_uInt16 POOL_ID_1;
 static const sal_uInt16 POOL_ID_2;
-static constexpr OUStringLiteral URL_1 = u"#anyUrl1";
-static constexpr OUStringLiteral URL_2 = u"#anyUrl2";
+static constexpr OUString URL_1 = u"#anyUrl1"_ustr;
+static constexpr OUString URL_2 = u"#anyUrl2"_ustr;
 };
 
 const sal_

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-20 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/floattable-nested-rowspan.docx |binary
 sw/qa/core/layout/tabfrm.cxx  |   11 +
 sw/source/core/layout/tabfrm.cxx  |   37 ++
 3 files changed, 48 insertions(+)

New commits:
commit 8e03dfd6a4bff4eabf779ace9b758b49cf80f8ba
Author: Miklos Vajna 
AuthorDate: Fri Oct 20 08:57:08 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri Oct 20 11:53:29 2023 +0200

tdf#157590 sw floattable: avoid hang in the nested + row span case

Regression from commit 905962db870e9d1cf1dcf3bd1be44c347cddafe1 (sw
floattable: handle AllowOverlap==false in the layout, 2023-08-10), the
document load resulted in a hang due to a layout loop.

What happens is that SwTabFrame::MakeAll() first does a Split(), but the
problematic row has cells with rowspans, and once this is combined with
multi-page nested floating tables, we move all the content to the next
page (we only leave a stub table frame on the old page), so the next
time SwTabFrame::MakeAll() is called, we do a Join(), and this leads to
a loop.

The traditional Writer way here would be to add a loop control, but we
can do a little bit better: nobody really asked for row span handling
with nested floating tables, so just don't split rows with row span in
this case, move the entire row forward instead. This is enough to avoid
the layout loop, and a next iteration can still use
SwFlowFrame::MoveBwd() / SwFlowFrame::MoveFwd() to split the complex
row.

The bug is fairly hard to hit, any naive simplification to the original
bugdoc leads to a working layout. Carefully keeping the size of the
document, it's possible to at least simplify the content of the table
cells (while keeping their size unchanged), so we avoid half of the
tables and half of the shapes for a faster test case.

Change-Id: Ib14154200c45ecb7f59e85f9f4f1fe0124c4256e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158228
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-nested-rowspan.docx 
b/sw/qa/core/layout/data/floattable-nested-rowspan.docx
new file mode 100644
index ..48cbdbfe59c3
Binary files /dev/null and 
b/sw/qa/core/layout/data/floattable-nested-rowspan.docx differ
diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx
index a5e448081b0f..1659cf0df6fd 100644
--- a/sw/qa/core/layout/tabfrm.cxx
+++ b/sw/qa/core/layout/tabfrm.cxx
@@ -98,6 +98,17 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInInlineTable)
 CPPUNIT_ASSERT(!pTab->GetFollow());
 }
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNestedRowSpan)
+{
+// Given a document with nested floating tables and a row with rowspan 
cells at page boundary:
+// When loading that document:
+// Without the accompanying fix in place, this test would have resulted in 
a layout loop.
+createSwDoc("floattable-nested-rowspan.docx");
+
+// Then make sure the resulting page count matches Word:
+CPPUNIT_ASSERT_EQUAL(6, getPages());
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 183c5114178a..688f1e9770a2 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -2644,6 +2644,43 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 // See if this is a split fly that can also grow.
 auto pUpperFly = static_cast(GetUpper());
 bFlySplit = pUpperFly->IsFlySplitAllowed();
+
+if (bFlySplit)
+{
+// See if this is a nested split fly where the inner 
table also has
+// rowspans.
+SwTextFrame* pAnchorCharFrame = 
pUpperFly->FindAnchorCharFrame();
+if (pAnchorCharFrame && pAnchorCharFrame->IsInFly())
+{
+// Find the row we'll split.
+SwTwips nRemaining
+= aRectFnSet.YDiff(nDeadLine, 
aRectFnSet.GetTop(getFrameArea()));
+nRemaining -= aRectFnSet.GetTopMargin(*this);
+const SwFrame* pRow = Lower();
+for (; pRow->GetNext(); pRow = pRow->GetNext())
+{
+if (nRemaining < 
aRectFnSet.GetHeight(pRow->getFrameArea()))
+{
+break;
+}
+
+nRemaining -= 
aRectFnSet.GetHeight(pRow->getFrameArea());
+}
+// See if any cells have rowspans.
+for (const SwFrame* pLower = pRow->GetLower(); 
pLowe

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-19 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   10 +-
 sw/source/core/doc/DocumentRedlineManager.cxx  |   23 +++
 2 files changed, 24 insertions(+), 9 deletions(-)

New commits:
commit 34ac12dca3f5af50fddfb7c77e2943897980b815
Author: Mike Kaganski 
AuthorDate: Thu Oct 19 20:32:56 2023 +0300
Commit: Mike Kaganski 
CommitDate: Fri Oct 20 00:55:03 2023 +0200

Do not forget to notify in cases when modified redline's start/end don't 
move

SwRangeRedline::SetStart/SetEnd call MaybeNotifyRedlineModification,
which means that e.g. continuing typing at the end of the current
redline would continue sending notifications. But as soon as cursor
is moved (e.g. using arrow left, inside the current redline), the
next modification is completely inside the current one, and would
be simply deleted. In this case (and other similar), notifications
weren't sent.

This change tries to make sure that every such case is handled. In
case of delete-inside-insert, when positions are equal, the current
redline is deleted; MaybeNotifyRedlineModification is not called,
to not crash. I don't know if this needs additional notification.

Change-Id: I2a97354623a5a784928ce4e1f2c93606954bd11c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158198
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 13a882b7f82f..d66a2bc98c2d 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -1652,9 +1652,9 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testRedlineUpdateCallback)
 m_nRedlineTableEntryModified = 0;
 pWrtShell->DelLeft();
 
-// Assert that we get exactly one notification about the redline update.
+// Assert that we get exactly two notification about the redline update.
 // This was 0, as LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED wasn't sent.
-CPPUNIT_ASSERT_EQUAL(1, m_nRedlineTableEntryModified);
+CPPUNIT_ASSERT_EQUAL(2, m_nRedlineTableEntryModified);
 
 // Turn off the change tracking mode, make some modification to left of the
 // redline so that its position changes
@@ -1663,18 +1663,18 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testRedlineUpdateCallback)
 pWrtShell->Insert("This text is left of the redline");
 
 // Position of the redline has changed => Modify callback
-CPPUNIT_ASSERT_EQUAL(2, m_nRedlineTableEntryModified);
+CPPUNIT_ASSERT_EQUAL(3, m_nRedlineTableEntryModified);
 
 pWrtShell->DelLeft();
 // Deletion also emits Modify callback
-CPPUNIT_ASSERT_EQUAL(3, m_nRedlineTableEntryModified);
+CPPUNIT_ASSERT_EQUAL(4, m_nRedlineTableEntryModified);
 
 // Make changes to the right of the redline => no position change in 
redline
 pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 100/*Go 
enough right */, /*bBasicCall=*/false);
 pWrtShell->Insert("This text is right of the redline");
 
 // No Modify callbacks
-CPPUNIT_ASSERT_EQUAL(3, m_nRedlineTableEntryModified);
+CPPUNIT_ASSERT_EQUAL(4, m_nRedlineTableEntryModified);
 }
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testGetViewRenderState)
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index f5ab5a9fdba3..7a9af1ee8891 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -1427,6 +1427,7 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* 
pNewRedl, bool const bCall
 !pRedl->IsMoved() )
 {
 bool bDelete = false;
+bool bMaybeNotify = false;
 
 // Merge if applicable?
 if( (( SwComparePosition::Behind == eCmpPos &&
@@ -1477,22 +1478,22 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* 
pNewRedl, bool const bCall
 *pStt = *pREnd;
 if( ( *pStt == *pEnd ) &&
 ( pNewRedl->GetContentIdx() == nullptr ) )
-bDelete = true;
+bDelete = bMaybeNotify = true;
 }
 else if( SwComparePosition::OverlapBefore == eCmpPos )
 {
 *pEnd = *pRStt;
 if( ( *pStt == *pEnd ) &&
 ( pNewRedl->GetContentIdx() == nullptr ) )
-bDelete = true;
+bDelete = bMaybeNotify = true;
 }
 else if( SwComparePosition::Inside == eCmpPos )
 {
-bDelete = true;
+bDelete = bMaybeNotify = true;
 bMerged = true;
 }
  

[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/qa writerfilter/source

2023-10-16 Thread Miklos Vajna (via logerrit)
 sw/qa/filter/ww8/ww8.cxx|  
 23 ++
 sw/source/filter/ww8/docxexport.cxx |  
 12 +
 writerfilter/qa/cppunittests/dmapper/SettingsTable.cxx  |  
 18 +++
 writerfilter/qa/cppunittests/dmapper/data/floattable-wrap-on-all-pages.docx 
|binary
 writerfilter/source/dmapper/SettingsTable.cxx   |  
 23 ++
 writerfilter/source/ooxml/OOXMLPropertySet.cxx  |  
  2 
 writerfilter/source/ooxml/OOXMLPropertySet.hxx  |  
  2 
 7 files changed, 79 insertions(+), 1 deletion(-)

New commits:
commit 33ade4171a1a443fd24e6463a9eaa279f7d778bb
Author: Miklos Vajna 
AuthorDate: Mon Oct 16 08:46:54 2023 +0200
Commit: Miklos Vajna 
CommitDate: Mon Oct 16 09:53:35 2023 +0200

sw floattable, wrap on all pages: add DOCX filter

- map DocumentSettingId::ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK to
   on export

- do the opposite on import

  - this requires a bit of rework, to avoid routing 
via a grab-bag when we want to actually read it during import

  - also expose GetBooleanValue() from the OOXML tokenizer, so dmapper
can know when the value of the compat flag is a true-like string.

Note that it seems DOC and RTF don't have a matching compat flag for
this.

Change-Id: I0cb1230ee40994f59b816c42f8e7d2ac658b3212
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158013
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx
index 6a858193e776..1d863545578e 100644
--- a/sw/qa/filter/ww8/ww8.cxx
+++ b/sw/qa/filter/ww8/ww8.cxx
@@ -332,6 +332,29 @@ CPPUNIT_TEST_FIXTURE(Test, testDoNotBreakWrappedTables)
 assertXPath(pXmlDoc, "/w:settings/w:compat/w:doNotBreakWrappedTables", 1);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testAllowTextAfterFloatingTableBreak)
+{
+// Given a document with the ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK compat 
mode enabled:
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+IDocumentSettingAccess& rIDSA = pDoc->getIDocumentSettingAccess();
+rIDSA.set(DocumentSettingId::ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK, true);
+
+// When saving to docx:
+save("Office Open XML Text");
+
+// Then make sure the compat flag is serialized:
+xmlDocUniquePtr pXmlDoc = parseExport("word/settings.xml");
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 0
+// - XPath 
'/w:settings/w:compat/w:compatSetting[@w:name='allowTextAfterFloatingTableBreak']'
 number of nodes is incorrect
+// i.e. the compat flag was lost on export.
+assertXPath(pXmlDoc,
+
"/w:settings/w:compat/w:compatSetting[@w:name='allowTextAfterFloatingTableBreak']",
+"val", "1");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testDOCfDontBreakWrappedTables)
 {
 // Given a document with fDontBreakWrappedTables:
diff --git a/sw/source/filter/ww8/docxexport.cxx 
b/sw/source/filter/ww8/docxexport.cxx
index 61319d5e2f3b..42ff0fdf7a09 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -1435,6 +1435,18 @@ void DocxExport::WriteSettings()
 FSNS( XML_w, XML_name ), "compatibilityMode",
 FSNS( XML_w, XML_uri ),  
"http://schemas.microsoft.com/office/word";,
 FSNS( XML_w, XML_val ),  
OString::number(nTargetCompatibilityMode));
+
+const IDocumentSettingAccess& rIDSA = 
m_rDoc.getIDocumentSettingAccess();
+if 
(rIDSA.get(DocumentSettingId::ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK))
+{
+// AllowTextAfterFloatingTableBreak doesn't have its own XML 
element, it's a
+//  with a specific name.
+pFS->singleElementNS(XML_w, XML_compatSetting,
+FSNS(XML_w, XML_name), "allowTextAfterFloatingTableBreak",
+FSNS(XML_w, XML_uri), 
"http://schemas.microsoft.com/office/word";,
+FSNS(XML_w, XML_val), "1");
+}
+
 pFS->endElementNS( XML_w, XML_compat );
 }
 
diff --git a/writerfilter/qa/cppunittests/dmapper/SettingsTable.cxx 
b/writerfilter/qa/cppunittests/dmapper/SettingsTable.cxx
index 8b36a6170bb0..00d4147bfb05 100644
--- a/writerfilter/qa/cppunittests/dmapper/SettingsTable.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/SettingsTable.cxx
@@ -41,6 +41,24 @@ CPPUNIT_TEST_FIXTURE(Test, testDoNotBreakWrappedTables)
 // set.
 CPPUNIT_ASSERT(bDoNotBreakWrappedTables);
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testAllowTextAfterFloatingTableBreak)
+{
+// Given a document with :
+// When importing that document:
+loadFromURL(u"floattable-wrap-on-all-pages.docx");
+
+// Then make sure that the matching compat flag is set:
+uno::Reference xDocument(mxComponent, 
uno::UNO_QUERY);
+uno:

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-13 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/floattable-wrap-on-all-pages.docx |binary
 sw/qa/core/layout/flycnt.cxx |   39 +++
 sw/source/core/inc/flyfrms.hxx   |1 
 sw/source/core/layout/flycnt.cxx |   18 ++
 sw/source/core/text/frmform.cxx  |5 +
 sw/source/core/text/porrst.cxx   |7 ++
 6 files changed, 68 insertions(+), 2 deletions(-)

New commits:
commit 7d7ca347fafa7a06094b00e8fb0d0452c4c81366
Author: Miklos Vajna 
AuthorDate: Fri Oct 13 08:48:43 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri Oct 13 10:25:26 2023 +0200

sw floattable, wrap on all pages: add layout

The anchor text of a floating table is normally wrapped around the table
only on the last page of the table. This compat flag requests to wrap on
all pages instead.

First, disable the SwTextFrame::FormatEmpty() optimization in this case,
so not only the last page has portions inside the text frame.

Second, improve SwTextFrame::FormatAdjust(), so that anchor content from
the last page can flow to previous pages.

Note that having a dedicated SwFlyAtContentFrame::IsWrapOnAllPages()
means that later it'll be possible to do per-frame decision on this if
there is demand for that (this came up on the mailing list, but it's not
something Word would support).

Change-Id: I75df539df859aaa6c7eaaeddb33f004639b1c004
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157902
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-wrap-on-all-pages.docx 
b/sw/qa/core/layout/data/floattable-wrap-on-all-pages.docx
new file mode 100644
index ..39642002bbed
Binary files /dev/null and 
b/sw/qa/core/layout/data/floattable-wrap-on-all-pages.docx differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 325b0078ecb0..16cd9cda4a57 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace
 {
@@ -1183,6 +1184,44 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInTableInSection)
 SwSortedObjs& rPage3Objs = *pPage3->GetSortedObjs();
 CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage3Objs.size());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWrapOnAllPages)
+{
+// Given a document where we want to wrap on all pages, around a split 
floating table:
+createSwDoc("floattable-wrap-on-all-pages.docx");
+SwDoc* pDoc = getSwDoc();
+
pDoc->getIDocumentSettingAccess().set(DocumentSettingId::ALLOW_TEXT_AFTER_FLOATING_TABLE_BREAK,
+  true);
+
+// When formatting that document:
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+pWrtShell->Reformat();
+
+// Then make sure that the anchor text is also split between page 1 and 
page 2:
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+pLayout->dumpAsXml();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+auto pPage1Anchor = pPage1->FindLastBodyContent()->DynCastTextFrame();
+CPPUNIT_ASSERT(pPage1Anchor);
+OUString aAnchor1Text(pPage1Anchor->GetText().subView(
+static_cast(pPage1Anchor->GetOffset()),
+static_cast(pPage1Anchor->GetFollow()->GetOffset()
+   - pPage1Anchor->GetOffset(;
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: He heard quiet steps behind him. That
+// - Actual  :
+// i.e. the first page had no anchor text, only the second.
+CPPUNIT_ASSERT_EQUAL(OUString("He heard quiet steps behind him. That "), 
aAnchor1Text);
+auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage2);
+auto pPage2Anchor = pPage2->FindLastBodyContent()->DynCastTextFrame();
+CPPUNIT_ASSERT(pPage2Anchor);
+OUString aAnchor2Text(
+
pPage2Anchor->GetText().subView(static_cast(pPage2Anchor->GetOffset(;
+CPPUNIT_ASSERT(!pPage2Anchor->GetFollow());
+CPPUNIT_ASSERT_EQUAL(OUString("didn't bode well."), aAnchor2Text);
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx
index fd4fff11b1d5..051d514fd31e 100644
--- a/sw/source/core/inc/flyfrms.hxx
+++ b/sw/source/core/inc/flyfrms.hxx
@@ -202,6 +202,7 @@ public:
 SwFlyAtContentFrame* GetPrecede();
 /// Like Cut(), except that follow chaining is maintained.
 void DelEmpty();
+bool IsWrapOnAllPages() const;
 void dumpAsXmlAttributes(xmlTextWriterPtr pWriter) const override;
 };
 
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 98843c2c0d47..c07201f49f43 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -1784,6 +1784

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-11 Thread Miklos Vajna (via logerrit)
 sw/qa/core/text/data/content-control-header.docx |binary
 sw/qa/core/text/itrform2.cxx |   27 +++
 sw/source/core/text/itrform2.cxx |   10 +++-
 3 files changed, 36 insertions(+), 1 deletion(-)

New commits:
commit 5dff1f3a995a8e78a156214fd9c32b1005337183
Author: Miklos Vajna 
AuthorDate: Tue Oct 10 20:06:39 2023 +0200
Commit: Miklos Vajna 
CommitDate: Wed Oct 11 10:11:20 2023 +0200

tdf#157593 sw content control, PDF export: fix headers/footers

Regression from commit de90c192cb8f1f03a4028493d8bfe9a127a76b2a (sw
content controls, plain text: enable DOCX filter with data binding,
2022-09-19), the PDF export of the bugdoc was broken, content was
missing on page 2.

Looking at the problem at a higher level, PDF form control in a header
or footer makes no sense, since then you would get multiple answers for
the same question.

Fix the problem by disabling the mapping of Writer content controls to
PDF widgets in headers and footers.

Note that the original motivation is probably around providing a way to
set the document header via scripting, without touching document.xml or
headerN.xml. This valid use-case still works after this fix, we still
update the value of the content control from data binding.

Change-Id: I969682bf90026236276992dd6b6099e50dffe949
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157769
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/core/text/data/content-control-header.docx 
b/sw/qa/core/text/data/content-control-header.docx
new file mode 100644
index ..c65ac1d41cac
Binary files /dev/null and b/sw/qa/core/text/data/content-control-header.docx 
differ
diff --git a/sw/qa/core/text/itrform2.cxx b/sw/qa/core/text/itrform2.cxx
index 637396a01c2e..187eb9ab678e 100644
--- a/sw/qa/core/text/itrform2.cxx
+++ b/sw/qa/core/text/itrform2.cxx
@@ -112,6 +112,33 @@ CPPUNIT_TEST_FIXTURE(Test, testFlyMinimalWrap)
 // text frames in the body frame, not 2.
 CPPUNIT_ASSERT(!pPage2Para2->GetNext());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testContentControlHeaderPDFExport)
+{
+// Given a document with a content control in the header:
+createSwDoc("content-control-header.docx");
+
+// When exporting to PDF:
+save("writer_pdf_Export");
+
+// Then make sure all the expected text is there on page 2:
+std::unique_ptr pPdfDocument = parsePDFExport();
+std::unique_ptr pPage2 = pPdfDocument->openPage(1);
+int nTextCount = 0;
+for (int i = 0; i < pPage2->getObjectCount(); ++i)
+{
+std::unique_ptr pObject = 
pPage2->getObject(i);
+if (pObject->getType() == vcl::pdf::PDFPageObjectType::Text)
+{
+++nTextCount;
+}
+}
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 3
+// - Actual  : 2
+// i.e. not all of header, heading and body text was there on page 2, 
content was lost.
+CPPUNIT_ASSERT_EQUAL(3, nTextCount);
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 36a86504adc5..6511d0ab45c9 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -974,8 +974,16 @@ bool SwContentControlPortion::DescribePDFControl(const 
SwTextPaintInfo& rInf) co
 return false;
 }
 
-// Check if this is the first content control portion of this content 
control.
 SwTextNode* pTextNode = pContentControl->GetTextNode();
+SwDoc& rDoc = pTextNode->GetDoc();
+if (rDoc.IsInHeaderFooter(*pTextNode))
+{
+// Form control in header/footer makes no sense, would allow multiple 
values for the same
+// control.
+return false;
+}
+
+// Check if this is the first content control portion of this content 
control.
 sal_Int32 nStart = m_pTextContentControl->GetStart();
 sal_Int32 nEnd = *m_pTextContentControl->GetEnd();
 TextFrameIndex nViewStart = rInf.GetTextFrame()->MapModelToView(pTextNode, 
nStart);


[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-11 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/floattable-in-inltbl-in-sect.docx |binary
 sw/qa/core/layout/flycnt.cxx |   26 +++
 sw/source/core/layout/flycnt.cxx |   26 ---
 3 files changed, 48 insertions(+), 4 deletions(-)

New commits:
commit 6b9378154f9b504b9e924fe4565df444786e7d73
Author: Miklos Vajna 
AuthorDate: Wed Oct 11 08:32:02 2023 +0200
Commit: Miklos Vajna 
CommitDate: Wed Oct 11 09:47:26 2023 +0200

sw floattable, crashtesting: fix PDF export of ooo91654-1.doc

Regression from 89a75cd194371002247d0138e759835bc673f7b0 (tdf#126449 sw
floattable: DOC import: handle inner floating table, 2023-10-04), the
document crashed Writer layout when exporting to PDF, which triggers a
layout calculation.

The trouble seems to be that in case the split fly is anchored in a
table which is in a section, then we assume that we can create a section
on the next page and move the follow fly frame there, which will mean
the follow anchor won't be in a table anymore.

Fix this by not moving the follow anchor explicitly, similar to what the
nested floating table (inline or floating outer table) code does. The
layout will later figure out that the available space is not enough,
split the outer table for us, which will lead to a correct result.

Note that the original bugdoc is DOC, but just saving it as-is in Word
hides the problem, so it's not easy to minimize the reproducer. Instead
create a similar DOCX reproducer from scratch.

Change-Id: I769615af467ccaa88057ab322da2865f11d3d2ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157803
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-in-inltbl-in-sect.docx 
b/sw/qa/core/layout/data/floattable-in-inltbl-in-sect.docx
new file mode 100644
index ..ff329ecb5a5f
Binary files /dev/null and 
b/sw/qa/core/layout/data/floattable-in-inltbl-in-sect.docx differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 37b255945d9e..325b0078ecb0 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -1157,6 +1157,32 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyDelEmpty)
 // Then make sure that the page count matches Word:
 CPPUNIT_ASSERT_EQUAL(7, getPages());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInTableInSection)
+{
+// Given a document where page 2 and page 3 has a floating table inside an 
inline table, inside
+// a section:
+// Without the accompanying fix in place, this test would have crashed, we 
created a follow
+// anchor which was marked as "in table", but had no table parent.
+createSwDoc("floattable-in-inltbl-in-sect.docx");
+
+// Then make sure that the floating table is on page 2 and page 3:
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+CPPUNIT_ASSERT(!pPage1->GetSortedObjs());
+auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage2);
+CPPUNIT_ASSERT(pPage2->GetSortedObjs());
+SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size());
+auto pPage3 = pPage2->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage3);
+CPPUNIT_ASSERT(pPage3->GetSortedObjs());
+SwSortedObjs& rPage3Objs = *pPage3->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage3Objs.size());
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 3c0254f929b8..98843c2c0d47 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -1579,11 +1579,30 @@ SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType 
eMakePage )
 SwLayoutFrame *pLayLeaf = nullptr;
 // Look up the first candidate.
 SwSectionFrame* pFlyAnchorSection = pFlyAnchor ? 
pFlyAnchor->FindSctFrame() : nullptr;
+bool bNesting = false;
 if (pFlyAnchorSection)
 {
-// We can't just move the split anchor to the next page, that would be 
outside the section.
-// Rather split that section as well.
-pLayLeaf = pFlyAnchorSection->GetNextSctLeaf(eMakePage);
+// The anchor is in a section.
+if (pFlyAnchor)
+{
+SwTabFrame* pFlyAnchorTab = pFlyAnchor->FindTabFrame();
+if (pFlyAnchorTab)
+{
+// The anchor is in table as well.
+if (pFlyAnchorTab->FindSctFrame() == pFlyAnchorSection)
+{
+// We're in a table-in-section, no anchor move in this 
case, because that would
+// mean we're not in a table anymore.
+bNesting = true;
+}
+  

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-10 Thread Miklos Vajna (via logerrit)
 sw/qa/core/text/data/fly-minimal-wrap.docx |binary
 sw/qa/core/text/itrform2.cxx   |   30 +
 sw/qa/core/text/text.cxx   |4 +--
 sw/source/core/text/itrform2.cxx   |   23 --
 4 files changed, 53 insertions(+), 4 deletions(-)

New commits:
commit 4a5fb05d5e2448453477ce14862a8cf9846ecb49
Author: Miklos Vajna 
AuthorDate: Tue Oct 10 08:23:14 2023 +0200
Commit: Miklos Vajna 
CommitDate: Tue Oct 10 09:29:37 2023 +0200

tdf#157571 sw floattable: fix incorrect blank space after table-in-shape

Regression from a4af5432753408c4eea8a8d56c2f48202160c5fe (tdf#120262 sw
floattable, legacy: fix text wrap around fly when no content fits,
2023-07-17), the bugdoc has a shape which contains a table, and lots of
empty paragraphs next to it wrap around the shape. Writer didn't wrap
these empty paragraphs, so some of the page 1 content was shifted to
page 2.

What happened here is that in case there is a really small space for the
wrapping text around a floating object, then Word has some minimal
limit. If the available horizontal space is smaller than the limit, we
don't even try to wrap, even if the content (an empty paragraph) would
fit. It was assumed that this limit is the shape for normal anchored
objects and floating tables, but the two bugdocs show that there are two
different limits here.

Fix the problem by going back to MINLAY as the default limit where we
start wrapping, and only increase that to TEXT_MIN_SMALL when wrapping
around floating tables. That fixes the bugdoc and keeps the older
floating table use-case working as well.

This also allows reverting changes to testParaUpperMarginFlyIntersect,
to assert the non-floating-table case again.

Change-Id: I8f8a776c6ad5bdfa0ee4f197b600463fef6431f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157743
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/text/data/fly-minimal-wrap.docx 
b/sw/qa/core/text/data/fly-minimal-wrap.docx
new file mode 100644
index ..f5955d29d0ed
Binary files /dev/null and b/sw/qa/core/text/data/fly-minimal-wrap.docx differ
diff --git a/sw/qa/core/text/itrform2.cxx b/sw/qa/core/text/itrform2.cxx
index e190bed46f33..637396a01c2e 100644
--- a/sw/qa/core/text/itrform2.cxx
+++ b/sw/qa/core/text/itrform2.cxx
@@ -82,6 +82,36 @@ CPPUNIT_TEST_FIXTURE(Test, 
testFloattableLegacyWrapEmptyParagraph)
 const SwSortedObjs& rPageObjs2 = *pPage2->GetSortedObjs();
 CPPUNIT_ASSERT_EQUAL(static_cast(1), rPageObjs2.size());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testFlyMinimalWrap)
+{
+// Given a document with a first page that has a shape and a table in it 
(not floating table),
+// some empty paragraphs wrapping around the shape:
+createSwDoc("fly-minimal-wrap.docx");
+
+// When calculating the layout:
+calcLayout();
+
+// Then make sure the wrap happens, so the 2nd page only has 2 paragraphs:
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage = dynamic_cast(pLayout->Lower());
+CPPUNIT_ASSERT(pPage);
+CPPUNIT_ASSERT(pPage->GetSortedObjs());
+const SwSortedObjs& rPageObjs = *pPage->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(2), rPageObjs.size());
+auto pPage2 = dynamic_cast(pPage->GetNext());
+CPPUNIT_ASSERT(pPage2);
+CPPUNIT_ASSERT(!pPage2->GetSortedObjs());
+SwLayoutFrame* pBody2 = pPage2->FindBodyCont();
+SwFrame* pPage2Para1 = pBody2->GetLower();
+CPPUNIT_ASSERT(pPage2Para1);
+SwFrame* pPage2Para2 = pPage2Para1->GetNext();
+CPPUNIT_ASSERT(pPage2Para2);
+// Without the accompanying fix in place, this test would have failed, the 
second page had 19
+// text frames in the body frame, not 2.
+CPPUNIT_ASSERT(!pPage2Para2->GetNext());
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index 16aa73cd9823..8a48b75a03e4 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -1419,10 +1419,10 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, 
testParaUpperMarginFlyIntersect)
 nHeight += getXPath(pXmlDoc, xPath, "height").toInt32();
 }
 // Without the accompanying fix in place, this test would have failed with:
-// - Expected: 542 (~500)
+// - Expected: 521 (~500)
 // - Actual  : 857 (~1000)
 // I.e. both upper and lower margin was taken into account.
-CPPUNIT_ASSERT_EQUAL(542, nHeight);
+CPPUNIT_ASSERT_EQUAL(521, nHeight);
 }
 
 CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf129810)
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index f8b2c3a41459..36a86504adc5 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -2806,8 +2806,27 @@ void SwTextFormatter::CalcFlyWidth( Sw

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-07 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/htmlexport/data/table_with_wide_horizontal_border.fodt |   27 
++
 sw/qa/extras/htmlexport/htmlexport.cxx  |   11 
 sw/source/filter/html/htmltabw.cxx  |   11 
 3 files changed, 38 insertions(+), 11 deletions(-)

New commits:
commit b6a5e84cd3f22a223d67fe88595006a33c291c48
Author: Mike Kaganski 
AuthorDate: Fri Oct 6 20:19:28 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sat Oct 7 12:19:25 2023 +0200

tdf#157643: Drop extra cellless rows, a "substitute" for bold borders

Change-Id: Ic98bec72ed14623c880fad3b881d72ee13395a0c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157670
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git 
a/sw/qa/extras/htmlexport/data/table_with_wide_horizontal_border.fodt 
b/sw/qa/extras/htmlexport/data/table_with_wide_horizontal_border.fodt
new file mode 100644
index ..a3c53a070784
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/table_with_wide_horizontal_border.fodt
@@ -0,0 +1,27 @@
+
+
+http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/200
 4/writer" xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; xmlns
 :css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:officeooo="http://openoffice.org/2009/office"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ 
+  
+   
+  
+ 
+ 
+  
+   
+
+
+ 
+  A1
+ 
+
+
+ 
+  A2
+ 
+
+   
+   
+  
+ 
+
\ No newline at end of file
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx 
b/sw/qa/extras/htmlexport/htmlexport.cxx
index dbdf472ceff9..6810baa1efe3 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -2751,6 +2751,17 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, 
testTdf156647_CellPaddingRoundtrip)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTdf157643_WideHBorder)
+{
+// Given a document with a table with a wide border between its two rows:
+createSwDoc("table_with_wide_horizontal_border.fodt");
+// When exporting to reqif-xhtml:
+ExportToReqif();
+// Make sure that there's no extra tr's:
+xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile();
+assertXPath(pXmlDoc, 
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr", 2);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmltabw.cxx 
b/sw/source/filter/html/htmltabw.cxx
index 9a3c0183142f..bd1f35888331 100644
--- a/sw/source/filter/html/htmltabw.cxx
+++ b/sw/source/filter/html/htmltabw.cxx
@@ -827,17 +827,6 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 
eAlign,
 {
 --nSkipRows;
 }
-if( !m_nCellSpacing && nRow < m_aRows.size()-1 && 
pRow->m_bBottomBorder &&
-pRow->m_nBottomBorder > SvxBorderLineWidth::Thin )
-{
-for( auto nCnt = (pRow->m_nBottomBorder / 
SvxBorderLineWidth::Thin) - 1; nCnt; --nCnt )
-{
-rWrt.OutNewLine();
-HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), 
Concat2View(rWrt.Get

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-05 Thread Hossein (via logerrit)
 dev/null |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx |9 -
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx|2 +-
 sw/source/filter/ww8/docxattributeoutput.cxx |3 ---
 4 files changed, 1 insertion(+), 13 deletions(-)

New commits:
commit e0bedd3f7311bf47392a46d097304e3c7afcb246
Author: Hossein 
AuthorDate: Wed Oct 4 22:22:06 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Oct 5 10:14:59 2023 +0200

Revert "tdf#155470 DOCX export: fix RTL numbers changed to LTR"

This reverts commit 40ed8dd3a5a16f21f2e98440c62efa0fa6ec60ff.

Reason for revert: tdf#157598 problem with LTR documents

Change-Id: I6f25913df4e308be660070e1eeca81f08c0547ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157547
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sw/qa/extras/ooxmlexport/data/numbers-rtl.docx 
b/sw/qa/extras/ooxmlexport/data/numbers-rtl.docx
deleted file mode 100644
index 2142967a3619..
Binary files a/sw/qa/extras/ooxmlexport/data/numbers-rtl.docx and /dev/null 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 60e097925829..cbca150319b7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1106,15 +1106,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf115094v3)
 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblpPr", "tblpY", 
"1064");
 }
 
-CPPUNIT_TEST_FIXTURE(Test, testTdf155470)
-{
-loadAndSave("numbers-rtl.docx");
-xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
-
-// Make sure that  is preserved
-assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:rtl");
-}
-
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 9458051ea6d3..db2abe3513a7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -174,7 +174,7 @@ CPPUNIT_TEST_FIXTURE(Test, testStyleInheritance)
 
 // We output exactly 2 properties in rPrDefault, nothing else was
 // introduced as an additional default
-assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/*", 3);
+assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/*", 2);
 // Check that we output real content of rPrDefault
 assertXPath(pXmlStyles, 
"/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "ascii", "Times New 
Roman");
 assertXPath(pXmlStyles, 
"/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:lang", "bidi", "ar-SA");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 4f0c67f3ce99..9c67855acbdd 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -160,7 +160,6 @@
 #include 
 #include 
 #include 
-#include 
 
 using ::editeng::SvxBorderLine;
 
@@ -7932,8 +7931,6 @@ void DocxAttributeOutput::CharLanguage( const 
SvxLanguageItem& rLanguage )
 AddToAttrList( m_pCharLangAttrList, FSNS( XML_w, XML_eastAsia ), 
aLanguageCode );
 break;
 case RES_CHRATR_CTL_LANGUAGE:
-if (MsLangId::isRightToLeft(rLanguage.GetLanguage()))
-m_pSerializer->singleElementNS(XML_w, XML_rtl);
 AddToAttrList( m_pCharLangAttrList, FSNS( XML_w, XML_bidi ), 
aLanguageCode );
 break;
 }


[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-05 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/floattable-del-empty.docx |binary
 sw/qa/core/layout/flycnt.cxx |   12 
 sw/source/core/layout/flycnt.cxx |   11 ---
 3 files changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 2d6f48d53674ee85179ec8cee8648830207200a2
Author: Miklos Vajna 
AuthorDate: Thu Oct 5 08:14:41 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Oct 5 09:35:30 2023 +0200

sw floattable, crashtesting: fix PDF export of fdo56210-3.docx

The bugdoc crashed on PDF export:

heap-use-after-free on address 0x614000205148 at pc 0x7fb757347d7a 
bp 0x7fffeff17170 sp 0x7fffeff17168
READ of size 8 at 0x614000205148 thread T0
#2 0x7fb75785959b in SwFrame::GetDrawObjs() 
sw/source/core/inc/frame.hxx:569:66
#3 0x7fb75a802a60 in 
SwObjectFormatterTextFrame::InvalidatePrevObjs(SwAnchoredObject&) 
sw/source/core/layout/objectformattertxtfrm.cxx:494:50
#4 0x7fb75a7fe371 in 
SwObjectFormatterTextFrame::DoFormatObj(SwAnchoredObject&, bool) 
sw/source/core/layout/objectformattertxtfrm.cxx:155:13
#5 0x7fb75a7ee2c3 in 
SwObjectFormatter::FormatObjsAtFrame_(SwTextFrame*) 
sw/source/core/layout/objectformatter.cxx:413:19
#6 0x7fb75a807bff in SwObjectFormatterTextFrame::DoFormatObjs() 
sw/source/core/layout/objectformattertxtfrm.cxx:337:20
freed by thread T0 here:
#1 0x7fb75b7a0b06 in SwTextFrame::~SwTextFrame() 
sw/source/core/text/txtfrm.cxx:988:1
#2 0x7fb75ab070e3 in SwFrame::DestroyFrame(SwFrame*) 
sw/source/core/layout/ssfrm.cxx:397:9
#3 0x7fb75b1925be in SwTextFrame::JoinFrame() 
sw/source/core/text/frmform.cxx:763:5
#4 0x7fb75a4dcd9e in SwFlyAtContentFrame::DelEmpty() 
sw/source/core/layout/flycnt.cxx:1748:26
#5 0x7fb75a3e3764 in SwFlowFrame::MoveSubTree(SwLayoutFrame*, 
SwFrame*) sw/source/core/layout/flowfrm.cxx:713:28
#6 0x7fb75a418138 in SwFlowFrame::MoveFwd(bool, bool, bool) 
sw/source/core/layout/flowfrm.cxx:2149:13
#7 0x7fb75ab63f19 in SwTabFrame::MakeAll(OutputDevice*) 
sw/source/core/layout/tabfrm.cxx:2886:23
#8 0x7fb75a2fc227 in SwFrame::PrepareMake(OutputDevice*) 
sw/source/core/layout/calcmove.cxx:388:5
#9 0x7fb75abf7383 in SwFrame::Calc(OutputDevice*) const 
sw/source/core/layout/trvlfrm.cxx:1803:37
#10 0x7fb75a7e9bd0 in 
SwObjectFormatter::FormatLayout_(SwLayoutFrame&) 
sw/source/core/layout/objectformatter.cxx:207:19
#11 0x7fb75a7e9f7d in 
SwObjectFormatter::FormatLayout_(SwLayoutFrame&) 
sw/source/core/layout/objectformatter.cxx:214:13
#12 0x7fb75a7eb550 in 
SwObjectFormatter::FormatObj_(SwAnchoredObject&) 
sw/source/core/layout/objectformatter.cxx:296:17
#13 0x7fb75a7fd88d in 
SwObjectFormatterTextFrame::DoFormatObj(SwAnchoredObject&, bool) 
sw/source/core/layout/objectformattertxtfrm.cxx:133:9
#14 0x7fb75a7ee2c3 in 
SwObjectFormatter::FormatObjsAtFrame_(SwTextFrame*) 
sw/source/core/layout/objectformatter.cxx:413:19
#15 0x7fb75a807bff in 
SwObjectFormatterTextFrame::DoFormatObjs() 
sw/source/core/layout/objectformattertxtfrm.cxx:337:20

I.e. the trouble is that SwObjectFormatter::FormatObjsAtFrame_() calls
first calls DoFormatObj(), which joins a follow text frame, but then the
same SwObjectFormatter::FormatObjsAtFrame_() calls DoFormatObj() again,
and that still refers to the now deleted text frame.
SwFlyAtContentFrame::DelEmpty() calling SwTextFrame::JoinFrame() was
added recently, in commit cfe9c68a7a19dd77d1fcbde3a7dd75730634becc
(tdf#157119 sw floattable: fix moving master of split fly to next page,
2023-09-21).

Fix the problem by dropping the 2nd fix from the above commit (and leave
the other 3 unchanged): that is no longer necessary for the old
use-case, probably because in the meantime commit
695390b08799af34b393c81c834d615bea330d89 (tdf#126449 sw floattable: fix
too small height of non-last anchors, 2023-10-03) started to add some
real height for some of the split fly anchor frames, so less manual
joins are needed.

Note that the crash only happens with this bugdoc in case
MALLOC_PERTURB_ is set to something non-empty or when using sanitizers.

Change-Id: I4b810bd77a01a251dd1225426c50a7d7f100ece2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157577
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-del-empty.docx 
b/sw/qa/core/layout/data/floattable-del-empty.docx
new file mode 100644
index ..340d06b6222b
Binary files /dev/null and b/sw/qa/core/layout/data/floattable-del-empty.docx 
differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index f5f5fb094a37..37b255945d9e 100644
--

[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/source

2023-10-04 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf157572_insidiousCombination.docx |binary
 sw/qa/extras/ooxmlexport/data/tdf157572_noVAlignAsText.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |   28 
++
 sw/source/filter/ww8/docxattributeoutput.cxx  |9 +--
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |7 +-
 5 files changed, 37 insertions(+), 7 deletions(-)

New commits:
commit 5760d7876dae55d351e80b990dc064440fa46a73
Author: Justin Luth 
AuthorDate: Tue Oct 3 15:48:48 2023 -0400
Commit: Justin Luth 
CommitDate: Wed Oct 4 20:43:10 2023 +0200

related tdf#157572 writerfilter framePr: no vAlign if vAnchor=text

See bug 157572 for the documentation.

This can be seen in MS Word's UI.
Have the vertical position be centered, and then change to "para":
-> the vertical position changes to a numbered distance.

make CppunitTest_sw_ooxmlexport5 \
CPPUNIT_TEST_NAME=testTdf157572_noVAlignAsText

make CppunitTest_sw_ooxmlexport5 \
CPPUNIT_TEST_NAME=testTdf157572_insidiousCombination

Change-Id: I6c00a34f14633e16178c1504a37e644a30cf4cd7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157529
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf157572_insidiousCombination.docx 
b/sw/qa/extras/ooxmlexport/data/tdf157572_insidiousCombination.docx
new file mode 100644
index ..d7437aedec30
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf157572_insidiousCombination.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf157572_noVAlignAsText.docx 
b/sw/qa/extras/ooxmlexport/data/tdf157572_noVAlignAsText.docx
new file mode 100644
index ..98f1bb195ca8
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf157572_noVAlignAsText.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 2ee3e1e80bf7..d97fd7c237d0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1440,6 +1440,34 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf157572_defaultVAnchor)
 assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr", "yAlign");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf157572_insidiousCombination)
+{
+loadAndSave("tdf157572_insidiousCombination.docx");
+xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
+
+// This is a NASTY example. In MS Word, it IMPORTS yAlign=bottom, but 
positions it as y=0.
+// although the UI shows "bottom" instead of position 0cm. Clicking -ok- 
MOVES the textbox.
+// Seems best to throw away "bottom" in LO, since a round-trip in MS Word 
keeps the 0cm
+// position and the vAlign ONLY affects the UI.
+
+// vAnchor was defined as text.
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","text");
+// yAlign=something is not compatible with "text" - don't write anything 
out
+assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr", "yAlign");
+// y is zero - no need to write out the default value
+assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr", "y");
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf157572_noVAlignAsText)
+{
+loadAndSave("tdf157572_noVAlignAsText.docx");
+xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml");
+
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","text");
+// yAlign=something is not compatible with vAnchor="text" - don't write 
anything out
+assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr", "yAlign");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf112287B)
 {
 loadAndSave("tdf112287B.docx");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 1b209d26a0de..144469810097 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1051,13 +1051,15 @@ void DocxAttributeOutput::PopulateFrameProperties(const 
SwFrameFormat* pFrameFor
 
 attrList->add( FSNS( XML_w, XML_x), OString::number(aPos.X));
 
+const OString relativeFromH = 
convertToOOXMLHoriOrientRel(rHoriOrient.GetRelationOrient());
+const OString relativeFromV = 
convertToOOXMLVertOrientRel(rVertOrient.GetRelationOrient());
 OString aXAlign = convertToOOXMLHoriOrient(rHoriOrient.GetHoriOrient(), 
/*bIsPosToggle=*/false);
 OString aYAlign = convertToOOXMLVertOrient(rVertOrient.GetVertOrient());
 if (!aXAlign.isEmpty())
 attrList->add(FSNS(XML_w, XML_xAlign), aXAlign);
-if (!aYAlign.isEmpty())
+if (!aYAlign.isEmpty() && relativeFromV != "text")
 attrList->add(FSNS(XML_w, XML_yAlign), aYAlign);
-else
+else if (aPos.Y)
 attrList->add( FSNS( XML_w, 

[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/source

2023-10-04 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|2 ++
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |2 +-
 sw/source/filter/ww8/docxattributeoutput.cxx  |3 ++-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   14 +-
 4 files changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 44401e14ff0aab5bc9505c2ec3b78ce91eaf8f4f
Author: Justin Luth 
AuthorDate: Tue Oct 3 15:43:00 2023 -0400
Commit: Justin Luth 
CommitDate: Wed Oct 4 18:41:32 2023 +0200

related tdf#157572 writerfilter framePr: no vAlign if w:y defined

Documentation suggests that vAlign overrides w:y
(as long as vAnchor is not equal to text).
However, testing proves the opposite.
Only when w:y is not defined does vAlign take effect.

make CppunitTest_sw_ooxmlexport5 \
CPPUNIT_TEST_NAME=testTdf157572_defaultVAnchor

make CppunitTest_sw_ooxmlexport18 \
CPPUNIT_TEST_NAME=testTdf154703_framePr2

Change-Id: I8a5366d9b6bde0ad838f9584836a85fe79ce8b1b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157528
Tested-by: Justin Luth 
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index ddf14cb6bc10..bf7eb22eb270 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -285,6 +285,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf154703_framePr2, 
"tdf154703_framePr2.rtf")
 assertXPath(pXmlDoc, "//w:body/w:p[1]/w:pPr/w:shd", "fill", "80");
 assertXPath(pXmlDoc, "//w:body/w:p[2]/w:pPr/w:shd", "fill", "548DD4"); // 
was blue already, no change
 assertXPath(pXmlDoc, "//w:body/w:p[3]/w:pPr/w:shd", "fill", "80");
+assertXPath(pXmlDoc, "//w:body/w:p[3]/w:pPr/w:framePr", "yAlign", 
"center");
+assertXPathNoAttribute(pXmlDoc, "//w:body/w:p[3]/w:pPr/w:framePr", "y");
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf154703_framePrWrapSpacing, 
"tdf154703_framePrWrapSpacing.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 71cea9fa2964..2ee3e1e80bf7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1437,7 +1437,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf157572_defaultVAnchor)
 // vAnchor wasn't defined on import. It should default to 'margin' when 
w:y=non-zero
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr","vAnchor","margin");
 // yAlign=something is not compatible with w:y=non-zero" - don't write 
anything out
-// assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr", "yAlign");
+assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:p[1]/w:pPr/w:framePr", "yAlign");
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf112287B)
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index b809870dcf28..1b209d26a0de 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1050,7 +1050,6 @@ void DocxAttributeOutput::PopulateFrameProperties(const 
SwFrameFormat* pFrameFor
 attrList->add( FSNS( XML_w, XML_h), OString::number(rSize.Height()));
 
 attrList->add( FSNS( XML_w, XML_x), OString::number(aPos.X));
-attrList->add( FSNS( XML_w, XML_y), OString::number(aPos.Y));
 
 OString aXAlign = convertToOOXMLHoriOrient(rHoriOrient.GetHoriOrient(), 
/*bIsPosToggle=*/false);
 OString aYAlign = convertToOOXMLVertOrient(rVertOrient.GetVertOrient());
@@ -1058,6 +1057,8 @@ void DocxAttributeOutput::PopulateFrameProperties(const 
SwFrameFormat* pFrameFor
 attrList->add(FSNS(XML_w, XML_xAlign), aXAlign);
 if (!aYAlign.isEmpty())
 attrList->add(FSNS(XML_w, XML_yAlign), aYAlign);
+else
+attrList->add( FSNS( XML_w, XML_y), OString::number(aPos.Y));
 
 sal_Int16 nLeft = pFrameFormat->GetLRSpace().GetLeft();
 sal_Int16 nRight = pFrameFormat->GetLRSpace().GetRight();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 9c1b32a54927..77528bc546c7 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1863,12 +1863,16 @@ DomainMapper_Impl::MakeFrameProperties(const 
ParagraphProperties& rProps)
 
comphelper::makePropertyValue(getPropertyName(PROP_VERT_ORIENT_POSITION), nY));
 
 sal_Int16 nVertOrient = text::VertOrientation::NONE;
-for (const auto pProp : vProps)
+// Testing indicates that yAlign should be ignored if there is any 
specified w:y
+if (!bValidY)
 {
-if (pProp->GetyAlign() < 0)
-continue;
-nVertOrient = pProp->GetyAlign();
-break;
+for (const auto pProp : vProps)
+{
+if (pProp->GetyAlign() < 0)
+

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-04 Thread Miklos Vajna (via logerrit)
 sw/qa/filter/ww8/data/floattable-in-inlinetable.doc |binary
 sw/qa/filter/ww8/ww8.cxx|   37 
 sw/source/filter/ww8/ww8par2.cxx|   11 +++--
 3 files changed, 44 insertions(+), 4 deletions(-)

New commits:
commit 89a75cd194371002247d0138e759835bc673f7b0
Author: Miklos Vajna 
AuthorDate: Wed Oct 4 08:29:13 2023 +0200
Commit: Miklos Vajna 
CommitDate: Wed Oct 4 11:54:54 2023 +0200

tdf#126449 sw floattable: DOC import: handle inner floating table

One problem with the bugdoc is that the inner floating tables in the DOC
file stay in a single page.

Seems the usual to-para anchoring + allow-to-split logic is not used
here, because the toplevel table is handled at
SwWW8ImplReader::StartApo(), but the inner table is handled in
SwWW8ImplReader::StartTable(). Additionally, the toplevel table is
anchored to-para (which seems to be the closest to Word's "position this
table based on the next paragraph" concept), but the inner table was
anchored to-char, and such fly frames can't split.

Fix the problem by switching to to-para anchoring even for inner
floating tables. This improves consistency with toplevel floatint tables
from DOC and all floating tables from DOCX. It seems to the to-char
anchor type was added in commit 10f352d2faf6a4d72337b2c098a65377eee5138b
(INTEGRATION: CWS swqbugfixes18 (1.111.60); FILE MERGED, 2005-03-30),
but there the motivation was to make sure these are not inline; so that
use-case keeps working.

This does fix the overlapping text with the original bugdoc, but
otherwise the DOCX version is still slightly closer to the Word render
result.

Change-Id: I379a26194da4d3a06241aa3c6f5ae78606f8fc12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157550
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/filter/ww8/data/floattable-in-inlinetable.doc 
b/sw/qa/filter/ww8/data/floattable-in-inlinetable.doc
new file mode 100644
index ..a2f06973a53c
Binary files /dev/null and 
b/sw/qa/filter/ww8/data/floattable-in-inlinetable.doc differ
diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx
index 14cde1758588..ebd4e3d38d36 100644
--- a/sw/qa/filter/ww8/ww8.cxx
+++ b/sw/qa/filter/ww8/ww8.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace
 {
@@ -488,6 +489,42 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableFootnote)
 // - Actual  : 0
 CPPUNIT_ASSERT_EQUAL(static_cast(1), rFootnotes.size());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInInlineTableDOC)
+{
+// Outer inline table on pages 1 -> 2 -> 3, inner floating table on pages 
2 -> 3:
+// When laying out that document:
+createSwDoc("floattable-in-inlinetable.doc");
+
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+{
+SwFrame* pBody = pPage1->FindBodyCont();
+auto pTab = pBody->GetLower()->DynCastTabFrame();
+CPPUNIT_ASSERT(!pTab->GetPrecede());
+CPPUNIT_ASSERT(pTab->GetFollow());
+}
+auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage2);
+{
+SwFrame* pBody = pPage2->FindBodyCont();
+auto pTab = pBody->GetLower()->DynCastTabFrame();
+CPPUNIT_ASSERT(pTab->GetPrecede());
+// Without the accompanying fix in place, this test would have failed, 
the outer table was
+// missing on page 3.
+CPPUNIT_ASSERT(pTab->GetFollow());
+}
+auto pPage3 = pPage2->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage3);
+{
+SwFrame* pBody = pPage3->FindBodyCont();
+auto pTab = pBody->GetLower()->DynCastTabFrame();
+CPPUNIT_ASSERT(pTab->GetPrecede());
+CPPUNIT_ASSERT(!pTab->GetFollow());
+}
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 6c18f5a9ce08..4cc4f8379b58 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -3419,8 +3419,8 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
 m_aSectionManager.GetTextAreaWidth(),
 m_nIniFlyDx, m_nIniFlyDy);
 
-// #i45301# - anchor nested table Writer fly frame at-character
-eAnchor = RndStdIds::FLY_AT_CHAR;
+// #i45301# - anchor nested table Writer fly frame
+eAnchor = RndStdIds::FLY_AT_PARA;
 }
 }
 }
@@ -3438,7 +3438,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
 {
 int nNewInTable = m_nInTable + 1;
 
-if ((eAnchor == RndStdIds::FLY_AT_CHAR)
+if ((eAnchor == RndStdIds::FLY_AT_PARA)
 && !m_aTableStack.empty() && !InEqualApo(nNewInTable) )
 {
  

[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-03 Thread Miklos Vajna (via logerrit)
 sw/qa/uibase/fldui/fldui.cxx  |   24 
 sw/source/uibase/fldui/fldmgr.cxx |7 +--
 2 files changed, 29 insertions(+), 2 deletions(-)

New commits:
commit 4c5f51a7ac4c0f7043ead2b3b48e71c33e16f992
Author: Miklos Vajna 
AuthorDate: Tue Oct 3 20:12:09 2023 +0200
Commit: Miklos Vajna 
CommitDate: Wed Oct 4 08:05:21 2023 +0200

tdf#157394 sw: fix inserting reference mark with existing selection

Type "myword" in Writer, select it, Insert -> Cross-reference, set Name
to "myname", click Insert. The body text now had "myword" twice, instead
of creating a reference mark on the existing "myword" word.

This went wrong in commit 16075474819696f920979969474aa8300f4af530 (sw,
field insert: handle the Content param for refmarks and accept HTML
there, 2022-12-21), because it assumed that in case the uno comand is
dispatched with some reference text, then that has to be inserted at the
cursor position and only then the refmark can be created on that range.
It was not expected that the current Writer selection would show up as
refmark text.

Fix the problem by taking the refmark text from the uno command
parameter only in case we don't have selection, which restores the old
behavior on manual insert of a refmark and keeps the new uno command
parameter working.

Note that contrary to the bug title, inserting cross-references did
work, but the trouble was the insert of the duplicated word.

Change-Id: I1a8b002c2a6f196975a18e01f0e8c457cfb416bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157524
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/uibase/fldui/fldui.cxx b/sw/qa/uibase/fldui/fldui.cxx
index 79a53c842a46..78b2fcedd42a 100644
--- a/sw/qa/uibase/fldui/fldui.cxx
+++ b/sw/qa/uibase/fldui/fldui.cxx
@@ -120,6 +120,30 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertRefmark)
 CPPUNIT_ASSERT_EQUAL(static_cast(1), aAttrs.size());
 CPPUNIT_ASSERT_EQUAL(OUString("aaabbbccc"), pTextNode->GetText());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testInsertRefmarkSelection)
+{
+// Given a document with a single selected word:
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->Insert2("myword");
+pWrtShell->SelAll();
+
+// When inserting a refmark:
+SwFieldMgr aMgr(pWrtShell);
+SwInsertField_Data aData(SwFieldTypesEnum::SetRef, /*nSubType=*/0, 
"myname", "myword",
+ /*nFormatId=*/0);
+aMgr.InsertField(aData);
+
+// Then make sure the document still just contains that word only once:
+SwTextNode* pTextNode = 
pWrtShell->GetCursor()->GetPointNode().GetTextNode();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: myword
+// - Actual  : mywordmyword
+// i.e. the content of the selection was duplicated.
+CPPUNIT_ASSERT_EQUAL(OUString("myword"), pTextNode->GetText());
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/uibase/fldui/fldmgr.cxx 
b/sw/source/uibase/fldui/fldmgr.cxx
index b7c3e60e9a84..bf53ae29b0a4 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -1074,7 +1074,10 @@ bool SwFieldMgr::InsertField(
 const OUString& rRefmarkText = rData.m_sPar2;
 SwPaM* pCursorPos = pCurShell->GetCursor();
 pCurShell->StartAction();
-if (!rRefmarkText.isEmpty())
+bool bHadMark = pCursorPos->HasMark();
+// If we have no selection and the refmark text is provided, 
then the text is
+// expected to be HTML.
+if (!bHadMark && !rRefmarkText.isEmpty())
 {
 // Split node to remember where the start position is.
 bool bSuccess = 
pCurShell->GetDoc()->getIDocumentContentOperations().SplitNode(
@@ -1100,7 +1103,7 @@ bool SwFieldMgr::InsertField(
 
 pCurShell->SetAttrItem( SwFormatRefMark( rData.m_sPar1 ) );
 
-if (!rRefmarkText.isEmpty())
+if (!bHadMark && !rRefmarkText.isEmpty())
 {
 pCursorPos->DeleteMark();
 }


[Libreoffice-commits] core.git: sw/qa sw/source

2023-10-03 Thread Miklos Vajna (via logerrit)
 sw/qa/core/text/data/floattable-anchor-height.docx |binary
 sw/qa/core/text/porrst.cxx |   37 +
 sw/source/core/text/porrst.cxx |   26 +-
 3 files changed, 61 insertions(+), 2 deletions(-)

New commits:
commit 695390b08799af34b393c81c834d615bea330d89
Author: Miklos Vajna 
AuthorDate: Tue Oct 3 12:08:36 2023 +0200
Commit: Miklos Vajna 
CommitDate: Tue Oct 3 17:29:14 2023 +0200

tdf#126449 sw floattable: fix too small height of non-last anchors

The bugdoc had an outer inline table, a middle inline table and an inner
floating table. The floating table is expected to be on pages 2, 3 and
4; actually it was only on page 2 and 3.

This happened because the fly frame that should be on page 4 was on page
3, leading to overlapping text. And that bad fly position seems to
happen because the anchor frames just have a 1 line height (~269 twips
instead of the fly height).

Fix this similar to how "first paragraph only" wrapping works: increase
the (anchor) text frame height, even if the contained lines would not
require that amount of height.

With this, finally the DOCX version of the bugdoc lays out reasonable
(all 5 pages).

Change-Id: Ib08bf34be61eb2b4d8656887f83ac7fd17e3b252
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157507
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/text/data/floattable-anchor-height.docx 
b/sw/qa/core/text/data/floattable-anchor-height.docx
new file mode 100644
index ..3052f0daef73
Binary files /dev/null and b/sw/qa/core/text/data/floattable-anchor-height.docx 
differ
diff --git a/sw/qa/core/text/porrst.cxx b/sw/qa/core/text/porrst.cxx
index 1c343dc0d9f2..f2e14e7f7f31 100644
--- a/sw/qa/core/text/porrst.cxx
+++ b/sw/qa/core/text/porrst.cxx
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace
 {
@@ -52,6 +53,42 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableLeftoverParaPortion)
 // also had some (duplicated) anchor text.
 CPPUNIT_ASSERT(!pPara2->GetPara());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testFloattableAnchorHeight)
+{
+#if !defined(MACOSX) // FIXME fails on macOS
+// Given 3 tables, innermost table on pages 2-3-4:
+createSwDoc("floattable-anchor-height.docx");
+
+// When laying out the document:
+calcLayout();
+
+// Then make sure the flys are on the expected pages:
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+CPPUNIT_ASSERT(!pPage1->GetSortedObjs());
+auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage2);
+SwSortedObjs* pPage2Objs = pPage2->GetSortedObjs();
+CPPUNIT_ASSERT(pPage2Objs);
+CPPUNIT_ASSERT_EQUAL(static_cast(1), pPage2Objs->size());
+auto pPage3 = pPage2->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage3);
+SwSortedObjs* pPage3Objs = pPage3->GetSortedObjs();
+CPPUNIT_ASSERT(pPage3Objs);
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 2
+// i.e. page 3 also had the fly frame of page 4 as well.
+CPPUNIT_ASSERT_EQUAL(static_cast(1), pPage3Objs->size());
+auto pPage4 = pPage3->GetNext()->DynCastPageFrame();
+SwSortedObjs* pPage4Objs = pPage4->GetSortedObjs();
+CPPUNIT_ASSERT(pPage4Objs);
+CPPUNIT_ASSERT_EQUAL(static_cast(1), pPage4Objs->size());
+#endif
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index 5c6ea428c1db..bd3589b25676 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -51,6 +51,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 SwTmpEndPortion::SwTmpEndPortion( const SwLinePortion &rPortion,
 const FontLineStyle eUL,
@@ -412,7 +414,8 @@ bool SwTextFrame::FormatEmpty()
 // sw_redlinehide: just disable FormatEmpty optimisation for now
 // Split fly frames: non-last parts of the anchor want this optimization 
to clear the old
 // content.
-bool bHasNonLastSplitFlyDrawObj = HasNonLastSplitFlyDrawObj();
+SwFlyAtContentFrame* pNonLastSplitFlyDrawObj = HasNonLastSplitFlyDrawObj();
+bool bHasNonLastSplitFlyDrawObj = pNonLastSplitFlyDrawObj != nullptr;
 if ((HasFollow() && !bHasNonLastSplitFlyDrawObj) || GetMergedPara() || 
(GetTextNodeFirst()->GetpSwpHints() && !bHasNonLastSplitFlyDrawObj) ||
 nullptr != GetTextNodeForParaProps()->GetNumRule() ||
 GetTextNodeFirst()->HasHiddenCharAttribute(true) ||
@@ -468,7 +471,26 @@ bool SwTextFrame::FormatEmpty()
 }
 
 SwRectFnSet aRectFnSet(this);
-const SwTwips nChg = nHeight - aRectFnSet.GetHeight(getFramePrintArea());
+SwTwips nChg = nHeight - aRectFnSe

[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-29 Thread Miklos Vajna (via logerrit)
 sw/qa/core/text/data/floattable-bad-fly-pos.docx |binary
 sw/qa/core/text/frmform.cxx  |   30 +++
 sw/source/core/text/frmform.cxx  |   14 --
 3 files changed, 41 insertions(+), 3 deletions(-)

New commits:
commit 83abd141bf41c1c8a1d4e5a894b235c842da2a07
Author: Miklos Vajna 
AuthorDate: Fri Sep 29 09:01:29 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri Sep 29 09:58:23 2023 +0200

Related: tdf#126449 sw floattable: fix bad position of in-table follow fly

The reduced bugdoc is of 4 pages, an inner floating table should be on
pages 2 -> 4 but was only on 2 -> 3.

The reason for this seems to be that we correctly split the inner table
twice, but the 3rd fly frame in the chain is positioned on page 3, and
once the anchor moves to page 4, we never re-position the fly frame. The
fly frame is normally only positioned once, since the position of the
anchor and the fly frame depend on each other, so the loop has to be
broken, and this is normally done by locking the position of the fly
after one positioning.

Fix the problem by extending the condition when to unlock the position
of anchored fly frames in SwTextFrame::MakePos(): similar to not yet
positioned fly frames, do one more cycle in case the anchor and the fly
frame are not on the same page.

This just fixes a simplified DOCX bugdoc, the full document still needs
more fixes.

Change-Id: I066c64cf4e12bf31f22218f84f0f2425256ba63e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157393
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/text/data/floattable-bad-fly-pos.docx 
b/sw/qa/core/text/data/floattable-bad-fly-pos.docx
new file mode 100644
index ..a0a8bb4dbdb9
Binary files /dev/null and b/sw/qa/core/text/data/floattable-bad-fly-pos.docx 
differ
diff --git a/sw/qa/core/text/frmform.cxx b/sw/qa/core/text/frmform.cxx
index f2f942bde324..ee791f325729 100644
--- a/sw/qa/core/text/frmform.cxx
+++ b/sw/qa/core/text/frmform.cxx
@@ -116,6 +116,36 @@ CPPUNIT_TEST_FIXTURE(Test, 
testFloattableAvoidLastManipOfst)
 CPPUNIT_ASSERT_EQUAL(static_cast(0),
  static_cast(pAnchorText->GetOffset()));
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testFloattableBadFlyPos)
+{
+// Given a document with an inner floating table on page 2 -> 4:
+// When laying out that document:
+createSwDoc("floattable-bad-fly-pos.docx");
+
+// Then make sure that pages 2 -> 4 get the 3 fly frames:
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+CPPUNIT_ASSERT(!pPage1->GetSortedObjs());
+auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage2);
+CPPUNIT_ASSERT(pPage2->GetSortedObjs());
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
pPage2->GetSortedObjs()->size());
+auto pPage3 = pPage2->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage3);
+CPPUNIT_ASSERT(pPage3->GetSortedObjs());
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 2
+// i.e. the fly on page 4 was still on page 3.
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
pPage3->GetSortedObjs()->size());
+auto pPage4 = pPage3->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage4);
+CPPUNIT_ASSERT(pPage4->GetSortedObjs());
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
pPage4->GetSortedObjs()->size());
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index 0b63c796d913..495820336fb3 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -365,10 +365,18 @@ void SwTextFrame::MakePos()
 // Possibly this fly was positioned relative to us, invalidate its 
position now that our
 // position is changed.
 SwPageFrame* pPageFrame = pFly->FindPageFrame();
-if (pPageFrame && pFly->getFrameArea().Pos() == 
pPageFrame->getFrameArea().Pos())
+bool bFlyNeedsPositioning = false;
+bool bFlyPageMismatch = false;
+if (pPageFrame)
 {
-// The position was just adjusted to be inside the page frame, 
so not really
-// positioned, unlock the position once to allow a recalc.
+// Was the position just adjusted to be inside the page frame?
+bFlyNeedsPositioning = pFly->getFrameArea().Pos() == 
pPageFrame->getFrameArea().Pos();
+// Is the fly on a page different than the anchor frame?
+bFlyPageMismatch = pPageFrame != FindPageFrame();
+}
+if (bFlyNeedsPositioning || bFlyPageMismatch)
+{
+// Not really 

[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-28 Thread László Németh (via logerrit)
 sw/qa/uitest/writer_tests7/tdf156900.py |   46 
 sw/source/core/frmedt/fetab.cxx |   28 ---
 2 files changed, 58 insertions(+), 16 deletions(-)

New commits:
commit 5d490133efe7a2509515ac6d85ed3db0a7988b3c
Author: László Németh 
AuthorDate: Wed Sep 27 14:16:53 2023 +0200
Commit: László Németh 
CommitDate: Thu Sep 28 09:37:13 2023 +0200

tdf#156900 sw tracked table column: fix row deletion

If the last deleted table column was hidden, it was
not possible to delete the table rows.

Regression from commit aff269c18b9029fec992135a406dc5031927c401
"tdf#155345 sw tracked table column: hide them in Hide Changes mode".

Change-Id: I51b78f6f5552bdba2240bf278ac1d796830a1beb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157330
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/uitest/writer_tests7/tdf156900.py 
b/sw/qa/uitest/writer_tests7/tdf156900.py
new file mode 100644
index ..545be94242f4
--- /dev/null
+++ b/sw/qa/uitest/writer_tests7/tdf156900.py
@@ -0,0 +1,46 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_url_for_data_file
+
+# Bug 156900 - no row deletion when there is a hidden last column
+
+class tdf156900(UITestCase):
+def test_tdf156900(self):
+with 
self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as 
self.document:
+
+xToolkit = 
self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+
+# accept all tracked changes
+self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges")
+
+# delete last column
+self.xUITest.executeCommand(".uno:GoRight")
+self.xUITest.executeCommand(".uno:GoRight")
+self.xUITest.executeCommand(".uno:GoRight")
+self.xUITest.executeCommand(".uno:GoRight")
+self.xUITest.executeCommand(".uno:DeleteColumns")
+
+# hide changes
+self.xUITest.executeCommand(".uno:ShowTrackedChanges")
+
+# delete first row
+self.xUITest.executeCommand(".uno:DeleteRows")
+
+# accept all changes
+self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges")
+
+tables = self.document.getTextTables()
+# This was 3 (not deleted row)
+self.assertEqual(len(tables[0].getRows()), 2)
+
+# show changes
+self.xUITest.executeCommand(".uno:ShowTrackedChanges")
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index 59b031ce772a..74b9874dc5ac 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -425,8 +425,10 @@ bool SwFEShell::DeleteRow(bool bCompleteTable)
 
 // tracked deletion: remove only textbox content,
 // and set HasTextChangesOnly table line property to false
+SwEditShell* pEditShell = nullptr;
 if ( bRecordChanges )
 {
+pEditShell = GetDoc()->GetEditShell();
 SvxPrintItem aHasTextChangesOnly(RES_PRINT, false);
 GetDoc()->SetRowNotTracked( *getShellCursor( false ), 
aHasTextChangesOnly );
 
@@ -436,7 +438,7 @@ bool SwFEShell::DeleteRow(bool bCompleteTable)
 // don't need to remove the row frames in Show Changes mode
 if ( !bRecordAndHideChanges )
 {
-if (SwEditShell* pEditShell = GetDoc()->GetEditShell())
+if ( pEditShell )
 pEditShell->Delete(false);
 
 EndAllActionAndCall();
@@ -540,36 +542,30 @@ bool SwFEShell::DeleteRow(bool bCompleteTable)
 }
 
 // delete row content in Hide Changes mode
-if ( bRecordAndHideChanges )
+if ( pEditShell && bRecordAndHideChanges )
 {
-SwEditShell* pEditShell = GetDoc()->GetEditShell();
-
-// select the rows deleted with change tracking
-if ( SwWrtShell* pWrtShell = dynamic_cast(this) )
+// select the row deleted with change tracking cell by cell to 
handle
+// the already deleted cells
+SwWrtShell* pWrtShell = dynamic_cast(this);
+for (SwSelBoxes::size_type nBox = 0; pWrtShell && nBox < 
aBoxes.size(); ++nBox)
 {
 pWrtShell->SelectTableRow();
 SwCursor* pTableCursor = 
static_cast(GetTableCursor());
-auto pStt = aBoxes[0];
-auto pEnd = aBoxes.back();
-if ( pTableCursor )
-   

[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-27 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/floattable-in-inlinetable.docx |binary
 sw/qa/core/layout/tabfrm.cxx  |   37 +++
 sw/source/core/layout/tabfrm.cxx  |   44 ++
 3 files changed, 81 insertions(+)

New commits:
commit c86d6111525f09e895483c7c4919a4b9a5dbd9b9
Author: Miklos Vajna 
AuthorDate: Wed Sep 27 08:36:12 2023 +0200
Commit: Miklos Vajna 
CommitDate: Wed Sep 27 09:33:35 2023 +0200

Related: tdf#126449 sw floattable: fix bad join of inline tbl with inner fly

The problem is that the bugdoc has 3 pages with an inline outer table,
where pages 2 & 3 have an inner floating table. The outer table is only
on pages 1 -> 2, while it should be on pages 1 -> 2 -> 3.

The trouble is similar to point 4) of commit
cfe9c68a7a19dd77d1fcbde3a7dd75730634becc (tdf#157119 sw floattable: fix
moving master of split fly to next page, 2023-09-21), i.e. our normal
behavior would move up the follow table to page 2 from page 3 and simply
shift up the floating table, which is fine for images, but not for
floating tables.

Fix the problem by checking for flys on the old page when determining if
it's OK to move or not. Checking for flys on the new page is already
done in SwTabFrame::ShouldBwdMoved(), when it calls the precede's
CalcFlyOffsets().

This just fixes a simplified DOCX bugdoc (inline outer table, floating
inner table), the full document still needs more fixes.

Change-Id: I7946c0f3cb9995a497fdfff3bfac28b6f16ff844
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157306
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-in-inlinetable.docx 
b/sw/qa/core/layout/data/floattable-in-inlinetable.docx
new file mode 100644
index ..56505316cd8e
Binary files /dev/null and 
b/sw/qa/core/layout/data/floattable-in-inlinetable.docx differ
diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx
index 705bf47af4bc..a5e448081b0f 100644
--- a/sw/qa/core/layout/tabfrm.cxx
+++ b/sw/qa/core/layout/tabfrm.cxx
@@ -61,6 +61,43 @@ CPPUNIT_TEST_FIXTURE(Test, testTableMissingJoin)
 // page 3.
 CPPUNIT_ASSERT(!pTab->HasFollow());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInInlineTable)
+{
+// Outer inline table on pages 1 -> 2 -> 3, inner floating table on pages 
2 -> 3:
+// When laying out that document:
+createSwDoc("floattable-in-inlinetable.docx");
+
+// Then make sure that the outer table is not missing on page 3:
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+{
+SwFrame* pBody = pPage1->FindBodyCont();
+auto pTab = pBody->GetLower()->DynCastTabFrame();
+CPPUNIT_ASSERT(!pTab->GetPrecede());
+CPPUNIT_ASSERT(pTab->GetFollow());
+}
+auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage2);
+{
+SwFrame* pBody = pPage2->FindBodyCont();
+auto pTab = pBody->GetLower()->DynCastTabFrame();
+CPPUNIT_ASSERT(pTab->GetPrecede());
+// Without the accompanying fix in place, this test would have failed, 
the outer table was
+// missing on page 3.
+CPPUNIT_ASSERT(pTab->GetFollow());
+}
+auto pPage3 = pPage2->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage3);
+{
+SwFrame* pBody = pPage3->FindBodyCont();
+auto pTab = pBody->GetLower()->DynCastTabFrame();
+CPPUNIT_ASSERT(pTab->GetPrecede());
+CPPUNIT_ASSERT(!pTab->GetFollow());
+}
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 693c180154df..183c5114178a 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -2357,6 +2357,50 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 // when the upper has no space, but the follow is
 // empty.
 bFits = aRectFnSet.BottomDist(getFrameArea(), 
nDeadLine) >= 0;
+
+if (bFits)
+{
+// The follow table's wants to move backwards, see if 
the first row has a
+// split fly anchored in it that would have more space 
than what we have:
+SwRowFrame* pRow = 
GetFollow()->GetFirstNonHeadlineRow();
+if (pRow)
+{
+SwPageFrame* pPage = GetFollow()->FindPageFrame();
+SwSortedObjs* pPageObjs = pPage->GetSortedObjs();
+if (pPageObjs)
+{
+bool bSplitFly = false;
+ 

[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-25 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/table-missing-join.docx |binary
 sw/qa/core/layout/tabfrm.cxx   |   28 +
 sw/source/core/layout/tabfrm.cxx   |9 
 3 files changed, 37 insertions(+)

New commits:
commit b8521d969ab5be4fc947e467d4afe969f9d3b563
Author: Miklos Vajna 
AuthorDate: Mon Sep 25 08:38:28 2023 +0200
Commit: Miklos Vajna 
CommitDate: Mon Sep 25 09:41:41 2023 +0200

tdf#157263 sw floattable: prefer join over split after moving fwd

Regression from commit a4af5432753408c4eea8a8d56c2f48202160c5fe
(tdf#120262 sw floattable, legacy: fix text wrap around fly when no
content fits, 2023-07-17), the bugdoc was of 3 pages in both Word and
Writer, but is now of 4 pages in Writer.

The above commit fixed the layout, so the first row of the table around
the page 1 -> page 2 boundary goes to the start of page 2 instead of to
the end of page 1. This matches the Word layout, so a wanted change on
its own, but it regressed the page acount. The reason for this is that
the table has a single row on page 2 and its follow on page 3 is not
joined, even if there would be still space on page 2. A reduced bugdoc
appears to reproduce this problem even without floating tables, also
with old versions, so it's not a new problem, but it's now more visible.

Fix the problem by tweaking what to do in the next iteration in the loop
of SwTabFrame::MakeAll() after moving forward. Moving forward is
followed by a next iteration in that function, but it does both a
MakePos() and a Format(), so it'll be the last iteration in the "is the
postion / size of this tab frame valid" loop. We used to hit the "bSplit
== true" case, there we found that there is enough remaining space, so
no need to split and we quit the loop. This is now changed, so in case
we moved the table forward and there is still enough space for the
follow to be next to us, then the last iteration will try to join
instead of trying to split.

Note that probably split almost never makes sense after moving forward
in the !HasNext() && HasFollow() case, but let's stay on the safe side
and only do this when the follow definitely fits, which is enough for
our needs here.

Change-Id: I64b0a7d257b0ab01353741506969a287b361c5ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157233
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/table-missing-join.docx 
b/sw/qa/core/layout/data/table-missing-join.docx
new file mode 100644
index ..1fabb9e5b27c
Binary files /dev/null and b/sw/qa/core/layout/data/table-missing-join.docx 
differ
diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx
index 4b991c27dbf8..705bf47af4bc 100644
--- a/sw/qa/core/layout/tabfrm.cxx
+++ b/sw/qa/core/layout/tabfrm.cxx
@@ -9,6 +9,13 @@
 
 #include 
 
+#include 
+#include 
+#include 
+#include 
+
+namespace
+{
 /// Covers sw/source/core/layout/tabfrm.cxx fixes.
 class Test : public SwModelTestBase
 {
@@ -35,4 +42,25 @@ CPPUNIT_TEST_FIXTURE(Test, testTablePrintAreaLeft)
 CPPUNIT_ASSERT_EQUAL(static_cast(5), nTablePrintLeft);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTableMissingJoin)
+{
+// Given a document with a table on page 2:
+// When laying out that document:
+createSwDoc("table-missing-join.docx");
+
+// Then make sure that the table fits page 2:
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage2);
+SwFrame* pBody = pPage2->FindBodyCont();
+auto pTab = pBody->GetLower()->DynCastTabFrame();
+// Without the accompanying fix in place, this test would have failed, the 
table continued on
+// page 3.
+CPPUNIT_ASSERT(!pTab->HasFollow());
+}
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 68bb19b7f39d..693c180154df 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -2872,6 +2872,15 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 if ( GetFollow() )
 Join();
 }
+else if (!GetNext() && !HasFollowFlowLine() && GetFollow()
+ && (getFrameArea().Bottom() + 
GetFollow()->getFrameArea().Height())
+< GetUpper()->getFrameArea().Bottom())
+{
+// We're the last lower of the upper, no split row and we have a 
follow.  That follow
+// fits our upper, still.  Prefer joining that follow in the next 
iteration, instead of
+// trying to split the current table.
+bSplit = false;
+}
 
 if ( bMovedBwd &&

[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-21 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/rtl-table.docx |binary
 sw/qa/core/layout/paintfrm.cxx|   41 ++
 sw/source/core/layout/paintfrm.cxx|4 ++-
 3 files changed, 44 insertions(+), 1 deletion(-)

New commits:
commit 652ab50ce18d0ce7fa1209e6bcf3b10ac5c9a933
Author: Miklos Vajna 
AuthorDate: Thu Sep 21 20:21:07 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri Sep 22 08:33:18 2023 +0200

tdf#154198 sw: fix lost vertical table cell borders for WordTableCell + RTL

This went wrong in commit 0dbecd2d2ebe18a262cfab96e105637840b5b7fe (sw:
fix too long inner borders intersecting with outer borders for Word
cells, 2022-01-06), the problem is that in its current form this assumes
that the first cell is on the left and the last cell is on the right,
which is not true for RTL, so only tweak the length of the borders in
the LTR case.

Change-Id: I513af974855496e507134cf156f9ee5a937a46db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157161
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/core/layout/data/rtl-table.docx 
b/sw/qa/core/layout/data/rtl-table.docx
new file mode 100644
index ..a329229699e8
Binary files /dev/null and b/sw/qa/core/layout/data/rtl-table.docx differ
diff --git a/sw/qa/core/layout/paintfrm.cxx b/sw/qa/core/layout/paintfrm.cxx
index 2416c6b95f8c..ad09405fe3fb 100644
--- a/sw/qa/core/layout/paintfrm.cxx
+++ b/sw/qa/core/layout/paintfrm.cxx
@@ -68,6 +68,47 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitTableBorder)
 // missing.
 CPPUNIT_ASSERT_EQUAL(4, nHorizontalBorders);
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testRTLBorderMerge)
+{
+// Given a document with an RTL table:
+createSwDoc("rtl-table.docx");
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+SwDocShell* pShell = pTextDoc->GetDocShell();
+
+// When rendering that document:
+std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile();
+
+// Then make sure the 5 columns all have left and right vertical borders:
+MetafileXmlDump aDumper;
+xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile);
+xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, 
"//polyline[@style='solid']/point");
+xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
+int nVerticalBorders = 0;
+// Count the vertical borders:
+for (int i = 0; i < xmlXPathNodeSetGetLength(pXmlNodes); i += 2)
+{
+xmlNodePtr pStart = pXmlNodes->nodeTab[i];
+xmlNodePtr pEnd = pXmlNodes->nodeTab[i + 1];
+xmlChar* pStartY = xmlGetProp(pStart, BAD_CAST("y"));
+xmlChar* pEndY = xmlGetProp(pEnd, BAD_CAST("y"));
+sal_Int32 nStartY = o3tl::toInt32(reinterpret_cast(pStartY));
+sal_Int32 nEndY = o3tl::toInt32(reinterpret_cast(pEndY));
+if (nStartY == nEndY)
+{
+// Horizontal border.
+continue;
+}
+
+++nVerticalBorders;
+}
+xmlXPathFreeObject(pXmlObj);
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 6
+// - Actual  : 4
+// i.e. the 2nd and 5th vertical border was missing.
+CPPUNIT_ASSERT_EQUAL(6, nVerticalBorders);
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/paintfrm.cxx 
b/sw/source/core/layout/paintfrm.cxx
index 6b55991efc16..d66af6331c93 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3124,11 +3124,13 @@ void SwTabFramePainter::Insert( SwLineEntry& rNew, bool 
bHori )
 const IDocumentSettingAccess& rIDSA = 
pShell->GetDoc()->getIDocumentSettingAccess();
 bWordTableCell = rIDSA.get(DocumentSettingId::TABLE_ROW_KEEP);
 }
+bool bR2L = mrTabFrame.IsRightToLeft();
 while ( aIter != pLineSet->end() && rNew.mnStartPos < rNew.mnEndPos )
 {
 const SwLineEntry& rOld = *aIter;
 
-if (rOld.mnLimitedEndPos || (bWordTableCell && (rOld.mbOuter != 
rNew.mbOuter)))
+// The bWordTableCell code only works for LTR at the moment, avoid it 
for RTL.
+if (rOld.mnLimitedEndPos || (bWordTableCell && (rOld.mbOuter != 
rNew.mbOuter) && !bR2L))
 {
 // Don't merge with this line entry as it ends sooner than 
mnEndPos.
 ++aIter;


[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-21 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/floattable-move-master.docx |binary
 sw/qa/core/layout/flycnt.cxx   |   42 
++
 sw/source/core/inc/rootfrm.hxx |1 
 sw/source/core/inc/txtfrm.hxx  |2 
 sw/source/core/layout/calcmove.cxx |   13 +++
 sw/source/core/layout/flycnt.cxx   |   27 
++
 sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx |6 +
 sw/source/core/text/itratr.cxx |   10 +-
 8 files changed, 95 insertions(+), 6 deletions(-)

New commits:
commit cfe9c68a7a19dd77d1fcbde3a7dd75730634becc
Author: Miklos Vajna 
AuthorDate: Thu Sep 21 08:31:01 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Sep 21 09:46:28 2023 +0200

tdf#157119 sw floattable: fix moving master of split fly to next page

The problem with the bugdoc is that in case you split the text frame
hosting the start of the anchor text, then the fly will be split in a
broken way on pages 1 -> 4 -> 2, while we want a split on just pages 2
-> 3.

There were several problems here:

1) We created an unnecessary follow fly in SwFrame::GetNextFlyLeaf():
   when page 1 wanted to split, we discarded the flys on page 2 and 3,
   because the original anchor was in the body text and the flys on page
   2/3 was in a fly, so that's rejected. This resulted in a follow fly on
   page 4, which is not correct. Fix this by using an existing follow if
   possible, this is similar to what SwFrame::GetNextSctLeaf() does.

2) SwFlyAtContentFrame::DelEmpty() broke the invariant that in case the
   fly is split to N pieces then the anchor chain's first N frame is
   matching that. Fix this by joining the unwanted anchor with its
   follow right before unlinking the to-be-deleted fly from the fly chain.

3) SwToContentAnchoredObjectPosition::CalcOverlap() tried to shift down
   flys due to overlapping with the to-be-deleted frames, fix this by
   ignoring flys which are already in the to-delete list.

4) SwContentFrame::ShouldBwdMoved() tried to move the master fly back
   from page 2 to page 1, which makes no sense, since there is not
   enough space there to lay out the fly master correctly there.

   Normally we only check if the paragraph fits the remaining space on
   the previous page, and this is wanted: if there is a normal to-para
   anchored image that would not fit, we simply shift up the image. But
   this is not wanted to floating tables, since here the anchor's only
   purpose is to host the start of the fly chain at a correct position.

   Fix this by checking not only for the text frame height vs the
   available space, but also the height of our (only) anchored object.

Note that 3) is not a huge problem, it just causes some extra cycles for
the layout (erase the to-delete flys, then position flys once more), do
it because things are complicated enough already.

Change-Id: I6f2c9d479125309d16b95df0236715c9353e8ba0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157133
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-move-master.docx 
b/sw/qa/core/layout/data/floattable-move-master.docx
new file mode 100644
index ..03087eb358a8
Binary files /dev/null and b/sw/qa/core/layout/data/floattable-move-master.docx 
differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 73a107c4bc5e..f5f5fb094a37 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -1103,6 +1103,48 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNestedOverlap)
 SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs();
 CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage2Objs.size());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyMoveMaster)
+{
+// Given a document with a multi-page floating table on pages 1 -> 2 -> 3:
+createSwDoc("floattable-move-master.docx");
+
+// When adding an empty para before the table, so the table gets shifted 
to pages 2 -> 3:
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+pWrtShell->SttEndDoc(/*bStt=*/true);
+pWrtShell->Down(/*bSelect=*/false, /*nCount=*/4);
+pWrtShell->SplitNode();
+
+// Then make sure page 1 has no flys, page 2 and 3 has the split fly and 
no flys on page 4:
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+// Without the accompanying fix in place, this test would have failed, the 
start of the fly was
+// still on page 1 instead of page 2.
+CPPUNIT_ASSERT(!pPage1->GetSortedObjs());
+auto pPage2 = pPage1->GetNex

[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-14 Thread Miklos Vajna (via logerrit)
 sw/qa/extras/ooxmlexport/data/floattable-nested-cell-start.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx |   17 
++
 sw/source/filter/ww8/docxattributeoutput.cxx   |   16 +
 3 files changed, 26 insertions(+), 7 deletions(-)

New commits:
commit d50e5d6d53c94124f825758a74e186b934fc2a4e
Author: Miklos Vajna 
AuthorDate: Thu Sep 14 08:29:30 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Sep 14 09:15:33 2023 +0200

Related: tdf#55160 sw floattable, nested DOCX exp: fix inner tbl at cell 
start

A cut-down bugdoc had an inline table, and an inner floating table,
anchored in the start of the C1 cell.

Exporting to DOCX resulted in a layout that looks like the floating
table is not anchored inside the outer table anymore. Checking the
markup, the floating table was written between row 1 & row 2, which is
not a valid position for a floating table. Probably the intention was to
write the floating table before the first paragraph in C1.

Fix the problem by still writing the floating table in
DocxAttributeOutput::StartParagraph(), before opening , but do this
after opening table/row/cell, which is late enough to have a correct
anchor but is early enough to be still outside the paragraph.

The import side of this still needs fixing.

Change-Id: I1827b2def1faaf53312522f5a8415fbe697fcb8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156904
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/floattable-nested-cell-start.odt 
b/sw/qa/extras/ooxmlexport/data/floattable-nested-cell-start.odt
new file mode 100644
index ..3e2ed72eca8c
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/floattable-nested-cell-start.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 6b9a61fe2c0d..fb01ab2b47ba 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -139,6 +139,23 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableNestedDOCXExport)
 assertXPath(pXmlDoc, "//w:tblpPr", 2);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testFloattableNestedCellStartDOCXExport)
+{
+// Given a document with a nested floating table at cell start:
+createSwDoc("floattable-nested-cell-start.odt");
+
+// When exporting to DOCX:
+save("Office Open XML Text");
+
+// Then make sure both floating table is exported at the right position:
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+// Without the accompanying fix in place, this test would have failed with
+// - Expected: 1
+// - Actual  : 0
+// i.e. the inner  was between the two , not inside the C1 
cell.
+assertXPath(pXmlDoc, "//w:tc/w:tbl/w:tblPr/w:tblpPr", 1);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testWpgOnly, "wpg-only.docx")
 {
 uno::Reference xShape = getShape(1);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 6d67081e932f..79b9df031924 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -503,13 +503,6 @@ sal_Int32 
DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p
 if ( !m_aFramesOfParagraph.size() || !m_nTextFrameLevel )
 m_aFramesOfParagraph.push(std::vector());
 
-// look ahead for floating tables that were put into a frame during import
-// floating tables in shapes are not supported: exclude this case
-if (!m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen())
-{
-checkAndWriteFloatingTables(*this);
-}
-
 if ( m_nColBreakStatus == COLBRK_POSTPONE )
 m_nColBreakStatus = COLBRK_WRITE;
 
@@ -557,6 +550,15 @@ sal_Int32 
DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p
 }
 }
 
+// look ahead for floating tables that were put into a frame during import
+// floating tables in shapes are not supported: exclude this case
+if (!m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen())
+{
+// Do this after opening table/row/cell, so floating tables anchored 
at cell start go inside
+// the cell, not outside.
+checkAndWriteFloatingTables(*this);
+}
+
 // Look up the "sdt end before this paragraph" property early, when it
 // would normally arrive, it would be too late (would be after the
 // paragraph start has been written).


[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-13 Thread László Németh (via logerrit)
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx   |4 
 sw/source/core/table/swtable.cxx |2 +-
 sw/source/filter/ww8/docxattributeoutput.cxx |   14 --
 sw/source/filter/ww8/docxattributeoutput.hxx |4 
 4 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit d23ba9e6103bba27b57c59505641cc64db63ec98
Author: László Németh 
AuthorDate: Wed Sep 13 10:42:45 2023 +0200
Commit: László Németh 
CommitDate: Wed Sep 13 23:37:02 2023 +0200

tdf#157187 sw tracked table column: fix DOCX export

DOCX export of tracked table column changes
could result dummy content boxes and missing
tracked table column changes in MSO, i.e. lost
interoperability. As a workaround, skip
exporting content boxes within tracked table cells.

Note: bad 0x01 characters and incomplete w:sdt export in table
cells since commit b5c616d10bff3213840d4893d13b4493de71fa56
"tdf#104823: support for sdt plain text fields".

See also commit 4697d2bda1b37f9cf8b301f5bf044c2390f56333
"tdf#157011 sw tracked table column: fix DOCX import of empty cell".

Change-Id: I32f77c7532a9cc6bf5d88a626ac3c62a5c02a34a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156895
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index e5a585f01d68..243bfffb23c2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -1335,6 +1335,10 @@ DECLARE_OOXMLEXPORT_TEST(testTdf157011, 
"tdf157011_ins_del_empty_cols.docx")
 
 // This was 4 (missing tracked table cell deletions)
 assertXPath(pXmlDoc, "//w:del", 6);
+
+// tdf#157187 This was false (dummy w:tc/w:p/w:sdt/w:sdtContent 
content box)
+assertXPath(pXmlDoc, "//w:tc/w:p/w:del", 6);
+assertXPath(pXmlDoc, "//w:tc/w:p/w:ins", 3);
 }
 }
 
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index ca360e324081..3d53ef518903 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -2267,7 +2267,7 @@ bool SwTableBox::IsEmpty( bool bWithRemainingNestedTable 
) const
 
 // tdf#157011 OOXML w:std cell content is imported with terminating 
0x01 characters,
 // i.e. an empty box can contain double 0x01: handle it to avoid 
losing change tracking
-// FIXME regression since LibreOffice 7.3?
+// FIXME regression since commit 
b5c616d10bff3213840d4893d13b4493de71fa56
 if ( pCNd && pCNd->Len() == 2 && pCNd->GetTextNode() )
 {
 const OUString &rText = pCNd->GetTextNode()->GetText();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 4b51f52c6796..6d67081e932f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2013,7 +2013,10 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 {
 auto pTextContentControl = 
static_txtattr_cast(pAttr);
 m_pContentControl = 
pTextContentControl->GetContentControl().GetContentControl();
-WriteContentControlStart();
+if (!m_tableReference.m_bTableCellChanged)
+{
+WriteContentControlStart();
+}
 }
 }
 
@@ -2039,7 +2042,7 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, 
sal_Int32 nPos, sal_In
 {
 sal_Int32 nEnd = nPos + nLen;
 SwTextAttr* pAttr = pNode->GetTextAttrAt(nPos, 
RES_TXTATR_CONTENTCONTROL, ::sw::GetTextAttrMode::Default);
-if (pAttr && *pAttr->GetEnd() == nEnd)
+if (pAttr && *pAttr->GetEnd() == nEnd && 
!m_tableReference.m_bTableCellChanged)
 {
 WriteContentControlEnd();
 }
@@ -4725,6 +4728,12 @@ void DocxAttributeOutput::StartTableCell( 
ww8::WW8TableNodeInfoInner::Pointer_t
 
 InitTableHelper( pTableTextNodeInfoInner );
 
+// check tracked table column deletion or insertion
+const SwTableBox* pTabBox = pTableTextNodeInfoInner->getTableBox();
+SwRedlineTable::size_type nChange = pTabBox->GetRedline();
+if (nChange != SwRedlineTable::npos)
+m_tableReference.m_bTableCellChanged = true;
+
 m_pSerializer->startElementNS(XML_w, XML_tc);
 
 // Write the cell properties here
@@ -4745,6 +4754,7 @@ void DocxAttributeOutput::EndTableCell(sal_uInt32 nCell)
 
 m_tableReference.m_bTableCellOpen = false;
 m_tableReference.m_bTableCellParaSdtOpen = false;
+m_tableReference.m_bTableCellChanged = false;
 }
 
 void DocxAttributeOutput::StartStyles()
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index e8b255bdc990..88fbeeaf740f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@

[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-12 Thread Miklos Vajna (via logerrit)
 sw/qa/extras/ooxmlexport/data/floattable-nested.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx  |   17 +
 sw/source/filter/ww8/docxattributeoutput.cxx|5 -
 3 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit 2887e6b8edbb4fdb093515a3a68269ed40e42116
Author: Miklos Vajna 
AuthorDate: Tue Sep 12 08:42:31 2023 +0200
Commit: Miklos Vajna 
CommitDate: Tue Sep 12 09:35:12 2023 +0200

sw floattable, nesting: fix DOCX export

There were two problems here:

1) DocxAttributeOutput::StartParagraph() didn't try to export an inner
   floating table as a floating table, resulting in writing a shape that
   can't span over multiple pages.

   Dropping the !pTextNodeInfo check should be OK, we'll just now
   clear the m_aFloatingTablesOfParagraph list at the end of the outer
   table.

2) Once we tried to export the inner fly, the actual table/row/cell
   start was missing, because m_tableReference.m_nTableDepth wasn't
   reset, so DocxAttributeOutput::StartParagraph() didn't know it has to
   emit a table definition before the first para of the table.

   Fix this by stashing away the table state before the inner fly's
   export and restoring it after the inner fly export, similar to how this
   is done in e.g. DocxExport::WriteHeaderFooter().

This is related to tdf#55160.

Change-Id: Ib860283d32e392e2906aa12bc9eb61b5af5ca8de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156833
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/floattable-nested.odt 
b/sw/qa/extras/ooxmlexport/data/floattable-nested.odt
new file mode 100644
index ..8644412f60b6
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/floattable-nested.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 5ad22de67e62..6b9a61fe2c0d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -122,6 +122,23 @@ DECLARE_OOXMLEXPORT_TEST(testWpsOnly, "wps-only.docx")
 CPPUNIT_ASSERT_EQUAL(false, getProperty(getShape(2), "Opaque"));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testFloattableNestedDOCXExport)
+{
+// Given a document with nested floating tables:
+createSwDoc("floattable-nested.odt");
+
+// When exporting to DOCX:
+save("Office Open XML Text");
+
+// Then make sure both floating table is exported:
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+// Without the accompanying fix in place, this test would have failed with
+// - Expected: 2
+// - Actual  : 1
+// i.e. the inner floating table was lost.
+assertXPath(pXmlDoc, "//w:tblpPr", 2);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testWpgOnly, "wpg-only.docx")
 {
 uno::Reference xShape = getShape(1);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index c2a55ff8bfc7..4b51f52c6796 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -421,6 +421,9 @@ void DocxAttributeOutput::WriteFloatingTable(ww8::Frame 
const* pParentFrame)
 //Save data here and restore when out of scope
 ExportDataSaveRestore aDataGuard(GetExport(), nStt, nEnd, pParentFrame);
 
+// Stash away info about the current table, so m_tableReference is clean.
+DocxTableExportContext aTableExportContext(*this);
+
 // set a floatingTableFrame AND unset parent frame,
 // otherwise exporter thinks we are still in a frame
 m_rExport.SetFloatingTableFrame(pParentFrame);
@@ -502,7 +505,7 @@ sal_Int32 
DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p
 
 // look ahead for floating tables that were put into a frame during import
 // floating tables in shapes are not supported: exclude this case
-if (!pTextNodeInfo && !m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen())
+if (!m_rExport.SdrExporter().IsDMLAndVMLDrawingOpen())
 {
 checkAndWriteFloatingTables(*this);
 }


[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-11 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/floattable-nested-overlap.odt   |binary
 sw/qa/core/layout/flycnt.cxx   |   23 
+
 sw/source/core/layout/tabfrm.cxx   |   23 
+
 sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx |   24 
--
 4 files changed, 48 insertions(+), 22 deletions(-)

New commits:
commit e20bacc209a8e8483209cb4ec51c9e0b55423cdb
Author: Miklos Vajna 
AuthorDate: Mon Sep 11 08:26:43 2023 +0200
Commit: Miklos Vajna 
CommitDate: Mon Sep 11 09:22:37 2023 +0200

sw floattable, nesting: fix overlap support

The bugdoc had a nested, split floating table with overlap=never and
that lead to a layout loop.

The root of the trouble seems to be that the inner fly will obviously
overlap with its outer fly but we tried to prevent that and we failed.

Fix the problem by ignoring inner flys in
SwToContentAnchoredObjectPosition::CalcOverlap().

This also allows removing special handling of nested split flys in
lcl_ArrangeLowers() and special handling of split flys at an other place
in the same function, because now the non-bDirectMove case works out of
the box.

Change-Id: Icf3a8f776aa758ef4ae2c2994a7216c5a6142a62
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156810
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-nested-overlap.odt 
b/sw/qa/core/layout/data/floattable-nested-overlap.odt
new file mode 100644
index ..b90ae9a7b01e
Binary files /dev/null and 
b/sw/qa/core/layout/data/floattable-nested-overlap.odt differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 1c69606c8a24..73a107c4bc5e 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -1080,6 +1080,29 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNested)
 CPPUNIT_ASSERT(!pPage2Fly2->GetAnchorFrameContainingAnchPos()->IsInFly());
 CPPUNIT_ASSERT(pPage2Fly2->GetPrecede());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNestedOverlap)
+{
+// Given a document with a nested, multi-page floating table, enabling the 
"don't overlap" logic:
+// When calculating the layout:
+createSwDoc("floattable-nested-overlap.odt");
+calcLayout();
+
+// Then make sure we get 2 pages (2 flys on each page):
+// Without the accompanying fix in place, this test would have failed with 
a layout loop.
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+CPPUNIT_ASSERT(pPage1->GetSortedObjs());
+SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage1Objs.size());
+auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage2);
+CPPUNIT_ASSERT(pPage2->GetSortedObjs());
+SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage2Objs.size());
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index bbd7ebece6d8..68bb19b7f39d 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -5287,24 +5287,11 @@ static bool lcl_ArrangeLowers( SwLayoutFrame *pLay, 
tools::Long lYStart, bool bI
 lcl_ArrangeLowers( static_cast(pFrame),
 
aRectFnSet.GetTop(static_cast(pFrame)->Lower()->getFrameArea())
 + lDiffX, bInva );
-SwSortedObjs* pDrawObjs = pFrame->GetDrawObjs();
-auto pTextFrame = pFrame->DynCastTextFrame();
-if (pTextFrame && pTextFrame->IsInFly())
+if ( pFrame->GetDrawObjs() )
 {
-// See if this is a follow anchor. If so, we want the flys 
anchored in the master
-// which are also lowers of pFrame.
-SwTextFrame* pMaster = pTextFrame;
-while (pMaster->IsFollow())
+for ( size_t i = 0; i < pFrame->GetDrawObjs()->size(); ++i )
 {
-pMaster = pMaster->FindMaster();
-}
-pDrawObjs = pMaster->GetDrawObjs();
-}
-if (pDrawObjs)
-{
-for (size_t i = 0; i < pDrawObjs->size(); ++i)
-{
-SwAnchoredObject* pAnchoredObj = (*pDrawObjs)[i];
+SwAnchoredObject* pAnchoredObj = 
(*pFrame->GetDrawObjs())[i];
 // #i26945# - check, if anchored object
 // is lower of layout frame by checking, if the anchor
 // frame, which contains the anchor position, is a lower
@@ -5338,12 +5325,10 @@ static bool lcl_ArrangeLowers( SwLayoutFrame *pLay, 
tools::Long lYStart, bool bI

[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-08 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/flycnt.cxx  |7 +++
 sw/source/core/layout/objectformatter.cxx |7 ++-
 2 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit facdac2443d50339f81415d09c1869d19dded7bf
Author: Miklos Vajna 
AuthorDate: Fri Sep 8 08:26:40 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri Sep 8 09:25:19 2023 +0200

sw floattable, nesting: fix PDF export

The problem was that the bugdoc rendered fine when opened interactively,
but not when converted to PDF via 'soffice --convert-to pdf'.

The direct cause was that the interactive case also enabled the
navigator that did one more calculation for each fly, and that fixes the
layout. The headless export to PDF has no navigator, so that didn't
happen.

The root of the problem seems to be that:

1) There is a bad left position for the inner follow fly (it's outside
   the page rectangle).

2) SwTabFrame::Split() for the outer tab normally calls
   lcl_RecalcSplitLine() which moves flys away + back.

3) Moving away happens in lcl_InvalidateLowerObjs() in the
   _bMoveObjsOutOfRange case, here we move away both fly 10 and 20 (both
  inner flys).

4) Moving back happens in
   SwToContentAnchoredObjectPosition::CalcPosition(), but that's not
   invoked for the inner follow fly.

Fix the problem by extending SwObjectFormatter::FormatObjsAtFrame_() to
be more consistent here and move back both flys.

This is related to tdf#55160.

Change-Id: Ia264a828f36cf2bc1d67986ab3a97d57e9d167a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156691
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 797d5d8c5691..1c69606c8a24 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -1068,6 +1068,13 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNested)
 // rendered and this way the inner anchor had no fly portion, either.
 CPPUNIT_ASSERT_GREATER(pPage2->getFrameArea().Top(), 
pPage2Fly1->getFrameArea().Top());
 
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected less than: 12523
+// - Actual  : 15312
+// i.e. the inner follow fly was not "moved back" to its place to have the 
wanted 4400 position,
+// which makes the "Inner A2" text visible.
+CPPUNIT_ASSERT_LESS(pPage2->getFrameArea().Right(), 
pPage2Fly1->getFrameArea().Right());
+
 auto pPage2Fly2 = 
rPage2Objs[1]->DynCastFlyFrame()->DynCastFlyAtContentFrame();
 CPPUNIT_ASSERT(pPage2Fly2);
 CPPUNIT_ASSERT(!pPage2Fly2->GetAnchorFrameContainingAnchPos()->IsInFly());
diff --git a/sw/source/core/layout/objectformatter.cxx 
b/sw/source/core/layout/objectformatter.cxx
index 15ca544a2d9c..b99da6a0fe4b 100644
--- a/sw/source/core/layout/objectformatter.cxx
+++ b/sw/source/core/layout/objectformatter.cxx
@@ -390,7 +390,12 @@ bool SwObjectFormatter::FormatObjsAtFrame_( SwTextFrame* 
_pMasterTextFrame )
 pAnchorCharFrame != pAnchoredObj->GetAnchorFrame() &&
 pAnchorCharFrame->FindBodyFrame() ==
 
static_cast(pAnchoredObj->AnchorFrame())->FindBodyFrame();
-if ( bAnchoredAtFollowInSameBodyAsMaster )
+// Make sure that in case nested split flys are moved "out of range" in
+// lcl_InvalidateLowerObjs(), then we moved them back here.
+SwFlyFrame* pFly = pAnchoredObj->DynCastFlyFrame();
+bool bSplitFly = pFly && pFly->IsFlySplitAllowed();
+bool bNestedSplitFly = bSplitFly && pAnchorCharFrame && 
pAnchorCharFrame->IsInFly();
+if (bAnchoredAtFollowInSameBodyAsMaster && !bNestedSplitFly)
 {
 continue;
 }


[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-07 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/flycnt.cxx |8 
 sw/source/core/layout/tabfrm.cxx |4 +++-
 sw/source/core/text/txtfly.cxx   |   17 +
 3 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit 3aa3f0a1638a8d8006955b62bb647526768be3d8
Author: Miklos Vajna 
AuthorDate: Thu Sep 7 08:25:18 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Sep 7 09:57:40 2023 +0200

sw floattable, nesting: fix position of the inner follow table

The bugdoc was no longer crashing, but the inner table's follow part on
page 2 was not visible.

The problem was that lcl_ArrangeLowers() didn't try to update the fly's
position when the cell's position changed, now we do this for split
flys.

The other problem was that as SwTextFly::GetTop() is called by
SwTextFly::InitAnchoredObjList(), the inner flys were ignored while
collecting the intersecting fly frames for a paragraph, leading to an
overlap between the inner follow fly and the inner anchor text. This is
now fixed by explicitly checking for the splitfly-in-splitfly case.

With this, the ODT bugdoc now renders correctly when opened. (This is
related to tdf#55160.)

Change-Id: I60997e7913984872319250b0fb1cb91e02512800
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156632
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 0839e6a34b36..797d5d8c5691 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -1060,6 +1060,14 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNested)
 CPPUNIT_ASSERT(pPage2Fly1);
 CPPUNIT_ASSERT(pPage2Fly1->GetAnchorFrameContainingAnchPos()->IsInFly());
 CPPUNIT_ASSERT(pPage2Fly1->GetPrecede());
+
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected greater than: 6204
+// - Actual  : 1725
+// i.e. the inner follow fly had a bad position, it was outside the page 
rectangle, it was not
+// rendered and this way the inner anchor had no fly portion, either.
+CPPUNIT_ASSERT_GREATER(pPage2->getFrameArea().Top(), 
pPage2Fly1->getFrameArea().Top());
+
 auto pPage2Fly2 = 
rPage2Objs[1]->DynCastFlyFrame()->DynCastFlyAtContentFrame();
 CPPUNIT_ASSERT(pPage2Fly2);
 CPPUNIT_ASSERT(!pPage2Fly2->GetAnchorFrameContainingAnchPos()->IsInFly());
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 5b14113825e4..bbd7ebece6d8 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -5338,10 +5338,12 @@ static bool lcl_ArrangeLowers( SwLayoutFrame *pLay, 
tools::Long lYStart, bool bI
 // on the object positioning.
 // #i52904# - no direct move of objects,
 // whose vertical position doesn't depend on anchor 
frame.
+// Also move split flys directly, otherwise the 
follows would not be moved
+// at all.
 const bool bDirectMove =
 FAR_AWAY != pFly->getFrameArea().Top() &&
 bVertPosDepOnAnchor &&
-!pFly->ConsiderObjWrapInfluenceOnObjPos();
+(!pFly->ConsiderObjWrapInfluenceOnObjPos() || 
pFly->IsFlySplitAllowed());
 if ( bDirectMove )
 {
 {
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index e5bf03162db4..a290ac4d2010 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -679,6 +679,23 @@ bool SwTextFly::GetTop( const SwAnchoredObject* 
_pAnchoredObj,
 bool bEvade = !mpCurrAnchoredObj ||
   Is_Lower_Of( mpCurrAnchoredObj->DynCastFlyFrame(), 
pNew);
 
+auto pFly = _pAnchoredObj->DynCastFlyFrame();
+if (pFly && pFly->IsFlySplitAllowed())
+{
+// Check if _pAnchoredObj is a split fly inside an other split 
fly. Always collect such
+// flys, otherwise the inner anchor text will overlap with the 
inner fly.
+SwFrame* pFlyAnchor = const_cast(_pAnchoredObj)
+->GetAnchorFrameContainingAnchPos();
+if (pFlyAnchor && pFlyAnchor->IsInFly())
+{
+auto pOuterFly = pFlyAnchor->FindFlyFrame();
+if (pOuterFly && pOuterFly->IsFlySplitAllowed())
+{
+return true;
+}
+}
+}
+
 if ( !bEvade )
 {
 // We are currently inside a fly frame and pNew is not


[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-06 Thread László Németh (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf157011_ins_del_empty_cols.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport12.cxx  |   15 
++
 sw/source/core/table/swtable.cxx|   10 ++
 3 files changed, 25 insertions(+)

New commits:
commit 4697d2bda1b37f9cf8b301f5bf044c2390f56333
Author: László Németh 
AuthorDate: Wed Sep 6 18:01:28 2023 +0200
Commit: László Németh 
CommitDate: Wed Sep 6 20:33:16 2023 +0200

tdf#157011 sw tracked table column: fix DOCX import of empty cell

OOXML w:std elements are imported with 0x01 characters in text
content of tracked table columns (as a regression in LO 7.3?),
losing change tracking data. Fix this temporarily by completing
SwTableBox::IsEmpty() handling the bad 0x01 characters of the
imported tracked empty cells.

See also commit a483a44ca00f43a64ae51d62b8fbb4129a413f6d
"tdf#143215 DOCX import: fix tracked empty row insertion/deletion".

Change-Id: I4895754e540cca6ba2cb3442f24a8affcedd51fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156626
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf157011_ins_del_empty_cols.docx 
b/sw/qa/extras/ooxmlexport/data/tdf157011_ins_del_empty_cols.docx
new file mode 100644
index ..5ebb98fda0d7
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf157011_ins_del_empty_cols.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index e406d546aea6..e5a585f01d68 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -1323,6 +1323,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf150824, "tdf150824.fodt")
 }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf157011, "tdf157011_ins_del_empty_cols.docx")
+{
+// check tracked table column insertions and deletions with empty cells
+if (isExported())
+{
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+
+// This was 1 (missing tracked table cell insertions)
+assertXPath(pXmlDoc, "//w:ins", 3);
+
+// This was 4 (missing tracked table cell deletions)
+assertXPath(pXmlDoc, "//w:del", 6);
+}
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf150824_regression, "ooo30436-1-minimized.sxw")
 {
 // There should be no crash during loading of the document
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index f42b9ad95ce5..ca360e324081 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -2264,6 +2264,16 @@ bool SwTableBox::IsEmpty( bool bWithRemainingNestedTable 
) const
 const SwContentNode *pCNd = pFirstNode->GetContentNode();
 if ( pCNd && !pCNd->Len() )
 return true;
+
+// tdf#157011 OOXML w:std cell content is imported with terminating 
0x01 characters,
+// i.e. an empty box can contain double 0x01: handle it to avoid 
losing change tracking
+// FIXME regression since LibreOffice 7.3?
+if ( pCNd && pCNd->Len() == 2 && pCNd->GetTextNode() )
+{
+const OUString &rText = pCNd->GetTextNode()->GetText();
+if ( rText[0] == 0x01 && rText[1] == 0x01 )
+return true;
+}
 }
 else if ( bWithRemainingNestedTable )
 {


[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-06 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/floattable-nested.odt   |binary
 sw/qa/core/layout/flycnt.cxx   |   41 
++
 sw/source/core/layout/flycnt.cxx   |   21 -
 sw/source/core/layout/tabfrm.cxx   |   19 +++-
 sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx |4 
 5 files changed, 79 insertions(+), 6 deletions(-)

New commits:
commit d29c1a90ae77dde7c87c51f21e859fa254f23e01
Author: Miklos Vajna 
AuthorDate: Wed Sep 6 08:30:10 2023 +0200
Commit: Miklos Vajna 
CommitDate: Wed Sep 6 14:11:37 2023 +0200

sw floattable, nesting: fix layout crash

The manually created ODT bugdoc has a nested floating table. The outer
table is just 1 cell, the inner one has 2 rows: it's meant to span over
2 pages. This bugdoc currently crashes the layout.

In practice what happens is that the inner fly would split + move the
follow to the next page, so we hit a case where the inner fly is marked
to be "in table", but it won't have a table parent anymore, so the
layout crashes.

As a first step, fix the crash:

1) SwFrame::GetNextFlyLeaf() should only split the inner fly and its
   anchor (not move it), the move will happen with the split of the
   outer fly.

2) Fix SwToContentAnchoredObjectPosition::CalcPosition() to move the
   inner, follow fly down (it should not overlap with its master). This
   was not visible previously, as we manually moved the follow fly to the
   next page, but now we need a vertical cut position that is between the
   inner master and follow flys.

3) lcl_ArrangeLowers(), called by SwCellFrame::Format() now updates the
   position of follow flys, so exactly two master flys are on page 1 and
   two follow flys are on page 2.

This is related to tdf#55160, but it's not yet focusing on DOCX, where
nested floating tables are currently disabled at a filter level. Also,
this fixes the crash, but the position of the inner follow table still
needs fixing.

Change-Id: Ife42b64cda53946a8262ddabfd000803620c4ff1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156587
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-nested.odt 
b/sw/qa/core/layout/data/floattable-nested.odt
new file mode 100644
index ..3d21314f5871
Binary files /dev/null and b/sw/qa/core/layout/data/floattable-nested.odt differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 539d379d97c2..0839e6a34b36 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -1024,6 +1024,47 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyFromAsCharAnchor)
 // frame+table inside a footnote.
 dispatchCommand(mxComponent, ".uno:SetAnchorToPara", {});
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNested)
+{
+// Given a document with a nested, multi-page floating table:
+// When calculating the layout:
+createSwDoc("floattable-nested.odt");
+calcLayout();
+
+// Then make sure we don't crash:
+// Without the accompanying fix in place, this test would have crashed.
+// Check that we have exactly 4 fly frames, all of them on the expected 
pages: master outer,
+// follow outer, master inner and follow inner.
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+CPPUNIT_ASSERT(pPage1->GetSortedObjs());
+SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage1Objs.size());
+auto pPage1Fly1 = 
rPage1Objs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame();
+CPPUNIT_ASSERT(pPage1Fly1);
+CPPUNIT_ASSERT(pPage1Fly1->GetAnchorFrameContainingAnchPos()->IsInFly());
+CPPUNIT_ASSERT(pPage1Fly1->GetFollow());
+auto pPage1Fly2 = 
rPage1Objs[1]->DynCastFlyFrame()->DynCastFlyAtContentFrame();
+CPPUNIT_ASSERT(pPage1Fly2);
+CPPUNIT_ASSERT(!pPage1Fly2->GetAnchorFrameContainingAnchPos()->IsInFly());
+CPPUNIT_ASSERT(pPage1Fly2->GetFollow());
+auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage2);
+CPPUNIT_ASSERT(pPage2->GetSortedObjs());
+SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage2Objs.size());
+auto pPage2Fly1 = 
rPage2Objs[0]->DynCastFlyFrame()->DynCastFlyAtContentFrame();
+CPPUNIT_ASSERT(pPage2Fly1);
+CPPUNIT_ASSERT(pPage2Fly1->GetAnchorFrameContainingAnchPos()->IsInFly());
+CPPUNIT_ASSERT(pPage2Fly1->GetPrecede());
+auto pPage2Fly2 = 
rPage2Objs[1]->DynCastFlyFrame()->DynCastFlyAtContentFrame();
+CPPUNIT_ASSERT(pPage2Fly2);
+CPPUNIT_ASSERT(!pPage2Fly2->GetAnchorFrameContainingAnchPos()->IsInFly());
+CPPUNIT_ASSER

[Libreoffice-commits] core.git: sw/qa sw/source

2023-09-01 Thread Miklos Vajna (via logerrit)
 sw/qa/core/objectpositioning/data/floattable-vert-orient-top.odt   |binary
 sw/qa/core/objectpositioning/objectpositioning.cxx |   24 
++
 sw/source/core/inc/frame.hxx   |2 
 sw/source/core/layout/findfrm.cxx  |   10 
 sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx |5 +-
 5 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit 7d4213b9f0253b323750acceca8f4edb9d1a7fc5
Author: Miklos Vajna 
AuthorDate: Fri Sep 1 08:51:20 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri Sep 1 11:00:20 2023 +0200

Related: tdf#156318 sw floattable: fix handling of vert orient == top

The bugdoc resulted in a layout loop on load. It was created by forcing
pages to be in a single column + increasing the top+bottom margin of the
page to 2.5cm.

The problem was that the SwFormatVertOrient's m_eOrient is usually
text::VertOrientation::NONE ("from top" with 0 offset), but here it's
text::VertOrientation::TOP. These are meant to be more or less
equivalent, but SwToContentAnchoredObjectPosition::CalcPosition() has
different codepath for them.

Fix the problem by making sure that TOP doesn't have a vertical offset
for follow fly frame: do this by realizing that in case the "orient
frame" and the "anchor" is not the same that may need no action, since
the fly frame case changes the "orient" to the follow anchor and the
"anchor" is the master anchor.

The original scenario still needs more work, we don't hang anymore but
the follow fly appears on page 3 instead of page 2.

Change-Id: I1596a07b78575583070d494ddb8e1400e5653820
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156392
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/objectpositioning/data/floattable-vert-orient-top.odt 
b/sw/qa/core/objectpositioning/data/floattable-vert-orient-top.odt
new file mode 100644
index ..b10f0b7188fa
Binary files /dev/null and 
b/sw/qa/core/objectpositioning/data/floattable-vert-orient-top.odt differ
diff --git a/sw/qa/core/objectpositioning/objectpositioning.cxx 
b/sw/qa/core/objectpositioning/objectpositioning.cxx
index 4958b8b6deb4..611ce1294c22 100644
--- a/sw/qa/core/objectpositioning/objectpositioning.cxx
+++ b/sw/qa/core/objectpositioning/objectpositioning.cxx
@@ -313,6 +313,30 @@ CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, 
testFloatingTableOverlapNever)
 CPPUNIT_ASSERT_GREATER(pFlyFrame1->getFrameArea().Bottom(), 
pFlyFrame2->getFrameArea().Top());
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, 
testFloatingTableVertOrientTop)
+{
+// Given a document with a vert-orient=from-top anchored floating table:
+createSwDoc("floattable-vert-orient-top.odt");
+
+// When laying out that document:
+calcLayout();
+
+// Then make sure we correctly split the table to two pages:
+// Without the accompanying fix in place, this test would have produced a 
layout loop.
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = pLayout->Lower()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage1);
+CPPUNIT_ASSERT(pPage1->GetSortedObjs());
+const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size());
+auto pPage2 = pPage1->GetNext()->DynCastPageFrame();
+CPPUNIT_ASSERT(pPage2);
+CPPUNIT_ASSERT(pPage2->GetSortedObjs());
+const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index d405da36515b..d57654f6a9e7 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -874,6 +874,8 @@ public:
 inline bool IsTextFrame() const;
 SwTextFrame* DynCastTextFrame();
 const SwTextFrame* DynCastTextFrame() const;
+SwPageFrame* DynCastPageFrame();
+const SwPageFrame* DynCastPageFrame() const;
 inline bool IsNoTextFrame() const;
 // Frames where its PrtArea depends on their neighbors and that are
 // positioned in the content flow
diff --git a/sw/source/core/layout/findfrm.cxx 
b/sw/source/core/layout/findfrm.cxx
index 1a98f6cf6747..5331baacd93e 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -1944,4 +1944,14 @@ const SwTextFrame* SwFrame::DynCastTextFrame() const
 return IsTextFrame() ? static_cast(this) : nullptr;
 }
 
+SwPageFrame* SwFrame::DynCastPageFrame()
+{
+return IsPageFrame() ? static_cast(this) : nullptr;
+}
+
+const SwPageFrame* SwFrame::DynCastPageFrame() const
+{
+return IsPageFrame() ? static_cast(this) : nullptr;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 exp

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-30 Thread Miklos Vajna (via logerrit)
 sw/qa/uibase/shells/textsh.cxx  |   46 
 sw/source/uibase/shells/textsh1.cxx |   15 ++-
 2 files changed, 60 insertions(+), 1 deletion(-)

New commits:
commit 739597df38dcaab0460482e3bc3f18f2471d43ab
Author: Miklos Vajna 
AuthorDate: Wed Aug 30 08:59:44 2023 +0200
Commit: Miklos Vajna 
CommitDate: Wed Aug 30 11:53:10 2023 +0200

tdf#77760 sw floattable: add support for footnotes, UI

Import filters could already create footnotes in floating tables, allow
the same from the UI.

Use IsFlySplitAllowed() as the check, because that already knows
rejecting special anchor locations like footnotes/headers/footers in
addition to actually decide if this is a split fly or not.

Change-Id: Ib9bab7b29d1bea0c15f3d829d16c9edbf1455b6b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156275
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/uibase/shells/textsh.cxx b/sw/qa/uibase/shells/textsh.cxx
index a97fc8bd7f5f..f4c63ad5e8d8 100644
--- a/sw/qa/uibase/shells/textsh.cxx
+++ b/sw/qa/uibase/shells/textsh.cxx
@@ -12,8 +12,16 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 namespace
 {
@@ -59,6 +67,44 @@ CPPUNIT_TEST_FIXTURE(Test, testDeleteSections)
 // i.e. the section was not deleted.
 CPPUNIT_ASSERT_EQUAL(static_cast(0), pDoc->GetSections().size());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyFootnoteUI)
+{
+// Given a document with a split fly (to host a table):
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr);
+RndStdIds eAnchor = RndStdIds::FLY_AT_PARA;
+pWrtShell->StartAllAction();
+aMgr.InsertFlyFrame(eAnchor, aMgr.GetPos(), aMgr.GetSize());
+pWrtShell->EndAllAction();
+pWrtShell->StartAllAction();
+sw::FrameFormats& rFlys = *pDoc->GetSpzFrameFormats();
+sw::SpzFrameFormat* pFly = rFlys[0];
+{
+SwAttrSet aSet(pFly->GetAttrSet());
+aSet.Put(SwFormatFlySplit(true));
+pDoc->SetAttr(aSet, *pFly);
+}
+pWrtShell->EndAllAction();
+pWrtShell->UnSelectFrame();
+pWrtShell->LeaveSelFrameMode();
+pWrtShell->GetView().AttrChangedNotify(nullptr);
+pWrtShell->MoveSection(GoCurrSection, fnSectionEnd);
+
+// When checking if we can insert a footnote inside the split fly:
+SwView& rView = pWrtShell->GetView();
+std::unique_ptr pItem;
+SfxItemState eState = 
rView.GetViewFrame().GetBindings().QueryState(FN_INSERT_FOOTNOTE, pItem);
+
+// Then make sure that the insertion is allowed:
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 32 (DEFAULT)
+// - Actual  : 1 (DISABLED)
+// i.e. the insertion was denied.
+CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, eState);
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index abf5caee862d..5ba3d0a25c32 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -118,6 +118,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 using namespace ::com::sun::star;
 using namespace com::sun::star::beans;
@@ -2278,7 +2280,18 @@ void SwTextShell::GetState( SfxItemSet &rSet )
 {
 const FrameTypeFlags nNoType =
 FrameTypeFlags::FLY_ANY | FrameTypeFlags::HEADER | 
FrameTypeFlags::FOOTER | FrameTypeFlags::FOOTNOTE;
-if ( rSh.GetFrameType(nullptr,true) & nNoType )
+FrameTypeFlags eType = rSh.GetFrameType(nullptr, true);
+bool bSplitFly = false;
+if (eType & FrameTypeFlags::FLY_ATCNT)
+{
+SwContentFrame* pContentFrame = 
rSh.GetCurrFrame(/*bCalcFrame=*/false);
+if (pContentFrame)
+{
+SwFlyFrame* pFlyFrame = pContentFrame->FindFlyFrame();
+bSplitFly = pFlyFrame && 
pFlyFrame->IsFlySplitAllowed();
+}
+}
+if (eType & nNoType && !bSplitFly)
 rSet.DisableItem(nWhich);
 
 if ( rSh.CursorInsideInputField() )


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-28 Thread Michael Stahl (via logerrit)
 sw/qa/extras/layout/data/tdf155177-1-min.odt |binary
 sw/qa/extras/layout/layout3.cxx  |   57 +++
 sw/source/core/text/txtfrm.cxx   |   23 --
 sw/source/core/text/widorp.cxx   |   44 ++--
 sw/source/core/text/widorp.hxx   |6 ++
 5 files changed, 94 insertions(+), 36 deletions(-)

New commits:
commit fe89122c15744afcaccaa6d6628fa0436adf12e1
Author: Michael Stahl 
AuthorDate: Fri Aug 25 14:20:34 2023 +0200
Commit: Michael Stahl 
CommitDate: Mon Aug 28 13:46:23 2023 +0200

tdf#155177 sw: fix 2-line bug in WidowsAndOrphans::WouldFit()

The problem is that the check if the line contains a non-fly portion
was only done in the loop, but the first line is already handled before
the loop, so its non-fly portions are ignored and never less than 2
lines are moved, regardless of widow/orphan settings.

(regression from commit 8c32cc17ce914188ea6783b0f79e19c5ddbf0b8d)

Change-Id: Ic017a17233fcd58e22d54386650328f00fb3e9f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156121
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/layout/data/tdf155177-1-min.odt 
b/sw/qa/extras/layout/data/tdf155177-1-min.odt
new file mode 100644
index ..68363860f05d
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf155177-1-min.odt differ
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 60da1bcbd9af..b390e6e38b9c 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -253,6 +253,63 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf120287c)
 assertXPath(pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout", 
3);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf155177)
+{
+createSwDoc("tdf155177-1-min.odt");
+
+uno::Reference 
xStyle(getStyles("ParagraphStyles")->getByName("Body Text"),
+   uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(210), getProperty(xStyle, 
"ParaTopMargin"));
+
+{
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[2]/body/txt", 6);
+assertXPath(pXmlDoc, 
"/root/page[2]/body/txt[6]/SwParaPortion/SwLineLayout", 2);
+assertXPath(pXmlDoc, 
"/root/page[2]/body/txt[6]/SwParaPortion/SwLineLayout[2]", "portion",
+"long as two lines.");
+assertXPath(pXmlDoc, 
"/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout", 3);
+assertXPath(pXmlDoc, 
"/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion",
+"This paragraph is even longer so that ");
+discardDumpedLayout();
+}
+
+// this should bring one line back
+xStyle->setPropertyValue("ParaTopMargin", uno::Any(sal_Int32(200)));
+
+Scheduler::ProcessEventsToIdle();
+
+{
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[2]/body/txt", 7);
+assertXPath(pXmlDoc, 
"/root/page[2]/body/txt[7]/SwParaPortion/SwLineLayout", 1);
+assertXPath(pXmlDoc, 
"/root/page[2]/body/txt[7]/SwParaPortion/SwLineLayout[1]", "portion",
+"This paragraph is even longer so that ");
+assertXPath(pXmlDoc, 
"/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout", 2);
+assertXPath(pXmlDoc, 
"/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion",
+"it is now three lines long though ");
+discardDumpedLayout();
+}
+
+// this should bring second line back
+xStyle->setPropertyValue("ParaTopMargin", uno::Any(sal_Int32(120)));
+
+Scheduler::ProcessEventsToIdle();
+
+{
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[2]/body/txt", 7);
+assertXPath(pXmlDoc, 
"/root/page[2]/body/txt[7]/SwParaPortion/SwLineLayout", 2);
+assertXPath(pXmlDoc, 
"/root/page[2]/body/txt[7]/SwParaPortion/SwLineLayout[1]", "portion",
+"This paragraph is even longer so that ");
+assertXPath(pXmlDoc, 
"/root/page[2]/body/txt[7]/SwParaPortion/SwLineLayout[2]", "portion",
+"it is now three lines long though ");
+assertXPath(pXmlDoc, 
"/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout", 1);
+assertXPath(pXmlDoc, 
"/root/page[3]/body/txt[1]/SwParaPortion/SwLineLayout[1]", "portion",
+"containing a single sentence.");
+discardDumpedLayout();
+}
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf122878)
 {
 createSwDoc("tdf122878.docx");
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index f4b90547173f..a86dfcaf175f 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -3882,28 +3882,7 @@ sal_uInt16 SwTextFrame::FirstLineHeight() const
 for (SwLineLayout const* pLine = pPara; p

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-26 Thread László Németh (via logerrit)
 sw/qa/uitest/writer_tests7/tdf156784.py |   38 
 sw/source/core/crsr/crsrsh.cxx  |9 +++
 sw/source/core/frmedt/fetab.cxx |3 +-
 3 files changed, 49 insertions(+), 1 deletion(-)

New commits:
commit e16e84c44fc7517529c8a183fbd8f97c0c3e380e
Author: László Németh 
AuthorDate: Thu Aug 24 16:27:16 2023 +0200
Commit: László Németh 
CommitDate: Sun Aug 27 01:20:27 2023 +0200

tdf#156784 sw tracked table column: fix crash at Select All

Section starting table with hidden deleted first column
freezed at Select All, resulting crash because of infinite
recursion during waiting frame creation of a hidden cell
without frame in Hide Changes mode.

Regression from commit d1004cdd6a445ae73673b0ca360ae034b0ec09f2
"tdf#150673 sw offapi: add change tracking of table column deletion".

Change-Id: I15d9fa0138261d7a95c6e34a8d07fb2e001d0c7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156056
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/uitest/writer_tests7/tdf156784.py 
b/sw/qa/uitest/writer_tests7/tdf156784.py
new file mode 100644
index ..5cac8fc628db
--- /dev/null
+++ b/sw/qa/uitest/writer_tests7/tdf156784.py
@@ -0,0 +1,38 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_url_for_data_file
+
+# Bug 156784 - crash fix: Select All in section starting table with hidden 
first column
+
+class tdf156784(UITestCase):
+def test_tdf156784(self):
+with 
self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as 
self.document:
+
+xToolkit = 
self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+
+# accept all tracked changes
+self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges")
+
+# delete first column
+self.xUITest.executeCommand(".uno:DeleteColumns")
+
+# hide changes
+self.xUITest.executeCommand(".uno:ShowTrackedChanges")
+
+# select cell content
+self.xUITest.executeCommand(".uno:SelectAll")
+
+# This resulted crashing (select section starting table with 
hidden first column)
+self.xUITest.executeCommand(".uno:SelectAll")
+
+# show changes
+self.xUITest.executeCommand(".uno:ShowTrackedChanges")
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index f22e0bc9450a..4d69e2a6d705 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -77,6 +77,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace com::sun::star;
 using namespace util;
@@ -2168,6 +2169,14 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, 
bool bIdleEnd )
 // created, because there used to be a Frame here!
 if ( !pFrame )
 {
+// skip, if it is a hidden deleted cell without frame
+if ( GetLayout()->IsHideRedlines() )
+{
+const SwStartNode* pNd = 
pShellCursor->GetPointNode().FindTableBoxStartNode();
+if ( pNd && pNd->GetTableBox()->GetRedlineType() == 
RedlineType::Delete )
+return;
+}
+
 do
 {
 CalcLayout();
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index dced56c1f2a0..59b031ce772a 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -1175,7 +1175,8 @@ bool SwFEShell::CanUnProtectCells() const
 {
 SwFrame *pFrame = GetCurrFrame();
 do {
-pFrame = pFrame->GetUpper();
+if ( pFrame )
+pFrame = pFrame->GetUpper();
 } while ( pFrame && !pFrame->IsCellFrame() );
 if( pFrame )
 {


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-25 Thread Miklos Vajna (via logerrit)
 sw/qa/filter/ww8/data/floattable-footnote.doc |binary
 sw/qa/filter/ww8/ww8.cxx  |   18 +
 sw/source/filter/ww8/ww8par2.cxx  |   34 ++
 3 files changed, 48 insertions(+), 4 deletions(-)

New commits:
commit c7b59c9484ae6ff88cd8d7017aeb83b02e212c9c
Author: Miklos Vajna 
AuthorDate: Fri Aug 25 08:31:08 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri Aug 25 17:19:52 2023 +0200

tdf#77760 sw floattable: add support for footnotes, DOC import

This is similar to commit 178421a6c719dac9c16f220b76292fec16a53f60
(tdf#77760 sw floattable: add support for footnotes, DOCX import,
2023-08-24), the problematic part was to reject everything that is not
in the body text, relax that to allow insertion into split flys.

Do an early check to see if we'll insert into the fly/header/footer
section, because otherwise it would be pointless to call
SwNode::GetFlyFormat(), which can be expensive in case we don't have a
layout yet.

The DOC export, the RTF import and the RTF export was working already,
so filters are mostly covered with this.

Change-Id: I59c69fac0692c6656c054e32503ec0cbc2fd11e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156083
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/filter/ww8/data/floattable-footnote.doc 
b/sw/qa/filter/ww8/data/floattable-footnote.doc
new file mode 100644
index ..c99bc13f43f2
Binary files /dev/null and b/sw/qa/filter/ww8/data/floattable-footnote.doc 
differ
diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx
index db1dbcd1bf36..14cde1758588 100644
--- a/sw/qa/filter/ww8/ww8.cxx
+++ b/sw/qa/filter/ww8/ww8.cxx
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace
 {
@@ -470,6 +471,23 @@ CPPUNIT_TEST_FIXTURE(Test, 
testFloattableOverlapNeverDOCImport)
 // "can overlap".
 
CPPUNIT_ASSERT(!pFly->GetAttrSet().GetWrapInfluenceOnObjPos().GetAllowOverlap());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testFloattableFootnote)
+{
+// Given a document with a floating table and a footnote inside:
+// When importing that document:
+createSwDoc("floattable-footnote.doc");
+
+// Then make sure we both have a fly frame and a footnote:
+SwDoc* pDoc = getSwDoc();
+sw::FrameFormats& rFlys = *pDoc->GetSpzFrameFormats();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rFlys.size());
+SwFootnoteIdxs& rFootnotes = pDoc->GetFootnoteIdxs();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 0
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rFootnotes.size());
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index a461b465ed72..6c18f5a9ce08 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -58,6 +58,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "sprmids.hxx"
 #include 
@@ -167,14 +168,38 @@ sal_uInt32 wwSectionManager::GetWWPageTopMargin() const
 return !maSegments.empty() ? maSegments.back().maSep.dyaTop : 0;
 }
 
+namespace
+{
+bool IsInSplitFly(SwPaM& rPaM)
+{
+SwNode& rNode = rPaM.GetPoint()->GetNode();
+SwNodeOffset nNodeIndex = rNode.GetIndex();
+SwNodes& rNodes = rNode.GetNodes();
+if (nNodeIndex >= rNodes.GetEndOfAutotext().GetIndex()
+|| nNodeIndex < rNodes.GetEndOfInserts().GetIndex())
+{
+return false;
+}
+
+SwFrameFormat* pFlyFormat = rNode.StartOfSectionNode()->GetFlyFormat();
+if (!pFlyFormat)
+{
+return false;
+}
+
+return pFlyFormat->GetFlySplit().GetValue();
+}
+}
+
 sal_uInt16 SwWW8ImplReader::End_Footnote()
 {
 /*
 Ignoring Footnote outside of the normal Text. People will put footnotes
 into field results and field commands.
 */
-if (m_bIgnoreText ||
-m_pPaM->GetPoint()->GetNode() < m_rDoc.GetNodes().GetEndOfExtras())
+bool bSplitFly = IsInSplitFly(*m_pPaM);
+if (m_bIgnoreText
+|| (m_pPaM->GetPoint()->GetNode() < m_rDoc.GetNodes().GetEndOfExtras() 
&& !bSplitFly))
 {
 return 0;
 }
@@ -303,8 +328,9 @@ tools::Long 
SwWW8ImplReader::Read_Footnote(WW8PLCFManResult* pRes)
 Ignoring Footnote outside of the normal Text. People will put footnotes
 into field results and field commands.
 */
-if (m_bIgnoreText ||
-m_pPaM->GetPoint()->GetNode() < m_rDoc.GetNodes().GetEndOfExtras())
+bool bSplitFly = IsInSplitFly(*m_pPaM);
+if (m_bIgnoreText
+|| (m_pPaM->GetPoint()->GetNode() < m_rDoc.GetNodes().GetEndOfExtras() 
&& !bSplitFly))
 {
 return 0;
 }


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-24 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/table-in-footnote.docx |binary
 sw/qa/core/layout/flycnt.cxx  |   14 ++
 sw/source/core/layout/fly.cxx |6 ++
 3 files changed, 20 insertions(+)

New commits:
commit 2e1ddc8aeb0a92cc43ef4b7dc4762cd50a6b7fbc
Author: Miklos Vajna 
AuthorDate: Thu Aug 24 16:58:14 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Aug 24 19:40:11 2023 +0200

sw floattable: don't split if anchored inside a footnote

See

,
if we import an (inline) table inside a footnote from DOCX, we currently
put that into an as-char anchored fly. In case the user would later
change the anchor type to to-para, then we would crash in
SwFlowFrame::GetPrevFrameForUpperSpaceCalc_().

Avoid all this trouble by simply not allowing split floating tables in
footnotes, seeing that the Word UI is also disabled for this case.

Change-Id: I3cf9461beb291084e1cced5c66ca14e6b6d55126
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156058
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/table-in-footnote.docx 
b/sw/qa/core/layout/data/table-in-footnote.docx
new file mode 100644
index ..10e20ffbf44c
Binary files /dev/null and b/sw/qa/core/layout/data/table-in-footnote.docx 
differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index ba688728743b..539d379d97c2 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -1010,6 +1010,20 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyIntoTable)
 // second part of a floating table into a table on the next page, not 
before that table.
 calcLayout();
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyFromAsCharAnchor)
+{
+// Given a document with a footnote that has a table (imported in an 
as-char anchored frame in
+// Writer):
+createSwDoc("table-in-footnote.docx");
+
+// When changing the anchor type of that frame to to-para:
+// Then make sure we don't crash:
+selectShape(1);
+// Without the accompanying fix in place, this test would have crashed, we 
tried to split a
+// frame+table inside a footnote.
+dispatchCommand(mxComponent, ".uno:SetAnchorToPara", {});
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index a06c2a9e7f70..039aeb549f77 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -687,6 +687,12 @@ bool SwFlyFrame::IsFlySplitAllowed() const
 return false;
 }
 
+if (pFlyAnchor && pFlyAnchor->IsInFootnote())
+{
+// No split in footnotes.
+return false;
+}
+
 const SwFlyFrameFormat* pFormat = GetFormat();
 const SwFormatVertOrient& rVertOrient = pFormat->GetVertOrient();
 if (rVertOrient.GetVertOrient() == text::VertOrientation::BOTTOM)


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-22 Thread Michael Stahl (via logerrit)
 sw/qa/extras/layout/data/tdf137523-1-min.fodt |  319 ++
 sw/qa/extras/layout/layout3.cxx   |   12 
 sw/source/core/layout/layact.cxx  |6 
 3 files changed, 336 insertions(+), 1 deletion(-)

New commits:
commit 027f8328eef1e149b6c99b478ed5df870291dc2d
Author: Michael Stahl 
AuthorDate: Mon Aug 21 19:21:34 2023 +0200
Commit: Michael Stahl 
CommitDate: Tue Aug 22 11:26:45 2023 +0200

tdf#137523 sw: layout: fix text below tables in footer

In the footer, the text frames below a table have a very small height
and are effectively invisible.

This is because the JoinLock in SwLayAction::FormatLayoutTab() causes
SwTabFrame::MakeAll() to return early, which is called for every cell
frame in the table, and which would move the table up the page in
MakePos(), by calling SwHeadFootFrame::Format().

(regression from commit cc5916cd314a27b0cc99560ab887480026630a95)

Change-Id: I4add9fdd73ad3756000969af20ebf758025a0ada
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155902
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/layout/data/tdf137523-1-min.fodt 
b/sw/qa/extras/layout/data/tdf137523-1-min.fodt
new file mode 100644
index ..cbe85c9fbb82
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf137523-1-min.fodt
@@ -0,0 +1,319 @@
+
+http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:c
 alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:
 meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ 
2020-10-16T11:14:14.930082474LibreOfficeDev/24.2.0.0.alpha0$Linux_X86_64
 
LibreOffice_project/53ef297ff9342db2a32da0dd0e8e2f858a3624eeuser_manualP0D1Release 3.0.32020-10-181Train Backbone NodeT
 est Report
+ 
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+ 
+  
+   
+   
+
+   
+   
+  
+  
+   
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+
+ 
+
+   
+   
+  
+  
+   
+   
+  
+  
+  
+   
+  
+  
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+  
+  
+  
+  
+  
+   
+   /
+   
+   /
+   
+  
+  
+   
+
+
+
+
+
+
+
+
+
+
+
+
+   
+  
+ 
+ 
+  
+   
+
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+
+   
+  
+  
+   
+   
+  
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+   
+
+   
+  
+  
+   
+   
+  
+  
+   
+   
+  
+  
+   
+   
+  
+  
+   
+   
+  
+  
+   
+   
+  
+  
+   
+   
+  
+  
+   
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+
+
+   
+   
+   
+
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+ 

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-21 Thread Hossein (via logerrit)
 sw/qa/extras/ooxmlexport/data/numbers-rtl.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx   |9 +
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx  |2 +-
 sw/source/filter/ww8/docxattributeoutput.cxx   |3 +++
 4 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit 40ed8dd3a5a16f21f2e98440c62efa0fa6ec60ff
Author: Hossein 
AuthorDate: Tue Aug 15 14:56:53 2023 +0200
Commit: Hossein 
CommitDate: Mon Aug 21 14:26:51 2023 +0200

tdf#155470 DOCX export: fix RTL numbers changed to LTR

When using numerals in "context" mode in "Tools > Options", in
"Language Settings > Complext Text Layout > General Options > Numerals",
the actual display of the numbers is dependant on the direction and
the language of those numbers.

Previously, when exporting the DOCX in LO the RTL direction was lost,
and because of that, the numerals were shown incorrectly after saving
in LibreOffice, and loading again.

This patch adds  where  contains an RTL language.
For example, before  inside , it always
adds .

It is worth noting that this is not always the case, as there are
situations that  is not present in  with an RTL language
like  and  should not be in the output.
This patch does not handle that case, because currently loading such a
text is not done correctly in LO, and the LTR numbers inside RTL
environment are shown just like RTL numbers. To fix it, first loading
and displaying of that should be fixed.

A test is added to check the export of the sample file, which can be
invoked with:

 make CppunitTest_sw_ooxmlexport CPPUNIT_TEST_NAME=testTdf155470

Change-Id: I8fc54916fcd3295010c5c81ccb632bc6082ffaa2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155721
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/sw/qa/extras/ooxmlexport/data/numbers-rtl.docx 
b/sw/qa/extras/ooxmlexport/data/numbers-rtl.docx
new file mode 100755
index ..2142967a3619
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/numbers-rtl.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index cbca150319b7..60e097925829 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1106,6 +1106,15 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf115094v3)
 assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblpPr", "tblpY", 
"1064");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf155470)
+{
+loadAndSave("numbers-rtl.docx");
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+
+// Make sure that  is preserved
+assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:rtl");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index db2abe3513a7..9458051ea6d3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -174,7 +174,7 @@ CPPUNIT_TEST_FIXTURE(Test, testStyleInheritance)
 
 // We output exactly 2 properties in rPrDefault, nothing else was
 // introduced as an additional default
-assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/*", 2);
+assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/*", 3);
 // Check that we output real content of rPrDefault
 assertXPath(pXmlStyles, 
"/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "ascii", "Times New 
Roman");
 assertXPath(pXmlStyles, 
"/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:lang", "bidi", "ar-SA");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index df29dd801e08..c2a55ff8bfc7 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -160,6 +160,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using ::editeng::SvxBorderLine;
 
@@ -7916,6 +7917,8 @@ void DocxAttributeOutput::CharLanguage( const 
SvxLanguageItem& rLanguage )
 AddToAttrList( m_pCharLangAttrList, FSNS( XML_w, XML_eastAsia ), 
aLanguageCode );
 break;
 case RES_CHRATR_CTL_LANGUAGE:
+if (MsLangId::isRightToLeft(rLanguage.GetLanguage()))
+m_pSerializer->singleElementNS(XML_w, XML_rtl);
 AddToAttrList( m_pCharLangAttrList, FSNS( XML_w, XML_bidi ), 
aLanguageCode );
 break;
 }


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-21 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/paintfrm.cxx |   10 ++--
 sw/source/core/layout/paintfrm.cxx |   80 -
 2 files changed, 85 insertions(+), 5 deletions(-)

New commits:
commit 08aea5526c75ff4c5385e960bd940f10ffa19cd5
Author: Miklos Vajna 
AuthorDate: Mon Aug 21 08:33:14 2023 +0200
Commit: Miklos Vajna 
CommitDate: Mon Aug 21 09:36:32 2023 +0200

tdf#156351 sw floattable: fix missing bottom border in master table

The problem was that the bugdoc has a split floating table, and the
bottom of the table on the first page was missing its border. The
borders on the second page were correct.

This happens because the cell itself has no bottom border and the layout
did not extra effort to mirror the top table margin at the buttom, like
Word does.

Fix the problem similar to commit
53798fef2cc0b5b0b9706081a4af5ceca964a41b (Related: tdf#156351 sw
floattable: fix missing top border in follow table, 2023-08-18), so we
add a bottom border for master tables at a layout level, similar how a
top border was already added for follow tables.

Given that this kind of worked already in the past (just top borders,
just the 1 row case), do this unconditionally; but if needed this could
be limited to the "Word table cell" case.

Change-Id: Iafdcd90226fdc425be597d36ad97fb69dca5a89a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155884
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/paintfrm.cxx b/sw/qa/core/layout/paintfrm.cxx
index 15b9df6a4fb4..2416c6b95f8c 100644
--- a/sw/qa/core/layout/paintfrm.cxx
+++ b/sw/qa/core/layout/paintfrm.cxx
@@ -36,7 +36,8 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitTableBorder)
 // When rendering that document:
 std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile();
 
-// Then make sure that the follow table has a top border:
+// Then make sure that the master table has a bottom border and the follow 
table has a top
+// border:
 MetafileXmlDump aDumper;
 xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile);
 xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, 
"//polyline[@style='solid']/point");
@@ -61,10 +62,11 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitTableBorder)
 }
 xmlXPathFreeObject(pXmlObj);
 // Without the accompanying fix in place, this test would have failed with:
-// - Expected: 3
+// - Expected: 4
 // - Actual  : 2
-// i.e. the top border in the follow table was missing.
-CPPUNIT_ASSERT_EQUAL(3, nHorizontalBorders);
+// i.e. the bottom border in the master table and the top border in the 
follow table were
+// missing.
+CPPUNIT_ASSERT_EQUAL(4, nHorizontalBorders);
 }
 }
 
diff --git a/sw/source/core/layout/paintfrm.cxx 
b/sw/source/core/layout/paintfrm.cxx
index 51dabd080b01..cf9edb359c98 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2400,6 +2400,9 @@ class SwTabFramePainter
 void InsertFollowTopBorder(const SwFrame& rFrame, const SvxBoxItem& 
rBoxItem,
bool bWordTableCell, SwTwips nTop, SwTwips 
nLeft, SwTwips nRight,
bool bTopIsOuter);
+void InsertMasterBottomBorder(const SwFrame& rFrame, const SvxBoxItem& 
rBoxItem,
+  bool bWordTableCell, SwTwips nBottom, 
SwTwips nLeft, SwTwips nRight,
+  bool bBottomIsOuter);
 
 void HandleFrame(const SwLayoutFrame& rFrame, const SwRect& rPaintArea);
 void FindStylesForLine( Point&,
@@ -2894,7 +2897,7 @@ void SwTabFramePainter::InsertFollowTopBorder(const 
SwFrame& rFrame, const SvxBo
 
 // This is then a first row in a follow table, without repeated headlines.
 auto pLastRow = dynamic_cast(mrTabFrame.GetLastLower());
-if (!pLastRow && pLastRow == pThisRow)
+if (!pLastRow || pLastRow == pThisRow)
 {
 return;
 }
@@ -2930,6 +2933,79 @@ void SwTabFramePainter::InsertFollowTopBorder(const 
SwFrame& rFrame, const SvxBo
 Insert(aFollowTop, true);
 }
 
+void SwTabFramePainter::InsertMasterBottomBorder(const SwFrame& rFrame, const 
SvxBoxItem& rBoxItem,
+  bool bWordTableCell, SwTwips 
nBottom, SwTwips nLeft,
+  SwTwips nRight, bool 
bBottomIsOuter)
+{
+// Figure out which cell to copy.
+int nCol = 0;
+const SwFrame* pCell = &rFrame;
+while (pCell)
+{
+if (!pCell->GetPrev())
+{
+break;
+}
+
+++nCol;
+pCell = pCell->GetPrev();
+}
+
+auto pThisRow = dynamic_cast(rFrame.GetUpper());
+if (!pThisRow || pThisRow->GetUpper() != &mrTabFrame)
+{
+return;
+}
+
+if (mrTabFrame.IsFollow() || !mrTabFrame.GetFollow())
+{
+return;
+}
+
+// This is a master table that is split.
+if (pThisRow->GetNex

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-19 Thread Justin Luth (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf148834_lineNumbering.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx|4 +
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx|   13 +
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx |7 ++
 sw/source/filter/ww8/attributeoutputbase.hxx  |1 
 sw/source/filter/ww8/docxattributeoutput.cxx  |2 
 sw/source/filter/ww8/ww8atr.cxx   |   36 +-
 7 files changed, 62 insertions(+), 1 deletion(-)

New commits:
commit 91358f11ee7e87c8c8290b9507f64d8f90aac3ea
Author: Justin Luth 
AuthorDate: Fri Aug 18 21:55:12 2023 -0400
Commit: Justin Luth 
CommitDate: Sun Aug 20 03:34:41 2023 +0200

tdf#148834 docxexport: also write suppressLineNumbers = false

This code also affects DOC export,
but shouldn't be detrimental.
It just means that some unnecessary sprms
will not be added to DOC files.

RTF - similar to old DOCX - only outputs if !IsCount,
but I didn't find a corresponding "enable" to offset \noline.

make CppunitTest_sw_ooxmlexport18 \
CPPUNIT_TEST_NAME=testTdf148834_lineNumbering

Change-Id: Ib5369c2f2c24f75dab7d02e3591a4ddefa335ebf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155858
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf148834_lineNumbering.odt 
b/sw/qa/extras/ooxmlexport/data/tdf148834_lineNumbering.odt
new file mode 100644
index ..4006cfe66239
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf148834_lineNumbering.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 67fba9e9b114..eb26ce7763b8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1145,6 +1145,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf128290)
 xmlDocUniquePtr pXml = parseExport("word/document.xml");
 CPPUNIT_ASSERT(pXml);
 assertXPath(pXml, "/w:document/w:body/w:tbl/w:tblPr/w:tblLayout", "type", 
"fixed");
+
+// ensure unnecessary suppressLineNumbers entry is not created.
+xmlDocUniquePtr pStylesXml = parseExport("word/styles.xml");
+assertXPath(pStylesXml, 
"//w:style[@w:styleId='Normal']/w:pPr/w:suppressLineNumbers", 0);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf120394, "tdf120394.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 4d1136f24c42..6835a06d5ff4 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -516,6 +516,19 @@ 
DECLARE_OOXMLEXPORT_TEST(testTdf153964_firstIndentAfterBreak14, "tdf153964_first
 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xPara, 
"ParaFirstLineIndent"));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf148834_lineNumbering)
+{
+loadAndSave("tdf148834_lineNumbering.odt");
+
+xmlDocUniquePtr pStylesXml = parseExport("word/styles.xml");
+// user specified: do not include in line numbering
+assertXPath(pStylesXml, 
"//w:style[@w:styleId='Normal']/w:pPr/w:suppressLineNumbers", 1);
+// even though it matches the parent style, these should always avoid 
showing line numberings
+assertXPath(pStylesXml, 
"//w:style[@w:styleId='Footer']/w:pPr/w:suppressLineNumbers", 1);
+assertXPath(pStylesXml,
+
"//w:style[@w:styleId='0NUMBERED']/w:pPr/w:suppressLineNumbers", "val", "0");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf76022_textboxWrap)
 {
 // Granted, this is an ODT with a bit of an anomaly - tables ignore fly 
wrapping.
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index 607feea76ac7..05559dc49e18 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -882,6 +882,13 @@ DECLARE_OOXMLEXPORT_TEST(testFdo66543, "fdo66543.docx")
 uno::Reference< text::XTextRange > paragraph1 = getParagraph( 1 );
 CPPUNIT_ASSERT_EQUAL(sal_Int32(2),
  getProperty(paragraph1, 
"ParaLineNumberStartValue"));
+
+if (!isExported())
+return;
+
+// ensure unnecessary suppressLineNumbers entry is not created.
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+assertXPath(pXmlDoc, "//w:p[1]/w:pPr/w:suppressLineNumbers", 0);
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testN822175)
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx 
b/sw/source/filter/ww8/attributeoutputbase.hxx
index d5d92924ba9c..bad43d37843a 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -618,6 +618,7 @@ protected:
 virtual void FormatTextGrid( const SwTextGridItem& ) = 0;
 
 /// Sfx item RES_LINENUMBER
+void FormatLineNumberingBase(const SwFormatLineNumber&);
 virtual void FormatLineNumbering( const SwFormatLineNumber& ) = 0;
 
 /// Sfx it

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-18 Thread Michael Stahl (via logerrit)
 sw/qa/extras/layout/data/linked_frames_section_bug.odt |binary
 sw/qa/extras/layout/layout3.cxx|   18 +
 sw/source/core/layout/sectfrm.cxx  |1 
 3 files changed, 19 insertions(+)

New commits:
commit 987fe1175de2db53235cc6f2441335fcc3548d64
Author: Michael Stahl 
AuthorDate: Fri Aug 18 16:44:16 2023 +0200
Commit: Michael Stahl 
CommitDate: Fri Aug 18 18:55:57 2023 +0200

tdf#156419 sw: layout: don't prevent moving between linked flys

... when there is a page break on the next page.

Of course you can put a section into a fly, and then link multiple flys.

(regression from commit 325fe7ab507fd8f2ca17a3db32181edf30169525)

Change-Id: I5cb854fc7ee5caa2af4e04f4da2d8a8083c0d007
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155842
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/layout/data/linked_frames_section_bug.odt 
b/sw/qa/extras/layout/data/linked_frames_section_bug.odt
new file mode 100644
index ..639332ad5516
Binary files /dev/null and 
b/sw/qa/extras/layout/data/linked_frames_section_bug.odt differ
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 9c75ff31a322..4ddb46b025b9 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -1228,6 +1228,24 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf156725)
 
"/root/page[2]/body/txt/anchored/fly/column[2]/body/section/column[2]/body/txt",
 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf156419)
+{
+createSwDoc("linked_frames_section_bug.odt");
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page", 2);
+// there are 2 flys on page 1, and 1 on page 2, all linked
+assertXPath(pXmlDoc, 
"/root/page[1]/body/txt/anchored/fly[1]/section/column", 2);
+assertXPath(pXmlDoc, 
"/root/page[1]/body/txt/anchored/fly[1]/section/column[1]/body/txt", 11);
+assertXPath(pXmlDoc, 
"/root/page[1]/body/txt/anchored/fly[1]/section/column[2]/body/txt", 11);
+assertXPath(pXmlDoc, 
"/root/page[1]/body/txt/anchored/fly[2]/section/column", 2);
+assertXPath(pXmlDoc, 
"/root/page[1]/body/txt/anchored/fly[2]/section/column[1]/body/txt", 12);
+assertXPath(pXmlDoc, 
"/root/page[1]/body/txt/anchored/fly[2]/section/column[2]/body/txt", 12);
+assertXPath(pXmlDoc, 
"/root/page[2]/body/txt/anchored/fly[1]/section/column", 2);
+assertXPath(pXmlDoc, 
"/root/page[2]/body/txt/anchored/fly[1]/section/column[1]/body/txt", 2);
+assertXPath(pXmlDoc, 
"/root/page[2]/body/txt/anchored/fly[1]/section/column[2]/body/txt", 1);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf145826)
 {
 createSwDoc("tdf145826.odt");
diff --git a/sw/source/core/layout/sectfrm.cxx 
b/sw/source/core/layout/sectfrm.cxx
index 9023550cacd1..7afcb6b89800 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -1758,6 +1758,7 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType 
eMakePage )
 // creating / moving the cell frame.
 // It doesn't make sense to move to a page that starts with break?
 if (pNxtPg != FindPageFrame() // tdf#156725 not between columns!
+&& !FindFlyFrame() // tdf#156419 linked fly frames don't care!
 && (WrongPageDesc(pNxtPg) || HasPageBreakBefore(*pNxtPg))
 && !bLayLeafTableAllowed)
 {


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-18 Thread Michael Stahl (via logerrit)
 sw/qa/extras/layout/data/tdf156725.fodt |  163 
 sw/qa/extras/layout/layout3.cxx |   21 
 sw/source/core/layout/sectfrm.cxx   |4 
 3 files changed, 187 insertions(+), 1 deletion(-)

New commits:
commit db83c41d460103df5d80f5bd99816575c4ead5cd
Author: Michael Stahl 
AuthorDate: Thu Aug 17 18:32:35 2023 +0200
Commit: Michael Stahl 
CommitDate: Fri Aug 18 10:58:12 2023 +0200

tdf#156725 sw: layout: don't prevent moving between columns ...

... on the same page when there is a page break on the next page.

The existing, presumably pointless/always-false in case of same page,
check of WrongPageDesc() let me assume that this would only be reached
if the current page and the target page are different, but that was a
mistake.

(regression from commit 325fe7ab507fd8f2ca17a3db32181edf30169525)

Change-Id: I4df53b77bed006095c34976011aa0cd5e12879e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155809
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/layout/data/tdf156725.fodt 
b/sw/qa/extras/layout/data/tdf156725.fodt
new file mode 100644
index ..9f60e7011954
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf156725.fodt
@@ -0,0 +1,163 @@
+
+http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:c
 alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:
 meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ 
2023-08-17T18:14:28.1153022102023-08-17T18:20:06.109127302PT4M30S2LibreOfficeDev/24.2.0.0.alpha0$Linux_X86_64
 
LibreOffice_project/79452241ad33f9eaace2ba8bd1336be69c99ed4d
+ 
+  
+  
+  
+ 
+ 
+  
+   
+   
+
+   
+   
+  
+  
+   
+   
+  
+  
+   
+  
+  
+   
+  
+  
+  
+  
+   
+  
+  
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+  
+  
+  
+  
+  
+   
+
+
+
+
+
+
+
+
+
+
+
+
+   
+  
+ 
+ 
+  
+   
+  
+  
+   
+  
+  
+   
+
+ 
+ 
+
+   
+  
+  
+   
+
+ 
+ 
+
+   
+  
+  
+   
+
+   
+   
+   
+  
+  
+   
+  
+ 
+ 
+  
+ 
+ 
+  
+   
+
+
+
+
+
+   
+   
+   
+ 
+  
+   a
+   b
+   c
+   d
+  
+ 
+
+  
+ 
+
\ No newline at end of file
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 9e47f435df94..9c75ff31a322 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -1207,6 +1207,27 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf156724)
 assertXPath(pXmlDoc, "/root/page", 2);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf156725)
+{
+createSwDoc("tdf156725.fodt");
+
+xmlDocUniquePtr pXmlDoc = parse

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-17 Thread László Németh (via logerrit)
 sw/qa/uitest/writer_tests7/tdf156783.py |   63 
 sw/source/core/crsr/crsrsh.cxx  |2 -
 2 files changed, 64 insertions(+), 1 deletion(-)

New commits:
commit e79f0f65ab06baafc7e8a6aeb1d89ca748087b24
Author: László Németh 
AuthorDate: Wed Aug 16 21:41:26 2023 +0200
Commit: László Németh 
CommitDate: Fri Aug 18 00:06:43 2023 +0200

tdf#156783 sw tracked table column: fix crash setting border

or border padding without correct table cursor.

Table formatting is allowed on text selections starting
with tables, but adding border or border padding
resulted crashing. This regression became more visible
with hidden deleted table columns, where SelectTable
(e.g. Ctrl-A) doesn't select the whole table, but only
the text content of the visible cells, and in the case
of hidden right table columns, without table cursor.

Manual test: insert two tables in the document, and in the
first cell of the first table, select the whole document
by  pressing Ctrl-A 2 times or more. In table settings,
enable table border or modify padding to crash LibreOffice.

Regression since version 7.5.

Change-Id: If8ebb52c7662ff37ac42348c8f412549b793b6d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155749
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/uitest/writer_tests7/tdf156783.py 
b/sw/qa/uitest/writer_tests7/tdf156783.py
new file mode 100644
index ..2ccdb7dcf6e1
--- /dev/null
+++ b/sw/qa/uitest/writer_tests7/tdf156783.py
@@ -0,0 +1,63 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.common import get_url_for_data_file
+
+# Bug 156783 - crash fix: setting table border on a table without correct 
table cursor
+
+class tdf156783(UITestCase):
+def test_tdf156783(self):
+with 
self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as 
self.document:
+
+xToolkit = 
self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+
+# accept all tracked changes
+self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges")
+
+# select all tables
+self.xUITest.executeCommand(".uno:SelectAll")
+self.xUITest.executeCommand(".uno:SelectAll")
+self.xUITest.executeCommand(".uno:SelectAll")
+
+# dialog Table Properties - Borders
+with 
self.ui_test.execute_dialog_through_command(".uno:TableDialog", 
close_button="ok") as xDialog:
+tabcontrol = xDialog.getChild("tabcontrol")
+select_pos(tabcontrol, "3")
+
+sync = xDialog.getChild("sync")
+rightmf = xDialog.getChild("rightmf")
+leftmf = xDialog.getChild("leftmf")
+topmf = xDialog.getChild("topmf")
+bottommf = xDialog.getChild("bottommf")
+sync.executeAction("CLICK", tuple())
+
+rightmf.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
+rightmf.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+rightmf.executeAction("TYPE", 
mkPropertyValues({"TEXT":"72pt"}))
+leftmf.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
+leftmf.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+leftmf.executeAction("TYPE", mkPropertyValues({"TEXT":"72pt"}))
+topmf.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
+topmf.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+topmf.executeAction("TYPE", mkPropertyValues({"TEXT":"72pt"}))
+bottommf.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
+bottommf.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+bottommf.executeAction("TYPE", 
mkPropertyValues({"TEXT":"72pt"}))
+
+self.assertEqual(get_state_as_dict(rightmf)["Text"], u"72pt")
+self.assertEqual(get_state_as_dict(leftmf)["Text"], u"72pt")
+self.assertEqual(get_state_as_dict(topmf)["Text"], u"72pt")
+self.assertEqual(get_state_as_dict(bottommf)["Text"], u"72pt")
+
+# Without the fix in place, this test would have crashed here
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/core/

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-14 Thread Michael Stahl (via logerrit)
 sw/qa/extras/layout/data/fdo56797-2-min.odt |binary
 sw/qa/extras/layout/layout3.cxx |   31 
 sw/source/core/layout/layact.cxx|6 ++---
 3 files changed, 34 insertions(+), 3 deletions(-)

New commits:
commit 610c6f02b11b4b4c555a78b0feb2a1eb35159e39
Author: Michael Stahl 
AuthorDate: Mon Aug 14 17:13:17 2023 +0200
Commit: Michael Stahl 
CommitDate: Mon Aug 14 21:15:46 2023 +0200

tdf#156724 tdf#156722 tdf#156745 sw: layout: partially remove 
IsPaintLocked()

Having the layout algorithm dependend on IsPaintLocked() is very
problematic; it is typically set when the layout is invoked from
SwViewShell code, as happens several times when loading a document in
response to window resize events etc., but not for idle formatting or
from SwXTextDocument::getRendererCount(), hence these bugs only
reproduce with soffice --convert-to pdf, not via UI.

For tdf#156724 the problem is that the table is split, during formatting
of the split row a new footnote is created on page 1, and this reduces
the space, so splitting fails and is never attempted again.

When the document is loaded from UI, when the table is split the
footnote already exists and so splitting succeeds; it was created by
a call from SwLayAction::FormatLayout() of the cell frame.

It turns out that when the condition is removed completely, testUXTSOREL
will take 5 minutes instead of 5 seconds, which seems excessive; the
problem there appears to be that a text frame in a columned section
moves forward and backward; plausibly columned section content should be
formatted by ::CalcContent() only.

(reportedly regression from commit c605283ad6785dea762feab5fdffd9d27e75c292 
and commit
7e8b4756d95057f069467b34e7849f9354856578)

Change-Id: I9ed73588efeec654a769eee8aa825186bd51e059
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155672
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/layout/data/fdo56797-2-min.odt 
b/sw/qa/extras/layout/data/fdo56797-2-min.odt
new file mode 100644
index ..624149ec0248
Binary files /dev/null and b/sw/qa/extras/layout/data/fdo56797-2-min.odt differ
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index f26a6af25abf..9e47f435df94 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -1176,6 +1176,37 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf128399)
 CPPUNIT_ASSERT_EQUAL(nExpected, aPosition.GetNodeIndex());
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf156724)
+{
+discardDumpedLayout();
+if (mxComponent.is())
+mxComponent->dispose();
+
+OUString const url(createFileURL(u"fdo56797-2-min.odt"));
+
+// note: must set Hidden property, so that 
SfxFrameViewWindow_Impl::Resize()
+// does *not* forward initial VCL Window Resize and thereby triggers a
+// layout which does not happen on soffice --convert-to pdf.
+std::vector aFilterOptions = {
+{ beans::PropertyValue("Hidden", -1, uno::Any(true), 
beans::PropertyState_DIRECT_VALUE) },
+};
+
+// inline the loading because currently properties can't be passed...
+mxComponent = loadFromDesktop(url, "com.sun.star.text.TextDocument",
+  
comphelper::containerToSequence(aFilterOptions));
+save("writer_pdf_Export");
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+// both pages have a tab frame and one footnote
+assertXPath(pXmlDoc, "/root/page[1]/body/tab", 1);
+assertXPath(pXmlDoc, "/root/page[1]/ftncont", 1);
+assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn", 1);
+assertXPath(pXmlDoc, "/root/page[2]/body/tab", 1);
+assertXPath(pXmlDoc, "/root/page[2]/ftncont", 1);
+assertXPath(pXmlDoc, "/root/page[2]/ftncont/ftn", 1);
+assertXPath(pXmlDoc, "/root/page", 2);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf145826)
 {
 createSwDoc("tdf145826.odt");
diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index ecce180eb336..af93ab796ff6 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -1431,10 +1431,10 @@ bool SwLayAction::FormatLayout( OutputDevice 
*pRenderContext, SwLayoutFrame *pLa
 PopFormatLayout();
 }
 }
-else if ( m_pImp->GetShell()->IsPaintLocked() )
-// Shortcut to minimize the cycles. With Lock, the
-// paint is coming either way (primarily for browse)
+else if (m_pImp->GetShell()->IsPaintLocked() || 
!pLay->IsColBodyFrame())
+{   // tdf#156724 unconditionally for frames in tables, so their 
footnotes exist before trying to split
 pLow->OptCalc();
+}
 
 if ( IsAgain() )
 return false;


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-14 Thread Michael Stahl (via logerrit)
 sw/qa/extras/layout/data/tdf142694-1.odt |binary
 sw/qa/extras/layout/layout.cxx   |   24 
 sw/source/core/layout/findfrm.cxx|   16 +---
 3 files changed, 37 insertions(+), 3 deletions(-)

New commits:
commit fcf6f5550cc7949e94dc74cbcd10a700a225e574
Author: Michael Stahl 
AuthorDate: Thu Aug 10 19:04:08 2023 +0200
Commit: Michael Stahl 
CommitDate: Mon Aug 14 15:00:47 2023 +0200

tdf#142694 sw: layout: fix infinite loop in SwFrame::PrepareMake()

The problem is that SwFrame::FindNext_() returns itself, because it's a
table frame 401 and its last cell is empty.

There was a nested table in the cell, but during an attempt to split the
outer table 401, the inner table moved backwards.

This is due to code that was added in commit
c9c956f2716c58e2573a9ac07073f712d736ed02, which only checks that the
height of the table frame is 0, but in this case the inner table does
contain a text frame which has never been formatted yet, but still the
table frame's size and print area was set to valid.

Unfortunately adding an obvious !ContainsContent() check to the
condition breaks uiwriter4 testTdf114306_2, the last table is not on
page 4 but on page 5, for no good reason.

So just fix SwFrame::FindNext_(), it should never return "this" anyway.

(somehow regression from commit 53a0a86df6eb5fc64a85ecd03f2e354fd4d8e213)

Change-Id: If043a53c32f175fc560d422c4a4e16d8e8c6ef49
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155563
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/layout/data/tdf142694-1.odt 
b/sw/qa/extras/layout/data/tdf142694-1.odt
new file mode 100644
index ..9e9245998735
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf142694-1.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index f36eaa93237b..743b88d350ba 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3532,6 +3532,30 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128611)
 assertXPathContent(pXmlDoc, "//tab/row/cell[1]/txt", "Abcd efghijkl");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf142694)
+{
+createSwDoc("tdf142694-1.odt");
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+CPPUNIT_ASSERT(pXmlDoc);
+
+// the problem with this table is that the 3rd text frame (inside a nested
+// table) contains an as-char fly that doesn't fit on a page with the
+// repeated header row; currently it's split so that the 3rd text frame is
+// on a page of its own and extends outside the table.
+
+assertXPathNoAttribute(pXmlDoc, "/root/page[4]/body/tab[1]", "precede");
+CPPUNIT_ASSERT(!getXPath(pXmlDoc, "/root/page[4]/body/tab[1]", 
"follow").isEmpty());
+assertXPath(pXmlDoc, "/root/page[4]/body/tab[1]/row[1]/cell[1]/tab", 1);
+assertXPath(pXmlDoc, "/root/page[4]/body/tab[1]/row[2]/cell[1]/txt", 2);
+CPPUNIT_ASSERT(!getXPath(pXmlDoc, "/root/page[5]/body/tab[1]", 
"precede").isEmpty());
+assertXPathNoAttribute(pXmlDoc, "/root/page[5]/body/tab[1]", "follow");
+assertXPath(pXmlDoc, "/root/page[5]/body/tab[1]/row[1]/cell[1]/tab", 1);
+assertXPath(pXmlDoc, "/root/page[5]/body/tab[1]/row[2]/cell[1]/tab", 1);
+assertXPathNoAttribute(pXmlDoc, 
"/root/page[5]/body/tab[1]/row[2]/cell[1]/tab", "follow");
+assertXPath(pXmlDoc, 
"/root/page[5]/body/tab[1]/row[2]/cell[1]/tab/row/cell/txt", 1);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf152413)
 {
 createSwDoc("tdf152413.fodt");
diff --git a/sw/source/core/layout/findfrm.cxx 
b/sw/source/core/layout/findfrm.cxx
index ae2c7473baf3..1a98f6cf6747 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -945,9 +945,19 @@ SwFrame *SwFrame::FindNext_()
  )
)
 {
-pRet = pNxtCnt->IsInTab() ? pNxtCnt->FindTabFrame()
-: pNxtCnt;
-break;
+if (pNxtCnt->IsInTab())
+{
+if (!IsTabFrame() || 
!static_cast(this)->IsAnLower(pNxtCnt))
+{
+pRet = pNxtCnt->FindTabFrame();
+break;
+}
+}
+else
+{
+pRet = pNxtCnt;
+break;
+}
 }
 pNxtCnt = lcl_NextFrame( pNxtCnt );
 }


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-14 Thread Miklos Vajna (via logerrit)
 sw/qa/extras/ww8export/ww8export4.cxx|   50 +++
 sw/qa/filter/ww8/data/floattable-tbl-overlap.doc |binary
 sw/qa/filter/ww8/ww8.cxx |   15 ++
 sw/source/filter/ww8/wrtww8.cxx  |8 +++
 sw/source/filter/ww8/ww8par6.cxx |   17 +++
 sw/source/filter/ww8/ww8struc.hxx|1 
 6 files changed, 91 insertions(+)

New commits:
commit d44af60677740b151305799a4325d0f0699fce66
Author: Miklos Vajna 
AuthorDate: Mon Aug 14 08:25:41 2023 +0200
Commit: Miklos Vajna 
CommitDate: Mon Aug 14 10:49:45 2023 +0200

sw floattable: handle AllowOverlap==false in the DOC filter

Map sprmTFNoAllowOverlap to
SwFormatWrapInfluenceOnObjPos::mbAllowOverlap on import, and do the
opposite on export.

Change-Id: Id61be49adb39862e30ffb2da9ff9aabae11f7d83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155650
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/extras/ww8export/ww8export4.cxx 
b/sw/qa/extras/ww8export/ww8export4.cxx
index 459daa69ec81..0d101f818acf 100644
--- a/sw/qa/extras/ww8export/ww8export4.cxx
+++ b/sw/qa/extras/ww8export/ww8export4.cxx
@@ -27,6 +27,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 class Test : public SwModelTestBase
 {
@@ -144,6 +149,51 @@ CPPUNIT_TEST_FIXTURE(Test, testDontBreakWrappedTables)
 CPPUNIT_ASSERT(bDontBreakWrappedTables);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testFloattableOverlapNeverDOCExport)
+{
+// Given a document with a floating table, overlap is not allowed:
+{
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+pWrtShell->Insert2("before table");
+// Insert a table:
+SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 
0);
+pWrtShell->InsertTable(aTableOptions, /*nRows=*/1, /*nCols=*/1);
+pWrtShell->MoveTable(GotoPrevTable, fnTableStart);
+// Select table:
+pWrtShell->SelAll();
+// Wrap the table in a text frame:
+SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr);
+pWrtShell->StartAllAction();
+aMgr.InsertFlyFrame(RndStdIds::FLY_AT_PARA, aMgr.GetPos(), 
aMgr.GetSize());
+pWrtShell->EndAllAction();
+// Allow the text frame to split:
+pWrtShell->StartAllAction();
+sw::FrameFormats* pFlys = 
pDoc->GetSpzFrameFormats();
+sw::SpzFrameFormat* pFly = (*pFlys)[0];
+SwAttrSet aSet(pFly->GetAttrSet());
+aSet.Put(SwFormatFlySplit(true));
+// Don't allow overlap:
+SwFormatWrapInfluenceOnObjPos aInfluence;
+aInfluence.SetAllowOverlap(false);
+aSet.Put(aInfluence);
+pDoc->SetAttr(aSet, *pFly);
+pWrtShell->EndAllAction();
+}
+
+// When saving to DOC:
+saveAndReload("MS Word 97");
+
+// Then make sure that the overlap=never markup is written:
+SwDoc* pDoc = getSwDoc();
+sw::FrameFormats* pFlys = pDoc->GetSpzFrameFormats();
+sw::SpzFrameFormat* pFly = (*pFlys)[0];
+// Without the accompanying fix in place, this test would have failed, 
i.e. TFNoAllowOverlap was
+// not written.
+
CPPUNIT_ASSERT(!pFly->GetAttrSet().GetWrapInfluenceOnObjPos().GetAllowOverlap());
+}
+
 static bool IsFirstLine(const SwTextNode* pTextNode)
 {
 const SfxPoolItem* pItem = pTextNode->GetNoCondAttr(RES_MARGIN_FIRSTLINE, 
false);
diff --git a/sw/qa/filter/ww8/data/floattable-tbl-overlap.doc 
b/sw/qa/filter/ww8/data/floattable-tbl-overlap.doc
new file mode 100644
index ..921ffe1fa667
Binary files /dev/null and b/sw/qa/filter/ww8/data/floattable-tbl-overlap.doc 
differ
diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx
index 2d12e980dbdb..db1dbcd1bf36 100644
--- a/sw/qa/filter/ww8/ww8.cxx
+++ b/sw/qa/filter/ww8/ww8.cxx
@@ -455,6 +455,21 @@ CPPUNIT_TEST_FIXTURE(Test, 
testFloattableOverlapNeverDOCXExport)
 // i.e.  was not written.
 assertXPath(pXmlDoc, "//w:tblPr/w:tblOverlap", "val", "never");
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testFloattableOverlapNeverDOCImport)
+{
+// Given a document with two floating tables, the second has 
sprmTFNoAllowOverlap=1 set:
+// When importing that document:
+createSwDoc("floattable-tbl-overlap.doc");
+
+// Then make sure the second table is marked as "can't overlap":
+SwDoc* pDoc = getSwDoc();
+sw::FrameFormats& rFlys = *pDoc->GetSpzFrameFormats();
+sw::SpzFrameFormat* pFly = rFlys[1];
+// Without the accompanying fix in place, this test would have failed, the 
fly had the default
+// "can overlap".
+
CPPUNIT_ASSERT(!pFly->GetAttrSet().GetWrapInfluenceOnObjPos().GetAllowOverlap());
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index c51b1c3f..fc2beabe9bef 100644
--- a/sw/source/fi

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-11 Thread Miklos Vajna (via logerrit)
 sw/qa/filter/ww8/ww8.cxx |   45 +++
 sw/source/filter/ww8/docxtableexport.cxx |8 +
 2 files changed, 53 insertions(+)

New commits:
commit 5af44a176d2a738dd7523713202aeee27c5578b6
Author: Miklos Vajna 
AuthorDate: Fri Aug 11 08:27:32 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri Aug 11 11:09:30 2023 +0200

sw floattable: export  to DOCX

Once split flys containing tables have "allow overlap" disabled, this is
not saved to DOCX when we map them to floating tables.

The working case is the allowOverlap attribute on shapes, added in
commit f8c7a2284b88c149addc8a30abb0cad8a10dad77 (Related: tdf#124600 sw
anchored object allow overlap: add DOCX filter, 2019-09-20).

Fix the problem by extending DocxAttributeOutput::TableDefinition(), to
write  in case overlap is not allowed, after .

DOC and RTF filters are still missing.

Change-Id: I7d0bd4a15567014d3add8cbbcd92c62c5a33b7e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155573
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx
index 68bbc28fcfc3..2d12e980dbdb 100644
--- a/sw/qa/filter/ww8/ww8.cxx
+++ b/sw/qa/filter/ww8/ww8.cxx
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace
 {
@@ -410,6 +411,50 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableThenFloattable)
 // anchor.
 CPPUNIT_ASSERT_EQUAL(nFly1Anchor + 1, nFly2Anchor);
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testFloattableOverlapNeverDOCXExport)
+{
+// Given a document with a floating table, overlap is not allowed:
+createSwDoc();
+SwDoc* pDoc = getSwDoc();
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+pWrtShell->Insert2("before table");
+// Insert a table:
+SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0);
+pWrtShell->InsertTable(aTableOptions, /*nRows=*/1, /*nCols=*/1);
+pWrtShell->MoveTable(GotoPrevTable, fnTableStart);
+// Select table:
+pWrtShell->SelAll();
+// Wrap the table in a text frame:
+SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr);
+pWrtShell->StartAllAction();
+aMgr.InsertFlyFrame(RndStdIds::FLY_AT_PARA, aMgr.GetPos(), aMgr.GetSize());
+pWrtShell->EndAllAction();
+// Allow the text frame to split:
+pWrtShell->StartAllAction();
+auto& rFlys = *pDoc->GetSpzFrameFormats();
+auto pFly = rFlys[0];
+SwAttrSet aSet(pFly->GetAttrSet());
+aSet.Put(SwFormatFlySplit(true));
+// Don't allow overlap:
+SwFormatWrapInfluenceOnObjPos aInfluence;
+aInfluence.SetAllowOverlap(false);
+aSet.Put(aInfluence);
+pDoc->SetAttr(aSet, *pFly);
+pWrtShell->EndAllAction();
+
+// When saving to DOCX:
+save("Office Open XML Text");
+
+// Then make sure that the overlap=never markup is written:
+xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 0
+// - XPath '//w:tblPr/w:tblOverlap' number of nodes is incorrect
+// i.e.  was not written.
+assertXPath(pXmlDoc, "//w:tblPr/w:tblOverlap", "val", "never");
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxtableexport.cxx 
b/sw/source/filter/ww8/docxtableexport.cxx
index 51fb3540c9df..b3e2d014222b 100644
--- a/sw/source/filter/ww8/docxtableexport.cxx
+++ b/sw/source/filter/ww8/docxtableexport.cxx
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "docxexportfilter.hxx"
 #include "docxhelper.hxx"
@@ -281,6 +282,13 @@ void DocxAttributeOutput::TableDefinition(
 bFloatingTableWritten = true;
 // The outer table was floating, make sure potential inner tables are 
not floating.
 m_rExport.SetFloatingTableFrame(nullptr);
+
+const SwFrameFormat& rFloatingTableFormat = 
pFloatingTableFrame->GetFrameFormat();
+if (!rFloatingTableFormat.GetWrapInfluenceOnObjPos().GetAllowOverlap())
+{
+// Allowing overlap is the default, both in OOXML and in Writer.
+m_pSerializer->singleElementNS(XML_w, XML_tblOverlap, FSNS(XML_w, 
XML_val), "never");
+}
 }
 
 // Extract properties from grab bag


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-10 Thread László Németh (via logerrit)
 sw/qa/core/txtnode/data/special-insert-after-merged-cells.fodt |   25 +
 sw/qa/core/txtnode/txtnode.cxx |   26 
++
 sw/source/core/edit/edsect.cxx |   21 +++-
 3 files changed, 71 insertions(+), 1 deletion(-)

New commits:
commit 8258a70a7ca596a8ce5ff417f312a99a96694bed
Author: László Németh 
AuthorDate: Thu Aug 10 13:37:13 2023 +0200
Commit: László Németh 
CommitDate: Thu Aug 10 18:49:30 2023 +0200

tdf#156492 sw: fix alt-Enter in cells merged vertically

Inserting empty paragragh after the tables didn't work,
if the bottom right corner of the table contains cells
merged vertically.

Manual test: positionate the text cursor at the end
of the last paragraph of the bottom right cell of the
table (which contains also cells merged vertically), and
press alt-Enter to insert an empty paragraph after the
table.

Note: SpecialInsert, i.e. inserting empty paragraph by pressing
alt-Enter is the quick and sometimes the only possible way to insert
an empty paragraph before or after tables and sections.

Change-Id: Ic845c3d683a561784afe69588b3b1538e82c35c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/16
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/core/txtnode/data/special-insert-after-merged-cells.fodt 
b/sw/qa/core/txtnode/data/special-insert-after-merged-cells.fodt
new file mode 100644
index ..55ba746b669c
--- /dev/null
+++ b/sw/qa/core/txtnode/data/special-insert-after-merged-cells.fodt
@@ -0,0 +1,25 @@
+
+
+ 
+  
+   
+
+
+ 
+  
+ 
+ 
+  
+ 
+
+
+ 
+  
+ 
+ 
+
+   
+   
+  
+ 
+
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index 640df69ed211..4a4bf9901a2f 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -64,6 +64,32 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testBtlrCellChinese)
 assertXPath(pXmlDoc, "//font[1]", "vertical", "false");
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testSpecialInsertAfterMergedCells)
+{
+// Load a document with a table with bottom right cells merged vertically.
+// SpecialInsert with alt-Enter must work here, too.
+createSwDoc("special-insert-after-merged-cells.fodt");
+SwDoc* pDoc = getSwDoc();
+SwNodeOffset const nNodes(pDoc->GetNodes().Count());
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+SwDocShell* pShell = pTextDoc->GetDocShell();
+SwWrtShell* pWrtShell = pShell->GetWrtShell();
+// go to the merged cell
+pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+
+// When pressing alt-Enter on the keyboard:
+SwEditWin& rEditWin = pWrtShell->GetView().GetEditWin();
+vcl::KeyCode aKeyCode(KEY_RETURN, KEY_MOD2);
+KeyEvent aKeyEvent(' ', aKeyCode);
+rEditWin.KeyInput(aKeyEvent);
+
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: nNodes + 1
+// - Actual  : nNodes
+// i.e. new empty paragraph wasn't inserted under the table
+CPPUNIT_ASSERT_EQUAL(nNodes + 1, pDoc->GetNodes().Count());
+}
+
 CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTextBoxCopyAnchor)
 {
 createSwDoc("textbox-copy-anchor.docx");
diff --git a/sw/source/core/edit/edsect.cxx b/sw/source/core/edit/edsect.cxx
index 6116a422557f..a7e652aea9de 100644
--- a/sw/source/core/edit/edsect.cxx
+++ b/sw/source/core/edit/edsect.cxx
@@ -356,12 +356,31 @@ static const SwNode* lcl_SpecialInsertNode(const 
SwPosition* pCurrentPos)
 // we found an end if
 // - we're at or just before an end node
 // - there are only end nodes between the current node and
-//   pInnermostNode's end node
+//   pInnermostNode's end node or
+// - there are only end nodes between the last table cell merged with
+//   the current cell and pInnermostNode's end node
 SwNodeIndex aEnd( pCurrentPos->GetNode() );
 if( rCurrentNode.IsContentNode() &&
 ( pCurrentPos->GetContentIndex() ==
   rCurrentNode.GetContentNode()->Len() ) )
+{
 ++aEnd;
+
+// tdf#156492 handle cells merged vertically in the bottom right 
corner
+if ( pInnermostNode->IsTableNode() )
+{
+const SwNode* pTableBoxStartNode = 
pCurrentPos->GetNode().FindTableBoxStartNode();
+const SwTableBox* pTableBox = 
pTableBoxStartNode->GetTableBox();
+if ( pTableBox && pTableBox->getRowSpan() > 1 )
+{
+const SwTableNode* pTableNd = 
pInnermostNode->FindTableNode();
+pTableBox = & pTableBox->FindEndOfRowSpan( 
pTableNd->GetTable(),
+
pTableBox->getRowSpan() );
+  

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-10 Thread Miklos Vajna (via logerrit)
 sw/qa/core/objectpositioning/data/floattable-tbl-overlap.docx  |binary
 sw/qa/core/objectpositioning/objectpositioning.cxx |   33 
++
 sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx |   22 
++
 3 files changed, 55 insertions(+)

New commits:
commit 905962db870e9d1cf1dcf3bd1be44c347cddafe1
Author: Miklos Vajna 
AuthorDate: Thu Aug 10 09:05:18 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Aug 10 10:41:09 2023 +0200

sw floattable: handle AllowOverlap==false in the layout

The bugdoc has two floating tables, and these would normally overlap,
but SwFormatWrapInfluenceOnObjPos::mbAllowOverlap requests tweaking the
position at a layout level to avoid that overlap.

This is similar to what commit d37096f59e7e0286e55008153591a60bab92b9e8
(Related: tdf#124600 sw anchored object allow overlap: add layout,
2019-09-19) did, but that was for draw shapes and this is for split
flys.

Fix the problem by extending
SwToContentAnchoredObjectPosition::CalcOverlap(): the overlap detection
can be reused, just need to look for split flys on the entire page +
need to check split flys against other split flys.

The ODT filter works out of the box.

Change-Id: Id31308a67ba502bcc830f15a1679996ec153f209
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155536
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/objectpositioning/data/floattable-tbl-overlap.docx 
b/sw/qa/core/objectpositioning/data/floattable-tbl-overlap.docx
new file mode 100644
index ..b5b23931a240
Binary files /dev/null and 
b/sw/qa/core/objectpositioning/data/floattable-tbl-overlap.docx differ
diff --git a/sw/qa/core/objectpositioning/objectpositioning.cxx 
b/sw/qa/core/objectpositioning/objectpositioning.cxx
index bb3a12793ae8..4958b8b6deb4 100644
--- a/sw/qa/core/objectpositioning/objectpositioning.cxx
+++ b/sw/qa/core/objectpositioning/objectpositioning.cxx
@@ -15,6 +15,12 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 /// Covers sw/source/core/objectpositioning/ fixes.
 class SwCoreObjectpositioningTest : public SwModelTestBase
@@ -280,6 +286,33 @@ CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, 
testVMLVertAlignBottomMargin)
 CPPUNIT_ASSERT_EQUAL(static_cast(1), nFifthVMLShapeOutside - 
nPageBottom);
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreObjectpositioningTest, 
testFloatingTableOverlapNever)
+{
+// Given a document with two floating tables, positioned in a way that 
normally these would
+// overlap, but SwFormatWrapInfluenceOnObjPos::mbAllowOverlap == false 
explicitly asks to avoid
+// overlaps:
+createSwDoc("floattable-tbl-overlap.docx");
+
+// When laying out that document:
+calcLayout();
+
+// Then make sure no overlap happens:
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = dynamic_cast(pLayout->Lower());
+CPPUNIT_ASSERT(pPage1);
+CPPUNIT_ASSERT(pPage1->GetSortedObjs());
+const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(2), rPage1Objs.size());
+auto pFlyFrame1 = rPage1Objs[0]->DynCastFlyFrame();
+auto pFlyFrame2 = rPage1Objs[1]->DynCastFlyFrame();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected greater than: 2291
+// - Actual  : 2175
+// i.e. the 2nd floating table overlapped with the first one.
+CPPUNIT_ASSERT_GREATER(pFlyFrame1->getFrameArea().Bottom(), 
pFlyFrame2->getFrameArea().Top());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx 
b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
index 9a9abc9f4dd8..33168ceba432 100644
--- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
@@ -1194,6 +1194,21 @@ void 
SwToContentAnchoredObjectPosition::CalcOverlap(const SwTextFrame* pAnchorFr
 
 // Get the list of objects.
 auto pSortedObjs = pAnchorFrameForVertPos->GetDrawObjs();
+
+bool bSplitFly = false;
+SwFlyFrame* pFlyFrame = GetAnchoredObj().DynCastFlyFrame();
+if (pFlyFrame && pFlyFrame->IsFlySplitAllowed())
+{
+// At least for split flys we need to consider objects on the same 
page, but anchored in
+// different text frames.
+bSplitFly = true;
+const SwPageFrame* pPageFrame = 
pAnchorFrameForVertPos->FindPageFrame();
+if (pPageFrame)
+{
+pSortedObjs = pPageFrame->GetSortedObjs();
+}
+}
+
 if (!pSortedObjs)
 {
 return;
@@ -1213,6 +1228,13 @@ void 
SwToContentAnchoredObjectPosition::CalcOverlap(const SwTextFrame* pAnchorFr
 conti

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-09 Thread László Németh (via logerrit)
 sw/qa/extras/uiwriter/uiwriter5.cxx |   30 ++
 sw/source/core/frmedt/fetab.cxx |   33 +++--
 2 files changed, 53 insertions(+), 10 deletions(-)

New commits:
commit f65c04b2b32a9e00dd05a16614b4dedb86171c97
Author: László Németh 
AuthorDate: Tue Aug 8 19:46:15 2023 +0200
Commit: László Németh 
CommitDate: Wed Aug 9 17:22:21 2023 +0200

tdf#156487 sw tracked table column: fix Hide Changes

In Hide Changes mode, deleting table columns with change tracking
wasn't applied on the table layout immediately, only using Show
Changes and Hide Changes again. Now the deleted column removed from
the table instead leaving an empty table column.

Also revert commit 33058b5dc47a140516669945efbdd30ea65138a6
"tdf#156544 sw tracked table column: delete empty column".

See also commit a74c51025fa4519caaf461492e4ed8e68bd34885
"tdf#146962 sw: hide deleted row at deletion in Hide Changes".

Change-Id: If03d2bc5996a168cb44839b0753effb9031edbc7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155522
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx 
b/sw/qa/extras/uiwriter/uiwriter5.cxx
index 3e8babfff390..285a3adb7c61 100644
--- a/sw/qa/extras/uiwriter/uiwriter5.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter5.cxx
@@ -2777,6 +2777,36 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156544)
 assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156487)
+{
+// load a table, and delete a column in Hide Changes mode
+createSwDoc("tdf118311.fodt");
+SwDoc* pDoc = getSwDoc();
+
+// turn on red-lining and hide changes
+pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On);
+CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+   pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+CPPUNIT_ASSERT_MESSAGE("redlines shouldn't be visible",
+   !IDocumentRedlineAccess::IsShowChanges(
+   
pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+// delete table column with enabled change tracking
+// (HasTextChangesOnly property of the cell will be false)
+dispatchCommand(mxComponent, ".uno:DeleteColumns", {});
+
+// Dump the rendering of the first page as an XML file.
+SwDocShell* pShell = pDoc->GetDocShell();
+std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile();
+MetafileXmlDump dumper;
+xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+CPPUNIT_ASSERT(pXmlDoc);
+
+// This would be 2 without hiding the first cell
+assertXPath(pXmlDoc, "/metafile/push/push/push/textarray/text", 1);
+}
+
 #ifndef DBG_UTIL
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf149498)
 {
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index a766596daa29..dced56c1f2a0 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -279,11 +279,14 @@ bool SwFEShell::DeleteCol()
 
 CurrShell aCurr( this );
 
+bool bRecordChanges = GetDoc()->GetDocShell()->IsChangeRecording();
+bool bRecordAndHideChanges = bRecordChanges &&
+
GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout()->IsHideRedlines();
+
 // tracked deletion: remove only textbox content,
 // and set IsNoTracked table box property to false
-if ( GetDoc()->GetDocShell()->IsChangeRecording() )
+if ( bRecordChanges )
 {
-bool bDeletedEmptyCell = false;
 StartUndo(SwUndoId::COL_DELETE);
 StartAllAction();
 
@@ -296,6 +299,10 @@ bool SwFEShell::DeleteCol()
 
 TableWait aWait( 20, pFrame, *GetDoc()->GetDocShell(), aBoxes.size() );
 
+SwTableNode* pTableNd = pFrame->IsTextFrame()
+? 
static_cast(pFrame)->GetTextNodeFirst()->FindTableNode()
+: static_cast(pFrame)->GetNode()->FindTableNode();
+
 for (size_t i = 0; i < aBoxes.size(); ++i)
 {
 SwTableBox *pBox = aBoxes[i];
@@ -318,24 +325,30 @@ bool SwFEShell::DeleteCol()
 aCursor.GetMark()->SetContent(0);
 rIDRA.SetRedlineFlags_intern( eOld );
 rIDCO.DeleteAndJoin( aCursor );
-bDeletedEmptyCell = true;
 }
 
 }
 }
 
 SwEditShell* pEditShell = GetDoc()->GetEditShell();
-SwRedlineTable::size_type nPrev = pEditShell->GetRedlineCount();
 pEditShell->Delete();
 
+// remove cell frames in Hide Changes mode (and table frames, if 
needed)
+if ( bRecordAndHideChanges )
+{
+// remove all frames of the table, and make them again without the 
deleted ones
+// TODO remove only the deleted frames
+pTableNd->DelFrames();
+
+if ( !pTableNd->GetTable().IsDeleted() )
+{
+

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-08 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/floattable-then-table.doc |binary
 sw/qa/core/layout/flycnt.cxx |   14 ++
 sw/source/core/layout/flycnt.cxx |9 +
 3 files changed, 23 insertions(+)

New commits:
commit 0d571ff8079f858a5650bf6cbb38296d22cc58e1
Author: Miklos Vajna 
AuthorDate: Tue Aug 8 08:17:17 2023 +0200
Commit: Miklos Vajna 
CommitDate: Tue Aug 8 09:42:34 2023 +0200

tdf#156589 sw floattable: fix follow fly moving inside a table on the next 
page

Opening the bugdoc and inserting a page break at the document start
resulted in a crash.

The direct problem was a nullptr deref in Notify_Background(), because
pCnt reported true for IsInTab(), but then FindTabFrame() didn't find
anything. The deeper problem was that SwFrame::GetNextFlyLeaf() had a
case where it created a follow text frame for the anchor of a floating
table, but that follow text frame went inside a table on the start of
the next page, not to the start of the page.

Fix the problem by continuing to use GetNextLayoutLeaf() (which knows
how to traverse the layout tree from a fly frame to its anchor and then
to a next page), but once we moved to a body on a next page and we would
insert inside an inline table, insert before the table instead.

Need to make sure the target is in a body frame, because a next layout
leaf in a footer's table is not OK.

Change-Id: I3ff6a0bbc2cac5f1bc2803a52a632c13053d4daa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155444
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-then-table.doc 
b/sw/qa/core/layout/data/floattable-then-table.doc
new file mode 100644
index ..8c9684e5950a
Binary files /dev/null and b/sw/qa/core/layout/data/floattable-then-table.doc 
differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 6207a956f574..ba688728743b 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -996,6 +996,20 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyGrowFromBottom)
 // frame on page 1 even when it would fit, and this lead to a crash on 
export later.
 CPPUNIT_ASSERT(!pFly->GetFollow());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyIntoTable)
+{
+// Given a document with a floating table, then an inline table on the 
next page:
+createSwDoc("floattable-then-table.doc");
+
+// When inserting a page break:
+// Then make sure the layout doesn't crash:
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+pWrtShell->InsertPageBreak();
+// Without the accompanying fix in place, this test would have crashed, we 
tried to insert the
+// second part of a floating table into a table on the next page, not 
before that table.
+calcLayout();
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 25e3f45c0bfa..113eaafbce9d 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -1614,6 +1614,15 @@ SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType 
eMakePage )
 // The above conditions are not held, reject.
 pOldLayLeaf = pLayLeaf;
 pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
+
+if (pLayLeaf && pLayLeaf->IsInDocBody() && !bSameBody && 
!pLayLeaf->IsInFly() && pLayLeaf->IsInTab())
+{
+// We found a next leaf in a next body frame, which is in 
an inline table. Make
+// sure we won't insert the follow anchor inside the 
table, but before it.
+SwTabFrame* pTabFrame = pLayLeaf->FindTabFrame();
+pLayLeaf = pTabFrame->GetUpper();
+}
+
 continue;
 }
 }


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-07 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/htmlexport/data/table_cell_padding.fodt |   34 +++
 sw/qa/extras/htmlexport/htmlexport.cxx   |   32 +
 sw/source/filter/html/htmltab.cxx|   27 +--
 3 files changed, 91 insertions(+), 2 deletions(-)

New commits:
commit 97a6e3f22185b26745dbe27949a9b283937f98da
Author: Mike Kaganski 
AuthorDate: Mon Aug 7 09:22:00 2023 +0300
Commit: Mike Kaganski 
CommitDate: Mon Aug 7 09:50:04 2023 +0200

tdf#156647: restore the explicitly set properties after applying defaults

Since commit 63c91b9cb3f73b66a915875721b0efd65b8aebac (sw HTML import: apply
default table autoformat on cells in reqif mode, 2018-08-08), defaults are
applied to imported-from-ReqIF tables. This resets the padding correctly
imported from the markup.

This change saves the previous box item, and restores the non-default line
and distance settings from it after the defaults application.

Change-Id: Ibcd8868875905fa93ab2e0443b2a8900ce1441a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155410
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/qa/extras/htmlexport/data/table_cell_padding.fodt 
b/sw/qa/extras/htmlexport/data/table_cell_padding.fodt
new file mode 100644
index ..059a37b9dab7
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/table_cell_padding.fodt
@@ -0,0 +1,34 @@
+
+
+
+ 
+  
+   
+  
+ 
+ 
+  
+   
+
+
+
+ 
+  A
+ 
+ 
+  B
+ 
+
+
+ 
+  C
+ 
+ 
+  D
+ 
+
+   
+   
+  
+ 
+
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx 
b/sw/qa/extras/htmlexport/htmlexport.cxx
index becda28a832a..9cd104f77292 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2714,6 +2715,37 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, 
testReqIF_Tdf156602)
 assertXPathContent(pDoc, 
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p", "Following text");
 }
 
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTdf156647_CellPaddingRoundtrip)
+{
+// Given a document with a table with cell padding:
+createSwDoc("table_cell_padding.fodt");
+{
+auto xTable = getParagraphOrTable(1);
+auto aTableBorder = getProperty(xTable, 
"TableBorder2");
+CPPUNIT_ASSERT_EQUAL(sal_Int16(1270), aTableBorder.Distance);
+CPPUNIT_ASSERT(aTableBorder.IsDistanceValid);
+}
+// When exporting to reqif-xhtml:
+ExportToReqif();
+// Make sure that we export it:
+xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile();
+assertXPath(pXmlDoc, "//reqif-xhtml:table", "cellpadding", "48"); // px
+// Now import it
+mxComponent->dispose();
+ImportFromReqif(maTempFile.GetURL());
+// Then make sure that padding is not lost:
+{
+auto xTable = getParagraphOrTable(1);
+auto aTableBorder = getProperty(xTable, 
"TableBorder2");
+// Without the accompanying fix in place, this test would have failed:
+// - Expected: 1270
+// - Actual  : 97
+// as the padding was lost, and the default 55 twip padding was used.
+CPPUNIT_ASSERT_EQUAL(sal_Int16(1270), aTableBorder.Distance);
+CPPUNIT_ASSERT(aTableBorder.IsDistanceValid);
+}
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmltab.cxx 
b/sw/source/filter/html/htmltab.cxx
index 861152083455..e1e50865f624 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -1486,11 +1486,34 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
 if (pTableFormat)
 {
 sal_uInt8 nPos = SwTableAutoFormat::CountPos(nCol, m_nCols, 
nRow, m_nRows);
+const SfxItemSet& rAttrSet = pFrameFormat->GetAttrSet();
+std::unique_ptr pOldBoxItem;
+if (const SvxBoxItem* pBoxItem2 = 
rAttrSet.GetItemIfSet(RES_BOX))
+pOldBoxItem.reset(pBoxItem2->Clone());
 pTableFormat->UpdateToSet(nPos, m_nRows==1, m_nCols==1,
-  
const_cast(static_cast(
-  pFrameFormat->GetAttrSet())),
+  const_cast(rAttrSet),
   SwTableAutoFormatUpdateFlags::Box,
   
pFrameFormat->GetDoc()->GetNumberFormatter());
+if (pOldBoxItem)
+{
+// There was an old item, so it's guaranteed that there's 
a new item
+const SvxBoxItem* pBoxItem2(rAttrSet.GetItem(RES_BOX));
+if (*pBoxItem2 != *pOldBoxItem)
+{
+std::unique_ptr 
pNewBoxItem(pBoxItem2->

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-04 Thread Michael Stahl (via logerrit)
 sw/qa/extras/uiwriter/data/tdf147938.fodt |  160 ++
 sw/qa/extras/uiwriter/uiwriter8.cxx   |   57 ++
 sw/source/core/docnode/node.cxx   |9 +
 3 files changed, 226 insertions(+)

New commits:
commit 5b55ccfd384d3c0c11e05f22bd7e956b4bc7e43a
Author: Michael Stahl 
AuthorDate: Fri Aug 4 13:12:05 2023 +0200
Commit: Michael Stahl 
CommitDate: Fri Aug 4 18:14:22 2023 +0200

tdf#147938 sw_redlinehide: fix undo of table to text

The problem is that when the text node is split in
SwNodes::UndoTableToText(), the 2nd one retains the merge flag NonFirst,
not the 1st one, and it ends up in the 2nd table cell, so it's skipped
when creating the layout frames (and an assert in InsertCnt_()
segfaults).

SwContentNode::DelFrames() should probably reset the merge flags of
nodes when it deletes the merged frame.

(regression from commit 32902f66e7749b2d06d13f50416be5323a0c0ea9)

Change-Id: I7b3b1ca873bde831481c676780200a3206ae667c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155345
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sw/qa/extras/uiwriter/data/tdf147938.fodt 
b/sw/qa/extras/uiwriter/data/tdf147938.fodt
new file mode 100644
index ..6a95cb59c203
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf147938.fodt
@@ -0,0 +1,160 @@
+
+http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:c
 alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:
 meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ 
2023-08-04T13:37:50.9405330032023-08-04T13:39:42.785634897PT1M27S2LibreOfficeDev/7.5.5.0.0$Linux_X86_64
 
LibreOffice_project/c430b30a2ea9a678e44af112a171c86fab519a37
+ 
+  
+  
+  
+ 
+ 
+  
+   
+   
+
+   
+   
+  
+  
+   
+   
+  
+  
+   
+  
+  
+   
+  
+  
+  
+   
+  
+  
+  
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+  
+  
+  
+  
+ 
+ 
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+
+   
+   
+   
+  
+  
+   
+  
+ 
+ 
+  
+ 
+ 
+  
+   
+
+ 
+  
+   Unknown Author
+   2023-08-04T13:38:41
+  
+ 
+
+   
+   
+
+
+
+
+
+   
+   Foo
+   
+
+
+
+ 
+  Bar
+  baz quux
+ 
+ 
+  blah
+ 
+
+   
+   
+  
+ 
+
\ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 621fecc6fd98..b4dbaa771593 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -36,6 +36,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 /// 8th set of tests asserting the behavior of Writ

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-04 Thread Miklos Vajna (via logerrit)
 sw/qa/core/layout/data/floattable-from-bottom.docx |binary
 sw/qa/core/layout/flycnt.cxx   |   21 +
 sw/source/core/layout/fly.cxx  |   15 ++-
 3 files changed, 35 insertions(+), 1 deletion(-)

New commits:
commit c545a0729e89ee2e8f14534b77422cc9eb4eb7cf
Author: Miklos Vajna 
AuthorDate: Fri Aug 4 10:44:30 2023 +0200
Commit: Miklos Vajna 
CommitDate: Fri Aug 4 11:28:41 2023 +0200

sw floattable, crashtesting: fix PDF export of tdf73201-1.docx

The direct cause is that in in the SwTextFrameBreak ctor, m_pFrame has
IsInSct() as true, but FindSctFrame() then doesn't find anything, which
should not happen.

The bigger problem is that currently the fly split code assumes that
frames grow from (logical) top to bottom, so in case the vertical
orientation is bottom, and we have to grow from bottom to top, that
needs re-positioning the fly, but the fly split code has no support for
that.

Fix the crash by denying this case in SwFlyFrame::IsFlySplitAllowed()
for now, the document's table is not supposed to split in the first
place.

In case later there is a real need to split such flys, then more
research is needed how that re-positioning works in detail for non-split
flys and then we have to adapt the fly split code accordingly.

Change-Id: I56cf074a3d740ab716f7de232fbd131d17544d9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155339
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-from-bottom.docx 
b/sw/qa/core/layout/data/floattable-from-bottom.docx
new file mode 100644
index ..86374a68ba27
Binary files /dev/null and b/sw/qa/core/layout/data/floattable-from-bottom.docx 
differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index a1e4c05c6c1d..6207a956f574 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -975,6 +975,27 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNoFooterOverlap)
 const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs();
 CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyGrowFromBottom)
+{
+// Given a document with a floating table that grows from the bottom:
+createSwDoc("floattable-from-bottom.docx");
+
+// When calculating the layout:
+calcLayout();
+
+// Then make sure that such a floating table is not split, matching Word:
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = dynamic_cast(pLayout->Lower());
+CPPUNIT_ASSERT(pPage1);
+CPPUNIT_ASSERT(pPage1->GetSortedObjs());
+const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs();
+const auto pFly = dynamic_cast(rPage1Objs[0]);
+// Without the accompanying fix in place, this test would have failed, we 
tried to split the fly
+// frame on page 1 even when it would fit, and this lead to a crash on 
export later.
+CPPUNIT_ASSERT(!pFly->GetFollow());
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index a365668c4ce2..4022e1995fe8 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -687,7 +687,20 @@ bool SwFlyFrame::IsFlySplitAllowed() const
 return false;
 }
 
-return GetFormat()->GetFlySplit().GetValue();
+const SwFlyFrameFormat* pFormat = GetFormat();
+const SwFormatVertOrient& rVertOrient = pFormat->GetVertOrient();
+if (rVertOrient.GetVertOrient() == text::VertOrientation::BOTTOM)
+{
+// We have to grow from bottom to top, and the fly split code assumes 
that we grow from top
+// to bottom, so don't split for now.
+if (rVertOrient.GetRelationOrient() == 
text::RelOrientation::PAGE_PRINT_AREA)
+{
+// Growing from the bottom of the body frame.
+return false;
+}
+}
+
+return pFormat->GetFlySplit().GetValue();
 }
 
 SwFrame *SwFlyFrame::FindLastLower()


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-04 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/htmlexport/data/NestingInA1.fodt |   47 +
 sw/qa/extras/htmlexport/htmlexport.cxx|   69 ++
 sw/source/filter/html/wrthtml.cxx |   17 +++---
 3 files changed, 126 insertions(+), 7 deletions(-)

New commits:
commit 094fc93dfb5f9f6d441e63a8515c09d6165add00
Author: Mike Kaganski 
AuthorDate: Fri Aug 4 07:46:12 2023 +0300
Commit: Mike Kaganski 
CommitDate: Fri Aug 4 10:59:48 2023 +0200

tdf#156602: fix handling of nesting of tables in the document beginning

The old code only accounted for a single table in the document start,
finding the innermost table, and so ignoring any outer tables there.
Do the same as for nesting sections: find the outermost one.

Change-Id: Ide0e5bcf7c81e43fa5467da86e2e7e00a7076528
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155332
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/qa/extras/htmlexport/data/NestingInA1.fodt 
b/sw/qa/extras/htmlexport/data/NestingInA1.fodt
new file mode 100644
index ..439ef0a57d42
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/NestingInA1.fodt
@@ -0,0 +1,47 @@
+
+
+
+ 
+  
+   
+
+
+ 
+  
+   
+   
+
+ Inner.A1
+
+
+ Inner.B1
+
+   
+   
+
+ Inner.A2
+
+
+ Inner.B2
+
+   
+  
+  Outer.A1
+ 
+ 
+  Outer.B1
+ 
+
+
+ 
+  Outer.A2
+ 
+ 
+  Outer.B2
+ 
+
+   
+   Following text
+  
+ 
+
\ No newline at end of file
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx 
b/sw/qa/extras/htmlexport/htmlexport.cxx
index ab825a735fa7..becda28a832a 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -2645,6 +2645,75 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, 
testSingleOleExport)
 CPPUNIT_ASSERT_EQUAL(tools::Long(450), xReader->GetObjh());
 }
 
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_Tdf156602)
+{
+createSwDoc("NestingInA1.fodt");
+ExportToReqif();
+
+xmlDocUniquePtr pDoc = WrapReqifFromTempFile();
+
+// The outer table must be kept in the document where the outer table is 
the first element,
+// and its A1 starts with a nested table
+
+// Only two sub-elements must be inside the div: an outer table and a 
trailing paragraph
+assertXPathChildren(pDoc, "/reqif-xhtml:html/reqif-xhtml:div", 2);
+// The outer table must have exactly two rows
+assertXPath(pDoc, 
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr", 2);
+// First outer table cell must have two sub-elements: an inner table and a 
trailing paragraph
+assertXPathChildren(
+pDoc,
+
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr[1]/reqif-xhtml:td[1]",
+2);
+// The inner table must have exactly two rows
+assertXPath(
+pDoc,
+
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr[1]/reqif-xhtml:td[1]/"
+"reqif-xhtml:table/reqif-xhtml:tr",
+2);
+// Check all the elements' content
+assertXPathContent(
+pDoc,
+
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr[1]/reqif-xhtml:td[1]/"
+"reqif-xhtml:table/reqif-xhtml:tr[1]/reqif-xhtml:td[1]/reqif-xhtml:p",
+"Inner.A1");
+assertXPathContent(
+pDoc,
+
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr[1]/reqif-xhtml:td[1]/"
+"reqif-xhtml:table/reqif-xhtml:tr[1]/reqif-xhtml:td[2]/reqif-xhtml:p",
+"Inner.B1");
+assertXPathContent(
+pDoc,
+
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr[1]/reqif-xhtml:td[1]/"
+"reqif-xhtml:table/reqif-xhtml:tr[2]/reqif-xhtml:td[1]/reqif-xhtml:p",
+"Inner.A2");
+assertXPathContent(
+pDoc,
+
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr[1]/reqif-xhtml:td[1]/"
+"reqif-xhtml:table/reqif-xhtml:tr[2]/reqif-xhtml:td[2]/reqif-xhtml:p",
+"Inner.B2");
+assertXPathContent(
+pDoc,
+
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr[1]/reqif-xhtml:td[1]/"
+"reqif-xhtml:p",
+"Outer.A1");
+assertXPathContent(
+pDoc,
+
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr[1]/reqif-xhtml:td[2]/"
+"reqif-xhtml:p",
+"Outer.B1");
+assertXPathContent(
+pDoc,
+
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr[2]/reqif-xhtml:td[1]/"
+"reqif-xhtml:p",
+"Outer.A2");
+assertXPathContent(
+pDoc,
+
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:table/reqif-xhtml:tr[2]/reqif-xhtml:td[2]/"
+"reqif-xhtml:p",
+"Outer.B2");
+assertXPathContent(pDoc, 
"/reqif-xhtml:html/reqif-xhtml:div/reqif-x

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-03 Thread László Németh (via logerrit)
 sw/qa/uitest/table/tdf146145.py |   32 
 sw/source/core/crsr/trvltbl.cxx |2 +-
 sw/source/core/frmedt/fetab.cxx |   26 --
 3 files changed, 49 insertions(+), 11 deletions(-)

New commits:
commit d17b16215629ff078d5707309115233d4752f7d8
Author: László Németh 
AuthorDate: Thu Aug 3 12:00:07 2023 +0200
Commit: László Németh 
CommitDate: Thu Aug 3 14:53:59 2023 +0200

tdf#156595 sw tracked table column: fix crash at row deletion

In Hide Changes mode, deleting a row, which has
a hidden column deletion before the first cell,
resulted a crash because of missing cell frame/table
cursor.

Regression from commit aff269c18b9029fec992135a406dc5031927c401
"tdf#155345 sw tracked table column: hide them in Hide Changes mode".

Note: it seems, plain uiwriter testing is not enough to catch
the problem.

Change-Id: I12675ecd402d6411107b90809728454f13e60580
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155287
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sw/qa/uitest/table/tdf146145.py b/sw/qa/uitest/table/tdf146145.py
index 84cda61a6cd1..55d2092ca51e 100644
--- a/sw/qa/uitest/table/tdf146145.py
+++ b/sw/qa/uitest/table/tdf146145.py
@@ -250,4 +250,36 @@ class tdf146145(UITestCase):
 xToolkit.processEventsToIdle()
 self.assertEqual(len(tables[0].getColumns()), 5)
 
+   def test_crashWithHiddenFirstTableColumn(self):
+with 
self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as 
self.document:
+
+# accept all tracked changes
+self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges")
+# delete first table column
+self.xUITest.executeCommand(".uno:DeleteColumns")
+
+# Check enabling Accept/Reject Track Change icons
+# and Accept Change/Reject Change context menu items
+# on table columns with tracked deletion or insertion
+
+# enable Track Changes toolbar
+
self.xUITest.executeCommand(".uno:AvailableToolbars?Toolbar:string=changes")
+
+xToolkit = 
self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+xToolkit.processEventsToIdle()
+
+# cursor at changed text: Accept Track Change is enabled
+self.assertTrue(self.is_enabled_Accept_Track_Change())
+
+# hide changes
+self.xUITest.executeCommand(".uno:ShowTrackedChanges")
+while self.is_enabled_Accept_Track_Change():
+time.sleep(0.1)
+self.assertFalse(self.is_enabled_Accept_Track_Change())
+
+# Without the fix in place, this test would have crashed here
+self.xUITest.executeCommand(".uno:DeleteRows")
+
+self.xUITest.executeCommand(".uno:ShowTrackedChanges")
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx
index 0aaa899b5a46..689457d02863 100644
--- a/sw/source/core/crsr/trvltbl.cxx
+++ b/sw/source/core/crsr/trvltbl.cxx
@@ -128,7 +128,7 @@ bool SwCursorShell::SelTableRowOrCol( bool bRow, bool 
bRowSimple )
 {
 // check if the current cursor's SPoint/Mark are in a table
 SwFrame *pFrame = GetCurrFrame();
-if( !pFrame->IsInTab() )
+if( !pFrame || !pFrame->IsInTab() )
 return false;
 
 const SwTabFrame* pTabFrame = pFrame->FindTabFrame();
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index 8a6a664fe206..a766596daa29 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -535,18 +535,24 @@ bool SwFEShell::DeleteRow(bool bCompleteTable)
 if ( SwWrtShell* pWrtShell = dynamic_cast(this) )
 {
 pWrtShell->SelectTableRow();
-SwShellTableCursor* pTableCursor = GetTableCursor();
+SwCursor* pTableCursor = 
static_cast(GetTableCursor());
 auto pStt = aBoxes[0];
 auto pEnd = aBoxes.back();
-pTableCursor->DeleteMark();
-
-// set start and end of the selection
-pTableCursor->GetPoint()->Assign( 
*pEnd->GetSttNd()->EndOfSectionNode() );
-pTableCursor->Move( fnMoveBackward, GoInContent );
-pTableCursor->SetMark();
-pTableCursor->GetPoint()->Assign( 
*pStt->GetSttNd()->EndOfSectionNode() );
-pTableCursor->Move( fnMoveBackward, GoInContent );
-pWrtShell->UpdateCursor();
+if ( pTableCursor )
+pTableCursor->DeleteMark();
+else
+pTableCursor = GetCursor(true);
+
+if ( pTableCursor )
+{
+// set start and end of the se

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-03 Thread Hossein (via logerrit)
 sw/qa/extras/uiwriter/data/tdf156560.docx |binary
 sw/qa/extras/uiwriter/uiwriter8.cxx   |   16 
 sw/source/core/layout/paintfrm.cxx|4 
 3 files changed, 20 insertions(+)

New commits:
commit a99a63287f96290f5641a4216432f7b637402ea6
Author: Hossein 
AuthorDate: Tue Aug 1 14:48:26 2023 +0200
Commit: Hossein 
CommitDate: Thu Aug 3 11:41:27 2023 +0200

tdf#156560 Fix assertion failure editing RTL header

Clicking on an RTL header previously lead to assertion failure, but now
it is checked if the SwFrame pointer is null. If so, an empty vector is
returned.

It should be noted that the rendering of the rtl header in the
attachment 188689 is still wrong as the text and image are misplaced.

A test is added to the patch, and can be run using:

 make CppunitTest_sw_uiwriter8 CPPUNIT_TEST_NAME=testTdf156560

Change-Id: I9e8f66895b4ef9369300c9d7c03d22a2085a1d71
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155159
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/sw/qa/extras/uiwriter/data/tdf156560.docx 
b/sw/qa/extras/uiwriter/data/tdf156560.docx
new file mode 100755
index ..8cfd5501914c
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf156560.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 48b17ef211ea..621fecc6fd98 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -2674,6 +2674,22 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, 
testTdf62032ApplyStyle)
  getProperty(getParagraph(2), 
"ListLabelString").trim());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf156560)
+{
+createSwDoc("tdf156560.docx");
+
+uno::Reference 
xPageStyle(getStyles("PageStyles")->getByName("Standard"),
+   uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(true, getProperty(xPageStyle, "HeaderIsOn"));
+
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_MOD1 | KEY_PAGEUP);
+
+// Insert header
+// Without the fix in place, this test would have got SIGABRT here
+dispatchCommand(mxComponent, ".uno:InsertHeader", {});
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/paintfrm.cxx 
b/sw/source/core/layout/paintfrm.cxx
index 7c757e4d19ca..8b44b33445d5 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -7070,6 +7070,10 @@ std::vector 
SwPageFrame::GetSubsidiaryLinesPolygons(const S
 const SwFrame* pLay = Lower();
 const SwFrame* pFootnoteCont = nullptr;
 const SwFrame* pPageBody = nullptr;
+
+if (!pLay)
+return aPolygons;
+
 while ( pLay && !( pFootnoteCont && pPageBody ) )
 {
 if ( pLay->IsFootnoteContFrame( ) )


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-03 Thread Miklos Vajna (via logerrit)
 sw/qa/core/frmedt/data/floating-table-caption.docx |binary
 sw/qa/core/frmedt/frmedt.cxx   |   28 +
 sw/source/core/frmedt/fews.cxx |   18 -
 3 files changed, 45 insertions(+), 1 deletion(-)

New commits:
commit 107de1a2c6882213cf0ef6783417302f43cdada0
Author: Miklos Vajna 
AuthorDate: Thu Aug 3 08:50:39 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Aug 3 09:30:38 2023 +0200

tdf#156349 sw floattable: fix caption insert for tables inside split fly 
frames

Inserting a long enough caption below the table inside a split fly
resulted in a layout loop.

An additional, second problem is that in case a split fly only has a
table, that can be mapped to a floating table in Word formats, but once
a caption is inserted after the table (but still inside the frame), then
this will be a normal shape, which can't be split.

Fix the problem by disabling the "is split allowed" property on the fly
in case it's on, and only then insert the caption.

This not only avoids the layout loop, it also results in rendering that
will match after save + load, for Word formats.

Change-Id: Ie8b04e6266dd5c4068e5add86efb09cc6a6ea01f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155276
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/frmedt/data/floating-table-caption.docx 
b/sw/qa/core/frmedt/data/floating-table-caption.docx
new file mode 100644
index ..18c4690322d8
Binary files /dev/null and b/sw/qa/core/frmedt/data/floating-table-caption.docx 
differ
diff --git a/sw/qa/core/frmedt/frmedt.cxx b/sw/qa/core/frmedt/frmedt.cxx
index 26c64c0833f8..f5a12e9392f1 100644
--- a/sw/qa/core/frmedt/frmedt.cxx
+++ b/sw/qa/core/frmedt/frmedt.cxx
@@ -23,6 +23,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 /// Covers sw/source/core/frmedt/ fixes.
 class SwCoreFrmedtTest : public SwModelTestBase
@@ -168,6 +171,31 @@ CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, 
testTextBoxSelectCursorPos)
 CPPUNIT_ASSERT_EQUAL(nAnchor, nCursor);
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, testSplitFlyInsertCaption)
+{
+// Given a document with a full-page floating table:
+createSwDoc("floating-table-caption.docx");
+
+// When trying to insert a caption below that table:
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+pWrtShell->GotoTable("Table1");
+InsCaptionOpt aOpt;
+SwView& rView = pWrtShell->GetView();
+aOpt.SetCategory("Table");
+aOpt.SetCaption("Numbers English-German");
+// After, not before.
+aOpt.SetPos(1);
+// Without the accompanying fix in place, this call never finished, layout 
didn't handle content
+// after the table in a floating table.
+rView.InsertCaption(&aOpt);
+
+// Then make sure the insertion finishes and now this is just a plain 
table-in-frame:
+SwDoc* pDoc = getSwDoc();
+sw::SpzFrameFormats& rFlys = *pDoc->GetSpzFrameFormats();
+sw::SpzFrameFormat* pFly = rFlys[0];
+CPPUNIT_ASSERT(!pFly->GetAttrSet().GetFlySplit().GetValue());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx
index c89e26cf6a2c..cb26f3357225 100644
--- a/sw/source/core/frmedt/fews.cxx
+++ b/sw/source/core/frmedt/fews.cxx
@@ -50,6 +50,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace com::sun::star;
 
@@ -452,9 +453,24 @@ void SwFEShell::InsertLabel( const SwLabelType eType, 
const OUString &rText, con
 if( pCnt->IsInTab() )
 {
 // pass down index to the TableNode for tables
-const SwTable& rTable = *pCnt->FindTabFrame()->GetTable();
+SwTabFrame* pTabFrame = pCnt->FindTabFrame();
+const SwTable& rTable = *pTabFrame->GetTable();
 nIdx = rTable.GetTabSortBoxes()[ 0 ]
 ->GetSttNd()->FindTableNode()->GetIndex();
+
+SwFlyFrame* pFly = pTabFrame->FindFlyFrame();
+if (pFly && pFly->IsFlySplitAllowed())
+{
+// This table is in a split fly, but we will insert a label, 
which means this is not
+// a floating table anymore, disable the "can split" bit, 
it'll be hidden on the UI
+// anyway.
+SwFrameFormat& rFlyFormat = pFly->GetFrameFormat();
+SfxItemSetFixed 
aSet(GetDoc()->GetAttrPool());
+SwFormatFlySplit aSplit(false);
+aSet.Put(aSplit);
+// SwUndoFormatAttr is created for us.
+GetDoc()->SetFlyFrameAttr(rFlyFormat, aSet);
+}
 }
 break;
 case SwLabelType::Draw:


[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-02 Thread Miklos Vajna (via logerrit)
 sw/qa/core/text/data/floattable-avoid-last-manip-ofst.docx |binary
 sw/qa/core/text/frmform.cxx|   37 +
 sw/source/core/text/frmform.cxx|   20 +--
 3 files changed, 54 insertions(+), 3 deletions(-)

New commits:
commit b6a22e2be79cd874c7526107a6793fae692620dc
Author: Miklos Vajna 
AuthorDate: Wed Aug 2 09:56:49 2023 +0200
Commit: Miklos Vajna 
CommitDate: Wed Aug 2 10:57:00 2023 +0200

tdf#156260 sw floattable: avoid moving text from the last anchor to its 
precede

The 5 page long bugdoc had a "dt" in the last paragraph, expanding that
to an actual dummy text with F3 resulted in anchor text on both page 4
and page 5, while the expected behavior is that text only wraps on the
last page, i.e. page 5.

What happened is that the (text) "offset" of the text frame anchors on
pages 1..5 are meant to be all 0 (so the actual anchor text is only on
the last page), but in practice the anchor text frame on page 5 had an
offset of 1123, which breaks the invariant that in case a fly frame is
split to N pages, then only the last matching anchor text frame has
text. (If it has too much text, then a next page with just anchor text
is fine, but 0..N-1 pages should have no anchor text.)

Fix the problem by SwTextFrame::AdjustFollow_(): in case it would reach
the end for the "has follow, but no follow's follow" case, then still
avoid setting the offset of the follow in case we know this is text
frame has a non-last split fly anchored in it.

With this, the render result matches in no overlaps and also what Word
does in a similar edit session. (No F3 there, but can paste similar text
at the document end.)

Change-Id: I6c8d4f825d9dc356bb2a3a87a2f9c2e6529ce533
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155209
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/text/data/floattable-avoid-last-manip-ofst.docx 
b/sw/qa/core/text/data/floattable-avoid-last-manip-ofst.docx
new file mode 100644
index ..017b3001b813
Binary files /dev/null and 
b/sw/qa/core/text/data/floattable-avoid-last-manip-ofst.docx differ
diff --git a/sw/qa/core/text/frmform.cxx b/sw/qa/core/text/frmform.cxx
index d23611a7eb05..f2f942bde324 100644
--- a/sw/qa/core/text/frmform.cxx
+++ b/sw/qa/core/text/frmform.cxx
@@ -17,6 +17,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 namespace
 {
@@ -79,6 +81,41 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableAvoidManipOfst)
 // anchors of non-last split fly frames should contain no text.
 CPPUNIT_ASSERT_EQUAL(static_cast(0), 
pAnchor->GetOffset().get());
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testFloattableAvoidLastManipOfst)
+{
+// Given a document with a 5-page floating table and some anchor text:
+createSwDoc("floattable-avoid-last-manip-ofst.docx");
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+pWrtShell->SttEndDoc(/*bStt=*/false);
+pWrtShell->Insert2("dt");
+
+// When expanding dummy text on the last page:
+dispatchCommand(mxComponent, ".uno:ExpandGlossary", {});
+
+// Then make sure the expanded text starts on page 5:
+SwDoc* pDoc = getSwDocShell()->GetDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = dynamic_cast(pLayout->Lower());
+CPPUNIT_ASSERT(pPage1);
+auto pPage2 = dynamic_cast(pPage1->GetNext());
+CPPUNIT_ASSERT(pPage2);
+auto pPage3 = dynamic_cast(pPage2->GetNext());
+CPPUNIT_ASSERT(pPage3);
+auto pPage4 = dynamic_cast(pPage3->GetNext());
+CPPUNIT_ASSERT(pPage4);
+auto pPage5 = dynamic_cast(pPage4->GetNext());
+CPPUNIT_ASSERT(pPage5);
+SwContentFrame* pAnchor = pPage5->FindFirstBodyContent();
+SwTextFrame* pAnchorText = pAnchor->DynCastTextFrame();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 0
+// - Actual  : 1123
+// i.e. the expand result went to page 4 and page 5 (page 5's content had 
no zero offset),
+// instead of starting on page 5 (and creating a 6th page).
+CPPUNIT_ASSERT_EQUAL(static_cast(0),
+ static_cast(pAnchorText->GetOffset()));
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index 78ac57637ce1..0b63c796d913 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -602,7 +602,8 @@ void SwTextFrame::AdjustFollow_( SwTextFormatter &rLine,
 // We got the rest of the text mass: Delete all Follows
 // DummyPortions() are a special case.
 // Special cases are controlled by parameter .
-if( HasFollow() && !(nMode & 1) && nOffset == nEnd )
+bool bDontJoin = nMode & 1;
+if( HasFollow() && !bDontJoin && nOffset == nEnd )
 {
 while( GetFollow() )
 {
@@ -

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-01 Thread László Németh (via logerrit)
 sw/qa/extras/uiwriter/uiwriter5.cxx |   76 
 sw/source/core/frmedt/fetab.cxx |4 +
 2 files changed, 79 insertions(+), 1 deletion(-)

New commits:
commit 33058b5dc47a140516669945efbdd30ea65138a6
Author: László Németh 
AuthorDate: Tue Aug 1 13:10:07 2023 +0200
Commit: László Németh 
CommitDate: Tue Aug 1 17:22:03 2023 +0200

tdf#156544 sw tracked table column: delete empty column

Empty table columns were removed without change tracking
in Record Changes mode, too.

Follow-up to commit fe43f5971dfd2a121634eea9e39c7ad0cf3f962a
"tdf#156475 sw tracked table column: delete empty cell".

Change-Id: I8154cb1c75cf793f5a60e8259a91dd779fc766e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155153
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx 
b/sw/qa/extras/uiwriter/uiwriter5.cxx
index 07579cc6662a..3e8babfff390 100644
--- a/sw/qa/extras/uiwriter/uiwriter5.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter5.cxx
@@ -2701,6 +2701,82 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf155747)
 assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156544)
+{
+// load a table, and insert a column without change tracking,
+// and delete the first column with the empty cell in the second row with 
change tracking
+createSwDoc("tdf118311.fodt");
+SwDoc* pDoc = getSwDoc();
+
+// turn off red-lining and show changes
+pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::ShowDelete
+  | 
RedlineFlags::ShowInsert);
+CPPUNIT_ASSERT_MESSAGE("redlining should be off",
+   !pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+CPPUNIT_ASSERT_MESSAGE(
+"redlines should be visible",
+
IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+// insert table column without change tracking
+// (HasTextChangesOnly property of the cell will be false)
+dispatchCommand(mxComponent, ".uno:InsertColumnsBefore", {});
+
+// check table
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "//page[1]//body/tab");
+assertXPath(pXmlDoc, "//page[1]//body/tab/row", 1);
+assertXPath(pXmlDoc, "//page[1]//body/tab/row[1]/cell", 3);
+
+// turn on red-lining
+pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | 
RedlineFlags::ShowDelete
+  | 
RedlineFlags::ShowInsert);
+CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+   pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+// go to the empty column
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+
+// delete table column with enabled change tracking
+// (HasTextChangesOnly property of the cell will be false)
+dispatchCommand(mxComponent, ".uno:DeleteColumns", {});
+
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "//page[1]//body/tab");
+assertXPath(pXmlDoc, "//page[1]//body/tab/row", 1);
+
+// This was 2 (deleted column)
+assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 3);
+
+// accept the deletion of the empty column
+dispatchCommand(mxComponent, ".uno:AcceptTrackedChange", {});
+
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "//page[1]//body/tab");
+assertXPath(pXmlDoc, "//page[1]//body/tab/row", 1);
+assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2);
+
+// test Undo/Redo
+dispatchCommand(mxComponent, ".uno:Undo", {});
+
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "//page[1]//body/tab");
+assertXPath(pXmlDoc, "//page[1]//body/tab/row", 1);
+assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 3);
+
+dispatchCommand(mxComponent, ".uno:Redo", {});
+
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "//page[1]//body/tab");
+assertXPath(pXmlDoc, "//page[1]//body/tab/row", 1);
+assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2);
+}
+
 #ifndef DBG_UTIL
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf149498)
 {
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index c271d975d567..8a6a664fe206 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -283,6 +283,7 @@ bool SwFEShell::DeleteCol()
 // and set IsNoTracked table box property to false
 if ( GetDoc()->GetDocShell()->IsChangeRecording() )
 {
+bool bDeletedEmptyCell = false;
 StartUndo(SwUndoId::COL_DELETE);
 StartAllAction();
 
@@ -317,6 +318,7 @@ bool SwFEShell::DeleteCol()
  

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-01 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/ooxmlexport/data/longBookmarkName.fodt |   13 +
 sw/qa/extras/ooxmlexport/ooxmlexport19.cxx  |   31 
 sw/source/filter/ww8/docxattributeoutput.cxx|   32 ++---
 sw/source/filter/ww8/docxattributeoutput.hxx|2 
 sw/source/filter/ww8/wrtw8nds.cxx   |   42 -
 sw/source/filter/ww8/wrtww8.cxx |   49 
 sw/source/filter/ww8/wrtww8.hxx |   10 +++-
 sw/source/filter/ww8/ww8atr.cxx |   14 ++---
 8 files changed, 128 insertions(+), 65 deletions(-)

New commits:
commit 38feff6a04b2785b219fabe7172c857e97ef90ae
Author: Mike Kaganski 
AuthorDate: Mon Jul 31 15:08:58 2023 +0300
Commit: Mike Kaganski 
CommitDate: Tue Aug 1 10:36:30 2023 +0200

tdf#156548: make truncated long bookmark name unique, and use it in 
hyperlinks

Change-Id: I156359339ff8be85fe90cb6612eafdc6030c851f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155092
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlexport/data/longBookmarkName.fodt 
b/sw/qa/extras/ooxmlexport/data/longBookmarkName.fodt
new file mode 100644
index ..8b09760fcb6f
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/longBookmarkName.fodt
@@ -0,0 +1,13 @@
+
+
+http://www.w3.org/1999/xlink"; 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ 
+  
+   This is a hyperlink 
to the first target paragraph below
+   This is a hyperlink 
to the second target paragraph below
+   
+   The first target 
paragraph with a bookmark with a very long name
+   The second target 
paragraph with a bookmark with a very long name
+  
+ 
+
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
index 6e784193ba97..69a3fc137acb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
@@ -1059,6 +1059,37 @@ DECLARE_OOXMLEXPORT_TEST(testTdf156372, "tdf156372.doc")
 CPPUNIT_ASSERT_EQUAL(1, getPages());
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf156548)
+{
+// Given a document using two bookmarks with similar names longer than 40 
characters
+loadAndReload("longBookmarkName.fodt");
+
+// After the export, the names must be no longer than 40 characters; they 
must be unique;
+// and the hyperlinks must use the same names, to still point to the 
correct targets:
+
+{
+// 1st  paragraph - hyperlink to 4th paragraph
+auto sURL = getProperty(getRun(getParagraph(1), 1), 
"HyperLinkURL");
+
CPPUNIT_ASSERT_EQUAL(OUString("#A_bookmark_name_longer_than_forty_charac"), 
sURL);
+// 4th paragraph - a bookmark
+auto xBookmark = 
getProperty>(getRun(getParagraph(4), 1),
+
"Bookmark");
+
CPPUNIT_ASSERT_EQUAL(OUString("A_bookmark_name_longer_than_forty_charac"),
+ xBookmark->getName());
+}
+
+{
+// 2nd  paragraph - hyperlink to 5th paragraph
+auto sURL = getProperty(getRun(getParagraph(2), 1), 
"HyperLinkURL");
+
CPPUNIT_ASSERT_EQUAL(OUString("#A_bookmark_name_longer_than_forty_chara1"), 
sURL);
+// 5th paragraph - a bookmark
+auto xBookmark = 
getProperty>(getRun(getParagraph(5), 1),
+
"Bookmark");
+
CPPUNIT_ASSERT_EQUAL(OUString("A_bookmark_name_longer_than_forty_chara1"),
+ xBookmark->getName());
+}
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index c97000ca3e4b..ec55455d5d3c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2170,11 +2170,11 @@ void DocxAttributeOutput::EndRun(const SwTextNode* 
pNode, sal_Int32 nPos, sal_In
 DoWriteBookmarkEndIfExist(nPos);
 }
 
-void DocxAttributeOutput::DoWriteBookmarkTagStart(std::u16string_view 
bookmarkName)
+void DocxAttributeOutput::DoWriteBookmarkTagStart(const OUString& bookmarkName)
 {
 m_pSerializer->singleElementNS(XML_w, XML_bookmarkStart,
 FSNS(XML_w, XML_id), OString::number(m_nNextBookmarkId),
-FSNS(XML_w, XML_name), BookmarkToWord(bookmarkName));
+FSNS(XML_w, XML_name), GetExport().BookmarkToWord(bookmarkName));
 }
 
 void DocxAttributeOutput::DoWriteBookmarkTagEnd(sal_Int32 const nId)
@@ -2230,7 +2230,7 @@ void 
DocxAttributeOutput::DoWriteBookmarkStartIfExist(sal_Int32 nRunPos)
 {
 DoWriteBookmarkTagStart(aIter->second);
 m_rOpenedBookmarksIds[aIter->second] = m_nNextBookmarkId;
-m_sLastOpenedBookmark = BookmarkToWord(aIter->second);
+m_sLas

[Libreoffice-commits] core.git: sw/qa sw/source

2023-08-01 Thread Miklos Vajna (via logerrit)
 sw/qa/core/doc/data/floating-table-dummy-text.docx  |binary
 sw/qa/core/doc/doc.cxx  |   33 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   21 ++
 3 files changed, 54 insertions(+)

New commits:
commit 073072f0a3abacfe4f9cc920b8138d7abc84db70
Author: Miklos Vajna 
AuthorDate: Tue Aug 1 09:06:43 2023 +0200
Commit: Miklos Vajna 
CommitDate: Tue Aug 1 09:59:02 2023 +0200

tdf#156260 sw floattable: avoid overlapping flys on anchor change

Going to the end of the document, typing "dt" and F3 collapses the
multi-page floating table into a single page, with overlapping text.

In practice we insert a new paragraph before the "dt" one, insert the
dummy text there and then re-anchor the floating table from the old
paragraph to the new one. Such re-anchoring isn't really meant to be
done with floating tables, which are always just anchored in the next
paragraph in practice. An additional problem is that the amount of fly
frames created depends on the position of the first fly frame, so if the
anchor changes, we may need a different number of split fly frames.

Fix the problem by not trying to reuse the old fly frames on anchor
change: delete the old frames, change the anchor and finally create the
new frames, which leads to correct layout with complicated logic trying
to update the old fly chain to the new anchor.

The original document still puts some dummy text on page 4 instead of
starting it on page 5, that part is still unfixed.

Change-Id: I74549e2ea8ca0d06a9e4814a58aaa8ca476263dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155122
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/doc/data/floating-table-dummy-text.docx 
b/sw/qa/core/doc/data/floating-table-dummy-text.docx
new file mode 100644
index ..14de5a920a88
Binary files /dev/null and b/sw/qa/core/doc/data/floating-table-dummy-text.docx 
differ
diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx
index 5b523067523a..f8faee3a1bcd 100644
--- a/sw/qa/core/doc/doc.cxx
+++ b/sw/qa/core/doc/doc.cxx
@@ -34,6 +34,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 /// Covers sw/source/core/doc/ fixes.
 class SwCoreDocTest : public SwModelTestBase
@@ -482,6 +486,35 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testSplitFlyChain)
 CPPUNIT_ASSERT_EQUAL(SwChainRet::IS_IN_CHAIN, eActual);
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testSplitExpandGlossary)
+{
+// Given a document with a split fly (2 pages) and a 'dt' at the end:
+createSwDoc("floating-table-dummy-text.docx");
+SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+pWrtShell->SttEndDoc(/*bStt=*/false);
+
+// When expanding 'dt' to an actual dummy text:
+dispatchCommand(mxComponent, ".uno:ExpandGlossary", {});
+
+// Then make sure the 2 fly frames stay on the 2 pages:
+SwDoc* pDoc = getSwDoc();
+SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+auto pPage1 = dynamic_cast(pLayout->Lower());
+CPPUNIT_ASSERT(pPage1);
+CPPUNIT_ASSERT(pPage1->GetSortedObjs());
+const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 2
+// i.e. both parts of the split fly chain were on page 1.
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size());
+auto pPage2 = dynamic_cast(pPage1->GetNext());
+CPPUNIT_ASSERT(pPage2);
+CPPUNIT_ASSERT(pPage2->GetSortedObjs());
+const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage2Objs.size());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 0b51fc65e46e..4ad364ea6afc 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -70,6 +70,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -5241,7 +5242,27 @@ bool 
DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
 {
 SwFormatAnchor anchor(*pAnchor);
 anchor.SetAnchor( &startPosAtPara );
+
+bool bSplitFly = false;
+if (pFly->GetFlySplit().GetValue())
+{
+SwIterator aIter(*pFly);
+bSplitFly = aIter.First() && aIter.Next();
+}
+if (bSplitFly)
+{
+// This fly format has multiple frames, and we change 
the anchor. Remove the
+// old frames, w

[Libreoffice-commits] core.git: sw/qa sw/source

2023-07-31 Thread Miklos Vajna (via logerrit)
 sw/qa/core/unocore/data/floattable-split.docx |binary
 sw/qa/core/unocore/unocore.cxx|   19 +++
 sw/source/core/inc/flyfrm.hxx |3 +++
 sw/source/core/layout/fly.cxx |5 +
 sw/source/core/unocore/unoobj2.cxx|   18 ++
 5 files changed, 45 insertions(+)

New commits:
commit 2b401b7c0322d9ff972d252208ebe9a77913778d
Author: Miklos Vajna 
AuthorDate: Mon Jul 31 08:24:03 2023 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jul 31 21:47:30 2023 +0200

tdf#156350 sw floattable: fix bad additional  in ODT with layout

The document has a floating table, split on two pages. Saving as ODT
creates two  elements, while we only expect one.

The document model is correct, SwDoc::mpSpzFrameFormatTable only
contains one frame, and in general the ODT export works with the SwDoc,
but CollectFrameAtNode() uses the layout to help performance, and the
layout is available when saving interactively (i.e. not --convert-to),
which visits both layout frames of the same frame format.

Fix the problem by ignoring follow fly frames in
lcl_CollectFrameAtNodeWithLayout(), just working from master should
ensure there is no duplication.

This is similar to 4721729fba32a02683ecc930b630491599f8c6c5
(SwXParaFrameEnumeration: ignore textboxes, 2014-05-27), but that was
for fly frames of draw shapes, and this is for split flys.

Change-Id: I09729c0b0f9afd694e3cbf8886ccbc530bfc9674
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155081
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/unocore/data/floattable-split.docx 
b/sw/qa/core/unocore/data/floattable-split.docx
new file mode 100644
index ..2e2c9c705df9
Binary files /dev/null and b/sw/qa/core/unocore/data/floattable-split.docx 
differ
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index 199da2e72a79..cb6f52d0fdbb 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -965,6 +965,25 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testTdf155951)
 xText->insertString(xCursor, "test", /*bAbsorb=*/false);
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testCollectFrameAtNodeWithLayout)
+{
+// Given a document with a floating table on 2 pages, with a calculated 
layout:
+createSwDoc("floattable-split.docx");
+calcLayout();
+
+// When saving to ODT:
+save("writer8");
+
+// Then make sure the output is valid and hasa 1 :
+// Without the accompanying fix in place, this test would have failed with:
+// Error: uncompleted content model.
+// i.e. the output was not valid, the second  has an empty 
 as a child
+// element.
+xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
+// Also make sure that we don't have multiple  elements in the 
first place.
+assertXPath(pXmlDoc, "//draw:frame", 1);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index bbcf2845e5d7..6083fd67d266 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -38,6 +38,7 @@ class SwFormat;
 class SwViewShell;
 class SwFEShell;
 class SwWrtShell;
+class SwFlyAtContentFrame;
 
 
 /** search an anchor for paragraph bound frames starting from pOldAnch
@@ -307,6 +308,8 @@ public:
 virtual const SwFlyFrame* DynCastFlyFrame() const override;
 virtual SwFlyFrame* DynCastFlyFrame() override;
 
+SwFlyAtContentFrame* DynCastFlyAtContentFrame();
+
 private:
 void UpdateUnfloatButton(SwWrtShell* pWrtSh, bool bShow) const;
 void PaintDecorators() const;
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 68184da48fd6..a365668c4ce2 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2100,6 +2100,11 @@ void SwFlyFrame::UpdateUnfloatButton(SwWrtShell* pWrtSh, 
bool bShow) const
 rMngr.SetUnfloatTableButton(this, bShow,  aTopRightPixel);
 }
 
+SwFlyAtContentFrame* SwFlyFrame::DynCastFlyAtContentFrame()
+{
+return IsFlyAtContentFrame() ? static_cast(this) : 
nullptr;
+}
+
 SwTwips SwFlyFrame::Grow_( SwTwips nDist, bool bTst )
 {
 SwRectFnSet aRectFnSet(this);
diff --git a/sw/source/core/unocore/unoobj2.cxx 
b/sw/source/core/unocore/unoobj2.cxx
index 01682ef48587..472babcd8243 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -48,6 +48,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -123,6 +125,22 @@ struct FrameClientSortListLess
 // Filter out textboxes, which are not interesting at a UNO level.
 if(SwTextBoxHelper::isTextBox(&rFormat, RES_FLYFRMFMT))
 continue;
+
+if (nAnchorType == RndStdIds::FLY_AT_PARA)
+{
+SwFlyF

[Libreoffice-commits] core.git: sw/qa sw/source

2023-07-28 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/htmlexport/htmlexport.cxx |   46 ++
 sw/source/core/doc/doclay.cxx  |   25 ++-
 sw/source/filter/basflt/shellio.cxx|   14 ++--
 sw/source/filter/html/htmlplug.cxx |   91 ++--
 sw/source/filter/html/wrthtml.cxx  |  104 ++---
 sw/source/filter/html/wrthtml.hxx  |2 
 sw/source/uibase/app/docsh.cxx |   14 +++-
 7 files changed, 193 insertions(+), 103 deletions(-)

New commits:
commit 2f9c1990a85b0e867400f5952095704e178680ad
Author: Mike Kaganski 
AuthorDate: Fri Jul 28 13:06:08 2023 +0300
Commit: Mike Kaganski 
CommitDate: Fri Jul 28 19:55:06 2023 +0200

ReqIF: allow to output a single selected OLE object

To do that, "SelectionOnly" boolean propertyvalue is supported in the
store arguments.

Change-Id: I265e802256a9a678779bbd021dde9b0c87ca08b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155012
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx 
b/sw/qa/extras/htmlexport/htmlexport.cxx
index ebeab5963eda..7571e3b3535e 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2725,6 +2726,51 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, 
testReqIF_FrameTextAsObjectAltText)
"Some text in frame & ");
 }
 
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testSingleOleExport)
+{
+// Given a document containing an embedded OLE object:
+createSwDoc("ole2.odt");
+
+// Create a selection for that object:
+auto 
xDrawPageSupplier(mxComponent.queryThrow());
+auto xDrawPage(xDrawPageSupplier->getDrawPage());
+auto xModel(mxComponent.queryThrow());
+auto 
xController(xModel->getCurrentController().queryThrow());
+xController->select(xDrawPage->getByIndex(0));
+
+// Store only the selection
+auto xStorable(mxComponent.queryThrow());
+css::uno::Sequence aStoreProperties = {
+comphelper::makePropertyValue("FilterName", OUString("HTML 
(StarWriter)")),
+comphelper::makePropertyValue("FilterOptions", 
OUString("xhtmlns=reqif-xhtml")),
+comphelper::makePropertyValue("RTFOLEMimeType", OUString("text/rtf")),
+comphelper::makePropertyValue("SelectionOnly", true),
+};
+xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties);
+
+SvMemoryStream aStream;
+WrapReqifFromTempFile(aStream);
+xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream);
+
+// The root element must be reqif-xhtml:object
+assertXPath(pXmlDoc, "/reqif-xhtml:html/reqif-xhtml:object", "type", 
"text/rtf");
+// It has no children
+assertXPathChildren(pXmlDoc, "/reqif-xhtml:html/reqif-xhtml:object", 0);
+// And the content is empty
+assertXPathContent(pXmlDoc, "/reqif-xhtml:html/reqif-xhtml:object", "");
+
+OUString aRtfData = getXPath(pXmlDoc, 
"/reqif-xhtml:html/reqif-xhtml:object", "data");
+INetURLObject aUrl(maTempFile.GetURL());
+aUrl.setName(aRtfData);
+SvMemoryStream aRtf;
+
HtmlExportTest::wrapRtfFragment(aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE),
 aRtf);
+tools::SvRef xReader(new TestReqIfRtfReader(aRtf));
+// The RTF OLE exports correctly
+CPPUNIT_ASSERT(xReader->CallParser() != SvParserState::Error);
+CPPUNIT_ASSERT_EQUAL(tools::Long(9358), xReader->GetObjw());
+CPPUNIT_ASSERT_EQUAL(tools::Long(450), xReader->GetObjh());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 48e77a284d77..b6398ee8ce7f 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -499,6 +499,13 @@ SwPosFlyFrames SwDoc::GetAllFlyFormats( const SwPaM* 
pCmpRange, bool bDrawAlso,
bool bAsCharAlso ) const
 {
 SwPosFlyFrames aRetval;
+const SwStartNode* pDirectFly = nullptr;
+if (pCmpRange && *pCmpRange->GetPoint() == *pCmpRange->GetMark()
+&& (pCmpRange->GetPoint()->GetNode().IsOLENode()
+|| pCmpRange->GetPoint()->GetNode().IsGrfNode()))
+{
+pDirectFly = pCmpRange->GetPoint()->GetNode().FindFlyStartNode();
+}
 
 // collect all anchored somehow to paragraphs
 for(sw::SpzFrameFormat* pFly: *GetSpzFrameFormats())
@@ -509,11 +516,23 @@ SwPosFlyFrames SwDoc::GetAllFlyFormats( const SwPaM* 
pCmpRange, bool bDrawAlso,
 {
 const SwFormatAnchor& rAnchor = pFly->GetAnchor();
 SwNode const*const pAnchorNode = rAnchor.GetAnchorNode();
-if (pAnchorNode &&
-((RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId()) ||
+if (!pAnchorNode)
+continue;
+if (pDirectFly)
+{
+const SwFormatContent& rContent = pFly->GetContent();
+  

[Libreoffice-commits] core.git: sw/qa sw/source

2023-07-27 Thread László Németh (via logerrit)
 sw/qa/extras/uiwriter/uiwriter5.cxx |   63 
 sw/source/core/frmedt/fetab.cxx |   17 +
 2 files changed, 80 insertions(+)

New commits:
commit fe43f5971dfd2a121634eea9e39c7ad0cf3f962a
Author: László Németh 
AuthorDate: Thu Jul 27 15:40:52 2023 +0200
Commit: László Németh 
CommitDate: Thu Jul 27 23:45:53 2023 +0200

tdf#156475 sw tracked table column: delete empty cell

Tracking changes, only non-empty cells of the deleted
columns got coloring, and were hidden in Hide Changes
mode.

Add dummy text content to empty cells of the deleted
columns to get visible deletion in Show Changes mode,
also working context menu in that cell; to allow hiding
them in Hide Changes mode, also to store the time stamp
of the deletion, if all the other rows are removed during
editing.

Follow-up to commit 472abf99a4d90d7a53316394a2e51a26b7e62345
"tdf#155341 sw tracked table column: add insertion".

Change-Id: Ieb5d237b3c82c81fded25608ef3d2906d7474003
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154994
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx 
b/sw/qa/extras/uiwriter/uiwriter5.cxx
index 937567b9b2bc..07579cc6662a 100644
--- a/sw/qa/extras/uiwriter/uiwriter5.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter5.cxx
@@ -2605,6 +2605,69 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156474)
 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, tdf156475)
+{
+// load a table, and insert a row without change tracking,
+// and delete the first column with the empty cell in the second row with 
change tracking
+createSwDoc("tdf118311.fodt");
+SwDoc* pDoc = getSwDoc();
+
+// turn off red-lining and show changes
+pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::ShowDelete
+  | 
RedlineFlags::ShowInsert);
+CPPUNIT_ASSERT_MESSAGE("redlining should be off",
+   !pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+CPPUNIT_ASSERT_MESSAGE(
+"redlines should be visible",
+
IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+// insert table row
+dispatchCommand(mxComponent, ".uno:InsertRowsAfter", {});
+
+// check table
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "//page[1]//body/tab");
+assertXPath(pXmlDoc, "//page[1]//body/tab/row", 2);
+assertXPath(pXmlDoc, "//page[1]//body/tab/row[1]/cell", 2);
+assertXPath(pXmlDoc, "//page[1]//body/tab/row[2]/cell", 2);
+
+// turn on red-lining
+pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | 
RedlineFlags::ShowDelete
+  | 
RedlineFlags::ShowInsert);
+CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+   pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+// delete table column with enabled change tracking
+// (HasTextChangesOnly property of the cell will be false)
+dispatchCommand(mxComponent, ".uno:DeleteColumns", {});
+
+// go down to the empty cell
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->Down(/*bSelect=*/false);
+
+// Without the fix in place, this couldn't work
+dispatchCommand(mxComponent, ".uno:AcceptTrackedChange", {});
+
+discardDumpedLayout();
+pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "//page[1]//body/tab");
+assertXPath(pXmlDoc, "//page[1]//body/tab/row", 2);
+assertXPath(pXmlDoc, "//page[1]//body/tab/row[1]/cell", 1);
+assertXPath(pXmlDoc, "//page[1]//body/tab/row[2]/cell", 1);
+
+// test Undo/Redo
+for (sal_Int32 i = 0; i < 4; ++i)
+{
+dispatchCommand(mxComponent, ".uno:Undo", {});
+}
+
+for (sal_Int32 i = 0; i < 4; ++i)
+{
+dispatchCommand(mxComponent, ".uno:Redo", {});
+}
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf155747)
 {
 // load a table, and delete the first column with enabled change tracking:
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index daca7b86bc9c..c271d975d567 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -37,6 +37,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -302,6 +304,21 @@ bool SwFEShell::DeleteCol()
 SwCursor aCursor( SwPosition(aIdx), nullptr );
 SvxPrintItem aHasTextChangesOnly(RES_PRINT, false);
 GetDoc()->SetBoxAttr( aCursor, aHasTextChangesOnly );
+
+// add dummy text content to the empty box for change tracking
+if ( pBox->IsEmpty() )
+{
+IDocumentContentOperations& rIDCO = 
GetDoc()

[Libreoffice-commits] core.git: sw/qa sw/source

2023-07-26 Thread László Németh (via logerrit)
 sw/qa/extras/uiwriter/uiwriter5.cxx   |   49 ++
 sw/source/core/doc/DocumentRedlineManager.cxx |3 -
 2 files changed, 50 insertions(+), 2 deletions(-)

New commits:
commit 7f0e31976793c2701110742eb3d7ef4858eec72a
Author: László Németh 
AuthorDate: Wed Jul 26 11:00:38 2023 +0200
Commit: László Németh 
CommitDate: Wed Jul 26 16:09:03 2023 +0200

tdf#156474 sw tracked table column: fix accept of insertion

Accepting tracked table column insertion didn't reset
HasTextChangesOnly bit of the table cells, resulting
blue/pink cells (i.e. column change) after modifying
only text content of the text, and later bad column
deletion at accepting text-only deletion and at rejecting
text-only insertion.

Follow-up to commit 472abf99a4d90d7a53316394a2e51a26b7e62345
"tdf#155341 sw tracked table column: add insertion".

Change-Id: I2e06e1b064d51c5e7cf8140a5fd7932e7be4f765
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154935
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx 
b/sw/qa/extras/uiwriter/uiwriter5.cxx
index dfe0cc80f7ec..937567b9b2bc 100644
--- a/sw/qa/extras/uiwriter/uiwriter5.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter5.cxx
@@ -2556,6 +2556,55 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, 
testRedlineTableColumnDeletion)
 assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156474)
+{
+// load a table, and insert a column with change tracking
+createSwDoc("tdf118311.fodt");
+SwDoc* pDoc = getSwDoc();
+
+// turn on red-lining and show changes
+pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | 
RedlineFlags::ShowDelete
+  | 
RedlineFlags::ShowInsert);
+CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+   pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+CPPUNIT_ASSERT_MESSAGE(
+"redlines should be visible",
+
IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+uno::Reference xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTextTablesSupplier->getTextTables(),
+uno::UNO_QUERY);
+
+// there is a table in the text with two columns
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+uno::Reference xTextTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getColumns()->getCount());
+
+// insert table column with enabled change tracking
+// (HasTextChangesOnly property of the cell will be false)
+dispatchCommand(mxComponent, ".uno:InsertColumnsBefore", {});
+
+// 3 columns
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount());
+
+// accept tracked changes: remove HasTextChangesOnly = false of the 
inserted cells
+dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {});
+
+// still 3 columns
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount());
+
+// delete the text content (dummy character of the previous text change) 
of the newly
+// inserted cell, and accept tracked changes
+SwWrtShell* const pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, 
/*bBasicCall=*/false);
+dispatchCommand(mxComponent, ".uno:SwBackspace", {});
+dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {});
+
+// This was 2 columns (not removed HasTextChangesOnly = false resulted 
column deletion
+// instead of deleting only content of the cell)
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf155747)
 {
 // load a table, and delete the first column with enabled change tracking:
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index efed70b44a1a..898590d6201b 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -517,8 +517,7 @@ namespace
 const SvxPrintItem *pHasBoxTextChangesOnlyProp =
 
pBox->GetFrameFormat()->GetAttrSet().GetItem(RES_PRINT);
 // table cell property "HasTextChangesOnly" is set and its value is 
false
-if ( bRejectDeletion && pHasBoxTextChangesOnlyProp &&
-!pHasBoxTextChangesOnlyProp->GetValue() )
+if ( pHasBoxTextChangesOnlyProp && 
!pHasBoxTextChangesOnlyProp->GetValue() )
 {
 SvxPrintItem aUnsetTracking(RES_PRINT, true);
 SwCursor aCursor( *pPos, nullptr );


[Libreoffice-commits] core.git: sw/qa sw/source

2023-07-19 Thread Satya (via logerrit)
 sw/qa/extras/ooxmlexport/data/tdf156372.doc |binary
 sw/qa/extras/ooxmlexport/ooxmlexport19.cxx  |   11 +++
 sw/source/core/layout/flowfrm.cxx   |6 --
 3 files changed, 15 insertions(+), 2 deletions(-)

New commits:
commit a3b76c2cb216a55d60fdf8b4533ac02c7f37c005
Author: Satya 
AuthorDate: Wed Jul 19 14:14:27 2023 +0530
Commit: Justin Luth 
CommitDate: Wed Jul 19 21:30:08 2023 +0200

tdf#156372 sw: Stop adding GetLower to every cell in header table

The code was doubling the lower spacing of the last paragraph
in every cell of the table. This change is to not add the space
when in tables, since that was intended to only apply
to the last paragraph in the header.

make CppunitTest_sw_ooxmlexport19 CPPUNIT_TEST_NAME=testTdf156372

Change-Id: Ia8c2b31e3e56302735e858c39f80cc35e190af6b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154643
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf156372.doc 
b/sw/qa/extras/ooxmlexport/data/tdf156372.doc
new file mode 100644
index ..3b8ade19f83d
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf156372.doc differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
index 329248532342..6e784193ba97 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
@@ -1048,6 +1048,17 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf150408_isLvl_RoundTrip)
 assertXPath(pXml, "/w:numbering/w:abstractNum/w:lvl[2]/w:isLgl");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf156372, "tdf156372.doc")
+{
+sal_Int32 nHeight = parseDump("//page[1]/header/tab/row[1]/infos/bounds", 
"height").toInt32();
+// Without a fix in place, this would fail with
+// - Expected: 847
+// - Actual  : 1327
+CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(847), nHeight, 5);
+
+CPPUNIT_ASSERT_EQUAL(1, getPages());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/flowfrm.cxx 
b/sw/source/core/layout/flowfrm.cxx
index f30c34938c20..981736de7004 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -1851,9 +1851,11 @@ SwTwips SwFlowFrame::CalcLowerSpace( const 
SwBorderAttrs* _pAttrs ) const
 // tdf#128195 Consider para spacing below last paragraph in header
 bool bHasSpacingBelowPara = 
m_rThis.GetUpper()->GetFormat()->getIDocumentSettingAccess().get(
 DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA);
-if (bHasSpacingBelowPara && !m_rThis.IsInFly() && 
m_rThis.FindFooterOrHeader() && !GetFollow()
-&& !m_rThis.GetIndNext())
+if (bHasSpacingBelowPara && !m_rThis.IsInTab() && !m_rThis.IsInFly()
+&& m_rThis.FindFooterOrHeader() && !GetFollow() && 
!m_rThis.GetIndNext())
+{
 nLowerSpace += _pAttrs->GetULSpace().GetLower() + 
_pAttrs->CalcLineSpacing();
+}
 
 return nLowerSpace;
 }


[Libreoffice-commits] core.git: sw/qa sw/source

2023-07-19 Thread Miklos Vajna (via logerrit)
 dev/null|binary
 sw/qa/core/layout/data/floattable-no-footer-overlap.doc |binary
 sw/qa/core/layout/flycnt.cxx|9 ++
 sw/source/core/layout/flowfrm.cxx   |   13 
 sw/source/core/layout/tabfrm.cxx|   50 +++-
 5 files changed, 70 insertions(+), 2 deletions(-)

New commits:
commit 45574624ff05673d44f11cd49e1af599133e
Author: Miklos Vajna 
AuthorDate: Wed Jul 19 08:29:01 2023 +0200
Commit: Miklos Vajna 
CommitDate: Wed Jul 19 12:17:50 2023 +0200

tdf#120262 sw floattable: no split when none of first row fits the vert 
space

The final problem with the bugdoc is that half row of the second
floating table was still on page 1, while it should be fully on page 2.

The reason for this was that first we thought we can't move forward,
since GetIndPrev() returns nullptr for a table that's inside a fly
frame. Then we thought it's a good idea to split, even if the split
would move the entire first row to the next page.

Fix the problem by:

- In SwTabFrame::MakeAll(), handle split flys after calling
  GetIndPrev(), an indirect prev of the anchor has the same meaning in
  this context.

- In SwTabFrame::Split(), fail for split flys in case only half of the first
  row's first line would fit, which gives an opporunity to call
  MoveFwd().

- In SwTabFrame::MakeAll(), call MoveFwd() in a way that it's not a
  problem that the GetIndPrev() call in MoveFwd() gives us a nullptr.

- At this point we don't split the table, we move it forward, but an
  empty master remains on page 1. Fix that by improving
  SwFlowFrame::MoveSubTree() to mark empty flys for deletion, similar to
  how it does the same for sections.

- Finally avoid a layout warning in SwTabFrame::MakeAll(), it's OK to
  try to split in case our split fly has a follow, we can move there on
  split failure.

Also bring the test document closed to the original bugdoc, so we can
assert the content on both pages.

Change-Id: I2d3f88342d91b3e256bc41416a9afb274a9309d1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154633
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/sw/qa/core/layout/data/floattable-no-footer-overlap.doc 
b/sw/qa/core/layout/data/floattable-no-footer-overlap.doc
new file mode 100644
index ..87e301189df5
Binary files /dev/null and 
b/sw/qa/core/layout/data/floattable-no-footer-overlap.doc differ
diff --git a/sw/qa/core/layout/data/floattable-no-footer-overlap.docx 
b/sw/qa/core/layout/data/floattable-no-footer-overlap.docx
deleted file mode 100644
index ca2f0d6d7244..
Binary files a/sw/qa/core/layout/data/floattable-no-footer-overlap.docx and 
/dev/null differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 106be77ceac2..a1e4c05c6c1d 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -950,7 +950,7 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyAnchorKeepWithNext)
 CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNoFooterOverlap)
 {
 // Given a document with 2 pages, a floating table on both pages:
-createSwDoc("floattable-no-footer-overlap.docx");
+createSwDoc("floattable-no-footer-overlap.doc");
 
 // When calculating the layout:
 calcLayout();
@@ -960,6 +960,13 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNoFooterOverlap)
 SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
 auto pPage1 = dynamic_cast(pLayout->Lower());
 CPPUNIT_ASSERT(pPage1);
+CPPUNIT_ASSERT(pPage1->GetSortedObjs());
+const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs();
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: 1
+// - Actual  : 2
+// i.e. part of the second table was on page 1.
+CPPUNIT_ASSERT_EQUAL(static_cast(1), rPage1Objs.size());
 auto pPage2 = dynamic_cast(pPage1->GetNext());
 // Without the accompanying fix in place, this test would have failed, 
there was no page 2, both
 // floating tables were on page 1.
diff --git a/sw/source/core/layout/flowfrm.cxx 
b/sw/source/core/layout/flowfrm.cxx
index fbcd6e14d159..f30c34938c20 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -693,6 +693,7 @@ void SwFlowFrame::MoveSubTree( SwLayoutFrame* pParent, 
SwFrame* pSibling )
 // disappear automatically.
 SwSectionFrame *pSct;
 
+SwFlyFrame* pFly = nullptr;
 if ( pOldParent && !pOldParent->Lower() &&
  ( pOldParent->IsInSct() &&
!(pSct = pOldParent->FindSctFrame())->ContainsContent() &&
@@ -700,6 +701,18 @@ void SwFlowFrame::MoveSubTree( SwLayoutFrame* pParent, 
SwFrame* pSibling )
 {
 pSct->DelEmpty( false );
 }
+else if (pOldParent && !pOldParent->Lower(

  1   2   3   4   5   6   7   8   9   10   >