]> git.lyx.org Git - features.git/commitdiff
Revert the box alignment part of 8010b90c
authorGeorg Baum <baum@lyx.org>
Fri, 23 Oct 2015 20:08:38 +0000 (22:08 +0200)
committerGeorg Baum <baum@lyx.org>
Fri, 23 Oct 2015 20:08:38 +0000 (22:08 +0200)
The horizontal alignment changes caused a regression for documents in older
formats. This could have been fixed by adding the following lines to the
format entry for 489 in development/FORMAT:

Previously, the horizontal position was ignored except for the
following parameter combinations:
- fixed width and type Boxed and without inner box
- fixed width and any type   and with    inner box and with makebox
Now, it is also used for the parameter combination below:
- makebox is not used and not (type Boxed and without inner box)

and a corresponding conversion to convert_BoxFeatures() in
lib/lyx2lyx/lyx_2_2.py. However, it was decided to revert the box alignment
changes instead: The box alignment can contradict the paragraph alignment. A
better way to avoid the additional space that can be created by paragraph
alignment (which was the motivation for implementing box alignment) is the
same as for table cells (see noTrivlistCentering() in src/Paragraph.cpp).
This would be a file format change and it is too late now for 2.2.0.

See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg188147.html for the
complete discussion (subject "Regression in lyx2lyx box alignment").

src/frontends/qt4/GuiBox.cpp
src/insets/InsetBox.cpp
src/tex2lyx/test/box-color-size-space-align.lyx.lyx
src/tex2lyx/text.cpp

index c76aeaf2b5ecdccbf5121b1b9c6be08c75b146fd..0999039ddadb9fcea100b6c07aae1bd5f2709585 100644 (file)
@@ -344,8 +344,10 @@ void GuiBox::paramsToDialog(Inset const * inset)
        ialignCO->setEnabled(ibox);
        setSpecial(ibox);
 
-       // halign is only allowed if a width is used
-       halignCO->setEnabled(widthCB->isChecked());
+       // halign is only allowed without inner box and if a width is used and if
+       // pagebreak is not used
+       halignCO->setEnabled(!pagebreakCB->isChecked() && widthCB->isChecked()
+                            && ((!ibox && type == "Boxed") || inner_type == "makebox"));
        // add the entry "Stretch" if the box is \makebox or \framebox and if not already there
        if ((inner_type == "makebox" || (type == "Boxed" && inner_type == "none"))
                && halignCO->count() < 4)
@@ -557,8 +559,10 @@ bool GuiBox::checkWidgets(bool readonly) const
                        widthED->setEnabled(false);
                        widthUnitsLC->setEnabled(false);
                }
-               // halign is only allowed if a width is used
-               halignCO->setEnabled(widthCB->isChecked());
+               // halign is only allowed without inner box and if a width is used and if
+               // pagebreak is not used
+               halignCO->setEnabled(!pagebreakCB->isChecked() && widthCB->isChecked()
+                                    && ((!ibox && outer == "Boxed") || itype == "makebox"));
                // add the entry "Stretch" if the box is \makebox or \framebox and if not already there
                if ((itype == "makebox" || (outer == "Boxed" && itype == "none"))
                        && halignCO->count() < 4)
index 21d7feb9951da235f751bfbbaad4d1e76b3fc1ec..bfa188e36eddbc0835e701104eb7ad6f20d14a96 100644 (file)
@@ -508,23 +508,6 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
                os << "\\begin{shaded}%\n";
        }
 
-       // \framebox and \makebox handle hor_pos their own way
-       // hor_pos is senseless for \mbox and \fbox
-       if (!params_.use_makebox
-               && !(btype == Boxed && !params_.inner_box)) {
-                       switch (params_.hor_pos) {
-                       case 'l':
-                               // do nothing because this is LaTeX's default
-                               break;
-                       case 'c':
-                               os << "\\centering ";
-                               break;
-                       case 'r':
-                               os << "\\raggedleft ";
-                               break;
-                       }
-       }
-
        InsetText::latex(os, runparams);
 
        if (btype == Shaded)
