editundo.cxx (190118d0) editundo.cxx (69ffbee1)
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

--- 51 unchanged lines hidden (view full) ---

60 aPaM.SetIndex( aPaM.GetNode()->Len() );
61 EditSelection aSel( aPaM, aPaM );
62 pView->GetImpEditView()->SetEditSelection( aSel );
63}
64
65 // -----------------------------------------------------------------------
66// EditUndoManager
67// ------------------------------------------------------------------------
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

--- 51 unchanged lines hidden (view full) ---

60 aPaM.SetIndex( aPaM.GetNode()->Len() );
61 EditSelection aSel( aPaM, aPaM );
62 pView->GetImpEditView()->SetEditSelection( aSel );
63}
64
65 // -----------------------------------------------------------------------
66// EditUndoManager
67// ------------------------------------------------------------------------
68EditUndoManager::EditUndoManager( ImpEditEngine* p )
68EditUndoManager::EditUndoManager(sal_uInt16 nMaxUndoActionCount )
69: SfxUndoManager(nMaxUndoActionCount),
70 mpImpEE(0)
69{
71{
70 pImpEE = p;
71}
72
72}
73
74void EditUndoManager::SetImpEditEngine(ImpEditEngine* pNew)
75{
76 mpImpEE = pNew;
77}
78
73sal_Bool __EXPORT EditUndoManager::Undo()
74{
79sal_Bool __EXPORT EditUndoManager::Undo()
80{
75 if ( GetUndoActionCount() == 0 )
81 if ( !mpImpEE || GetUndoActionCount() == 0 )
76 return sal_False;
77
82 return sal_False;
83
78 DBG_ASSERT( pImpEE->GetActiveView(), "Active View?" );
84 DBG_ASSERT( mpImpEE->GetActiveView(), "Active View?" );
79
85
80 if ( !pImpEE->GetActiveView() )
86 if ( !mpImpEE->GetActiveView() )
81 {
87 {
82 if ( pImpEE->GetEditViews().Count() )
83 pImpEE->SetActiveView( pImpEE->GetEditViews().GetObject(0) );
88 if ( mpImpEE->GetEditViews().Count() )
89 mpImpEE->SetActiveView( mpImpEE->GetEditViews().GetObject(0) );
84 else
85 {
86 DBG_ERROR( "Undo in Engine ohne View nicht moeglich!" );
87 return sal_False;
88 }
89 }
90
90 else
91 {
92 DBG_ERROR( "Undo in Engine ohne View nicht moeglich!" );
93 return sal_False;
94 }
95 }
96
91 pImpEE->GetActiveView()->GetImpEditView()->DrawSelection(); // alte Selektion entfernen
97 mpImpEE->GetActiveView()->GetImpEditView()->DrawSelection(); // alte Selektion entfernen
92
98
93 pImpEE->SetUndoMode( sal_True );
99 mpImpEE->SetUndoMode( sal_True );
94 sal_Bool bDone = SfxUndoManager::Undo();
100 sal_Bool bDone = SfxUndoManager::Undo();
95 pImpEE->SetUndoMode( sal_False );
101 mpImpEE->SetUndoMode( sal_False );
96
102
97 EditSelection aNewSel( pImpEE->GetActiveView()->GetImpEditView()->GetEditSelection() );
103 EditSelection aNewSel( mpImpEE->GetActiveView()->GetImpEditView()->GetEditSelection() );
98 DBG_ASSERT( !aNewSel.IsInvalid(), "Ungueltige Selektion nach Undo()" );
104 DBG_ASSERT( !aNewSel.IsInvalid(), "Ungueltige Selektion nach Undo()" );
99 DBG_ASSERT( !aNewSel.DbgIsBuggy( pImpEE->GetEditDoc() ), "Kaputte Selektion nach Undo()" );
105 DBG_ASSERT( !aNewSel.DbgIsBuggy( mpImpEE->GetEditDoc() ), "Kaputte Selektion nach Undo()" );
100
101 aNewSel.Min() = aNewSel.Max();
106
107 aNewSel.Min() = aNewSel.Max();
102 pImpEE->GetActiveView()->GetImpEditView()->SetEditSelection( aNewSel );
103 pImpEE->FormatAndUpdate( pImpEE->GetActiveView() );
108 mpImpEE->GetActiveView()->GetImpEditView()->SetEditSelection( aNewSel );
109 mpImpEE->FormatAndUpdate( mpImpEE->GetActiveView() );
104
105 return bDone;
106}
107
108sal_Bool __EXPORT EditUndoManager::Redo()
109{
110
111 return bDone;
112}
113
114sal_Bool __EXPORT EditUndoManager::Redo()
115{
110 if ( GetRedoActionCount() == 0 )
116 if ( !mpImpEE || GetRedoActionCount() == 0 )
111 return sal_False;
112
117 return sal_False;
118
113 DBG_ASSERT( pImpEE->GetActiveView(), "Active View?" );
119 DBG_ASSERT( mpImpEE->GetActiveView(), "Active View?" );
114
120
115 if ( !pImpEE->GetActiveView() )
121 if ( !mpImpEE->GetActiveView() )
116 {
122 {
117 if ( pImpEE->GetEditViews().Count() )
118 pImpEE->SetActiveView( pImpEE->GetEditViews().GetObject(0) );
123 if ( mpImpEE->GetEditViews().Count() )
124 mpImpEE->SetActiveView( mpImpEE->GetEditViews().GetObject(0) );
119 else
120 {
121 DBG_ERROR( "Redo in Engine ohne View nicht moeglich!" );
122 return sal_False;
123 }
124 }
125
125 else
126 {
127 DBG_ERROR( "Redo in Engine ohne View nicht moeglich!" );
128 return sal_False;
129 }
130 }
131
126 pImpEE->GetActiveView()->GetImpEditView()->DrawSelection(); // alte Selektion entfernen
132 mpImpEE->GetActiveView()->GetImpEditView()->DrawSelection(); // alte Selektion entfernen
127
133
128 pImpEE->SetUndoMode( sal_True );
134 mpImpEE->SetUndoMode( sal_True );
129 sal_Bool bDone = SfxUndoManager::Redo();
135 sal_Bool bDone = SfxUndoManager::Redo();
130 pImpEE->SetUndoMode( sal_False );
136 mpImpEE->SetUndoMode( sal_False );
131
137
132 EditSelection aNewSel( pImpEE->GetActiveView()->GetImpEditView()->GetEditSelection() );
138 EditSelection aNewSel( mpImpEE->GetActiveView()->GetImpEditView()->GetEditSelection() );
133 DBG_ASSERT( !aNewSel.IsInvalid(), "Ungueltige Selektion nach Undo()" );
139 DBG_ASSERT( !aNewSel.IsInvalid(), "Ungueltige Selektion nach Undo()" );
134 DBG_ASSERT( !aNewSel.DbgIsBuggy( pImpEE->GetEditDoc() ), "Kaputte Selektion nach Redo()" );
140 DBG_ASSERT( !aNewSel.DbgIsBuggy( mpImpEE->GetEditDoc() ), "Kaputte Selektion nach Redo()" );
135
136 aNewSel.Min() = aNewSel.Max();
141
142 aNewSel.Min() = aNewSel.Max();
137 pImpEE->GetActiveView()->GetImpEditView()->SetEditSelection( aNewSel );
138 pImpEE->FormatAndUpdate( pImpEE->GetActiveView() );
143 mpImpEE->GetActiveView()->GetImpEditView()->SetEditSelection( aNewSel );
144 mpImpEE->FormatAndUpdate( mpImpEE->GetActiveView() );
139
140 return bDone;
141}
142
143 // -----------------------------------------------------------------------
144// EditUndo
145// ------------------------------------------------------------------------
146EditUndo::EditUndo( sal_uInt16 nI, ImpEditEngine* p )

--- 600 unchanged lines hidden ---
145
146 return bDone;
147}
148
149 // -----------------------------------------------------------------------
150// EditUndo
151// ------------------------------------------------------------------------
152EditUndo::EditUndo( sal_uInt16 nI, ImpEditEngine* p )

--- 600 unchanged lines hidden ---