#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"
}
-int InsetIPADeco::plaintext(odocstringstream & os,
- OutputParams const & runparams, size_t max_length) const
+namespace {
+std::pair<docstring, docstring> splitPlainTextInHalves(
+ const InsetIPADeco * inset, OutputParams const & runparams,
+ size_t max_length = INT_MAX)
{
odocstringstream ods;
- int h = (int)(InsetCollapsible::plaintext(ods, runparams, max_length) / 2);
+ int h = inset->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());
+ return {before, after};
+}
+}
+
+
+int InsetIPADeco::plaintext(odocstringstream & os,
+ OutputParams const & runparams, size_t max_length) const
+{
+ docstring before;
+ docstring after;
+ tie(before, after) = splitPlainTextInHalves(this, runparams, max_length);
if (params_.type == InsetIPADecoParams::Toptiebar) {
os << before;
os.put(0x035c);
os << after;
}
- return result.size();
+ return before.size() + after.size();
}
{
// 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 = (int)(InsetText::plaintext(ods, runparams) / 2);
- docstring result = ods.str();
- docstring const before = result.substr(0, h);
- docstring const after = result.substr(h, result.size());
+ docstring before;
+ docstring after;
+ tie(before, after) = splitPlainTextInHalves(this, runparams);
xs << XMLStream::ESCAPE_NONE << before;
if (params_.type == InsetIPADecoParams::Toptiebar)
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 InsetCollapsible::xhtml(xs, runparams);
+ // The DocBook encoding for this inset has no DocBook tag, but sheer XML (relying on a plaintext
+ // transformation of the inset).
+ docbook(xs, runparams);
+ return docstring();
}
InsetIPAChar::InsetIPAChar(Kind k)
- : Inset(0), kind_(k)
+ : Inset(nullptr), kind_(k)
{}
}
+namespace {
+std::string ipaCharToXMLEntity(InsetIPAChar::Kind kind) {
+ switch (kind) {
+ case InsetIPAChar::Kind::TONE_FALLING:
+ return "˥˩";
+ case InsetIPAChar::Kind::TONE_RISING:
+ return "˩˥";
+ case InsetIPAChar::Kind::TONE_HIGH_RISING:
+ return "˧˥";
+ case InsetIPAChar::Kind::TONE_LOW_RISING:
+ return "˩˧";
+ case InsetIPAChar::Kind::TONE_HIGH_RISING_FALLING:
+ return "˨˥˨";
+ }
+ return "";
+}
+}
+
+
void InsetIPAChar::docbook(XMLStream & xs, OutputParams const &) const
{
- switch (kind_) {
- 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;
- }
+ xs << XMLStream::ESCAPE_NONE << from_ascii(ipaCharToXMLEntity(kind()));
}
docstring InsetIPAChar::xhtml(XMLStream & xs, OutputParams const &) const
{
- switch (kind_) {
- case TONE_FALLING:
- xs << XMLStream::ESCAPE_NONE << "˥"
- << XMLStream::ESCAPE_NONE << "˩";
- break;
- case TONE_RISING:
- xs << XMLStream::ESCAPE_NONE << "˩"
- << XMLStream::ESCAPE_NONE << "˥";
- break;
- case TONE_HIGH_RISING:
- xs << XMLStream::ESCAPE_NONE << "˧"
- << XMLStream::ESCAPE_NONE << "˥";
- break;
- case TONE_LOW_RISING:
- xs << XMLStream::ESCAPE_NONE << "˩"
- << XMLStream::ESCAPE_NONE << "˧";
- break;
- case TONE_HIGH_RISING_FALLING:
- xs << XMLStream::ESCAPE_NONE << "˨"
- << XMLStream::ESCAPE_NONE << "˥"
- << XMLStream::ESCAPE_NONE << "˨";
- break;
- }
+ xs << XMLStream::ESCAPE_NONE << from_ascii(ipaCharToXMLEntity(kind()));
return docstring();
}