]> git.lyx.org Git - features.git/commitdiff
Fix bug #5805 and similar requests. Adds a document setting that
authorRichard Heck <rgheck@comcast.net>
Wed, 7 Dec 2011 22:33:25 +0000 (22:33 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 7 Dec 2011 22:33:25 +0000 (22:33 +0000)
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

lib/doc/UserGuide.lyx
lib/lyx2lyx/lyx_2_1.py
src/BufferParams.cpp
src/BufferParams.h
src/TextMetrics.cpp
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/ui/TextLayoutUi.ui
src/version.h

index b8b2949438b052528d022e1ec4967f9887f67c9c..c6a8d61662db40a5c237b8d38ae43e28108af52e 100644 (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
index ebff63693b43ef0084502148bc5a679fd4935c7a..064b938ad1bb5e862a4a6fbe57c663603c419a8e 100644 (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]],
index e20cca4f71d087ee627d5091374eaffb082c0e65..5770d2544b9bf89bfbcfe2c06fce34355037c330 100644 (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)
index 842fc28f71b7fed78cad7bde1e2754f2663b74d3..4a483b99483e156c8026bdab00ba812b1fe03b0c 100644 (file)
@@ -305,6 +305,8 @@ public:
        std::string float_placement;
        ///
        unsigned int columns;
+       ///
+       bool justification;
        /// parameters for the listings package
        std::string listings_params;
        ///
index ecc9e5219487d3015fde15ecb0d6aaf336fcb139..50f6062275a685b238031c94eb8c02cccc8bf8f5 100644 (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);
index 0f9e14b8f0fbd0c4475f6a78448c3b7ef0ee6b3a..378149f6170e7af2b97629f638490e1081292819 100644 (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(
index dadcd79cc4b102aa1363a4f419e381c0d7e0b224..365170bed75887c7b74b2835142fd88985ce847a 100644 (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">
         </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>
      </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>
   <tabstop>skipLengthCO</tabstop>
   <tabstop>lspacingCO</tabstop>
   <tabstop>lspacingLE</tabstop>
-  <tabstop>twoColumnCB</tabstop>
  </tabstops>
  <includes>
   <include location="local">qt_i18n.h</include>
index dd0ad2ba2a6e1f10ba313547b5d91eb1269e2b2b..fc2bfdd36f68b854b81bfd8a6789361cda2f2940 100644 (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