#include "support/convert.h"
#include "support/debug.h"
#include "support/lstrings.h"
+#include "support/lyxalgo.h"
#include "support/textutils.h"
#include <QThreadStorage>
-#include <algorithm>
-#include <boost/next_prior.hpp>
#include <list>
using namespace std;
}
+string const getPolyglossiaBegin(string const & lang_begin_command,
+ string const & lang, string const & opts)
+{
+ string result;
+ if (!lang.empty())
+ result = subst(lang_begin_command, "$$lang", lang);
+ string options = opts.empty() ?
+ string() : "[" + opts + "]";
+ result = subst(result, "$$opts", options);
+
+ return result;
+}
+
+
struct TeXEnvironmentData
{
bool cjk_nested;
ParagraphList const & paragraphs = text.paragraphs();
ParagraphList::const_iterator const priorpit =
- pit == paragraphs.begin() ? pit : boost::prior(pit);
+ pit == paragraphs.begin() ? pit : prev(pit, 1);
OutputState * state = getOutputState();
bool const use_prev_env_language = state->prev_env_language_ != 0
if ((lang_end_command.empty() ||
par_lang != doc_lang) &&
!par_lang.empty()) {
- os << from_ascii(subst(
- lang_begin_command,
- "$$lang",
- par_lang));
- if (use_polyglossia
- && !data.par_language->polyglossiaOpts().empty())
- os << "["
- << from_ascii(data.par_language->polyglossiaOpts())
- << "]";
- // the '%' is necessary to prevent unwanted whitespace
- os << "%\n";
+ string bc = use_polyglossia ?
+ getPolyglossiaBegin(lang_begin_command, par_lang,
+ data.par_language->polyglossiaOpts())
+ : subst(lang_begin_command, "$$lang", par_lang);
+ os << bc;
+ // the '%' is necessary to prevent unwanted whitespace
+ os << "%\n";
}
}
// get the first paragraph in sequence with this layout and depth
pit_type offset = 0;
while (true) {
- if (boost::prior(pit, offset) == pars.begin())
+ if (prev(pit, offset) == pars.begin())
break;
- ParagraphList::const_iterator priorpit = boost::prior(pit, offset + 1);
+ ParagraphList::const_iterator priorpit = prev(pit, offset + 1);
if (priorpit->layout() == current_layout
&& priorpit->params().depth() == current_depth)
++offset;
break;
}
- ParagraphList::const_iterator spit = boost::prior(pit, offset);
+ ParagraphList::const_iterator spit = prev(pit, offset);
for (; spit != pars.end(); ++spit) {
if (spit->layout() != current_layout || spit->params().depth() < current_depth)
Paragraph const & par = paragraphs.at(pit);
// FIXME This check should not really be needed.
// Perhaps we should issue an error if it is.
- Layout const style = text.inset().forcePlainLayout() ?
+ Layout const & style = text.inset().forcePlainLayout() ?
bparams.documentClass().plainLayout() : par.layout();
if (style.inpreamble)
string const outer_lang = use_polyglossia ?
getPolyglossiaEnvName(outer_language) : outer_language->babel();
string lang_begin_command = use_polyglossia ?
- "\\begin{$$lang}" : lyxrc.language_command_begin;
+ "\\begin{$$lang}$$opts" : lyxrc.language_command_begin;
string lang_end_command = use_polyglossia ?
"\\end{$$lang}" : lyxrc.language_command_end;
// the '%' is necessary to prevent unwanted whitespace
string lang_command_termination = "%\n";
// In some insets (such as Arguments), we cannot use \selectlanguage
- bool const localswitch = !use_polyglossia
- && text.inset().getLayout().forcelocalfontswitch();
+ bool const localswitch = text.inset().forceLocalFontSwitch();
if (localswitch) {
- lang_begin_command = lyxrc.language_command_local;
+ lang_begin_command = use_polyglossia ?
+ "\\text$$lang$$opts{" : lyxrc.language_command_local;
lang_end_command = "}";
lang_command_termination.clear();
}
// With CJK, the CJK tag has to be closed first (see below)
if (runparams.encoding->package() != Encoding::CJK
&& !par_lang.empty()) {
- os << from_ascii(subst(
- lang_begin_command,
- "$$lang",
- par_lang));
- if (use_polyglossia
- && !par_language->polyglossiaOpts().empty())
- os << "["
- << from_ascii(par_language->polyglossiaOpts())
- << "]";
+ string bc = use_polyglossia ?
+ getPolyglossiaBegin(lang_begin_command, par_lang, par_language->polyglossiaOpts())
+ : subst(lang_begin_command, "$$lang", par_lang);
+ os << bc;
os << lang_command_termination;
}
}
// calculates the space between the baselines according
// to this font. (Matthias)
//
- // Is this really needed ? (Dekel)
- // We do not need to use to change the font for the last paragraph
- // or for a command.
- // Spitz: We need for the last par, actually. See #9231.
+ // We must not change the font for the last paragraph
+ // of non-multipar insets, tabular cells or commands,
+ // since this produces unwanted whitespace.
Font const font = par.empty()
? par.getLayoutFont(bparams, outerfont)
bool const is_command = style.isCommand();
if (style.resfont.size() != font.fontInfo().size()
+ && (nextpar || maintext
+ || (text.inset().getLayout().isMultiPar()
+ && text.inset().lyxCode() != CELL_CODE))
&& !is_command) {
os << '{';
os << "\\" << from_ascii(font.latexSize()) << " \\par}";
? getPolyglossiaEnvName(current_language)
: current_language->babel();
if (!current_lang.empty()) {
- os << from_ascii(subst(
- lang_begin_command,
- "$$lang",
- current_lang));
+ string bc = use_polyglossia ?
+ getPolyglossiaBegin(lang_begin_command, current_lang,
+ current_language->polyglossiaOpts())
+ : subst(lang_begin_command, "$$lang", current_lang);
+ os << bc;
pending_newline = !localswitch;
unskip_newline = !localswitch;
}
DocumentClass const & tclass = bparams.documentClass();
if ((style == next_layout
&& !style.parbreak_is_newline
+ && !text.inset().getLayout().parbreakIsNewline()
&& style.latextype != LATEX_ITEM_ENVIRONMENT
&& style.latextype != LATEX_LIST_ENVIRONMENT
&& style.align == par.getAlign()
? getPolyglossiaEnvName(bparams.language)
: bparams.language->babel();
string const lang_begin_command = runparams.use_polyglossia ?
- "\\begin{$$lang}" : lyxrc.language_command_begin;
+ "\\begin{$$lang}$$opts" : lyxrc.language_command_begin;
if (maintext && !lyxrc.language_auto_begin &&
!mainlang.empty()) {
// FIXME UNICODE
- os << from_utf8(subst(lang_begin_command,
- "$$lang",
- mainlang));
- if (runparams.use_polyglossia
- && !bparams.language->polyglossiaOpts().empty())
- os << "["
- << from_ascii(bparams.language->polyglossiaOpts())
- << "]";
+ string bc = runparams.use_polyglossia ?
+ getPolyglossiaBegin(lang_begin_command, mainlang,
+ bparams.language->polyglossiaOpts())
+ : subst(lang_begin_command, "$$lang", mainlang);
+ os << bc;
os << '\n';
}