]> git.lyx.org Git - features.git/commitdiff
Fix right and left layout alignment (in workarea) with RTL
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 10 Jul 2019 12:50:08 +0000 (14:50 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:35 +0000 (15:48 +0200)
Fixes: #11606
src/Paragraph.cpp
src/Paragraph.h
src/TextMetrics.cpp
src/frontends/qt4/GuiParagraph.cpp
src/frontends/qt4/GuiParagraph.h
src/output_latex.cpp

index 4900104e692d855526122ce9a7ea75874a65d0d7..ab5aeb95ebd0b96cb1b613508119dfbfc58cc435 100644 (file)
@@ -1983,15 +1983,29 @@ depth_type Paragraph::getMaxDepthAfter() const
 }
 
 
-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();
index 2f61083b801d7c203faae6ffbf25f67740ad6b40..dbf7f2a51cda8a1d01261c460dbd49ce4a768ad5 100644 (file)
@@ -312,7 +312,9 @@ public:
        /// Set label width string.
        void setLabelWidthString(docstring const & s);
        /// Actual paragraph alignment used
-       LyXAlignment getAlign() const;
+       LyXAlignment getAlign(BufferParams const &) const;
+       /// Default paragraph alignment as determined by layout
+       LyXAlignment getDefaultAlign(BufferParams const &) const;
        /// The nesting depth of a paragraph
        depth_type getDepth() const;
        /// The maximal possible depth of a paragraph after this one
index 739b980dccf6e8f8f4c181363a4f6ea3da72661a..d07c5500eec47f5d51c1de2f5a2e41b5b7476a5a 100644 (file)
@@ -595,7 +595,7 @@ bool TextMetrics::redoParagraph(pit_type const pit, bool const align_rows)
 
 LyXAlignment TextMetrics::getAlign(Paragraph const & par, Row const & row) const
 {
-       LyXAlignment align = par.getAlign();
+       LyXAlignment align = par.getAlign(bv_->buffer().params());
 
        // handle alignment inside tabular cells
        Inset const & owner = text_->inset();
@@ -1755,7 +1755,7 @@ int TextMetrics::leftMargin(pit_type const pit, pos_type const pos) const
        if (!par.params().leftIndent().zero())
                l_margin += par.params().leftIndent().inPixels(max_width_, lfm.em());
 
-       LyXAlignment align = par.getAlign();
+       LyXAlignment align = par.getAlign(bv_->buffer().params());
 
        // set the correct parindent
        if (pos == 0
index ab6c9aef8b671cee8386a098c0244fb547c88b0b..0b54d7aaa4bb0c093c488fbfa8086a149c2d0d50 100644 (file)
@@ -125,7 +125,7 @@ void GuiParagraph::checkAlignmentRadioButtons()
                alignDefaultRB->setText(alignDefaultLabel_);
        else
                alignDefaultRB->setText(alignDefaultLabel_ + " ("
-                       + labelMap_[alignDefault()] + ")");
+                       + labelMap_[bufferview()->cursor().innerParagraph().getDefaultAlign(buffer().params())] + ")");
 }
 
 
@@ -372,12 +372,6 @@ LyXAlignment GuiParagraph::alignPossible() const
 }
 
 
-LyXAlignment GuiParagraph::alignDefault() const
-{
-       return bufferview()->cursor().innerParagraph().layout().align;
-}
-
-
 bool GuiParagraph::hasLabelwidth() const
 {
        Layout layout = bufferview()->cursor().innerParagraph().layout();
index 132e916509d77fab48ae2ecf745a7a47f4d688c3..49e0074d64a67140053729c489cbc144dc2f4d9a 100644 (file)
@@ -60,8 +60,6 @@ private:
        bool hasLabelwidth() const;
        ///
        LyXAlignment alignPossible() const;
-       ///
-       LyXAlignment alignDefault() const;
 
 private Q_SLOTS:
        ///
index ed11307f148e5fba7e9ca248be9e31abec9b1bae..41e579a55441b49ff9cc4729d2bb43046e12e504 100644 (file)
@@ -1402,20 +1402,20 @@ void TeXOnePar(Buffer const & buf,
                             && !text.inset().getLayout().parbreakIgnored()
                             && style.latextype != LATEX_ITEM_ENVIRONMENT
                             && style.latextype != LATEX_LIST_ENVIRONMENT
-                            && style.align == par.getAlign()
+                            && style.align == par.getAlign(bparams)
                             && nextpar->getDepth() == par.getDepth()
-                            && nextpar->getAlign() == par.getAlign())
+                            && nextpar->getAlign(bparams) == par.getAlign(bparams))
                            || (!next_layout.isEnvironment()
                                && nextpar->getDepth() > par.getDepth()
-                               && nextpar->getAlign() == next_layout.align)
+                               && nextpar->getAlign(bparams) == next_layout.align)
                            || (!style.isEnvironment()
                                && next_layout.latextype == LATEX_ENVIRONMENT
                                && nextpar->getDepth() < par.getDepth())
                            || (style.isCommand()
                                && !next_layout.isEnvironment()
-                               && style.align == par.getAlign()
-                               && next_layout.align == nextpar->getAlign())
-                           || (style.align != par.getAlign()
+                               && style.align == par.getAlign(bparams)
+                               && next_layout.align == nextpar->getAlign(bparams))
+                           || (style.align != par.getAlign(bparams)
                                && tclass.isDefaultLayout(next_layout))) {
                                os << '\n';
                        }