X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetIPAMacro.cpp;h=a529d04b08ddfbf92078592dfec1bdf09f71ab87;hb=997f0621c5346bb623cf86713c4fe1be0c941104;hp=7852486b7d60ce7333f3a4c12a6d826706bdb3d0;hpb=7f6f56f40ab4aab138621361ce90953b5f0ccbe4;p=lyx.git diff --git a/src/insets/InsetIPAMacro.cpp b/src/insets/InsetIPAMacro.cpp index 7852486b7d..a529d04b08 100644 --- a/src/insets/InsetIPAMacro.cpp +++ b/src/insets/InsetIPAMacro.cpp @@ -16,13 +16,14 @@ #include "BufferParams.h" #include "Dimension.h" #include "Encoding.h" -#include "Font.h" +#include "FontInfo.h" #include "FuncRequest.h" #include "FuncStatus.h" +#include "InsetLayout.h" #include "LaTeXFeatures.h" #include "Lexer.h" #include "MetricsInfo.h" -#include "output_xhtml.h" +#include "xml.h" #include "texstream.h" #include "frontends/FontMetrics.h" @@ -94,7 +95,7 @@ IPACharTranslator const & ipachartranslator() return chartranslator; } -} // anon +} // namespace InsetIPADecoParams::InsetIPADecoParams() @@ -125,7 +126,7 @@ void InsetIPADecoParams::read(Lexer & lex) ///////////////////////////////////////////////////////////////////// InsetIPADeco::InsetIPADeco(Buffer * buf, string const & label) - : InsetCollapsable(buf) + : InsetCollapsible(buf) { setDrawFrame(true); setFrameColor(Color_insetframe); @@ -179,7 +180,7 @@ void InsetIPADeco::metrics(MetricsInfo & mi, Dimension & dim) const void InsetIPADeco::draw(PainterInfo & pi, int x, int y) const { // draw the text - InsetCollapsable::draw(pi, x, y); + InsetCollapsible::draw(pi, x, y); // draw the inset marker drawMarkers(pi, x, y); @@ -223,14 +224,14 @@ void InsetIPADeco::draw(PainterInfo & pi, int x, int y) const void InsetIPADeco::write(ostream & os) const { params_.write(os); - InsetCollapsable::write(os); + InsetCollapsible::write(os); } void InsetIPADeco::read(Lexer & lex) { params_.read(lex); - InsetCollapsable::read(lex); + InsetCollapsible::read(lex); } @@ -277,7 +278,7 @@ void InsetIPADeco::latex(otexstream & os, OutputParams const & runparams) const os << "\\texttoptiebar{"; else if (params_.type == InsetIPADecoParams::Bottomtiebar) os << "\\textbottomtiebar{"; - InsetCollapsable::latex(os, runparams); + InsetCollapsible::latex(os, runparams); os << "}"; } @@ -286,7 +287,7 @@ int InsetIPADeco::plaintext(odocstringstream & os, OutputParams const & runparams, size_t max_length) const { odocstringstream ods; - int h = (int)(InsetCollapsable::plaintext(ods, runparams, max_length) / 2); + int h = InsetCollapsible::plaintext(ods, runparams, max_length) / 2; docstring result = ods.str(); docstring const before = result.substr(0, h); docstring const after = result.substr(h, result.size()); @@ -305,19 +306,31 @@ int InsetIPADeco::plaintext(odocstringstream & os, } -int InsetIPADeco::docbook(odocstream & os, OutputParams const & runparams) const +void InsetIPADeco::docbook(XMLStream & xs, OutputParams const & runparams) const { - // FIXME: Any docbook option here? - return InsetCollapsable::docbook(os, runparams); + // The special combining character must be put in the middle, between the two other characters. + // It will not work if there is anything else than two pure characters, so going back to plaintext. + odocstringstream ods; + int h = InsetText::plaintext(ods, runparams) / 2; + docstring result = ods.str(); + docstring const before = result.substr(0, h); + docstring const after = result.substr(h, result.size()); + + xs << XMLStream::ESCAPE_NONE << before; + if (params_.type == InsetIPADecoParams::Toptiebar) + xs << XMLStream::ESCAPE_NONE << "͡"; + else if (params_.type == InsetIPADecoParams::Bottomtiebar) + xs << XMLStream::ESCAPE_NONE << "͜"; + xs << XMLStream::ESCAPE_NONE << after; } -docstring InsetIPADeco::xhtml(XHTMLStream & xs, OutputParams const & runparams) const +docstring InsetIPADeco::xhtml(XMLStream & xs, OutputParams const & runparams) const { // FIXME: Like in plaintext, the combining characters "͡" (toptiebar) // or "͜" (bottomtiebar) would need to be inserted just in the mid // of the text string. (How) can this be done with the xhtml stream? - return InsetCollapsable::xhtml(xs, runparams); + return InsetCollapsible::xhtml(xs, runparams); } @@ -381,7 +394,7 @@ bool InsetIPADeco::insetAllowed(InsetCode code) const InsetIPAChar::InsetIPAChar(Kind k) - : Inset(0), kind_(k) + : Inset(nullptr), kind_(k) {} @@ -540,45 +553,57 @@ int InsetIPAChar::plaintext(odocstringstream & os, OutputParams const &, size_t) } -int InsetIPAChar::docbook(odocstream & /*os*/, OutputParams const &) const +void InsetIPAChar::docbook(XMLStream & xs, OutputParams const &) const { switch (kind_) { - // FIXME - LYXERR0("IPA tone macros not yet implemented with DocBook!"); case TONE_FALLING: + xs << XMLStream::ESCAPE_NONE << "˥"; + xs << XMLStream::ESCAPE_NONE << "˩"; + break; case TONE_RISING: + xs << XMLStream::ESCAPE_NONE << "˩"; + xs << XMLStream::ESCAPE_NONE << "˥"; + break; case TONE_HIGH_RISING: + xs << XMLStream::ESCAPE_NONE << "˧"; + xs << XMLStream::ESCAPE_NONE << "˥"; + break; case TONE_LOW_RISING: + xs << XMLStream::ESCAPE_NONE << "˩"; + xs << XMLStream::ESCAPE_NONE << "˧"; + break; case TONE_HIGH_RISING_FALLING: + xs << XMLStream::ESCAPE_NONE << "˨"; + xs << XMLStream::ESCAPE_NONE << "˥"; + xs << XMLStream::ESCAPE_NONE << "˨"; break; } - return 0; } -docstring InsetIPAChar::xhtml(XHTMLStream & xs, OutputParams const &) const +docstring InsetIPAChar::xhtml(XMLStream & xs, OutputParams const &) const { switch (kind_) { case TONE_FALLING: - xs << XHTMLStream::ESCAPE_NONE << "˥" - << XHTMLStream::ESCAPE_NONE << "˩"; + xs << XMLStream::ESCAPE_NONE << "˥" + << XMLStream::ESCAPE_NONE << "˩"; break; case TONE_RISING: - xs << XHTMLStream::ESCAPE_NONE << "˩" - << XHTMLStream::ESCAPE_NONE << "˥"; + xs << XMLStream::ESCAPE_NONE << "˩" + << XMLStream::ESCAPE_NONE << "˥"; break; case TONE_HIGH_RISING: - xs << XHTMLStream::ESCAPE_NONE << "˧" - << XHTMLStream::ESCAPE_NONE << "˥"; + xs << XMLStream::ESCAPE_NONE << "˧" + << XMLStream::ESCAPE_NONE << "˥"; break; case TONE_LOW_RISING: - xs << XHTMLStream::ESCAPE_NONE << "˩" - << XHTMLStream::ESCAPE_NONE << "˧"; + xs << XMLStream::ESCAPE_NONE << "˩" + << XMLStream::ESCAPE_NONE << "˧"; break; case TONE_HIGH_RISING_FALLING: - xs << XHTMLStream::ESCAPE_NONE << "˨" - << XHTMLStream::ESCAPE_NONE << "˥" - << XHTMLStream::ESCAPE_NONE << "˨"; + xs << XMLStream::ESCAPE_NONE << "˨" + << XMLStream::ESCAPE_NONE << "˥" + << XMLStream::ESCAPE_NONE << "˨"; break; } return docstring();