LCOV - code coverage report
Current view: top level - dbaccess/source/ui/tabledesign - TableUndo.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 188 0.0 %
Date: 2012-08-25 Functions: 0 83 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 240 0.0 %

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

Generated by: LCOV version 1.10