From 5b83287abe01f137a737350abece586c4c81c04b Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sat, 20 May 2006 12:03:40 +0000 Subject: [PATCH] * src/format.[Ch] (document_): new flag, telling whether this is a document format and we want to show this format in the export and view menus (documentFormat): accessor for document_ * src/format.h: Add some documentation * src/frontends/qt3/QPrefsDialog.C (QPrefsDialog::QPrefsDialog): handle new documentCB checkbox (QPrefsDialog::switch_format): ditto (QPrefsDialog::updateFormatsButtons): ditto (QPrefsDialog::new_format): ditto (QPrefsDialog::modify_format): ditto * src/frontends/qt3/ui/QPrefFileformatsModule.ui: Add documentCB checkbox * src/frontends/qt4/QPrefsDialog.C (QPrefsDialog::QPrefsDialog): handle new documentCB checkbox (QPrefsDialog::switch_format): ditto (QPrefsDialog::updateFormatsButtons): ditto (QPrefsDialog::new_format): ditto (QPrefsDialog::modify_format): ditto * src/frontends/qt4/ui/QPrefFileformatsUi.ui: Add documentCB checkbox * src/frontends/xforms/FormPreferences.C (FormPreferences::Formats::build): handle new check_document checkbox (FormPreferences::Formats::input): ditto (FormPreferences::Formats::Add): ditto (FormPreferences::Formats::Browser): ditto * src/frontends/xforms/forms/form_preferences.fd: Add check_document checkbox * src/lyxrc.C (LyXRC::read): Remove compatibility code for 1.3 \format entries. Read the new format flags (but don't require them for 1.4 compatibility) (LyXRC::write): Write the new format flags * src/MenuBackend.C (expandFormats): Remove the hardcoded exception for image formats and use Format::isDocument() instead * lib/doc/Customization.lyx: Document auto viever/editor and the "document format" flag git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13887 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/configure.py | 88 +++++++++---------- lib/doc/Customization.lyx | 52 ++++++++++- src/MenuBackend.C | 19 ++-- src/format.C | 17 ++-- src/format.h | 37 +++++--- src/frontends/qt3/QPrefsDialog.C | 14 ++- .../qt3/ui/QPrefFileformatsModule.ui | 17 +++- src/frontends/qt4/QPrefsDialog.C | 14 ++- src/frontends/qt4/ui/QPrefFileformatsUi.ui | 14 +++ src/frontends/xforms/FormPreferences.C | 13 ++- .../xforms/forms/form_preferences.fd | 26 +++++- src/lyxrc.C | 47 ++++++---- 12 files changed, 259 insertions(+), 99 deletions(-) diff --git a/lib/configure.py b/lib/configure.py index fe7f8abc1e..bdcde5ae78 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -194,76 +194,76 @@ def checkLatex(): def checkFormatEntries(): ''' Check all formats (\Format entries) ''' checkProg('a Tgif viewer and editor', ['tgif'], - rc_entry = [ r'\Format tgif obj Tgif "" "%%" "%%"']) + rc_entry = [ r'\Format tgif obj Tgif "" "%%" "%%" ""']) # checkProg('a FIG viewer and editor', ['xfig'], - rc_entry = [ r'\Format fig fig FIG "" "%%" "%%"'] ) + rc_entry = [ r'\Format fig fig FIG "" "%%" "%%" ""'] ) # checkProg('a Grace viewer and editor', ['xmgrace'], - rc_entry = [ r'\Format agr agr Grace "" "%%" "%%"'] ) + rc_entry = [ r'\Format agr agr Grace "" "%%" "%%" ""'] ) # checkProg('a FEN viewer and editor', ['xboard -lpf $$i -mode EditPosition'], - rc_entry = [ r'\Format fen fen FEN "" "%%" "%%"' ]) + rc_entry = [ r'\Format fen fen FEN "" "%%" "%%" ""' ]) # path, iv = checkProg('a raster image viewer', ['xv', 'kview', 'gimp']) path, ie = checkProg('a raster image editor', ['gimp']) - addToRC(r'''\Format bmp bmp BMP "" "%s" "%s" -\Format gif gif GIF "" "%s" "%s" -\Format jpg jpg JPEG "" "%s" "%s" -\Format pbm pbm PBM "" "%s" "%s" -\Format pgm pgm PGM "" "%s" "%s" -\Format png png PNG "" "%s" "%s" -\Format ppm ppm PPM "" "%s" "%s" -\Format tiff tif TIFF "" "%s" "%s" -\Format xbm xbm XBM "" "%s" "%s" -\Format xpm xpm XPM "" "%s" "%s"''' % \ + addToRC(r'''\Format bmp bmp BMP "" "%s" "%s" "" +\Format gif gif GIF "" "%s" "%s" "" +\Format jpg jpg JPEG "" "%s" "%s" "" +\Format pbm pbm PBM "" "%s" "%s" "" +\Format pgm pgm PGM "" "%s" "%s" "" +\Format png png PNG "" "%s" "%s" "" +\Format ppm ppm PPM "" "%s" "%s" "" +\Format tiff tif TIFF "" "%s" "%s" "" +\Format xbm xbm XBM "" "%s" "%s" "" +\Format xpm xpm XPM "" "%s" "%s" ""''' % \ (iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie) ) # checkProg('a text editor', ['xemacs', 'gvim', 'kedit', 'kwrite', 'kate', \ 'nedit', 'gedit', 'notepad'], - rc_entry = [ r'''\Format asciichess asc "Plain text (chess output)" "" "" "%%" -\Format asciiimage asc "Plain text (image)" "" "" "%%" -\Format asciixfig asc "Plain text (Xfig output)" "" "" "%%" -\Format dateout tmp "date (output)" "" "" "%%" -\Format docbook sgml DocBook B "" "%%" -\Format docbook-xml xml "Docbook (XML)" "" "" "%%" -\Format literate nw NoWeb N "" "%%" -\Format latex tex "LaTeX (plain)" L "" "%%" -\Format linuxdoc sgml LinuxDoc x "" "%%" -\Format pdflatex tex "LaTeX (pdflatex)" "" "" "%%" -\Format text txt "Plain text" a "" "%%" -\Format textparagraph txt "Plain text (paragraphs)" "" "" "%%"''' ]) + rc_entry = [ r'''\Format asciichess asc "Plain text (chess output)" "" "" "%%" "" +\Format asciiimage asc "Plain text (image)" "" "" "%%" "" +\Format asciixfig asc "Plain text (Xfig output)" "" "" "%%" "" +\Format dateout tmp "date (output)" "" "" "%%" "" +\Format docbook sgml DocBook B "" "%%" "document" +\Format docbook-xml xml "Docbook (XML)" "" "" "%%" "document" +\Format literate nw NoWeb N "" "%%" "document" +\Format latex tex "LaTeX (plain)" L "" "%%" "document" +\Format linuxdoc sgml LinuxDoc x "" "%%" "document" +\Format pdflatex tex "LaTeX (pdflatex)" "" "" "%%" "document" +\Format text txt "Plain text" a "" "%%" "document" +\Format textparagraph txt "Plain text (paragraphs)" "" "" "%%" "document"''' ]) # #checkProg('a Postscript interpreter', ['gs'], # rc_entry = [ r'\ps_command "%%"' ]) checkProg('a Postscript previewer', ['gv', 'ghostview -swap', 'kghostview'], - rc_entry = [ r'''\Format eps eps EPS "" "%%" "" -\Format ps ps Postscript t "%%" ""''' ]) + rc_entry = [ r'''\Format eps eps EPS "" "%%" "" "" +\Format ps ps Postscript t "%%" "" "document"''' ]) # checkProg('a PDF previewer', ['acrobat', 'acroread', 'gv', 'ghostview', \ 'xpdf', 'kpdf', 'kghostview'], - rc_entry = [ r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" -\Format pdf2 pdf "PDF (pdflatex)" F "%%" "" -\Format pdf3 pdf "PDF (dvipdfm)" m "%%" ""''' ]) + rc_entry = [ r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" "document" +\Format pdf2 pdf "PDF (pdflatex)" F "%%" "" "document" +\Format pdf3 pdf "PDF (dvipdfm)" m "%%" "" "document"''' ]) # checkProg('a DVI previewer', ['xdvi', 'kdvi'], - rc_entry = [ r'\Format dvi dvi DVI D "%%" ""' ]) + rc_entry = [ r'\Format dvi dvi DVI D "%%" "" "document"' ]) # checkProg('a HTML previewer', ['mozilla file://$$p$$i', 'netscape'], - rc_entry = [ r'\Format html html HTML H "%%" ""' ]) + rc_entry = [ r'\Format html html HTML H "%%" "" "document"' ]) # # entried that do not need checkProg - addToRC(r'''\Format date "" "date command" "" "" "" -\Format fax "" Fax "" "" "" -\Format lyx lyx LyX "" "" "" -\Format lyx13x lyx13 "LyX 1.3.x" "" "" "" -\Format lyxpreview lyxpreview "LyX Preview" "" "" "" -\Format pdftex pdftex_t PDFTEX "" "" "" -\Format program "" Program "" "" "" -\Format pstex pstex_t PSTEX "" "" "" -\Format sxw sxw "OpenOffice.Org Writer" O "" "" -\Format word doc "MS Word" W "" "" -\Format wordhtml html "MS Word (HTML)" "" "" "" + addToRC(r'''\Format date "" "date command" "" "" "" "" +\Format fax "" Fax "" "" "" "document" +\Format lyx lyx LyX "" "" "" "" +\Format lyx13x lyx13 "LyX 1.3.x" "" "" "" "document" +\Format lyxpreview lyxpreview "LyX Preview" "" "" "" "" +\Format pdftex pdftex_t PDFTEX "" "" "" "" +\Format program "" Program "" "" "" "" +\Format pstex pstex_t PSTEX "" "" "" "" +\Format sxw sxw "OpenOffice.Org Writer" O "" "" "document" +\Format word doc "MS Word" W "" "" "document" +\Format wordhtml html "MS Word (HTML)" "" "" "" "document" ''') diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index 88668dcd16..c674197fd4 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -1,4 +1,4 @@ -#LyX 1.4.0svn created this file. For more info see http://www.lyx.org/ +#LyX 1.5.0svn created this file. For more info see http://www.lyx.org/ \lyxformat 245 \begin_document \begin_header @@ -1846,6 +1846,45 @@ For example, the file may reference other files with relative filenames, directory and may modify it in the process. \end_layout +\begin_layout Standard +With the checkbox +\family sans +Document Format +\family default + you can choose whether the format is a document format or not. + The difference between document and non--document formats is that you can + export your LyX document only to document formats. + Non--document formats are used for included graphics. + Examples for document formats are +\family typewriter +dvi +\family default + or +\family typewriter +ps. + +\family default +Examples for non--document formats are +\family typewriter +png +\family default + or +\family typewriter +jpeg +\family default +. + Some formats like +\family typewriter +pdf +\family default + are both document formats and non--document formats. + The checkbox +\family sans +Document Format +\family default + should be checked for these formats. +\end_layout + \begin_layout Section BibTeX and makeindex \end_layout @@ -2902,6 +2941,7 @@ status inlined \begin_layout Standard + \backslash begin{sloppypar} \end_layout @@ -3047,6 +3087,7 @@ status inlined \begin_layout Standard + \backslash end{sloppypar} \end_layout @@ -3474,6 +3515,7 @@ status inlined \begin_layout Standard + \backslash b o \end_layout @@ -3498,6 +3540,7 @@ status inlined \begin_layout Standard + \backslash d o \end_layout @@ -3530,6 +3573,7 @@ status inlined \begin_layout Standard + \backslash t o \end_layout @@ -3549,6 +3593,7 @@ status inlined \begin_layout Standard + \backslash u o \end_layout @@ -3591,6 +3636,7 @@ status inlined \begin_layout Standard + \backslash .s \end_layout @@ -5507,6 +5553,7 @@ status inlined \begin_layout Standard + \backslash begin{sloppypar} \end_layout @@ -5998,6 +6045,7 @@ status inlined \begin_layout Standard + \backslash end{sloppypar} \end_layout @@ -6148,6 +6196,7 @@ status inlined \begin_layout Standard + \backslash begin{sloppypar} \end_layout @@ -7442,6 +7491,7 @@ status inlined \begin_layout Standard + \backslash end{sloppypar} \end_layout diff --git a/src/MenuBackend.C b/src/MenuBackend.C index 3c334aadf1..13c2e18f79 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -504,23 +504,22 @@ void expandFormats(MenuItem::Kind kind, Menu & tomenu, LyXView const * view) if ((*fit)->dummy()) continue; string label = (*fit)->prettyname(); - // we need to hide the default graphic export formats - // from the external menu, because we need them only - // for the internal lyx-view and external latex run - if (label == "EPS" || label == "XPM" || label == "PNG") - continue; - if (kind == MenuItem::ImportFormats) { + switch (kind) { + case MenuItem::ImportFormats: if ((*fit)->name() == "text") label = _("Plain Text as Lines"); else if ((*fit)->name() == "textparagraph") label = _("Plain Text as Paragraphs"); label += "..."; - } else if (kind == MenuItem::ExportFormats) { - // exporting to LyX does not make sense - // FIXME: Introduce noexport flag - if ((*fit)->name() == "lyx") + break; + case MenuItem::ViewFormats: + case MenuItem::ExportFormats: + if (!(*fit)->documentFormat()) continue; + break; + case MenuItem::UpdateFormats: + break; } if (!(*fit)->shortcut().empty()) label += '|' + (*fit)->shortcut(); diff --git a/src/format.C b/src/format.C index e51358df6d..3cb3926f78 100644 --- a/src/format.C +++ b/src/format.C @@ -92,9 +92,12 @@ bool operator<(Format const & a, Format const & b) return compare_ascii_no_case(a.prettyname(), b.prettyname()) < 0; } + Format::Format(string const & n, string const & e, string const & p, - string const & s, string const & v, string const & ed) - : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), editor_(ed) + string const & s, string const & v, string const & ed, + bool d) + : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), + editor_(ed), document_(d) {} @@ -208,22 +211,24 @@ int Formats::getNumber(string const & name) const void Formats::add(string const & name) { if (!getFormat(name)) - add(name, name, name, string(), string(), string()); + add(name, name, name, string(), string(), string(), true); } void Formats::add(string const & name, string const & extension, string const & prettyname, string const & shortcut, - string const & viewer, string const & editor) + string const & viewer, string const & editor, bool document) { FormatList::iterator it = find_if(formatlist.begin(), formatlist.end(), FormatNamesEqual(name)); if (it == formatlist.end()) formatlist.push_back(Format(name, extension, prettyname, - shortcut, viewer, editor)); + shortcut, viewer, editor, + document)); else - *it = Format(name, extension, prettyname, shortcut, viewer, editor); + *it = Format(name, extension, prettyname, shortcut, viewer, + editor, document); } diff --git a/src/format.h b/src/format.h index 85ad850de2..1b025a60e8 100644 --- a/src/format.h +++ b/src/format.h @@ -21,12 +21,14 @@ class Format { public: /// Format(std::string const & n, std::string const & e, std::string const & p, - std::string const & s, std::string const & v, std::string const & ed); + std::string const & s, std::string const & v, std::string const & ed, + bool ex); /// bool dummy() const; - /// + /// Tell whether this format is a child format. + /// Child formats inherit settings like the viewer from their parent. bool isChildFormat() const; - /// + /// Name fo the parent format std::string const parentFormat() const; /// std::string const & name() const { @@ -60,18 +62,32 @@ public: void setEditor(std::string const & v) { editor_ = v; } + /// + bool documentFormat() const { + return document_; + } private: + /// Internal name. Needs to be unique. std::string name_; - /// + /// Filename extension std::string extension_; - /// + /// Name presented to the user. Needs to be unique. std::string prettyname_; - /// + /// Keyboard shortcut for the View and Export menu. std::string shortcut_; - /// + /*! + * Viewer for this format. Needs to be in the PATH or an absolute + * filename. + * This format cannot be viewed if \c viewer_ is empty. + * If it is \c auto the default viewer of the OS for this format is + * used. + */ std::string viewer_; - /// + /// Editor for this format. \sa viewer_. std::string editor_; + /// Is this format a document format? (as opposed to e.g. image formats) + /// Some formats are both (e.g. pdf), they have this flag set. + bool document_; }; @@ -106,8 +122,9 @@ public: void add(std::string const & name); /// void add(std::string const & name, std::string const & extension, - std::string const & prettyname, std::string const & shortcut, - std::string const & viewer, std::string const & editor); + std::string const & prettyname, std::string const & shortcut, + std::string const & viewer, std::string const & editor, + bool document); /// void erase(std::string const & name); /// diff --git a/src/frontends/qt3/QPrefsDialog.C b/src/frontends/qt3/QPrefsDialog.C index 5393eb8a5f..f17dfb3f05 100644 --- a/src/frontends/qt3/QPrefsDialog.C +++ b/src/frontends/qt3/QPrefsDialog.C @@ -187,6 +187,7 @@ QPrefsDialog::QPrefsDialog(QPrefs * form) connect(fileformatsModule->extensionED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); connect(fileformatsModule->viewerED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); connect(fileformatsModule->editorED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); + connect(fileformatsModule->documentCB, SIGNAL(toggled(bool)), this, SLOT(fileformat_changed())); connect(convertersModule->converterNewPB, SIGNAL(clicked()), this, SLOT(new_converter())); connect(convertersModule->converterRemovePB, SIGNAL(clicked()), this, SLOT(remove_converter())); @@ -729,6 +730,7 @@ void QPrefsDialog::switch_format(int nr) fileformatsModule->shortcutED->setText(toqstr(f.shortcut())); fileformatsModule->viewerED->setText(toqstr(f.viewer())); fileformatsModule->editorED->setText(toqstr(f.editor())); + fileformatsModule->documentCB->setChecked(f.documentFormat()); fileformatsModule->formatRemovePB->setEnabled( !form_->converters().formatIsUsed(f.name())); @@ -770,16 +772,18 @@ void QPrefsDialog::updateFormatsButtons() string const old_extension(f.extension()); string const old_viewer(f.viewer()); string const old_editor(f.editor()); + bool const old_document(f.documentFormat()); string const new_pretty(fromqstr(gui_name)); string const new_shortcut(fromqstr(fileformatsModule->shortcutED->text())); string const new_extension(fromqstr(fileformatsModule->extensionED->text())); string const new_viewer(fromqstr(fileformatsModule->viewerED->text())); string const new_editor(fromqstr(fileformatsModule->editorED->text())); + bool const new_document(fileformatsModule->documentCB->isChecked()); bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut) || (old_extension != new_extension) || (old_viewer != new_viewer) - || (old_editor != new_editor)); + || (old_editor != new_editor)) || old_document != new_document; fileformatsModule->formatModifyPB->setEnabled( valid && known && modified && !known_otherwise); @@ -796,8 +800,10 @@ void QPrefsDialog::new_format() string const shortcut = fromqstr(fileformatsModule->shortcutED->text()); string const viewer = fromqstr(fileformatsModule->viewerED->text()); string const editor = fromqstr(fileformatsModule->editorED->text()); + bool const document = fileformatsModule->documentCB->isChecked(); - form_->formats().add(name, extension, prettyname, shortcut, viewer, editor); + form_->formats().add(name, extension, prettyname, shortcut, viewer, + editor, document); form_->formats().sort(); updateFormats(); fileformatsModule->formatsLB->setCurrentItem(form_->formats().getNumber(name)); @@ -825,8 +831,10 @@ void QPrefsDialog::modify_format() string const shortcut = fromqstr(fileformatsModule->shortcutED->text()); string const viewer = fromqstr(fileformatsModule->viewerED->text()); string const editor = fromqstr(fileformatsModule->editorED->text()); + bool const document = fileformatsModule->documentCB->isChecked(); - form_->formats().add(name, extension, prettyname, shortcut, viewer, editor); + form_->formats().add(name, extension, prettyname, shortcut, viewer, + editor, document); form_->formats().sort(); fileformatsModule->formatsLB->setUpdatesEnabled(false); diff --git a/src/frontends/qt3/ui/QPrefFileformatsModule.ui b/src/frontends/qt3/ui/QPrefFileformatsModule.ui index a812962ffd..3e3216be8e 100644 --- a/src/frontends/qt3/ui/QPrefFileformatsModule.ui +++ b/src/frontends/qt3/ui/QPrefFileformatsModule.ui @@ -9,7 +9,7 @@ 0 0 419 - 261 + 286 @@ -49,6 +49,20 @@ editorED + + + documentCB + + + &Document format + + + Alt+D + + + Tell whether this format is a document format. A document can not be exported to or viewed in a non-document format. + + shortcutED @@ -324,6 +338,7 @@ extensionED viewerED editorED + documentCB config.h diff --git a/src/frontends/qt4/QPrefsDialog.C b/src/frontends/qt4/QPrefsDialog.C index dbba8dce80..01bb4ad5f6 100644 --- a/src/frontends/qt4/QPrefsDialog.C +++ b/src/frontends/qt4/QPrefsDialog.C @@ -1291,6 +1291,7 @@ PrefFileformats::PrefFileformats(QPrefs * form, QWidget * parent) connect(extensionED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); connect(viewerED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); connect(editorED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); + connect(documentCB, SIGNAL(toggled(bool)), this, SLOT(fileformat_changed())); connect(formatNewPB, SIGNAL(clicked()), this, SIGNAL(changed())); connect(formatRemovePB, SIGNAL(clicked()), @@ -1353,6 +1354,7 @@ void PrefFileformats::switch_format(int nr) shortcutED->setText(toqstr(f.shortcut())); viewerED->setText(toqstr(f.viewer())); editorED->setText(toqstr(f.editor())); + documentCB->setChecked((f.documentFormat())); formatRemovePB->setEnabled( !form_->converters().formatIsUsed(f.name())); @@ -1394,16 +1396,18 @@ void PrefFileformats::updateButtons() string const old_extension(f.extension()); string const old_viewer(f.viewer()); string const old_editor(f.editor()); + bool const old_document(f.documentFormat()); string const new_pretty(fromqstr(gui_name)); string const new_shortcut(fromqstr(shortcutED->text())); string const new_extension(fromqstr(extensionED->text())); string const new_viewer(fromqstr(viewerED->text())); string const new_editor(fromqstr(editorED->text())); + bool const new_document(documentCB->isChecked()); bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut) || (old_extension != new_extension) || (old_viewer != new_viewer) - || (old_editor != new_editor)); + || (old_editor != new_editor) || old_document != new_document); formatModifyPB->setEnabled( valid && known && modified && !known_otherwise); @@ -1424,8 +1428,10 @@ void PrefFileformats::new_format() string const shortcut = fromqstr(shortcutED->text()); string const viewer = fromqstr(viewerED->text()); string const editor = fromqstr(editorED->text()); + bool const document = documentCB->isChecked(); - form_->formats().add(name, extension, prettyname, shortcut, viewer, editor); + form_->formats().add(name, extension, prettyname, shortcut, viewer, + editor, document); form_->formats().sort(); update(); @@ -1457,8 +1463,10 @@ void PrefFileformats::modify_format() string const shortcut = fromqstr(shortcutED->text()); string const viewer = fromqstr(viewerED->text()); string const editor = fromqstr(editorED->text()); + bool const document = documentCB->isChecked(); - form_->formats().add(name, extension, prettyname, shortcut, viewer, editor); + form_->formats().add(name, extension, prettyname, shortcut, viewer, + editor, document); form_->formats().sort(); formatsLW->setUpdatesEnabled(false); diff --git a/src/frontends/qt4/ui/QPrefFileformatsUi.ui b/src/frontends/qt4/ui/QPrefFileformatsUi.ui index df44ed9814..5781a1d3a0 100644 --- a/src/frontends/qt4/ui/QPrefFileformatsUi.ui +++ b/src/frontends/qt4/ui/QPrefFileformatsUi.ui @@ -167,6 +167,19 @@ + + + + true + + + Tell whether this format is a document format. A document can not be exported to or viewed in a non-document format. + + + &Document format + + + @@ -227,6 +240,7 @@ extensionED viewerED editorED + documentCB diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 3cc85e5050..14f0c4b0a7 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -1313,6 +1313,7 @@ void FormPreferences::Formats::build() setPrehandler(dialog_->input_viewer); setPrehandler(dialog_->input_editor); setPrehandler(dialog_->input_shrtcut); + setPrehandler(dialog_->check_document); } @@ -1345,6 +1346,10 @@ FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const return _("Remove the current format from the list of available " "formats. Note: you must then \"Apply\" the change."); + if (ob == dialog_->check_document) + return _("Tell whether this format is a document format. " + "A document can not be exported to or viewed in a non-document format."); + if (ob == dialog_->button_add) { if (string(ob->label) == _("Add")) return _("Add the current format to the list of available " @@ -1368,7 +1373,8 @@ bool FormPreferences::Formats::input(FL_OBJECT const * const ob) || ob == dialog_->input_shrtcut || ob == dialog_->input_extension || ob == dialog_->input_viewer - || ob == dialog_->input_editor) + || ob == dialog_->input_editor + || ob == dialog_->check_document) return Input(); if (ob == dialog_->button_add) @@ -1416,10 +1422,12 @@ bool FormPreferences::Formats::Add() string const shortcut = getString(dialog_->input_shrtcut); string const viewer = getString(dialog_->input_viewer); string const editor = getString(dialog_->input_editor); + bool const document = fl_get_button(dialog_->check_document); Format const * old = formats().getFormat(name); string const old_prettyname = old ? old->prettyname() : string(); - formats().add(name, extension, prettyname, shortcut, viewer, editor); + formats().add(name, extension, prettyname, shortcut, viewer, editor, + document); if (!old || prettyname != old_prettyname) { UpdateBrowser(); if (old) @@ -1447,6 +1455,7 @@ bool FormPreferences::Formats::Browser() fl_set_input(dialog_->input_extension, f.extension().c_str()); fl_set_input(dialog_->input_viewer, f.viewer().c_str()); fl_set_input(dialog_->input_editor, f.editor().c_str()); + fl_set_button(dialog_->check_document, f.documentFormat()); fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str()); diff --git a/src/frontends/xforms/forms/form_preferences.fd b/src/frontends/xforms/forms/form_preferences.fd index 21a48de2dc..2a29ce3aab 100644 --- a/src/frontends/xforms/forms/form_preferences.fd +++ b/src/frontends/xforms/forms/form_preferences.fd @@ -1704,8 +1704,8 @@ argument: =============== FORM =============== Name: form_preferences_formats Width: 450 -Height: 400 -Number of Objects: 10 +Height: 440 +Number of Objects: 11 -------------------- class: FL_BOX @@ -1851,10 +1851,28 @@ name: input_editor callback: C_FormDialogView_InputCB argument: 0 +-------------------- +class: FL_CHECKBUTTON +type: PUSH_BUTTON +box: 200 270 150 30 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Document format|#D +shortcut: +resize: FL_RESIZE_NONE +gravity: FL_West FL_West +name: check_document +callback: C_FormDialogView_InputCB +argument: 0 + -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 240 300 90 30 +box: 240 340 90 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -1872,7 +1890,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 340 300 90 30 +box: 340 340 90 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER diff --git a/src/lyxrc.C b/src/lyxrc.C index 4263802a9a..3b7a3d408a 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -48,6 +48,7 @@ using lyx::support::expandPath; using lyx::support::getEnv; using lyx::support::libFileSearch; using lyx::support::token; +using lyx::support::tokenPos; using std::cout; using std::endl; @@ -1086,24 +1087,35 @@ int LyXRC::read(LyXLex & lexrc) shortcut = lexrc.getString(); } string viewer, editor; + if (lexrc.next()) + viewer = lexrc.getString(); + if (lexrc.next()) + editor = lexrc.getString(); + // The only supported flag for now is "document". + // More flags could be added in the future. + // Therefore we use tokenPos below to read the flag. + string flags; // Hack to ensure compatibility with versions older - // than 1.4.0 + // than 1.5.0 int le = lexrc.lex(); if (le != LyXLex::LEX_FEOF && le != LyXLex::LEX_UNDEF) { - viewer = lexrc.getString(); - if (le == LyXLex::LEX_DATA) { - if (lexrc.next()) { - editor = lexrc.getString(); - } - } else { + flags = lexrc.getString(); + if (le != LyXLex::LEX_DATA) { // We have got a known token. // Therefore this is an old style // format definition without - // viewer and editor. - lexrc.pushToken(viewer); - viewer.erase(); + // flags. + lexrc.pushToken(flags); + flags.erase(); } } + bool const document = + (tokenPos(flags, ',', "document") >= 0); + if (!flags.empty() && flags != "document") + lyxerr << "Ignoring flags other than " + "`document' in `" << flags + << "' for format `" << format << "'." + << endl; if (prettyname.empty()) { if (converters.formatIsUsed(format)) { lyxerr << "Can't delete format " @@ -1113,7 +1125,7 @@ int LyXRC::read(LyXLex & lexrc) } } else { formats.add(format, extension, prettyname, - shortcut, viewer, editor); + shortcut, viewer, editor, document); } break; } @@ -2007,7 +2019,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const << "#\n\n"; case RC_FORMAT: - // New/modifed formats + // New/modified formats for (Formats::const_iterator cit = formats.begin(); cit != formats.end(); ++cit) { Format const * format = @@ -2017,13 +2029,18 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const format->prettyname() != cit->prettyname() || format->shortcut() != cit->shortcut() || format->viewer() != cit->viewer() || - format->editor() != cit->editor()) + format->editor() != cit->editor() || + format->documentFormat() != cit->documentFormat()) { os << "\\format \"" << cit->name() << "\" \"" << cit->extension() << "\" \"" << cit->prettyname() << "\" \"" << cit->shortcut() << "\" \"" << cit->viewer() << "\" \"" - << cit->editor() << "\"\n"; + << cit->editor() << "\" \""; + if (cit->documentFormat()) + os << "document"; + os << "\"\n"; + } } // Look for deleted formats @@ -2031,7 +2048,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const cit != system_formats.end(); ++cit) if (!formats.getFormat(cit->name())) os << "\\format \"" << cit->name() - << "\" \"\" \"\" \"\" \"\" \"\"\n"; + << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n"; case RC_VIEWER: // Ignore it -- 2.39.2