11#include <ThemeColorChanger.hxx>
25#include <stlsheet.hxx>
29#include <document.hxx>
41 : m_rDocShell(rDocShell)
72 bool bChanged =
false;
75 auto const* pColorItem =
static_cast<const SvxColorItem*
>(pItem);
86 aColorItem.setColor(aColor);
87 rItemSet.
Put(aColorItem);
94 auto const* pBrushItem =
static_cast<const SvxBrushItem*
>(pItem);
105 aNewBrushItem.SetColor(aColor);
106 rItemSet.
Put(aNewBrushItem);
113 auto const* pBoxItem =
static_cast<const SvxBoxItem*
>(pItem);
115 bool bLineChanged =
false;
117 bLineChanged = changeBorderLine(rNewItem.GetBottom(), rColorSet) || bChanged;
118 bLineChanged = changeBorderLine(rNewItem.GetTop(), rColorSet) || bChanged;
119 bLineChanged = changeBorderLine(rNewItem.GetLeft(), rColorSet) || bChanged;
120 bLineChanged = changeBorderLine(rNewItem.GetRight(), rColorSet) || bChanged;
124 rItemSet.
Put(rNewItem);
131bool changeStyles(
ScDocShell& rDocShell, std::shared_ptr<model::ColorSet>
const& pColorSet)
136 bool bChanged =
false;
146 if (changeCellItems(rItemSet, *pColorSet))
153 &rDocShell, SfxStyleFamily::Para, aOldData, aNewData));
166 std::shared_ptr<model::ColorSet>
const& pColorSet)
169 bool bChanged =
false;
181 while (
const ScPatternAttr* pPattern = aAttributeIterator.GetNext(nCol, nRow1, nRow2))
183 if (!pPattern || !pPattern->IsVisible())
187 auto& rItemSet = aNewPattern.GetItemSet();
188 bool bItemChanged = changeCellItems(rItemSet, *pColorSet);
189 bChanged = bChanged || bItemChanged;
193 ScRange aRange(nCol, nRow1, nTab, nCol, nRow2, nTab);
195 aMark.SetMarkArea(aRange);
198 pUndoDoc->InitUndo(rDocument, nTab, nTab);
199 pUndoDoc->AddUndoTab(nTab, nTab);
206 auto pUndo = std::make_unique<ScUndoSelectionAttr>(
207 &rDocShell, aMark, aRange.aStart.Col(), aRange.aStart.Row(),
208 aRange.aStart.Tab(), aRange.aEnd.Col(), aRange.aEnd.Row(),
209 aRange.aEnd.Tab(), std::move(pUndoDoc),
true, &aNewPattern);
233 std::unique_ptr<SdrUndoGroup> pUndo = pModel->
GetCalcUndo();
238 pUndo->SetComment(
"Hi!");
239 auto pUndoDraw = std::make_unique<ScUndoDraw>(std::move(pUndo), &rDocShell);
248void changeTheTheme(
ScDocShell& rDocShell, std::shared_ptr<model::ColorSet>
const& pColorSet)
257 pTheme = std::make_shared<model::Theme>(
"Office");
261 std::shared_ptr<model::ColorSet> pNewColorSet = pColorSet;
262 std::shared_ptr<model::ColorSet> pOldColorSet = pTheme->getColorSet();
263 pTheme->setColorSet(pNewColorSet);
267 auto pUndoThemeChange
268 = std::make_unique<sc::UndoThemeChange>(rDocShell, pOldColorSet, pNewColorSet);
287 nViewShellId = pViewSh->GetViewShellId();
291 OUString aUndo =
ScResId(STR_UNDO_THEME_COLOR_CHANGE);
292 pUndoManager->EnterListAction(aUndo, aUndo, 0, nViewShellId);
295 bool bChanged =
false;
296 bChanged = changeStyles(
m_rDocShell, pColorSet) || bChanged;
303 pUndoManager->LeaveListAction();
Create before modifications of the document and destroy thereafter.
void SetDocumentModified()
const ScDocument & GetDocument() const
ScDrawLayer * MakeDrawLayer()
void SetDrawModified()
SetDrawModified - without Formula update.
virtual SfxUndoManager * GetUndoManager() override
ScSheetLimits & GetSheetLimits() const
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
SC_DLLPUBLIC void ApplySelectionPattern(const ScPatternAttr &rAttr, const ScMarkData &rMark, ScEditDataArray *pDataArray=nullptr, bool *pIsChanged=nullptr)
void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, InsertDeleteFlags nFlags, bool bMarked, ScDocument &rDestDoc, const ScMarkData *pMarks=nullptr, bool bColRowFlags=true)
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
bool IsUndoEnabled() const
SC_DLLPUBLIC SCTAB GetTableCount() const
void BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager)
std::unique_ptr< SdrUndoGroup > GetCalcUndo()
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
void InitFromStyle(const SfxStyleSheetBase *pSource)
virtual SC_DLLPUBLIC SfxItemSet & GetItemSet() override
static ScTabViewShell * GetActiveViewShell()
const SdrPage * GetPage(sal_uInt16 nPgNum) const
std::shared_ptr< model::Theme > const & GetTheme() const
void SetTheme(std::shared_ptr< model::Theme > const &pTheme)
SdrPageProperties & getSdrPageProperties()
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
SfxStyleSheetBase * Next()
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
void SetColor(const Color &rColor)
model::ComplexColor const & getComplexColor() const
Color getColor(model::ThemeColorType eType) const
Color resolveColor(model::ComplexColor const &rComplexColor) const
ThemeColorType meSchemeType
Color applyTransformations(Color const &rColor) const
virtual ~ThemeColorChanger() override
void apply(std::shared_ptr< model::ColorSet > const &pColorSet) override
ThemeColorChanger(ScDocShell &rDocShell)
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
EmbeddedObjectRef * pObject
@ ATTRIB
Internal use only (d&d undo): do not delete caption objects of cell notes.
CAUTION! The following defines must be in the same namespace as the respective type.
void updateSdrObject(model::ColorSet const &rColorSet, SdrObject *pObject)
OUString ScResId(TranslateId aId)
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)