Allow unicode in Layout names.

* Layout.h:
  - name_, obsoleted_by_, depends_on_ are now docstrings.

All other changes results from the above string -> docstring changes. In particular, we now try to translate the layout names only if possible (i.e. if they are ASCII only).



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19042 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-07-11 13:39:08 +00:00
parent ba4214cbe9
commit 4a53fa6e01
25 changed files with 109 additions and 100 deletions

View File

@ -242,7 +242,7 @@ public:
std::string data)> updateDialog;
/// This signal is emitted when the layout at the cursor is changed.
boost::signal<void(std::string layout)> layoutChanged;
boost::signal<void(docstring layout)> layoutChanged;
private:
///

View File

@ -426,7 +426,7 @@ void switchBetweenClasses(textclass_type c1, textclass_type c2,
// layouts
ParIterator end = par_iterator_end(in);
for (ParIterator it = par_iterator_begin(in); it != end; ++it) {
string const name = it->layout()->name();
docstring const name = it->layout()->name();
bool hasLayout = tclass2.hasLayout(name);
if (hasLayout)
@ -438,7 +438,7 @@ void switchBetweenClasses(textclass_type c1, textclass_type c2,
docstring const s = bformat(
_("Layout had to be changed from\n%1$s to %2$s\n"
"because of class conversion from\n%3$s to %4$s"),
from_utf8(name), from_utf8(it->layout()->name()),
name, it->layout()->name(),
from_utf8(tclass1.name()), from_utf8(tclass2.name()));
// To warn the user that something had to be done.
errorlist.push_back(ErrorItem(_("Changed Layout"), s,

View File

@ -254,7 +254,7 @@ void LaTeXFeatures::getAvailable()
}
void LaTeXFeatures::useLayout(string const & layoutname)
void LaTeXFeatures::useLayout(docstring const & layoutname)
{
// Some code to avoid loops in dependency definition
static int level = 0;
@ -262,15 +262,15 @@ void LaTeXFeatures::useLayout(string const & layoutname)
if (level > maxlevel) {
lyxerr << "LaTeXFeatures::useLayout: maximum level of "
<< "recursion attained by layout "
<< layoutname << endl;
<< to_utf8(layoutname) << endl;
return;
}
TextClass const & tclass = params_.getTextClass();
if (tclass.hasLayout(layoutname)) {
// Is this layout already in usedLayouts?
list<string>::const_iterator cit = usedLayouts_.begin();
list<string>::const_iterator end = usedLayouts_.end();
list<docstring>::const_iterator cit = usedLayouts_.begin();
list<docstring>::const_iterator end = usedLayouts_.end();
for (; cit != end; ++cit) {
if (layoutname == *cit)
return;
@ -285,7 +285,7 @@ void LaTeXFeatures::useLayout(string const & layoutname)
usedLayouts_.push_back(layoutname);
} else {
lyxerr << "LaTeXFeatures::useLayout: layout `"
<< layoutname << "' does not exist in this class"
<< to_utf8(layoutname) << "' does not exist in this class"
<< endl;
}
@ -712,8 +712,8 @@ docstring const LaTeXFeatures::getTClassPreamble() const
tcpreamble << tclass.preamble();
list<string>::const_iterator cit = usedLayouts_.begin();
list<string>::const_iterator end = usedLayouts_.end();
list<docstring>::const_iterator cit = usedLayouts_.begin();
list<docstring>::const_iterator end = usedLayouts_.end();
for (; cit != end; ++cit) {
tcpreamble << tclass[*cit]->preamble();
}

View File

@ -91,7 +91,7 @@ public:
///
std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
///
void useLayout(std::string const & lyt);
void useLayout(docstring const & lyt);
///
Buffer const & buffer() const;
///
@ -104,7 +104,7 @@ public:
OutputParams const & runparams() const { return runparams_; }
private:
std::list<std::string> usedLayouts_;
std::list<docstring> usedLayouts_;
/// Static preamble bits from the external material insets
typedef std::list<std::string> FeaturesList;

View File

@ -212,16 +212,16 @@ bool Layout::read(Lexer & lexrc, TextClass const & tclass)
case LT_COPYSTYLE: // initialize with a known style
if (lexrc.next()) {
string const style = subst(lexrc.getString(),
docstring const style = subst(lexrc.getDocString(),
'_', ' ');
if (tclass.hasLayout(style)) {
string const tmpname = name_;
docstring const tmpname = name_;
this->operator=(*tclass[style]);
name_ = tmpname;
} else {
lyxerr << "Cannot copy unknown style `"
<< style << "'\n"
<< to_utf8(style) << "'\n"
<< "All layouts so far:"
<< endl;
TextClass::const_iterator it =
@ -229,7 +229,7 @@ bool Layout::read(Lexer & lexrc, TextClass const & tclass)
TextClass::const_iterator end =
tclass.end();
for (; it != end; ++it) {
lyxerr << (*it)->name()
lyxerr << to_utf8((*it)->name())
<< endl;
}
@ -241,16 +241,17 @@ bool Layout::read(Lexer & lexrc, TextClass const & tclass)
case LT_OBSOLETEDBY: // replace with a known style
if (lexrc.next()) {
string const style = lexrc.getString();
docstring const style = lexrc.getDocString();
if (tclass.hasLayout(style)) {
string const tmpname = name_;
docstring const tmpname = name_;
this->operator=(*tclass[style]);
name_ = tmpname;
if (obsoleted_by().empty())
obsoleted_by_ = style;
} else {
lyxerr << "Cannot replace with unknown style `" << style << '\'' << endl;
lyxerr << "Cannot replace with unknown style `"
<< to_utf8(style) << '\'' << endl;
//lexrc.printError("Cannot replace with"
// " unknown style "
@ -261,7 +262,7 @@ bool Layout::read(Lexer & lexrc, TextClass const & tclass)
case LT_DEPENDSON:
if (lexrc.next())
depends_on_ = lexrc.getString();
depends_on_ = lexrc.getDocString();
break;
case LT_MARGIN: // margin style definition.
@ -797,33 +798,34 @@ void Layout::readSpacing(Lexer & lexrc)
}
string const & Layout::name() const
docstring const & Layout::name() const
{
return name_;
}
void Layout::setName(string const & n)
void Layout::setName(docstring const & n)
{
name_ = n;
}
string const & Layout::obsoleted_by() const
docstring const & Layout::obsoleted_by() const
{
return obsoleted_by_;
}
string const & Layout::depends_on() const
docstring const & Layout::depends_on() const
{
return depends_on_;
}
Layout * Layout::forCaption()
{
Layout * lay = new Layout();
lay->name_ = "Caption";
lay->name_ = from_ascii("Caption");
lay->latexname_ = "caption";
lay->latextype = LATEX_COMMAND;
lay->optionalargs = 1;

View File

@ -188,13 +188,13 @@ public:
///
void readSpacing(Lexer &);
///
std::string const & name() const;
docstring const & name() const;
///
void setName(std::string const & n);
void setName(docstring const & n);
///
std::string const & obsoleted_by() const;
docstring const & obsoleted_by() const;
///
std::string const & depends_on() const;
docstring const & depends_on() const;
///
std::string const & latexname() const { return latexname_; }
///
@ -345,19 +345,19 @@ public:
private:
/// Name of the layout/paragraph environment
std::string name_;
docstring name_;
/** Name of an layout that has replaced this layout.
This is used to rename a layout, while keeping backward
compatibility
*/
std::string obsoleted_by_;
docstring obsoleted_by_;
/** Name of an layout which preamble must come before this one
This is used when the preamble snippet uses macros defined in
another preamble
*/
std::string depends_on_;
docstring depends_on_;
/// LaTeX name for environment
std::string latexname_;

View File

@ -1110,7 +1110,7 @@ void Paragraph::write(Buffer const & buf, ostream & os,
}
// First write the layout
os << "\n\\begin_layout " << layout()->name() << '\n';
os << "\n\\begin_layout " << to_utf8(layout()->name()) << '\n';
params().write(os);
@ -1640,8 +1640,7 @@ docstring Paragraph::expandLabel(Layout_ptr const & layout,
size_t const j = fmt.find('@', i + 1);
if (j != docstring::npos) {
docstring parent(fmt, i + 1, j - i - 1);
// FIXME UNICODE
docstring label = expandLabel(tclass[to_utf8(parent)], bparams);
docstring label = expandLabel(tclass[parent], bparams);
fmt = docstring(fmt, 0, i) + label + docstring(fmt, j + 1, docstring::npos);
}
}

View File

@ -118,7 +118,7 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
#endif
} else if (token == "\\begin_layout") {
lex.eatLine();
string layoutname = lex.getString();
docstring layoutname = lex.getDocString();
font = Font(Font::ALL_INHERIT, bp.language);
change = Change(Change::UNCHANGED);
@ -134,7 +134,7 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
if (!hasLayout) {
errorList.push_back(ErrorItem(_("Unknown layout"),
bformat(_("Layout '%1$s' does not exist in textclass '%2$s'\nTrying to use the default instead.\n"),
from_utf8(layoutname), from_utf8(tclass.name())), par.id(), 0, par.size()));
layoutname, from_utf8(tclass.name())), par.id(), 0, par.size()));
layoutname = tclass.defaultLayoutName();
}

View File

@ -81,10 +81,10 @@ public:
/// set layout over selection
void setLayout(Buffer const & buffer, pit_type start, pit_type end,
std::string const & layout);
docstring const & layout);
/// Set given layout to current cursor position.
/// FIXME: replace Cursor with DocIterator.
void setLayout(Cursor & cur, std::string const & layout);
void setLayout(Cursor & cur, docstring const & layout);
/// what type of depth change to make
enum DEPTH_CHANGE {

View File

@ -358,7 +358,7 @@ pit_type Text::undoSpan(pit_type pit)
void Text::setLayout(Buffer const & buffer, pit_type start, pit_type end,
string const & layout)
docstring const & layout)
{
BOOST_ASSERT(start != end);
@ -376,7 +376,7 @@ void Text::setLayout(Buffer const & buffer, pit_type start, pit_type end,
// set layout over selection and make a total rebreak of those paragraphs
void Text::setLayout(Cursor & cur, string const & layout)
void Text::setLayout(Cursor & cur, docstring const & layout)
{
BOOST_ASSERT(this == cur.text());
// special handling of new environment insets
@ -385,7 +385,7 @@ void Text::setLayout(Cursor & cur, string const & layout)
Layout_ptr const & lyxlayout = params.getTextClass()[layout];
if (lyxlayout->is_environment) {
// move everything in a new environment inset
LYXERR(Debug::DEBUG) << "setting layout " << layout << endl;
LYXERR(Debug::DEBUG) << "setting layout " << to_utf8(layout) << endl;
lyx::dispatch(FuncRequest(LFUN_LINE_BEGIN));
lyx::dispatch(FuncRequest(LFUN_LINE_END_SELECT));
lyx::dispatch(FuncRequest(LFUN_CUT));

View File

@ -89,7 +89,7 @@ using std::istringstream;
using std::ostringstream;
extern string current_layout;
extern docstring current_layout;
namespace {
@ -399,6 +399,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// Should LFUN_APPENDIX be restricted to top-level paragraphs?
#endif
// ensure that we have only one start_of_appendix in this document
// FIXME: this don't work for multipart document!
for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
if (pars_[tmp].params().startOfAppendix()) {
recUndo(cur, tmp);
@ -868,12 +869,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
break;
case LFUN_SERVER_GET_LAYOUT:
cur.message(from_utf8(cur.paragraph().layout()->name()));
cur.message(cur.paragraph().layout()->name());
break;
case LFUN_LAYOUT: {
string layout = to_ascii(cmd.argument());
LYXERR(Debug::INFO) << "LFUN_LAYOUT: (arg) " << layout << endl;
docstring layout = cmd.argument();
LYXERR(Debug::INFO) << "LFUN_LAYOUT: (arg) " << to_utf8(layout) << endl;
// Derive layout number from given argument (string)
// and current buffer's textclass (number)
@ -884,7 +885,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// If the entry is obsolete, use the new one instead.
if (hasLayout) {
string const & obs = tclass[layout]->obsoleted_by();
docstring const & obs = tclass[layout]->obsoleted_by();
if (!obs.empty())
layout = obs;
}

View File

@ -18,9 +18,12 @@
#include "debug.h"
#include "Lexer.h"
#include "Counters.h"
#include "gettext.h"
#include "Floating.h"
#include "FloatList.h"
#include "frontends/alert.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
#include "support/filetools.h"
@ -53,7 +56,7 @@ namespace {
class LayoutNamesEqual : public std::unary_function<Layout_ptr, bool> {
public:
LayoutNamesEqual(string const & name)
LayoutNamesEqual(docstring const & name)
: name_(name)
{}
bool operator()(Layout_ptr const & c) const
@ -61,7 +64,7 @@ public:
return c->name() == name_;
}
private:
string name_;
docstring name_;
};
@ -127,7 +130,7 @@ bool TextClass::isTeXClassAvailable() const
bool TextClass::do_readStyle(Lexer & lexrc, Layout & lay)
{
LYXERR(Debug::TCLASS) << "Reading style " << lay.name() << endl;
LYXERR(Debug::TCLASS) << "Reading style " << to_utf8(lay.name()) << endl;
if (!lay.read(lexrc, *this)) {
// Resolve fonts
lay.resfont = lay.font;
@ -136,7 +139,7 @@ bool TextClass::do_readStyle(Lexer & lexrc, Layout & lay)
lay.reslabelfont.realize(defaultfont());
return false; // no errors
}
lyxerr << "Error parsing style `" << lay.name() << '\'' << endl;
lyxerr << "Error parsing style `" << to_utf8(lay.name()) << '\'' << endl;
return true;
}
@ -271,8 +274,8 @@ bool TextClass::read(FileName const & filename, bool merge)
case TC_DEFAULTSTYLE:
if (lexrc.next()) {
string const name = subst(lexrc.getString(),
'_', ' ');
docstring const name = from_utf8(subst(lexrc.getString(),
'_', ' '));
defaultlayout_ = name;
}
break;
@ -280,9 +283,15 @@ bool TextClass::read(FileName const & filename, bool merge)
case TC_ENVIRONMENT:
case TC_STYLE:
if (lexrc.next()) {
string const name = subst(lexrc.getString(),
'_', ' ');
if (hasLayout(name)) {
docstring const name = from_utf8(subst(lexrc.getString(),
'_', ' '));
if (name.empty()) {
string s = "Could not read name for style: `$$Token' "
+ lexrc.getString() + " is probably not valid UTF-8!";
lexrc.printError(s.c_str());
Layout lay;
error = do_readStyle(lexrc, lay);
} else if (hasLayout(name)) {
Layout * lay = operator[](name).get();
error = do_readStyle(lexrc, *lay);
} else {
@ -313,11 +322,11 @@ bool TextClass::read(FileName const & filename, bool merge)
case TC_NOSTYLE:
if (lexrc.next()) {
string const style = subst(lexrc.getString(),
'_', ' ');
docstring const style = from_utf8(subst(lexrc.getString(),
'_', ' '));
if (!delete_layout(style))
lyxerr << "Cannot delete style `"
<< style << '\'' << endl;
<< to_utf8(style) << '\'' << endl;
// lexrc.printError("Cannot delete style"
// " `$$Token'");
}
@ -850,9 +859,9 @@ string const & TextClass::rightmargin() const
}
bool TextClass::hasLayout(string const & n) const
bool TextClass::hasLayout(docstring const & n) const
{
string const name = (n.empty() ? defaultLayoutName() : n);
docstring const name = n.empty() ? defaultLayoutName() : n;
return find_if(layoutlist_.begin(), layoutlist_.end(),
LayoutNamesEqual(name))
@ -861,7 +870,7 @@ bool TextClass::hasLayout(string const & n) const
Layout_ptr const & TextClass::operator[](string const & name) const
Layout_ptr const & TextClass::operator[](docstring const & name) const
{
BOOST_ASSERT(!name.empty());
@ -871,12 +880,12 @@ Layout_ptr const & TextClass::operator[](string const & name) const
LayoutNamesEqual(name));
if (cit == layoutlist_.end()) {
lyxerr << "We failed to find the layout '" << name
lyxerr << "We failed to find the layout '" << to_utf8(name)
<< "' in the layout list. You MUST investigate!"
<< endl;
for (LayoutList::const_iterator it = layoutlist_.begin();
it != layoutlist_.end(); ++it)
lyxerr << " " << it->get()->name() << endl;
lyxerr << " " << to_utf8(it->get()->name()) << endl;
// we require the name to exist
BOOST_ASSERT(false);
@ -887,7 +896,7 @@ Layout_ptr const & TextClass::operator[](string const & name) const
bool TextClass::delete_layout(string const & name)
bool TextClass::delete_layout(docstring const & name)
{
if (name == defaultLayoutName())
return false;
@ -959,7 +968,7 @@ CharStyles::iterator TextClass::charstyle(string const & s) const
}
string const & TextClass::defaultLayoutName() const
docstring const & TextClass::defaultLayoutName() const
{
// This really should come from the actual layout... (Lgb)
return defaultlayout_;

View File

@ -83,10 +83,10 @@ public:
///
void readCounter(Lexer &);
///
bool hasLayout(std::string const & name) const;
bool hasLayout(docstring const & name) const;
///
Layout_ptr const & operator[](std::string const & vname) const;
Layout_ptr const & operator[](docstring const & vname) const;
/// Sees to that the textclass structure has been loaded
bool load(std::string const & path = std::string()) const;
@ -104,7 +104,7 @@ public:
/// Retrieve element of name s:
CharStyles::iterator charstyle(std::string const & s) const;
///
std::string const & defaultLayoutName() const;
docstring const & defaultLayoutName() const;
///
Layout_ptr const & defaultLayout() const;
///
@ -172,7 +172,7 @@ public:
bool hasTocLevels() const;
private:
///
bool delete_layout(std::string const &);
bool delete_layout(docstring const &);
///
bool do_readStyle(Lexer &, Layout &);
/// Layout file name
@ -192,7 +192,7 @@ private:
///
std::string class_header_;
///
std::string defaultlayout_;
docstring defaultlayout_;
/// preamble text to support layout styles
docstring preamble_;
/// latex packages loaded by document class.

View File

@ -228,7 +228,7 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd)
return new InsetTOC(InsetCommandParams("tableofcontents"));
case LFUN_ENVIRONMENT_INSERT:
return new InsetEnvironment(params, to_utf8(cmd.argument()));
return new InsetEnvironment(params, cmd.argument());
#if 0
case LFUN_LIST_INSERT:
@ -491,7 +491,7 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
inset.reset(new InsetInclude(p));
} else if (tmptok == "Environment") {
lex.next();
inset.reset(new InsetEnvironment(buf.params(), lex.getString()));
inset.reset(new InsetEnvironment(buf.params(), lex.getDocString()));
} else if (tmptok == "ERT") {
inset.reset(new InsetERT(buf.params()));
} else if (tmptok == "listings") {

View File

@ -68,7 +68,7 @@ using std::string;
using lyx::frontend::ControlCommandBuffer;
string current_layout;
docstring current_layout;
LyXView::LyXView(int id)
@ -473,7 +473,7 @@ void LyXView::updateLayoutChoice()
}
BOOST_ASSERT(work_area_);
string const & layout = work_area_->bufferView().cursor().
docstring const & layout = work_area_->bufferView().cursor().
innerParagraph().layout()->name();
if (layout != current_layout) {

View File

@ -278,7 +278,7 @@ void Toolbars::saveToolbarInfo()
}
void Toolbars::setLayout(string const & layout)
void Toolbars::setLayout(docstring const & layout)
{
if (layout_)
layout_->set(layout);
@ -356,16 +356,15 @@ void Toolbars::update()
}
void layoutSelected(LyXView & lv, string const & name)
void layoutSelected(LyXView & lv, docstring const & name)
{
TextClass const & tc = lv.buffer()->params().getTextClass();
TextClass::const_iterator it = tc.begin();
TextClass::const_iterator const end = tc.end();
for (; it != end; ++it) {
string const & itname = (*it)->name();
// Yes, the lyx::to_utf8(_()) is correct
if (lyx::to_utf8(_(itname)) == name) {
docstring const & itname = (*it)->name();
if (translateIfPossible(itname) == name) {
FuncRequest const func(LFUN_LAYOUT, itname,
FuncRequest::TOOLBAR);
lv.dispatch(func);

View File

@ -37,7 +37,7 @@ class LayoutBox {
public:
virtual ~LayoutBox() {}
/// Select the correct layout in the combox.
virtual void set(std::string const & layout) = 0;
virtual void set(docstring const & layout) = 0;
/// Populate the layout combox.
virtual void update() = 0;
/// Erase the layout list.
@ -108,7 +108,7 @@ public:
void saveToolbarInfo();
/// Select the right layout in the combox.
void setLayout(std::string const & layout);
void setLayout(docstring const & layout);
/** Populate the layout combox - returns whether we did a full
* update or not
@ -155,7 +155,7 @@ private:
};
/// Set the layout in the kernel when an entry has been selected
void layoutSelected(LyXView & lv, std::string const & name);
void layoutSelected(LyXView & lv, docstring const & name);
} // namespace lyx

View File

@ -852,7 +852,7 @@ void QDocumentDialog::updateNumbering()
if (toclevel != Layout::NOT_IN_TOC
&& (*cit)->labeltype == LABEL_COUNTER) {
item = new QTreeWidgetItem(numberingModule->tocTW);
item->setText(0, qt_((*cit)->name()));
item->setText(0, toqstr(translateIfPossible((*cit)->name())));
item->setText(1, (toclevel <= depth) ? yes : no);
item->setText(2, (toclevel <= toc) ? yes : no);
}

View File

@ -81,11 +81,11 @@ QLayoutBox::QLayoutBox(QToolBar * toolbar, GuiView & owner)
}
void QLayoutBox::set(string const & layout)
void QLayoutBox::set(docstring const & layout)
{
TextClass const & tc = getTextClass(owner_);
QString const & name = qt_(tc[layout]->name());
QString const & name = toqstr(translateIfPossible(tc[layout]->name()));
int i = 0;
for (; i < combo_->count(); ++i) {
@ -116,7 +116,7 @@ void QLayoutBox::update()
for (; it != end; ++it) {
// ignore obsolete entries
if ((*it)->obsoleted_by().empty())
combo_->addItem(qt_((*it)->name()));
combo_->addItem(toqstr(translateIfPossible((*it)->name())));
}
// needed to recalculate size hint
@ -152,11 +152,9 @@ void QLayoutBox::setEnabled(bool enable)
void QLayoutBox::selected(const QString & str)
{
string const sel = fromqstr(str);
owner_.setFocus();
layoutSelected(owner_, sel);
layoutSelected(owner_, qstring_to_ucs4(str));
}

View File

@ -40,7 +40,7 @@ public:
QLayoutBox(QToolBar *, GuiView &);
/// select the right layout in the combox.
void set(std::string const & layout);
void set(docstring const & layout);
/// Populate the layout combox.
void update();
/// Erase the layout list.

View File

@ -27,8 +27,8 @@ using std::ostream;
InsetEnvironment::InsetEnvironment
(BufferParams const & bp, string const & name)
: InsetText(bp), layout_(bp.getTextClass()[name]), name_(from_utf8(name))
(BufferParams const & bp, docstring const & name)
: InsetText(bp), layout_(bp.getTextClass()[name]), name_(name)
{
setAutoBreakRows(true);
setDrawFrame(true);

View File

@ -21,7 +21,7 @@ namespace lyx {
class InsetEnvironment : public InsetText {
public:
///
InsetEnvironment(BufferParams const &, std::string const & name);
InsetEnvironment(BufferParams const &, docstring const & name);
///
docstring name() const { return name_; }
///

View File

@ -89,7 +89,7 @@ void writePlaintextParagraph(Buffer const & buf,
depth_type depth = par.params().depth();
// First write the layout
string const & tmp = par.layout()->name();
string const tmp = to_utf8(par.layout()->name());
if (compare_ascii_no_case(tmp, "itemize") == 0) {
ltype = 1;
ltype_depth = depth + 1;

View File

@ -28,7 +28,7 @@ namespace {
void begin_layout(ostream & os, Layout_ptr layout, TeXFont const & font,
TeXFont const & normalfont)
{
os << "\n\\begin_layout " << layout->name() << "\n";
os << "\n\\begin_layout " << to_utf8(layout->name()) << "\n";
// FIXME: This is not enough for things like
// \\Huge par1 \\par par2
output_font_change(os, normalfont, font);
@ -231,8 +231,8 @@ void Context::dump(ostream & os, string const & desc) const
if (!extra_stuff.empty())
os << "extrastuff=[" << extra_stuff << "] ";
os << "textclass=" << textclass.name()
<< " layout=" << layout->name()
<< " parent_layout=" << parent_layout->name() << "] font=["
<< " layout=" << to_utf8(layout->name())
<< " parent_layout=" << to_utf8(parent_layout->name()) << "] font=["
<< font.size << ' ' << font.family << ' ' << font.series << ' '
<< font.shape << ']' << endl;
}

View File

@ -1051,7 +1051,7 @@ void parse_noweb(Parser & p, ostream & os, Context & context)
}
if (!scrap || !context.new_layout_allowed ||
!context.textclass.hasLayout("Scrap")) {
!context.textclass.hasLayout(from_ascii("Scrap"))) {
cerr << "Warning: Could not interpret '" << name
<< "'. Ignoring it." << endl;
return;
@ -1064,7 +1064,8 @@ void parse_noweb(Parser & p, ostream & os, Context & context)
// noweb code chunks are implemented with a layout style in LyX they
// always must be in an own paragraph.
context.new_paragraph(os);
Context newcontext(true, context.textclass, context.textclass["Scrap"]);
Context newcontext(true, context.textclass,
context.textclass[from_ascii("Scrap")]);
newcontext.check_layout(os);
os << name;
while (p.good()) {