diff --git a/development/FORMAT b/development/FORMAT index 19c1eb7c2c..218517e637 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,9 @@ LyX file-format changes ----------------------- +2009-04-06 Jürgen Spitzmüller + * Format incremented to 350: new param \default_output_format. + 2009-04-05 Jürgen Spitzmüller * Format incremented to 349: initial support for XeTeX. diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index 77e29aba92..a1d44edc4e 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -913,6 +913,7 @@ src_frontends_qt4_ui_files = Split(''' NomenclUi.ui NoteUi.ui NumberingUi.ui + OutputUi.ui PageLayoutUi.ui ParagraphUi.ui PDFSupportUi.ui diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index fd0eabd518..2ee691feba 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -287,6 +287,15 @@ def revert_xetex(document): document.header[i] = "\\font_tt_scale 100" +def revert_outputformat(document): + " Remove default output format param " + i = find_token(document.header, '\\default_output_format', 0) + if i == -1: + document.warning("Malformed LyX document: Missing \\default_output_format.") + return + del document.header[i] + + ## # Conversion hub # @@ -295,10 +304,12 @@ supported_versions = ["2.0.0","2.0"] convert = [[346, []], [347, []], [348, []], - [349, []] + [349, []], + [350, []] ] -revert = [[348, [revert_xetex]], +revert = [[349, [revert_outputformat]], + [348, [revert_xetex]], [347, [revert_phantom, revert_hphantom, revert_vphantom]], [346, [revert_tabularvalign]], [345, [revert_swiss]] diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 3ec76bbb73..4de45635e1 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -124,7 +124,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 349; // jspitzm: initial XeTeX support +int const LYX_FORMAT = 350; // jspitzm: default output format typedef map DepClean; typedef map > RefCache; @@ -2654,6 +2654,9 @@ string Buffer::bufferFormat() const string Buffer::getDefaultOutputFormat() const { + if (!params().defaultOutputFormat.empty() + && params().defaultOutputFormat != "default") + return params().defaultOutputFormat; typedef vector Formats; Formats formats = exportableFormats(true); if (isDocBook() diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index f540cb543b..7e8c16512a 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -351,6 +351,7 @@ BufferParams::BufferParams() fontsTypewriterScale = 100; inputenc = "auto"; graphicsDriver = "default"; + defaultOutputFormat = "default"; sides = OneSide; columns = 1; listings_params = string(); @@ -509,6 +510,8 @@ string BufferParams::readToken(Lexer & lex, string const & token, lex >> inputenc; } else if (token == "\\graphics") { readGraphicsDriver(lex); + } else if (token == "\\default_output_format") { + lex >> defaultOutputFormat; } else if (token == "\\font_roman") { lex.eatLine(); fontsRoman = lex.getString(); @@ -758,6 +761,7 @@ void BufferParams::writeFile(ostream & os) const os << "\\font_cjk " << fontsCJK << '\n'; } os << "\n\\graphics " << graphicsDriver << '\n'; + os << "\\default_output_format " << defaultOutputFormat << '\n'; if (!float_placement.empty()) { os << "\\float_placement " << float_placement << '\n'; diff --git a/src/BufferParams.h b/src/BufferParams.h index 63558190d8..7c8c815041 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -181,6 +181,8 @@ public: /* some LaTeX options */ /// The graphics driver std::string graphicsDriver; + /// The default output format + std::string defaultOutputFormat; /// the rm font std::string fontsRoman; /// the sf font diff --git a/src/TextClass.h b/src/TextClass.h index 60cc25a830..7255165c23 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -184,11 +184,13 @@ public: // accessors /////////////////////////////////////////////////////////////////// /// - std::string const & name() const { return name_; }; + std::string const & name() const { return name_; } /// - std::string const & description() const { return description_; }; + std::string const & description() const { return description_; } /// std::string const & latexname() const { return latexname_; } + /// Can be LaTeX, DocBook, etc. + OutputType outputType() const { return outputType_; } protected: /// Protect construction TextClass(); diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 8d85dddeb4..104df745f7 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -30,6 +30,7 @@ #include "Color.h" #include "Encoding.h" #include "FloatPlacement.h" +#include "Format.h" #include "FuncRequest.h" #include "Language.h" #include "LaTeXFeatures.h" @@ -583,8 +584,18 @@ GuiDocument::GuiDocument(GuiView & lv) // initialize the length validator bc().addCheckedLineEdit(textLayoutModule->skipLE); - fontModule = new UiWidget; + // output + outputModule = new UiWidget; + + connect(outputModule->xetexCB, SIGNAL(clicked()), + this, SLOT(change_adaptor())); + connect(outputModule->xetexCB, SIGNAL(toggled(bool)), + this, SLOT(xetexChanged(bool))); + connect(outputModule->defaultFormatCO, SIGNAL(activated(int)), + this, SLOT(change_adaptor())); + // fonts + fontModule = new UiWidget; connect(fontModule->fontsRomanCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); connect(fontModule->fontsRomanCO, SIGNAL(activated(int)), @@ -611,10 +622,6 @@ GuiDocument::GuiDocument(GuiView & lv) this, SLOT(change_adaptor())); connect(fontModule->fontOsfCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(fontModule->xetexCB, SIGNAL(clicked()), - this, SLOT(change_adaptor())); - connect(fontModule->xetexCB, SIGNAL(toggled(bool)), - this, SLOT(xetexChanged(bool))); updateFontlist(); @@ -982,6 +989,7 @@ GuiDocument::GuiDocument(GuiView & lv) docPS->addPanel(floatModule, qt_("Float Placement")); docPS->addPanel(bulletsModule, qt_("Bullets")); docPS->addPanel(branchesModule, qt_("Branches")); + docPS->addPanel(outputModule, qt_("Output")); docPS->addPanel(preambleModule, qt_("LaTeX Preamble")); docPS->setCurrentPanel(qt_("Document Class")); // FIXME: hack to work around resizing bug in Qt >= 4.2 @@ -1161,6 +1169,7 @@ void GuiDocument::setCustomMargins(bool custom) void GuiDocument::xetexChanged(bool xetex) { updateFontlist(); + updateDefaultFormat(); langModule->encodingCO->setEnabled(!xetex && !langModule->defaultencodingRB->isChecked()); langModule->defaultencodingRB->setEnabled(!xetex); @@ -1197,7 +1206,7 @@ void GuiDocument::updateFontlist() fontModule->fontsTypewriterCO->clear(); // With XeTeX, we have access to all system fonts, but not the LaTeX fonts - if (fontModule->xetexCB->isChecked()) { + if (outputModule->xetexCB->isChecked()) { fontModule->fontsRomanCO->addItem(qt_("Default")); fontModule->fontsSansCO->addItem(qt_("Default")); fontModule->fontsTypewriterCO->addItem(qt_("Default")); @@ -1235,7 +1244,7 @@ void GuiDocument::updateFontlist() void GuiDocument::romanChanged(int item) { - if (fontModule->xetexCB->isChecked()) { + if (outputModule->xetexCB->isChecked()) { fontModule->fontScCB->setEnabled(false); return; } @@ -1247,7 +1256,7 @@ void GuiDocument::romanChanged(int item) void GuiDocument::sansChanged(int item) { - if (fontModule->xetexCB->isChecked()) { + if (outputModule->xetexCB->isChecked()) { fontModule->fontScCB->setEnabled(false); return; } @@ -1260,7 +1269,7 @@ void GuiDocument::sansChanged(int item) void GuiDocument::ttChanged(int item) { - if (fontModule->xetexCB->isChecked()) { + if (outputModule->xetexCB->isChecked()) { fontModule->fontScCB->setEnabled(false); return; } @@ -1599,6 +1608,32 @@ void GuiDocument::updateNumbering() } +void GuiDocument::updateDefaultFormat() +{ + // make a copy in order to consider unapplied changes + Buffer * tmpbuf = const_cast(&buffer()); + tmpbuf->params().useXetex = outputModule->xetexCB->isChecked(); + int idx = latexModule->classCO->currentIndex(); + if (idx >= 0) { + string const classname = classes_model_.getIDString(idx); + tmpbuf->params().setBaseClass(classname); + tmpbuf->params().makeDocumentClass(); + } + outputModule->defaultFormatCO->blockSignals(true); + outputModule->defaultFormatCO->clear(); + outputModule->defaultFormatCO->addItem(qt_("Default"), + QVariant(QString("default"))); + typedef vector Formats; + Formats formats = tmpbuf->exportableFormats(true); + Formats::const_iterator cit = formats.begin(); + Formats::const_iterator end = formats.end(); + for (; cit != end; ++cit) + outputModule->defaultFormatCO->addItem(qt_((*cit)->prettyname()), + QVariant(toqstr((*cit)->name()))); + outputModule->defaultFormatCO->blockSignals(false); +} + + void GuiDocument::applyView() { // preamble @@ -1799,10 +1834,14 @@ void GuiDocument::applyView() bp_.float_placement = floatModule->get(); - // fonts - bool const xetex = fontModule->xetexCB->isChecked(); + // output + bp_.defaultOutputFormat = fromqstr(outputModule->defaultFormatCO->itemData( + outputModule->defaultFormatCO->currentIndex()).toString()); + + bool const xetex = outputModule->xetexCB->isChecked(); bp_.useXetex = xetex; + // fonts if (xetex) { if (fontModule->fontsRomanCO->currentIndex() == 0) bp_.fontsRoman = "default"; @@ -2127,12 +2166,23 @@ void GuiDocument::paramsToDialog() floatModule->set(bp_.float_placement); + // Output + // update combobox with formats + updateDefaultFormat(); + int index = outputModule->defaultFormatCO->findData(toqstr( + bp_.defaultOutputFormat)); + // set to default if format is not found + if (index == -1) + index = 0; + outputModule->defaultFormatCO->setCurrentIndex(index); + outputModule->xetexCB->setEnabled(bp_.baseClass()->outputType() == lyx::LATEX); + outputModule->xetexCB->setChecked( + bp_.baseClass()->outputType() == lyx::LATEX && bp_.useXetex); + // Fonts updateFontsize(documentClass().opt_fontsize(), bp_.fontsize); - fontModule->xetexCB->setChecked(bp_.useXetex); - if (bp_.useXetex) { for (int i = 0; i < fontModule->fontsRomanCO->count(); ++i) { if (fontModule->fontsRomanCO->itemText(i) == toqstr(bp_.fontsRoman)) { diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h index 04338820fc..7dd64cc0d9 100644 --- a/src/frontends/qt4/GuiDocument.h +++ b/src/frontends/qt4/GuiDocument.h @@ -33,6 +33,7 @@ #include "ui_PreambleUi.h" #include "ui_PDFSupportUi.h" #include "ui_ModulesUi.h" +#include "ui_OutputUi.h" #include #include @@ -70,6 +71,7 @@ public: void paramsToDialog(); void updateFontsize(std::string const &, std::string const &); void updateFontlist(); + void updateDefaultFormat(); void updatePagestyle(std::string const &, std::string const &); void showPreamble(); @@ -114,6 +116,7 @@ private: UiWidget *latexModule; UiWidget *pdfSupportModule; UiWidget *modulesModule; + UiWidget *outputModule; PreambleModule *preambleModule; GuiBranches *branchesModule; diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index 13391190fd..d44cfe4579 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -267,6 +267,7 @@ UIFILES = \ NomenclUi.ui \ NoteUi.ui \ NumberingUi.ui \ + OutputUi.ui \ PageLayoutUi.ui \ ParagraphUi.ui \ PDFSupportUi.ui \ diff --git a/src/frontends/qt4/ui/FontUi.ui b/src/frontends/qt4/ui/FontUi.ui index 574152d66c..f3f46934cf 100644 --- a/src/frontends/qt4/ui/FontUi.ui +++ b/src/frontends/qt4/ui/FontUi.ui @@ -12,222 +12,30 @@ FontUi - - - - - Use the XeTeX processor, which allows access to all system fonts - - - Use &XeTeX - - - - - - - Qt::Horizontal - - - - - - - &Default Family: - - - fontsDefaultCO - - - - - - - Select the default family for the document - - - - - - - &Base Size: - - - fontsizeCO - - - - - - - - - - - + + + 9 + + + 6 + + - Qt::Horizontal + Qt::Vertical - + + QSizePolicy::Expanding + + - 182 + 391 16 - - - - &Roman: - - - fontsRomanCO - - - - - - - Select the roman (serif) typeface - - - - - - - Qt::Horizontal - - - - 131 - 20 - - - - - - - - &Sans Serif: - - - fontsSansCO - - - - - - - Select the Sans Serif (grotesque) typeface - - - - - - - S&cale (%): - - - scaleSansSB - - - - - - - Scale the Sans Serif font to match the base font's dimensions - - - 10 - - - 200 - - - - - - - &Typewriter: - - - fontsTypewriterCO - - - - - - - Select the typewriter (monospaced) typeface - - - - - - - Sc&ale (%): - - - scaleTypewriterSB - - - - - - - Scale the Typewriter font to match the base font's dimensions - - - 10 - - - 200 - - - - - - - C&JK: - - - cjkFontLE - - - - - - Input the font to be used for Chinese, Japanese or Korean (CJK) script - - - - - - - Qt::Horizontal - - - - 151 - 20 - - - - - - - - Use a real small caps shape, if the font provides one - - - Use true S&mall Caps - - - - Use old style instead of lining figures @@ -237,22 +45,203 @@ - + + + + Use a real small caps shape, if the font provides one + + + Use true S&mall Caps + + + + - Qt::Vertical + Qt::Horizontal - - QSizePolicy::Expanding - - + - 391 + 151 + 20 + + + + + + + + Input the font to be used for Chinese, Japanese or Korean (CJK) script + + + + + + + C&JK: + + + cjkFontLE + + + + + + + Scale the Typewriter font to match the base font's dimensions + + + 200 + + + 10 + + + + + + + Sc&ale (%): + + + scaleTypewriterSB + + + + + + + Select the typewriter (monospaced) typeface + + + + + + + &Typewriter: + + + fontsTypewriterCO + + + + + + + Scale the Sans Serif font to match the base font's dimensions + + + 200 + + + 10 + + + + + + + S&cale (%): + + + scaleSansSB + + + + + + + Select the Sans Serif (grotesque) typeface + + + + + + + &Sans Serif: + + + fontsSansCO + + + + + + + Qt::Horizontal + + + + 131 + 20 + + + + + + + + Select the roman (serif) typeface + + + + + + + &Roman: + + + fontsRomanCO + + + + + + + Qt::Horizontal + + + + 182 16 + + + + + + + + + + + &Base Size: + + + fontsizeCO + + + + + + + Select the default family for the document + + + + + + + &Default Family: + + + fontsDefaultCO + + + diff --git a/src/frontends/qt4/ui/OutputUi.ui b/src/frontends/qt4/ui/OutputUi.ui new file mode 100644 index 0000000000..27c223028c --- /dev/null +++ b/src/frontends/qt4/ui/OutputUi.ui @@ -0,0 +1,100 @@ + + OutputUi + + + + 0 + 0 + 271 + 295 + + + + Form + + + + 9 + + + 6 + + + + + Output Format + + + true + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + Specify the default output format (for view/update) + + + De&fault Output Format: + + + defaultFormatCO + + + + + + + Specify the default output format (for view/update) + + + + + + + + + Use the XeTeX processing engine + + + Use &XeTeX + + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + qt_i18n.h + + + +