1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_sd.hxx"
32 #ifdef SD_DLLIMPLEMENTATION
33 #undef SD_DLLIMPLEMENTATION
36 #include <svx/dialogs.hrc>
38 #include "sdresid.hxx"
40 #include "strings.hrc"
41 #include "dialogs.hrc"
42 #include "masterlayoutdlg.hxx"
43 #include "masterlayoutdlg.hrc"
44 #include "drawdoc.hxx"
48 MasterLayoutDialog::MasterLayoutDialog( Window
* pParent
, SdDrawDocument
* pDoc
, SdPage
* pCurrentPage
)
49 : ModalDialog( pParent
, SdResId( RID_SD_DLG_MASTER_LAYOUT
) ),
51 mpCurrentPage( pCurrentPage
),
52 maFLPlaceholders( this, SdResId( FL_PLACEHOLDERS
) ),
53 maCBDate( this, SdResId( CB_DATE
) ),
54 maCBPageNumber( this, SdResId( CB_PAGE_NUMBER
) ),
55 maCBHeader( this, SdResId( CB_HEADER
) ),
56 maCBFooter( this, SdResId( CB_FOOTER
) ),
57 maPBOK( this, SdResId( BT_OK
) ),
58 maPBCancel( this, SdResId( BT_CANCEL
) )
60 if( mpCurrentPage
&& !mpCurrentPage
->IsMasterPage() )
62 mpCurrentPage
= (SdPage
*)(&(mpCurrentPage
->TRG_GetMasterPage()));
65 if( mpCurrentPage
== 0 )
67 mpCurrentPage
= pDoc
->GetMasterSdPage( 0, PK_STANDARD
);
68 DBG_ERROR( "MasterLayoutDialog::MasterLayoutDialog() - no current page?" );
71 switch( mpCurrentPage
->GetPageKind() )
75 // aTitle = String( SdResId( STR_MASTER_LAYOUT_TITLE ) );
76 maCBHeader
.Enable( FALSE
);
77 String
aSlideNumberStr( SdResId( STR_SLIDE_NUMBER
) );
78 maCBPageNumber
.SetText( aSlideNumberStr
);
82 // aTitle = String( SdResId( STR_NOTES_MASTER_LAYOUT_TITLE ) );
85 // aTitle = String( SdResId( STR_HANDOUT_TEMPLATE_LAYOUT_TITLE ) );
88 String
aTitle (SdResId( STR_MASTER_LAYOUT_TITLE
) );
94 mbOldHeader
= mpCurrentPage
->GetPresObj( PRESOBJ_HEADER
) != NULL
;
95 mbOldDate
= mpCurrentPage
->GetPresObj( PRESOBJ_DATETIME
) != NULL
;
96 mbOldFooter
= mpCurrentPage
->GetPresObj( PRESOBJ_FOOTER
) != NULL
;
97 mbOldPageNumber
= mpCurrentPage
->GetPresObj( PRESOBJ_SLIDENUMBER
) != NULL
;
99 maCBHeader
.Check( mbOldHeader
);
100 maCBDate
.Check( mbOldDate
);
101 maCBFooter
.Check( mbOldFooter
);
102 maCBPageNumber
.Check( mbOldPageNumber
);
105 MasterLayoutDialog::~MasterLayoutDialog()
109 short MasterLayoutDialog::Execute()
111 if ( ModalDialog::Execute() )
116 void MasterLayoutDialog::applyChanges()
118 mpDoc
->BegUndo(GetText());
120 if( (mpCurrentPage
->GetPageKind() != PK_STANDARD
) && (mbOldHeader
!= maCBHeader
.IsChecked() ) )
123 remove( PRESOBJ_HEADER
);
125 create( PRESOBJ_HEADER
);
128 if( mbOldFooter
!= maCBFooter
.IsChecked() )
131 remove( PRESOBJ_FOOTER
);
133 create( PRESOBJ_FOOTER
);
136 if( mbOldDate
!= maCBDate
.IsChecked() )
139 remove( PRESOBJ_DATETIME
);
141 create( PRESOBJ_DATETIME
);
144 if( mbOldPageNumber
!= maCBPageNumber
.IsChecked() )
146 if( mbOldPageNumber
)
147 remove( PRESOBJ_SLIDENUMBER
);
149 create( PRESOBJ_SLIDENUMBER
);
155 void MasterLayoutDialog::create( PresObjKind eKind
)
157 mpCurrentPage
->CreateDefaultPresObj( eKind
, true );
160 void MasterLayoutDialog::remove( PresObjKind eKind
)
162 SdrObject
* pObject
= mpCurrentPage
->GetPresObj( eKind
);
166 const bool bUndo
= mpDoc
->IsUndoEnabled();
168 mpDoc
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject
));
169 SdrObjList
* pOL
=pObject
->GetObjList();
170 UINT32 nOrdNum
=pObject
->GetOrdNumDirect();
171 pOL
->RemoveObject(nOrdNum
);
174 SdrObject::Free(pObject
);
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */