Add an option to assure that all aux files are maintained when using the includeonly feature, so that the

page numbering and the references of the master file are maintained in the included children (bug 1005).

I made this optional since some people use \includeonly to save compilation time, but a proper aux file update
needs a full compilation of the complete master prior to the compilation of the \includeonly master.

Hence, a new buffer param is introduced (file format change). 

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32936 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2010-01-10 13:25:41 +00:00
parent 93510f741c
commit 7a7ab8f14b
11 changed files with 109 additions and 32 deletions

View File

@ -1,6 +1,12 @@
LyX file-format changes LyX file-format changes
----------------------- -----------------------
2010-01-10 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 376: new buffer param
\maintain_unincluded_children. If true, the aux files of
non-included children (with \includeonly) are updated to
keep the counters and refs correct.
2010-01-06 Jürgen Spitzmüller <spitz@lyx.org> 2010-01-06 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 375: add support for \includeonly * Format incremented to 375: add support for \includeonly
This adds a new buffer param list of relative filenames This adds a new buffer param list of relative filenames

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# This file is part of lyx2lyx # This file is part of lyx2lyx
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2008 José Matos <jamatos@lyx.org> # Copyright (C) 2008 José Matos <jamatos@lyx.org>
@ -1154,6 +1155,13 @@ def revert_includeonly(document):
document.header[i : j + 1] = [] document.header[i : j + 1] = []
def revert_includeall(document):
" Remove maintain_unincluded_children param "
i = find_token(document.header, '\\maintain_unincluded_children', 0)
if i != -1:
del document.header[i]
## ##
# Conversion hub # Conversion hub
# #
@ -1188,10 +1196,12 @@ convert = [[346, []],
[372, []], [372, []],
[373, [merge_gbrief]], [373, [merge_gbrief]],
[374, []], [374, []],
[375, []] [375, []],
[376, []]
] ]
revert = [[374, [revert_includeonly]], revert = [[375, [revert_includeall]],
[374, [revert_includeonly]],
[373, [revert_html_options]], [373, [revert_html_options]],
[372, [revert_gbrief]], [372, [revert_gbrief]],
[371, [revert_fontenc]], [371, [revert_fontenc]],

View File

@ -127,7 +127,7 @@ namespace {
// Do not remove the comment below, so we get merge conflict in // Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own. // independent branches. Instead add your own.
int const LYX_FORMAT = 375; // jspitzm: includeonly support int const LYX_FORMAT = 376; // jspitzm: support for unincluded file maintenance
typedef map<string, bool> DepClean; typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache; typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
@ -1830,7 +1830,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
break; break;
case LFUN_BUFFER_EXPORT: { case LFUN_BUFFER_EXPORT: {
bool success = doExport(argument, false); bool success = doExport(argument, false, false);
dr.setError(success); dr.setError(success);
if (!success) if (!success)
dr.setMessage(bformat(_("Error exporting to format: %1$s."), dr.setMessage(bformat(_("Error exporting to format: %1$s."),
@ -1839,7 +1839,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
} }
case LFUN_BUILD_PROGRAM: case LFUN_BUILD_PROGRAM:
doExport("program", true); doExport("program", true, false);
break; break;
case LFUN_BUFFER_CHKTEX: case LFUN_BUFFER_CHKTEX:
@ -1871,7 +1871,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
break; break;
} else { } else {
doExport(format_name, true, filename); doExport(format_name, true, false, filename);
} }
// Substitute $$FName for filename // Substitute $$FName for filename
@ -2005,7 +2005,10 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
break; break;
} }
if (!doExport("dvi", true)) { bool const update_unincluded =
params().maintain_unincluded_children
&& !params().getIncludedChildren().empty();
if (!doExport("dvi", true, update_unincluded)) {
showPrintError(absFileName()); showPrintError(absFileName());
dr.setMessage(_("Error exporting to DVI.")); dr.setMessage(_("Error exporting to DVI."));
break; break;
@ -3141,12 +3144,13 @@ string Buffer::getDefaultOutputFormat() const
bool Buffer::doExport(string const & format, bool put_in_tempdir, bool Buffer::doExport(string const & format, bool put_in_tempdir,
string & result_file) const bool includeall, string & result_file) const
{ {
string backend_format; string backend_format;
OutputParams runparams(&params().encoding()); OutputParams runparams(&params().encoding());
runparams.flavor = OutputParams::LATEX; runparams.flavor = OutputParams::LATEX;
runparams.linelen = lyxrc.plaintext_linelen; runparams.linelen = lyxrc.plaintext_linelen;
runparams.includeall = includeall;
vector<string> backs = backends(); vector<string> backs = backends();
if (find(backs.begin(), backs.end(), format) == backs.end()) { if (find(backs.begin(), backs.end(), format) == backs.end()) {
// Get shortest path to format // Get shortest path to format
@ -3286,17 +3290,26 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
} }
bool Buffer::doExport(string const & format, bool put_in_tempdir) const bool Buffer::doExport(string const & format, bool put_in_tempdir,
bool includeall) const
{ {
string result_file; string result_file;
return doExport(format, put_in_tempdir, result_file); // (1) export with all included children (omit \includeonly)
if (includeall && !doExport(format, put_in_tempdir, true, result_file))
return false;
// (2) export with included children only
return doExport(format, put_in_tempdir, false, result_file);
} }
bool Buffer::preview(string const & format) const bool Buffer::preview(string const & format, bool includeall) const
{ {
string result_file; string result_file;
if (!doExport(format, true, result_file)) // (1) export with all included children (omit \includeonly)
if (includeall && !doExport(format, true, true))
return false;
// (2) export with included children only
if (!doExport(format, true, false, result_file))
return false; return false;
return formats.view(*this, FileName(result_file), format); return formats.view(*this, FileName(result_file), format);
} }

View File

@ -513,11 +513,12 @@ public:
/// ///
bool doExport(std::string const & format, bool put_in_tempdir, bool doExport(std::string const & format, bool put_in_tempdir,
std::string & result_file) const; bool includeall, std::string & result_file) const;
/// ///
bool doExport(std::string const & format, bool put_in_tempdir) const; bool doExport(std::string const & format, bool put_in_tempdir,
bool includeall = false) const;
/// ///
bool preview(std::string const & format) const; bool preview(std::string const & format, bool includeall = false) const;
/// ///
bool isExportable(std::string const & format) const; bool isExportable(std::string const & format) const;
/// ///

View File

@ -343,6 +343,7 @@ BufferParams::BufferParams()
trackChanges = false; trackChanges = false;
outputChanges = false; outputChanges = false;
use_default_options = true; use_default_options = true;
maintain_unincluded_children = false;
secnumdepth = 3; secnumdepth = 3;
tocdepth = 3; tocdepth = 3;
language = default_language; language = default_language;
@ -538,6 +539,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
readRemovedModules(lex); readRemovedModules(lex);
} else if (token == "\\begin_includeonly") { } else if (token == "\\begin_includeonly") {
readIncludeonly(lex); readIncludeonly(lex);
} else if (token == "\\maintain_unincluded_children") {
lex >> maintain_unincluded_children;
} else if (token == "\\options") { } else if (token == "\\options") {
lex.eatLine(); lex.eatLine();
options = lex.getString(); options = lex.getString();
@ -846,6 +849,8 @@ void BufferParams::writeFile(ostream & os) const
os << *it << '\n'; os << *it << '\n';
os << "\\end_includeonly" << '\n'; os << "\\end_includeonly" << '\n';
} }
os << "\\maintain_unincluded_children "
<< convert<string>(maintain_unincluded_children) << '\n';
// local layout information // local layout information
if (!local_layout.empty()) { if (!local_layout.empty()) {
@ -1262,7 +1267,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
writeEncodingPreamble(os, features, texrow); writeEncodingPreamble(os, features, texrow);
// includeonly // includeonly
if (!includedChildren_.empty()) { if (!features.runparams().includeall && !includedChildren_.empty()) {
os << "\\includeonly{"; os << "\\includeonly{";
list<string>::const_iterator it = includedChildren_.begin(); list<string>::const_iterator it = includedChildren_.begin();
bool first = true; bool first = true;

View File

@ -165,6 +165,9 @@ public:
/// Clear the list of included children /// Clear the list of included children
void clearIncludedChildren() { includedChildren_.clear(); } void clearIncludedChildren() { includedChildren_.clear(); }
/// update aux files of unincluded children (with \includeonly)
bool maintain_unincluded_children;
/// returns the main font for the buffer (document) /// returns the main font for the buffer (document)
Font const getFont() const; Font const getFont() const;

View File

@ -30,7 +30,7 @@ OutputParams::OutputParams(Encoding const * enc)
par_begin(0), par_end(0), isLastPar(false), par_begin(0), par_end(0), isLastPar(false),
dryrun(false), verbatim(false), dryrun(false), verbatim(false),
html_disable_captions(false), html_in_par(false), html_disable_captions(false), html_in_par(false),
html_make_pars(true) html_make_pars(true), includeall(false)
{ {
// Note: in PreviewLoader::Impl::dumpPreamble // Note: in PreviewLoader::Impl::dumpPreamble
// OutputParams runparams(0); // OutputParams runparams(0);

View File

@ -216,6 +216,8 @@ public:
bool html_in_par; bool html_in_par;
/// Does the present context even permit paragraphs? /// Does the present context even permit paragraphs?
bool html_make_pars; bool html_make_pars;
/// Include all children notwithstanding the use of \includeonly
bool includeall;
}; };

View File

@ -624,10 +624,14 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(includeonlyClicked(QTreeWidgetItem *, int))); this, SLOT(includeonlyClicked(QTreeWidgetItem *, int)));
connect(masterChildModule->includeonlyRB, SIGNAL(toggled(bool)), connect(masterChildModule->includeonlyRB, SIGNAL(toggled(bool)),
masterChildModule->childrenTW, SLOT(setEnabled(bool))); masterChildModule->childrenTW, SLOT(setEnabled(bool)));
connect(masterChildModule->includeonlyRB, SIGNAL(toggled(bool)),
masterChildModule->maintainAuxCB, SLOT(setEnabled(bool)));
connect(masterChildModule->includeallRB, SIGNAL(clicked()), connect(masterChildModule->includeallRB, SIGNAL(clicked()),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(masterChildModule->includeonlyRB, SIGNAL(clicked()), connect(masterChildModule->includeonlyRB, SIGNAL(clicked()),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(masterChildModule->maintainAuxCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
masterChildModule->childrenTW->setColumnCount(2); masterChildModule->childrenTW->setColumnCount(2);
masterChildModule->childrenTW->headerItem()->setText(0, qt_("Child Document")); masterChildModule->childrenTW->headerItem()->setText(0, qt_("Child Document"));
masterChildModule->childrenTW->headerItem()->setText(1, qt_("Include to Output")); masterChildModule->childrenTW->headerItem()->setText(1, qt_("Include to Output"));
@ -2098,6 +2102,8 @@ void GuiDocument::applyView()
bp_.addIncludedChildren(*it); bp_.addIncludedChildren(*it);
} }
} }
bp_.maintain_unincluded_children =
masterChildModule->maintainAuxCB->isChecked();
// Float Placement // Float Placement
bp_.float_placement = floatModule->get(); bp_.float_placement = floatModule->get();
@ -2481,13 +2487,17 @@ void GuiDocument::paramsToDialog()
// Master/Child // Master/Child
std::vector<Buffer *> children = buffer().getChildren(false); std::vector<Buffer *> children = buffer().getChildren(false);
if (children.empty()) { if (children.empty()) {
masterChildModule->childrenTW->clear();
masterChildModule->setEnabled(false); masterChildModule->setEnabled(false);
masterChildModule->includeallRB->setChecked(true);
includeonlys_.clear(); includeonlys_.clear();
} else { } else {
masterChildModule->setEnabled(true); masterChildModule->setEnabled(true);
includeonlys_ = bp_.getIncludedChildren(); includeonlys_ = bp_.getIncludedChildren();
updateIncludeonlys(); updateIncludeonlys();
} }
masterChildModule->maintainAuxCB->setChecked(
bp_.maintain_unincluded_children);
// Float Settings // Float Settings
floatModule->set(bp_.float_placement); floatModule->set(bp_.float_placement);
@ -2725,9 +2735,11 @@ void GuiDocument::updateIncludeonlys()
if (includeonlys_.empty()) { if (includeonlys_.empty()) {
masterChildModule->includeallRB->setChecked(true); masterChildModule->includeallRB->setChecked(true);
masterChildModule->childrenTW->setEnabled(false); masterChildModule->childrenTW->setEnabled(false);
masterChildModule->maintainAuxCB->setEnabled(false);
} else { } else {
masterChildModule->includeonlyRB->setChecked(true); masterChildModule->includeonlyRB->setChecked(true);
masterChildModule->childrenTW->setEnabled(true); masterChildModule->childrenTW->setEnabled(true);
masterChildModule->maintainAuxCB->setEnabled(true);
} }
QTreeWidgetItem * item = 0; QTreeWidgetItem * item = 0;
std::vector<Buffer *> children = buffer().getChildren(false); std::vector<Buffer *> children = buffer().getChildren(false);

View File

@ -2644,7 +2644,10 @@ bool GuiView::goToFileRow(string const & argument)
#if (QT_VERSION >= 0x040400) #if (QT_VERSION >= 0x040400)
static docstring exportAndDestroy(Buffer * buffer, string const & format) static docstring exportAndDestroy(Buffer * buffer, string const & format)
{ {
bool const success = buffer->doExport(format, true); bool const update_unincluded =
buffer->params().maintain_unincluded_children
&& !buffer->params().getIncludedChildren().empty();
bool const success = buffer->doExport(format, true, update_unincluded);
delete buffer; delete buffer;
return success return success
? bformat(_("Successful export to format: %1$s"), from_utf8(format)) ? bformat(_("Successful export to format: %1$s"), from_utf8(format))
@ -2654,7 +2657,10 @@ static docstring exportAndDestroy(Buffer * buffer, string const & format)
static docstring previewAndDestroy(Buffer * buffer, string const & format) static docstring previewAndDestroy(Buffer * buffer, string const & format)
{ {
bool const success = buffer->preview(format); bool const update_unincluded =
buffer->params().maintain_unincluded_children
&& !buffer->params().getIncludedChildren().empty();
bool const success = buffer->preview(format, update_unincluded);
delete buffer; delete buffer;
return success return success
? bformat(_("Successful preview of format: %1$s"), from_utf8(format)) ? bformat(_("Successful preview of format: %1$s"), from_utf8(format))
@ -2719,7 +2725,10 @@ bool GuiView::dispatch(FuncRequest const & cmd)
doc_buffer->clone(), format); doc_buffer->clone(), format);
d.setPreviewFuture(f); d.setPreviewFuture(f);
#else #else
doc_buffer->doExport(format, true); bool const update_unincluded =
doc_buffer->params().maintain_unincluded_children
&& !doc_buffer->params().getIncludedChildren().empty();
doc_buffer->doExport(format, true, update_unincluded);
#endif #endif
break; break;
} }
@ -2736,7 +2745,10 @@ bool GuiView::dispatch(FuncRequest const & cmd)
doc_buffer->clone(), format); doc_buffer->clone(), format);
d.setPreviewFuture(f); d.setPreviewFuture(f);
#else #else
doc_buffer->preview(format); bool const update_unincluded =
doc_buffer->params().maintain_unincluded_children
&& !doc_buffer->params().getIncludedChildren().empty();
doc_buffer->preview(format, update_unincluded);
#endif #endif
break; break;
} }
@ -2752,6 +2764,9 @@ bool GuiView::dispatch(FuncRequest const & cmd)
master->clone(), format); master->clone(), format);
d.setPreviewFuture(f); d.setPreviewFuture(f);
#else #else
bool const update_unincluded =
master->params().maintain_unincluded_children
&& !master->params().getIncludedChildren().empty();
master->doExport(format, true); master->doExport(format, true);
#endif #endif
break; break;

View File

@ -6,7 +6,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>348</width> <width>348</width>
<height>327</height> <height>355</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
@ -34,16 +34,6 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="0" >
<widget class="QRadioButton" name="includeallRB" >
<property name="toolTip" >
<string>Include all included subdocuments in the output</string>
</property>
<property name="text" >
<string>&amp;Include all children</string>
</property>
</widget>
</item>
<item row="1" column="0" > <item row="1" column="0" >
<widget class="QRadioButton" name="includeonlyRB" > <widget class="QRadioButton" name="includeonlyRB" >
<property name="toolTip" > <property name="toolTip" >
@ -55,8 +45,28 @@
</widget> </widget>
</item> </item>
<item row="2" column="0" > <item row="2" column="0" >
<widget class="QCheckBox" name="maintainAuxCB" >
<property name="toolTip" >
<string>Assure counters and references are as in the complete document (prolonges compilation)</string>
</property>
<property name="text" >
<string>&amp;Maintain counters and references</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QTreeWidget" name="childrenTW" /> <widget class="QTreeWidget" name="childrenTW" />
</item> </item>
<item row="0" column="0" >
<widget class="QRadioButton" name="includeallRB" >
<property name="toolTip" >
<string>Include all included subdocuments in the output</string>
</property>
<property name="text" >
<string>&amp;Include all children</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>