* Inset and derivatives: insetName() -> name()

* InsetMath::name(): deleted.

* buffer_funcs.cpp:setCaptions() fix potential bug by using docstring copy instead of reference while using Inset::name.





git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18119 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-04-30 14:39:09 +00:00
parent 699fd5a7b4
commit 2640b21228
21 changed files with 22 additions and 36 deletions

View File

@ -82,7 +82,7 @@ void CoordCache::dump() const
for (CoordCacheBase<Inset>::cache_type::const_iterator it = getInsets().getData().begin(); it != getInsets().getData().end(); ++it) { for (CoordCacheBase<Inset>::cache_type::const_iterator it = getInsets().getData().begin(); it != getInsets().getData().end(); ++it) {
Inset const * inset = it->first; Inset const * inset = it->first;
Point const p = it->second; Point const p = it->second;
lyxerr << "Inset " << inset << "(" << to_utf8(inset->insetName()) lyxerr << "Inset " << inset << "(" << to_utf8(inset->name())
<< ") has point " << p.x_ << "," << p.y_ << std::endl; << ") has point " << p.x_ << "," << p.y_ << std::endl;
} }
} }

View File

@ -1820,7 +1820,7 @@ docstring Text::getPossibleLabel(Cursor & cur) const
if (!float_inset) if (!float_inset)
float_inset = cur.innerInsetOfType(Inset::WRAP_CODE); float_inset = cur.innerInsetOfType(Inset::WRAP_CODE);
if (float_inset) if (float_inset)
name = float_inset->insetName(); name = float_inset->name();
} }
// Create a correct prefix for prettyref // Create a correct prefix for prettyref

View File

