mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 21:55:29 +00:00
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:
parent
93510f741c
commit
7a7ab8f14b
@ -1,6 +1,12 @@
|
||||
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>
|
||||
* Format incremented to 375: add support for \includeonly
|
||||
This adds a new buffer param list of relative filenames
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2008 José Matos <jamatos@lyx.org>
|
||||
@ -1154,6 +1155,13 @@ def revert_includeonly(document):
|
||||
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
|
||||
#
|
||||
@ -1188,10 +1196,12 @@ convert = [[346, []],
|
||||
[372, []],
|
||||
[373, [merge_gbrief]],
|
||||
[374, []],
|
||||
[375, []]
|
||||
[375, []],
|
||||
[376, []]
|
||||
]
|
||||
|
||||
revert = [[374, [revert_includeonly]],
|
||||
revert = [[375, [revert_includeall]],
|
||||
[374, [revert_includeonly]],
|
||||
[373, [revert_html_options]],
|
||||
[372, [revert_gbrief]],
|
||||
[371, [revert_fontenc]],
|
||||
|
@ -127,7 +127,7 @@ namespace {
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// 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<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
@ -1830,7 +1830,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
||||
break;
|
||||
|
||||
case LFUN_BUFFER_EXPORT: {
|
||||
bool success = doExport(argument, false);
|
||||
bool success = doExport(argument, false, false);
|
||||
dr.setError(success);
|
||||
if (!success)
|
||||
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:
|
||||
doExport("program", true);
|
||||
doExport("program", true, false);
|
||||
break;
|
||||
|
||||
case LFUN_BUFFER_CHKTEX:
|
||||
@ -1871,7 +1871,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
||||
break;
|
||||
|
||||
} else {
|
||||
doExport(format_name, true, filename);
|
||||
doExport(format_name, true, false, filename);
|
||||
}
|
||||
|
||||
// Substitute $$FName for filename
|
||||
@ -2005,7 +2005,10 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!doExport("dvi", true)) {
|
||||
bool const update_unincluded =
|
||||
params().maintain_unincluded_children
|
||||
&& !params().getIncludedChildren().empty();
|
||||
if (!doExport("dvi", true, update_unincluded)) {
|
||||
showPrintError(absFileName());
|
||||
dr.setMessage(_("Error exporting to DVI."));
|
||||
break;
|
||||
@ -3141,12 +3144,13 @@ string Buffer::getDefaultOutputFormat() const
|
||||
|
||||
|
||||
bool Buffer::doExport(string const & format, bool put_in_tempdir,
|
||||
string & result_file) const
|
||||
bool includeall, string & result_file) const
|
||||
{
|
||||
string backend_format;
|
||||
OutputParams runparams(¶ms().encoding());
|
||||
runparams.flavor = OutputParams::LATEX;
|
||||
runparams.linelen = lyxrc.plaintext_linelen;
|
||||
runparams.includeall = includeall;
|
||||
vector<string> backs = backends();
|
||||
if (find(backs.begin(), backs.end(), format) == backs.end()) {
|
||||
// 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;
|
||||
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;
|
||||
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 formats.view(*this, FileName(result_file), format);
|
||||
}
|
||||
|
@ -513,11 +513,12 @@ public:
|
||||
|
||||
///
|
||||
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;
|
||||
///
|
||||
|
@ -343,6 +343,7 @@ BufferParams::BufferParams()
|
||||
trackChanges = false;
|
||||
outputChanges = false;
|
||||
use_default_options = true;
|
||||
maintain_unincluded_children = false;
|
||||
secnumdepth = 3;
|
||||
tocdepth = 3;
|
||||
language = default_language;
|
||||
@ -538,6 +539,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
readRemovedModules(lex);
|
||||
} else if (token == "\\begin_includeonly") {
|
||||
readIncludeonly(lex);
|
||||
} else if (token == "\\maintain_unincluded_children") {
|
||||
lex >> maintain_unincluded_children;
|
||||
} else if (token == "\\options") {
|
||||
lex.eatLine();
|
||||
options = lex.getString();
|
||||
@ -846,6 +849,8 @@ void BufferParams::writeFile(ostream & os) const
|
||||
os << *it << '\n';
|
||||
os << "\\end_includeonly" << '\n';
|
||||
}
|
||||
os << "\\maintain_unincluded_children "
|
||||
<< convert<string>(maintain_unincluded_children) << '\n';
|
||||
|
||||
// local layout information
|
||||
if (!local_layout.empty()) {
|
||||
@ -1262,7 +1267,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
|
||||
writeEncodingPreamble(os, features, texrow);
|
||||
|
||||
// includeonly
|
||||
if (!includedChildren_.empty()) {
|
||||
if (!features.runparams().includeall && !includedChildren_.empty()) {
|
||||
os << "\\includeonly{";
|
||||
list<string>::const_iterator it = includedChildren_.begin();
|
||||
bool first = true;
|
||||
|
@ -165,6 +165,9 @@ public:
|
||||
/// Clear the list of included children
|
||||
void clearIncludedChildren() { includedChildren_.clear(); }
|
||||
|
||||
/// update aux files of unincluded children (with \includeonly)
|
||||
bool maintain_unincluded_children;
|
||||
|
||||
/// returns the main font for the buffer (document)
|
||||
Font const getFont() const;
|
||||
|
||||
|
@ -30,7 +30,7 @@ OutputParams::OutputParams(Encoding const * enc)
|
||||
par_begin(0), par_end(0), isLastPar(false),
|
||||
dryrun(false), verbatim(false),
|
||||
html_disable_captions(false), html_in_par(false),
|
||||
html_make_pars(true)
|
||||
html_make_pars(true), includeall(false)
|
||||
{
|
||||
// Note: in PreviewLoader::Impl::dumpPreamble
|
||||
// OutputParams runparams(0);
|
||||
|
@ -216,6 +216,8 @@ public:
|
||||
bool html_in_par;
|
||||
/// Does the present context even permit paragraphs?
|
||||
bool html_make_pars;
|
||||
/// Include all children notwithstanding the use of \includeonly
|
||||
bool includeall;
|
||||
};
|
||||
|
||||
|
||||
|
@ -624,10 +624,14 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
this, SLOT(includeonlyClicked(QTreeWidgetItem *, int)));
|
||||
connect(masterChildModule->includeonlyRB, SIGNAL(toggled(bool)),
|
||||
masterChildModule->childrenTW, SLOT(setEnabled(bool)));
|
||||
connect(masterChildModule->includeonlyRB, SIGNAL(toggled(bool)),
|
||||
masterChildModule->maintainAuxCB, SLOT(setEnabled(bool)));
|
||||
connect(masterChildModule->includeallRB, SIGNAL(clicked()),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(masterChildModule->includeonlyRB, SIGNAL(clicked()),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(masterChildModule->maintainAuxCB, SIGNAL(clicked()),
|
||||
this, SLOT(change_adaptor()));
|
||||
masterChildModule->childrenTW->setColumnCount(2);
|
||||
masterChildModule->childrenTW->headerItem()->setText(0, qt_("Child Document"));
|
||||
masterChildModule->childrenTW->headerItem()->setText(1, qt_("Include to Output"));
|
||||
@ -2098,6 +2102,8 @@ void GuiDocument::applyView()
|
||||
bp_.addIncludedChildren(*it);
|
||||
}
|
||||
}
|
||||
bp_.maintain_unincluded_children =
|
||||
masterChildModule->maintainAuxCB->isChecked();
|
||||
|
||||
// Float Placement
|
||||
bp_.float_placement = floatModule->get();
|
||||
@ -2481,13 +2487,17 @@ void GuiDocument::paramsToDialog()
|
||||
// Master/Child
|
||||
std::vector<Buffer *> children = buffer().getChildren(false);
|
||||
if (children.empty()) {
|
||||
masterChildModule->childrenTW->clear();
|
||||
masterChildModule->setEnabled(false);
|
||||
masterChildModule->includeallRB->setChecked(true);
|
||||
includeonlys_.clear();
|
||||
} else {
|
||||
masterChildModule->setEnabled(true);
|
||||
includeonlys_ = bp_.getIncludedChildren();
|
||||
updateIncludeonlys();
|
||||
}
|
||||
masterChildModule->maintainAuxCB->setChecked(
|
||||
bp_.maintain_unincluded_children);
|
||||
|
||||
// Float Settings
|
||||
floatModule->set(bp_.float_placement);
|
||||
@ -2725,9 +2735,11 @@ void GuiDocument::updateIncludeonlys()
|
||||
if (includeonlys_.empty()) {
|
||||
masterChildModule->includeallRB->setChecked(true);
|
||||
masterChildModule->childrenTW->setEnabled(false);
|
||||
masterChildModule->maintainAuxCB->setEnabled(false);
|
||||
} else {
|
||||
masterChildModule->includeonlyRB->setChecked(true);
|
||||
masterChildModule->childrenTW->setEnabled(true);
|
||||
masterChildModule->maintainAuxCB->setEnabled(true);
|
||||
}
|
||||
QTreeWidgetItem * item = 0;
|
||||
std::vector<Buffer *> children = buffer().getChildren(false);
|
||||
|
@ -2644,7 +2644,10 @@ bool GuiView::goToFileRow(string const & argument)
|
||||
#if (QT_VERSION >= 0x040400)
|
||||
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;
|
||||
return success
|
||||
? 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)
|
||||
{
|
||||
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;
|
||||
return success
|
||||
? bformat(_("Successful preview of format: %1$s"), from_utf8(format))
|
||||
@ -2719,7 +2725,10 @@ bool GuiView::dispatch(FuncRequest const & cmd)
|
||||
doc_buffer->clone(), format);
|
||||
d.setPreviewFuture(f);
|
||||
#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
|
||||
break;
|
||||
}
|
||||
@ -2736,7 +2745,10 @@ bool GuiView::dispatch(FuncRequest const & cmd)
|
||||
doc_buffer->clone(), format);
|
||||
d.setPreviewFuture(f);
|
||||
#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
|
||||
break;
|
||||
}
|
||||
@ -2752,6 +2764,9 @@ bool GuiView::dispatch(FuncRequest const & cmd)
|
||||
master->clone(), format);
|
||||
d.setPreviewFuture(f);
|
||||
#else
|
||||
bool const update_unincluded =
|
||||
master->params().maintain_unincluded_children
|
||||
&& !master->params().getIncludedChildren().empty();
|
||||
master->doExport(format, true);
|
||||
#endif
|
||||
break;
|
||||
|
@ -6,7 +6,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>348</width>
|
||||
<height>327</height>
|
||||
<height>355</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
@ -34,16 +34,6 @@
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</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>&Include all children</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QRadioButton" name="includeonlyRB" >
|
||||
<property name="toolTip" >
|
||||
@ -55,8 +45,28 @@
|
||||
</widget>
|
||||
</item>
|
||||
<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>&Maintain counters and references</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QTreeWidget" name="childrenTW" />
|
||||
</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>&Include all children</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user