mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-24 12:34:39 +03:00
Pages are cloned before generation to prevent them from changing by init script
This commit is contained in:
parent
c406920206
commit
3019f239f0
@ -858,13 +858,13 @@ QString ReportEnginePrivate::renderToString()
|
||||
if (m_pages.count()){
|
||||
render.setDatasources(dataManager());
|
||||
render.setScriptContext(scriptContext());
|
||||
return render.renderPageToString(m_pages.at(0));
|
||||
return render.renderPageToString(m_pages.at(0)->pageItem());
|
||||
}else return QString();
|
||||
}
|
||||
|
||||
PageDesignIntf* ReportEnginePrivate::getPageByName(const QString& pageName)
|
||||
PageItemDesignIntf* ReportEnginePrivate::getPageByName(const QString& pageName)
|
||||
{
|
||||
foreach(PageDesignIntf* page, m_pages){
|
||||
foreach(PageItemDesignIntf* page, m_renderingPages){
|
||||
if ( page->objectName().compare(pageName, Qt::CaseInsensitive) == 0)
|
||||
return page;
|
||||
}
|
||||
@ -931,10 +931,10 @@ void ReportEnginePrivate::activateLanguage(QLocale::Language language)
|
||||
ReportTranslation* translation = m_translations.value(language);
|
||||
|
||||
foreach(PageTranslation* pageTranslation, translation->pagesTranslation()){
|
||||
PageDesignIntf* page = getPageByName(pageTranslation->pageName);
|
||||
PageItemDesignIntf* page = getPageByName(pageTranslation->pageName);
|
||||
if (page){
|
||||
foreach(ItemTranslation* itemTranslation, pageTranslation->itemsTranslation){
|
||||
BaseDesignIntf* item = page->pageItem()->childByName(itemTranslation->itemName);
|
||||
BaseDesignIntf* item = page->childByName(itemTranslation->itemName);
|
||||
if (item) {
|
||||
foreach(PropertyTranslation* propertyTranslation, itemTranslation->propertyesTranslation){
|
||||
item->setProperty(propertyTranslation->propertyName.toLatin1(), propertyTranslation->value);
|
||||
@ -1017,6 +1017,13 @@ void ReportEnginePrivate::setPreviewWindowIcon(const QIcon &previewWindowIcon)
|
||||
m_previewWindowIcon = previewWindowIcon;
|
||||
}
|
||||
|
||||
PageItemDesignIntf* ReportEnginePrivate::createRenderingPage(PageItemDesignIntf* page){
|
||||
PageItemDesignIntf* result = dynamic_cast<PageItemDesignIntf*>(page->cloneItem(page->itemMode()));
|
||||
ICollectionContainer* co = dynamic_cast<ICollectionContainer*>(result);
|
||||
if (co) co->collectionLoadFinished("children");
|
||||
return result;
|
||||
}
|
||||
|
||||
ReportPages ReportEnginePrivate::renderToPages()
|
||||
{
|
||||
if (m_reportRendering) return ReportPages();
|
||||
@ -1031,6 +1038,7 @@ ReportPages ReportEnginePrivate::renderToPages()
|
||||
this, SIGNAL(renderPageFinished(int)));
|
||||
|
||||
if (m_pages.count()){
|
||||
|
||||
#ifdef HAVE_UI_LOADER
|
||||
m_scriptEngineContext->initDialogs();
|
||||
#endif
|
||||
@ -1041,7 +1049,9 @@ ReportPages ReportEnginePrivate::renderToPages()
|
||||
m_reportRender->setScriptContext(scriptContext());
|
||||
|
||||
foreach (PageDesignIntf* page, m_pages) {
|
||||
scriptContext()->baseDesignIntfToScript(page->pageItem()->objectName(), page->pageItem());
|
||||
PageItemDesignIntf* rp = createRenderingPage(page->pageItem());
|
||||
m_renderingPages.append(rp);
|
||||
scriptContext()->baseDesignIntfToScript(rp->objectName(), rp);
|
||||
}
|
||||
|
||||
scriptContext()->qobjectToScript("engine",this);
|
||||
@ -1051,27 +1061,25 @@ ReportPages ReportEnginePrivate::renderToPages()
|
||||
activateLanguage(m_reportLanguage);
|
||||
emit renderStarted();
|
||||
|
||||
foreach(PageDesignIntf* page , m_pages){
|
||||
if (!page->pageItem()->isTOC()){
|
||||
foreach(PageItemDesignIntf* page , m_renderingPages){
|
||||
if (!page->isTOC() && page->isPrintable()){
|
||||
page->setReportSettings(&m_reportSettings);
|
||||
result.append(m_reportRender->renderPageToPages(page));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// m_reportRender->secondRenderPass(result);
|
||||
|
||||
for (int i=0; i<m_pages.count(); ++i){
|
||||
PageDesignIntf* page = m_pages.at(i);
|
||||
if (page->pageItem()->isTOC()){
|
||||
for (int i=0; i<m_renderingPages.count(); ++i){
|
||||
PageItemDesignIntf* page = m_renderingPages.at(i);
|
||||
if (page->isTOC()){
|
||||
page->setReportSettings(&m_reportSettings);
|
||||
if (i==0){
|
||||
PageDesignIntf* secondPage = 0;
|
||||
if (m_pages.count()>1) secondPage = m_pages.at(1);
|
||||
PageItemDesignIntf* secondPage = 0;
|
||||
if (m_pages.count()>1) secondPage = m_renderingPages.at(1);
|
||||
ReportPages pages = m_reportRender->renderTOC(
|
||||
page,
|
||||
true,
|
||||
secondPage && secondPage->pageItem()->resetPageNumber()
|
||||
secondPage && secondPage->resetPageNumber()
|
||||
);
|
||||
for (int j=0; j<pages.count(); ++j){
|
||||
result.insert(j,pages.at(j));
|
||||
@ -1087,9 +1095,14 @@ ReportPages ReportEnginePrivate::renderToPages()
|
||||
|
||||
emit renderFinished();
|
||||
m_reportRender.clear();
|
||||
|
||||
foreach(PageItemDesignIntf* page, m_renderingPages){
|
||||
delete page;
|
||||
}
|
||||
m_renderingPages.clear();
|
||||
}
|
||||
m_reportRendering = false;
|
||||
activateLanguage(QLocale::AnyLanguage);
|
||||
//activateLanguage(QLocale::AnyLanguage);
|
||||
return result;
|
||||
} else {
|
||||
return ReportPages();
|
||||
|
@ -214,10 +214,12 @@ private:
|
||||
//ITranslationContainer
|
||||
ReportPages renderToPages();
|
||||
QString renderToString();
|
||||
PageDesignIntf* getPageByName(const QString& pageName);
|
||||
PageItemDesignIntf *getPageByName(const QString& pageName);
|
||||
ATranslationProperty fakeTranslationReader(){ return ATranslationProperty();}
|
||||
PageItemDesignIntf *createRenderingPage(PageItemDesignIntf *page);
|
||||
private:
|
||||
QList<PageDesignIntf*> m_pages;
|
||||
QList<PageItemDesignIntf*> m_renderingPages;
|
||||
DataSourceManager* m_datasources;
|
||||
ScriptEngineContext* m_scriptEngineContext;
|
||||
ReportRender::Ptr m_reportRender;
|
||||
|
@ -187,10 +187,10 @@ void ReportRender::initDatasource(const QString& name){
|
||||
}
|
||||
}
|
||||
|
||||
void ReportRender::renderPage(PageDesignIntf* patternPage, bool isTOC, bool isFirst, bool resetPageNumbers)
|
||||
void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool isFirst, bool resetPageNumbers)
|
||||
{
|
||||
m_curentNameIndex = 0;
|
||||
m_patternPageItem = patternPage->pageItem();
|
||||
m_patternPageItem = patternPage;
|
||||
m_renderingFirstTOC = isTOC && isFirst;
|
||||
|
||||
if (m_patternPageItem->resetPageNumber() && m_pageCount>0 && !isTOC) {
|
||||
@ -269,19 +269,19 @@ PageItemDesignIntf::Ptr ReportRender::pageAt(int index)
|
||||
else return m_renderedPages.at(index);
|
||||
}
|
||||
|
||||
QString ReportRender::renderPageToString(PageDesignIntf *patternPage)
|
||||
QString ReportRender::renderPageToString(PageItemDesignIntf *patternPage)
|
||||
{
|
||||
renderPage(patternPage);
|
||||
return toString();
|
||||
}
|
||||
|
||||
ReportPages ReportRender::renderPageToPages(PageDesignIntf *patternPage)
|
||||
ReportPages ReportRender::renderPageToPages(PageItemDesignIntf *patternPage)
|
||||
{
|
||||
renderPage(patternPage);
|
||||
return m_renderedPages;
|
||||
}
|
||||
|
||||
ReportPages ReportRender::renderTOC(PageDesignIntf* patternPage, bool first, bool resetPages){
|
||||
ReportPages ReportRender::renderTOC(PageItemDesignIntf* patternPage, bool first, bool resetPages){
|
||||
renderPage(patternPage, true, first, resetPages);
|
||||
return m_renderedPages;
|
||||
}
|
||||
@ -1134,7 +1134,7 @@ BandDesignIntf *ReportRender::renderData(BandDesignIntf *patternBand)
|
||||
{
|
||||
BandDesignIntf* bandClone = dynamic_cast<BandDesignIntf*>(patternBand->cloneItem(PreviewMode));
|
||||
|
||||
m_scriptEngineContext->baseDesignIntfToScript(patternBand->page()->pageItem()->objectName(), bandClone);
|
||||
m_scriptEngineContext->baseDesignIntfToScript(patternBand->parent()->objectName(), bandClone);
|
||||
m_scriptEngineContext->setCurrentBand(bandClone);
|
||||
emit(patternBand->beforeRender());
|
||||
|
||||
|
@ -80,9 +80,9 @@ public:
|
||||
DataSourceManager* datasources(){return m_datasources;}
|
||||
int pageCount();
|
||||
PageItemDesignIntf::Ptr pageAt(int index);
|
||||
QString renderPageToString(PageDesignIntf *patternPage);
|
||||
ReportPages renderPageToPages(PageDesignIntf *patternPage);
|
||||
ReportPages renderTOC(PageDesignIntf* patternPage, bool first, bool resetPages);
|
||||
QString renderPageToString(PageItemDesignIntf *patternPage);
|
||||
ReportPages renderPageToPages(PageItemDesignIntf *patternPage);
|
||||
ReportPages renderTOC(PageItemDesignIntf *patternPage, bool first, bool resetPages);
|
||||
void secondRenderPass(ReportPages renderedPages);
|
||||
signals:
|
||||
void pageRendered(int renderedPageCount);
|
||||
@ -96,7 +96,7 @@ private:
|
||||
void initGroups();
|
||||
void clearPageMap();
|
||||
|
||||
void renderPage(PageDesignIntf *patternPage, bool isTOC = false, bool isFirst = false, bool resetPageNumbers = false);
|
||||
void renderPage(PageItemDesignIntf *patternPage, bool isTOC = false, bool isFirst = false, bool resetPageNumbers = false);
|
||||
BandDesignIntf* renderBand(BandDesignIntf *patternBand, BandDesignIntf *bandData, DataRenderMode mode = NotStartNewPage, bool isLast = false);
|
||||
void renderDataBand(BandDesignIntf* dataBand);
|
||||
void renderPageHeader(PageItemDesignIntf* patternPage);
|
||||
|
@ -32,7 +32,7 @@ ReportTranslation::~ReportTranslation()
|
||||
PageTranslation* ReportTranslation::createPageTranslation(PageDesignIntf* page)
|
||||
{
|
||||
PageTranslation* pageTranslation = new PageTranslation;
|
||||
pageTranslation->pageName = page->objectName();
|
||||
pageTranslation->pageName = page->pageItem()->objectName();
|
||||
foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){
|
||||
createItemTranslation(item, pageTranslation);
|
||||
}
|
||||
|
@ -78,8 +78,14 @@ void TranslationEditor::updateUi()
|
||||
ui->lvLanguages->addItem(QLocale::languageToString(language));
|
||||
}
|
||||
if (!translations->keys().isEmpty()){
|
||||
ui->lvLanguages->item(0)->setSelected(true);
|
||||
activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text()));
|
||||
if (ui->lvLanguages->count()!=0){
|
||||
ui->lvLanguages->item(0)->setSelected(true);
|
||||
activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text()));
|
||||
} else {
|
||||
//activateLanguage(QLocale::AnyLanguage);
|
||||
ui->twPages->clear();
|
||||
ui->tbStrings->setRowCount(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user