LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - masterlayoutdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 66 0.0 %
Date: 2012-12-27 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             : 
      21             : #ifdef SD_DLLIMPLEMENTATION
      22             : #undef SD_DLLIMPLEMENTATION
      23             : #endif
      24             : 
      25             : #include <svx/dialogs.hrc>
      26             : 
      27             : #include "sdresid.hxx"
      28             : 
      29             : #include "strings.hrc"
      30             : #include "dialogs.hrc"
      31             : #include "masterlayoutdlg.hxx"
      32             : #include "masterlayoutdlg.hrc"
      33             : #include "drawdoc.hxx"
      34             : 
      35             : using namespace ::sd;
      36             : 
      37           0 : MasterLayoutDialog::MasterLayoutDialog( Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage )
      38             : :   ModalDialog( pParent, SdResId( RID_SD_DLG_MASTER_LAYOUT ) ),
      39             :     mpDoc( pDoc ),
      40             :     mpCurrentPage( pCurrentPage ),
      41             :     maFLPlaceholders( this, SdResId( FL_PLACEHOLDERS ) ),
      42             :     maCBDate( this, SdResId( CB_DATE ) ),
      43             :     maCBPageNumber( this, SdResId( CB_PAGE_NUMBER ) ),
      44             :     maCBHeader( this, SdResId( CB_HEADER ) ),
      45             :     maCBFooter( this, SdResId( CB_FOOTER ) ),
      46             :     maPBOK( this, SdResId( BT_OK ) ),
      47           0 :     maPBCancel( this, SdResId( BT_CANCEL ) )
      48             : {
      49           0 :     if( mpCurrentPage && !mpCurrentPage->IsMasterPage() )
      50             :     {
      51           0 :         mpCurrentPage = (SdPage*)(&(mpCurrentPage->TRG_GetMasterPage()));
      52             :     }
      53             : 
      54           0 :     if( mpCurrentPage == 0 )
      55             :     {
      56           0 :         mpCurrentPage = pDoc->GetMasterSdPage( 0, PK_STANDARD );
      57             :         OSL_FAIL( "MasterLayoutDialog::MasterLayoutDialog() - no current page?" );
      58             :     }
      59             : 
      60           0 :     switch( mpCurrentPage->GetPageKind() )
      61             :     {
      62             :     case PK_STANDARD:
      63             :     {
      64             :         //      aTitle = String( SdResId( STR_MASTER_LAYOUT_TITLE ) );
      65           0 :         maCBHeader.Enable( sal_False );
      66           0 :     String aSlideNumberStr( SdResId( STR_SLIDE_NUMBER ) );
      67           0 :         maCBPageNumber.SetText( aSlideNumberStr );
      68           0 :         break;
      69             :     }
      70             :     case PK_NOTES:
      71             :         //      aTitle = String( SdResId( STR_NOTES_MASTER_LAYOUT_TITLE ) );
      72           0 :         break;
      73             :     case PK_HANDOUT:
      74             :         //      aTitle = String( SdResId( STR_HANDOUT_TEMPLATE_LAYOUT_TITLE ) );
      75           0 :         break;
      76             :     }
      77           0 :     String aTitle (SdResId( STR_MASTER_LAYOUT_TITLE ) );
      78             : 
      79           0 :     SetText( aTitle );
      80             : 
      81           0 :     FreeResource();
      82             : 
      83           0 :     mbOldHeader = mpCurrentPage->GetPresObj( PRESOBJ_HEADER ) != NULL;
      84           0 :     mbOldDate = mpCurrentPage->GetPresObj( PRESOBJ_DATETIME ) != NULL;
      85           0 :     mbOldFooter = mpCurrentPage->GetPresObj( PRESOBJ_FOOTER ) != NULL;
      86           0 :     mbOldPageNumber = mpCurrentPage->GetPresObj( PRESOBJ_SLIDENUMBER ) != NULL;
      87             : 
      88           0 :     maCBHeader.Check( mbOldHeader );
      89           0 :     maCBDate.Check( mbOldDate );
      90           0 :     maCBFooter.Check( mbOldFooter );
      91           0 :     maCBPageNumber.Check( mbOldPageNumber );
      92           0 : }
      93             : 
      94           0 : MasterLayoutDialog::~MasterLayoutDialog()
      95             : {
      96           0 : }
      97             : 
      98           0 : short MasterLayoutDialog::Execute()
      99             : {
     100           0 :     if ( ModalDialog::Execute() )
     101           0 :         applyChanges();
     102           0 :     return 1;
     103             : }
     104             : 
     105           0 : void MasterLayoutDialog::applyChanges()
     106             : {
     107           0 :     mpDoc->BegUndo(GetText());
     108             : 
     109           0 :     if( (mpCurrentPage->GetPageKind() != PK_STANDARD) && (mbOldHeader != maCBHeader.IsChecked() ) )
     110             :     {
     111           0 :         if( mbOldHeader )
     112           0 :             remove( PRESOBJ_HEADER );
     113             :         else
     114           0 :             create( PRESOBJ_HEADER );
     115             :     }
     116             : 
     117           0 :     if( mbOldFooter != maCBFooter.IsChecked() )
     118             :     {
     119           0 :         if( mbOldFooter )
     120           0 :             remove( PRESOBJ_FOOTER );
     121             :         else
     122           0 :             create( PRESOBJ_FOOTER );
     123             :     }
     124             : 
     125           0 :     if( mbOldDate != maCBDate.IsChecked() )
     126             :     {
     127           0 :         if( mbOldDate )
     128           0 :             remove( PRESOBJ_DATETIME );
     129             :         else
     130           0 :             create( PRESOBJ_DATETIME );
     131             :     }
     132             : 
     133           0 :     if( mbOldPageNumber != maCBPageNumber.IsChecked() )
     134             :     {
     135           0 :         if( mbOldPageNumber )
     136           0 :             remove( PRESOBJ_SLIDENUMBER );
     137             :         else
     138           0 :             create( PRESOBJ_SLIDENUMBER );
     139             :     }
     140             : 
     141           0 :     mpDoc->EndUndo();
     142           0 : }
     143             : 
     144           0 : void MasterLayoutDialog::create( PresObjKind eKind )
     145             : {
     146           0 :     mpCurrentPage->CreateDefaultPresObj( eKind, true );
     147           0 : }
     148             : 
     149           0 : void MasterLayoutDialog::remove( PresObjKind eKind )
     150             : {
     151           0 :     SdrObject* pObject = mpCurrentPage->GetPresObj( eKind );
     152             : 
     153           0 :     if( pObject )
     154             :     {
     155           0 :         const bool bUndo = mpDoc->IsUndoEnabled();
     156           0 :         if( bUndo )
     157           0 :             mpDoc->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject));
     158           0 :         SdrObjList* pOL =pObject->GetObjList();
     159           0 :         sal_uInt32 nOrdNum=pObject->GetOrdNumDirect();
     160           0 :         pOL->RemoveObject(nOrdNum);
     161             : 
     162           0 :         if( !bUndo )
     163           0 :             SdrObject::Free(pObject);
     164             :     }
     165           0 : }
     166             : 
     167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10