From b27bb5cb53edeee088cf408eb37dd7d72586b90d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Fri, 20 Oct 2006 19:26:23 +0000 Subject: [PATCH] Change (and fix) the bullets in itemize to be more unicode friendly. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15416 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Bullet.C | 16 +++++++------ src/Bullet.h | 14 ++++++------ src/ParagraphParameters.C | 13 ++++++----- src/ParagraphParameters.h | 13 ++++++----- src/TocBackend.C | 3 +-- src/buffer_funcs.C | 37 +++++++++++++++---------------- src/bufferparams.C | 8 ++++--- src/frontends/gtk/GParagraph.C | 9 ++++---- src/frontends/qt3/BulletsModule.C | 2 +- src/frontends/qt3/QParagraph.C | 8 +++---- src/frontends/qt3/qt_helpers.C | 19 ++++++++++++++++ src/frontends/qt3/qt_helpers.h | 4 ++++ src/frontends/qt4/BulletsModule.C | 2 +- src/frontends/qt4/QParagraph.C | 8 +++---- src/frontends/qt4/qt_helpers.C | 8 +++++++ src/frontends/qt4/qt_helpers.h | 2 ++ src/output_latex.C | 3 +-- src/output_plaintext.C | 3 +-- src/paragraph.C | 13 +++++------ src/paragraph.h | 6 ++--- src/rowpainter.C | 5 ++--- src/text.C | 11 +++++---- src/text2.C | 13 +++++++---- src/text3.C | 11 ++++----- 24 files changed, 135 insertions(+), 96 deletions(-) diff --git a/src/Bullet.C b/src/Bullet.C index 91965f9706..460791a71a 100644 --- a/src/Bullet.C +++ b/src/Bullet.C @@ -20,6 +20,8 @@ #include +using lyx::docstring; + using std::string; @@ -54,7 +56,7 @@ Bullet::Bullet(int f, int c, int s) -Bullet::Bullet(string const & t) +Bullet::Bullet(docstring const & t) : font(MIN), character(MIN), size(MIN), user_text(1), text(t) { testInvariant(); @@ -97,7 +99,7 @@ void Bullet::setSize(int s) } -void Bullet::setText(string const & t) +void Bullet::setText(docstring const & t) { font = character = size = MIN; user_text = 1; @@ -137,7 +139,7 @@ Bullet & Bullet::operator=(Bullet const & b) } -string const & Bullet::getText() const +docstring const & Bullet::getText() const { if (user_text == 0) { generateText(); @@ -193,7 +195,7 @@ void Bullet::generateText() const } -string const Bullet::bulletSize(int s) +docstring const Bullet::bulletSize(int s) { // use a parameter rather than hard code `size' in here // in case some future function may want to retrieve @@ -205,11 +207,11 @@ string const Bullet::bulletSize(int s) "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge" }; - return BulletSize[s]; + return lyx::from_ascii(BulletSize[s]); } -string const Bullet::bulletEntry(int f, int c) +docstring const Bullet::bulletEntry(int f, int c) { // Despite how this may at first appear the static local variables // are only initialized once.. @@ -350,7 +352,7 @@ string const Bullet::bulletEntry(int f, int c) BulletPanel4, BulletPanel5 }; - return BulletPanels[f][c]; + return lyx::from_ascii(BulletPanels[f][c]); } void Bullet::testInvariant() const diff --git a/src/Bullet.h b/src/Bullet.h index 0f16f15ce2..6562591340 100644 --- a/src/Bullet.h +++ b/src/Bullet.h @@ -13,7 +13,7 @@ #ifndef BULLET_H #define BULLET_H -#include +#include "support/docstring.h" /// class Bullet { @@ -22,7 +22,7 @@ public: Bullet(int f = -1, int c = -1, int s = -1); /// - explicit Bullet(std::string const &); + explicit Bullet(lyx::docstring const &); /// void setCharacter(int); @@ -31,7 +31,7 @@ public: /// void setSize(int); /// - void setText(std::string const &); + void setText(lyx::docstring const &); /// int getCharacter() const; /// @@ -39,7 +39,7 @@ public: /// int getSize() const; /// - std::string const & getText() const; + lyx::docstring const & getText() const; /// Bullet & operator=(Bullet const &); /// @@ -70,9 +70,9 @@ private: /// void generateText() const; /// - static std::string const bulletSize(int); + static lyx::docstring const bulletSize(int); /// - static std::string const bulletEntry(int, int); + static lyx::docstring const bulletEntry(int, int); /// int font; @@ -97,7 +97,7 @@ private: or one generated internally from the font, character and size settings. */ - mutable std::string text; + mutable lyx::docstring text; }; diff --git a/src/ParagraphParameters.C b/src/ParagraphParameters.C index 1e80444b2d..bfd81ec5ab 100644 --- a/src/ParagraphParameters.C +++ b/src/ParagraphParameters.C @@ -28,6 +28,7 @@ #include +using lyx::docstring; using lyx::support::rtrim; using std::istringstream; @@ -141,25 +142,25 @@ void ParagraphParameters::appendix(bool a) } -string const & ParagraphParameters::labelString() const +docstring const & ParagraphParameters::labelString() const { return labelstring_; } -void ParagraphParameters::labelString(string const & ls) +void ParagraphParameters::labelString(docstring const & ls) { labelstring_ = ls; } -string const & ParagraphParameters::labelWidthString() const +docstring const & ParagraphParameters::labelWidthString() const { return labelwidthstring_; } -void ParagraphParameters::labelWidthString(string const & lws) +void ParagraphParameters::labelWidthString(docstring const & lws) { labelwidthstring_ = lws; } @@ -223,7 +224,7 @@ void ParagraphParameters::read(LyXLex & lex) align(LyXAlignment(1 << tmpret)); } else if (token == "\\labelwidthstring") { lex.eatLine(); - labelWidthString(lex.getString()); + labelWidthString(lex.getDocString()); } else { lex.pushToken(token); break; @@ -240,7 +241,7 @@ void ParagraphParameters::write(ostream & os) const // The labelwidth string used in lists. if (!labelWidthString().empty()) os << "\\labelwidthstring " - << labelWidthString() << '\n'; + << lyx::to_utf8(labelWidthString()) << '\n'; // Start of appendix? if (startOfAppendix()) diff --git a/src/ParagraphParameters.h b/src/ParagraphParameters.h index fc6d9acf3b..73fce34030 100644 --- a/src/ParagraphParameters.h +++ b/src/ParagraphParameters.h @@ -19,6 +19,7 @@ #include "Spacing.h" #include "support/types.h" +#include "support/docstring.h" #include #include @@ -66,13 +67,13 @@ public: /// void appendix(bool); /// - std::string const & labelString() const; + lyx::docstring const & labelString() const; /// - void labelString(std::string const &); + void labelString(lyx::docstring const &); /// - std::string const & labelWidthString() const; + lyx::docstring const & labelWidthString() const; /// - void labelWidthString(std::string const &); + void labelWidthString(lyx::docstring const &); /// LyXLength const & leftIndent() const; /// @@ -101,9 +102,9 @@ private: /// depth_type depth_; /// - std::string labelstring_; + lyx::docstring labelstring_; /// - std::string labelwidthstring_; + lyx::docstring labelwidthstring_; /// LyXLength leftindent_; }; diff --git a/src/TocBackend.C b/src/TocBackend.C index d7eb1250b8..63b5d79ffc 100644 --- a/src/TocBackend.C +++ b/src/TocBackend.C @@ -187,8 +187,7 @@ void TocBackend::update() Paragraph const & par = *static_cast(it->inset)->paragraphs().begin(); if (!pit->getLabelstring().empty()) // FIXME UNICODE - tocstring = lyx::from_utf8( - pit->getLabelstring() + ' '); + tocstring = pit->getLabelstring() + ' '; tocstring += par.asString(*buffer_, false); break; } diff --git a/src/buffer_funcs.C b/src/buffer_funcs.C index 573c77a726..7dd64ea012 100644 --- a/src/buffer_funcs.C +++ b/src/buffer_funcs.C @@ -371,13 +371,14 @@ void setLabel(Buffer const & buf, ParIterator & it) par.itemdepth = getItemDepth(it); // erase what was there before - par.params().labelString(string()); + par.params().labelString(docstring()); if (layout->margintype == MARGIN_MANUAL) { if (par.params().labelWidthString().empty()) - par.setLabelWidthString(layout->labelstring()); + // FIXME UNICODE + par.setLabelWidthString(lyx::from_ascii(layout->labelstring())); } else { - par.setLabelWidthString(string()); + par.setLabelWidthString(docstring()); } // is it a layout that has an automatic label? @@ -386,8 +387,10 @@ void setLabel(Buffer const & buf, ParIterator & it) && (layout->latextype != LATEX_ENVIRONMENT || isFirstInSequence(it.pit(), it.plist()))) { counters.step(layout->counter); - string label = expandLabel(buf, layout, - par.params().appendix()); + // FIXME UNICODE + docstring label = + lyx::from_ascii(expandLabel(buf, layout, + par.params().appendix())); par.params().labelString(label); } } else if (layout->labeltype == LABEL_ITEMIZE) { @@ -396,19 +399,19 @@ void setLabel(Buffer const & buf, ParIterator & it) // par.params().labelString( // bufparams.user_defined_bullet(par.itemdepth).getText()); // for now, use a simple hardcoded label - string itemlabel; + docstring itemlabel; switch (par.itemdepth) { case 0: - itemlabel = "*"; + itemlabel = lyx::char_type(0x2022); break; case 1: - itemlabel = "-"; + itemlabel = lyx::char_type(0x2013); break; case 2: - itemlabel = "@"; + itemlabel = lyx::char_type(0x2217); break; case 3: - itemlabel = "·"; + itemlabel += lyx::char_type(0x2219); // or 0x00b7 break; } @@ -462,14 +465,13 @@ void setLabel(Buffer const & buf, ParIterator & it) } // FIXME UNICODE - par.params().labelString(counters.counterLabel(lyx::to_utf8(buf.B_(format)))); + par.params().labelString(lyx::from_utf8(counters.counterLabel(lyx::to_utf8(buf.B_(format))))); } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302 counters.step("bibitem"); int number = counters.value("bibitem"); if (par.bibitem()) par.bibitem()->setCounter(number); - // FIXME UNICODE - par.params().labelString(lyx::to_utf8(buf.B_(layout->labelstring()))); + par.params().labelString(buf.B_(layout->labelstring())); // In biblio should't be following counters but... } else if (layout->labeltype == LABEL_SENSITIVE) { // Search for the first float or wrap inset in the iterator @@ -492,20 +494,17 @@ void setLabel(Buffer const & buf, ParIterator & it) counters.step(fl.type()); // Doesn't work... yet. - // FIXME UNICODE s = bformat(_("%1$s #:"), buf.B_(fl.name())); } else { // par->SetLayout(0); - // FIXME UNICODE s = buf.B_(layout->labelstring()); } - par.params().labelString(lyx::to_utf8(s)); + par.params().labelString(s); } else if (layout->labeltype == LABEL_NO_LABEL) - par.params().labelString(string()); + par.params().labelString(docstring()); else - // FIXME UNICODE - par.params().labelString(lyx::to_utf8(buf.B_(layout->labelstring()))); + par.params().labelString(buf.B_(layout->labelstring())); } } // anon namespace diff --git a/src/bufferparams.C b/src/bufferparams.C index ad6c3d2110..ab542c0db2 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -694,8 +694,9 @@ void BufferParams::writeFile(ostream & os) const << user_defined_bullet(i).getSize() << "\n"; } else { + // FIXME UNICODE os << "\\bulletLaTeX " << i << " \"" - << user_defined_bullet(i).getText() + << lyx::to_ascii(user_defined_bullet(i).getText()) << "\"\n"; } } @@ -1073,8 +1074,9 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, bullets_def += 'v'; break; } + // FIXME UNICODE bullets_def += '{' + - user_defined_bullet(i).getText() + lyx::to_ascii(user_defined_bullet(i).getText()) + "}\n"; } } @@ -1239,7 +1241,7 @@ void BufferParams::readBulletsLaTeX(LyXLex & lex) if (!lex.next()) return; int const index = lex.getInteger(); lex.next(true); - string const temp_str = lex.getString(); + docstring const temp_str = lex.getDocString(); user_defined_bullet(index).setText(temp_str); temp_bullet(index).setText(temp_str); diff --git a/src/frontends/gtk/GParagraph.C b/src/frontends/gtk/GParagraph.C index e731937439..8411b7656a 100644 --- a/src/frontends/gtk/GParagraph.C +++ b/src/frontends/gtk/GParagraph.C @@ -93,10 +93,10 @@ void GParagraph::doBuild() void GParagraph::update() { // label width - string const labelwidth = controller().params().labelWidthString(); - maxlabelwidthentry_->set_text(labelwidth); + docstring const labelwidth = controller().params().labelWidthString(); + maxlabelwidthentry_->set_text(lyx::to_utf8(labelwidth)); maxlabelwidthentry_->set_sensitive( - labelwidth != lyx::to_utf8(_("Senseless with this layout!"))); + labelwidth != _("Senseless with this layout!")); // alignment LyXAlignment const current_alignment = controller().params().align(); @@ -175,8 +175,9 @@ void GParagraph::onSpacingChanged() void GParagraph::onMaxLabelWidthChanged() { + // FIXME UNICODE controller().params().labelWidthString( - maxlabelwidthentry_->get_text()); + lyx::from_utf8(Glib::locale_to_utf8(maxlabelwidthentry_->get_text()))); controller().dispatchParams(); } diff --git a/src/frontends/qt3/BulletsModule.C b/src/frontends/qt3/BulletsModule.C index 67e1db8e0c..46d719005c 100644 --- a/src/frontends/qt3/BulletsModule.C +++ b/src/frontends/qt3/BulletsModule.C @@ -351,7 +351,7 @@ void BulletsModule::setCustom() return; tmpbulletset = true; - tmpbullet.setText(fromqstr(text)); + tmpbullet.setText(qstring_to_ucs4(text)); tmpbullet.setFont(-1); } diff --git a/src/frontends/qt3/QParagraph.C b/src/frontends/qt3/QParagraph.C index adde93c02b..5f02db9af4 100644 --- a/src/frontends/qt3/QParagraph.C +++ b/src/frontends/qt3/QParagraph.C @@ -104,7 +104,7 @@ void QParagraph::apply() params.spacing(spacing); // label width - params.labelWidthString(fromqstr(dialog_->labelWidth->text())); + params.labelWidthString(qstring_to_ucs4(dialog_->labelWidth->text())); // indendation params.noindent(!dialog_->indentCB->isChecked()); } @@ -115,11 +115,11 @@ void QParagraph::update_contents() ParagraphParameters const & params = controller().params(); // label width - string const & labelwidth = params.labelWidthString(); + docstring const & labelwidth = params.labelWidthString(); // lyx::to_utf8(_() is correct here (this is stupid though !)) - if (labelwidth != lyx::to_utf8(_("Senseless with this layout!"))) { + if (labelwidth != _("Senseless with this layout!")) { dialog_->labelwidthGB->setEnabled(true); - dialog_->labelWidth->setText(toqstr(labelwidth)); + dialog_->labelWidth->setText(ucs4_to_qstring(labelwidth)); } else { dialog_->labelwidthGB->setEnabled(false); dialog_->labelWidth->setText(""); diff --git a/src/frontends/qt3/qt_helpers.C b/src/frontends/qt3/qt_helpers.C index 51e06f2fd4..f9c2be1604 100644 --- a/src/frontends/qt3/qt_helpers.C +++ b/src/frontends/qt3/qt_helpers.C @@ -163,6 +163,25 @@ docstring const qstring_to_ucs4(QString const & str) } +void ucs4_to_qstring(lyx::docstring const & str, QString & s) +{ + size_t ls = str.size(); + s = ""; + s.reserve(ls); + + for (size_t i = 0; i < ls; ++i) + s.append(ucs4_to_qchar(str[i])); +} + + +QString ucs4_to_qstring(lyx::docstring const & str) +{ + QString tmp; + ucs4_to_qstring(str, tmp); + return tmp; +} + + docstring const formatted(docstring const & text, int w) { docstring sout; diff --git a/src/frontends/qt3/qt_helpers.h b/src/frontends/qt3/qt_helpers.h index 72f739e89a..61a1832096 100644 --- a/src/frontends/qt3/qt_helpers.h +++ b/src/frontends/qt3/qt_helpers.h @@ -103,4 +103,8 @@ std::string const fromqstr(QString const & str); */ lyx::docstring const qstring_to_ucs4(QString const & str); +void ucs4_to_qstring(lyx::docstring const & str, QString & s); + +QString ucs4_to_qstring(lyx::docstring const & str); + #endif // QTHELPERS_H diff --git a/src/frontends/qt4/BulletsModule.C b/src/frontends/qt4/BulletsModule.C index 2cb0c1b143..de2318518f 100644 --- a/src/frontends/qt4/BulletsModule.C +++ b/src/frontends/qt4/BulletsModule.C @@ -172,7 +172,7 @@ void BulletsModule::on_customLE_textEdited(const QString & text) return; bullets_[levelLW->currentRow()].setFont(current_font_); - bullets_[levelLW->currentRow()].setText(fromqstr(text)); + bullets_[levelLW->currentRow()].setText(qstring_to_ucs4(text)); changed(); } diff --git a/src/frontends/qt4/QParagraph.C b/src/frontends/qt4/QParagraph.C index 306a1ab568..47337d9f17 100644 --- a/src/frontends/qt4/QParagraph.C +++ b/src/frontends/qt4/QParagraph.C @@ -102,7 +102,7 @@ void QParagraph::apply() params.spacing(spacing); // label width - params.labelWidthString(fromqstr(dialog_->labelWidth->text())); + params.labelWidthString(qstring_to_ucs4(dialog_->labelWidth->text())); // indendation params.noindent(!dialog_->indentCB->isChecked()); } @@ -113,11 +113,11 @@ void QParagraph::update_contents() ParagraphParameters const & params = controller().params(); // label width - string const & labelwidth = params.labelWidthString(); + docstring const & labelwidth = params.labelWidthString(); // lyx::to_utf8(_() is correct here (this is stupid though !)) - if (labelwidth != lyx::to_utf8(_("Senseless with this layout!"))) { + if (labelwidth != _("Senseless with this layout!")) { dialog_->labelwidthGB->setEnabled(true); - dialog_->labelWidth->setText(toqstr(labelwidth)); + dialog_->labelWidth->setText(ucs4_to_qstring(labelwidth)); } else { dialog_->labelwidthGB->setEnabled(false); dialog_->labelWidth->setText(""); diff --git a/src/frontends/qt4/qt_helpers.C b/src/frontends/qt4/qt_helpers.C index 67116455fd..50ac1d9d98 100644 --- a/src/frontends/qt4/qt_helpers.C +++ b/src/frontends/qt4/qt_helpers.C @@ -141,6 +141,14 @@ void ucs4_to_qstring(lyx::docstring const & str, QString & s) } +QString ucs4_to_qstring(lyx::docstring const & str) +{ + QString tmp; + ucs4_to_qstring(str, tmp); + return tmp; +} + + QString const toqstr(docstring const & ucs4) { QString s; diff --git a/src/frontends/qt4/qt_helpers.h b/src/frontends/qt4/qt_helpers.h index 21b011e3e7..36a84e1470 100644 --- a/src/frontends/qt4/qt_helpers.h +++ b/src/frontends/qt4/qt_helpers.h @@ -73,6 +73,8 @@ void ucs4_to_qstring(lyx::char_type const * str, size_t ls, QString & s); void ucs4_to_qstring(lyx::docstring const & str, QString & s); +QString ucs4_to_qstring(lyx::docstring const & str); + lyx::docstring const qstring_to_ucs4(QString const & qstr); void qstring_to_ucs4(QString const & qstr, std::vector & ucs4); diff --git a/src/output_latex.C b/src/output_latex.C index d739f86176..6772b98e81 100644 --- a/src/output_latex.C +++ b/src/output_latex.C @@ -147,9 +147,8 @@ TeXEnvironment(Buffer const & buf, } } if (style->latextype == LATEX_LIST_ENVIRONMENT) { - // FIXME UNICODE os << '{' - << lyx::from_utf8(pit->params().labelWidthString()) + << pit->params().labelWidthString() << "}\n"; } else if (style->labeltype == LABEL_BIBLIO) { // ale970405 diff --git a/src/output_plaintext.C b/src/output_plaintext.C index 5903965595..ce40c8c407 100644 --- a/src/output_plaintext.C +++ b/src/output_plaintext.C @@ -174,9 +174,8 @@ void asciiParagraph(Buffer const & buf, break; default: { - // FIXME UNICODE docstring const label = - lyx::from_utf8(par.params().labelString()); + par.params().labelString(); os << label << ' '; currlinelen += label.length() + 1; break; diff --git a/src/paragraph.C b/src/paragraph.C index 72332c850c..c7fdeeacb2 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -606,23 +606,23 @@ char Paragraph::getAlign() const } -string const & Paragraph::getLabelstring() const +docstring const & Paragraph::getLabelstring() const { return params().labelString(); } // the next two functions are for the manual labels -string const Paragraph::getLabelWidthString() const +docstring const Paragraph::getLabelWidthString() const { if (!params().labelWidthString().empty()) return params().labelWidthString(); else - return lyx::to_utf8(_("Senseless with this layout!")); + return _("Senseless with this layout!"); } -void Paragraph::setLabelWidthString(string const & s) +void Paragraph::setLabelWidthString(docstring const & s) { params().labelWidthString(s); } @@ -631,7 +631,7 @@ void Paragraph::setLabelWidthString(string const & s) void Paragraph::applyLayout(LyXLayout_ptr const & new_layout) { layout(new_layout); - params().labelWidthString(string()); + params().labelWidthString(docstring()); params().align(LYX_ALIGN_LAYOUT); params().spacing(Spacing(Spacing::Default)); } @@ -1402,8 +1402,7 @@ docstring const Paragraph::asString(Buffer const & buffer, lyx::odocstringstream os; if (beg == 0 && label && !params().labelString().empty()) - // FIXME UNICODE - os << lyx::from_utf8(params().labelString()) << ' '; + os << params().labelString() << ' '; for (pos_type i = beg; i < end; ++i) { value_type const c = getUChar(buffer.params(), i); diff --git a/src/paragraph.h b/src/paragraph.h index a3cf57cd63..2e63fe5d41 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -224,12 +224,12 @@ public: void setBeginOfBody(); /// - std::string const & getLabelstring() const; + lyx::docstring const & getLabelstring() const; /// the next two functions are for the manual labels - std::string const getLabelWidthString() const; + lyx::docstring const getLabelWidthString() const; /// - void setLabelWidthString(std::string const & s); + void setLabelWidthString(lyx::docstring const & s); /// char getAlign() const; /// The nesting depth of a paragraph diff --git a/src/rowpainter.C b/src/rowpainter.C index b130f4bbe2..7c78a4e1e5 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -522,8 +522,7 @@ void RowPainter::paintFirst() LyXFont const font = getLabelFont(); FontMetrics const & fm = theFontMetrics(font); - // FIXME UNICODE - docstring const str = lyx::from_utf8(par_.getLabelstring()); + docstring const str = par_.getLabelstring(); if (!str.empty()) { double x = x_; @@ -572,7 +571,7 @@ void RowPainter::paintFirst() layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) { LyXFont font = getLabelFont(); if (!par_.getLabelstring().empty()) { - docstring const str = lyx::from_utf8(par_.getLabelstring()); + docstring const str = par_.getLabelstring(); double spacing_val = 1.0; if (!parparams.spacing().isDefault()) spacing_val = parparams.spacing().getValue(); diff --git a/src/text.C b/src/text.C index 241b5a44eb..fd36a3f81d 100644 --- a/src/text.C +++ b/src/text.C @@ -537,7 +537,7 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const // FIXME UNICODE docstring labin = lyx::from_utf8(layout->labelindent); l_margin += labelfont_metrics.signedWidth(labin); - docstring labstr = lyx::from_utf8(par.getLabelstring()); + docstring labstr = par.getLabelstring(); l_margin += labelfont_metrics.width(labstr); docstring labsep = lyx::from_utf8(layout->labelsep); l_margin += labelfont_metrics.width(labsep); @@ -551,7 +551,7 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const // The width of an empty par, even with manual label, should be 0 if (!par.empty() && pos >= par.beginOfBody()) { if (!par.getLabelWidthString().empty()) { - docstring labstr = lyx::from_utf8(par.getLabelWidthString()); + docstring labstr = par.getLabelWidthString(); l_margin += labelfont_metrics.width(labstr); docstring labsep = lyx::from_utf8(layout->labelsep); l_margin += labelfont_metrics.width(labsep); @@ -593,7 +593,7 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const LABEL_CENTERED_TOP_ENVIRONMENT) { l_margin += labelfont_metrics.signedWidth(lyx::from_utf8(layout->labelindent)); l_margin += labelfont_metrics.width(lyx::from_utf8(layout->labelsep)); - l_margin += labelfont_metrics.width(lyx::from_utf8(par.getLabelstring())); + l_margin += labelfont_metrics.width(par.getLabelstring()); } break; @@ -880,14 +880,13 @@ int LyXText::labelFill(Paragraph const & par, Row const & row) const for (pos_type i = row.pos(); i <= last; ++i) w += singleWidth(par, i); - string const & label = par.params().labelWidthString(); + docstring const & label = par.params().labelWidthString(); if (label.empty()) return 0; FontMetrics const & fm = theFontMetrics(getLabelFont(par)); - // FIXME UNICODE - return max(0, fm.width(lyx::from_utf8(label)) - w); + return max(0, fm.width(label) - w); } diff --git a/src/text2.C b/src/text2.C index 143151d4ea..4149adfa35 100644 --- a/src/text2.C +++ b/src/text2.C @@ -354,7 +354,8 @@ void LyXText::setLayout(pit_type start, pit_type end, string const & layout) for (pit_type pit = start; pit != end; ++pit) { pars_[pit].applyLayout(lyxlayout); if (lyxlayout->margintype == MARGIN_MANUAL) - pars_[pit].setLabelWidthString(lyxlayout->labelstring()); + // FIXME UNICODE + pars_[pit].setLabelWidthString(lyx::from_ascii(lyxlayout->labelstring())); } } @@ -637,7 +638,8 @@ void LyXText::setParagraph(LCursor & cur, else params.align(align); } - par.setLabelWidthString(labelwidthstring); + // FIXME UNICODE + par.setLabelWidthString(lyx::from_ascii(labelwidthstring)); params.noindent(noindent); } } @@ -991,8 +993,11 @@ InsetBase * LyXText::editXY(LCursor & cur, int x, int y) // This should be just before or just behind the // cursor position set above. - BOOST_ASSERT((pos != 0 && inset == pars_[pit].getInset(pos - 1)) - || inset == pars_[pit].getInset(pos)); + InsetBase * inset2 = pars_[pit].getInset(pos - 1); + InsetBase * inset3 = pars_[pit].getInset(pos); + + BOOST_ASSERT((pos != 0 && inset == inset2) + || inset == inset3); // Make sure the cursor points to the position before // this inset. if (inset == pars_[pit].getInset(pos - 1)) diff --git a/src/text3.C b/src/text3.C index 8497102986..847bdf5a3a 100644 --- a/src/text3.C +++ b/src/text3.C @@ -652,7 +652,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH. lyx::cap::replaceSelection(cur); if (cur.pos() == 0) - cur.paragraph().params().labelWidthString(string()); + cur.paragraph().params().labelWidthString(docstring()); else breakParagraph(cur, 0); cur.resetAnchor(); @@ -1446,11 +1446,12 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) lex.setStream(is); ParagraphParameters params; params.read(lex); + // FIXME UNICODE setParagraph(cur, - params.spacing(), - params.align(), - params.labelWidthString(), - params.noindent()); + params.spacing(), + params.align(), + lyx::to_ascii(params.labelWidthString()), + params.noindent()); cur.message(_("Paragraph layout set")); break; }