mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 11:08:41 +00:00
Unicode: Avoid another from_utf8(to_utf8()) roundtrip
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15854 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d78c8a0b0b
commit
1354f4b6d6
@ -1175,9 +1175,9 @@ string LCursor::currentState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string LCursor::getPossibleLabel()
|
docstring LCursor::getPossibleLabel()
|
||||||
{
|
{
|
||||||
return inMathed() ? "eq:" : text()->getPossibleLabel(*this);
|
return inMathed() ? from_ascii("eq:") : text()->getPossibleLabel(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ public:
|
|||||||
/// display an error message
|
/// display an error message
|
||||||
void errorMessage(docstring const & msg) const;
|
void errorMessage(docstring const & msg) const;
|
||||||
///
|
///
|
||||||
std::string getPossibleLabel();
|
docstring getPossibleLabel();
|
||||||
|
|
||||||
/// moves position somehow up or down
|
/// moves position somehow up or down
|
||||||
bool goUpDown(bool up);
|
bool goUpDown(bool up);
|
||||||
|
@ -322,7 +322,7 @@ public:
|
|||||||
///
|
///
|
||||||
double spacing(Buffer const & buffer, Paragraph const & par) const;
|
double spacing(Buffer const & buffer, Paragraph const & par) const;
|
||||||
/// make a suggestion for a label
|
/// make a suggestion for a label
|
||||||
std::string getPossibleLabel(LCursor & cur) const;
|
docstring getPossibleLabel(LCursor & cur) const;
|
||||||
/// is this paragraph right-to-left?
|
/// is this paragraph right-to-left?
|
||||||
bool isRTL(Buffer const &, Paragraph const & par) const;
|
bool isRTL(Buffer const &, Paragraph const & par) const;
|
||||||
///
|
///
|
||||||
|
15
src/text.C
15
src/text.C
@ -2355,7 +2355,7 @@ string LyXText::currentState(LCursor & cur)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string LyXText::getPossibleLabel(LCursor & cur) const
|
docstring LyXText::getPossibleLabel(LCursor & cur) const
|
||||||
{
|
{
|
||||||
pit_type pit = cur.pit();
|
pit_type pit = cur.pit();
|
||||||
|
|
||||||
@ -2369,7 +2369,7 @@ string LyXText::getPossibleLabel(LCursor & cur) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string name = layout->latexname();
|
docstring name = from_ascii(layout->latexname());
|
||||||
|
|
||||||
// for captions, we want the abbreviation of the float type
|
// for captions, we want the abbreviation of the float type
|
||||||
if (layout->labeltype == LABEL_SENSITIVE) {
|
if (layout->labeltype == LABEL_SENSITIVE) {
|
||||||
@ -2378,26 +2378,25 @@ string LyXText::getPossibleLabel(LCursor & cur) const
|
|||||||
InsetBase * const in = &cur[i].inset();
|
InsetBase * const in = &cur[i].inset();
|
||||||
if (in->lyxCode() == InsetBase::FLOAT_CODE
|
if (in->lyxCode() == InsetBase::FLOAT_CODE
|
||||||
|| in->lyxCode() == InsetBase::WRAP_CODE) {
|
|| in->lyxCode() == InsetBase::WRAP_CODE) {
|
||||||
name = to_utf8(in->getInsetName());
|
name = in->getInsetName();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string text = name.substr(0, 3);
|
docstring text = name.substr(0, 3);
|
||||||
if (name == "theorem")
|
if (name == "theorem")
|
||||||
text = "thm"; // Create a correct prefix for prettyref
|
text = from_ascii("thm"); // Create a correct prefix for prettyref
|
||||||
|
|
||||||
text += ':';
|
text += ':';
|
||||||
if (layout->latextype == LATEX_PARAGRAPH || lyxrc.label_init_length < 0)
|
if (layout->latextype == LATEX_PARAGRAPH || lyxrc.label_init_length < 0)
|
||||||
text.erase();
|
text.erase();
|
||||||
|
|
||||||
// FIXME UNICODE
|
docstring par_text = pars_[pit].asString(cur.buffer(), false);
|
||||||
string par_text = to_utf8(pars_[pit].asString(cur.buffer(), false));
|
|
||||||
for (int i = 0; i < lyxrc.label_init_length; ++i) {
|
for (int i = 0; i < lyxrc.label_init_length; ++i) {
|
||||||
if (par_text.empty())
|
if (par_text.empty())
|
||||||
break;
|
break;
|
||||||
string head;
|
docstring head;
|
||||||
par_text = split(par_text, head, ' ');
|
par_text = split(par_text, head, ' ');
|
||||||
// Is it legal to use spaces in labels ?
|
// Is it legal to use spaces in labels ?
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
|
@ -1105,8 +1105,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
InsetCommandParams p("label");
|
InsetCommandParams p("label");
|
||||||
// Try to generate a valid label
|
// Try to generate a valid label
|
||||||
p["name"] = (cmd.argument().empty()) ?
|
p["name"] = (cmd.argument().empty()) ?
|
||||||
// FIXME UNICODE
|
cur.getPossibleLabel() :
|
||||||
from_utf8(cur.getPossibleLabel()) :
|
|
||||||
cmd.argument();
|
cmd.argument();
|
||||||
string const data = InsetCommandMailer::params2string("label", p);
|
string const data = InsetCommandMailer::params2string("label", p);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user