]> git.lyx.org Git - features.git/commitdiff
GuiDocument.cpp: allow to use percent lengths for the paragraph skip separation;...
authorUwe Stöhr <uwestoehr@web.de>
Sun, 19 Jul 2009 22:08:58 +0000 (22:08 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Sun, 19 Jul 2009 22:08:58 +0000 (22:08 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30696 a592a061-630c-0410-9148-cb99ea01b6c8

development/FORMAT
lib/lyx2lyx/lyx_2_0.py
src/Buffer.cpp
src/frontends/qt4/GuiDocument.cpp

index ece447fbcf6f896a53bda395fab7e2a19b8a8786..ab57e82937cec44c5641f5e5632a3f45b7cc6f6b 100644 (file)
@@ -1,6 +1,10 @@
 LyX file-format changes
 -----------------------
 
+2009-07-20 Uwe Stöhr <uwestoehr@web.de>
+       * Format incremented to 366: allow to use percent lengths for the
+         paragraph skip separation.
+
 2009-07-19 Uwe Stöhr <uwestoehr@web.de>
        * Format incremented to 365: support for paragraph indentation.
 
index 4f6d7478de3b36faf824b3bc99bc697115a42b38..a72f9bc158fdc07863554f102492fe0a25dc37f3 100644 (file)
@@ -184,39 +184,39 @@ def latex_length(string):
         percent = True
         value = string[:i]
         value = str(float(value)/100)
-        return value + "\\textwidth"
+        return "True," + value + "\\textwidth"
     i = string.find("col%")
     if i > -1:
         percent = True
         value = string[:i]
         value = str(float(value)/100)
-        return value + "\\columnwidth"
+        return "True," + value + "\\columnwidth"
     i = string.find("page%")
     if i > -1:
         percent = True
         value = string[:i]
         value = str(float(value)/100)
-        return value + "\\paperwidth"
+        return "True," + value + "\\paperwidth"
     i = string.find("line%")
     if i > -1:
         percent = True
         value = string[:i]
         value = str(float(value)/100)
-        return value + "\\linewidth"
+        return "True," + value + "\\linewidth"
     i = string.find("theight%")
     if i > -1:
         percent = True
         value = string[:i]
         value = str(float(value)/100)
-        return value + "\\textheight"
+        return "True," + value + "\\textheight"
     i = string.find("pheight%")
     if i > -1:
         percent = True
         value = string[:i]
         value = str(float(value)/100)
-        return value + "\\paperheight"
+        return "True," + value + "\\paperheight"
     if percent ==  False:
-        return string
+        return "False," +  string
 
 
 ####################################################################
@@ -808,6 +808,7 @@ def revert_paragraph_indentation(document):
     " Revert custom paragraph indentation to preamble code "
     i = 0
     j = 0
+    k = 0
     while True:
       i = find_token(document.header, "\\paragraph_indentation", i)
       if i == -1:
@@ -823,13 +824,51 @@ def revert_paragraph_indentation(document):
           j = document.header[i].find(" ")
           length = document.header[i][j+1:]
           # handle percent lengths
-          length = latex_length(length) 
+          length = latex_length(length)
+          # latex_length returns "bool,length"
+          k = length.find(",")
+          length = length[k+1:]
           add_to_preamble(document, ["% this command was inserted by lyx2lyx"])
           add_to_preamble(document, ["\\setlength{\\parindent}{" + length + "}"])
           del document.header[i]
       i = i + 1
 
 
+def revert_percent_skip_lengths(document):
+    " Revert relative lengths for paragraph skip separation to preamble code "
+    i = 0
+    j = 0
+    k = 0
+    l = 0
+    while True:
+      i = find_token(document.header, "\\defskip", i)
+      if i == -1:
+          break
+      # only revert when a custom length was set and when
+      # it used a percent length
+      j = document.header[i].find("smallskip")
+      k = document.header[i].find("medskip")
+      l = document.header[i].find("bigskip")
+      if (j > -1) or (k > -1) or (l > -1):
+          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)
+          # latex_length returns "bool,length"
+          l = length.find(",")
+          percent = length[:l]
+          length = length[l+1:]
+          if percent == "True":
+              add_to_preamble(document, ["% this command was inserted by lyx2lyx"])
+              add_to_preamble(document, ["\\setlength{\\parskip}{" + length + "}"])
+              # set defskip to medskip as default
+              document.header[i] = "\\defskip medskip"
+      i = i + 1
+
+
 ##
 # Conversion hub
 #
@@ -854,10 +893,12 @@ convert = [[346, []],
            [362, []],
            [363, []],
            [364, []],
-           [365, []]
+           [365, []],
+           [366, []]
           ]
 
-revert =  [[364, [revert_paragraph_indentation]],
+revert =  [[365, [revert_percent_skip_lengths]],
+           [364, [revert_paragraph_indentation]],
            [363, [revert_branch_filename]],
            [362, [revert_longtable_align]],
            [361, [revert_applemac]],
index dfc32f3950899f6962a2eda2df962bacf25e5cb9..7bf4ac30e3b18f1fe6be0ce00208bef8efe15a47 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 = 365;  // uwestoehr: support for custom paragraph indentation
+int const LYX_FORMAT = 366; // uwestoehr: percent lengths for the paragraph skip separation
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
index 6286db3d99e746fa1faf3b74cf07867a5db22414..8c068a371ccbf9b94f9632300b8036c7fa9dda4c 100644 (file)
@@ -613,8 +613,6 @@ GuiDocument::GuiDocument(GuiView & lv)
        textLayoutModule->skipCO->addItem(qt_("MedSkip"));
        textLayoutModule->skipCO->addItem(qt_("BigSkip"));
        textLayoutModule->skipCO->addItem(qt_("Length"));
-       // remove the %-items from the unit choice
-       textLayoutModule->skipLengthCO->noPercents();
        textLayoutModule->lspacingCO->insertItem(
                Spacing::Single, qt_("Single"));
        textLayoutModule->lspacingCO->insertItem(