[Libreoffice-commits] core.git: Branch 'feature/themesupport2' - 5 commits - editeng/source include/editeng include/oox include/sfx2 include/svx oox/source sfx2/Library_sfx.mk sfx2/source svx/Library_svxcore.mk svx/source sw/source
Sarper Akdemir (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 25 08:12:49 UTC 2021
Rebased ref, commits from common ancestor:
commit 357221a85605722c41588f30d4c7ee875aafe99d
Author: Sarper Akdemir <sarper.akdemir at collabora.com>
AuthorDate: Wed Aug 25 02:24:42 2021 +0300
Commit: Sarper Akdemir <sarper.akdemir at collabora.com>
CommitDate: Wed Aug 25 02:36:59 2021 +0300
implement color tint or shade import for pptx
Change-Id: I38661afecec6d769bd41b8c3b71c9a4de5e69440
diff --git a/include/oox/drawingml/color.hxx b/include/oox/drawingml/color.hxx
index 00473cfe6f27..bd67982c6e92 100644
--- a/include/oox/drawingml/color.hxx
+++ b/include/oox/drawingml/color.hxx
@@ -99,6 +99,7 @@ public:
/** Returns the scheme name from the a:schemeClr element for interoperability purposes */
const OUString& getSchemeColorName() const { return msSchemeName; }
sal_Int16 getSchemeColorIndex() const;
+ sal_Int16 getTintOrShade();
/** Returns the unaltered list of transformations for interoperability purposes */
const css::uno::Sequence< css::beans::PropertyValue >& getTransformations() const { return maInteropTransformations;}
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx
index edb317eaac3d..1c1e9f7a110a 100644
--- a/oox/source/drawingml/color.cxx
+++ b/oox/source/drawingml/color.cxx
@@ -478,6 +478,22 @@ void Color::clearTransparence()
mnAlpha = MAX_PERCENT;
}
+sal_Int16 Color::getTintOrShade()
+{
+ for(auto const& aTransform : maTransforms)
+ {
+ switch(aTransform.mnToken)
+ {
+ case XML_tint:
+ // from 1000th percent to 100th percent...
+ return aTransform.mnValue/10;
+ case XML_shade:
+ // from 1000th percent to 100th percent...
+ return -aTransform.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 90b0e38c1d3a..bd4d051a490b 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -113,6 +113,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil
rPropMap.setProperty(PROP_CharColor, aColor.getColor(rFilter.getGraphicHelper()));
// set color theme index
rPropMap.setProperty(PROP_CharColorTheme, aColor.getSchemeColorIndex());
+ rPropMap.setProperty(PROP_CharColorTintOrShade, aColor.getTintOrShade());
if (aColor.hasTransparency())
{
commit 9f4720bff45d867249d2762c01112eb500fcdf5c
Author: Sarper Akdemir <sarper.akdemir at collabora.com>
AuthorDate: Tue Aug 24 23:58:35 2021 +0300
Commit: Sarper Akdemir <sarper.akdemir at collabora.com>
CommitDate: Wed Aug 25 02:36:59 2021 +0300
rename getSchemeName getSchemeIndex to remove ambiguity
Change-Id: Ib1fa16b15c219b38754ffe5cbfc9d11ff2be0fcd
diff --git a/include/oox/drawingml/color.hxx b/include/oox/drawingml/color.hxx
index f213dba9a973..00473cfe6f27 100644
--- a/include/oox/drawingml/color.hxx
+++ b/include/oox/drawingml/color.hxx
@@ -97,8 +97,8 @@ public:
sal_Int16 getTransparency() const;
/** Returns the scheme name from the a:schemeClr element for interoperability purposes */
- const OUString& getSchemeName() const { return msSchemeName; }
- sal_Int16 getSchemeIndex() const;
+ const OUString& getSchemeColorName() const { return msSchemeName; }
+ sal_Int16 getSchemeColorIndex() const;
/** Returns the unaltered list of transformations for interoperability purposes */
const css::uno::Sequence< css::beans::PropertyValue >& getTransformations() const { return maInteropTransformations;}
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx
index 5d3ea6cb8708..edb317eaac3d 100644
--- a/oox/source/drawingml/color.cxx
+++ b/oox/source/drawingml/color.cxx
@@ -660,7 +660,7 @@ sal_Int16 Color::getTransparency() const
return sal_Int16(std::round( (1.0 * (MAX_PERCENT - mnAlpha)) / PER_PERCENT) );
}
-sal_Int16 Color::getSchemeIndex() const
+sal_Int16 Color::getSchemeColorIndex() const
{
static std::map<OUString, sal_Int32> const aSchemeColorNameToIndex{
{ "dk1", 0 }, { "lt1", 1 }, { "dk2", 2 }, { "lt2", 3 },
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index b0e2ddef30e7..78a482abd446 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1060,7 +1060,7 @@ Reference< XShape > const & Shape::createAndInsert(
// Store style-related properties to InteropGrabBag to be able to export them back
uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence(
{
- {"SchemeClr", uno::makeAny(pLineRef->maPhClr.getSchemeName())},
+ {"SchemeClr", uno::makeAny(pLineRef->maPhClr.getSchemeColorName())},
{"Idx", uno::makeAny(pLineRef->mnThemedIdx)},
{"Color", uno::makeAny(nLinePhClr)},
{"LineStyle", uno::makeAny(aLineProperties.getLineStyle())},
@@ -1078,7 +1078,7 @@ Reference< XShape > const & Shape::createAndInsert(
nFillPhClr = pFillRef->maPhClr.getColor(rGraphicHelper);
}
- OUString sColorScheme = pFillRef->maPhClr.getSchemeName();
+ OUString sColorScheme = pFillRef->maPhClr.getSchemeColorName();
if( !sColorScheme.isEmpty() )
{
uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence(
@@ -1100,7 +1100,7 @@ Reference< XShape > const & Shape::createAndInsert(
// Store style-related properties to InteropGrabBag to be able to export them back
uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence(
{
- {"SchemeClr", uno::makeAny(pEffectRef->maPhClr.getSchemeName())},
+ {"SchemeClr", uno::makeAny(pEffectRef->maPhClr.getSchemeColorName())},
{"Idx", uno::makeAny(pEffectRef->mnThemedIdx)},
{"Transformations", uno::makeAny(pEffectRef->maPhClr.getTransformations())}
});
@@ -1349,13 +1349,13 @@ Reference< XShape > const & Shape::createAndInsert(
aProperties.push_back(comphelper::makePropertyValue("EmuLineWidth", aLineProperties.moLineWidth.get(0)));
aProperties.push_back(comphelper::makePropertyValue("OriginalSolidFillClr", aShapeProps.getProperty(PROP_FillColor)));
aProperties.push_back(comphelper::makePropertyValue("OriginalLnSolidFillClr", aShapeProps.getProperty(PROP_LineColor)));
- OUString sColorFillScheme = aFillProperties.maFillColor.getSchemeName();
+ OUString sColorFillScheme = aFillProperties.maFillColor.getSchemeColorName();
if( !aFillProperties.maFillColor.isPlaceHolder() && !sColorFillScheme.isEmpty() )
{
aProperties.push_back(comphelper::makePropertyValue("SpPrSolidFillSchemeClr", sColorFillScheme));
aProperties.push_back(comphelper::makePropertyValue("SpPrSolidFillSchemeClrTransformations", aFillProperties.maFillColor.getTransformations()));
}
- OUString sLnColorFillScheme = aLineProperties.maLineFill.maFillColor.getSchemeName();
+ OUString sLnColorFillScheme = aLineProperties.maLineFill.maFillColor.getSchemeColorName();
if( !aLineProperties.maLineFill.maFillColor.isPlaceHolder() && !sLnColorFillScheme.isEmpty() )
{
aProperties.push_back(comphelper::makePropertyValue("SpPrLnSolidFillSchemeClr", sLnColorFillScheme));
@@ -1379,7 +1379,7 @@ Reference< XShape > const & Shape::createAndInsert(
std::vector<beans::PropertyValue> aGradientStop;
aGradientStop.push_back(comphelper::makePropertyValue("Pos", rPos));
- OUString sStopColorScheme = rColor.getSchemeName();
+ OUString sStopColorScheme = rColor.getSchemeColorName();
if( sStopColorScheme.isEmpty() )
{
// save RGB color
@@ -1422,7 +1422,7 @@ Reference< XShape > const & Shape::createAndInsert(
aEffectsGrabBag.push_back(comphelper::makePropertyValue("Attribs", aEffect.Value));
Color& aColor( it->moColor );
- OUString sColorScheme = aColor.getSchemeName();
+ OUString sColorScheme = aColor.getSchemeColorName();
if( sColorScheme.isEmpty() )
{
// RGB color and transparency value
diff --git a/oox/source/drawingml/shape3dproperties.cxx b/oox/source/drawingml/shape3dproperties.cxx
index 18f53a7e309f..c4e03ddc9390 100644
--- a/oox/source/drawingml/shape3dproperties.cxx
+++ b/oox/source/drawingml/shape3dproperties.cxx
@@ -312,7 +312,7 @@ css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getColorAtt
const Color& rColor, const GraphicHelper& rGraphicHelper, ::Color rPhClr )
{
css::uno::Sequence<css::beans::PropertyValue> aSeq(2);
- const OUString& sColorScheme = rColor.getSchemeName();
+ const OUString& sColorScheme = rColor.getSchemeColorName();
if( sColorScheme.isEmpty() )
{
// RGB color and transparency value
diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx
index 9cbc331d05fa..90b0e38c1d3a 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -112,7 +112,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil
Color aColor = maFillProperties.getBestSolidColor();
rPropMap.setProperty(PROP_CharColor, aColor.getColor(rFilter.getGraphicHelper()));
// set color theme index
- rPropMap.setProperty(PROP_CharColorTheme, aColor.getSchemeIndex());
+ rPropMap.setProperty(PROP_CharColorTheme, aColor.getSchemeColorIndex());
if (aColor.hasTransparency())
{
commit f66ad076ae913a618741c59d350e69cf5f195730
Author: Sarper Akdemir <sarper.akdemir at collabora.com>
AuthorDate: Fri Aug 20 00:45:55 2021 +0300
Commit: Sarper Akdemir <sarper.akdemir at collabora.com>
CommitDate: Wed Aug 25 02:36:58 2021 +0300
implement initial pptx theme color import
Change-Id: Ic3a46c2d01c8f8be73f22d2af41aa11a9bb3267d
diff --git a/include/oox/drawingml/color.hxx b/include/oox/drawingml/color.hxx
index 59f417cfac52..f213dba9a973 100644
--- a/include/oox/drawingml/color.hxx
+++ b/include/oox/drawingml/color.hxx
@@ -98,6 +98,8 @@ public:
/** Returns the scheme name from the a:schemeClr element for interoperability purposes */
const OUString& getSchemeName() const { return msSchemeName; }
+ sal_Int16 getSchemeIndex() const;
+
/** Returns the unaltered list of transformations for interoperability purposes */
const css::uno::Sequence< css::beans::PropertyValue >& getTransformations() const { return maInteropTransformations;}
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx
index 1cd5d2ebaed7..5d3ea6cb8708 100644
--- a/oox/source/drawingml/color.cxx
+++ b/oox/source/drawingml/color.cxx
@@ -660,6 +660,21 @@ sal_Int16 Color::getTransparency() const
return sal_Int16(std::round( (1.0 * (MAX_PERCENT - mnAlpha)) / PER_PERCENT) );
}
+sal_Int16 Color::getSchemeIndex() const
+{
+ static std::map<OUString, sal_Int32> const aSchemeColorNameToIndex{
+ { "dk1", 0 }, { "lt1", 1 }, { "dk2", 2 }, { "lt2", 3 },
+ { "accent1", 4 }, { "accent2", 5 }, { "accent3", 6 }, { "accent4", 7 },
+ { "accent5", 8 }, { "accent6", 9 }, { "hlink", 10 }, { "folHlink", 11 }
+ };
+
+ auto aIt = aSchemeColorNameToIndex.find(msSchemeName);
+ if( aIt == aSchemeColorNameToIndex.end() )
+ return -1;
+ else
+ return aIt->second;
+}
+
// private --------------------------------------------------------------------
void Color::setResolvedRgb( ::Color nRgb ) const
diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx
index 4eb5acaffb56..9cbc331d05fa 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -111,6 +111,8 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil
{
Color aColor = maFillProperties.getBestSolidColor();
rPropMap.setProperty(PROP_CharColor, aColor.getColor(rFilter.getGraphicHelper()));
+ // set color theme index
+ rPropMap.setProperty(PROP_CharColorTheme, aColor.getSchemeIndex());
if (aColor.hasTransparency())
{
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 68b5e2d14af5..1b20bfe61828 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -54,6 +54,8 @@ CharBackColor
CharCaseMap
CharColor
CharContoured
+CharColorTheme
+CharColorTintOrShade
CharEscapement
CharEscapementHeight
CharFontCharSet
commit 6357d2beab1622d7442bc6884065f49c8ddd5d6f
Author: Sarper Akdemir <sarper.akdemir at collabora.com>
AuthorDate: Wed Aug 18 16:04:37 2021 +0300
Commit: Sarper Akdemir <sarper.akdemir at collabora.com>
CommitDate: Wed Aug 25 02:36:58 2021 +0300
expose the SvxColorItem theme related uno for draw/impress
Change-Id: I6d8dc19d5c2418aa61fed507cb2bb5b119d15acd
diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx
index c637521dcf2d..3c5011210d51 100644
--- a/include/editeng/unoprnms.hxx
+++ b/include/editeng/unoprnms.hxx
@@ -325,6 +325,8 @@
#define UNO_NAME_EDIT_CHAR_LOCALE_COMPLEX "CharLocaleComplex"
#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_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 0c09b4361edc..896130f6d257 100644
--- a/include/editeng/unotext.hxx
+++ b/include/editeng/unotext.hxx
@@ -85,8 +85,10 @@ struct SfxItemPropertyMapEntry;
{ u"" UNO_NAME_EDIT_CHAR_POSTURE, EE_CHAR_ITALIC, ::cppu::UnoType<css::awt::FontSlant>::get(),0, MID_POSTURE }, \
{ u"" UNO_NAME_EDIT_CHAR_WEIGHT, EE_CHAR_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT }, \
{ u"" UNO_NAME_EDIT_CHAR_LOCALE, EE_CHAR_LANGUAGE, ::cppu::UnoType<css::lang::Locale>::get(),0, MID_LANG_LOCALE }, \
- { u"" UNO_NAME_EDIT_CHAR_COLOR, EE_CHAR_COLOR, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, \
+ { u"" UNO_NAME_EDIT_CHAR_COLOR, EE_CHAR_COLOR, ::cppu::UnoType<sal_Int32>::get(), 0, MID_COLOR_RGB }, \
{ 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"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/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index e90d980ebd89..f5564ef236d0 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -578,7 +578,9 @@ static SfxItemPropertyMapEntry const * ImplGetSvxControlShapePropertyMap()
{ u"" UNO_NAME_EDIT_CHAR_UNDERLINE, 0, cppu::UnoType<sal_Int16>::get(), 0, 0 },
{ u"" UNO_NAME_EDIT_CHAR_STRIKEOUT, 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
{ u"" UNO_NAME_EDIT_CHAR_CASEMAP, 0, cppu::UnoType<sal_Int16>::get(), 0, 0 },
- { u"" UNO_NAME_EDIT_CHAR_COLOR, 0, cppu::UnoType<sal_Int32>::get(), 0, 0 },
+ { u"" UNO_NAME_EDIT_CHAR_COLOR, 0, cppu::UnoType<sal_Int32>::get(), 0, MID_COLOR_RGB },
+ { u"" UNO_NAME_EDIT_CHAR_COLOR_THEME, 0, cppu::UnoType<sal_Int16>::get(), 0, MID_COLOR_THEME_INDEX },
+ { u"" UNO_NAME_EDIT_CHAR_COLOR_TINT_OR_SHADE, 0, cppu::UnoType<sal_Int16>::get(), 0, MID_COLOR_TINT_OR_SHADE },
{ u"CharBackColor", 0, cppu::UnoType<sal_Int32>::get(), 0, 0 },
{ u"CharBackTransparent", 0, cppu::UnoType<bool>::get(), 0, 0 },
{ u"CharRelief", 0, cppu::UnoType<sal_Int16>::get(), 0, 0 },
commit 12b8b2b16a1b27d431fa50c97533ea9e83c6e3d9
Author: Sarper Akdemir <sarper.akdemir at collabora.com>
AuthorDate: Wed Jul 28 02:03:12 2021 +0300
Commit: Sarper Akdemir <sarper.akdemir at collabora.com>
CommitDate: Wed Aug 25 02:36:58 2021 +0300
make colorsets work outside of styles and with direct formatting
Change-Id: Id3cb073d4567f4dbc70a52bc08403751f4c8ddd4
diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx
index ac87db3a2573..eddcc756d493 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/frame/status/FontHeight.hpp>
#include <math.h>
+#include <optional>
#include <sal/log.hxx>
#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
@@ -78,6 +79,9 @@
#include <editeng/eerdll.hxx>
#include <libxml/xmlwriter.h>
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/objsh.hxx>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::text;
@@ -1309,20 +1313,62 @@ bool SvxContourItem::GetPresentation
return true;
}
+// struct ThemeColorData
+ThemeColorData::ThemeColorData() :
+ mnThemeIndex(-1),
+ mnTintShade(0),
+ maCachedBaseColor(),
+ mpColorSets(nullptr)
+{
+}
+
+std::optional<Color> ThemeColorData::getThemeColorIfNeedsUpdate()
+{
+ if (mnThemeIndex > -1)
+ {
+ // try to get the pointer for ColorSets if it's not there...
+ if (!mpColorSets)
+ {
+ if (SfxObjectShell* pObjShell = SfxObjectShell::Current())
+ {
+ if (const SfxColorSetListItem* pColorSetItem = pObjShell->GetItem(SID_COLOR_SETS))
+ {
+ mpColorSets = &pColorSetItem->GetSfxColorSetList();
+ }
+ }
+ }
+
+ if (mpColorSets)
+ {
+ Color aColor = mpColorSets->getThemeColorSet().getColor(mnThemeIndex);
+
+ // only calculate tint or shade applied color when necessary
+ if(aColor != maCachedBaseColor || mnTintShade != mnCalculatedTintShade)
+ {
+ maCachedBaseColor = aColor;
+ aColor.ApplyTintOrShade(mnTintShade);
+ mnCalculatedTintShade = mnTintShade;
+ return aColor;
+ }
+ }
+ }
+
+ // if there's no update needed or the color isn't a theme color return nullopt
+ return std::nullopt;
+}
+
// class SvxColorItem ----------------------------------------------------
SvxColorItem::SvxColorItem( const sal_uInt16 nId ) :
SfxPoolItem(nId),
mColor( COL_BLACK ),
- maThemeIndex(-1),
- maTintShade(0)
+ maThemeColorData()
{
}
SvxColorItem::SvxColorItem( const Color& rCol, const sal_uInt16 nId ) :
SfxPoolItem( nId ),
mColor( rCol ),
- maThemeIndex(-1),
- maTintShade(0)
+ maThemeColorData()
{
}
@@ -1335,9 +1381,9 @@ bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const
assert(SfxPoolItem::operator==(rAttr));
const SvxColorItem& rColorItem = static_cast<const SvxColorItem&>(rAttr);
- return mColor == rColorItem.mColor &&
- maThemeIndex == rColorItem.maThemeIndex &&
- maTintShade == rColorItem.maTintShade;
+ return mColor == rColorItem.mColor
+ && maThemeColorData.mnThemeIndex == rColorItem.maThemeColorData.mnThemeIndex
+ && maThemeColorData.mnTintShade == rColorItem.maThemeColorData.mnTintShade;
}
bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
@@ -1358,12 +1404,12 @@ bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
}
case MID_COLOR_THEME_INDEX:
{
- rVal <<= maThemeIndex;
+ rVal <<= maThemeColorData.mnThemeIndex;
break;
}
case MID_COLOR_TINT_OR_SHADE:
{
- rVal <<= maTintShade;
+ rVal <<= maThemeColorData.mnTintShade;
break;
}
default:
@@ -1401,7 +1447,7 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
sal_Int16 nIndex = -1;
if (!(rVal >>= nIndex))
return false;
- maThemeIndex = nIndex;
+ maThemeColorData.mnThemeIndex = nIndex;
}
break;
case MID_COLOR_TINT_OR_SHADE:
@@ -1409,7 +1455,7 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
sal_Int16 nTintShade = -1;
if (!(rVal >>= nTintShade))
return false;
- maTintShade = nTintShade;
+ maThemeColorData.mnTintShade = nTintShade;
}
break;
default:
@@ -1454,7 +1500,13 @@ void SvxColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
(void)xmlTextWriterEndElement(pWriter);
}
+const Color& SvxColorItem::GetValue() const
+{
+ if(auto aOptionalColor = maThemeColorData.getThemeColorIfNeedsUpdate())
+ mColor = aOptionalColor.value();
+ return mColor;
+}
void SvxColorItem::SetValue( const Color& rNewCol )
{
diff --git a/include/editeng/colritem.hxx b/include/editeng/colritem.hxx
index ce51be7f3e30..22b7bb8d312c 100644
--- a/include/editeng/colritem.hxx
+++ b/include/editeng/colritem.hxx
@@ -19,20 +19,64 @@
#ifndef INCLUDED_EDITENG_COLRITEM_HXX
#define INCLUDED_EDITENG_COLRITEM_HXX
+#include <sfx2/objsh.hxx>
+#include <sfx2/ColorSets.hxx>
#include <svl/poolitem.hxx>
#include <tools/color.hxx>
#include <editeng/editengdllapi.h>
+#include <sal/log.hxx>
+
#define VERSION_USEAUTOCOLOR 1
+/** ThemeColorData holds theme color related
+ data of a color item eg. SvxColorItem
+*/
+struct ThemeColorData
+{
+ ThemeColorData();
+
+ /** Calculates and returns the theme color from current ThemeColorData
+
+ @returns std::nullopt if color item that owns the ThemeColorData
+ doesn't need a color update, returns calculated color otherwise.
+
+ */
+ std::optional<Color> getThemeColorIfNeedsUpdate();
+
+ /** Specifies which color of the current theme color set
+ is the base color for this item.
+
+ If it is -1, this item isn't a theme color.
+ */
+ sal_Int16 mnThemeIndex;
+ /** Tint or Shade value that will be applied on top
+ of to the base color
+ */
+ sal_Int16 mnTintShade;
+ /** Cached tint or shade value used to determine whether
+ a recalculation of theme color is required.
+ */
+ sal_Int16 mnCalculatedTintShade;
+ /** Cached base color value used to determine whether
+ a recalculation of theme color is required.
+ */
+ Color maCachedBaseColor;
+ /** Pointer to the ColorSets of the document.
+ */
+ const ColorSets* mpColorSets;
+};
+
/** SvxColorItem item describes a color.
*/
class EDITENG_DLLPUBLIC SvxColorItem final : public SfxPoolItem
{
private:
- Color mColor;
- sal_Int16 maThemeIndex;
- sal_Int16 maTintShade;
+ mutable Color mColor;
+ /** ThemeColorData that is used to calculate and update mColor
+ if color item is a theme color.
+ */
+ mutable ThemeColorData maThemeColorData;
public:
static SfxPoolItem* CreateDefault();
@@ -53,31 +97,20 @@ public:
virtual SvxColorItem* Clone(SfxItemPool* pPool = nullptr) const override;
SvxColorItem(SvxColorItem const &) = default; // SfxPoolItem copy function dichotomy
- const Color& GetValue() const
- {
- return mColor;
- }
+ const Color& GetValue() const;
+
void SetValue(const Color& rNewColor);
sal_Int16 GetThemeIndex() const
{
- return maThemeIndex;
+ return maThemeColorData.mnThemeIndex;
}
- void SetThemeIndex(sal_Int16 nIndex)
- {
- maThemeIndex = nIndex;
- }
+ void SetThemeIndex(sal_Int16 nIndex) { maThemeColorData.mnThemeIndex = nIndex; }
- sal_Int16 GetTintOrShade() const
- {
- return maTintShade;
- }
+ sal_Int16 GetTintOrShade() const { return maThemeColorData.mnTintShade; }
- void SetTintOrShade(sal_Int16 nTintOrShade)
- {
- maTintShade = nTintOrShade;
- }
+ void SetTintOrShade(sal_Int16 nTintOrShade) { maThemeColorData.mnTintShade = nTintOrShade; }
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
};
diff --git a/include/sfx2/ColorSets.hxx b/include/sfx2/ColorSets.hxx
new file mode 100644
index 000000000000..ffd3ea4f6ed3
--- /dev/null
+++ b/include/sfx2/ColorSets.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <vector>
+
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <sfx2/dllapi.h>
+#include <svl/poolitem.hxx>
+#include <tools/color.hxx>
+
+class ColorSet
+{
+ OUString maColorSetName;
+ std::vector<Color> maColors;
+
+public:
+ ColorSet(OUString const& aName);
+
+ void add(sal_uInt32 nIndex, ::Color aColorData) { maColors[nIndex] = aColorData; }
+
+ const OUString& getName() const { return maColorSetName; }
+ const Color& getColor(sal_uInt32 nIndex) const { return maColors[nIndex]; }
+
+ const std::vector<Color>& getColors() const { return maColors; }
+};
+
+class SFX2_DLLPUBLIC ColorSets
+{
+ std::vector<ColorSet> maColorSets;
+ sal_Int32 mnThemeColorSetIndex;
+
+public:
+ ColorSets();
+ ~ColorSets();
+
+ static ColorSets& get()
+ {
+ static ColorSets aColorSetsInstance;
+ return aColorSetsInstance;
+ }
+
+ const ColorSet& getThemeColorSet() const { return getColorSet(mnThemeColorSetIndex); }
+
+ void setThemeColorSet(sal_Int32 nIndex);
+
+ void setThemeColorSet(std::u16string_view rName);
+
+ const std::vector<ColorSet>& getColorSets() const { return maColorSets; }
+
+ const ColorSet& getColorSet(sal_uInt32 nIndex) const { return maColorSets[nIndex]; }
+
+ const ColorSet& getColorSet(std::u16string_view rName) const;
+};
+
+class SFX2_DLLPUBLIC SfxColorSetListItem final : public SfxPoolItem
+{
+ std::shared_ptr<ColorSets> mpColorSets;
+
+public:
+ static SfxPoolItem* CreateDefault();
+ SfxColorSetListItem();
+ SfxColorSetListItem(const ColorSets& rColorSets, sal_uInt16 nWhich);
+ SfxColorSetListItem(const SfxColorSetListItem&);
+
+ virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric,
+ MapUnit ePresMetric, OUString& rText,
+ const IntlWrapper&) const override;
+
+ virtual bool operator==(const SfxPoolItem&) const override;
+ virtual SfxColorSetListItem* Clone(SfxItemPool* pPool = nullptr) const override;
+ virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
+ virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
+
+ const ColorSets& GetSfxColorSetList() const { return *mpColorSets; }
+ std::shared_ptr<ColorSets> GetSfxColorSetListPtr() const { return mpColorSets; }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 35d9ab895856..c2b3a13818bc 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -28,6 +28,7 @@ class SfxUInt16Item;
class SvxHyperlinkItem;
class SfxDocumentInfoItem;
class SvxSearchItem;
+class SfxColorSetListItem;
// Please be careful:
// Changing just one part here doesn't add new
@@ -362,6 +363,7 @@ class SvxSearchItem;
#define SID_STYLE_UPD_BY_EX_NAME (SID_SFX_START + 1585)
#define SID_STYLE_REFERENCE TypedWhichId<SfxStringItem>(SID_SFX_START + 1602)
+#define SID_COLOR_SETS TypedWhichId<SfxColorSetListItem>(SID_SFX_START + 1605)
#define SID_TEMPLATE_NAME (SID_SFX_START + 660)
#define SID_TEMPLATE_REGIONNAME (SID_SFX_START + 662)
#define SID_TEMPLATE_LOAD (SID_SFX_START + 663)
diff --git a/include/svx/ColorSets.hxx b/include/svx/ColorSets.hxx
deleted file mode 100644
index 361fe47c622e..000000000000
--- a/include/svx/ColorSets.hxx
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- */
-
-#ifndef INCLUDED_SVX_COLORSETS_HXX
-#define INCLUDED_SVX_COLORSETS_HXX
-
-#include <vector>
-
-#include <rtl/ustring.hxx>
-#include <sal/types.h>
-#include <svx/svxdllapi.h>
-#include <tools/color.hxx>
-
-namespace svx
-{
-
-class ColorSet
-{
- OUString maColorSetName;
- std::vector<Color> maColors;
-public:
- ColorSet(OUString const & aName);
-
- void add(sal_uInt32 nIndex, ::Color aColorData)
- {
- maColors[nIndex] = aColorData;
- }
-
- const OUString& getName() const
- {
- return maColorSetName;
- }
- const Color& getColor(sal_uInt32 nIndex) const
- {
- return maColors[nIndex];
- }
-};
-
-class SVXCORE_DLLPUBLIC ColorSets
-{
- std::vector<ColorSet> maColorSets;
-public:
- ColorSets();
- ~ColorSets();
-
- void init();
- const std::vector<ColorSet>& getColorSets() const
- {
- return maColorSets;
- }
-
- const ColorSet& getColorSet(sal_uInt32 nIndex)
- {
- return maColorSets[nIndex];
- }
-
- const ColorSet& getColorSet(std::u16string_view rName);
-};
-
-} // end of namespace svx
-
-#endif // INCLUDED_SVX_COLORSETS_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 0120cee75b4e..d2369bb43247 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -294,6 +294,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/sidebar/UnoDecks \
sfx2/source/sidebar/UnoSidebar \
sfx2/source/statbar/stbitem \
+ sfx2/source/styles/ColorSets \
sfx2/source/styles/StyleManager \
sfx2/source/toolbox/tbxitem \
sfx2/source/toolbox/weldutils \
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index 70b2e1e2e486..4175ddf3e467 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -41,6 +41,7 @@
#include <unotools/configmgr.hxx>
#include <unotools/eventcfg.hxx>
+#include <sfx2/ColorSets.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/signaturestate.hxx>
#include <sfx2/sfxmodelfactory.hxx>
@@ -260,6 +261,8 @@ SfxObjectShell::SfxObjectShell( const SfxModelFlags i_nCreationFlags )
const bool bDocRecovery = ( i_nCreationFlags & SfxModelFlags::DISABLE_DOCUMENT_RECOVERY ) == SfxModelFlags::NONE;
if ( !bDocRecovery )
pImpl->m_bDocRecoverySupport = false;
+
+ PutItem(SfxColorSetListItem(ColorSets(), SID_COLOR_SETS));
}
/** Constructor of the class SfxObjectShell.
@@ -277,6 +280,7 @@ SfxObjectShell::SfxObjectShell(SfxObjectCreateMode eMode)
, bIsInGenerateThumbnail(false)
, mbAvoidRecentDocs(false)
{
+ PutItem(SfxColorSetListItem(ColorSets(), SID_COLOR_SETS));
}
SfxObjectShell::~SfxObjectShell()
diff --git a/sfx2/source/styles/ColorSets.cxx b/sfx2/source/styles/ColorSets.cxx
new file mode 100644
index 000000000000..ac0088311c93
--- /dev/null
+++ b/sfx2/source/styles/ColorSets.cxx
@@ -0,0 +1,155 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <sfx2/ColorSets.hxx>
+
+ColorSet::ColorSet(OUString const& aColorSetName)
+ : maColorSetName(aColorSetName)
+ , maColors(12)
+{
+}
+
+ColorSets::ColorSets()
+ : maColorSets()
+ , mnThemeColorSetIndex(0)
+{
+ {
+ ColorSet aColorSet("Breeze");
+ aColorSet.add(0, 0xFCFCFC);
+ aColorSet.add(1, 0x232629);
+ aColorSet.add(2, 0xEFF0F1);
+ aColorSet.add(3, 0x31363B);
+ aColorSet.add(4, 0xDA4453);
+ aColorSet.add(5, 0xF47750);
+ aColorSet.add(6, 0xFDBC4B);
+ aColorSet.add(7, 0xC9CE3B);
+ aColorSet.add(8, 0x1CDC9A);
+ aColorSet.add(9, 0x2ECC71);
+ aColorSet.add(10, 0x1D99F3);
+ aColorSet.add(11, 0x3DAEE9);
+ maColorSets.push_back(aColorSet);
+ }
+ {
+ ColorSet aColorSet("Material Blue");
+ aColorSet.add(0, 0xFFFFFF);
+ aColorSet.add(1, 0x212121);
+ aColorSet.add(2, 0xECEFF1);
+ aColorSet.add(3, 0x37474F);
+ aColorSet.add(4, 0x7986CB);
+ aColorSet.add(5, 0x303F9F);
+ aColorSet.add(6, 0x64B5F6);
+ aColorSet.add(7, 0x1976D2);
+ aColorSet.add(8, 0x4FC3F7);
+ aColorSet.add(9, 0x0277BD);
+ aColorSet.add(10, 0x4DD0E1);
+ aColorSet.add(11, 0x0097A7);
+ maColorSets.push_back(aColorSet);
+ }
+ {
+ ColorSet aColorSet("Material Red");
+ aColorSet.add(0, 0xFFFFFF);
+ aColorSet.add(1, 0x212121);
+ aColorSet.add(2, 0xF5F5F5);
+ aColorSet.add(3, 0x424242);
+ aColorSet.add(4, 0xFF9800);
+ aColorSet.add(5, 0xFF6D00);
+ aColorSet.add(6, 0xFF5722);
+ aColorSet.add(7, 0xDD2C00);
+ aColorSet.add(8, 0xF44336);
+ aColorSet.add(9, 0xD50000);
+ aColorSet.add(10, 0xE91E63);
+ aColorSet.add(11, 0xC51162);
+ maColorSets.push_back(aColorSet);
+ }
+ {
+ ColorSet aColorSet("Material Green");
+ aColorSet.add(0, 0xFFFFFF);
+ aColorSet.add(1, 0x212121);
+ aColorSet.add(2, 0xF5F5F5);
+ aColorSet.add(3, 0x424242);
+ aColorSet.add(4, 0x009688);
+ aColorSet.add(5, 0x00bfa5);
+ aColorSet.add(6, 0x4caf50);
+ aColorSet.add(7, 0x00c853);
+ aColorSet.add(8, 0x8bc34a);
+ aColorSet.add(9, 0x64dd17);
+ aColorSet.add(10, 0xcddc39);
+ aColorSet.add(11, 0xaeea00);
+ maColorSets.push_back(aColorSet);
+ }
+}
+
+ColorSets::~ColorSets() {}
+
+const ColorSet& ColorSets::getColorSet(std::u16string_view rName) const
+{
+ for (const ColorSet& rColorSet : maColorSets)
+ {
+ if (rColorSet.getName() == rName)
+ return rColorSet;
+ }
+ return maColorSets[0];
+}
+
+void ColorSets::setThemeColorSet(sal_Int32 nIndex) { mnThemeColorSetIndex = nIndex; }
+
+void ColorSets::setThemeColorSet(std::u16string_view rName)
+{
+ for (sal_uInt32 nIndex = 0; nIndex < maColorSets.size(); ++nIndex)
+ {
+ if (maColorSets[nIndex].getName() == rName)
+ mnThemeColorSetIndex = nIndex;
+ }
+}
+
+SfxColorSetListItem::SfxColorSetListItem() {}
+
+SfxColorSetListItem::SfxColorSetListItem(const ColorSets& rColorSets, sal_uInt16 nW)
+ : SfxPoolItem(nW)
+{
+ mpColorSets = std::make_shared<ColorSets>(rColorSets);
+}
+
+SfxColorSetListItem::SfxColorSetListItem(const SfxColorSetListItem& rItem)
+ : SfxPoolItem(rItem)
+ , mpColorSets(rItem.mpColorSets)
+{
+}
+
+bool SfxColorSetListItem::GetPresentation(SfxItemPresentation /*ePres*/, MapUnit /*eCoreUnit*/,
+ MapUnit /*ePresUnit*/, OUString& rText,
+ const IntlWrapper&) const
+{
+ rText.clear();
+ return false;
+}
+
+bool SfxColorSetListItem::operator==(const SfxPoolItem& rItem) const
+{
+ assert(SfxPoolItem::operator==(rItem));
+ // TODO: check these out before pushing...
+ return false;
+ // return static_cast<const SfxColorSetListItem&>(rItem).mrColorSets == mrColorSets;
+}
+
+SfxColorSetListItem* SfxColorSetListItem::Clone(SfxItemPool*) const
+{
+ return new SfxColorSetListItem(*this);
+}
+
+/// TODO: check these out before pushing...
+bool SfxColorSetListItem::QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId) const
+{
+ return false;
+}
+
+bool SfxColorSetListItem::PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) { return false; }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index b7fa742cabe8..a7dc6bb2e199 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sfx2/ColorSets.hxx>
+
#include <config_feature_desktop.h>
#include <osl/file.hxx>
#include <sfx2/docfilt.hxx>
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 8e596acd4605..625fa6297109 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -359,7 +359,6 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
svx/source/svdraw/textchaincursor \
svx/source/styles/CommonStylePreviewRenderer \
svx/source/styles/CommonStyleManager \
- svx/source/styles/ColorSets \
svx/source/table/cell \
svx/source/table/cellcursor \
svx/source/table/cellrange \
diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx
deleted file mode 100644
index 7a04eb4e6314..000000000000
--- a/svx/source/styles/ColorSets.cxx
+++ /dev/null
@@ -1,107 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- */
-
-#include <svx/ColorSets.hxx>
-
-namespace svx
-{
-
-ColorSet::ColorSet(OUString const & aColorSetName)
- : maColorSetName(aColorSetName)
- , maColors(12)
-{}
-
-ColorSets::ColorSets()
-{}
-
-ColorSets::~ColorSets()
-{}
-
-void ColorSets::init()
-{
- {
- ColorSet aColorSet("Breeze");
- aColorSet.add(0, 0xFCFCFC);
- aColorSet.add(1, 0x232629);
- aColorSet.add(2, 0xEFF0F1);
- aColorSet.add(3, 0x31363B);
- aColorSet.add(4, 0xDA4453);
- aColorSet.add(5, 0xF47750);
- aColorSet.add(6, 0xFDBC4B);
- aColorSet.add(7, 0xC9CE3B);
- aColorSet.add(8, 0x1CDC9A);
- aColorSet.add(9, 0x2ECC71);
- aColorSet.add(10, 0x1D99F3);
- aColorSet.add(11, 0x3DAEE9);
- maColorSets.push_back(aColorSet);
- }
- {
- ColorSet aColorSet("Material Blue");
- aColorSet.add(0, 0xFFFFFF);
- aColorSet.add(1, 0x212121);
- aColorSet.add(2, 0xECEFF1);
- aColorSet.add(3, 0x37474F);
- aColorSet.add(4, 0x7986CB);
- aColorSet.add(5, 0x303F9F);
- aColorSet.add(6, 0x64B5F6);
- aColorSet.add(7, 0x1976D2);
- aColorSet.add(8, 0x4FC3F7);
- aColorSet.add(9, 0x0277BD);
- aColorSet.add(10, 0x4DD0E1);
- aColorSet.add(11, 0x0097A7);
- maColorSets.push_back(aColorSet);
- }
- {
- ColorSet aColorSet("Material Red");
- aColorSet.add(0, 0xFFFFFF);
- aColorSet.add(1, 0x212121);
- aColorSet.add(2, 0xF5F5F5);
- aColorSet.add(3, 0x424242);
- aColorSet.add(4, 0xFF9800);
- aColorSet.add(5, 0xFF6D00);
- aColorSet.add(6, 0xFF5722);
- aColorSet.add(7, 0xDD2C00);
- aColorSet.add(8, 0xF44336);
- aColorSet.add(9, 0xD50000);
- aColorSet.add(10, 0xE91E63);
- aColorSet.add(11, 0xC51162);
- maColorSets.push_back(aColorSet);
- }
- {
- ColorSet aColorSet("Material Green");
- aColorSet.add(0, 0xFFFFFF);
- aColorSet.add(1, 0x212121);
- aColorSet.add(2, 0xF5F5F5);
- aColorSet.add(3, 0x424242);
- aColorSet.add(4, 0x009688);
- aColorSet.add(5, 0x00bfa5);
- aColorSet.add(6, 0x4caf50);
- aColorSet.add(7, 0x00c853);
- aColorSet.add(8, 0x8bc34a);
- aColorSet.add(9, 0x64dd17);
- aColorSet.add(10, 0xcddc39);
- aColorSet.add(11, 0xaeea00);
- maColorSets.push_back(aColorSet);
- }
-}
-
-const ColorSet& ColorSets::getColorSet(std::u16string_view rName)
-{
- for (const ColorSet & rColorSet : maColorSets)
- {
- if (rColorSet.getName() == rName)
- return rColorSet;
- }
- return maColorSets[0];
-}
-
-} // end of namespace svx
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx b/sw/source/uibase/sidebar/ThemePanel.cxx
index ce42983879ce..a9ddb4af0c83 100644
--- a/sw/source/uibase/sidebar/ThemePanel.cxx
+++ b/sw/source/uibase/sidebar/ThemePanel.cxx
@@ -13,6 +13,7 @@
#include "ThemePanel.hxx"
#include <sfx2/objsh.hxx>
+#include <sfx2/sfxsids.hrc>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
@@ -75,7 +76,7 @@ public:
maVariable = aVariable;
}
- Color getColor(svx::ColorSet const & rColorSet)
+ Color getColor(ColorSet const & rColorSet)
{
Color aColor;
if (maVariable.mnIndex > -1)
@@ -229,7 +230,7 @@ void changeFont(SwFormat* pFormat, SwDocStyleSheet const * pStyle, FontSet const
}
}*/
-void changeColor(SwTextFormatColl* pCollection, svx::ColorSet const& rColorSet, StyleRedefinition* /*pRedefinition*/)
+void changeColor(SwTextFormatColl* pCollection, ColorSet const& rColorSet, StyleRedefinition* /*pRedefinition*/)
{
SvxColorItem aColorItem(pCollection->GetColor());
sal_Int16 nIndex = aColorItem.GetThemeIndex();
@@ -331,16 +332,19 @@ FontSet getFontSet(std::u16string_view rFontVariant, std::vector<FontSet>& aFont
}
void applyTheme(SfxStyleSheetBasePool* pPool, std::u16string_view sFontSetName, std::u16string_view sColorSetName,
- StyleSet& rStyleSet, svx::ColorSets& rColorSets)
+ StyleSet& rStyleSet, ColorSets& rColorSets)
{
SwDocStyleSheet* pStyle;
std::vector<FontSet> aFontSets = initFontSets();
FontSet aFontSet = getFontSet(sFontSetName, aFontSets);
- svx::ColorSet aColorSet = rColorSets.getColorSet(sColorSetName);
+ ColorSet aColorSet = rColorSets.getColorSet(sColorSetName);
pStyle = static_cast<SwDocStyleSheet*>(pPool->First(SfxStyleFamily::Para));
+
+ rColorSets.setThemeColorSet(sColorSetName);
+
while (pStyle)
{
SwTextFormatColl* pCollection = pStyle->GetCollection();
@@ -368,7 +372,7 @@ void applyTheme(SfxStyleSheetBasePool* pPool, std::u16string_view sFontSetName,
}
}
-BitmapEx GenerateColorPreview(const svx::ColorSet& rColorSet)
+BitmapEx GenerateColorPreview(const ColorSet& rColorSet)
{
ScopedVclPtrInstance<VirtualDevice> pVirtualDev(*Application::GetDefaultDevice());
float fScaleFactor = pVirtualDev->GetDPIScaleFactor();
@@ -440,7 +444,7 @@ ThemePanel::ThemePanel(weld::Widget* pParent)
, mxValueSetColors(new ValueSet(nullptr))
, mxValueSetColorsWin(new weld::CustomWeld(*m_xBuilder, "valueset_colors", *mxValueSetColors))
, mxApplyButton(m_xBuilder->weld_button("apply"))
- , maColorSets()
+ , maColorSets(nullptr)
{
mxValueSetColors->SetColCount(2);
mxValueSetColors->SetLineCount(3);
@@ -454,26 +458,32 @@ ThemePanel::ThemePanel(weld::Widget* pParent)
for (const FontSet & rFontSet : aFontSets)
mxListBoxFonts->append_text(rFontSet.maName);
mxListBoxFonts->set_size_request(-1, mxListBoxFonts->get_height_rows(aFontSets.size()));
+ if (SfxObjectShell* pObjShell = SfxObjectShell::Current())
+ {
+ if (const SfxColorSetListItem* pColorSetItem = pObjShell->GetItem(SID_COLOR_SETS))
+ {
+ maColorSets = pColorSetItem->GetSfxColorSetListPtr();
+ }
+ }
- maColorSets.init();
- const std::vector<svx::ColorSet>& aColorSets = maColorSets.getColorSets();
- for (size_t i = 0; i < aColorSets.size(); ++i)
- {
- const svx::ColorSet& rColorSet = aColorSets[i];
+ const std::vector<ColorSet>& aColorSets = maColorSets->getColorSets();
+ for (size_t i = 0; i < aColorSets.size(); ++i)
+ {
+ const ColorSet& rColorSet = aColorSets[i];
- const OUString& aName = rColorSet.getName();
- BitmapEx aPreview = GenerateColorPreview(rColorSet);
+ const OUString& aName = rColorSet.getName();
+ BitmapEx aPreview = GenerateColorPreview(rColorSet);
- sal_uInt16 nId = i + 1;
- mxValueSetColors->InsertItem(nId, Image(aPreview), aName);
- }
+ sal_uInt16 nId = i + 1;
+ mxValueSetColors->InsertItem(nId, Image(aPreview), aName);
+ }
- mxValueSetColors->SetOptimalSize();
+ mxValueSetColors->SetOptimalSize();
- if (!aColorSets.empty())
- mxValueSetColors->SelectItem(1); // ItemId 1, position 0
-}
+ if (!aColorSets.empty())
+ mxValueSetColors->SelectItem(1); // ItemId 1, position 0
+ }
ThemePanel::~ThemePanel()
{
@@ -510,11 +520,11 @@ void ThemePanel::DoubleClickHdl()
return;
OUString sEntryFonts = mxListBoxFonts->get_selected_text();
sal_uInt32 nIndex = nItemId - 1;
- OUString sEntryColors = maColorSets.getColorSet(nIndex).getName();
+ OUString sEntryColors = maColorSets->getColorSet(nIndex).getName();
StyleSet aStyleSet = setupThemes();
- applyTheme(pDocSh->GetStyleSheetPool(), sEntryFonts, sEntryColors, aStyleSet, maColorSets);
+ applyTheme(pDocSh->GetStyleSheetPool(), sEntryFonts, sEntryColors, aStyleSet, *maColorSets);
}
void ThemePanel::NotifyItemUpdate(const sal_uInt16 /*nSId*/,
diff --git a/sw/source/uibase/sidebar/ThemePanel.hxx b/sw/source/uibase/sidebar/ThemePanel.hxx
index 14af479e664a..ee0cbeaadfa1 100644
--- a/sw/source/uibase/sidebar/ThemePanel.hxx
+++ b/sw/source/uibase/sidebar/ThemePanel.hxx
@@ -13,7 +13,7 @@
#include <sfx2/sidebar/PanelLayout.hxx>
#include <sfx2/sidebar/ControllerItem.hxx>
#include <svtools/valueset.hxx>
-#include <svx/ColorSets.hxx>
+#include <sfx2/ColorSets.hxx>
namespace sw::sidebar {
@@ -40,7 +40,7 @@ private:
std::unique_ptr<weld::CustomWeld> mxValueSetColorsWin;
std::unique_ptr<weld::Button> mxApplyButton;
- svx::ColorSets maColorSets;
+ std::shared_ptr<ColorSets> maColorSets;
DECL_LINK(ClickHdl, weld::Button&, void);
DECL_LINK(DoubleClickHdl, weld::TreeView&, bool);
More information about the Libreoffice-commits
mailing list