* 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
This commit is contained in:
Georg Baum 2006-05-20 12:03:40 +00:00
parent f8918b0859
commit 5b83287abe
12 changed files with 259 additions and 99 deletions

View File

@ -194,76 +194,76 @@ def checkLatex():
def checkFormatEntries(): def checkFormatEntries():
''' Check all formats (\Format entries) ''' ''' Check all formats (\Format entries) '''
checkProg('a Tgif viewer and editor', ['tgif'], 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'], 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'], 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'], 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, iv = checkProg('a raster image viewer', ['xv', 'kview', 'gimp'])
path, ie = checkProg('a raster image editor', ['gimp']) path, ie = checkProg('a raster image editor', ['gimp'])
addToRC(r'''\Format bmp bmp BMP "" "%s" "%s" addToRC(r'''\Format bmp bmp BMP "" "%s" "%s" ""
\Format gif gif GIF "" "%s" "%s" \Format gif gif GIF "" "%s" "%s" ""
\Format jpg jpg JPEG "" "%s" "%s" \Format jpg jpg JPEG "" "%s" "%s" ""
\Format pbm pbm PBM "" "%s" "%s" \Format pbm pbm PBM "" "%s" "%s" ""
\Format pgm pgm PGM "" "%s" "%s" \Format pgm pgm PGM "" "%s" "%s" ""
\Format png png PNG "" "%s" "%s" \Format png png PNG "" "%s" "%s" ""
\Format ppm ppm PPM "" "%s" "%s" \Format ppm ppm PPM "" "%s" "%s" ""
\Format tiff tif TIFF "" "%s" "%s" \Format tiff tif TIFF "" "%s" "%s" ""
\Format xbm xbm XBM "" "%s" "%s" \Format xbm xbm XBM "" "%s" "%s" ""
\Format xpm xpm XPM "" "%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) ) (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', \ checkProg('a text editor', ['xemacs', 'gvim', 'kedit', 'kwrite', 'kate', \
'nedit', 'gedit', 'notepad'], 'nedit', 'gedit', 'notepad'],
rc_entry = [ r'''\Format asciichess asc "Plain text (chess output)" "" "" "%%" rc_entry = [ r'''\Format asciichess asc "Plain text (chess output)" "" "" "%%" ""
\Format asciiimage asc "Plain text (image)" "" "" "%%" \Format asciiimage asc "Plain text (image)" "" "" "%%" ""
\Format asciixfig asc "Plain text (Xfig output)" "" "" "%%" \Format asciixfig asc "Plain text (Xfig output)" "" "" "%%" ""
\Format dateout tmp "date (output)" "" "" "%%" \Format dateout tmp "date (output)" "" "" "%%" ""
\Format docbook sgml DocBook B "" "%%" \Format docbook sgml DocBook B "" "%%" "document"
\Format docbook-xml xml "Docbook (XML)" "" "" "%%" \Format docbook-xml xml "Docbook (XML)" "" "" "%%" "document"
\Format literate nw NoWeb N "" "%%" \Format literate nw NoWeb N "" "%%" "document"
\Format latex tex "LaTeX (plain)" L "" "%%" \Format latex tex "LaTeX (plain)" L "" "%%" "document"
\Format linuxdoc sgml LinuxDoc x "" "%%" \Format linuxdoc sgml LinuxDoc x "" "%%" "document"
\Format pdflatex tex "LaTeX (pdflatex)" "" "" "%%" \Format pdflatex tex "LaTeX (pdflatex)" "" "" "%%" "document"
\Format text txt "Plain text" a "" "%%" \Format text txt "Plain text" a "" "%%" "document"
\Format textparagraph txt "Plain text (paragraphs)" "" "" "%%"''' ]) \Format textparagraph txt "Plain text (paragraphs)" "" "" "%%" "document"''' ])
# #
#checkProg('a Postscript interpreter', ['gs'], #checkProg('a Postscript interpreter', ['gs'],
# rc_entry = [ r'\ps_command "%%"' ]) # rc_entry = [ r'\ps_command "%%"' ])
checkProg('a Postscript previewer', ['gv', 'ghostview -swap', 'kghostview'], checkProg('a Postscript previewer', ['gv', 'ghostview -swap', 'kghostview'],
rc_entry = [ r'''\Format eps eps EPS "" "%%" "" rc_entry = [ r'''\Format eps eps EPS "" "%%" "" ""
\Format ps ps Postscript t "%%" ""''' ]) \Format ps ps Postscript t "%%" "" "document"''' ])
# #
checkProg('a PDF previewer', ['acrobat', 'acroread', 'gv', 'ghostview', \ checkProg('a PDF previewer', ['acrobat', 'acroread', 'gv', 'ghostview', \
'xpdf', 'kpdf', 'kghostview'], 'xpdf', 'kpdf', 'kghostview'],
rc_entry = [ r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" rc_entry = [ r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" "document"
\Format pdf2 pdf "PDF (pdflatex)" F "%%" "" \Format pdf2 pdf "PDF (pdflatex)" F "%%" "" "document"
\Format pdf3 pdf "PDF (dvipdfm)" m "%%" ""''' ]) \Format pdf3 pdf "PDF (dvipdfm)" m "%%" "" "document"''' ])
# #
checkProg('a DVI previewer', ['xdvi', 'kdvi'], 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'], 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 # entried that do not need checkProg
addToRC(r'''\Format date "" "date command" "" "" "" addToRC(r'''\Format date "" "date command" "" "" "" ""
\Format fax "" Fax "" "" "" \Format fax "" Fax "" "" "" "document"
\Format lyx lyx LyX "" "" "" \Format lyx lyx LyX "" "" "" ""
\Format lyx13x lyx13 "LyX 1.3.x" "" "" "" \Format lyx13x lyx13 "LyX 1.3.x" "" "" "" "document"
\Format lyxpreview lyxpreview "LyX Preview" "" "" "" \Format lyxpreview lyxpreview "LyX Preview" "" "" "" ""
\Format pdftex pdftex_t PDFTEX "" "" "" \Format pdftex pdftex_t PDFTEX "" "" "" ""
\Format program "" Program "" "" "" \Format program "" Program "" "" "" ""
\Format pstex pstex_t PSTEX "" "" "" \Format pstex pstex_t PSTEX "" "" "" ""
\Format sxw sxw "OpenOffice.Org Writer" O "" "" \Format sxw sxw "OpenOffice.Org Writer" O "" "" "document"
\Format word doc "MS Word" W "" "" \Format word doc "MS Word" W "" "" "document"
\Format wordhtml html "MS Word (HTML)" "" "" "" \Format wordhtml html "MS Word (HTML)" "" "" "" "document"
''') ''')

View File

@ -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 \lyxformat 245
\begin_document \begin_document
\begin_header \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. directory and may modify it in the process.
\end_layout \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 \begin_layout Section
BibTeX and makeindex BibTeX and makeindex
\end_layout \end_layout
@ -2902,6 +2941,7 @@ status inlined
\begin_layout Standard \begin_layout Standard
\backslash \backslash
begin{sloppypar} begin{sloppypar}
\end_layout \end_layout
@ -3047,6 +3087,7 @@ status inlined
\begin_layout Standard \begin_layout Standard
\backslash \backslash
end{sloppypar} end{sloppypar}
\end_layout \end_layout
@ -3474,6 +3515,7 @@ status inlined
\begin_layout Standard \begin_layout Standard
\backslash \backslash
b o b o
\end_layout \end_layout
@ -3498,6 +3540,7 @@ status inlined
\begin_layout Standard \begin_layout Standard
\backslash \backslash
d o d o
\end_layout \end_layout
@ -3530,6 +3573,7 @@ status inlined
\begin_layout Standard \begin_layout Standard
\backslash \backslash
t o t o
\end_layout \end_layout
@ -3549,6 +3593,7 @@ status inlined
\begin_layout Standard \begin_layout Standard
\backslash \backslash
u o u o
\end_layout \end_layout
@ -3591,6 +3636,7 @@ status inlined
\begin_layout Standard \begin_layout Standard
\backslash \backslash
.s .s
\end_layout \end_layout
@ -5507,6 +5553,7 @@ status inlined
\begin_layout Standard \begin_layout Standard
\backslash \backslash
begin{sloppypar} begin{sloppypar}
\end_layout \end_layout
@ -5998,6 +6045,7 @@ status inlined
\begin_layout Standard \begin_layout Standard
\backslash \backslash
end{sloppypar} end{sloppypar}
\end_layout \end_layout
@ -6148,6 +6196,7 @@ status inlined
\begin_layout Standard \begin_layout Standard
\backslash \backslash
begin{sloppypar} begin{sloppypar}
\end_layout \end_layout
@ -7442,6 +7491,7 @@ status inlined
\begin_layout Standard \begin_layout Standard
\backslash \backslash
end{sloppypar} end{sloppypar}
\end_layout \end_layout

View File

@ -504,23 +504,22 @@ void expandFormats(MenuItem::Kind kind, Menu & tomenu, LyXView const * view)
if ((*fit)->dummy()) if ((*fit)->dummy())
continue; continue;
string label = (*fit)->prettyname(); 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") if ((*fit)->name() == "text")
label = _("Plain Text as Lines"); label = _("Plain Text as Lines");
else if ((*fit)->name() == "textparagraph") else if ((*fit)->name() == "textparagraph")
label = _("Plain Text as Paragraphs"); label = _("Plain Text as Paragraphs");
label += "..."; label += "...";
} else if (kind == MenuItem::ExportFormats) { break;
// exporting to LyX does not make sense case MenuItem::ViewFormats:
// FIXME: Introduce noexport flag case MenuItem::ExportFormats:
if ((*fit)->name() == "lyx") if (!(*fit)->documentFormat())
continue; continue;
break;
case MenuItem::UpdateFormats:
break;
} }
if (!(*fit)->shortcut().empty()) if (!(*fit)->shortcut().empty())
label += '|' + (*fit)->shortcut(); label += '|' + (*fit)->shortcut();

View File

@ -92,9 +92,12 @@ bool operator<(Format const & a, Format const & b)
return compare_ascii_no_case(a.prettyname(), b.prettyname()) < 0; return compare_ascii_no_case(a.prettyname(), b.prettyname()) < 0;
} }
Format::Format(string const & n, string const & e, string const & p, Format::Format(string const & n, string const & e, string const & p,
string const & s, string const & v, string const & ed) string const & s, string const & v, string const & ed,
: name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), editor_(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) void Formats::add(string const & name)
{ {
if (!getFormat(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, void Formats::add(string const & name, string const & extension,
string const & prettyname, string const & shortcut, string const & prettyname, string const & shortcut,
string const & viewer, string const & editor) string const & viewer, string const & editor, bool document)
{ {
FormatList::iterator it = FormatList::iterator it =
find_if(formatlist.begin(), formatlist.end(), find_if(formatlist.begin(), formatlist.end(),
FormatNamesEqual(name)); FormatNamesEqual(name));
if (it == formatlist.end()) if (it == formatlist.end())
formatlist.push_back(Format(name, extension, prettyname, formatlist.push_back(Format(name, extension, prettyname,
shortcut, viewer, editor)); shortcut, viewer, editor,
document));
else else
*it = Format(name, extension, prettyname, shortcut, viewer, editor); *it = Format(name, extension, prettyname, shortcut, viewer,
editor, document);
} }

View File

@ -21,12 +21,14 @@ class Format {
public: public:
/// ///
Format(std::string const & n, std::string const & e, std::string const & p, 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; bool dummy() const;
/// /// Tell whether this format is a child format.
/// Child formats inherit settings like the viewer from their parent.
bool isChildFormat() const; bool isChildFormat() const;
/// /// Name fo the parent format
std::string const parentFormat() const; std::string const parentFormat() const;
/// ///
std::string const & name() const { std::string const & name() const {
@ -60,18 +62,32 @@ public:
void setEditor(std::string const & v) { void setEditor(std::string const & v) {
editor_ = v; editor_ = v;
} }
///
bool documentFormat() const {
return document_;
}
private: private:
/// Internal name. Needs to be unique.
std::string name_; std::string name_;
/// /// Filename extension
std::string extension_; std::string extension_;
/// /// Name presented to the user. Needs to be unique.
std::string prettyname_; std::string prettyname_;
/// /// Keyboard shortcut for the View and Export menu.
std::string shortcut_; 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_; std::string viewer_;
/// /// Editor for this format. \sa viewer_.
std::string editor_; 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_;
}; };
@ -107,7 +123,8 @@ public:
/// ///
void add(std::string const & name, std::string const & extension, void add(std::string const & name, std::string const & extension,
std::string const & prettyname, std::string const & shortcut, std::string const & prettyname, std::string const & shortcut,
std::string const & viewer, std::string const & editor); std::string const & viewer, std::string const & editor,
bool document);
/// ///
void erase(std::string const & name); void erase(std::string const & name);
/// ///

View File

@ -187,6 +187,7 @@ QPrefsDialog::QPrefsDialog(QPrefs * form)
connect(fileformatsModule->extensionED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); connect(fileformatsModule->extensionED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
connect(fileformatsModule->viewerED, 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->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->converterNewPB, SIGNAL(clicked()), this, SLOT(new_converter()));
connect(convertersModule->converterRemovePB, SIGNAL(clicked()), this, SLOT(remove_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->shortcutED->setText(toqstr(f.shortcut()));
fileformatsModule->viewerED->setText(toqstr(f.viewer())); fileformatsModule->viewerED->setText(toqstr(f.viewer()));
fileformatsModule->editorED->setText(toqstr(f.editor())); fileformatsModule->editorED->setText(toqstr(f.editor()));
fileformatsModule->documentCB->setChecked(f.documentFormat());
fileformatsModule->formatRemovePB->setEnabled( fileformatsModule->formatRemovePB->setEnabled(
!form_->converters().formatIsUsed(f.name())); !form_->converters().formatIsUsed(f.name()));
@ -770,16 +772,18 @@ void QPrefsDialog::updateFormatsButtons()
string const old_extension(f.extension()); string const old_extension(f.extension());
string const old_viewer(f.viewer()); string const old_viewer(f.viewer());
string const old_editor(f.editor()); string const old_editor(f.editor());
bool const old_document(f.documentFormat());
string const new_pretty(fromqstr(gui_name)); string const new_pretty(fromqstr(gui_name));
string const new_shortcut(fromqstr(fileformatsModule->shortcutED->text())); string const new_shortcut(fromqstr(fileformatsModule->shortcutED->text()));
string const new_extension(fromqstr(fileformatsModule->extensionED->text())); string const new_extension(fromqstr(fileformatsModule->extensionED->text()));
string const new_viewer(fromqstr(fileformatsModule->viewerED->text())); string const new_viewer(fromqstr(fileformatsModule->viewerED->text()));
string const new_editor(fromqstr(fileformatsModule->editorED->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) bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut)
|| (old_extension != new_extension) || (old_viewer != new_viewer) || (old_extension != new_extension) || (old_viewer != new_viewer)
|| (old_editor != new_editor)); || (old_editor != new_editor)) || old_document != new_document;
fileformatsModule->formatModifyPB->setEnabled( fileformatsModule->formatModifyPB->setEnabled(
valid && known && modified && !known_otherwise); valid && known && modified && !known_otherwise);
@ -796,8 +800,10 @@ void QPrefsDialog::new_format()
string const shortcut = fromqstr(fileformatsModule->shortcutED->text()); string const shortcut = fromqstr(fileformatsModule->shortcutED->text());
string const viewer = fromqstr(fileformatsModule->viewerED->text()); string const viewer = fromqstr(fileformatsModule->viewerED->text());
string const editor = fromqstr(fileformatsModule->editorED->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(); form_->formats().sort();
updateFormats(); updateFormats();
fileformatsModule->formatsLB->setCurrentItem(form_->formats().getNumber(name)); fileformatsModule->formatsLB->setCurrentItem(form_->formats().getNumber(name));
@ -825,8 +831,10 @@ void QPrefsDialog::modify_format()
string const shortcut = fromqstr(fileformatsModule->shortcutED->text()); string const shortcut = fromqstr(fileformatsModule->shortcutED->text());
string const viewer = fromqstr(fileformatsModule->viewerED->text()); string const viewer = fromqstr(fileformatsModule->viewerED->text());
string const editor = fromqstr(fileformatsModule->editorED->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(); form_->formats().sort();
fileformatsModule->formatsLB->setUpdatesEnabled(false); fileformatsModule->formatsLB->setUpdatesEnabled(false);

View File

@ -9,7 +9,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>419</width> <width>419</width>
<height>261</height> <height>286</height>
</rect> </rect>
</property> </property>
<property name="caption"> <property name="caption">
@ -49,6 +49,20 @@
<cstring>editorED</cstring> <cstring>editorED</cstring>
</property> </property>
</widget> </widget>
<widget class="QCheckBox" row="6" column="1">
<property name="name">
<cstring>documentCB</cstring>
</property>
<property name="text">
<string>&amp;Document format</string>
</property>
<property name="accel">
<string>Alt+D</string>
</property>
<property name="toolTip" stdset="0">
<string>Tell whether this format is a document format. A document can not be exported to or viewed in a non-document format.</string>
</property>
</widget>
<widget class="QLineEdit" row="2" column="1"> <widget class="QLineEdit" row="2" column="1">
<property name="name"> <property name="name">
<cstring>shortcutED</cstring> <cstring>shortcutED</cstring>
@ -324,6 +338,7 @@
<tabstop>extensionED</tabstop> <tabstop>extensionED</tabstop>
<tabstop>viewerED</tabstop> <tabstop>viewerED</tabstop>
<tabstop>editorED</tabstop> <tabstop>editorED</tabstop>
<tabstop>documentCB</tabstop>
</tabstops> </tabstops>
<includes> <includes>
<include location="global" impldecl="in implementation">config.h</include> <include location="global" impldecl="in implementation">config.h</include>

View File

@ -1291,6 +1291,7 @@ PrefFileformats::PrefFileformats(QPrefs * form, QWidget * parent)
connect(extensionED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); connect(extensionED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
connect(viewerED, 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(editorED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
connect(documentCB, SIGNAL(toggled(bool)), this, SLOT(fileformat_changed()));
connect(formatNewPB, SIGNAL(clicked()), connect(formatNewPB, SIGNAL(clicked()),
this, SIGNAL(changed())); this, SIGNAL(changed()));
connect(formatRemovePB, SIGNAL(clicked()), connect(formatRemovePB, SIGNAL(clicked()),
@ -1353,6 +1354,7 @@ void PrefFileformats::switch_format(int nr)
shortcutED->setText(toqstr(f.shortcut())); shortcutED->setText(toqstr(f.shortcut()));
viewerED->setText(toqstr(f.viewer())); viewerED->setText(toqstr(f.viewer()));
editorED->setText(toqstr(f.editor())); editorED->setText(toqstr(f.editor()));
documentCB->setChecked((f.documentFormat()));
formatRemovePB->setEnabled( formatRemovePB->setEnabled(
!form_->converters().formatIsUsed(f.name())); !form_->converters().formatIsUsed(f.name()));
@ -1394,16 +1396,18 @@ void PrefFileformats::updateButtons()
string const old_extension(f.extension()); string const old_extension(f.extension());
string const old_viewer(f.viewer()); string const old_viewer(f.viewer());
string const old_editor(f.editor()); string const old_editor(f.editor());
bool const old_document(f.documentFormat());
string const new_pretty(fromqstr(gui_name)); string const new_pretty(fromqstr(gui_name));
string const new_shortcut(fromqstr(shortcutED->text())); string const new_shortcut(fromqstr(shortcutED->text()));
string const new_extension(fromqstr(extensionED->text())); string const new_extension(fromqstr(extensionED->text()));
string const new_viewer(fromqstr(viewerED->text())); string const new_viewer(fromqstr(viewerED->text()));
string const new_editor(fromqstr(editorED->text())); string const new_editor(fromqstr(editorED->text()));
bool const new_document(documentCB->isChecked());
bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut) bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut)
|| (old_extension != new_extension) || (old_viewer != new_viewer) || (old_extension != new_extension) || (old_viewer != new_viewer)
|| (old_editor != new_editor)); || (old_editor != new_editor) || old_document != new_document);
formatModifyPB->setEnabled( formatModifyPB->setEnabled(
valid && known && modified && !known_otherwise); valid && known && modified && !known_otherwise);
@ -1424,8 +1428,10 @@ void PrefFileformats::new_format()
string const shortcut = fromqstr(shortcutED->text()); string const shortcut = fromqstr(shortcutED->text());
string const viewer = fromqstr(viewerED->text()); string const viewer = fromqstr(viewerED->text());
string const editor = fromqstr(editorED->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(); form_->formats().sort();
update(); update();
@ -1457,8 +1463,10 @@ void PrefFileformats::modify_format()
string const shortcut = fromqstr(shortcutED->text()); string const shortcut = fromqstr(shortcutED->text());
string const viewer = fromqstr(viewerED->text()); string const viewer = fromqstr(viewerED->text());
string const editor = fromqstr(editorED->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(); form_->formats().sort();
formatsLW->setUpdatesEnabled(false); formatsLW->setUpdatesEnabled(false);

View File

@ -167,6 +167,19 @@
<item row="3" column="1" > <item row="3" column="1" >
<widget class="QLineEdit" name="extensionED" /> <widget class="QLineEdit" name="extensionED" />
</item> </item>
<item row="6" column="0" >
<widget class="QCheckBox" name="documentCB" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="toolTip" >
<string>Tell whether this format is a document format. A document can not be exported to or viewed in a non-document format.</string>
</property>
<property name="text" >
<string>&amp;Document format</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="4" column="0" > <item row="4" column="0" >
@ -227,6 +240,7 @@
<tabstop>extensionED</tabstop> <tabstop>extensionED</tabstop>
<tabstop>viewerED</tabstop> <tabstop>viewerED</tabstop>
<tabstop>editorED</tabstop> <tabstop>editorED</tabstop>
<tabstop>documentCB</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -1313,6 +1313,7 @@ void FormPreferences::Formats::build()
setPrehandler(dialog_->input_viewer); setPrehandler(dialog_->input_viewer);
setPrehandler(dialog_->input_editor); setPrehandler(dialog_->input_editor);
setPrehandler(dialog_->input_shrtcut); 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 " return _("Remove the current format from the list of available "
"formats. Note: you must then \"Apply\" the change."); "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 (ob == dialog_->button_add) {
if (string(ob->label) == _("Add")) if (string(ob->label) == _("Add"))
return _("Add the current format to the list of available " 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_shrtcut
|| ob == dialog_->input_extension || ob == dialog_->input_extension
|| ob == dialog_->input_viewer || ob == dialog_->input_viewer
|| ob == dialog_->input_editor) || ob == dialog_->input_editor
|| ob == dialog_->check_document)
return Input(); return Input();
if (ob == dialog_->button_add) if (ob == dialog_->button_add)
@ -1416,10 +1422,12 @@ bool FormPreferences::Formats::Add()
string const shortcut = getString(dialog_->input_shrtcut); string const shortcut = getString(dialog_->input_shrtcut);
string const viewer = getString(dialog_->input_viewer); string const viewer = getString(dialog_->input_viewer);
string const editor = getString(dialog_->input_editor); string const editor = getString(dialog_->input_editor);
bool const document = fl_get_button(dialog_->check_document);
Format const * old = formats().getFormat(name); Format const * old = formats().getFormat(name);
string const old_prettyname = old ? old->prettyname() : string(); 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) { if (!old || prettyname != old_prettyname) {
UpdateBrowser(); UpdateBrowser();
if (old) 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_extension, f.extension().c_str());
fl_set_input(dialog_->input_viewer, f.viewer().c_str()); fl_set_input(dialog_->input_viewer, f.viewer().c_str());
fl_set_input(dialog_->input_editor, f.editor().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, fl_set_object_label(dialog_->button_add,
idex(_("Modify|#M")).c_str()); idex(_("Modify|#M")).c_str());

View File

@ -1704,8 +1704,8 @@ argument:
=============== FORM =============== =============== FORM ===============
Name: form_preferences_formats Name: form_preferences_formats
Width: 450 Width: 450
Height: 400 Height: 440
Number of Objects: 10 Number of Objects: 11
-------------------- --------------------
class: FL_BOX class: FL_BOX
@ -1851,10 +1851,28 @@ name: input_editor
callback: C_FormDialogView_InputCB callback: C_FormDialogView_InputCB
argument: 0 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 class: FL_BUTTON
type: NORMAL_BUTTON type: NORMAL_BUTTON
box: 240 300 90 30 box: 240 340 90 30
boxtype: FL_UP_BOX boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1 colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -1872,7 +1890,7 @@ argument: 0
-------------------- --------------------
class: FL_BUTTON class: FL_BUTTON
type: NORMAL_BUTTON type: NORMAL_BUTTON
box: 340 300 90 30 box: 340 340 90 30
boxtype: FL_UP_BOX boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1 colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER

View File

@ -48,6 +48,7 @@ using lyx::support::expandPath;
using lyx::support::getEnv; using lyx::support::getEnv;
using lyx::support::libFileSearch; using lyx::support::libFileSearch;
using lyx::support::token; using lyx::support::token;
using lyx::support::tokenPos;
using std::cout; using std::cout;
using std::endl; using std::endl;
@ -1086,24 +1087,35 @@ int LyXRC::read(LyXLex & lexrc)
shortcut = lexrc.getString(); shortcut = lexrc.getString();
} }
string viewer, editor; 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 // Hack to ensure compatibility with versions older
// than 1.4.0 // than 1.5.0
int le = lexrc.lex(); int le = lexrc.lex();
if (le != LyXLex::LEX_FEOF && le != LyXLex::LEX_UNDEF) { if (le != LyXLex::LEX_FEOF && le != LyXLex::LEX_UNDEF) {
viewer = lexrc.getString(); flags = lexrc.getString();
if (le == LyXLex::LEX_DATA) { if (le != LyXLex::LEX_DATA) {
if (lexrc.next()) {
editor = lexrc.getString();
}
} else {
// We have got a known token. // We have got a known token.
// Therefore this is an old style // Therefore this is an old style
// format definition without // format definition without
// viewer and editor. // flags.
lexrc.pushToken(viewer); lexrc.pushToken(flags);
viewer.erase(); 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 (prettyname.empty()) {
if (converters.formatIsUsed(format)) { if (converters.formatIsUsed(format)) {
lyxerr << "Can't delete format " lyxerr << "Can't delete format "
@ -1113,7 +1125,7 @@ int LyXRC::read(LyXLex & lexrc)
} }
} else { } else {
formats.add(format, extension, prettyname, formats.add(format, extension, prettyname,
shortcut, viewer, editor); shortcut, viewer, editor, document);
} }
break; break;
} }
@ -2007,7 +2019,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
<< "#\n\n"; << "#\n\n";
case RC_FORMAT: case RC_FORMAT:
// New/modifed formats // New/modified formats
for (Formats::const_iterator cit = formats.begin(); for (Formats::const_iterator cit = formats.begin();
cit != formats.end(); ++cit) { cit != formats.end(); ++cit) {
Format const * format = Format const * format =
@ -2017,13 +2029,18 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
format->prettyname() != cit->prettyname() || format->prettyname() != cit->prettyname() ||
format->shortcut() != cit->shortcut() || format->shortcut() != cit->shortcut() ||
format->viewer() != cit->viewer() || format->viewer() != cit->viewer() ||
format->editor() != cit->editor()) format->editor() != cit->editor() ||
format->documentFormat() != cit->documentFormat()) {
os << "\\format \"" << cit->name() << "\" \"" os << "\\format \"" << cit->name() << "\" \""
<< cit->extension() << "\" \"" << cit->extension() << "\" \""
<< cit->prettyname() << "\" \"" << cit->prettyname() << "\" \""
<< cit->shortcut() << "\" \"" << cit->shortcut() << "\" \""
<< cit->viewer() << "\" \"" << cit->viewer() << "\" \""
<< cit->editor() << "\"\n"; << cit->editor() << "\" \"";
if (cit->documentFormat())
os << "document";
os << "\"\n";
}
} }
// Look for deleted formats // Look for deleted formats
@ -2031,7 +2048,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
cit != system_formats.end(); ++cit) cit != system_formats.end(); ++cit)
if (!formats.getFormat(cit->name())) if (!formats.getFormat(cit->name()))
os << "\\format \"" << cit->name() os << "\\format \"" << cit->name()
<< "\" \"\" \"\" \"\" \"\" \"\"\n"; << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
case RC_VIEWER: case RC_VIEWER:
// Ignore it // Ignore it