UT_UTF8String IE_Exp_HTML_NavigationHelper::getFilenameByPosition(
    PT_DocPosition position) const
{
    PT_DocPosition posCurrent;
	char * s = UT_go_basename_from_uri(m_baseName);
    UT_UTF8String chapterFile = s;
	g_free(s);

    if (hasTOC())
    {
        for (int i = getNumTOCEntries() - 1; i >= m_minTOCIndex; i--)
        {
            int currentLevel;
            getNthTOCEntry(i, &currentLevel);
            getNthTOCEntryPos(i, posCurrent);

            if (currentLevel == m_minTOCLevel)
            {
                if ((i != m_minTOCIndex) && (posCurrent <= position))
                {
                    chapterFile = ConvertToClean(getNthTOCEntry(i, NULL)) + m_suffix;
                    break;
                }
                else if ((i == m_minTOCIndex) && (posCurrent >= position))
                {
                    break;
                }
            }
        }
    }

    UT_DEBUGMSG(("Got filename by position: %s\n", chapterFile.utf8_str()));
    return chapterFile;
}
Exemplo n.º 2
0
void TOC::notifySetup( const QValueVector< KPDFPage * > & /*pages*/, bool documentChanged )
{
    if ( !documentChanged )
        return;

    // clear contents
    clear();

    // request synopsis description (is a dom tree)
    const DocumentSynopsis * syn = m_document->documentSynopsis();

    // if not present, disable the contents tab
    if ( !syn )
    {
        emit hasTOC( false );
        return;
    }

    // else populate the listview and enable the tab
    addChildren( *syn );
    emit hasTOC( true );
}