diff options
-rw-r--r-- | sd/source/core/ThemeColorChanger.cxx | 42 | ||||
-rw-r--r-- | svx/source/theme/ThemeColorChangerCommon.cxx | 17 |
2 files changed, 32 insertions, 27 deletions
diff --git a/sd/source/core/ThemeColorChanger.cxx b/sd/source/core/ThemeColorChanger.cxx index adfacb6a47ac..3a5c7804ae57 100644 --- a/sd/source/core/ThemeColorChanger.cxx +++ b/sd/source/core/ThemeColorChanger.cxx @@ -154,31 +154,35 @@ void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet) { SdrPage* pCurrentPage = rModel.GetPage(nPage); - // Skip pages that are using a different master page - if (!pCurrentPage->TRG_HasMasterPage() - || &pCurrentPage->TRG_GetMasterPage() != mpMasterPage) - continue; - - for (size_t nObject = 0; nObject < pCurrentPage->GetObjCount(); ++nObject) + // TODO - for now change all the objects regardless to which master page it belongs to. + // Currently we don't have a concept of master slide with a group of layouts as in MSO, but we always only + // have master pages, which aren't grouped together. In MSO the theme is defined per master slide, so when + // changing a theme, all the layouts get the new theme, as layouts are synonomus to master pages in LibreOffise, + // this is not possible to do and we would need to change the theme for each master page separately, which + // is just annoying for the user. + + // if (!pCurrentPage->TRG_HasMasterPage() || &pCurrentPage->TRG_GetMasterPage() != mpMasterPage) + // continue; + + SdrObjListIter aIter(pCurrentPage, SdrIterMode::DeepWithGroups); + while (aIter.IsMore()) { - SdrObject* pObject = pCurrentPage->GetObj(nObject); - svx::theme::updateSdrObject(*pColorSet, pObject, pView, pUndoManager); - - // update child objects - SdrObjList* pList = pObject->GetSubList(); - if (pList) - { - SdrObjListIter aIter(pList, SdrIterMode::DeepWithGroups); - while (aIter.IsMore()) - { - svx::theme::updateSdrObject(*pColorSet, aIter.Next(), pView, pUndoManager); - } - } + svx::theme::updateSdrObject(*pColorSet, aIter.Next(), pView, pUndoManager); } } changeThemeColors(mpDocShell, mpMasterPage, pColorSet); + // See the TODO comment a couple of line above for the explanation - need to change the ThemeColors for all master + // pages for now, but the following code will need to be changed in the future when we have the concept similar to + // master slide and layouts + for (sal_uInt16 nPage = 0; nPage < rModel.GetPageCount(); ++nPage) + { + SdrPage* pCurrentPage = rModel.GetPage(nPage); + if (pCurrentPage->IsMasterPage() && pCurrentPage != mpMasterPage) + changeThemeColors(mpDocShell, pCurrentPage, pColorSet); + } + pUndoManager->LeaveListAction(); } diff --git a/svx/source/theme/ThemeColorChangerCommon.cxx b/svx/source/theme/ThemeColorChangerCommon.cxx index 44f041f5f3b0..446943100101 100644 --- a/svx/source/theme/ThemeColorChangerCommon.cxx +++ b/svx/source/theme/ThemeColorChangerCommon.cxx @@ -104,13 +104,8 @@ bool updateEditEngTextSections(model::ColorSet const& rColorSet, SdrObject* pObj bool updateObjectAttributes(model::ColorSet const& rColorSet, SdrObject& rObject, SfxUndoManager* pUndoManager) { - if (pUndoManager) - { - pUndoManager->AddUndoAction( - rObject.getSdrModelFromSdrObject().GetSdrUndoFactory().CreateUndoAttrObject( - rObject, true, true)); - } bool bChanged = false; + auto aItemSet = rObject.GetMergedItemSet(); if (const XFillColorItem* pItem = aItemSet.GetItemIfSet(XATTR_FILLCOLOR, false)) @@ -151,6 +146,13 @@ bool updateObjectAttributes(model::ColorSet const& rColorSet, SdrObject& rObject } if (bChanged) { + const bool bUndo = pUndoManager && pUndoManager->IsInListAction(); + if (bUndo) + { + pUndoManager->AddUndoAction( + rObject.getSdrModelFromSdrObject().GetSdrUndoFactory().CreateUndoAttrObject( + rObject)); + } rObject.SetMergedItemSetAndBroadcast(aItemSet); } return bChanged; @@ -164,10 +166,9 @@ void updateSdrObject(model::ColorSet const& rColorSet, SdrObject* pObject, SdrVi { if (!pObject) return; - + updateObjectAttributes(rColorSet, *pObject, pUndoManager); if (pView) updateEditEngTextSections(rColorSet, pObject, *pView); - updateObjectAttributes(rColorSet, *pObject, pUndoManager); } } // end svx::theme namespace |