bool Buffer::isLatex() const
{
- return params().textClass().outputType() == LATEX;
+ return params().getTextClass().outputType() == LATEX;
}
bool Buffer::isLiterate() const
{
- return params().textClass().outputType() == LITERATE;
+ return params().getTextClass().outputType() == LITERATE;
}
bool Buffer::isDocBook() const
{
- return params().textClass().outputType() == DOCBOOK;
+ return params().getTextClass().outputType() == DOCBOOK;
}
d->texrow.reset();
- TextClass const & tclass = params().textClass();
+ TextClass const & tclass = params().getTextClass();
string const top_element = tclass.latexname();
if (!only_body) {
<< " file was created by LyX " << lyx_version
<< "\n See http://www.lyx.org/ for more information -->\n";
- params().textClass().counters().reset();
+ params().getTextClass().counters().reset();
loadChildDocuments();
vector<string> Buffer::backends() const
{
vector<string> v;
- if (params().textClass().isTeXClassAvailable()) {
+ if (params().getTextClass().isTeXClassAvailable()) {
v.push_back(bufferFormat());
// FIXME: Don't hardcode format names here, but use a flag
if (v.back() == "latex")
*/
VSpace defskip;
PDFOptions pdfoptions;
-
- /// the base TextClass associated with the document
- TextClassIndex baseClass_;
- /// the possibly modular TextClass actually in use
- TextClassIndex textClass_;
};
BufferParams::Impl::Impl()
- : defskip(VSpace::MEDSKIP), baseClass_(0), textClass_(0)
+ : defskip(VSpace::MEDSKIP)
{
// set initial author
// FIXME UNICODE
string const classname = lex.getString();
// if there exists a local layout file, ignore the system one
// NOTE: in this case, the textclass (.cls file) is assumed to be available.
- pair<bool, TextClassIndex> pp =
- make_pair(false, TextClassIndex(0));
+ pair<bool, lyx::textclass_type> pp =
+ make_pair(false, textclass_type(0));
if (!filepath.empty())
pp = textclasslist.addTextClass(
classname, filepath.absFilename());
// FIXME: this warning will be given even if there exists a local .cls
// file. Even worse, the .lyx file can not be compiled or exported
// because the textclass is marked as unavilable.
- if (!textClass().isTeXClassAvailable()) {
+ if (!getTextClass().isTeXClassAvailable()) {
docstring const msg =
bformat(_("The layout file requested by this document,\n"
"%1$s.layout,\n"
// Prints out the buffer info into the .lyx file given by file
// the textclass
- os << "\\textclass " << textClass().name() << '\n';
+ os << "\\textclass " << textclasslist[baseClass_].name() << '\n';
// then the preamble
if (!preamble.empty()) {
void BufferParams::validate(LaTeXFeatures & features) const
{
- features.require(textClass().requires());
+ features.require(getTextClass().requires());
if (outputChanges) {
bool dvipost = LaTeXFeatures::isAvailable("dvipost");
features.require("float");
// AMS Style is at document level
- if (use_amsmath == package_on || textClass().provides("amsmath"))
+ if (use_amsmath == package_on
+ || getTextClass().provides("amsmath"))
features.require("amsmath");
if (use_esint == package_on)
features.require("esint");
{
os << "\\documentclass";
- TextClass const & tclass = textClass();
+ TextClass const & tclass = getTextClass();
+
ostringstream clsoptions; // the document class options.
if (tokenPos(tclass.opt_fontsize(),
// hyperref, see
// http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
if (language->lang() == "japanese-plain" &&
- !textClass().provides("japanese")) {
+ !getTextClass().provides("japanese")) {
//load babel in case it was not loaded due to an empty language list
if (language_options.str().empty())
lyxpreamble += "\\usepackage{babel}\n";
// use hyperref explicitely when it is required
if (features.isRequired("hyperref")) {
odocstringstream oss;
- pdfoptions().writeLaTeX(oss, textClass().provides("hyperref"));
+ pdfoptions().writeLaTeX(oss, getTextClass().provides("hyperref"));
lyxpreamble += oss.str();
}
void BufferParams::useClassDefaults()
{
- TextClass const & tclass = textclasslist[pimpl_->baseClass_];
+ TextClass const & tclass = textclasslist[baseClass_];
sides = tclass.sides();
columns = tclass.columns();
bool BufferParams::hasClassDefaults() const
{
- TextClass const & tclass = textclasslist[pimpl_->baseClass_];
+ TextClass const & tclass = textclasslist[baseClass_];
- return sides == tclass.sides()
+ return (sides == tclass.sides()
&& columns == tclass.columns()
&& pagestyle == tclass.pagestyle()
&& options == tclass.options()
&& secnumdepth == tclass.secnumdepth()
- && tocdepth == tclass.tocdepth();
+ && tocdepth == tclass.tocdepth());
}
-TextClass const & BufferParams::textClass() const
+TextClass const & BufferParams::getTextClass() const
{
- return textclasslist[pimpl_->textClass_];
+ return *textClass_;
}
-TextClassIndex BufferParams::textClassIndex() const
-{
- return pimpl_->textClass_;
+TextClassPtr BufferParams::getTextClassPtr() const {
+ return textClass_;
}
-void BufferParams::setTextClass(TextClassIndex const & tc)
-{
- pimpl_->textClass_ = tc;
+void BufferParams::setTextClass(TextClassPtr tc) {
+ textClass_ = tc;
}
-bool BufferParams::setBaseClass(TextClassIndex const & tc)
+bool BufferParams::setBaseClass(textclass_type tc)
{
if (textclasslist[tc].load()) {
- pimpl_->baseClass_ = tc;
+ baseClass_ = tc;
return true;
}
}
-TextClassIndex BufferParams::baseClass() const
+textclass_type BufferParams::getBaseClass() const
{
- return pimpl_->baseClass_;
+ return baseClass_;
}
void BufferParams::makeTextClass()
{
- pimpl_->textClass_ = baseClass();
+ textClass_.reset(new TextClass(textclasslist[getBaseClass()]));
//FIXME It might be worth loading the children's modules here,
//just as we load their bibliographies and such, instead of just
frontend::Alert::warning(_("Package not available"), msg);
}
FileName layout_file = libFileSearch("layouts", lm->getFilename());
- if (!textclasslist.at(pimpl_->textClass_).read(layout_file, TextClass::MODULE)) {
+ if (!textClass_->read(layout_file, TextClass::MODULE)) {
docstring const msg =
bformat(_("Error reading module %1$s\n"), from_utf8(modName));
frontend::Alert::warning(_("Read Error"), msg);
}
-vector<string> const & BufferParams::getModules() const
-{
+vector<string> const & BufferParams::getModules() const {
return layoutModules_;
}
-bool BufferParams::addLayoutModule(string const & modName)
-{
+bool BufferParams::addLayoutModule(string const & modName) {
LayoutModuleList::const_iterator it = layoutModules_.begin();
LayoutModuleList::const_iterator end = layoutModules_.end();
for (; it != end; it++) {
}
-void BufferParams::clearLayoutModules()
-{
+void BufferParams::clearLayoutModules() {
layoutModules_.clear();
}
Font const BufferParams::getFont() const
{
- FontInfo f = textClass().defaultfont();
+ FontInfo f = getTextClass().defaultfont();
if (fontsDefaultFamily == "rmdefault")
f.setFamily(ROMAN_FAMILY);
else if (fontsDefaultFamily == "sfdefault")
void BufferParams::readGraphicsDriver(Lexer & lex)
{
- if (!lex.next())
- return;
+ if (!lex.next()) return;
string const tmptok = lex.getString();
// check if tmptok is part of tex_graphics in tex_defs.h
void BufferParams::readBullets(Lexer & lex)
{
- if (!lex.next())
- return;
+ if (!lex.next()) return;
int const index = lex.getInteger();
lex.next();
void BufferParams::readBulletsLaTeX(Lexer & lex)
{
// The bullet class should be able to read this.
- if (!lex.next())
- return;
+ if (!lex.next()) return;
int const index = lex.getInteger();
lex.next(true);
docstring const temp_str = lex.getDocString();
{
// FIXME the class should provide the numerical/
// authoryear choice
- if (textClass().provides("natbib")
+ if (getTextClass().provides("natbib")
&& cite_engine_ != biblio::ENGINE_NATBIB_NUMERICAL)
return biblio::ENGINE_NATBIB_AUTHORYEAR;
return cite_engine_;
#ifndef BUFFERPARAMS_H
#define BUFFERPARAMS_H
-#include "BiblioInfo.h"
#include "Font.h"
+#include "BiblioInfo.h"
#include "paper.h"
+#include "TextClassPtr.h"
#include "insets/InsetQuotes.h"
class PDFOptions;
class Spacing;
class TextClass;
-class TextClassIndex;
class TexRow;
class VSpace;
InsetQuotes::quote_times quotes_times;
///
std::string fontsize;
- /// Get the LyX TextClass (that is, the layout file) this document is using.
- TextClassIndex baseClass() const;
+ ///Get the LyX TextClass (that is, the layout file) this document is using.
+ textclass_type getBaseClass() const;
/// Set the LyX TextClass (that is, the layout file) this document is using.
/// NOTE: This does not call makeTextClass() to update the local TextClass.
/// That needs to be done manually.
- bool setBaseClass(TextClassIndex const & index);
+ bool setBaseClass(textclass_type);
/// Adds the module information to the baseClass information to
/// create our local TextClass.
void makeTextClass();
/// Returns the TextClass currently in use: the BaseClass as modified
/// by modules.
- TextClass const & textClass() const;
+ TextClass const & getTextClass() const;
/// Returns a pointer to the TextClass currently in use: the BaseClass
- /// as modified by modules. (See \file TextClass.h for the definition.)
- TextClassIndex textClassIndex() const;
+ /// as modified by modules. (See \file TextClassPtr.h for the typedef.)
+ TextClassPtr getTextClassPtr() const;
/// This bypasses the baseClass and sets the textClass directly.
/// Should be called with care and would be better not being here,
/// but it seems to be needed by CutAndPaste::putClipboard().
- void setTextClass(TextClassIndex const & index);
+ void setTextClass(TextClassPtr);
/// List of modules in use
std::vector<std::string> const & getModules() const;
/// Add a module to the list of modules in use.
/// for use with natbib
biblio::CiteEngine cite_engine_;
+ /// the base TextClass associated with the document
+ textclass_type baseClass_;
+ /// the possibly modular TextClass actually in use
+ TextClassPtr textClass_;
///
typedef std::vector<std::string> LayoutModuleList;
///
el = buf.errorList("Parse");
buffer_.undo().recordUndo(d->cursor_);
cap::pasteParagraphList(d->cursor_, buf.paragraphs(),
- buf.params().textClassIndex(), el);
+ buf.params().getTextClassPtr(), el);
res = _("Document %1$s inserted.");
} else {
res = _("Could not insert document %1$s");
-/*
+/**
* \file CutAndPaste.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
typedef pair<pit_type, int> PitPosPair;
-typedef limited_stack<pair<ParagraphList, TextClassIndex> > CutStack;
+typedef limited_stack<pair<ParagraphList, TextClassPtr> > CutStack;
CutStack theCuts(10);
// persistent selection, cleared until the next selection
pair<PitPosPair, pit_type>
pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
- TextClassIndex const & textclass, ErrorList & errorlist)
+ TextClassPtr textclass, ErrorList & errorlist)
{
Buffer const & buffer = cur.buffer();
pit_type pit = cur.pit();
// Make a copy of the CaP paragraphs.
ParagraphList insertion = parlist;
- TextClassIndex tcindex = buffer.params().textClassIndex();
+ TextClassPtr const tc = buffer.params().getTextClassPtr();
// Now remove all out of the pars which is NOT allowed in the
// new environment and set also another font if that is required.
// supposed to be the default, not just if it is forced
if (cur.inset().useEmptyLayout()) {
LayoutPtr const layout =
- buffer.params().textClass().emptyLayout();
+ buffer.params().getTextClass().emptyLayout();
ParagraphList::iterator const end = insertion.end();
for (ParagraphList::iterator par = insertion.begin();
par != end; ++par)
// since we store pointers to insets at some places and we don't
// want to invalidate them.
insertion.swap(in.paragraphs());
- cap::switchBetweenClasses(textclass, tcindex, in, errorlist);
+ cap::switchBetweenClasses(textclass, tc, in, errorlist);
insertion.swap(in.paragraphs());
ParagraphList::iterator tmpbuf = insertion.begin();
}
-void putClipboard(ParagraphList const & paragraphs, TextClassIndex textclass,
+void putClipboard(ParagraphList const & paragraphs, TextClassPtr textclass,
docstring const & plaintext)
{
// For some strange reason gcc 3.2 and 3.3 do not accept
void copySelectionHelper(Buffer const & buf, ParagraphList & pars,
pit_type startpit, pit_type endpit,
- int start, int end, TextClassIndex tc, CutStack & cutstack)
+ int start, int end, TextClassPtr tc, CutStack & cutstack)
{
BOOST_ASSERT(0 <= start && start <= pars[startpit].size());
BOOST_ASSERT(0 <= end && end <= pars[endpit].size());
}
-void switchBetweenClasses(TextClassIndex const & oldtcindex,
- TextClassIndex const & newtcindex, InsetText & in, ErrorList & errorlist)
+void switchBetweenClasses(TextClassPtr const & oldone,
+ TextClassPtr const & newone, InsetText & in, ErrorList & errorlist)
{
errorlist.clear();
BOOST_ASSERT(!in.paragraphs().empty());
- if (oldtcindex == newtcindex)
+ if (oldone == newone)
return;
+ TextClass const & oldtc = *oldone;
+ TextClass const & newtc = *newone;
+
// layouts
ParIterator end = par_iterator_end(in);
- TextClass const & oldtc = textclasslist[oldtcindex];
- TextClass const & newtc = textclasslist[newtcindex];
for (ParIterator it = par_iterator_begin(in); it != end; ++it) {
docstring const name = it->layout()->name();
bool hasLayout = newtc.hasLayout(name);
if (inset->lyxCode() != FLEX_CODE)
// FIXME: Should we verify all InsetCollapsable?
continue;
- inset->setLayout(newtcindex);
+ inset->setLayout(newone);
if (!inset->undefined())
continue;
// The flex inset is undefined in newtc
text->paragraphs(),
begpit, endpit,
cur.selBegin().pos(), endpos,
- bp.textClassIndex(), theCuts);
+ bp.getTextClassPtr(), theCuts);
// Stuff what we got on the clipboard.
// Even if there is no selection.
putClipboard(theCuts[0].first, theCuts[0].second,
copySelectionHelper(cur.buffer(), pars, par, cur.selEnd().pit(),
pos, cur.selEnd().pos(),
- cur.buffer().params().textClassIndex(), cutstack);
+ cur.buffer().params().getTextClassPtr(), cutstack);
dirtyTabularStack(false);
}
ParagraphList pars;
Paragraph par;
BufferParams const & bp = cur.buffer().params();
- par.setLayout(bp.textClass().defaultLayout());
+ par.setLayout(bp.getTextClass().defaultLayout());
par.insert(0, grabSelection(cur), Font(), Change(Change::UNCHANGED));
pars.push_back(par);
- cutstack.push(make_pair(pars, bp.textClassIndex()));
+ cutstack.push(make_pair(pars, bp.getTextClassPtr()));
}
}
ParagraphList pars;
Paragraph par;
BufferParams const & bp = cur.buffer().params();
- par.setLayout(bp.textClass().defaultLayout());
+ par.setLayout(bp.getTextClass().defaultLayout());
par.insert(0, plaintext, Font(), Change(Change::UNCHANGED));
pars.push_back(par);
- theCuts.push(make_pair(pars, bp.textClassIndex()));
+ theCuts.push(make_pair(pars, bp.getTextClassPtr()));
} else {
copySelectionToStack(cur, theCuts);
}
void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
- TextClassIndex const & textclass, ErrorList & errorList)
+ TextClassPtr textclass, ErrorList & errorList)
{
if (cur.inTexted()) {
Text * text = cur.text();
PitPosPair ppp;
boost::tie(ppp, endpit) =
- pasteSelectionHelper(cur, parlist, textclass, errorList);
+ pasteSelectionHelper(cur, parlist,
+ textclass, errorList);
updateLabels(cur.buffer());
cur.clearSelection();
text->setCursor(cur, ppp.first, ppp.second);
if (buffer.readString(lyx)) {
cur.recordUndo();
pasteParagraphList(cur, buffer.paragraphs(),
- buffer.params().textClassIndex(), errorList);
+ buffer.params().getTextClassPtr(), errorList);
cur.setSelection();
return;
}
}
-void pasteClipboardGraphics(Cursor & cur, ErrorList & /*errorList*/,
+void pasteClipboardGraphics(Cursor & cur, ErrorList & errorList,
Clipboard::GraphicsType preferedType)
{
BOOST_ASSERT(theClipboard().hasGraphicsContents(preferedType));
#ifndef CUTANDPASTE_H
#define CUTANDPASTE_H
+#include "TextClassPtr.h"
+
#include "support/types.h"
#include "support/docstring.h"
namespace lyx {
class Buffer;
-class Cursor;
class ErrorList;
class InsetText;
+class Cursor;
class ParagraphList;
-class TextClassIndex;
namespace cap {
/// Paste the paragraph list \p parlist at the position given by \p cur.
/// Does not handle undo. Does only work in text, not mathed.
void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
- TextClassIndex const & textclass, ErrorList & errorList);
+ TextClassPtr textclass, ErrorList & errorList);
/** Needed to switch between different classes. This works
* for a list of paragraphs beginning with the specified par.
* It changes layouts and character styles.
*/
-void switchBetweenClasses(TextClassIndex const & c1, TextClassIndex const & c2,
- InsetText & in, ErrorList &);
+void switchBetweenClasses(TextClassPtr const & c1,
+ TextClassPtr const & c2, InsetText & in, ErrorList &);
/// Get the current selection as a string. Does not change the selection.
/// Does only work if the whole selection is in mathed.
void dirtyTabularStack(bool b);
/// is the tabular paste stack newer than the ordinary one?
bool tabularStackDirty();
-
} // namespace cap
} // namespce lyx
return;
}
- TextClass const & tclass = params_.textClass();
+ TextClass const & tclass = params_.getTextClass();
if (tclass.hasLayout(layoutname)) {
// Is this layout already in usedLayouts?
if (find(usedLayouts_.begin(), usedLayouts_.end(), layoutname)
bool LaTeXFeatures::mustProvide(string const & name) const
{
- return isRequired(name) && !params_.textClass().provides(name);
+ return isRequired(name) && !params_.getTextClass().provides(name);
}
// We only need float.sty if we use non builtin floats, or if we
// use the "H" modifier. This includes modified table and
// figure floats. (Lgb)
- Floating const & fl = params_.textClass().floats().getType(name);
+ Floating const & fl = params_.getTextClass().floats().getType(name);
if (!fl.type().empty() && !fl.builtin()) {
require("float");
}
string const LaTeXFeatures::getPackages() const
{
ostringstream packages;
- TextClass const & tclass = params_.textClass();
+ TextClass const & tclass = params_.getTextClass();
// FIXME: currently, we can only load packages and macros known
// to LyX.
docstring const LaTeXFeatures::getTClassPreamble() const
{
// the text class specific preamble
- TextClass const & tclass = params_.textClass();
+ TextClass const & tclass = params_.getTextClass();
odocstringstream tcpreamble;
tcpreamble << tclass.preamble();
void LaTeXFeatures::getFloatDefinitions(ostream & os) const
{
- FloatList const & floats = params_.textClass().floats();
+ FloatList const & floats = params_.getTextClass().floats();
// Here we will output the code to create the needed float styles.
// We will try to do this as minimal as possible.
void loadTextClass(string const & name, string const & buf_path)
{
- pair<bool, TextClassIndex> const tc_pair =
+ pair<bool, textclass_type> const tc_pair =
textclasslist.numberOfClass(name);
if (!tc_pair.first) {
return;
}
- TextClassIndex const tc = tc_pair.second;
+ textclass_type const tc = tc_pair.second;
if (!textclasslist[tc].load(buf_path)) {
docstring s = bformat(_("The document class %1$s."
Buffer * buffer = lyx_view_->buffer();
- TextClassIndex oldClass = buffer->params().textClassIndex();
+ TextClassPtr oldClass = buffer->params().getTextClassPtr();
Cursor & cur = view()->cursor();
cur.recordUndoFullDocument();
case LFUN_LAYOUT_MODULES_CLEAR: {
BOOST_ASSERT(lyx_view_);
Buffer * buffer = lyx_view_->buffer();
- TextClassIndex oldClass = buffer->params().textClassIndex();
+ TextClassPtr oldClass = buffer->params().getTextClassPtr();
view()->cursor().recordUndoFullDocument();
buffer->params().clearLayoutModules();
buffer->params().makeTextClass();
case LFUN_LAYOUT_MODULE_ADD: {
BOOST_ASSERT(lyx_view_);
Buffer * buffer = lyx_view_->buffer();
- TextClassIndex oldClass = buffer->params().textClassIndex();
+ TextClassPtr oldClass = buffer->params().getTextClassPtr();
view()->cursor().recordUndoFullDocument();
buffer->params().addLayoutModule(argument);
buffer->params().makeTextClass();
loadTextClass(argument, buffer->filePath());
- pair<bool, TextClassIndex> const tc_pair =
+ pair<bool, textclass_type> const tc_pair =
textclasslist.numberOfClass(argument);
if (!tc_pair.first)
break;
- TextClassIndex const old_class = buffer->params().baseClass();
- TextClassIndex const new_class = tc_pair.second;
+ textclass_type const old_class = buffer->params().getBaseClass();
+ textclass_type const new_class = tc_pair.second;
if (old_class == new_class)
// nothing to do
break;
//Save the old, possibly modular, layout for use in conversion.
- TextClassIndex oldClass = buffer->params().textClassIndex();
+ TextClassPtr oldClass = buffer->params().getTextClassPtr();
view()->cursor().recordUndoFullDocument();
buffer->params().setBaseClass(new_class);
buffer->params().makeTextClass();
case LFUN_LAYOUT_RELOAD: {
BOOST_ASSERT(lyx_view_);
Buffer * buffer = lyx_view_->buffer();
- TextClassIndex oldClass = buffer->params().textClassIndex();
- TextClassIndex const tc = buffer->params().baseClass();
+ TextClassPtr oldClass = buffer->params().getTextClassPtr();
+ textclass_type const tc = buffer->params().getBaseClass();
textclasslist.reset(tc);
buffer->params().setBaseClass(tc);
buffer->params().makeTextClass();
}
-void LyXFunc::updateLayout(TextClassIndex const & oldlayout,
+void LyXFunc::updateLayout(TextClassPtr const & oldlayout,
Buffer * buffer)
{
lyx_view_->message(_("Converting document to new document class..."));
StableDocIterator backcur(view()->cursor());
ErrorList & el = buffer->errorList("Class Switch");
cap::switchBetweenClasses(
- oldlayout, buffer->params().textClassIndex(),
+ oldlayout, buffer->params().getTextClassPtr(),
static_cast<InsetText &>(buffer->inset()), el);
view()->setCursor(backcur.asDocIterator(&(buffer->inset())));
#include "KeySequence.h"
#include "lfuns.h"
+#include "TextClassPtr.h"
#include "support/docstring.h"
class FuncStatus;
class KeySymbol;
class Text;
-class TextClassIndex;
namespace support {
class FileName;
class LyXView;
}
-
/** This class encapsulates all the LyX command operations.
This is the class of the LyX's "high level event handler".
Every user command is processed here, either invocated from
///
bool ensureBufferClean(BufferView * bv);
///
- void updateLayout(TextClassIndex const & oldlayout, Buffer * buffer);
+ void updateLayout(TextClassPtr const & oldlayout, Buffer * buffer);
};
/// Implementation is in LyX.cpp
return;
}
- FloatList const & floats = buf->params().textClass().floats();
+ FloatList const & floats =
+ buf->params().getTextClass().floats();
FloatList::const_iterator cit = floats.begin();
FloatList::const_iterator end = floats.end();
for (; cit != end; ++cit) {
return;
}
- FloatList const & floats = buf->params().textClass().floats();
+ FloatList const & floats =
+ buf->params().getTextClass().floats();
FloatList::const_iterator cit = floats.begin();
FloatList::const_iterator end = floats.end();
for (; cit != end; ++cit) {
return;
}
InsetLayouts const & insetLayouts =
- buf->params().textClass().insetLayouts();
+ buf->params().getTextClass().insetLayouts();
InsetLayouts::const_iterator cit = insetLayouts.begin();
InsetLayouts::const_iterator end = insetLayouts.end();
for (; cit != end; ++cit) {
tomenu.add(MenuItem(MenuItem::Command, _("Master Document"), f));
}
- FloatList const & floatlist = buf->params().textClass().floats();
+ FloatList const & floatlist = buf->params().getTextClass().floats();
TocList const & toc_list = buf->tocBackend().tocs();
TocList::const_iterator cit = toc_list.begin();
TocList::const_iterator end = toc_list.end();
docstring Paragraph::expandLabel(LayoutPtr const & layout,
BufferParams const & bparams, bool process_appendix) const
{
- TextClass const & tclass = bparams.textClass();
+ TextClass const & tclass = bparams.getTextClass();
docstring fmt;
if (process_appendix && d->params_.appendix())
// to be valid!
bool asdefault = forceEmptyLayout();
- if (asdefault)
- style = bparams.textClass().defaultLayout();
- else
+ if (asdefault) {
+ style = bparams.getTextClass().defaultLayout();
+ } else {
style = d->layout_;
+ }
// Current base font for all inherited font changes, without any
// change caused by an individual character, except for the language:
namespace lyx {
-ParagraphMetrics::ParagraphMetrics(Paragraph const & par)
- : position_(-1), par_(&par)
-{}
+ParagraphMetrics::ParagraphMetrics(Paragraph const & par): position_(-1), par_(&par)
+{
+}
ParagraphMetrics & ParagraphMetrics::operator=(
int ParagraphMetrics::rightMargin(BufferView const & bv) const
{
BufferParams const & params = bv.buffer().params();
- TextClass const & tclass = params.textClass();
+ TextClass const & tclass = params.getTextClass();
frontend::FontMetrics const & fm = theFontMetrics(params.getFont());
int const r_margin =
bv.rightMargin()
font = Font(inherit_font, bp.language);
change = Change(Change::UNCHANGED);
- TextClass const & tclass = bp.textClass();
+ TextClass const & tclass = bp.getTextClass();
if (layoutname.empty())
layoutname = tclass.defaultLayoutName();
tclass.defaultLayoutName();
}
- par.setLayout(bp.textClass()[layoutname]);
+ par.setLayout(bp.getTextClass()[layoutname]);
// Test whether the layout is obsolete.
LayoutPtr const & layout = par.layout();
if (!layout->obsoleted_by().empty())
- par.setLayout(bp.textClass()[layout->obsoleted_by()]);
+ par.setLayout(bp.getTextClass()[layout->obsoleted_by()]);
par.params().read(lex);
Paragraph & cpar = cur.paragraph();
pit_type cpit = cur.pit();
- TextClass const & tclass = cur.buffer().params().textClass();
+ TextClass const & tclass = cur.buffer().params().getTextClass();
LayoutPtr const & layout = cpar.layout();
// this is only allowed, if the current paragraph is not empty
// otherwise reset to default
if (par.useEmptyLayout())
- cur.paragraph().setLayout(bufparams.textClass().emptyLayout());
+ cur.paragraph().setLayout(bufparams.getTextClass().emptyLayout());
else
- cur.paragraph().setLayout(bufparams.textClass().defaultLayout());
+ cur.paragraph().setLayout(bufparams.getTextClass().defaultLayout());
return true;
}
bool needsUpdate = false;
BufferParams const & bufparams = cur.buffer().params();
- TextClass const & tclass = bufparams.textClass();
+ TextClass const & tclass = bufparams.getTextClass();
ParagraphList & plist = cur.text()->paragraphs();
Paragraph const & par = cur.paragraph();
Cursor prevcur = cur;
for (; it != it_end; it++)
it->changeLanguage(b.params(), latex_language, b.language());
- pasteParagraphList(cur, plist, b.params().textClassIndex(),
+ pasteParagraphList(cur, plist, b.params().getTextClassPtr(),
b.errorList("Paste"));
// restore position
cur.pit() = min(cur.lastpit(), spit);
BOOST_ASSERT(start != end);
BufferParams const & bufparams = buffer.params();
- LayoutPtr const & lyxlayout = bufparams.textClass()[layout];
+ LayoutPtr const & lyxlayout = bufparams.getTextClass()[layout];
for (pit_type pit = start; pit != end; ++pit) {
Paragraph & par = pars_[pit];
// special handling of new environment insets
BufferView & bv = cur.bv();
BufferParams const & params = bv.buffer().params();
- LayoutPtr const & lyxlayout = params.textClass()[layout];
+ LayoutPtr const & lyxlayout = params.getTextClass()[layout];
if (lyxlayout->is_environment) {
// move everything in a new environment inset
LYXERR(Debug::DEBUG, "setting layout " << to_utf8(layout));
if (insetText && !insetText->allowMultiPar() || cur.lastpit() == 0) {
// reset first par to default
cur.text()->paragraphs().begin()
- ->setEmptyOrDefaultLayout(bparams.textClass());
+ ->setEmptyOrDefaultLayout(bparams.getTextClass());
cur.pos() = 0;
cur.pit() = 0;
// Merge multiple paragraphs -- hack
} else {
// reset surrounding par to default
docstring const layoutname = insetText->useEmptyLayout()
- ? bparams.textClass().emptyLayoutName()
- : bparams.textClass().defaultLayoutName();
+ ? bparams.getTextClass().emptyLayoutName()
+ : bparams.getTextClass().defaultLayoutName();
cur.leaveInset(*inset);
text->setLayout(cur, layoutname);
}
ParagraphList::iterator finish = start;
ParagraphList::iterator end = pars.end();
- TextClass const & tc = buf.params().textClass();
+ TextClass const & tc = buf.params().getTextClass();
int const thistoclevel = start->layout()->toclevel;
int toclevel;
Paragraph const & para = cur.paragraph();
docstring const old_layout = para.layout()->name();
- TextClass const & tclass = bv->buffer().params().textClass();
+ TextClass const & tclass = bv->buffer().params().getTextClass();
if (layout.empty())
layout = tclass.defaultLayoutName();
cur.posForward();
ParagraphList & pars = cur.text()->paragraphs();
- TextClass const & tclass = bv->buffer().params().textClass();
+ TextClass const & tclass = bv->buffer().params().getTextClass();
// add a separate paragraph for the caption inset
pars.push_back(Paragraph());
break;
case LFUN_FLOAT_LIST: {
- TextClass const & tclass = bv->buffer().params().textClass();
+ TextClass const & tclass = bv->buffer().params().getTextClass();
if (tclass.floats().typeExist(to_utf8(cmd.argument()))) {
cur.recordUndo();
if (cur.selection())
case LFUN_FLEX_INSERT: {
code = FLEX_CODE;
string s = cmd.getArg(0);
- InsetLayout il = cur.buffer().params().textClass().insetLayout(from_utf8(s));
+ InsetLayout il = cur.buffer().params().getTextClass().insetLayout(from_utf8(s));
if (il.lyxtype() != "charstyle" &&
il.lyxtype() != "custom" &&
il.lyxtype() != "element" &&
/// List of inset layouts
typedef std::map<docstring, InsetLayout> InsetLayouts;
-/// Index in globel text class list. Basically a 'strong typedef'.
-class TextClassIndex
-{
-public:
- ///
- TextClassIndex(size_t t) : data_(t) {}
- ///
- operator size_t() const { return data_; }
-private:
- ///
- size_t data_;
-};
-
-
-
/// Stores the layout specification of a LyX document class.
class TextClass {
public:
using boost::smatch;
// Gets textclass number from name
-pair<bool, TextClassIndex> const
+pair<bool, textclass_type> const
TextClassList::numberOfClass(string const & textclass) const
{
ClassList::const_iterator cit =
textclass));
return cit != classlist_.end() ?
- make_pair(true, TextClassIndex(cit - classlist_.begin())) :
- make_pair(false, TextClassIndex(0));
+ make_pair(true, textclass_type(cit - classlist_.begin())) :
+ make_pair(false, textclass_type(0));
}
// Gets a textclass structure from number
TextClass const &
-TextClassList::operator[](TextClassIndex textclass) const
-{
- if (textclass >= classlist_.size())
- return classlist_[0];
-
- //FIXME I don't believe the following line is actually necessary (rgh)
- classlist_[textclass].load();
- return classlist_[textclass];
-}
-
-TextClass & TextClassList::at(TextClassIndex textclass)
+TextClassList::operator[](textclass_type textclass) const
{
if (textclass >= classlist_.size())
return classlist_[0];
}
-void TextClassList::reset(TextClassIndex const & textclass)
-{
+void TextClassList::reset(textclass_type const textclass) {
if (textclass >= classlist_.size())
return;
TextClass const & tc = classlist_[textclass];
}
-pair<bool, TextClassIndex> const
+pair<bool, textclass_type> const
TextClassList::addTextClass(string const & textclass, string const & path)
{
// only check for textclass.layout file, .cls can be anywhere in $TEXINPUTS
tmpl.load(path);
// Do not add this local TextClass to classlist_ if it has
// already been loaded by, for example, a master buffer.
- pair<bool, lyx::TextClassIndex> pp =
+ pair<bool, lyx::textclass_type> pp =
textclasslist.numberOfClass(textclass);
// only layouts from the same directory are considered to be identical.
if (pp.first && classlist_[pp.second].description() == tmpl.description())
}
}
// If .layout is not in local directory, or an invalid layout is found, return false
- return make_pair(false, TextClassIndex(0));
+ return make_pair(false, textclass_type(0));
}
TextClassList textclasslist;
-TextClassIndex defaultTextclass()
+textclass_type defaultTextclass()
{
// We want to return the article class. if `first' is
// true in the returned pair, then `second' is the textclass
bool empty() const { return classlist_.empty(); }
/// Gets textclass number from name, -1 if textclass name does not exist
- std::pair<bool, TextClassIndex> const
- numberOfClass(std::string const & textClassName) const;
+ std::pair<bool, textclass_type> const
+ numberOfClass(std::string const & textclass) const;
///
- TextClass const & operator[](TextClassIndex index) const;
- TextClass & at(TextClassIndex index);
+ TextClass const & operator[](textclass_type textclass) const;
/// Read textclass list. Returns false if this fails.
bool read();
/// Clears the textclass so as to force it to be reloaded
- void reset(TextClassIndex const & index);
+ void reset(textclass_type const textclass);
/// add a textclass from user local directory.
/// Return ture/false, and textclass number
- std::pair<bool, TextClassIndex> const
+ std::pair<bool, textclass_type> const
addTextClass(std::string const & textclass, std::string const & path);
private:
///
extern TextClassList textclasslist;
///
-TextClassIndex defaultTextclass();
+textclass_type defaultTextclass();
} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file TextClassPtr.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef TEXTCLASS_PTR_H
+#define TEXTCLASS_PTR_H
+
+#include <boost/shared_ptr.hpp>
+
+namespace lyx {
+
+class TextClass;
+
+/// Global typedef
+/** Shared pointer for possibly modular layout. Needed so that paste,
+ * for example, will still be able to retain the pointer, even when
+ * the buffer itself is closed.
+ */
+typedef boost::shared_ptr<TextClass> TextClassPtr;
+
+} // namespace lyx
+
+#endif
BOOST_ASSERT(pos <= par.size());
Buffer const & buffer = bv_->buffer();
//lyxerr << "TextMetrics::leftMargin: pit: " << pit << " pos: " << pos << endl;
- TextClass const & tclass = buffer.params().textClass();
+ TextClass const & tclass = buffer.params().getTextClass();
LayoutPtr const & layout = par.layout();
docstring parindent = layout->parindent;
}
BufferParams const & bufparams = buffer_->params();
- const int min_toclevel = bufparams.textClass().min_toclevel();
+ const int min_toclevel = bufparams.getTextClass().min_toclevel();
TocIterator toc_item = item("tableofcontents", par_it);
}
int const toclevel = toc_item->par_it_->layout()->toclevel;
- if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel
- && tocstring.empty())
+ if (toclevel != Layout::NOT_IN_TOC
+ && toclevel >= min_toclevel
+ && tocstring.empty())
tocstring = toc_item->par_it_->asString(*buffer_, true);
const_cast<TocItem &>(*toc_item).str_ = tocstring;
tocs_.clear();
BufferParams const & bufparams = buffer_->params();
- const int min_toclevel = bufparams.textClass().min_toclevel();
+ const int min_toclevel = bufparams.getTextClass().min_toclevel();
Toc & toc = tocs_["tableofcontents"];
ParConstIterator pit = buffer_->par_iterator_begin();
// set the label of a paragraph. This includes the counters.
void setLabel(Buffer const & buf, ParIterator & it)
{
- TextClass const & textclass = buf.params().textClass();
+ TextClass const & textclass = buf.params().getTextClass();
Paragraph & par = it.paragraph();
LayoutPtr const & layout = par.layout();
Counters & counters = textclass.counters();
{
Buffer const * const master = buf.masterBuffer();
// Use the master text class also for child documents
- TextClass const & textclass = master->params().textClass();
+ TextClass const & textclass = master->params().getTextClass();
if (!childonly) {
// If this is a child document start with the master
case LFUN_FLEX_INSERT: {
string s = cmd.getArg(0);
- return new InsetFlex(params, params.textClassIndex(), s);
+ return new InsetFlex(params, params.getTextClassPtr(), s);
}
case LFUN_NOTE_INSERT: {
case LFUN_FLOAT_INSERT: {
// check if the float type exists
string const argument = to_utf8(cmd.argument());
- if (params.textClass().floats().typeExist(argument))
+ if (params.getTextClass().floats().typeExist(argument))
return new InsetFloat(params, argument);
lyxerr << "Non-existent float type: " << argument << endl;
}
case LFUN_FLOAT_WIDE_INSERT: {
// check if the float type exists
string const argument = to_utf8(cmd.argument());
- if (params.textClass().floats().typeExist(argument)) {
+ if (params.getTextClass().floats().typeExist(argument)) {
auto_ptr<InsetFloat> p(new InsetFloat(params, argument));
p->wide(true, params);
return p.release();
lex.next();
string s = lex.getString();
inset.reset(new InsetFlex(buf.params(),
- buf.params().textClassIndex(), s));
+ buf.params().getTextClassPtr(), s));
} else if (tmptok == "Branch") {
inset.reset(new InsetBranch(buf.params(),
InsetBranchParams()));
#include <QSettings>
#include <QString>
-#include <boost/assert.hpp>
-
#include <string>
using namespace std;
void GuiDocument::classChanged()
{
- TextClassIndex const tc = latexModule->classCO->currentIndex();
+ textclass_type const tc = latexModule->classCO->currentIndex();
bp_.setBaseClass(tc);
if (lyxrc.auto_reset_options) {
if (applyPB->isEnabled()) {
namespace {
- // This is an insanely complicated attempt to make this sort of thing
- // work with RTL languages.
+ //This is an insanely complicated attempt to make this sort of thing
+ //work with RTL languages.
docstring formatStrVec(vector<string> const & v, docstring const & s)
{
//this mess formats the list as "v[0], v[1], ..., [s] v[n]"
void GuiDocument::updateNumbering()
{
- TextClass const & tclass = bp_.textClass();
+ TextClass const & tclass = bp_.getTextClass();
numberingModule->tocTW->setUpdatesEnabled(false);
numberingModule->tocTW->clear();
params.language = lyx::languages.getLanguage(lang_[pos]);
// numbering
- if (params.textClass().hasTocLevels()) {
+ if (params.getTextClass().hasTocLevels()) {
params.tocdepth = numberingModule->tocSL->value();
params.secnumdepth = numberingModule->depthSL->value();
}
}
// text layout
- latexModule->classCO->setCurrentIndex(params.baseClass());
+ latexModule->classCO->setCurrentIndex(params.getBaseClass());
updatePagestyle(textClass().opt_pagestyle(),
params.pagestyle);
TextClass const & GuiDocument::textClass() const
{
- return textclasslist[bp_.baseClass()];
+ return textclasslist[bp_.getBaseClass()];
}
if (type == "note")
return _("List of Notes");
- FloatList const & floats = buffer().params().textClass().floats();
+ FloatList const & floats = buffer().params().getTextClass().floats();
if (floats.typeExist(type))
return _(floats.getType(type).listName());
return;
}
- TextClass const * text_class = &buffer->params().textClass();
+ TextClass const * text_class = &buffer->params().getTextClass();
Inset const * inset =
owner_.view()->cursor().innerParagraph().inInset();
#include "Layout.h"
#include "LyX.h"
#include "LyXFunc.h"
+#include "TextClass.h"
#include "ToolbarBackend.h"
#include "support/debug.h"
LYXERR(Debug::INIT, "Adding " << tb->key << " at position "
<< tb->info.posx << " " << tb->info.posy);
// add toolbar break if posx or posy changes
- bool newline = tb->info.location == last_loc && (
+ bool newline = tb->info.location == last_loc && (
// if two toolbars at the same location, assume uninitialized and add toolbar break
(tb->info.posx == last_posx && tb->info.posy == last_posy) ||
(last_loc == ToolbarSection::ToolbarInfo::TOP && tb->info.posy != last_posy) ||
#ifndef GUI_TOOLBARS_H
#define GUI_TOOLBARS_H
+#include "TextClassPtr.h"
+
#include "support/docstring.h"
#include <map>
namespace lyx {
class ToolbarInfo;
-class TextClassIndex;
namespace frontend {
/// Toolbar store providing access to individual toolbars by name.
typedef std::map<std::string, GuiToolbar *> ToolbarsMap;
ToolbarsMap toolbars_;
+
+ /// The last textclass layout list in the layout choice selector
+ TextClassPtr last_textclass_;
};
} // namespace frontend
} // namespace lyx
-#endif // GUI_TOOLBARS_H
+#endif // NOT GUI_TOOLBARS_H
InsetLayout const & Inset::getLayout(BufferParams const & bp) const
{
- return bp.textClass().insetLayout(name());
+ return bp.getTextClass().insetLayout(name());
}
/// Update the counters of this inset and of its contents
void InsetBibitem::updateLabels(Buffer const &buf, ParIterator const &)
{
- Counters & counters = buf.params().textClass().counters();
+ Counters & counters = buf.params().getTextClass().counters();
docstring const bibitem = from_ascii("bibitem");
if (counters.hasCounter(bibitem) && getParam("label").empty()) {
counters.step(bibitem);
// part of its name, because it's than book.
// For the "official" lyx-layouts it's no problem to support
// all well
- if (!contains(buffer.params().textClass().name(),
+ if (!contains(buffer.params().getTextClass().name(),
"art")) {
if (buffer.params().sides == OneSide) {
// oneside
: InsetCollapsable(bp), params_(label)
{
if (forceEmptyLayout())
- paragraphs().back().setLayout(bp.textClass().emptyLayout());
+ paragraphs().back().setLayout(bp.getTextClass().emptyLayout());
}
if (isBranchSelected(buf))
InsetCollapsable::updateLabels(buf, it);
else {
- TextClass const & tclass = buf.params().textClass();
+ TextClass const & tclass = buf.params().getTextClass();
Counters savecnt = tclass.counters();
InsetCollapsable::updateLabels(buf, it);
tclass.counters() = savecnt;
InsetCaption::InsetCaption(BufferParams const & bp)
- : InsetText(bp), textclass_(bp.textClass())
+ : InsetText(bp), textclass_(bp.getTextClass())
{
setAutoBreakRows(true);
setDrawFrame(true);
setFrameColor(Color_captionframe);
//FIXME Do we need to set all paragraphs here? or will there
//always only be one?
- paragraphs().back().setLayout(bp.textClass().emptyLayout());
+ paragraphs().back().setLayout(bp.getTextClass().emptyLayout());
}
void InsetCaption::updateLabels(Buffer const & buf, ParIterator const & it)
{
- TextClass const & tclass = buf.params().textClass();
+ TextClass const & tclass = buf.params().getTextClass();
Counters & cnts = tclass.counters();
string const & type = cnts.current_float();
// Memorize type for addToToc().
#include "MetricsInfo.h"
#include "ParagraphParameters.h"
#include "TextClass.h"
-#include "TextClassList.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
InsetCollapsable::InsetCollapsable(BufferParams const & bp,
- CollapseStatus status, TextClassIndex tc)
- : InsetText(bp), textClass_(tc), status_(status),
+ CollapseStatus status, TextClassPtr tc)
+ : InsetText(bp), status_(status),
openinlined_(false), autoOpen_(false), mouse_hover_(false)
{
setLayout(tc);
setAutoBreakRows(true);
setDrawFrame(true);
setFrameColor(Color_collapsableframe);
- paragraphs().back().setLayout(bp.textClass().emptyLayout());
+ paragraphs().back().setLayout(bp.getTextClass().emptyLayout());
}
Dimension dim = dimensionCollapsed();
if (geometry() == NoButton)
return layout_->labelstring();
- if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des)
+ else if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des)
return docstring();
switch (status_) {
void InsetCollapsable::setLayout(BufferParams const & bp)
{
- setLayout(bp.textClassIndex());
+ setLayout(bp.getTextClassPtr());
}
-void InsetCollapsable::setLayout(TextClassIndex tcindex)
+void InsetCollapsable::setLayout(TextClassPtr tc)
{
- textClass_ = tcindex;
- if (tcindex != TextClassIndex(-1)) {
- layout_ = &textclasslist[tcindex].insetLayout(name());
+ textClass_ = tc;
+ if ( tc.get() != 0 ) {
+ layout_ = &tc->insetLayout(name());
labelstring_ = layout_->labelstring();
} else {
layout_ = &TextClass::emptyInsetLayout();
lex.pushToken(token);
}
}
-
- // this must be set before we enter InsetText::read()
+ //this must be set before we enter InsetText::read()
setLayout(buf.params());
InsetText::read(buf, lex);
case LeftButton:
case ButtonOnly:
dim = dimensionCollapsed();
- if (geometry() == TopButton || geometry() == LeftButton) {
+ if (geometry() == TopButton
+ || geometry() == LeftButton) {
Dimension textdim;
InsetText::metrics(mi, textdim);
openinlined_ = (textdim.wid + dim.wid) < mi.base.textwidth;
case LFUN_TABULAR_INSERT:
case LFUN_TOC_INSERT:
case LFUN_WRAP_INSERT:
- if (layout_->isPassThru()) {
- flag.enabled(false);
- return true;
- }
+ if (layout_->isPassThru()) {
+ flag.enabled(false);
+ return true;
+ } else
return InsetText::getStatus(cur, cmd, flag);
case LFUN_INSET_TOGGLE:
docstring InsetCollapsable::floatName(
string const & type, BufferParams const & bp) const
{
- FloatList const & floats = bp.textClass().floats();
+ FloatList const & floats = bp.getTextClass().floats();
FloatList::const_iterator it = floats[type];
// FIXME UNICODE
return (it == floats.end()) ? from_ascii(type) : bp.B_(it->second.name());
#include "Box.h"
#include "TextClass.h"
+#include "TextClassPtr.h"
#include <string>
InsetCollapsable(
BufferParams const &,
CollapseStatus status = Inset::Open,
- TextClassIndex tc = TextClassIndex(0)
+ TextClassPtr tc = TextClassPtr((TextClass *)0)
);
///
InsetCollapsable(InsetCollapsable const & rhs);
void setLayout(BufferParams const &);
/// (Re-)set the character style parameters from \p tc according
/// to name()
- void setLayout(TextClassIndex tc);
+ void setLayout(TextClassPtr tc);
///
virtual bool useEmptyLayout() { return true; }
///
private:
/// text class to keep the InsetLayout above in memory
- TextClassIndex textClass_;
+ TextClassPtr textClass_;
/// cache for the layout_. Make sure it is in sync with the text class!
InsetLayout const * layout_;
///
{
BufferParams const & bp = cur.buffer().params();
LayoutPtr const layout =
- bp.textClass().emptyLayout();
+ bp.getTextClass().emptyLayout();
//lyxerr << "\nInsetERT::doDispatch (begin): cmd: " << cmd << endl;
switch (cmd.action) {
InsetEnvironment::InsetEnvironment
(BufferParams const & bp, docstring const & name)
- : InsetText(bp), layout_(bp.textClass()[name]), name_(name)
+ : InsetText(bp), layout_(bp.getTextClass()[name]), name_(name)
{
setAutoBreakRows(true);
setDrawFrame(true);
InsetFlex::InsetFlex(BufferParams const & bp,
- TextClassIndex tc, string const & layoutName)
+ TextClassPtr tc, string const & layoutName)
: InsetCollapsable(bp, Collapsed, tc),
name_(layoutName)
{
public:
///
InsetFlex(BufferParams const &,
- TextClassIndex tc, string const & layoutName);
+ TextClassPtr tc, string const & layoutName);
///
docstring name() const { return from_utf8(name_); }
void InsetFloat::updateLabels(Buffer const & buf, ParIterator const & it)
{
- Counters & cnts = buf.params().textClass().counters();
+ Counters & cnts = buf.params().getTextClass().counters();
string const saveflt = cnts.current_float();
// Tell to captions what the current float is
int InsetFloat::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
- FloatList const & floats = buf.params().textClass().floats();
+ FloatList const & floats = buf.params().getTextClass().floats();
string tmptype = params_.type;
if (params_.sideways)
tmptype = "sideways" + params_.type;
docstring const InsetFloatList::getScreenLabel(Buffer const & buf) const
{
- FloatList const & floats = buf.params().textClass().floats();
+ FloatList const & floats = buf.params().getTextClass().floats();
FloatList::const_iterator it = floats[to_ascii(getParam("type"))];
if (it != floats.end())
return buf.B_(it->second.listName());
void InsetFloatList::read(Buffer const & buf, Lexer & lex)
{
- FloatList const & floats = buf.params().textClass().floats();
+ FloatList const & floats = buf.params().getTextClass().floats();
string token;
if (lex.eatLine()) {
int InsetFloatList::latex(Buffer const & buf, odocstream & os,
OutputParams const &) const
{
- FloatList const & floats = buf.params().textClass().floats();
+ FloatList const & floats = buf.params().getTextClass().floats();
FloatList::const_iterator cit = floats[to_ascii(getParam("type"))];
if (cit != floats.end()) {
void InsetFoot::updateLabels(Buffer const & buf, ParIterator const & it)
{
- TextClass const & tclass = buf.params().textClass();
+ TextClass const & tclass = buf.params().getTextClass();
Counters & cnts = tclass.counters();
docstring const foot = from_ascii("footnote");
Paragraph const & outer = it.paragraph();
Buffer * tmp = theBufferList().getBuffer(included_file.absFilename());
- if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
+ if (tmp->params().getBaseClass() != masterBuffer->params().getBaseClass()) {
// FIXME UNICODE
docstring text = bformat(_("Included file `%1$s'\n"
"has textclass `%2$s'\n"
"while parent file has textclass `%3$s'."),
included_file.displayName(),
- from_utf8(tmp->params().textClass().name()),
- from_utf8(masterBuffer->params().textClass().name()));
+ from_utf8(tmp->params().getTextClass().name()),
+ from_utf8(masterBuffer->params().getTextClass().name()));
Alert::warning(_("Different textclasses"), text);
//return 0;
}
listings_label_.clear();
return;
}
- Counters & counters = buffer.params().textClass().counters();
+ Counters & counters = buffer.params().getTextClass().counters();
docstring const cnt = from_ascii("listing");
listings_label_ = buffer.B_("Program Listing");
if (counters.hasCounter(cnt)) {
}
-static Translator<InsetInfo::info_type, string> initTranslator()
+namespace {
+
+Translator<InsetInfo::info_type, string> const initTranslator()
{
- Translator<InsetInfo::info_type, string>
- translator(InsetInfo::UNKNOWN_INFO, "unknown");
+ Translator<InsetInfo::info_type, string> translator(InsetInfo::UNKNOWN_INFO, "unknown");
translator.addPair(InsetInfo::SHORTCUT_INFO, "shortcut");
translator.addPair(InsetInfo::LYXRC_INFO, "lyxrc");
return translator;
}
+} // namespace anon
+
Translator<InsetInfo::info_type, string> const & InsetInfo::nameTranslator() const
{
- static Translator<info_type, string> const translator = initTranslator();
+ static Translator<info_type, string> const translator =
+ initTranslator();
return translator;
}
+
void InsetInfo::read(Buffer const & buf, Lexer & lex)
{
void InsetInfo::write(Buffer const &, ostream & os) const
{
- os << "Info\ntype \"" << nameTranslator().find(type_)
+ os << "Info\ntype \""
+ << nameTranslator().find(type_)
<< "\"\narg \"" << name_ << '\"';
}
break;
case TEXTCLASS_INFO: {
// name_ is the class name
- pair<bool, TextClassIndex> pp = textclasslist.numberOfClass(name_);
+ pair<bool, lyx::textclass_type> pp =
+ textclasslist.numberOfClass(name_);
setText(pp.first ? _("yes") : _("no"),
bp.getFont(), false);
break;
else if (name_ == "path")
setText(from_utf8(buf.filePath()), bp.getFont(), false);
else if (name_ == "class")
- setText(from_utf8(bp.textClass().name()), bp.getFont(), false);
+ setText(from_utf8(bp.getTextClass().name()), bp.getFont(), false);
else
setText(_("Unknown buffer info"), bp.getFont(), false);
break;
void InsetListings::updateLabels(Buffer const & buf, ParIterator const & it)
{
- Counters & cnts = buf.params().textClass().counters();
+ Counters & cnts = buf.params().getTextClass().counters();
string const saveflt = cnts.current_float();
// Tell to captions what the current float is
void InsetNote::updateLabels(Buffer const & buf, ParIterator const & it)
{
- TextClass const & tclass = buf.params().textClass();
+ TextClass const & tclass = buf.params().getTextClass();
Counters savecnt = tclass.counters();
InsetCollapsable::updateLabels(buf, it);
tclass.counters() = savecnt;
rotate(false),
inset(new InsetText(bp))
{
- inset->paragraphs().back().setLayout(bp.textClass().emptyLayout());
+ inset->paragraphs().back().setLayout(bp.getTextClass().emptyLayout());
}
cur.push(*inset);
// undo information has already been recorded
inset->getText(0)->setLayout(cur.bv().buffer(), 0, cur.lastpit() + 1,
- bp.textClass().emptyLayoutName());
+ bp.getTextClass().emptyLayoutName());
cur.pop();
}
void InsetTabular::updateLabels(Buffer const & buf, ParIterator const & it)
{
// In a longtable, tell captions what the current float is
- Counters & cnts = buf.params().textClass().counters();
+ Counters & cnts = buf.params().getTextClass().counters();
string const saveflt = cnts.current_float();
if (tabular.isLongTabular())
cnts.current_float("table");
{
paragraphs().push_back(Paragraph());
Paragraph & ourpar = paragraphs().back();
- ourpar.setEmptyOrDefaultLayout(bp.textClass());
+ ourpar.setEmptyOrDefaultLayout(bp.getTextClass());
ourpar.setInsetOwner(this);
}
void InsetWrap::updateLabels(Buffer const & buf, ParIterator const & it)
{
- Counters & cnts = buf.params().textClass().counters();
+ Counters & cnts = buf.params().getTextClass().counters();
string const saveflt = cnts.current_float();
// Tell to captions what the current float is
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend)
{
- LayoutPtr const & defaultstyle = buf.params().textClass().defaultLayout();
+ LayoutPtr const & defaultstyle =
+ buf.params().getTextClass().defaultLayout();
for (ParagraphList::const_iterator par = pbegin; par != pend; ++par) {
if (par != pbegin)
os << '\n';
ParagraphList::const_iterator const & pend) {
ParagraphList::const_iterator par = pbegin;
- LayoutPtr const & defaultstyle = buf.params().textClass().defaultLayout();
+ LayoutPtr const & defaultstyle = buf.params().getTextClass().defaultLayout();
LayoutPtr const & bstyle = par->layout();
string item_tag;
BufferParams const & bparams = buf.params();
LayoutPtr const & style = pit->forceEmptyLayout() ?
- bparams.textClass().emptyLayout() : pit->layout();
+ bparams.getTextClass().emptyLayout() :
+ pit->layout();
ParagraphList const & paragraphs = text.paragraphs();
// In an inset with unlimited length (all in one row),
// force layout to default
LayoutPtr const style = pit->forceEmptyLayout() ?
- bparams.textClass().emptyLayout() : pit->layout();
+ bparams.getTextClass().emptyLayout() :
+ pit->layout();
OutputParams runparams = runparams_in;
runparams.moving_arg |= style->needprotect;
}
}
- bool const useSetSpace = bparams.textClass().provides("SetSpace");
+ bool const useSetSpace = bparams.getTextClass().provides("SetSpace");
if (pit->allowParagraphCustomization()) {
if (pit->params().startOfAppendix()) {
os << "\\appendix\n";
bool was_title = false;
bool already_title = false;
BufferParams const & bparams = buf.params();
- TextClass const & tclass = bparams.textClass();
+ TextClass const & tclass = bparams.getTextClass();
ParagraphList const & paragraphs = text.paragraphs();
ParagraphList::const_iterator par = paragraphs.begin();
ParagraphList::const_iterator endpar = paragraphs.end();
// without doing that we get a crash when typing <Return> at the
// end of a paragraph
if (par.useEmptyLayout())
- tmp->setLayout(bparams.textClass().emptyLayout());
+ tmp->setLayout(bparams.getTextClass().emptyLayout());
else
- tmp->setLayout(bparams.textClass().defaultLayout());
+ tmp->setLayout(bparams.getTextClass().defaultLayout());
// layout stays the same with latex-environments
if (keep_layout) {
par.params().clear();
// do not lose start of appendix marker (bug 4212)
par.params().startOfAppendix(soa);
- par.setLayout(bparams.textClass().defaultLayout());
+ par.setLayout(bparams.getTextClass().defaultLayout());
}
// layout stays the same with latex-environments
// and adds a number for uniqueness.
// If you know what you are doing, you can set allowed==""
// to disable this mangling.
- TextClass const & tclass = buf.params().textClass();
+ TextClass const & tclass = buf.params().getTextClass();
docstring const allowed = from_ascii(
- runparams.flavor == OutputParams::XML? ".-_:" : tclass.options());
+ runparams.flavor == OutputParams::XML? ".-_:":tclass.options());
if (allowed.empty())
return orig;
MangledMap::const_iterator const known = mangledNames.find(orig);
if (known != mangledNames.end())
- return known->second;
+ return (*known).second;
// make sure it starts with a letter
if (!isAlphaASCII(*it) && allowed.find(*it) >= allowed.size())
LayoutPtr const & style = par.layout();
string const & name = style->latexname();
string param = style->latexparam();
- Counters & counters = buf.params().textClass().counters();
+ Counters & counters = buf.params().getTextClass().counters();
string id = par.getID(buf, runparams);
/// a type for sizes
typedef size_t size_type;
+ /// a type used for numbering text classes
+ typedef size_t textclass_type;
+
#else
// These structs wrap simple things to make them distinguishible
base_type data_;
};
+ struct textclass_type {
+ ///
+ typedef size_t base_type;
+ ///
+ textclass_type(base_type t) { data_ = t; }
+ ///
+ operator base_type() const { return data_; }
+ ///
+ private:
+ base_type data_;
+ };
+
+
#endif
///