bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / dlg / masterlayoutdlg.cxx
blob881ed7b5bf36ded93eee95838cd76f050e2939a0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
22 #include <sdpage.hxx>
24 using namespace ::sd;
26 MasterLayoutDialog::MasterLayoutDialog(weld::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage)
27 : GenericDialogController(pParent, "modules/simpress/ui/masterlayoutdlg.ui", "MasterLayoutDialog")
28 , mpDoc(pDoc)
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());
53 break;
55 case PageKind::Notes:
56 break;
57 case PageKind::Handout:
58 break;
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)
79 applyChanges();
80 return RET_OK;
83 void MasterLayoutDialog::applyChanges()
85 mpDoc->BegUndo(m_xDialog->get_title());
87 if( (mpCurrentPage->GetPageKind() != PageKind::Standard) && (mbOldHeader != mxCBHeader->get_active() ) )
89 if( mbOldHeader )
90 remove( PRESOBJ_HEADER );
91 else
92 create( PRESOBJ_HEADER );
95 if( mbOldFooter != mxCBFooter->get_active() )
97 if( mbOldFooter )
98 remove( PRESOBJ_FOOTER );
99 else
100 create( PRESOBJ_FOOTER );
103 if( mbOldDate != mxCBDate->get_active() )
105 if( mbOldDate )
106 remove( PRESOBJ_DATETIME );
107 else
108 create( PRESOBJ_DATETIME );
111 if( mbOldPageNumber != mxCBPageNumber->get_active() )
113 if( mbOldPageNumber )
114 remove( PRESOBJ_SLIDENUMBER );
115 else
116 create( PRESOBJ_SLIDENUMBER );
119 mpDoc->EndUndo();
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: */