bool close = false;
odocstream::pos_type const len = os.os().tellp();
- if (inset->forceLTR()
+ if (inset->forceLTR(runparams)
&& running_font.isRightToLeft()
// ERT is an exception, it should be output with no
// decorations at all
// Most likely, we should simply rely on Qt's unicode handling here.
string const & lang = getFontSettings(bparams, pos).language()->lang();
- // With polyglossia, brackets and stuff need not be reversed in RTL scripts
+ // With polyglossia and XeTeX (bidi), brackets and stuff need not be
+ // reversed in RTL scripts
// FIXME: The special casing for Hebrew parens is due to the special
// handling on input (for Hebrew in e5f42f67d/lyxgit); see #8251.
char_type uc = c;
- if (rp.use_polyglossia) {
+ if (rp.use_polyglossia && rp.flavor == OutputParams::XETEX) {
switch (c) {
case '(':
if (lang == "hebrew")
}
return uc;
}
+ // LuaTeX (luabidi) is different
+ if (rp.use_polyglossia && rp.flavor != OutputParams::XETEX) {
+ switch (c) {
+ case '(':
+ if (lang != "hebrew")
+ uc = ')';
+ break;
+ case ')':
+ if (lang != "hebrew")
+ uc = '(';
+ break;
+ }
+ }
// In the following languages, brackets don't need to be reversed.
// Furthermore, in arabic_arabi, they are transformed to Arabic
}
-LyXAlignment Paragraph::getAlign() const
+LyXAlignment Paragraph::getAlign(BufferParams const & bparams) const
{
if (d->params_.align() == LYX_ALIGN_LAYOUT)
- return d->layout_->align;
+ return getDefaultAlign(bparams);
else
return d->params_.align();
}
+LyXAlignment Paragraph::getDefaultAlign(BufferParams const & bparams) const
+{
+ LyXAlignment res = layout().align;
+ if (isRTL(bparams)) {
+ // Swap sides
+ if (res == LYX_ALIGN_LEFT)
+ res = LYX_ALIGN_RIGHT;
+ else if (res == LYX_ALIGN_RIGHT)
+ res = LYX_ALIGN_LEFT;
+ }
+ return res;
+}
+
+
docstring const & Paragraph::labelString() const
{
return d->params_.labelString();
string const begin_tag = "\\begin";
InsetCode code = ownerCode();
bool const lastpar = runparams.isLastPar;
- // RTL without the Bidi package switches the left/right logic
+ // RTL in classic (PDF)LaTeX (without the Bidi package)
+ // Luabibdi (used by LuaTeX) behaves like classic
bool const rtl_classic = owner_->getParLanguage(bparams)->rightToLeft()
- && !runparams.use_polyglossia;
+ && (!runparams.use_polyglossia || runparams.flavor != OutputParams::XETEX);
switch (curAlign) {
case LYX_ALIGN_NONE:
string const end_tag = "\\par\\end";
InsetCode code = ownerCode();
bool const lastpar = runparams.isLastPar;
- // RTL without the Bidi package switches the left/right logic
+ // RTL in classic (PDF)LaTeX (without the Bidi package)
+ // Luabibdi (used by LuaTeX) behaves like classic
bool const rtl_classic = owner_->getParLanguage(bparams)->rightToLeft()
- && !runparams.use_polyglossia;
+ && (!runparams.use_polyglossia || runparams.flavor != OutputParams::XETEX);
switch (curAlign) {
case LYX_ALIGN_NONE:
runningChange, style, i, column);
if (incremented)
--parInline;
+
+ if (deleted_display_math) {
+ // Close \lyxdeleted and force its
+ // reopening (if needed)
+ os << '}';
+ column++;
+ runningChange = Change(Change::UNCHANGED);
+ }
}
} else if (i >= start_pos && (end_pos == -1 || i < end_pos)) {
try {
// such as Note that do not produce any output, so that no
// command is ever executed but its opening was recorded.
runparams.inulemcmd = rp.inulemcmd;
+
+ // These need to be passed upstream as well
+ runparams.need_maketitle = rp.need_maketitle;
+ runparams.have_maketitle = rp.have_maketitle;
}
// If we have an open font definition, we have to close it
bool Paragraph::brokenBiblio() const
{
- // there is a problem if there is no bibitem at position 0 or
- // if there is another bibitem in the paragraph.
- return d->layout_->labeltype == LABEL_BIBLIO
+ // There is a problem if there is no bibitem at position 0 in
+ // paragraphs that need one, if there is another bibitem in the
+ // paragraph or if this paragraph is not supposed to have
+ // a bibitem inset at all.
+ return ((d->layout_->labeltype == LABEL_BIBLIO
&& (d->insetlist_.find(BIBITEM_CODE) != 0
- || d->insetlist_.find(BIBITEM_CODE, 1) > 0);
+ || d->insetlist_.find(BIBITEM_CODE, 1) > 0))
+ || (d->layout_->labeltype != LABEL_BIBLIO
+ && d->insetlist_.find(BIBITEM_CODE) != -1));
}
int Paragraph::fixBiblio(Buffer const & buffer)
{
- // FIXME: What about the case where paragraph is not BIBLIO
- // but there is an InsetBibitem?
// FIXME: when there was already an inset at 0, the return value is 1,
- // which does not tell whether another inset has been remove; the
+ // which does not tell whether another inset has been removed; the
// cursor cannot be correctly updated.
- if (d->layout_->labeltype != LABEL_BIBLIO)
- return 0;
-
bool const track_changes = buffer.params().track_changes;
int bibitem_pos = d->insetlist_.find(BIBITEM_CODE);
- bool const hasbibitem0 = bibitem_pos == 0;
+ // The case where paragraph is not BIBLIO
+ if (d->layout_->labeltype != LABEL_BIBLIO) {
+ if (bibitem_pos == -1)
+ // No InsetBibitem => OK
+ return 0;
+ // There is an InsetBibitem: remove it!
+ d->insetlist_.release(bibitem_pos);
+ eraseChar(bibitem_pos, track_changes);
+ return (bibitem_pos == 0) ? -1 : -bibitem_pos;
+ }
+
+ bool const hasbibitem0 = bibitem_pos == 0;
if (hasbibitem0) {
bibitem_pos = d->insetlist_.find(BIBITEM_CODE, 1);
- // There was an InsetBibitem at pos 0, and no other one => OK
+ // There was an InsetBibitem at pos 0,
+ // and no other one => OK
if (bibitem_pos == -1)
return 0;
// there is a bibitem at the 0 position, but since
// than keep the first? (JMarc)
Inset * inset = releaseInset(bibitem_pos);
d->insetlist_.begin()->inset = inset;
+ // This needs to be done to update the counter (#8499)
+ buffer.updateBuffer();
return -bibitem_pos;
}
// We need to create an inset at the beginning
- Inset * inset = 0;
+ Inset * inset = nullptr;
if (bibitem_pos > 0) {
// there was one somewhere in the paragraph, let's move it
inset = d->insetlist_.release(bibitem_pos);
insertInset(0, inset, font, Change(track_changes ? Change::INSERTED
: Change::UNCHANGED));
+ // This is needed to get the counters right
+ buffer.updateBuffer();
return 1;
}