From 4ab6f265e992c7e2e9ecf47acd6e43893d98ae58 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 19 Feb 2008 05:24:48 +0000 Subject: [PATCH] Add support for column separation in page margins. Fixes bug 3337. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23059 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/FORMAT | 3 +++ lib/lyx2lyx/LyX.py | 2 +- lib/lyx2lyx/lyx_1_6.py | 24 ++++++++++++++++++-- src/Buffer.cpp | 3 ++- src/BufferParams.cpp | 7 ++++++ src/BufferParams.h | 2 ++ src/frontends/qt4/GuiDocument.cpp | 16 +++++++++++++ src/frontends/qt4/ui/MarginsUi.ui | 37 +++++++++++++++++++++++++++++++ 8 files changed, 90 insertions(+), 4 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index d2a782e275..eeae6d703d 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,9 @@ LyX file-format changes ----------------------- +2008-02-18 Richard Heck + * Format incremented to 315: support for column separation in page margins + 2008-02-03 Uwe Stöhr * Format incremented to 314: adapt scrlttr2 class for serial letters diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index ad41ba7a81..0c1cbdb302 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -80,7 +80,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)), ("1_3", [221], minor_versions("1.3" , 7)), ("1_4", range(222,246), minor_versions("1.4" , 5)), ("1_5", range(246,277), minor_versions("1.5" , 2)), - ("1_6", range(277,315), minor_versions("1.6" , 0))] # Uwe Stöhr: scrlttr2 for serial letters + ("1_6", range(277,316), minor_versions("1.6" , 0))] # rgh: colsep def formats_list(): diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index 394e88a0b6..d4cd21fe05 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -960,6 +960,24 @@ def revert_module_names(document): document.set_module_list(newmodlist) +def revert_colsep(document): + i = find_token(document.header, "\\columnsep", 0) + if i == -1: + return + colsepline = document.header[i] + r = re.compile(r'\\columnsep (.*)') + m = r.match(colsepline) + if not m: + document.warning("Malformed column separation line!") + return + colsep = m.group(1) + del document.header[i] + #it seems to be safe to add the package even if it is already used + pretext = ["\\usepackage{geometry}", "\\geometry{columnsep=" + colsep + "}"] + + add_to_preamble(document, pretext) + + def revert_framed_notes(document): "Revert framed boxes to notes. " i = 0 @@ -1265,10 +1283,12 @@ convert = [[277, [fix_wrong_tables]], [311, [convert_ams_classes]], [312, []], [313, [convert_module_names]], - [314, []] + [314, []], + [315, []] ] -revert = [[313, []], +revert = [[314, [revert_colsep]], + [313, []], [312, [revert_module_names]], [311, [revert_rotfloat, revert_widesideways]], [310, []], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 33eb3d907a..5fac06411b 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -113,7 +113,7 @@ namespace os = support::os; namespace { -int const LYX_FORMAT = 314; // Uwe Stöhr: scrlttr2 for serial letters +int const LYX_FORMAT = 315; // Richard Heck: column separation } // namespace anon @@ -466,6 +466,7 @@ int Buffer::readHeader(Lexer & lex) params().headheight.erase(); params().headsep.erase(); params().footskip.erase(); + params().columnsep.erase(); params().listings_params.clear(); params().clearLayoutModules(); params().pdfoptions().clear(); diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index e4d241d56c..d22d94fd52 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -619,6 +619,8 @@ string const BufferParams::readToken(Lexer & lex, string const & token, lex >> headsep; } else if (token == "\\footskip") { lex >> footskip; + } else if (token == "\\columnsep") { + lex >> columnsep; } else if (token == "\\paperfontsize") { lex >> fontsize; } else if (token == "\\papercolumns") { @@ -768,6 +770,9 @@ void BufferParams::writeFile(ostream & os) const if (!footskip.empty()) os << "\\footskip " << VSpace(footskip).asLyXCommand() << '\n'; + if (!columnsep.empty()) + os << "\\columnsep " + << VSpace(columnsep).asLyXCommand() << '\n'; os << "\\secnumdepth " << secnumdepth << "\n\\tocdepth " << tocdepth << "\n\\paragraph_separation " @@ -1139,6 +1144,8 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, os << ",headsep=" << from_ascii(Length(headsep).asLatexString()); if (!footskip.empty()) os << ",footskip=" << from_ascii(Length(footskip).asLatexString()); + if (!columnsep.empty()) + os << ",columnsep=" << from_ascii(Length(columnsep).asLatexString()); os << "}\n"; texrow.newline(); } diff --git a/src/BufferParams.h b/src/BufferParams.h index 61c8612fae..5fc57aecc8 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -165,6 +165,8 @@ public: std::string headsep; /// std::string footskip; + /// + std::string columnsep; /* some LaTeX options */ /// The graphics driver diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 58859ab704..a0054bf48b 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -718,6 +718,10 @@ GuiDocument::GuiDocument(GuiView & lv) this, SLOT(change_adaptor())); connect(marginsModule->footskipUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(marginsModule->columnsepLE, SIGNAL(textChanged(const QString&)), + this, SLOT(change_adaptor())); + connect(marginsModule->columnsepUnit, SIGNAL(activated(int)), + this, SLOT(change_adaptor())); marginsModule->topLE->setValidator(unsignedLengthValidator( marginsModule->topLE)); marginsModule->bottomLE->setValidator(unsignedLengthValidator( @@ -732,6 +736,8 @@ GuiDocument::GuiDocument(GuiView & lv) marginsModule->headheightLE)); marginsModule->footskipLE->setValidator(unsignedLengthValidator( marginsModule->footskipLE)); + marginsModule->columnsepLE->setValidator(unsignedLengthValidator( + marginsModule->columnsepLE)); bc().addCheckedLineEdit(marginsModule->topLE, marginsModule->topL); @@ -747,6 +753,8 @@ GuiDocument::GuiDocument(GuiView & lv) marginsModule->headheightL); bc().addCheckedLineEdit(marginsModule->footskipLE, marginsModule->footskipL); + bc().addCheckedLineEdit(marginsModule->columnsepLE, + marginsModule->columnsepL); langModule = new UiWidget; @@ -1111,6 +1119,10 @@ void GuiDocument::setCustomMargins(bool custom) marginsModule->footskipL->setEnabled(!custom); marginsModule->footskipLE->setEnabled(!custom); marginsModule->footskipUnit->setEnabled(!custom); + + marginsModule->columnsepL->setEnabled(!custom); + marginsModule->columnsepLE->setEnabled(!custom); + marginsModule->columnsepUnit->setEnabled(!custom); } @@ -1600,6 +1612,7 @@ void GuiDocument::apply(BufferParams & params) params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit); params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit); params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit); + params.columnsep = widgetsToLength(m->columnsepLE, m->columnsepUnit); branchesModule->apply(params); @@ -1909,6 +1922,9 @@ void GuiDocument::updateParams(BufferParams const & params) lengthToWidgets(m->footskipLE, m->footskipUnit, params.footskip, defaultUnit); + lengthToWidgets(m->columnsepLE, m->columnsepUnit, + params.columnsep, defaultUnit); + branchesModule->update(params); // PDF support diff --git a/src/frontends/qt4/ui/MarginsUi.ui b/src/frontends/qt4/ui/MarginsUi.ui index 7d822fb628..081a86c4ed 100644 --- a/src/frontends/qt4/ui/MarginsUi.ui +++ b/src/frontends/qt4/ui/MarginsUi.ui @@ -171,6 +171,19 @@ + + + + false + + + &Column Sep: + + + columnsepLE + + + @@ -352,6 +365,30 @@ + + + + 0 + + + 6 + + + + + false + + + + + + + false + + + + +