Name change CharStyle -> Flex

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20072 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Martin Vermeer 2007-09-05 15:29:04 +00:00
parent 67a2b3f28f
commit 12e1d4bc8d
11 changed files with 57 additions and 70 deletions

View 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));
}
}

View 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();

View 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;

View 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: {

View 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_;

View 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()));

View 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),

View File

@ -352,7 +352,7 @@ public:
///
BOX_CODE,
///
CHARSTYLE_CODE,
FLEX_CODE,
///
VSPACE_CODE,
///

View 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);
}

View File

@ -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 <config.h>
#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();

View File

@ -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_;
};