diff options
-rw-r--r-- | cui/source/tabpages/backgrnd.cxx | 8 | ||||
-rw-r--r-- | editeng/source/items/frmitems.cxx | 36 | ||||
-rw-r--r-- | editeng/source/items/textitem.cxx | 5 | ||||
-rw-r--r-- | include/editeng/brushitem.hxx | 22 | ||||
-rw-r--r-- | include/editeng/colritem.hxx | 14 | ||||
-rw-r--r-- | include/editeng/memberids.h | 1 | ||||
-rw-r--r-- | sc/Library_sc.mk | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/ThemeColorChanger.hxx | 31 | ||||
-rw-r--r-- | sc/source/ui/theme/ThemeColorChanger.cxx | 97 | ||||
-rw-r--r-- | sc/source/ui/view/formatsh.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh3.cxx | 6 |
11 files changed, 204 insertions, 21 deletions
diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx index 14269ad3c6c8..5706f98c310a 100644 --- a/cui/source/tabpages/backgrnd.cxx +++ b/cui/source/tabpages/backgrnd.cxx @@ -166,13 +166,13 @@ bool SvxBkgTabPage::FillItemSet( SfxItemSet* rCoreSet ) XFillColorItem aColorItem( maSet.Get( XATTR_FILLCOLOR ) ); if ( SID_ATTR_CHAR_BACK_COLOR == nSlot ) { - maSet.Put( SvxColorItem( aColorItem.GetColorValue(), nWhich ) ); - rCoreSet->Put( SvxColorItem( aColorItem.GetColorValue(), nWhich ) ); + maSet.Put( SvxColorItem( aColorItem.GetColorValue(), aColorItem.getComplexColor(), nWhich ) ); + rCoreSet->Put( SvxColorItem( aColorItem.GetColorValue(), aColorItem.getComplexColor(), nWhich ) ); } else { - maSet.Put( SvxBrushItem( aColorItem.GetColorValue(), nWhich ) ); - rCoreSet->Put( SvxBrushItem( aColorItem.GetColorValue(), nWhich ) ); + maSet.Put( SvxBrushItem( aColorItem.GetColorValue(), aColorItem.getComplexColor(), nWhich ) ); + rCoreSet->Put( SvxBrushItem( aColorItem.GetColorValue(), aColorItem.getComplexColor(), nWhich ) ); } break; } diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index ad0977fab753..63cbc018c1ab 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/frame/status/LeftRightMarginScale.hpp> #include <com/sun/star/drawing/ShadingPattern.hpp> #include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/util/XComplexColor.hpp> #include <osl/diagnose.h> #include <i18nutil/unicode.hxx> @@ -75,6 +76,7 @@ #include <sal/log.hxx> #include <vcl/GraphicLoader.hxx> #include <unotools/securityoptions.hxx> +#include <docmodel/uno/UnoComplexColor.hxx> #include <boost/property_tree/ptree.hpp> @@ -3857,6 +3859,18 @@ SvxBrushItem::SvxBrushItem(const Color& rColor, sal_uInt16 _nWhich) { } +SvxBrushItem::SvxBrushItem(Color const& rColor, model::ComplexColor const& rComplexColor, sal_uInt16 nWhich) + : SfxPoolItem(nWhich) + , aColor(rColor) + , maComplexColor(rComplexColor) + , aFilterColor(COL_TRANSPARENT) + , nShadingValue(ShadingPattern::CLEAR) + , nGraphicTransparency(0) + , eGraphicPos(GPOS_NONE) + , bLoadAgain(true) +{ +} + SvxBrushItem::SvxBrushItem(const Graphic& rGraphic, SvxGraphicPosition ePos, sal_uInt16 _nWhich) : SfxPoolItem(_nWhich) , aColor(COL_TRANSPARENT) @@ -3901,6 +3915,7 @@ SvxBrushItem::SvxBrushItem(OUString aLink, OUString aFilter, SvxBrushItem::SvxBrushItem(const SvxBrushItem& rItem) : SfxPoolItem(rItem) , aColor(rItem.aColor) + , maComplexColor(rItem.maComplexColor) , aFilterColor(rItem.aFilterColor) , nShadingValue(rItem.nShadingValue) , xGraphicObject(rItem.xGraphicObject ? new GraphicObject(*rItem.xGraphicObject) : nullptr) @@ -3915,6 +3930,7 @@ SvxBrushItem::SvxBrushItem(const SvxBrushItem& rItem) SvxBrushItem::SvxBrushItem(SvxBrushItem&& rItem) : SfxPoolItem(std::move(rItem)) , aColor(std::move(rItem.aColor)) + , maComplexColor(std::move(rItem.maComplexColor)) , aFilterColor(std::move(rItem.aFilterColor)) , nShadingValue(std::move(rItem.nShadingValue)) , xGraphicObject(std::move(rItem.xGraphicObject)) @@ -3974,6 +3990,15 @@ bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const case MID_BACK_COLOR_TRANSPARENCY: rVal <<= SvxBrushItem::TransparencyToPercent(255 - aColor.GetAlpha()); break; + + case MID_BACKGROUND_COMPLEX_COLOR: + { + auto xComplexColor = model::color::createXComplexColor(maComplexColor); + rVal <<= xComplexColor; + break; + } + break; + case MID_GRAPHIC_POSITION: rVal <<= static_cast<style::GraphicLocation>(static_cast<sal_Int16>(eGraphicPos)); break; @@ -4047,6 +4072,17 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) } break; + case MID_BACKGROUND_COMPLEX_COLOR: + { + css::uno::Reference<css::util::XComplexColor> xComplexColor; + if (!(rVal >>= xComplexColor)) + return false; + + if (xComplexColor.is()) + maComplexColor = model::color::getFromXComplexColor(xComplexColor); + } + break; + case MID_GRAPHIC_POSITION: { style::GraphicLocation eLocation; diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 1112bcf1a548..bc9b8e573027 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -1616,11 +1616,6 @@ void SvxColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const (void)xmlTextWriterEndElement(pWriter); } -void SvxColorItem::SetValue( const Color& rNewCol ) -{ - mColor = rNewCol; -} - // class SvxKerningItem -------------------------------------------------- SvxKerningItem::SvxKerningItem( const short nKern, const sal_uInt16 nId ) : diff --git a/include/editeng/brushitem.hxx b/include/editeng/brushitem.hxx index 522bf92e1bfa..b995c7fa0637 100644 --- a/include/editeng/brushitem.hxx +++ b/include/editeng/brushitem.hxx @@ -16,15 +16,13 @@ * 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_EDITENG_BRUSHITEM_HXX -#define INCLUDED_EDITENG_BRUSHITEM_HXX +#pragma once #include <tools/color.hxx> #include <svl/poolitem.hxx> #include <editeng/editengdllapi.h> #include <memory> - -// class SvxBrushItem ---------------------------------------------------- +#include <docmodel/color/ComplexColor.hxx> class Graphic; class GraphicObject; @@ -43,6 +41,7 @@ enum SvxGraphicPosition class EDITENG_DLLPUBLIC SvxBrushItem final : public SfxPoolItem { Color aColor; + model::ComplexColor maComplexColor; Color aFilterColor; sal_Int32 nShadingValue; mutable std::unique_ptr<GraphicObject> xGraphicObject; @@ -59,7 +58,8 @@ public: static SfxPoolItem* CreateDefault(); explicit SvxBrushItem( sal_uInt16 nWhich ); - SvxBrushItem( const Color& rColor, sal_uInt16 nWhich ); + SvxBrushItem(Color const& rColor, sal_uInt16 nWhich); + SvxBrushItem(Color const& rColor, model::ComplexColor const& rComplexColor, sal_uInt16 nWhich); SvxBrushItem( const Graphic& rGraphic, SvxGraphicPosition ePos, sal_uInt16 nWhich ); @@ -91,6 +91,16 @@ public: Color& GetColor() { return aColor; } void SetColor( const Color& rCol) { aColor = rCol; } + model::ComplexColor getComplexColor() const + { + return maComplexColor; + } + + void setComplexColor(model::ComplexColor const& rComplexColor) + { + maComplexColor = rComplexColor; + } + const Color& GetFiltColor() const { return aFilterColor; } void SetFiltColor( const Color& rCol) { aFilterColor = rCol; } @@ -117,6 +127,4 @@ public: void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; -#endif // INCLUDED_EDITENG_BRUSHITEM_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/editeng/colritem.hxx b/include/editeng/colritem.hxx index dca36a5b9fda..e70b27b577e5 100644 --- a/include/editeng/colritem.hxx +++ b/include/editeng/colritem.hxx @@ -58,7 +58,19 @@ public: { return mColor; } - void SetValue(const Color& rNewColor); + void SetValue(const Color& rNewColor) + { + mColor = rNewColor; + } + + const Color& getColor() const + { + return mColor; + } + void setColor(const Color& rNewColor) + { + mColor = rNewColor; + } model::ComplexColor const& getComplexColor() const { return maComplexColor; } void setComplexColor(model::ComplexColor const& rComplexColor) { maComplexColor = rComplexColor; } diff --git a/include/editeng/memberids.h b/include/editeng/memberids.h index e5f1f075290a..5787f70ae1e8 100644 --- a/include/editeng/memberids.h +++ b/include/editeng/memberids.h @@ -169,6 +169,7 @@ #define MID_BACK_COLOR_R_G_B 8 #define MID_BACK_COLOR_TRANSPARENCY 9 #define MID_SHADING_VALUE 10 +#define MID_BACKGROUND_COMPLEX_COLOR 11 //SvxFormatBreakItem #define MID_BREAK_BEFORE 0 diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index 141c01fc73b8..75e9a1743d12 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -542,6 +542,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools \ sc/source/ui/StatisticsDialogs/TTestDialog \ sc/source/ui/StatisticsDialogs/ZTestDialog \ + sc/source/ui/theme/ThemeColorChanger \ sc/source/ui/uitest/uiobject \ sc/source/ui/undo/areasave \ sc/source/ui/undo/refundo \ diff --git a/sc/source/ui/inc/ThemeColorChanger.hxx b/sc/source/ui/inc/ThemeColorChanger.hxx new file mode 100644 index 000000000000..89d154aca7d9 --- /dev/null +++ b/sc/source/ui/inc/ThemeColorChanger.hxx @@ -0,0 +1,31 @@ +/* -*- 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 <svx/theme/ThemeColorChanger.hxx> +#include "docsh.hxx" + +namespace sc +{ +class ThemeColorChanger : public svx::IThemeColorChanger +{ + ScDocShell& m_rDocShell; + +public: + ThemeColorChanger(ScDocShell& rDocShell); + virtual ~ThemeColorChanger() override; + + void apply(model::ColorSet const& rColorSet) override; +}; + +} // end sc namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/theme/ThemeColorChanger.cxx b/sc/source/ui/theme/ThemeColorChanger.cxx new file mode 100644 index 000000000000..1e8641f525a4 --- /dev/null +++ b/sc/source/ui/theme/ThemeColorChanger.cxx @@ -0,0 +1,97 @@ +/* -*- 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 <ThemeColorChanger.hxx> + +#include <sal/config.h> + +#include <docmodel/uno/UnoComplexColor.hxx> +#include <docmodel/theme/Theme.hxx> +#include <editeng/colritem.hxx> +#include <editeng/brushitem.hxx> + +#include <stlpool.hxx> +#include <stlsheet.hxx> +#include <scitems.hxx> +#include <document.hxx> + +namespace sc +{ +ThemeColorChanger::ThemeColorChanger(ScDocShell& rDocShell) + : m_rDocShell(rDocShell) +{ +} + +ThemeColorChanger::~ThemeColorChanger() = default; + +namespace +{ +void paragraphStyleChange(ScStyleSheet* pStyle, model::ColorSet const& rColorSet) +{ + const SfxPoolItem* pItem = nullptr; + auto& rItemSet = pStyle->GetItemSet(); + + if (rItemSet.HasItem(ATTR_FONT_COLOR, &pItem)) + { + auto const* pColorItem = static_cast<const SvxColorItem*>(pItem); + model::ComplexColor const& rComplexColor = pColorItem->getComplexColor(); + if (rComplexColor.meType == model::ColorType::Scheme) + { + auto eThemeType = rComplexColor.meSchemeType; + if (eThemeType != model::ThemeColorType::Unknown) + { + Color aColor = rColorSet.getColor(eThemeType); + aColor = rComplexColor.applyTransformations(aColor); + + SvxColorItem aColorItem(*pColorItem); + aColorItem.setColor(aColor); + rItemSet.Put(aColorItem); + } + } + } + if (rItemSet.HasItem(ATTR_BACKGROUND, &pItem)) + { + auto const* pBrushItem = static_cast<const SvxBrushItem*>(pItem); + model::ComplexColor const& rComplexColor = pBrushItem->getComplexColor(); + if (rComplexColor.meType == model::ColorType::Scheme) + { + auto eThemeType = rComplexColor.meSchemeType; + if (eThemeType != model::ThemeColorType::Unknown) + { + Color aColor = rColorSet.getColor(eThemeType); + aColor = rComplexColor.applyTransformations(aColor); + + SvxBrushItem aNewBrushItem(*pBrushItem); + aNewBrushItem.SetColor(aColor); + rItemSet.Put(aNewBrushItem); + } + } + } +} +} // end anonymous ns + +void ThemeColorChanger::apply(model::ColorSet const& rColorSet) +{ + auto& rDocument = m_rDocShell.GetDocument(); + ScStyleSheetPool* pPool = rDocument.GetStyleSheetPool(); + ScStyleSheet* pStyle; + + // Paragraph style color change + pStyle = static_cast<ScStyleSheet*>(pPool->First(SfxStyleFamily::Para)); + while (pStyle) + { + paragraphStyleChange(pStyle, rColorSet); + pStyle = static_cast<ScStyleSheet*>(pPool->Next()); + } +} + +} // end sw namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index 91bafb695d94..1efb52fae3d6 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -1224,7 +1224,8 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq ) SvxBrushItem aBrushItem( pTabViewShell->GetSelectionPattern()->GetItem( ATTR_BACKGROUND ) ); - aBrushItem.SetColor( aColor ); + aBrushItem.SetColor(aColor); + aBrushItem.setComplexColor(rNewColorItem.getComplexColor()); pTabViewShell->ApplyAttr( aBrushItem, false ); } @@ -1237,6 +1238,7 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq ) const SvxBrushItem& rNewBrushItem = static_cast<const SvxBrushItem&>( pNewAttrs->Get( GetPool().GetWhich(nSlot) ) ); aBrushItem.SetColor(rNewBrushItem.GetColor()); + aBrushItem.setComplexColor(rNewBrushItem.getComplexColor()); pTabViewShell->ApplyAttr( aBrushItem ); } break; diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index da061b14e57b..6cb57e0ecc53 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -62,7 +62,7 @@ #include <svx/svdpagv.hxx> #include <svx/svdpage.hxx> #include <svx/dialog/ThemeDialog.hxx> -#include <svx/theme/ThemeColorChanger.hxx> +#include <ThemeColorChanger.hxx> namespace { @@ -1352,7 +1352,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) ScViewData& rViewData = GetViewData(); vcl::Window* pWin = rViewData.GetActiveWin(); auto pDialog = std::make_shared<svx::ThemeDialog>(pWin ? pWin->GetFrameWeld() : nullptr, pTheme.get()); - weld::DialogController::runAsync(pDialog, [pDialog, pPage](sal_uInt32 nResult) { + weld::DialogController::runAsync(pDialog, [this, pDialog](sal_uInt32 nResult) { if (RET_OK != nResult) return; @@ -1360,7 +1360,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) if (oColorSet) { auto& rColorSet = (*oColorSet).get(); - svx::ThemeColorChanger aChanger(pPage); + sc::ThemeColorChanger aChanger(*GetViewData().GetDocShell()); aChanger.apply(rColorSet); } }); |