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

2023-08-08 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/htmlexport/data/NestingInA1.fodt |   47 
 sw/qa/extras/htmlexport/htmlexport.cxx|  302 ++
 sw/qa/filter/html/html.cxx|   12 -
 sw/qa/inc/swmodeltestbase.hxx |5 
 sw/qa/unit/swmodeltestbase.cxx|   15 -
 sw/source/filter/html/wrthtml.cxx |   17 -
 6 files changed, 193 insertions(+), 205 deletions(-)

New commits:
commit 9b0ac7bf8d9cb4f0a52279e7177606795475150b
Author: Mike Kaganski 
AuthorDate: Fri Aug 4 07:46:12 2023 +0300
Commit: Xisco Fauli 
CommitDate: Tue Aug 8 10:16:43 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 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155413
Reviewed-by: Michael Stahl 

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 8eea82b9263d..54df6ebf4e1e 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",
+  

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

2023-07-03 Thread Mike Kaganski (via logerrit)
 sw/qa/extras/htmlexport/data/frameWithText.fodt |   25 ++
 sw/qa/extras/htmlexport/data/twoListsWithSameStyle.fodt |   19 +++
 sw/qa/extras/htmlexport/htmlexport.cxx  |   33 +
 sw/source/filter/html/htmlflywriter.cxx |   38 ++-
 sw/source/filter/html/htmlnumwriter.cxx |   40 
 5 files changed, 133 insertions(+), 22 deletions(-)

New commits:
commit b1534305f7a395d88e688398f150658f25676c8a
Author: Mike Kaganski 
AuthorDate: Thu Jun 29 12:00:31 2023 +0300
Commit: Xisco Fauli 
CommitDate: Mon Jul 3 11:31:13 2023 +0200

ReqIF: add unit test for frame text in 'object' elements' alt text

Change-Id: I369ee9a4e50d758f2a463f79e37e60fb38ca49b8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153734
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153791

diff --git a/sw/qa/extras/htmlexport/data/frameWithText.fodt 
b/sw/qa/extras/htmlexport/data/frameWithText.fodt
new file mode 100644
index ..3c4635b14a78
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/frameWithText.fodt
@@ -0,0 +1,25 @@
+
+
+
+ 
+  
+   
+  
+ 
+ 
+  
+   
+  
+ 
+ 
+  
+   A frame with text below
+   
+ 
+  Some text in frame
+ 
+
+   A text after the frame
+  
+ 
+
\ No newline at end of file
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx 
b/sw/qa/extras/htmlexport/htmlexport.cxx
index 4d2efd109adc..d5226975ec03 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -2709,6 +2709,25 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, 
testReqIF_ListsNoStartAttribute)
 assertXPath(pDoc, "//reqif-xhtml:ol[@start]", 0);
 }
 
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_FrameTextAsObjectAltText)
+{
+createSwDoc("frameWithText.fodt");
+ExportToReqif();
+
+SvMemoryStream aStream;
+WrapReqifFromTempFile(aStream);
+xmlDocUniquePtr pDoc = parseXmlStream();
+CPPUNIT_ASSERT(pDoc);
+
+// Without the fix, this would fail with
+// - Expected: Some text in frame
+// - Actual  : Frame1
+// i.e., frame name was used as the object element content, not frame text
+assertXPathContent(pDoc,
+   
"/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p[2]/reqif-xhtml:object",
+   "Some text in frame");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3b001eab36f177139e9d3209b2c4f43b21828d15
Author: Mike Kaganski 
AuthorDate: Wed Jun 28 18:50:48 2023 +0300
Commit: Xisco Fauli 
CommitDate: Mon Jul 3 11:31:06 2023 +0200

ReqIF: output frame text instead of name in 'object' elements' alt text

Change-Id: I79d827edf00143e06b2601018fdf647d6d342355
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153721
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153790

diff --git a/sw/source/filter/html/htmlflywriter.cxx 
b/sw/source/filter/html/htmlflywriter.cxx
index 1fb4d1a65ef2..1a440c4c2c4c 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -1230,6 +1230,34 @@ OUString lclWriteOutImap(SwHTMLWriter& rWrt, const 
SfxItemSet& rItemSet, const S
 return aIMapName;
 }
 
+OUString getFrameFormatText(const SwFrameFormat& rFrameFormat)
+{
+const SwFormatContent& rFlyContent = rFrameFormat.GetContent();
+const SwNodeIndex* pSttIx = rFlyContent.GetContentIdx();
+if (!pSttIx)
+return {};
+
+const SwNodeOffset nStt = pSttIx->GetIndex();
+const auto& nodes = rFrameFormat.GetDoc()->GetNodes();
+const SwNodeOffset nEnd = nodes[nStt]->EndOfSectionIndex();
+
+OUStringBuffer result;
+for (SwNodeOffset i = nStt + 1; i < nEnd; ++i)
+{
+if (const auto* pTextNd = nodes[i]->GetTextNode())
+{
+if (!result.isEmpty())
+result.append("\n");
+result.append(pTextNd->GetExpandText(
+nullptr, 0, -1, true, true, false,
+ExpandMode::ExpandFields | ExpandMode::HideInvisible | 
ExpandMode::HideDeletions
+| ExpandMode::HideFieldmarkCommands));
+}
+}
+
+return result.makeStringAndClear();
+}
+
 }
 
 SwHTMLWriter& OutHTML_ImageStart( HtmlWriter& rHtml, SwHTMLWriter& rWrt, const 
SwFrameFormat ,
@@ -1452,13 +1480,19 @@ SwHTMLWriter& OutHTML_ImageStart( HtmlWriter& rHtml, 
SwHTMLWriter& rWrt, const S
 
 if (bReplacement)
 {
+OUString aAltText = rAlternateText;
+// In ReqIF mode, output text from the frame instead
+if (rWrt.mbReqIF)
+if (OUString aFrameText = getFrameFormatText(rFrameFormat); 
!aFrameText.isEmpty())
+aAltText = aFrameText;
+
 // XHTML object replacement image's