cui/source/inc/cuitabarea.hxx | 4 - cui/source/tabpages/tpcolor.cxx | 91 +++++++++++++++--------------- include/docmodel/color/ComplexColor.hxx | 30 +++++++++ include/docmodel/color/Transformation.hxx | 20 ++++++ include/svx/Palette.hxx | 31 ++++++++-- sd/source/ui/unoidl/unomodel.cxx | 13 ++-- 6 files changed, 134 insertions(+), 55 deletions(-)
New commits: commit 6ee03e6dc269c712dc6ed2c3af38ffda6240d0e6 Author: Luigi Iucci <luigi.iu...@collabora.com> AuthorDate: Fri May 26 11:49:59 2023 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jun 5 11:28:22 2023 +0200 sd: fix crash deleting 2 slides during paintTile pPageView was null in SdXImpressDocument::paintTile while trying to paint form controls, which is a corner case in most cases then we skip painting in order to avoid a crash Change-Id: I6c166035220c058fac276f2b7746a8ebc9651f81 (cherry picked from commit 16dbf903a809a6c5b2099c91adca88666228f2cc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152399 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index d52974081ee1..f2bceac96fd4 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2300,11 +2300,14 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice, // Draw Form controls SdrView* pDrawView = pViewSh->GetDrawView(); SdrPageView* pPageView = pDrawView->GetSdrPageView(); - SdrPage* pPage = pPageView->GetPage(); - ::sd::Window* pActiveWin = pViewSh->GetActiveWindow(); - ::tools::Rectangle aTileRect(Point(nTilePosX, nTilePosY), Size(nTileWidth, nTileHeight)); - Size aOutputSize(nOutputWidth, nOutputHeight); - LokControlHandler::paintControlTile(pPage, pDrawView, *pActiveWin, rDevice, aOutputSize, aTileRect); + if (pPageView != nullptr) + { + SdrPage* pPage = pPageView->GetPage(); + ::sd::Window* pActiveWin = pViewSh->GetActiveWindow(); + ::tools::Rectangle aTileRect(Point(nTilePosX, nTilePosY), Size(nTileWidth, nTileHeight)); + Size aOutputSize(nOutputWidth, nOutputHeight); + LokControlHandler::paintControlTile(pPage, pDrawView, *pActiveWin, rDevice, aOutputSize, aTileRect); + } comphelper::LibreOfficeKit::setTiledPainting(false); } commit 3daad27698f3e91f6e35ba44cd193fc892c12ec9 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon May 29 19:03:33 2023 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Jun 5 11:28:16 2023 +0200 prefix aPreviousColor and aCurrentColor in SvxColorTabPage Change-Id: I631ce120d7a2825c6d170f4b25ffefdd155e04e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152396 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit d7d2b172065f90aa2f61c0216f3722e868ae76a1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152518 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index bc2d968f2443..6ed45b7a85c7 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -657,8 +657,8 @@ private: ColorModel eCM; - Color aPreviousColor; - NamedColor aCurrentColor; + Color m_aPreviousColor; + NamedColor m_aCurrentColor; PaletteManager maPaletteManager; SvxXRectPreview m_aCtlPreviewOld; diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index cf09baf45c06..36794ec929b4 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -239,25 +239,25 @@ bool SvxColorTabPage::FillItemSet( SfxItemSet* rSet ) { Color aColor = m_xValSetColorList->GetItemColor( m_xValSetColorList->GetSelectedItemId() ); OUString sColorName; - if ( aCurrentColor.m_aColor == aColor ) + if (m_aCurrentColor.m_aColor == aColor) sColorName = m_xValSetColorList->GetItemText( m_xValSetColorList->GetSelectedItemId() ); else - sColorName = "#" + aCurrentColor.m_aColor.AsRGBHexString().toAsciiUpperCase(); - maPaletteManager.AddRecentColor( aCurrentColor.m_aColor, sColorName ); - XFillColorItem aColorItem( sColorName, aCurrentColor.m_aColor ); - model::ThemeColorType eType = model::convertToThemeColorType(aCurrentColor.m_nThemeIndex); + sColorName = "#" + m_aCurrentColor.m_aColor.AsRGBHexString().toAsciiUpperCase(); + maPaletteManager.AddRecentColor( m_aCurrentColor.m_aColor, sColorName ); + XFillColorItem aColorItem( sColorName, m_aCurrentColor.m_aColor ); + model::ThemeColorType eType = model::convertToThemeColorType(m_aCurrentColor.m_nThemeIndex); if (eType != model::ThemeColorType::Unknown) { aColorItem.getComplexColor().setSchemeColor(eType); } aColorItem.getComplexColor().clearTransformations(); - if (aCurrentColor.m_nLumMod != 10000) + if (m_aCurrentColor.m_nLumMod != 10000) { - aColorItem.getComplexColor().addTransformation({model::TransformationType::LumMod, aCurrentColor.m_nLumMod}); + aColorItem.getComplexColor().addTransformation({model::TransformationType::LumMod, m_aCurrentColor.m_nLumMod}); } - if (aCurrentColor.m_nLumOff != 0) + if (m_aCurrentColor.m_nLumOff != 0) { - aColorItem.getComplexColor().addTransformation({model::TransformationType::LumOff, aCurrentColor.m_nLumOff}); + aColorItem.getComplexColor().addTransformation({model::TransformationType::LumOff, m_aCurrentColor.m_nLumOff}); } rSet->Put( aColorItem ); rSet->Put( XFillStyleItem( drawing::FillStyle_SOLID ) ); @@ -279,7 +279,7 @@ void SvxColorTabPage::Reset( const SfxItemSet* rSet ) if ( nState >= SfxItemState::DEFAULT ) { XFillColorItem aColorItem( rSet->Get( XATTR_FILLCOLOR ) ); - aPreviousColor = aColorItem.GetColorValue(); + m_aPreviousColor = aColorItem.GetColorValue(); aNewColor = aColorItem.GetColorValue(); } @@ -305,12 +305,12 @@ std::unique_ptr<SfxTabPage> SvxColorTabPage::Create(weld::Container* pPage, weld IMPL_LINK_NOARG(SvxColorTabPage, SpinValueHdl_Impl, weld::SpinButton&, void) { // read current MtrFields, if cmyk, then k-value as transparency - aCurrentColor.m_aColor = Color(static_cast<sal_uInt8>(PercentToColor_Impl(m_xRcustom->get_value())), + m_aCurrentColor.m_aColor = Color(static_cast<sal_uInt8>(PercentToColor_Impl(m_xRcustom->get_value())), static_cast<sal_uInt8>(PercentToColor_Impl(m_xGcustom->get_value())), static_cast<sal_uInt8>(PercentToColor_Impl(m_xBcustom->get_value()))); UpdateColorValues(); - rXFSet.Put( XFillColorItem( OUString(), aCurrentColor.m_aColor ) ); + rXFSet.Put( XFillColorItem( OUString(), m_aCurrentColor.m_aColor ) ); m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); m_aCtlPreviewNew.Invalidate(); @@ -319,13 +319,13 @@ IMPL_LINK_NOARG(SvxColorTabPage, SpinValueHdl_Impl, weld::SpinButton&, void) IMPL_LINK_NOARG(SvxColorTabPage, MetricSpinValueHdl_Impl, weld::MetricSpinButton&, void) { // read current MtrFields, if cmyk, then k-value as transparency - aCurrentColor.m_aColor = Color(ColorTransparency, static_cast<sal_uInt8>(PercentToColor_Impl(m_xKcustom->get_value(FieldUnit::NONE))), + m_aCurrentColor.m_aColor = Color(ColorTransparency, static_cast<sal_uInt8>(PercentToColor_Impl(m_xKcustom->get_value(FieldUnit::NONE))), static_cast<sal_uInt8>(PercentToColor_Impl(m_xCcustom->get_value(FieldUnit::NONE))), static_cast<sal_uInt8>(PercentToColor_Impl(m_xYcustom->get_value(FieldUnit::NONE))), static_cast<sal_uInt8>(PercentToColor_Impl(m_xMcustom->get_value(FieldUnit::NONE)))); - ConvertColorValues (aCurrentColor.m_aColor, ColorModel::RGB); + ConvertColorValues (m_aCurrentColor.m_aColor, ColorModel::RGB); - rXFSet.Put( XFillColorItem( OUString(), aCurrentColor.m_aColor ) ); + rXFSet.Put( XFillColorItem( OUString(), m_aCurrentColor.m_aColor ) ); m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); m_aCtlPreviewNew.Invalidate(); @@ -333,10 +333,10 @@ IMPL_LINK_NOARG(SvxColorTabPage, MetricSpinValueHdl_Impl, weld::MetricSpinButton IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl, weld::Entry&, void) { - aCurrentColor.m_aColor = m_xHexcustom->GetColor(); + m_aCurrentColor.m_aColor = m_xHexcustom->GetColor(); UpdateColorValues(); - rXFSet.Put( XFillColorItem( OUString(), aCurrentColor.m_aColor ) ); + rXFSet.Put( XFillColorItem( OUString(), m_aCurrentColor.m_aColor ) ); m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); m_aCtlPreviewNew.Invalidate(); @@ -390,13 +390,13 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, weld::Button&, void) sal_Int32 nSize = aCustomColorList.getLength(); aCustomColorList.realloc( nSize + 1 ); aCustomColorNameList.realloc( nSize + 1 ); - aCustomColorList.getArray()[nSize] = sal_Int32(aCurrentColor.m_aColor); + aCustomColorList.getArray()[nSize] = sal_Int32(m_aCurrentColor.m_aColor); aCustomColorNameList.getArray()[nSize] = aName; officecfg::Office::Common::UserColors::CustomColor::set(aCustomColorList, batch); officecfg::Office::Common::UserColors::CustomColorName::set(aCustomColorNameList, batch); batch->commit(); sal_uInt16 nId = m_xValSetColorList->GetItemId(nSize - 1); - m_xValSetColorList->InsertItem( nId + 1 , aCurrentColor.m_aColor, aName ); + m_xValSetColorList->InsertItem( nId + 1 , m_aCurrentColor.m_aColor, aName ); m_xValSetColorList->SelectItem( nId + 1 ); m_xBtnDelete->set_sensitive(false); m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR2) ); @@ -410,13 +410,13 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl, weld::Button&, void) { SvColorDialog aColorDlg; - aColorDlg.SetColor (aCurrentColor.m_aColor); + aColorDlg.SetColor (m_aCurrentColor.m_aColor); aColorDlg.SetMode( svtools::ColorPickerMode::Modify ); if (aColorDlg.Execute(GetFrameWeld()) == RET_OK) { Color aPreviewColor = aColorDlg.GetColor(); - aCurrentColor.m_aColor = aPreviewColor; + m_aCurrentColor.m_aColor = aPreviewColor; UpdateColorValues( false ); // fill ItemSet and pass it on to XOut rXFSet.Put( XFillColorItem( OUString(), aPreviewColor ) ); @@ -597,11 +597,14 @@ IMPL_STATIC_LINK_NOARG(SvxColorTabPage, OnMoreColorsClick, weld::Button&, void) void SvxColorTabPage::ChangeColor(const NamedColor &rNewColor, bool bUpdatePreset ) { - aPreviousColor = rNewColor.m_aColor; - aCurrentColor = rNewColor; + m_aPreviousColor = rNewColor.m_aColor; + m_aCurrentColor = rNewColor; UpdateColorValues( bUpdatePreset ); // fill ItemSet and pass it on to XOut - rXFSet.Put( XFillColorItem( OUString(), aCurrentColor.m_aColor ) ); + XFillColorItem aItem(OUString(), m_aCurrentColor.m_aColor); + aItem.setComplexColor(m_aCurrentColor.getComplexColor()); + rXFSet.Put(aItem); + m_aCtlPreviewNew.SetAttributes(aXFillAttr.GetItemSet()); m_aCtlPreviewNew.Invalidate(); } @@ -642,42 +645,42 @@ void SvxColorTabPage::UpdateColorValues( bool bUpdatePreset ) { if (eCM != ColorModel::RGB) { - ConvertColorValues (aPreviousColor, eCM ); - ConvertColorValues (aCurrentColor.m_aColor, eCM); + ConvertColorValues (m_aPreviousColor, eCM ); + ConvertColorValues (m_aCurrentColor.m_aColor, eCM); - m_xCcustom->set_value( ColorToPercent_Impl( aCurrentColor.m_aColor.GetRed() ), FieldUnit::PERCENT ); - m_xMcustom->set_value( ColorToPercent_Impl( aCurrentColor.m_aColor.GetBlue() ), FieldUnit::PERCENT ); - m_xYcustom->set_value( ColorToPercent_Impl( aCurrentColor.m_aColor.GetGreen() ), FieldUnit::PERCENT ); - m_xKcustom->set_value( ColorToPercent_Impl( 255 - aCurrentColor.m_aColor.GetAlpha() ), FieldUnit::PERCENT ); + m_xCcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetRed() ), FieldUnit::PERCENT ); + m_xMcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetBlue() ), FieldUnit::PERCENT ); + m_xYcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetGreen() ), FieldUnit::PERCENT ); + m_xKcustom->set_value( ColorToPercent_Impl( 255 - m_aCurrentColor.m_aColor.GetAlpha() ), FieldUnit::PERCENT ); if( bUpdatePreset ) { - m_xCpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetRed()), + m_xCpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(m_aPreviousColor.GetRed()), Application::GetSettings().GetUILanguageTag())); - m_xMpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetBlue()), + m_xMpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(m_aPreviousColor.GetBlue()), Application::GetSettings().GetUILanguageTag())); - m_xYpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetGreen()), + m_xYpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(m_aPreviousColor.GetGreen()), Application::GetSettings().GetUILanguageTag())); - m_xKpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(255 - aPreviousColor.GetAlpha()), + m_xKpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(255 - m_aPreviousColor.GetAlpha()), Application::GetSettings().GetUILanguageTag())); } - ConvertColorValues (aPreviousColor, ColorModel::RGB); - ConvertColorValues (aCurrentColor.m_aColor, ColorModel::RGB); + ConvertColorValues (m_aPreviousColor, ColorModel::RGB); + ConvertColorValues (m_aCurrentColor.m_aColor, ColorModel::RGB); } else { - m_xRcustom->set_value( ColorToPercent_Impl( aCurrentColor.m_aColor.GetRed() ) ); - m_xGcustom->set_value( ColorToPercent_Impl( aCurrentColor.m_aColor.GetGreen() ) ); - m_xBcustom->set_value( ColorToPercent_Impl( aCurrentColor.m_aColor.GetBlue() ) ); - m_xHexcustom->SetColor( aCurrentColor.m_aColor ); + m_xRcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetRed() ) ); + m_xGcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetGreen() ) ); + m_xBcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetBlue() ) ); + m_xHexcustom->SetColor( m_aCurrentColor.m_aColor ); if( bUpdatePreset ) { - m_xRpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetRed()))); - m_xGpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetGreen()))); - m_xBpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetBlue()))); - m_xHexpreset->SetColor( aPreviousColor ); + m_xRpreset->set_text(OUString::number(ColorToPercent_Impl(m_aPreviousColor.GetRed()))); + m_xGpreset->set_text(OUString::number(ColorToPercent_Impl(m_aPreviousColor.GetGreen()))); + m_xBpreset->set_text(OUString::number(ColorToPercent_Impl(m_aPreviousColor.GetBlue()))); + m_xHexpreset->SetColor( m_aPreviousColor ); } } } diff --git a/include/svx/Palette.hxx b/include/svx/Palette.hxx index ebdcb63a1377..4858b47140c4 100644 --- a/include/svx/Palette.hxx +++ b/include/svx/Palette.hxx @@ -16,8 +16,8 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_SVX_PALETTE_HXX -#define INCLUDED_SVX_PALETTE_HXX + +#pragma once #include <sal/config.h> @@ -27,6 +27,9 @@ #include <tools/color.hxx> #include <svx/svxdllapi.h> +#include <docmodel/color/ComplexColor.hxx> +#include <docmodel/theme/ThemeColorType.hxx> + class SvxColorValueSet; struct SVXCORE_DLLPUBLIC NamedColor @@ -43,6 +46,28 @@ struct SVXCORE_DLLPUBLIC NamedColor : m_aColor(rColor) , m_aName(rName) {} + + model::ComplexColor getComplexColor() + { + model::ComplexColor aComplexColor; + + auto eThemeColorType = model::convertToThemeColorType(m_nThemeIndex); + + if (eThemeColorType != model::ThemeColorType::Unknown) + { + aComplexColor.setSchemeColor(eThemeColorType); + + if (m_nLumMod != 10000) + aComplexColor.addTransformation({model::TransformationType::LumMod, m_nLumMod}); + + if (m_nLumMod != 0) + aComplexColor.addTransformation({model::TransformationType::LumOff, m_nLumOff}); + } + + aComplexColor.setFinalColor(m_aColor); + + return aComplexColor; + } }; typedef std::function<void(const OUString&, const NamedColor&)> ColorSelectFunction; @@ -64,6 +89,4 @@ public: virtual Palette* Clone() const = 0; }; -#endif // INCLUDED_SVX_PALETTE_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit d3cbe4c4792e94dfdef9ee54decce48cb3fa2843 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu May 18 14:48:30 2023 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Jun 5 11:28:08 2023 +0200 docmodel: add hash to ComplexColor and Transformation classes Change-Id: I206235162b057f184fbd413982c06f9bd9fa8a94 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152013 Tested-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit a3d566165c0580ab41334cb3e031465df1f839ad) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152596 diff --git a/include/docmodel/color/ComplexColor.hxx b/include/docmodel/color/ComplexColor.hxx index 1cac6816bfa5..958f82f19b4e 100644 --- a/include/docmodel/color/ComplexColor.hxx +++ b/include/docmodel/color/ComplexColor.hxx @@ -14,6 +14,7 @@ #include <tools/color.hxx> #include <docmodel/theme/ThemeColor.hxx> #include <com/sun/star/graphic/XGraphic.hpp> +#include <o3tl/hash_combine.hxx> namespace model { @@ -89,6 +90,8 @@ public: ThemeColorType meSchemeType = ThemeColorType::Unknown; std::vector<Transformation> maTransformations; + ::Color maFinalColor; + public: ColorType getType() const { return meType; } @@ -212,8 +215,35 @@ public: } return aColor; } + + void setFinalColor(Color const& rColor) { maFinalColor = rColor; } + + Color const& getFinalColor() const { return maFinalColor; } + + std::size_t getHash() const + { + std::size_t seed = 0; + o3tl::hash_combine(seed, meType); + o3tl::hash_combine(seed, mnComponent1); + o3tl::hash_combine(seed, mnComponent2); + o3tl::hash_combine(seed, mnComponent3); + o3tl::hash_combine(seed, meSystemColorType); + o3tl::hash_combine(seed, sal_uInt32(maLastColor)); + for (auto const& rTransform : maTransformations) + o3tl::hash_combine(seed, rTransform); + o3tl::hash_combine(seed, sal_uInt32(maFinalColor)); + return seed; + } }; } // end of namespace svx +namespace std +{ +template <> struct hash<model::ComplexColor> +{ + std::size_t operator()(model::ComplexColor const& rColor) const { return rColor.getHash(); } +}; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/docmodel/color/Transformation.hxx b/include/docmodel/color/Transformation.hxx index 26f618dee289..7a05d88aa9e9 100644 --- a/include/docmodel/color/Transformation.hxx +++ b/include/docmodel/color/Transformation.hxx @@ -12,6 +12,7 @@ #include <docmodel/dllapi.h> #include <vector> +#include <o3tl/hash_combine.hxx> namespace model { @@ -65,8 +66,27 @@ struct DOCMODEL_DLLPUBLIC Transformation { return meType == rTransformation.meType && mnValue == rTransformation.mnValue; } + + std::size_t getHash() const + { + std::size_t seed = 0; + o3tl::hash_combine(seed, meType); + o3tl::hash_combine(seed, mnValue); + return seed; + } }; } // end of namespace model +namespace std +{ +template <> struct hash<model::Transformation> +{ + std::size_t operator()(model::Transformation const& rTransformation) const + { + return rTransformation.getHash(); + } +}; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */