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 <mike.kagan...@collabora.com>
AuthorDate: Mon Nov 27 16:01:11 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
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 <mike.kagan...@collabora.com>

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 000000000000..f1080724307e
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/image_anchored_to_paragraph_no_wrap.fodt
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office: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:automatic-styles>
+  <style:style style:name="fr1" style:family="graphic" 
style:parent-style-name="OLE">
+   <style:graphic-properties style:wrap="none"/>
+  </style:style>
+ </office:automatic-styles>
+ <office:body>
+  <office:text>
+   <text:p><draw:frame draw:style-name="fr1" draw:name="Image1" 
text:anchor-type="paragraph" svg:width="17cm" svg:height="13cm"><draw:image 
draw:mime-type="image/svg+xml">
+      
<office:binary-data>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0
+       cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDIw
+       IDIwIiBzdHJva2U9ImJsYWNrIj4KPHBhdGggZD0iTTEsMUwxOSwxOSIvPgo8L3N2Zz4=
+      </office:binary-data>
+     </draw:image>
+    </draw: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 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
-    // <BR CLEAR=...> 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
+        // <BR CLEAR=...> 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;
-                default:
-                    ;
+                    switch( eSurround )
+                    {
+                    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;
+                    default:
+                        ;
+                    }
                 }
-            }
-            break;
+                break;
 
-        default:
-            // If a frame is centered, it gets left aligned. This
-            // should be taken into account here, too.
-            {
-                switch( eSurround )
+            default:
+                // If a frame is centered, it gets left aligned. This
+                // should be taken into account here, too.
                 {
-                case css::text::WrapTextMode_NONE:
-                case css::text::WrapTextMode_LEFT:
-                    pStr = OOO_STRING_SVTOOLS_HTML_AL_left;
-                    break;
-                case css::text::WrapTextMode_RIGHT:
-                case css::text::WrapTextMode_PARALLEL:
-                    if( bAnchorOnly )
-                        m_bClearLeft = true;
-                    break;
-                default:
-                    ;
+                    switch( eSurround )
+                    {
+                    case css::text::WrapTextMode_NONE:
+                    case css::text::WrapTextMode_LEFT:
+                        pStr = OOO_STRING_SVTOOLS_HTML_AL_left;
+                        break;
+                    case css::text::WrapTextMode_RIGHT:
+                    case css::text::WrapTextMode_PARALLEL:
+                        if( bAnchorOnly )
+                            m_bClearLeft = true;
+                        break;
+                    default:
+                        ;
+                    }
                 }
-            }
-            break;
+                break;
 
-        }
+            }
 
-        if( pStr )
-        {
-            sOut.append("<" OOO_STRING_SVTOOLS_HTML_linebreak
-                    " " OOO_STRING_SVTOOLS_HTML_O_clear
-                    "=\"" + OString::Concat(pStr) + "\">");
-            sRetEndTags = sOut.makeStringAndClear();
+            if( pStr )
+            {
+                sOut.append("<" OOO_STRING_SVTOOLS_HTML_linebreak
+                        " " OOO_STRING_SVTOOLS_HTML_O_clear
+                        "=\"" + OString::Concat(pStr) + "\">");
+                sRetEndTags = sOut.makeStringAndClear();
+            }
         }
     }
     return sRetEndTags;
@@ -997,6 +1000,9 @@ void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& 
aHtml, const SwFrameForma
         }
     }
 
+    if (mbReqIF)
+        return;
+
     // Insert wrap for graphics that are anchored to a paragraph as
     // <BR CLEAR=...> in the string
 

Reply via email to