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 <UndoBookmark.hxx> 28 29 #include "doc.hxx" 30 #include "docary.hxx" 31 #include "swundo.hxx" // fuer die UndoIds 32 #include "pam.hxx" 33 34 #include <UndoCore.hxx> 35 #include "IMark.hxx" 36 #include "rolbck.hxx" 37 38 #include "SwRewriter.hxx" 39 40 41 SwUndoBookmark::SwUndoBookmark( SwUndoId nUndoId, 42 const ::sw::mark::IMark& rBkmk ) 43 : SwUndo( nUndoId ) 44 , m_pHistoryBookmark(new SwHistoryBookmark(rBkmk, true, rBkmk.IsExpanded())) 45 { 46 } 47 48 SwUndoBookmark::~SwUndoBookmark() 49 { 50 } 51 52 void SwUndoBookmark::SetInDoc( SwDoc* pDoc ) 53 { 54 m_pHistoryBookmark->SetInDoc( pDoc, false ); 55 } 56 57 void SwUndoBookmark::ResetInDoc( SwDoc* pDoc ) 58 { 59 IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); 60 for (IDocumentMarkAccess::const_iterator_t ppBkmk = 61 pMarkAccess->getMarksBegin(); 62 ppBkmk != pMarkAccess->getMarksEnd(); 63 ++ppBkmk) 64 { 65 if ( m_pHistoryBookmark->IsEqualBookmark( **ppBkmk ) ) 66 { 67 pMarkAccess->deleteMark( ppBkmk ); 68 break; 69 } 70 } 71 } 72 73 SwRewriter SwUndoBookmark::GetRewriter() const 74 { 75 SwRewriter aResult; 76 77 aResult.AddRule(UNDO_ARG1, m_pHistoryBookmark->GetName()); 78 79 return aResult; 80 } 81 82 //---------------------------------------------------------------------- 83 84 85 SwUndoInsBookmark::SwUndoInsBookmark( const ::sw::mark::IMark& rBkmk ) 86 : SwUndoBookmark( UNDO_INSBOOKMARK, rBkmk ) 87 { 88 } 89 90 91 void SwUndoInsBookmark::UndoImpl(::sw::UndoRedoContext & rContext) 92 { 93 ResetInDoc( &rContext.GetDoc() ); 94 } 95 96 void SwUndoInsBookmark::RedoImpl(::sw::UndoRedoContext & rContext) 97 { 98 SetInDoc( &rContext.GetDoc() ); 99 } 100 101