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
This commit is contained in:
Richard Heck 2011-12-07 22:33:25 +00:00
parent 70ad54bec9
commit 5a7672adec
8 changed files with 61 additions and 19 deletions

View File

@ -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

View File

@ -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]],

View File

@ -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<string>(use_indices)
<< "\n\\paperorientation " << string_orientation[orientation]
<< "\n\\suppress_date " << convert<string>(suppress_date)
<< "\n\\justification " << convert<string>(justification)
<< "\n\\use_refstyle " << use_refstyle
<< '\n';
if (isbackgroundcolor == true)

View File

@ -305,6 +305,8 @@ public:
std::string float_placement;
///
unsigned int columns;
///
bool justification;
/// parameters for the listings package
std::string listings_params;
///

View File

@ -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);

View File

@ -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(

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TextLayoutUi</class>
<widget class="QWidget" name="TextLayoutUi">
@ -6,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>421</width>
<height>280</height>
<height>327</height>
</rect>
</property>
<property name="windowTitle">
@ -245,20 +246,10 @@
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="twoColumnCB">
<property name="toolTip">
<string>Format text into two columns</string>
</property>
<property name="text">
<string>Two-&amp;column document</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<item row="4" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -274,6 +265,23 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="twoColumnCB">
<property name="toolTip">
<string>Format text into two columns</string>
</property>
<property name="text">
<string>Two-&amp;column document</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="justCB">
<property name="text">
<string>Use &amp;Justification</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
@ -294,7 +302,6 @@
<tabstop>skipLengthCO</tabstop>
<tabstop>lspacingCO</tabstop>
<tabstop>lspacingLE</tabstop>
<tabstop>twoColumnCB</tabstop>
</tabstops>
<includes>
<include location="local">qt_i18n.h</include>

View File

@ -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