Commit b43fe1ce authored by Pino Toscano's avatar Pino Toscano

djvu toc:

- do not skip any entry
- better detection of the destination in case it is a page number, a page name or a url
- simplier handling of page numbers as destination

svn path=/trunk/KDE/kdegraphics/okular/; revision=890869
parent 769a7095
......@@ -40,16 +40,12 @@ static void recurseCreateTOC( QDomDocument &maindoc, const QDomNode &parent, QDo
QDomElement newel = maindoc.createElement( el.attribute( "title" ) );
parentDestination.appendChild( newel );
if ( !el.attribute( "destination" ).isEmpty() )
QString dest;
if ( !( dest = el.attribute( "PageNumber" ) ).isEmpty() )
{
bool ok = true;
int page = el.attribute( "destination" ).toInt( &ok );
if ( ok && ( page > 0 ) )
{
Okular::DocumentViewport vp;
vp.pageNumber = page - 1;
newel.setAttribute( "Viewport", vp.toString() );
}
Okular::DocumentViewport vp;
vp.pageNumber = dest.toInt() - 1;
newel.setAttribute( "Viewport", vp.toString() );
}
if ( el.hasChildNodes() )
......
......@@ -534,14 +534,30 @@ void KDjVu::Private::fillBookmarksRecurse( QDomDocument& maindoc, QDomNode& curn
{
QString title = QString::fromUtf8( miniexp_to_str( miniexp_nth( 0, cur ) ) );
QString dest = QString::fromUtf8( miniexp_to_str( miniexp_nth( 1, cur ) ) );
QDomElement el;
if ( dest.isEmpty() || ( ( dest.at( 0 ) == QLatin1Char( '#' ) ) && ( dest.remove( 0, 1 ) != title ) ) )
QDomElement el = maindoc.createElement( "item" );
el.setAttribute( "title", title );
if ( !dest.isEmpty() )
{
el = maindoc.createElement( "item" );
el.setAttribute( "title", title );
el.setAttribute( "destination", dest );
curnode.appendChild( el );
if ( dest.at( 0 ) == QLatin1Char( '#' ) )
{
dest.remove( 0, 1 );
bool isNumber = false;
dest.toInt( &isNumber );
if ( isNumber )
{
el.setAttribute( "PageNumber", dest );
}
else
{
el.setAttribute( "PageName", dest );
}
}
else
{
el.setAttribute( "URL", dest );
}
}
curnode.appendChild( el );
if ( !el.isNull() && ( miniexp_length( cur ) > 2 ) )
{
fillBookmarksRecurse( maindoc, el, cur, 2 );
......
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