1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unchss.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include <svtools/itemset.hxx>
36 #include <svtools/style.hxx>
37 #include <svtools/smplhint.hxx>
38 #include <svx/svdobj.hxx>
42 #include "strings.hrc"
44 #include "sdresid.hxx"
45 #include "drawdoc.hxx"
46 #include "stlsheet.hxx"
50 TYPEINIT1(StyleSheetUndoAction
, SdUndoAction
);
54 /*************************************************************************
58 \************************************************************************/
60 StyleSheetUndoAction::StyleSheetUndoAction(SdDrawDocument
* pTheDoc
,
61 SfxStyleSheet
* pTheStyleSheet
,
62 const SfxItemSet
* pTheNewItemSet
) :
65 DBG_ASSERT(pTheStyleSheet
, "Undo ohne StyleSheet ???");
66 pStyleSheet
= pTheStyleSheet
;
68 // ItemSets anlegen; Vorsicht, das neue koennte aus einem anderen Pool
69 // stammen, also mitsamt seinen Items clonen
70 pNewSet
= new SfxItemSet((SfxItemPool
&)SdrObject::GetGlobalDrawObjectItemPool(), pTheNewItemSet
->GetRanges());
71 pTheDoc
->MigrateItemSet( pTheNewItemSet
, pNewSet
, pTheDoc
);
73 pOldSet
= new SfxItemSet((SfxItemPool
&)SdrObject::GetGlobalDrawObjectItemPool(),pStyleSheet
->GetItemSet().GetRanges());
74 pTheDoc
->MigrateItemSet( &pStyleSheet
->GetItemSet(), pOldSet
, pTheDoc
);
76 aComment
= String(SdResId(STR_UNDO_CHANGE_PRES_OBJECT
));
77 String
aName(pStyleSheet
->GetName());
79 // Layoutnamen und Separator loeschen
80 String
aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR
) );
81 USHORT nPos
= aName
.Search(aSep
);
82 if( nPos
!= STRING_NOTFOUND
)
83 aName
.Erase(0, nPos
+ aSep
.Len());
85 if (aName
== String(SdResId(STR_LAYOUT_TITLE
)))
87 aName
= String(SdResId(STR_PSEUDOSHEET_TITLE
));
89 else if (aName
== String(SdResId(STR_LAYOUT_SUBTITLE
)))
91 aName
= String(SdResId(STR_PSEUDOSHEET_SUBTITLE
));
93 else if (aName
== String(SdResId(STR_LAYOUT_BACKGROUND
)))
95 aName
= String(SdResId(STR_PSEUDOSHEET_BACKGROUND
));
97 else if (aName
== String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS
)))
99 aName
= String(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS
));
101 else if (aName
== String(SdResId(STR_LAYOUT_NOTES
)))
103 aName
= String(SdResId(STR_PSEUDOSHEET_NOTES
));
107 String
aOutlineStr(SdResId(STR_PSEUDOSHEET_OUTLINE
));
108 nPos
= aName
.Search(aOutlineStr
);
109 if (nPos
!= STRING_NOTFOUND
)
111 String
aNumStr(aName
.Copy(aOutlineStr
.Len()));
112 aName
= String(SdResId(STR_LAYOUT_OUTLINE
));
117 // Platzhalter durch Vorlagennamen ersetzen
118 nPos
= aComment
.Search(sal_Unicode('$'));
119 aComment
.Erase(nPos
, 1);
120 aComment
.Insert(aName
, nPos
);
124 /*************************************************************************
128 \************************************************************************/
130 void StyleSheetUndoAction::Undo()
132 SfxItemSet
aNewSet( mpDoc
->GetItemPool(), pOldSet
->GetRanges() );
133 mpDoc
->MigrateItemSet( pOldSet
, &aNewSet
, mpDoc
);
135 pStyleSheet
->GetItemSet().Set(aNewSet
);
136 if( pStyleSheet
->GetFamily() == SD_STYLE_FAMILY_PSEUDO
)
137 ( (SdStyleSheet
*)pStyleSheet
)->GetRealStyleSheet()->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED
));
139 pStyleSheet
->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED
));
142 /*************************************************************************
146 \************************************************************************/
148 void StyleSheetUndoAction::Redo()
150 SfxItemSet
aNewSet( mpDoc
->GetItemPool(), pOldSet
->GetRanges() );
151 mpDoc
->MigrateItemSet( pNewSet
, &aNewSet
, mpDoc
);
153 pStyleSheet
->GetItemSet().Set(aNewSet
);
154 if( pStyleSheet
->GetFamily() == SD_STYLE_FAMILY_PSEUDO
)
155 ( (SdStyleSheet
*)pStyleSheet
)->GetRealStyleSheet()->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED
));
157 pStyleSheet
->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED
));
160 /*************************************************************************
164 \************************************************************************/
166 StyleSheetUndoAction::~StyleSheetUndoAction()
172 /*************************************************************************
176 \************************************************************************/
178 String
StyleSheetUndoAction::GetComment() const