summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-11-27 16:01:11 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-11-29 10:47:34 +0300
commitb0391cf000850b28546f0d21f194060ed86507c2 (patch)
tree528cc20e3ff864c7c3b236734369f056580a47e1
parentFix HtmlWriter::characters (diff)
downloadcore-distro/vector/vector-7.5.tar.gz
core-distro/vector/vector-7.5.zip
Don't emit 'br clear=...' for graphics wrap in ReqIF export distro/vector/vector-7.5
Change-Id: I7684c78c9b98fe63c2281bf3b2a2186d125e0ba4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159994 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--sw/qa/extras/htmlexport/data/image_anchored_to_paragraph_no_wrap.fodt20
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx18
-rw-r--r--sw/source/filter/html/htmlflywriter.cxx112
3 files changed, 97 insertions, 53 deletions
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 d72e2b1daf9e..662dc12a5a0b 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -2997,6 +2997,24 @@ 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):
+ SvMemoryStream aStream;
+ WrapReqifFromTempFile(aStream);
+ xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream);
+ CPPUNIT_ASSERT(pXmlDoc);
+ assertXPath(pXmlDoc, "/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p/reqif-xhtml:object");
+ assertXPath(pXmlDoc,
+ "/reqif-xhtml:html/reqif-xhtml:div/reqif-xhtml:p/reqif-xhtml:object/reqif-xhtml:br",
+ 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 b58d3d9f6c44..624d992fb273 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -723,68 +723,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;
@@ -1034,6 +1037,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