LCOV - code coverage report
Current view: top level - sc/source/ui/undo - undorangename.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 15 65 23.1 %
Date: 2014-04-11 Functions: 2 17 11.8 %
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             : 
      10             : 
      11             : #include "undorangename.hxx"
      12             : #include "globstr.hrc"
      13             : #include "global.hxx"
      14             : #include "docfunc.hxx"
      15             : #include "sc.hrc"
      16             : 
      17             : #include "sfx2/app.hxx"
      18             : 
      19             : #include <memory>
      20             : 
      21             : using ::std::auto_ptr;
      22             : 
      23           1 : ScUndoAllRangeNames::ScUndoAllRangeNames(
      24             :     ScDocShell* pDocSh,
      25             :     const std::map<OUString, ScRangeName*>& rOldNames,
      26             :     const boost::ptr_map<OUString, ScRangeName>& rNewNames) :
      27           1 :     ScSimpleUndo(pDocSh)
      28             : {
      29           1 :     std::map<OUString, ScRangeName*>::const_iterator itr, itrEnd;
      30           3 :     for (itr = rOldNames.begin(), itrEnd = rOldNames.end(); itr != itrEnd; ++itr)
      31             :     {
      32             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
      33           2 :         auto_ptr<ScRangeName> p(new ScRangeName(*itr->second));
      34             :         SAL_WNODEPRECATED_DECLARATIONS_POP
      35           2 :         maOldNames.insert(itr->first, p);
      36           2 :     }
      37             : 
      38           1 :     boost::ptr_map<OUString, ScRangeName>::const_iterator it, itEnd;
      39           2 :     for (it = rNewNames.begin(), itEnd = rNewNames.end(); it != itEnd; ++it)
      40             :     {
      41             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
      42           1 :         auto_ptr<ScRangeName> p(new ScRangeName(*it->second));
      43             :         SAL_WNODEPRECATED_DECLARATIONS_POP
      44           1 :         maNewNames.insert(it->first, p);
      45           1 :     }
      46           1 : }
      47             : 
      48           0 : ScUndoAllRangeNames::~ScUndoAllRangeNames()
      49             : {
      50           0 : }
      51             : 
      52           0 : void ScUndoAllRangeNames::Undo()
      53             : {
      54           0 :     DoChange(maOldNames);
      55           0 : }
      56             : 
      57           0 : void ScUndoAllRangeNames::Redo()
      58             : {
      59           0 :     DoChange(maNewNames);
      60           0 : }
      61             : 
      62           0 : void ScUndoAllRangeNames::Repeat(SfxRepeatTarget& /*rTarget*/)
      63             : {
      64           0 : }
      65             : 
      66           0 : bool ScUndoAllRangeNames::CanRepeat(SfxRepeatTarget& /*rTarget*/) const
      67             : {
      68           0 :     return false;
      69             : }
      70             : 
      71           1 : OUString ScUndoAllRangeNames::GetComment() const
      72             : {
      73           1 :     return ScGlobal::GetRscString(STR_UNDO_RANGENAMES);
      74             : }
      75             : 
      76           0 : void ScUndoAllRangeNames::DoChange(const boost::ptr_map<OUString, ScRangeName>& rNames)
      77             : {
      78           0 :     ScDocument& rDoc = *pDocShell->GetDocument();
      79             : 
      80           0 :     rDoc.PreprocessRangeNameUpdate();
      81           0 :     rDoc.SetAllRangeNames(rNames);
      82           0 :     rDoc.PostprocessRangeNameUpdate();
      83             : 
      84           0 :     SFX_APP()->Broadcast(SfxSimpleHint(SC_HINT_AREAS_CHANGED));
      85           0 : }
      86             : 
      87           0 : ScUndoAddRangeData::ScUndoAddRangeData(ScDocShell* pDocSh, ScRangeData* pRangeData, SCTAB nTab) :
      88             :     ScSimpleUndo(pDocSh),
      89           0 :     mpRangeData(new ScRangeData(*pRangeData)),
      90           0 :     mnTab(nTab)
      91             : {
      92             : 
      93           0 : }
      94             : 
      95           0 : ScUndoAddRangeData::~ScUndoAddRangeData()
      96             : {
      97           0 :     delete mpRangeData;
      98           0 : }
      99             : 
     100           0 : void ScUndoAddRangeData::Undo()
     101             : {
     102           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     103           0 :     ScRangeName* pRangeName = NULL;
     104           0 :     if (mnTab == -1)
     105             :     {
     106           0 :         pRangeName = pDoc->GetRangeName();
     107             :     }
     108             :     else
     109             :     {
     110           0 :         pRangeName = pDoc->GetRangeName( mnTab );
     111             :     }
     112           0 :     pRangeName->erase(*mpRangeData);
     113           0 :     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
     114             : 
     115           0 : }
     116             : 
     117           0 : void ScUndoAddRangeData::Redo()
     118             : {
     119           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     120           0 :     ScRangeName* pRangeName = NULL;
     121           0 :     if (mnTab == -1)
     122             :     {
     123           0 :         pRangeName = pDoc->GetRangeName();
     124             :     }
     125             :     else
     126             :     {
     127           0 :         pRangeName = pDoc->GetRangeName( mnTab );
     128             :     }
     129           0 :     pRangeName->insert(new ScRangeData(*mpRangeData));
     130           0 :     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
     131           0 : }
     132             : 
     133           0 : void ScUndoAddRangeData::Repeat(SfxRepeatTarget& /*rTarget*/)
     134             : {
     135           0 : }
     136             : 
     137           0 : bool ScUndoAddRangeData::CanRepeat(SfxRepeatTarget& /*rTarget*/) const
     138             : {
     139           0 :     return false;
     140             : }
     141             : 
     142           0 : OUString ScUndoAddRangeData::GetComment() const
     143             : {
     144           0 :     return ScGlobal::GetRscString(STR_UNDO_RANGENAMES);
     145             : }
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10