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