summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svx/strings.hrc1
-rw-r--r--sd/source/core/ThemeColorChanger.cxx84
2 files changed, 61 insertions, 24 deletions
diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc
index d0a7390045ae..f17b76c7a3ae 100644
--- a/include/svx/strings.hrc
+++ b/include/svx/strings.hrc
@@ -1135,6 +1135,7 @@
#define RID_SVXSTR_THEME_COLOR12 NC_("RID_SVXSTR_THEME_COLOR12", "Followed Hyperlink")
#define RID_SVXSTR_THEME_EFFECT_LIGHTER NC_("RID_SVXSTR_THEME_EFFECT_LIGHTER", "$THEME_NAME, $PERCENTAGE% Lighter")
#define RID_SVXSTR_THEME_EFFECT_DARKER NC_("RID_SVXSTR_THEME_EFFECT_DARKER", "$THEME_NAME, $PERCENTAGE% Darker")
+#define RID_SVXSTR_UNDO_THEME_COLOR_CHANGE NC_("RID_SVXSTR_UNDO_THEME_COLOR_CHANGE", "Theme Color Change")
#define RID_SVX_EXTRUSION_BAR NC_("RID_SVX_EXTRUSION_BAR", "Extrusion")
#define RID_SVXSTR_UNDO_APPLY_EXTRUSION_ON_OFF NC_("RID_SVXSTR_UNDO_APPLY_EXTRUSION_ON_OFF", "Apply Extrusion On/Off")
diff --git a/sd/source/core/ThemeColorChanger.cxx b/sd/source/core/ThemeColorChanger.cxx
index d0a84c866495..84a00527069c 100644
--- a/sd/source/core/ThemeColorChanger.cxx
+++ b/sd/source/core/ThemeColorChanger.cxx
@@ -17,6 +17,13 @@
#include <svx/xlnclit.hxx>
#include <svx/xflclit.hxx>
#include <svx/xdef.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/strings.hrc>
+#include <editeng/eeitem.hxx>
+
+#include <unchss.hxx>
+#include <ViewShell.hxx>
+#include <ViewShellBase.hxx>
using namespace css;
@@ -43,46 +50,73 @@ void changeTheTheme(SdrPage* pMasterPage, std::shared_ptr<model::ColorSet> const
pTheme->setColorSet(pColorSet);
}
-bool changeStyles(sd::DrawDocShell* pDocShell, std::shared_ptr<model::ColorSet> const& pColorSet)
+bool changeStyle(sd::DrawDocShell* pDocShell, SdStyleSheet* pStyle,
+ std::shared_ptr<model::ColorSet> const& pColorSet)
{
- SfxStyleSheetBasePool* pPool = pDocShell->GetStyleSheetPool();
+ bool bChanged = false;
- SdStyleSheet* pStyle = static_cast<SdStyleSheet*>(pPool->First(SfxStyleFamily::Para));
- while (pStyle)
+ auto aItemSet = pStyle->GetItemSet();
+ if (const XFillColorItem* pItem = aItemSet.GetItemIfSet(XATTR_FILLCOLOR, false))
{
- auto& rItemSet = pStyle->GetItemSet();
- if (const XFillColorItem* pItem = rItemSet.GetItemIfSet(XATTR_FILLCOLOR, false))
+ model::ComplexColor const& rComplexColor = pItem->getComplexColor();
+ if (rComplexColor.isValidThemeType())
{
- model::ComplexColor const& rComplexColor = pItem->getComplexColor();
- if (rComplexColor.isValidThemeType())
- {
- Color aNewColor = pColorSet->resolveColor(rComplexColor);
- std::unique_ptr<XFillColorItem> pNewItem(pItem->Clone());
- pNewItem->SetColorValue(aNewColor);
- rItemSet.Put(*pNewItem);
- }
+ Color aNewColor = pColorSet->resolveColor(rComplexColor);
+ std::unique_ptr<XFillColorItem> pNewItem(pItem->Clone());
+ pNewItem->SetColorValue(aNewColor);
+ aItemSet.Put(*pNewItem);
+ bChanged = true;
}
- if (const XLineColorItem* pItem = rItemSet.GetItemIfSet(XATTR_LINECOLOR, false))
+ }
+ if (const XLineColorItem* pItem = aItemSet.GetItemIfSet(XATTR_LINECOLOR, false))
+ {
+ model::ComplexColor const& rComplexColor = pItem->getComplexColor();
+ if (rComplexColor.isValidThemeType())
{
- model::ComplexColor const& rComplexColor = pItem->getComplexColor();
- if (rComplexColor.isValidThemeType())
- {
- Color aNewColor = pColorSet->resolveColor(rComplexColor);
- std::unique_ptr<XLineColorItem> pNewItem(pItem->Clone());
- pNewItem->SetColorValue(aNewColor);
- rItemSet.Put(*pNewItem);
- }
+ Color aNewColor = pColorSet->resolveColor(rComplexColor);
+ std::unique_ptr<XLineColorItem> pNewItem(pItem->Clone());
+ pNewItem->SetColorValue(aNewColor);
+ aItemSet.Put(*pNewItem);
+ bChanged = true;
}
+ }
+ if (bChanged)
+ {
+ pDocShell->GetUndoManager()->AddUndoAction(
+ std::make_unique<StyleSheetUndoAction>(pDocShell->GetDoc(), pStyle, &aItemSet));
+ pStyle->GetItemSet().Put(aItemSet);
+ pStyle->Broadcast(SfxHint(SfxHintId::DataChanged));
+ }
+ return bChanged;
+}
+
+bool changeStyles(sd::DrawDocShell* pDocShell, std::shared_ptr<model::ColorSet> const& pColorSet)
+{
+ bool bChanged = false;
+ SfxStyleSheetBasePool* pPool = pDocShell->GetStyleSheetPool();
+
+ SdStyleSheet* pStyle = static_cast<SdStyleSheet*>(pPool->First(SfxStyleFamily::Para));
+ while (pStyle)
+ {
+ bChanged = changeStyle(pDocShell, pStyle, pColorSet) || bChanged;
pStyle = static_cast<SdStyleSheet*>(pPool->Next());
}
- return true;
+ return bChanged;
}
} // end anonymous ns
void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet)
{
+ auto* pUndoManager = mpDocShell->GetUndoManager();
+
+ ViewShellId nViewShellId(-1);
+ if (sd::ViewShell* pViewShell = mpDocShell->GetViewShell())
+ nViewShellId = pViewShell->GetViewShellBase().GetViewShellId();
+ pUndoManager->EnterListAction(SvxResId(RID_SVXSTR_UNDO_THEME_COLOR_CHANGE), "", 0,
+ nViewShellId);
+
changeStyles(mpDocShell, pColorSet);
SdrModel& rModel = mpMasterPage->getSdrModelFromSdrPage();
@@ -112,6 +146,8 @@ void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet)
}
changeTheTheme(mpMasterPage, pColorSet);
+
+ pUndoManager->LeaveListAction();
}
} // end sd namespace