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