summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2022-12-28 09:43:46 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-01-12 23:15:58 +0000
commitbd0f526f2d3e1ffe43a74672485815768eee6e9e (patch)
treefcb675aa06dcc3251f2c23961520ee317483a225 /editeng
parentc945eafc99856f0bcd0a99195e2c5164c2a6d24a (diff)
introduce docmodel comp., model::ThemeColor, use it in SvxColorItem
Added a new component docmodel, that has the document model types, which only depend on other basic components. This is needed so the types can be used in every relevant component - xmloff, oox, svx, editeng,... Introduces model::ThemeColor, which is a class used to store the theme color data, including transformations (svx::Transformation). For UNO use XThemeColor is added, and the implementation UnoThemeColor which wraps svx::ThemeColor, so it can be tranported around. Reactor all the code and tests to accomodate for this change. Change-Id: I7ce6752cdfaf5e4d3b8e4d90314afa469dd65cfc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144847 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/CppunitTest_editeng_core.mk1
-rw-r--r--editeng/Library_editeng.mk1
-rw-r--r--editeng/inc/pch/precompiled_editeng.hxx7
-rw-r--r--editeng/source/items/textitem.cxx105
-rw-r--r--editeng/source/uno/unotext.cxx22
5 files changed, 85 insertions, 51 deletions
diff --git a/editeng/CppunitTest_editeng_core.mk b/editeng/CppunitTest_editeng_core.mk
index 3b3a999e8fa0..9b79048b637a 100644
--- a/editeng/CppunitTest_editeng_core.mk
+++ b/editeng/CppunitTest_editeng_core.mk
@@ -22,6 +22,7 @@ $(eval $(call gb_CppunitTest_use_libraries,editeng_core, \
comphelper \
cppu \
cppuhelper \
+ docmodel \
i18nlangtag \
i18nutil \
lng \
diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk
index 6602793e3e02..7f7f3581b62f 100644
--- a/editeng/Library_editeng.mk
+++ b/editeng/Library_editeng.mk
@@ -138,6 +138,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\
$(eval $(call gb_Library_use_libraries,editeng,\
xo \
basegfx \
+ docmodel \
lng \
svt \
tk \
diff --git a/editeng/inc/pch/precompiled_editeng.hxx b/editeng/inc/pch/precompiled_editeng.hxx
index 8472a893b5a1..3f5d71018ac5 100644
--- a/editeng/inc/pch/precompiled_editeng.hxx
+++ b/editeng/inc/pch/precompiled_editeng.hxx
@@ -13,7 +13,7 @@
manual changes will be rewritten by the next run of update_pch.sh (which presumably
also fixes all possible problems, so it's usually better to use it).
- Generated on 2022-09-03 23:10:43 using:
+ Generated on 2023-01-10 23:29:32 using:
./bin/update_pch editeng editeng --cutoff=5 --exclude:system --include:module --exclude:local
If after updating build fails, use the following command to locate conflicting headers:
@@ -107,7 +107,6 @@
#include <vcl/bitmapex.hxx>
#include <vcl/checksum.hxx>
#include <vcl/dllapi.h>
-#include <comphelper/errcode.hxx>
#include <vcl/font.hxx>
#include <vcl/gfxlink.hxx>
#include <vcl/graph.hxx>
@@ -128,6 +127,7 @@
#if PCH_LEVEL >= 3
#include <basegfx/basegfxdllapi.h>
#include <basegfx/color/bcolor.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/numeric/ftools.hxx>
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/point/b2ipoint.hxx>
@@ -136,6 +136,7 @@
#include <basegfx/range/Range2D.hxx>
#include <basegfx/range/b2drange.hxx>
#include <basegfx/range/basicrange.hxx>
+#include <basegfx/tuple/Size2D.hxx>
#include <basegfx/tuple/Tuple2D.hxx>
#include <basegfx/tuple/Tuple3D.hxx>
#include <basegfx/tuple/b2dtuple.hxx>
@@ -145,6 +146,7 @@
#include <basegfx/vector/b2dsize.hxx>
#include <basegfx/vector/b2dvector.hxx>
#include <basegfx/vector/b2enums.hxx>
+#include <basegfx/vector/b2isize.hxx>
#include <basegfx/vector/b2ivector.hxx>
#include <com/sun/star/awt/Key.hpp>
#include <com/sun/star/awt/KeyGroup.hpp>
@@ -190,6 +192,7 @@
#include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
#include <comphelper/comphelperdllapi.h>
#include <comphelper/diagnose_ex.hxx>
+#include <comphelper/errcode.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
#include <cppu/cppudllapi.h>
diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx
index 30b780f1b855..bf6017cdcf6d 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -1353,38 +1353,6 @@ bool SvxContourItem::GetPresentation
return true;
}
-SvxThemeColor::SvxThemeColor()
- : maThemeIndex(-1)
- , mnLumMod(10000)
- , mnLumOff(0)
- , mnTintOrShade(0)
-{
-}
-
-bool SvxThemeColor::operator==(const SvxThemeColor& rThemeColor) const
-{
- return maThemeIndex == rThemeColor.maThemeIndex &&
- mnLumMod == rThemeColor.mnLumMod &&
- mnLumOff == rThemeColor.mnLumOff &&
- mnTintOrShade == rThemeColor.mnTintOrShade;
-}
-
-void SvxThemeColor::dumpAsXml(xmlTextWriterPtr pWriter) const
-{
- (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxThemeColor"));
-
- (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("theme-index"),
- BAD_CAST(OString::number(maThemeIndex).getStr()));
- (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("lum-mod"),
- BAD_CAST(OString::number(mnLumMod).getStr()));
- (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("lum-off"),
- BAD_CAST(OString::number(mnLumOff).getStr()));
- (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("tint-or-shade"),
- BAD_CAST(OString::number(mnTintOrShade).getStr()));
-
- (void)xmlTextWriterEndElement(pWriter);
-}
-
// class SvxColorItem ----------------------------------------------------
SvxColorItem::SvxColorItem( const sal_uInt16 nId ) :
SfxPoolItem(nId),
@@ -1429,22 +1397,42 @@ bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
}
case MID_COLOR_THEME_INDEX:
{
- rVal <<= maThemeColor.GetThemeIndex();
+ rVal <<= sal_Int16(maThemeColor.getType());
break;
}
case MID_COLOR_TINT_OR_SHADE:
{
- rVal <<= maThemeColor.GetTintOrShade();
+ sal_Int16 nValue = 0;
+ for (auto const& rTransform : maThemeColor.getTransformations())
+ {
+ if (rTransform.meType == model::TransformationType::Tint)
+ nValue = rTransform.mnValue;
+ else if (rTransform.meType == model::TransformationType::Shade)
+ nValue = -rTransform.mnValue;
+ }
+ rVal <<= nValue;
break;
}
case MID_COLOR_LUM_MOD:
{
- rVal <<= maThemeColor.GetLumMod();
+ sal_Int16 nValue = 10000;
+ for (auto const& rTransform : maThemeColor.getTransformations())
+ {
+ if (rTransform.meType == model::TransformationType::LumMod)
+ nValue = rTransform.mnValue;
+ }
+ rVal <<= nValue;
break;
}
case MID_COLOR_LUM_OFF:
{
- rVal <<= maThemeColor.GetLumOff();
+ sal_Int16 nValue = 0;
+ for (auto const& rTransform : maThemeColor.getTransformations())
+ {
+ if (rTransform.meType == model::TransformationType::LumOff)
+ nValue = rTransform.mnValue;
+ }
+ rVal <<= nValue;
break;
}
default:
@@ -1482,31 +1470,43 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
sal_Int16 nIndex = -1;
if (!(rVal >>= nIndex))
return false;
- maThemeColor.SetThemeIndex(nIndex);
+ maThemeColor.setType(model::convertToThemeColorType(nIndex));
}
break;
case MID_COLOR_TINT_OR_SHADE:
{
- sal_Int16 nTintShade = -1;
+ sal_Int16 nTintShade = 0;
if (!(rVal >>= nTintShade))
return false;
- maThemeColor.SetTintOrShade(nTintShade);
+
+ maThemeColor.removeTransformations(model::TransformationType::Tint);
+ maThemeColor.removeTransformations(model::TransformationType::Shade);
+
+ if (nTintShade > 0)
+ maThemeColor.addTransformation({model::TransformationType::Tint, nTintShade});
+ else if (nTintShade < 0)
+ {
+ sal_Int16 nShade = o3tl::narrowing<sal_Int16>(-nTintShade);
+ maThemeColor.addTransformation({model::TransformationType::Shade, nShade});
+ }
}
break;
case MID_COLOR_LUM_MOD:
{
- sal_Int16 nLumMod = -1;
+ sal_Int16 nLumMod = 10000;
if (!(rVal >>= nLumMod))
return false;
- maThemeColor.SetLumMod(nLumMod);
+ maThemeColor.removeTransformations(model::TransformationType::LumMod);
+ maThemeColor.addTransformation({model::TransformationType::LumMod, nLumMod});
}
break;
case MID_COLOR_LUM_OFF:
{
- sal_Int16 nLumOff = -1;
+ sal_Int16 nLumOff = 0;
if (!(rVal >>= nLumOff))
return false;
- maThemeColor.SetLumOff(nLumOff);
+ maThemeColor.removeTransformations(model::TransformationType::LumOff);
+ maThemeColor.addTransformation({model::TransformationType::LumOff, nLumOff});
}
break;
default:
@@ -1549,12 +1549,25 @@ void SvxColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
GetPresentation( SfxItemPresentation::Complete, MapUnit::Map100thMM, MapUnit::Map100thMM, aStr, aIntlWrapper);
(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(OUStringToOString(aStr, RTL_TEXTENCODING_UTF8).getStr()));
- maThemeColor.dumpAsXml(pWriter);
+ (void)xmlTextWriterStartElement(pWriter, BAD_CAST("theme-color"));
- (void)xmlTextWriterEndElement(pWriter);
-}
+ (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("theme-index"),
+ BAD_CAST(OString::number(sal_Int16(maThemeColor.getType())).getStr()));
+
+ for (auto const& rTransform : maThemeColor.getTransformations())
+ {
+ (void)xmlTextWriterStartElement(pWriter, BAD_CAST("transformation"));
+ (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"),
+ BAD_CAST(OString::number(sal_Int16(rTransform.meType)).getStr()));
+ (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
+ BAD_CAST(OString::number(rTransform.mnValue).getStr()));
+ (void)xmlTextWriterEndElement(pWriter);
+ }
+ (void)xmlTextWriterEndElement(pWriter);
+ (void)xmlTextWriterEndElement(pWriter);
+}
void SvxColorItem::SetValue( const Color& rNewCol )
{
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index 8d6b2aa9ec53..e5877a7d2e5a 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -1142,23 +1142,39 @@ bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const Sf
switch (pMap->nMemberId)
{
case MID_COLOR_THEME_INDEX:
- if (pColor->GetThemeColor().GetThemeIndex() == -1)
+ if (pColor->GetThemeColor().getType() == model::ThemeColorType::Unknown)
{
eItemState = SfxItemState::DEFAULT;
}
break;
case MID_COLOR_LUM_MOD:
- if (pColor->GetThemeColor().GetLumMod() == 10000)
+ {
+ sal_Int16 nLumMod = 10000;
+ for (auto const& rTransform : pColor->GetThemeColor().getTransformations())
+ {
+ if (rTransform.meType == model::TransformationType::LumMod)
+ nLumMod = rTransform.mnValue;
+ }
+ if (nLumMod == 10000)
{
eItemState = SfxItemState::DEFAULT;
}
break;
+ }
case MID_COLOR_LUM_OFF:
- if (pColor->GetThemeColor().GetLumOff() == 0)
+ {
+ sal_Int16 nLumOff = 0;
+ for (auto const& rTransform : pColor->GetThemeColor().getTransformations())
+ {
+ if (rTransform.meType == model::TransformationType::LumOff)
+ nLumOff = rTransform.mnValue;
+ }
+ if (nLumOff == 0)
{
eItemState = SfxItemState::DEFAULT;
}
break;
+ }
}
}