196de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
396de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
496de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file
596de5490SAndrew Rist * distributed with this work for additional information
696de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file
796de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the
896de5490SAndrew Rist * "License"); you may not use this file except in compliance
996de5490SAndrew Rist * with the License. You may obtain a copy of the License at
1096de5490SAndrew Rist *
1196de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
1296de5490SAndrew Rist *
1396de5490SAndrew Rist * Unless required by applicable law or agreed to in writing,
1496de5490SAndrew Rist * software distributed under the License is distributed on an
1596de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1696de5490SAndrew Rist * KIND, either express or implied. See the License for the
1796de5490SAndrew Rist * specific language governing permissions and limitations
1896de5490SAndrew Rist * under the License.
1996de5490SAndrew Rist *
2096de5490SAndrew Rist *************************************************************/
2196de5490SAndrew Rist
2296de5490SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25*b63233d8Sdamjan #include "precompiled_dbui.hxx"
26cdf0e10cSrcweir #ifndef DBAUI_TABLEUNDO_HXX
27cdf0e10cSrcweir #include "TableUndo.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _DBU_TBL_HRC_
30cdf0e10cSrcweir #include "dbu_tbl.hrc"
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef DBAUI_TABLEEDITORCONTROL_HXX
33cdf0e10cSrcweir #include "TEditControl.hxx"
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef DBAUI_TABLEROW_HXX
36cdf0e10cSrcweir #include "TableRow.hxx"
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef DBACCESS_UI_BROWSER_ID_HXX
39cdf0e10cSrcweir #include "browserids.hxx"
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef DBUI_TABLECONTROLLER_HXX
42cdf0e10cSrcweir #include "TableController.hxx"
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #ifndef DBAUI_TABLEDESIGNVIEW_HXX
45cdf0e10cSrcweir #include "TableDesignView.hxx"
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #ifndef DBAUI_FIELDDESCRIPTIONS_HXX
48cdf0e10cSrcweir #include "FieldDescriptions.hxx"
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
51cdf0e10cSrcweir #include <tools/debug.hxx>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir
54cdf0e10cSrcweir using namespace dbaui;
55cdf0e10cSrcweir using namespace ::svt;
56cdf0e10cSrcweir
57cdf0e10cSrcweir TYPEINIT1( OCommentUndoAction, SfxUndoAction );
58cdf0e10cSrcweir TYPEINIT1( OTableDesignUndoAct, OCommentUndoAction );
59cdf0e10cSrcweir TYPEINIT1( OTableEditorUndoAct, OTableDesignUndoAct );
60cdf0e10cSrcweir TYPEINIT1( OTableDesignCellUndoAct, OTableDesignUndoAct );
61cdf0e10cSrcweir TYPEINIT1( OTableEditorTypeSelUndoAct, OTableEditorUndoAct );
62cdf0e10cSrcweir TYPEINIT1( OTableEditorDelUndoAct, OTableEditorUndoAct );
63cdf0e10cSrcweir TYPEINIT1( OTableEditorInsUndoAct, OTableEditorUndoAct );
64cdf0e10cSrcweir TYPEINIT1( OTableEditorInsNewUndoAct, OTableEditorUndoAct );
65cdf0e10cSrcweir TYPEINIT1( OPrimKeyUndoAct, OTableEditorUndoAct );
66cdf0e10cSrcweir
67cdf0e10cSrcweir //==============================================================================
68cdf0e10cSrcweir // class OTableDesignUndoAct
69cdf0e10cSrcweir //==============================================================================
70cdf0e10cSrcweir DBG_NAME(OTableDesignUndoAct);
OTableDesignUndoAct(OTableRowView * pOwner,sal_uInt16 nCommentID)71cdf0e10cSrcweir OTableDesignUndoAct::OTableDesignUndoAct( OTableRowView* pOwner,sal_uInt16 nCommentID ) : OCommentUndoAction(nCommentID)
72cdf0e10cSrcweir ,m_pTabDgnCtrl( pOwner )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir DBG_CTOR(OTableDesignUndoAct,NULL);
75cdf0e10cSrcweir m_pTabDgnCtrl->m_nCurUndoActId++;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
78cdf0e10cSrcweir //-------------------------------------------------------------------------
~OTableDesignUndoAct()79cdf0e10cSrcweir OTableDesignUndoAct::~OTableDesignUndoAct()
80cdf0e10cSrcweir {
81cdf0e10cSrcweir DBG_DTOR(OTableDesignUndoAct,NULL);
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
84cdf0e10cSrcweir //-------------------------------------------------------------------------
Undo()85cdf0e10cSrcweir void OTableDesignUndoAct::Undo()
86cdf0e10cSrcweir {
87cdf0e10cSrcweir m_pTabDgnCtrl->m_nCurUndoActId--;
88cdf0e10cSrcweir
89cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
90cdf0e10cSrcweir // Wenn erstes Undo zurueckgenommen wurde, ist Doc nicht modifiziert worden
91cdf0e10cSrcweir if( m_pTabDgnCtrl->m_nCurUndoActId == 0 )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir m_pTabDgnCtrl->GetView()->getController().setModified(sal_False);
94cdf0e10cSrcweir m_pTabDgnCtrl->GetView()->getController().InvalidateFeature(SID_SAVEDOC);
95cdf0e10cSrcweir }
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
98cdf0e10cSrcweir //-------------------------------------------------------------------------
Redo()99cdf0e10cSrcweir void OTableDesignUndoAct::Redo()
100cdf0e10cSrcweir {
101cdf0e10cSrcweir m_pTabDgnCtrl->m_nCurUndoActId++;
102cdf0e10cSrcweir
103cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
104cdf0e10cSrcweir // Wenn Redo fuer erste Undo-Action, muss Modified-Flag wieder gesetzt werden
105cdf0e10cSrcweir if( m_pTabDgnCtrl->m_nCurUndoActId > 0 )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir m_pTabDgnCtrl->GetView()->getController().setModified(sal_True);
108cdf0e10cSrcweir m_pTabDgnCtrl->GetView()->getController().InvalidateFeature(SID_SAVEDOC);
109cdf0e10cSrcweir }
110cdf0e10cSrcweir }
111cdf0e10cSrcweir //==============================================================================
112cdf0e10cSrcweir // class OTableDesignCellUndoAct
113cdf0e10cSrcweir //==============================================================================
114cdf0e10cSrcweir DBG_NAME(OTableDesignCellUndoAct);
OTableDesignCellUndoAct(OTableRowView * pOwner,long nRowID,sal_uInt16 nColumn)115cdf0e10cSrcweir OTableDesignCellUndoAct::OTableDesignCellUndoAct( OTableRowView* pOwner, long nRowID, sal_uInt16 nColumn ) :
116cdf0e10cSrcweir OTableDesignUndoAct( pOwner ,STR_TABED_UNDO_CELLMODIFIED)
117cdf0e10cSrcweir ,m_nCol( nColumn )
118cdf0e10cSrcweir ,m_nRow( nRowID )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir DBG_CTOR(OTableDesignCellUndoAct,NULL);
121cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
122cdf0e10cSrcweir // Text an der Position (m_nRow, m_nCol) auslesen
123cdf0e10cSrcweir m_sOldText = m_pTabDgnCtrl->GetCellData( m_nRow, m_nCol );
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir //-------------------------------------------------------------------------
~OTableDesignCellUndoAct()127cdf0e10cSrcweir OTableDesignCellUndoAct::~OTableDesignCellUndoAct()
128cdf0e10cSrcweir {
129cdf0e10cSrcweir DBG_DTOR(OTableDesignCellUndoAct,NULL);
130cdf0e10cSrcweir }
131cdf0e10cSrcweir
132cdf0e10cSrcweir //-------------------------------------------------------------------------
Undo()133cdf0e10cSrcweir void OTableDesignCellUndoAct::Undo()
134cdf0e10cSrcweir {
135cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
136cdf0e10cSrcweir // Neuen Text der alten Zelle speichern und alten wieder einsetzen
137cdf0e10cSrcweir m_pTabDgnCtrl->ActivateCell( m_nRow, m_nCol );
138cdf0e10cSrcweir m_sNewText = m_pTabDgnCtrl->GetCellData( m_nRow, m_nCol );
139cdf0e10cSrcweir m_pTabDgnCtrl->SetCellData( m_nRow, m_nCol, m_sOldText );
140cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
141cdf0e10cSrcweir // Wenn erstes Undo zurueckgenommen wurde, ist Zelle nicht mehr modifiziert
142cdf0e10cSrcweir if (m_pTabDgnCtrl->GetCurUndoActId() == 1)
143cdf0e10cSrcweir {
144cdf0e10cSrcweir CellControllerRef xController = m_pTabDgnCtrl->Controller();
145cdf0e10cSrcweir if ( xController.Is() )
146cdf0e10cSrcweir xController->ClearModified();
147cdf0e10cSrcweir m_pTabDgnCtrl->GetView()->getController().setModified(sal_False);
148cdf0e10cSrcweir
149cdf0e10cSrcweir }
150cdf0e10cSrcweir
151cdf0e10cSrcweir OTableDesignUndoAct::Undo();
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
154cdf0e10cSrcweir //-------------------------------------------------------------------------
Redo()155cdf0e10cSrcweir void OTableDesignCellUndoAct::Redo()
156cdf0e10cSrcweir {
157cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
158cdf0e10cSrcweir // Neuen Text wieder einseten
159cdf0e10cSrcweir m_pTabDgnCtrl->ActivateCell( m_nRow, m_nCol );
160cdf0e10cSrcweir m_pTabDgnCtrl->SetCellData( m_nRow, m_nCol, m_sNewText );
161cdf0e10cSrcweir
162cdf0e10cSrcweir OTableDesignUndoAct::Redo();
163cdf0e10cSrcweir }
164cdf0e10cSrcweir
165cdf0e10cSrcweir //==============================================================================
166cdf0e10cSrcweir // class OTableEditorUndoAct
167cdf0e10cSrcweir //==============================================================================
168cdf0e10cSrcweir DBG_NAME(OTableEditorUndoAct);
OTableEditorUndoAct(OTableEditorCtrl * pOwner,sal_uInt16 _nCommentID)169cdf0e10cSrcweir OTableEditorUndoAct::OTableEditorUndoAct( OTableEditorCtrl* pOwner,sal_uInt16 _nCommentID ) :
170cdf0e10cSrcweir OTableDesignUndoAct( pOwner ,_nCommentID)
171cdf0e10cSrcweir ,pTabEdCtrl(pOwner)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir DBG_CTOR(OTableEditorUndoAct,NULL);
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir //-------------------------------------------------------------------------
~OTableEditorUndoAct()177cdf0e10cSrcweir OTableEditorUndoAct::~OTableEditorUndoAct()
178cdf0e10cSrcweir {
179cdf0e10cSrcweir DBG_DTOR(OTableEditorUndoAct,NULL);
180cdf0e10cSrcweir }
181cdf0e10cSrcweir
182cdf0e10cSrcweir //==============================================================================
183cdf0e10cSrcweir // class OTableEditorTypeSelUndoAct
184cdf0e10cSrcweir //==============================================================================
185cdf0e10cSrcweir DBG_NAME(OTableEditorTypeSelUndoAct);
OTableEditorTypeSelUndoAct(OTableEditorCtrl * pOwner,long nRowID,sal_uInt16 nColumn,const TOTypeInfoSP & _pOldType)186cdf0e10cSrcweir OTableEditorTypeSelUndoAct::OTableEditorTypeSelUndoAct( OTableEditorCtrl* pOwner, long nRowID, sal_uInt16 nColumn, const TOTypeInfoSP& _pOldType )
187cdf0e10cSrcweir :OTableEditorUndoAct( pOwner ,STR_TABED_UNDO_TYPE_CHANGED)
188cdf0e10cSrcweir ,m_nCol( nColumn )
189cdf0e10cSrcweir ,m_nRow( nRowID )
190cdf0e10cSrcweir ,m_pOldType( _pOldType )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir DBG_CTOR(OTableEditorTypeSelUndoAct,NULL);
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
195cdf0e10cSrcweir //-------------------------------------------------------------------------
~OTableEditorTypeSelUndoAct()196cdf0e10cSrcweir OTableEditorTypeSelUndoAct::~OTableEditorTypeSelUndoAct()
197cdf0e10cSrcweir {
198cdf0e10cSrcweir DBG_DTOR(OTableEditorTypeSelUndoAct,NULL);
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
201cdf0e10cSrcweir //-------------------------------------------------------------------------
Undo()202cdf0e10cSrcweir void OTableEditorTypeSelUndoAct::Undo()
203cdf0e10cSrcweir {
204cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
205cdf0e10cSrcweir // Typ zuruecksetzen
206cdf0e10cSrcweir OFieldDescription* pFieldDesc = pTabEdCtrl->GetFieldDescr(m_nRow);
207cdf0e10cSrcweir if(pFieldDesc)
208cdf0e10cSrcweir m_pNewType = pFieldDesc->getTypeInfo();
209cdf0e10cSrcweir else
210cdf0e10cSrcweir m_pNewType = TOTypeInfoSP();
211cdf0e10cSrcweir pTabEdCtrl->SetCellData(m_nRow,m_nCol,m_pOldType);
212cdf0e10cSrcweir pTabEdCtrl->SwitchType( m_pOldType );
213cdf0e10cSrcweir
214cdf0e10cSrcweir OTableEditorUndoAct::Undo();
215cdf0e10cSrcweir }
216cdf0e10cSrcweir
217cdf0e10cSrcweir //-------------------------------------------------------------------------
Redo()218cdf0e10cSrcweir void OTableEditorTypeSelUndoAct::Redo()
219cdf0e10cSrcweir {
220cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
221cdf0e10cSrcweir // Neuen Typ
222cdf0e10cSrcweir pTabEdCtrl->GoToRowColumnId( m_nRow ,m_nCol);
223cdf0e10cSrcweir pTabEdCtrl->SetCellData(m_nRow,m_nCol,m_pNewType);
224cdf0e10cSrcweir
225cdf0e10cSrcweir OTableEditorUndoAct::Redo();
226cdf0e10cSrcweir }
227cdf0e10cSrcweir
228cdf0e10cSrcweir //==============================================================================
229cdf0e10cSrcweir // class OTableEditorDelUndoAct
230cdf0e10cSrcweir //==============================================================================
231cdf0e10cSrcweir DBG_NAME(OTableEditorDelUndoAct);
OTableEditorDelUndoAct(OTableEditorCtrl * pOwner)232cdf0e10cSrcweir OTableEditorDelUndoAct::OTableEditorDelUndoAct( OTableEditorCtrl* pOwner) :
233cdf0e10cSrcweir OTableEditorUndoAct( pOwner ,STR_TABED_UNDO_ROWDELETED)
234cdf0e10cSrcweir {
235cdf0e10cSrcweir DBG_CTOR(OTableEditorDelUndoAct,NULL);
236cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
237cdf0e10cSrcweir // DeletedRowList fuellen
238cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pOwner->GetRowList();
239cdf0e10cSrcweir long nIndex = pOwner->FirstSelectedRow();
240cdf0e10cSrcweir ::boost::shared_ptr<OTableRow> pOriginalRow;
241cdf0e10cSrcweir ::boost::shared_ptr<OTableRow> pNewRow;
242cdf0e10cSrcweir
243cdf0e10cSrcweir while( nIndex >= 0 )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir pOriginalRow = (*pOriginalRows)[nIndex];
246cdf0e10cSrcweir pNewRow.reset(new OTableRow( *pOriginalRow, nIndex ));
247cdf0e10cSrcweir m_aDeletedRows.push_back( pNewRow);
248cdf0e10cSrcweir
249cdf0e10cSrcweir nIndex = pOwner->NextSelectedRow();
250cdf0e10cSrcweir }
251cdf0e10cSrcweir }
252cdf0e10cSrcweir
253cdf0e10cSrcweir //-------------------------------------------------------------------------
~OTableEditorDelUndoAct()254cdf0e10cSrcweir OTableEditorDelUndoAct::~OTableEditorDelUndoAct()
255cdf0e10cSrcweir {
256cdf0e10cSrcweir DBG_DTOR(OTableEditorDelUndoAct,NULL);
257cdf0e10cSrcweir m_aDeletedRows.clear();
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
260cdf0e10cSrcweir //-------------------------------------------------------------------------
Undo()261cdf0e10cSrcweir void OTableEditorDelUndoAct::Undo()
262cdf0e10cSrcweir {
263cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
264cdf0e10cSrcweir // Geloeschte Zeilen wieder einfuegen
265cdf0e10cSrcweir sal_uLong nPos;
266cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_aDeletedRows.begin();
267cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_aDeletedRows.end();
268cdf0e10cSrcweir
269cdf0e10cSrcweir ::boost::shared_ptr<OTableRow> pNewOrigRow;
270cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList();
271cdf0e10cSrcweir
272cdf0e10cSrcweir for(;aIter != aEnd;++aIter)
273cdf0e10cSrcweir {
274cdf0e10cSrcweir pNewOrigRow.reset(new OTableRow( **aIter ));
275cdf0e10cSrcweir nPos = (*aIter)->GetPos();
276cdf0e10cSrcweir pOriginalRows->insert( pOriginalRows->begin()+nPos,pNewOrigRow);
277cdf0e10cSrcweir }
278cdf0e10cSrcweir
279cdf0e10cSrcweir pTabEdCtrl->DisplayData(pTabEdCtrl->GetCurRow());
280cdf0e10cSrcweir pTabEdCtrl->Invalidate();
281cdf0e10cSrcweir OTableEditorUndoAct::Undo();
282cdf0e10cSrcweir }
283cdf0e10cSrcweir
284cdf0e10cSrcweir //-------------------------------------------------------------------------
Redo()285cdf0e10cSrcweir void OTableEditorDelUndoAct::Redo()
286cdf0e10cSrcweir {
287cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
288cdf0e10cSrcweir // Zeilen wieder loeschen
289cdf0e10cSrcweir sal_uLong nPos;
290cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_aDeletedRows.begin();
291cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_aDeletedRows.end();
292cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList();
293cdf0e10cSrcweir
294cdf0e10cSrcweir for(;aIter != aEnd;++aIter)
295cdf0e10cSrcweir {
296cdf0e10cSrcweir nPos = (*aIter)->GetPos();
297cdf0e10cSrcweir pOriginalRows->erase( pOriginalRows->begin()+nPos );
298cdf0e10cSrcweir }
299cdf0e10cSrcweir
300cdf0e10cSrcweir pTabEdCtrl->DisplayData(pTabEdCtrl->GetCurRow());
301cdf0e10cSrcweir pTabEdCtrl->Invalidate();
302cdf0e10cSrcweir OTableEditorUndoAct::Redo();
303cdf0e10cSrcweir }
304cdf0e10cSrcweir
305cdf0e10cSrcweir //-------------------------------------------------------------------------
306cdf0e10cSrcweir //==============================================================================
307cdf0e10cSrcweir // class OTableEditorInsUndoAct
308cdf0e10cSrcweir //==============================================================================
309cdf0e10cSrcweir DBG_NAME(OTableEditorInsUndoAct);
OTableEditorInsUndoAct(OTableEditorCtrl * pOwner,long nInsertPosition,const::std::vector<::boost::shared_ptr<OTableRow>> & _vInsertedRows)310cdf0e10cSrcweir OTableEditorInsUndoAct::OTableEditorInsUndoAct( OTableEditorCtrl* pOwner,
311cdf0e10cSrcweir long nInsertPosition ,
312cdf0e10cSrcweir const ::std::vector< ::boost::shared_ptr<OTableRow> >& _vInsertedRows)
313cdf0e10cSrcweir :OTableEditorUndoAct( pOwner,STR_TABED_UNDO_ROWINSERTED )
314cdf0e10cSrcweir ,m_vInsertedRows(_vInsertedRows)
315cdf0e10cSrcweir ,m_nInsPos( nInsertPosition )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir DBG_CTOR(OTableEditorInsUndoAct,NULL);
318cdf0e10cSrcweir }
319cdf0e10cSrcweir
320cdf0e10cSrcweir //-------------------------------------------------------------------------
~OTableEditorInsUndoAct()321cdf0e10cSrcweir OTableEditorInsUndoAct::~OTableEditorInsUndoAct()
322cdf0e10cSrcweir {
323cdf0e10cSrcweir DBG_DTOR(OTableEditorInsUndoAct,NULL);
324cdf0e10cSrcweir m_vInsertedRows.clear();
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
327cdf0e10cSrcweir //-------------------------------------------------------------------------
Undo()328cdf0e10cSrcweir void OTableEditorInsUndoAct::Undo()
329cdf0e10cSrcweir {
330cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
331cdf0e10cSrcweir // Eingefuegte Zeilen wieder loeschen
332cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList();
333cdf0e10cSrcweir for( long i=(m_nInsPos+m_vInsertedRows.size()-1); i>(m_nInsPos-1); i-- )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir pOriginalRows->erase(pOriginalRows->begin()+i);
336cdf0e10cSrcweir }
337cdf0e10cSrcweir
338cdf0e10cSrcweir pTabEdCtrl->RowRemoved( m_nInsPos, m_vInsertedRows.size(), sal_True );
339cdf0e10cSrcweir pTabEdCtrl->InvalidateHandleColumn();
340cdf0e10cSrcweir
341cdf0e10cSrcweir OTableEditorUndoAct::Undo();
342cdf0e10cSrcweir }
343cdf0e10cSrcweir
344cdf0e10cSrcweir //-------------------------------------------------------------------------
Redo()345cdf0e10cSrcweir void OTableEditorInsUndoAct::Redo()
346cdf0e10cSrcweir {
347cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
348cdf0e10cSrcweir // Zeilen wieder einfuegen
349cdf0e10cSrcweir long nInsertRow = m_nInsPos;
350cdf0e10cSrcweir ::boost::shared_ptr<OTableRow> pRow;
351cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vInsertedRows.begin();
352cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_vInsertedRows.end();
353cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList();
354cdf0e10cSrcweir for(;aIter != aEnd;++aIter)
355cdf0e10cSrcweir {
356cdf0e10cSrcweir pRow.reset(new OTableRow( **aIter ));
357cdf0e10cSrcweir pRowList->insert( pRowList->begin()+nInsertRow ,pRow );
358cdf0e10cSrcweir nInsertRow++;
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
361cdf0e10cSrcweir pTabEdCtrl->RowInserted( m_nInsPos, m_vInsertedRows.size(), sal_True );
362cdf0e10cSrcweir pTabEdCtrl->InvalidateHandleColumn();
363cdf0e10cSrcweir
364cdf0e10cSrcweir OTableEditorUndoAct::Redo();
365cdf0e10cSrcweir }
366cdf0e10cSrcweir
367cdf0e10cSrcweir //==============================================================================
368cdf0e10cSrcweir // class OTableEditorInsNewUndoAct
369cdf0e10cSrcweir //==============================================================================
370cdf0e10cSrcweir DBG_NAME(OTableEditorInsNewUndoAct);
OTableEditorInsNewUndoAct(OTableEditorCtrl * pOwner,long nInsertPosition,long nInsertedRows)371cdf0e10cSrcweir OTableEditorInsNewUndoAct::OTableEditorInsNewUndoAct( OTableEditorCtrl* pOwner, long nInsertPosition, long nInsertedRows ) :
372cdf0e10cSrcweir OTableEditorUndoAct( pOwner ,STR_TABED_UNDO_NEWROWINSERTED)
373cdf0e10cSrcweir ,m_nInsPos( nInsertPosition )
374cdf0e10cSrcweir ,m_nInsRows( nInsertedRows )
375cdf0e10cSrcweir {
376cdf0e10cSrcweir DBG_CTOR(OTableEditorInsNewUndoAct,NULL);
377cdf0e10cSrcweir }
378cdf0e10cSrcweir
379cdf0e10cSrcweir //-------------------------------------------------------------------------
~OTableEditorInsNewUndoAct()380cdf0e10cSrcweir OTableEditorInsNewUndoAct::~OTableEditorInsNewUndoAct()
381cdf0e10cSrcweir {
382cdf0e10cSrcweir DBG_DTOR(OTableEditorInsNewUndoAct,NULL);
383cdf0e10cSrcweir }
384cdf0e10cSrcweir
385cdf0e10cSrcweir //-------------------------------------------------------------------------
Undo()386cdf0e10cSrcweir void OTableEditorInsNewUndoAct::Undo()
387cdf0e10cSrcweir {
388cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
389cdf0e10cSrcweir // Eingefuegte Zeilen wieder loeschen
390cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList();
391cdf0e10cSrcweir
392cdf0e10cSrcweir for( long i=(m_nInsPos+m_nInsRows-1); i>(m_nInsPos-1); i-- )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir pOriginalRows->erase(pOriginalRows->begin()+i);
395cdf0e10cSrcweir }
396cdf0e10cSrcweir
397cdf0e10cSrcweir pTabEdCtrl->RowRemoved( m_nInsPos, m_nInsRows, sal_True );
398cdf0e10cSrcweir pTabEdCtrl->InvalidateHandleColumn();
399cdf0e10cSrcweir
400cdf0e10cSrcweir OTableEditorUndoAct::Undo();
401cdf0e10cSrcweir }
402cdf0e10cSrcweir
403cdf0e10cSrcweir //-------------------------------------------------------------------------
Redo()404cdf0e10cSrcweir void OTableEditorInsNewUndoAct::Redo()
405cdf0e10cSrcweir {
406cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
407cdf0e10cSrcweir // Zeilen wieder einfuegen
408cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList();
409cdf0e10cSrcweir
410cdf0e10cSrcweir for( long i=m_nInsPos; i<(m_nInsPos+m_nInsRows); i++ )
411cdf0e10cSrcweir pRowList->insert( pRowList->begin()+i,::boost::shared_ptr<OTableRow>(new OTableRow()) );
412cdf0e10cSrcweir
413cdf0e10cSrcweir pTabEdCtrl->RowInserted( m_nInsPos, m_nInsRows, sal_True );
414cdf0e10cSrcweir pTabEdCtrl->InvalidateHandleColumn();
415cdf0e10cSrcweir
416cdf0e10cSrcweir OTableEditorUndoAct::Redo();
417cdf0e10cSrcweir }
418cdf0e10cSrcweir
419cdf0e10cSrcweir //-------------------------------------------------------------------------
420cdf0e10cSrcweir //========================================================================
421cdf0e10cSrcweir // class OPrimKeyUndoAct
422cdf0e10cSrcweir //========================================================================
423cdf0e10cSrcweir DBG_NAME(OPrimKeyUndoAct);
424cdf0e10cSrcweir //-------------------------------------------------------------------------
OPrimKeyUndoAct(OTableEditorCtrl * pOwner,MultiSelection aDeletedKeys,MultiSelection aInsertedKeys)425cdf0e10cSrcweir OPrimKeyUndoAct::OPrimKeyUndoAct( OTableEditorCtrl* pOwner, MultiSelection aDeletedKeys, MultiSelection aInsertedKeys) :
426cdf0e10cSrcweir OTableEditorUndoAct( pOwner ,STR_TABLEDESIGN_UNDO_PRIMKEY)
427cdf0e10cSrcweir ,m_aDelKeys( aDeletedKeys )
428cdf0e10cSrcweir ,m_aInsKeys( aInsertedKeys )
429cdf0e10cSrcweir ,m_pEditorCtrl( pOwner )
430cdf0e10cSrcweir {
431cdf0e10cSrcweir DBG_CTOR(OPrimKeyUndoAct,NULL);
432cdf0e10cSrcweir }
433cdf0e10cSrcweir
434cdf0e10cSrcweir //-------------------------------------------------------------------------
~OPrimKeyUndoAct()435cdf0e10cSrcweir OPrimKeyUndoAct::~OPrimKeyUndoAct()
436cdf0e10cSrcweir {
437cdf0e10cSrcweir DBG_DTOR(OPrimKeyUndoAct,NULL);
438cdf0e10cSrcweir }
439cdf0e10cSrcweir
440cdf0e10cSrcweir //-------------------------------------------------------------------------
Undo()441cdf0e10cSrcweir void OPrimKeyUndoAct::Undo()
442cdf0e10cSrcweir {
443cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList();
444cdf0e10cSrcweir ::boost::shared_ptr<OTableRow> pRow;
445cdf0e10cSrcweir long nIndex;
446cdf0e10cSrcweir
447cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
448cdf0e10cSrcweir // Die eingefuegten Keys loeschen
449cdf0e10cSrcweir for( nIndex = m_aInsKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aInsKeys.NextSelected() )
450cdf0e10cSrcweir {
451cdf0e10cSrcweir OSL_ENSURE(nIndex <= static_cast<long>(pRowList->size()),"Index for undo isn't valid!");
452cdf0e10cSrcweir pRow = (*pRowList)[nIndex];
453cdf0e10cSrcweir pRow->SetPrimaryKey( sal_False );
454cdf0e10cSrcweir }
455cdf0e10cSrcweir
456cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
457cdf0e10cSrcweir // Die geloeschten Keys herstellen
458cdf0e10cSrcweir for( nIndex = m_aDelKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aDelKeys.NextSelected() )
459cdf0e10cSrcweir {
460cdf0e10cSrcweir OSL_ENSURE(nIndex <= static_cast<long>(pRowList->size()),"Index for undo isn't valid!");
461cdf0e10cSrcweir pRow = (*pRowList)[nIndex];
462cdf0e10cSrcweir pRow->SetPrimaryKey( sal_True );
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
465cdf0e10cSrcweir m_pEditorCtrl->InvalidateHandleColumn();
466cdf0e10cSrcweir OTableEditorUndoAct::Undo();
467cdf0e10cSrcweir }
468cdf0e10cSrcweir
469cdf0e10cSrcweir //-------------------------------------------------------------------------
Redo()470cdf0e10cSrcweir void OPrimKeyUndoAct::Redo()
471cdf0e10cSrcweir {
472cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList();
473cdf0e10cSrcweir long nIndex;
474cdf0e10cSrcweir
475cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
476cdf0e10cSrcweir // Die geloeschten Keys loeschen
477cdf0e10cSrcweir for( nIndex = m_aDelKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aDelKeys.NextSelected() )
478cdf0e10cSrcweir (*pRowList)[nIndex]->SetPrimaryKey( sal_False );
479cdf0e10cSrcweir
480cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
481cdf0e10cSrcweir // Die eingefuegten Keys herstellen
482cdf0e10cSrcweir for( nIndex = m_aInsKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aInsKeys.NextSelected() )
483cdf0e10cSrcweir (*pRowList)[nIndex]->SetPrimaryKey( sal_True );
484cdf0e10cSrcweir
485cdf0e10cSrcweir m_pEditorCtrl->InvalidateHandleColumn();
486cdf0e10cSrcweir OTableEditorUndoAct::Redo();
487cdf0e10cSrcweir }
488cdf0e10cSrcweir
489cdf0e10cSrcweir
490cdf0e10cSrcweir
491cdf0e10cSrcweir
492