File indexing completed on 2024-05-12 16:36:43

0001 /* This file is part of the KDE project
0002  * Copyright ( C ) 2007 Thorsten Zachmann <zachmann@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (  at your option ) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #include "KPrMasterPage.h"
0021 
0022 #include "pagelayout/KPrPageLayouts.h"
0023 #include "KPresenter.h"
0024 #include "StageDebug.h"
0025 
0026 #include <KoXmlNS.h>
0027 //#include <KoDocumentResourceManager.h>
0028 #include <KoPALoadingContext.h>
0029 #include <KoOdfWorkaround.h>
0030 #include <KoXmlReader.h>
0031 
0032 KPrMasterPage::KPrMasterPage(KPrDocument *document)
0033     : KPrPageData(document)
0034 {
0035 }
0036 
0037 KPrMasterPage::~KPrMasterPage()
0038 {
0039 }
0040 
0041 KoPageApp::PageType KPrMasterPage::pageType() const
0042 {
0043     return KoPageApp::Slide;
0044 }
0045 
0046 bool KPrMasterPage::loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context)
0047 {
0048 #ifndef NWORKAROUND_ODF_BUGS
0049     KoOdfWorkaround::setFixPresentationPlaceholder(true, context);
0050 #endif
0051     bool retval = KoPAPageBase::loadOdf(element, context);
0052 #ifndef NWORKAROUND_ODF_BUGS
0053     KoOdfWorkaround::setFixPresentationPlaceholder(false, context);
0054 #endif
0055     return retval;
0056 }
0057 
0058 void KPrMasterPage::loadOdfPageExtra( const KoXmlElement &element, KoPALoadingContext & loadingContext )
0059 {
0060     // the layout needs to be loaded after the shapes are already loaded so the initialization of the data works
0061     KPrPageLayout * layout = 0;
0062     if ( element.hasAttributeNS( KoXmlNS::presentation, "presentation-page-layout-name" ) ) {
0063         KPrPageLayouts *layouts = loadingContext.documentResourceManager()->resource(KPresenter::PageLayouts).value<KPrPageLayouts*>();
0064         Q_ASSERT( layouts );
0065         if ( layouts ) {
0066             QString layoutName = element.attributeNS( KoXmlNS::presentation, "presentation-page-layout-name" );
0067             QRectF pageRect( 0, 0, pageLayout().width, pageLayout().height );
0068             layout = layouts->pageLayout( layoutName, loadingContext, pageRect );
0069             debugStage << "page layout" << layoutName << layout;
0070         }
0071     }
0072     placeholders().init( layout, shapes() );
0073 }