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 <masterlayoutdlg.hxx>
21 #include <drawdoc.hxx>
26 MasterLayoutDialog::MasterLayoutDialog(weld::Window
* pParent
, SdDrawDocument
* pDoc
, SdPage
* pCurrentPage
)
27 : GenericDialogController(pParent
, "modules/simpress/ui/masterlayoutdlg.ui", "MasterLayoutDialog")
29 , mpCurrentPage(pCurrentPage
)
30 , mxCBDate(m_xBuilder
->weld_check_button("datetime"))
31 , mxCBPageNumber(m_xBuilder
->weld_check_button("pagenumber"))
32 , mxCBSlideNumber(m_xBuilder
->weld_check_button("slidenumber"))
33 , mxCBHeader(m_xBuilder
->weld_check_button("header"))
34 , mxCBFooter(m_xBuilder
->weld_check_button("footer"))
36 if( mpCurrentPage
&& !mpCurrentPage
->IsMasterPage() )
38 mpCurrentPage
= static_cast<SdPage
*>(&(mpCurrentPage
->TRG_GetMasterPage()));
41 if( mpCurrentPage
== nullptr )
43 mpCurrentPage
= pDoc
->GetMasterSdPage( 0, PageKind::Standard
);
44 OSL_FAIL( "MasterLayoutDialog::MasterLayoutDialog() - no current page?" );
47 switch( mpCurrentPage
->GetPageKind() )
49 case PageKind::Standard
:
51 mxCBHeader
->set_sensitive(false);
52 mxCBPageNumber
->set_label(mxCBSlideNumber
->get_label());
57 case PageKind::Handout
:
61 mbOldHeader
= mpCurrentPage
->GetPresObj( PRESOBJ_HEADER
) != nullptr;
62 mbOldDate
= mpCurrentPage
->GetPresObj( PRESOBJ_DATETIME
) != nullptr;
63 mbOldFooter
= mpCurrentPage
->GetPresObj( PRESOBJ_FOOTER
) != nullptr;
64 mbOldPageNumber
= mpCurrentPage
->GetPresObj( PRESOBJ_SLIDENUMBER
) != nullptr;
66 mxCBHeader
->set_active( mbOldHeader
);
67 mxCBDate
->set_active( mbOldDate
);
68 mxCBFooter
->set_active( mbOldFooter
);
69 mxCBPageNumber
->set_active( mbOldPageNumber
);
72 MasterLayoutDialog::~MasterLayoutDialog()
76 short MasterLayoutDialog::run()
78 if (GenericDialogController::run() == RET_OK
)
83 void MasterLayoutDialog::applyChanges()
85 mpDoc
->BegUndo(m_xDialog
->get_title());
87 if( (mpCurrentPage
->GetPageKind() != PageKind::Standard
) && (mbOldHeader
!= mxCBHeader
->get_active() ) )
90 remove( PRESOBJ_HEADER
);
92 create( PRESOBJ_HEADER
);
95 if( mbOldFooter
!= mxCBFooter
->get_active() )
98 remove( PRESOBJ_FOOTER
);
100 create( PRESOBJ_FOOTER
);
103 if( mbOldDate
!= mxCBDate
->get_active() )
106 remove( PRESOBJ_DATETIME
);
108 create( PRESOBJ_DATETIME
);
111 if( mbOldPageNumber
!= mxCBPageNumber
->get_active() )
113 if( mbOldPageNumber
)
114 remove( PRESOBJ_SLIDENUMBER
);
116 create( PRESOBJ_SLIDENUMBER
);
122 void MasterLayoutDialog::create(PresObjKind eKind
)
124 mpCurrentPage
->CreateDefaultPresObj(eKind
);
127 void MasterLayoutDialog::remove( PresObjKind eKind
)
129 mpCurrentPage
->DestroyDefaultPresObj(eKind
);
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */