From 1af3b165c9377702ca62a64112bc089a6f575c30 Mon Sep 17 00:00:00 2001 From: "Roberto C. Sanchez" Date: Tue, 21 Oct 2014 22:48:19 -0400 Subject: Imported Upstream version 2.0~beta2 --- bibletime/backend/chtmlexportrendering.cpp | 236 ----------------------------- 1 file changed, 236 deletions(-) delete mode 100644 bibletime/backend/chtmlexportrendering.cpp (limited to 'bibletime/backend/chtmlexportrendering.cpp') diff --git a/bibletime/backend/chtmlexportrendering.cpp b/bibletime/backend/chtmlexportrendering.cpp deleted file mode 100644 index a32d57c..0000000 --- a/bibletime/backend/chtmlexportrendering.cpp +++ /dev/null @@ -1,236 +0,0 @@ -// -// C++ Implementation: chtmlexportrendering -// -// Description: -// -// -// Author: The BibleTime team , (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// -// - -//Backend -#include "chtmlexportrendering.h" - -#include "cdisplaytemplatemgr.h" -#include "clanguagemgr.h" -#include "cswordkey.h" -#include "cswordversekey.h" -#include "cswordmoduleinfo.h" - -//Util -#include "util/cpointers.h" -#include "util/scoped_resource.h" - -//KDE includes -#include - -namespace Rendering { - - CHTMLExportRendering::CHTMLExportRendering(const CHTMLExportRendering::Settings& settings, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) -: m_displayOptions(displayOptions), - m_filterOptions(filterOptions), - m_settings(settings) {} - - CHTMLExportRendering::~CHTMLExportRendering() {} - - const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey* k) { - // qDebug("CHTMLExportRendering::renderEntry"); - - if (i.hasAlternativeContent()) { - QString ret; - ret.setLatin1(i.settings().highlight ? "
" : "
"); - ret.append(i.getAlternativeContent()); - - // Q_ASSERT(i.hasChildItems()); - - if (i.hasChildItems()) { - KeyTree const * tree = i.childList(); - - const ListCSwordModuleInfo& modules( tree->collectModules() ); - - if (modules.count() == 1) { //insert the direction into the sorrounding div - ret.insert( 5, QString("dir=\"%1\" ").arg((modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl" )); - } - - for ( KeyTreeItem* c = tree->first(); c; c = tree->next() ) { - ret.append( renderEntry( *c ) ); - } - } - - ret.append("
"); - return ret; //WARNING: Return already here! - } - - - const ListCSwordModuleInfo& modules( i.modules() ); - - Q_ASSERT(modules.count() >= 1); - - util::scoped_ptr scoped_key( !k ? CSwordKey::createInstance(modules.first()) : 0 ); - - CSwordKey* key = k ? k : scoped_key; - - Q_ASSERT(key); - - CSwordVerseKey* myVK = dynamic_cast(key); - - if ( myVK ) { - myVK->Headings(1); - } - - QString renderedText( (modules.count() > 1) ? "" : "" ); - - if (modules.count() == 0) { - return QString(""); //no module present for rendering - } - - // Only insert the table stuff if we are displaying parallel. - // Otherwise, strip out he table stuff -> the whole chapter will be rendered in one cell! - - //declarations out of the loop for optimization - QString entry; - - QString keyText; - - bool isRTL; - - //taken out of the loop for optimization - QString preverseHeading; - - QString langAttr; - - ListCSwordModuleInfo::const_iterator end_modItr = modules.end(); - - for (ListCSwordModuleInfo::const_iterator mod_Itr(modules.begin()); mod_Itr != end_modItr; ++mod_Itr) { - key->module(*mod_Itr); - key->key( i.key() ); - - keyText = key->key(); - isRTL = ((*mod_Itr)->textDirection() == CSwordModuleInfo::RightToLeft); - entry = QString::null; - - if ((*mod_Itr)->language()->isValid()) { - langAttr.setLatin1("xml:lang=\"") - .append((*mod_Itr)->language()->abbrev()) - .append("\" lang=\"") - .append((*mod_Itr)->language()->abbrev()) - .append("\""); - } - else { - langAttr.setLatin1("xml:lang=\"") - .append((*mod_Itr)->module()->Lang()) - .append("\" lang=\"") - .append((*mod_Itr)->module()->Lang()) - .append("\""); - } - - const QString key_renderedText = key->renderedText(); - - // qWarning(key_renderedText.latin1()); - - if (m_filterOptions.headings) { - AttributeValue::const_iterator it = - (*mod_Itr)->module()->getEntryAttributes()["Heading"]["Preverse"].begin(); - const AttributeValue::const_iterator end = - (*mod_Itr)->module()->getEntryAttributes()["Heading"]["Preverse"].end(); - - for (; it != end; ++it) { - preverseHeading = QString::fromUtf8(it->second.c_str()); - - //TODO: Take care of the heading type! - - if (!preverseHeading.isEmpty()) { - entry.append("
") - .append(preverseHeading) - .append("
"); - } - } - } - - entry.append(m_displayOptions.lineBreaks ? "
"); - - //keys should normally be left-to-right, but this doesn't apply in all cases - entry.append("").append(entryLink(i, *mod_Itr)).append(""); - - if (m_settings.addText) { - //entry.append( QString::fromLatin1("%2").arg(langAttr).arg(key_renderedText) ); - entry.append( key_renderedText ); - } - - if (i.hasChildItems()) { - KeyTree const * tree = i.childList(); - - for (KeyTreeItem* c = tree->first(); c; c = tree->next()) { - entry.append( renderEntry(*c) ); - } - } - - entry.append(m_displayOptions.lineBreaks ? "
\n" : "\n"); - - if (modules.count() == 1) { - renderedText.append( entry ); - } - else { - renderedText.append("") - .append(entry) - .append("\n"); - } - } - - if (modules.count() > 1) { - renderedText.append("\n"); - } - - // qDebug("CHTMLExportRendering: %s", renderedText.latin1()); - return renderedText; - } - - void CHTMLExportRendering::initRendering() { - CPointers::backend()->setDisplayOptions( m_displayOptions ); - CPointers::backend()->setFilterOptions( m_filterOptions ); - } - - const QString CHTMLExportRendering::finishText( const QString& text, KeyTree& tree ) { - ListCSwordModuleInfo modules = tree.collectModules(); - - const CLanguageMgr::Language* const lang = modules.first()->language(); - - CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager(); - CDisplayTemplateMgr::Settings settings; - settings.modules = modules; - settings.langAbbrev = ((modules.count() == 1) && lang->isValid()) - ? lang->abbrev() - : "unknown"; - settings.pageDirection = (modules.count() == 1) - ? ((modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl") - : QString::null; - - return tMgr->fillTemplate(i18n("Export"), text, settings); - } - - /*! - \fn CHTMLExportRendering::entryLink( KeyTreeItem& item ) - */ - const QString CHTMLExportRendering::entryLink( const KeyTreeItem& item, CSwordModuleInfo* ) { - return item.key(); - } - -} - -; //end of namespace "Rendering" -- cgit v1.2.3