Fix bug 2868

* src/insets/insetgraphics.C
	(findTargetFormat): return pdf for vector graphics

	* src/format.h
	(Flags): new enum describing format flags
	(flags_): new member variable for format flags
	(vectorFormat): new, tell whether a format can contain vector graphics

	* src/format.C: adjust to flags changes

	* src/frontends/qt2QPrefsDialog.C
	(QPrefsDialog::QPrefsDialog): handle new vector flag
	(QPrefsDialog::switch_format): ditto
	(QPrefsDialog::updateFormatsButtons): ditto
	(QPrefsDialog::new_format): ditto
	(QPrefsDialog::modify_format): ditto

	* src/frontends/qt2/ui/QPrefFileformatsModule.ui
	(vectorCB): new checkbox for vector flag

	* src/lyxrc.C
	(LyXRC::read): read vector flag
	(LyXRC::write): write vector flag

	* lib/doc/Customization.lyx: document format flags

	* lib/configure.py
	(checkFormatEntries): Add vector flag to some formats


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@16432 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2006-12-29 21:11:42 +00:00
parent 382e7201b0
commit 125e638bdb
11 changed files with 220 additions and 46 deletions

View File

@ -240,13 +240,13 @@ def checkLatex(dtl_tools):
def checkFormatEntries(dtl_tools):
''' Check all formats (\Format entries) '''
checkViewer('a Tgif viewer and editor', ['tgif'],
rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%"'])
rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%" "vector"'])
#
checkViewer('a FIG viewer and editor', ['xfig'],
rc_entry = [r'\Format fig fig FIG "" "%%" "%%"'])
rc_entry = [r'\Format fig fig FIG "" "%%" "%%" "vector"'])
#
checkViewer('a Grace viewer and editor', ['xmgrace'],
rc_entry = [r'\Format agr agr Grace "" "%%" "%%"'])
rc_entry = [r'\Format agr agr Grace "" "%%" "%%" "vector"'])
#
checkViewer('a FEN viewer and editor', ['xboard -lpf $$i -mode EditPosition'],
rc_entry = [r'\Format fen fen FEN "" "%%" "%%"'])
@ -284,38 +284,38 @@ def checkFormatEntries(dtl_tools):
#checkProg('a Postscript interpreter', ['gs'],
# rc_entry = [ r'\ps_command "%%"' ])
checkViewer('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 "" "%%" "" "vector"
\Format ps ps Postscript t "%%" "" "vector"'''])
#
checkViewer('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 "%%" "" "vector"
\Format pdf2 pdf "PDF (pdflatex)" F "%%" "" "vector"
\Format pdf3 pdf "PDF (dvipdfm)" m "%%" "" "vector"'''])
#
checkViewer('a DVI previewer', ['xdvi', 'kdvi'],
rc_entry = [r'\Format dvi dvi DVI D "%%" ""'])
rc_entry = [r'\Format dvi dvi DVI D "%%" "" "vector"'])
if dtl_tools:
# Windows only: DraftDVI
addToRC(r'\Format dvi2 dvi DraftDVI "" "" ""')
addToRC(r'\Format dvi2 dvi DraftDVI "" "" "vector"')
#
checkViewer('a HTML previewer', ['mozilla file://$$p$$i', 'netscape'],
rc_entry = [r'\Format html html HTML H "%%" ""'])
#
# 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 rtf rtf "Rich Text Format" "" "" ""
\Format sxw sxw "OpenOffice.Org Writer" O "" ""
\Format wmf wmf "Windows Meta File" "" "" ""
\Format word doc "MS Word" W "" ""
\Format wordhtml html "MS Word (HTML)" "" "" ""
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 rtf rtf "Rich Text Format" "" "" "" "vector"
\Format sxw sxw "OpenOffice.Org Writer" O "" "" "vector"
\Format wmf wmf "Windows Meta File" "" "" "" "vector"
\Format word doc "MS Word" W "" "" "vector"
\Format wordhtml html "MS Word (HTML)" "" "" "" ""
''')

View File

@ -1,4 +1,4 @@
#LyX 1.4.3svn created this file. For more info see http://www.lyx.org/
#LyX 1.4.3 created this file. For more info see http://www.lyx.org/
\lyxformat 245
\begin_document
\begin_header
@ -1791,8 +1791,9 @@ P
references:Conversion
\family default
dialog.
This does currently only work in the Windows® port of LyX, but it is planned
to implement this feature on all other ports that can support it, too.
This does currently only work in the Windows® and Mac OS X ports of LyX,
but it is planned to implement this feature on all other ports that can
support it, too.
\end_layout
\begin_layout Standard
@ -1848,6 +1849,68 @@ For example, the file may reference other files with relative filenames,
directory and may modify it in the process.
\end_layout
\begin_layout Standard
Sometimes LyX needs to know a bit more about the properties of a format.
These bits can be specified with flags.
Currently there is only one flag, but more will be added in the future:
\end_layout
\begin_layout Standard
The
\family typewriter
vector
\family default
flag tells LyX whether a format can contain vector graphics.
This information is used to determine the target format of included graphics
for
\family typewriter
pdflatex
\family default
export.
Included graphics may need to be converted to either
\family typewriter
pdf
\family default
,
\family typewriter
png
\family default
or
\family typewriter
jpg
\family default
, since
\family typewriter
pdflatex
\family default
can not handle other image formats.
If an included graphic is not already in
\family typewriter
pdf
\family default
,
\family typewriter
png
\family default
or
\family typewriter
jpg
\family default
format it is converted to
\family typewriter
pdf
\family default
if the
\family typewriter
vector
\family default
flag of the format is set, and otherwise to
\family typewriter
png
\family default
.
\end_layout
\begin_layout Section
BibTeX and makeindex
\end_layout

View File

@ -93,8 +93,10 @@ bool operator<(Format const & a, Format const & b)
}
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,
int flags)
: name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v),
editor_(ed), flags_(flags)
{}
@ -208,22 +210,25 @@ 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(),
Format::none);
}
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,
int flags)
{
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, flags));
else
*it = Format(name, extension, prettyname, shortcut, viewer, editor);
*it = Format(name, extension, prettyname, shortcut, viewer,
editor, flags);
}

View File

@ -19,9 +19,16 @@ class Buffer;
class Format {
public:
/// Flags for some format properties
enum Flags {
none = 0,
/// Set if this format can contain vector graphics.
vector = 1,
};
///
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,
int);
///
bool dummy() const;
///
@ -60,6 +67,10 @@ public:
void setEditor(std::string const & v) {
editor_ = v;
}
///
bool vectorFormat() const {
return flags_ & vector;
}
private:
std::string name_;
///
@ -72,11 +83,14 @@ private:
std::string viewer_;
///
std::string editor_;
///
int flags_;
};
bool operator<(Format const & a, Format const & b);
///
class Formats {
public:
@ -107,7 +121,8 @@ public:
///
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 & viewer, std::string const & editor,
int flags);
///
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->viewerED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
connect(fileformatsModule->editorED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
connect(fileformatsModule->vectorCB, 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()));
@ -727,6 +728,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->vectorCB->setChecked(f.vectorFormat());
fileformatsModule->formatRemovePB->setEnabled(
!form_->converters().formatIsUsed(f.name()));
@ -768,16 +770,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_vector(f.vectorFormat());
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_vector(fileformatsModule->vectorCB->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_vector != new_vector);
fileformatsModule->formatModifyPB->setEnabled(
valid && known && modified && !known_otherwise);
@ -794,8 +798,12 @@ 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());
int flags = Format::none;
if (fileformatsModule->vectorCB->isChecked())
flags |= Format::vector;
form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
form_->formats().add(name, extension, prettyname, shortcut, viewer,
editor, flags);
form_->formats().sort();
updateFormats();
fileformatsModule->formatsLB->setCurrentItem(form_->formats().getNumber(name));
@ -823,8 +831,12 @@ 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());
int flags = Format::none;
if (fileformatsModule->vectorCB->isChecked())
flags |= Format::vector;
form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
form_->formats().add(name, extension, prettyname, shortcut, viewer,
editor, flags);
form_->formats().sort();
fileformatsModule->formatsLB->setUpdatesEnabled(false);

View File

@ -59,6 +59,21 @@
<cstring>editorED</cstring>
</property>
</widget>
<widget row="7" column="1" >
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>vectorCB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Vector graphi&amp;cs format</string>
</property>
<property>
<name>toolTip</name>
<string>Tell whether this format can contain vector graphics.</string>
</property>
</widget>
<widget row="2" column="1" >
<class>QLineEdit</class>
<property stdset="1">
@ -402,5 +417,6 @@
<tabstop>extensionED</tabstop>
<tabstop>viewerED</tabstop>
<tabstop>editorED</tabstop>
<tabstop>vectorCB</tabstop>
</tabstops>
</UI>

View File

@ -1309,6 +1309,7 @@ void FormPreferences::Formats::build()
setPrehandler(dialog_->input_extension);
setPrehandler(dialog_->input_viewer);
setPrehandler(dialog_->input_editor);
setPrehandler(dialog_->check_vector);
setPrehandler(dialog_->input_shrtcut);
}
@ -1338,6 +1339,9 @@ FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
if (ob == dialog_->input_editor)
return _("The command used to launch the editor application.");
if (ob == dialog_->check_vector)
return _("Tell whether this format can contain vector graphics.");
if (ob == dialog_->button_delete)
return _("Remove the current format from the list of available "
"formats. Note: you must then \"Apply\" the change.");
@ -1365,7 +1369,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_vector)
return Input();
if (ob == dialog_->button_add)
@ -1413,10 +1418,15 @@ 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 vector = fl_get_button(dialog_->check_vector);
Format const * old = formats().getFormat(name);
string const old_prettyname = old ? old->prettyname() : string();
formats().add(name, extension, prettyname, shortcut, viewer, editor);
int flags = Format::none;
if (vector)
flags |= Format::vector;
formats().add(name, extension, prettyname, shortcut, viewer, editor,
flags);
if (!old || prettyname != old_prettyname) {
UpdateBrowser();
if (old)
@ -1444,6 +1454,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_vector, f.vectorFormat());
fl_set_object_label(dialog_->button_add,
idex(_("Modify|#M")).c_str());

View File

@ -1705,7 +1705,7 @@ argument:
Name: form_preferences_formats
Width: 450
Height: 400
Number of Objects: 10
Number of Objects: 11
--------------------
class: FL_BOX
@ -1851,6 +1851,24 @@ name: input_editor
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 280 270 25 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Vector graphics format:|#c
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: check_vector
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON

View File

@ -135,11 +135,12 @@ string findTargetFormat(string const & format, OutputParams const & runparams)
// Are we using latex or pdflatex?
if (runparams.flavor == OutputParams::PDFLATEX) {
lyxerr[Debug::GRAPHICS] << "findTargetFormat: PDF mode" << endl;
// Convert postscript to pdf
if (format == "eps" || format == "ps")
Format const * const f = formats.getFormat(format);
// Convert vector graphics to pdf
if (f && f->vectorFormat())
return "pdf";
// pdflatex can use jpeg, png and pdf directly
if (format == "jpg" || format == "pdf")
if (format == "jpg")
return format;
// Convert everything else to png
return "png";

View File

@ -1053,6 +1053,7 @@ int LyXRC::read(LyXLex & lexrc)
shortcut = lexrc.getString();
}
string viewer, editor;
string flags;
// Hack to ensure compatibility with versions older
// than 1.4.0
int le = lexrc.lex();
@ -1061,6 +1062,15 @@ int LyXRC::read(LyXLex & lexrc)
if (le == LyXLex::LEX_DATA) {
if (lexrc.next()) {
editor = lexrc.getString();
le = lexrc.lex();
if (le != LyXLex::LEX_FEOF &&
le != LyXLex::LEX_UNDEF) {
flags = lexrc.getString();
if (le != LyXLex::LEX_DATA) {
lexrc.pushToken(flags);
flags.erase();
}
}
}
} else {
// We have got a known token.
@ -1071,6 +1081,17 @@ int LyXRC::read(LyXLex & lexrc)
viewer.erase();
}
}
int flgs = Format::none;
while (!flags.empty()) {
string flag;
flags = lyx::support::split(flags, flag, ',');
if (flag == "vector")
flgs |= Format::vector;
else
lyxerr << "Ignoring unknown flag `"
<< flag << "' for format `"
<< format << "'." << endl;
}
if (prettyname.empty()) {
if (converters.formatIsUsed(format)) {
lyxerr << "Can't delete format "
@ -1080,7 +1101,7 @@ int LyXRC::read(LyXLex & lexrc)
}
} else {
formats.add(format, extension, prettyname,
shortcut, viewer, editor);
shortcut, viewer, editor, flgs);
}
break;
}
@ -1960,13 +1981,20 @@ 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->vectorFormat() != cit->vectorFormat()) {
os << "\\format \"" << cit->name() << "\" \""
<< cit->extension() << "\" \""
<< cit->prettyname() << "\" \""
<< cit->shortcut() << "\" \""
<< cit->viewer() << "\" \""
<< cit->editor() << "\"\n";
<< cit->editor() << "\" \"";
std::vector<string> flags;
if (cit->vectorFormat())
flags.push_back("vector");
os << lyx::support::getStringFromVector(flags);
os << "\"\n";
}
}
// Look for deleted formats

View File

@ -51,6 +51,11 @@ What's new
Tutorial); Update German (all), Hebrew (Intro) and Italian
(Tutorial, UserGuide) documentation.
- Convert included vector graphics to pdf instead of png for pdflatex export
(bug 2868). This is implemented with the help of a new format flag "vector"
that you have to set manually for your self defined vector graphics formats
if you want to use this feature.
** Bug fixes:
* Document Input/Output