editeng/source/items/textitem.cxx                |   22 +++++++++++++++++++---
 include/editeng/colritem.hxx                     |    2 ++
 include/editeng/memberids.h                      |    1 +
 include/editeng/unoprnms.hxx                     |    1 +
 include/editeng/unotext.hxx                      |    1 +
 include/oox/drawingml/color.hxx                  |    1 +
 oox/qa/unit/data/theme.pptx                      |binary
 oox/qa/unit/drawingml.cxx                        |    7 +++++++
 oox/source/drawingml/color.cxx                   |   17 +++++++++++++++++
 oox/source/drawingml/textcharacterproperties.cxx |    1 +
 oox/source/token/properties.txt                  |    1 +
 11 files changed, 51 insertions(+), 3 deletions(-)

New commits:
commit ed662bcc20804e8b8d5946904f1b577a825f09de
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Nov 23 08:11:22 2021 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Nov 23 09:07:42 2021 +0100

    PPTX import: implement native handling of a color's luminance modulation
    
    This was already handled in oox/ at import-time: this adds it to the doc
    model, including UNO API and PPTX import.
    
    This is a dependency PPTX export and UI.
    
    Change-Id: I5d875b53d715beb10c13ef616d06cf958d43f70f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125684
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/editeng/source/items/textitem.cxx 
b/editeng/source/items/textitem.cxx
index 02f8d6a9be4e..73ce5c3fd1f1 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -1357,7 +1357,8 @@ SvxColorItem::SvxColorItem( const sal_uInt16 nId ) :
     SfxPoolItem(nId),
     mColor( COL_BLACK ),
     maThemeIndex(-1),
-    maTintShade(0)
+    maTintShade(0),
+    mnLumMod(10000)
 {
 }
 
@@ -1365,7 +1366,8 @@ SvxColorItem::SvxColorItem( const Color& rCol, const 
sal_uInt16 nId ) :
     SfxPoolItem( nId ),
     mColor( rCol ),
     maThemeIndex(-1),
-    maTintShade(0)
+    maTintShade(0),
+    mnLumMod(10000)
 {
 }
 
@@ -1380,7 +1382,8 @@ bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) 
const
 
     return mColor == rColorItem.mColor &&
            maThemeIndex == rColorItem.maThemeIndex &&
-           maTintShade == rColorItem.maTintShade;
+           maTintShade == rColorItem.maTintShade &&
+           mnLumMod == rColorItem.mnLumMod;
 }
 
 bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
@@ -1409,6 +1412,11 @@ bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 
nMemberId ) const
             rVal <<= maTintShade;
             break;
         }
+        case MID_COLOR_LUM_MOD:
+        {
+            rVal <<= mnLumMod;
+            break;
+        }
         default:
         {
             rVal <<= mColor;
@@ -1455,6 +1463,14 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, 
sal_uInt8 nMemberId )
             maTintShade = nTintShade;
         }
         break;
