Kaydet (Commit) 0db96caf authored tarafından Joren De Cuyper's avatar Joren De Cuyper

tdf#76941 and tdf#87539: docx export image greyscale, watermark, black&white

Thanks to Miklos :)

Change-Id: Ib6344ff654e39bf712d7071545573fb2ec525b63
Reviewed-on: https://gerrit.libreoffice.org/15733Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJoren De Cuyper <jorendc@libreoffice.org>
üst fcc7ba44
...@@ -948,6 +948,36 @@ DECLARE_OOXMLEXPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.docx") ...@@ -948,6 +948,36 @@ DECLARE_OOXMLEXPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aSeq.getLength()); CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aSeq.getLength());
} }
DECLARE_OOXMLEXPORT_TEST(testPictureColormodeGrayscale, "picture_colormode_grayscale.docx")
{
// THe problem was that the grayscale was not exported
xmlDocPtr pXmlDoc = parseExport ("word/document.xml");
if (!pXmlDoc)
return;
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing/wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:grayscl", 1);
}
DECLARE_OOXMLEXPORT_TEST(testPictureColormodeBlackWhite, "picture_colormode_black_white.odt")
{
xmlDocPtr pXmlDoc = parseExport ("word/document.xml");
if (!pXmlDoc)
return;
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:biLevel", "thresh", "50000");
}
DECLARE_OOXMLEXPORT_TEST(testPictureColormodeWatermark, "picture_colormode_watermark.odt")
{
xmlDocPtr pXmlDoc = parseExport ("word/document.xml");
if (!pXmlDoc)
return;
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:lum", "bright", "50000");
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:drawing/wp:anchor/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:lum", "contrast", "-70000");
}
DECLARE_OOXMLEXPORT_TEST(testExportShadow, "bnc637947.odt") DECLARE_OOXMLEXPORT_TEST(testExportShadow, "bnc637947.odt")
{ {
// The problem was that shadows of shapes from non-OOXML origin were not exported to DrawingML // The problem was that shadows of shapes from non-OOXML origin were not exported to DrawingML
......
...@@ -4192,13 +4192,28 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size ...@@ -4192,13 +4192,28 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
completely discarding it. completely discarding it.
*/ */
if ( aRelId.isEmpty() ) if ( aRelId.isEmpty() )
m_pSerializer->singleElementNS( XML_a, XML_blip, m_pSerializer->startElementNS( XML_a, XML_blip,
FSEND ); FSEND );
else else
m_pSerializer->singleElementNS( XML_a, XML_blip, m_pSerializer->startElementNS( XML_a, XML_blip,
FSNS( XML_r, nImageType ), aRelId.getStr(), FSNS( XML_r, nImageType ), aRelId.getStr(),
FSEND ); FSEND );
pItem = 0;
sal_uInt32 nMode = GRAPHICDRAWMODE_STANDARD;
if ( pGrfNode && SfxItemState::SET == pGrfNode->GetSwAttrSet().GetItemState(RES_GRFATR_DRAWMODE, true, &pItem))
{
nMode = static_cast<const SfxEnumItem*>(pItem)->GetValue();
if (nMode == GRAPHICDRAWMODE_GREYS)
m_pSerializer->singleElementNS (XML_a, XML_grayscl, FSEND);
else if (nMode == GRAPHICDRAWMODE_MONO) //black/white has a 0,5 threshold in LibreOffice
m_pSerializer->singleElementNS (XML_a, XML_biLevel, XML_thresh, OString::number(50000), FSEND);
else if (nMode == GRAPHICDRAWMODE_WATERMARK) //watermark has a brightness/luminance of 0,5 and contrast of -0.7 in LibreOffice
m_pSerializer->singleElementNS( XML_a, XML_lum, XML_bright, OString::number(50000), XML_contrast, OString::number(-70000), FSEND );
}
m_pSerializer->endElementNS( XML_a, XML_blip );
if (pSdrObj){ if (pSdrObj){
WriteSrcRect(pSdrObj); WriteSrcRect(pSdrObj);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment