Exemple #1
0
 // update pages which have a duplicate master page
 foreach (KoPAPage * page, pages)
 {
     KoPAPage * p = dynamic_cast<KoPAPage*>(page);
     Q_ASSERT(p);
     if (p) {
         KoPAMasterPage * masterPage(p->masterPage());
         QMap<KoPAMasterPage*, KoPAMasterPage*>::const_iterator pageIt(updateMasterPage.constFind(masterPage));
         if (pageIt != updateMasterPage.constEnd()) {
             p->setMasterPage(pageIt.value());
         }
     }
 }
void KPrAnimationDirector::updateActivePage( KoPAPageBase * page )
{
    deactivate();

    if ( m_canvas == m_view->kopaCanvas() ) {
        m_view->viewMode()->updateActivePage( page );
    }
    else {
        QList<KoShape*> shapes = page->shapes();
        m_canvas->shapeManager()->setShapes(shapes, KoShapeManager::AddWithoutRepaint);
        //Make the top most layer active
        if ( !shapes.isEmpty() ) {
            KoShapeLayer* layer = dynamic_cast<KoShapeLayer*>( shapes.last() );
            m_canvas->shapeManager()->selection()->setActiveLayer( layer );
        }

        // if the page is not a master page itself set shapes of the master page
        KoPAPage * paPage = dynamic_cast<KoPAPage *>( page );

        Q_ASSERT( paPage );
        KoPAMasterPage * masterPage = paPage->masterPage();
        QList<KoShape*> masterShapes = masterPage->shapes();
        m_canvas->masterShapeManager()->setShapes(masterShapes, KoShapeManager::AddWithoutRepaint);
        // Make the top most layer active
        if ( !masterShapes.isEmpty() ) {
            KoShapeLayer* layer = dynamic_cast<KoShapeLayer*>( masterShapes.last() );
            m_canvas->masterShapeManager()->selection()->setActiveLayer( layer );
        }
    }

    KPrPage * kprPage = dynamic_cast<KPrPage *>( page );
    Q_ASSERT( kprPage );
    if (m_pageIndex > m_pages.size() || m_pageIndex < 0) {
        m_pageIndex = m_pages.indexOf(page);
    }
    m_animations = kprPage->animations().steps();

    // it can be that the pages have different sizes. So we need to recalulate
    // the zoom when we change the page
    updateZoom( m_canvas->size() );
}
KoPAOdfPageSaveHelper::KoPAOdfPageSaveHelper( KoPADocument * doc, QList<KoPAPageBase *> pages )
    : m_doc(doc),
    m_context(0)
{
    foreach( KoPAPageBase * page, pages ) {
        if ( dynamic_cast<KoPAPage *>( page ) ) {
            m_pages.append( page );
        }
        else {
            m_masterPages.append( page );
        }
    }

    if ( m_pages.size() > 0 ) {
        m_masterPages.clear();

        // this might result in a different order of master pages when copying to a different document
        QSet<KoPAPageBase *> masterPages;
        foreach( KoPAPageBase * page, m_pages ) {
            KoPAPage * p = static_cast<KoPAPage *>( page );
            masterPages.insert( p->masterPage() );
        }
Exemple #4
0
void KPrPicturesImport::import(KPrView *view)
{
    m_factory = KoShapeRegistry::instance()->value("PictureShape");
    Q_ASSERT(m_factory);
    if (m_factory) {
        m_urls = KFileDialog::getOpenUrls(KUrl(), "image/png image/jpeg image/gif");

        // TODO there should be a progress bar
        // instead of the progress bar opening for each loaded picture
        m_currentPage = view->activePage();
        KoPAPage *activePage = dynamic_cast<KoPAPage*>(m_currentPage);
        if (activePage) {
            m_masterPage = activePage->masterPage();

            m_doc = view->kprDocument();
            m_cmd = new KUndo2Command(kundo2_i18n("Insert Pictures"));
            import();
        }
    }
    else {
        kWarning(33001) << "picture shape factory not found";
    }
}