[LyX/master] Move some tests upstream, since we'll need it there
Juergen Spitzmueller
spitz at lyx.org
Sat Aug 15 10:04:25 UTC 2020
commit 0a44c1687e11d7943517ae36ee413c4a7568714d
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Sat Aug 15 12:26:07 2020 +0200
Move some tests upstream, since we'll need it there
---
src/Paragraph.cpp | 49 +++++++++++++++++++++++++++++++------------------
1 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 7fd7eeb..3acdd93 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -342,7 +342,10 @@ public:
Change & running_change,
Layout const & style,
pos_type & i,
- unsigned int & column);
+ unsigned int & column,
+ bool const fontswitch_inset,
+ bool const closeLanguage,
+ bool const lang_switched_at_inset);
///
void latexSpecialChar(
@@ -957,7 +960,10 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
Change & running_change,
Layout const & style,
pos_type & i,
- unsigned int & column)
+ unsigned int & column,
+ bool const fontswitch_inset,
+ bool const closeLanguage,
+ bool const lang_switched_at_inset)
{
Inset * inset = owner_->getInset(i);
LBUFERR(inset);
@@ -1028,21 +1034,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
}
if (open_font && (!inset->inheritFont() || inset->allowMultiPar())) {
- // Some insets cannot be inside a font change command.
- // However, even such insets *can* be placed in \L or \R
- // or their equivalents (for RTL language switches),
- // so we don't close the language in those cases
- // (= differing isRightToLeft()).
- // ArabTeX, though, doesn't seem to handle this special behavior.
- bool const inRLSwitch =
- basefont.isRightToLeft() != running_font.isRightToLeft()
- && basefont.language()->lang() != "arabic_arabtex"
- && running_font.language()->lang() != "arabic_arabtex";
- // Having said that, PassThru insets must be inside a font change command,
- // as we do not re-open the font inside. So:
- bool const closeLanguage = !inset->isPassThru() && !inRLSwitch;
bool lang_closed = false;
- bool lang_switched_at_inset = false;
// Close language if needed
if (closeLanguage) {
// We need prev_font here as language changes directly at inset
@@ -1058,7 +1050,6 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
needPar, closeLanguage);
column += count;
lang_closed = count > 0;
- lang_switched_at_inset = prev_font.language() != running_font.language();
}
// Update the running_font, making sure, however,
// to leave the language as it was.
@@ -2788,10 +2779,32 @@ void Paragraph::latex(BufferParams const & bparams,
// We need to restore parts of this after insets with
// allowMultiPar() true
Font const save_basefont = basefont;
+ Font const save_runningfont = running_font;
+ bool closeLanguage = false;
+ bool lang_switched_at_inset = false;
+ if (fontswitch_inset) {
+ // Some insets cannot be inside a font change command.
+ // However, even such insets *can* be placed in \L or \R
+ // or their equivalents (for RTL language switches),
+ // so we don't close the language in those cases
+ // (= differing isRightToLeft()).
+ // ArabTeX, though, doesn't seem to handle this special behavior.
+ bool const inRLSwitch =
+ basefont.isRightToLeft() != running_font.isRightToLeft()
+ && basefont.language()->lang() != "arabic_arabtex"
+ && running_font.language()->lang() != "arabic_arabtex";
+ // Having said that, PassThru insets must be inside a font change command,
+ // as we do not re-open the font inside. So:
+ closeLanguage = !inset->isPassThru() && !inRLSwitch;;
+ // We need to check prev_font as language changes directly at inset
+ // will only be started inside the inset.
+ lang_switched_at_inset = prev_font.language() != running_font.language();
+ }
d->latexInset(bparams, os, rp, running_font,
basefont, real_outerfont, open_font,
- runningChange, style, i, column);
if (multipar_inset) {
+ runningChange, style, i, column,
+ fontswitch_inset, closeLanguage, lang_switched_at_inset);
if (open_font) {
bool needPar = false;
column += running_font.latexWriteEndChanges(
More information about the lyx-cvs
mailing list