[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - oox/source sd/qa writerfilter/source

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 15 12:32:52 UTC 2019


 oox/source/drawingml/fillproperties.cxx       |    5 ++
 sd/qa/unit/data/pptx/tdf79007.pptx            |binary
 sd/qa/unit/import-tests.cxx                   |   58 ++++++++++++++++++++++++++
 writerfilter/source/dmapper/GraphicImport.cxx |    9 ----
 4 files changed, 63 insertions(+), 9 deletions(-)

New commits:
commit 4b8415616071ec74e21040369d5dd1a9496db71d
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Sep 30 23:18:14 2019 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue Oct 15 14:31:55 2019 +0200

    tdf#79007: PPTX: reset Contrast and Brightness when we map...
    
    ...MSO 'washout' to our watermark colormode
    
    After d151ed35ad4c4e7aa9fbb807930fcf91dea2eba7,
    Contrast and Brightness was reset only in writer,
    so do it earlier for Impress and Writer
    
    Reviewed-on: https://gerrit.libreoffice.org/79905
    Tested-by: Jenkins
    Reviewed-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>
    (cherry picked from commit 727ca36e83868acbe40aaa239cefc69659b9bc39)
    
    Change-Id: Icaf2b565880e31d86e09e2f56bac25eba52c8467
    Reviewed-on: https://gerrit.libreoffice.org/80003
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 9c5338ce8975..f784f6f0b57f 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -758,8 +758,12 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
         xGraphic = lclCheckAndApplyDuotoneTransform(maBlipProps, xGraphic, rGraphicHelper, API_RGB_TRANSPARENT);
 
         if (eColorMode == ColorMode_STANDARD && nBrightness == 70 && nContrast == -70)
+        {
             // map MSO 'washout' to our Watermark colormode
             eColorMode = ColorMode_WATERMARK;
+            nBrightness = 0;
+            nContrast = 0;
+        }
         else if( nBrightness != 0 && nContrast != 0 )
         {
             // MSO uses a different algorithm for contrast+brightness, LO applies contrast before brightness,
@@ -770,6 +774,7 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
             nBrightness = 0;
             nContrast = 0;
         }
+
         if(mbIsCustomShape)
         {
             // it is a cropped graphic.
diff --git a/sd/qa/unit/data/pptx/tdf79007.pptx b/sd/qa/unit/data/pptx/tdf79007.pptx
new file mode 100644
index 000000000000..65e94f1a9d9e
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf79007.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 28a908197fdc..f083b38bbc58 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -53,6 +53,7 @@
 #include <com/sun/star/presentation/XPresentationPage.hpp>
 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
 #include <com/sun/star/drawing/BitmapMode.hpp>
+#include <com/sun/star/drawing/ColorMode.hpp>
 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
 #include <com/sun/star/drawing/XDrawPage.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
@@ -169,6 +170,7 @@ public:
     void testTdf103567();
     void testTdf103792();
     void testTdf103876();
+    void testTdf79007();
     void testTdf104015();
     void testTdf104201();
     void testTdf103477();
@@ -264,6 +266,7 @@ public:
     CPPUNIT_TEST(testTdf103567);
     CPPUNIT_TEST(testTdf103792);
     CPPUNIT_TEST(testTdf103876);
+    CPPUNIT_TEST(testTdf79007);
     CPPUNIT_TEST(testTdf104015);
     CPPUNIT_TEST(testTdf104201);
     CPPUNIT_TEST(testTdf103477);
@@ -1707,6 +1710,61 @@ void SdImportTest::testTdf103876()
     xDocShRef->DoClose();
 }
 
+void SdImportTest::testTdf79007()
+{
+    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf79007.pptx"), PPTX);
+
+    uno::Reference<beans::XPropertySet> xShape1(getShapeFromPage(0, 0, xDocShRef));
+    CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape1.is());
+
+    // Check we map mso washout to our watermark
+    drawing::ColorMode aColorMode1;
+    xShape1->getPropertyValue("GraphicColorMode") >>= aColorMode1;
+    CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_WATERMARK, aColorMode1);
+
+    sal_Int16 nContrast1;
+    xShape1->getPropertyValue("AdjustContrast") >>= nContrast1;
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nContrast1);
+
+    sal_Int16 nLuminance1;
+    xShape1->getPropertyValue("AdjustLuminance") >>= nLuminance1;
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nLuminance1);
+
+    uno::Reference<beans::XPropertySet> xShape2(getShapeFromPage(1, 0, xDocShRef));
+    CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape2.is());
+
+    // Check we map mso grayscale to our grayscale
+    drawing::ColorMode aColorMode2;
+    xShape2->getPropertyValue("GraphicColorMode") >>= aColorMode2;
+    CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_GREYS, aColorMode2);
+
+    sal_Int16 nContrast2;
+    xShape2->getPropertyValue("AdjustContrast") >>= nContrast2;
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nContrast2);
+
+    sal_Int16 nLuminance2;
+    xShape2->getPropertyValue("AdjustLuminance") >>= nLuminance2;
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nLuminance2);
+
+    uno::Reference<beans::XPropertySet> xShape3(getShapeFromPage(2, 0, xDocShRef));
+    CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape3.is());
+
+    // Check we map mso black/white to our black/white
+    drawing::ColorMode aColorMode3;
+    xShape3->getPropertyValue("GraphicColorMode") >>= aColorMode3;
+    CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_MONO, aColorMode3);
+
+    sal_Int16 nContrast3;
+    xShape3->getPropertyValue("AdjustContrast") >>= nContrast3;
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nContrast3);
+
+    sal_Int16 nLuminance3;
+    xShape3->getPropertyValue("AdjustLuminance") >>= nLuminance3;
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nLuminance3);
+
+    xDocShRef->DoClose();
+}
+
 void SdImportTest::testTdf104015()
 {
     // Shape fill, line and effect properties were not inherited from master slide shape
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index e51b440ae7ac..15f2ddb23643 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1337,15 +1337,6 @@ uno::Reference<text::XTextContent> GraphicImport::createGraphicObject(uno::Refer
                 m_pImpl->applyMargins(xGraphicObjectProperties);
             }
 
-            if( m_pImpl->eColorMode == drawing::ColorMode_WATERMARK &&
-                m_pImpl->nContrast == -70 &&
-                m_pImpl->nBrightness == 70 )
-            {
-                // watermark filter is already applied at this point, so reset Contrast and Brightness
-                m_pImpl->nContrast = 0;
-                m_pImpl->nBrightness = 0;
-            }
-
             xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_ADJUST_CONTRAST ),
                 uno::makeAny(static_cast<sal_Int16>(m_pImpl->nContrast)));
             xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_ADJUST_LUMINANCE ),


More information about the Libreoffice-commits mailing list