Commit b9f1f7f3 authored by Thorsten Zachmann's avatar Thorsten Zachmann

o refactor to avoid code duplication

svn path=/trunk/koffice/; revision=681981
parent 175d7df4
......@@ -287,12 +287,7 @@ void KoPADocument::addShape( KoShape * shape )
if(!shape)
return;
KoShape * parent = shape;
KoPAPageBase * page = 0;
while ( !page && ( parent = parent->parent() ) )
{
page = dynamic_cast<KoPAPageBase*>( parent );
}
KoPAPageBase * page( getPage( shape ) );
bool isMaster = dynamic_cast<KoPAMasterPage*>( page ) != 0;
......@@ -317,12 +312,7 @@ void KoPADocument::removeShape( KoShape *shape )
if(!shape)
return;
KoShape * parent = shape;
KoPAPageBase * page = 0;
while ( !page && ( parent = parent->parent() ) )
{
page = dynamic_cast<KoPAPageBase*>( parent );
}
KoPAPageBase * page( getPage( shape ) );
bool isMaster = dynamic_cast<KoPAMasterPage*>( page ) != 0;
......@@ -341,6 +331,17 @@ void KoPADocument::removeShape( KoShape *shape )
}
}
KoPAPageBase * KoPADocument::getPage( KoShape * shape ) const
{
KoShape * parent = shape;
KoPAPageBase * page = 0;
while ( !page && ( parent = parent->parent() ) )
{
page = dynamic_cast<KoPAPageBase*>( parent );
}
return page;
}
void KoPADocument::insertPage( KoPAPageBase* page, int index )
{
if ( !page )
......
......@@ -108,6 +108,14 @@ protected:
void saveOdfAutomaticStyles( KoXmlWriter& contentWriter, KoGenStyles& mainStyles, bool stylesDotXml );
void saveOdfDocumentStyles( KoStore * store, KoGenStyles& mainStyles, QFile *masterStyles );
/**
* Get the page on which the shape is located
*
* @param shape The shape for which the page should be found
* @return The page on which the shape is located
*/
KoPAPageBase * getPage( KoShape * shape ) const;
private:
QList<KoPAPageBase*> m_pages;
QList<KoPAPageBase*> m_masterPages;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment