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 <mike.kagan...@collabora.com>
AuthorDate: Thu Jun 29 12:00:31 2023 +0300
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
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 <mike.kagan...@collabora.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    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 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 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(&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: */
commit 3b001eab36f177139e9d3209b2c4f43b21828d15
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Jun 28 18:50:48 2023 +0300
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
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 <mike.kagan...@collabora.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    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 &rFrameFormat,
@@ -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 alternate text doesn't use the
         // "alt" attribute.
-        if (rAlternateText.isEmpty())
+        if (aAltText.isEmpty())
             // Empty alternate text is not valid.
             rHtml.characters(" ");
         else
-            rHtml.characters(rAlternateText.toUtf8());
+            rHtml.characters(aAltText.toUtf8());
     }
 
     return rWrt;
commit ba12094e9bbf1fd2a41fd00c6c5e3edbf4ebb27b
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Jun 24 12:00:08 2023 +0300
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Jul 3 11:30:59 2023 +0200

    ReqIF: 'ol' elements must have no 'start' attribute
    
    Change-Id: If02f4d2f0a34f2f39b90fb7b8c6d29e46d0da0ed
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153549
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153789

diff --git a/sw/qa/extras/htmlexport/data/twoListsWithSameStyle.fodt 
b/sw/qa/extras/htmlexport/data/twoListsWithSameStyle.fodt
new file mode 100644
index 000000000000..a5dc0f014d2a
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/twoListsWithSameStyle.fodt
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:body>
+  <office:text>
+   <text:list text:style-name="Numbering 123">
+    <text:list-header>
+     <text:p/>
+    </text:list-header>
+   </text:list>
+   <text:p/>
+   <text:list text:style-name="Numbering 123">
+    <text:list-header>
+     <text:p/>
+    </text:list-header>
+   </text:list>
+  </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 5bbde8166453..4d2efd109adc 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -2695,6 +2695,20 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTdf155871)
     CPPUNIT_ASSERT(pDoc);
 }
 
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_ListsNoStartAttribute)
+{
+    createSwDoc("twoListsWithSameStyle.fodt");
+    ExportToReqif();
+
+    SvMemoryStream aStream;
+    WrapReqifFromTempFile(aStream);
+    xmlDocUniquePtr pDoc = parseXmlStream(&aStream);
+    CPPUNIT_ASSERT(pDoc);
+
+    // No 'start' attribute must be present in 'ol'
+    assertXPath(pDoc, "//reqif-xhtml:ol[@start]", 0);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlnumwriter.cxx 
b/sw/source/filter/html/htmlnumwriter.cxx
index 8fa9b0074c99..6640f8f9376b 100644
--- a/sw/source/filter/html/htmlnumwriter.cxx
+++ b/sw/source/filter/html/htmlnumwriter.cxx
@@ -217,10 +217,10 @@ SwHTMLWriter& OutHTML_NumberBulletListStart( 
SwHTMLWriter& rWrt,
             // Ordered list: <OL>
             sOut += OOO_STRING_SVTOOLS_HTML_orderlist;
 
-            // determine the type by the format
-            char cType = 0;
-            if (!rWrt.mbReqIF) // No 'type' attribute in ReqIF
+            if (!rWrt.mbReqIF) // No 'type' nor 'start' attribute in ReqIF
             {
+                // determine the type by the format
+                char cType = 0;
                 switch (eType)
                 {
                 case SVX_NUM_CHARS_UPPER_LETTER:
@@ -238,29 +238,29 @@ SwHTMLWriter& OutHTML_NumberBulletListStart( 
SwHTMLWriter& rWrt,
                     cType = 'i';
                     break;
                 }
-            }
-            if( cType )
-            {
-                sOut += " " OOO_STRING_SVTOOLS_HTML_O_type "=\"" + 
OStringChar(cType) + "\"";
-            }
+                if( cType )
+                {
+                    sOut += " " OOO_STRING_SVTOOLS_HTML_O_type "=\"" + 
OStringChar(cType) + "\"";
+                }
 
-            sal_uInt16 nStartVal = rNumFormat.GetStart();
-            if( bStartValue && 1 == nStartVal && i == rInfo.GetDepth()-1 )
-            {
-                if ( 
rWrt.m_pCurrentPam->GetPointNode().GetTextNode()->GetNum() )
+                sal_uInt16 nStartVal = rNumFormat.GetStart();
+                if( bStartValue && 1 == nStartVal && i == rInfo.GetDepth()-1 )
                 {
-                    nStartVal = static_cast< sal_uInt16 >( 
rWrt.m_pCurrentPam->GetPointNode()
-                                .GetTextNode()->GetNumberVector()[i] );
+                    if ( 
rWrt.m_pCurrentPam->GetPointNode().GetTextNode()->GetNum() )
+                    {
+                        nStartVal = static_cast< sal_uInt16 >( 
rWrt.m_pCurrentPam->GetPointNode()
+                                    .GetTextNode()->GetNumberVector()[i] );
+                    }
+                    else
+                    {
+                        OSL_FAIL( "<OutHTML_NumberBulletListStart(..) - text 
node has no number." );
+                    }
                 }
-                else
+                if( nStartVal != 1 )
                 {
-                    OSL_FAIL( "<OutHTML_NumberBulletListStart(..) - text node 
has no number." );
+                    sOut += " " OOO_STRING_SVTOOLS_HTML_O_start "=\"" + 
OString::number(static_cast<sal_Int32>(nStartVal)) + "\"";
                 }
             }
-            if( nStartVal != 1 )
-            {
-                sOut += " " OOO_STRING_SVTOOLS_HTML_O_start "=\"" + 
OString::number(static_cast<sal_Int32>(nStartVal)) + "\"";
-            }
         }
 
         rWrt.Strm().WriteOString(sOut);

Reply via email to