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