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 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 #include <undoflystrattr.hxx>
32 #include <frmfmt.hxx>
33 
34 SwUndoFlyStrAttr::SwUndoFlyStrAttr( SwFlyFrmFmt& rFlyFrmFmt,
35                                     const SwUndoId eUndoId,
36                                     const String& sOldStr,
37                                     const String& sNewStr )
38     : SwUndo( eUndoId ),
39       mrFlyFrmFmt( rFlyFrmFmt ),
40       msOldStr( sOldStr ),
41       msNewStr( sNewStr )
42 {
43     ASSERT( eUndoId == UNDO_FLYFRMFMT_TITLE ||
44             eUndoId == UNDO_FLYFRMFMT_DESCRIPTION,
45             "<SwUndoFlyStrAttr::SwUndoFlyStrAttr(..)> - unexpected undo id --> Undo will not work" );
46 }
47 
48 SwUndoFlyStrAttr::~SwUndoFlyStrAttr()
49 {
50 }
51 
52 void SwUndoFlyStrAttr::UndoImpl(::sw::UndoRedoContext &)
53 {
54     switch ( GetId() )
55     {
56         case UNDO_FLYFRMFMT_TITLE:
57         {
58             mrFlyFrmFmt.SetObjTitle( msOldStr, true );
59         }
60         break;
61         case UNDO_FLYFRMFMT_DESCRIPTION:
62         {
63             mrFlyFrmFmt.SetObjDescription( msOldStr, true );
64         }
65         break;
66         default:
67         {
68         }
69     }
70 }
71 
72 void SwUndoFlyStrAttr::RedoImpl(::sw::UndoRedoContext &)
73 {
74     switch ( GetId() )
75     {
76         case UNDO_FLYFRMFMT_TITLE:
77         {
78             mrFlyFrmFmt.SetObjTitle( msNewStr, true );
79         }
80         break;
81         case UNDO_FLYFRMFMT_DESCRIPTION:
82         {
83             mrFlyFrmFmt.SetObjDescription( msNewStr, true );
84         }
85         break;
86         default:
87         {
88         }
89     }
90 }
91 
92 SwRewriter SwUndoFlyStrAttr::GetRewriter() const
93 {
94     SwRewriter aResult;
95 
96     aResult.AddRule( UNDO_ARG1, mrFlyFrmFmt.GetName() );
97 
98     return aResult;
99 }
100