KoTableOfContentsGeneratorInfo::KoTableOfContentsGeneratorInfo(bool generateEntryTemplate) : m_indexScope("document") , m_outlineLevel(10) , m_relativeTabStopPosition(true) , m_useIndexMarks(true) , m_useIndexSourceStyles(false) , m_useOutlineLevel(true) { // index-title-template // m_indexTitleTemplate.text = "title"; if (generateEntryTemplate) { // table-of-content-entry-template for (int level = 1; level <= m_outlineLevel; level++) { TocEntryTemplate tocEntryTemplate; tocEntryTemplate.outlineLevel = level; // index-entry-link-start IndexEntryLinkStart *link = new IndexEntryLinkStart(QString()); tocEntryTemplate.indexEntries.append(static_cast<IndexEntry*>(link)); // index-entry-chapter // use null String if the style name is not present, it means that we inherit it from the parent IndexEntryChapter *entryChapter = new IndexEntryChapter(QString()); entryChapter->display = "number"; entryChapter->outlineLevel = level; tocEntryTemplate.indexEntries.append(static_cast<IndexEntry*>(entryChapter)); // index-entry-text IndexEntryText *entryText = new IndexEntryText(QString()); tocEntryTemplate.indexEntries.append(static_cast<IndexEntry*>(entryText)); // index-entry-tab-stop IndexEntryTabStop *entryTabStop = new IndexEntryTabStop(QString()); entryTabStop->tab.type = QTextOption::RightTab; entryTabStop->setPosition(""); entryTabStop->tab.leaderText = '.'; tocEntryTemplate.indexEntries.append(static_cast<IndexEntry*>(entryTabStop)); // index-entry-page-number IndexEntryPageNumber *entryPageNumber = new IndexEntryPageNumber(QString()); tocEntryTemplate.indexEntries.append(static_cast<IndexEntry*>(entryPageNumber) ); // index-entry-link-end IndexEntryLinkEnd *linkend = new IndexEntryLinkEnd(QString()); tocEntryTemplate.indexEntries.append(static_cast<IndexEntry*>(linkend)); m_entryTemplate.append(tocEntryTemplate); } } }
void KoBibliographyInfo::loadOdf(KoTextSharedLoadingData *sharedLoadingData, const KoXmlElement& element) { Q_ASSERT(element.localName() == "bibliography-source" && element.namespaceURI() == KoXmlNS::text); KoXmlElement p; forEachElement(p, element) { if (p.namespaceURI() != KoXmlNS::text) { continue; } // first child if (p.localName() == "index-title-template") { m_indexTitleTemplate.styleName = p.attribute("style-name"); m_indexTitleTemplate.styleId = styleNameToStyleId(sharedLoadingData, m_indexTitleTemplate.styleName); m_indexTitleTemplate.text = p.text(); // second child } else if (p.localName() == "bibliography-entry-template") { BibliographyEntryTemplate bibEntryTemplate; bibEntryTemplate.styleName = p.attribute("style-name"); bibEntryTemplate.bibliographyType = p.attribute("bibliography-type"); bibEntryTemplate.styleId = styleNameToStyleId(sharedLoadingData, bibEntryTemplate.styleName ); KoXmlElement indexEntry; forEachElement(indexEntry, p) { if (indexEntry.namespaceURI() != KoXmlNS::text) { continue; } if (indexEntry.localName() == "index-entry-bibliography") { // use null String if the style name is not present, it means that we inherit it from the parent IndexEntryBibliography * entryBibliography = new IndexEntryBibliography( indexEntry.attribute("style-name", QString()) ); entryBibliography->dataField = indexEntry.attribute("bibliography-data-field", "article"); bibEntryTemplate.indexEntries.append(static_cast<IndexEntry*>(entryBibliography)); } else if (indexEntry.localName() == "index-entry-span") { IndexEntrySpan * entrySpan = new IndexEntrySpan(indexEntry.attribute("style-name", QString())); entrySpan->text = indexEntry.text(); bibEntryTemplate.indexEntries.append(static_cast<IndexEntry*>(entrySpan)); } else if (indexEntry.localName() == "index-entry-tab-stop") { IndexEntryTabStop * entryTabStop = new IndexEntryTabStop(indexEntry.attribute("style-name", QString())); QString type = indexEntry.attribute("type","right"); // left or right if (type == "left") { entryTabStop->tab.type = QTextOption::LeftTab; } else { entryTabStop->tab.type = QTextOption::RightTab; } entryTabStop->setPosition(indexEntry.attribute("position", QString())); entryTabStop->tab.leaderText = indexEntry.attribute("leader-char","."); bibEntryTemplate.indexEntries.append(static_cast<IndexEntry*>(entryTabStop)); } } m_entryTemplate[bibEntryTemplate.bibliographyType] = bibEntryTemplate; // third child } }// forEachElement