summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-03-12 16:30:55 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-03-13 09:09:11 +0100
commit9034207b3019e395390e5aa9eaa1a11ca81c63b5 (patch)
tree177380d97ccbe280bea71f88a96e9e2c5aa29853
parentfb04780cf8523ad4e900ae8b9cecbe7a2697a12a (diff)
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@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--sw/qa/extras/htmlexport/data/reqif-jpg-img.xhtml4
-rw-r--r--sw/qa/extras/htmlexport/data/reqif-ole-img.jpgbin0 -> 696 bytes
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx12
-rw-r--r--sw/source/filter/html/htmlflywriter.cxx31
-rw-r--r--sw/source/filter/html/wrthtml.hxx3
5 files changed, 39 insertions, 11 deletions
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
--- /dev/null
+++ b/sw/qa/extras/htmlexport/data/reqif-ole-img.jpg
Binary files 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,