2001-12-28 13:26:54 +00:00
|
|
|
// -*- C++ -*-
|
2002-11-07 19:51:22 +00:00
|
|
|
/**
|
|
|
|
* \file lyxtextclass.h
|
|
|
|
* 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
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-11-07 19:51:22 +00:00
|
|
|
*/
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
#ifndef LYXTEXTCLASS_H
|
|
|
|
#define LYXTEXTCLASS_H
|
|
|
|
|
|
|
|
#include "lyxlayout.h"
|
2003-09-05 17:23:11 +00:00
|
|
|
#include "support/std_string.h"
|
2002-06-24 20:28:12 +00:00
|
|
|
#include "lyxlayout_ptr_fwd.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
#include "support/types.h"
|
|
|
|
|
2002-09-06 14:48:01 +00:00
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class LyXLex;
|
2002-09-06 14:48:01 +00:00
|
|
|
class Counters;
|
2002-09-11 07:39:55 +00:00
|
|
|
class FloatList;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Stores the layout specification of a LyX document class.
|
2001-12-28 13:26:54 +00:00
|
|
|
class LyXTextClass {
|
|
|
|
public:
|
2002-11-07 19:51:22 +00:00
|
|
|
/// The individual styles comprising the document class
|
2002-06-24 20:28:12 +00:00
|
|
|
typedef std::vector<LyXLayout_ptr> LayoutList;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Enumerate the paragraph styles.
|
2001-12-28 13:26:54 +00:00
|
|
|
typedef LayoutList::const_iterator const_iterator;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Construct a layout with default values. Actual values loaded later.
|
2001-12-28 13:26:54 +00:00
|
|
|
explicit
|
2002-09-06 14:48:01 +00:00
|
|
|
LyXTextClass(string const & = string(),
|
|
|
|
string const & = string(),
|
2003-05-03 19:24:36 +00:00
|
|
|
string const & = string(),
|
|
|
|
bool = false);
|
|
|
|
|
|
|
|
/// check whether the TeX class is available
|
|
|
|
bool isTeXClassAvailable() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// paragraph styles begin iterator.
|
2002-08-27 15:51:19 +00:00
|
|
|
const_iterator begin() const { return layoutlist_.begin(); }
|
2002-11-07 19:51:22 +00:00
|
|
|
/// paragraph styles end iterator
|
2002-08-27 15:51:19 +00:00
|
|
|
const_iterator end() const { return layoutlist_.end(); }
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Performs the read of the layout file.
|
2001-12-28 13:26:54 +00:00
|
|
|
bool Read(string const & filename, bool merge = false);
|
|
|
|
///
|
|
|
|
void readOutputType(LyXLex &);
|
|
|
|
///
|
2003-02-13 17:49:09 +00:00
|
|
|
void readTitleType(LyXLex &);
|
|
|
|
///
|
2001-12-28 13:26:54 +00:00
|
|
|
void readMaxCounter(LyXLex &);
|
|
|
|
///
|
|
|
|
void readClassOptions(LyXLex &);
|
|
|
|
///
|
2002-09-04 06:52:26 +00:00
|
|
|
void readFloat(LyXLex &);
|
|
|
|
///
|
2002-09-06 14:48:01 +00:00
|
|
|
void readCounter(LyXLex &);
|
|
|
|
///
|
2001-12-28 13:26:54 +00:00
|
|
|
bool hasLayout(string const & name) const;
|
|
|
|
|
|
|
|
///
|
2002-06-24 20:28:12 +00:00
|
|
|
LyXLayout_ptr const & operator[](string const & vname) const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
/// Sees to that the textclass structure has been loaded
|
2002-03-02 16:39:54 +00:00
|
|
|
bool load() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// the list of floats defined in the document class
|
2002-08-27 15:51:19 +00:00
|
|
|
FloatList & floats();
|
2002-11-07 19:51:22 +00:00
|
|
|
/// the list of floats defined in the document class
|
2002-08-27 15:51:19 +00:00
|
|
|
FloatList const & floats() const;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// The Counters present in this document class.
|
2002-09-06 14:48:01 +00:00
|
|
|
Counters & counters() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-09-06 14:48:01 +00:00
|
|
|
string const & defaultLayoutName() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-06-24 20:28:12 +00:00
|
|
|
LyXLayout_ptr const & defaultLayout() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
string const & name() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
string const & latexname() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
string const & description() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
string const & opt_fontsize() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
string const & opt_pagestyle() const;
|
|
|
|
///
|
|
|
|
string const & options() const;
|
|
|
|
///
|
|
|
|
string const & pagestyle() const;
|
|
|
|
///
|
|
|
|
string const & preamble() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
/// Packages that are already loaded by the class
|
|
|
|
enum Provides {
|
|
|
|
///
|
|
|
|
nothing = 0,
|
|
|
|
///
|
|
|
|
amsmath = 1,
|
|
|
|
///
|
|
|
|
makeidx = 2,
|
|
|
|
///
|
2002-04-23 22:34:24 +00:00
|
|
|
url = 4,
|
|
|
|
///
|
|
|
|
natbib = 8
|
2001-12-28 13:26:54 +00:00
|
|
|
};
|
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
bool provides(Provides p) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
unsigned int columns() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
|
|
|
enum PageSides {
|
|
|
|
///
|
|
|
|
OneSide,
|
|
|
|
///
|
|
|
|
TwoSides
|
|
|
|
};
|
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
PageSides sides() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
int secnumdepth() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
int tocdepth() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Can be LaTeX, LinuxDoc, etc.
|
2002-03-02 16:39:54 +00:00
|
|
|
OutputType outputType() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
LyXFont const & defaultfont() const;
|
|
|
|
|
|
|
|
/// Text that dictates how wide the left margin is on the screen
|
|
|
|
string const & leftmargin() const;
|
|
|
|
|
|
|
|
/// Text that dictates how wide the right margin is on the screen
|
|
|
|
string const & rightmargin() const;
|
2002-03-21 17:27:08 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
int maxcounter() const;
|
2003-02-13 17:49:09 +00:00
|
|
|
|
|
|
|
/// The type of command used to produce a title
|
|
|
|
LYX_TITLE_LATEX_TYPES titletype() const;
|
|
|
|
/// The name of the title command
|
|
|
|
string const & titlename() const;
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
int size() const;
|
2001-12-28 13:26:54 +00:00
|
|
|
private:
|
|
|
|
///
|
|
|
|
bool delete_layout(string const &);
|
|
|
|
///
|
|
|
|
bool do_readStyle(LyXLex &, LyXLayout &);
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Layout file name
|
2001-12-28 13:26:54 +00:00
|
|
|
string name_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// document class name
|
2001-12-28 13:26:54 +00:00
|
|
|
string latexname_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// document class description
|
2001-12-28 13:26:54 +00:00
|
|
|
string description_;
|
|
|
|
/// Specific class options
|
|
|
|
string opt_fontsize_;
|
|
|
|
///
|
|
|
|
string opt_pagestyle_;
|
|
|
|
///
|
|
|
|
string options_;
|
|
|
|
///
|
|
|
|
string pagestyle_;
|
|
|
|
///
|
2002-03-02 16:39:54 +00:00
|
|
|
string defaultlayout_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// preamble text to support layout styles
|
2001-12-28 13:26:54 +00:00
|
|
|
string preamble_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// latex packages loaded by document class.
|
2001-12-28 13:26:54 +00:00
|
|
|
Provides provides_;
|
|
|
|
///
|
|
|
|
unsigned int columns_;
|
|
|
|
///
|
|
|
|
PageSides sides_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// header depth to have numbering
|
2001-12-28 13:26:54 +00:00
|
|
|
int secnumdepth_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// header depth to appear in table of contents
|
2001-12-28 13:26:54 +00:00
|
|
|
int tocdepth_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Can be LaTeX, LinuxDoc, etc.
|
2001-12-28 13:26:54 +00:00
|
|
|
OutputType outputType_;
|
|
|
|
/** Base font. The paragraph and layout fonts are resolved against
|
|
|
|
this font. This has to be fully instantiated. Attributes
|
|
|
|
LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
|
|
|
|
extremely illegal.
|
|
|
|
*/
|
|
|
|
LyXFont defaultfont_;
|
|
|
|
/// Text that dictates how wide the left margin is on the screen
|
|
|
|
string leftmargin_;
|
|
|
|
|
|
|
|
/// Text that dictates how wide the right margin is on the screen
|
|
|
|
string rightmargin_;
|
2002-11-07 19:51:22 +00:00
|
|
|
/// highest header level used in this layout.
|
2001-12-28 13:26:54 +00:00
|
|
|
int maxcounter_; // add approp. signedness
|
|
|
|
|
2003-02-13 17:49:09 +00:00
|
|
|
/// The type of command used to produce a title
|
|
|
|
LYX_TITLE_LATEX_TYPES titletype_;
|
|
|
|
/// The name of the title command
|
|
|
|
string titlename_;
|
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Paragraph styles used in this layout
|
2002-08-27 15:51:19 +00:00
|
|
|
LayoutList layoutlist_;
|
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// available types of float, eg. figure, algorithm.
|
2002-09-11 07:39:55 +00:00
|
|
|
boost::shared_ptr<FloatList> floatlist_;
|
2001-12-28 13:26:54 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Types of counters, eg. sections, eqns, figures, avail. in document class.
|
2002-09-06 14:48:01 +00:00
|
|
|
boost::shared_ptr<Counters> ctrs_;
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
/// Has this layout file been loaded yet?
|
2002-03-02 16:39:54 +00:00
|
|
|
mutable bool loaded;
|
2003-05-03 19:24:36 +00:00
|
|
|
|
|
|
|
/// Is the TeX class available?
|
|
|
|
bool texClassAvail_;
|
2001-12-28 13:26:54 +00:00
|
|
|
};
|
|
|
|
|
2002-03-02 16:39:54 +00:00
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// Merge two different provides flags into one bit field record
|
2001-12-28 13:26:54 +00:00
|
|
|
inline
|
|
|
|
void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
|
|
|
|
{
|
|
|
|
p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-07 19:51:22 +00:00
|
|
|
/// convert page sides option to text 1 or 2
|
2001-12-28 13:26:54 +00:00
|
|
|
std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
|
|
|
|
|
|
|
|
#endif
|