]> git.lyx.org Git - features.git/commitdiff
support to specify the paragraph indentation in the document settings dialog; introdu...
authorUwe Stöhr <uwestoehr@web.de>
Sun, 19 Jul 2009 21:13:27 +0000 (21:13 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Sun, 19 Jul 2009 21:13:27 +0000 (21:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30694 a592a061-630c-0410-9148-cb99ea01b6c8

13 files changed:
development/FORMAT
development/scons/scons_manifest.py
lib/lyx2lyx/lyx_2_0.py
src/Buffer.cpp
src/BufferParams.cpp
src/BufferParams.h
src/HSpace.cpp [new file with mode: 0644]
src/HSpace.h [new file with mode: 0644]
src/Makefile.am
src/TextMetrics.cpp
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiDocument.h
src/frontends/qt4/ui/TextLayoutUi.ui

index 5c36ddb90218b6d88fe11262364950411c97918f..ece447fbcf6f896a53bda395fab7e2a19b8a8786 100644 (file)
@@ -1,6 +1,9 @@
 LyX file-format changes
 -----------------------
 
+2009-07-19 Uwe Stöhr <uwestoehr@web.de>
+       * Format incremented to 365: support for paragraph indentation.
+
 2009-07-13 Jürgen Spitzmüller <spitz@lyx.org>
        * Format incremented to 364: add \filename_suffix parameter
          to branches.
index da065ca46f4c121380747ba5f617079fbd82d2ab..ada004755b91f786476e92b38e2fc3d606f919c3 100644 (file)
@@ -74,6 +74,7 @@ src_header_files = Split('''
     FuncRequest.h
     FuncStatus.h
     Graph.h
+    HSpace.h
     HunspellSpellChecker.h
     IndicesList.h
     InsetIterator.h
@@ -177,6 +178,7 @@ src_pre_files = Split('''
     FuncRequest.cpp
     FuncStatus.cpp
     Graph.cpp
+    HSpace.cpp
     IndicesList.cpp
     InsetIterator.cpp
     InsetList.cpp
index cb2461dd52f10b5267ed25bbfc611869d2b7010d..5d043a1ddec8afe37f512a18f255c62305b3043d 100644 (file)
@@ -175,6 +175,50 @@ def lyx2latex(document, lines):
     return content
 
 
+def latex_length(string):
+    'Convert some LyX stuff into corresponding LaTeX stuff, as best we can.'
+    i = 0
+    percent = False
+    i = string.find("text%")
+    if i > -1:
+        percent = True
+        value = string[:i]
+        value = str(float(value)/100)
+        return value + "\\textwidth"
+    i = string.find("col%")
+    if i > -1:
+        percent = True
+        value = string[:i]
+        value = str(float(value)/100)
+        return value + "\\columnwidth"
+    i = string.find("page%")
+    if i > -1:
+        percent = True
+        value = string[:i]
+        value = str(float(value)/100)
+        return value + "\\paperwidth"
+    i = string.find("line%")
+    if i > -1:
+        percent = True
+        value = string[:i]
+        value = str(float(value)/100)
+        return value + "\\linewidth"
+    i = string.find("theight%")
+    if i > -1:
+        percent = True
+        value = string[:i]
+        value = str(float(value)/100)
+        return value + "\\textheight"
+    i = string.find("pheight%")
+    if i > -1:
+        percent = True
+        value = string[:i]
+        value = str(float(value)/100)
+        return value + "\\paperheight"
+    if percent ==  False:
+        return string
+
+
 ####################################################################
 
 
@@ -760,6 +804,32 @@ def revert_branch_filename(document):
         del document.header[i]
 
 
+def revert_paragraph_indentation(document):
+    " Revert custom paragraph indentation to preamble code "
+    i = 0
+    j = 0
+    while True:
+      i = find_token(document.header, "\\paragraph_indentation", i)
+      if i == -1:
+          break
+      # only remove the preamble line when default
+      # otherwise also write the value to the preamble  
+      j = document.header[i].find("default")
+      if j > -1:
+          del document.header[i]
+          break
+      else:
+          # search for the beginning of the value via the space
+          j = document.header[i].find(" ")
+          length = document.header[i][j+1:]
+          # handle percent lengths
+          length = latex_length(length) 
+          add_to_preamble(document, ["% this command was inserted by lyx2lyx"])
+          add_to_preamble(document, ["\\setlength{\\parindent}{" + length + "}"])
+          del document.header[i]
+      i = i + 1
+
+
 ##
 # Conversion hub
 #
@@ -783,10 +853,12 @@ convert = [[346, []],
            [361, []],
            [362, []],
            [363, []],
-           [364, []]
+           [364, []],
+           [365, []]
           ]
 
-revert =  [[363, [revert_branch_filename]],
+revert =  [[364, [revert_paragraph_indentation]],
+           [363, [revert_branch_filename]],
            [362, [revert_longtable_align]],
            [361, [revert_applemac]],
            [360, []],
index b9bdb05c0852f08c32418389f450409810ffbaaa..dfc32f3950899f6962a2eda2df962bacf25e5cb9 100644 (file)
@@ -127,7 +127,7 @@ namespace {
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-int const LYX_FORMAT = 364;  // spitz: branch suffixes for filenames
+int const LYX_FORMAT = 365;  // uwestoehr: support for custom paragraph indentation
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
index 1d54cd9fbaf984ee6d518cda54e15dbea601968d..250d3aa75d106277b78f4a0c67e5a0ad2689600f 100644 (file)
@@ -25,6 +25,7 @@
 #include "Color.h"
 #include "ColorSet.h"
 #include "Encoding.h"
+#include "HSpace.h"
 #include "IndicesList.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
@@ -289,6 +290,7 @@ public:
        /** This is the amount of space used for paragraph_separation "skip",
         * and for detached paragraphs in "indented" documents.
         */
+       HSpace indentation;
        VSpace defskip;
        PDFOptions pdfoptions;
        LayoutFileIndex baseClass_;
@@ -468,6 +470,18 @@ PDFOptions const & BufferParams::pdfoptions() const
 }
 
 
+HSpace const & BufferParams::getIndentation() const
+{
+       return pimpl_->indentation;
+}
+
+
+void BufferParams::setIndentation(HSpace const & indent)
+{
+       pimpl_->indentation = indent;
+}
+
+
 VSpace const & BufferParams::getDefSkip() const
 {
        return pimpl_->defskip;
@@ -566,6 +580,10 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                string parsep;
                lex >> parsep;
                paragraph_separation = parseptranslator().find(parsep);
+       } else if (token == "\\paragraph_indentation") {
+               lex.next();
+               string indentation = lex.getString();
+               pimpl_->indentation = HSpace(indentation);
        } else if (token == "\\defskip") {
                lex.next();
                string defskip = lex.getString();
@@ -903,9 +921,12 @@ void BufferParams::writeFile(ostream & os) const
        os << "\\secnumdepth " << secnumdepth
           << "\n\\tocdepth " << tocdepth
           << "\n\\paragraph_separation "
-          << string_paragraph_separation[paragraph_separation]
-          << "\n\\defskip " << getDefSkip().asLyXCommand()
-          << "\n\\quotes_language "
+          << string_paragraph_separation[paragraph_separation];
+       if (!paragraph_separation)
+               os << "\n\\paragraph_indentation " << getIndentation().asLyXCommand();
+       else
+               os << "\n\\defskip " << getDefSkip().asLyXCommand();
+       os << "\n\\quotes_language "
           << string_quotes_language[quotes_language]
           << "\n\\papercolumns " << columns
           << "\n\\papersides " << sides
@@ -1370,6 +1391,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        }
 
        if (paragraph_separation) {
+               // when skip separation
                switch (getDefSkip().kind()) {
                case VSpace::SMALLSKIP:
                        os << "\\setlength{\\parskip}{\\smallskipamount}\n";
@@ -1390,9 +1412,17 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                        break;
                }
                texrow.newline();
-
                os << "\\setlength{\\parindent}{0pt}\n";
                texrow.newline();
+       } else {
+               // when separation by indentation
+               // only output something when a width is given
+               if (getIndentation().asLyXCommand() != "default") {
+                       os << "\\setlength{\\parindent}{"
+                               << from_utf8(getIndentation().asLatexCommand())
+                          << "}\n";
+                       texrow.newline();
+               }
        }
 
        // Now insert the LyX specific LaTeX commands...
index d0888406f80f3a95f62ad92d821798d288dce0a9..32ea2e2ae09e546431a95dd3fb7aaadfa4527336 100644 (file)
@@ -36,6 +36,7 @@ class BranchList;
 class Bullet;
 class DocumentClass;
 class Encoding;
+class HSpace;
 class IndicesList;
 class Language;
 class LatexFeatures;
@@ -89,6 +90,10 @@ public:
        ///
        bool hasClassDefaults() const;
 
+       ///
+       HSpace const & getIndentation() const;
+       ///
+       void setIndentation(HSpace const & indent);
        ///
        VSpace const & getDefSkip() const;
        ///
diff --git a/src/HSpace.cpp b/src/HSpace.cpp
new file mode 100644 (file)
index 0000000..5a2b166
--- /dev/null
@@ -0,0 +1,163 @@
+/**
+ * \file HSpace.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Spitzmüller
+ * \author Uwe Stöhr
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "HSpace.h"
+
+#include "Buffer.h"
+#include "BufferParams.h"
+#include "BufferView.h"
+#include "support/gettext.h"
+#include "Length.h"
+#include "Text.h"
+
+#include "support/lstrings.h"
+
+#include "support/lassert.h"
+
+using namespace std;
+using namespace lyx::support;
+
+
+namespace lyx {
+
+
+HSpace::HSpace()
+       : kind_(DEFAULT), len_()
+{}
+
+
+HSpace::HSpace(HSpaceKind k)
+       : kind_(k), len_()
+{}
+
+
+HSpace::HSpace(Length const & l)
+       : kind_(LENGTH), len_(l)
+{}
+
+
+HSpace::HSpace(GlueLength const & l)
+       : kind_(LENGTH), len_(l)
+{}
+
+
+HSpace::HSpace(string const & data)
+       : kind_(DEFAULT), len_()
+{
+       if (data.empty())
+               return;
+
+       string input = rtrim(data);
+
+       if (prefixIs(input, "default"))
+               kind_ = DEFAULT;
+       else if (isValidGlueLength(input, &len_))
+               kind_ = LENGTH;
+}
+
+
+bool HSpace::operator==(HSpace const & other) const
+{
+       if (kind_ != other.kind_)
+               return false;
+       if (len_ != other.len_)
+               return false;
+       return true;
+}
+
+
+string const HSpace::asLyXCommand() const
+{
+       string result;
+       switch (kind_) {
+       case DEFAULT:
+               result = "default";
+               break;
+       case LENGTH:
+               result = len_.asString();
+               break;
+       }
+       return result;
+}
+
+
+string const HSpace::asLatexCommand() const
+{
+       switch (kind_) {
+       case DEFAULT:
+               return string();
+               break;
+       case LENGTH: {
+               return len_.asLatexString();
+               break;
+                                }
+       default: {
+               LASSERT(false, /**/);
+               return string();
+                        }
+       }
+}
+
+
+docstring const HSpace::asGUIName() const
+{
+       docstring result;
+       switch (kind_) {
+       case DEFAULT:
+               result = _("Default");
+               break;
+       case LENGTH:
+               result = from_ascii(len_.asString());
+               break;
+       }
+       return result;
+}
+
+
+string HSpace::asHTMLLength() const 
+{
+       string result;
+       switch (kind_) {
+       case DEFAULT:
+               // 30pt are LaTeX's default
+               result = "30pt";
+               break;
+       case LENGTH: {
+               Length tmp = len_.len();
+               if (tmp.value() > 0)
+                       result = tmp.asHTMLString();
+               break;
+               }
+       }
+       return result;
+}
+
+int HSpace::inPixels(BufferView const & bv) const
+{
+       switch (kind_) {
+       case DEFAULT:
+               // FIXME: replace by correct length
+               return bv.buffer().params().getIndentation().inPixels(bv);
+               //return 0;
+               break;
+       case LENGTH:
+               return len_.len().inPixels(bv.workWidth());
+               break;
+       default:
+               LASSERT(false, /**/);
+               return 0;
+       }
+}
+
+
+} // namespace lyx
diff --git a/src/HSpace.h b/src/HSpace.h
new file mode 100644 (file)
index 0000000..7c01f37
--- /dev/null
@@ -0,0 +1,78 @@
+// -*- C++ -*-
+/**
+ * \file HSpace.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Spitzmüller
+ * \author Uwe Stöhr
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef HSPACE_H
+#define HSPACE_H
+
+#include "Length.h"
+
+
+namespace lyx {
+
+
+class BufferParams;
+class BufferView;
+
+
+/// A class representing latex horizontal spacing
+class HSpace {
+public:
+       /// The different kinds of spaces.
+       enum HSpaceKind {
+               DEFAULT,
+               LENGTH ///< user-defined length
+       };
+
+       ///
+       HSpace();
+       ///
+       explicit HSpace(HSpaceKind k);
+       ///
+       explicit HSpace(Length const & l);
+       ///
+       explicit HSpace(GlueLength const & l);
+
+       /// Constructor for reading from a .lyx file
+       explicit HSpace(std::string const & data);
+
+       /// return the type of vertical space
+       HSpaceKind kind() const { return kind_; }
+       /// return the length of this space
+       GlueLength const & length() const { return len_; }
+
+       ///
+       bool operator==(HSpace const &) const;
+
+       // conversion
+
+       /// how it goes into the LyX file
+       std::string const asLyXCommand() const;
+       /// the latex representation
+       std::string const asLatexCommand() const;
+       ///
+       std::string asHTMLLength() const;
+       /// how it is seen in the LyX window
+       docstring const asGUIName() const;
+       /// the size of the space on-screen
+       int inPixels(BufferView const & bv) const;
+
+private:
+       /// This HSpace kind
+       HSpaceKind kind_;
+       /// the specified length
+       GlueLength len_;
+};
+
+
+} // namespace lyx
+
+#endif // HSPACE_H
index f1c9a5cbe4e933ff57a57f6e97b2747391c09224..c32ab7fa3cc3833c64114a98e83ebc95d35c890f 100644 (file)
@@ -116,6 +116,7 @@ SOURCEFILESCORE = \
        FuncRequest.cpp \
        FuncStatus.cpp \
        Graph.cpp \
+       HSpace.cpp \
        IndicesList.cpp \
        InsetIterator.cpp \
        InsetList.cpp \
@@ -216,6 +217,7 @@ HEADERFILESCORE = \
        FuncRequest.h \
        FuncStatus.h \
        Graph.h \
+       HSpace.h \
        IndicesList.h \
        InsetIterator.h \
        InsetList.h \
index c17bf2180a279a13a23bfedf0b4e08613b7d015b..45300db647e4a9ce90faed243dd6edbaaff182a3 100644 (file)
@@ -28,6 +28,7 @@
 #include "Cursor.h"
 #include "CutAndPaste.h"
 #include "FuncRequest.h"
+#include "HSpace.h"
 #include "InsetList.h"
 #include "Layout.h"
 #include "Length.h"
@@ -1949,11 +1950,16 @@ int TextMetrics::leftMargin(int max_width,
                 || tclass.isPlainLayout(par.layout()))
                || buffer.params().paragraph_separation == BufferParams::ParagraphIndentSeparation)
            )
-       {
-               l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
-                       parindent);
-       }
-
+               {
+                       // use the parindent of the layout when the default indentation is used
+                       // otherwise use the indentation set in the document settings
+                       if (buffer.params().getIndentation().asLyXCommand() == "default")
+                               l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
+                               parindent);
+                       else
+                               l_margin += buffer.params().getIndentation().inPixels(*bv_);
+               }
+       
        return l_margin;
 }
 
index 5b560160c91278577f6bfc2f0ef90d3a02e4ff20..6286db3d99e746fa1faf3b74cf07867a5db22414 100644 (file)
@@ -34,6 +34,7 @@
 #include "FloatPlacement.h"
 #include "Format.h"
 #include "FuncRequest.h"
+#include "HSpace.h"
 #include "IndicesList.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
@@ -553,20 +554,38 @@ GuiDocument::GuiDocument(GuiView & lv)
                this, SLOT(setLSpacing(int)));
        connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString &)),
                this, SLOT(change_adaptor()));
-       connect(textLayoutModule->skipRB, SIGNAL(clicked()),
-               this, SLOT(change_adaptor()));
+
        connect(textLayoutModule->indentRB, SIGNAL(clicked()),
                this, SLOT(change_adaptor()));
+       connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)),
+               textLayoutModule->indentCO, SLOT(setEnabled(bool)));
+       connect(textLayoutModule->indentCO, SIGNAL(activated(int)),
+               this, SLOT(change_adaptor()));
+       connect(textLayoutModule->indentCO, SIGNAL(activated(int)),
+               this, SLOT(setIndent(int)));
+       connect(textLayoutModule->indentLE, SIGNAL(textChanged(const QString &)),
+               this, SLOT(change_adaptor()));
+       connect(textLayoutModule->indentLengthCO, SIGNAL(activated(int)),
+               this, SLOT(change_adaptor()));
+
+       connect(textLayoutModule->skipRB, SIGNAL(clicked()),
+               this, SLOT(change_adaptor()));
+       connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
+               textLayoutModule->skipCO, SLOT(setEnabled(bool)));
        connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
                this, SLOT(change_adaptor()));
+       connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
+               this, SLOT(setSkip(int)));
        connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)),
                this, SLOT(change_adaptor()));
        connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)),
                this, SLOT(change_adaptor()));
-       connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
-               this, SLOT(setSkip(int)));
+
+       connect(textLayoutModule->indentRB, SIGNAL(toggled(bool)),
+               this, SLOT(enableIndent(bool)));
        connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
                this, SLOT(enableSkip(bool)));
+
        connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
                this, SLOT(change_adaptor()));
        connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
@@ -583,9 +602,13 @@ GuiDocument::GuiDocument(GuiView & lv)
                qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
        textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
                textLayoutModule->lspacingLE));
+       textLayoutModule->indentLE->setValidator(unsignedLengthValidator(
+               textLayoutModule->indentLE));
        textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
                textLayoutModule->skipLE));
 
+       textLayoutModule->indentCO->addItem(qt_("Default"));
+       textLayoutModule->indentCO->addItem(qt_("Custom"));
        textLayoutModule->skipCO->addItem(qt_("SmallSkip"));
        textLayoutModule->skipCO->addItem(qt_("MedSkip"));
        textLayoutModule->skipCO->addItem(qt_("BigSkip"));
@@ -600,8 +623,8 @@ GuiDocument::GuiDocument(GuiView & lv)
                Spacing::Double, qt_("Double"));
        textLayoutModule->lspacingCO->insertItem(
                Spacing::Other, qt_("Custom"));
-
        // initialize the length validator
+       bc().addCheckedLineEdit(textLayoutModule->indentLE);
        bc().addCheckedLineEdit(textLayoutModule->skipLE);
 
        // output
@@ -1115,19 +1138,39 @@ void GuiDocument::setLSpacing(int item)
 }
 
 
+void GuiDocument::setIndent(int item)
+{
+       bool const enable = (item == 1);
+       textLayoutModule->indentLE->setEnabled(enable);
+       textLayoutModule->indentLengthCO->setEnabled(enable);
+       textLayoutModule->skipLE->setEnabled(false);
+       textLayoutModule->skipLengthCO->setEnabled(false);
+       isValid();
+}
+
+
+void GuiDocument::enableIndent(bool indent)
+{
+       textLayoutModule->skipLE->setEnabled(!indent);
+       textLayoutModule->skipLengthCO->setEnabled(!indent);
+       if (indent)
+               setIndent(textLayoutModule->indentCO->currentIndex());
+}
+
+
 void GuiDocument::setSkip(int item)
 {
        bool const enable = (item == 3);
        textLayoutModule->skipLE->setEnabled(enable);
        textLayoutModule->skipLengthCO->setEnabled(enable);
+       isValid();
 }
 
 
 void GuiDocument::enableSkip(bool skip)
 {
-       textLayoutModule->skipCO->setEnabled(skip);
-       textLayoutModule->skipLE->setEnabled(skip);
-       textLayoutModule->skipLengthCO->setEnabled(skip);
+       textLayoutModule->indentLE->setEnabled(!skip);
+       textLayoutModule->indentLengthCO->setEnabled(!skip);
        if (skip)
                setSkip(textLayoutModule->skipCO->currentIndex());
 }
@@ -1894,35 +1937,53 @@ void GuiDocument::applyView()
        bp_.listings_params =
                InsetListingsParams(fromqstr(textLayoutModule->listingsED->toPlainText())).params();
 
-       if (textLayoutModule->indentRB->isChecked())
+       if (textLayoutModule->indentRB->isChecked()) {
+               // if paragraphs are separated by an indentation
                bp_.paragraph_separation = BufferParams::ParagraphIndentSeparation;
-       else
+               switch (textLayoutModule->indentCO->currentIndex()) {
+               case 0:
+                       bp_.setIndentation(HSpace(HSpace::DEFAULT));
+                       break;
+               case 1: {
+                       HSpace indent = HSpace(
+                               widgetsToLength(textLayoutModule->indentLE,
+                               textLayoutModule->indentLengthCO)
+                               );
+                       bp_.setIndentation(indent);
+                       break;
+                       }
+               default:
+                       // this should never happen
+                       bp_.setIndentation(HSpace(HSpace::DEFAULT));
+                       break;
+               }
+       } else {
+               // if paragraphs are separated by a skip
                bp_.paragraph_separation = BufferParams::ParagraphSkipSeparation;
-
-       switch (textLayoutModule->skipCO->currentIndex()) {
-       case 0:
-               bp_.setDefSkip(VSpace(VSpace::SMALLSKIP));
-               break;
-       case 1:
-               bp_.setDefSkip(VSpace(VSpace::MEDSKIP));
-               break;
-       case 2:
-               bp_.setDefSkip(VSpace(VSpace::BIGSKIP));
-               break;
-       case 3:
-       {
-               VSpace vs = VSpace(
-                       widgetsToLength(textLayoutModule->skipLE,
+               switch (textLayoutModule->skipCO->currentIndex()) {
+               case 0:
+                       bp_.setDefSkip(VSpace(VSpace::SMALLSKIP));
+                       break;
+               case 1:
+                       bp_.setDefSkip(VSpace(VSpace::MEDSKIP));
+                       break;
+               case 2:
+                       bp_.setDefSkip(VSpace(VSpace::BIGSKIP));
+                       break;
+               case 3:
+                       {
+                       VSpace vs = VSpace(
+                               widgetsToLength(textLayoutModule->skipLE,
                                textLayoutModule->skipLengthCO)
-                       );
-               bp_.setDefSkip(vs);
-               break;
-       }
-       default:
-               // DocumentDefskipCB assures that this never happens
-               // so Assert then !!!  - jbl
-               bp_.setDefSkip(VSpace(VSpace::MEDSKIP));
-               break;
+                               );
+                       bp_.setDefSkip(vs);
+                       break;
+                       }
+               default:
+                       // this should never happen
+                       bp_.setDefSkip(VSpace(VSpace::MEDSKIP));
+                       break;
+               }
        }
 
        bp_.options =
@@ -2210,37 +2271,49 @@ void GuiDocument::paramsToDialog()
        }
        setLSpacing(nitem);
 
-       if (bp_.paragraph_separation == BufferParams::ParagraphIndentSeparation)
+       if (bp_.paragraph_separation == BufferParams::ParagraphIndentSeparation) {
                textLayoutModule->indentRB->setChecked(true);
-       else
+               string indentation = bp_.getIndentation().asLyXCommand();
+               int indent = 0;
+               if (indentation == "default")
+                       indent = 0;
+               else {
+                       lengthToWidgets(textLayoutModule->indentLE,
+                       textLayoutModule->indentLengthCO,
+                       indentation, defaultUnit);
+                       indent = 1;
+               }
+               textLayoutModule->indentCO->setCurrentIndex(indent);
+               setIndent(indent);
+       } else {
                textLayoutModule->skipRB->setChecked(true);
-
-       int skip = 0;
-       switch (bp_.getDefSkip().kind()) {
-       case VSpace::SMALLSKIP:
-               skip = 0;
-               break;
-       case VSpace::MEDSKIP:
-               skip = 1;
-               break;
-       case VSpace::BIGSKIP:
-               skip = 2;
-               break;
-       case VSpace::LENGTH:
-       {
-               skip = 3;
-               string const length = bp_.getDefSkip().asLyXCommand();
-               lengthToWidgets(textLayoutModule->skipLE,
-                       textLayoutModule->skipLengthCO,
-                       length, defaultUnit);
-               break;
-       }
-       default:
-               skip = 0;
-               break;
+               int skip = 0;
+               switch (bp_.getDefSkip().kind()) {
+               case VSpace::SMALLSKIP:
+                       skip = 0;
+                       break;
+               case VSpace::MEDSKIP:
+                       skip = 1;
+                       break;
+               case VSpace::BIGSKIP:
+                       skip = 2;
+                       break;
+               case VSpace::LENGTH:
+                       {
+                       skip = 3;
+                       string const length = bp_.getDefSkip().asLyXCommand();
+                       lengthToWidgets(textLayoutModule->skipLE,
+                               textLayoutModule->skipLengthCO,
+                               length, defaultUnit);
+                       break;
+                       }
+               default:
+                       skip = 0;
+                       break;
+               }
+               textLayoutModule->skipCO->setCurrentIndex(skip);
+               setSkip(skip);
        }
-       textLayoutModule->skipCO->setCurrentIndex(skip);
-       setSkip(skip);
 
        textLayoutModule->twoColumnCB->setChecked(
                bp_.columns == 2);
@@ -2539,7 +2612,11 @@ bool GuiDocument::isValid()
 {
        return validateListingsParameters().isEmpty()
                && (textLayoutModule->skipCO->currentIndex() != 3
-                       || !textLayoutModule->skipLE->text().isEmpty());
+                       || !textLayoutModule->skipLE->text().isEmpty()
+                       || textLayoutModule->indentRB->isChecked())
+               && (textLayoutModule->indentCO->currentIndex() != 1
+                       || !textLayoutModule->indentLE->text().isEmpty()
+                       || textLayoutModule->skipRB->isChecked());
 }
 
 
index 00665eba73d6f0eded3860cc47a7d17475b490ee..161f48f6f66de9eca18954540c78545d8528b46c 100644 (file)
@@ -93,6 +93,8 @@ private Q_SLOTS:
        void romanChanged(int);
        void sansChanged(int);
        void ttChanged(int);
+       void setIndent(int);
+       void enableIndent(bool);
        void setSkip(int);
        void enableSkip(bool);
        void portraitChanged();
index 3e6712472c1d3e4511a18cfb882b810cef5bdee0..d91703049f622f274f4779356854d9bcabb4bbac 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>400</width>
-    <height>366</height>
+    <width>440</width>
+    <height>410</height>
    </rect>
   </property>
   <property name="windowTitle">
         </property>
        </widget>
       </item>
-      <item row="1" column="0">
+      <item row="0" column="1">
+       <widget class="QComboBox" name="indentCO">
+        <property name="enabled">
+         <bool>false</bool>
+        </property>
+        <property name="minimumSize">
+         <size>
+          <width>120</width>
+          <height>20</height>
+         </size>
+        </property>
+        <property name="maximumSize">
+         <size>
+          <width>121</width>
+          <height>21</height>
+         </size>
+        </property>
+        <property name="toolTip">
+         <string>size of the vertical space</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2" colspan="2">
+       <spacer name="spacer_3">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeType">
+         <enum>QSizePolicy::Expanding</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>135</width>
+          <height>26</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="1" column="1">
+       <widget class="QLineEdit" name="indentLE">
+        <property name="enabled">
+         <bool>false</bool>
+        </property>
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimumSize">
+         <size>
+          <width>120</width>
+          <height>20</height>
+         </size>
+        </property>
+        <property name="maximumSize">
+         <size>
+          <width>121</width>
+          <height>21</height>
+         </size>
+        </property>
+        <property name="toolTip">
+         <string>value</string>
+        </property>
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="2">
+       <widget class="LengthCombo" name="indentLengthCO">
+        <property name="enabled">
+         <bool>false</bool>
+        </property>
+        <property name="minimumSize">
+         <size>
+          <width>121</width>
+          <height>20</height>
+         </size>
+        </property>
+        <property name="maximumSize">
+         <size>
+          <width>16777215</width>
+          <height>21</height>
+         </size>
+        </property>
+        <property name="toolTip">
+         <string>unit</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="3">
+       <spacer name="spacer_4">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>48</width>
+          <height>26</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="2" column="0">
        <widget class="QRadioButton" name="skipRB">
         <property name="minimumSize">
          <size>
         </property>
        </widget>
       </item>
-      <item row="1" column="1">
+      <item row="2" column="1">
        <widget class="QComboBox" name="skipCO">
         <property name="enabled">
          <bool>false</bool>
         </property>
        </widget>
       </item>
-      <item row="1" column="2" colspan="2">
+      <item row="2" column="2" colspan="2">
        <spacer name="spacer_2">
         <property name="orientation">
          <enum>Qt::Horizontal</enum>
         </property>
        </spacer>
       </item>
-      <item row="2" column="1">
+      <item row="3" column="1">
        <widget class="QLineEdit" name="skipLE">
         <property name="enabled">
          <bool>false</bool>
         </property>
        </widget>
       </item>
-      <item row="2" column="2">
+      <item row="3" column="2">
        <widget class="LengthCombo" name="skipLengthCO">
         <property name="enabled">
          <bool>false</bool>
         </property>
         <property name="minimumSize">
          <size>
-          <width>69</width>
+          <width>121</width>
           <height>20</height>
          </size>
         </property>
         <property name="maximumSize">
          <size>
-          <width>70</width>
+          <width>16777215</width>
           <height>21</height>
          </size>
         </property>
         </property>
        </widget>
       </item>
-      <item row="2" column="3">
-       <spacer>
+      <item row="3" column="3">
+       <spacer name="spacer">
         <property name="orientation">
          <enum>Qt::Horizontal</enum>
         </property>
-        <property name="sizeType">
-         <enum>QSizePolicy::Expanding</enum>
-        </property>
         <property name="sizeHint" stdset="0">
          <size>
-          <width>62</width>
-          <height>23</height>
+          <width>48</width>
+          <height>26</height>
          </size>
         </property>
        </spacer>