mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Move some code around in an effort to make information about modules
available to tex2lyx. The point is to move the crucial routines that deal with modules out of BufferParams.cpp, which tex2lyx does not have, and into TextClass.cpp, which it does. This is all cleanup that makes a lot of sense independently. Note that LayoutModuleList will shortly become a real class. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28456 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7e4d4d2641
commit
52d3a1e426
@ -1708,41 +1708,8 @@ void BufferParams::makeDocumentClass()
|
||||
if (!baseClass())
|
||||
return;
|
||||
|
||||
doc_class_ = &(DocumentClassBundle::get().newClass(*baseClass()));
|
||||
doc_class_ = &(DocumentClassBundle::get().makeDocumentClass(*baseClass(), layoutModules_));
|
||||
|
||||
// FIXME It might be worth loading the children's modules here,
|
||||
// just as we load their bibliographies and such, instead of just
|
||||
// doing a check in InsetInclude.
|
||||
LayoutModuleList::const_iterator it = layoutModules_.begin();
|
||||
for (; it != layoutModules_.end(); it++) {
|
||||
string const modName = *it;
|
||||
LyXModule * lm = moduleList[modName];
|
||||
if (!lm) {
|
||||
docstring const msg =
|
||||
bformat(_("The module %1$s has been requested by\n"
|
||||
"this document but has not been found in the list of\n"
|
||||
"available modules. If you recently installed it, you\n"
|
||||
"probably need to reconfigure LyX.\n"), from_utf8(modName));
|
||||
frontend::Alert::warning(_("Module not available"),
|
||||
msg + _("Some layouts may not be available."));
|
||||
LYXERR0("BufferParams::makeDocumentClass(): Module " <<
|
||||
modName << " requested but not found in module list.");
|
||||
continue;
|
||||
}
|
||||
if (!lm->isAvailable()) {
|
||||
docstring const msg =
|
||||
bformat(_("The module %1$s requires a package that is\n"
|
||||
"not available in your LaTeX installation. LaTeX output\n"
|
||||
"may not be possible.\n"), from_utf8(modName));
|
||||
frontend::Alert::warning(_("Package not available"), msg);
|
||||
}
|
||||
FileName layout_file = libFileSearch("layouts", lm->getFilename());
|
||||
if (!doc_class_->read(layout_file, TextClass::MODULE)) {
|
||||
docstring const msg =
|
||||
bformat(_("Error reading module %1$s\n"), from_utf8(modName));
|
||||
frontend::Alert::warning(_("Read Error"), msg);
|
||||
}
|
||||
}
|
||||
if (!local_layout.empty()) {
|
||||
if (!doc_class_->read(local_layout, TextClass::MODULE)) {
|
||||
docstring const msg = _("Error reading internal layout information");
|
||||
|
@ -15,8 +15,9 @@
|
||||
#ifndef BUFFERPARAMS_H
|
||||
#define BUFFERPARAMS_H
|
||||
|
||||
#include "Font.h"
|
||||
#include "Citation.h"
|
||||
#include "Font.h"
|
||||
#include "LayoutModuleList.h"
|
||||
#include "paper.h"
|
||||
|
||||
#include "insets/InsetQuotes.h"
|
||||
@ -53,8 +54,6 @@ class VSpace;
|
||||
*/
|
||||
class BufferParams {
|
||||
public:
|
||||
///
|
||||
typedef std::list<std::string> LayoutModuleList;
|
||||
///
|
||||
enum ParagraphSeparation {
|
||||
///
|
||||
|
22
src/LayoutModuleList.h
Normal file
22
src/LayoutModuleList.h
Normal file
@ -0,0 +1,22 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file ModuleList.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Richard Heck
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef LAYOUTMODULELIST_H
|
||||
#define LAYOUTMODULELIST_H
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
namespace lyx {
|
||||
///
|
||||
typedef std::list<std::string> LayoutModuleList;
|
||||
}
|
||||
#endif
|
@ -219,6 +219,7 @@ HEADERFILESCORE = \
|
||||
Layout.h \
|
||||
LayoutEnums.h \
|
||||
LayoutFile.h \
|
||||
LayoutModuleList.h \
|
||||
Length.h \
|
||||
Lexer.h \
|
||||
LyXAction.h \
|
||||
|
@ -45,6 +45,9 @@ LyXModule::LyXModule(string const & n, string const & i,
|
||||
|
||||
|
||||
bool LyXModule::isAvailable() {
|
||||
#ifdef TEX2LYX
|
||||
return true;
|
||||
#else
|
||||
if (packageList.empty())
|
||||
return true;
|
||||
if (checked)
|
||||
@ -61,6 +64,7 @@ bool LyXModule::isAvailable() {
|
||||
}
|
||||
available = true;
|
||||
return available;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "Layout.h"
|
||||
#include "Lexer.h"
|
||||
#include "Font.h"
|
||||
#include "ModuleList.h"
|
||||
|
||||
#include "frontends/alert.h"
|
||||
|
||||
@ -1105,6 +1106,45 @@ DocumentClassBundle & DocumentClassBundle::get()
|
||||
}
|
||||
|
||||
|
||||
DocumentClass & DocumentClassBundle::makeDocumentClass(
|
||||
LayoutFile const & baseClass, LayoutModuleList const & modlist)
|
||||
{
|
||||
DocumentClass & doc_class = newClass(baseClass);
|
||||
LayoutModuleList::const_iterator it = modlist.begin();
|
||||
LayoutModuleList::const_iterator en = modlist.end();
|
||||
for (; it != en; it++) {
|
||||
string const modName = *it;
|
||||
LyXModule * lm = moduleList[modName];
|
||||
if (!lm) {
|
||||
docstring const msg =
|
||||
bformat(_("The module %1$s has been requested by\n"
|
||||
"this document but has not been found in the list of\n"
|
||||
"available modules. If you recently installed it, you\n"
|
||||
"probably need to reconfigure LyX.\n"), from_utf8(modName));
|
||||
ExceptionMessage(WarningException,_("Module not available"),
|
||||
msg + _("Some layouts may not be available."));
|
||||
LYXERR0("DocumentClassBundle::makeDocumentClass(): Module " <<
|
||||
modName << " requested but not found in module list.");
|
||||
continue;
|
||||
}
|
||||
if (!lm->isAvailable()) {
|
||||
docstring const msg =
|
||||
bformat(_("The module %1$s requires a package that is\n"
|
||||
"not available in your LaTeX installation. LaTeX output\n"
|
||||
"may not be possible.\n"), from_utf8(modName));
|
||||
ExceptionMessage(WarningException, _("Package not available"), msg);
|
||||
}
|
||||
FileName layout_file = libFileSearch("layouts", lm->getFilename());
|
||||
if (!doc_class.read(layout_file, TextClass::MODULE)) {
|
||||
docstring const msg =
|
||||
bformat(_("Error reading module %1$s\n"), from_utf8(modName));
|
||||
throw ExceptionMessage(WarningException, _("Read Error"), msg);
|
||||
}
|
||||
}
|
||||
return doc_class;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DocumentClass
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "FontInfo.h"
|
||||
#include "Layout.h"
|
||||
#include "LayoutEnums.h"
|
||||
#include "LayoutModuleList.h"
|
||||
|
||||
#include "insets/InsetLayout.h"
|
||||
|
||||
@ -254,11 +255,11 @@ protected:
|
||||
/// latex packages requested by document class.
|
||||
std::set<std::string> requires_;
|
||||
/// default modules wanted by document class
|
||||
std::list<std::string> default_modules_;
|
||||
LayoutModuleList default_modules_;
|
||||
/// modules provided by document class
|
||||
std::list<std::string> provided_modules_;
|
||||
LayoutModuleList provided_modules_;
|
||||
/// modules excluded by document class
|
||||
std::list<std::string> excluded_modules_;
|
||||
LayoutModuleList excluded_modules_;
|
||||
///
|
||||
unsigned int columns_;
|
||||
///
|
||||
@ -429,15 +430,19 @@ private:
|
||||
/// DocumentClassBundle::get().
|
||||
class DocumentClassBundle : boost::noncopyable {
|
||||
public:
|
||||
/// \return Pointer to a new class equal to baseClass
|
||||
DocumentClass & newClass(LayoutFile const & baseClass);
|
||||
/// \return The sole instance of this class.
|
||||
static DocumentClassBundle & get();
|
||||
/// \return A new DocumentClass based on baseClass, with info added
|
||||
/// from the modules in modlist.
|
||||
DocumentClass & makeDocumentClass(LayoutFile const & baseClass,
|
||||
LayoutModuleList const & modlist);
|
||||
private:
|
||||
/// control instantiation
|
||||
DocumentClassBundle() {}
|
||||
/// clean up
|
||||
~DocumentClassBundle();
|
||||
/// \return Reference to a new DocumentClass equal to baseClass
|
||||
DocumentClass & newClass(LayoutFile const & baseClass);
|
||||
///
|
||||
std::vector<DocumentClass *> documentClasses_;
|
||||
};
|
||||
|
@ -36,6 +36,9 @@ LINKED_FILES = \
|
||||
../LayoutFile.h \
|
||||
../Layout.h \
|
||||
../Layout.cpp \
|
||||
../LayoutModuleList.h \
|
||||
../ModuleList.h \
|
||||
../ModuleList.cpp \
|
||||
../TextClass.cpp \
|
||||
../TextClass.h \
|
||||
../Lexer.cpp \
|
||||
|
Loading…
Reference in New Issue
Block a user