From 862f6396954587b2b4c173682f4d861fdca0e78f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Fri, 20 Oct 2006 22:17:16 +0000 Subject: [PATCH] More unicode, this time some focus on layouts and textclasses git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15421 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/buffer_funcs.C | 20 +++++++++++--------- src/lyxlayout.C | 8 ++++---- src/lyxlayout.h | 15 ++++++++------- src/lyxtextclass.C | 16 +++++++--------- src/lyxtextclass.h | 2 +- src/paragraph_pimpl.C | 2 +- src/rowpainter.C | 3 +-- src/sgml.C | 4 ++-- src/text2.C | 3 +-- 9 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/buffer_funcs.C b/src/buffer_funcs.C index 0e94ff2b62..8291f4b41a 100644 --- a/src/buffer_funcs.C +++ b/src/buffer_funcs.C @@ -375,8 +375,7 @@ void setLabel(Buffer const & buf, ParIterator & it) if (layout->margintype == MARGIN_MANUAL) { if (par.params().labelWidthString().empty()) - // FIXME UNICODE - par.setLabelWidthString(lyx::from_ascii(layout->labelstring())); + par.setLabelWidthString(layout->labelstring()); } else { par.setLabelWidthString(docstring()); } @@ -386,8 +385,7 @@ void setLabel(Buffer const & buf, ParIterator & it) if (layout->toclevel <= buf.params().secnumdepth && (layout->latextype != LATEX_ENVIRONMENT || isFirstInSequence(it.pit(), it.plist()))) { - // FIXME UNICODE - counters.step(lyx::from_ascii(layout->counter)); + counters.step(layout->counter); docstring label = expandLabel(buf, layout, par.params().appendix()); par.params().labelString(label); @@ -469,7 +467,8 @@ void setLabel(Buffer const & buf, ParIterator & it) int number = counters.value(lyx::from_ascii("bibitem")); if (par.bibitem()) par.bibitem()->setCounter(number); - par.params().labelString(buf.B_(layout->labelstring())); + // FIXME UNICODE + par.params().labelString(buf.B_(lyx::to_ascii(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 @@ -495,14 +494,16 @@ void setLabel(Buffer const & buf, ParIterator & it) s = bformat(_("%1$s #:"), buf.B_(fl.name())); } else { // par->SetLayout(0); - s = buf.B_(layout->labelstring()); + // FIXME UNICODE + s = buf.B_(lyx::to_ascii(layout->labelstring())); } par.params().labelString(s); } else if (layout->labeltype == LABEL_NO_LABEL) par.params().labelString(docstring()); else - par.params().labelString(buf.B_(layout->labelstring())); + // FIXME UNICODE + par.params().labelString(buf.B_(lyx::to_ascii(layout->labelstring()))); } } // anon namespace @@ -594,8 +595,9 @@ docstring expandLabel(Buffer const & buf, { LyXTextClass const & tclass = buf.params().getLyXTextClass(); - docstring fmt = buf.B_(appendix ? layout->labelstring_appendix() - : layout->labelstring()); + // FIXME UNICODE + docstring fmt = buf.B_(lyx::to_ascii(appendix ? layout->labelstring_appendix() + : layout->labelstring())); // handle 'inherited level parts' in 'fmt', // i.e. the stuff between '@' in '@Section@.\arabic{subsection}' diff --git a/src/lyxlayout.C b/src/lyxlayout.C index f0a0e33910..2400a1c1d7 100644 --- a/src/lyxlayout.C +++ b/src/lyxlayout.C @@ -448,22 +448,22 @@ bool LyXLayout::read(LyXLex & lexrc, LyXTextClass const & tclass) case LT_LABELSTRING: // label string definition if (lexrc.next()) - labelstring_ = trim(lexrc.getString()); + labelstring_ = lyx::from_ascii(trim(lexrc.getString())); break; case LT_ENDLABELSTRING: // endlabel string definition if (lexrc.next()) - endlabelstring_ = trim(lexrc.getString()); + endlabelstring_ = lyx::from_ascii(trim(lexrc.getString())); break; case LT_LABELSTRING_APPENDIX: // label string appendix definition if (lexrc.next()) - labelstring_appendix_ = trim(lexrc.getString()); + labelstring_appendix_ = lyx::from_ascii(trim(lexrc.getString())); break; case LT_LABELCOUNTER: // name of counter to use if (lexrc.next()) - counter = trim(lexrc.getString()); + counter = lyx::from_ascii(trim(lexrc.getString())); break; case LT_FREE_SPACING: // Allow for free spacing. diff --git a/src/lyxlayout.h b/src/lyxlayout.h index 88907d7aa0..324bd3c028 100644 --- a/src/lyxlayout.h +++ b/src/lyxlayout.h @@ -17,6 +17,7 @@ #include "lyxfont.h" #include "layout.h" #include "Spacing.h" +#include "support/docstring.h" #include @@ -55,9 +56,9 @@ public: /// std::string const & latexname() const { return latexname_; } /// - std::string const & labelstring() const { return labelstring_; } + lyx::docstring const & labelstring() const { return labelstring_; } /// - std::string const & endlabelstring() const { return endlabelstring_; } + lyx::docstring const & endlabelstring() const { return endlabelstring_; } /// std::string const & preamble() const { return preamble_; } /// @@ -69,7 +70,7 @@ public: /// std::string const & itemtag() const { return itemtag_; } /// - std::string const & labelstring_appendix() const { + lyx::docstring const & labelstring_appendix() const { return labelstring_appendix_; } /** Default font for this layout/environment. @@ -185,7 +186,7 @@ public: /// Does this layout allow for an optional parameter? int optionalargs; /// Which counter to step - std::string counter; + lyx::docstring counter; /// Depth of XML command int commanddepth; @@ -208,11 +209,11 @@ private: /// LaTeX name for environment std::string latexname_; /// Label string. "Abstract", "Reference", "Caption"... - std::string labelstring_; + lyx::docstring labelstring_; /// - std::string endlabelstring_; + lyx::docstring endlabelstring_; /// Label string inside appendix. "Appendix", ... - std::string labelstring_appendix_; + lyx::docstring labelstring_appendix_; /// LaTeX parameter for environment std::string latexparam_; /// Internal tag to use (e.g., for sect header) diff --git a/src/lyxtextclass.C b/src/lyxtextclass.C index f82a8fd3d2..51b50ecd15 100644 --- a/src/lyxtextclass.C +++ b/src/lyxtextclass.C @@ -804,8 +804,8 @@ void LyXTextClass::readCounter(LyXLex & lexrc) lexrc.pushTable(counterTags, CT_END); - string name; - string within; + docstring name; + docstring within; bool getout = false; while (!getout && lexrc.isOK()) { @@ -819,12 +819,12 @@ void LyXTextClass::readCounter(LyXLex & lexrc) switch (static_cast(le)) { case CT_NAME: lexrc.next(); - name = lexrc.getString(); + name = lyx::from_ascii(lexrc.getString()); break; case CT_WITHIN: lexrc.next(); - within = lexrc.getString(); - if (within == "none") + within = lyx::from_ascii(lexrc.getString()); + if (within == lyx::from_ascii("none")) within.erase(); break; case CT_END: @@ -835,12 +835,10 @@ void LyXTextClass::readCounter(LyXLex & lexrc) // Here if have a full counter if getout == true if (getout) { - // FIXME UNICODE if (within.empty()) { - ctrs_->newCounter(lyx::from_ascii(name)); + ctrs_->newCounter(name); } else { - ctrs_->newCounter(lyx::from_ascii(name), - lyx::from_ascii(within)); + ctrs_->newCounter(name, within); } } diff --git a/src/lyxtextclass.h b/src/lyxtextclass.h index 8dacb47c0a..4341223078 100644 --- a/src/lyxtextclass.h +++ b/src/lyxtextclass.h @@ -84,7 +84,7 @@ public: LyXLayout_ptr const & operator[](std::string const & vname) const; /// Sees to that the textclass structure has been loaded - bool load(std::string const & path=std::string()) const; + bool load(std::string const & path = std::string()) const; /// Has this layout file been loaded yet? bool loaded() const { return loaded_; } diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index 4993e540bc..cea2b47fd7 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -322,7 +322,7 @@ void Paragraph::Pimpl::erase(pos_type pos) } -bool Paragraph::Pimpl::erase(pos_type pos, bool trackChanges) +bool Paragraph::Pimpl::erase(pos_type pos, bool /*trackChanges*/) { // FIXME: change tracking (MG) BOOST_ASSERT(pos <= size()); diff --git a/src/rowpainter.C b/src/rowpainter.C index 7c78a4e1e5..779f5a6ee1 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -630,8 +630,7 @@ void RowPainter::paintLast() case END_LABEL_STATIC: { LyXFont font = getLabelFont(); FontMetrics const & fm = theFontMetrics(font); - // FIXME UNICODE - docstring const & str = lyx::from_utf8(par_.layout()->endlabelstring()); + docstring const & str = par_.layout()->endlabelstring(); double const x = is_rtl ? x_ - fm.width(str) : - text_.rightMargin(par_) - row_.width(); diff --git a/src/sgml.C b/src/sgml.C index 23d4904fad..05977ab4ec 100644 --- a/src/sgml.C +++ b/src/sgml.C @@ -229,9 +229,9 @@ void sgml::openTag(Buffer const & buf, odocstream & os, OutputParams const & run if (param.find('#') != string::npos) { // FIXME UNICODE if(!style->counter.empty()) - counters.step(lyx::from_ascii(style->counter)); + counters.step(style->counter); else - counters.step(lyx::from_ascii(style->latexname())); + counters.step(lyx::from_ascii(name)); int i = counters.value(lyx::from_ascii(name)); attribute = subst(param, "#", convert(i)); } else { diff --git a/src/text2.C b/src/text2.C index 4149adfa35..10cd34d5a1 100644 --- a/src/text2.C +++ b/src/text2.C @@ -354,8 +354,7 @@ 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) - // FIXME UNICODE - pars_[pit].setLabelWidthString(lyx::from_ascii(lyxlayout->labelstring())); + pars_[pit].setLabelWidthString(lyxlayout->labelstring()); } } -- 2.39.5