]> 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)
committerJuergen Spitzmueller <spitz@lyx.org>
Thu, 11 Jul 2019 06:31:50 +0000 (08:31 +0200)
Fixes: #11606
(cherry picked from commit b6f0c1de3d31b33452ad87a3a416731907e3c52e)

src/Paragraph.cpp
src/Paragraph.h
src/TextMetrics.cpp
src/frontends/qt4/GuiParagraph.cpp
src/frontends/qt4/GuiParagraph.h
src/output_latex.cpp
status.23x

index 8c77f5876726f9d5259869e5498d0137ff0f245f..9d1b9e6f1fcb63f72f33316d31fe1df0b3cf1791 100644 (file)
@@ -2032,15 +2032,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 34ae917f182cb49856aedd6ec5015850bb219bf8..61cd05853e9adaeff51f0ab9d72c426f21961c0f 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 f7397f7b89eba53042340c1293ad61e0327b215f..070a880e62d7c60fe9aa4415004bd55e6be968e1 100644 (file)
@@ -537,7 +537,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
 
 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();
@@ -1749,7 +1749,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 656e70f3042e7a19fb541b2a20dc2b271102d7f8..7b16fe9fdabdef77ed15ba1277c5ba418903e2b1 100644 (file)
@@ -122,7 +122,7 @@ void GuiParagraph::checkAlignmentRadioButtons()
                alignDefaultRB->setText(alignDefaultLabel_);
        else
                alignDefaultRB->setText(alignDefaultLabel_ + " ("
-                       + labelMap_[alignDefault()] + ")");
+                       + labelMap_[bufferview()->cursor().innerParagraph().getDefaultAlign(buffer().params())] + ")");
 }
 
 
@@ -370,12 +370,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 735d58ca8f457c989bb0ca4ca651e49b13727b7d..7d9170b856fbb3ae979bf5163f7375bb18035479 100644 (file)
@@ -60,8 +60,6 @@ private:
        bool hasLabelwidth() const;
        ///
        LyXAlignment alignPossible() const;
-       ///
-       LyXAlignment alignDefault() const;
 
 private Q_SLOTS:
        ///
index 3aa219b42ff56f2ea78bf585d24e57113e325516..91e9f60149a6c53d8594132b5535b516d0d3247b 100644 (file)
@@ -1328,20 +1328,20 @@ void TeXOnePar(Buffer const & buf,
                             && !text.inset().getLayout().parbreakIsNewline()
                             && 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';
                        }
index e3c552244359e0322e59f7868613de80f2d47017..d29ff0a4ae4cc6e1c628fa6840c645ed4d35f600 100644 (file)
@@ -90,6 +90,8 @@ What's new
 - Preserve "all authors" state when switching citation style via context
   menu (bug 11439).
 
+- Fix right and left layout alignment (in workarea) with RTL (bug 11606).
+
 
 * INTERNALS