From: Richard Heck Date: Wed, 7 Dec 2011 22:33:25 +0000 (+0000) Subject: Fix bug #5805 and similar requests. Adds a document setting that X-Git-Tag: 2.1.0beta1~2240 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=5a7672adec7da591fe5c43ebcf8787a1fa11aa2c;p=features.git Fix bug #5805 and similar requests. Adds a document setting that tells LyX not to show BLOCK text as justified, but still keeps the usual paragraph indentation. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40427 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/doc/UserGuide.lyx b/lib/doc/UserGuide.lyx index b8b2949438..c6a8d61662 100644 --- a/lib/doc/UserGuide.lyx +++ b/lib/doc/UserGuide.lyx @@ -1,5 +1,5 @@ -#LyX 2.0 created this file. For more info see http://www.lyx.org/ -\lyxformat 413 +#LyX 2.1 created this file. For more info see http://www.lyx.org/ +\lyxformat 418 \begin_document \begin_header \textclass scrbook @@ -100,11 +100,13 @@ enumitem \use_esint 1 \use_mhchem 1 \use_mathdots 1 +\use_undertilde 1 \cite_engine basic \use_bibtopic false \use_indices false \paperorientation portrait \suppress_date false +\justification true \use_refstyle 0 \notefontcolor #0000ff \branch Question @@ -129,11 +131,12 @@ enumitem \papercolumns 1 \papersides 2 \paperpagestyle default -\tracking_changes false +\tracking_changes true \output_changes false \html_math_output 0 \html_css_as_file 0 \html_be_strict true +\author 1414654397 "Richard Heck" \end_header \begin_body @@ -43395,13 +43398,19 @@ Text Layout You can specify if paragraphs should be separated by indentations or vertical skips. The line spacing and the number of text columns can also be specified here. + +\change_inserted 1414654397 1323297066 +You can also determine whether text will be shown as justified in LyX itself. + Note that this does not affect whether the text is justified in the output. +\change_unchanged + \end_layout \begin_layout Standard Note that LyX will not show two columns or the set up line spacing on screen. That would be impractical, often unreadable and is not part of the WYSIWYM concept. - However, it will be as you specified it in the output. + However, in the output, it will be as you specified it. \end_layout \begin_layout Section diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index ebff63693b..064b938ad1 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -25,7 +25,8 @@ import sys, os # Uncomment only what you need to import, please. -from parser_tools import find_token, find_end_of_inset, get_value +from parser_tools import find_token, find_end_of_inset, get_value, \ + del_token #from parser_tools import find_token, find_end_of, find_tokens, \ #find_token_exact, find_end_of_inset, find_end_of_layout, \ @@ -192,6 +193,13 @@ def revert_japanese_encodings(document): document.header[i] = "\\inputencoding %s" % jap_enc_dict[val] +def revert_justification(document): + " Revert the \\justification buffer param" + if not del_token(document.header, '\\justification', 0): + document.warning("Malformed LyX document: Missing \\justification.") + + + ## # Conversion hub # @@ -202,9 +210,11 @@ convert = [ [415, [convert_undertilde]], [416, []], [417, [convert_japanese_encodings]], + [418, []], ] revert = [ + [417, [revert_justification]], [416, [revert_japanese_encodings]], [415, [revert_negative_space,revert_math_spaces]], [414, [revert_undertilde]], diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index e20cca4f71..5770d2544b 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -397,6 +397,7 @@ BufferParams::BufferParams() listings_params = string(); pagestyle = "default"; suppress_date = false; + justification = true; // no color is the default (white) backgroundcolor = lyx::rgbFromHexName("#ffffff"); isbackgroundcolor = false; @@ -603,6 +604,8 @@ string BufferParams::readToken(Lexer & lex, string const & token, master = lex.getString(); } else if (token == "\\suppress_date") { lex >> suppress_date; + } else if (token == "\\justification") { + lex >> justification; } else if (token == "\\language") { readLanguage(lex); } else if (token == "\\language_package") { @@ -1002,6 +1005,7 @@ void BufferParams::writeFile(ostream & os) const << "\n\\use_indices " << convert(use_indices) << "\n\\paperorientation " << string_orientation[orientation] << "\n\\suppress_date " << convert(suppress_date) + << "\n\\justification " << convert(justification) << "\n\\use_refstyle " << use_refstyle << '\n'; if (isbackgroundcolor == true) diff --git a/src/BufferParams.h b/src/BufferParams.h index 842fc28f71..4a483b9948 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -305,6 +305,8 @@ public: std::string float_placement; /// unsigned int columns; + /// + bool justification; /// parameters for the listings package std::string listings_params; /// diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index ecc9e52194..50f6062275 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -598,6 +598,11 @@ void TextMetrics::computeRowMetrics(pit_type const pit, } } + // Has the user requested we not justify stuff? + if (!bv_->buffer().params().justification + && align == LYX_ALIGN_BLOCK) + align = LYX_ALIGN_LEFT; + switch (align) { case LYX_ALIGN_BLOCK: { int const ns = numberOfSeparators(par, row); diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 0f9e14b8f0..378149f617 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -710,6 +710,8 @@ GuiDocument::GuiDocument(GuiView & lv) this, SLOT(change_adaptor())); connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()), this, SLOT(setColSep())); + connect(textLayoutModule->justCB, SIGNAL(clicked()), + this, SLOT(change_adaptor())); textLayoutModule->lspacingLE->setValidator(new QDoubleValidator( textLayoutModule->lspacingLE)); @@ -2428,6 +2430,8 @@ void GuiDocument::applyView() else bp_.columns = 1; + bp_.justification = textLayoutModule->justCB->isChecked(); + if (textLayoutModule->indentRB->isChecked()) { // if paragraphs are separated by an indentation bp_.paragraph_separation = BufferParams::ParagraphIndentSeparation; @@ -2876,6 +2880,7 @@ void GuiDocument::paramsToDialog() textLayoutModule->twoColumnCB->setChecked( bp_.columns == 2); + textLayoutModule->justCB->setChecked(bp_.justification); if (!bp_.options.empty()) { latexModule->optionsLE->setText( diff --git a/src/frontends/qt4/ui/TextLayoutUi.ui b/src/frontends/qt4/ui/TextLayoutUi.ui index dadcd79cc4..365170bed7 100644 --- a/src/frontends/qt4/ui/TextLayoutUi.ui +++ b/src/frontends/qt4/ui/TextLayoutUi.ui @@ -1,3 +1,4 @@ + TextLayoutUi @@ -6,7 +7,7 @@ 0 0 421 - 280 + 327 @@ -245,20 +246,10 @@ - - - - Format text into two columns - - - Two-&column document - - - - + Qt::Vertical @@ -274,6 +265,23 @@ + + + + Format text into two columns + + + Two-&column document + + + + + + + Use &Justification + + + @@ -294,7 +302,6 @@ skipLengthCO lspacingCO lspacingLE - twoColumnCB qt_i18n.h diff --git a/src/version.h b/src/version.h index dd0ad2ba2a..fc2bfdd36f 100644 --- a/src/version.h +++ b/src/version.h @@ -30,7 +30,7 @@ extern char const * const lyx_version_info; // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -#define LYX_FORMAT_LYX 417 // jrioux : rename the japanese encodings +#define LYX_FORMAT_LYX 418 // rgh: justification option #define LYX_FORMAT_TEX2LYX 417 #if LYX_FORMAT_FOR_TEX2LYX != LYX_FORMAT_FOR_LYX