|
|
@ -1404,65 +1404,68 @@ void KPDFDocument::saveDocumentInfo() const
|
|
|
|
if ( d->docFileName.isNull() )
|
|
|
|
if ( d->docFileName.isNull() )
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
TQFile infoFile( d->xmlFileName );
|
|
|
|
if ( KpdfSettings::retainDocumentData() )
|
|
|
|
if (infoFile.open( IO_WriteOnly | IO_Truncate) )
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Create DOM
|
|
|
|
TQFile infoFile( d->xmlFileName );
|
|
|
|
TQDomDocument doc( "documentInfo" );
|
|
|
|
if (infoFile.open( IO_WriteOnly | IO_Truncate) )
|
|
|
|
TQDomElement root = doc.createElement( "documentInfo" );
|
|
|
|
{
|
|
|
|
doc.appendChild( root );
|
|
|
|
// Create DOM
|
|
|
|
|
|
|
|
TQDomDocument doc( "documentInfo" );
|
|
|
|
// Add bookmark list to DOM
|
|
|
|
TQDomElement root = doc.createElement( "documentInfo" );
|
|
|
|
TQDomElement bookmarkList = doc.createElement( "bookmarkList" );
|
|
|
|
doc.appendChild( root );
|
|
|
|
root.appendChild( bookmarkList );
|
|
|
|
|
|
|
|
|
|
|
|
// Add bookmark list to DOM
|
|
|
|
for ( uint i = 0; i < pages_vector.count() ; i++ )
|
|
|
|
TQDomElement bookmarkList = doc.createElement( "bookmarkList" );
|
|
|
|
{
|
|
|
|
root.appendChild( bookmarkList );
|
|
|
|
if ( pages_vector[i]->hasBookmark() )
|
|
|
|
|
|
|
|
{
|
|
|
|
for ( uint i = 0; i < pages_vector.count() ; i++ )
|
|
|
|
TQDomElement page = doc.createElement( "page" );
|
|
|
|
{
|
|
|
|
page.appendChild( doc.createTextNode( TQString::number(i) ) );
|
|
|
|
if ( pages_vector[i]->hasBookmark() )
|
|
|
|
|
|
|
|
{
|
|
|
|
bookmarkList.appendChild( page );
|
|
|
|
TQDomElement page = doc.createElement( "page" );
|
|
|
|
}
|
|
|
|
page.appendChild( doc.createTextNode( TQString::number(i) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bookmarkList.appendChild( page );
|
|
|
|
// Add general info to DOM
|
|
|
|
}
|
|
|
|
TQDomElement generalInfo = doc.createElement( "generalInfo" );
|
|
|
|
}
|
|
|
|
root.appendChild( generalInfo );
|
|
|
|
|
|
|
|
|
|
|
|
// Add general info to DOM
|
|
|
|
// <general info><history> ... </history> saves history up to 10 viewports
|
|
|
|
TQDomElement generalInfo = doc.createElement( "generalInfo" );
|
|
|
|
TQValueList< DocumentViewport >::iterator backIterator = d->viewportIterator;
|
|
|
|
root.appendChild( generalInfo );
|
|
|
|
if ( backIterator != d->viewportHistory.end() )
|
|
|
|
|
|
|
|
{
|
|
|
|
// <general info><history> ... </history> saves history up to 10 viewports
|
|
|
|
// go back up to 10 steps from the current viewportIterator
|
|
|
|
TQValueList< DocumentViewport >::iterator backIterator = d->viewportIterator;
|
|
|
|
int backSteps = 10;
|
|
|
|
if ( backIterator != d->viewportHistory.end() )
|
|
|
|
while ( backSteps-- && backIterator != d->viewportHistory.begin() )
|
|
|
|
{
|
|
|
|
--backIterator;
|
|
|
|
// go back up to 10 steps from the current viewportIterator
|
|
|
|
|
|
|
|
int backSteps = 10;
|
|
|
|
// create history root node
|
|
|
|
while ( backSteps-- && backIterator != d->viewportHistory.begin() )
|
|
|
|
TQDomElement historyNode = doc.createElement( "history" );
|
|
|
|
--backIterator;
|
|
|
|
generalInfo.appendChild( historyNode );
|
|
|
|
|
|
|
|
|
|
|
|
// create history root node
|
|
|
|
// add old[backIterator] and present[viewportIterator] items
|
|
|
|
TQDomElement historyNode = doc.createElement( "history" );
|
|
|
|
TQValueList< DocumentViewport >::iterator endIt = d->viewportIterator;
|
|
|
|
generalInfo.appendChild( historyNode );
|
|
|
|
++endIt;
|
|
|
|
|
|
|
|
while ( backIterator != endIt )
|
|
|
|
// add old[backIterator] and present[viewportIterator] items
|
|
|
|
{
|
|
|
|
TQValueList< DocumentViewport >::iterator endIt = d->viewportIterator;
|
|
|
|
TQString name = (backIterator == d->viewportIterator) ? "current" : "oldPage";
|
|
|
|
++endIt;
|
|
|
|
TQDomElement historyEntry = doc.createElement( name );
|
|
|
|
while ( backIterator != endIt )
|
|
|
|
historyEntry.setAttribute( "viewport", (*backIterator).toString() );
|
|
|
|
{
|
|
|
|
historyNode.appendChild( historyEntry );
|
|
|
|
TQString name = (backIterator == d->viewportIterator) ? "current" : "oldPage";
|
|
|
|
++backIterator;
|
|
|
|
TQDomElement historyEntry = doc.createElement( name );
|
|
|
|
}
|
|
|
|
historyEntry.setAttribute( "viewport", (*backIterator).toString() );
|
|
|
|
}
|
|
|
|
historyNode.appendChild( historyEntry );
|
|
|
|
|
|
|
|
++backIterator;
|
|
|
|
// Save DOM to XML file
|
|
|
|
}
|
|
|
|
TQString xml = doc.toString();
|
|
|
|
}
|
|
|
|
TQTextStream os( &infoFile );
|
|
|
|
|
|
|
|
os << xml;
|
|
|
|
// Save DOM to XML file
|
|
|
|
|
|
|
|
TQString xml = doc.toString();
|
|
|
|
|
|
|
|
TQTextStream os( &infoFile );
|
|
|
|
|
|
|
|
os << xml;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
infoFile.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
infoFile.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KPDFDocument::slotTimedMemoryCheck()
|
|
|
|
void KPDFDocument::slotTimedMemoryCheck()
|
|
|
|