Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 4573c7a6 authored by Albert Astals Cid's avatar Albert Astals Cid

Recalculate forms after other are edited

BUGS: 376958
parent 20a81c9d
......@@ -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<int> formCalculateOrder = fco.value<QVector<int>>();
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 )
......
......@@ -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();
......
......@@ -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<QVector<int>>(pdfdoc->formCalculateOrder());
#endif
}
return QVariant();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment