2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file bufferparams.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Alfredo Braunstein
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \author Martin Vermeer
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "bufferparams.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
|
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include "author.h"
|
|
|
|
|
#include "BranchList.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
|
#include "Bullet.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "debug.h"
|
2003-02-16 00:54:43 +00:00
|
|
|
|
#include "encoding.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "gettext.h"
|
2000-03-10 13:22:20 +00:00
|
|
|
|
#include "language.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2003-09-16 09:44:34 +00:00
|
|
|
|
#include "LColor.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "lyxlex.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
|
#include "lyxrc.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "lyxtextclasslist.h"
|
2003-11-05 12:06:20 +00:00
|
|
|
|
#include "outputparams.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "tex-strings.h"
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include "Spacing.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "texrow.h"
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include "vspace.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "frontends/Alert.h"
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
2003-02-16 00:54:43 +00:00
|
|
|
|
#include "support/lyxalgo.h" // for lyx::count
|
2005-01-06 16:39:35 +00:00
|
|
|
|
#include "support/convert.h"
|
2004-10-05 13:18:28 +00:00
|
|
|
|
#include "support/translator.h"
|
2003-05-03 19:24:36 +00:00
|
|
|
|
|
2003-09-09 17:00:19 +00:00
|
|
|
|
#include <boost/array.hpp>
|
|
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
2000-02-22 00:36:17 +00:00
|
|
|
|
|
2003-09-09 17:00:19 +00:00
|
|
|
|
namespace support = lyx::support;
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::bformat;
|
|
|
|
|
using lyx::support::rtrim;
|
|
|
|
|
using lyx::support::tokenPos;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2003-09-06 23:36:02 +00:00
|
|
|
|
using std::endl;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::istringstream;
|
2000-04-04 00:19:15 +00:00
|
|
|
|
using std::ostream;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::ostringstream;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
using std::pair;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
|
namespace biblio = lyx::biblio;
|
|
|
|
|
|
2003-05-13 16:24:49 +00:00
|
|
|
|
|
2004-10-05 13:18:28 +00:00
|
|
|
|
// Local translators
|
2004-08-20 13:06:33 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2004-10-05 13:18:28 +00:00
|
|
|
|
// Paragraph separation
|
2005-01-05 20:21:27 +00:00
|
|
|
|
typedef Translator<string, BufferParams::PARSEP> ParSepTranslator;
|
2004-10-05 13:18:28 +00:00
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
ParSepTranslator const init_parseptranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
ParSepTranslator translator(string_paragraph_separation[0], BufferParams::PARSEP_INDENT);
|
|
|
|
|
translator.addPair(string_paragraph_separation[1], BufferParams::PARSEP_SKIP);
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
ParSepTranslator const & parseptranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
static ParSepTranslator translator = init_parseptranslator();
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
|
2004-10-05 13:18:28 +00:00
|
|
|
|
// Quotes language
|
2005-01-05 20:21:27 +00:00
|
|
|
|
typedef Translator<string, InsetQuotes::quote_language> QuotesLangTranslator;
|
2004-10-05 13:18:28 +00:00
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
QuotesLangTranslator const init_quoteslangtranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
QuotesLangTranslator translator(string_quotes_language[0], InsetQuotes::EnglishQ);
|
|
|
|
|
translator.addPair(string_quotes_language[1], InsetQuotes::SwedishQ);
|
|
|
|
|
translator.addPair(string_quotes_language[2], InsetQuotes::GermanQ);
|
|
|
|
|
translator.addPair(string_quotes_language[3], InsetQuotes::PolishQ);
|
|
|
|
|
translator.addPair(string_quotes_language[4], InsetQuotes::FrenchQ);
|
|
|
|
|
translator.addPair(string_quotes_language[5], InsetQuotes::DanishQ);
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
QuotesLangTranslator const & quoteslangtranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
static QuotesLangTranslator translator = init_quoteslangtranslator();
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
|
2004-10-05 13:18:28 +00:00
|
|
|
|
// Paper size
|
2005-07-16 16:57:55 +00:00
|
|
|
|
typedef Translator<std::string, PAPER_SIZE> PaperSizeTranslator;
|
2004-10-05 13:18:28 +00:00
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
PaperSizeTranslator const init_papersizetranslator()
|
|
|
|
|
{
|
2005-07-16 16:57:55 +00:00
|
|
|
|
PaperSizeTranslator translator(string_papersize[0], PAPER_DEFAULT);
|
|
|
|
|
translator.addPair(string_papersize[1], PAPER_CUSTOM);
|
|
|
|
|
translator.addPair(string_papersize[2], PAPER_USLETTER);
|
|
|
|
|
translator.addPair(string_papersize[3], PAPER_USLEGAL);
|
|
|
|
|
translator.addPair(string_papersize[4], PAPER_USEXECUTIVE);
|
|
|
|
|
translator.addPair(string_papersize[5], PAPER_A3);
|
|
|
|
|
translator.addPair(string_papersize[6], PAPER_A4);
|
|
|
|
|
translator.addPair(string_papersize[7], PAPER_A5);
|
|
|
|
|
translator.addPair(string_papersize[8], PAPER_B3);
|
|
|
|
|
translator.addPair(string_papersize[9], PAPER_B4);
|
|
|
|
|
translator.addPair(string_papersize[10], PAPER_B5);
|
2004-10-05 13:18:28 +00:00
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
PaperSizeTranslator const & papersizetranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
static PaperSizeTranslator translator = init_papersizetranslator();
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
|
2004-10-05 13:18:28 +00:00
|
|
|
|
// Paper orientation
|
2005-01-05 20:21:27 +00:00
|
|
|
|
typedef Translator<string, PAPER_ORIENTATION> PaperOrientationTranslator;
|
2004-10-05 13:18:28 +00:00
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
PaperOrientationTranslator const init_paperorientationtranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
PaperOrientationTranslator translator(string_orientation[0], ORIENTATION_PORTRAIT);
|
|
|
|
|
translator.addPair(string_orientation[1], ORIENTATION_LANDSCAPE);
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
PaperOrientationTranslator const & paperorientationtranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
static PaperOrientationTranslator translator = init_paperorientationtranslator();
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Page sides
|
|
|
|
|
typedef Translator<int, LyXTextClass::PageSides> SidesTranslator;
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
SidesTranslator const init_sidestranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
SidesTranslator translator(1, LyXTextClass::OneSide);
|
|
|
|
|
translator.addPair(2, LyXTextClass::TwoSides);
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
SidesTranslator const & sidestranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
static SidesTranslator translator = init_sidestranslator();
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AMS
|
|
|
|
|
typedef Translator<int, BufferParams::AMS> AMSTranslator;
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
AMSTranslator const init_amstranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
AMSTranslator translator(0, BufferParams::AMS_OFF);
|
|
|
|
|
translator.addPair(1, BufferParams::AMS_AUTO);
|
|
|
|
|
translator.addPair(2, BufferParams::AMS_ON);
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
AMSTranslator const & amstranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
static AMSTranslator translator = init_amstranslator();
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Cite engine
|
|
|
|
|
typedef Translator<string, biblio::CiteEngine> CiteEngineTranslator;
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
CiteEngineTranslator const init_citeenginetranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
CiteEngineTranslator translator("basic", biblio::ENGINE_BASIC);
|
|
|
|
|
translator.addPair("natbib_numerical", biblio::ENGINE_NATBIB_NUMERICAL);
|
|
|
|
|
translator.addPair("natbib_authoryear", biblio::ENGINE_NATBIB_AUTHORYEAR);
|
|
|
|
|
translator.addPair("jurabib", biblio::ENGINE_JURABIB);
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
CiteEngineTranslator const & citeenginetranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
static CiteEngineTranslator translator = init_citeenginetranslator();
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Spacing
|
|
|
|
|
typedef Translator<string, Spacing::Space> SpaceTranslator;
|
2004-08-20 13:06:33 +00:00
|
|
|
|
|
2004-10-05 13:18:28 +00:00
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
SpaceTranslator const init_spacetranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
SpaceTranslator translator("default", Spacing::Default);
|
|
|
|
|
translator.addPair("single", Spacing::Single);
|
|
|
|
|
translator.addPair("onehalf", Spacing::Onehalf);
|
|
|
|
|
translator.addPair("double", Spacing::Double);
|
2005-01-06 13:48:13 +00:00
|
|
|
|
translator.addPair("other", Spacing::Other);
|
2004-10-05 13:18:28 +00:00
|
|
|
|
return translator;
|
2004-08-20 13:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-10-05 13:18:28 +00:00
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
SpaceTranslator const & spacetranslator()
|
|
|
|
|
{
|
2004-10-05 13:18:28 +00:00
|
|
|
|
static SpaceTranslator translator = init_spacetranslator();
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ends annonym namespace
|
2004-08-20 13:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class BufferParams::Impl
|
2003-09-09 17:00:19 +00:00
|
|
|
|
{
|
2005-01-19 15:03:31 +00:00
|
|
|
|
public:
|
2003-09-09 17:00:19 +00:00
|
|
|
|
Impl();
|
|
|
|
|
|
|
|
|
|
AuthorList authorlist;
|
|
|
|
|
BranchList branchlist;
|
|
|
|
|
boost::array<Bullet, 4> temp_bullets;
|
|
|
|
|
boost::array<Bullet, 4> user_defined_bullets;
|
|
|
|
|
Spacing spacing;
|
|
|
|
|
/** This is the amount of space used for paragraph_separation "skip",
|
|
|
|
|
* and for detached paragraphs in "indented" documents.
|
|
|
|
|
*/
|
|
|
|
|
VSpace defskip;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BufferParams::Impl::Impl()
|
|
|
|
|
: defskip(VSpace::MEDSKIP)
|
|
|
|
|
{
|
|
|
|
|
// set initial author
|
|
|
|
|
authorlist.record(Author(lyxrc.user_name, lyxrc.user_email));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-15 20:23:57 +00:00
|
|
|
|
BufferParams::Impl *
|
|
|
|
|
BufferParams::MemoryTraits::clone(BufferParams::Impl const * ptr)
|
|
|
|
|
{
|
2005-01-05 20:21:27 +00:00
|
|
|
|
BOOST_ASSERT(ptr);
|
|
|
|
|
|
2003-09-15 20:23:57 +00:00
|
|
|
|
return new BufferParams::Impl(*ptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BufferParams::MemoryTraits::destroy(BufferParams::Impl * ptr)
|
|
|
|
|
{
|
|
|
|
|
delete ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
BufferParams::BufferParams()
|
2003-09-15 10:03:17 +00:00
|
|
|
|
: // Initialize textclass to point to article. if `first' is
|
2003-09-09 17:00:19 +00:00
|
|
|
|
// true in the returned pair, then `second' is the textclass
|
|
|
|
|
// number; if it is false, second is 0. In both cases, second
|
|
|
|
|
// is what we want.
|
2003-09-15 10:03:17 +00:00
|
|
|
|
textclass(textclasslist.NumberOfClass("article").second),
|
|
|
|
|
pimpl_(new Impl)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
|
paragraph_separation = PARSEP_INDENT;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
quotes_language = InsetQuotes::EnglishQ;
|
|
|
|
|
fontsize = "default";
|
1999-11-25 17:29:19 +00:00
|
|
|
|
|
2001-11-29 17:12:21 +00:00
|
|
|
|
/* PaperLayout */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
papersize = PAPER_DEFAULT;
|
|
|
|
|
orientation = ORIENTATION_PORTRAIT;
|
2001-11-29 17:12:21 +00:00
|
|
|
|
use_geometry = false;
|
2003-03-06 11:07:55 +00:00
|
|
|
|
use_amsmath = AMS_AUTO;
|
2004-05-13 20:44:35 +00:00
|
|
|
|
cite_engine = biblio::ENGINE_BASIC;
|
2004-03-29 13:17:25 +00:00
|
|
|
|
use_bibtopic = false;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
tracking_changes = false;
|
2005-01-24 17:12:19 +00:00
|
|
|
|
output_changes = false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
secnumdepth = 3;
|
|
|
|
|
tocdepth = 3;
|
2000-10-10 12:36:36 +00:00
|
|
|
|
language = default_language;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
fonts = "default";
|
2000-07-04 20:32:37 +00:00
|
|
|
|
inputenc = "auto";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
graphicsDriver = "default";
|
1999-11-04 01:40:20 +00:00
|
|
|
|
sides = LyXTextClass::OneSide;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
columns = 1;
|
|
|
|
|
pagestyle = "default";
|
2003-07-28 14:40:29 +00:00
|
|
|
|
compressed = false;
|
2000-11-04 10:00:12 +00:00
|
|
|
|
for (int iter = 0; iter < 4; ++iter) {
|
2003-09-09 17:00:19 +00:00
|
|
|
|
user_defined_bullet(iter) = ITEMIZE_DEFAULTS[iter];
|
|
|
|
|
temp_bullet(iter) = ITEMIZE_DEFAULTS[iter];
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-09 17:00:19 +00:00
|
|
|
|
BufferParams::~BufferParams()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AuthorList & BufferParams::authors()
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->authorlist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AuthorList const & BufferParams::authors() const
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->authorlist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BranchList & BufferParams::branchlist()
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->branchlist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BranchList const & BufferParams::branchlist() const
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->branchlist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
Bullet & BufferParams::temp_bullet(lyx::size_type const index)
|
2003-09-09 17:00:19 +00:00
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(index < 4);
|
2003-09-09 17:00:19 +00:00
|
|
|
|
return pimpl_->temp_bullets[index];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
Bullet const & BufferParams::temp_bullet(lyx::size_type const index) const
|
2003-09-09 17:00:19 +00:00
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(index < 4);
|
2003-09-09 17:00:19 +00:00
|
|
|
|
return pimpl_->temp_bullets[index];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
Bullet & BufferParams::user_defined_bullet(lyx::size_type const index)
|
2003-09-09 17:00:19 +00:00
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(index < 4);
|
2003-09-09 17:00:19 +00:00
|
|
|
|
return pimpl_->user_defined_bullets[index];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
Bullet const & BufferParams::user_defined_bullet(lyx::size_type const index) const
|
2003-09-09 17:00:19 +00:00
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
|
BOOST_ASSERT(index < 4);
|
2003-09-09 17:00:19 +00:00
|
|
|
|
return pimpl_->user_defined_bullets[index];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Spacing & BufferParams::spacing()
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->spacing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Spacing const & BufferParams::spacing() const
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->spacing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VSpace const & BufferParams::getDefSkip() const
|
|
|
|
|
{
|
|
|
|
|
return pimpl_->defskip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BufferParams::setDefSkip(VSpace const & vs)
|
|
|
|
|
{
|
|
|
|
|
pimpl_->defskip = vs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-12 02:39:12 +00:00
|
|
|
|
string const BufferParams::readToken(LyXLex & lex, string const & token)
|
|
|
|
|
{
|
|
|
|
|
if (token == "\\textclass") {
|
2004-08-14 18:41:27 +00:00
|
|
|
|
lex.next();
|
2003-03-12 02:39:12 +00:00
|
|
|
|
string const classname = lex.getString();
|
|
|
|
|
pair<bool, lyx::textclass_type> pp =
|
|
|
|
|
textclasslist.NumberOfClass(classname);
|
|
|
|
|
if (pp.first) {
|
|
|
|
|
textclass = pp.second;
|
|
|
|
|
} else {
|
|
|
|
|
textclass = 0;
|
|
|
|
|
return classname;
|
|
|
|
|
}
|
2003-05-03 19:24:36 +00:00
|
|
|
|
if (!getLyXTextClass().isTeXClassAvailable()) {
|
2005-01-05 20:21:27 +00:00
|
|
|
|
string const msg =
|
|
|
|
|
bformat(_("The document uses a missing "
|
2003-05-13 09:48:57 +00:00
|
|
|
|
"TeX class \"%1$s\".\n"), classname);
|
2003-05-03 19:24:36 +00:00
|
|
|
|
Alert::warning(_("Document class not available"),
|
|
|
|
|
msg + _("LyX will not be able to produce output."));
|
|
|
|
|
}
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\begin_preamble") {
|
|
|
|
|
readPreamble(lex);
|
|
|
|
|
} else if (token == "\\options") {
|
|
|
|
|
lex.eatLine();
|
|
|
|
|
options = lex.getString();
|
|
|
|
|
} else if (token == "\\language") {
|
|
|
|
|
readLanguage(lex);
|
|
|
|
|
} else if (token == "\\inputencoding") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> inputenc;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\graphics") {
|
|
|
|
|
readGraphicsDriver(lex);
|
|
|
|
|
} else if (token == "\\fontscheme") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> fonts;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\paragraph_separation") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
string parsep;
|
|
|
|
|
lex >> parsep;
|
|
|
|
|
paragraph_separation = parseptranslator().find(parsep);
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\defskip") {
|
2004-08-14 18:41:27 +00:00
|
|
|
|
lex.next();
|
2003-09-09 17:00:19 +00:00
|
|
|
|
pimpl_->defskip = VSpace(lex.getString());
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\quotes_language") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
string quotes_lang;
|
|
|
|
|
lex >> quotes_lang;
|
|
|
|
|
quotes_language = quoteslangtranslator().find(quotes_lang);
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\papersize") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
string ppsize;
|
|
|
|
|
lex >> ppsize;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
papersize = papersizetranslator().find(ppsize);
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\use_geometry") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> use_geometry;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\use_amsmath") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
int use_ams;
|
|
|
|
|
lex >> use_ams;
|
|
|
|
|
use_amsmath = amstranslator().find(use_ams);
|
2004-05-13 20:44:35 +00:00
|
|
|
|
} else if (token == "\\cite_engine") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
string engine;
|
|
|
|
|
lex >> engine;
|
|
|
|
|
cite_engine = citeenginetranslator().find(engine);
|
2004-03-29 13:17:25 +00:00
|
|
|
|
} else if (token == "\\use_bibtopic") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> use_bibtopic;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\tracking_changes") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> tracking_changes;
|
2005-01-24 17:12:19 +00:00
|
|
|
|
} else if (token == "\\output_changes") {
|
|
|
|
|
lex >> output_changes;
|
2003-08-17 11:28:23 +00:00
|
|
|
|
} else if (token == "\\branch") {
|
2004-08-14 18:41:27 +00:00
|
|
|
|
lex.next();
|
2003-08-17 11:28:23 +00:00
|
|
|
|
string branch = lex.getString();
|
2003-09-09 17:00:19 +00:00
|
|
|
|
branchlist().add(branch);
|
2003-08-17 11:28:23 +00:00
|
|
|
|
while (true) {
|
2004-08-14 18:41:27 +00:00
|
|
|
|
lex.next();
|
2003-08-17 11:28:23 +00:00
|
|
|
|
string const tok = lex.getString();
|
|
|
|
|
if (tok == "\\end_branch")
|
|
|
|
|
break;
|
2003-12-14 16:33:56 +00:00
|
|
|
|
Branch * branch_ptr = branchlist().find(branch);
|
2003-08-17 11:28:23 +00:00
|
|
|
|
if (tok == "\\selected") {
|
2004-08-14 18:41:27 +00:00
|
|
|
|
lex.next();
|
2003-12-14 16:33:56 +00:00
|
|
|
|
if (branch_ptr)
|
|
|
|
|
branch_ptr->setSelected(lex.getInteger());
|
2003-08-17 11:28:23 +00:00
|
|
|
|
}
|
|
|
|
|
// not yet operational
|
|
|
|
|
if (tok == "\\color") {
|
2004-08-14 18:41:27 +00:00
|
|
|
|
lex.eatLine();
|
2003-08-17 11:28:23 +00:00
|
|
|
|
string color = lex.getString();
|
2003-12-14 16:33:56 +00:00
|
|
|
|
if (branch_ptr)
|
|
|
|
|
branch_ptr->setColor(color);
|
2003-08-17 11:28:23 +00:00
|
|
|
|
// Update also the LColor table:
|
2003-09-09 17:25:35 +00:00
|
|
|
|
if (color == "none")
|
2003-08-17 11:28:23 +00:00
|
|
|
|
color = lcolor.getX11Name(LColor::background);
|
2004-03-25 15:51:21 +00:00
|
|
|
|
lcolor.setColor(branch, color);
|
|
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\author") {
|
2004-08-23 11:02:20 +00:00
|
|
|
|
lex.eatLine();
|
2003-09-15 11:00:00 +00:00
|
|
|
|
istringstream ss(lex.getString());
|
2003-03-12 02:39:12 +00:00
|
|
|
|
Author a;
|
|
|
|
|
ss >> a;
|
2003-09-09 17:00:19 +00:00
|
|
|
|
author_map.push_back(pimpl_->authorlist.record(a));
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\paperorientation") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
string orient;
|
|
|
|
|
lex >> orient;
|
|
|
|
|
orientation = paperorientationtranslator().find(orient);
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\paperwidth") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> paperwidth;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\paperheight") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> paperheight;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\leftmargin") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> leftmargin;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\topmargin") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> topmargin;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\rightmargin") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> rightmargin;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\bottommargin") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> bottommargin;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\headheight") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> headheight;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\headsep") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> headsep;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\footskip") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> footskip;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\paperfontsize") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> fontsize;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\papercolumns") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> columns;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\papersides") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
int psides;
|
|
|
|
|
lex >> psides;
|
|
|
|
|
sides = sidestranslator().find(psides);
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\paperpagestyle") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> pagestyle;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\bullet") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
readBullets(lex);
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\bulletLaTeX") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
readBulletsLaTeX(lex);
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\secnumdepth") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> secnumdepth;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\tocdepth") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> tocdepth;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\spacing") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
string nspacing;
|
|
|
|
|
lex >> nspacing;
|
2005-01-06 13:48:13 +00:00
|
|
|
|
string tmp_val;
|
2004-10-05 13:18:28 +00:00
|
|
|
|
if (nspacing == "other") {
|
|
|
|
|
lex >> tmp_val;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
}
|
2004-10-05 13:18:28 +00:00
|
|
|
|
spacing().set(spacetranslator().find(nspacing), tmp_val);
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else if (token == "\\float_placement") {
|
2004-10-05 13:18:28 +00:00
|
|
|
|
lex >> float_placement;
|
2003-03-12 02:39:12 +00:00
|
|
|
|
} else {
|
|
|
|
|
return token;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-02-22 00:36:17 +00:00
|
|
|
|
void BufferParams::writeFile(ostream & os) const
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
// The top of the file is written by the buffer.
|
|
|
|
|
// Prints out the buffer info into the .lyx file given by file
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
// the textclass
|
|
|
|
|
os << "\\textclass " << textclasslist[textclass].name() << '\n';
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// then the the preamble
|
|
|
|
|
if (!preamble.empty()) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
// remove '\n' from the end of preamble
|
2002-07-28 22:50:13 +00:00
|
|
|
|
string const tmppreamble = rtrim(preamble, "\n");
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\begin_preamble\n"
|
2000-02-22 00:36:17 +00:00
|
|
|
|
<< tmppreamble
|
1999-12-07 00:44:53 +00:00
|
|
|
|
<< "\n\\end_preamble\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
// the options
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (!options.empty()) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\options " << options << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
// then the text parameters
|
2001-07-27 12:03:36 +00:00
|
|
|
|
if (language != ignore_language)
|
|
|
|
|
os << "\\language " << language->lang() << '\n';
|
|
|
|
|
os << "\\inputencoding " << inputenc
|
1999-12-07 00:44:53 +00:00
|
|
|
|
<< "\n\\fontscheme " << fonts
|
|
|
|
|
<< "\n\\graphics " << graphicsDriver << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
if (!float_placement.empty()) {
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\float_placement " << float_placement << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\paperfontsize " << fontsize << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-09-09 17:00:19 +00:00
|
|
|
|
spacing().writeFile(os);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2005-07-16 16:57:55 +00:00
|
|
|
|
os << "\\papersize " << string_papersize[papersize]
|
2005-01-06 15:40:49 +00:00
|
|
|
|
<< "\n\\use_geometry " << convert<string>(use_geometry)
|
1999-12-07 00:44:53 +00:00
|
|
|
|
<< "\n\\use_amsmath " << use_amsmath
|
2004-10-05 13:18:28 +00:00
|
|
|
|
<< "\n\\cite_engine " << citeenginetranslator().find(cite_engine)
|
2005-01-06 15:40:49 +00:00
|
|
|
|
<< "\n\\use_bibtopic " << convert<string>(use_bibtopic)
|
1999-12-07 00:44:53 +00:00
|
|
|
|
<< "\n\\paperorientation " << string_orientation[orientation]
|
|
|
|
|
<< '\n';
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
2005-10-25 15:21:49 +00:00
|
|
|
|
BranchList::const_iterator it = branchlist().begin();
|
|
|
|
|
BranchList::const_iterator end = branchlist().end();
|
2003-08-17 11:28:23 +00:00
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
|
os << "\\branch " << it->getBranch()
|
2003-09-09 17:25:35 +00:00
|
|
|
|
<< "\n\\selected " << it->getSelected()
|
|
|
|
|
<< "\n\\color " << it->getColor()
|
|
|
|
|
<< "\n\\end_branch"
|
2003-08-17 11:28:23 +00:00
|
|
|
|
<< "\n";
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (!paperwidth.empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\paperwidth "
|
|
|
|
|
<< VSpace(paperwidth).asLyXCommand() << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (!paperheight.empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\paperheight "
|
|
|
|
|
<< VSpace(paperheight).asLyXCommand() << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (!leftmargin.empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\leftmargin "
|
|
|
|
|
<< VSpace(leftmargin).asLyXCommand() << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (!topmargin.empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\topmargin "
|
|
|
|
|
<< VSpace(topmargin).asLyXCommand() << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (!rightmargin.empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\rightmargin "
|
|
|
|
|
<< VSpace(rightmargin).asLyXCommand() << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (!bottommargin.empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\bottommargin "
|
|
|
|
|
<< VSpace(bottommargin).asLyXCommand() << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (!headheight.empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\headheight "
|
|
|
|
|
<< VSpace(headheight).asLyXCommand() << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (!headsep.empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\headsep "
|
|
|
|
|
<< VSpace(headsep).asLyXCommand() << '\n';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (!footskip.empty())
|
1999-12-07 00:44:53 +00:00
|
|
|
|
os << "\\footskip "
|
|
|
|
|
<< VSpace(footskip).asLyXCommand() << '\n';
|
|
|
|
|
os << "\\secnumdepth " << secnumdepth
|
|
|
|
|
<< "\n\\tocdepth " << tocdepth
|
|
|
|
|
<< "\n\\paragraph_separation "
|
|
|
|
|
<< string_paragraph_separation[paragraph_separation]
|
2003-09-09 17:00:19 +00:00
|
|
|
|
<< "\n\\defskip " << getDefSkip().asLyXCommand()
|
1999-12-07 00:44:53 +00:00
|
|
|
|
<< "\n\\quotes_language "
|
2005-10-13 10:59:39 +00:00
|
|
|
|
<< string_quotes_language[quotes_language]
|
2004-10-05 13:18:28 +00:00
|
|
|
|
<< "\n\\papercolumns " << columns
|
1999-12-07 00:44:53 +00:00
|
|
|
|
<< "\n\\papersides " << sides
|
|
|
|
|
<< "\n\\paperpagestyle " << pagestyle << '\n';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
2003-09-09 17:00:19 +00:00
|
|
|
|
if (user_defined_bullet(i) != ITEMIZE_DEFAULTS[i]) {
|
|
|
|
|
if (user_defined_bullet(i).getFont() != -1) {
|
2004-08-14 18:41:27 +00:00
|
|
|
|
os << "\\bullet " << i << " "
|
|
|
|
|
<< user_defined_bullet(i).getFont() << " "
|
|
|
|
|
<< user_defined_bullet(i).getCharacter() << " "
|
|
|
|
|
<< user_defined_bullet(i).getSize() << "\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2004-08-14 18:41:27 +00:00
|
|
|
|
os << "\\bulletLaTeX " << i << " \""
|
2003-09-09 17:00:19 +00:00
|
|
|
|
<< user_defined_bullet(i).getText()
|
2004-08-14 18:41:27 +00:00
|
|
|
|
<< "\"\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
2005-01-06 15:40:49 +00:00
|
|
|
|
os << "\\tracking_changes " << convert<string>(tracking_changes) << "\n";
|
2005-01-24 17:12:19 +00:00
|
|
|
|
os << "\\output_changes " << convert<string>(output_changes) << "\n";
|
2003-03-12 02:39:12 +00:00
|
|
|
|
|
|
|
|
|
if (tracking_changes) {
|
2003-09-09 17:00:19 +00:00
|
|
|
|
AuthorList::Authors::const_iterator it = pimpl_->authorlist.begin();
|
|
|
|
|
AuthorList::Authors::const_iterator end = pimpl_->authorlist.end();
|
2003-03-12 02:39:12 +00:00
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
|
os << "\\author " << it->second << "\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-22 22:44:30 +00:00
|
|
|
|
bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
|
2003-02-16 00:54:43 +00:00
|
|
|
|
TexRow & texrow) const
|
|
|
|
|
{
|
|
|
|
|
os << "\\documentclass";
|
|
|
|
|
|
|
|
|
|
LyXTextClass const & tclass = getLyXTextClass();
|
|
|
|
|
|
|
|
|
|
ostringstream clsoptions; // the document class options.
|
|
|
|
|
|
|
|
|
|
if (tokenPos(tclass.opt_fontsize(),
|
|
|
|
|
'|', fontsize) >= 0) {
|
|
|
|
|
// only write if existing in list (and not default)
|
|
|
|
|
clsoptions << fontsize << "pt,";
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-16 16:57:55 +00:00
|
|
|
|
// custom, A3, B3 and B4 paper sizes need geometry
|
|
|
|
|
bool nonstandard_papersize = (papersize == PAPER_B3) ||
|
|
|
|
|
(papersize == PAPER_B4) ||
|
|
|
|
|
(papersize == PAPER_A3) ||
|
|
|
|
|
(papersize == PAPER_CUSTOM);
|
2003-02-16 00:54:43 +00:00
|
|
|
|
|
2005-07-17 11:17:13 +00:00
|
|
|
|
if (!use_geometry) {
|
2003-02-16 00:54:43 +00:00
|
|
|
|
switch (papersize) {
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_A4:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
clsoptions << "a4paper,";
|
|
|
|
|
break;
|
|
|
|
|
case PAPER_USLETTER:
|
|
|
|
|
clsoptions << "letterpaper,";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_A5:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
clsoptions << "a5paper,";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_B5:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
clsoptions << "b5paper,";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_USEXECUTIVE:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
clsoptions << "executivepaper,";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_USLEGAL:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
clsoptions << "legalpaper,";
|
|
|
|
|
break;
|
2003-06-10 14:39:45 +00:00
|
|
|
|
case PAPER_DEFAULT:
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_A3:
|
|
|
|
|
case PAPER_B3:
|
|
|
|
|
case PAPER_B4:
|
|
|
|
|
case PAPER_CUSTOM:
|
2003-06-10 14:39:45 +00:00
|
|
|
|
break;
|
2003-02-16 00:54:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if needed
|
|
|
|
|
if (sides != tclass.sides()) {
|
|
|
|
|
switch (sides) {
|
|
|
|
|
case LyXTextClass::OneSide:
|
|
|
|
|
clsoptions << "oneside,";
|
|
|
|
|
break;
|
|
|
|
|
case LyXTextClass::TwoSides:
|
|
|
|
|
clsoptions << "twoside,";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if needed
|
|
|
|
|
if (columns != tclass.columns()) {
|
|
|
|
|
if (columns == 2)
|
|
|
|
|
clsoptions << "twocolumn,";
|
|
|
|
|
else
|
|
|
|
|
clsoptions << "onecolumn,";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!use_geometry
|
|
|
|
|
&& orientation == ORIENTATION_LANDSCAPE)
|
|
|
|
|
clsoptions << "landscape,";
|
|
|
|
|
|
|
|
|
|
// language should be a parameter to \documentclass
|
|
|
|
|
if (language->babel() == "hebrew"
|
|
|
|
|
&& default_language->babel() != "hebrew")
|
|
|
|
|
// This seems necessary
|
|
|
|
|
features.useLanguage(default_language);
|
|
|
|
|
|
2003-05-23 11:18:43 +00:00
|
|
|
|
ostringstream language_options;
|
|
|
|
|
bool const use_babel = features.useBabel();
|
|
|
|
|
if (use_babel) {
|
2003-02-16 00:54:43 +00:00
|
|
|
|
language_options << features.getLanguages();
|
|
|
|
|
language_options << language->babel();
|
|
|
|
|
if (lyxrc.language_global_options)
|
|
|
|
|
clsoptions << language_options.str() << ',';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// the user-defined options
|
|
|
|
|
if (!options.empty()) {
|
|
|
|
|
clsoptions << options << ',';
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
string strOptions(clsoptions.str());
|
2003-02-16 00:54:43 +00:00
|
|
|
|
if (!strOptions.empty()) {
|
|
|
|
|
strOptions = rtrim(strOptions, ",");
|
|
|
|
|
os << '[' << strOptions << ']';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
os << '{' << tclass.latexname() << "}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
// end of \documentclass defs
|
|
|
|
|
|
|
|
|
|
// font selection must be done before loading fontenc.sty
|
|
|
|
|
// The ae package is not needed when using OT1 font encoding.
|
|
|
|
|
if (fonts != "default" &&
|
|
|
|
|
(fonts != "ae" || lyxrc.fontenc != "default")) {
|
|
|
|
|
os << "\\usepackage{" << fonts << "}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
if (fonts == "ae") {
|
|
|
|
|
os << "\\usepackage{aecompl}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// this one is not per buffer
|
|
|
|
|
if (lyxrc.fontenc != "default") {
|
|
|
|
|
os << "\\usepackage[" << lyxrc.fontenc
|
|
|
|
|
<< "]{fontenc}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (inputenc == "auto") {
|
|
|
|
|
string const doc_encoding =
|
|
|
|
|
language->encoding()->LatexName();
|
|
|
|
|
|
|
|
|
|
// Create a list with all the input encodings used
|
|
|
|
|
// in the document
|
2003-02-16 12:48:24 +00:00
|
|
|
|
std::set<string> encodings =
|
|
|
|
|
features.getEncodingSet(doc_encoding);
|
2003-02-16 00:54:43 +00:00
|
|
|
|
|
|
|
|
|
os << "\\usepackage[";
|
|
|
|
|
std::copy(encodings.begin(), encodings.end(),
|
|
|
|
|
std::ostream_iterator<string>(os, ","));
|
|
|
|
|
os << doc_encoding << "]{inputenc}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
} else if (inputenc != "default") {
|
|
|
|
|
os << "\\usepackage[" << inputenc
|
|
|
|
|
<< "]{inputenc}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-16 16:57:55 +00:00
|
|
|
|
if (use_geometry || nonstandard_papersize) {
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << "\\usepackage{geometry}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
os << "\\geometry{verbose";
|
|
|
|
|
if (orientation == ORIENTATION_LANDSCAPE)
|
|
|
|
|
os << ",landscape";
|
2005-07-16 16:57:55 +00:00
|
|
|
|
switch (papersize) {
|
|
|
|
|
case PAPER_CUSTOM:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
if (!paperwidth.empty())
|
|
|
|
|
os << ",paperwidth="
|
|
|
|
|
<< paperwidth;
|
|
|
|
|
if (!paperheight.empty())
|
|
|
|
|
os << ",paperheight="
|
|
|
|
|
<< paperheight;
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_USLETTER:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",letterpaper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_USLEGAL:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",legalpaper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_USEXECUTIVE:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",executivepaper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_A3:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",a3paper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_A4:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",a4paper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_A5:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",a5paper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_B3:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",b3paper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_B4:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",b4paper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_B5:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",b5paper";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2005-07-16 16:57:55 +00:00
|
|
|
|
// default papersize ie PAPER_DEFAULT
|
2003-02-16 00:54:43 +00:00
|
|
|
|
switch (lyxrc.default_papersize) {
|
|
|
|
|
case PAPER_DEFAULT: // keep compiler happy
|
|
|
|
|
case PAPER_USLETTER:
|
|
|
|
|
os << ",letterpaper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_USLEGAL:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",legalpaper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_USEXECUTIVE:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",executivepaper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_A3:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",a3paper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_A4:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",a4paper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_A5:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",a5paper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_B5:
|
2003-02-16 00:54:43 +00:00
|
|
|
|
os << ",b5paper";
|
|
|
|
|
break;
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_B3:
|
|
|
|
|
case PAPER_B4:
|
|
|
|
|
case PAPER_CUSTOM:
|
|
|
|
|
break;
|
2003-02-16 00:54:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!topmargin.empty())
|
|
|
|
|
os << ",tmargin=" << topmargin;
|
|
|
|
|
if (!bottommargin.empty())
|
|
|
|
|
os << ",bmargin=" << bottommargin;
|
|
|
|
|
if (!leftmargin.empty())
|
|
|
|
|
os << ",lmargin=" << leftmargin;
|
|
|
|
|
if (!rightmargin.empty())
|
|
|
|
|
os << ",rmargin=" << rightmargin;
|
|
|
|
|
if (!headheight.empty())
|
|
|
|
|
os << ",headheight=" << headheight;
|
|
|
|
|
if (!headsep.empty())
|
|
|
|
|
os << ",headsep=" << headsep;
|
|
|
|
|
if (!footskip.empty())
|
|
|
|
|
os << ",footskip=" << footskip;
|
|
|
|
|
os << "}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tokenPos(tclass.opt_pagestyle(),
|
|
|
|
|
'|', pagestyle) >= 0) {
|
|
|
|
|
if (pagestyle == "fancy") {
|
|
|
|
|
os << "\\usepackage{fancyhdr}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
os << "\\pagestyle{" << pagestyle << "}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-24 11:59:09 +00:00
|
|
|
|
// Only if class has a ToC hierarchy
|
|
|
|
|
if (tclass.hasTocLevels()) {
|
|
|
|
|
if (secnumdepth != tclass.secnumdepth()) {
|
|
|
|
|
os << "\\setcounter{secnumdepth}{"
|
|
|
|
|
<< secnumdepth
|
|
|
|
|
<< "}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
if (tocdepth != tclass.tocdepth()) {
|
|
|
|
|
os << "\\setcounter{tocdepth}{"
|
|
|
|
|
<< tocdepth
|
|
|
|
|
<< "}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
2003-02-16 00:54:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (paragraph_separation) {
|
2003-09-09 17:00:19 +00:00
|
|
|
|
switch (getDefSkip().kind()) {
|
2003-02-16 00:54:43 +00:00
|
|
|
|
case VSpace::SMALLSKIP:
|
|
|
|
|
os << "\\setlength\\parskip{\\smallskipamount}\n";
|
|
|
|
|
break;
|
|
|
|
|
case VSpace::MEDSKIP:
|
|
|
|
|
os << "\\setlength\\parskip{\\medskipamount}\n";
|
|
|
|
|
break;
|
|
|
|
|
case VSpace::BIGSKIP:
|
|
|
|
|
os << "\\setlength\\parskip{\\bigskipamount}\n";
|
|
|
|
|
break;
|
|
|
|
|
case VSpace::LENGTH:
|
|
|
|
|
os << "\\setlength\\parskip{"
|
2003-09-09 17:00:19 +00:00
|
|
|
|
<< getDefSkip().length().asLatexString()
|
2003-02-16 00:54:43 +00:00
|
|
|
|
<< "}\n";
|
|
|
|
|
break;
|
|
|
|
|
default: // should never happen // Then delete it.
|
|
|
|
|
os << "\\setlength\\parskip{\\medskipamount}\n";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
texrow.newline();
|
|
|
|
|
|
|
|
|
|
os << "\\setlength\\parindent{0pt}\n";
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-07 14:33:17 +00:00
|
|
|
|
// If we use jurabib, we have to call babel here.
|
|
|
|
|
if (use_babel && features.isRequired("jurabib")) {
|
|
|
|
|
os << babelCall(language_options.str())
|
|
|
|
|
<< '\n'
|
|
|
|
|
<< features.getBabelOptions();
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
2003-02-16 00:54:43 +00:00
|
|
|
|
// Now insert the LyX specific LaTeX commands...
|
|
|
|
|
|
|
|
|
|
// The optional packages;
|
|
|
|
|
string lyxpreamble(features.getPackages());
|
|
|
|
|
|
|
|
|
|
// this might be useful...
|
|
|
|
|
lyxpreamble += "\n\\makeatletter\n";
|
|
|
|
|
|
|
|
|
|
// Some macros LyX will need
|
|
|
|
|
string tmppreamble(features.getMacros());
|
|
|
|
|
|
|
|
|
|
if (!tmppreamble.empty()) {
|
|
|
|
|
lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
|
|
|
|
|
"LyX specific LaTeX commands.\n"
|
|
|
|
|
+ tmppreamble + '\n';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// the text class specific preamble
|
|
|
|
|
tmppreamble = features.getTClassPreamble();
|
|
|
|
|
if (!tmppreamble.empty()) {
|
|
|
|
|
lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
|
|
|
|
|
"Textclass specific LaTeX commands.\n"
|
|
|
|
|
+ tmppreamble + '\n';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* the user-defined preamble */
|
|
|
|
|
if (!preamble.empty()) {
|
|
|
|
|
lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
|
|
|
|
|
"User specified LaTeX commands.\n"
|
|
|
|
|
+ preamble + '\n';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Itemize bullet settings need to be last in case the user
|
|
|
|
|
// defines their own bullets that use a package included
|
|
|
|
|
// in the user-defined preamble -- ARRae
|
|
|
|
|
// Actually it has to be done much later than that
|
|
|
|
|
// since some packages like frenchb make modifications
|
|
|
|
|
// at \begin{document} time -- JMarc
|
|
|
|
|
string bullets_def;
|
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
2003-09-09 17:00:19 +00:00
|
|
|
|
if (user_defined_bullet(i) != ITEMIZE_DEFAULTS[i]) {
|
2003-02-16 00:54:43 +00:00
|
|
|
|
if (bullets_def.empty())
|
|
|
|
|
bullets_def="\\AtBeginDocument{\n";
|
2006-03-10 16:23:13 +00:00
|
|
|
|
bullets_def += " \\def\\labelitemi";
|
2003-02-16 00:54:43 +00:00
|
|
|
|
switch (i) {
|
|
|
|
|
// `i' is one less than the item to modify
|
|
|
|
|
case 0:
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
bullets_def += 'i';
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
bullets_def += "ii";
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
bullets_def += 'v';
|
|
|
|
|
break;
|
|
|
|
|
}
|
2006-03-10 16:23:13 +00:00
|
|
|
|
bullets_def += '{' +
|
2003-09-09 17:00:19 +00:00
|
|
|
|
user_defined_bullet(i).getText()
|
2003-02-16 00:54:43 +00:00
|
|
|
|
+ "}\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bullets_def.empty())
|
|
|
|
|
lyxpreamble += bullets_def + "}\n\n";
|
|
|
|
|
|
|
|
|
|
// We try to load babel late, in case it interferes
|
2004-04-03 08:37:12 +00:00
|
|
|
|
// with other packages.
|
2004-03-07 14:33:17 +00:00
|
|
|
|
// Jurabib has to be called after babel, though.
|
|
|
|
|
if (use_babel && !features.isRequired("jurabib")) {
|
|
|
|
|
lyxpreamble += babelCall(language_options.str()) + '\n';
|
2003-02-16 00:54:43 +00:00
|
|
|
|
lyxpreamble += features.getBabelOptions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lyxpreamble += "\\makeatother\n";
|
|
|
|
|
|
|
|
|
|
// dvipost settings come after everything else
|
2005-01-24 17:12:19 +00:00
|
|
|
|
if (features.isAvailable("dvipost") && tracking_changes && output_changes) {
|
2003-02-16 00:54:43 +00:00
|
|
|
|
lyxpreamble +=
|
|
|
|
|
"\\dvipostlayout\n"
|
|
|
|
|
"\\dvipost{osstart color push Red}\n"
|
|
|
|
|
"\\dvipost{osend color pop}\n"
|
|
|
|
|
"\\dvipost{cbstart color push Blue}\n"
|
2004-08-16 11:27:51 +00:00
|
|
|
|
"\\dvipost{cbend color pop}\n";
|
2003-02-16 00:54:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int const nlines =
|
|
|
|
|
int(lyx::count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
|
|
|
|
|
for (int j = 0; j != nlines; ++j) {
|
|
|
|
|
texrow.newline();
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-16 01:35:23 +00:00
|
|
|
|
os << lyxpreamble;
|
2003-05-22 22:44:30 +00:00
|
|
|
|
return use_babel;
|
2003-02-16 00:54:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
|
2001-09-17 15:39:58 +00:00
|
|
|
|
void BufferParams::useClassDefaults()
|
|
|
|
|
{
|
2002-03-02 16:39:54 +00:00
|
|
|
|
LyXTextClass const & tclass = textclasslist[textclass];
|
1999-11-04 01:40:20 +00:00
|
|
|
|
|
|
|
|
|
sides = tclass.sides();
|
|
|
|
|
columns = tclass.columns();
|
|
|
|
|
pagestyle = tclass.pagestyle();
|
|
|
|
|
options = tclass.options();
|
2006-03-24 11:59:09 +00:00
|
|
|
|
// Only if class has a ToC hierarchy
|
|
|
|
|
if (tclass.hasTocLevels()) {
|
|
|
|
|
secnumdepth = tclass.secnumdepth();
|
|
|
|
|
tocdepth = tclass.tocdepth();
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-09-17 15:39:58 +00:00
|
|
|
|
bool BufferParams::hasClassDefaults() const
|
|
|
|
|
{
|
2002-03-02 16:39:54 +00:00
|
|
|
|
LyXTextClass const & tclass = textclasslist[textclass];
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-09-17 15:39:58 +00:00
|
|
|
|
return (sides == tclass.sides()
|
|
|
|
|
&& columns == tclass.columns()
|
|
|
|
|
&& pagestyle == tclass.pagestyle()
|
|
|
|
|
&& options == tclass.options()
|
|
|
|
|
&& secnumdepth == tclass.secnumdepth()
|
|
|
|
|
&& tocdepth == tclass.tocdepth());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-21 21:21:06 +00:00
|
|
|
|
LyXTextClass const & BufferParams::getLyXTextClass() const
|
|
|
|
|
{
|
|
|
|
|
return textclasslist[textclass];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-02-05 13:20:16 +00:00
|
|
|
|
LyXFont const BufferParams::getFont() const
|
|
|
|
|
{
|
|
|
|
|
LyXFont f = getLyXTextClass().defaultfont();
|
|
|
|
|
f.setLanguage(language);
|
|
|
|
|
return f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
void BufferParams::readPreamble(LyXLex & lex)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2001-08-06 19:12:46 +00:00
|
|
|
|
if (lex.getString() != "\\begin_preamble")
|
1999-10-07 18:44:17 +00:00
|
|
|
|
lyxerr << "Error (BufferParams::readPreamble):"
|
|
|
|
|
"consistency check failed." << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
preamble = lex.getLongString("\\end_preamble");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
void BufferParams::readLanguage(LyXLex & lex)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
if (!lex.next()) return;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-08-06 19:12:46 +00:00
|
|
|
|
string const tmptok = lex.getString();
|
2000-03-12 10:35:05 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// check if tmptok is part of tex_babel in tex-defs.h
|
2000-10-10 12:36:36 +00:00
|
|
|
|
language = languages.getLanguage(tmptok);
|
|
|
|
|
if (!language) {
|
|
|
|
|
// Language tmptok was not found
|
|
|
|
|
language = default_language;
|
2000-11-28 06:46:06 +00:00
|
|
|
|
lyxerr << "Warning: Setting language `"
|
|
|
|
|
<< tmptok << "' to `" << language->lang()
|
2000-10-10 12:36:36 +00:00
|
|
|
|
<< "'." << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
|
void BufferParams::readGraphicsDriver(LyXLex & lex)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
if (!lex.next()) return;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-08-06 19:12:46 +00:00
|
|
|
|
string const tmptok = lex.getString();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// check if tmptok is part of tex_graphics in tex_defs.h
|
2000-11-21 15:46:13 +00:00
|
|
|
|
int n = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
while (true) {
|
2000-11-21 15:46:13 +00:00
|
|
|
|
string const test = tex_graphics[n++];
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
|
|
if (test == tmptok) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
graphicsDriver = tmptok;
|
|
|
|
|
break;
|
2005-02-12 16:21:32 +00:00
|
|
|
|
} else if (test == "") {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
lex.printError(
|
|
|
|
|
"Warning: graphics driver `$$Token' not recognized!\n"
|
|
|
|
|
" Setting graphics driver to `default'.\n");
|
|
|
|
|
graphicsDriver = "default";
|
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-17 08:23:33 +00:00
|
|
|
|
|
|
|
|
|
|
2004-10-05 13:18:28 +00:00
|
|
|
|
void BufferParams::readBullets(LyXLex & lex)
|
|
|
|
|
{
|
|
|
|
|
if (!lex.next()) return;
|
|
|
|
|
|
|
|
|
|
int const index = lex.getInteger();
|
|
|
|
|
lex.next();
|
|
|
|
|
int temp_int = lex.getInteger();
|
|
|
|
|
user_defined_bullet(index).setFont(temp_int);
|
|
|
|
|
temp_bullet(index).setFont(temp_int);
|
|
|
|
|
lex >> temp_int;
|
|
|
|
|
user_defined_bullet(index).setCharacter(temp_int);
|
|
|
|
|
temp_bullet(index).setCharacter(temp_int);
|
|
|
|
|
lex >> temp_int;
|
|
|
|
|
user_defined_bullet(index).setSize(temp_int);
|
2004-10-26 21:16:44 +00:00
|
|
|
|
temp_bullet(index).setSize(temp_int);
|
2004-10-05 13:18:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BufferParams::readBulletsLaTeX(LyXLex & lex)
|
|
|
|
|
{
|
|
|
|
|
// The bullet class should be able to read this.
|
|
|
|
|
if (!lex.next()) return;
|
|
|
|
|
int const index = lex.getInteger();
|
|
|
|
|
lex.next(true);
|
2005-01-05 20:21:27 +00:00
|
|
|
|
string const temp_str = lex.getString();
|
2004-10-05 13:18:28 +00:00
|
|
|
|
|
|
|
|
|
user_defined_bullet(index).setText(temp_str);
|
|
|
|
|
temp_bullet(index).setText(temp_str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-17 08:23:33 +00:00
|
|
|
|
string const BufferParams::paperSizeName() const
|
|
|
|
|
{
|
|
|
|
|
char real_papersize = papersize;
|
|
|
|
|
if (real_papersize == PAPER_DEFAULT)
|
|
|
|
|
real_papersize = lyxrc.default_papersize;
|
|
|
|
|
|
|
|
|
|
switch (real_papersize) {
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_A3:
|
2003-07-17 08:23:33 +00:00
|
|
|
|
return "a3";
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_A4:
|
2003-07-17 08:23:33 +00:00
|
|
|
|
return "a4";
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_A5:
|
2003-07-17 08:23:33 +00:00
|
|
|
|
return "a5";
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_B5:
|
2003-07-17 08:23:33 +00:00
|
|
|
|
return "b5";
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_USEXECUTIVE:
|
2003-07-17 08:23:33 +00:00
|
|
|
|
return "foolscap";
|
2005-07-16 16:57:55 +00:00
|
|
|
|
case PAPER_USLEGAL:
|
2003-07-17 08:23:33 +00:00
|
|
|
|
return "legal";
|
|
|
|
|
case PAPER_USLETTER:
|
|
|
|
|
default:
|
|
|
|
|
return "letter";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const BufferParams::dvips_options() const
|
|
|
|
|
{
|
|
|
|
|
string result;
|
|
|
|
|
|
|
|
|
|
if (use_geometry
|
2005-07-16 16:57:55 +00:00
|
|
|
|
&& papersize == PAPER_CUSTOM
|
2003-07-17 08:23:33 +00:00
|
|
|
|
&& !lyxrc.print_paper_dimension_flag.empty()
|
|
|
|
|
&& !paperwidth.empty()
|
|
|
|
|
&& !paperheight.empty()) {
|
|
|
|
|
// using a custom papersize
|
|
|
|
|
result = lyxrc.print_paper_dimension_flag;
|
|
|
|
|
result += ' ' + paperwidth;
|
|
|
|
|
result += ',' + paperheight;
|
|
|
|
|
} else {
|
|
|
|
|
string const paper_option = paperSizeName();
|
|
|
|
|
if (paper_option != "letter" ||
|
|
|
|
|
orientation != ORIENTATION_LANDSCAPE) {
|
2003-07-28 14:40:29 +00:00
|
|
|
|
// dvips won't accept -t letter -t landscape.
|
2003-07-17 08:23:33 +00:00
|
|
|
|
// In all other cases, include the paper size
|
|
|
|
|
// explicitly.
|
|
|
|
|
result = lyxrc.print_paper_flag;
|
|
|
|
|
result += ' ' + paper_option;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (orientation == ORIENTATION_LANDSCAPE &&
|
2005-07-16 16:57:55 +00:00
|
|
|
|
papersize != PAPER_CUSTOM)
|
2003-07-17 08:23:33 +00:00
|
|
|
|
result += ' ' + lyxrc.print_landscape_flag;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2004-03-07 14:33:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const BufferParams::babelCall(string const & lang_opts) const
|
|
|
|
|
{
|
|
|
|
|
string tmp = lyxrc.language_package;
|
|
|
|
|
if (!lyxrc.language_global_options && tmp == "\\usepackage{babel}")
|
|
|
|
|
tmp = string("\\usepackage[") + lang_opts + "]{babel}";
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|