1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: masterlayoutdlg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #ifdef SD_DLLIMPLEMENTATION
35 #undef SD_DLLIMPLEMENTATION
38 #ifndef _SVX_DIALOGS_HRC
39 #include <svx/dialogs.hrc>
42 #ifndef _SD_SDRESID_HXX
43 #include "sdresid.hxx"
46 #include "strings.hrc"
47 #include "dialogs.hrc"
48 #include "masterlayoutdlg.hxx"
49 #include "masterlayoutdlg.hrc"
50 #include "drawdoc.hxx"
54 MasterLayoutDialog::MasterLayoutDialog( Window
* pParent
, SdDrawDocument
* pDoc
, SdPage
* pCurrentPage
)
55 : ModalDialog( pParent
, SdResId( RID_SD_DLG_MASTER_LAYOUT
) ),
57 mpCurrentPage( pCurrentPage
),
58 maFLPlaceholders( this, SdResId( FL_PLACEHOLDERS
) ),
59 maCBDate( this, SdResId( CB_DATE
) ),
60 maCBPageNumber( this, SdResId( CB_PAGE_NUMBER
) ),
61 maCBHeader( this, SdResId( CB_HEADER
) ),
62 maCBFooter( this, SdResId( CB_FOOTER
) ),
63 maPBOK( this, SdResId( BT_OK
) ),
64 maPBCancel( this, SdResId( BT_CANCEL
) )
66 if( mpCurrentPage
&& !mpCurrentPage
->IsMasterPage() )
68 mpCurrentPage
= (SdPage
*)(&(mpCurrentPage
->TRG_GetMasterPage()));
71 if( mpCurrentPage
== 0 )
73 mpCurrentPage
= pDoc
->GetMasterSdPage( 0, PK_STANDARD
);
74 DBG_ERROR( "MasterLayoutDialog::MasterLayoutDialog() - no current page?" );
77 switch( mpCurrentPage
->GetPageKind() )
81 // aTitle = String( SdResId( STR_MASTER_LAYOUT_TITLE ) );
82 maCBHeader
.Enable( FALSE
);
83 String
aSlideNumberStr( SdResId( STR_SLIDE_NUMBER
) );
84 maCBPageNumber
.SetText( aSlideNumberStr
);
88 // aTitle = String( SdResId( STR_NOTES_MASTER_LAYOUT_TITLE ) );
91 // aTitle = String( SdResId( STR_HANDOUT_TEMPLATE_LAYOUT_TITLE ) );
94 String
aTitle (SdResId( STR_MASTER_LAYOUT_TITLE
) );
100 mbOldHeader
= mpCurrentPage
->GetPresObj( PRESOBJ_HEADER
) != NULL
;
101 mbOldDate
= mpCurrentPage
->GetPresObj( PRESOBJ_DATETIME
) != NULL
;
102 mbOldFooter
= mpCurrentPage
->GetPresObj( PRESOBJ_FOOTER
) != NULL
;
103 mbOldPageNumber
= mpCurrentPage
->GetPresObj( PRESOBJ_SLIDENUMBER
) != NULL
;
105 maCBHeader
.Check( mbOldHeader
);
106 maCBDate
.Check( mbOldDate
);
107 maCBFooter
.Check( mbOldFooter
);
108 maCBPageNumber
.Check( mbOldPageNumber
);
111 MasterLayoutDialog::~MasterLayoutDialog()
115 short MasterLayoutDialog::Execute()
117 if ( ModalDialog::Execute() )
122 void MasterLayoutDialog::applyChanges()
124 mpDoc
->BegUndo(GetText());
126 if( (mpCurrentPage
->GetPageKind() != PK_STANDARD
) && (mbOldHeader
!= maCBHeader
.IsChecked() ) )
129 remove( PRESOBJ_HEADER
);
131 create( PRESOBJ_HEADER
);
134 if( mbOldFooter
!= maCBFooter
.IsChecked() )
137 remove( PRESOBJ_FOOTER
);
139 create( PRESOBJ_FOOTER
);
142 if( mbOldDate
!= maCBDate
.IsChecked() )
145 remove( PRESOBJ_DATETIME
);
147 create( PRESOBJ_DATETIME
);
150 if( mbOldPageNumber
!= maCBPageNumber
.IsChecked() )
152 if( mbOldPageNumber
)
153 remove( PRESOBJ_SLIDENUMBER
);
155 create( PRESOBJ_SLIDENUMBER
);
161 void MasterLayoutDialog::create( PresObjKind eKind
)
163 mpCurrentPage
->CreateDefaultPresObj( eKind
, true );
166 void MasterLayoutDialog::remove( PresObjKind eKind
)
168 SdrObject
* pObject
= mpCurrentPage
->GetPresObj( eKind
);
172 const bool bUndo
= mpDoc
->IsUndoEnabled();
174 mpDoc
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject
));
175 SdrObjList
* pOL
=pObject
->GetObjList();
176 UINT32 nOrdNum
=pObject
->GetOrdNumDirect();
177 pOL
->RemoveObject(nOrdNum
);
180 SdrObject::Free(pObject
);