diff --git a/core/document.cpp b/core/document.cpp index 460deb1fe..f8f825c6a 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -1119,6 +1119,35 @@ void DocumentPrivate::performSetAnnotationContents( const QString & newContents, performModifyPageAnnotation( pageNumber, annot, appearanceChanged ); } +void DocumentPrivate::recalculateForms() +{ + const QVariant fco = m_parent->metaData(QLatin1String("FormCalculateOrder")); + const QVector formCalculateOrder = fco.value>(); + foreach(int formId, formCalculateOrder) { + for ( uint pageIdx = 0; pageIdx < m_parent->pages(); pageIdx++ ) + { + const Page *p = m_parent->page( pageIdx ); + if (p) + { + foreach( FormField *form, p->formFields() ) + { + if ( form->id() == formId ) { + Action *action = form->additionalAction( FormField::CalculateField ); + if (action) + { + m_parent->processAction( action ); + } + else + { + qWarning() << "Form that is part of calculate order doesn't have a calculate action"; + } + } + } + } + } + } +} + void DocumentPrivate::saveDocumentInfo() const { if ( m_xmlFileName.isEmpty() ) @@ -3697,6 +3726,8 @@ void Document::editFormText( int pageNumber, { QUndoCommand *uc = new EditFormTextCommand( this->d, form, pageNumber, newContents, newCursorPos, form->text(), prevCursorPos, prevAnchorPos ); d->m_undoStack->push( uc ); + + d->recalculateForms(); } void Document::editFormList( int pageNumber, @@ -3706,6 +3737,8 @@ void Document::editFormList( int pageNumber, const QList< int > prevChoices = form->currentChoices(); QUndoCommand *uc = new EditFormListCommand( this->d, form, pageNumber, newChoices, prevChoices ); d->m_undoStack->push( uc ); + + d->recalculateForms(); } void Document::editFormCombo( int pageNumber, @@ -3728,6 +3761,8 @@ void Document::editFormCombo( int pageNumber, QUndoCommand *uc = new EditFormComboCommand( this->d, form, pageNumber, newText, newCursorPos, prevText, prevCursorPos, prevAnchorPos ); d->m_undoStack->push( uc ); + + d->recalculateForms(); } void Document::editFormButtons( int pageNumber, const QList< FormFieldButton* >& formButtons, const QList< bool >& newButtonStates ) diff --git a/core/document_p.h b/core/document_p.h index af697a65b..851194d30 100644 --- a/core/document_p.h +++ b/core/document_p.h @@ -145,6 +145,8 @@ class DocumentPrivate void performModifyPageAnnotation( int page, Annotation * annotation, bool appearanceChanged ); void performSetAnnotationContents( const QString & newContents, Annotation *annot, int pageNumber ); + void recalculateForms(); + // private slots void saveDocumentInfo() const; void slotTimedMemoryCheck(); diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp index 8c562aca9..42ccb3a26 100644 --- a/generators/poppler/generator_pdf.cpp +++ b/generators/poppler/generator_pdf.cpp @@ -1242,6 +1242,13 @@ QVariant PDFGenerator::metaData( const QString & key, const QVariant & option ) QMutexLocker ml(userMutex()); return pdfdoc->formType() == Poppler::Document::XfaForm; } + else if ( key == QLatin1String("FormCalculateOrder") ) + { +#ifdef HAVE_POPPLER_0_53 + QMutexLocker ml(userMutex()); + return QVariant::fromValue>(pdfdoc->formCalculateOrder()); +#endif + } return QVariant(); }