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

2022-09-15 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/odfexport/data/table-in-frame-in-table-in-header-base.odt |binary
 sw/qa/extras/odfexport/odfexport.cxx   |   14 
+++
 sw/source/filter/xml/xmltble.cxx   |   40 
++
 sw/source/filter/xml/xmltexte.hxx  |4 +
 xmloff/source/text/txtparae.cxx|3 
 5 files changed, 45 insertions(+), 16 deletions(-)

New commits:
commit c43b50bf027def7054bc15187d61d61d9b132bd7
Author: Mike Kaganski 
AuthorDate: Tue Sep 13 20:42:22 2022 +0300
Commit: Xisco Fauli 
CommitDate: Thu Sep 15 10:09:43 2022 +0200

tdf#150927: properly handle nesting in tables

This re-implements the relevant part of commit
35021cd56b3b4e38035804087f215c80085564be, to follow the same
recursion logic that is used in SwXMLExport::ExportTable.

Additionally, it found a place where XML was still emitted
when collecting autostyles (breaks were exported); fixed.

Change-Id: I3b7eed06e0eca9ad20304b45db4c3e9d72478c9b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139901
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 58cb4fc7d17ae5b339c5ed6ae139e6ef2433c927)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139843
Reviewed-by: Xisco Fauli 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139930

diff --git 
a/sw/qa/extras/odfexport/data/table-in-frame-in-table-in-header-base.odt 
b/sw/qa/extras/odfexport/data/table-in-frame-in-table-in-header-base.odt
new file mode 100644
index ..44dbf0bdec69
Binary files /dev/null and 
b/sw/qa/extras/odfexport/data/table-in-frame-in-table-in-header-base.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx 
b/sw/qa/extras/odfexport/odfexport.cxx
index a907a3981cce..d57712f593bc 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -3154,6 +3154,20 @@ DECLARE_ODFEXPORT_EXPORTONLY_TEST(tdf135942, 
"nestedTableInFooter.odt")
 assertXPath(pXmlDoc, 
"/office:document-styles/office:automatic-styles/style:style[@style:family='table']",
 2);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, tdf150927)
+{
+// Similar to tdf135942
+
+loadAndReload("table-in-frame-in-table-in-header-base.odt");
+// All table autostyles should be collected, including nested, and must 
not crash.
+
+CPPUNIT_ASSERT_EQUAL(1, getPages());
+
+xmlDocUniquePtr pXmlDoc = parseExport("styles.xml");
+
+assertXPath(pXmlDoc, 
"/office:document-styles/office:automatic-styles/style:style[@style:family='table']",
 2);
+}
+
 DECLARE_ODFEXPORT_TEST(testGutterLeft, "gutter-left.odt")
 {
 CPPUNIT_ASSERT_EQUAL(1, getPages());
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index 3655949f522c..fae84d9be2c8 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -1209,6 +1209,30 @@ void SwXMLTextParagraphExport::exportTableAutoStyles() {
 }
 }
 
+void SwXMLTextParagraphExport::CollectTableLinesAutoStyles(const SwTableLines& 
rLines,
+   SwFrameFormat& 
rFormat, bool _bProgress)
+{
+// Follow SwXMLExport::ExportTableLines/ExportTableLine/ExportTableBox
+for (const SwTableLine* pLine : rLines)
+{
+for (SwTableBox* pBox : pLine->GetTabBoxes())
+{
+if (pBox->getRowSpan() <= 0)
+continue;
+if (pBox->GetSttNd())
+{
+if (rtl::Reference xCell = 
SwXCell::CreateXCell(, pBox))
+exportText(xCell, true /*bAutoStyles*/, _bProgress, true 
/*bExportParagraph*/);
+}
+else
+{
+// no start node -> merged cells: export subtable in cell
+CollectTableLinesAutoStyles(pBox->GetTabLines(), rFormat, 
_bProgress);
+}
+}
+}
+}
+
 void SwXMLTextParagraphExport::exportTable(
 const Reference < XTextContent > & rTextContent,
 bool bAutoStyles, bool _bProgress )
