コード例 #1
0
void BFSRunner::pagesParsed()
{
	if (m_urlsLeft == 0) {
		stop();
		emit bfsDone();
	}
	else {
		m_depth++;
		QList<Page *> pages;
		Page *page;
		for (const QString &url : m_newUrls) {
			if (m_visited.count(url) > 0) {
				continue;
			}
			m_visited.insert(url);
			m_urlsLeft--;
			page = new Page(url, m_text, m_depth);
			m_pages.push(page);
			pages << page;
			if (m_urlsLeft == 0) {
				break;
			}
		}
		m_newUrls.clear();
		emit newPages(pages);
	}
}
コード例 #2
0
void BFSRunner::runBfs(QString url, QString text, quint32 threads, quint32 urls)
{
	m_maxThreads = threads;
	m_urlsLeft = urls - 1;
	m_depth = 0;
	m_text = text;
	m_visited.insert(url);
	Page *page = new Page(url, text);
	m_pages.push(page);
	emit newPages(QList<Page *>() << page);

	run();
}
コード例 #3
0
bool KoPAPastePage::process( const KoXmlElement & body, KoOdfReadStore & odfStore )
{
    KoOdfLoadingContext loadingContext( odfStore.styles(), odfStore.store(), m_doc->defaultStylesResourcePath() );
    KoPALoadingContext paContext(loadingContext, m_doc->resourceManager());

    QList<KoPAPageBase *> newMasterPages( m_doc->loadOdfMasterPages( odfStore.styles().masterPages(), paContext ) );
    QList<KoPAPageBase *> newPages( m_doc->loadOdfPages( body, paContext ) );

    // Check where to start inserting pages
    KoPAPageBase * insertAfterPage = 0;
    KoPAPageBase * insertAfterMasterPage = 0;
    if ( dynamic_cast<KoPAMasterPage *>( m_activePage ) || ( m_activePage == 0 && newPages.empty() ) ) {
        insertAfterMasterPage = m_activePage;
        insertAfterPage = m_doc->pages( false ).last();
    }
    else {
        insertAfterPage = m_activePage;
        insertAfterMasterPage = m_doc->pages( true ).last();
    }

    if ( !newPages.empty() ) {
        KoGenStyles mainStyles;
        QBuffer buffer;
        buffer.open( QIODevice::WriteOnly );
        KoXmlWriter xmlWriter( &buffer );
        KoEmbeddedDocumentSaver embeddedSaver;
        KoPASavingContext savingContext(xmlWriter, mainStyles, embeddedSaver, 1);
        savingContext.addOption( KoShapeSavingContext::UniqueMasterPages );
        QList<KoPAPageBase*> emptyList;
        QList<KoPAPageBase*> existingMasterPages = m_doc->pages( true );
        savingContext.setClearDrawIds( true );
        m_doc->saveOdfPages( savingContext, emptyList, existingMasterPages );

        QMap<QString, KoPAMasterPage*> masterPageNames;

        foreach ( KoPAPageBase * page, existingMasterPages )
        {
            KoPAMasterPage * masterPage = dynamic_cast<KoPAMasterPage*>( page );
            Q_ASSERT( masterPage );
            if ( masterPage ) {
                QString masterPageName( savingContext.masterPageName( masterPage ) );
                if ( !masterPageNames.contains( masterPageName ) ) {
                    masterPageNames.insert( masterPageName, masterPage );
                }
            }

        }