mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 13:04:58 +00:00
bug 809 from Michael, and some small changes to it
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6932 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f48e8300e1
commit
fc7c77587f
@ -59,9 +59,9 @@
|
|||||||
% the variable chk_<name>.
|
% the variable chk_<name>.
|
||||||
%%%
|
%%%
|
||||||
\newcommand{\prefix}{+} % the character used by grep to filter 'good' output
|
\newcommand{\prefix}{+} % the character used by grep to filter 'good' output
|
||||||
\newcommand{\AddLayout}[3][\default]{
|
\newcommand{\AddLayout}[4][\default]{
|
||||||
\def\default{#2}
|
\def\default{#2}
|
||||||
\immediate\write\layouts{"#2" "#1" "#3"}}
|
\immediate\write\layouts{"#2" "#1" "#3" "#4"}}
|
||||||
\newcommand{\AddVariable}[2]{
|
\newcommand{\AddVariable}[2]{
|
||||||
\immediate\write\sed{s!@chk_#1@!#2!g}
|
\immediate\write\sed{s!@chk_#1@!#2!g}
|
||||||
\immediate\write\vars{chk_#1='#2'}}
|
\immediate\write\vars{chk_#1='#2'}}
|
||||||
@ -107,15 +107,17 @@
|
|||||||
}
|
}
|
||||||
\newcommand{\DeclareLaTeXClass}[2][\default]{
|
\newcommand{\DeclareLaTeXClass}[2][\default]{
|
||||||
\TestItem[#1]{\layoutname}{document class}{cls}
|
\TestItem[#1]{\layoutname}{document class}{cls}
|
||||||
{\AddLayout[\firstelement]{\layoutname}{#2}}{}
|
{\AddLayout[\firstelement]{\layoutname}{#2}{true}}
|
||||||
|
{\AddLayout[\firstelement]{\layoutname}{#2}{false}}
|
||||||
\expandafter\endinput
|
\expandafter\endinput
|
||||||
}
|
}
|
||||||
\newcommand{\DeclareLinuxDocClass}[2][\default]{
|
\newcommand{\DeclareLinuxDocClass}[2][\default]{
|
||||||
\message{^^J\prefix checking for linuxdoc class \layoutname... }
|
\message{^^J\prefix checking for linuxdoc class \layoutname... }
|
||||||
\@ifundefined{haslinuxdoc}
|
\@ifundefined{haslinuxdoc}
|
||||||
{\message{no^^J}}
|
{\message{no^^J}
|
||||||
|
\AddLayout[#1]{\layoutname}{#2}{false}}
|
||||||
{\message{yes^^J}
|
{\message{yes^^J}
|
||||||
\AddLayout[#1]{\layoutname}{#2}}
|
\AddLayout[#1]{\layoutname}{#2}{true}}
|
||||||
\expandafter\endinput
|
\expandafter\endinput
|
||||||
}
|
}
|
||||||
% Only for compatibility. Will be removed later.
|
% Only for compatibility. Will be removed later.
|
||||||
@ -124,9 +126,10 @@
|
|||||||
\newcommand{\DeclareDocBookClass}[2][\default]{
|
\newcommand{\DeclareDocBookClass}[2][\default]{
|
||||||
\message{^^J\prefix checking for docbook\space\space class \layoutname... }
|
\message{^^J\prefix checking for docbook\space\space class \layoutname... }
|
||||||
\@ifundefined{hasdocbook}
|
\@ifundefined{hasdocbook}
|
||||||
{\message{no^^J}}
|
{\message{no^^J}
|
||||||
|
\AddLayout[#1]{\layoutname}{#2}{false}}
|
||||||
{\message{yes^^J}
|
{\message{yes^^J}
|
||||||
\AddLayout[#1]{\layoutname}{#2}}
|
\AddLayout[#1]{\layoutname}{#2}{true}}
|
||||||
\expandafter\endinput
|
\expandafter\endinput
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
2003-05-02 Michael Schmitt <michael.schmitt@teststep.org>
|
||||||
|
|
||||||
|
* bufferparams.C: Output warning if a document with missing
|
||||||
|
TeX document class is loaded
|
||||||
|
* exporter.C: Disable TeX exports if the document class is missing
|
||||||
|
* lyxtextclass.C:
|
||||||
|
* lyxtextclass.h:
|
||||||
|
* lyxtextclasslist.C: Handle new textclass.lst format; new method
|
||||||
|
isTeXClassAvailable()
|
||||||
|
|
||||||
2003-05-03 John Levon <levon@movementarian.org>
|
2003-05-03 John Levon <levon@movementarian.org>
|
||||||
|
|
||||||
* BufferView.h:
|
* BufferView.h:
|
||||||
|
@ -22,11 +22,15 @@
|
|||||||
#include "lyxlex.h"
|
#include "lyxlex.h"
|
||||||
#include "Lsstream.h"
|
#include "Lsstream.h"
|
||||||
#include "author.h"
|
#include "author.h"
|
||||||
|
#include "gettext.h"
|
||||||
|
|
||||||
#include "support/lyxalgo.h" // for lyx::count
|
#include "support/lyxalgo.h" // for lyx::count
|
||||||
#include "support/lyxlib.h"
|
#include "support/lyxlib.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/types.h"
|
#include "support/types.h"
|
||||||
|
#include "support/BoostFormat.h"
|
||||||
|
|
||||||
|
#include "frontends/Alert.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -92,6 +96,16 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
|
|||||||
textclass = 0;
|
textclass = 0;
|
||||||
return classname;
|
return classname;
|
||||||
}
|
}
|
||||||
|
if (!getLyXTextClass().isTeXClassAvailable()) {
|
||||||
|
string msg =
|
||||||
|
#if USE_BOOST_FORMAT
|
||||||
|
boost::io::str(boost::format(_("The document uses a missing TeX class \"%1$s\".\n")) % classname);
|
||||||
|
#else
|
||||||
|
_("The document uses a missing TeX class ") + classname + ".\n";
|
||||||
|
#endif
|
||||||
|
Alert::warning(_("Document class not available"),
|
||||||
|
msg + _("LyX will not be able to produce output."));
|
||||||
|
}
|
||||||
} else if (token == "\\begin_preamble") {
|
} else if (token == "\\begin_preamble") {
|
||||||
readPreamble(lex);
|
readPreamble(lex);
|
||||||
} else if (token == "\\options") {
|
} else if (token == "\\options") {
|
||||||
|
@ -176,6 +176,7 @@ string const Exporter::BufferFormat(Buffer const * buffer)
|
|||||||
vector<string> const Exporter::Backends(Buffer const * buffer)
|
vector<string> const Exporter::Backends(Buffer const * buffer)
|
||||||
{
|
{
|
||||||
vector<string> v;
|
vector<string> v;
|
||||||
|
if (buffer->params.getLyXTextClass().isTeXClassAvailable())
|
||||||
v.push_back(BufferFormat(buffer));
|
v.push_back(BufferFormat(buffer));
|
||||||
v.push_back("text");
|
v.push_back("text");
|
||||||
return v;
|
return v;
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2003-05-02 Michael Schmitt <michael.schmitt@teststep.org>
|
||||||
|
|
||||||
|
* QDocument.C:
|
||||||
|
* QDocumentDialog.C: Handle document classes with missing TeX class
|
||||||
|
(-> class name prefix: "Unavailable: ")
|
||||||
|
|
||||||
2003-05-03 John Levon <levon@movementarian.org>
|
2003-05-03 John Levon <levon@movementarian.org>
|
||||||
|
|
||||||
* qscreen.h:
|
* qscreen.h:
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "tex-strings.h" // tex_graphics
|
#include "tex-strings.h" // tex_graphics
|
||||||
#include "support/lstrings.h" // tostr()
|
#include "support/lstrings.h" // tostr()
|
||||||
#include "support/filetools.h" // LibFileSearch()
|
#include "support/filetools.h" // LibFileSearch()
|
||||||
|
#include "support/BoostFormat.h"
|
||||||
#include "lyxtextclasslist.h"
|
#include "lyxtextclasslist.h"
|
||||||
#include "vspace.h"
|
#include "vspace.h"
|
||||||
#include "bufferparams.h"
|
#include "bufferparams.h"
|
||||||
@ -122,7 +123,17 @@ void QDocument::build_dialog()
|
|||||||
// layout
|
// layout
|
||||||
for (LyXTextClassList::const_iterator cit = textclasslist.begin();
|
for (LyXTextClassList::const_iterator cit = textclasslist.begin();
|
||||||
cit != textclasslist.end(); ++cit) {
|
cit != textclasslist.end(); ++cit) {
|
||||||
|
if (cit->isTeXClassAvailable()) {
|
||||||
dialog_->latexModule->classCO->insertItem(toqstr(cit->description()));
|
dialog_->latexModule->classCO->insertItem(toqstr(cit->description()));
|
||||||
|
} else {
|
||||||
|
string item =
|
||||||
|
#if USE_BOOST_FORMAT
|
||||||
|
boost::io::str(boost::format(_("Unavailable: %1$s")) % cit->description());
|
||||||
|
#else
|
||||||
|
_("Unavailable: ") + cit->description();
|
||||||
|
#endif
|
||||||
|
dialog_->latexModule->classCO->insertItem(toqstr(item));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int n = 0; tex_fonts[n][0]; ++n) {
|
for (int n = 0; tex_fonts[n][0]; ++n) {
|
||||||
@ -499,13 +510,7 @@ void QDocument::update_contents()
|
|||||||
|
|
||||||
|
|
||||||
// layout
|
// layout
|
||||||
for (int n = 0; n<dialog_->latexModule->classCO->count(); ++n) {
|
dialog_->latexModule->classCO->setCurrentItem(params.textclass);
|
||||||
if (dialog_->latexModule->classCO->text(n) ==
|
|
||||||
toqstr(controller().textClass().description())) {
|
|
||||||
dialog_->latexModule->classCO->setCurrentItem(n);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog_->updateFontsize(controller().textClass().opt_fontsize(),
|
dialog_->updateFontsize(controller().textClass().opt_fontsize(),
|
||||||
params.fontsize);
|
params.fontsize);
|
||||||
|
@ -358,13 +358,7 @@ void QDocumentDialog::classChanged()
|
|||||||
params.pagestyle);
|
params.pagestyle);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int n = 0; n<latexModule->classCO->count(); ++n) {
|
latexModule->classCO->setCurrentItem(params.textclass);
|
||||||
if (latexModule->classCO->text(n) ==
|
|
||||||
toqstr(cntrl.textClass().description())) {
|
|
||||||
latexModule->classCO->setCurrentItem(n);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2003-05-02 Michael Schmitt <michael.schmitt@teststep.org>
|
||||||
|
|
||||||
|
* FormDocument.C: Handle document classes with missing TeX class
|
||||||
|
(-> class name prefix: "Unavailable: ")
|
||||||
|
|
||||||
2003-05-03 John Levon <levon@movementarian.org>
|
2003-05-03 John Levon <levon@movementarian.org>
|
||||||
|
|
||||||
* xscreen.h:
|
* xscreen.h:
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "support/lstrings.h" // contains_functor, getStringFromVector
|
#include "support/lstrings.h" // contains_functor, getStringFromVector
|
||||||
#include "support/filetools.h" // LibFileSearch
|
#include "support/filetools.h" // LibFileSearch
|
||||||
|
#include "support/BoostFormat.h"
|
||||||
|
|
||||||
#include XPM_H_LOCATION
|
#include XPM_H_LOCATION
|
||||||
#include FORMS_H_LOCATION
|
#include FORMS_H_LOCATION
|
||||||
@ -135,7 +136,17 @@ void FormDocument::build()
|
|||||||
LyXTextClassList::const_iterator tit = textclasslist.begin();
|
LyXTextClassList::const_iterator tit = textclasslist.begin();
|
||||||
LyXTextClassList::const_iterator tend = textclasslist.end();
|
LyXTextClassList::const_iterator tend = textclasslist.end();
|
||||||
for (; tit != tend; ++tit) {
|
for (; tit != tend; ++tit) {
|
||||||
|
if (tit->isTeXClassAvailable()) {
|
||||||
fl_addto_combox(obj, tit->description().c_str());
|
fl_addto_combox(obj, tit->description().c_str());
|
||||||
|
} else {
|
||||||
|
string item =
|
||||||
|
#if USE_BOOST_FORMAT
|
||||||
|
boost::io::str(boost::format(_("Unavailable: %1$s")) % tit->description());
|
||||||
|
#else
|
||||||
|
_("Unavailable: ") + tit->description();
|
||||||
|
#endif
|
||||||
|
fl_addto_combox(obj, item.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fl_set_combox_browser_height(obj, 400);
|
fl_set_combox_browser_height(obj, 400);
|
||||||
|
|
||||||
|
@ -50,9 +50,9 @@ struct compare_name {
|
|||||||
|
|
||||||
|
|
||||||
LyXTextClass::LyXTextClass(string const & fn, string const & cln,
|
LyXTextClass::LyXTextClass(string const & fn, string const & cln,
|
||||||
string const & desc)
|
string const & desc, bool texClassAvail )
|
||||||
: name_(fn), latexname_(cln), description_(desc),
|
: name_(fn), latexname_(cln), description_(desc),
|
||||||
floatlist_(new FloatList), ctrs_(new Counters)
|
floatlist_(new FloatList), ctrs_(new Counters), texClassAvail_(texClassAvail)
|
||||||
{
|
{
|
||||||
outputType_ = LATEX;
|
outputType_ = LATEX;
|
||||||
columns_ = 1;
|
columns_ = 1;
|
||||||
@ -71,6 +71,12 @@ LyXTextClass::LyXTextClass(string const & fn, string const & cln,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LyXTextClass::isTeXClassAvailable() const
|
||||||
|
{
|
||||||
|
return texClassAvail_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LyXTextClass::do_readStyle(LyXLex & lexrc, LyXLayout & lay)
|
bool LyXTextClass::do_readStyle(LyXLex & lexrc, LyXLayout & lay)
|
||||||
{
|
{
|
||||||
lyxerr[Debug::TCLASS] << "Reading style " << lay.name() << endl;
|
lyxerr[Debug::TCLASS] << "Reading style " << lay.name() << endl;
|
||||||
|
@ -35,7 +35,11 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
LyXTextClass(string const & = string(),
|
LyXTextClass(string const & = string(),
|
||||||
string const & = string(),
|
string const & = string(),
|
||||||
string const & = string());
|
string const & = string(),
|
||||||
|
bool = false);
|
||||||
|
|
||||||
|
/// check whether the TeX class is available
|
||||||
|
bool isTeXClassAvailable() const;
|
||||||
|
|
||||||
/// paragraph styles begin iterator.
|
/// paragraph styles begin iterator.
|
||||||
const_iterator begin() const { return layoutlist_.begin(); }
|
const_iterator begin() const { return layoutlist_.begin(); }
|
||||||
@ -217,6 +221,9 @@ private:
|
|||||||
|
|
||||||
/// Has this layout file been loaded yet?
|
/// Has this layout file been loaded yet?
|
||||||
mutable bool loaded;
|
mutable bool loaded;
|
||||||
|
|
||||||
|
/// Is the TeX class available?
|
||||||
|
bool texClassAvail_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,10 +62,16 @@ LyXTextClassList::operator[](textclass_type textclass) const
|
|||||||
|
|
||||||
|
|
||||||
// used when sorting the textclass list.
|
// used when sorting the textclass list.
|
||||||
class less_textclass_desc {
|
class less_textclass_avail_desc {
|
||||||
public:
|
public:
|
||||||
int operator()(LyXTextClass const & tc1, LyXTextClass const & tc2) {
|
int operator()(LyXTextClass const & tc1, LyXTextClass const & tc2) {
|
||||||
return tc1.description() < tc2.description();
|
// Ordering criteria:
|
||||||
|
// 1. Availability of text class
|
||||||
|
// 2. Description (lexicographic)
|
||||||
|
|
||||||
|
return (tc1.isTeXClassAvailable() && !tc2.isTeXClassAvailable()) ||
|
||||||
|
(tc1.isTeXClassAvailable() == tc2.isTeXClassAvailable() &&
|
||||||
|
tc1.description() < tc2.description());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -122,9 +128,12 @@ bool LyXTextClassList::Read()
|
|||||||
if (lex.next()) {
|
if (lex.next()) {
|
||||||
string const desc = lex.getString();
|
string const desc = lex.getString();
|
||||||
lyxerr[Debug::TCLASS] << "Desc: " << desc << endl;
|
lyxerr[Debug::TCLASS] << "Desc: " << desc << endl;
|
||||||
|
if (lex.next()) {
|
||||||
|
bool avail = lex.getBool();
|
||||||
|
lyxerr[Debug::TCLASS] << "Avail: " << avail << endl;
|
||||||
// This code is run when we have
|
// This code is run when we have
|
||||||
// fname, clname and desc
|
// fname, clname, desc, and avail
|
||||||
LyXTextClass tmpl(fname, clname, desc);
|
LyXTextClass tmpl(fname, clname, desc, avail);
|
||||||
if (lyxerr.debugging(Debug::TCLASS)) {
|
if (lyxerr.debugging(Debug::TCLASS)) {
|
||||||
tmpl.load();
|
tmpl.load();
|
||||||
}
|
}
|
||||||
@ -133,6 +142,7 @@ bool LyXTextClassList::Read()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
lyxerr[Debug::TCLASS] << "End of parsing of textclass.lst" << endl;
|
lyxerr[Debug::TCLASS] << "End of parsing of textclass.lst" << endl;
|
||||||
|
|
||||||
if (classlist_.empty()) {
|
if (classlist_.empty()) {
|
||||||
@ -141,7 +151,7 @@ bool LyXTextClassList::Read()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Ok everything loaded ok, now sort the list.
|
// Ok everything loaded ok, now sort the list.
|
||||||
sort(classlist_.begin(), classlist_.end(), less_textclass_desc());
|
sort(classlist_.begin(), classlist_.end(), less_textclass_avail_desc());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user