2 * \file GuiDocument.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Richard Heck (modules)
9 * Full author contact details are available in file CREDITS.
14 #include "GuiDocument.h"
16 #include "BranchList.h"
17 #include "buffer_funcs.h"
19 #include "BufferParams.h"
20 #include "BufferView.h"
22 #include "EmbeddedFiles.h"
24 #include "FloatPlacement.h"
25 #include "FuncRequest.h"
26 #include "support/gettext.h"
27 #include "GuiBranches.h"
29 #include "LaTeXFeatures.h"
30 #include "LaTeXHighlighter.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"
40 #include "TextClassList.h"
41 #include "Validator.h"
43 #include "insets/InsetListingsParams.h"
45 //#include "support/debug.h"
46 #include "support/FileName.h"
47 #include "support/filetools.h"
48 #include "support/lstrings.h"
50 #include <boost/bind.hpp>
52 #include <QCloseEvent>
54 #include <QTextCursor>
60 using namespace lyx::support;
64 vector<typename Pair::second_type> const
65 getSecond(vector<Pair> const & pr)
67 vector<typename Pair::second_type> tmp(pr.size());
68 transform(pr.begin(), pr.end(), tmp.begin(),
69 boost::bind(&Pair::second, _1));
73 char const * const tex_graphics[] =
75 "default", "dvips", "dvitops", "emtex",
76 "ln", "oztex", "textures", "none", ""
80 char const * const tex_graphics_gui[] =
82 N_("Default"), "Dvips", "DVItoPS", "EmTeX",
83 "LN", "OzTeX", "Textures", N_("None"), ""
87 char const * const tex_fonts_roman[] =
89 "default", "cmr", "lmodern", "ae", "times", "palatino",
90 "charter", "newcent", "bookman", "utopia", "beraserif",
91 "ccfonts", "chancery", ""
95 char const * tex_fonts_roman_gui[] =
97 N_("Default"), N_("Computer Modern Roman"), N_("Latin Modern Roman"),
98 N_("AE (Almost European)"), N_("Times Roman"), N_("Palatino"),
99 N_("Bitstream Charter"), N_("New Century Schoolbook"), N_("Bookman"),
100 N_("Utopia"), N_("Bera Serif"), N_("Concrete Roman"), N_("Zapf Chancery"),
105 char const * const tex_fonts_sans[] =
107 "default", "cmss", "lmss", "helvet", "avant", "berasans", "cmbr", ""
111 char const * tex_fonts_sans_gui[] =
113 N_("Default"), N_("Computer Modern Sans"), N_("Latin Modern Sans"),
114 N_("Helvetica"), N_("Avant Garde"), N_("Bera Sans"), N_("CM Bright"), ""
118 char const * const tex_fonts_monospaced[] =
120 "default", "cmtt", "lmtt", "courier", "beramono", "luximono", "cmtl", ""
124 char const * tex_fonts_monospaced_gui[] =
126 N_("Default"), N_("Computer Modern Typewriter"),
127 N_("Latin Modern Typewriter"), N_("Courier"), N_("Bera Mono"),
128 N_("LuxiMono"), N_("CM Typewriter Light"), ""
132 vector<pair<string, lyx::docstring> > pagestyles;
139 vector<string> getRequiredList(string const & modName)
141 LyXModule const * const mod = moduleList[modName];
143 return vector<string>(); //empty such thing
144 return mod->getRequiredModules();
148 vector<string> getExcludedList(string const & modName)
150 LyXModule const * const mod = moduleList[modName];
152 return vector<string>(); //empty such thing
153 return mod->getExcludedModules();
157 docstring getModuleDescription(string const & modName)
159 LyXModule const * const mod = moduleList[modName];
161 return _("Module not found!");
162 return from_ascii(mod->getDescription());
166 vector<string> getPackageList(string const & modName)
168 LyXModule const * const mod = moduleList[modName];
170 return vector<string>(); //empty such thing
171 return mod->getPackageList();
175 bool isModuleAvailable(string const & modName)
177 LyXModule * mod = moduleList[modName];
180 return mod->isAvailable();
182 } //anonymous namespace
185 ModuleSelMan::ModuleSelMan(
186 QListView * availableLV,
187 QListView * selectedLV,
191 QPushButton * downPB,
192 GuiIdListModel * availableModel,
193 GuiIdListModel * selectedModel) :
194 GuiSelectionManager(availableLV, selectedLV, addPB, delPB,
195 upPB, downPB, availableModel, selectedModel)
200 QModelIndex getSelectedIndex(QListView * lv)
202 QModelIndex retval = QModelIndex();
203 QModelIndexList selIdx =
204 lv->selectionModel()->selectedIndexes();
206 retval = selIdx.first();
212 void ModuleSelMan::updateAddPB()
214 int const arows = availableModel->rowCount();
215 QModelIndexList const availSels =
216 availableLV->selectionModel()->selectedIndexes();
217 if (arows == 0 || availSels.isEmpty() || isSelected(availSels.first())) {
218 addPB->setEnabled(false);
222 QModelIndex const & idx = availableLV->selectionModel()->currentIndex();
223 string const modName = getAvailableModel()->getIDString(idx.row());
224 vector<string> reqs = getRequiredList(modName);
225 vector<string> excl = getExcludedList(modName);
227 if (reqs.empty() && excl.empty()) {
228 addPB->setEnabled(true);
232 int const srows = selectedModel->rowCount();
233 vector<string> selModList;
234 for (int i = 0; i < srows; ++i)
235 selModList.push_back(getSelectedModel()->getIDString(i));
237 vector<string>::const_iterator selModStart = selModList.begin();
238 vector<string>::const_iterator selModEnd = selModList.end();
240 //Check whether some required module is available
242 bool foundOne = false;
243 vector<string>::const_iterator it = reqs.begin();
244 vector<string>::const_iterator end = reqs.end();
245 for (; it != end; ++it) {
246 if (find(selModStart, selModEnd, *it) != selModEnd) {
252 addPB->setEnabled(false);
257 //Check whether any excluded module is being used
259 vector<string>::const_iterator it = excl.begin();
260 vector<string>::const_iterator end = excl.end();
261 for (; it != end; ++it) {
262 if (find(selModStart, selModEnd, *it) != selModEnd) {
263 addPB->setEnabled(false);
269 addPB->setEnabled(true);
273 void ModuleSelMan::updateDownPB()
275 int const srows = selectedModel->rowCount();
277 downPB->setEnabled(false);
280 QModelIndexList const selSels =
281 selectedLV->selectionModel()->selectedIndexes();
282 //disable if empty or last item is selected
283 if (selSels.empty() || selSels.first().row() == srows - 1) {
284 downPB->setEnabled(false);
287 //determine whether immediately succeding element requires this one
288 QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
289 int curRow = curIdx.row();
290 if (curRow < 0 || curRow >= srows - 1) { //this shouldn't happen...
291 downPB->setEnabled(false);
294 string const curModName = getSelectedModel()->getIDString(curRow);
295 string const nextModName = getSelectedModel()->getIDString(curRow + 1);
297 vector<string> reqs = getRequiredList(nextModName);
299 //if it doesn't require anything....
301 downPB->setEnabled(true);
305 //FIXME This should perhaps be more flexible and check whether, even
306 //if this one is required, there is also an earlier one that is required.
307 //enable it if this module isn't required
309 find(reqs.begin(), reqs.end(), curModName) == reqs.end());
312 void ModuleSelMan::updateUpPB()
314 int const srows = selectedModel->rowCount();
316 upPB->setEnabled(false);
319 QModelIndexList const selSels =
320 selectedLV->selectionModel()->selectedIndexes();
321 //disable if empty or first item is selected
322 if (selSels.empty() || selSels.first().row() == 0) {
323 upPB->setEnabled(false);
327 //determine whether immediately preceding element is required by this one
328 QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
329 int curRow = curIdx.row();
330 if (curRow <= -1 || curRow > srows - 1) { //sanity check
331 downPB->setEnabled(false);
334 string const curModName = getSelectedModel()->getIDString(curRow);
335 vector<string> reqs = getRequiredList(curModName);
337 //if this one doesn't require anything....
339 upPB->setEnabled(true);
343 string preModName = getSelectedModel()->getIDString(curRow - 1);
345 //NOTE This is less flexible than it might be. You could check whether, even
346 //if this one is required, there is also an earlier one that is required.
347 //enable it if the preceding module isn't required
348 upPB->setEnabled(find(reqs.begin(), reqs.end(), preModName) == reqs.end());
351 void ModuleSelMan::updateDelPB()
353 int const srows = selectedModel->rowCount();
355 deletePB->setEnabled(false);
358 QModelIndexList const selSels =
359 selectedLV->selectionModel()->selectedIndexes();
360 if (selSels.empty() || selSels.first().row() < 0) {
361 deletePB->setEnabled(false);
365 //determine whether some LATER module requires this one
366 //NOTE Things are arranged so that this is the only way there
367 //can be a problem. At least, we hope so.
368 QModelIndex const & curIdx =
369 selectedLV->selectionModel()->currentIndex();
370 int const curRow = curIdx.row();
371 if (curRow < 0 || curRow >= srows) { //this shouldn't happen
372 deletePB->setEnabled(false);
376 QString const curModName = curIdx.data().toString();
378 //We're looking here for a reason NOT to enable the button. If we
379 //find one, we disable it and return. If we don't, we'll end up at
380 //the end of the function, and then we enable it.
381 for (int i = curRow + 1; i < srows; ++i) {
382 string const thisMod = getSelectedModel()->getIDString(i);
383 vector<string> reqs = getRequiredList(thisMod);
384 //does this one require us?
385 if (find(reqs.begin(), reqs.end(), fromqstr(curModName)) == reqs.end())
389 //OK, so this module requires us
390 //is there an EARLIER module that also satisfies the require?
391 //NOTE We demand that it be earlier to keep the list of modules
392 //consistent with the rule that a module must be proceeded by a
393 //required module. There would be more flexible ways to proceed,
394 //but that would be a lot more complicated, and the logic here is
395 //already complicated. (That's why I've left the debugging code.)
396 //lyxerr << "Testing " << thisMod << std::endl;
397 bool foundOne = false;
398 for (int j = 0; j < curRow; ++j) {
399 string const mod = getSelectedModel()->getIDString(j);
400 //lyxerr << "In loop: Testing " << mod << std::endl;
401 //do we satisfy the require?
402 if (find(reqs.begin(), reqs.end(), mod) != reqs.end()) {
403 //lyxerr << mod << " does the trick." << std::endl;
408 //did we find a module to satisfy the require?
410 //lyxerr << "No matching module found." << std::endl;
411 deletePB->setEnabled(false);
415 //lyxerr << "All's well that ends well." << std::endl;
416 deletePB->setEnabled(true);
420 /////////////////////////////////////////////////////////////////////
424 /////////////////////////////////////////////////////////////////////
426 PreambleModule::PreambleModule(): current_id_(0)
428 // This is not a memory leak. The object will be destroyed
430 (void) new LaTeXHighlighter(preambleTE->document());
431 setFocusProxy(preambleTE);
432 connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
436 void PreambleModule::update(BufferParams const & params, BufferId id)
438 QString preamble = toqstr(params.preamble);
439 // Nothing to do if the params and preamble are unchanged.
440 if (id == current_id_
441 && preamble == preambleTE->document()->toPlainText())
444 QTextCursor cur = preambleTE->textCursor();
445 // Save the coords before switching to the new one.
446 preamble_coords_[current_id_] =
447 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
449 // Save the params address for further use.
451 preambleTE->document()->setPlainText(preamble);
452 Coords::const_iterator it = preamble_coords_.find(current_id_);
453 if (it == preamble_coords_.end())
454 // First time we open this one.
455 preamble_coords_[current_id_] = make_pair(0,0);
457 // Restore saved coords.
458 QTextCursor cur = preambleTE->textCursor();
459 cur.setPosition(it->second.first);
460 preambleTE->setTextCursor(cur);
461 preambleTE->verticalScrollBar()->setValue(it->second.second);
466 void PreambleModule::apply(BufferParams & params)
468 params.preamble = fromqstr(preambleTE->document()->toPlainText());
472 void PreambleModule::closeEvent(QCloseEvent * e)
474 // Save the coords before closing.
475 QTextCursor cur = preambleTE->textCursor();
476 preamble_coords_[current_id_] =
477 make_pair(cur.position(), preambleTE->verticalScrollBar()->value());
482 /////////////////////////////////////////////////////////////////////
486 /////////////////////////////////////////////////////////////////////
490 GuiDocument::GuiDocument(GuiView & lv)
491 : GuiDialog(lv, "document")
494 setViewTitle(_("Document Settings"));
496 lang_ = getSecond(getLanguageData(false));
498 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
499 connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
500 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
501 connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
503 connect(savePB, SIGNAL(clicked()), this, SLOT(saveDefaultClicked()));
504 connect(defaultPB, SIGNAL(clicked()), this, SLOT(useDefaultsClicked()));
506 // Manage the restore, ok, apply, restore and cancel/close buttons
507 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
509 bc().setApply(applyPB);
510 bc().setCancel(closePB);
511 bc().setRestore(restorePB);
513 textLayoutModule = new UiWidget<Ui::TextLayoutUi>;
515 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
516 this, SLOT(change_adaptor()));
517 connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
518 this, SLOT(setLSpacing(int)));
519 connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)),
520 this, SLOT(change_adaptor()));
521 connect(textLayoutModule->skipRB, SIGNAL(clicked()),
522 this, SLOT(change_adaptor()));
523 connect(textLayoutModule->indentRB, SIGNAL(clicked()),
524 this, SLOT(change_adaptor()));
525 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
526 this, SLOT(change_adaptor()));
527 connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString &)),
528 this, SLOT(change_adaptor()));
529 connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)),
530 this, SLOT(change_adaptor()));
531 connect(textLayoutModule->skipCO, SIGNAL(activated(int)),
532 this, SLOT(setSkip(int)));
533 connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)),
534 this, SLOT(enableSkip(bool)));
535 connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()),
536 this, SLOT(change_adaptor()));
537 connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
538 this, SLOT(change_adaptor()));
539 connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
540 this, SLOT(change_adaptor()));
541 connect(textLayoutModule->bypassCB, SIGNAL(clicked()),
542 this, SLOT(set_listings_msg()));
543 connect(textLayoutModule->listingsED, SIGNAL(textChanged()),
544 this, SLOT(set_listings_msg()));
545 textLayoutModule->listingsTB->setPlainText(
546 qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
547 textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
548 textLayoutModule->lspacingLE));
549 textLayoutModule->skipLE->setValidator(unsignedLengthValidator(
550 textLayoutModule->skipLE));
552 textLayoutModule->skipCO->addItem(qt_("SmallSkip"));
553 textLayoutModule->skipCO->addItem(qt_("MedSkip"));
554 textLayoutModule->skipCO->addItem(qt_("BigSkip"));
555 textLayoutModule->skipCO->addItem(qt_("Length"));
556 // remove the %-items from the unit choice
557 textLayoutModule->skipLengthCO->noPercents();
558 textLayoutModule->lspacingCO->insertItem(
559 Spacing::Single, qt_("Single"));
560 textLayoutModule->lspacingCO->insertItem(
561 Spacing::Onehalf, qt_("OneHalf"));
562 textLayoutModule->lspacingCO->insertItem(
563 Spacing::Double, qt_("Double"));
564 textLayoutModule->lspacingCO->insertItem(
565 Spacing::Other, qt_("Custom"));
567 // initialize the length validator
568 bc().addCheckedLineEdit(textLayoutModule->skipLE);
570 fontModule = new UiWidget<Ui::FontUi>;
572 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
573 this, SLOT(change_adaptor()));
574 connect(fontModule->fontsRomanCO, SIGNAL(activated(int)),
575 this, SLOT(romanChanged(int)));
576 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
577 this, SLOT(change_adaptor()));
578 connect(fontModule->fontsSansCO, SIGNAL(activated(int)),
579 this, SLOT(sansChanged(int)));
580 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
581 this, SLOT(change_adaptor()));
582 connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
583 this, SLOT(ttChanged(int)));
584 connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)),
585 this, SLOT(change_adaptor()));
586 connect(fontModule->fontsizeCO, SIGNAL(activated(int)),
587 this, SLOT(change_adaptor()));
588 connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
589 this, SLOT(change_adaptor()));
590 connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
591 this, SLOT(change_adaptor()));
592 connect(fontModule->fontScCB, SIGNAL(clicked()),
593 this, SLOT(change_adaptor()));
594 connect(fontModule->fontOsfCB, SIGNAL(clicked()),
595 this, SLOT(change_adaptor()));
597 for (int n = 0; tex_fonts_roman[n][0]; ++n) {
598 QString font = qt_(tex_fonts_roman_gui[n]);
599 if (!isFontAvailable(tex_fonts_roman[n]))
600 font += qt_(" (not installed)");
601 fontModule->fontsRomanCO->addItem(font);
603 for (int n = 0; tex_fonts_sans[n][0]; ++n) {
604 QString font = qt_(tex_fonts_sans_gui[n]);
605 if (!isFontAvailable(tex_fonts_sans[n]))
606 font += qt_(" (not installed)");
607 fontModule->fontsSansCO->addItem(font);
609 for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
610 QString font = qt_(tex_fonts_monospaced_gui[n]);
611 if (!isFontAvailable(tex_fonts_monospaced[n]))
612 font += qt_(" (not installed)");
613 fontModule->fontsTypewriterCO->addItem(font);
616 fontModule->fontsizeCO->addItem(qt_("Default"));
617 fontModule->fontsizeCO->addItem(qt_("10"));
618 fontModule->fontsizeCO->addItem(qt_("11"));
619 fontModule->fontsizeCO->addItem(qt_("12"));
621 for (int n = 0; GuiDocument::fontfamilies_gui[n][0]; ++n)
622 fontModule->fontsDefaultCO->addItem(
623 qt_(GuiDocument::fontfamilies_gui[n]));
626 pageLayoutModule = new UiWidget<Ui::PageLayoutUi>;
628 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
629 this, SLOT(setCustomPapersize(int)));
630 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
631 this, SLOT(setCustomPapersize(int)));
632 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
633 this, SLOT(portraitChanged()));
634 connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
635 this, SLOT(change_adaptor()));
636 connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString &)),
637 this, SLOT(change_adaptor()));
638 connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString &)),
639 this, SLOT(change_adaptor()));
640 connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)),
641 this, SLOT(change_adaptor()));
642 connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)),
643 this, SLOT(change_adaptor()));
644 connect(pageLayoutModule->portraitRB, SIGNAL(clicked()),
645 this, SLOT(change_adaptor()));
646 connect(pageLayoutModule->landscapeRB, SIGNAL(clicked()),
647 this, SLOT(change_adaptor()));
648 connect(pageLayoutModule->facingPagesCB, SIGNAL(clicked()),
649 this, SLOT(change_adaptor()));
650 connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)),
651 this, SLOT(change_adaptor()));
653 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
654 pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
655 pageLayoutModule->pagestyleCO->addItem(qt_("plain"));
656 pageLayoutModule->pagestyleCO->addItem(qt_("headings"));
657 pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
658 bc().addCheckedLineEdit(pageLayoutModule->paperheightLE,
659 pageLayoutModule->paperheightL);
660 bc().addCheckedLineEdit(pageLayoutModule->paperwidthLE,
661 pageLayoutModule->paperwidthL);
664 QComboBox * cb = pageLayoutModule->papersizeCO;
665 cb->addItem(qt_("Default"));
666 cb->addItem(qt_("Custom"));
667 cb->addItem(qt_("US letter"));
668 cb->addItem(qt_("US legal"));
669 cb->addItem(qt_("US executive"));
670 cb->addItem(qt_("A3"));
671 cb->addItem(qt_("A4"));
672 cb->addItem(qt_("A5"));
673 cb->addItem(qt_("B3"));
674 cb->addItem(qt_("B4"));
675 cb->addItem(qt_("B5"));
676 // remove the %-items from the unit choice
677 pageLayoutModule->paperwidthUnitCO->noPercents();
678 pageLayoutModule->paperheightUnitCO->noPercents();
679 pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator(
680 pageLayoutModule->paperheightLE));
681 pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator(
682 pageLayoutModule->paperwidthLE));
685 marginsModule = new UiWidget<Ui::MarginsUi>;
687 connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
688 this, SLOT(setCustomMargins(bool)));
689 connect(marginsModule->marginCB, SIGNAL(clicked()),
690 this, SLOT(change_adaptor()));
691 connect(marginsModule->topLE, SIGNAL(textChanged(const QString &)),
692 this, SLOT(change_adaptor()));
693 connect(marginsModule->topUnit, SIGNAL(activated(int)),
694 this, SLOT(change_adaptor()));
695 connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString &)),
696 this, SLOT(change_adaptor()));
697 connect(marginsModule->bottomUnit, SIGNAL(activated(int)),
698 this, SLOT(change_adaptor()));
699 connect(marginsModule->innerLE, SIGNAL(textChanged(const QString &)),
700 this, SLOT(change_adaptor()));
701 connect(marginsModule->innerUnit, SIGNAL(activated(int)),
702 this, SLOT(change_adaptor()));
703 connect(marginsModule->outerLE, SIGNAL(textChanged(const QString &)),
704 this, SLOT(change_adaptor()));
705 connect(marginsModule->outerUnit, SIGNAL(activated(int)),
706 this, SLOT(change_adaptor()));
707 connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString &)),
708 this, SLOT(change_adaptor()));
709 connect(marginsModule->headheightUnit, SIGNAL(activated(int)),
710 this, SLOT(change_adaptor()));
711 connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString &)),
712 this, SLOT(change_adaptor()));
713 connect(marginsModule->headsepUnit, SIGNAL(activated(int)),
714 this, SLOT(change_adaptor()));
715 connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)),
716 this, SLOT(change_adaptor()));
717 connect(marginsModule->footskipUnit, SIGNAL(activated(int)),
718 this, SLOT(change_adaptor()));
719 marginsModule->topLE->setValidator(unsignedLengthValidator(
720 marginsModule->topLE));
721 marginsModule->bottomLE->setValidator(unsignedLengthValidator(
722 marginsModule->bottomLE));
723 marginsModule->innerLE->setValidator(unsignedLengthValidator(
724 marginsModule->innerLE));
725 marginsModule->outerLE->setValidator(unsignedLengthValidator(
726 marginsModule->outerLE));
727 marginsModule->headsepLE->setValidator(unsignedLengthValidator(
728 marginsModule->headsepLE));
729 marginsModule->headheightLE->setValidator(unsignedLengthValidator(
730 marginsModule->headheightLE));
731 marginsModule->footskipLE->setValidator(unsignedLengthValidator(
732 marginsModule->footskipLE));
734 bc().addCheckedLineEdit(marginsModule->topLE,
735 marginsModule->topL);
736 bc().addCheckedLineEdit(marginsModule->bottomLE,
737 marginsModule->bottomL);
738 bc().addCheckedLineEdit(marginsModule->innerLE,
739 marginsModule->innerL);
740 bc().addCheckedLineEdit(marginsModule->outerLE,
741 marginsModule->outerL);
742 bc().addCheckedLineEdit(marginsModule->headsepLE,
743 marginsModule->headsepL);
744 bc().addCheckedLineEdit(marginsModule->headheightLE,
745 marginsModule->headheightL);
746 bc().addCheckedLineEdit(marginsModule->footskipLE,
747 marginsModule->footskipL);
750 langModule = new UiWidget<Ui::LanguageUi>;
752 connect(langModule->languageCO, SIGNAL(activated(int)),
753 this, SLOT(change_adaptor()));
754 connect(langModule->defaultencodingRB, SIGNAL(clicked()),
755 this, SLOT(change_adaptor()));
756 connect(langModule->otherencodingRB, SIGNAL(clicked()),
757 this, SLOT(change_adaptor()));
758 connect(langModule->encodingCO, SIGNAL(activated(int)),
759 this, SLOT(change_adaptor()));
760 connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
761 this, SLOT(change_adaptor()));
763 vector<LanguagePair> const langs = getLanguageData(false);
764 vector<LanguagePair>::const_iterator lit = langs.begin();
765 vector<LanguagePair>::const_iterator lend = langs.end();
766 for (; lit != lend; ++lit) {
767 langModule->languageCO->addItem(toqstr(lit->first));
770 // Always put the default encoding in the first position.
771 // It is special because the displayed text is translated.
772 langModule->encodingCO->addItem(qt_("LaTeX default"));
773 Encodings::const_iterator it = encodings.begin();
774 Encodings::const_iterator const end = encodings.end();
775 for (; it != end; ++it)
776 langModule->encodingCO->addItem(toqstr(it->latexName()));
778 langModule->quoteStyleCO->addItem(qt_("``text''"));
779 langModule->quoteStyleCO->addItem(qt_("''text''"));
780 langModule->quoteStyleCO->addItem(qt_(",,text``"));
781 langModule->quoteStyleCO->addItem(qt_(",,text''"));
782 langModule->quoteStyleCO->addItem(qt_("<<text>>"));
783 langModule->quoteStyleCO->addItem(qt_(">>text<<"));
787 numberingModule = new UiWidget<Ui::NumberingUi>;
789 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
790 this, SLOT(change_adaptor()));
791 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
792 this, SLOT(change_adaptor()));
793 connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
794 this, SLOT(updateNumbering()));
795 connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
796 this, SLOT(updateNumbering()));
797 numberingModule->tocTW->setColumnCount(3);
798 numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
799 numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
800 numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
803 biblioModule = new UiWidget<Ui::BiblioUi>;
804 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
805 biblioModule->citationStyleL, SLOT(setEnabled(bool)));
806 connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
807 biblioModule->citeStyleCO, SLOT(setEnabled(bool)));
809 connect(biblioModule->citeDefaultRB, SIGNAL(clicked()),
810 this, SLOT(change_adaptor()));
811 connect(biblioModule->citeNatbibRB, SIGNAL(clicked()),
812 this, SLOT(change_adaptor()));
813 connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
814 this, SLOT(change_adaptor()));
815 connect(biblioModule->citeJurabibRB, SIGNAL(clicked()),
816 this, SLOT(change_adaptor()));
817 connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
818 this, SLOT(change_adaptor()));
820 biblioModule->citeStyleCO->addItem(qt_("Author-year"));
821 biblioModule->citeStyleCO->addItem(qt_("Numerical"));
822 biblioModule->citeStyleCO->setCurrentIndex(0);
825 mathsModule = new UiWidget<Ui::MathsUi>;
826 connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)),
827 mathsModule->amsCB, SLOT(setDisabled(bool)));
828 connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)),
829 mathsModule->esintCB, SLOT(setDisabled(bool)));
831 connect(mathsModule->amsCB, SIGNAL(clicked()),
832 this, SLOT(change_adaptor()));
833 connect(mathsModule->amsautoCB, SIGNAL(clicked()),
834 this, SLOT(change_adaptor()));
835 connect(mathsModule->esintCB, SIGNAL(clicked()),
836 this, SLOT(change_adaptor()));
837 connect(mathsModule->esintautoCB, SIGNAL(clicked()),
838 this, SLOT(change_adaptor()));
840 latexModule = new UiWidget<Ui::LaTeXUi>;
842 connect(latexModule->classCO, SIGNAL(activated(int)),
843 this, SLOT(change_adaptor()));
844 connect(latexModule->optionsLE, SIGNAL(textChanged(const QString &)),
845 this, SLOT(change_adaptor()));
846 connect(latexModule->psdriverCO, SIGNAL(activated(int)),
847 this, SLOT(change_adaptor()));
848 connect(latexModule->classCO, SIGNAL(activated(int)),
849 this, SLOT(classChanged()));
852 new ModuleSelMan(latexModule->availableLV, latexModule->selectedLV,
853 latexModule->addPB, latexModule->deletePB,
854 latexModule->upPB, latexModule->downPB,
855 availableModel(), selectedModel());
856 connect(selectionManager, SIGNAL(updateHook()),
857 this, SLOT(updateModuleInfo()));
858 connect(selectionManager, SIGNAL(updateHook()),
859 this, SLOT(change_adaptor()));
861 // postscript drivers
862 for (int n = 0; tex_graphics[n][0]; ++n) {
863 QString enc = qt_(tex_graphics_gui[n]);
864 latexModule->psdriverCO->addItem(enc);
867 //FIXME This seems too involved with the kernel. Some of this
868 //should be moved to the kernel---which should perhaps just
869 //give us a list of entries or something of the sort.
870 for (TextClassList::const_iterator cit = textclasslist.begin();
871 cit != textclasslist.end(); ++cit) {
872 if (cit->isTeXClassAvailable()) {
873 latexModule->classCO->addItem(toqstr(cit->description()));
876 bformat(_("Unavailable: %1$s"), from_utf8(cit->description()));
877 latexModule->classCO->addItem(toqstr(item));
882 branchesModule = new GuiBranches;
883 connect(branchesModule, SIGNAL(changed()),
884 this, SLOT(change_adaptor()));
887 preambleModule = new PreambleModule;
888 connect(preambleModule, SIGNAL(changed()),
889 this, SLOT(change_adaptor()));
892 bulletsModule = new BulletsModule;
893 connect(bulletsModule, SIGNAL(changed()),
894 this, SLOT(change_adaptor()));
897 embeddedFilesModule = new UiWidget<Ui::EmbeddedFilesUi>;
898 connect(embeddedFilesModule->bundleCB, SIGNAL(toggled(bool)),
899 this, SLOT(change_adaptor()));
900 connect(embeddedFilesModule->addPB, SIGNAL(clicked()),
901 this, SLOT(change_adaptor()));
902 connect(embeddedFilesModule->removePB, SIGNAL(clicked()),
903 this, SLOT(change_adaptor()));
906 pdfSupportModule = new UiWidget<Ui::PDFSupportUi>;
908 connect(pdfSupportModule->use_hyperrefGB, SIGNAL(toggled(bool)),
909 this, SLOT(change_adaptor()));
910 connect(pdfSupportModule->titleLE, SIGNAL(textChanged(const QString &)),
911 this, SLOT(change_adaptor()));
912 connect(pdfSupportModule->authorLE, SIGNAL(textChanged(const QString &)),
913 this, SLOT(change_adaptor()));
914 connect(pdfSupportModule->subjectLE, SIGNAL(textChanged(const QString &)),
915 this, SLOT(change_adaptor()));
916 connect(pdfSupportModule->keywordsLE, SIGNAL(textChanged(const QString &)),
917 this, SLOT(change_adaptor()));
918 connect(pdfSupportModule->bookmarksGB, SIGNAL(toggled(bool)),
919 this, SLOT(change_adaptor()));
920 connect(pdfSupportModule->bookmarksnumberedCB, SIGNAL(toggled(bool)),
921 this, SLOT(change_adaptor()));
922 connect(pdfSupportModule->bookmarksopenGB, SIGNAL(toggled(bool)),
923 this, SLOT(change_adaptor()));
924 connect(pdfSupportModule->bookmarksopenlevelSB, SIGNAL(valueChanged(int)),
925 this, SLOT(change_adaptor()));
926 connect(pdfSupportModule->breaklinksCB, SIGNAL(toggled(bool)),
927 this, SLOT(change_adaptor()));
928 connect(pdfSupportModule->pdfborderCB, SIGNAL(toggled(bool)),
929 this, SLOT(change_adaptor()));
930 connect(pdfSupportModule->colorlinksCB, SIGNAL(toggled(bool)),
931 this, SLOT(change_adaptor()));
932 connect(pdfSupportModule->backrefCB, SIGNAL(toggled(bool)),
933 this, SLOT(change_adaptor()));
934 connect(pdfSupportModule->pdfusetitleCB, SIGNAL(toggled(bool)),
935 this, SLOT(change_adaptor()));
936 connect(pdfSupportModule->pagebackrefCB, SIGNAL(toggled(bool)),
937 this, SLOT(change_adaptor()));
938 connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
939 this, SLOT(change_adaptor()));
940 connect(pdfSupportModule->optionsLE, SIGNAL(textChanged(const QString &)),
941 this, SLOT(change_adaptor()));
944 floatModule = new FloatPlacement;
945 connect(floatModule, SIGNAL(changed()),
946 this, SLOT(change_adaptor()));
948 docPS->addPanel(latexModule, _("Document Class"));
949 docPS->addPanel(fontModule, _("Fonts"));
950 docPS->addPanel(textLayoutModule, _("Text Layout"));
951 docPS->addPanel(pageLayoutModule, _("Page Layout"));
952 docPS->addPanel(marginsModule, _("Page Margins"));
953 docPS->addPanel(langModule, _("Language"));
954 docPS->addPanel(numberingModule, _("Numbering & TOC"));
955 docPS->addPanel(biblioModule, _("Bibliography"));
956 docPS->addPanel(pdfSupportModule, _("PDF Properties"));
957 docPS->addPanel(mathsModule, _("Math Options"));
958 docPS->addPanel(floatModule, _("Float Placement"));
959 docPS->addPanel(bulletsModule, _("Bullets"));
960 docPS->addPanel(branchesModule, _("Branches"));
961 docPS->addPanel(embeddedFilesModule, _("Embedded Files"));
962 docPS->addPanel(preambleModule, _("LaTeX Preamble"));
963 docPS->setCurrentPanel(_("Document Class"));
964 // FIXME: hack to work around resizing bug in Qt >= 4.2
965 // bug verified with Qt 4.2.{0-3} (JSpitzm)
966 #if QT_VERSION >= 0x040200
967 docPS->updateGeometry();
972 void GuiDocument::showPreamble()
974 docPS->setCurrentPanel(_("LaTeX Preamble"));
978 void GuiDocument::saveDefaultClicked()
984 void GuiDocument::useDefaultsClicked()
990 void GuiDocument::change_adaptor()
996 docstring GuiDocument::validate_listings_params()
998 // use a cache here to avoid repeated validation
999 // of the same parameters
1000 static string param_cache = string();
1001 static docstring msg_cache = docstring();
1003 if (textLayoutModule->bypassCB->isChecked())
1006 string params = fromqstr(textLayoutModule->listingsED->toPlainText());
1007 if (params != param_cache) {
1008 param_cache = params;
1009 msg_cache = InsetListingsParams(params).validate();
1015 void GuiDocument::set_listings_msg()
1017 static bool isOK = true;
1018 docstring msg = validate_listings_params();
1023 // listingsTB->setTextColor("black");
1024 textLayoutModule->listingsTB->setPlainText(
1025 qt_("Input listings parameters on the right. Enter ? for a list of parameters."));
1028 // listingsTB->setTextColor("red");
1029 textLayoutModule->listingsTB->setPlainText(toqstr(msg));
1034 void GuiDocument::closeEvent(QCloseEvent * e)
1041 void GuiDocument::setLSpacing(int item)
1043 textLayoutModule->lspacingLE->setEnabled(item == 3);
1047 void GuiDocument::setSkip(int item)
1049 bool const enable = (item == 3);
1050 textLayoutModule->skipLE->setEnabled(enable);
1051 textLayoutModule->skipLengthCO->setEnabled(enable);
1055 void GuiDocument::enableSkip(bool skip)
1057 textLayoutModule->skipCO->setEnabled(skip);
1058 textLayoutModule->skipLE->setEnabled(skip);
1059 textLayoutModule->skipLengthCO->setEnabled(skip);
1061 setSkip(textLayoutModule->skipCO->currentIndex());
1064 void GuiDocument::portraitChanged()
1066 setMargins(pageLayoutModule->papersizeCO->currentIndex());
1069 void GuiDocument::setMargins(bool custom)
1071 marginsModule->marginCB->setChecked(custom);
1072 setCustomMargins(custom);
1076 void GuiDocument::setCustomPapersize(int papersize)
1078 bool const custom = (papersize == 1);
1080 pageLayoutModule->paperwidthL->setEnabled(custom);
1081 pageLayoutModule->paperwidthLE->setEnabled(custom);
1082 pageLayoutModule->paperwidthUnitCO->setEnabled(custom);
1083 pageLayoutModule->paperheightL->setEnabled(custom);
1084 pageLayoutModule->paperheightLE->setEnabled(custom);
1085 pageLayoutModule->paperheightLE->setFocus();
1086 pageLayoutModule->paperheightUnitCO->setEnabled(custom);
1090 void GuiDocument::setCustomMargins(bool custom)
1092 marginsModule->topL->setEnabled(!custom);
1093 marginsModule->topLE->setEnabled(!custom);
1094 marginsModule->topUnit->setEnabled(!custom);
1096 marginsModule->bottomL->setEnabled(!custom);
1097 marginsModule->bottomLE->setEnabled(!custom);
1098 marginsModule->bottomUnit->setEnabled(!custom);
1100 marginsModule->innerL->setEnabled(!custom);
1101 marginsModule->innerLE->setEnabled(!custom);
1102 marginsModule->innerUnit->setEnabled(!custom);
1104 marginsModule->outerL->setEnabled(!custom);
1105 marginsModule->outerLE->setEnabled(!custom);
1106 marginsModule->outerUnit->setEnabled(!custom);
1108 marginsModule->headheightL->setEnabled(!custom);
1109 marginsModule->headheightLE->setEnabled(!custom);
1110 marginsModule->headheightUnit->setEnabled(!custom);
1112 marginsModule->headsepL->setEnabled(!custom);
1113 marginsModule->headsepLE->setEnabled(!custom);
1114 marginsModule->headsepUnit->setEnabled(!custom);
1116 marginsModule->footskipL->setEnabled(!custom);
1117 marginsModule->footskipLE->setEnabled(!custom);
1118 marginsModule->footskipUnit->setEnabled(!custom);
1122 void GuiDocument::updateFontsize(string const & items, string const & sel)
1124 fontModule->fontsizeCO->clear();
1125 fontModule->fontsizeCO->addItem(qt_("Default"));
1127 for (int n = 0; !token(items,'|',n).empty(); ++n)
1128 fontModule->fontsizeCO->
1129 addItem(toqstr(token(items,'|',n)));
1131 for (int n = 0; n < fontModule->fontsizeCO->count(); ++n) {
1132 if (fromqstr(fontModule->fontsizeCO->itemText(n)) == sel) {
1133 fontModule->fontsizeCO->setCurrentIndex(n);
1140 void GuiDocument::romanChanged(int item)
1142 string const font = tex_fonts_roman[item];
1143 fontModule->fontScCB->setEnabled(providesSC(font));
1144 fontModule->fontOsfCB->setEnabled(providesOSF(font));
1148 void GuiDocument::sansChanged(int item)
1150 string const font = tex_fonts_sans[item];
1151 bool scaleable = providesScale(font);
1152 fontModule->scaleSansSB->setEnabled(scaleable);
1153 fontModule->scaleSansLA->setEnabled(scaleable);
1157 void GuiDocument::ttChanged(int item)
1159 string const font = tex_fonts_monospaced[item];
1160 bool scaleable = providesScale(font);
1161 fontModule->scaleTypewriterSB->setEnabled(scaleable);
1162 fontModule->scaleTypewriterLA->setEnabled(scaleable);
1166 void GuiDocument::updatePagestyle(string const & items, string const & sel)
1169 pageLayoutModule->pagestyleCO->clear();
1170 pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
1172 for (int n = 0; !token(items,'|',n).empty(); ++n) {
1173 string style = token(items, '|', n);
1174 docstring style_gui = _(style);
1175 pagestyles.push_back(pair<string, docstring>(style, style_gui));
1176 pageLayoutModule->pagestyleCO->addItem(toqstr(style_gui));
1179 if (sel == "default") {
1180 pageLayoutModule->pagestyleCO->setCurrentIndex(0);
1186 for (size_t i = 0; i < pagestyles.size(); ++i)
1187 if (pagestyles[i].first == sel)
1188 nn = pageLayoutModule->pagestyleCO->findText(
1189 toqstr(pagestyles[i].second));
1192 pageLayoutModule->pagestyleCO->setCurrentIndex(nn);
1196 void GuiDocument::classChanged()
1198 textclass_type const tc = latexModule->classCO->currentIndex();
1199 bp_.setBaseClass(tc);
1200 if (lyxrc.auto_reset_options) {
1201 bp_.useClassDefaults();
1208 //This is an insanely complicated attempt to make this sort of thing
1209 //work with RTL languages.
1210 docstring formatStrVec(vector<string> const & v, docstring const & s)
1212 //this mess formats the list as "v[0], v[1], ..., [s] v[n]"
1213 int const vSize = v.size();
1216 else if (v.size() == 1)
1217 return from_ascii(v[0]);
1218 else if (v.size() == 2) {
1219 docstring retval = _("%1$s and %2$s");
1220 retval = subst(retval, _("and"), s);
1221 return bformat(retval, from_ascii(v[0]), from_ascii(v[1]));
1223 //The idea here is to format all but the last two items...
1224 docstring t2 = _("%1$s, %2$s");
1225 docstring retval = from_ascii(v[0]);
1226 for (int i = 1; i < vSize - 2; ++i)
1227 retval = bformat(t2, retval, from_ascii(v[i]));
1228 //...and then to plug them, and the last two, into this schema
1229 docstring t = _("%1$s, %2$s, and %3$s");
1230 t = subst(t, _("and"), s);
1231 return bformat(t, retval, from_ascii(v[vSize - 2]), from_ascii(v[vSize - 1]));
1234 vector<string> idsToNames(vector<string> const & idList)
1236 vector<string> retval;
1237 vector<string>::const_iterator it = idList.begin();
1238 vector<string>::const_iterator end = idList.end();
1239 for (; it != end; ++it) {
1240 LyXModule const * const mod = moduleList[*it];
1242 retval.push_back(*it + " (Unavailable)");
1244 retval.push_back(mod->getName());
1251 void GuiDocument::updateModuleInfo()
1253 selectionManager->update();
1255 //Module description
1256 bool const focusOnSelected = selectionManager->selectedFocused();
1257 QListView const * const lv =
1258 focusOnSelected ? latexModule->selectedLV : latexModule->availableLV;
1259 if (lv->selectionModel()->selectedIndexes().isEmpty()) {
1260 latexModule->infoML->document()->clear();
1263 QModelIndex const & idx = lv->selectionModel()->currentIndex();
1264 GuiIdListModel const & idModel =
1265 focusOnSelected ? selected_model_ : available_model_;
1266 string const modName = idModel.getIDString(idx.row());
1267 docstring desc = getModuleDescription(modName);
1269 vector<string> pkgList = getPackageList(modName);
1270 docstring pkgdesc = formatStrVec(pkgList, _("and"));
1271 if (!pkgdesc.empty()) {
1274 desc += bformat(_("Package(s) required: %1$s."), pkgdesc);
1277 pkgList = getRequiredList(modName);
1278 if (!pkgList.empty()) {
1279 vector<string> const reqDescs = idsToNames(pkgList);
1280 pkgdesc = formatStrVec(reqDescs, _("or"));
1283 desc += bformat(_("Module required: %1$s."), pkgdesc);
1286 pkgList = getExcludedList(modName);
1287 if (!pkgList.empty()) {
1288 vector<string> const reqDescs = idsToNames(pkgList);
1289 pkgdesc = formatStrVec(reqDescs, _( "and"));
1292 desc += bformat(_("Modules excluded: %1$s."), pkgdesc);
1295 if (!isModuleAvailable(modName)) {
1298 desc += _("WARNING: Some packages are unavailable!");
1301 latexModule->infoML->document()->setPlainText(toqstr(desc));
1305 void GuiDocument::updateEmbeddedFileList()
1307 embeddedFilesModule->filesLW->clear();
1308 // add current embedded files
1309 EmbeddedFileList & files = buffer().embeddedFiles();
1310 files.update(buffer());
1311 EmbeddedFileList::iterator fit = files.begin();
1312 EmbeddedFileList::iterator fit_end = files.end();
1313 for (; fit != fit_end; ++fit) {
1314 QString label = toqstr(fit->relFilename(buffer().filePath()));
1315 if (fit->refCount() > 1)
1316 label += " (" + QString::number(fit->refCount()) + ")";
1317 QListWidgetItem * item = new QListWidgetItem(label);
1318 item->setFlags(item->flags() | Qt::ItemIsSelectable
1319 | Qt::ItemIsUserCheckable);
1321 item->setCheckState(Qt::Checked);
1323 item->setCheckState(Qt::Unchecked);
1324 // index of the currently used ParConstIterator
1325 embeddedFilesModule->filesLW->addItem(item);
1330 void GuiDocument::updateNumbering()
1332 TextClass const & tclass = bp_.getTextClass();
1334 numberingModule->tocTW->setUpdatesEnabled(false);
1335 numberingModule->tocTW->clear();
1337 int const depth = numberingModule->depthSL->value();
1338 int const toc = numberingModule->tocSL->value();
1339 QString const no = qt_("No");
1340 QString const yes = qt_("Yes");
1341 TextClass::const_iterator end = tclass.end();
1342 TextClass::const_iterator cit = tclass.begin();
1343 QTreeWidgetItem * item = 0;
1344 for ( ; cit != end ; ++cit) {
1345 int const toclevel = (*cit)->toclevel;
1346 if (toclevel != Layout::NOT_IN_TOC
1347 && (*cit)->labeltype == LABEL_COUNTER) {
1348 item = new QTreeWidgetItem(numberingModule->tocTW);
1349 item->setText(0, toqstr(translateIfPossible((*cit)->name())));
1350 item->setText(1, (toclevel <= depth) ? yes : no);
1351 item->setText(2, (toclevel <= toc) ? yes : no);
1355 numberingModule->tocTW->setUpdatesEnabled(true);
1356 numberingModule->tocTW->update();
1360 void GuiDocument::apply(BufferParams & params)
1363 preambleModule->apply(params);
1366 params.setCiteEngine(biblio::ENGINE_BASIC);
1368 if (biblioModule->citeNatbibRB->isChecked()) {
1369 bool const use_numerical_citations =
1370 biblioModule->citeStyleCO->currentIndex();
1371 if (use_numerical_citations)
1372 params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
1374 params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
1376 } else if (biblioModule->citeJurabibRB->isChecked())
1377 params.setCiteEngine(biblio::ENGINE_JURABIB);
1379 params.use_bibtopic =
1380 biblioModule->bibtopicCB->isChecked();
1382 // language & quotes
1383 if (langModule->defaultencodingRB->isChecked()) {
1384 params.inputenc = "auto";
1386 int i = langModule->encodingCO->currentIndex();
1388 params.inputenc = "default";
1391 fromqstr(langModule->encodingCO->currentText());
1394 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
1395 switch (langModule->quoteStyleCO->currentIndex()) {
1397 lga = InsetQuotes::EnglishQ;
1400 lga = InsetQuotes::SwedishQ;
1403 lga = InsetQuotes::GermanQ;
1406 lga = InsetQuotes::PolishQ;
1409 lga = InsetQuotes::FrenchQ;
1412 lga = InsetQuotes::DanishQ;
1415 params.quotes_language = lga;
1417 int const pos = langModule->languageCO->currentIndex();
1418 params.language = lyx::languages.getLanguage(lang_[pos]);
1421 if (params.getTextClass().hasTocLevels()) {
1422 params.tocdepth = numberingModule->tocSL->value();
1423 params.secnumdepth = numberingModule->depthSL->value();
1427 params.user_defined_bullet(0) = bulletsModule->getBullet(0);
1428 params.user_defined_bullet(1) = bulletsModule->getBullet(1);
1429 params.user_defined_bullet(2) = bulletsModule->getBullet(2);
1430 params.user_defined_bullet(3) = bulletsModule->getBullet(3);
1433 params.graphicsDriver =
1434 tex_graphics[latexModule->psdriverCO->currentIndex()];
1437 params.setBaseClass(latexModule->classCO->currentIndex());
1440 params.clearLayoutModules();
1441 int const srows = selected_model_.rowCount();
1442 vector<string> selModList;
1443 for (int i = 0; i < srows; ++i)
1444 params.addLayoutModule(selected_model_.getIDString(i));
1446 if (mathsModule->amsautoCB->isChecked()) {
1447 params.use_amsmath = BufferParams::package_auto;
1449 if (mathsModule->amsCB->isChecked())
1450 params.use_amsmath = BufferParams::package_on;
1452 params.use_amsmath = BufferParams::package_off;
1455 if (mathsModule->esintautoCB->isChecked())
1456 params.use_esint = BufferParams::package_auto;
1458 if (mathsModule->esintCB->isChecked())
1459 params.use_esint = BufferParams::package_on;
1461 params.use_esint = BufferParams::package_off;
1464 if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
1465 params.pagestyle = "default";
1467 docstring style_gui =
1468 qstring_to_ucs4(pageLayoutModule->pagestyleCO->currentText());
1469 for (size_t i = 0; i < pagestyles.size(); ++i)
1470 if (pagestyles[i].second == style_gui)
1471 params.pagestyle = pagestyles[i].first;
1474 switch (textLayoutModule->lspacingCO->currentIndex()) {
1476 params.spacing().set(Spacing::Single);
1479 params.spacing().set(Spacing::Onehalf);
1482 params.spacing().set(Spacing::Double);
1485 params.spacing().set(Spacing::Other,
1486 fromqstr(textLayoutModule->lspacingLE->text()));
1490 if (textLayoutModule->twoColumnCB->isChecked())
1495 // text should have passed validation
1496 params.listings_params =
1497 InsetListingsParams(fromqstr(textLayoutModule->listingsED->toPlainText())).params();
1499 if (textLayoutModule->indentRB->isChecked())
1500 params.paragraph_separation = BufferParams::PARSEP_INDENT;
1502 params.paragraph_separation = BufferParams::PARSEP_SKIP;
1504 switch (textLayoutModule->skipCO->currentIndex()) {
1506 params.setDefSkip(VSpace(VSpace::SMALLSKIP));
1509 params.setDefSkip(VSpace(VSpace::MEDSKIP));
1512 params.setDefSkip(VSpace(VSpace::BIGSKIP));
1517 widgetsToLength(textLayoutModule->skipLE,
1518 textLayoutModule->skipLengthCO)
1520 params.setDefSkip(vs);
1524 // DocumentDefskipCB assures that this never happens
1525 // so Assert then !!! - jbl
1526 params.setDefSkip(VSpace(VSpace::MEDSKIP));
1531 fromqstr(latexModule->optionsLE->text());
1533 params.float_placement = floatModule->get();
1537 tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
1540 tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
1542 params.fontsTypewriter =
1543 tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
1545 params.fontsSansScale = fontModule->scaleSansSB->value();
1547 params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value();
1549 params.fontsSC = fontModule->fontScCB->isChecked();
1551 params.fontsOSF = fontModule->fontOsfCB->isChecked();
1553 params.fontsDefaultFamily = GuiDocument::fontfamilies[
1554 fontModule->fontsDefaultCO->currentIndex()];
1556 if (fontModule->fontsizeCO->currentIndex() == 0)
1557 params.fontsize = "default";
1560 fromqstr(fontModule->fontsizeCO->currentText());
1563 params.papersize = PAPER_SIZE(
1564 pageLayoutModule->papersizeCO->currentIndex());
1566 // custom, A3, B3 and B4 paper sizes need geometry
1567 int psize = pageLayoutModule->papersizeCO->currentIndex();
1568 bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9);
1570 params.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE,
1571 pageLayoutModule->paperwidthUnitCO);
1573 params.paperheight = widgetsToLength(pageLayoutModule->paperheightLE,
1574 pageLayoutModule->paperheightUnitCO);
1576 if (pageLayoutModule->facingPagesCB->isChecked())
1577 params.sides = TwoSides;
1579 params.sides = OneSide;
1581 if (pageLayoutModule->landscapeRB->isChecked())
1582 params.orientation = ORIENTATION_LANDSCAPE;
1584 params.orientation = ORIENTATION_PORTRAIT;
1587 params.use_geometry =
1588 (!marginsModule->marginCB->isChecked()
1591 Ui::MarginsUi const * m(marginsModule);
1593 params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
1594 params.topmargin = widgetsToLength(m->topLE, m->topUnit);
1595 params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
1596 params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
1597 params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
1598 params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
1599 params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
1601 branchesModule->apply(params);
1604 PDFOptions & pdf = params.pdfoptions();
1605 pdf.use_hyperref = pdfSupportModule->use_hyperrefGB->isChecked();
1606 pdf.title = fromqstr(pdfSupportModule->titleLE->text());
1607 pdf.author = fromqstr(pdfSupportModule->authorLE->text());
1608 pdf.subject = fromqstr(pdfSupportModule->subjectLE->text());
1609 pdf.keywords = fromqstr(pdfSupportModule->keywordsLE->text());
1611 pdf.bookmarks = pdfSupportModule->bookmarksGB->isChecked();
1612 pdf.bookmarksnumbered = pdfSupportModule->bookmarksnumberedCB->isChecked();
1613 pdf.bookmarksopen = pdfSupportModule->bookmarksopenGB->isChecked();
1614 pdf.bookmarksopenlevel = pdfSupportModule->bookmarksopenlevelSB->value();
1616 pdf.breaklinks = pdfSupportModule->breaklinksCB->isChecked();
1617 pdf.pdfborder = pdfSupportModule->pdfborderCB->isChecked();
1618 pdf.pdfusetitle = pdfSupportModule->pdfusetitleCB->isChecked();
1619 pdf.colorlinks = pdfSupportModule->colorlinksCB->isChecked();
1620 pdf.backref = pdfSupportModule->backrefCB->isChecked();
1621 pdf.pagebackref = pdfSupportModule->pagebackrefCB->isChecked();
1622 if (pdfSupportModule->fullscreenCB->isChecked())
1623 pdf.pagemode = pdf.pagemode_fullscreen;
1625 pdf.pagemode.clear();
1626 pdf.quoted_options = fromqstr(pdfSupportModule->optionsLE->text());
1633 /** Return the position of val in the vector if found.
1634 If not found, return 0.
1637 static size_t findPos(vector<A> const & vec, A const & val)
1639 typename vector<A>::const_iterator it =
1640 find(vec.begin(), vec.end(), val);
1641 if (it == vec.end())
1643 return distance(vec.begin(), it);
1647 void GuiDocument::updateParams()
1653 void GuiDocument::updateParams(BufferParams const & params)
1655 // set the default unit
1656 Length::UNIT defaultUnit = Length::CM;
1657 switch (lyxrc.default_papersize) {
1658 case PAPER_DEFAULT: break;
1660 case PAPER_USLETTER:
1662 case PAPER_USEXECUTIVE:
1663 defaultUnit = Length::IN;
1672 defaultUnit = Length::CM;
1679 preambleModule->update(params, id());
1682 biblioModule->citeDefaultRB->setChecked(
1683 params.getEngine() == biblio::ENGINE_BASIC);
1685 biblioModule->citeNatbibRB->setChecked(
1686 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
1687 params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
1689 biblioModule->citeStyleCO->setCurrentIndex(
1690 params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
1692 biblioModule->citeJurabibRB->setChecked(
1693 params.getEngine() == biblio::ENGINE_JURABIB);
1695 biblioModule->bibtopicCB->setChecked(
1696 params.use_bibtopic);
1698 // language & quotes
1699 int const pos = int(findPos(lang_,
1700 params.language->lang()));
1701 langModule->languageCO->setCurrentIndex(pos);
1703 langModule->quoteStyleCO->setCurrentIndex(
1704 params.quotes_language);
1706 bool default_enc = true;
1707 if (params.inputenc != "auto") {
1708 default_enc = false;
1709 if (params.inputenc == "default") {
1710 langModule->encodingCO->setCurrentIndex(0);
1712 int const i = langModule->encodingCO->findText(
1713 toqstr(params.inputenc));
1715 langModule->encodingCO->setCurrentIndex(i);
1717 // unknown encoding. Set to default.
1721 langModule->defaultencodingRB->setChecked(default_enc);
1722 langModule->otherencodingRB->setChecked(!default_enc);
1725 int const min_toclevel = textClass().min_toclevel();
1726 int const max_toclevel = textClass().max_toclevel();
1727 if (textClass().hasTocLevels()) {
1728 numberingModule->setEnabled(true);
1729 numberingModule->depthSL->setMinimum(min_toclevel - 1);
1730 numberingModule->depthSL->setMaximum(max_toclevel);
1731 numberingModule->depthSL->setValue(params.secnumdepth);
1732 numberingModule->tocSL->setMaximum(min_toclevel - 1);
1733 numberingModule->tocSL->setMaximum(max_toclevel);
1734 numberingModule->tocSL->setValue(params.tocdepth);
1737 numberingModule->setEnabled(false);
1738 numberingModule->tocTW->clear();
1742 bulletsModule->setBullet(0, params.user_defined_bullet(0));
1743 bulletsModule->setBullet(1, params.user_defined_bullet(1));
1744 bulletsModule->setBullet(2, params.user_defined_bullet(2));
1745 bulletsModule->setBullet(3, params.user_defined_bullet(3));
1746 bulletsModule->init();
1749 int nitem = findToken(tex_graphics, params.graphicsDriver);
1751 latexModule->psdriverCO->setCurrentIndex(nitem);
1754 mathsModule->amsCB->setChecked(
1755 params.use_amsmath == BufferParams::package_on);
1756 mathsModule->amsautoCB->setChecked(
1757 params.use_amsmath == BufferParams::package_auto);
1759 mathsModule->esintCB->setChecked(
1760 params.use_esint == BufferParams::package_on);
1761 mathsModule->esintautoCB->setChecked(
1762 params.use_esint == BufferParams::package_auto);
1764 switch (params.spacing().getSpace()) {
1765 case Spacing::Other: nitem = 3; break;
1766 case Spacing::Double: nitem = 2; break;
1767 case Spacing::Onehalf: nitem = 1; break;
1768 case Spacing::Default: case Spacing::Single: nitem = 0; break;
1772 latexModule->classCO->setCurrentIndex(params.getBaseClass());
1774 updatePagestyle(textClass().opt_pagestyle(),
1777 textLayoutModule->lspacingCO->setCurrentIndex(nitem);
1778 if (params.spacing().getSpace() == Spacing::Other) {
1779 textLayoutModule->lspacingLE->setText(
1780 toqstr(params.spacing().getValueAsString()));
1784 if (params.paragraph_separation == BufferParams::PARSEP_INDENT)
1785 textLayoutModule->indentRB->setChecked(true);
1787 textLayoutModule->skipRB->setChecked(true);
1790 switch (params.getDefSkip().kind()) {
1791 case VSpace::SMALLSKIP:
1794 case VSpace::MEDSKIP:
1797 case VSpace::BIGSKIP:
1800 case VSpace::LENGTH:
1803 string const length = params.getDefSkip().asLyXCommand();
1804 lengthToWidgets(textLayoutModule->skipLE,
1805 textLayoutModule->skipLengthCO,
1806 length, defaultUnit);
1813 textLayoutModule->skipCO->setCurrentIndex(skip);
1816 textLayoutModule->twoColumnCB->setChecked(
1817 params.columns == 2);
1819 // break listings_params to multiple lines
1821 InsetListingsParams(params.listings_params).separatedParams();
1822 textLayoutModule->listingsED->setPlainText(toqstr(lstparams));
1824 if (!params.options.empty()) {
1825 latexModule->optionsLE->setText(
1826 toqstr(params.options));
1828 latexModule->optionsLE->setText(QString());
1831 floatModule->set(params.float_placement);
1834 updateFontsize(textClass().opt_fontsize(),
1837 int n = findToken(tex_fonts_roman, params.fontsRoman);
1839 fontModule->fontsRomanCO->setCurrentIndex(n);
1843 n = findToken(tex_fonts_sans, params.fontsSans);
1845 fontModule->fontsSansCO->setCurrentIndex(n);
1849 n = findToken(tex_fonts_monospaced, params.fontsTypewriter);
1851 fontModule->fontsTypewriterCO->setCurrentIndex(n);
1855 fontModule->fontScCB->setChecked(params.fontsSC);
1856 fontModule->fontOsfCB->setChecked(params.fontsOSF);
1857 fontModule->scaleSansSB->setValue(params.fontsSansScale);
1858 fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale);
1859 n = findToken(GuiDocument::fontfamilies, params.fontsDefaultFamily);
1861 fontModule->fontsDefaultCO->setCurrentIndex(n);
1864 int const psize = params.papersize;
1865 pageLayoutModule->papersizeCO->setCurrentIndex(psize);
1866 setCustomPapersize(psize);
1868 bool const landscape =
1869 params.orientation == ORIENTATION_LANDSCAPE;
1870 pageLayoutModule->landscapeRB->setChecked(landscape);
1871 pageLayoutModule->portraitRB->setChecked(!landscape);
1873 pageLayoutModule->facingPagesCB->setChecked(
1874 params.sides == TwoSides);
1877 lengthToWidgets(pageLayoutModule->paperwidthLE,
1878 pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit);
1880 lengthToWidgets(pageLayoutModule->paperheightLE,
1881 pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit);
1884 Ui::MarginsUi * m = marginsModule;
1886 setMargins(!params.use_geometry);
1888 lengthToWidgets(m->topLE, m->topUnit,
1889 params.topmargin, defaultUnit);
1891 lengthToWidgets(m->bottomLE, m->bottomUnit,
1892 params.bottommargin, defaultUnit);
1894 lengthToWidgets(m->innerLE, m->innerUnit,
1895 params.leftmargin, defaultUnit);
1897 lengthToWidgets(m->outerLE, m->outerUnit,
1898 params.rightmargin, defaultUnit);
1900 lengthToWidgets(m->headheightLE, m->headheightUnit,
1901 params.headheight, defaultUnit);
1903 lengthToWidgets(m->headsepLE, m->headsepUnit,
1904 params.headsep, defaultUnit);
1906 lengthToWidgets(m->footskipLE, m->footskipUnit,
1907 params.footskip, defaultUnit);
1909 branchesModule->update(params);
1912 PDFOptions const & pdf = params.pdfoptions();
1913 pdfSupportModule->use_hyperrefGB->setChecked(pdf.use_hyperref);
1914 pdfSupportModule->titleLE->setText(toqstr(pdf.title));
1915 pdfSupportModule->authorLE->setText(toqstr(pdf.author));
1916 pdfSupportModule->subjectLE->setText(toqstr(pdf.subject));
1917 pdfSupportModule->keywordsLE->setText(toqstr(pdf.keywords));
1919 pdfSupportModule->bookmarksGB->setChecked(pdf.bookmarks);
1920 pdfSupportModule->bookmarksnumberedCB->setChecked(pdf.bookmarksnumbered);
1921 pdfSupportModule->bookmarksopenGB->setChecked(pdf.bookmarksopen);
1923 pdfSupportModule->bookmarksopenlevelSB->setValue(pdf.bookmarksopenlevel);
1925 pdfSupportModule->breaklinksCB->setChecked(pdf.breaklinks);
1926 pdfSupportModule->pdfborderCB->setChecked(pdf.pdfborder);
1927 pdfSupportModule->pdfusetitleCB->setChecked(pdf.pdfusetitle);
1928 pdfSupportModule->colorlinksCB->setChecked(pdf.colorlinks);
1929 pdfSupportModule->backrefCB->setChecked(pdf.backref);
1930 pdfSupportModule->pagebackrefCB->setChecked(pdf.pagebackref);
1931 pdfSupportModule->fullscreenCB->setChecked
1932 (pdf.pagemode == pdf.pagemode_fullscreen);
1934 pdfSupportModule->optionsLE->setText(
1935 toqstr(pdf.quoted_options));
1938 updateEmbeddedFileList();
1942 void GuiDocument::applyView()
1948 void GuiDocument::saveDocDefault()
1950 // we have to apply the params first
1956 void GuiDocument::updateAvailableModules()
1958 available_model_.clear();
1959 vector<modInfoStruct> const modInfoList = getModuleInfo();
1960 int const mSize = modInfoList.size();
1961 for (int i = 0; i < mSize; ++i) {
1962 modInfoStruct const & modInfo = modInfoList[i];
1963 available_model_.insertRow(i, modInfo.name, modInfo.id);
1968 void GuiDocument::updateSelectedModules()
1970 //and selected ones, too
1971 selected_model_.clear();
1972 vector<modInfoStruct> const selModList = getSelectedModules();
1973 int const sSize = selModList.size();
1974 for (int i = 0; i < sSize; ++i) {
1975 modInfoStruct const & modInfo = selModList[i];
1976 selected_model_.insertRow(i, modInfo.name, modInfo.id);
1981 void GuiDocument::updateContents()
1983 updateAvailableModules();
1984 updateSelectedModules();
1986 //FIXME It'd be nice to make sure here that the selected
1987 //modules are consistent: That required modules are actually
1988 //selected, and that we don't have conflicts. If so, we could
1989 //at least pop up a warning.
1993 void GuiDocument::useClassDefaults()
1995 bp_.setBaseClass(latexModule->classCO->currentIndex());
1996 bp_.useClassDefaults();
2001 bool GuiDocument::isValid()
2003 return validate_listings_params().empty();
2007 char const * const GuiDocument::fontfamilies[5] = {
2008 "default", "rmdefault", "sfdefault", "ttdefault", ""
2012 char const * GuiDocument::fontfamilies_gui[5] = {
2013 N_("Default"), N_("Roman"), N_("Sans Serif"), N_("Typewriter"), ""
2017 bool GuiDocument::initialiseParams(string const &)
2019 bp_ = buffer().params();
2025 void GuiDocument::clearParams()
2027 bp_ = BufferParams();
2031 BufferId GuiDocument::id() const
2037 vector<GuiDocument::modInfoStruct> const & GuiDocument::getModuleInfo()
2039 return moduleNames_;
2043 vector<GuiDocument::modInfoStruct> const GuiDocument::getSelectedModules()
2045 vector<string> const & mods = params().getModules();
2046 vector<string>::const_iterator it = mods.begin();
2047 vector<string>::const_iterator end = mods.end();
2048 vector<modInfoStruct> mInfo;
2049 for (; it != end; ++it) {
2052 LyXModule * mod = moduleList[*it];
2054 m.name = mod->getName();
2056 m.name = *it + " (Not Found)";
2063 TextClass const & GuiDocument::textClass() const
2065 return textclasslist[bp_.getBaseClass()];
2069 static void dispatch_bufferparams(Dialog const & dialog,
2070 BufferParams const & bp, kb_action lfun)
2073 ss << "\\begin_header\n";
2075 ss << "\\end_header\n";
2076 dialog.dispatch(FuncRequest(lfun, ss.str()));
2080 void GuiDocument::dispatchParams()
2082 // This must come first so that a language change is correctly noticed
2085 // Apply the BufferParams. Note that this will set the base class
2086 // and then update the buffer's layout.
2087 dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY);
2089 // Generate the colours requested by each new branch.
2090 BranchList & branchlist = params().branchlist();
2091 if (!branchlist.empty()) {
2092 BranchList::const_iterator it = branchlist.begin();
2093 BranchList::const_iterator const end = branchlist.end();
2094 for (; it != end; ++it) {
2095 docstring const & current_branch = it->getBranch();
2096 Branch const * branch = branchlist.find(current_branch);
2097 string const x11hexname = X11hexname(branch->getColor());
2098 // display the new color
2099 docstring const str = current_branch + ' ' + from_ascii(x11hexname);
2100 dispatch(FuncRequest(LFUN_SET_COLOR, str));
2103 // Open insets of selected branches, close deselected ones
2104 dispatch(FuncRequest(LFUN_ALL_INSETS_TOGGLE,
2107 // FIXME: If we used an LFUN, we would not need those two lines:
2108 bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
2112 void GuiDocument::setLanguage() const
2114 Language const * const newL = bp_.language;
2115 if (buffer().params().language == newL)
2118 string const & lang_name = newL->lang();
2119 dispatch(FuncRequest(LFUN_BUFFER_LANGUAGE, lang_name));
2123 void GuiDocument::saveAsDefault() const
2125 dispatch_bufferparams(*this, params(), LFUN_BUFFER_SAVE_AS_DEFAULT);
2129 bool GuiDocument::isFontAvailable(string const & font) const
2131 if (font == "default" || font == "cmr"
2132 || font == "cmss" || font == "cmtt")
2133 // these are standard
2135 if (font == "lmodern" || font == "lmss" || font == "lmtt")
2136 return LaTeXFeatures::isAvailable("lmodern");
2137 if (font == "times" || font == "palatino"
2138 || font == "helvet" || font == "courier")
2139 return LaTeXFeatures::isAvailable("psnfss");
2140 if (font == "cmbr" || font == "cmtl")
2141 return LaTeXFeatures::isAvailable("cmbright");
2142 if (font == "utopia")
2143 return LaTeXFeatures::isAvailable("utopia")
2144 || LaTeXFeatures::isAvailable("fourier");
2145 if (font == "beraserif" || font == "berasans"
2146 || font == "beramono")
2147 return LaTeXFeatures::isAvailable("bera");
2148 return LaTeXFeatures::isAvailable(font);
2152 bool GuiDocument::providesOSF(string const & font) const
2155 return isFontAvailable("eco");
2156 if (font == "palatino")
2157 return isFontAvailable("mathpazo");
2162 bool GuiDocument::providesSC(string const & font) const
2164 if (font == "palatino")
2165 return isFontAvailable("mathpazo");
2166 if (font == "utopia")
2167 return isFontAvailable("fourier");
2172 bool GuiDocument::providesScale(string const & font) const
2174 return font == "helvet" || font == "luximono"
2175 || font == "berasans" || font == "beramono";
2179 void GuiDocument::loadModuleInfo()
2181 moduleNames_.clear();
2182 LyXModuleList::const_iterator it = moduleList.begin();
2183 LyXModuleList::const_iterator end = moduleList.end();
2184 for (; it != end; ++it) {
2187 m.name = it->getName();
2188 moduleNames_.push_back(m);
2193 Dialog * createGuiDocument(GuiView & lv) { return new GuiDocument(lv); }
2196 } // namespace frontend
2199 #include "GuiDocument_moc.cpp"