]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDocument.cpp
PDFOptions: Pavel's final touches patch
[lyx.git] / src / frontends / qt4 / GuiDocument.cpp
1 /**
2  * \file GuiDocument.cpp
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  * \author Richard Heck (modules)
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "GuiDocument.h"
15
16 #include "BranchList.h"
17 #include "buffer_funcs.h"
18 #include "Buffer.h"
19 #include "BufferParams.h"
20 #include "BufferView.h"
21 #include "Color.h"
22 #include "Encoding.h"
23 #include "FloatPlacement.h"
24 #include "frontend_helpers.h"
25 #include "FuncRequest.h"
26 #include "gettext.h"
27 #include "GuiBranches.h"
28 #include "Language.h"
29 #include "LaTeXFeatures.h"
30 #include "LaTeXHighlighter.h"
31 #include "Layout.h"
32 #include "LengthCombo.h"
33 #include "LyXRC.h" // defaultUnit
34 #include "ModuleList.h"
35 #include "OutputParams.h"
36 #include "PanelStack.h"
37 #include "PDFOptions.h"
38 #include "qt_helpers.h"
39 #include "Spacing.h"
40 #include "TextClassList.h"
41 #include "Validator.h"
42
43
44 // FIXME: those two headers are needed because of the
45 // WorkArea::redraw() call below.
46 #include "frontends/LyXView.h"
47 #include "frontends/WorkArea.h"
48
49 #include "insets/InsetListingsParams.h"
50
51 #include "support/lstrings.h"
52
53 #include <boost/bind.hpp>
54
55 #include <QCloseEvent>
56 #include <QScrollBar>
57 #include <QTextCursor>
58
59 #include <algorithm>
60 #include <sstream>
61
62 using std::distance;
63 using std::make_pair;
64 using std::pair;
65 using std::vector;
66 using std::string;
67 using std::ostringstream;
68 using std::sort;
69
70 ///
71 template<class Pair>
72 std::vector<typename Pair::second_type> const
73 getSecond(std::vector<Pair> const & pr)
74 {
75          std::vector<typename Pair::second_type> tmp(pr.size());
76          std::transform(pr.begin(), pr.end(), tmp.begin(),
77                                          boost::bind(&Pair::second, _1));
78          return tmp;
79 }
80
81 char const * const tex_graphics[] =
82 {
83         "default", "dvips", "dvitops", "emtex",
84         "ln", "oztex", "textures", "none", ""
85 };
86
87
88 char const * const tex_graphics_gui[] =
89 {
90         N_("Default"), "Dvips", "DVItoPS", "EmTeX",
91         "LN", "OzTeX", "Textures", N_("None"), ""
92 };
93
94
95 char const * const tex_fonts_roman[] =
96 {
97         "default", "cmr", "lmodern", "ae", "times", "palatino",
98         "charter", "newcent", "bookman", "utopia", "beraserif",
99         "ccfonts", "chancery", ""
100 };
101
102
103 char const * tex_fonts_roman_gui[] =
104 {
105         N_("Default"), N_("Computer Modern Roman"), N_("Latin Modern Roman"),
106         N_("AE (Almost European)"), N_("Times Roman"), N_("Palatino"),
107         N_("Bitstream Charter"), N_("New Century Schoolbook"), N_("Bookman"),
108         N_("Utopia"),  N_("Bera Serif"), N_("Concrete Roman"), N_("Zapf Chancery"),
109         ""
110 };
111
112
113 char const * const tex_fonts_sans[] =
114 {
115         "default", "cmss", "lmss", "helvet", "avant", "berasans", "cmbr", ""
116 };
117
118
119 char const * tex_fonts_sans_gui[] =
120 {
121         N_("Default"), N_("Computer Modern Sans"), N_("Latin Modern Sans"),
122         N_("Helvetica"), N_("Avant Garde"), N_("Bera Sans"), N_("CM Bright"), ""
123 };
124
125
126 char const * const tex_fonts_monospaced[] =
127 {
128         "default", "cmtt", "lmtt", "courier", "beramono", "luximono", "cmtl", ""
129 };
130
131
132 char const * tex_fonts_monospaced_gui[] =
133 {
134         N_("Default"), N_("Computer Modern Typewriter"),
135         N_("Latin Modern Typewriter"), N_("Courier"), N_("Bera Mono"),
136         N_("LuxiMono"), N_("CM Typewriter Light"), ""
137 };
138
139
140 vector<pair<string, lyx::docstring> > pagestyles;
141
142
143 namespace lyx {
144 namespace frontend {
145
146 using support::token;
147 using support::bformat;
148 using support::findToken;
149 using support::getVectorFromString;
150
151 /////////////////////////////////////////////////////////////////////
152 //
153 // PreambleModule
154 //
155 /////////////////////////////////////////////////////////////////////
156
157 PreambleModule::PreambleModule(): current_id_(0)
158 {
159         // This is not a memory leak. The object will be destroyed
160         // with this.
161         (void) new LaTeXHighlighter(preambleTE->document());
162         setFocusProxy(preambleTE);
163         connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
164 }
165
166
167 void PreambleModule::update(BufferParams const & params, BufferId id)
168 {
169         QString preamble = toqstr(params.preamble);
170         // Nothing to do if the params and preamble are unchanged.
171         if (id == current_id_
172                 && preamble == preambleTE->document()->toPlainText())
173                 return;
174
175         QTextCursor cur = preambleTE->textCursor();
176         // Save the coords before switching to the new one.
177         preamble_coords_[current_id_] =
178                 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
179
180         // Save the params address for further use.
181         current_id_ = id;
182         preambleTE->document()->setPlainText(preamble);
183         Coords::const_iterator it = preamble_coords_.find(current_id_);
184         if (it == preamble_coords_.end())
185                 // First time we open this one.
186                 preamble_coords_[current_id_] = make_pair(0,0);
187         else {
188                 // Restore saved coords.
189                 QTextCursor cur = preambleTE->textCursor();
190                 cur.setPosition(it->second.first);
191                 preambleTE->setTextCursor(cur);
192                 preambleTE->verticalScrollBar()->setValue(it->second.second);
193         }
194 }
195
196
197 void PreambleModule::apply(BufferParams & params)
198 {
199         params.preamble = fromqstr(preambleTE->document()->toPlainText());
200 }
201
202
203 void PreambleModule::closeEvent(QCloseEvent * e)
204 {
205         // Save the coords before closing.
206         QTextCursor cur = preambleTE->textCursor();
207         preamble_coords_[current_id_] =
208                 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
209         e->accept();
210 }
211
212
213 /////////////////////////////////////////////////////////////////////
214 //
215 // DocumentDialog
216 //
217 /////////////////////////////////////////////////////////////////////
218
219
220
221 GuiDocument::GuiDocument(LyXView & lv)
222         : GuiDialog(lv, "document")
223 {
224         setupUi(this);
225         setViewTitle(_("Document Settings"));
226
227         lang_ = getSecond(getLanguageData(false));
228
229         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
230         connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
231         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
232         connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
233
234         connect(savePB, SIGNAL(clicked()), this, SLOT(saveDefaultClicked()));
235         connect(defaultPB, SIGNAL(clicked()), this, SLOT(useDefaultsClicked()));
236
237         // Manage the restore, ok, apply, restore and cancel/close buttons
238         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
239         bc().setOK(okPB);
240         bc().setApply(applyPB);
241         bc().setCancel(closePB);
242         bc().setRestore(restorePB);
243
244         textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
245         // text layout
246         connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
247                 this, SLOT(change_adaptor()));
248         connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
249                 this, SLOT(setLSpacing(int)));
250         connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)),
251                 this, SLOT(change_adaptor()));
252         connect(textLayoutModule->skipRB, SIGNAL(clicked()),
253                 this, SLOT(change_adaptor()));
254         connect(textLayoutModule->indentRB, SIGNAL(clicked()),
255                 this, SLOT(change_adaptor()));
256         connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
257                 this, SLOT(change_adaptor()));
258         connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)),
259                 this, SLOT(change_adaptor()));
260         connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)),
261                 this, SLOT(change_adaptor()));
262         connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
263                 this, SLOT(setSkip(int)));
264         connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
265                 this, SLOT(enableSkip(bool)));
266         connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
267                 this, SLOT(change_adaptor()));
268         connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
269                 this, SLOT(change_adaptor()));
270         connect(textLayoutModule->bypassCB, SIGNAL(clicked()), 
271                 this, SLOT(change_adaptor()));
272         connect(textLayoutModule->bypassCB, SIGNAL(clicked()), 
273                 this, SLOT(set_listings_msg()));
274         connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
275                 this, SLOT(set_listings_msg()));
276         textLayoutModule->listingsTB->setPlainText(
277                 qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
278         textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
279                 textLayoutModule->lspacingLE));
280         textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
281                 textLayoutModule->skipLE));
282
283         textLayoutModule->skipCO->addItem(qt_("SmallSkip"));
284         textLayoutModule->skipCO->addItem(qt_("MedSkip"));
285         textLayoutModule->skipCO->addItem(qt_("BigSkip"));
286         textLayoutModule->skipCO->addItem(qt_("Length"));
287         // remove the %-items from the unit choice
288         textLayoutModule->skipLengthCO->noPercents();
289         textLayoutModule->lspacingCO->insertItem(
290                 Spacing::Single, qt_("Single"));
291         textLayoutModule->lspacingCO->insertItem(
292                 Spacing::Onehalf, qt_("OneHalf"));
293         textLayoutModule->lspacingCO->insertItem(
294                 Spacing::Double, qt_("Double"));
295         textLayoutModule->lspacingCO->insertItem(
296                 Spacing::Other, qt_("Custom"));
297
298         // initialize the length validator
299         bc().addCheckedLineEdit(textLayoutModule->skipLE);
300
301         fontModule = new UiWidget<Ui::FontUi>;
302         // fonts
303         connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
304                 this, SLOT(change_adaptor()));
305         connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
306                 this, SLOT(romanChanged(int)));
307         connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
308                 this, SLOT(change_adaptor()));
309         connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
310                 this, SLOT(sansChanged(int)));
311         connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
312                 this, SLOT(change_adaptor()));
313         connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
314                 this, SLOT(ttChanged(int)));
315         connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)),
316                 this, SLOT(change_adaptor()));
317         connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
318                 this, SLOT(change_adaptor()));
319         connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
320                 this, SLOT(change_adaptor()));
321         connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
322                 this, SLOT(change_adaptor()));
323         connect(fontModule->fontScCB, SIGNAL(clicked()),
324                 this, SLOT(change_adaptor()));
325         connect(fontModule->fontOsfCB, SIGNAL(clicked()),
326                 this, SLOT(change_adaptor()));
327
328         for (int n = 0; tex_fonts_roman[n][0]; ++n) {
329                 QString font = qt_(tex_fonts_roman_gui[n]);
330                 if (!isFontAvailable(tex_fonts_roman[n]))
331                         font += qt_(" (not installed)");
332                 fontModule->fontsRomanCO->addItem(font);
333         }
334         for (int n = 0; tex_fonts_sans[n][0]; ++n) {
335                 QString font = qt_(tex_fonts_sans_gui[n]);
336                 if (!isFontAvailable(tex_fonts_sans[n]))
337                         font += qt_(" (not installed)");
338                 fontModule->fontsSansCO->addItem(font);
339         }
340         for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
341                 QString font = qt_(tex_fonts_monospaced_gui[n]);
342                 if (!isFontAvailable(tex_fonts_monospaced[n]))
343                         font += qt_(" (not installed)");
344                 fontModule->fontsTypewriterCO->addItem(font);
345         }
346
347         fontModule->fontsizeCO->addItem(qt_("Default"));
348         fontModule->fontsizeCO->addItem(qt_("10"));
349         fontModule->fontsizeCO->addItem(qt_("11"));
350         fontModule->fontsizeCO->addItem(qt_("12"));
351
352         for (int n = 0; GuiDocument::fontfamilies_gui[n][0]; ++n)
353                 fontModule->fontsDefaultCO->addItem(
354                         qt_(GuiDocument::fontfamilies_gui[n]));
355
356
357         pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
358         // page layout
359         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
360                 this, SLOT(setCustomPapersize(int)));
361         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
362                 this, SLOT(setCustomPapersize(int)));
363         connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
364                 this, SLOT(portraitChanged()));
365         connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
366                 this, SLOT(change_adaptor()));
367         connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString &)),
368                 this, SLOT(change_adaptor()));
369         connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString &)),
370                 this, SLOT(change_adaptor()));
371         connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)),
372                 this, SLOT(change_adaptor()));
373         connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)),
374                 this, SLOT(change_adaptor()));
375         connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
376                 this, SLOT(change_adaptor()));
377         connect(pageLayoutModule->landscapeRB, SIGNAL(clicked()),
378                 this, SLOT(change_adaptor()));
379         connect(pageLayoutModule->facingPagesCB, SIGNAL(clicked()),
380                 this, SLOT(change_adaptor()));
381         connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)),
382                 this, SLOT(change_adaptor()));
383
384         pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
385         pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
386         pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
387         pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
388         pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
389         bc().addCheckedLineEdit(pageLayoutModule->paperheightLE,
390                 pageLayoutModule->paperheightL);
391         bc().addCheckedLineEdit(pageLayoutModule->paperwidthLE,
392                 pageLayoutModule->paperwidthL);
393
394         // paper
395         QComboBox * cb = pageLayoutModule->papersizeCO;
396         cb->addItem(qt_("Default"));
397         cb->addItem(qt_("Custom"));
398         cb->addItem(qt_("US letter"));
399         cb->addItem(qt_("US legal"));
400         cb->addItem(qt_("US executive"));
401         cb->addItem(qt_("A3"));
402         cb->addItem(qt_("A4"));
403         cb->addItem(qt_("A5"));
404         cb->addItem(qt_("B3"));
405         cb->addItem(qt_("B4"));
406         cb->addItem(qt_("B5"));
407         // remove the %-items from the unit choice
408         pageLayoutModule->paperwidthUnitCO->noPercents();
409         pageLayoutModule->paperheightUnitCO->noPercents();
410         pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator(
411                 pageLayoutModule->paperheightLE));
412         pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator(
413                 pageLayoutModule->paperwidthLE));
414
415
416         marginsModule = new UiWidget<Ui::MarginsUi>;
417         // margins
418         connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
419                 this, SLOT(setCustomMargins(bool)));
420         connect(marginsModule->marginCB, SIGNAL(clicked()),
421                 this, SLOT(change_adaptor()));
422         connect(marginsModule->topLE, SIGNAL(textChanged(const QString &)),
423                 this, SLOT(change_adaptor()));
424         connect(marginsModule->topUnit, SIGNAL(activated(int)),
425                 this, SLOT(change_adaptor()));
426         connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString &)),
427                 this, SLOT(change_adaptor()));
428         connect(marginsModule->bottomUnit, SIGNAL(activated(int)),
429                 this, SLOT(change_adaptor()));
430         connect(marginsModule->innerLE, SIGNAL(textChanged(const QString &)),
431                 this, SLOT(change_adaptor()));
432         connect(marginsModule->innerUnit, SIGNAL(activated(int)),
433                 this, SLOT(change_adaptor()));
434         connect(marginsModule->outerLE, SIGNAL(textChanged(const QString &)),
435                 this, SLOT(change_adaptor()));
436         connect(marginsModule->outerUnit, SIGNAL(activated(int)),
437                 this, SLOT(change_adaptor()));
438         connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString &)),
439                 this, SLOT(change_adaptor()));
440         connect(marginsModule->headheightUnit, SIGNAL(activated(int)),
441                 this, SLOT(change_adaptor()));
442         connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString &)),
443                 this, SLOT(change_adaptor()));
444         connect(marginsModule->headsepUnit, SIGNAL(activated(int)),
445                 this, SLOT(change_adaptor()));
446         connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)),
447                 this, SLOT(change_adaptor()));
448         connect(marginsModule->footskipUnit, SIGNAL(activated(int)),
449                 this, SLOT(change_adaptor()));
450         marginsModule->topLE->setValidator(unsignedLengthValidator(
451                 marginsModule->topLE));
452         marginsModule->bottomLE->setValidator(unsignedLengthValidator(
453                 marginsModule->bottomLE));
454         marginsModule->innerLE->setValidator(unsignedLengthValidator(
455                 marginsModule->innerLE));
456         marginsModule->outerLE->setValidator(unsignedLengthValidator(
457                 marginsModule->outerLE));
458         marginsModule->headsepLE->setValidator(unsignedLengthValidator(
459                 marginsModule->headsepLE));
460         marginsModule->headheightLE->setValidator(unsignedLengthValidator(
461                 marginsModule->headheightLE));
462         marginsModule->footskipLE->setValidator(unsignedLengthValidator(
463                 marginsModule->footskipLE));
464
465         bc().addCheckedLineEdit(marginsModule->topLE,
466                 marginsModule->topL);
467         bc().addCheckedLineEdit(marginsModule->bottomLE,
468                 marginsModule->bottomL);
469         bc().addCheckedLineEdit(marginsModule->innerLE,
470                 marginsModule->innerL);
471         bc().addCheckedLineEdit(marginsModule->outerLE,
472                 marginsModule->outerL);
473         bc().addCheckedLineEdit(marginsModule->headsepLE,
474                 marginsModule->headsepL);
475         bc().addCheckedLineEdit(marginsModule->headheightLE,
476                 marginsModule->headheightL);
477         bc().addCheckedLineEdit(marginsModule->footskipLE,
478                 marginsModule->footskipL);
479
480
481         langModule = new UiWidget<Ui::LanguageUi>;
482         // language & quote
483         connect(langModule->languageCO, SIGNAL(activated(int)),
484                 this, SLOT(change_adaptor()));
485         connect(langModule->defaultencodingRB, SIGNAL(clicked()),
486                 this, SLOT(change_adaptor()));
487         connect(langModule->otherencodingRB, SIGNAL(clicked()),
488                 this, SLOT(change_adaptor()));
489         connect(langModule->encodingCO, SIGNAL(activated(int)),
490                 this, SLOT(change_adaptor()));
491         connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
492                 this, SLOT(change_adaptor()));
493         // language & quotes
494         vector<LanguagePair> const langs = getLanguageData(false);
495         vector<LanguagePair>::const_iterator lit  = langs.begin();
496         vector<LanguagePair>::const_iterator lend = langs.end();
497         for (; lit != lend; ++lit) {
498                 langModule->languageCO->addItem(toqstr(lit->first));
499         }
500
501         // Always put the default encoding in the first position.
502         // It is special because the displayed text is translated.
503         langModule->encodingCO->addItem(qt_("LaTeX default"));
504         Encodings::const_iterator it = encodings.begin();
505         Encodings::const_iterator const end = encodings.end();
506         for (; it != end; ++it)
507                 langModule->encodingCO->addItem(toqstr(it->latexName()));
508
509         langModule->quoteStyleCO->addItem(qt_("``text''"));
510         langModule->quoteStyleCO->addItem(qt_("''text''"));
511         langModule->quoteStyleCO->addItem(qt_(",,text``"));
512         langModule->quoteStyleCO->addItem(qt_(",,text''"));
513         langModule->quoteStyleCO->addItem(qt_("<<text>>"));
514         langModule->quoteStyleCO->addItem(qt_(">>text<<"));
515
516
517
518         numberingModule = new UiWidget<Ui::NumberingUi>;
519         // numbering
520         connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
521                 this, SLOT(change_adaptor()));
522         connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
523                 this, SLOT(change_adaptor()));
524         connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
525                 this, SLOT(updateNumbering()));
526         connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
527                 this, SLOT(updateNumbering()));
528         numberingModule->tocTW->setColumnCount(3);
529         numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
530         numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
531         numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
532
533
534         biblioModule = new UiWidget<Ui::BiblioUi>;
535         connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
536                 biblioModule->citationStyleL, SLOT(setEnabled(bool)));
537         connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
538                 biblioModule->citeStyleCO, SLOT(setEnabled(bool)));
539         // biblio
540         connect(biblioModule->citeDefaultRB, SIGNAL(clicked()),
541                 this, SLOT(change_adaptor()));
542         connect(biblioModule->citeNatbibRB, SIGNAL(clicked()),
543                 this, SLOT(change_adaptor()));
544         connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
545                 this, SLOT(change_adaptor()));
546         connect(biblioModule->citeJurabibRB, SIGNAL(clicked()),
547                 this, SLOT(change_adaptor()));
548         connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
549                 this, SLOT(change_adaptor()));
550         // biblio
551         biblioModule->citeStyleCO->addItem(qt_("Author-year"));
552         biblioModule->citeStyleCO->addItem(qt_("Numerical"));
553         biblioModule->citeStyleCO->setCurrentIndex(0);
554
555
556         mathsModule = new UiWidget<Ui::MathsUi>;
557         connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)),
558                 mathsModule->amsCB, SLOT(setDisabled(bool)));
559         connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)),
560                 mathsModule->esintCB, SLOT(setDisabled(bool)));
561         // maths
562         connect(mathsModule->amsCB, SIGNAL(clicked()),
563                 this, SLOT(change_adaptor()));
564         connect(mathsModule->amsautoCB, SIGNAL(clicked()),
565                 this, SLOT(change_adaptor()));
566         connect(mathsModule->esintCB, SIGNAL(clicked()),
567                 this, SLOT(change_adaptor()));
568         connect(mathsModule->esintautoCB, SIGNAL(clicked()),
569                 this, SLOT(change_adaptor()));
570
571         latexModule = new UiWidget<Ui::LaTeXUi>;
572         // latex class
573         connect(latexModule->classCO, SIGNAL(activated(int)),
574                 this, SLOT(change_adaptor()));
575         connect(latexModule->optionsLE, SIGNAL(textChanged(const QString &)),
576                 this, SLOT(change_adaptor()));
577         connect(latexModule->psdriverCO, SIGNAL(activated(int)),
578                 this, SLOT(change_adaptor()));
579         connect(latexModule->classCO, SIGNAL(activated(int)),
580                 this, SLOT(classChanged()));
581         
582         selectionManager = 
583                 new GuiSelectionManager(latexModule->availableLV, latexModule->selectedLV, 
584                         latexModule->addPB, latexModule->deletePB, 
585                         latexModule->upPB, latexModule->downPB, 
586                         availableModel(), selectedModel());
587         connect(selectionManager, SIGNAL(updateHook()),
588                 this, SLOT(updateModuleInfo()));
589         connect(selectionManager, SIGNAL(updateHook()),
590                 this, SLOT(change_adaptor()));
591         
592         // postscript drivers
593         for (int n = 0; tex_graphics[n][0]; ++n) {
594                 QString enc = qt_(tex_graphics_gui[n]);
595                 latexModule->psdriverCO->addItem(enc);
596         }
597         // latex classes
598         //FIXME This seems too involved with the kernel. Some of this
599         //should be moved to the kernel---which should perhaps just
600         //give us a list of entries or something of the sort.
601         for (TextClassList::const_iterator cit = textclasslist.begin();
602              cit != textclasslist.end(); ++cit) {
603                 if (cit->isTeXClassAvailable()) {
604                         latexModule->classCO->addItem(toqstr(cit->description()));
605                 } else {
606                         docstring item =
607                                 bformat(_("Unavailable: %1$s"), from_utf8(cit->description()));
608                         latexModule->classCO->addItem(toqstr(item));
609                 }
610         }
611
612         // branches
613         branchesModule = new GuiBranches;
614         connect(branchesModule, SIGNAL(changed()),
615                 this, SLOT(change_adaptor()));
616
617         // preamble
618         preambleModule = new PreambleModule;
619         connect(preambleModule, SIGNAL(changed()),
620                 this, SLOT(change_adaptor()));
621
622         // bullets
623         bulletsModule = new BulletsModule;
624         connect(bulletsModule, SIGNAL(changed()),
625                 this, SLOT(change_adaptor()));
626
627         // PDF support
628         pdfSupportModule = new UiWidget<Ui::PDFSupportUi>;
629
630         connect(pdfSupportModule->use_hyperrefGB, SIGNAL(toggled(bool)),
631                 this, SLOT(change_adaptor()));
632         connect(pdfSupportModule->titleLE, SIGNAL(textChanged(const QString &)),
633                 this, SLOT(change_adaptor()));
634         connect(pdfSupportModule->authorLE, SIGNAL(textChanged(const QString &)),
635                 this, SLOT(change_adaptor()));
636         connect(pdfSupportModule->subjectLE, SIGNAL(textChanged(const QString &)),
637                 this, SLOT(change_adaptor()));
638         connect(pdfSupportModule->keywordsLE, SIGNAL(textChanged(const QString &)),
639                 this, SLOT(change_adaptor()));
640         connect(pdfSupportModule->bookmarksGB, SIGNAL(toggled(bool)),
641                 this, SLOT(change_adaptor()));
642         connect(pdfSupportModule->bookmarksnumberedCB, SIGNAL(toggled(bool)),
643                 this, SLOT(change_adaptor()));
644         connect(pdfSupportModule->bookmarksopenGB, SIGNAL(toggled(bool)),
645                 this, SLOT(change_adaptor()));
646         connect(pdfSupportModule->bookmarksopenlevelSB, SIGNAL(valueChanged(int)),
647                 this, SLOT(change_adaptor()));
648         connect(pdfSupportModule->breaklinksCB, SIGNAL(toggled(bool)),
649                 this, SLOT(change_adaptor()));
650         connect(pdfSupportModule->pdfborderCB, SIGNAL(toggled(bool)),
651                 this, SLOT(change_adaptor()));
652         connect(pdfSupportModule->colorlinksCB, SIGNAL(toggled(bool)),
653                 this, SLOT(change_adaptor()));
654         connect(pdfSupportModule->backrefCB, SIGNAL(toggled(bool)),
655                 this, SLOT(change_adaptor()));
656         connect(pdfSupportModule->pdfusetitleCB, SIGNAL(toggled(bool)),
657                 this, SLOT(change_adaptor()));
658         connect(pdfSupportModule->pagebackrefCB, SIGNAL(toggled(bool)),
659                 this, SLOT(change_adaptor()));
660         connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
661                 this, SLOT(change_adaptor()));
662         connect(pdfSupportModule->optionsLE, SIGNAL(textChanged(const QString &)),
663                 this, SLOT(change_adaptor()));
664
665         // float
666         floatModule = new FloatPlacement;
667         connect(floatModule, SIGNAL(changed()),
668                 this, SLOT(change_adaptor()));
669
670         docPS->addPanel(latexModule, _("Document Class"));
671         docPS->addPanel(fontModule, _("Fonts"));
672         docPS->addPanel(textLayoutModule, _("Text Layout"));
673         docPS->addPanel(pageLayoutModule, _("Page Layout"));
674         docPS->addPanel(marginsModule, _("Page Margins"));
675         docPS->addPanel(langModule, _("Language"));
676         docPS->addPanel(numberingModule, _("Numbering & TOC"));
677         docPS->addPanel(biblioModule, _("Bibliography"));
678         docPS->addPanel(pdfSupportModule, _("PDF Properties"));
679         docPS->addPanel(mathsModule, _("Math Options"));
680         docPS->addPanel(floatModule, _("Float Placement"));
681         docPS->addPanel(bulletsModule, _("Bullets"));
682         docPS->addPanel(branchesModule, _("Branches"));
683         docPS->addPanel(preambleModule, _("LaTeX Preamble"));
684         docPS->setCurrentPanel(_("Document Class"));
685 // FIXME: hack to work around resizing bug in Qt >= 4.2
686 // bug verified with Qt 4.2.{0-3} (JSpitzm)
687 #if QT_VERSION >= 0x040200
688         docPS->updateGeometry();
689 #endif
690 }
691
692
693 void GuiDocument::showPreamble()
694 {
695         docPS->setCurrentPanel(_("LaTeX Preamble"));
696 }
697
698
699 void GuiDocument::saveDefaultClicked()
700 {
701         saveDocDefault();
702 }
703
704
705 void GuiDocument::useDefaultsClicked()
706 {
707         useClassDefaults();
708 }
709
710
711 void GuiDocument::change_adaptor()
712 {
713         changed();
714 }
715
716
717 docstring GuiDocument::validate_listings_params()
718 {
719         // use a cache here to avoid repeated validation
720         // of the same parameters
721         static string param_cache = string();
722         static docstring msg_cache = docstring();
723         
724         if (textLayoutModule->bypassCB->isChecked())
725                 return docstring();
726
727         string params = fromqstr(textLayoutModule->listingsED->toPlainText());
728         if (params != param_cache) {
729                 param_cache = params;
730                 msg_cache = InsetListingsParams(params).validate();
731         }
732         return msg_cache;
733 }
734
735
736 void GuiDocument::set_listings_msg()
737 {
738         static bool isOK = true;
739         docstring msg = validate_listings_params();
740         if (msg.empty()) {
741                 if (isOK)
742                         return;
743                 isOK = true;
744                 // listingsTB->setTextColor("black");
745                 textLayoutModule->listingsTB->setPlainText(
746                         qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
747         } else {
748                 isOK = false;
749                 // listingsTB->setTextColor("red");
750                 textLayoutModule->listingsTB->setPlainText(toqstr(msg));
751         }
752 }
753
754
755 void GuiDocument::closeEvent(QCloseEvent * e)
756 {
757         slotClose();
758         e->accept();
759 }
760
761
762 void GuiDocument::setLSpacing(int item)
763 {
764         textLayoutModule->lspacingLE->setEnabled(item == 3);
765 }
766
767
768 void GuiDocument::setSkip(int item)
769 {
770         bool const enable = (item == 3);
771         textLayoutModule->skipLE->setEnabled(enable);
772         textLayoutModule->skipLengthCO->setEnabled(enable);
773 }
774
775
776 void GuiDocument::enableSkip(bool skip)
777 {
778         textLayoutModule->skipCO->setEnabled(skip);
779         textLayoutModule->skipLE->setEnabled(skip);
780         textLayoutModule->skipLengthCO->setEnabled(skip);
781         if (skip)
782                 setSkip(textLayoutModule->skipCO->currentIndex());
783 }
784
785 void GuiDocument::portraitChanged()
786 {
787         setMargins(pageLayoutModule->papersizeCO->currentIndex());
788 }
789
790 void GuiDocument::setMargins(bool custom)
791 {
792         marginsModule->marginCB->setChecked(custom);
793         setCustomMargins(custom);
794 }
795
796
797 void GuiDocument::setCustomPapersize(int papersize)
798 {
799         bool const custom = (papersize == 1);
800
801         pageLayoutModule->paperwidthL->setEnabled(custom);
802         pageLayoutModule->paperwidthLE->setEnabled(custom);
803         pageLayoutModule->paperwidthUnitCO->setEnabled(custom);
804         pageLayoutModule->paperheightL->setEnabled(custom);
805         pageLayoutModule->paperheightLE->setEnabled(custom);
806         pageLayoutModule->paperheightLE->setFocus();
807         pageLayoutModule->paperheightUnitCO->setEnabled(custom);
808 }
809
810
811 void GuiDocument::setCustomMargins(bool custom)
812 {
813         marginsModule->topL->setEnabled(!custom);
814         marginsModule->topLE->setEnabled(!custom);
815         marginsModule->topUnit->setEnabled(!custom);
816
817         marginsModule->bottomL->setEnabled(!custom);
818         marginsModule->bottomLE->setEnabled(!custom);
819         marginsModule->bottomUnit->setEnabled(!custom);
820
821         marginsModule->innerL->setEnabled(!custom);
822         marginsModule->innerLE->setEnabled(!custom);
823         marginsModule->innerUnit->setEnabled(!custom);
824
825         marginsModule->outerL->setEnabled(!custom);
826         marginsModule->outerLE->setEnabled(!custom);
827         marginsModule->outerUnit->setEnabled(!custom);
828
829         marginsModule->headheightL->setEnabled(!custom);
830         marginsModule->headheightLE->setEnabled(!custom);
831         marginsModule->headheightUnit->setEnabled(!custom);
832
833         marginsModule->headsepL->setEnabled(!custom);
834         marginsModule->headsepLE->setEnabled(!custom);
835         marginsModule->headsepUnit->setEnabled(!custom);
836
837         marginsModule->footskipL->setEnabled(!custom);
838         marginsModule->footskipLE->setEnabled(!custom);
839         marginsModule->footskipUnit->setEnabled(!custom);
840 }
841
842
843 void GuiDocument::updateFontsize(string const & items, string const & sel)
844 {
845         fontModule->fontsizeCO->clear();
846         fontModule->fontsizeCO->addItem(qt_("Default"));
847
848         for (int n = 0; !token(items,'|',n).empty(); ++n)
849                 fontModule->fontsizeCO->
850                         addItem(toqstr(token(items,'|',n)));
851
852         for (int n = 0; n < fontModule->fontsizeCO->count(); ++n) {
853                 if (fromqstr(fontModule->fontsizeCO->itemText(n)) == sel) {
854                         fontModule->fontsizeCO->setCurrentIndex(n);
855                         break;
856                 }
857         }
858 }
859
860
861 void GuiDocument::romanChanged(int item)
862 {
863         string const font = tex_fonts_roman[item];
864         fontModule->fontScCB->setEnabled(providesSC(font));
865         fontModule->fontOsfCB->setEnabled(providesOSF(font));
866 }
867
868
869 void GuiDocument::sansChanged(int item)
870 {
871         string const font = tex_fonts_sans[item];
872         bool scaleable = providesScale(font);
873         fontModule->scaleSansSB->setEnabled(scaleable);
874         fontModule->scaleSansLA->setEnabled(scaleable);
875 }
876
877
878 void GuiDocument::ttChanged(int item)
879 {
880         string const font = tex_fonts_monospaced[item];
881         bool scaleable = providesScale(font);
882         fontModule->scaleTypewriterSB->setEnabled(scaleable);
883         fontModule->scaleTypewriterLA->setEnabled(scaleable);
884 }
885
886
887 void GuiDocument::updatePagestyle(string const & items, string const & sel)
888 {
889         pagestyles.clear();
890         pageLayoutModule->pagestyleCO->clear();
891         pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
892
893         for (int n = 0; !token(items,'|',n).empty(); ++n) {
894                 string style = token(items, '|', n);
895                 docstring style_gui = _(style);
896                 pagestyles.push_back(pair<string, docstring>(style, style_gui));
897                 pageLayoutModule->pagestyleCO->addItem(toqstr(style_gui));
898         }
899
900         if (sel == "default") {
901                 pageLayoutModule->pagestyleCO->setCurrentIndex(0);
902                 return;
903         }
904
905         int nn = 0;
906
907         for (size_t i = 0; i < pagestyles.size(); ++i)
908                 if (pagestyles[i].first == sel)
909                         nn = pageLayoutModule->pagestyleCO->findText(
910                                         toqstr(pagestyles[i].second));
911
912         if (nn > 0)
913                 pageLayoutModule->pagestyleCO->setCurrentIndex(nn);
914 }
915
916
917 void GuiDocument::classChanged()
918 {
919         textclass_type const tc = latexModule->classCO->currentIndex();
920         bp_.setJustBaseClass(tc);
921         if (lyxrc.auto_reset_options)
922                 bp_.useClassDefaults();
923         updateContents();
924 }
925
926
927 void GuiDocument::updateModuleInfo()
928 {
929         selectionManager->update();
930         //Module description
931         QListView const * const lv = selectionManager->selectedFocused() ?
932                                      latexModule->selectedLV :
933                         latexModule->availableLV;
934         if (lv->selectionModel()->selectedIndexes().isEmpty())
935                 latexModule->infoML->document()->clear();
936         else {
937                 QModelIndex const idx = lv->selectionModel()->currentIndex();
938                 string const modName = fromqstr(idx.data().toString());
939                 string desc = getModuleDescription(modName);
940                 vector<string> pkgList = getPackageList(modName);
941                 string pkgdesc;
942                 //this mess formats the package list as "pkg1, pkg2, and pkg3"
943                 int const pkgListSize = pkgList.size();
944                 for (int i = 0; i < pkgListSize; ++i) {
945                         if (i == 1) {
946                                 if (i == pkgListSize - 1) //last element
947                                         pkgdesc += " and ";
948                                 else
949                                         pkgdesc += ", ";
950                         } else if (i > 1) {
951                                 if (i == pkgListSize - 1) //last element
952                                         pkgdesc += ", and ";
953                                 else
954                                         pkgdesc += ", ";
955                         }
956                         pkgdesc += pkgList[i];
957                 }
958                 if (!pkgdesc.empty())
959                         desc += " Requires " + pkgdesc + ".";
960                 latexModule->infoML->document()->setPlainText(toqstr(desc));
961         }
962 }
963
964
965 void GuiDocument::updateNumbering()
966 {
967         TextClass const & tclass = bp_.getTextClass();
968
969         numberingModule->tocTW->setUpdatesEnabled(false);
970         numberingModule->tocTW->clear();
971
972         int const depth = numberingModule->depthSL->value();
973         int const toc = numberingModule->tocSL->value();
974         QString const no = qt_("No");
975         QString const yes = qt_("Yes");
976         TextClass::const_iterator end = tclass.end();
977         TextClass::const_iterator cit = tclass.begin();
978         QTreeWidgetItem * item = 0;
979         for ( ; cit != end ; ++cit) {
980                 int const toclevel = (*cit)->toclevel;
981                 if (toclevel != Layout::NOT_IN_TOC
982                     && (*cit)->labeltype == LABEL_COUNTER) {
983                         item = new QTreeWidgetItem(numberingModule->tocTW);
984                         item->setText(0, toqstr(translateIfPossible((*cit)->name())));
985                         item->setText(1, (toclevel <= depth) ? yes : no);
986                         item->setText(2, (toclevel <= toc) ? yes : no);
987                 }
988         }
989
990         numberingModule->tocTW->setUpdatesEnabled(true);
991         numberingModule->tocTW->update();
992 }
993
994
995 void GuiDocument::apply(BufferParams & params)
996 {
997         // preamble
998         preambleModule->apply(params);
999
1000         // biblio
1001         params.setCiteEngine(biblio::ENGINE_BASIC);
1002
1003         if (biblioModule->citeNatbibRB->isChecked()) {
1004                 bool const use_numerical_citations =
1005                         biblioModule->citeStyleCO->currentIndex();
1006                 if (use_numerical_citations)
1007                         params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
1008                 else
1009                         params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
1010
1011         } else if (biblioModule->citeJurabibRB->isChecked())
1012                 params.setCiteEngine(biblio::ENGINE_JURABIB);
1013
1014         params.use_bibtopic =
1015                 biblioModule->bibtopicCB->isChecked();
1016
1017         // language & quotes
1018         if (langModule->defaultencodingRB->isChecked()) {
1019                 params.inputenc = "auto";
1020         } else {
1021                 int i = langModule->encodingCO->currentIndex();
1022                 if (i == 0)
1023                         params.inputenc = "default";
1024                 else
1025                         params.inputenc =
1026                                 fromqstr(langModule->encodingCO->currentText());
1027         }
1028
1029         InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
1030         switch (langModule->quoteStyleCO->currentIndex()) {
1031         case 0:
1032                 lga = InsetQuotes::EnglishQ;
1033                 break;
1034         case 1:
1035                 lga = InsetQuotes::SwedishQ;
1036                 break;
1037         case 2:
1038                 lga = InsetQuotes::GermanQ;
1039                 break;
1040         case 3:
1041                 lga = InsetQuotes::PolishQ;
1042                 break;
1043         case 4:
1044                 lga = InsetQuotes::FrenchQ;
1045                 break;
1046         case 5:
1047                 lga = InsetQuotes::DanishQ;
1048                 break;
1049         }
1050         params.quotes_language = lga;
1051
1052         int const pos = langModule->languageCO->currentIndex();
1053         params.language = lyx::languages.getLanguage(lang_[pos]);
1054
1055         // numbering
1056         if (params.getTextClass().hasTocLevels()) {
1057                 params.tocdepth = numberingModule->tocSL->value();
1058                 params.secnumdepth = numberingModule->depthSL->value();
1059         }
1060
1061         // bullets
1062         params.user_defined_bullet(0) = bulletsModule->getBullet(0);
1063         params.user_defined_bullet(1) = bulletsModule->getBullet(1);
1064         params.user_defined_bullet(2) = bulletsModule->getBullet(2);
1065         params.user_defined_bullet(3) = bulletsModule->getBullet(3);
1066
1067         // packages
1068         params.graphicsDriver =
1069                 tex_graphics[latexModule->psdriverCO->currentIndex()];
1070         
1071         // Modules
1072         params.clearLayoutModules();
1073         QStringList const selMods = selectedModel()->stringList();
1074         for (int i = 0; i != selMods.size(); ++i)
1075                 params.addLayoutModule(lyx::fromqstr(selMods[i]));
1076
1077
1078         if (mathsModule->amsautoCB->isChecked()) {
1079                 params.use_amsmath = BufferParams::package_auto;
1080         } else {
1081                 if (mathsModule->amsCB->isChecked())
1082                         params.use_amsmath = BufferParams::package_on;
1083                 else
1084                         params.use_amsmath = BufferParams::package_off;
1085         }
1086
1087         if (mathsModule->esintautoCB->isChecked())
1088                 params.use_esint = BufferParams::package_auto;
1089         else {
1090                 if (mathsModule->esintCB->isChecked())
1091                         params.use_esint = BufferParams::package_on;
1092                 else
1093                         params.use_esint = BufferParams::package_off;
1094         }
1095
1096         // text layout
1097         params.setJustBaseClass(latexModule->classCO->currentIndex());
1098
1099         if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
1100                 params.pagestyle = "default";
1101         else {
1102                 docstring style_gui =
1103                         qstring_to_ucs4(pageLayoutModule->pagestyleCO->currentText());
1104                 for (size_t i = 0; i < pagestyles.size(); ++i)
1105                         if (pagestyles[i].second == style_gui)
1106                                 params.pagestyle = pagestyles[i].first;
1107         }
1108
1109         switch (textLayoutModule->lspacingCO->currentIndex()) {
1110         case 0:
1111                 params.spacing().set(Spacing::Single);
1112                 break;
1113         case 1:
1114                 params.spacing().set(Spacing::Onehalf);
1115                 break;
1116         case 2:
1117                 params.spacing().set(Spacing::Double);
1118                 break;
1119         case 3:
1120                 params.spacing().set(Spacing::Other,
1121                         fromqstr(textLayoutModule->lspacingLE->text()));
1122                 break;
1123         }
1124
1125         if (textLayoutModule->twoColumnCB->isChecked())
1126                 params.columns = 2;
1127         else
1128                 params.columns = 1;
1129
1130         // text should have passed validation
1131         params.listings_params =
1132                 InsetListingsParams(fromqstr(textLayoutModule->listingsED->toPlainText())).params();
1133
1134         if (textLayoutModule->indentRB->isChecked())
1135                 params.paragraph_separation = BufferParams::PARSEP_INDENT;
1136         else
1137                 params.paragraph_separation = BufferParams::PARSEP_SKIP;
1138
1139         switch (textLayoutModule->skipCO->currentIndex()) {
1140         case 0:
1141                 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
1142                 break;
1143         case 1:
1144                 params.setDefSkip(VSpace(VSpace::MEDSKIP));
1145                 break;
1146         case 2:
1147                 params.setDefSkip(VSpace(VSpace::BIGSKIP));
1148                 break;
1149         case 3:
1150         {
1151                 VSpace vs = VSpace(
1152                         widgetsToLength(textLayoutModule->skipLE,
1153                                 textLayoutModule->skipLengthCO)
1154                         );
1155                 params.setDefSkip(vs);
1156                 break;
1157         }
1158         default:
1159                 // DocumentDefskipCB assures that this never happens
1160                 // so Assert then !!!  - jbl
1161                 params.setDefSkip(VSpace(VSpace::MEDSKIP));
1162                 break;
1163         }
1164
1165         params.options =
1166                 fromqstr(latexModule->optionsLE->text());
1167
1168         params.float_placement = floatModule->get();
1169
1170         // fonts
1171         params.fontsRoman =
1172                 tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
1173
1174         params.fontsSans =
1175                 tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
1176
1177         params.fontsTypewriter =
1178                 tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
1179
1180         params.fontsSansScale = fontModule->scaleSansSB->value();
1181
1182         params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value();
1183
1184         params.fontsSC = fontModule->fontScCB->isChecked();
1185
1186         params.fontsOSF = fontModule->fontOsfCB->isChecked();
1187
1188         params.fontsDefaultFamily = GuiDocument::fontfamilies[
1189                 fontModule->fontsDefaultCO->currentIndex()];
1190
1191         if (fontModule->fontsizeCO->currentIndex() == 0)
1192                 params.fontsize = "default";
1193         else
1194                 params.fontsize =
1195                         fromqstr(fontModule->fontsizeCO->currentText());
1196
1197         // paper
1198         params.papersize = PAPER_SIZE(
1199                 pageLayoutModule->papersizeCO->currentIndex());
1200
1201         // custom, A3, B3 and B4 paper sizes need geometry
1202         int psize = pageLayoutModule->papersizeCO->currentIndex();
1203         bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9);
1204
1205         params.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
1206                 pageLayoutModule->paperwidthUnitCO);
1207
1208         params.paperheight = widgetsToLength(pageLayoutModule->paperheightLE,
1209                 pageLayoutModule->paperheightUnitCO);
1210
1211         if (pageLayoutModule->facingPagesCB->isChecked())
1212                 params.sides = TextClass::TwoSides;
1213         else
1214                 params.sides = TextClass::OneSide;
1215
1216         if (pageLayoutModule->landscapeRB->isChecked())
1217                 params.orientation = ORIENTATION_LANDSCAPE;
1218         else
1219                 params.orientation = ORIENTATION_PORTRAIT;
1220
1221         // margins
1222         params.use_geometry =
1223                 (!marginsModule->marginCB->isChecked()
1224                 || geom_papersize);
1225
1226         Ui::MarginsUi const * m(marginsModule);
1227
1228         params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
1229         params.topmargin = widgetsToLength(m->topLE, m->topUnit);
1230         params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
1231         params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
1232         params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
1233         params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
1234         params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
1235
1236         branchesModule->apply(params);
1237
1238         // PDF support
1239         PDFOptions & pdf = params.pdfoptions();
1240         pdf.use_hyperref = pdfSupportModule->use_hyperrefGB->isChecked();
1241         pdf.title = fromqstr(pdfSupportModule->titleLE->text());
1242         pdf.author = fromqstr(pdfSupportModule->authorLE->text());
1243         pdf.subject = fromqstr(pdfSupportModule->subjectLE->text());
1244         pdf.keywords = fromqstr(pdfSupportModule->keywordsLE->text());
1245
1246         pdf.bookmarks = pdfSupportModule->bookmarksGB->isChecked();
1247         pdf.bookmarksnumbered = pdfSupportModule->bookmarksnumberedCB->isChecked();
1248         pdf.bookmarksopen = pdfSupportModule->bookmarksopenGB->isChecked();
1249         pdf.bookmarksopenlevel = pdfSupportModule->bookmarksopenlevelSB->value();
1250
1251         pdf.breaklinks = pdfSupportModule->breaklinksCB->isChecked();
1252         pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked();
1253         pdf.pdfusetitle = pdfSupportModule->pdfusetitleCB->isChecked();
1254         pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked();
1255         pdf.backref = pdfSupportModule->backrefCB->isChecked();
1256         pdf.pagebackref = pdfSupportModule->pagebackrefCB->isChecked();
1257         if (pdfSupportModule->fullscreenCB->isChecked())
1258                 pdf.pagemode = pdf.pagemode_fullscreen;
1259         else
1260                 pdf.pagemode.clear();
1261         pdf.quoted_options = fromqstr(pdfSupportModule->optionsLE->text());
1262 }
1263
1264
1265 /** Return the position of val in the vector if found.
1266     If not found, return 0.
1267  */
1268 template<class A>
1269 static size_t findPos(std::vector<A> const & vec, A const & val)
1270 {
1271         typename std::vector<A>::const_iterator it =
1272                 std::find(vec.begin(), vec.end(), val);
1273         if (it == vec.end())
1274                 return 0;
1275         return distance(vec.begin(), it);
1276 }
1277
1278
1279 void GuiDocument::updateParams()
1280 {
1281         updateParams(bp_);
1282 }
1283
1284
1285 void GuiDocument::updateParams(BufferParams const & params)
1286 {
1287         // set the default unit
1288         Length::UNIT defaultUnit = Length::CM;
1289         switch (lyxrc.default_papersize) {
1290                 case PAPER_DEFAULT: break;
1291
1292                 case PAPER_USLETTER:
1293                 case PAPER_USLEGAL:
1294                 case PAPER_USEXECUTIVE:
1295                         defaultUnit = Length::IN;
1296                         break;
1297
1298                 case PAPER_A3:
1299                 case PAPER_A4:
1300                 case PAPER_A5:
1301                 case PAPER_B3:
1302                 case PAPER_B4:
1303                 case PAPER_B5:
1304                         defaultUnit = Length::CM;
1305                         break;
1306                 case PAPER_CUSTOM:
1307                         break;
1308         }
1309
1310         // preamble
1311         preambleModule->update(params, id());
1312
1313         // biblio
1314         biblioModule->citeDefaultRB->setChecked(
1315                 params.getEngine() == biblio::ENGINE_BASIC);
1316
1317         biblioModule->citeNatbibRB->setChecked(
1318                 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
1319                 params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
1320
1321         biblioModule->citeStyleCO->setCurrentIndex(
1322                 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
1323
1324         biblioModule->citeJurabibRB->setChecked(
1325                 params.getEngine() == biblio::ENGINE_JURABIB);
1326
1327         biblioModule->bibtopicCB->setChecked(
1328                 params.use_bibtopic);
1329
1330         // language & quotes
1331         int const pos = int(findPos(lang_,
1332                                     params.language->lang()));
1333         langModule->languageCO->setCurrentIndex(pos);
1334
1335         langModule->quoteStyleCO->setCurrentIndex(
1336                 params.quotes_language);
1337
1338         bool default_enc = true;
1339         if (params.inputenc != "auto") {
1340                 default_enc = false;
1341                 if (params.inputenc == "default") {
1342                         langModule->encodingCO->setCurrentIndex(0);
1343                 } else {
1344                         int const i = langModule->encodingCO->findText(
1345                                         toqstr(params.inputenc));
1346                         if (i >= 0)
1347                                 langModule->encodingCO->setCurrentIndex(i);
1348                         else
1349                                 // unknown encoding. Set to default.
1350                                 default_enc = true;
1351                 }
1352         }
1353         langModule->defaultencodingRB->setChecked(default_enc);
1354         langModule->otherencodingRB->setChecked(!default_enc);
1355
1356         // numbering
1357         int const min_toclevel = textClass().min_toclevel();
1358         int const max_toclevel = textClass().max_toclevel();
1359         if (textClass().hasTocLevels()) {
1360                 numberingModule->setEnabled(true);
1361                 numberingModule->depthSL->setMinimum(min_toclevel - 1);
1362                 numberingModule->depthSL->setMaximum(max_toclevel);
1363                 numberingModule->depthSL->setValue(params.secnumdepth);
1364                 numberingModule->tocSL->setMaximum(min_toclevel - 1);
1365                 numberingModule->tocSL->setMaximum(max_toclevel);
1366                 numberingModule->tocSL->setValue(params.tocdepth);
1367                 updateNumbering();
1368         } else {
1369                 numberingModule->setEnabled(false);
1370                 numberingModule->tocTW->clear();
1371         }
1372
1373         // bullets
1374         bulletsModule->setBullet(0, params.user_defined_bullet(0));
1375         bulletsModule->setBullet(1, params.user_defined_bullet(1));
1376         bulletsModule->setBullet(2, params.user_defined_bullet(2));
1377         bulletsModule->setBullet(3, params.user_defined_bullet(3));
1378         bulletsModule->init();
1379
1380         // packages
1381         int nitem = findToken(tex_graphics, params.graphicsDriver);
1382         if (nitem >= 0)
1383                 latexModule->psdriverCO->setCurrentIndex(nitem);
1384         updateModuleInfo();
1385         
1386         mathsModule->amsCB->setChecked(
1387                 params.use_amsmath == BufferParams::package_on);
1388         mathsModule->amsautoCB->setChecked(
1389                 params.use_amsmath == BufferParams::package_auto);
1390
1391         mathsModule->esintCB->setChecked(
1392                 params.use_esint == BufferParams::package_on);
1393         mathsModule->esintautoCB->setChecked(
1394                 params.use_esint == BufferParams::package_auto);
1395
1396         switch (params.spacing().getSpace()) {
1397                 case Spacing::Other: nitem = 3; break;
1398                 case Spacing::Double: nitem = 2; break;
1399                 case Spacing::Onehalf: nitem = 1; break;
1400                 case Spacing::Default: case Spacing::Single: nitem = 0; break;
1401         }
1402
1403         // text layout
1404         latexModule->classCO->setCurrentIndex(params.getBaseClass());
1405         
1406         updatePagestyle(textClass().opt_pagestyle(),
1407                                  params.pagestyle);
1408
1409         textLayoutModule->lspacingCO->setCurrentIndex(nitem);
1410         if (params.spacing().getSpace() == Spacing::Other) {
1411                 textLayoutModule->lspacingLE->setText(
1412                         toqstr(params.spacing().getValueAsString()));
1413         }
1414         setLSpacing(nitem);
1415
1416         if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
1417                 textLayoutModule->indentRB->setChecked(true);
1418         else
1419                 textLayoutModule->skipRB->setChecked(true);
1420
1421         int skip = 0;
1422         switch (params.getDefSkip().kind()) {
1423         case VSpace::SMALLSKIP:
1424                 skip = 0;
1425                 break;
1426         case VSpace::MEDSKIP:
1427                 skip = 1;
1428                 break;
1429         case VSpace::BIGSKIP:
1430                 skip = 2;
1431                 break;
1432         case VSpace::LENGTH:
1433         {
1434                 skip = 3;
1435                 string const length = params.getDefSkip().asLyXCommand();
1436                 lengthToWidgets(textLayoutModule->skipLE,
1437                         textLayoutModule->skipLengthCO,
1438                         length, defaultUnit);
1439                 break;
1440         }
1441         default:
1442                 skip = 0;
1443                 break;
1444         }
1445         textLayoutModule->skipCO->setCurrentIndex(skip);
1446         setSkip(skip);
1447
1448         textLayoutModule->twoColumnCB->setChecked(
1449                 params.columns == 2);
1450
1451         // break listings_params to multiple lines
1452         string lstparams =
1453                 InsetListingsParams(params.listings_params).separatedParams();
1454         textLayoutModule->listingsED->setPlainText(toqstr(lstparams));
1455
1456         if (!params.options.empty()) {
1457                 latexModule->optionsLE->setText(
1458                         toqstr(params.options));
1459         } else {
1460                 latexModule->optionsLE->setText(QString());
1461         }
1462
1463         floatModule->set(params.float_placement);
1464
1465         // Fonts
1466         updateFontsize(textClass().opt_fontsize(),
1467                         params.fontsize);
1468
1469         int n = findToken(tex_fonts_roman, params.fontsRoman);
1470         if (n >= 0) {
1471                 fontModule->fontsRomanCO->setCurrentIndex(n);
1472                 romanChanged(n);
1473         }
1474
1475         n = findToken(tex_fonts_sans, params.fontsSans);
1476         if (n >= 0)     {
1477                 fontModule->fontsSansCO->setCurrentIndex(n);
1478                 sansChanged(n);
1479         }
1480
1481         n = findToken(tex_fonts_monospaced, params.fontsTypewriter);
1482         if (n >= 0) {
1483                 fontModule->fontsTypewriterCO->setCurrentIndex(n);
1484                 ttChanged(n);
1485         }
1486
1487         fontModule->fontScCB->setChecked(params.fontsSC);
1488         fontModule->fontOsfCB->setChecked(params.fontsOSF);
1489         fontModule->scaleSansSB->setValue(params.fontsSansScale);
1490         fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale);
1491         n = findToken(GuiDocument::fontfamilies, params.fontsDefaultFamily);
1492         if (n >= 0)
1493                 fontModule->fontsDefaultCO->setCurrentIndex(n);
1494
1495         // paper
1496         int const psize = params.papersize;
1497         pageLayoutModule->papersizeCO->setCurrentIndex(psize);
1498         setCustomPapersize(psize);
1499
1500         bool const landscape =
1501                 params.orientation == ORIENTATION_LANDSCAPE;
1502         pageLayoutModule->landscapeRB->setChecked(landscape);
1503         pageLayoutModule->portraitRB->setChecked(!landscape);
1504
1505         pageLayoutModule->facingPagesCB->setChecked(
1506                 params.sides == TextClass::TwoSides);
1507
1508
1509         lengthToWidgets(pageLayoutModule->paperwidthLE,
1510                 pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit);
1511
1512         lengthToWidgets(pageLayoutModule->paperheightLE,
1513                 pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit);
1514
1515         // margins
1516         Ui::MarginsUi * m = marginsModule;
1517
1518         setMargins(!params.use_geometry);
1519
1520         lengthToWidgets(m->topLE, m->topUnit,
1521                 params.topmargin, defaultUnit);
1522
1523         lengthToWidgets(m->bottomLE, m->bottomUnit,
1524                 params.bottommargin, defaultUnit);
1525
1526         lengthToWidgets(m->innerLE, m->innerUnit,
1527                 params.leftmargin, defaultUnit);
1528
1529         lengthToWidgets(m->outerLE, m->outerUnit,
1530                 params.rightmargin, defaultUnit);
1531
1532         lengthToWidgets(m->headheightLE, m->headheightUnit,
1533                 params.headheight, defaultUnit);
1534
1535         lengthToWidgets(m->headsepLE, m->headsepUnit,
1536                 params.headsep, defaultUnit);
1537
1538         lengthToWidgets(m->footskipLE, m->footskipUnit,
1539                 params.footskip, defaultUnit);
1540
1541         branchesModule->update(params);
1542
1543         // PDF support
1544         PDFOptions const & pdf = params.pdfoptions();
1545         pdfSupportModule->use_hyperrefGB->setChecked(pdf.use_hyperref);
1546         pdfSupportModule->titleLE->setText(toqstr(pdf.title));
1547         pdfSupportModule->authorLE->setText(toqstr(pdf.author));
1548         pdfSupportModule->subjectLE->setText(toqstr(pdf.subject));
1549         pdfSupportModule->keywordsLE->setText(toqstr(pdf.keywords));
1550
1551         pdfSupportModule->bookmarksGB->setChecked(pdf.bookmarks);
1552         pdfSupportModule->bookmarksnumberedCB->setChecked(pdf.bookmarksnumbered);
1553         pdfSupportModule->bookmarksopenGB->setChecked(pdf.bookmarksopen);
1554
1555         pdfSupportModule->bookmarksopenlevelSB->setValue(pdf.bookmarksopenlevel);
1556
1557         pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks);
1558         pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder);
1559         pdfSupportModule->pdfusetitleCB->setChecked(pdf.pdfusetitle);
1560         pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks);
1561         pdfSupportModule->backrefCB->setChecked(pdf.backref);
1562         pdfSupportModule->pagebackrefCB->setChecked(pdf.pagebackref);
1563         pdfSupportModule->fullscreenCB->setChecked
1564                 (pdf.pagemode == pdf.pagemode_fullscreen);
1565
1566         pdfSupportModule->optionsLE->setText(
1567                 toqstr(pdf.quoted_options));
1568 }
1569
1570
1571 void GuiDocument::applyView()
1572 {
1573         apply(params());
1574 }
1575
1576
1577 void GuiDocument::saveDocDefault()
1578 {
1579         // we have to apply the params first
1580         applyView();
1581         saveAsDefault();
1582 }
1583
1584
1585 void GuiDocument::updateContents()
1586 {
1587         //update list of available modules
1588         QStringList strlist;
1589         vector<string> const modNames = getModuleNames();
1590         vector<string>::const_iterator it = modNames.begin();
1591         for (; it != modNames.end(); ++it)
1592                 strlist.push_back(toqstr(*it));
1593         available_model_.setStringList(strlist);
1594         //and selected ones, too
1595         QStringList strlist2;
1596         vector<string> const & selMods = getSelectedModules();
1597         it = selMods.begin();
1598         for (; it != selMods.end(); ++it)
1599                 strlist2.push_back(toqstr(*it));
1600         selected_model_.setStringList(strlist2);
1601
1602         updateParams(bp_);
1603 }
1604
1605 void GuiDocument::useClassDefaults()
1606 {
1607         bp_.setJustBaseClass(latexModule->classCO->currentIndex());
1608         bp_.useClassDefaults();
1609         updateContents();
1610 }
1611
1612
1613 bool GuiDocument::isValid()
1614 {
1615         return validate_listings_params().empty();
1616 }
1617
1618
1619 char const * const GuiDocument::fontfamilies[5] = {
1620         "default", "rmdefault", "sfdefault", "ttdefault", ""
1621 };
1622
1623
1624 char const * GuiDocument::fontfamilies_gui[5] = {
1625         N_("Default"), N_("Roman"), N_("Sans Serif"), N_("Typewriter"), ""
1626 };
1627
1628
1629 bool GuiDocument::initialiseParams(string const &)
1630 {
1631         bp_ = buffer().params();
1632         loadModuleNames();
1633         return true;
1634 }
1635
1636
1637 void GuiDocument::clearParams()
1638 {
1639         bp_ = BufferParams();
1640 }
1641
1642
1643 BufferId GuiDocument::id() const
1644 {
1645         return &buffer();
1646 }
1647
1648
1649 vector<string> GuiDocument::getModuleNames()
1650 {
1651         return moduleNames_;
1652 }
1653
1654
1655 vector<string> const & GuiDocument::getSelectedModules()
1656 {
1657         return params().getModules();
1658 }
1659
1660
1661 string GuiDocument::getModuleDescription(string const & modName) const
1662 {
1663         LyXModule const * const mod = moduleList[modName];
1664         if (!mod)
1665                 return string("Module unavailable!");
1666         return mod->description;
1667 }
1668
1669
1670 vector<string>
1671 GuiDocument::getPackageList(string const & modName) const
1672 {
1673         LyXModule const * const mod = moduleList[modName];
1674         if (!mod)
1675                 return vector<string>(); //empty such thing
1676         return mod->packageList;
1677 }
1678
1679
1680 TextClass const & GuiDocument::textClass() const
1681 {
1682         return textclasslist[bp_.getBaseClass()];
1683 }
1684
1685
1686 static void dispatch_bufferparams(Dialog const & dialog,
1687         BufferParams const & bp, kb_action lfun)
1688 {
1689         ostringstream ss;
1690         ss << "\\begin_header\n";
1691         bp.writeFile(ss);
1692         ss << "\\end_header\n";
1693         dialog.dispatch(FuncRequest(lfun, ss.str()));
1694 }
1695
1696
1697 void GuiDocument::dispatchParams()
1698 {
1699         // This must come first so that a language change is correctly noticed
1700         setLanguage();
1701
1702         // Apply the BufferParams. Note that this will set the base class
1703         // and then update the buffer's layout.
1704         //FIXME Could this be done last? Then, I think, we'd get the automatic
1705         //update mentioned in the next FIXME...
1706         dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY);
1707
1708         // Generate the colours requested by each new branch.
1709         BranchList & branchlist = params().branchlist();
1710         if (!branchlist.empty()) {
1711                 BranchList::const_iterator it = branchlist.begin();
1712                 BranchList::const_iterator const end = branchlist.end();
1713                 for (; it != end; ++it) {
1714                         docstring const & current_branch = it->getBranch();
1715                         Branch const * branch = branchlist.find(current_branch);
1716                         string const x11hexname = X11hexname(branch->getColor());
1717                         // display the new color
1718                         docstring const str = current_branch + ' ' + from_ascii(x11hexname);
1719                         dispatch(FuncRequest(LFUN_SET_COLOR, str));
1720                 }
1721
1722                 // Open insets of selected branches, close deselected ones
1723                 dispatch(FuncRequest(LFUN_ALL_INSETS_TOGGLE,
1724                         "assign branch"));
1725         }
1726         // FIXME: If we used an LFUN, we would not need those two lines:
1727         bufferview()->update();
1728         lyxview().currentWorkArea()->redraw();
1729 }
1730
1731
1732 void GuiDocument::setLanguage() const
1733 {
1734         Language const * const newL = bp_.language;
1735         if (buffer().params().language == newL)
1736                 return;
1737
1738         string const & lang_name = newL->lang();
1739         dispatch(FuncRequest(LFUN_BUFFER_LANGUAGE, lang_name));
1740 }
1741
1742
1743 void GuiDocument::saveAsDefault() const
1744 {
1745         dispatch_bufferparams(*this, params(), LFUN_BUFFER_SAVE_AS_DEFAULT);
1746 }
1747
1748
1749 bool GuiDocument::isFontAvailable(string const & font) const
1750 {
1751         if (font == "default" || font == "cmr"
1752             || font == "cmss" || font == "cmtt")
1753                 // these are standard
1754                 return true;
1755         if (font == "lmodern" || font == "lmss" || font == "lmtt")
1756                 return LaTeXFeatures::isAvailable("lmodern");
1757         if (font == "times" || font == "palatino"
1758                  || font == "helvet" || font == "courier")
1759                 return LaTeXFeatures::isAvailable("psnfss");
1760         if (font == "cmbr" || font == "cmtl")
1761                 return LaTeXFeatures::isAvailable("cmbright");
1762         if (font == "utopia")
1763                 return LaTeXFeatures::isAvailable("utopia")
1764                         || LaTeXFeatures::isAvailable("fourier");
1765         if (font == "beraserif" || font == "berasans"
1766                 || font == "beramono")
1767                 return LaTeXFeatures::isAvailable("bera");
1768         return LaTeXFeatures::isAvailable(font);
1769 }
1770
1771
1772 bool GuiDocument::providesOSF(string const & font) const
1773 {
1774         if (font == "cmr")
1775                 return isFontAvailable("eco");
1776         if (font == "palatino")
1777                 return isFontAvailable("mathpazo");
1778         return false;
1779 }
1780
1781
1782 bool GuiDocument::providesSC(string const & font) const
1783 {
1784         if (font == "palatino")
1785                 return isFontAvailable("mathpazo");
1786         if (font == "utopia")
1787                 return isFontAvailable("fourier");
1788         return false;
1789 }
1790
1791
1792 bool GuiDocument::providesScale(string const & font) const
1793 {
1794         return font == "helvet" || font == "luximono"
1795                 || font == "berasans"  || font == "beramono";
1796 }
1797
1798
1799 void GuiDocument::loadModuleNames ()
1800 {
1801         moduleNames_.clear();
1802         LyXModuleList::const_iterator it = moduleList.begin();
1803         for (; it != moduleList.end(); ++it)
1804                 moduleNames_.push_back(it->name);
1805         if (!moduleNames_.empty())
1806                 sort(moduleNames_.begin(), moduleNames_.end());
1807 }
1808
1809
1810 Dialog * createGuiDocument(LyXView & lv) { return new GuiDocument(lv); }
1811
1812
1813 } // namespace frontend
1814 } // namespace lyx
1815
1816 #include "GuiDocument_moc.cpp"