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

Generated by: LCOV version 1.10