+        case MID_COLOR_LUM_MOD:
+        {
+            sal_Int16 nLumMod = -1;
+            if (!(rVal >>= nLumMod))
+                return false;
+            mnLumMod = nLumMod;
+        }
+        break;
         default:
         {
             return rVal >>= mColor;
diff --git a/include/editeng/colritem.hxx b/include/editeng/colritem.hxx
index ce51be7f3e30..103c887fbdb6 100644
--- a/include/editeng/colritem.hxx
+++ b/include/editeng/colritem.hxx
@@ -33,6 +33,8 @@ private:
     Color mColor;
     sal_Int16 maThemeIndex;
     sal_Int16 maTintShade;
+    /// Luminance Modulation: 100th percentage, defaults to 10000.
+    sal_Int16 mnLumMod;
 
 public:
     static SfxPoolItem* CreateDefault();
diff --git a/include/editeng/memberids.h b/include/editeng/memberids.h
index c6d781da568a..117c9e2873e1 100644
--- a/include/editeng/memberids.h
+++ b/include/editeng/memberids.h
@@ -183,6 +183,7 @@
 //#define MID_GRAPHIC_TRANSPARENT 3 // used, but already defined above
 #define MID_COLOR_THEME_INDEX   4
 #define MID_COLOR_TINT_OR_SHADE 5
+#define MID_COLOR_LUM_MOD       6
 
 
 #endif
diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx
index 91273845fbd2..e980acb9c8ec 100644
--- a/include/editeng/unoprnms.hxx
+++ b/include/editeng/unoprnms.hxx
@@ -329,6 +329,7 @@
 #define UNO_NAME_EDIT_CHAR_COLOR                "CharColor"
 #define UNO_NAME_EDIT_CHAR_COLOR_THEME          "CharColorTheme"
 #define UNO_NAME_EDIT_CHAR_COLOR_TINT_OR_SHADE  "CharColorTintOrShade"
+#define UNO_NAME_EDIT_CHAR_COLOR_LUM_MOD        "CharColorLumMod"
 #define UNO_NAME_EDIT_CHAR_TRANSPARENCE         "CharTransparence"
 #define UNO_NAME_EDIT_CHAR_CROSSEDOUT           "CharCrossedOut"
 #define UNO_NAME_EDIT_CHAR_STRIKEOUT            "CharStrikeout"
diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx
index c9c4b9580f72..0b38565f179f 100644
--- a/include/editeng/unotext.hxx
+++ b/include/editeng/unotext.hxx
@@ -89,6 +89,7 @@ struct SfxItemPropertyMapEntry;
     { u"" UNO_NAME_EDIT_CHAR_TRANSPARENCE,EE_CHAR_COLOR,      
::cppu::UnoType<sal_Int16>::get(),        0, MID_COLOR_ALPHA }, \
     { u"" UNO_NAME_EDIT_CHAR_COLOR_THEME, EE_CHAR_COLOR,      
::cppu::UnoType<sal_Int16>::get(),        0, MID_COLOR_THEME_INDEX }, \
     { u"" UNO_NAME_EDIT_CHAR_COLOR_TINT_OR_SHADE, EE_CHAR_COLOR, 
::cppu::UnoType<sal_Int16>::get(),     0, MID_COLOR_TINT_OR_SHADE }, \
+    { u"" UNO_NAME_EDIT_CHAR_COLOR_LUM_MOD,       EE_CHAR_COLOR, 
::cppu::UnoType<sal_Int16>::get(),     0, MID_COLOR_LUM_MOD }, \
     { u"CharBackColor",                EE_CHAR_BKGCOLOR,   
::cppu::UnoType<sal_Int32>::get(),        0, 0 }, \
     { u"CharBackTransparent",          EE_CHAR_BKGCOLOR,   
::cppu::UnoType<bool>::get(),             0, MID_GRAPHIC_TRANSPARENT }, \
     { u"" UNO_NAME_EDIT_CHAR_ESCAPEMENT,  EE_CHAR_ESCAPEMENT, 
::cppu::UnoType<sal_Int16>::get(),        0, MID_ESC }, \
diff --git a/include/oox/drawingml/color.hxx b/include/oox/drawingml/color.hxx
index bd67982c6e92..3a8f494ca089 100644
--- a/include/oox/drawingml/color.hxx
+++ b/include/oox/drawingml/color.hxx
@@ -100,6 +100,7 @@ public:
     const OUString&     getSchemeColorName() const { return msSchemeName; }
     sal_Int16           getSchemeColorIndex() const;
     sal_Int16           getTintOrShade();
+    sal_Int16           getLumMod();
 
     /** Returns the unaltered list of transformations for interoperability 
purposes */
     const css::uno::Sequence< css::beans::PropertyValue >& 
getTransformations() const { return maInteropTransformations;}
diff --git a/oox/qa/unit/data/theme.pptx b/oox/qa/unit/data/theme.pptx
index 6d9ffc00bbbb..5268e4041300 100644
Binary files a/oox/qa/unit/data/theme.pptx and b/oox/qa/unit/data/theme.pptx 
differ
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx
index e45ee8d98dd1..f7b6e9b237a3 100644
--- a/oox/qa/unit/drawingml.cxx
+++ b/oox/qa/unit/drawingml.cxx
@@ -437,6 +437,13 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testPptxTheme)
     // 4 is accent1, see oox::drawingml::Color::getSchemeColorIndex().
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4),
                          
xPortion->getPropertyValue("CharColorTheme").get<sal_Int32>());
+    // 60000 in the file, just 100th vs 1000th percents.
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 6000
+    // - Actual  : 10000
+    // i.e. we had the default 100% value, not the value from the file.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6000),
+                         
xPortion->getPropertyValue("CharColorLumMod").get<sal_Int32>());
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx
index 426197102160..35f19c42ed30 100644
--- a/oox/source/drawingml/color.cxx
+++ b/oox/source/drawingml/color.cxx
@@ -495,6 +495,23 @@ sal_Int16 Color::getTintOrShade()
     }
     return 0;
 }
+
+sal_Int16 Color::getLumMod()
+{
+    for (const auto& rTransform : maTransforms)
+    {
+        if (rTransform.mnToken != XML_lumMod)
+        {
+            continue;
+        }
+
+        // From 1000th percent to 100th percent.
+        return rTransform.mnValue / 10;
+    }
+
+    return 10000;
+}
+
 ::Color Color::getColor( const GraphicHelper& rGraphicHelper, ::Color nPhClr ) 
const
 {
     const sal_Int32 nTempC1 = mnC1;
diff --git a/oox/source/drawingml/textcharacterproperties.cxx 
b/oox/source/drawingml/textcharacterproperties.cxx
index 93d642324782..e25c07a2bd70 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -131,6 +131,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& 
rPropMap, const XmlFil
         // set color theme index
         rPropMap.setProperty(PROP_CharColorTheme, 
aColor.getSchemeColorIndex());
         rPropMap.setProperty(PROP_CharColorTintOrShade, 
aColor.getTintOrShade());
+        rPropMap.setProperty(PROP_CharColorLumMod, aColor.getLumMod());
 
         if (aColor.hasTransparency())
         {
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 951a03e7eba0..e85d2bae19e6 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -56,6 +56,7 @@ CharColor
 CharContoured
 CharColorTheme
 CharColorTintOrShade
+CharColorLumMod
 CharEscapement
 CharEscapementHeight
 CharFontCharSet

Reply via email to