@ -402,7 +402,7 @@ void setCaptions(Paragraph & par, TextClass const & textclass)
Inset & inset = *it->inset; Inset & inset = *it->inset;
if (inset.lyxCode() == Inset::FLOAT_CODE if (inset.lyxCode() == Inset::FLOAT_CODE
|| inset.lyxCode() == Inset::WRAP_CODE) { || inset.lyxCode() == Inset::WRAP_CODE) {
docstring const & name = inset.insetName(); docstring const name = inset.name();
if (name.empty()) if (name.empty())
continue; continue;
@ -559,13 +559,13 @@ void setLabel(Buffer const & buf, ParIterator & it, TextClass const & textclass)
break; break;
} }
} }
// FIXME Can insetName() return an empty name for wide or // FIXME Can Inset::name() return an empty name for wide or
// float insets? If not we can put the definition of type // float insets? If not we can put the definition of type
// inside the if (in) clause and use that instead of // inside the if (in) clause and use that instead of
// if (!type.empty()). // if (!type.empty()).
docstring type; docstring type;
if (in) if (in)
type = in->insetName(); type = in->name();
if (!type.empty()) { if (!type.empty()) {
Floating const & fl = textclass.floats().getType(to_ascii(type)); Floating const & fl = textclass.floats().getType(to_ascii(type));

View File

@ -133,12 +133,6 @@ std::auto_ptr<Inset> Inset::clone() const
} }
docstring Inset::insetName() const
{
return from_ascii("unknown");
}
Inset::Code Inset::translate(std::string const & name) Inset::Code Inset::translate(std::string const & name)
{ {
static TranslatorMap const translator = build_translator(); static TranslatorMap const translator = build_translator();

View File

@ -365,7 +365,7 @@ public:
virtual bool hasFixedWidth() const { return false; } virtual bool hasFixedWidth() const { return false; }
/// ///
virtual docstring insetName() const; virtual docstring name() const { return from_ascii("unknown"); }
/// used to toggle insets /// used to toggle insets
/// is the inset open? /// is the inset open?
/// should this inset be handled like a normal charater /// should this inset be handled like a normal charater

View File

@ -110,7 +110,7 @@ protected:
/// Is the width forced to some value? /// Is the width forced to some value?
virtual bool hasFixedWidth() const; virtual bool hasFixedWidth() const;
/// ///
virtual docstring insetName() const { return from_ascii("Box"); } virtual docstring name() const { return from_ascii("Box"); }
private: private:
friend class InsetBoxParams; friend class InsetBoxParams;

View File

@ -85,7 +85,7 @@ protected:
/// ///
virtual void doDispatch(Cursor & cur, FuncRequest & cmd); virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
/// ///
docstring insetName() const { return from_ascii("Branch"); } docstring name() const { return from_ascii("Branch"); }
private: private:
friend class InsetBranchParams; friend class InsetBranchParams;

View File

@ -53,7 +53,7 @@ public:
/// ///
InsetCharStyle(BufferParams const &, CharStyles::iterator); InsetCharStyle(BufferParams const &, CharStyles::iterator);
/// ///
docstring insetName() const { return from_ascii("CharStyle"); } docstring name() const { return from_ascii("CharStyle"); }
/// Is this character style defined in the document's textclass? /// Is this character style defined in the document's textclass?
/// May be wrong after textclass change or paste from another document /// May be wrong after textclass change or paste from another document
bool undefined() const; bool undefined() const;

View File

@ -44,7 +44,7 @@ public:
/// ///
InsetCollapsable(InsetCollapsable const & rhs); InsetCollapsable(InsetCollapsable const & rhs);
/// ///
docstring insetName() const { return from_ascii("Collapsable"); } docstring name() const { return from_ascii("Collapsable"); }
/// ///
void read(Buffer const &, Lexer &); void read(Buffer const &, Lexer &);
/// ///

View File

@ -44,7 +44,7 @@ public:
/// ///
Inset::Code lyxCode() const { return Inset::ERT_CODE; } Inset::Code lyxCode() const { return Inset::ERT_CODE; }
/// ///
docstring insetName() const { return from_ascii("ERT"); } docstring name() const { return from_ascii("ERT"); }
/// ///
void write(Buffer const & buf, std::ostream & os) const; void write(Buffer const & buf, std::ostream & os) const;
/// ///

View File

@ -49,7 +49,7 @@ auto_ptr<Inset> InsetEnvironment::doClone() const
void InsetEnvironment::write(Buffer const & buf, ostream & os) const void InsetEnvironment::write(Buffer const & buf, ostream & os) const
{ {
os << "Environment " << to_utf8(insetName()) << "\n"; os << "Environment " << to_utf8(name()) << "\n";
InsetText::write(buf, os); InsetText::write(buf, os);
} }
@ -62,7 +62,7 @@ void InsetEnvironment::read(Buffer const & buf, Lexer & lex)
docstring const InsetEnvironment::editMessage() const docstring const InsetEnvironment::editMessage() const
{ {
return _("Opened Environment Inset: ") + insetName(); return _("Opened Environment Inset: ") + name();
} }
@ -83,7 +83,7 @@ int InsetEnvironment::latex(Buffer const & buf, odocstream & os,
int InsetEnvironment::plaintext(Buffer const & buf, odocstream & os, int InsetEnvironment::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const OutputParams const & runparams) const
{ {
os << '[' << to_utf8(insetName()) << ":\n"; os << '[' << to_utf8(name()) << ":\n";
InsetText::plaintext(buf, os, runparams); InsetText::plaintext(buf, os, runparams);
os << "\n]"; os << "\n]";

View File

@ -23,7 +23,7 @@ public:
/// ///
InsetEnvironment(BufferParams const &, std::string const & name); InsetEnvironment(BufferParams const &, std::string const & name);
/// ///
docstring insetName() const { return name_; } docstring name() const { return name_; }
/// ///
void write(Buffer const & buf, std::ostream & os) const; void write(Buffer const & buf, std::ostream & os) const;
/// ///

View File

@ -49,7 +49,7 @@ public:
/// ///
~InsetFloat(); ~InsetFloat();
/// ///
docstring insetName() const { return name_; } docstring name() const { return name_; }
/// ///
void write(Buffer const & buf, std::ostream & os) const; void write(Buffer const & buf, std::ostream & os) const;
/// ///

View File

@ -28,7 +28,7 @@ public:
/// ///
Inset::Code lyxCode() const { return Inset::FOOT_CODE; } Inset::Code lyxCode() const { return Inset::FOOT_CODE; }
/// ///
docstring insetName() const { return from_ascii("Foot"); } docstring name() const { return from_ascii("Foot"); }
/// ///
int latex(Buffer const &, odocstream &, int latex(Buffer const &, odocstream &,
OutputParams const &) const; OutputParams const &) const;

View File

@ -67,7 +67,7 @@ void InsetFootlike::draw(PainterInfo & pi, int x, int y) const
void InsetFootlike::write(Buffer const & buf, std::ostream & os) const void InsetFootlike::write(Buffer const & buf, std::ostream & os) const
{ {
os << to_utf8(insetName()) << "\n"; os << to_utf8(name()) << "\n";
InsetCollapsable::write(buf, os); InsetCollapsable::write(buf, os);
} }

View File

@ -52,7 +52,7 @@ public:
/// ///
Inset::Code lyxCode() const { return Inset::NOTE_CODE; } Inset::Code lyxCode() const { return Inset::NOTE_CODE; }
/// ///
docstring insetName() const { return from_ascii("Note"); } docstring name() const { return from_ascii("Note"); }
/// ///
void write(Buffer const &, std::ostream &) const; void write(Buffer const &, std::ostream &) const;
/// ///

View File

@ -74,7 +74,7 @@ public:
/// Direct access to inner/outer quotation marks /// Direct access to inner/outer quotation marks
InsetQuotes(char_type c, quote_language l, quote_times t); InsetQuotes(char_type c, quote_language l, quote_times t);
/// ///
docstring insetName() const { return from_ascii("Quotes"); } docstring name() const { return from_ascii("Quotes"); }
/// ///
bool metrics(MetricsInfo &, Dimension &) const; bool metrics(MetricsInfo &, Dimension &) const;
/// ///

View File

@ -53,7 +53,7 @@ Inset.heorem::InsetTheorem()
void Inset.heorem::write(Buffer const * buf, ostream & os) const void Inset.heorem::write(Buffer const * buf, ostream & os) const
{ {
os << insetName() << "\n"; os << name() << "\n";
InsetCollapsable::write(buf, os); InsetCollapsable::write(buf, os);
} }

View File

@ -77,7 +77,7 @@ protected:
/// ///
virtual void doDispatch(Cursor & cur, FuncRequest & cmd); virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
/// ///
virtual docstring insetName() const { return name_; } virtual docstring name() const { return name_; }
private: private:
virtual std::auto_ptr<Inset> doClone() const; virtual std::auto_ptr<Inset> doClone() const;

View File

@ -139,12 +139,6 @@ HullType InsetMath::getType() const
} }
docstring InsetMath::name() const
{
return from_ascii("unknown");
}
std::ostream & operator<<(std::ostream & os, MathAtom const & at) std::ostream & operator<<(std::ostream & os, MathAtom const & at)
{ {
odocstringstream oss; odocstringstream oss;

View File

@ -195,8 +195,6 @@ public:
virtual HullType getType() const; virtual HullType getType() const;
/// change type /// change type
virtual void mutate(HullType /*newtype*/) {} virtual void mutate(HullType /*newtype*/) {}
/// usually the latex name
virtual docstring name() const;
/// math stuff usually isn't allowed in text mode /// math stuff usually isn't allowed in text mode
virtual bool allowedIn(mode_type mode) const { return mode == MATH_MODE; } virtual bool allowedIn(mode_type mode) const { return mode == MATH_MODE; }