@@ -1245,21 +1269,7 @@ void SwXMLTextParagraphExport::exportTable(
 maTableNodes.push_back(pTableNd);
 m_TableFormats.emplace(pTableNd, 
::std::make_pair(SwXMLTextParagraphExport::FormatMap(), 
SwXMLTextParagraphExport::FormatMap()));
 // Collect all tables inside cells of this table, too
-const auto aCellNames = pXTable->getCellNames();
-for (const OUString& rCellName : aCellNames)
-{
-
css::uno::Reference xCell(
-pXTable->getCellByName(rCellName), 
css::uno::UNO_QUERY);
-if (!xCell)
-continue;
-auto xEnumeration = xCell->createEnumeration();
-while 

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

2022-04-05 Thread Michael Stahl (via logerrit)
 sw/qa/extras/odfimport/data/forcepoint101.fodt  |   13 +
 sw/qa/extras/odfimport/odfimport.cxx|6 ++
 sw/source/core/unocore/unodraw.cxx  |4 +++-
 sw/source/core/unocore/unoframe.cxx |1 +
 xmloff/source/text/XMLTextShapeImportHelper.cxx |   15 ++-
 5 files changed, 33 insertions(+), 6 deletions(-)

New commits:
commit 5188a1aa3c6ca44e6bdf0991546109fcd3ab3400
Author: Michael Stahl 
AuthorDate: Mon Apr 4 17:19:51 2022 +0200
Commit: Caolán McNamara 
CommitDate: Tue Apr 5 10:44:41 2022 +0200

forcepoint#101 sw: fix inserting at-page shapes to not set anchor pos

The problem is that for an at-page anchor SwXDrawPage::add() sets an
anchor position, but then a fieldmark is inserted and the node with the
anchor position is deleted.

The code that sets the surprising anchor position for at-page shape was
added in commit cf345e026fc0378c4436173c8064717c7db4d538 "Fix #91289#:
Draw objects anchored at page but without page number" and is similar to
the code for fly-frames added in commit
2e6d999cf8ceacabb94b11feee6ee0808c2a75bc "If no page number is given for
page bound frames, calculate it using cursor" except that it is missing
a check for GetPageNum() == 0, for no obvious reason.

The matching code to replace the anchor position with a page number is
in SwFlyFrameFormat::MakeFrames() and was added in commit
572a48cd16f6ce3a68ffead44a975698954dfe11 "Fix #85019#: Insertion of
flyframes without correct pagenumber"; it's not clear if this is only
needed for shapes inserted via the above 2 UNO APIs or also for shapes
inserted via UI.

Then there is the issue that the page number is set in
XMLTextShapeImportHelper::addShape() only after the shape is inserted,
which was added and commented in commit
b5fc47fe5c2892dd712e2bda922656eacbd932f1, earlier than all the above
commits; testing shows that if the page number is set before inserting
the shape, the shape ends up on the expected page anyway.

Let's change this:
1. the page number is set before inserting the shape
2. at-page anchor with page number is left as is
3. at-page anchor without page number gets anchor position and is changed
   to at-char

Change-Id: I2f874bec8424de5eee94cf022e3b49382eaa55f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132479
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132530
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/sw/qa/extras/odfimport/data/forcepoint101.fodt 
b/sw/qa/extras/odfimport/data/forcepoint101.fodt
new file mode 100644
index ..7210888262dc
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/forcepoint101.fodt
@@ -0,0 +1,13 @@
+
+http://openoffice.org/2009/office; 
xmlns:css3t="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:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:rpt="http://openoffice.org/2005/report; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns
 :config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:ooo="http://openoffice.org/2004/office; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d: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:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:drawooo="http://openoffice.org/2010/draw; 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:dom="http://www.w3.org/2001/xml-events; 
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="ur
 n:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:xforms="http://www.w3.org/2002/xforms;