+2002-03-02 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * layouts/stdclass.inc: add DefaultStyle
+
2002-03-01 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* doc/LaTeXConfig.lyx.in: add entry for svprothb
Sides 1
SecNumDepth 2
TocDepth 2
+DefaultStyle Standard
# This is just to show how to declare the default font.
# The defaults are exactly those shown here.
inset->insetUnlock(this);
theLockingInset(0);
// make sure we update the combo !
- owner()->setLayout(getLyXText()->cursor.par()->getLayout());
+ owner()->setLayout(getLyXText()->cursor.par()->layout());
finishUndo();
return 0;
} else if (inset && theLockingInset() &&
#include <clocale>
-extern lyx::layout_type current_layout;
+extern string current_layout;
using std::vector;
using std::find_if;
using SigC::slot;
using lyx::pos_type;
-using lyx::layout_type;
using lyx::textclass_type;
/* the selection possible is needed, that only motion events are
// Maybe we want to edit a bibitem ale970302
if (bv_->text->cursor.par()->bibkey && x < 20 +
- bibitemMaxWidth(bv_, textclasslist.
- TextClass(buffer_->
- params.textclass).defaultfont())) {
+ bibitemMaxWidth(bv_, textclasslist[buffer_->params.textclass].defaultfont())) {
bv_->text->cursor.par()->bibkey->edit(bv_, 0, 0, 0);
}
// Derive layout number from given argument (string)
// and current buffer's textclass (number). */
textclass_type tclass = buffer_->params.textclass;
- pair <bool, layout_type> layout =
- textclasslist.NumberOfLayout(tclass, argument);
+ bool hasLayout =
+ textclasslist[tclass].hasLayout(argument);
+ string layout = argument;
// If the entry is obsolete, use the new one instead.
- if (layout.first) {
- string obs = textclasslist.Style(tclass, layout.second)
+ if (hasLayout) {
+ string const & obs = textclasslist[tclass][layout]
.obsoleted_by();
if (!obs.empty())
- layout = textclasslist.NumberOfLayout(tclass, obs);
+ layout = obs;
}
- // see if we found the layout number:
- if (!layout.first) {
+ if (!hasLayout) {
owner_->getLyXFunc()->setErrorMessage(
string(N_("Layout ")) + argument +
N_(" not known"));
break;
}
- if (current_layout != layout.second) {
+ if (current_layout != layout) {
LyXText * lt = bv_->getLyXText();
hideCursor();
- current_layout = layout.second;
+ current_layout = layout;
update(lt,
BufferView::SELECT
| BufferView::FITCUR);
- lt->setLayout(bv_, layout.second);
- owner_->setLayout(layout.second);
+ lt->setLayout(bv_, layout);
+ owner_->setLayout(layout);
update(lt,
BufferView::SELECT
| BufferView::FITCUR
{
LyXText * lt = bv_->getLyXText();
- LyXLayout const & style = textclasslist
- .Style(buffer_->params.textclass,
- lt->cursor.par()->getLayout());
+ LyXLayout const & style = textclasslist[buffer_->params.textclass][lt->cursor.par()->layout()];
if (style.free_spacing) {
lt->insertChar(bv_, ' ');
break;
case LFUN_GETLAYOUT:
- owner_->getLyXFunc()->setMessage(tostr(bv_->getLyXText()->cursor.par()->layout));
+ owner_->getLyXFunc()->setMessage(tostr(bv_->getLyXText()->cursor.par()->layout()));
break;
case LFUN_GETFONT:
hideCursor();
- LyXLayout const & style = textclasslist.Style(
- bv_->buffer()->params.textclass, par->getLayout());
+ LyXLayout const & style =
+ textclasslist[bv_->buffer()->params.textclass][par->layout()];
if (style.pass_thru ||
(!insertInset(new InsetQuotes(c, bv_->buffer()->params))))
update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
- pair<bool, layout_type> lres =
- textclasslist.NumberOfLayout(buffer_->params .textclass, lout);
- layout_type lay = 0;
- if (lres.first != false) {
+ string lres = lout;
+ LyXTextClass const & tclass =
+ textclasslist[buffer_->params.textclass];
+ bool hasLayout = tclass.hasLayout(lres);
+ string lay = tclass.defaultLayoutName();
+
+ if (hasLayout != false) {
// layout found
- lay = lres.second;
+ lay = lres;
} else {
- // layout not fount using default "Standard" (0)
- lay = 0;
+ // layout not fount using default
+ lay = tclass.defaultLayoutName();
}
-
+
bv_->text->setLayout(bv_, lay);
bv_->text->setParagraph(bv_, 0, 0,
2002-03-02 Lars Gullik Bjønnes <larsbj@birdstep.com>
+ * text2.C: layout as string
+
+ * text.C: layout as string
+
+ * paragraph_pimpl.C: layout as string
+
+ * paragraph.[Ch]: layout as string
+
+ * lyxtextclasslist.[Ch]: layout as string
+
+ * lyxtextclass.[Ch]: layout as string
+
+ * lyxtext.h: layout as string
+
+ * lyxlayout.[Ch]: layout as string
+
+ * lyx_cb.C: layout as string
+
+ * bufferview_funcs.C: layout as string
+
+ * bufferparams.C: layout as string
+
+ * buffer.C: layout as string
+
+ * LyXView.[Ch]: layout as string
+
+ * LaTeXFeatures.[Ch]: layout as string
+
+ * CutAndPaste.C (SwitchLayoutsBetweenClasses): layout as string
+
+ * BufferView_pimpl.C: change current_layout to string, remove
+ lyx::layout_type.
+ (Dispatch):
+ (smartQuote):
+ (insertInset):
+ (workAreaButtonRelease): layout as string
+
+ * BufferView2.C (unlockInset): adjust
+
* vspace.C (asLatexCommand): use an explict temp variable.
2002-03-01 John Levon <moz@compsoc.man.ac.uk>
using std::pair;
using lyx::pos_type;
-using lyx::layout_type;
using lyx::textclass_type;
extern BufferView * current_view;
ParIterator end = ParIterator();
for (ParIterator it = ParIterator(par); it != end; ++it) {
par = *it;
- string const name = textclasslist.NameOfLayout(c1, par->layout);
- int lay = 0;
- pair<bool, layout_type> pp =
- textclasslist.NumberOfLayout(c2, name);
- if (pp.first) {
- lay = pp.second;
+ string const name = par->layout();
+ LyXTextClass const & tclass = textclasslist[c2];
+
+ bool hasLayout = tclass.hasLayout(name);
+
+ string lay = tclass.defaultLayoutName();
+ if (hasLayout) {
+ lay = name;
} else {
- // not found: use default layout "Standard" (0)
- lay = 0;
+ // not found: use default layout
+ lay = tclass.defaultLayoutName();
}
- par->layout = lay;
+ par->layout(lay);
- if (name != textclasslist.NameOfLayout(c2, par->layout)) {
+ if (name != par->layout()) {
++ret;
string const s = _("Layout had to be changed from\n")
+ name + _(" to ")
- + textclasslist.NameOfLayout(c2, par->layout)
+ + par->layout()
+ _("\nbecause of class conversion from\n")
- + textclasslist.NameOfClass(c1) + _(" to ")
- + textclasslist.NameOfClass(c2);
+ + textclasslist[c1].name() + _(" to ")
+ + textclasslist[c2].name();
InsetError * new_inset = new InsetError(s);
par->insertInset(0, new_inset,
LyXFont(LyXFont::ALL_INHERIT,
#include "support/filetools.h"
#include "support/lstrings.h"
-using lyx::layout_type;
using lyx::textclass_type;
using std::endl;
using std::ostream;
-LaTeXFeatures::LaTeXFeatures(BufferParams const & p, layout_type n)
- : layout(n, false), params(p)
+LaTeXFeatures::LaTeXFeatures(BufferParams const & p)
+ : params(p)
{}
}
-void LaTeXFeatures::useLayout(vector<bool>::size_type const & idx)
+void LaTeXFeatures::useLayout(string const & lyt)
{
- layout[idx] = true;
+ layout.insert(lyt);
}
string const LaTeXFeatures::getPackages() const
{
ostringstream packages;
- LyXTextClass const & tclass =
- textclasslist.TextClass(params.textclass);
+ LyXTextClass const & tclass = textclasslist[params.textclass];
/**
string const LaTeXFeatures::getTClassPreamble() const
{
// the text class specific preamble
- LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
+ LyXTextClass const & tclass = textclasslist[params.textclass];
ostringstream tcpreamble;
tcpreamble << tclass.preamble();
- for (layout_type i = 0; i < tclass.numLayouts(); ++i) {
- if (layout[i]) {
- tcpreamble << tclass[i].preamble();
- }
+ set<string>::const_iterator cit = layout.begin();
+ set<string>::const_iterator end = layout.end();
+ for (; cit != end; ++cit) {
+ tcpreamble << tclass[*cit].preamble();
}
-
+
return tcpreamble.str().c_str();
}
return params;
}
+
void LaTeXFeatures::getFloatDefinitions(ostream & os) const
{
// Here we will output the code to create the needed float styles.
class LaTeXFeatures {
public:
///
- LaTeXFeatures(BufferParams const &, lyx::layout_type n) ;
+ LaTeXFeatures(BufferParams const &);
/// The packages needed by the document
string const getPackages() const;
/// The macros definitions needed by the document
///
std::set<string> getEncodingSet(string const & doc_encoding);
///
- ///
- void useLayout(std::vector<bool>::size_type const & idx);
+ void useLayout(string const & lyt);
///
BufferParams const & bufferParams() const;
///
private:
string externalPreambles;
- std::vector<bool> layout;
+ std::set<string> layout;
/// Static preamble bits from the external material insets
#include "gettext.h"
#include "lyxfunc.h"
#include "BufferView.h"
+#include "lyxtextclasslist.h"
#include "frontends/Dialogs.h"
#include "frontends/Toolbar.h"
#include <unistd.h>
using std::endl;
-using lyx::layout_type;
extern void AutoSave(BufferView *);
extern void QuitLyX();
-layout_type current_layout = 0;
+string current_layout;
LyXView::LyXView()
}
-void LyXView::setLayout(layout_type layout)
+void LyXView::setLayout(string const & layout)
{
toolbar->setLayout(layout);
}
if (last_textclass != int(buffer()->params.textclass)) {
toolbar->updateLayoutList(true);
last_textclass = int(buffer()->params.textclass);
- current_layout = 0;
+ current_layout = textclasslist[last_textclass].defaultLayoutName();
} else {
toolbar->updateLayoutList(false);
}
-
- layout_type layout = bufferview->getLyXText()->cursor.par()->getLayout();
+
+ string const & layout =
+ bufferview->getLyXText()->cursor.par()->layout();
if (layout != current_layout) {
toolbar->setLayout(layout);
Toolbar * getToolbar() const;
/// sets the layout in the toolbar layout combox
- void setLayout(lyx::layout_type layout);
-
+ void setLayout(string const & layout);
/// update the toolbar
void updateToolbar();
using std::list;
using lyx::pos_type;
-using lyx::layout_type;
using lyx::textclass_type;
// all these externs should eventually be removed.
string const layoutname = lex.getString();
//lyxerr << "Looking for layout '"
// << layoutname << "'!" << endl;
-
- pair<bool, layout_type> pp
- = textclasslist.NumberOfLayout(params.textclass, layoutname);
//lyxerr << "Result: " << pp.first << "/" << pp.second << endl;
par = new Paragraph(par);
}
pos = 0;
- if (pp.first) {
- par->layout = pp.second;
-#ifndef NO_COMPABILITY
- } else if (ert_comp.active) {
- par->layout = 0;
-#endif
- } else {
- // layout not found
- // use default layout "Standard" (0)
- //lyxerr << "Layout '" << layoutname
- // << "' was not found!" << endl;
-
- par->layout = 0;
- ++unknown_layouts;
- string const s = _("Layout had to be changed from\n")
- + layoutname + _(" to ")
- + textclasslist.NameOfLayout(params.textclass, par->layout);
- InsetError * new_inset = new InsetError(s);
- par->insertInset(0, new_inset,
- LyXFont(LyXFont::ALL_INHERIT,
- params.language));
- }
+ par->layout(layoutname);
// Test whether the layout is obsolete.
LyXLayout const & layout =
- textclasslist.Style(params.textclass,
- par->layout);
+ textclasslist[params.textclass][par->layout()];
if (!layout.obsoleted_by().empty())
- par->layout = textclasslist
- .NumberOfLayout(params.textclass,
- layout.obsoleted_by())
- .second;
+ par->layout(layout.obsoleted_by());
par->params().depth(depth);
font = LyXFont(LyXFont::ALL_INHERIT, params.language);
if (file_format < 216
string(_("LyX will not be able to produce output correctly.")));
params.textclass = 0;
}
- if (!textclasslist.Load(params.textclass)) {
+ if (!textclasslist[params.textclass].load()) {
// if the textclass wasn't loaded properly
// we need to either substitute another
// or stop loading the file.
// stop loading... ideas?? ARRae980418
Alert::alert(_("Textclass Loading Error!"),
string(_("Can't load textclass ")) +
- textclasslist.NameOfClass(params.textclass),
+ textclasslist[params.textclass].name(),
_("-- substituting default"));
params.textclass = 0;
}
#endif
} else if (token == "\\SpecialChar") {
LyXLayout const & layout =
- textclasslist.Style(params.textclass,
- par->getLayout());
+ textclasslist[params.textclass][par->layout()];
// Insets don't make sense in a free-spacing context! ---Kayvan
if (layout.free_spacing || par->isFreeSpacing()) {
// Remove it later some time...introduced with fileformat
// 2.16. (Lgb)
LyXLayout const & layout =
- textclasslist.Style(params.textclass,
- par->getLayout());
+ textclasslist[params.textclass][par->layout()];
if (layout.free_spacing || par->isFreeSpacing()) {
par->insertChar(pos, ' ', font);
if (checkminipage && (call_depth == 1)) {
checkminipage = false;
if (minipar && (minipar != par) &&
- (par->params().pextraType()==Paragraph::PEXTRA_MINIPAGE))
- {
+ (par->params().pextraType() == Paragraph::PEXTRA_MINIPAGE)) {
lyxerr << "minipages in a row" << endl;
if (par->params().pextraStartMinipage()) {
lyxerr << "start new minipage" << endl;
// create a new paragraph to insert the
// minipages in the following case
if (par->params().pextraStartMinipage() &&
- !par->params().pextraHfill())
- {
+ !par->params().pextraHfill()) {
Paragraph * p = new Paragraph;
- p->layout = 0;
+ p->layout(textclasslist[params.textclass].defaultLayoutName());
+
p->previous(parBeforeMinipage);
parBeforeMinipage->next(p);
p->next(0);
// a sequence of minipages
// in its own paragraph.
Paragraph * p = new Paragraph;
- p->layout = 0;
+ p->layout(textclasslist[params.textclass].defaultLayoutName());
p->previous(par->previous());
p->next(0);
p->params().depth(depth);
void Buffer::insertStringAsLines(Paragraph *& par, pos_type & pos,
LyXFont const & fn,string const & str) const
{
- LyXLayout const & layout = textclasslist.Style(params.textclass,
- par->getLayout());
+ LyXLayout const & layout =
+ textclasslist[params.textclass][par->layout()];
LyXFont font = fn;
- (void)par->checkInsertChar(font);
+ par->checkInsertChar(font);
// insert the string, don't insert doublespace
bool space_inserted = true;
for(string::const_iterator cit = str.begin();
#endif
// First write the layout
- string const tmp = textclasslist.NameOfLayout(params.textclass, par->layout);
- if (tmp == "Itemize") {
+ string const & tmp = lowercase(par->layout());
+ if (tmp == "itemize") {
ltype = 1;
ltype_depth = depth + 1;
- } else if (tmp == "Enumerate") {
+ } else if (tmp == "enumerate") {
ltype = 2;
ltype_depth = depth + 1;
} else if (contains(tmp, "ection")) {
} else if (contains(tmp, "aragraph")) {
ltype = 4;
ltype_depth = depth + 1;
- } else if (tmp == "Description") {
+ } else if (tmp == "description") {
ltype = 5;
ltype_depth = depth + 1;
- } else if (tmp == "Abstract") {
+ } else if (tmp == "abstract") {
ltype = 6;
ltype_depth = 0;
- } else if (tmp == "Bibliography") {
+ } else if (tmp == "bibliography") {
ltype = 7;
ltype_depth = 0;
} else {
tex_code_break_column = lyxrc.ascii_linelen;
LyXTextClass const & tclass =
- textclasslist.TextClass(params.textclass);
+ textclasslist[params.textclass];
ofstream ofs(fname.c_str());
if (!ofs) {
// validate the buffer.
lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
- LaTeXFeatures features(params, tclass.numLayouts());
+ LaTeXFeatures features(params, tclass.size());
validate(features);
lyxerr[Debug::LATEX] << " Buffer validation done." << endl;
}
ofs << '{'
- << textclasslist.LatexnameOfClass(params.textclass)
+ << textclasslist[params.textclass].latexname()
<< "}\n";
texrow.newline();
// end of \documentclass defs
// any environment other then "Standard" to be valid!
if ((in == 0) || !in->forceDefaultParagraphs(in)) {
LyXLayout const & layout =
- textclasslist.Style(params.textclass, par->layout);
+ textclasslist[params.textclass][par->layout()];
if (layout.intitle) {
if (already_title) {
bool Buffer::isLatex() const
{
- return textclasslist.TextClass(params.textclass).outputType() == LATEX;
+ return textclasslist[params.textclass].outputType() == LATEX;
}
bool Buffer::isLinuxDoc() const
{
- return textclasslist.TextClass(params.textclass).outputType() == LINUXDOC;
+ return textclasslist[params.textclass].outputType() == LINUXDOC;
}
bool Buffer::isLiterate() const
{
- return textclasslist.TextClass(params.textclass).outputType() == LITERATE;
+ return textclasslist[params.textclass].outputType() == LITERATE;
}
bool Buffer::isDocBook() const
{
- return textclasslist.TextClass(params.textclass).outputType() == DOCBOOK;
+ return textclasslist[params.textclass].outputType() == DOCBOOK;
}
bool Buffer::isSGML() const
{
- return textclasslist.TextClass(params.textclass).outputType() == LINUXDOC ||
- textclasslist.TextClass(params.textclass).outputType() == DOCBOOK;
+ LyXTextClass const & tclass = textclasslist[params.textclass];
+
+ return tclass.outputType() == LINUXDOC ||
+ tclass.outputType() == DOCBOOK;
}
niceFile = nice; // this will be used by included files.
- LyXTextClass const & tclass =
- textclasslist.TextClass(params.textclass);
+ LyXTextClass const & tclass = textclasslist[params.textclass];
- LaTeXFeatures features(params, tclass.numLayouts());
+ LaTeXFeatures features(params, tclass.size());
+
validate(features);
texrow.reset();
- string top_element = textclasslist.LatexnameOfClass(params.textclass);
+ string top_element = textclasslist[params.textclass].latexname();
if (!body_only) {
ofs << "<!doctype linuxdoc system";
while (par) {
LyXLayout const & style =
- textclasslist.Style(params.textclass,
- par->layout);
+ textclasslist[params.textclass][par->layout()];
// treat <toc> as a special case for compatibility with old code
if (par->isInset(0)) {
Paragraph * par,
Paragraph::depth_type /*depth*/)
{
- LyXLayout const & style = textclasslist.Style(params.textclass,
- par->getLayout());
+ LyXLayout const & style =
+ textclasslist[params.textclass][par->layout()];
string::size_type char_line_count = 5; // Heuristic choice ;-)
// gets paragraph main font
niceFile = nice; // this will be used by Insetincludes.
LyXTextClass const & tclass =
- textclasslist.TextClass(params.textclass);
+ textclasslist[params.textclass];
- LaTeXFeatures features(params, tclass.numLayouts());
+ LaTeXFeatures features(params, tclass.size());
validate(features);
texrow.reset();
- string top_element = textclasslist.LatexnameOfClass(params.textclass);
+ string top_element = textclasslist[params.textclass].latexname();
if (!only_body) {
ofs << "<!DOCTYPE " << top_element
int desc_on = 0; // description mode
LyXLayout const & style =
- textclasslist.Style(params.textclass,
- par->layout);
+ textclasslist[params.textclass][par->layout()];
// environment tag closing
for (; depth > par->params().depth(); --depth) {
{
bool emph_flag = false;
- LyXLayout const & style = textclasslist.Style(params.textclass,
- par->getLayout());
+ LyXLayout const & style =
+ textclasslist[params.textclass][par->layout()];
LyXFont font_old = style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
void Buffer::validate(LaTeXFeatures & features) const
{
Paragraph * par = paragraph;
- LyXTextClass const & tclass =
- textclasslist.TextClass(params.textclass);
+ LyXTextClass const & tclass = textclasslist[params.textclass];
// AMS Style is at document level
if (params.use_amsmath || tclass.provides(LyXTextClass::amsmath))
Lists l;
Paragraph * par = paragraph;
-#if 1
- std::pair<bool, textclass_type> const tmp =
- textclasslist.NumberOfLayout(params.textclass, "Caption");
- bool const found = tmp.first;
- textclass_type const cap = tmp.second;
-
-#else
- // This is the prefered way to to this, but boost::tie can break
- // some compilers
- bool found;
- textclass_type cap;
- boost::tie(found, cap) = textclasslist
- .NumberOfLayout(params.textclass, "Caption");
-#endif
+ LyXTextClass const & textclass = textclasslist[params.textclass];
+ bool found = textclass.hasLayout("caption");
+ string const layout("caption");
while (par) {
- char const labeltype =
- textclasslist.Style(params.textclass,
- par->getLayout()).labeltype;
+ char const labeltype = textclass[par->layout()].labeltype;
if (labeltype >= LABEL_COUNTER_CHAPTER
&& labeltype <= LABEL_COUNTER_CHAPTER + params.tocdepth) {
SingleList & item = l["TOC"];
int depth = max(0,
labeltype -
- textclasslist.TextClass(params.textclass).maxcounter());
+ textclass.maxcounter());
item.push_back(TocItem(par, depth, par->asString(this, true)));
}
// For each paragrph, traverse its insets and look for
// the inset...
Paragraph * tmp = il->inset.paragraph();
while (tmp) {
- if (tmp->layout == cap) {
+ if (tmp->layout() == layout) {
SingleList & item = l[type];
string const str =
tostr(item.size()+1) + ". " + tmp->asString(this, false);
// Prints out the buffer info into the .lyx file given by file
// the textclass
- os << "\\textclass " << textclasslist.NameOfClass(textclass) << '\n';
+ os << "\\textclass " << textclasslist[textclass].name() << '\n';
// then the the preamble
if (!preamble.empty()) {
void BufferParams::useClassDefaults()
{
- LyXTextClass const & tclass = textclasslist.TextClass(textclass);
+ LyXTextClass const & tclass = textclasslist[textclass];
sides = tclass.sides();
columns = tclass.columns();
bool BufferParams::hasClassDefaults() const
{
- LyXTextClass const & tclass = textclasslist.TextClass(textclass);
+ LyXTextClass const & tclass = textclasslist[textclass];
return (sides == tclass.sides()
&& columns == tclass.columns()
Buffer * buffer = bv->buffer();
LyXFont font = text->real_current_font;
LyXFont const & defaultfont =
- textclasslist
- .TextClass(buffer->params.textclass)
- .defaultfont();
+ textclasslist[buffer->params.textclass].defaultfont();
font.reduce(defaultfont);
state << _("Font:") << ' '
+2002-03-02 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * Toolbar.[Ch] (setLayout): layout as string
+
2002-02-28 Angus Leeming <a.leeming@ic.ac.uk>
* Dialogs.h (initialiseGraphics): a new static method.
}
-void Toolbar::setLayout(int layout)
+
+void Toolbar::setLayout(string const & layout)
{
pimpl_->setLayout(layout);
}
void update();
/// update the layout combox
- void setLayout(int layout);
+ void setLayout(string const & layout);
/// Populate the layout combox; re-do everything if force is true.
void updateLayoutList(bool force);
/// Drop down the layout list
+2002-03-02 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * QDocument.C (class_update): layout as string
+
2002-03-01 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am:
if (!class_.get())
return;
- LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
+ LyXTextClass const & tclass = textclasslist[params.textclass];
combo_doc_class->select_text(
textclasslist.DescOfClass(params.textclass));
+2002-03-02 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * Toolbar_pimpl.[Ch]: layout as string
+
+ * FormParagraph.C: layout as string
+
+ * FormDocument.C (build): use remove_if and contains_functor
+ layout as string
+
2002-03-01 Martin Vermeer <martin.vermeer@hut.fi>
* FormMathsBitmap.[Ch]:
#include "support/filetools.h"
#include "support/lstrings.h"
+#include <functional>
+
+using std::bind2nd;
+
using Liason::setMinibuffer;
using SigC::slot;
+using std::vector;
FormDocument::FormDocument(LyXView * lv, Dialogs * d)
: FormBaseBD(lv, d, _("Document Layout")),
// Create the contents of the unit choices
// Don't include the "%" terms...
- std::vector<string> units_vec = getLatexUnits();
- for (std::vector<string>::iterator it = units_vec.begin();
+ vector<string> units_vec = getLatexUnits();
+#if 0
+ for (vector<string>::iterator it = units_vec.begin();
it != units_vec.end(); ++it) {
if (contains(*it, "%"))
it = units_vec.erase(it, it+1) - 1;
}
+#else
+ vector<string>::iterator ret =
+ remove_if(units_vec.begin(),
+ units_vec.end(),
+ bind2nd(contains_functor(), "%"));
+ units_vec.erase(ret, units_vec.end());
+#endif
string units = getStringFromVector(units_vec, "|");
fl_addto_choice(paper_->choice_custom_width_units, units.c_str());
if (params.textclass != old_class) {
// try to load new_class
- if (textclasslist.Load(params.textclass)) {
+ if (textclasslist[params.textclass].load()) {
// successfully loaded
redo = true;
setMinibuffer(lv_, _("Converting document to new document class..."));
lv_->buffer()->params);
if (ret) {
string s;
- if (ret==1) {
+ if (ret == 1) {
s = _("One paragraph couldn't be converted");
} else {
s += tostr(ret);
if (!class_.get())
return;
- LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
+ LyXTextClass const & tclass = textclasslist[params.textclass];
- combo_doc_class->select(
- textclasslist.DescOfClass(params.textclass));
+ combo_doc_class->select(tclass.description());
fl_set_choice_text(class_->choice_doc_fonts, params.fonts.c_str());
fl_clear_choice(class_->choice_doc_fontsize);
fl_addto_choice(class_->choice_doc_fontsize, "default");
lv_->prohibitInput();
unsigned int tc = combo_doc_class->get() - 1;
- if (textclasslist.Load(tc)) {
+ if (textclasslist[tc].load()) {
// we use a copy of the bufferparams because we do not
// want to modify them yet.
BufferParams params = lv_->buffer()->params;
fl_set_button(dialog_->radio_align_center, 0);
fl_set_button(dialog_->radio_align_block, 0);
+ LyXTextClass const & tclass = textclasslist[buf->params.textclass];
+
int align = par_->getAlign();
if (align == LYX_ALIGN_LAYOUT)
- align = textclasslist.Style(buf->params.textclass,
- par_->getLayout()).align;
+ align = tclass[par_->layout()].align;
switch (align) {
case LYX_ALIGN_RIGHT:
break;
}
- LyXAlignment alignpos =
- textclasslist.Style(buf->params.textclass,
- par_->getLayout()).alignpossible;
+ LyXAlignment alignpos = tclass[par_->layout()].alignpossible;
setEnabled(dialog_->radio_align_block, bool(alignpos & LYX_ALIGN_BLOCK));
setEnabled(dialog_->radio_align_center, bool(alignpos & LYX_ALIGN_CENTER));
{
string const & layoutguiname = combox->getline();
LyXTextClass const & tc =
- textclasslist.TextClass(owner->buffer()->
- params.textclass);
+ textclasslist[owner->buffer()->params.textclass];
LyXTextClass::const_iterator end = tc.end();
for (LyXTextClass::const_iterator cit = tc.begin();
}
-void Toolbar::Pimpl::setLayout(int layout)
+void Toolbar::Pimpl::setLayout(string const & layout)
{
if (combox) {
LyXTextClass const & tc =
- textclasslist.TextClass(owner->buffer()->
- params.textclass);
+ textclasslist[owner->buffer()->params.textclass];
combox->select(_(tc[layout].name()));
}
}
if (combox->empty() || force) {
combox->clear();
LyXTextClass const & tc =
- textclasslist.TextClass(owner->buffer()->
- params.textclass);
+ textclasslist[owner->buffer()->params.textclass];
LyXTextClass::const_iterator end = tc.end();
for (LyXTextClass::const_iterator cit = tc.begin();
cit != end; ++cit) {
/// update the state of the icons
void update();
-
/// select the right layout in the combox
- void setLayout(int layout);
+ void setLayout(string const & layout);
/// Populate the layout combox; re-do everything if force is true.
void updateLayoutList(bool force);
/// Drop down the layout list
+2002-03-02 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * insettext.C: layout as string
+
+ * insetinclude.C: layout as string
+
+ * insetert.C: layout as string
+
+ * insetbib.C: layout as string
+
2002-02-28 Angus Leeming <a.leeming@ic.ac.uk>
* insetert.C:
// 1. \bibliographystyle{style}
// 2. \addcontentsline{...} - if option bibtotoc set
// 3. \bibliography{database}
- string adb, db_out;
+ string adb;
string db_in = getContents();
db_in = split(db_in, adb, ',');
// part of its name, because it's than book.
// For the "official" lyx-layouts it's no problem to support
// all well
- if (!contains(textclasslist.NameOfClass(buffer->params.textclass),"art")) {
+ if (!contains(textclasslist[buffer->params.textclass].name(),
+ "art")) {
if (buffer->params.sides == LyXTextClass::OneSide) {
// oneside
os << "\\clearpage";
// If we generate in a temp dir, we might need to give an
// absolute path there. This is a bit complicated since we can
// have a comma-separated list of bibliographies
+ string db_out;
while (!adb.empty()) {
if (!buffer->niceFile &&
IsFileReadable(MakeAbsPath(adb, buffer->filePath())+".bib"))
<< "status "<< st << "\n";
//inset.writeParagraphData(buf, os);
- string const layout =
- textclasslist.NameOfLayout(buf->params.textclass, 0);
+ string const layout(textclasslist[buf->params.textclass].defaultLayoutName());
Paragraph * par = inset.paragraph();
while (par) {
os << "\n\\layout " << layout << "\n";
switch (action) {
case LFUN_LAYOUT:
- bv->owner()->setLayout(inset.paragraph()->getLayout());
+ bv->owner()->setLayout(inset.paragraph()->layout());
break;
default:
result = InsetCollapsable::localDispatch(bv, action, arg);
lyxerr << "WARNING: Included file `"
<< MakeDisplayPath(getFileName())
<< "' has textclass `"
- << textclasslist.NameOfClass(tmp->params.textclass)
+ << textclasslist[tmp->params.textclass].name()
<< "' while parent file has textclass `"
- << textclasslist.NameOfClass(buffer->params.textclass)
+ << textclasslist[buffer->params.textclass].name()
<< "'." << endl;
//return 0;
}
using std::pair;
using lyx::pos_type;
-using lyx::layout_type;
using lyx::textclass_type;
extern unsigned char getCurrentTextClass(Buffer *);
bv->owner()->updateMenubar();
bv->owner()->updateToolbar();
if (old_par != cpar(bv)) {
- bv->owner()->setLayout(cpar(bv)->getLayout());
+ bv->owner()->setLayout(cpar(bv)->layout());
old_par = cpar(bv);
}
}
code = FULL;
} else if (owner()) {
bv->owner()->setLayout(owner()->getLyXText(bv)
- ->cursor.par()->getLayout());
+ ->cursor.par()->layout());
} else
- bv->owner()->setLayout(bv->text->cursor.par()->getLayout());
+ bv->owner()->setLayout(bv->text->cursor.par()->layout());
// hack for deleteEmptyParMech
if (par->size()) {
lt->setCursor(bv, par, 0);
lt = 0;
updateLocal(bv, CURSOR, false);
}
- bv->owner()->setLayout(cpar(bv)->getLayout());
+ bv->owner()->setLayout(cpar(bv)->layout());
old_par = cpar(bv);
// Insert primary selection with middle mouse
// if there is a local selection in the current buffer,
case LFUN_LAYOUT:
// do not set layouts on non breakable textinsets
if (autoBreakRows) {
- layout_type cur_layout = cpar(bv)->layout;
+ string cur_layout = cpar(bv)->layout();
// Derive layout number from given argument (string)
// and current buffer's textclass (number). */
textclass_type tclass = bv->buffer()->params.textclass;
- pair<bool, layout_type> layout =
- textclasslist.NumberOfLayout(tclass, arg);
+ string layout = lowercase(arg);
+ bool hasLayout = textclasslist[tclass].hasLayout(layout);
// If the entry is obsolete, use the new one instead.
- if (layout.first) {
- string obs = textclasslist.Style(tclass,layout.second).
+ if (hasLayout) {
+ string const & obs =
+ textclasslist[tclass][layout].
obsoleted_by();
if (!obs.empty())
- layout = textclasslist.NumberOfLayout(tclass, obs);
+ layout = lowercase(obs);
}
// see if we found the layout number:
- if (!layout.first) {
+ if (!hasLayout) {
string const msg = string(N_("Layout ")) + arg + N_(" not known");
bv->owner()->getLyXFunc()->dispatch(LFUN_MESSAGE, msg);
break;
}
- if (cur_layout != layout.second) {
- cur_layout = layout.second;
- lt->setLayout(bv, layout.second);
- bv->owner()->setLayout(cpar(bv)->getLayout());
+ if (cur_layout != layout) {
+ cur_layout = layout;
+ lt->setLayout(bv, layout);
+ bv->owner()->setLayout(cpar(bv)->layout());
updwhat = CURSOR_PAR;
updflag = true;
}
} else {
// reset the layout box
- bv->owner()->setLayout(cpar(bv)->getLayout());
+ bv->owner()->setLayout(cpar(bv)->layout());
}
break;
case LFUN_PARAGRAPH_SPACING:
int desc_on = 0; // description mode
LyXLayout const & style =
- textclasslist.Style(buf->params.textclass,
- p->layout);
+ textclasslist[buf->params.textclass][p->layout()];
// environment tag closing
for (; depth > p->params().depth(); --depth) {
int InsetText::beginningOfMainBody(Buffer const * buf, Paragraph * p) const
{
- if (textclasslist.Style(buf->params.textclass,
- p->getLayout()).labeltype != LABEL_MANUAL)
+ if (textclasslist[buf->params.textclass][p->layout()].labeltype != LABEL_MANUAL)
return 0;
else
return p->beginningOfMainBody();
bv->owner()->prohibitInput();
if (label.empty()) {
Paragraph * par = bv->getLyXText()->cursor.par();
- LyXLayout const * layout =
- &textclasslist.Style(bv->buffer()->params.textclass,
- par->getLayout());
+ LyXTextClass const & tclass =
+ textclasslist[bv->buffer()->params.textclass];
+ LyXLayout const * layout = &tclass[par->layout()];
if (layout->latextype == LATEX_PARAGRAPH && par->previous()) {
Paragraph * par2 = par->previous();
- LyXLayout const * layout2 =
- &textclasslist.Style(bv->buffer()->params.textclass,
- par2->getLayout());
+ LyXLayout const * layout2 = &tclass[par2->layout()];
if (layout2->latextype != LATEX_PARAGRAPH) {
par = par2;
layout = layout2;
case LT_COPYSTYLE: // initialize with a known style
if (lexrc.next()) {
- if (tclass.hasLayout(lexrc.getString())) {
- string const tmpname = name_;
- this->operator= (tclass.GetLayout(lexrc.getString()));
- name_ = tmpname;
+ string const style = lowercase(lexrc.getString());
+
+ if (tclass.hasLayout(style)) {
+ string const tmpname = lowercase(name_);
+ this->operator=(tclass[style]);
+ name_ = lowercase(tmpname);
} else {
- lexrc.printError("Cannot copy known "
- "style `$$Token'");
+ lyxerr << "Cannot copy unknown style `" << style << "'" << endl;
+ LyXTextClass::const_iterator it = tclass.begin();
+ LyXTextClass::const_iterator end = tclass.end();
+ lyxerr << "All layouts so far:" << endl;
+ for (; it != end; ++it) {
+ //lyxerr << it->name() << endl;
+ fprintf(stderr, "%s\n", it->name().c_str());
+ }
+
+ //lexrc.printError("Cannot copy known "
+ // "style `$$Token'");
}
}
break;
case LT_OBSOLETEDBY: // replace with a known style
if (lexrc.next()) {
- if (tclass.hasLayout(lexrc.getString())) {
+ string const style = lowercase(lexrc.getString());
+
+ if (tclass.hasLayout(style)) {
string const tmpname = name_;
- this->operator= (tclass.GetLayout(lexrc.getString()));
+ this->operator=(tclass[style]);
name_ = tmpname;
if (obsoleted_by().empty())
- obsoleted_by_ = lexrc.getString();
+ obsoleted_by_ = style;
} else {
- lexrc.printError("Cannot replace with"
- " unknown style "
- "`$$Token'");
+ lyxerr << "Cannot replace with unknown style `" << style << "'" << endl;
+
+ //lexrc.printError("Cannot replace with"
+ // " unknown style "
+ // "`$$Token'");
}
}
break;
break;
}
}
+
+
+string const & LyXLayout::name() const
+{
+ static string name_t;
+ name_t = lowercase(name_);
+ return name_t;
+}
+
+
+void LyXLayout::setName(string const & n)
+{
+ name_ = lowercase(n);
+}
+
+
+string const & LyXLayout::obsoleted_by() const
+{
+ static string obsoleted_by_t;
+ obsoleted_by_t = lowercase(obsoleted_by_);
+ return obsoleted_by_t;
+}
class LyXLayout {
public:
///
- LyXLayout ();
-
+ LyXLayout();
///
- bool Read (LyXLex &, LyXTextClass const &);
+ bool Read(LyXLex &, LyXTextClass const &);
///
void readAlign(LyXLex &);
///
///
void readSpacing(LyXLex &);
///
- string const & name() const { return name_; }
+ string const & name() const;
///
- void setName(string const & n) { name_ = n; }
+ void setName(string const & n);
///
- string const & obsoleted_by() const { return obsoleted_by_; }
+ string const & obsoleted_by() const;
///
string const & latexname() const { return latexname_; }
///
those paragraphs
*/
Paragraph * setLayout(BufferView *, LyXCursor & actual_cursor,
- LyXCursor & selection_start,
- LyXCursor & selection_end,
- lyx::layout_type layout);
+ LyXCursor & selection_start,
+ LyXCursor & selection_end,
+ string const & layout);
///
- void setLayout(BufferView *, lyx::layout_type layout);
+ void setLayout(BufferView *, string const & layout);
/// used in setlayout
void makeFontEntriesLayoutSpecific(Buffer const *, Paragraph * par);
Asger has learned that this should be a buffer-property instead
Lgb has learned that 'char' is a lousy type for non-characters
*/
- lyx::layout_type copylayouttype;
-
+ string copylayouttype;
/** inserts a new row behind the specified row, increments
the touched counters */
void insertRow(Row * row, Paragraph * par, lyx::pos_type pos) const;
TC_OUTPUTTYPE = 1,
TC_INPUT,
TC_STYLE,
+ TC_DEFAULTSTYLE,
TC_NOSTYLE,
TC_COLUMNS,
TC_SIDES,
{ "classoptions", TC_CLASSOPTIONS },
{ "columns", TC_COLUMNS },
{ "defaultfont", TC_DEFAULTFONT },
+ { "defaultstyle", TC_DEFAULTSTYLE },
{ "input", TC_INPUT },
{ "leftmargin", TC_LEFTMARGIN },
{ "maxcounter", TC_MAXCOUNTER },
}
break;
+ case TC_DEFAULTSTYLE:
+ if (lexrc.next()) {
+ string const name = subst(lowercase(lexrc.getString()), '_', ' ');
+ defaultlayout_ = name;
+ }
+ break;
+
case TC_STYLE:
if (lexrc.next()) {
- string name = subst(lexrc.getString(),
+ string const name = subst(lowercase(lexrc.getString()),
'_', ' ');
if (hasLayout(name)) {
- LyXLayout & lay = GetLayout(name);
+ LyXLayout & lay = operator[](name);
error = do_readStyle(lexrc, lay);
} else {
LyXLayout lay;
case TC_NOSTYLE:
if (lexrc.next()) {
- string const style = subst(lexrc.getString(),
+ string const style = subst(lowercase(lexrc.getString()),
'_', ' ');
if (!delete_layout(style))
- lexrc.printError("Cannot delete style"
- " `$$Token'");
+ lyxerr << "Cannot delete style `" << style << "'" << endl;
+// lexrc.printError("Cannot delete style"
+// " `$$Token'");
}
break;
lyxerr[Debug::TCLASS] << "Finished reading textclass "
<< MakeDisplayPath(filename)
<< endl;
+ if (defaultlayout_.empty()) {
+ lyxerr << "Error: Textclass '" << name_
+ << "' is missing a defaultstyle." << endl;
+ error = true;
+ }
} else
lyxerr[Debug::TCLASS] << "Finished reading input file "
<< MakeDisplayPath(filename)
}
-bool LyXTextClass::hasLayout(string const & name) const
+bool LyXTextClass::hasLayout(string const & n) const
{
+ string const name = (n.empty() ? defaultLayoutName() : lowercase(n));
+
return find_if(layoutlist.begin(), layoutlist.end(),
lyx::compare_memfun(&LyXLayout::name, name))
!= layoutlist.end();
}
-LyXLayout const & LyXTextClass::GetLayout (string const & name) const
+LyXLayout const & LyXTextClass::operator[](string const & n) const
{
+ if (n.empty())
+ lyxerr << "Operator[] called with empty n" << endl;
+
+ string const name = (n.empty() ? defaultLayoutName() : lowercase(n));
+
LayoutList::const_iterator cit =
find_if(layoutlist.begin(),
layoutlist.end(),
lyx::compare_memfun(&LyXLayout::name, name));
- lyx::Assert(cit != layoutlist.end()); // we require the name to exist
- return (*cit);
+
+ if (cit == layoutlist.end()) {
+ lyxerr << "We failed to find the layout '" << name
+ << "' in the layout list. You MUST investigate!"
+ << endl;
+
+ // we require the name to exist
+ lyx::Assert(false);
+ }
+
+ return *cit;
}
-LyXLayout & LyXTextClass::GetLayout(string const & name)
+LyXLayout & LyXTextClass::operator[](string const & n)
{
+ if (n.empty())
+ lyxerr << "Operator[] called with empty n" << endl;
+
+ string const name = (n.empty() ? defaultLayoutName() : lowercase(n));
+
LayoutList::iterator it =
find_if(layoutlist.begin(),
layoutlist.end(),
lyx::compare_memfun(&LyXLayout::name, name));
- lyx::Assert(it != layoutlist.end()); // we require the name to exist
- return (*it);
+
+ if (it == layoutlist.end()) {
+ lyxerr << "We failed to find the layout '" << name
+ << "' in the layout list. You MUST investigate!"
+ << endl;
+
+ // we require the name to exist
+ lyx::Assert(false);
+ }
+
+ return *it;
}
-bool LyXTextClass::delete_layout(string const & name)
+bool LyXTextClass::delete_layout(string const & n)
{
+ string const name = lowercase(n);
+
+ if (name == defaultLayoutName())
+ return false;
+
LayoutList::iterator it =
remove_if(layoutlist.begin(), layoutlist.end(),
lyx::compare_memfun(&LyXLayout::name, name));
// Load textclass info if not loaded yet
-void LyXTextClass::load()
+bool LyXTextClass::load() const
{
- if (loaded) return;
+ if (loaded)
+ return true;
// Read style-file
string const real_file = LibFileSearch("layouts", name_, "layout");
- if (Read(real_file)) {
+ if (const_cast<LyXTextClass*>(this)->Read(real_file)) {
lyxerr << "Error reading `"
<< MakeDisplayPath(real_file)
<< "'\n(Check `" << name_
<< "')\nCheck your installation and "
"try Options/Reconfigure..." << endl;
+ loaded = false;
}
loaded = true;
+ return loaded;
+
+}
+
+
+string const LyXTextClass::defaultLayoutName() const
+{
+ // This really should come from the actual layout... (Lgb)
+ return defaultlayout_;
+}
+
+
+LyXLayout const & LyXTextClass::defaultLayout() const
+{
+ return operator[](defaultLayoutName());
+}
+
+
+LyXLayout & LyXTextClass::defaultLayout()
+{
+ return operator[](defaultLayoutName());
+}
+
+
+string const & LyXTextClass::name() const
+{
+ return name_;
+}
+
+
+string const & LyXTextClass::latexname() const
+{
+ const_cast<LyXTextClass*>(this)->load();
+ return latexname_;
+}
+
+
+string const & LyXTextClass::description() const
+{
+ return description_;
+}
+
+
+string const & LyXTextClass::opt_fontsize() const
+{
+ return opt_fontsize_;
+}
+
+
+string const & LyXTextClass::opt_pagestyle() const
+{
+ return opt_pagestyle_;
+}
+
+
+string const & LyXTextClass::options() const
+{
+ return options_;
+}
+
+
+string const & LyXTextClass::pagestyle() const
+{
+ return pagestyle_;
+}
+
+
+string const & LyXTextClass::preamble() const
+{
+ return preamble_;
+}
+
+
+LyXTextClass::PageSides LyXTextClass::sides() const
+{
+ return sides_;
+}
+
+
+int LyXTextClass::secnumdepth() const
+{
+ return secnumdepth_;
+}
+
+
+int LyXTextClass::tocdepth() const
+{
+ return tocdepth_;
+}
+
+
+OutputType LyXTextClass::outputType() const
+{
+ return outputType_;
+}
+
+
+bool LyXTextClass::provides(LyXTextClass::Provides p) const
+{
+ return provides_ & p;
+}
+
+
+unsigned int LyXTextClass::columns() const
+{
+ return columns_;
+}
+
+
+int LyXTextClass::maxcounter() const
+{
+ return maxcounter_;
+}
+
+
+int LyXTextClass::size() const
+{
+ return layoutlist.size();
}
bool hasLayout(string const & name) const;
///
- LyXLayout const & GetLayout(string const & vname) const;
+ LyXLayout const & operator[](string const & vname) const;
///
- LyXLayout & GetLayout(string const & vname);
+ LyXLayout & operator[](string const & vname);
/// Sees to that the textclass structure has been loaded
- void load();
+ bool load() const;
///
- string const & name() const { return name_; }
+ string const defaultLayoutName() const;
///
- string const & latexname() const { return latexname_; }
+ LyXLayout const & defaultLayout() const;
///
- string const & description() const { return description_; }
+ LyXLayout & defaultLayout();
///
- string const & opt_fontsize() const { return opt_fontsize_; }
+ string const & name() const;
///
- string const & opt_pagestyle() const { return opt_pagestyle_; }
+ string const & latexname() const;
///
- string const & options() const { return options_; }
+ string const & description() const;
///
- string const & pagestyle() const { return pagestyle_; }
+ string const & opt_fontsize() const;
///
- string const & preamble() const { return preamble_; }
+ string const & opt_pagestyle() const;
+ ///
+ string const & options() const;
+ ///
+ string const & pagestyle() const;
+ ///
+ string const & preamble() const;
/// Packages that are already loaded by the class
enum Provides {
url = 4
};
///
- bool provides(Provides p) const { return provides_ & p; }
+ bool provides(Provides p) const;
///
- unsigned int columns() const { return columns_; }
+ unsigned int columns() const;
///
enum PageSides {
///
TwoSides
};
///
- PageSides sides() const { return sides_; }
+ PageSides sides() const;
///
- int secnumdepth() const { return secnumdepth_; }
+ int secnumdepth() const;
///
- int tocdepth() const { return tocdepth_; }
+ int tocdepth() const;
///
- OutputType outputType() const { return outputType_; }
+ OutputType outputType() const;
///
LyXFont const & defaultfont() const;
/// Text that dictates how wide the right margin is on the screen
string const & rightmargin() const;
///
- int maxcounter() const { return maxcounter_; }
+ int maxcounter() const;
///
- lyx::layout_type numLayouts() const { return layoutlist.size(); }
- ///
- LyXLayout const & operator[](lyx::layout_type i) const {
- return layoutlist[i];
- }
+ int size() const;
private:
///
bool delete_layout(string const &);
///
string pagestyle_;
///
+ string defaultlayout_;
+ ///
string preamble_;
///
Provides provides_;
LayoutList layoutlist;
/// Has this layout file been loaded yet?
- bool loaded;
+ mutable bool loaded;
};
+
///
inline
void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
#include <utility>
-using lyx::layout_type;
using lyx::textclass_type;
using std::pair;
using std::make_pair;
}
-// Gets layout structure from style number and textclass number
-LyXLayout const &
-LyXTextClassList::Style(textclass_type textclass,
- layout_type layout) const
-{
- classlist[textclass].load();
- if (layout < classlist[textclass].numLayouts())
- return classlist[textclass][layout];
- return classlist[textclass][0];
-}
-
-
-// Gets layout number from name and textclass number
-pair<bool, layout_type> const
-LyXTextClassList::NumberOfLayout(textclass_type textclass,
- string const & name) const
-{
- classlist[textclass].load();
- for (unsigned int i = 0; i < classlist[textclass].numLayouts(); ++i) {
- if (classlist[textclass][i].name() == name)
- return make_pair(true, i);
- }
- return make_pair(false, layout_type(0)); // not found
-}
-
-
-// Gets a layout (style) name from layout number and textclass number
-string const &
-LyXTextClassList::NameOfLayout(textclass_type textclass,
- layout_type layout) const
-{
- static string const dummy("dummy");
- classlist[textclass].load();
- if (layout < classlist[textclass].numLayouts())
- return classlist[textclass][layout].name();
- return dummy;
-}
-
-
-// Gets a textclass name from number
-string const &
-LyXTextClassList::NameOfClass(textclass_type number) const
-{
- static string const dummy("dummy");
- if (classlist.empty()) {
- return dummy;
- }
- lyx::Assert(number < classlist.size());
- return classlist[number].name();
-}
-
-
-// Gets a textclass latexname from number
-string const &
-LyXTextClassList::LatexnameOfClass(textclass_type number) const
-{
- static string const dummy("dummy");
- classlist[number].load();
- if (classlist.empty()) {
- return dummy;
- }
- lyx::Assert(number < classlist.size());
- return classlist[number].latexname();
-}
-
-
-// Gets a textclass description from number
-string const &
-LyXTextClassList::DescOfClass(textclass_type number) const
-{
- static string const dummy("dummy");
- if (classlist.empty()) {
- return dummy;
- }
- lyx::Assert(number < classlist.size());
- return classlist[number].description();
-}
-
-
// Gets a textclass structure from number
LyXTextClass const &
-LyXTextClassList::TextClass(textclass_type textclass) const
+LyXTextClassList::operator[](textclass_type textclass) const
{
classlist[textclass].load();
if (textclass < classlist.size())
return true;
}
-
-/* Load textclass
- Returns false if this fails
-*/
-bool LyXTextClassList::Load(textclass_type number) const
-{
- bool result = true;
- if (number < classlist.size()) {
- classlist[number].load();
- if (classlist[number].numLayouts() == 0) {
- result = false;
- }
- } else {
- result = false;
- }
- return result;
-}
-
// Global variable: textclass table.
LyXTextClassList textclasslist;
const_iterator begin() const { return classlist.begin(); }
///
const_iterator end() const { return classlist.end(); }
-
- /// Gets layout structure from layout number and textclass number
- LyXLayout const & Style(lyx::textclass_type textclass,
- lyx::layout_type layout) const;
-
- /// Gets layout number from textclass number and layout name
- std::pair<bool, lyx::layout_type> const
- NumberOfLayout(lyx::textclass_type textclass, string const & name) const;
-
- /// Gets a layout name from layout number and textclass number
- string const &
- NameOfLayout(lyx::textclass_type textclass, lyx::layout_type layout) const;
/** Gets textclass number from name.
Returns -1 if textclass name does not exist
NumberOfClass(string const & textclass) const;
///
- string const & NameOfClass(lyx::textclass_type number) const;
-
- ///
- string const & LatexnameOfClass(lyx::textclass_type number) const;
-
- ///
- string const & DescOfClass(lyx::textclass_type number) const;
-
- ///
- LyXTextClass const & TextClass(lyx::textclass_type textclass) const;
+ LyXTextClass const & operator[](lyx::textclass_type textclass) const;
/** Read textclass list.
Returns false if this fails
*/
bool Read();
-
- /** Load textclass.
- Returns false if this fails
- */
- bool Load(lyx::textclass_type number) const;
private:
///
mutable ClassList classlist;
///
- void Add (LyXTextClass const &);
+ void Add(LyXTextClass const &);
};
///
using std::reverse;
using lyx::pos_type;
-using lyx::layout_type;
int tex_code_break_column = 72; // needs non-zero initialization. set later.
// this is a bad idea, but how can Paragraph find its buffer to get
Paragraph::Paragraph()
- : layout(0), pimpl_(new Paragraph::Pimpl(this))
+ : pimpl_(new Paragraph::Pimpl(this))
{
for (int i = 0; i < 10; ++i)
setCounter(i, 0);
// This constructor inserts the new paragraph in a list.
Paragraph::Paragraph(Paragraph * par)
- : layout(0), pimpl_(new Paragraph::Pimpl(this))
+ : pimpl_(new Paragraph::Pimpl(this))
{
for (int i = 0; i < 10; ++i)
setCounter(i, 0);
Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
- : layout(0), pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
+ : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
{
for (int i = 0; i < 10; ++i)
setCounter(i, 0);
// this is because of the dummy layout of the paragraphs that
// follow footnotes
- layout = lp.layout;
+ layout_ = lp.layout();
// ale970302
if (lp.bibkey) {
}
// First write the layout
- os << "\n\\layout "
- << textclasslist.NameOfLayout(bparams.textclass, layout)
- << "\n";
+ os << "\n\\layout " << layout() << "\n";
// Maybe some vertical spaces.
if (params().spaceTop().kind() != VSpace::NONE)
features.require("setspace");
// then the layouts
- features.useLayout(getLayout());
+ features.useLayout(layout());
// then the fonts
Language const * doc_language = bparams.language;
}
// then the insets
- LyXLayout const & layout =
- textclasslist.Style(bparams.textclass, getLayout());
+ LyXLayout const & lout = textclasslist[bparams.textclass][layout()];
for (InsetList::const_iterator cit = insetlist.begin();
cit != insetlist.end(); ++cit) {
if (cit->inset) {
cit->inset->validate(features);
- if (layout.needprotect &&
+ if (lout.needprotect &&
cit->inset->lyxCode() == Inset::FOOT_CODE)
features.require("NeedLyXFootnoteCode");
}
void Paragraph::clear()
{
params().clear();
-
- layout = 0;
+
+ layout_.erase();
+
bibkey = 0;
}
{
lyx::Assert(pos >= 0);
- LyXLayout const & layout =
- textclasslist.Style(bparams.textclass,
- getLayout());
+ LyXLayout const & lout =
+ textclasslist[bparams.textclass][layout()];
pos_type main_body = 0;
- if (layout.labeltype == LABEL_MANUAL)
+ if (lout.labeltype == LABEL_MANUAL)
main_body = beginningOfMainBody();
LyXFont layoutfont;
if (pos < main_body)
- layoutfont = layout.labelfont;
+ layoutfont = lout.labelfont;
else
- layoutfont = layout.font;
+ layoutfont = lout.font;
LyXFont tmpfont = getFontSettings(bparams, pos);
#ifndef INHERIT_LANGUAGE
LyXFont const Paragraph::getLabelFont(BufferParams const & bparams) const
{
- LyXLayout const & layout =
- textclasslist.Style(bparams.textclass, getLayout());
+ LyXLayout const & lout =
+ textclasslist[bparams.textclass][layout()];
- LyXFont tmpfont = layout.labelfont;
+ LyXFont tmpfont = lout.labelfont;
tmpfont.setLanguage(getParLanguage(bparams));
return pimpl_->realizeFont(tmpfont, bparams);
LyXFont const Paragraph::getLayoutFont(BufferParams const & bparams) const
{
- LyXLayout const & layout =
- textclasslist.Style(bparams.textclass,
- getLayout());
+ LyXLayout const & lout =
+ textclasslist[bparams.textclass][layout()];
- LyXFont tmpfont = layout.font;
+ LyXFont tmpfont = lout.font;
tmpfont.setLanguage(getParLanguage(bparams));
return pimpl_->realizeFont(tmpfont, bparams);
// layout stays the same with latex-environments
if (flag) {
- tmp->setOnlyLayout(layout);
+ tmp->layout(layout());
tmp->setLabelWidthString(params().labelWidthString());
}
if (size() > pos || !size() || flag == 2) {
- tmp->setOnlyLayout(layout);
+ tmp->layout(layout());
tmp->params().align(params().align());
tmp->setLabelWidthString(params().labelWidthString());
clear();
// layout stays the same with latex-environments
if (flag) {
- setOnlyLayout(tmp->layout);
+ layout(tmp->layout());
setLabelWidthString(tmp->params().labelWidthString());
params().depth(tmp->params().depth());
}
void Paragraph::makeSameLayout(Paragraph const * par)
{
- layout = par->layout;
+ layout(par->layout());
// move to pimpl?
params() = par->params();
}
int Paragraph::stripLeadingSpaces(lyx::textclass_type tclass)
{
- if (textclasslist.Style(tclass, getLayout()).free_spacing ||
- isFreeSpacing())
- {
+ if (textclasslist[tclass][layout()].free_spacing ||
+ isFreeSpacing()) {
return 0;
}
bool Paragraph::hasSameLayout(Paragraph const * par) const
{
return
- par->layout == layout &&
+ par->layout() == layout() &&
params().sameLayout(par->params());
}
Paragraph const * par = this;
depth_type par_depth = getDepth();
while (par) {
- layout_type layout = par->getLayout();
+ string const & layout = par->layout();
int const endlabeltype =
- textclasslist.Style(bparams.textclass,
- layout).endlabeltype;
+ textclasslist[bparams.textclass][layout].endlabeltype;
if (endlabeltype != END_LABEL_NO_LABEL) {
if (!next_)
return endlabeltype;
depth_type const next_depth = next_->getDepth();
if (par_depth > next_depth ||
(par_depth == next_depth
- && layout != next_->getLayout()))
+ && layout != next_->layout()))
return endlabeltype;
break;
}
Paragraph::depth_type Paragraph::getMaxDepthAfter(Buffer const * buffer) const
{
- const bool isenv = textclasslist.Style(buffer->params.textclass,
- getLayout()).isEnvironment();
+ bool const isenv = textclasslist[buffer->params.textclass][layout()].isEnvironment();
if (isenv)
return params().depth() + 1;
}
-void Paragraph::setOnlyLayout(layout_type new_layout)
-{
- layout = new_layout;
-}
-
-
-void Paragraph::setLayout(layout_type new_layout)
+void Paragraph::applyLayout(string const & new_layout)
{
- layout = new_layout;
+ layout(new_layout);
params().labelWidthString(string());
params().align(LYX_ALIGN_LAYOUT);
params().spaceTop(VSpace(VSpace::NONE));
// any special options in the paragraph and also we don't allow
// any environment other then "Standard" to be valid!
if ((in == 0) || !in->forceDefaultParagraphs(in)) {
- style = textclasslist.Style(bparams.textclass, layout);
+ style = textclasslist[bparams.textclass][layout()];
if (params().startOfAppendix()) {
os << "\\appendix\n";
texrow.newline();
}
} else {
- style = textclasslist.Style(bparams.textclass, 0);
+ style = textclasslist[bparams.textclass].defaultLayout();
}
Language const * language = getParLanguage(bparams);
if (language->babel() != previous_language->babel()
// check if we already put language command in TeXEnvironment()
&& !(style.isEnvironment()
- && (!previous() || previous()->layout != layout ||
+ && (!previous() || previous()->layout() != layout() ||
previous()->params().depth() != params().depth())))
{
if (!lyxrc.language_command_end.empty() &&
// if its the last paragraph of the current environment
// skip it otherwise fall through
if (next_
- && (next_->layout != layout
+ && (next_->layout() != layout()
|| next_->params().depth() != params().depth()))
break;
// fall through possible
(inInset() && inInset()->forceDefaultParagraphs(inInset()));
if (asdefault) {
- style = textclasslist.Style(bparams.textclass, 0);
+ style = textclasslist[bparams.textclass].defaultLayout();
} else {
- style = textclasslist.Style(bparams.textclass, layout);
+ style = textclasslist[bparams.textclass][layout()];
}
LyXFont basefont;
lyxerr[Debug::LATEX] << "TeXEnvironment... " << this << endl;
LyXLayout const & style =
- textclasslist.Style(bparams.textclass,
- layout);
+ textclasslist[bparams.textclass][layout()];
Language const * language = getParLanguage(bparams);
Language const * doc_language = bparams.language;
par = par->TeXOnePar(buf, bparams, os, texrow, false);
if (par && par->params().depth() > params().depth()) {
- if (textclasslist.Style(bparams.textclass,
- par->layout).isParagraph()
+ if (textclasslist[bparams.textclass][par->layout()].isParagraph()
// Thinko!
// How to handle this? (Lgb)
//&& !suffixIs(os, "\n\n")
par = par->pimpl_->TeXDeeper(buf, bparams, os, texrow);
}
} while (par
- && par->layout == layout
+ && par->layout() == layout()
&& par->params().depth() == params().depth());
if (style.isEnvironment()) {
}
-layout_type Paragraph::getLayout() const
+string const & Paragraph::layout() const
+{
+ return layout_;
+}
+
+
+void Paragraph::layout(string const & new_layout)
{
- return layout;
+ layout_ = new_layout;
}
{
Paragraph const * dhook = depthHook(getDepth());
return (dhook == this
- || dhook->getLayout() != getLayout()
+ || dhook->layout() != layout()
|| dhook->getDepth() != getDepth());
}
void clearContents();
///
- lyx::layout_type layout;
-
+ string const & layout() const;
+ ///
+ void layout(string const & new_layout);
+
///
void setCounter(int i, int v);
///
///
void setLabelWidthString(string const & s);
///
- lyx::layout_type getLayout() const;
- ///
char getAlign() const;
/// The nesting depth of a paragraph
depth_type getDepth() const;
/// The maximal possible depth of a paragraph after this one
depth_type getMaxDepthAfter(Buffer const *) const;
///
- void setLayout(lyx::layout_type new_layout);
- ///
- void setOnlyLayout(lyx::layout_type new_layout);
+ void applyLayout(string const & new_layout);
///
int getFirstCounter(int i) const;
///
ParagraphParameters & params();
ParagraphParameters const & params() const;
private:
-
+ ///
+ string layout_;
///
struct InsetTable {
///
Paragraph * par = owner_;
while (par && par->params().depth() == owner_->params().depth()) {
- if (textclasslist.Style(bparams.textclass,
- par->layout).isEnvironment()) {
+ if (textclasslist[bparams.textclass][par->layout()].isEnvironment()) {
par = par->TeXEnvironment(buf, bparams,
os, texrow);
} else {
// check for environment font information
char par_depth = owner_->getDepth();
Paragraph const * par = owner_;
+ LyXTextClass const & tclass = textclasslist[bparams.textclass];
+
while (par && par->getDepth() && !tmpfont.resolved()) {
par = par->outerHook();
if (par) {
- tmpfont.realize(textclasslist.
- Style(bparams.textclass,
- par->getLayout()).font
+ tmpfont.realize(tclass[par->layout()].font
#ifdef INHERIT_LANGUAGE
, bparams.language
#endif
}
}
- tmpfont.realize(textclasslist.TextClass(bparams.textclass)
- .defaultfont()
+ tmpfont.realize(tclass.defaultfont()
#ifdef INHERIT_LANGUAGE
, bparams.language
#endif
+2002-03-02 Lars Gullik Bjønnes <larsbj@birdstep.com>
+
+ * types.h: remove layout_type
+
2002-03-01 Angus Leeming <a.leeming@ic.ac.uk>
* filetools.C (getExtFromContents): cleanup.
/// a type for sizes
typedef std::vector<char>::size_type size_type;
- /// a type used for numbering layouts within a text class
- // used to be LyXTextClass::size_type
- typedef std::vector<char>::size_type layout_type;
-
/// a type used for numbering text classes
// used to be LyXTextClassList::size_type
typedef std::vector<char>::size_type textclass_type;
private:
base_type data_;
};
-
-
- struct layout_type {
- ///
- typedef std::vector<char>::size_type base_type;
- ///
- layout_type(base_type t) { data_ = t; }
- ///
- operator base_type() const { return data_; }
- ///
- void operator++() { ++data_; }
- ///
- private:
- base_type data_;
- };
-
struct textclass_type {
///
}
LyXLayout const & layout =
- textclasslist.Style(bview->buffer()->params.textclass,
- par->getLayout());
+ textclasslist[bview->buffer()->params.textclass][par->layout()];
if (layout.margintype != MARGIN_RIGHT_ADDRESS_BOX) {
// Optimization here: in most cases, the real row is
int LyXText::leftMargin(BufferView * bview, Row const * row) const
{
LyXTextClass const & tclass =
- textclasslist.TextClass(bview->buffer()->params.textclass);
- LyXLayout const & layout = tclass[row->par()->getLayout()];
+ textclasslist[bview->buffer()->params.textclass];
+ LyXLayout const & layout = tclass[row->par()->layout()];
string parindent = layout.parindent;
// I have had this idea very late, so it seems to be a
// later added hack and this is true
if (!row->par()->getDepth()) {
- if (!row->par()->getLayout()) {
+ if (row->par()->layout() == tclass.defaultLayoutName()) {
// find the previous same level paragraph
if (row->par()->previous()) {
Paragraph * newpar = row->par()
->depthHook(row->par()->getDepth());
if (newpar &&
- tclass[newpar->getLayout()].nextnoindent)
+ tclass[newpar->layout()].nextnoindent)
parindent.erase();
}
}
// make a corresponding row. Needed to call LeftMargin()
- // check wether it is a sufficent paragraph
- if (newpar && tclass[newpar->getLayout()].isEnvironment())
- {
+ // check wether it is a sufficent paragraph
+ if (newpar && tclass[newpar->layout()].isEnvironment()) {
Row dummyrow;
dummyrow.par(newpar);
dummyrow.pos(newpar->size());
// LeftMargin() is always called
row->par()->params().depth(0);
}
-
- if (newpar && !row->par()->getLayout()) {
+
+ if (newpar && row->par()->layout() == tclass.defaultLayoutName()) {
if (newpar->params().noindent())
parindent.erase();
else
- parindent = tclass[newpar->getLayout()].parindent;
+ parindent = tclass[newpar->layout()].parindent;
}
-
}
LyXFont const labelfont = getLabelFont(bview->buffer(), row->par());
&& !row->par()->params().noindent()
// in tabulars paragraphs are never indented!
&& (!row->par()->inInset() || row->par()->inInset()->owner()->lyxCode() != Inset::TABULAR_CODE)
- && (row->par()->layout ||
+ && (row->par()->layout() != tclass.defaultLayoutName() ||
bview->buffer()->params.paragraph_separation ==
- BufferParams::PARSEP_INDENT))
+ BufferParams::PARSEP_INDENT)) {
x += lyxfont::signedWidth(parindent,
tclass.defaultfont());
- else if (layout.labeltype == LABEL_BIBLIO) {
+ } else if (layout.labeltype == LABEL_BIBLIO) {
// ale970405 Right width for bibitems
x += bibitemMaxWidth(bview, tclass.defaultfont());
}
}
+
return x;
}
int LyXText::rightMargin(Buffer const * buf, Row const * row) const
{
- LyXTextClass const & tclass =
- textclasslist.TextClass(buf->params.textclass);
- LyXLayout const & layout = tclass[row->par()->getLayout()];
-
+ LyXTextClass const & tclass = textclasslist[buf->params.textclass];
+ LyXLayout const & layout = tclass[row->par()->layout()];
+
int x = LYX_PAPER_MARGIN
+ lyxfont::signedWidth(tclass.rightmargin(),
tclass.defaultfont());
// make a corresponding row. Needed to call LeftMargin()
// check wether it is a sufficent paragraph
- if (newpar
- && tclass[newpar->getLayout()].isEnvironment()) {
+ if (newpar && tclass[newpar->layout()].isEnvironment()) {
Row dummyrow;
dummyrow.par(newpar);
dummyrow.pos(0);
int LyXText::labelEnd(BufferView * bview, Row const * row) const
{
- if (textclasslist.Style(bview->buffer()->params.textclass,
- row->par()->getLayout()).margintype
+ if (textclasslist[bview->buffer()->params.textclass][row->par()->layout()].margintype
== MARGIN_MANUAL) {
Row tmprow;
tmprow = *row;
pos_type const main_body =
beginningOfMainBody(bview->buffer(), par);
LyXLayout const & layout =
- textclasslist.Style(bview->buffer()->params.textclass,
- par->getLayout());
+ textclasslist[bview->buffer()->params.textclass][par->layout()];
pos_type i = pos;
if (layout.margintype == MARGIN_RIGHT_ADDRESS_BOX) {
pos_type const last = rowLastPrintable(row);
// special handling of the right address boxes
- if (textclasslist.Style(bview->buffer()->params.textclass,
- row->par()->getLayout()).margintype
+ if (textclasslist[bview->buffer()->params.textclass][row->par()->layout()].margintype
== MARGIN_RIGHT_ADDRESS_BOX)
{
int const tmpfill = row->fill();
} else
w = leftMargin(bview, row);
- LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass,
- row->par()->getLayout());
+ LyXLayout const & layout = textclasslist[bview->buffer()->params.textclass][row->par()->layout()];
pos_type const main_body =
beginningOfMainBody(bview->buffer(), row->par());
pos_type i = row->pos();
return true;
// in some labels it does not count
- if (textclasslist.Style(buf->params.textclass,
- row_ptr->par()->getLayout()).margintype
+ if (textclasslist[buf->params.textclass][row_ptr->par()->layout()].margintype
!= MARGIN_MANUAL
&& pos < beginningOfMainBody(buf, row_ptr->par()))
return false;
Paragraph * par = row_ptr->par();
Paragraph * firstpar = row_ptr->par();
- LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass,
- firstpar->getLayout());
+ LyXLayout const & layout = textclasslist[bview->buffer()->params.textclass][firstpar->layout()];
// as max get the first character of this row then it can increes but not
// decrees the height. Just some point to start with so we don't have to
{
maxasc += bview->buffer()->params.getDefSkip().inPixels(bview);
} else if (firstpar->previous() &&
- textclasslist.Style(bview->buffer()->params.textclass,
- firstpar->previous()->
- getLayout()).isParagraph() &&
+ textclasslist[bview->buffer()->params.textclass][firstpar->previous()->layout()].isParagraph() &&
firstpar->previous()->getDepth() == 0)
{
// is it right to use defskip here too? (AS)
Paragraph * prev = row_ptr->par()->previous();
if (prev)
prev = row_ptr->par()->depthHook(row_ptr->par()->getDepth());
- if (prev && prev->getLayout() == firstpar->getLayout() &&
+ if (prev && prev->layout() == firstpar->layout() &&
prev->getDepth() == firstpar->getDepth() &&
prev->getLabelWidthString() == firstpar->getLabelWidthString())
{
tmptop = layout.topsep;
if (row_ptr->previous()->par()->getDepth() >= row_ptr->par()->getDepth())
- tmptop -= textclasslist.Style(bview->buffer()->params.textclass,
- row_ptr->previous()->par()->
- getLayout()).bottomsep;
+ tmptop -= textclasslist[bview->buffer()->params.textclass][row_ptr->previous()->par()->layout()].bottomsep;
if (tmptop > 0)
layoutasc = (tmptop * defaultHeight());
prev = row_ptr->par()->outerHook();
if (prev) {
- maxasc += int(textclasslist.Style(bview->buffer()->params.textclass,
- prev->getLayout()).parsep * defaultHeight());
+ maxasc += int(textclasslist[bview->buffer()->params.textclass][prev->layout()].parsep * defaultHeight());
} else {
if (firstpar->previous() &&
firstpar->previous()->getDepth() == 0 &&
- firstpar->previous()->getLayout() !=
- firstpar->getLayout())
+ firstpar->previous()->layout() !=
+ firstpar->layout())
{
// avoid parsep
} else if (firstpar->previous()) {
float unusual = 0;
if (comparepar->getDepth() > nextpar->getDepth()) {
- usual = (textclasslist.Style(bview->buffer()->params.textclass,
- comparepar->getLayout()).bottomsep * defaultHeight());
+ usual = (textclasslist[bview->buffer()->params.textclass][comparepar->layout()].bottomsep * defaultHeight());
comparepar = comparepar->depthHook(nextpar->getDepth());
- if (comparepar->getLayout()!= nextpar->getLayout()
+ if (comparepar->layout()!= nextpar->layout()
|| nextpar->getLabelWidthString() !=
comparepar->getLabelWidthString())
{
- unusual = (textclasslist.Style(bview->buffer()->params.textclass,
- comparepar->getLayout()).bottomsep * defaultHeight());
+ unusual = (textclasslist[bview->buffer()->params.textclass][comparepar->layout()].bottomsep * defaultHeight());
}
if (unusual > usual)
layoutdesc = unusual;
layoutdesc = usual;
} else if (comparepar->getDepth() == nextpar->getDepth()) {
- if (comparepar->getLayout()!= nextpar->getLayout()
+ if (comparepar->layout() != nextpar->layout()
|| nextpar->getLabelWidthString() !=
comparepar->getLabelWidthString())
- layoutdesc = int(textclasslist.Style(bview->buffer()->params.textclass,
- comparepar->getLayout()).bottomsep * defaultHeight());
+ layoutdesc = int(textclasslist[bview->buffer()->params.textclass][comparepar->layout()].bottomsep * defaultHeight());
}
}
}
void LyXText::breakParagraph(BufferView * bview, char keep_layout)
{
LyXLayout const & layout =
- textclasslist.Style(bview->buffer()->params.textclass,
- cursor.par()->getLayout());
+ textclasslist[bview->buffer()->params.textclass][cursor.par()->layout()];
// this is only allowed, if the current paragraph is not empty or caption
if ((cursor.par()->size() <= 0)
if (layout.labeltype == LABEL_SENSITIVE) {
if (!cursor.pos())
// set to standard-layout
- cursor.par()->setLayout(0);
+ cursor.par()->applyLayout(0);
else
// set to standard-layout
- cursor.par()->next()->setLayout(0);
+ cursor.par()->next()->applyLayout(0);
}
/* if the cursor is at the beginning of a row without prior newline,
// disable the double-space checking
bool const freeSpacing =
- textclasslist.Style(bview->buffer()->params.textclass,
- cursor.row()->par()->getLayout()).free_spacing ||
+ textclasslist[bview->buffer()->params.textclass][cursor.row()->par()->layout()].free_spacing ||
cursor.row()->par()->isFreeSpacing();
redoHeightOfParagraph(bview, cursor);
} else {
// now the special right address boxes
- if (textclasslist.Style(bview->buffer()->params.textclass,
- cursor.par()->getLayout()).margintype
+ if (textclasslist[bview->buffer()->params.textclass][cursor.par()->layout()].margintype
== MARGIN_RIGHT_ADDRESS_BOX) {
redoDrawingOfParagraph(bview, cursor);
}
x = (workWidth(bview) > 0) ? leftMargin(bview, row) : 0;
// is there a manual margin with a manual label
- if (textclasslist.Style(bview->buffer()->params.textclass,
- row->par()->getLayout()).margintype == MARGIN_MANUAL
- && textclasslist.Style(bview->buffer()->params.textclass,
- row->par()->getLayout()).labeltype == LABEL_MANUAL) {
-
- /* one more since labels are left aligned */
+ LyXTextClass const & tclass = textclasslist[bview->buffer()->params.textclass];
+ LyXLayout const & layout = tclass[row->par()->layout()];
+
+ if (layout.margintype == MARGIN_MANUAL
+ && layout.labeltype == LABEL_MANUAL) {
+ // one more since labels are left aligned
nlh = numberOfLabelHfills(bview->buffer(), row) + 1;
if (nlh && !row->par()->getLabelWidthString().empty()) {
fill_label_hfill = labelFill(bview, row) / nlh;
// set x how you need it
int align;
if (row->par()->params().align() == LYX_ALIGN_LAYOUT) {
- align = textclasslist.Style(bview->buffer()->params.textclass, row->par()->getLayout()).align;
+ align = layout.align;
} else {
align = row->par()->params().align();
}
pos_type last = rowLast(row);
if (main_body > 0 &&
- (main_body-1 > last ||
- !row->par()->isLineSeparator(main_body-1))) {
- LyXLayout const & layout =
- textclasslist.Style(bview->buffer()->params.textclass,
- row->par()->getLayout());
+ (main_body - 1 > last ||
+ !row->par()->isLineSeparator(main_body - 1))) {
x += lyxfont::width(layout.labelsep,
getLabelFont(bview->buffer(), row->par()));
- if (main_body-1 <= last)
+ if (main_body - 1 <= last)
x += fill_label_hfill;
}
}
if (cursor.par()->previous()) {
Paragraph * tmppar = cursor.par()->previous();
- if (cursor.par()->getLayout() == tmppar->getLayout()
+ if (cursor.par()->layout() == tmppar->layout()
&& cursor.par()->getAlign() == tmppar->getAlign()) {
// Inherit bottom DTD from the paragraph below.
// (the one we are deleting)
Correction: Pasting is always allowed with standard-layout
*/
+ LyXTextClass const & tclass = textclasslist[bview->buffer()->params.textclass];
+
if (cursor.par() != tmppar
- && (cursor.par()->getLayout() == tmppar->getLayout()
- || tmppar->getLayout() == 0 /*standard*/)
- && cursor.par()->getAlign() == tmppar->getAlign())
- {
+ && (cursor.par()->layout() == tmppar->layout()
+ || tmppar->layout() == tclass.defaultLayoutName())
+ && cursor.par()->getAlign() == tmppar->getAlign()) {
removeParagraph(tmprow);
removeRow(tmprow);
cursor.par()->pasteParagraph(bview->buffer()->params);
redoHeightOfParagraph(bview, cursor);
} else {
// now the special right address boxes
- if (textclasslist.Style(bview->buffer()->params.textclass,
- cursor.par()->getLayout()).margintype == MARGIN_RIGHT_ADDRESS_BOX) {
+ if (textclasslist
+ [bview->buffer()->params.textclass]
+ [cursor.par()->layout()].margintype == MARGIN_RIGHT_ADDRESS_BOX) {
redoDrawingOfParagraph(bview, cursor);
}
}
pos_type pos = vis2log(vpos);
float const old_tmpx = tmpx;
if (main_body > 0 && pos == main_body - 1) {
- LyXLayout const & layout = textclasslist.Style(buffer->params.textclass,
- par->getLayout());
+ LyXLayout const & layout =
+ textclasslist
+ [buffer->params.textclass]
+ [par->layout()];
LyXFont const lfont = getLabelFont(buffer, par);
parparams.spaceTop(), p.yo + y_top);
Buffer const * buffer = p.bv->buffer();
-
- LyXLayout const & layout =
- textclasslist.Style(buffer->params.textclass, par->getLayout());
+
+ LyXTextClass const & tclass = textclasslist[buffer->params.textclass];
+ LyXLayout const & layout = tclass[par->layout()];
// think about the parskip
// some parskips VERY EASY IMPLEMENTATION
y_top += buffer->params.getDefSkip().inPixels(p.bv);
} else {
LyXLayout const & playout =
- textclasslist.Style(buffer->params.textclass,
- par->previous()->getLayout());
+ tclass[par->previous()->layout()];
if (playout.latextype == LATEX_PARAGRAPH
&& !par->previous()->getDepth()) {
// is it right to use defskip here, too? (AS)
case END_LABEL_STATIC:
{
LyXFont font(LyXFont::ALL_SANE);
- LyXTextClass::LayoutList::size_type layout = par->getLayout();
- string const str = textclasslist.
- Style(buffer->params.textclass, layout).endlabelstring();
+ string const & layout = par->layout();
+ string const str = textclasslist[buffer->params.textclass][layout].endlabelstring();
font = getLabelFont(buffer, par);
int const x = is_rtl ?
int(p.x) - lyxfont::width(str, font)
}
LyXLayout const & layout =
- textclasslist.Style(buffer->params.textclass, par->getLayout());
+ textclasslist[buffer->params.textclass][par->layout()];
pos_type vpos = p.row->pos();
while (vpos <= last) {
pos_type last = rowLastPrintable(row);
pos_type c = 0;
LyXLayout const & layout =
- textclasslist.Style(bview->buffer()->params.textclass,
- row->par()->getLayout());
+ textclasslist[bview->buffer()->params.textclass][
+ row->par()->layout()];
bool left_side = false;
pos_type main_body = beginningOfMainBody(bview->buffer(), row->par());
: number_of_rows(0), height(0), width(0), first(0),
bv_owner(bv), inset_owner(0), the_locking_inset(0),
need_break_row(0), refresh_y(0), refresh_row(0),
- status_(LyXText::UNCHANGED), firstrow(0), lastrow(0),
- copylayouttype(0)
+ status_(LyXText::UNCHANGED), firstrow(0), lastrow(0)
{}
: number_of_rows(0), height(0), width(0), first(0),
bv_owner(0), inset_owner(inset), the_locking_inset(0),
need_break_row(0), refresh_y(0), refresh_row(0),
- status_(LyXText::UNCHANGED), firstrow(0), lastrow(0),
- copylayouttype(0)
+ status_(LyXText::UNCHANGED), firstrow(0), lastrow(0)
{}
+
void LyXText::init(BufferView * bview, bool reinit)
{
if (reinit) {
firstrow = tmprow;
}
lastrow = refresh_row = need_break_row = 0;
- width = height = copylayouttype = 0;
+ width = height = 0;
+ copylayouttype.erase();
number_of_rows = first = refresh_y = 0;
status_ = LyXText::UNCHANGED;
} else if (firstrow)
par = par->outerHook();
if (par) {
#ifndef INHERIT_LANGUAGE
- tmpfont.realize(textclasslist.
- Style(buf->params.textclass,
- par->getLayout()).font);
+ tmpfont.realize(textclasslist[buf->params.textclass][
+ par->layout()].font);
#else
tmpfont.realize(textclasslist.
Style(buf->params.textclass,
- par->getLayout()).font,
+ par->layout()).font,
buf->params.language);
#endif
par_depth = par->getDepth();
}
#ifndef INHERIT_LANGUAGE
- tmpfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+ tmpfont.realize(textclasslist[buf->params.textclass].defaultfont());
#else
- tmpfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont(),
+ tmpfont.realize(textclasslist[buf->params.textclass].defaultfont(),
buf->params.language);
#endif
lyx::Assert(pos >= 0);
LyXLayout const & layout =
- textclasslist.Style(buf->params.textclass, par->getLayout());
+ textclasslist[buf->params.textclass][par->layout()];
Paragraph::depth_type par_depth = par->getDepth();
// We specialize the 95% common case:
LyXFont const LyXText::getLayoutFont(Buffer const * buf, Paragraph * par) const
{
LyXLayout const & layout =
- textclasslist.Style(buf->params.textclass, par->getLayout());
+ textclasslist[buf->params.textclass][par->layout()];
Paragraph::depth_type par_depth = par->getDepth();
LyXFont const LyXText::getLabelFont(Buffer const * buf, Paragraph * par) const
{
LyXLayout const & layout =
- textclasslist.Style(buf->params.textclass, par->getLayout());
+ textclasslist[buf->params.textclass][par->layout()];
Paragraph::depth_type par_depth = par->getDepth();
// Plug thru to version below:
setCharFont(buf, par, pos, font);
-
}
{
LyXFont font(fnt);
- LyXLayout const & layout =
- textclasslist.Style(buf->params.textclass,
- par->getLayout());
+ LyXTextClass const & tclass = textclasslist[buf->params.textclass];
+ LyXLayout const & layout = tclass[par->layout()];
// Get concrete layout font to reduce against
LyXFont layoutfont;
tp = tp->outerHook();
if (tp)
#ifndef INHERIT_LANGUAGE
- layoutfont.realize(textclasslist.
- Style(buf->params.textclass,
- tp->getLayout()).font);
+ layoutfont.realize(tclass[tp->layout()].font);
#else
layoutfont.realize(textclasslist.
Style(buf->params.textclass,
- tp->getLayout()).font,
+ tp->layout()).font,
buf->params.language);
#endif
}
}
#ifndef INHERIT_LANGUAGE
- layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+ layoutfont.realize(tclass.defaultfont());
#else
- layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont(),
- buf->params.language);
+ layoutfont.realize(tclass.defaultfont(), buf->params.language);
#endif
// Now, reduce font against full layout font
Paragraph * par)
{
LyXLayout const & layout =
- textclasslist.Style(buf->params.textclass, par->getLayout());
+ textclasslist[buf->params.textclass][par->layout()];
LyXFont layoutfont;
for (pos_type pos = 0; pos < par->size(); ++pos) {
Paragraph * LyXText::setLayout(BufferView * bview,
LyXCursor & cur, LyXCursor & sstart_cur,
LyXCursor & send_cur,
- lyx::layout_type layout)
+ string const & layout)
{
Paragraph * endpar = send_cur.par()->next();
Paragraph * undoendpar = endpar;
// ok we have a selection. This is always between sstart_cur
// and sel_end cursor
cur = sstart_cur;
-
+
LyXLayout const & lyxlayout =
- textclasslist.Style(bview->buffer()->params.textclass, layout);
+ textclasslist[bview->buffer()->params.textclass][layout];
do {
- cur.par()->setLayout(layout);
+ cur.par()->applyLayout(layout);
makeFontEntriesLayoutSpecific(bview->buffer(), cur.par());
Paragraph * fppar = cur.par();
fppar->params().spaceTop(lyxlayout.fill_top ?
if (cur.par() != send_cur.par())
cur.par(cur.par()->next());
} while (cur.par() != send_cur.par());
-
+
return endpar;
}
// set layout over selection and make a total rebreak of those paragraphs
-void LyXText::setLayout(BufferView * bview, lyx::layout_type layout)
+void LyXText::setLayout(BufferView * bview, string const & layout)
{
LyXCursor tmpcursor = cursor; /* store the current cursor */
bool anything_changed = false;
+ LyXTextClass const & tclass =
+ textclasslist[bview->buffer()->params.textclass];
+
while (true) {
// NOTE: you can't change the depth of a bibliography entry
- if (textclasslist.Style(bview->buffer()->params.textclass,
- cursor.par()->getLayout()).labeltype != LABEL_BIBLIO) {
+ if (tclass[cursor.par()->layout()].labeltype != LABEL_BIBLIO) {
Paragraph * prev = cursor.par()->previous();
if (prev) {
pos_type LyXText::beginningOfMainBody(Buffer const * buf,
Paragraph const * par) const
{
- if (textclasslist.Style(buf->params.textclass,
- par->getLayout()).labeltype != LABEL_MANUAL)
+ if (textclasslist[buf->params.textclass][
+ par->layout()].labeltype != LABEL_MANUAL)
return 0;
else
return par->beginningOfMainBody();
Paragraph * tmppar = selection.end.par();
+ LyXTextClass const & tclass =
+ textclasslist[bview->buffer()->params.textclass];
+
while (tmppar != selection.start.par()->previous()) {
setCursor(bview, tmppar, 0);
status(bview, LyXText::NEED_MORE_REFRESH);
cursor.par()->params().spaceBottom(space_bottom);
cursor.par()->params().spacing(spacing);
// does the layout allow the new alignment?
+ LyXLayout const & layout = tclass[cursor.par()->layout()];
+
if (align == LYX_ALIGN_LAYOUT)
- align = textclasslist
- .Style(bview->buffer()->params.textclass,
- cursor.par()->getLayout()).align;
- if (align & textclasslist
- .Style(bview->buffer()->params.textclass,
- cursor.par()->getLayout()).alignpossible) {
- if (align == textclasslist
- .Style(bview->buffer()->params.textclass,
- cursor.par()->getLayout()).align)
+ align = layout.align;
+ if (align & layout.alignpossible) {
+ if (align == layout.align)
cursor.par()->params().align(LYX_ALIGN_LAYOUT);
else
cursor.par()->params().align(align);
// set the counter of a paragraph. This includes the labels
void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
{
- LyXLayout const & layout =
- textclasslist.Style(buf->params.textclass,
- par->getLayout());
+ LyXTextClass const & textclass = textclasslist[buf->params.textclass];
+ LyXLayout const & layout = textclass[par->layout()];
- LyXTextClass const & textclass =
- textclasslist.TextClass(buf->params.textclass);
// copy the prev-counters to this one,
// unless this is the first paragraph
*/
if (par->previous()
&& par->previous()->getDepth() < par->getDepth()
- && textclasslist.Style(buf->params.textclass,
- par->previous()->getLayout()
- ).labeltype == LABEL_COUNTER_ENUMI
+ && textclass[par->previous()->layout()].labeltype == LABEL_COUNTER_ENUMI
&& par->enumdepth < 3
&& layout.labeltype != LABEL_BIBLIO) {
par->enumdepth++;
// now check for the headline layouts. remember that they
// have a dynamic left margin
- if ((textclasslist.Style(bview->buffer()->params.textclass,
- par->layout).margintype == MARGIN_DYNAMIC
- || textclasslist.Style(bview->buffer()->params.textclass,
- par->layout).labeltype == LABEL_SENSITIVE)) {
-
+ LyXTextClass const & tclass =
+ textclasslist[bview->buffer()->params.textclass];
+ LyXLayout const & layout = tclass[par->layout()];
+
+ if (layout.margintype == MARGIN_DYNAMIC
+ || layout.labeltype == LABEL_SENSITIVE) {
// Rebreak the paragraph
removeParagraph(row);
appendParagraph(bview, row);
void LyXText::copyEnvironmentType()
{
- copylayouttype = cursor.par()->getLayout();
+ copylayouttype = cursor.par()->layout();
}
status(bview, LyXText::NEED_MORE_REFRESH);
// check the special right address boxes
- if (textclasslist.Style(bview->buffer()->params.textclass,
- par->getLayout()).margintype
+ if (textclasslist[bview->buffer()->params.textclass][
+ par->layout()].margintype
== MARGIN_RIGHT_ADDRESS_BOX)
{
tmpcursor.par(par);
pos = vis2log(vpos);
if (main_body > 0 && pos == main_body - 1) {
x += fill_label_hfill +
- lyxfont::width(textclasslist.Style(
- bview->buffer()->params.textclass,
- row->par()->getLayout())
+ lyxfont::width(textclasslist[
+ bview->buffer()->params.textclass][
+ row->par()->layout()]
.labelsep,
getLabelFont(bview->buffer(), row->par()));
if (row->par()->isLineSeparator(main_body-1))
if (selection.set()) return false;
// We allow all kinds of "mumbo-jumbo" when freespacing.
- if (textclasslist.Style(bview->buffer()->params.textclass,
- old_cursor.par()->getLayout()).free_spacing
+ if (textclasslist[bview->buffer()->params.textclass][
+ old_cursor.par()->layout()].free_spacing
|| old_cursor.par()->isFreeSpacing())
{
return false;
return false;
// Do not delete empty paragraphs with keepempty set.
- if ((textclasslist.Style(bview->buffer()->params.textclass,
- old_cursor.par()->getLayout())).keepempty)
+ if (textclasslist
+ [bview->buffer()->params.textclass]
+ [old_cursor.par()->layout()].keepempty)
return false;
// only do our magic if we changed paragraph