[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Mar 13 08:09:36 UTC 2018
sw/qa/extras/htmlexport/data/reqif-jpg-img.xhtml | 4 ++
sw/qa/extras/htmlexport/data/reqif-ole-img.jpg |binary
sw/qa/extras/htmlexport/htmlexport.cxx | 12 ++++++++
sw/source/filter/html/htmlflywriter.cxx | 31 +++++++++++++++--------
sw/source/filter/html/wrthtml.hxx | 3 +-
5 files changed, 39 insertions(+), 11 deletions(-)
New commits:
commit 9034207b3019e395390e5aa9eaa1a11ca81c63b5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Mar 12 16:30:55 2018 +0100
sw XHTML export: always write images as PNG in ReqIF mode
JPG image would have to be JPG + PNG fallback, at which point it's
easier to just write PNG.
Change-Id: I6e4f0759244d29735fdcda8e050d198f118c737d
Reviewed-on: https://gerrit.libreoffice.org/51151
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sw/qa/extras/htmlexport/data/reqif-jpg-img.xhtml b/sw/qa/extras/htmlexport/data/reqif-jpg-img.xhtml
new file mode 100644
index 000000000000..da7276192a31
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/reqif-jpg-img.xhtml
@@ -0,0 +1,4 @@
+<reqif-xhtml:div><reqif-xhtml:br/>
+ <reqif-xhtml:img data="reqif-ole-img.jpg" type="image/jpeg">OLE Object</reqif-xhtml:img>
+</reqif-xhtml:div>
+
diff --git a/sw/qa/extras/htmlexport/data/reqif-ole-img.jpg b/sw/qa/extras/htmlexport/data/reqif-ole-img.jpg
new file mode 100644
index 000000000000..ca9183e9d308
Binary files /dev/null and b/sw/qa/extras/htmlexport/data/reqif-ole-img.jpg differ
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 5c8f5cfaf5f1..289fcb2a26d7 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -424,6 +424,18 @@ DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfPngImg, "reqif-png-img.xhtml")
CPPUNIT_ASSERT(aStream.indexOf("<reqif-xhtml:object") != -1);
}
+DECLARE_HTMLEXPORT_TEST(testReqIfJpgImg, "reqif-jpg-img.xhtml")
+{
+ SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
+ CPPUNIT_ASSERT(pStream);
+ pStream->Seek(STREAM_SEEK_TO_END);
+ sal_uInt64 nLength = pStream->Tell();
+ pStream->Seek(0);
+ OString aStream(read_uInt8s_ToOString(*pStream, nLength));
+ // This was image/jpeg, JPG was not converted to PNG in ReqIF mode.
+ CPPUNIT_ASSERT(aStream.indexOf("type=\"image/png\"") != -1);
+}
+
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 30888b2e9d97..bd9d8e9cc946 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -1203,7 +1203,8 @@ Writer& OutHTML_Image( Writer& rWrt, const SwFrameFormat &rFrameFormat,
Graphic const & rGraphic, const OUString& rAlternateText,
const Size &rRealSize, HtmlFrmOpts nFrameOpts,
const sal_Char *pMarkType,
- const ImageMap *pAltImgMap )
+ const ImageMap *pAltImgMap,
+ const OUString& rMimeType )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
// <object data="..."> instead of <img src="...">
@@ -1391,13 +1392,8 @@ Writer& OutHTML_Image( Writer& rWrt, const SwFrameFormat &rFrameFormat,
if (bReplacement)
{
// Handle XHTML type attribute for OLE replacement images.
- uno::Reference<beans::XPropertySet> xGraphic(rGraphic.GetXGraphic(), uno::UNO_QUERY);
- if (xGraphic.is())
- {
- OUString aMimeType;
- xGraphic->getPropertyValue("MimeType") >>= aMimeType;
- aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_type, aMimeType.toUtf8());
- }
+ if (!rMimeType.isEmpty())
+ aHtml.attribute(OOO_STRING_SVTOOLS_HTML_O_type, rMimeType.toUtf8());
}
// Events
@@ -1796,6 +1792,7 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
Graphic aGraphic = pGrfNd->GetGraphic();
OUString aGraphicURL;
+ OUString aMimeType;
if(!rHTMLWrt.mbEmbedImages)
{
const SwMirrorGrf& rMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf();
@@ -1824,8 +1821,19 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
aMM100Size = OutputDevice::LogicToLogic( rSize.GetSize(),
MapMode( MapUnit::MapTwip ), MapMode( MapUnit::Map100thMM ));
+ OUString aFilterName("JPG");
+
+ if (rHTMLWrt.mbReqIF)
+ {
+ // Writing image without fallback PNG in ReqIF mode: force PNG
+ // output.
+ aFilterName = "PNG";
+ nFlags &= ~XOutFlags::UseNativeIfPossible;
+ aMimeType = "image/png";
+ }
+
ErrCode nErr = XOutBitmap::WriteGraphic( pGrfNd->GetGrf(), aGraphicURL,
- "JPG", nFlags, &aMM100Size );
+ aFilterName, nFlags, &aMM100Size );
if( nErr )
{
rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
@@ -1843,8 +1851,11 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
}
}
+ uno::Reference<beans::XPropertySet> xGraphic(aGraphic.GetXGraphic(), uno::UNO_QUERY);
+ if (xGraphic.is() && aMimeType.isEmpty())
+ xGraphic->getPropertyValue("MimeType") >>= aMimeType;
OutHTML_Image( rWrt, rFrameFormat, aGraphicURL, aGraphic, pGrfNd->GetTitle(),
- pGrfNd->GetTwipSize(), nFrameFlags, "graphic" );
+ pGrfNd->GetTwipSize(), nFrameFlags, "graphic", nullptr, aMimeType );
return rWrt;
}
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index d9f75db90c89..6251405bef52 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -655,7 +655,8 @@ Writer& OutHTML_Image( Writer&, const SwFrameFormat& rFormat,
Graphic const & rGraphic, const OUString& rAlternateText,
const Size& rRealSize, HtmlFrmOpts nFrameOpts,
const sal_Char *pMarkType,
- const ImageMap *pGenImgMap = nullptr );
+ const ImageMap *pGenImgMap = nullptr,
+ const OUString& rMimeType = OUString() );
Writer& OutHTML_BulletImage( Writer& rWrt, const sal_Char *pTag,
const SvxBrushItem* pBrush,
More information about the Libreoffice-commits
mailing list