#include "ParIterator.h"
#include "Undo.h"
-#include "insets/InsetCharStyle.h"
+#include "insets/InsetFlex.h"
#include "insets/InsetTabular.h"
#include "mathed/MathData.h"
// character styles
InsetIterator const i_end = inset_iterator_end(in);
for (InsetIterator it = inset_iterator_begin(in); it != i_end; ++it) {
- if (it->lyxCode() == Inset::CHARSTYLE_CODE) {
- InsetCharStyle & inset =
- static_cast<InsetCharStyle &>(*it);
+ if (it->lyxCode() == Inset::FLEX_CODE) {
+ InsetFlex & inset =
+ static_cast<InsetFlex &>(*it);
string const name = inset.params().name;
InsetLayout const il =
tclass2.insetlayout(from_utf8(name));
inset.setLayout(il);
if (il.labelstring == from_utf8("UNDEFINED")) {
- // The character style is undefined in tclass2
+ // The flex inset is undefined in tclass2
docstring const s = bformat(_(
- "Character style %1$s is "
+ "Flex inset %1$s is "
"undefined because of class "
"conversion from\n%2$s to %3$s"),
from_utf8(name), from_utf8(tclass1.name()),
from_utf8(tclass2.name()));
// To warn the user that something had to be done.
errorlist.push_back(ErrorItem(
- _("Undefined character style"),
+ _("Undefined flex inset"),
s, it.paragraph().id(), it.pos(), it.pos() + 1));
}
}
tcpreamble << tclass[*cit]->preamble();
}
- CharStyles::iterator cs = tclass.charstyles().begin();
- CharStyles::iterator csend = tclass.charstyles().end();
- for (; cs != csend; ++cs) {
- if (isRequired(cs->name))
- tcpreamble << cs->preamble;
+ InsetLayouts const & insetlayouts = tclass.insetlayouts();
+ InsetLayouts::const_iterator cit2 = insetlayouts.begin();
+ InsetLayouts::const_iterator end2 = insetlayouts.end();
+ for (; cit2 != end2; ++cit2) {
+ if (isRequired(to_utf8(cit2->first))) {
+ tcpreamble << from_utf8(cit2->second.preamble);
+ }
}
return tcpreamble.str();
code = Inset::NOTE_CODE;
break;
case LFUN_CHARSTYLE_INSERT:
- code = Inset::CHARSTYLE_CODE;
+ code = Inset::FLEX_CODE;
if (cur.buffer().params().getTextClass().insetlayouts().empty())
enable = false;
break;
case IL_FONT:
font.lyxRead(lexrc);
font.realize(defaultfont());
+ // So: define font before labelfont
labelfont = font;
break;
case IL_BGCOLOR: {
};
-/// List of semantically defined character style insets
-typedef std::vector<InsetLayout> CharStyles;
-
/// List of inset layouts
typedef std::map<docstring, InsetLayout> InsetLayouts;
FloatList const & floats() const;
/// The Counters present in this document class.
Counters & counters() const;
- /// CharStyles of this doc class
- CharStyles & charstyles() const { return charstylelist_; };
/// Inset layouts of this doc class
InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
///
/// Paragraph styles used in this layout
LayoutList layoutlist_;
- /// CharStyles available to this layout
- mutable CharStyles charstylelist_;
/// Input layouts available to this layout
mutable InsetLayouts insetlayoutlist_;
#include "insets/InsetBibtex.h"
#include "insets/InsetCaption.h"
#include "insets/InsetCitation.h"
-#include "insets/InsetCharStyle.h"
+#include "insets/InsetFlex.h"
#include "insets/InsetEnvironment.h"
#include "insets/InsetERT.h"
#include "insets/InsetListings.h"
string s = cmd.getArg(0);
TextClass tclass = params.getTextClass();
InsetLayout il = tclass.insetlayout(from_utf8(s));
- return new InsetCharStyle(params, il);
+ return new InsetFlex(params, il);
}
case LFUN_NOTE_INSERT: {
lex.next();
string s = lex.getString();
InsetLayout il = tclass.insetlayout(from_utf8(s));
- inset.reset(new InsetCharStyle(buf.params(), il));
+ inset.reset(new InsetFlex(buf.params(), il));
} else if (tmptok == "Branch") {
inset.reset(new InsetBranch(buf.params(),
InsetBranchParams()));
InsetName("line", Inset::LINE_CODE),
InsetName("branch", Inset::BRANCH_CODE),
InsetName("box", Inset::BOX_CODE),
- InsetName("charstyle", Inset::CHARSTYLE_CODE),
+ InsetName("flex", Inset::FLEX_CODE),
InsetName("vspace", Inset::VSPACE_CODE),
InsetName("mathmacroarg", Inset::MATHMACROARG_CODE),
InsetName("listings", Inset::LISTINGS_CODE),
///
BOX_CODE,
///
- CHARSTYLE_CODE,
+ FLEX_CODE,
///
VSPACE_CODE,
///
+++ /dev/null
-/**
- * \file InsetCharStyle.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- * \author Martin Vermeer
- * \author Jürgen Spitzmüller
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "InsetCharStyle.h"
-
-#include "Buffer.h"
-#include "BufferParams.h"
-#include "BufferView.h"
-#include "DispatchResult.h"
-#include "FuncRequest.h"
-#include "FuncStatus.h"
-#include "Cursor.h"
-#include "gettext.h"
-#include "Color.h"
-#include "Lexer.h"
-#include "Text.h"
-#include "MetricsInfo.h"
-#include "Paragraph.h"
-#include "paragraph_funcs.h"
-#include "sgml.h"
-
-#include "frontends/FontMetrics.h"
-#include "frontends/Painter.h"
-
-#include "support/convert.h"
-
-#include <sstream>
-
-
-namespace lyx {
-
-using std::string;
-using std::ostream;
-
-
-InsetCharStyle::InsetCharStyle(BufferParams const & bp, string const s)
- : InsetCollapsable(bp, Collapsed)
-{
- params_.name = s;
-}
-
-
-InsetCharStyle::InsetCharStyle(BufferParams const & bp,
- InsetLayout il)
- : InsetCollapsable(bp, Collapsed)
-{
- params_.name = il.name;
- setLayout(il);
-}
-
-
-InsetCharStyle::InsetCharStyle(InsetCharStyle const & in)
- : InsetCollapsable(in), params_(in.params_)
-{}
-
-
-Inset * InsetCharStyle::clone() const
-{
- return new InsetCharStyle(*this);
-}
-
-
-bool InsetCharStyle::undefined() const
-{
- return layout_.labelstring == from_utf8("UNDEFINED");
-}
-
-
-void InsetCharStyle::setLayout(InsetLayout il)
-{
- layout_ = il;
-}
-
-
-docstring const InsetCharStyle::editMessage() const
-{
- return _("Opened CharStyle Inset");
-}
-
-
-void InsetCharStyle::write(Buffer const & buf, ostream & os) const
-{
- params_.write(os);
- InsetCollapsable::write(buf, os);
-}
-
-
-void InsetCharStyle::read(Buffer const & buf, Lexer & lex)
-{
- params_.read(lex);
- InsetCollapsable::read(buf, lex);
-}
-
-
-bool InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const
-{
- Font tmpfont = mi.base.font;
- getDrawFont(mi.base.font);
- mi.base.font.reduce(Font(Font::ALL_SANE));
- mi.base.font.realize(tmpfont);
- bool changed = InsetCollapsable::metrics(mi, dim);
- mi.base.font = tmpfont;
- return changed;
-}
-
-
-void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
-{
- setPosCache(pi, x, y);
-
- Font tmpfont = pi.base.font;
- getDrawFont(pi.base.font);
- // I don't understand why the above .reduce and .realize aren't
- //needed, or even wanted, here. It just works. -- MV 10.04.2005
- InsetCollapsable::draw(pi, x, y);
- pi.base.font = tmpfont;
-}
-
-
-void InsetCharStyle::getDrawFont(Font & font) const
-{
- font = layout_.font;
-}
-
-
-void InsetCharStyle::doDispatch(Cursor & cur, FuncRequest & cmd)
-{
- InsetCollapsable::doDispatch(cur, cmd);
-}
-
-
-bool InsetCharStyle::getStatus(Cursor & cur, FuncRequest const & cmd,
- FuncStatus & status) const
-{
- switch (cmd.action) {
- // paragraph breaks not allowed in charstyle insets
- case LFUN_BREAK_PARAGRAPH:
- case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
- case LFUN_BREAK_PARAGRAPH_SKIP:
- status.enabled(false);
- return true;
-
- default:
- return InsetCollapsable::getStatus(cur, cmd, status);
- }
-}
-
-
-int InsetCharStyle::plaintext(Buffer const & buf, odocstream & os,
- OutputParams const & runparams) const
-{
- return InsetText::plaintext(buf, os, runparams);
-}
-
-
-int InsetCharStyle::docbook(Buffer const & buf, odocstream & os,
- OutputParams const & runparams) const
-{
- ParagraphList::const_iterator beg = paragraphs().begin();
- ParagraphList::const_iterator par = paragraphs().begin();
- ParagraphList::const_iterator end = paragraphs().end();
-
- if (!undefined())
- // FIXME UNICODE
- sgml::openTag(os, layout_.latexname,
- par->getID(buf, runparams) + layout_.latexparam);
-
- for (; par != end; ++par) {
- par->simpleDocBookOnePar(buf, os, runparams,
- outerFont(std::distance(beg, par),
- paragraphs()));
- }
-
- if (!undefined())
- sgml::closeTag(os, layout_.latexname);
-
- return 0;
-}
-
-
-void InsetCharStyle::textString(Buffer const & buf, odocstream & os) const
-{
- os << paragraphs().begin()->asString(buf, true);
-}
-
-
-void InsetCharStyleParams::write(ostream & os) const
-{
- os << "CharStyle " << name << "\n";
-}
-
-
-void InsetCharStyleParams::read(Lexer & lex)
-{
- while (lex.isOK()) {
- lex.next();
- string token = lex.getString();
-
- if (token == "CharStyle") {
- lex.next();
- name = lex.getString();
- }
-
- // This is handled in Collapsable
- else if (token == "status") {
- lex.pushToken(token);
- break;
- }
- }
-}
-
-
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file InsetCharStyle.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- * \author Martin Vermeer
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef INSETCHARSTYLE_H
-#define INSETCHARSTYLE_H
-
-#include "InsetCollapsable.h"
-#include "TextClass.h"
-
-
-namespace lyx {
-
-
-class InsetCharStyleParams {
-public:
- ///
- void write(std::ostream & os) const;
- ///
- void read(Lexer & lex);
- ///
- std::string name;
-};
-
-
-/** The CharStyle inset, also XML short element
-
-*/
-class InsetCharStyle : public InsetCollapsable {
-public:
- /// Construct an undefined character style
- InsetCharStyle(BufferParams const &, std::string const);
- ///
- InsetCharStyle(BufferParams const &, InsetLayout);
- ///
- docstring name() const { return from_ascii("CharStyle"); }
- /// Is this character style defined in the document's textclass?
- /// May be wrong after textclass change or paste from another document
- bool undefined() const;
- /// (Re-)set the character style parameters from \p il
- void setLayout(InsetLayout il);
- ///
- virtual docstring const editMessage() const;
- ///
- Inset::Code lyxCode() const { return Inset::CHARSTYLE_CODE; }
- ///
- void write(Buffer const &, std::ostream &) const;
- ///
- void read(Buffer const & buf, Lexer & lex);
- ///
- bool metrics(MetricsInfo &, Dimension &) const;
- ///
- void draw(PainterInfo &, int, int) const;
- ///
- void getDrawFont(Font &) const;
- ///
- bool forceDefaultParagraphs(idx_type) const { return true; }
-
- ///
- int plaintext(Buffer const &, odocstream &,
- OutputParams const &) const;
- ///
- int docbook(Buffer const &, odocstream &,
- OutputParams const &) const;
- /// the string that is passed to the TOC
- virtual void textString(Buffer const &, odocstream &) const;
-
- ///
- InsetCharStyleParams const & params() const { return params_; }
-
- /// should paragraph indendation be ommitted in any case?
- bool neverIndent(Buffer const &) const { return true; }
-
-protected:
- InsetCharStyle(InsetCharStyle const &);
- virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
- ///
- bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
-
-private:
- friend class InsetCharStyleParams;
-
- virtual Inset * clone() const;
-
- ///
- InsetCharStyleParams params_;
-};
-
-
-} // namespace lyx
-
-#endif
return Minimalistic;
if (layout_.decoration == "conglomerate")
return Conglomerate;
- if (name() == from_ascii("CharStyle"))
+ if (name() == from_ascii("Flex"))
return Conglomerate;
return Classic;
}
void InsetCollapsable::validate(LaTeXFeatures & features) const
{
// Force inclusion of preamble snippet in layout file
- features.addPreambleSnippet(layout_.preamble);
+ features.require(layout_.name);
InsetText::validate(features);
}
--- /dev/null
+/**
+ * \file InsetFlex.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ * \author Martin Vermeer
+ * \author Jürgen Spitzmüller
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "InsetFlex.h"
+
+#include "Buffer.h"
+#include "BufferParams.h"
+#include "BufferView.h"
+#include "DispatchResult.h"
+#include "FuncRequest.h"
+#include "FuncStatus.h"
+#include "Cursor.h"
+#include "gettext.h"
+#include "Color.h"
+#include "Lexer.h"
+#include "Text.h"
+#include "MetricsInfo.h"
+#include "Paragraph.h"
+#include "paragraph_funcs.h"
+#include "sgml.h"
+
+#include "frontends/FontMetrics.h"
+#include "frontends/Painter.h"
+
+#include "support/convert.h"
+
+#include <sstream>
+
+
+namespace lyx {
+
+using std::string;
+using std::ostream;
+
+
+InsetFlex::InsetFlex(BufferParams const & bp,
+ InsetLayout il)
+ : InsetCollapsable(bp, Collapsed)
+{
+ params_.name = il.name;
+ setLayout(il);
+}
+
+
+InsetFlex::InsetFlex(InsetFlex const & in)
+ : InsetCollapsable(in), params_(in.params_)
+{}
+
+
+Inset * InsetFlex::clone() const
+{
+ return new InsetFlex(*this);
+}
+
+
+bool InsetFlex::undefined() const
+{
+ return layout_.labelstring == from_utf8("UNDEFINED");
+}
+
+
+void InsetFlex::setLayout(InsetLayout il)
+{
+ layout_ = il;
+}
+
+
+docstring const InsetFlex::editMessage() const
+{
+ return _("Opened CharStyle Inset");
+}
+
+
+void InsetFlex::write(Buffer const & buf, ostream & os) const
+{
+ params_.write(os);
+ InsetCollapsable::write(buf, os);
+}
+
+
+void InsetFlex::read(Buffer const & buf, Lexer & lex)
+{
+ params_.read(lex);
+ InsetCollapsable::read(buf, lex);
+}
+
+
+bool InsetFlex::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+ Font tmpfont = mi.base.font;
+ getDrawFont(mi.base.font);
+ mi.base.font.reduce(Font(Font::ALL_SANE));
+ mi.base.font.realize(tmpfont);
+ bool changed = InsetCollapsable::metrics(mi, dim);
+ mi.base.font = tmpfont;
+ return changed;
+}
+
+
+void InsetFlex::draw(PainterInfo & pi, int x, int y) const
+{
+ setPosCache(pi, x, y);
+
+ Font tmpfont = pi.base.font;
+ getDrawFont(pi.base.font);
+ // I don't understand why the above .reduce and .realize aren't
+ //needed, or even wanted, here. It just works. -- MV 10.04.2005
+ InsetCollapsable::draw(pi, x, y);
+ pi.base.font = tmpfont;
+}
+
+
+void InsetFlex::getDrawFont(Font & font) const
+{
+ font = layout_.font;
+}
+
+
+void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd)
+{
+ InsetCollapsable::doDispatch(cur, cmd);
+}
+
+
+bool InsetFlex::getStatus(Cursor & cur, FuncRequest const & cmd,
+ FuncStatus & status) const
+{
+ switch (cmd.action) {
+ // paragraph breaks not allowed in charstyle insets
+ case LFUN_BREAK_PARAGRAPH:
+ case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
+ case LFUN_BREAK_PARAGRAPH_SKIP:
+ status.enabled(false);
+ return true;
+
+ default:
+ return InsetCollapsable::getStatus(cur, cmd, status);
+ }
+}
+
+
+int InsetFlex::plaintext(Buffer const & buf, odocstream & os,
+ OutputParams const & runparams) const
+{
+ return InsetText::plaintext(buf, os, runparams);
+}
+
+
+int InsetFlex::docbook(Buffer const & buf, odocstream & os,
+ OutputParams const & runparams) const
+{
+ ParagraphList::const_iterator beg = paragraphs().begin();
+ ParagraphList::const_iterator par = paragraphs().begin();
+ ParagraphList::const_iterator end = paragraphs().end();
+
+ if (!undefined())
+ // FIXME UNICODE
+ sgml::openTag(os, layout_.latexname,
+ par->getID(buf, runparams) + layout_.latexparam);
+
+ for (; par != end; ++par) {
+ par->simpleDocBookOnePar(buf, os, runparams,
+ outerFont(std::distance(beg, par),
+ paragraphs()));
+ }
+
+ if (!undefined())
+ sgml::closeTag(os, layout_.latexname);
+
+ return 0;
+}
+
+
+void InsetFlex::textString(Buffer const & buf, odocstream & os) const
+{
+ os << paragraphs().begin()->asString(buf, true);
+}
+
+
+void InsetFlexParams::write(ostream & os) const
+{
+ os << "CharStyle " << name << "\n";
+}
+
+
+void InsetFlexParams::read(Lexer & lex)
+{
+ while (lex.isOK()) {
+ lex.next();
+ string token = lex.getString();
+
+ if (token == "CharStyle") {
+ lex.next();
+ name = lex.getString();
+ }
+
+ // This is handled in Collapsable
+ else if (token == "status") {
+ lex.pushToken(token);
+ break;
+ }
+ }
+}
+
+
+} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file InsetFlex.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Angus Leeming
+ * \author Martin Vermeer
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef INSETFLEX_H
+#define INSETFLEX_H
+
+#include "InsetCollapsable.h"
+#include "TextClass.h"
+
+
+namespace lyx {
+
+
+class InsetFlexParams {
+public:
+ ///
+ void write(std::ostream & os) const;
+ ///
+ void read(Lexer & lex);
+ ///
+ std::string name;
+};
+
+
+/** The Flex inset, e.g., CharStyle, Custom inset or XML short element
+
+*/
+class InsetFlex : public InsetCollapsable {
+public:
+ ///
+ InsetFlex(BufferParams const &, InsetLayout);
+ ///
+ docstring name() const { return from_ascii("Flex"); }
+ /// Is this character style defined in the document's textclass?
+ /// May be wrong after textclass change or paste from another document
+ bool undefined() const;
+ /// (Re-)set the character style parameters from \p il
+ void setLayout(InsetLayout il);
+ ///
+ virtual docstring const editMessage() const;
+ ///
+ Inset::Code lyxCode() const { return Inset::FLEX_CODE; }
+ ///
+ void write(Buffer const &, std::ostream &) const;
+ ///
+ void read(Buffer const & buf, Lexer & lex);
+ ///
+ bool metrics(MetricsInfo &, Dimension &) const;
+ ///
+ void draw(PainterInfo &, int, int) const;
+ ///
+ void getDrawFont(Font &) const;
+ ///
+ bool forceDefaultParagraphs(idx_type) const { return true; }
+
+ ///
+ int plaintext(Buffer const &, odocstream &,
+ OutputParams const &) const;
+ ///
+ int docbook(Buffer const &, odocstream &,
+ OutputParams const &) const;
+ /// the string that is passed to the TOC
+ virtual void textString(Buffer const &, odocstream &) const;
+
+ ///
+ InsetFlexParams const & params() const { return params_; }
+
+ /// should paragraph indendation be ommitted in any case?
+ bool neverIndent(Buffer const &) const { return true; }
+
+protected:
+ InsetFlex(InsetFlex const &);
+ virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
+ ///
+ bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
+
+private:
+ friend class InsetFlexParams;
+
+ virtual Inset * clone() const;
+
+ ///
+ InsetFlexParams params_;
+};
+
+
+} // namespace lyx
+
+#endif