LCOV - code coverage report
Current view: top level - sd/source/ui/view - unmodpg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 87 0.0 %
Date: 2014-04-14 Functions: 0 15 0.0 %
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 <svx/svdlayer.hxx>
      21             : #include <sfx2/dispatch.hxx>
      22             : #include <sfx2/viewfrm.hxx>
      23             : 
      24             : #include "strings.hrc"
      25             : #include "glob.hxx"
      26             : #include "glob.hrc"
      27             : #include "app.hrc"
      28             : 
      29             : #include "unmodpg.hxx"
      30             : #include "sdpage.hxx"
      31             : #include "sdresid.hxx"
      32             : #include "drawdoc.hxx"
      33             : 
      34             : 
      35           0 : TYPEINIT1(ModifyPageUndoAction, SdUndoAction);
      36             : 
      37             : 
      38             : 
      39           0 : ModifyPageUndoAction::ModifyPageUndoAction(
      40             :     SdDrawDocument* pTheDoc,
      41             :     SdPage* pThePage,
      42             :     const OUString& aTheNewName,
      43             :     AutoLayout  eTheNewAutoLayout,
      44             :     sal_Bool bTheNewBckgrndVisible,
      45             :     sal_Bool bTheNewBckgrndObjsVisible)
      46           0 : :   SdUndoAction(pTheDoc)
      47             : {
      48             :     DBG_ASSERT(pThePage, "Undo without a page???");
      49             : 
      50           0 :     mpPage                  = pThePage;
      51           0 :     maNewName               = aTheNewName;
      52           0 :     meNewAutoLayout         = eTheNewAutoLayout;
      53           0 :     mbNewBckgrndVisible     = bTheNewBckgrndVisible;
      54           0 :     mbNewBckgrndObjsVisible = bTheNewBckgrndObjsVisible;
      55             : 
      56           0 :     meOldAutoLayout         = mpPage->GetAutoLayout();
      57             : 
      58           0 :     if (!mpPage->IsMasterPage())
      59             :     {
      60           0 :         maOldName = mpPage->GetName();
      61           0 :         SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
      62           0 :         sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND), false);
      63           0 :         sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ), false);
      64           0 :         SetOfByte aVisibleLayers = mpPage->TRG_GetMasterPageVisibleLayers();
      65             : 
      66           0 :         mbOldBckgrndVisible = aVisibleLayers.IsSet(aBckgrnd);
      67           0 :         mbOldBckgrndObjsVisible = aVisibleLayers.IsSet(aBckgrndObj);
      68             :     }
      69             :     else
      70             :     {
      71           0 :         mbOldBckgrndVisible = false;
      72           0 :         mbOldBckgrndObjsVisible = false;
      73             :     }
      74             : 
      75           0 :     maComment = SD_RESSTR(STR_UNDO_MODIFY_PAGE);
      76           0 : }
      77             : 
      78             : #include <svx/svdviter.hxx>
      79             : #include <svx/svdview.hxx>
      80           0 : void ModifyPageUndoAction::Undo()
      81             : {
      82             :     // invalidate Selection, there could be objects deleted in this UNDO
      83             :     // which are no longer allowed to be selected then.
      84           0 :       SdrViewIter aIter(mpPage);
      85           0 :     SdrView* pView = aIter.FirstView();
      86             : 
      87           0 :     while(pView)
      88             :     {
      89           0 :         if(pView->AreObjectsMarked())
      90           0 :             pView->UnmarkAll();
      91           0 :         pView = aIter.NextView();
      92             :     }
      93             : 
      94           0 :     mpPage->SetAutoLayout( meOldAutoLayout );
      95             : 
      96           0 :     if (!mpPage->IsMasterPage())
      97             :     {
      98           0 :         if (mpPage->GetName() != maOldName)
      99             :         {
     100           0 :             mpPage->SetName(maOldName);
     101             : 
     102           0 :             if (mpPage->GetPageKind() == PK_STANDARD)
     103             :             {
     104           0 :                 SdPage* pNotesPage = (SdPage*)mpDoc->GetPage(mpPage->GetPageNum() + 1);
     105           0 :                 pNotesPage->SetName(maOldName);
     106             :             }
     107             :         }
     108             : 
     109           0 :         SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
     110           0 :         sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND), false);
     111           0 :         sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ), false);
     112           0 :         SetOfByte aVisibleLayers;
     113           0 :         aVisibleLayers.Set(aBckgrnd, mbOldBckgrndVisible);
     114           0 :         aVisibleLayers.Set(aBckgrndObj, mbOldBckgrndObjsVisible);
     115           0 :         mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
     116             :     }
     117             : 
     118             :     // Redisplay
     119             :     SfxViewFrame::Current()->GetDispatcher()->Execute(
     120           0 :         SID_SWITCHPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
     121           0 : }
     122             : 
     123             : 
     124           0 : void ModifyPageUndoAction::Redo()
     125             : {
     126             :     // invalidate Selection, there could be objects deleted in this UNDO
     127             :     // which are no longer allowed to be selected then.
     128           0 :       SdrViewIter aIter(mpPage);
     129           0 :     SdrView* pView = aIter.FirstView();
     130             : 
     131           0 :     while(pView)
     132             :     {
     133           0 :         if(pView->AreObjectsMarked())
     134           0 :             pView->UnmarkAll();
     135           0 :         pView = aIter.NextView();
     136             :     }
     137             : 
     138           0 :     mpPage->meAutoLayout = meNewAutoLayout;
     139             : 
     140           0 :     if (!mpPage->IsMasterPage())
     141             :     {
     142           0 :         if (mpPage->GetName() != maNewName)
     143             :         {
     144           0 :             mpPage->SetName(maNewName);
     145             : 
     146           0 :             if (mpPage->GetPageKind() == PK_STANDARD)
     147             :             {
     148           0 :                 SdPage* pNotesPage = (SdPage*)mpDoc->GetPage(mpPage->GetPageNum() + 1);
     149           0 :                 pNotesPage->SetName(maNewName);
     150             :             }
     151             :         }
     152             : 
     153           0 :         SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
     154           0 :         sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND), false);
     155           0 :         sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ), false);
     156           0 :         SetOfByte aVisibleLayers;
     157           0 :         aVisibleLayers.Set(aBckgrnd, mbNewBckgrndVisible);
     158           0 :         aVisibleLayers.Set(aBckgrndObj, mbNewBckgrndObjsVisible);
     159           0 :         mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
     160             :     }
     161             : 
     162             :     // Redisplay
     163             :     SfxViewFrame::Current()->GetDispatcher()->Execute(
     164           0 :         SID_SWITCHPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
     165           0 : }
     166             : 
     167             : 
     168           0 : ModifyPageUndoAction::~ModifyPageUndoAction()
     169             : {
     170           0 : }
     171             : 
     172             : 
     173           0 : OUString ModifyPageUndoAction::GetComment() const
     174             : {
     175           0 :     return maComment;
     176             : }
     177             : 
     178             : 
     179           0 : RenameLayoutTemplateUndoAction::RenameLayoutTemplateUndoAction(
     180             :     SdDrawDocument* pDocument,
     181             :     const OUString& rOldLayoutName,
     182             :     const OUString& rNewLayoutName)
     183             :     : SdUndoAction(pDocument)
     184             :     , maOldName(rOldLayoutName)
     185             :     , maNewName(rNewLayoutName)
     186           0 :     , maComment(SD_RESSTR(STR_TITLE_RENAMESLIDE))
     187             : {
     188           0 :     sal_Int32 nPos = maOldName.indexOf(SD_LT_SEPARATOR);
     189           0 :     if (nPos != -1)
     190           0 :         maOldName = maOldName.copy(0, nPos);
     191           0 : }
     192             : 
     193           0 : void RenameLayoutTemplateUndoAction::Undo()
     194             : {
     195           0 :     OUString aLayoutName(maNewName + SD_LT_SEPARATOR + SD_RESSTR(STR_LAYOUT_OUTLINE));
     196           0 :     mpDoc->RenameLayoutTemplate( aLayoutName, maOldName );
     197           0 : }
     198             : 
     199           0 : void RenameLayoutTemplateUndoAction::Redo()
     200             : {
     201           0 :     OUString aLayoutName(maOldName + SD_LT_SEPARATOR + SD_RESSTR(STR_LAYOUT_OUTLINE));
     202           0 :     mpDoc->RenameLayoutTemplate( aLayoutName, maNewName );
     203           0 : }
     204             : 
     205           0 : OUString RenameLayoutTemplateUndoAction::GetComment() const
     206             : {
     207           0 :     return  maComment;
     208             : }
     209             : 
     210             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10