xref: /aoo42x/main/sc/source/ui/inc/undostyl.hxx (revision 38d50f7b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_UNDOSTYL_HXX
25 #define SC_UNDOSTYL_HXX
26 
27 #include <rsc/rscsfx.hxx>
28 #include "undobase.hxx"
29 
30 class ScDocShell;
31 class SfxStyleSheetBase;
32 
33 //----------------------------------------------------------------------------
34 
35 class ScStyleSaveData
36 {
37 private:
38 	String			aName;
39 	String			aParent;
40 	SfxItemSet*		pItems;
41 
42 public:
43 						ScStyleSaveData();
44 						ScStyleSaveData( const ScStyleSaveData& rOther );
45 						~ScStyleSaveData();
46 	ScStyleSaveData&	operator=( const ScStyleSaveData& rOther );
47 
48 	void				InitFromStyle( const SfxStyleSheetBase* pSource );
49 
GetName() const50 	const String&		GetName() const		{ return aName; }
GetParent() const51 	const String&		GetParent() const	{ return aParent; }
GetItems() const52 	const SfxItemSet*	GetItems() const	{ return pItems; }
53 };
54 
55 class ScUndoModifyStyle: public ScSimpleUndo
56 {
57 private:
58 	SfxStyleFamily	eFamily;
59 	ScStyleSaveData	aOldData;
60 	ScStyleSaveData	aNewData;
61 
62 	static void		DoChange( ScDocShell* pDocSh,
63 								const String& rName, SfxStyleFamily eStyleFamily,
64 								const ScStyleSaveData& rData );
65 
66 public:
67 					TYPEINFO();
68 					ScUndoModifyStyle( ScDocShell* pDocSh,
69 										SfxStyleFamily eFam,
70 										const ScStyleSaveData& rOld,
71 										const ScStyleSaveData& rNew );
72 	virtual 		~ScUndoModifyStyle();
73 
74 	virtual void	Undo();
75 	virtual void	Redo();
76 	virtual void	Repeat(SfxRepeatTarget& rTarget);
77 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
78 
79 	virtual String	GetComment() const;
80 };
81 
82 class ScUndoApplyPageStyle: public ScSimpleUndo
83 {
84 public:
85 					TYPEINFO();
86                     ScUndoApplyPageStyle( ScDocShell* pDocSh, const String& rNewStyle );
87 	virtual 		~ScUndoApplyPageStyle();
88 
89     void            AddSheetAction( SCTAB nTab, const String& rOld );
90 
91 	virtual void	Undo();
92 	virtual void	Redo();
93 	virtual void	Repeat(SfxRepeatTarget& rTarget);
94 	virtual sal_Bool	CanRepeat(SfxRepeatTarget& rTarget) const;
95 
96 	virtual String	GetComment() const;
97 
98 private:
99     struct ApplyStyleEntry
100     {
101         SCTAB           mnTab;
102         String          maOldStyle;
103         explicit        ApplyStyleEntry( SCTAB nTab, const String& rOldStyle );
104     };
105     typedef ::std::vector< ApplyStyleEntry > ApplyStyleVec;
106 
107     ApplyStyleVec   maEntries;
108     String          maNewStyle;
109 };
110 
111 
112 #endif
113 
114