mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Make use of otexstream also in external::writeExternal
This was not necessary when LyX was generously outputting newlines. As it may happen that the output produced by writeExternal (the result of an external inset) starts right at the beginning of a line, if otexstream does not know that something is already on the line, the iomanip-like variable 'breakln' fails to actually break the line.
This commit is contained in:
parent
371fdb8649
commit
15e1f5eb39
@ -333,23 +333,23 @@ string const substituteOptions(InsetExternalParams const & params,
|
|||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
int writeExternal(InsetExternalParams const & params,
|
void writeExternal(InsetExternalParams const & params,
|
||||||
string const & format,
|
string const & format,
|
||||||
Buffer const & buffer, odocstream & os,
|
Buffer const & buffer, otexstream & os,
|
||||||
ExportData & exportdata,
|
ExportData & exportdata,
|
||||||
bool external_in_tmpdir,
|
bool external_in_tmpdir,
|
||||||
bool dryrun)
|
bool dryrun)
|
||||||
{
|
{
|
||||||
Template const * const et_ptr = getTemplatePtr(params);
|
Template const * const et_ptr = getTemplatePtr(params);
|
||||||
if (!et_ptr)
|
if (!et_ptr)
|
||||||
return 0;
|
return;
|
||||||
Template const & et = *et_ptr;
|
Template const & et = *et_ptr;
|
||||||
|
|
||||||
Template::Formats::const_iterator cit = et.formats.find(format);
|
Template::Formats::const_iterator cit = et.formats.find(format);
|
||||||
if (cit == et.formats.end()) {
|
if (cit == et.formats.end()) {
|
||||||
LYXERR(Debug::EXTERNAL, "External template format '" << format
|
LYXERR(Debug::EXTERNAL, "External template format '" << format
|
||||||
<< "' not specified in template " << params.templatename());
|
<< "' not specified in template " << params.templatename());
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dryrun || contains(cit->second.product, "$$Contents"))
|
if (!dryrun || contains(cit->second.product, "$$Contents"))
|
||||||
@ -383,7 +383,7 @@ int writeExternal(InsetExternalParams const & params,
|
|||||||
str = substituteOptions(params, str, format);
|
str = substituteOptions(params, str, format);
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
os << from_utf8(str);
|
os << from_utf8(str);
|
||||||
return int(count(str.begin(), str.end(),'\n'));
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -60,13 +60,13 @@ std::string const doSubstitution(InsetExternalParams const & params,
|
|||||||
If \p external_in_tmpdir == true, then the generated file is
|
If \p external_in_tmpdir == true, then the generated file is
|
||||||
place in the buffer's temporary directory.
|
place in the buffer's temporary directory.
|
||||||
*/
|
*/
|
||||||
int writeExternal(InsetExternalParams const &,
|
void writeExternal(InsetExternalParams const &,
|
||||||
std::string const & format,
|
std::string const & format,
|
||||||
Buffer const &,
|
Buffer const &,
|
||||||
odocstream &,
|
otexstream &,
|
||||||
ExportData &,
|
ExportData &,
|
||||||
bool external_in_tmpdir,
|
bool external_in_tmpdir,
|
||||||
bool dryrun);
|
bool dryrun);
|
||||||
|
|
||||||
} // namespace external
|
} // namespace external
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -673,21 +673,19 @@ void InsetExternal::latex(otexstream & os, OutputParams const & runparams) const
|
|||||||
et.formats.find("PDFLaTeX");
|
et.formats.find("PDFLaTeX");
|
||||||
|
|
||||||
if (cit != et.formats.end()) {
|
if (cit != et.formats.end()) {
|
||||||
int l = external::writeExternal(params_, "PDFLaTeX",
|
external::writeExternal(params_, "PDFLaTeX",
|
||||||
buffer(), os.os(),
|
buffer(), os,
|
||||||
*(runparams.exportdata),
|
*(runparams.exportdata),
|
||||||
external_in_tmpdir,
|
external_in_tmpdir,
|
||||||
dryrun);
|
dryrun);
|
||||||
os.texrow().newlines(l);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int l = external::writeExternal(params_, "LaTeX", buffer(), os.os(),
|
external::writeExternal(params_, "LaTeX", buffer(), os,
|
||||||
*(runparams.exportdata),
|
*(runparams.exportdata),
|
||||||
external_in_tmpdir,
|
external_in_tmpdir,
|
||||||
dryrun);
|
dryrun);
|
||||||
os.texrow().newlines(l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -698,8 +696,10 @@ int InsetExternal::plaintext(odocstringstream & os,
|
|||||||
if (runparams.for_tooltip)
|
if (runparams.for_tooltip)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
os << '\n'; // output external material on a new line
|
TexRow texrow;
|
||||||
external::writeExternal(params_, "Ascii", buffer(), os,
|
otexstream ots(os, texrow);
|
||||||
|
ots << '\n'; // output external material on a new line
|
||||||
|
external::writeExternal(params_, "Ascii", buffer(), ots,
|
||||||
*(runparams.exportdata), false,
|
*(runparams.exportdata), false,
|
||||||
runparams.dryrun || runparams.inComment);
|
runparams.dryrun || runparams.inComment);
|
||||||
return PLAINTEXT_NEWLINE;
|
return PLAINTEXT_NEWLINE;
|
||||||
@ -709,9 +709,14 @@ int InsetExternal::plaintext(odocstringstream & os,
|
|||||||
int InsetExternal::docbook(odocstream & os,
|
int InsetExternal::docbook(odocstream & os,
|
||||||
OutputParams const & runparams) const
|
OutputParams const & runparams) const
|
||||||
{
|
{
|
||||||
return external::writeExternal(params_, "DocBook", buffer(), os,
|
TexRow texrow;
|
||||||
*(runparams.exportdata), false,
|
odocstringstream ods;
|
||||||
runparams.dryrun || runparams.inComment);
|
otexstream ots(ods, texrow);
|
||||||
|
external::writeExternal(params_, "DocBook", buffer(), ots,
|
||||||
|
*(runparams.exportdata), false,
|
||||||
|
runparams.dryrun || runparams.inComment);
|
||||||
|
os << ods.str();
|
||||||
|
return int(count(ods.str().begin(), ods.str().end(), '\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user