diff --git a/src/frontends/qt4/GuiBox.cpp b/src/frontends/qt4/GuiBox.cpp index c76aeaf2b5..0999039dda 100644 --- a/src/frontends/qt4/GuiBox.cpp +++ b/src/frontends/qt4/GuiBox.cpp @@ -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) diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 21d7feb995..bfa188e36e 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -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) diff --git a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx index 2b5fa541f6..131777a35b 100644 --- a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx +++ b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx @@ -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 diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index d7e18fa440..0e593ceca5 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -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{}