LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - masterlayoutdlg.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 64 0.0 %
Date: 2014-11-03 Functions: 0 7 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/dialogs.hrc>
      21             : 
      22             : #include "sdresid.hxx"
      23             : 
      24             : #include "strings.hrc"
      25             : #include "dialogs.hrc"
      26             : #include "masterlayoutdlg.hxx"
      27             : #include "drawdoc.hxx"
      28             : 
      29             : using namespace ::sd;
      30             : 
      31           0 : MasterLayoutDialog::MasterLayoutDialog( vcl::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage )
      32             :     : ModalDialog(pParent, "MasterLayoutDialog", "modules/simpress/ui/masterlayoutdlg.ui")
      33             :     , mpDoc(pDoc)
      34           0 :     , mpCurrentPage(pCurrentPage)
      35             : {
      36           0 :     get(mpCBDate, "datetime");
      37           0 :     get(mpCBPageNumber, "pagenumber");
      38           0 :     get(mpCBSlideNumber, "slidenumber");
      39           0 :     get(mpCBHeader, "header");
      40           0 :     get(mpCBFooter, "footer");
      41             : 
      42           0 :     if( mpCurrentPage && !mpCurrentPage->IsMasterPage() )
      43             :     {
      44           0 :         mpCurrentPage = (SdPage*)(&(mpCurrentPage->TRG_GetMasterPage()));
      45             :     }
      46             : 
      47           0 :     if( mpCurrentPage == 0 )
      48             :     {
      49           0 :         mpCurrentPage = pDoc->GetMasterSdPage( 0, PK_STANDARD );
      50             :         OSL_FAIL( "MasterLayoutDialog::MasterLayoutDialog() - no current page?" );
      51             :     }
      52             : 
      53           0 :     switch( mpCurrentPage->GetPageKind() )
      54             :     {
      55             :         case PK_STANDARD:
      56             :         {
      57           0 :             mpCBHeader->Enable(false);
      58           0 :             mpCBPageNumber->SetText(mpCBSlideNumber->GetText());
      59           0 :             break;
      60             :         }
      61             :         case PK_NOTES:
      62           0 :             break;
      63             :         case PK_HANDOUT:
      64           0 :             break;
      65             :     }
      66             : 
      67           0 :     mbOldHeader = mpCurrentPage->GetPresObj( PRESOBJ_HEADER ) != NULL;
      68           0 :     mbOldDate = mpCurrentPage->GetPresObj( PRESOBJ_DATETIME ) != NULL;
      69           0 :     mbOldFooter = mpCurrentPage->GetPresObj( PRESOBJ_FOOTER ) != NULL;
      70           0 :     mbOldPageNumber = mpCurrentPage->GetPresObj( PRESOBJ_SLIDENUMBER ) != NULL;
      71             : 
      72           0 :     mpCBHeader->Check( mbOldHeader );
      73           0 :     mpCBDate->Check( mbOldDate );
      74           0 :     mpCBFooter->Check( mbOldFooter );
      75           0 :     mpCBPageNumber->Check( mbOldPageNumber );
      76           0 : }
      77             : 
      78           0 : short MasterLayoutDialog::Execute()
      79             : {
      80           0 :     if ( ModalDialog::Execute() )
      81           0 :         applyChanges();
      82           0 :     return 1;
      83             : }
      84             : 
      85           0 : void MasterLayoutDialog::applyChanges()
      86             : {
      87           0 :     mpDoc->BegUndo(GetText());
      88             : 
      89           0 :     if( (mpCurrentPage->GetPageKind() != PK_STANDARD) && (mbOldHeader != (bool) mpCBHeader->IsChecked() ) )
      90             :     {
      91           0 :         if( mbOldHeader )
      92           0 :             remove( PRESOBJ_HEADER );
      93             :         else
      94           0 :             create( PRESOBJ_HEADER );
      95             :     }
      96             : 
      97           0 :     if( mbOldFooter != (bool) mpCBFooter->IsChecked() )
      98             :     {
      99           0 :         if( mbOldFooter )
     100           0 :             remove( PRESOBJ_FOOTER );
     101             :         else
     102           0 :             create( PRESOBJ_FOOTER );
     103             :     }
     104             : 
     105           0 :     if( mbOldDate != (bool) mpCBDate->IsChecked() )
     106             :     {
     107           0 :         if( mbOldDate )
     108           0 :             remove( PRESOBJ_DATETIME );
     109             :         else
     110           0 :             create( PRESOBJ_DATETIME );
     111             :     }
     112             : 
     113           0 :     if( mbOldPageNumber != (bool) mpCBPageNumber->IsChecked() )
     114             :     {
     115           0 :         if( mbOldPageNumber )
     116           0 :             remove( PRESOBJ_SLIDENUMBER );
     117             :         else
     118           0 :             create( PRESOBJ_SLIDENUMBER );
     119             :     }
     120             : 
     121           0 :     mpDoc->EndUndo();
     122           0 : }
     123             : 
     124           0 : void MasterLayoutDialog::create( PresObjKind eKind )
     125             : {
     126           0 :     mpCurrentPage->CreateDefaultPresObj( eKind, true );
     127           0 : }
     128             : 
     129           0 : void MasterLayoutDialog::remove( PresObjKind eKind )
     130             : {
     131           0 :     SdrObject* pObject = mpCurrentPage->GetPresObj( eKind );
     132             : 
     133           0 :     if( pObject )
     134             :     {
     135           0 :         const bool bUndo = mpDoc->IsUndoEnabled();
     136           0 :         if( bUndo )
     137           0 :             mpDoc->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject));
     138           0 :         SdrObjList* pOL =pObject->GetObjList();
     139           0 :         pOL->RemoveObject(pObject->GetOrdNumDirect());
     140             : 
     141           0 :         if( !bUndo )
     142           0 :             SdrObject::Free(pObject);
     143             :     }
     144           0 : }
     145             : 
     146             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10