LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - masterlayoutdlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 67 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 10 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 = static_cast<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 : MasterLayoutDialog::~MasterLayoutDialog()
      79             : {
      80           0 :     disposeOnce();
      81           0 : }
      82             : 
      83           0 : void MasterLayoutDialog::dispose()
      84             : {
      85           0 :     mpCBDate.clear();
      86           0 :     mpCBPageNumber.clear();
      87           0 :     mpCBSlideNumber.clear();
      88           0 :     mpCBHeader.clear();
      89           0 :     mpCBFooter.clear();
      90           0 :     ModalDialog::dispose();
      91           0 : }
      92             : 
      93           0 : short MasterLayoutDialog::Execute()
      94             : {
      95           0 :     if ( ModalDialog::Execute() )
      96           0 :         applyChanges();
      97           0 :     return 1;
      98             : }
      99             : 
     100           0 : void MasterLayoutDialog::applyChanges()
     101             : {
     102           0 :     mpDoc->BegUndo(GetText());
     103             : 
     104           0 :     if( (mpCurrentPage->GetPageKind() != PK_STANDARD) && (mbOldHeader != (bool) mpCBHeader->IsChecked() ) )
     105             :     {
     106           0 :         if( mbOldHeader )
     107           0 :             remove( PRESOBJ_HEADER );
     108             :         else
     109           0 :             create( PRESOBJ_HEADER );
     110             :     }
     111             : 
     112           0 :     if( mbOldFooter != (bool) mpCBFooter->IsChecked() )
     113             :     {
     114           0 :         if( mbOldFooter )
     115           0 :             remove( PRESOBJ_FOOTER );
     116             :         else
     117           0 :             create( PRESOBJ_FOOTER );
     118             :     }
     119             : 
     120           0 :     if( mbOldDate != (bool) mpCBDate->IsChecked() )
     121             :     {
     122           0 :         if( mbOldDate )
     123           0 :             remove( PRESOBJ_DATETIME );
     124             :         else
     125           0 :             create( PRESOBJ_DATETIME );
     126             :     }
     127             : 
     128           0 :     if( mbOldPageNumber != (bool) mpCBPageNumber->IsChecked() )
     129             :     {
     130           0 :         if( mbOldPageNumber )
     131           0 :             remove( PRESOBJ_SLIDENUMBER );
     132             :         else
     133           0 :             create( PRESOBJ_SLIDENUMBER );
     134             :     }
     135             : 
     136           0 :     mpDoc->EndUndo();
     137           0 : }
     138             : 
     139           0 : void MasterLayoutDialog::create(PresObjKind eKind)
     140             : {
     141           0 :     mpCurrentPage->CreateDefaultPresObj(eKind, true);
     142           0 : }
     143             : 
     144           0 : void MasterLayoutDialog::remove( PresObjKind eKind )
     145             : {
     146           0 :     mpCurrentPage->DestroyDefaultPresObj(eKind);
     147           0 : }
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11