diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2022-12-28 09:43:46 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-01-16 08:03:14 +0000 |
commit | 5be810bca2e5701d8451b4bf4e9e88e3f7b3a56d (patch) | |
tree | 8e646f4c7a7023e00a3570ef57c93f27ec315ac7 /svx | |
parent | 7169596baf030d89d95db63bd78d55dc8072d22b (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>
(cherry picked from commit bd0f526f2d3e1ffe43a74672485815768eee6e9e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145528
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/CppunitTest_svx_removewhichrange.mk | 1 | ||||
-rw-r--r-- | svx/CppunitTest_svx_styles.mk | 1 | ||||
-rw-r--r-- | svx/CppunitTest_svx_unit.mk | 1 | ||||
-rw-r--r-- | svx/Library_svxcore.mk | 1 | ||||
-rw-r--r-- | svx/inc/pch/precompiled_svx.hxx | 29 | ||||
-rw-r--r-- | svx/source/styles/ColorSets.cxx | 14 | ||||
-rw-r--r-- | svx/source/table/cell.cxx | 19 | ||||
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 18 | ||||
-rw-r--r-- | svx/source/xoutdev/xattr.cxx | 47 |
9 files changed, 100 insertions, 31 deletions
diff --git a/svx/CppunitTest_svx_removewhichrange.mk b/svx/CppunitTest_svx_removewhichrange.mk index 95f958a39e5f..c5037e9988d3 100644 --- a/svx/CppunitTest_svx_removewhichrange.mk +++ b/svx/CppunitTest_svx_removewhichrange.mk @@ -23,6 +23,7 @@ $(eval $(call gb_CppunitTest_use_libraries,svx_removewhichrange, \ comphelper \ cppu \ cppuhelper \ + docmodel \ drawinglayer \ editeng \ fwk \ diff --git a/svx/CppunitTest_svx_styles.mk b/svx/CppunitTest_svx_styles.mk index f617668ad705..2235826be06e 100644 --- a/svx/CppunitTest_svx_styles.mk +++ b/svx/CppunitTest_svx_styles.mk @@ -22,6 +22,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,svx_styles, \ $(eval $(call gb_CppunitTest_use_libraries,svx_styles, \ comphelper \ cppu \ + docmodel \ svx \ sal \ test \ diff --git a/svx/CppunitTest_svx_unit.mk b/svx/CppunitTest_svx_unit.mk index 5595d70ea8e9..1fdb36ec927e 100644 --- a/svx/CppunitTest_svx_unit.mk +++ b/svx/CppunitTest_svx_unit.mk @@ -38,6 +38,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,svx_unit, \ $(eval $(call gb_CppunitTest_use_libraries,svx_unit, \ basegfx \ + docmodel \ drawinglayer \ editeng \ sal \ diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index 0c3adee945c3..619ac13decbc 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -57,6 +57,7 @@ $(eval $(call gb_Library_use_libraries,svxcore,\ cppu \ $(call gb_Helper_optional,DBCONNECTIVITY, \ dbtools) \ + docmodel \ drawinglayer \ editeng \ fwk \ diff --git a/svx/inc/pch/precompiled_svx.hxx b/svx/inc/pch/precompiled_svx.hxx index 905ebede5f2b..6e94126ed03b 100644 --- a/svx/inc/pch/precompiled_svx.hxx +++ b/svx/inc/pch/precompiled_svx.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 2021-04-11 19:48:23 using: + Generated on 2023-01-16 00:10:07 using: ./bin/update_pch svx svx --cutoff=3 --exclude:system --exclude:module --include:local If after updating build fails, use the following command to locate conflicting headers: @@ -28,11 +28,15 @@ #include <climits> #include <cstddef> #include <cstdlib> +#include <deque> #include <functional> #include <iomanip> +#include <iterator> #include <limits.h> #include <map> #include <memory> +#include <mutex> +#include <numeric> #include <optional> #include <ostream> #include <set> @@ -48,10 +52,8 @@ #endif // PCH_LEVEL >= 1 #if PCH_LEVEL >= 2 #include <osl/diagnose.h> -#include <osl/doublecheckedlocking.h> #include <osl/endian.h> #include <osl/file.hxx> -#include <osl/getglobalmutex.hxx> #include <osl/interlck.h> #include <osl/mutex.hxx> #include <osl/thread.h> @@ -61,6 +63,7 @@ #include <rtl/instance.hxx> #include <rtl/math.hxx> #include <rtl/ref.hxx> +#include <rtl/strbuf.hxx> #include <rtl/string.hxx> #include <rtl/tencinfo.h> #include <rtl/textenc.h> @@ -79,6 +82,7 @@ #include <vcl/Scanline.hxx> #include <vcl/alpha.hxx> #include <vcl/bitmapex.hxx> +#include <vcl/canvastools.hxx> #include <vcl/commandevent.hxx> #include <vcl/commandinfoprovider.hxx> #include <vcl/customweld.hxx> @@ -114,16 +118,13 @@ #if PCH_LEVEL >= 3 #include <basegfx/basegfxdllapi.h> #include <basegfx/color/bcolor.hxx> -#include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/matrix/b3dhommatrix.hxx> #include <basegfx/point/b2dpoint.hxx> #include <basegfx/point/b2ipoint.hxx> #include <basegfx/point/b3dpoint.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> -#include <basegfx/range/b2irectangle.hxx> #include <basegfx/tuple/b2dtuple.hxx> -#include <basegfx/vector/b2enums.hxx> #include <basegfx/vector/b3dvector.hxx> #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/accessibility/AccessibleRelationType.hpp> @@ -216,10 +217,12 @@ #include <comphelper/broadcasthelper.hxx> #include <comphelper/comphelperdllapi.h> #include <comphelper/lok.hxx> +#include <comphelper/multicontainer2.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/proparrhlp.hxx> #include <comphelper/propertycontainer.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> #include <comphelper/servicehelper.hxx> #include <comphelper/string.hxx> @@ -234,16 +237,17 @@ #include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase1.hxx> #include <cppuhelper/interfacecontainer.h> -#include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/propshlp.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/weak.hxx> #include <cppuhelper/weakagg.hxx> #include <cppuhelper/weakref.hxx> +#include <docmodel/theme/ThemeColor.hxx> #include <drawinglayer/drawinglayerdllapi.h> -#include <drawinglayer/geometry/viewinformation2d.hxx> #include <drawinglayer/primitive2d/Primitive2DContainer.hxx> +#include <drawinglayer/processor2d/baseprocessor2d.hxx> +#include <drawinglayer/processor2d/processor2dtools.hxx> #include <editeng/borderline.hxx> #include <editeng/brushitem.hxx> #include <editeng/colritem.hxx> @@ -262,6 +266,7 @@ #include <editeng/numitem.hxx> #include <editeng/outliner.hxx> #include <editeng/outlobj.hxx> +#include <editeng/overflowingtxt.hxx> #include <editeng/paragraphdata.hxx> #include <editeng/postitem.hxx> #include <editeng/sizeitem.hxx> @@ -293,6 +298,7 @@ #include <sfx2/dispatch.hxx> #include <sfx2/dllapi.h> #include <sfx2/dockwin.hxx> +#include <sfx2/filedlghelper.hxx> #include <sfx2/module.hxx> #include <sfx2/objsh.hxx> #include <sfx2/request.hxx> @@ -309,6 +315,8 @@ #include <sot/sotdllapi.h> #include <svl/SfxBroadcaster.hxx> #include <svl/cenumitm.hxx> +#include <svl/cjkoptions.hxx> +#include <svl/ctloptions.hxx> #include <svl/eitem.hxx> #include <svl/hint.hxx> #include <svl/intitem.hxx> @@ -327,6 +335,7 @@ #include <svl/svldllapi.h> #include <svl/typedwhich.hxx> #include <svl/undo.hxx> +#include <svl/whiter.hxx> #include <svl/zforlist.hxx> #include <svtools/colorcfg.hxx> #include <svtools/ehdl.hxx> @@ -367,8 +376,8 @@ #include <unotools/accessiblestatesethelper.hxx> #include <unotools/fontcvt.hxx> #include <unotools/localedatawrapper.hxx> -#include <unotools/options.hxx> #include <unotools/pathoptions.hxx> +#include <unotools/resmgr.hxx> #include <unotools/syslocale.hxx> #include <unotools/unotoolsdllapi.h> #include <unotools/viewoptions.hxx> @@ -433,6 +442,7 @@ #include <svx/svdpagv.hxx> #include <svx/svdtext.hxx> #include <svx/svdtrans.hxx> +#include <svx/svdtypes.hxx> #include <svx/svdview.hxx> #include <svx/svx3ditems.hxx> #include <svx/svxdlg.hxx> @@ -455,6 +465,7 @@ #include <svx/xlnclit.hxx> #include <svx/xlntrit.hxx> #include <svx/xlnwtit.hxx> +#include <svx/xpoly.hxx> #include <svx/xtable.hxx> #include <uiobject.hxx> #endif // PCH_LEVEL >= 4 diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx index 206f4deda6b0..7e258f7d4b4c 100644 --- a/svx/source/styles/ColorSets.cxx +++ b/svx/source/styles/ColorSets.cxx @@ -41,9 +41,9 @@ void UpdateTextPortionColorSet(const uno::Reference<beans::XPropertySet>& xPorti { sal_Int16 nCharColorTheme = -1; xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_THEME) >>= nCharColorTheme; - svx::ThemeColorType eColorThemeType = svx::convertToThemeColorType(nCharColorTheme); + model::ThemeColorType eColorThemeType = model::convertToThemeColorType(nCharColorTheme); - if (eColorThemeType == svx::ThemeColorType::Unknown) + if (eColorThemeType == model::ThemeColorType::Unknown) return; Color aColor = rColorSet.getColor(eColorThemeType); @@ -76,8 +76,8 @@ void UpdateFillColorSet(const uno::Reference<beans::XPropertySet>& xShape, svx:: sal_Int16 nFillColorTheme = -1; xShape->getPropertyValue(UNO_NAME_FILLCOLOR_THEME) >>= nFillColorTheme; - svx::ThemeColorType eColorThemeType = svx::convertToThemeColorType(nFillColorTheme); - if (eColorThemeType == svx::ThemeColorType::Unknown) + model::ThemeColorType eColorThemeType = model::convertToThemeColorType(nFillColorTheme); + if (eColorThemeType == model::ThemeColorType::Unknown) return; Color aColor = rColorSet.getColor(eColorThemeType); @@ -283,7 +283,7 @@ void Theme::ToAny(css::uno::Any& rVal) const if (mpColorSet) { std::vector<util::Color> aColorScheme; - for (auto eThemeColorType : o3tl::enumrange<svx::ThemeColorType>()) + for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>()) { Color aColor = mpColorSet->getColor(eThemeColorType); aColorScheme.push_back(sal_Int32(aColor)); @@ -364,14 +364,14 @@ std::vector<Color> Theme::GetColors() const return {}; std::vector<Color> aColors; - for (auto eThemeColorType : o3tl::enumrange<svx::ThemeColorType>()) + for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>()) { aColors.push_back(mpColorSet->getColor(eThemeColorType)); } return aColors; } -Color Theme::GetColor(ThemeColorType eType) const +Color Theme::GetColor(model::ThemeColorType eType) const { if (!mpColorSet) return {}; diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index a156174f56d6..99f53a7c127f 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -1444,10 +1444,11 @@ PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName ) } break; case XATTR_FILLCOLOR: + if (pMap->nMemberId == MID_COLOR_THEME_INDEX) { const XFillColorItem* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID); - if (pColor->GetThemeColor().GetThemeIndex() == -1) + if (pColor->GetThemeColor().getType() == model::ThemeColorType::Unknown) { eState = PropertyState_DEFAULT_VALUE; } @@ -1455,7 +1456,13 @@ PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName ) else if (pMap->nMemberId == MID_COLOR_LUM_MOD) { const XFillColorItem* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID); - 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) { eState = PropertyState_DEFAULT_VALUE; } @@ -1463,7 +1470,13 @@ PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName ) else if (pMap->nMemberId == MID_COLOR_LUM_OFF) { const XFillColorItem* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID); - 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) { eState = PropertyState_DEFAULT_VALUE; } diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 4d7e00b42cdc..128785341c6d 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -2044,7 +2044,7 @@ beans::PropertyState SvxShape::_getPropertyState( const OUString& PropertyName ) if (pMap->nMemberId == MID_COLOR_THEME_INDEX) { const XFillColorItem* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID); - if (pColor->GetThemeColor().GetThemeIndex() == -1) + if (pColor->GetThemeColor().getType() == model::ThemeColorType::Unknown) { eState = beans::PropertyState_DEFAULT_VALUE; } @@ -2052,7 +2052,13 @@ beans::PropertyState SvxShape::_getPropertyState( const OUString& PropertyName ) else if (pMap->nMemberId == MID_COLOR_LUM_MOD) { const XFillColorItem* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID); - 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) { eState = beans::PropertyState_DEFAULT_VALUE; } @@ -2060,7 +2066,13 @@ beans::PropertyState SvxShape::_getPropertyState( const OUString& PropertyName ) else if (pMap->nMemberId == MID_COLOR_LUM_OFF) { const XFillColorItem* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID); - 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) { eState = beans::PropertyState_DEFAULT_VALUE; } diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index 9b4227ae458d..ebecbbbd41ef 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -334,7 +334,22 @@ void XColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const NameOrIndex::dumpAsXml(pWriter); - maThemeColor.dumpAsXml(pWriter); + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("theme-color")); + + (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); } @@ -1907,17 +1922,29 @@ bool XFillColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId ) cons { case MID_COLOR_THEME_INDEX: { - rVal <<= GetThemeColor().GetThemeIndex(); + rVal <<= sal_Int16(GetThemeColor().getType()); break; } case MID_COLOR_LUM_MOD: { - rVal <<= GetThemeColor().GetLumMod(); + sal_Int16 nValue = 10000; + for (auto const& rTransform : GetThemeColor().getTransformations()) + { + if (rTransform.meType == model::TransformationType::LumMod) + nValue = rTransform.mnValue; + } + rVal <<= nValue; break; } case MID_COLOR_LUM_OFF: { - rVal <<= GetThemeColor().GetLumOff(); + sal_Int16 nValue = 0; + for (auto const& rTransform : GetThemeColor().getTransformations()) + { + if (rTransform.meType == model::TransformationType::LumOff) + nValue = rTransform.mnValue; + } + rVal <<= nValue; break; } default: @@ -1940,23 +1967,25 @@ bool XFillColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) sal_Int16 nIndex = -1; if (!(rVal >>= nIndex)) return false; - GetThemeColor().SetThemeIndex(nIndex); + GetThemeColor().setType(model::convertToThemeColorType(nIndex)); break; } case MID_COLOR_LUM_MOD: { - sal_Int16 nLumMod = -1; + sal_Int16 nLumMod = 10000; if (!(rVal >>= nLumMod)) return false; - GetThemeColor().SetLumMod(nLumMod); + GetThemeColor().removeTransformations(model::TransformationType::LumMod); + GetThemeColor().addTransformation({model::TransformationType::LumMod, nLumMod}); } break; case MID_COLOR_LUM_OFF: { - sal_Int16 nLumOff = -1; + sal_Int16 nLumOff = 0; if (!(rVal >>= nLumOff)) return false; - GetThemeColor().SetLumOff(nLumOff); + GetThemeColor().removeTransformations(model::TransformationType::LumOff); + GetThemeColor().addTransformation({model::TransformationType::LumOff, nLumOff}); } break; default: |