xref: /trunk/main/sc/source/ui/inc/undostyl.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_UNDOSTYL_HXX
29 #define SC_UNDOSTYL_HXX
30 
31 #include <rsc/rscsfx.hxx>
32 #include "undobase.hxx"
33 
34 class ScDocShell;
35 class SfxStyleSheetBase;
36 
37 //----------------------------------------------------------------------------
38 
39 class ScStyleSaveData
40 {
41 private:
42     String          aName;
43     String          aParent;
44     SfxItemSet*     pItems;
45 
46 public:
47                         ScStyleSaveData();
48                         ScStyleSaveData( const ScStyleSaveData& rOther );
49                         ~ScStyleSaveData();
50     ScStyleSaveData&    operator=( const ScStyleSaveData& rOther );
51 
52     void                InitFromStyle( const SfxStyleSheetBase* pSource );
53 
54     const String&       GetName() const     { return aName; }
55     const String&       GetParent() const   { return aParent; }
56     const SfxItemSet*   GetItems() const    { return pItems; }
57 };
58 
59 class ScUndoModifyStyle: public ScSimpleUndo
60 {
61 private:
62     SfxStyleFamily  eFamily;
63     ScStyleSaveData aOldData;
64     ScStyleSaveData aNewData;
65 
66     static void     DoChange( ScDocShell* pDocSh,
67                                 const String& rName, SfxStyleFamily eStyleFamily,
68                                 const ScStyleSaveData& rData );
69 
70 public:
71                     TYPEINFO();
72                     ScUndoModifyStyle( ScDocShell* pDocSh,
73                                         SfxStyleFamily eFam,
74                                         const ScStyleSaveData& rOld,
75                                         const ScStyleSaveData& rNew );
76     virtual         ~ScUndoModifyStyle();
77 
78     virtual void    Undo();
79     virtual void    Redo();
80     virtual void    Repeat(SfxRepeatTarget& rTarget);
81     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
82 
83     virtual String  GetComment() const;
84 };
85 
86 class ScUndoApplyPageStyle: public ScSimpleUndo
87 {
88 public:
89                     TYPEINFO();
90                     ScUndoApplyPageStyle( ScDocShell* pDocSh, const String& rNewStyle );
91     virtual         ~ScUndoApplyPageStyle();
92 
93     void            AddSheetAction( SCTAB nTab, const String& rOld );
94 
95     virtual void    Undo();
96     virtual void    Redo();
97     virtual void    Repeat(SfxRepeatTarget& rTarget);
98     virtual sal_Bool    CanRepeat(SfxRepeatTarget& rTarget) const;
99 
100     virtual String  GetComment() const;
101 
102 private:
103     struct ApplyStyleEntry
104     {
105         SCTAB           mnTab;
106         String          maOldStyle;
107         explicit        ApplyStyleEntry( SCTAB nTab, const String& rOldStyle );
108     };
109     typedef ::std::vector< ApplyStyleEntry > ApplyStyleVec;
110 
111     ApplyStyleVec   maEntries;
112     String          maNewStyle;
113 };
114 
115 
116 #endif
117 
118