[Libreoffice-commits] core.git: oox/source sw/qa sw/source writerfilter/source

Joren De Cuyper jorendc at libreoffice.org
Wed Jul 15 16:44:30 PDT 2015


 oox/source/drawingml/fillproperties.cxx       |   30 ++++++++++++++------------
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx     |    2 -
 sw/source/filter/ww8/docxattributeoutput.cxx  |    2 -
 writerfilter/source/dmapper/GraphicImport.cxx |    5 +---
 4 files changed, 21 insertions(+), 18 deletions(-)

New commits:
commit d151ed35ad4c4e7aa9fbb807930fcf91dea2eba7
Author: Joren De Cuyper <jorendc at libreoffice.org>
Date:   Tue Jun 2 22:26:29 2015 +0200

    tdf#87539 map MSO washout filter to LO's watermark colormode
    
    Change-Id: Id28e301a74a729245b20ba6cd2adecf203633f0e
    Reviewed-on: https://gerrit.libreoffice.org/16048
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 1302a07..6879896 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -696,17 +696,29 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
 {
     sal_Int16 nBrightness = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moBrightness.get( 0 ) / PER_PERCENT, -100, 100 );
     sal_Int16 nContrast = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moContrast.get( 0 ) / PER_PERCENT, -100, 100 );
+    ColorMode eColorMode = ColorMode_STANDARD;
+
+    switch( maBlipProps.moColorEffect.get( XML_TOKEN_INVALID ) )
+    {
+        case XML_biLevel:   eColorMode = ColorMode_MONO;    break;
+        case XML_grayscl:   eColorMode = ColorMode_GREYS;   break;
+    }
+
     if( maBlipProps.mxGraphic.is() )
     {
         // created transformed graphic
         Reference< XGraphic > xGraphic = lclCheckAndApplyDuotoneTransform( maBlipProps, maBlipProps.mxGraphic, rGraphicHelper, nPhClr );
         xGraphic = lclCheckAndApplyChangeColorTransform( maBlipProps, xGraphic, rGraphicHelper, nPhClr );
-        // MSO uses a different algorithm for contrast+brightness, LO applies contrast before brightness,
-        // while MSO apparently applies half of brightness before contrast and half after. So if only
-        // contrast or brightness need to be altered, the result is the same, but if both are involved,
-        // there's no way to map that, so just force a conversion of the image.
-        if( nBrightness != 0 && nContrast != 0 )
+
+        if (eColorMode == ColorMode_STANDARD && nBrightness == 70 && nContrast == -70)
+            // map MSO 'washout' to our Watermark colormode
+            eColorMode = ColorMode_WATERMARK;
+        else if( nBrightness != 0 && nContrast != 0 )
         {
+            // MSO uses a different algorithm for contrast+brightness, LO applies contrast before brightness,
+            // while MSO apparently applies half of brightness before contrast and half after. So if only
+            // contrast or brightness need to be altered, the result is the same, but if both are involved,
+            // there's no way to map that, so just force a conversion of the image.
             xGraphic = applyBrightnessContrast( xGraphic, nBrightness, nContrast );
             nBrightness = 0;
             nContrast = 0;
@@ -738,14 +750,6 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
             }
         }
     }
-
-    // color effect
-    ColorMode eColorMode = ColorMode_STANDARD;
-    switch( maBlipProps.moColorEffect.get( XML_TOKEN_INVALID ) )
-    {
-        case XML_biLevel:   eColorMode = ColorMode_MONO;    break;
-        case XML_grayscl:   eColorMode = ColorMode_GREYS;   break;
-    }
     rPropMap.setProperty(PROP_GraphicColorMode, eColorMode);
 
     // brightness and contrast
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index 47b47b8..727d448 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -973,7 +973,7 @@ DECLARE_OOXMLEXPORT_TEST(testPictureColormodeWatermark, "picture_colormode_water
     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", "bright", "70000");
     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");
 }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index ddad776..710c862 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4246,7 +4246,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
         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->singleElementNS( XML_a, XML_lum, XML_bright, OString::number(70000), XML_contrast, OString::number(-70000), FSEND );
     }
     m_pSerializer->endElementNS( XML_a, XML_blip );
 
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 154b9e2..1d9078d 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1286,14 +1286,13 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b
                 m_pImpl->applyMargins(xGraphicObjectProperties);
             }
 
-            if( m_pImpl->eColorMode == drawing::ColorMode_STANDARD &&
+            if( m_pImpl->eColorMode == drawing::ColorMode_WATERMARK &&
                 m_pImpl->nContrast == -70 &&
                 m_pImpl->nBrightness == 70 )
             {
-                // strange definition of WATERMARK!
+                // watermark filter is already applied at this point, so reset Contrast and Brightness
                 m_pImpl->nContrast = 0;
                 m_pImpl->nBrightness = 0;
-                m_pImpl->eColorMode = drawing::ColorMode_WATERMARK;
             }
 
             xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_ADJUST_CONTRAST ),


More information about the Libreoffice-commits mailing list