mirror of
https://invent.kde.org/graphics/okular
synced 2024-07-07 19:29:21 +00:00
Don't save form contents to docdata/
But existing saved form from previous Okular versions are preserved
This commit is contained in:
parent
3b227582d2
commit
57c9cae257
|
@ -1198,12 +1198,13 @@ void DocumentPrivate::saveDocumentInfo() const
|
||||||
// 2.1. Save page attributes (bookmark state, annotations, ... ) to DOM
|
// 2.1. Save page attributes (bookmark state, annotations, ... ) to DOM
|
||||||
QDomElement pageList = doc.createElement( "pageList" );
|
QDomElement pageList = doc.createElement( "pageList" );
|
||||||
root.appendChild( pageList );
|
root.appendChild( pageList );
|
||||||
// OriginalAnnotationPageItems tells to store the same unmodified
|
// OriginalAnnotationPageItems and OriginalFormFieldPageItems tell to
|
||||||
// annotation list that we read when we opened the file and ignore any
|
// store the same unmodified annotation list and form contents that we
|
||||||
// change made by the user. Since we don't store annotations in
|
// read when we opened the file and ignore any change made by the user.
|
||||||
// docdata/ any more, this is necessary to preserve annotations that
|
// Since we don't store annotations and forms docdata/ any more, this is
|
||||||
// previous Okular version had stored there.
|
// necessary to preserve annotations/forms that previous Okular version
|
||||||
const PageItems saveWhat = AllPageItems | OriginalAnnotationPageItems;
|
// had stored there.
|
||||||
|
const PageItems saveWhat = AllPageItems | OriginalAnnotationPageItems | OriginalFormFieldPageItems;
|
||||||
// <page list><page number='x'>.... </page> save pages that hold data
|
// <page list><page number='x'>.... </page> save pages that hold data
|
||||||
QVector< Page * >::const_iterator pIt = m_pagesVector.constBegin(), pEnd = m_pagesVector.constEnd();
|
QVector< Page * >::const_iterator pIt = m_pagesVector.constBegin(), pEnd = m_pagesVector.constEnd();
|
||||||
for ( ; pIt != pEnd; ++pIt )
|
for ( ; pIt != pEnd; ++pIt )
|
||||||
|
@ -2921,6 +2922,16 @@ void DocumentPrivate::notifyAnnotationChanges( int page )
|
||||||
foreachObserverD( notifyPageChanged( page, flags ) );
|
foreachObserverD( notifyPageChanged( page, flags ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DocumentPrivate::notifyFormChanges( int page )
|
||||||
|
{
|
||||||
|
// Unless we're still loading initial form contents from metadata, the user
|
||||||
|
// now needs to save or form changes will be lost
|
||||||
|
if ( !m_metadataLoadingCompleted )
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreachObserverD( notifyPageChanged( page, DocumentObserver::NeedSaveAs ) );
|
||||||
|
}
|
||||||
|
|
||||||
void Document::addPageAnnotation( int page, Annotation * annotation )
|
void Document::addPageAnnotation( int page, Annotation * annotation )
|
||||||
{
|
{
|
||||||
// Transform annotation's base boundary rectangle into unrotated coordinates
|
// Transform annotation's base boundary rectangle into unrotated coordinates
|
||||||
|
|
|
@ -133,6 +133,7 @@ class DocumentPrivate
|
||||||
bool savePageDocumentInfo( KTemporaryFile *infoFile, int what ) const;
|
bool savePageDocumentInfo( KTemporaryFile *infoFile, int what ) const;
|
||||||
DocumentViewport nextDocumentViewport() const;
|
DocumentViewport nextDocumentViewport() const;
|
||||||
void notifyAnnotationChanges( int page );
|
void notifyAnnotationChanges( int page );
|
||||||
|
void notifyFormChanges( int page );
|
||||||
bool canAddAnnotationsNatively() const;
|
bool canAddAnnotationsNatively() const;
|
||||||
bool canModifyExternalAnnotations() const;
|
bool canModifyExternalAnnotations() const;
|
||||||
bool canRemoveExternalAnnotations() const;
|
bool canRemoveExternalAnnotations() const;
|
||||||
|
|
|
@ -368,6 +368,7 @@ void EditFormTextCommand::undo()
|
||||||
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
|
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
|
||||||
m_form->setText( m_prevContents );
|
m_form->setText( m_prevContents );
|
||||||
emit m_docPriv->m_parent->formTextChangedByUndoRedo( m_pageNumber, m_form, m_prevContents, m_prevCursorPos, m_prevAnchorPos );
|
emit m_docPriv->m_parent->formTextChangedByUndoRedo( m_pageNumber, m_form, m_prevContents, m_prevCursorPos, m_prevAnchorPos );
|
||||||
|
m_docPriv->notifyFormChanges( m_pageNumber );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditFormTextCommand::redo()
|
void EditFormTextCommand::redo()
|
||||||
|
@ -375,6 +376,7 @@ void EditFormTextCommand::redo()
|
||||||
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
|
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
|
||||||
m_form->setText( m_newContents );
|
m_form->setText( m_newContents );
|
||||||
emit m_docPriv->m_parent->formTextChangedByUndoRedo( m_pageNumber, m_form, m_newContents, m_newCursorPos, m_newCursorPos );
|
emit m_docPriv->m_parent->formTextChangedByUndoRedo( m_pageNumber, m_form, m_newContents, m_newCursorPos, m_newCursorPos );
|
||||||
|
m_docPriv->notifyFormChanges( m_pageNumber );
|
||||||
}
|
}
|
||||||
|
|
||||||
int EditFormTextCommand::id() const
|
int EditFormTextCommand::id() const
|
||||||
|
@ -415,6 +417,7 @@ void EditFormListCommand::undo()
|
||||||
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
|
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
|
||||||
m_form->setCurrentChoices( m_prevChoices );
|
m_form->setCurrentChoices( m_prevChoices );
|
||||||
emit m_docPriv->m_parent->formListChangedByUndoRedo( m_pageNumber, m_form, m_prevChoices );
|
emit m_docPriv->m_parent->formListChangedByUndoRedo( m_pageNumber, m_form, m_prevChoices );
|
||||||
|
m_docPriv->notifyFormChanges( m_pageNumber );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditFormListCommand::redo()
|
void EditFormListCommand::redo()
|
||||||
|
@ -422,6 +425,7 @@ void EditFormListCommand::redo()
|
||||||
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
|
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
|
||||||
m_form->setCurrentChoices( m_newChoices );
|
m_form->setCurrentChoices( m_newChoices );
|
||||||
emit m_docPriv->m_parent->formListChangedByUndoRedo( m_pageNumber, m_form, m_newChoices );
|
emit m_docPriv->m_parent->formListChangedByUndoRedo( m_pageNumber, m_form, m_newChoices );
|
||||||
|
m_docPriv->notifyFormChanges( m_pageNumber );
|
||||||
}
|
}
|
||||||
|
|
||||||
EditFormComboCommand::EditFormComboCommand( Okular::DocumentPrivate* docPriv,
|
EditFormComboCommand::EditFormComboCommand( Okular::DocumentPrivate* docPriv,
|
||||||
|
@ -468,6 +472,7 @@ void EditFormComboCommand::undo()
|
||||||
}
|
}
|
||||||
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
|
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
|
||||||
emit m_docPriv->m_parent->formComboChangedByUndoRedo( m_pageNumber, m_form, m_prevContents, m_prevCursorPos, m_prevAnchorPos );
|
emit m_docPriv->m_parent->formComboChangedByUndoRedo( m_pageNumber, m_form, m_prevContents, m_prevCursorPos, m_prevAnchorPos );
|
||||||
|
m_docPriv->notifyFormChanges( m_pageNumber );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditFormComboCommand::redo()
|
void EditFormComboCommand::redo()
|
||||||
|
@ -482,6 +487,7 @@ void EditFormComboCommand::redo()
|
||||||
}
|
}
|
||||||
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
|
moveViewportIfBoundingRectNotFullyVisible( m_form->rect(), m_docPriv, m_pageNumber );
|
||||||
emit m_docPriv->m_parent->formComboChangedByUndoRedo( m_pageNumber, m_form, m_newContents, m_newCursorPos, m_newCursorPos );
|
emit m_docPriv->m_parent->formComboChangedByUndoRedo( m_pageNumber, m_form, m_newContents, m_newCursorPos, m_newCursorPos );
|
||||||
|
m_docPriv->notifyFormChanges( m_pageNumber );
|
||||||
}
|
}
|
||||||
|
|
||||||
int EditFormComboCommand::id() const
|
int EditFormComboCommand::id() const
|
||||||
|
@ -538,6 +544,7 @@ void EditFormButtonsCommand::undo()
|
||||||
Okular::NormalizedRect boundingRect = buildBoundingRectangleForButtons( m_formButtons );
|
Okular::NormalizedRect boundingRect = buildBoundingRectangleForButtons( m_formButtons );
|
||||||
moveViewportIfBoundingRectNotFullyVisible( boundingRect, m_docPriv, m_pageNumber );
|
moveViewportIfBoundingRectNotFullyVisible( boundingRect, m_docPriv, m_pageNumber );
|
||||||
emit m_docPriv->m_parent->formButtonsChangedByUndoRedo( m_pageNumber, m_formButtons );
|
emit m_docPriv->m_parent->formButtonsChangedByUndoRedo( m_pageNumber, m_formButtons );
|
||||||
|
m_docPriv->notifyFormChanges( m_pageNumber );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditFormButtonsCommand::redo()
|
void EditFormButtonsCommand::redo()
|
||||||
|
@ -553,6 +560,7 @@ void EditFormButtonsCommand::redo()
|
||||||
Okular::NormalizedRect boundingRect = buildBoundingRectangleForButtons( m_formButtons );
|
Okular::NormalizedRect boundingRect = buildBoundingRectangleForButtons( m_formButtons );
|
||||||
moveViewportIfBoundingRectNotFullyVisible( boundingRect, m_docPriv, m_pageNumber );
|
moveViewportIfBoundingRectNotFullyVisible( boundingRect, m_docPriv, m_pageNumber );
|
||||||
emit m_docPriv->m_parent->formButtonsChangedByUndoRedo( m_pageNumber, m_formButtons );
|
emit m_docPriv->m_parent->formButtonsChangedByUndoRedo( m_pageNumber, m_formButtons );
|
||||||
|
m_docPriv->notifyFormChanges( m_pageNumber );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditFormButtonsCommand::clearFormButtonStates()
|
void EditFormButtonsCommand::clearFormButtonStates()
|
||||||
|
|
|
@ -45,7 +45,7 @@ class OKULAR_EXPORT DocumentObserver
|
||||||
TextSelection = 8, ///< Text selection has been changed
|
TextSelection = 8, ///< Text selection has been changed
|
||||||
Annotations = 16, ///< Annotations have been changed
|
Annotations = 16, ///< Annotations have been changed
|
||||||
BoundingBox = 32, ///< Bounding boxes have been changed
|
BoundingBox = 32, ///< Bounding boxes have been changed
|
||||||
NeedSaveAs = 64 ///< Set along with Annotations when Save As is needed or annotation changes will be lost @since 0.15 (KDE 4.9)
|
NeedSaveAs = 64 ///< Set when "Save" is needed or annotation/form changes will be lost @since 0.15 (KDE 4.9)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -832,6 +832,10 @@ void PagePrivate::restoreLocalContents( const QDomNode & pageNode )
|
||||||
// parse formList child element
|
// parse formList child element
|
||||||
else if ( childElement.tagName() == "forms" )
|
else if ( childElement.tagName() == "forms" )
|
||||||
{
|
{
|
||||||
|
// Clone forms as root node in restoredFormFieldList
|
||||||
|
const QDomNode clonedNode = restoredFormFieldList.importNode( childElement, true );
|
||||||
|
restoredFormFieldList.appendChild( clonedNode );
|
||||||
|
|
||||||
if ( formfields.isEmpty() )
|
if ( formfields.isEmpty() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -927,7 +931,17 @@ void PagePrivate::saveLocalContents( QDomNode & parentNode, QDomDocument & docum
|
||||||
}
|
}
|
||||||
|
|
||||||
// add forms info if has got any
|
// add forms info if has got any
|
||||||
if ( ( what & FormFieldPageItems ) && !formfields.isEmpty() )
|
if ( ( what & FormFieldPageItems ) && ( what & OriginalFormFieldPageItems ) )
|
||||||
|
{
|
||||||
|
const QDomElement savedDocRoot = restoredFormFieldList.documentElement();
|
||||||
|
if ( !savedDocRoot.isNull() )
|
||||||
|
{
|
||||||
|
// Import and append node in target document
|
||||||
|
const QDomNode importedNode = document.importNode( savedDocRoot, true );
|
||||||
|
pageElement.appendChild( importedNode );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( ( what & FormFieldPageItems ) && !formfields.isEmpty() )
|
||||||
{
|
{
|
||||||
// create the formList
|
// create the formList
|
||||||
QDomElement formListElement = document.createElement( "forms" );
|
QDomElement formListElement = document.createElement( "forms" );
|
||||||
|
|
|
@ -48,7 +48,11 @@ enum PageItem
|
||||||
|
|
||||||
/* If set along with AnnotationPageItems, tells saveLocalContents to save
|
/* If set along with AnnotationPageItems, tells saveLocalContents to save
|
||||||
* the original annotations (if any) instead of the modified ones */
|
* the original annotations (if any) instead of the modified ones */
|
||||||
OriginalAnnotationPageItems = 0x100
|
OriginalAnnotationPageItems = 0x100,
|
||||||
|
|
||||||
|
/* If set along with FormFieldPageItems, tells saveLocalContents to save
|
||||||
|
* the original form contents (if any) instead of the modified one */
|
||||||
|
OriginalFormFieldPageItems = 0x200
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(PageItems, PageItem)
|
Q_DECLARE_FLAGS(PageItems, PageItem)
|
||||||
|
|
||||||
|
@ -142,6 +146,7 @@ class PagePrivate
|
||||||
|
|
||||||
bool m_isBoundingBoxKnown : 1;
|
bool m_isBoundingBoxKnown : 1;
|
||||||
QDomDocument restoredLocalAnnotationList; // <annotationList>...</annotationList>
|
QDomDocument restoredLocalAnnotationList; // <annotationList>...</annotationList>
|
||||||
|
QDomDocument restoredFormFieldList; // <forms>...</forms>
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user