]> git.lyx.org Git - features.git/commitdiff
Name change CharStyle -> Flex
authorMartin Vermeer <martin.vermeer@hut.fi>
Wed, 5 Sep 2007 15:29:04 +0000 (15:29 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Wed, 5 Sep 2007 15:29:04 +0000 (15:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20072 a592a061-630c-0410-9148-cb99ea01b6c8

13 files changed:
src/CutAndPaste.cpp
src/LaTeXFeatures.cpp
src/Text3.cpp
src/TextClass.cpp
src/TextClass.h
src/factory.cpp
src/insets/Inset.cpp
src/insets/Inset.h
src/insets/InsetCharStyle.cpp [deleted file]
src/insets/InsetCharStyle.h [deleted file]
src/insets/InsetCollapsable.cpp
src/insets/InsetFlex.cpp [new file with mode: 0644]
src/insets/InsetFlex.h [new file with mode: 0644]

index d9f92ee1597f15d76cdc62d89d52e9ba374fe582..7aeed7a2cdd60f07f8dd005ca7bd91e0d9a7e6f8 100644 (file)
@@ -38,7 +38,7 @@
 #include "ParIterator.h"
 #include "Undo.h"
 
-#include "insets/InsetCharStyle.h"
+#include "insets/InsetFlex.h"
 #include "insets/InsetTabular.h"
 
 #include "mathed/MathData.h"
@@ -442,24 +442,24 @@ void switchBetweenClasses(TextClass_ptr const & c1,
        // 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));
                        } 
                }
index 06f65e566b6ea0303b322bdfe946fdc61b372402..44811fcfec248e008a26b4cb8346f8b3f77a1ffe 100644 (file)
@@ -719,11 +719,13 @@ docstring const LaTeXFeatures::getTClassPreamble() const
                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();
index d7dec77f53d16ee54265a5d378a6337c9c82ee21..9b826581d7a57c0357adeadee1b43877aa4a1773 100644 (file)
@@ -1681,7 +1681,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                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;
index dcff59a94541f8fbee64476934181882ea61b028..e663a8ff30810ea82ed62d2081ceb9daecceb701 100644 (file)
@@ -694,6 +694,7 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
                case IL_FONT:
                        font.lyxRead(lexrc);
                        font.realize(defaultfont());
+                       // So: define font before labelfont
                        labelfont = font;
                        break;
                case IL_BGCOLOR: {
index 699dae557d020701a92c8dea56138f4558c463df..d9a13e84c49baa9a35b6e7ec175acc65b7595e0e 100644 (file)
@@ -46,9 +46,6 @@ public:
 };
 
 
-/// List of semantically defined character style insets
-typedef std::vector<InsetLayout> CharStyles;
-
 /// List of inset layouts
 typedef std::map<docstring, InsetLayout> InsetLayouts;
 
@@ -115,8 +112,6 @@ public:
        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_; };
        ///
@@ -254,8 +249,6 @@ private:
 
        /// 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_;
index 30c822603e6f1dc74122e38da2706b5999813823..f3c85532d80777decfdb0aecb0ff493c911623d8 100644 (file)
@@ -26,7 +26,7 @@
 #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"
@@ -106,7 +106,7 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd)
                        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: {
@@ -474,7 +474,7 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
                        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()));
index 033764b307f055b44b962cf6f0da6fefe664492a..0995a7a0f8a2943658d48ed581dbe2b61d9ba104 100644 (file)
@@ -98,7 +98,7 @@ static TranslatorMap const build_translator()
                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),
index 6b2b14a7310c12f99beecbb4fbfd210dfff44cb1..d8c9622fd05fc2fae4175edb58ba786d1cc1fce5 100644 (file)
@@ -352,7 +352,7 @@ public:
                ///
                BOX_CODE,
                ///
-               CHARSTYLE_CODE,
+               FLEX_CODE,
                ///
                VSPACE_CODE,
                ///
diff --git a/src/insets/InsetCharStyle.cpp b/src/insets/InsetCharStyle.cpp
deleted file mode 100644 (file)
index 079d872..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/**
- * \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
diff --git a/src/insets/InsetCharStyle.h b/src/insets/InsetCharStyle.h
deleted file mode 100644 (file)
index 7364593..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-// -*- 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
index 3cd5c58c716a5d5fcae8fcb243eaae7a7bcc059b..6ae8229c8530c1086e023b17de760411d8e4b80e 100644 (file)
@@ -639,7 +639,7 @@ InsetCollapsable::Decoration InsetCollapsable::decoration() const
                return Minimalistic;
        if (layout_.decoration == "conglomerate")
                return Conglomerate;
-       if (name() == from_ascii("CharStyle"))
+       if (name() == from_ascii("Flex"))
                return Conglomerate;
        return Classic;
 }
@@ -680,7 +680,7 @@ int InsetCollapsable::latex(Buffer const & buf, odocstream & os,
 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);
 }
 
diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp
new file mode 100644 (file)
index 0000000..ae0430d
--- /dev/null
@@ -0,0 +1,217 @@
+/**
+ * \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
diff --git a/src/insets/InsetFlex.h b/src/insets/InsetFlex.h
new file mode 100644 (file)
index 0000000..2a42bbe
--- /dev/null
@@ -0,0 +1,98 @@
+// -*- 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