xref: /aoo41x/main/sd/source/ui/dlg/unchss.cxx (revision 79aad27f)
1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5b190011SAndrew Rist  * distributed with this work for additional information
6*5b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist  * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*5b190011SAndrew Rist  *
11*5b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*5b190011SAndrew Rist  *
13*5b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist  * software distributed under the License is distributed on an
15*5b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
17*5b190011SAndrew Rist  * specific language governing permissions and limitations
18*5b190011SAndrew Rist  * under the License.
19*5b190011SAndrew Rist  *
20*5b190011SAndrew Rist  *************************************************************/
21*5b190011SAndrew Rist 
22*5b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <svl/itemset.hxx>
29cdf0e10cSrcweir #include <svl/style.hxx>
30cdf0e10cSrcweir #include <svl/smplhint.hxx>
31cdf0e10cSrcweir #include <svx/svdobj.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "unchss.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "strings.hrc"
36cdf0e10cSrcweir #include "glob.hxx"
37cdf0e10cSrcweir #include "sdresid.hxx"
38cdf0e10cSrcweir #include "drawdoc.hxx"
39cdf0e10cSrcweir #include "stlsheet.hxx"
40cdf0e10cSrcweir #include "glob.hrc"
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 
43cdf0e10cSrcweir TYPEINIT1(StyleSheetUndoAction, SdUndoAction);
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir /*************************************************************************
48cdf0e10cSrcweir |*
49cdf0e10cSrcweir |* Konstruktor
50cdf0e10cSrcweir |*
51cdf0e10cSrcweir \************************************************************************/
52cdf0e10cSrcweir 
StyleSheetUndoAction(SdDrawDocument * pTheDoc,SfxStyleSheet * pTheStyleSheet,const SfxItemSet * pTheNewItemSet)53cdf0e10cSrcweir StyleSheetUndoAction::StyleSheetUndoAction(SdDrawDocument* pTheDoc,
54cdf0e10cSrcweir 										   SfxStyleSheet* pTheStyleSheet,
55cdf0e10cSrcweir 										   const SfxItemSet* pTheNewItemSet) :
56cdf0e10cSrcweir 					  SdUndoAction(pTheDoc)
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	DBG_ASSERT(pTheStyleSheet, "Undo ohne StyleSheet ???");
59cdf0e10cSrcweir 	pStyleSheet = pTheStyleSheet;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 	// ItemSets anlegen; Vorsicht, das neue koennte aus einem anderen Pool
62cdf0e10cSrcweir 	// stammen, also mitsamt seinen Items clonen
63cdf0e10cSrcweir 	pNewSet = new SfxItemSet((SfxItemPool&)SdrObject::GetGlobalDrawObjectItemPool(), pTheNewItemSet->GetRanges());
64cdf0e10cSrcweir 	pTheDoc->MigrateItemSet( pTheNewItemSet, pNewSet, pTheDoc );
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	pOldSet = new SfxItemSet((SfxItemPool&)SdrObject::GetGlobalDrawObjectItemPool(),pStyleSheet->GetItemSet().GetRanges());
67cdf0e10cSrcweir 	pTheDoc->MigrateItemSet( &pStyleSheet->GetItemSet(), pOldSet, pTheDoc );
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	aComment = String(SdResId(STR_UNDO_CHANGE_PRES_OBJECT));
70cdf0e10cSrcweir 	String aName(pStyleSheet->GetName());
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	// Layoutnamen und Separator loeschen
73cdf0e10cSrcweir 	String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ) );
74cdf0e10cSrcweir 	sal_uInt16 nPos = aName.Search(aSep);
75cdf0e10cSrcweir 	if( nPos != STRING_NOTFOUND )
76cdf0e10cSrcweir 		aName.Erase(0, nPos + aSep.Len());
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	if (aName == String(SdResId(STR_LAYOUT_TITLE)))
79cdf0e10cSrcweir 	{
80cdf0e10cSrcweir 		aName = String(SdResId(STR_PSEUDOSHEET_TITLE));
81cdf0e10cSrcweir 	}
82cdf0e10cSrcweir 	else if (aName == String(SdResId(STR_LAYOUT_SUBTITLE)))
83cdf0e10cSrcweir 	{
84cdf0e10cSrcweir 		aName = String(SdResId(STR_PSEUDOSHEET_SUBTITLE));
85cdf0e10cSrcweir 	}
86cdf0e10cSrcweir 	else if (aName == String(SdResId(STR_LAYOUT_BACKGROUND)))
87cdf0e10cSrcweir 	{
88cdf0e10cSrcweir 		aName = String(SdResId(STR_PSEUDOSHEET_BACKGROUND));
89cdf0e10cSrcweir 	}
90cdf0e10cSrcweir 	else if (aName == String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS)))
91cdf0e10cSrcweir 	{
92cdf0e10cSrcweir 		aName = String(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS));
93cdf0e10cSrcweir 	}
94cdf0e10cSrcweir 	else if (aName == String(SdResId(STR_LAYOUT_NOTES)))
95cdf0e10cSrcweir 	{
96cdf0e10cSrcweir 		aName = String(SdResId(STR_PSEUDOSHEET_NOTES));
97cdf0e10cSrcweir 	}
98cdf0e10cSrcweir 	else
99cdf0e10cSrcweir 	{
100cdf0e10cSrcweir 		String aOutlineStr(SdResId(STR_PSEUDOSHEET_OUTLINE));
101cdf0e10cSrcweir 		nPos = aName.Search(aOutlineStr);
102cdf0e10cSrcweir 		if (nPos != STRING_NOTFOUND)
103cdf0e10cSrcweir 		{
104cdf0e10cSrcweir 			String aNumStr(aName.Copy(aOutlineStr.Len()));
105cdf0e10cSrcweir 			aName = String(SdResId(STR_LAYOUT_OUTLINE));
106cdf0e10cSrcweir 			aName += aNumStr;
107cdf0e10cSrcweir 		}
108cdf0e10cSrcweir 	}
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	// Platzhalter durch Vorlagennamen ersetzen
111cdf0e10cSrcweir 	nPos = aComment.Search(sal_Unicode('$'));
112cdf0e10cSrcweir 	aComment.Erase(nPos, 1);
113cdf0e10cSrcweir 	aComment.Insert(aName, nPos);
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 
117cdf0e10cSrcweir /*************************************************************************
118cdf0e10cSrcweir |*
119cdf0e10cSrcweir |* Undo()
120cdf0e10cSrcweir |*
121cdf0e10cSrcweir \************************************************************************/
122cdf0e10cSrcweir 
Undo()123cdf0e10cSrcweir void StyleSheetUndoAction::Undo()
124cdf0e10cSrcweir {
125cdf0e10cSrcweir 	SfxItemSet aNewSet( mpDoc->GetItemPool(), pOldSet->GetRanges() );
126cdf0e10cSrcweir 	mpDoc->MigrateItemSet( pOldSet, &aNewSet, mpDoc );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	pStyleSheet->GetItemSet().Set(aNewSet);
129cdf0e10cSrcweir 	if( pStyleSheet->GetFamily() == SD_STYLE_FAMILY_PSEUDO )
130cdf0e10cSrcweir 		( (SdStyleSheet*)pStyleSheet )->GetRealStyleSheet()->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
131cdf0e10cSrcweir 	else
132cdf0e10cSrcweir 		pStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
133cdf0e10cSrcweir }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir /*************************************************************************
136cdf0e10cSrcweir |*
137cdf0e10cSrcweir |* Redo()
138cdf0e10cSrcweir |*
139cdf0e10cSrcweir \************************************************************************/
140cdf0e10cSrcweir 
Redo()141cdf0e10cSrcweir void StyleSheetUndoAction::Redo()
142cdf0e10cSrcweir {
143cdf0e10cSrcweir 	SfxItemSet aNewSet( mpDoc->GetItemPool(), pOldSet->GetRanges() );
144cdf0e10cSrcweir 	mpDoc->MigrateItemSet( pNewSet, &aNewSet, mpDoc );
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	pStyleSheet->GetItemSet().Set(aNewSet);
147cdf0e10cSrcweir 	if( pStyleSheet->GetFamily() == SD_STYLE_FAMILY_PSEUDO )
148cdf0e10cSrcweir 		( (SdStyleSheet*)pStyleSheet )->GetRealStyleSheet()->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
149cdf0e10cSrcweir 	else
150cdf0e10cSrcweir 		pStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir /*************************************************************************
154cdf0e10cSrcweir |*
155cdf0e10cSrcweir |* Destruktor
156cdf0e10cSrcweir |*
157cdf0e10cSrcweir \************************************************************************/
158cdf0e10cSrcweir 
~StyleSheetUndoAction()159cdf0e10cSrcweir StyleSheetUndoAction::~StyleSheetUndoAction()
160cdf0e10cSrcweir {
161cdf0e10cSrcweir 	delete pNewSet;
162cdf0e10cSrcweir 	delete pOldSet;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
165cdf0e10cSrcweir /*************************************************************************
166cdf0e10cSrcweir |*
167cdf0e10cSrcweir |* Kommentar liefern
168cdf0e10cSrcweir |*
169cdf0e10cSrcweir \************************************************************************/
170cdf0e10cSrcweir 
GetComment() const171cdf0e10cSrcweir String StyleSheetUndoAction::GetComment() const
172cdf0e10cSrcweir {
173cdf0e10cSrcweir 	return aComment;
174cdf0e10cSrcweir }
175