index 2b5fa541f6beb50f62dd75f3cbc4611daf3f0f0e..131777a35ba503724c685682393c77118c73a594 100644 (file)
@@ -1266,7 +1266,7 @@ status collapsed
 
 \begin_inset Box Shadowbox
 position "c"
-hor_pos "c"
+hor_pos "l"
 has_inner_box 0
 inner_pos "c"
 use_parbox 0
@@ -1284,7 +1284,19 @@ status open
 
 
 \begin_layout Standard
-www
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+centering
+\end_layout
+
+\end_inset
+
+ www
 \end_layout
 
 \end_inset
@@ -1306,7 +1318,7 @@ status collapsed
 
 \begin_inset Box Frameless
 position "t"
-hor_pos "c"
+hor_pos "l"
 has_inner_box 1
 inner_pos "t"
 use_parbox 1
@@ -1324,7 +1336,19 @@ status open
 
 
 \begin_layout Plain Layout
-www
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+centering
+\end_layout
+
+\end_inset
+
+ www
 \end_layout
 
 \end_inset
@@ -1358,7 +1382,7 @@ raggedleft
  
 \begin_inset Box Frameless
 position "t"
-hor_pos "c"
+hor_pos "l"
 has_inner_box 1
 inner_pos "t"
 use_parbox 1
@@ -1376,6 +1400,18 @@ status open
 
 
 \begin_layout Plain Layout
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+centering
+\end_layout
+
+\end_inset
+
  www
 \end_layout
 
index d7e18fa4402d4b2eee44a9eecda99bd0ed8ada6b..0e593ceca540515bb20d04ac25720e50fa34d814 100644 (file)
@@ -127,7 +127,6 @@ string parse_text_snippet(Parser & p, unsigned flags, const bool outer,
 string fboxrule = "";
 string fboxsep = "";
 string shadow_size = "";
-bool wasBoxAlign = false;
 
 char const * const known_ref_commands[] = { "ref", "pageref", "vref",
  "vpageref", "prettyref", "nameref", "eqref", 0 };
@@ -1023,37 +1022,6 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
                p.popPosition();
        }
 
-       // try to determine the box content alignment
-       // first handle the simple case of "{\centering..."
-       if (p.next_token().asInput() == "\\raggedright") {
-               wasBoxAlign = true;
-               hor_pos = "l";
-       } else if (p.next_token().asInput() == "\\centering") {
-               wasBoxAlign = true;
-               hor_pos = "c";
-       } else if (p.next_token().asInput() == "\\raggedleft") {
-               wasBoxAlign = true;
-               hor_pos = "r";
-       } else {
-               // now handle the cases "{%catNewline\centering..."
-               // and "{catNewline\centering..."
-               p.pushPosition();
-               p.get_token().asInput();
-               if (p.next_token().cat() == catComment || p.next_token().cat() == catNewline)
-                       p.get_token().asInput();
-               if (p.next_token().asInput() == "\\raggedright") {
-                       wasBoxAlign = true;
-                       hor_pos = "l";
-               } else if (p.next_token().asInput() == "\\centering") {
-                       wasBoxAlign = true;
-                       hor_pos = "c";
-               } else if (p.next_token().asInput() == "\\raggedleft") {
-                       wasBoxAlign = true;
-                       hor_pos = "r";
-               }
-               p.popPosition();
-       }
-
        if (use_ert) {
                ostringstream ss;
                if (!outer_type.empty()) {
@@ -4308,17 +4276,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                                shadow_size = shadow_size + p.get_token().asInput();
                                }
                        } else {
-                               // we only handle them if they are in a box
-                               if (wasBoxAlign) {
-                                       // LyX will add a space after outputting the
-                                       // alignment command, so eat any space which
-                                       // might follow. Otherwise the paragraph
-                                       // might start with an unneeded space.
-                                       p.skip_spaces(true);
-                               } else
-                                       output_ert_inset(os, t.asInput(), context);
+                               output_ert_inset(os, t.asInput(), context);
                        }
-                       wasBoxAlign = false;
                }
 
                //\framebox() is part of the picture environment and different from \framebox{}