diff options
author | Armin Le Grand <alg@apache.org> | 2012-06-20 08:17:23 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-04-30 15:39:57 +0100 |
commit | 4c8ffa01131f2df2b314218731d83bd776944802 (patch) | |
tree | 485475b3f905e01825b98b13a116cef6da99977d /svx | |
parent | 6ab8f15653af431fcacffb3c9227f90aa04456f7 (diff) |
i#120015# Let SdrUndoAttrObj remember a reference to the used style to survive
removal of the style by UI (which creates no undo actions). Re-add the
style when undoing if needed.
Change-Id: I6069a1cb42dfaeb0dd35fdc15687fd307f2b641e
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdundo.cxx | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx index 284aaca6a563..3bcace5e07b2 100644 --- a/svx/source/svdraw/svdundo.cxx +++ b/svx/source/svdraw/svdundo.cxx @@ -246,16 +246,29 @@ void SdrUndoObj::ImpShowPageOfThisObject() } } -//////////////////////////////////////////////////////////////////////////////////////////////////// +void SdrUndoAttrObj::ensureStyleSheetInStyleSheetPool(SfxStyleSheetBasePool& rStyleSheetPool, SfxStyleSheet& rSheet) +{ + SfxStyleSheetBase* pThere = rStyleSheetPool.Find(rSheet.GetName(), rSheet.GetFamily()); + + if(!pThere) + { + // re-insert remembered style which was removed in the meantime. To do this + // without assertion, do it without parent and set parent after insertion + const UniString aParent(rSheet.GetParent()); + + rSheet.SetParent(UniString()); + rStyleSheetPool.Insert(&rSheet); + rSheet.SetParent(aParent); + } +} SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSaveText) : SdrUndoObj(rNewObj), pUndoSet(NULL), pRedoSet(NULL), pRepeatSet(NULL), - pUndoStyleSheet(NULL), - pRedoStyleSheet(NULL), - pRepeatStyleSheet(NULL), + mxUndoStyleSheet(), + mxRedoStyleSheet(), bHaveToTakeRedoSet(sal_True), pTextUndo(NULL), @@ -288,7 +301,7 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSave pUndoSet = new SfxItemSet(pObj->GetMergedItemSet()); if(bStyleSheet) - pUndoStyleSheet = pObj->GetStyleSheet(); + mxUndoStyleSheet = pObj->GetStyleSheet(); if(bSaveText) { @@ -330,7 +343,7 @@ void SdrUndoAttrObj::Undo() pRedoSet = new SfxItemSet(pObj->GetMergedItemSet()); if(bStyleSheet) - pRedoStyleSheet=pObj->GetStyleSheet(); + mxRedoStyleSheet = pObj->GetStyleSheet(); if(pTextUndo) { @@ -344,8 +357,18 @@ void SdrUndoAttrObj::Undo() if(bStyleSheet) { - pRedoStyleSheet = pObj->GetStyleSheet(); - pObj->SetStyleSheet(pUndoStyleSheet, sal_True); + mxRedoStyleSheet = pObj->GetStyleSheet(); + SfxStyleSheet* pSheet = dynamic_cast< SfxStyleSheet* >(mxUndoStyleSheet.get()); + + if(pSheet && pObj->GetModel() && pObj->GetModel()->GetStyleSheetPool()) + { + ensureStyleSheetInStyleSheetPool(*pObj->GetModel()->GetStyleSheetPool(), *pSheet); + pObj->SetStyleSheet(pSheet, sal_True); + } + else + { + OSL_ENSURE(false, "OOps, something went wrong in SdrUndoAttrObj (!)"); + } } sdr::properties::ItemChangeBroadcaster aItemChange(*pObj); @@ -417,8 +440,18 @@ void SdrUndoAttrObj::Redo() { if(bStyleSheet) { - pUndoStyleSheet = pObj->GetStyleSheet(); - pObj->SetStyleSheet(pRedoStyleSheet, sal_True); + mxUndoStyleSheet = pObj->GetStyleSheet(); + SfxStyleSheet* pSheet = dynamic_cast< SfxStyleSheet* >(mxRedoStyleSheet.get()); + + if(pSheet && pObj->GetModel() && pObj->GetModel()->GetStyleSheetPool()) + { + ensureStyleSheetInStyleSheetPool(*pObj->GetModel()->GetStyleSheetPool(), *pSheet); + pObj->SetStyleSheet(pSheet, sal_True); + } + else + { + OSL_ENSURE(false, "OOps, something went wrong in SdrUndoAttrObj (!)"); + } } sdr::properties::ItemChangeBroadcaster aItemChange(*pObj); |