]> git.lyx.org Git - features.git/blob - src/frontends/qt2/QDocument.C
update ignore, and make sure to dist the lyx2lyx_version.py.in template file
[features.git] / src / frontends / qt2 / QDocument.C
1 /**
2  * \file QDocument.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Edwin Leuven
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "checkedwidgets.h"
14 #include "QDocument.h"
15 #include "QDocumentDialog.h"
16 #include "Qt2BC.h"
17 #include "qt_helpers.h"
18
19 #include "bufferparams.h"
20 #include "floatplacement.h"
21 #include "gettext.h"
22 #include "helper_funcs.h" // getSecond()
23 #include "language.h"
24 #include "lyxrc.h" // defaultUnit
25 #include "lyxtextclasslist.h"
26 #include "tex-strings.h" // tex_graphics
27
28 #include "support/lstrings.h"
29
30 #include "controllers/ControlDocument.h"
31 #include "controllers/frnt_lang.h"
32
33 #include <qpushbutton.h>
34 #include <qmultilineedit.h>
35 #include <qradiobutton.h>
36 #include <qcheckbox.h>
37 #include <qslider.h>
38 #include <qlineedit.h>
39 #include <qlistview.h>
40 #include "lengthcombo.h"
41
42
43 using lyx::support::bformat;
44 using lyx::support::getVectorFromString;
45
46 using std::distance;
47 using std::vector;
48 using std::string;
49
50 namespace lyx {
51 namespace frontend {
52
53 typedef QController<ControlDocument, QView<QDocumentDialog> > base_class;
54
55
56 namespace {
57
58 char const * encodings[] = { "LaTeX default", "latin1", "latin2",
59         "latin3", "latin4", "latin5", "latin9",
60         "koi8-r", "koi8-u", "cp866", "cp1251",
61         "iso88595", "pt154", 0
62 };
63
64 }
65
66
67 QDocument::QDocument(Dialog & parent)
68         : base_class(parent, _("Document Settings")),
69                 lang_(getSecond(getLanguageData(false)))
70 {}
71
72
73 void QDocument::build_dialog()
74 {
75         dialog_.reset(new QDocumentDialog(this));
76
77         // biblio
78         dialog_->biblioModule->citeStyleCO->insertItem(qt_("Author-year"));
79         dialog_->biblioModule->citeStyleCO->insertItem(qt_("Numerical"));
80         dialog_->biblioModule->citeStyleCO->setCurrentItem(0);
81
82         // language & quotes
83         vector<LanguagePair> const langs = getLanguageData(false);
84         vector<LanguagePair>::const_iterator lit  = langs.begin();
85         vector<LanguagePair>::const_iterator lend = langs.end();
86         for (; lit != lend; ++lit) {
87                 dialog_->langModule->languageCO->insertItem(
88                         toqstr(lit->first));
89         }
90
91         int i = 0;
92         while (encodings[i]) {
93                 dialog_->langModule->encodingCO->insertItem(qt_(encodings[i++]));
94         }
95
96         dialog_->langModule->quoteStyleCO->insertItem(qt_("``text''"));
97         dialog_->langModule->quoteStyleCO->insertItem(qt_("''text''"));
98         dialog_->langModule->quoteStyleCO->insertItem(qt_(",,text``"));
99         dialog_->langModule->quoteStyleCO->insertItem(qt_(",,text''"));
100         dialog_->langModule->quoteStyleCO->insertItem(qt_("<<text>>"));
101         dialog_->langModule->quoteStyleCO->insertItem(qt_(">>text<<"));
102
103         // packages
104         for (int n = 0; tex_graphics[n][0]; ++n) {
105                 QString enc = tex_graphics[n];
106                 dialog_->latexModule->psdriverCO->insertItem(enc);
107         }
108
109         // paper
110         QComboBox * cb = dialog_->pageLayoutModule->papersizeCO;
111         cb->insertItem(qt_("Default"));
112         cb->insertItem(qt_("Custom"));
113         cb->insertItem(qt_("US letter"));
114         cb->insertItem(qt_("US legal"));
115         cb->insertItem(qt_("US executive"));
116         cb->insertItem(qt_("A3"));
117         cb->insertItem(qt_("A4"));
118         cb->insertItem(qt_("A5"));
119         cb->insertItem(qt_("B3"));
120         cb->insertItem(qt_("B4"));
121         cb->insertItem(qt_("B5"));
122         // remove the %-items from the unit choice
123         dialog_->pageLayoutModule->paperwidthUnitCO->noPercents();
124         dialog_->pageLayoutModule->paperheightUnitCO->noPercents();
125
126         // layout
127         for (LyXTextClassList::const_iterator cit = textclasslist.begin();
128              cit != textclasslist.end(); ++cit) {
129                 if (cit->isTeXClassAvailable()) {
130                         dialog_->latexModule->classCO->insertItem(toqstr(cit->description()));
131                 } else {
132                         string item =
133                                 bformat(_("Unavailable: %1$s"), cit->description());
134                         dialog_->latexModule->classCO->insertItem(toqstr(item));
135                 }
136         }
137
138         for (int n = 0; tex_fonts[n][0]; ++n) {
139                 QString font = tex_fonts[n];
140                 dialog_->textLayoutModule->fontsCO->insertItem(font);
141         }
142
143         dialog_->textLayoutModule->fontsizeCO->insertItem(qt_("default"));
144         dialog_->textLayoutModule->fontsizeCO->insertItem(qt_("10"));
145         dialog_->textLayoutModule->fontsizeCO->insertItem(qt_("11"));
146         dialog_->textLayoutModule->fontsizeCO->insertItem(qt_("12"));
147
148         dialog_->textLayoutModule->skipCO->insertItem(qt_("SmallSkip"));
149         dialog_->textLayoutModule->skipCO->insertItem(qt_("MedSkip"));
150         dialog_->textLayoutModule->skipCO->insertItem(qt_("BigSkip"));
151         dialog_->textLayoutModule->skipCO->insertItem(qt_("Length"));
152         // remove the %-items from the unit choice
153         dialog_->textLayoutModule->skipLengthCO->noPercents();
154
155         dialog_->pageLayoutModule->pagestyleCO->insertItem(qt_("default"));
156         dialog_->pageLayoutModule->pagestyleCO->insertItem(qt_("empty"));
157         dialog_->pageLayoutModule->pagestyleCO->insertItem(qt_("plain"));
158         dialog_->pageLayoutModule->pagestyleCO->insertItem(qt_("headings"));
159         dialog_->pageLayoutModule->pagestyleCO->insertItem(qt_("fancy"));
160
161         dialog_->textLayoutModule->lspacingCO->insertItem(
162                 qt_("Single"), Spacing::Single);
163         dialog_->textLayoutModule->lspacingCO->insertItem(
164                 qt_("OneHalf"), Spacing::Onehalf);
165         dialog_->textLayoutModule->lspacingCO->insertItem(
166                 qt_("Double"), Spacing::Double);
167         dialog_->textLayoutModule->lspacingCO->insertItem(
168                 qt_("Custom"), Spacing::Other);
169
170
171         // Manage the restore, ok, apply, restore and cancel/close buttons
172         bcview().setOK(dialog_->okPB);
173         bcview().setApply(dialog_->applyPB);
174         bcview().setCancel(dialog_->closePB);
175         bcview().setRestore(dialog_->restorePB);
176
177         // initialize the length validator
178         addCheckedLineEdit(bcview(), dialog_->textLayoutModule->skipLE);
179         addCheckedLineEdit(bcview(), dialog_->pageLayoutModule->paperheightLE,
180                 dialog_->pageLayoutModule->paperheightL);
181         addCheckedLineEdit(bcview(), dialog_->pageLayoutModule->paperwidthLE,
182                 dialog_->pageLayoutModule->paperwidthL);
183         addCheckedLineEdit(bcview(), dialog_->marginsModule->topLE,
184                 dialog_->marginsModule->topL);
185         addCheckedLineEdit(bcview(), dialog_->marginsModule->bottomLE,
186                 dialog_->marginsModule->bottomL);
187         addCheckedLineEdit(bcview(), dialog_->marginsModule->innerLE,
188                 dialog_->marginsModule->innerL);
189         addCheckedLineEdit(bcview(), dialog_->marginsModule->outerLE,
190                 dialog_->marginsModule->outerL);
191         addCheckedLineEdit(bcview(), dialog_->marginsModule->headsepLE,
192                 dialog_->marginsModule->headsepL);
193         addCheckedLineEdit(bcview(), dialog_->marginsModule->headheightLE,
194                 dialog_->marginsModule->headheightL);
195         addCheckedLineEdit(bcview(), dialog_->marginsModule->footskipLE,
196                 dialog_->marginsModule->footskipL);
197 }
198
199
200 void QDocument::showPreamble()
201 {
202         dialog_->showPreamble();
203 }
204
205
206 void QDocument::apply()
207 {
208         BufferParams & params = controller().params();
209
210         // preamble
211         params.preamble =
212                 fromqstr(dialog_->preambleModule->preambleMLE->text());
213
214         // biblio
215         params.cite_engine = biblio::ENGINE_BASIC;
216
217         if (dialog_->biblioModule->citeNatbibRB->isChecked()) {
218                 bool const use_numerical_citations =
219                         dialog_->biblioModule->citeStyleCO->currentItem();
220                 if (use_numerical_citations)
221                         params.cite_engine = biblio::ENGINE_NATBIB_NUMERICAL;
222                 else
223                         params.cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
224
225         } else if (dialog_->biblioModule->citeJurabibRB->isChecked())
226                 params.cite_engine = biblio::ENGINE_JURABIB;
227
228         params.use_bibtopic =
229                 dialog_->biblioModule->bibtopicCB->isChecked();
230
231         // language & quotes
232         if (dialog_->langModule->defaultencodingCB->isChecked()) {
233                 params.inputenc = "auto";
234         } else {
235                 int i = dialog_->langModule->encodingCO->currentItem();
236                 if (i == 0) {
237                         params.inputenc = "default";
238                 } else {
239                         params.inputenc = encodings[i];
240                 }
241         }
242
243         InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
244         switch (dialog_->langModule->quoteStyleCO->currentItem()) {
245         case 0:
246                 lga = InsetQuotes::EnglishQ;
247                 break;
248         case 1:
249                 lga = InsetQuotes::SwedishQ;
250                 break;
251         case 2:
252                 lga = InsetQuotes::GermanQ;
253                 break;
254         case 3:
255                 lga = InsetQuotes::PolishQ;
256                 break;
257         case 4:
258                 lga = InsetQuotes::FrenchQ;
259                 break;
260         case 5:
261                 lga = InsetQuotes::DanishQ;
262                 break;
263         }
264         params.quotes_language = lga;
265
266         int const pos = dialog_->langModule->languageCO->currentItem();
267         params.language = languages.getLanguage(lang_[pos]);
268
269         // numbering
270         if (params.getLyXTextClass().hasTocLevels()) {
271                 params.tocdepth = dialog_->numberingModule->tocSL->value();
272                 params.secnumdepth = dialog_->numberingModule->depthSL->value();
273         }
274
275         // bullets
276         params.user_defined_bullet(0) = dialog_->bulletsModule->getBullet(0);
277         params.user_defined_bullet(1) = dialog_->bulletsModule->getBullet(1);
278         params.user_defined_bullet(2) = dialog_->bulletsModule->getBullet(2);
279         params.user_defined_bullet(3) = dialog_->bulletsModule->getBullet(3);
280
281         // packages
282         params.graphicsDriver =
283                 fromqstr(dialog_->latexModule->psdriverCO->currentText());
284
285         if (dialog_->mathsModule->amsautoCB->isChecked()) {
286                 params.use_amsmath = BufferParams::AMS_AUTO;
287         } else {
288                 if (dialog_->mathsModule->amsCB->isChecked())
289                         params.use_amsmath = BufferParams::AMS_ON;
290                 else
291                         params.use_amsmath = BufferParams::AMS_OFF;
292         }
293
294         // layout
295         params.textclass =
296                 dialog_->latexModule->classCO->currentItem();
297
298         params.fonts =
299                 fromqstr(dialog_->textLayoutModule->fontsCO->currentText());
300
301         params.fontsize =
302                 fromqstr(dialog_->textLayoutModule->fontsizeCO->currentText());
303
304         params.pagestyle =
305                 fromqstr(dialog_->pageLayoutModule->pagestyleCO->currentText());
306
307         switch (dialog_->textLayoutModule->lspacingCO->currentItem()) {
308         case 0:
309                 params.spacing().set(Spacing::Single);
310                 break;
311         case 1:
312                 params.spacing().set(Spacing::Onehalf);
313                 break;
314         case 2:
315                 params.spacing().set(Spacing::Double);
316                 break;
317         case 3:
318                 params.spacing().set(Spacing::Other,
319                         fromqstr(dialog_->textLayoutModule->lspacingLE->text()));
320                 break;
321         }
322
323         if (dialog_->textLayoutModule->twoColumnCB->isChecked())
324                 params.columns = 2;
325         else
326                 params.columns = 1;
327
328         if (dialog_->textLayoutModule->indentRB->isChecked())
329                 params.paragraph_separation = BufferParams::PARSEP_INDENT;
330         else
331                 params.paragraph_separation = BufferParams::PARSEP_SKIP;
332
333         switch (dialog_->textLayoutModule->skipCO->currentItem()) {
334         case 0:
335                 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
336                 break;
337         case 1:
338                 params.setDefSkip(VSpace(VSpace::MEDSKIP));
339                 break;
340         case 2:
341                 params.setDefSkip(VSpace(VSpace::BIGSKIP));
342                 break;
343         case 3:
344         {
345                 VSpace vs = VSpace(
346                         widgetsToLength(dialog_->textLayoutModule->skipLE,
347                                 dialog_->textLayoutModule->skipLengthCO)
348                         );
349                 params.setDefSkip(vs);
350                 break;
351         }
352         default:
353                 // DocumentDefskipCB assures that this never happens
354                 // so Assert then !!!  - jbl
355                 params.setDefSkip(VSpace(VSpace::MEDSKIP));
356                 break;
357         }
358
359         params.options =
360                 fromqstr(dialog_->latexModule->optionsLE->text());
361
362         params.float_placement = dialog_->floatModule->get();
363
364         // paper
365         params.papersize = PAPER_SIZE(
366                 dialog_->pageLayoutModule->papersizeCO->currentItem());
367
368         // custom, A3, B3 and B4 paper sizes need geometry
369         int psize = dialog_->pageLayoutModule->papersizeCO->currentItem();
370         bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9);
371
372         params.paperwidth = widgetsToLength(dialog_->pageLayoutModule->paperwidthLE,
373                 dialog_->pageLayoutModule->paperwidthUnitCO);
374
375         params.paperheight = widgetsToLength(dialog_->pageLayoutModule->paperheightLE,
376                 dialog_->pageLayoutModule->paperheightUnitCO);
377
378         if (dialog_->pageLayoutModule->facingPagesCB->isChecked())
379                 params.sides = LyXTextClass::TwoSides;
380         else
381                 params.sides = LyXTextClass::OneSide;
382
383         if (dialog_->pageLayoutModule->landscapeRB->isChecked())
384                 params.orientation = ORIENTATION_LANDSCAPE;
385         else
386                 params.orientation = ORIENTATION_PORTRAIT;
387
388         // margins
389         params.use_geometry =
390                 (!dialog_->marginsModule->marginCB->isChecked()
391                 || geom_papersize);
392
393         MarginsModuleBase const * m(dialog_->marginsModule);
394
395         params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
396
397         params.topmargin = widgetsToLength(m->topLE, m->topUnit);
398
399         params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
400
401         params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
402
403         params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
404
405         params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
406
407         params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
408
409         params.branchlist() = branchlist_;
410 }
411
412
413 namespace {
414
415 /** Return the position of val in the vector if found.
416     If not found, return 0.
417  */
418 template<class A>
419 typename std::vector<A>::size_type
420 findPos(std::vector<A> const & vec, A const & val)
421 {
422         typename std::vector<A>::const_iterator it =
423                 std::find(vec.begin(), vec.end(), val);
424         if (it == vec.end())
425                 return 0;
426         return distance(vec.begin(), it);
427 }
428
429 } // namespace anom
430
431
432 void QDocument::update_contents()
433 {
434         if (!dialog_.get())
435                 return;
436
437         BufferParams const & params = controller().params();
438
439         // set the default unit
440         // FIXME: move to controller
441         LyXLength::UNIT defaultUnit = LyXLength::CM;
442         switch (lyxrc.default_papersize) {
443                 case PAPER_DEFAULT: break;
444
445                 case PAPER_USLETTER:
446                 case PAPER_USLEGAL:
447                 case PAPER_USEXECUTIVE:
448                         defaultUnit = LyXLength::IN;
449                         break;
450
451                 case PAPER_A3:
452                 case PAPER_A4:
453                 case PAPER_A5:
454                 case PAPER_B3:
455                 case PAPER_B4:
456                 case PAPER_B5:
457                         defaultUnit = LyXLength::CM;
458                         break;
459                 case PAPER_CUSTOM:
460                         break;
461         }
462
463         // preamble
464         QString preamble = toqstr(params.preamble);
465         dialog_->preambleModule->preambleMLE->setText(preamble);
466
467         // biblio
468         dialog_->biblioModule->citeDefaultRB->setChecked(
469                 params.cite_engine == biblio::ENGINE_BASIC);
470
471         dialog_->biblioModule->citeNatbibRB->setChecked(
472                 params.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL ||
473                 params.cite_engine == biblio::ENGINE_NATBIB_AUTHORYEAR);
474
475         dialog_->biblioModule->citeStyleCO->setCurrentItem(
476                 params.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL);
477
478         dialog_->biblioModule->citeJurabibRB->setChecked(
479                 params.cite_engine == biblio::ENGINE_JURABIB);
480
481         dialog_->biblioModule->bibtopicCB->setChecked(
482                 params.use_bibtopic);
483
484         // language & quotes
485         int const pos = int(findPos(lang_,
486                                     params.language->lang()));
487         dialog_->langModule->languageCO->setCurrentItem(pos);
488
489         dialog_->langModule->quoteStyleCO->setCurrentItem(
490                 params.quotes_language);
491
492         dialog_->langModule->defaultencodingCB->setChecked(true);
493
494         if (params.inputenc != "auto") {
495                 dialog_->langModule->defaultencodingCB->setChecked(false);
496                 if (params.inputenc == "default") {
497                         dialog_->langModule->encodingCO->setCurrentItem(0);
498                 } else {
499                         int i = 0;
500                         while (encodings[i]) {
501                                 if (encodings[i] == params.inputenc)
502                                         dialog_->langModule->encodingCO->setCurrentItem(i);
503                                 ++i;
504                         }
505                 }
506         }
507
508         // numbering
509         int const min_toclevel = controller().textClass().min_toclevel();
510         int const max_toclevel = controller().textClass().max_toclevel();
511         if (controller().textClass().hasTocLevels()) {
512                 dialog_->numberingModule->setEnabled(true);
513                 dialog_->numberingModule->depthSL->setMinValue(min_toclevel - 1);
514                 dialog_->numberingModule->depthSL->setMaxValue(max_toclevel);
515                 dialog_->numberingModule->depthSL->setValue(params.secnumdepth);
516                 dialog_->numberingModule->tocSL->setMinValue(min_toclevel - 1);
517                 dialog_->numberingModule->tocSL->setMaxValue(max_toclevel);
518                 dialog_->numberingModule->tocSL->setValue(params.tocdepth);
519                 dialog_->updateNumbering();
520         } else {
521                 dialog_->numberingModule->setEnabled(false);
522                 dialog_->numberingModule->tocLV->clear();
523         }
524
525         // bullets
526         dialog_->bulletsModule->setBullet(0,params.user_defined_bullet(0));
527         dialog_->bulletsModule->setBullet(1,params.user_defined_bullet(1));
528         dialog_->bulletsModule->setBullet(2,params.user_defined_bullet(2));
529         dialog_->bulletsModule->setBullet(3,params.user_defined_bullet(3));
530
531         // packages
532         QString text = toqstr(params.graphicsDriver);
533         int nitem = dialog_->latexModule->psdriverCO->count();
534         for (int n = 0; n < nitem ; ++n) {
535                 QString enc = tex_graphics[n];
536                 if (enc == text) {
537                         dialog_->latexModule->psdriverCO->setCurrentItem(n);
538                 }
539         }
540
541
542         dialog_->mathsModule->amsCB->setChecked(
543                 params.use_amsmath == BufferParams::AMS_ON);
544         dialog_->mathsModule->amsautoCB->setChecked(
545                 params.use_amsmath == BufferParams::AMS_AUTO);
546
547         switch (params.spacing().getSpace()) {
548                 case Spacing::Other: nitem = 3; break;
549                 case Spacing::Double: nitem = 2; break;
550                 case Spacing::Onehalf: nitem = 1; break;
551                 case Spacing::Default: case Spacing::Single: nitem = 0; break;
552         }
553
554         // layout
555         dialog_->latexModule->classCO->setCurrentItem(params.textclass);
556
557         dialog_->updateFontsize(controller().textClass().opt_fontsize(),
558                                 params.fontsize);
559
560         dialog_->updatePagestyle(controller().textClass().opt_pagestyle(),
561                                  params.pagestyle);
562
563         for (int n = 0; tex_fonts[n][0]; ++n) {
564                 if (tex_fonts[n] == params.fonts) {
565                         dialog_->textLayoutModule->fontsCO->setCurrentItem(n);
566                         break;
567                 }
568         }
569
570         dialog_->textLayoutModule->lspacingCO->setCurrentItem(nitem);
571         if (params.spacing().getSpace() == Spacing::Other) {
572                 dialog_->textLayoutModule->lspacingLE->setText(
573                         toqstr(params.spacing().getValueAsString()));
574         }
575         dialog_->setLSpacing(nitem);
576
577         if (params.paragraph_separation
578             == BufferParams::PARSEP_INDENT) {
579                 dialog_->textLayoutModule->indentRB->setChecked(true);
580         } else {
581                 dialog_->textLayoutModule->skipRB->setChecked(true);
582         }
583
584         int skip = 0;
585         switch (params.getDefSkip().kind()) {
586         case VSpace::SMALLSKIP:
587                 skip = 0;
588                 break;
589         case VSpace::MEDSKIP:
590                 skip = 1;
591                 break;
592         case VSpace::BIGSKIP:
593                 skip = 2;
594                 break;
595         case VSpace::LENGTH:
596         {
597                 skip = 3;
598                 string const length = params.getDefSkip().asLyXCommand();
599                 lengthToWidgets(dialog_->textLayoutModule->skipLE,
600                         dialog_->textLayoutModule->skipLengthCO,
601                         length, defaultUnit);
602                 break;
603         }
604         default:
605                 skip = 0;
606                 break;
607         }
608         dialog_->textLayoutModule->skipCO->setCurrentItem(skip);
609         dialog_->setSkip(skip);
610
611         dialog_->textLayoutModule->twoColumnCB->setChecked(
612                 params.columns == 2);
613
614         if (!params.options.empty()) {
615                 dialog_->latexModule->optionsLE->setText(
616                         toqstr(params.options));
617         } else {
618                 dialog_->latexModule->optionsLE->setText("");
619         }
620
621         dialog_->floatModule->set(params.float_placement);
622
623         // paper
624         int const psize = params.papersize;
625         dialog_->pageLayoutModule->papersizeCO->setCurrentItem(psize);
626         dialog_->setCustomPapersize(psize);
627
628         bool const landscape =
629                 params.orientation == ORIENTATION_LANDSCAPE;
630         dialog_->pageLayoutModule->landscapeRB->setChecked(landscape);
631         dialog_->pageLayoutModule->portraitRB->setChecked(!landscape);
632
633         dialog_->pageLayoutModule->facingPagesCB->setChecked(
634                 params.sides == LyXTextClass::TwoSides);
635
636
637
638         lengthToWidgets(dialog_->pageLayoutModule->paperwidthLE,
639                 dialog_->pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit);
640
641         lengthToWidgets(dialog_->pageLayoutModule->paperheightLE,
642                 dialog_->pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit);
643
644         // margins
645         MarginsModuleBase * m = dialog_->marginsModule;
646
647         dialog_->setMargins(!params.use_geometry);
648
649         lengthToWidgets(m->topLE, m->topUnit,
650                 params.topmargin, defaultUnit);
651
652         lengthToWidgets(m->bottomLE, m->bottomUnit,
653                 params.bottommargin, defaultUnit);
654
655         lengthToWidgets(m->innerLE, m->innerUnit,
656                 params.leftmargin, defaultUnit);
657
658         lengthToWidgets(m->outerLE, m->outerUnit,
659                 params.rightmargin, defaultUnit);
660
661         lengthToWidgets(m->headheightLE, m->headheightUnit,
662                 params.headheight, defaultUnit);
663
664         lengthToWidgets(m->headsepLE, m->headsepUnit,
665                 params.headsep, defaultUnit);
666
667         lengthToWidgets(m->footskipLE, m->footskipUnit,
668                 params.footskip, defaultUnit);
669
670         // branches
671         branchlist_ = params.branchlist();
672         dialog_->updateBranchView();
673 }
674
675
676 void QDocument::saveDocDefault()
677 {
678         // we have to apply the params first
679         apply();
680         controller().saveAsDefault();
681 }
682
683
684 void QDocument::useClassDefaults()
685 {
686         BufferParams & params = controller().params();
687
688         params.textclass = dialog_->latexModule->classCO->currentItem();
689         params.useClassDefaults();
690         update_contents();
691 }
692
693 } // namespace frontend
694 } // namespace lyx