* GuiDocument:

- fix #6699; use_geometry now only means that the user don't want to have custom margins; that geometry also needs to be loaded for some paper formats is already done in BufferParams.cpp
- remove portraitChanged() because this was useless - A4 landscape is still A4 and still uses the default margins

* BufferParams.cpp: only output the margins if the option "Default margins" is not checked - this was a bug in the margins UI

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34429 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2010-05-18 02:56:36 +00:00
parent 10dc64bd18
commit 0600e656f8
3 changed files with 34 additions and 41 deletions

View File

@ -1397,7 +1397,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
texrow.newline(); texrow.newline();
} }
if (!tclass.provides("geometry") if (!tclass.provides("geometry")
&& (use_geometry || nonstandard_papersize)) { && (use_geometry || nonstandard_papersize)) {
odocstringstream ods; odocstringstream ods;
if (!getGraphicsDriver("geometry").empty()) if (!getGraphicsDriver("geometry").empty())
ods << getGraphicsDriver("geometry"); ods << getGraphicsDriver("geometry");
@ -1536,25 +1536,28 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
os << '[' << g_options << ']'; os << '[' << g_options << ']';
os << "{geometry}\n"; os << "{geometry}\n";
texrow.newline(); texrow.newline();
os << "\\geometry{verbose"; // output this if only use_geometry is true
if (!topmargin.empty()) if (use_geometry) {
os << ",tmargin=" << from_ascii(Length(topmargin).asLatexString()); os << "\\geometry{verbose";
if (!bottommargin.empty()) if (!topmargin.empty())
os << ",bmargin=" << from_ascii(Length(bottommargin).asLatexString()); os << ",tmargin=" << from_ascii(Length(topmargin).asLatexString());
if (!leftmargin.empty()) if (!bottommargin.empty())
os << ",lmargin=" << from_ascii(Length(leftmargin).asLatexString()); os << ",bmargin=" << from_ascii(Length(bottommargin).asLatexString());
if (!rightmargin.empty()) if (!leftmargin.empty())
os << ",rmargin=" << from_ascii(Length(rightmargin).asLatexString()); os << ",lmargin=" << from_ascii(Length(leftmargin).asLatexString());
if (!headheight.empty()) if (!rightmargin.empty())
os << ",headheight=" << from_ascii(Length(headheight).asLatexString()); os << ",rmargin=" << from_ascii(Length(rightmargin).asLatexString());
if (!headsep.empty()) if (!headheight.empty())
os << ",headsep=" << from_ascii(Length(headsep).asLatexString()); os << ",headheight=" << from_ascii(Length(headheight).asLatexString());
if (!footskip.empty()) if (!headsep.empty())
os << ",footskip=" << from_ascii(Length(footskip).asLatexString()); os << ",headsep=" << from_ascii(Length(headsep).asLatexString());
if (!columnsep.empty()) if (!footskip.empty())
os << ",columnsep=" << from_ascii(Length(columnsep).asLatexString()); os << ",footskip=" << from_ascii(Length(footskip).asLatexString());
os << "}\n"; if (!columnsep.empty())
texrow.newline(); os << ",columnsep=" << from_ascii(Length(columnsep).asLatexString());
os << "}\n";
texrow.newline();
}
} else if (orientation == ORIENTATION_LANDSCAPE) { } else if (orientation == ORIENTATION_LANDSCAPE) {
features.require("papersize"); features.require("papersize");
} }

View File

@ -721,7 +721,7 @@ GuiDocument::GuiDocument(GuiView & lv)
connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
this, SLOT(papersizeChanged(int))); this, SLOT(papersizeChanged(int)));
connect(pageLayoutModule->portraitRB, SIGNAL(clicked()), connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
this, SLOT(portraitChanged())); this, SLOT(change_adaptor()));
connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString &)), connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString &)),
@ -1297,13 +1297,7 @@ void GuiDocument::enableSkip(bool skip)
} }
void GuiDocument::portraitChanged() void GuiDocument::setMargins()
{
setMargins(pageLayoutModule->papersizeCO->currentIndex());
}
void GuiDocument::setMargins(bool custom)
{ {
bool const extern_geometry = bool const extern_geometry =
documentClass().provides("geometry"); documentClass().provides("geometry");
@ -1313,8 +1307,12 @@ void GuiDocument::setMargins(bool custom)
setCustomMargins(true); setCustomMargins(true);
return; return;
} }
marginsModule->marginCB->setChecked(custom); bool custom = false;
setCustomMargins(custom); // only check marginCB when there are no custom margins set
if (bp_.use_geometry)
custom = true;
marginsModule->marginCB->setChecked(!custom);
setCustomMargins(!custom);
} }
@ -2353,12 +2351,6 @@ void GuiDocument::applyView()
bp_.papersize = PAPER_SIZE( bp_.papersize = PAPER_SIZE(
pageLayoutModule->papersizeCO->currentIndex()); pageLayoutModule->papersizeCO->currentIndex());
// only custom, A4, B4, B5 and the US sizes don't need the LaTeX-
// package gegeometry
int psize = pageLayoutModule->papersizeCO->currentIndex();
bool geom_papersize = (psize != 1 && psize != 2 && psize != 3
&& psize != 4 && psize != 9 && psize != 10 && psize != 17);
bp_.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE, bp_.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
pageLayoutModule->paperwidthUnitCO); pageLayoutModule->paperwidthUnitCO);
@ -2376,8 +2368,7 @@ void GuiDocument::applyView()
bp_.orientation = ORIENTATION_PORTRAIT; bp_.orientation = ORIENTATION_PORTRAIT;
// margins // margins
bp_.use_geometry = !marginsModule->marginCB->isChecked() bp_.use_geometry = !marginsModule->marginCB->isChecked();
|| geom_papersize;
Ui::MarginsUi const * m = marginsModule; Ui::MarginsUi const * m = marginsModule;
@ -2822,7 +2813,7 @@ void GuiDocument::paramsToDialog()
// margins // margins
Ui::MarginsUi * m = marginsModule; Ui::MarginsUi * m = marginsModule;
setMargins(!bp_.use_geometry); setMargins();
lengthToWidgets(m->topLE, m->topUnit, lengthToWidgets(m->topLE, m->topUnit,
bp_.topmargin, defaultUnit); bp_.topmargin, defaultUnit);

View File

@ -88,7 +88,7 @@ private Q_SLOTS:
void saveDefaultClicked(); void saveDefaultClicked();
void useDefaultsClicked(); void useDefaultsClicked();
void setLSpacing(int); void setLSpacing(int);
void setMargins(bool); void setMargins();
void papersizeChanged(int); void papersizeChanged(int);
void setColSep(); void setColSep();
void setCustomMargins(bool); void setCustomMargins(bool);
@ -100,7 +100,6 @@ private Q_SLOTS:
void enableIndent(bool); void enableIndent(bool);
void setSkip(int); void setSkip(int);
void enableSkip(bool); void enableSkip(bool);
void portraitChanged();
void browseLayout(); void browseLayout();
void browseMaster(); void browseMaster();
void classChanged(); void classChanged();