xref: /aoo41x/main/sw/source/core/undo/unbkmk.cxx (revision dec99bbd)
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 
SwUndoBookmark(SwUndoId nUndoId,const::sw::mark::IMark & rBkmk)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 
~SwUndoBookmark()48 SwUndoBookmark::~SwUndoBookmark()
49 {
50 }
51 
SetInDoc(SwDoc * pDoc)52 void SwUndoBookmark::SetInDoc( SwDoc* pDoc )
53 {
54     m_pHistoryBookmark->SetInDoc( pDoc, false );
55 }
56 
ResetInDoc(SwDoc * pDoc)57 void SwUndoBookmark::ResetInDoc( SwDoc* pDoc )
58 {
59     IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
60     for ( IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->getAllMarksBegin();
61           ppBkmk != pMarkAccess->getAllMarksEnd();
62           ++ppBkmk )
63     {
64         if ( m_pHistoryBookmark->IsEqualBookmark( **ppBkmk ) )
65         {
66             pMarkAccess->deleteMark( ppBkmk );
67             break;
68         }
69     }
70 }
71 
GetRewriter() const72 SwRewriter SwUndoBookmark::GetRewriter() const
73 {
74     SwRewriter aResult;
75 
76     aResult.AddRule(UNDO_ARG1, m_pHistoryBookmark->GetName());
77 
78     return aResult;
79 }
80 
81 //----------------------------------------------------------------------
82 
83 
SwUndoInsBookmark(const::sw::mark::IMark & rBkmk)84 SwUndoInsBookmark::SwUndoInsBookmark( const ::sw::mark::IMark& rBkmk )
85 	: SwUndoBookmark( UNDO_INSBOOKMARK, rBkmk )
86 {
87 }
88 
89 
UndoImpl(::sw::UndoRedoContext & rContext)90 void SwUndoInsBookmark::UndoImpl(::sw::UndoRedoContext & rContext)
91 {
92     ResetInDoc( &rContext.GetDoc() );
93 }
94 
RedoImpl(::sw::UndoRedoContext & rContext)95 void SwUndoInsBookmark::RedoImpl(::sw::UndoRedoContext & rContext)
96 {
97     SetInDoc( &rContext.GetDoc() );
98 }
99 
100