1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/dialogs.hrc>
22 #include "sdresid.hxx"
24 #include "strings.hrc"
25 #include "dialogs.hrc"
26 #include "masterlayoutdlg.hxx"
27 #include "masterlayoutdlg.hrc"
28 #include "drawdoc.hxx"
32 MasterLayoutDialog::MasterLayoutDialog( Window
* pParent
, SdDrawDocument
* pDoc
, SdPage
* pCurrentPage
)
33 : ModalDialog( pParent
, SdResId( RID_SD_DLG_MASTER_LAYOUT
) ),
35 mpCurrentPage( pCurrentPage
),
36 maFLPlaceholders( this, SdResId( FL_PLACEHOLDERS
) ),
37 maCBDate( this, SdResId( CB_DATE
) ),
38 maCBPageNumber( this, SdResId( CB_PAGE_NUMBER
) ),
39 maCBHeader( this, SdResId( CB_HEADER
) ),
40 maCBFooter( this, SdResId( CB_FOOTER
) ),
41 maPBOK( this, SdResId( BT_OK
) ),
42 maPBCancel( this, SdResId( BT_CANCEL
) )
44 if( mpCurrentPage
&& !mpCurrentPage
->IsMasterPage() )
46 mpCurrentPage
= (SdPage
*)(&(mpCurrentPage
->TRG_GetMasterPage()));
49 if( mpCurrentPage
== 0 )
51 mpCurrentPage
= pDoc
->GetMasterSdPage( 0, PK_STANDARD
);
52 OSL_FAIL( "MasterLayoutDialog::MasterLayoutDialog() - no current page?" );
55 switch( mpCurrentPage
->GetPageKind() )
59 // aTitle = String( SdResId( STR_MASTER_LAYOUT_TITLE ) );
60 maCBHeader
.Enable( sal_False
);
61 String
aSlideNumberStr( SdResId( STR_SLIDE_NUMBER
) );
62 maCBPageNumber
.SetText( aSlideNumberStr
);
66 // aTitle = String( SdResId( STR_NOTES_MASTER_LAYOUT_TITLE ) );
69 // aTitle = String( SdResId( STR_HANDOUT_TEMPLATE_LAYOUT_TITLE ) );
72 String
aTitle (SdResId( STR_MASTER_LAYOUT_TITLE
) );
78 mbOldHeader
= mpCurrentPage
->GetPresObj( PRESOBJ_HEADER
) != NULL
;
79 mbOldDate
= mpCurrentPage
->GetPresObj( PRESOBJ_DATETIME
) != NULL
;
80 mbOldFooter
= mpCurrentPage
->GetPresObj( PRESOBJ_FOOTER
) != NULL
;
81 mbOldPageNumber
= mpCurrentPage
->GetPresObj( PRESOBJ_SLIDENUMBER
) != NULL
;
83 maCBHeader
.Check( mbOldHeader
);
84 maCBDate
.Check( mbOldDate
);
85 maCBFooter
.Check( mbOldFooter
);
86 maCBPageNumber
.Check( mbOldPageNumber
);
89 MasterLayoutDialog::~MasterLayoutDialog()
93 short MasterLayoutDialog::Execute()
95 if ( ModalDialog::Execute() )
100 void MasterLayoutDialog::applyChanges()
102 mpDoc
->BegUndo(GetText());
104 if( (mpCurrentPage
->GetPageKind() != PK_STANDARD
) && (mbOldHeader
!= maCBHeader
.IsChecked() ) )
107 remove( PRESOBJ_HEADER
);
109 create( PRESOBJ_HEADER
);
112 if( mbOldFooter
!= maCBFooter
.IsChecked() )
115 remove( PRESOBJ_FOOTER
);
117 create( PRESOBJ_FOOTER
);
120 if( mbOldDate
!= maCBDate
.IsChecked() )
123 remove( PRESOBJ_DATETIME
);
125 create( PRESOBJ_DATETIME
);
128 if( mbOldPageNumber
!= maCBPageNumber
.IsChecked() )
130 if( mbOldPageNumber
)
131 remove( PRESOBJ_SLIDENUMBER
);
133 create( PRESOBJ_SLIDENUMBER
);
139 void MasterLayoutDialog::create( PresObjKind eKind
)
141 mpCurrentPage
->CreateDefaultPresObj( eKind
, true );
144 void MasterLayoutDialog::remove( PresObjKind eKind
)
146 SdrObject
* pObject
= mpCurrentPage
->GetPresObj( eKind
);
150 const bool bUndo
= mpDoc
->IsUndoEnabled();
152 mpDoc
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject
));
153 SdrObjList
* pOL
=pObject
->GetObjList();
154 sal_uInt32 nOrdNum
=pObject
->GetOrdNumDirect();
155 pOL
->RemoveObject(nOrdNum
);
158 SdrObject::Free(pObject
);
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */