Warning, file /office/calligra/libs/pageapp/KoPASavingContext.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 "KoPASavingContext.h" 0021 0022 #include <QRegExp> 0023 0024 #include "KoPAPage.h" 0025 0026 KoPASavingContext::KoPASavingContext(KoXmlWriter &xmlWriter, KoGenStyles& mainStyles, 0027 KoEmbeddedDocumentSaver &embeddedSaver, int page) 0028 : KoShapeSavingContext(xmlWriter, mainStyles, embeddedSaver) 0029 , m_page( page ) 0030 , m_masterPageIndex( 0 ) 0031 , m_clearDrawIds( false ) 0032 { 0033 } 0034 0035 KoPASavingContext::~KoPASavingContext() 0036 { 0037 } 0038 0039 void KoPASavingContext::addMasterPage( const KoPAMasterPage * masterPage, const QString &name ) 0040 { 0041 m_masterPageNames.insert( masterPage, name ); 0042 } 0043 0044 QString KoPASavingContext::masterPageName( const KoPAMasterPage * masterPage ) const 0045 { 0046 QMap<const KoPAMasterPage *, QString>::const_iterator it( m_masterPageNames.find( masterPage ) ); 0047 if ( it != m_masterPageNames.constEnd() ) { 0048 return it.value(); 0049 } 0050 0051 // this should not happen 0052 Q_ASSERT( it != m_masterPageNames.constEnd() ); 0053 return QString(); 0054 } 0055 0056 QString KoPASavingContext::masterPageElementName() 0057 { 0058 if ( ! isSet( KoShapeSavingContext::UniqueMasterPages ) ) { 0059 ++m_masterPageIndex; 0060 } 0061 return QString( "content_%1" ).arg( m_masterPageIndex ); 0062 } 0063 0064 void KoPASavingContext::incrementPage() 0065 { 0066 m_page++; 0067 } 0068 0069 int KoPASavingContext::page() 0070 { 0071 return m_page; 0072 } 0073 0074 void KoPASavingContext::setClearDrawIds( bool clear ) 0075 { 0076 m_clearDrawIds = clear; 0077 } 0078 0079 bool KoPASavingContext::isSetClearDrawIds() 0080 { 0081 return m_clearDrawIds; 0082 } 0083 0084 QString KoPASavingContext::pageName( const KoPAPage * page ) 0085 { 0086 QString name; 0087 QMap<const KoPAPage *, QString>::ConstIterator it( m_pageToNames.constFind( page ) ); 0088 if ( it != m_pageToNames.constEnd() ) { 0089 name = it.value(); 0090 } 0091 else { 0092 name = page->name(); 0093 QRegExp rx( "^page[0-9]+$" ); 0094 if ( name.isEmpty() || m_pageNames.contains( name ) || rx.indexIn( name ) != -1 ) { 0095 name = "page" + QString::number( m_page ); 0096 } 0097 Q_ASSERT( !m_pageNames.contains( name ) ); 0098 m_pageNames.insert( name ); 0099 m_pageToNames.insert( page, name ); 0100 } 0101 return name; 0102 }