From 12e1d4bc8d0fc7daa015e74028be2d7b2860d69f Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Wed, 5 Sep 2007 15:29:04 +0000 Subject: [PATCH] Name change CharStyle -> Flex git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20072 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/CutAndPaste.cpp | 14 +++--- src/LaTeXFeatures.cpp | 12 +++-- src/Text3.cpp | 2 +- src/TextClass.cpp | 1 + src/TextClass.h | 7 --- src/factory.cpp | 6 +-- src/insets/Inset.cpp | 2 +- src/insets/Inset.h | 2 +- src/insets/InsetCollapsable.cpp | 4 +- .../{InsetCharStyle.cpp => InsetFlex.cpp} | 49 ++++++++----------- src/insets/{InsetCharStyle.h => InsetFlex.h} | 28 +++++------ 11 files changed, 57 insertions(+), 70 deletions(-) rename src/insets/{InsetCharStyle.cpp => InsetFlex.cpp} (71%) rename src/insets/{InsetCharStyle.h => InsetFlex.h} (72%) diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index d9f92ee159..7aeed7a2cd 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -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(*it); + if (it->lyxCode() == Inset::FLEX_CODE) { + InsetFlex & inset = + static_cast(*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)); } } diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 06f65e566b..44811fcfec 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -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(); diff --git a/src/Text3.cpp b/src/Text3.cpp index d7dec77f53..9b826581d7 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -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; diff --git a/src/TextClass.cpp b/src/TextClass.cpp index dcff59a945..e663a8ff30 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -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: { diff --git a/src/TextClass.h b/src/TextClass.h index 699dae557d..d9a13e84c4 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -46,9 +46,6 @@ public: }; -/// List of semantically defined character style insets -typedef std::vector CharStyles; - /// List of inset layouts typedef std::map 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_; diff --git a/src/factory.cpp b/src/factory.cpp index 30c822603e..f3c85532d8 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -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())); diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index 033764b307..0995a7a0f8 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -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), diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 6b2b14a731..d8c9622fd0 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -352,7 +352,7 @@ public: /// BOX_CODE, /// - CHARSTYLE_CODE, + FLEX_CODE, /// VSPACE_CODE, /// diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 3cd5c58c71..6ae8229c85 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -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/InsetCharStyle.cpp b/src/insets/InsetFlex.cpp similarity index 71% rename from src/insets/InsetCharStyle.cpp rename to src/insets/InsetFlex.cpp index 079d872299..ae0430d07e 100644 --- a/src/insets/InsetCharStyle.cpp +++ b/src/insets/InsetFlex.cpp @@ -1,5 +1,5 @@ /** - * \file InsetCharStyle.cpp + * \file InsetFlex.cpp * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -12,7 +12,7 @@ #include -#include "InsetCharStyle.h" +#include "InsetFlex.h" #include "Buffer.h" #include "BufferParams.h" @@ -44,14 +44,7 @@ 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, +InsetFlex::InsetFlex(BufferParams const & bp, InsetLayout il) : InsetCollapsable(bp, Collapsed) { @@ -60,50 +53,50 @@ InsetCharStyle::InsetCharStyle(BufferParams const & bp, } -InsetCharStyle::InsetCharStyle(InsetCharStyle const & in) +InsetFlex::InsetFlex(InsetFlex const & in) : InsetCollapsable(in), params_(in.params_) {} -Inset * InsetCharStyle::clone() const +Inset * InsetFlex::clone() const { - return new InsetCharStyle(*this); + return new InsetFlex(*this); } -bool InsetCharStyle::undefined() const +bool InsetFlex::undefined() const { return layout_.labelstring == from_utf8("UNDEFINED"); } -void InsetCharStyle::setLayout(InsetLayout il) +void InsetFlex::setLayout(InsetLayout il) { layout_ = il; } -docstring const InsetCharStyle::editMessage() const +docstring const InsetFlex::editMessage() const { return _("Opened CharStyle Inset"); } -void InsetCharStyle::write(Buffer const & buf, ostream & os) const +void InsetFlex::write(Buffer const & buf, ostream & os) const { params_.write(os); InsetCollapsable::write(buf, os); } -void InsetCharStyle::read(Buffer const & buf, Lexer & lex) +void InsetFlex::read(Buffer const & buf, Lexer & lex) { params_.read(lex); InsetCollapsable::read(buf, lex); } -bool InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetFlex::metrics(MetricsInfo & mi, Dimension & dim) const { Font tmpfont = mi.base.font; getDrawFont(mi.base.font); @@ -115,7 +108,7 @@ bool InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const } -void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const +void InsetFlex::draw(PainterInfo & pi, int x, int y) const { setPosCache(pi, x, y); @@ -128,19 +121,19 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const } -void InsetCharStyle::getDrawFont(Font & font) const +void InsetFlex::getDrawFont(Font & font) const { font = layout_.font; } -void InsetCharStyle::doDispatch(Cursor & cur, FuncRequest & cmd) +void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd) { InsetCollapsable::doDispatch(cur, cmd); } -bool InsetCharStyle::getStatus(Cursor & cur, FuncRequest const & cmd, +bool InsetFlex::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const { switch (cmd.action) { @@ -157,14 +150,14 @@ bool InsetCharStyle::getStatus(Cursor & cur, FuncRequest const & cmd, } -int InsetCharStyle::plaintext(Buffer const & buf, odocstream & os, +int InsetFlex::plaintext(Buffer const & buf, odocstream & os, OutputParams const & runparams) const { return InsetText::plaintext(buf, os, runparams); } -int InsetCharStyle::docbook(Buffer const & buf, odocstream & os, +int InsetFlex::docbook(Buffer const & buf, odocstream & os, OutputParams const & runparams) const { ParagraphList::const_iterator beg = paragraphs().begin(); @@ -189,19 +182,19 @@ int InsetCharStyle::docbook(Buffer const & buf, odocstream & os, } -void InsetCharStyle::textString(Buffer const & buf, odocstream & os) const +void InsetFlex::textString(Buffer const & buf, odocstream & os) const { os << paragraphs().begin()->asString(buf, true); } -void InsetCharStyleParams::write(ostream & os) const +void InsetFlexParams::write(ostream & os) const { os << "CharStyle " << name << "\n"; } -void InsetCharStyleParams::read(Lexer & lex) +void InsetFlexParams::read(Lexer & lex) { while (lex.isOK()) { lex.next(); diff --git a/src/insets/InsetCharStyle.h b/src/insets/InsetFlex.h similarity index 72% rename from src/insets/InsetCharStyle.h rename to src/insets/InsetFlex.h index 7364593c8f..2a42bbed2b 100644 --- a/src/insets/InsetCharStyle.h +++ b/src/insets/InsetFlex.h @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * \file InsetCharStyle.h + * \file InsetFlex.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -10,8 +10,8 @@ * Full author contact details are available in file CREDITS. */ -#ifndef INSETCHARSTYLE_H -#define INSETCHARSTYLE_H +#ifndef INSETFLEX_H +#define INSETFLEX_H #include "InsetCollapsable.h" #include "TextClass.h" @@ -20,7 +20,7 @@ namespace lyx { -class InsetCharStyleParams { +class InsetFlexParams { public: /// void write(std::ostream & os) const; @@ -31,17 +31,15 @@ public: }; -/** The CharStyle inset, also XML short element +/** The Flex inset, e.g., CharStyle, Custom inset or XML short element */ -class InsetCharStyle : public InsetCollapsable { +class InsetFlex : public InsetCollapsable { public: - /// Construct an undefined character style - InsetCharStyle(BufferParams const &, std::string const); /// - InsetCharStyle(BufferParams const &, InsetLayout); + InsetFlex(BufferParams const &, InsetLayout); /// - docstring name() const { return from_ascii("CharStyle"); } + 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; @@ -50,7 +48,7 @@ public: /// virtual docstring const editMessage() const; /// - Inset::Code lyxCode() const { return Inset::CHARSTYLE_CODE; } + Inset::Code lyxCode() const { return Inset::FLEX_CODE; } /// void write(Buffer const &, std::ostream &) const; /// @@ -74,24 +72,24 @@ public: virtual void textString(Buffer const &, odocstream &) const; /// - InsetCharStyleParams const & params() const { return params_; } + InsetFlexParams const & params() const { return params_; } /// should paragraph indendation be ommitted in any case? bool neverIndent(Buffer const &) const { return true; } protected: - InsetCharStyle(InsetCharStyle const &); + InsetFlex(InsetFlex const &); virtual void doDispatch(Cursor & cur, FuncRequest & cmd); /// bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const; private: - friend class InsetCharStyleParams; + friend class InsetFlexParams; virtual Inset * clone() const; /// - InsetCharStyleParams params_; + InsetFlexParams params_; };