LCOV - code coverage report
Current view: top level - dbaccess/source/ui/querydesign - QueryTabWinUndoAct.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 49 2.0 %
Date: 2015-06-13 12:38:46 Functions: 2 11 18.2 %
Legend: Lines: hit not hit

          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 "QueryTabWinUndoAct.hxx"
      21             : #include <osl/diagnose.h>
      22             : #include "QTableWindow.hxx"
      23             : #include "QTableWindowData.hxx"
      24             : #include "TableConnection.hxx"
      25             : #include "TableConnectionData.hxx"
      26             : #include "QueryDesignFieldUndoAct.hxx"
      27             : #include "QueryTableView.hxx"
      28             : 
      29             : using namespace dbaui;
      30           0 : OQueryDesignFieldUndoAct::OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID)
      31             :     : OCommentUndoAction(nCommentID)
      32             :     , pOwner(pSelBrwBox)
      33           0 :     , m_nColumnPostion(BROWSER_INVALIDID)
      34             : {
      35           0 : }
      36             : 
      37           0 : OQueryDesignFieldUndoAct::~OQueryDesignFieldUndoAct()
      38             : {
      39           0 :     pOwner = NULL;
      40           0 : }
      41             : 
      42           0 : OQueryTabWinUndoAct::OQueryTabWinUndoAct(OQueryTableView* pOwner, sal_uInt16 nCommentID)
      43             :     : OQueryDesignUndoAction(pOwner, nCommentID)
      44             :     , m_pTabWin(NULL)
      45           0 :     , m_bOwnerOfObjects(false)
      46             : {
      47           0 : }
      48             : 
      49           0 : OQueryTabWinUndoAct::~OQueryTabWinUndoAct()
      50             : {
      51           0 :     if (m_bOwnerOfObjects)
      52             :     {
      53             :         // I should take care to delete the window if I am the only owner
      54             :         OSL_ENSURE(m_pTabWin != nullptr, "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : m_pTabWin sollte nicht NULL sein");
      55             :         OSL_ENSURE(!m_pTabWin->IsVisible(), "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : *m_pTabWin sollte nicht sichtbar sein");
      56             : 
      57           0 :         if ( m_pTabWin )
      58           0 :             m_pTabWin->clearListBox();
      59           0 :         m_pTabWin.disposeAndClear();
      60             : 
      61             :         // and of course the corresponding connections
      62           0 :         auto aIter = m_vTableConnection.begin();
      63           0 :         auto aEnd = m_vTableConnection.end();
      64           0 :         for(;aIter != aEnd;++aIter)
      65             :         {
      66           0 :             m_pOwner->DeselectConn(*aIter);
      67           0 :             aIter->disposeAndClear();
      68             :         }
      69           0 :         m_vTableConnection.clear();
      70             :     }
      71           0 : }
      72             : 
      73           0 : void OTabFieldCellModifiedUndoAct::Undo()
      74             : {
      75           0 :     pOwner->EnterUndoMode();
      76             :     OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
      77             :     OSL_ENSURE(m_nColumnPostion < pOwner->GetColumnCount(),"Position outside the column count!");
      78           0 :     if ( m_nColumnPostion != BROWSER_INVALIDID )
      79             :     {
      80           0 :         sal_uInt16 nColumnId = pOwner->GetColumnId(m_nColumnPostion);
      81           0 :         OUString strNext = pOwner->GetCellContents(m_nCellIndex, nColumnId);
      82           0 :         pOwner->SetCellContents(m_nCellIndex, nColumnId, m_strNextCellContents);
      83           0 :         m_strNextCellContents = strNext;
      84             :     }
      85           0 :     pOwner->LeaveUndoMode();
      86           0 : }
      87             : 
      88           0 : void OTabFieldSizedUndoAct::Undo()
      89             : {
      90           0 :     pOwner->EnterUndoMode();
      91             :     OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
      92           0 :     if ( m_nColumnPostion != BROWSER_INVALIDID )
      93             :     {
      94           0 :         sal_uInt16 nColumnId = pOwner->GetColumnId(m_nColumnPostion);
      95           0 :         long nNextWidth = pOwner->GetColumnWidth(nColumnId);
      96           0 :         pOwner->SetColWidth(nColumnId, m_nNextWidth);
      97           0 :         m_nNextWidth = nNextWidth;
      98             :     }
      99           0 :     pOwner->LeaveUndoMode();
     100           0 : }
     101             : 
     102           0 : void OTabFieldMovedUndoAct::Undo()
     103             : {
     104           0 :     pOwner->EnterUndoMode();
     105             :     OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
     106           0 :     if ( m_nColumnPostion != BROWSER_INVALIDID )
     107             :     {
     108           0 :         sal_uInt16 nId = pDescr->GetColumnId();
     109           0 :         sal_uInt16 nOldPos = pOwner->GetColumnPos(nId);
     110           0 :         pOwner->SetColumnPos(nId,m_nColumnPostion);
     111           0 :         pOwner->ColumnMoved(nId,false);
     112           0 :         m_nColumnPostion = nOldPos;
     113             :     }
     114           0 :     pOwner->LeaveUndoMode();
     115          36 : }
     116             : 
     117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11