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

Generated by: LCOV version 1.10