sw/qa/extras/htmlexport/data/frameWithText.fodt |   25 ++++++++++++++++++++++++
 sw/qa/extras/htmlexport/htmlexport.cxx          |   19 ++++++++++++++++++
 sw/source/filter/html/htmlflywriter.cxx         |    5 ++--
 3 files changed, 47 insertions(+), 2 deletions(-)

New commits:
commit 532e37c8127c9ae8bc1c455ef2d582e6d2252fb5
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Jun 29 12:22:55 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Jun 29 14:36:11 2023 +0200

    XML-encode text that will appear in ReqIF
    
    Change-Id: I56ced6717496d6c0a5fe0bcb86de47ae4142e953
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153738
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/qa/extras/htmlexport/data/frameWithText.fodt 
b/sw/qa/extras/htmlexport/data/frameWithText.fodt
index 3c4635b14a78..97ee5b105984 100644
--- a/sw/qa/extras/htmlexport/data/frameWithText.fodt
+++ b/sw/qa/extras/htmlexport/data/frameWithText.fodt
@@ -16,7 +16,7 @@
    <text:p>A frame with text below</text:p>
    <text:p><draw:frame draw:style-name="fr1" draw:name="Frame1" 
text:anchor-type="as-char" svg:width="50mm" draw:z-index="0">
      <draw:text-box fo:min-height="27mm">
-      <text:p text:style-name="P1">Some text in frame</text:p>
+      <text:p text:style-name="P1">Some text in frame &amp; 
&lt;foo&gt;</text:p>
      </draw:text-box>
     </draw:frame></text:p>
    <text:p>A text after the frame</text:p>
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx 
b/sw/qa/extras/htmlexport/htmlexport.cxx
index 04f8f0d164dc..f83f446f9589 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -2728,12 +2728,12 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, 
testReqIF_FrameTextAsObjectAltText)
     CPPUNIT_ASSERT(pDoc);
 
     // Without the fix, this would fail with
-    // - Expected: Some text in frame
+    // - Expected: Some text in frame & <foo>
     // - 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");
+                       "Some text in frame & <foo>");
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/html/htmlflywriter.cxx 
b/sw/source/filter/html/htmlflywriter.cxx
index d404e305e172..6aafdeaa0f2f 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -42,6 +42,7 @@
 #include <sal/log.hxx>
 #include <osl/diagnose.h>
 #include <svx/svdograf.hxx>
+#include <comphelper/xmlencode.hxx>
 
 #include <fmtanchr.hxx>
 #include <fmtornt.hxx>
@@ -1245,10 +1246,10 @@ OUString getFrameFormatText(const SwFrameFormat& 
rFrameFormat)
         {
             if (!result.isEmpty())
                 result.append("\n");
-            result.append(pTextNd->GetExpandText(
+            
result.append(comphelper::string::encodeForXml(pTextNd->GetExpandText(
                 nullptr, 0, -1, true, true, false,
                 ExpandMode::ExpandFields | ExpandMode::HideInvisible | 
ExpandMode::HideDeletions
-                | ExpandMode::HideFieldmarkCommands));
+                    | ExpandMode::HideFieldmarkCommands)));
         }
     }
 
commit 2d8e0ce32d6dccc3441c25dc29bb60489f886ea0
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Jun 29 12:00:31 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Jun 29 14:36:00 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 <mike.kagan...@collabora.com>

diff --git a/sw/qa/extras/htmlexport/data/frameWithText.fodt 
b/sw/qa/extras/htmlexport/data/frameWithText.fodt
new file mode 100644
index 000000000000..3c4635b14a78
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/frameWithText.fodt
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible: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:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:styles>
+  <style:style style:name="Frame" style:family="graphic">
+   <style:graphic-properties text:anchor-type="paragraph" svg:x="0mm" 
svg:y="0mm" fo:margin-left="2mm" fo:margin-right="2mm" fo:margin-top="2mm" 
fo:margin-bottom="2mm" style:wrap="parallel" 
style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" 
style:vertical-pos="top" style:vertical-rel="paragraph-content" 
style:horizontal-pos="center" style:horizontal-rel="paragraph-content" 
fo:padding="1.5mm" fo:border="0.06pt solid #000000"/>
+  </style:style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="fr1" style:family="graphic" 
style:parent-style-name="Frame">
+   <style:graphic-properties style:wrap="parallel" 
style:number-wrapped-paragraphs="no-limit" style:vertical-pos="middle" 
style:vertical-rel="baseline" style:horizontal-pos="from-left" 
style:horizontal-rel="paragraph"/>
+  </style:style>
+ </office:automatic-styles>
+ <office:body>
+  <office:text>
+   <text:p>A frame with text below</text:p>
+   <text:p><draw:frame draw:style-name="fr1" draw:name="Frame1" 
text:anchor-type="as-char" svg:width="50mm" draw:z-index="0">
+     <draw:text-box fo:min-height="27mm">
+      <text:p text:style-name="P1">Some text in frame</text:p>
+     </draw:text-box>
+    </draw:frame></text:p>
+   <text:p>A text after the frame</text:p>
+  </office:text>
+ </office:body>
+</office:document>
\ No newline at end of file
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx 
b/sw/qa/extras/htmlexport/htmlexport.cxx
index 6fdb67f68eb7..04f8f0d164dc 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -2717,6 +2717,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(&aStream);
+    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: */

Reply via email to