diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-11-24 08:22:47 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-11-24 09:33:30 +0100 |
commit | a557a1c4ac0b73668452f80169870bdfb204aeb6 (patch) | |
tree | 5e7b2b4aa3a9d531b6bbbdff17643878f37f6707 | |
parent | ecfce0ff23d9f1ed5a51b29b14a7043dce87b300 (diff) |
PPTX import: implement native handling of a color's luminance offset
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, and also the last transform
which is easy to generate from the PowerPoint UI and we didn't import to
the doc model.
Change-Id: Ica4e738d8dc8e0409160ceab941a82f2475ddc68
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125749
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | editeng/source/items/textitem.cxx | 22 | ||||
-rw-r--r-- | include/editeng/colritem.hxx | 4 | ||||
-rw-r--r-- | include/editeng/memberids.h | 1 | ||||
-rw-r--r-- | include/editeng/unoprnms.hxx | 1 | ||||
-rw-r--r-- | include/editeng/unotext.hxx | 1 | ||||
-rw-r--r-- | include/oox/drawingml/color.hxx | 1 | ||||
-rw-r--r-- | oox/qa/unit/drawingml.cxx | 8 | ||||
-rw-r--r-- | oox/source/drawingml/color.cxx | 16 | ||||
-rw-r--r-- | oox/source/drawingml/textcharacterproperties.cxx | 1 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 1 |
10 files changed, 52 insertions, 4 deletions
diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 73ce5c3fd1f1..32c269480c5a 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -1358,7 +1358,8 @@ SvxColorItem::SvxColorItem( const sal_uInt16 nId ) : mColor( COL_BLACK ), maThemeIndex(-1), maTintShade(0), - mnLumMod(10000) + mnLumMod(10000), + mnLumOff(0) { } @@ -1367,7 +1368,8 @@ SvxColorItem::SvxColorItem( const Color& rCol, const sal_uInt16 nId ) : mColor( rCol ), maThemeIndex(-1), maTintShade(0), - mnLumMod(10000) + mnLumMod(10000), + mnLumOff(0) { } @@ -1383,7 +1385,8 @@ bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const return mColor == rColorItem.mColor && maThemeIndex == rColorItem.maThemeIndex && maTintShade == rColorItem.maTintShade && - mnLumMod == rColorItem.mnLumMod; + mnLumMod == rColorItem.mnLumMod && + mnLumOff == rColorItem.mnLumOff; } bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const @@ -1417,6 +1420,11 @@ bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const rVal <<= mnLumMod; break; } + case MID_COLOR_LUM_OFF: + { + rVal <<= mnLumOff; + break; + } default: { rVal <<= mColor; @@ -1471,6 +1479,14 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) mnLumMod = nLumMod; } break; + case MID_COLOR_LUM_OFF: + { + sal_Int16 nLumOff = -1; + if (!(rVal >>= nLumOff)) + return false; + mnLumOff = nLumOff; + } + break; default: { return rVal >>= mColor; diff --git a/include/editeng/colritem.hxx b/include/editeng/colritem.hxx index 103c887fbdb6..cd223d2777bc 100644 --- a/include/editeng/colritem.hxx +++ b/include/editeng/colritem.hxx @@ -33,8 +33,10 @@ private: Color mColor; sal_Int16 maThemeIndex; sal_Int16 maTintShade; - /// Luminance Modulation: 100th percentage, defaults to 10000. + /// Luminance Modulation: 100th percentage, defaults to 100%. sal_Int16 mnLumMod; + /// Luminance Offset: 100th percentage, defaults to 0%. + sal_Int16 mnLumOff; public: static SfxPoolItem* CreateDefault(); diff --git a/include/editeng/memberids.h b/include/editeng/memberids.h index 117c9e2873e1..1b50ab467229 100644 --- a/include/editeng/memberids.h +++ b/include/editeng/memberids.h @@ -184,6 +184,7 @@ #define MID_COLOR_THEME_INDEX 4 #define MID_COLOR_TINT_OR_SHADE 5 #define MID_COLOR_LUM_MOD 6 +#define MID_COLOR_LUM_OFF 7 #endif diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx index e980acb9c8ec..f09afa09d487 100644 --- a/include/editeng/unoprnms.hxx +++ b/include/editeng/unoprnms.hxx @@ -330,6 +330,7 @@ #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_COLOR_LUM_OFF "CharColorLumOff" #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 0b38565f179f..a2b4ae7e7181 100644 --- a/include/editeng/unotext.hxx +++ b/include/editeng/unotext.hxx @@ -90,6 +90,7 @@ struct SfxItemPropertyMapEntry; { 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"" UNO_NAME_EDIT_CHAR_COLOR_LUM_OFF, EE_CHAR_COLOR, ::cppu::UnoType<sal_Int16>::get(), 0, MID_COLOR_LUM_OFF }, \ { 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 3a8f494ca089..c0dd8d67a31c 100644 --- a/include/oox/drawingml/color.hxx +++ b/include/oox/drawingml/color.hxx @@ -101,6 +101,7 @@ public: sal_Int16 getSchemeColorIndex() const; sal_Int16 getTintOrShade(); sal_Int16 getLumMod(); + sal_Int16 getLumOff(); /** 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/drawingml.cxx b/oox/qa/unit/drawingml.cxx index f7b6e9b237a3..0d6f367f02c7 100644 --- a/oox/qa/unit/drawingml.cxx +++ b/oox/qa/unit/drawingml.cxx @@ -444,6 +444,14 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testPptxTheme) // 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>()); + + // 40000 in the file, just 100th vs 1000th percents. + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 4000 + // - Actual : 0 + // i.e. we had the default 0% value, not the value from the file. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4000), + xPortion->getPropertyValue("CharColorLumOff").get<sal_Int32>()); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index 35f19c42ed30..ee854a761fa2 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -512,6 +512,22 @@ sal_Int16 Color::getLumMod() return 10000; } +sal_Int16 Color::getLumOff() +{ + for (const auto& rTransform : maTransforms) + { + if (rTransform.mnToken != XML_lumOff) + { + continue; + } + + // From 1000th percent to 100th percent. + return rTransform.mnValue / 10; + } + + return 0; +} + ::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 e25c07a2bd70..7ffeaeba8da2 100644 --- a/oox/source/drawingml/textcharacterproperties.cxx +++ b/oox/source/drawingml/textcharacterproperties.cxx @@ -132,6 +132,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil rPropMap.setProperty(PROP_CharColorTheme, aColor.getSchemeColorIndex()); rPropMap.setProperty(PROP_CharColorTintOrShade, aColor.getTintOrShade()); rPropMap.setProperty(PROP_CharColorLumMod, aColor.getLumMod()); + rPropMap.setProperty(PROP_CharColorLumOff, aColor.getLumOff()); if (aColor.hasTransparency()) { diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index e85d2bae19e6..5d261469ca42 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -57,6 +57,7 @@ CharContoured CharColorTheme CharColorTintOrShade CharColorLumMod +CharColorLumOff CharEscapement CharEscapementHeight CharFontCharSet |