mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
change to use only ostream to write latex from insets
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@581 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0d167123ac
commit
a9b448a027
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
||||
2000-03-02 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* src/mathed/math_utils.C (MathedLookupBOP): using only res->id ==
|
||||
id in the check of the result from lower_bound is not enough since
|
||||
lower_bound can return last too, and then res->id will not be a
|
||||
valid construct.
|
||||
|
||||
* all insets and some code that use them: I have conditionalized
|
||||
removed the Latex(string & out, ...) this means that only the
|
||||
Latex(ostream &, ...) will be used. This is a work in progress to
|
||||
move towards using streams for all output of files.
|
||||
|
||||
* src/text.C (GetColumnNearX): initialize LyXParagraph::size_type
|
||||
c to 0.
|
||||
|
||||
2000-03-02 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* src/mathed/math_utils.C (MathedLookupBOP): fix the search
|
||||
|
@ -183,7 +183,7 @@ dnl Check the version of g++
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||
elif test $ac_cv_prog_cxx_g = yes; then
|
||||
case $gxx_version in
|
||||
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti";;
|
||||
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
|
||||
2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
|
||||
2.96*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
|
||||
*2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
|
||||
@ -194,9 +194,9 @@ dnl Check the version of g++
|
||||
fi
|
||||
if test x$with_warnings = xyes ; then
|
||||
case $gxx_version in
|
||||
2.95.*) CXXFLAGS="$CXXFLAGS -Wall -W -Wconversion";;
|
||||
2.96*) CXXFLAGS="$CXXFLAGS -Wall -W -Wconversion";;
|
||||
*) CXXFLAGS="$CXXFLAGS -ansi -Wall -W -Wno-return-type";;
|
||||
2.95.*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion";;
|
||||
2.96*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion";;
|
||||
*) CXXFLAGS="$CXXFLAGS -ansi -W -Wall -Wno-return-type";;
|
||||
esac
|
||||
if test $lyx_devel_version = yes ; then
|
||||
case $gxx_version in
|
||||
|
@ -183,7 +183,7 @@ dnl Check the version of g++
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||
elif test $ac_cv_prog_cxx_g = yes; then
|
||||
case $gxx_version in
|
||||
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti";;
|
||||
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
|
||||
2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
|
||||
2.96*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
|
||||
*2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
|
||||
@ -194,9 +194,9 @@ dnl Check the version of g++
|
||||
fi
|
||||
if test x$with_warnings = xyes ; then
|
||||
case $gxx_version in
|
||||
2.95.*) CXXFLAGS="$CXXFLAGS -Wall -W -Wconversion";;
|
||||
2.96*) CXXFLAGS="$CXXFLAGS -Wall -W -Wconversion";;
|
||||
*) CXXFLAGS="$CXXFLAGS -ansi -Wall -W -Wno-return-type";;
|
||||
2.95.*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion";;
|
||||
2.96*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion";;
|
||||
*) CXXFLAGS="$CXXFLAGS -ansi -W -Wall -Wno-return-type";;
|
||||
esac
|
||||
if test $lyx_devel_version = yes ; then
|
||||
case $gxx_version in
|
||||
|
@ -1202,12 +1202,14 @@ int InsetFig::Latex(ostream & os, signed char /* fragile*/ ) const
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetFig::Latex(string & file, signed char /* fragile*/ ) const
|
||||
{
|
||||
Regenerate();
|
||||
file += cmd + ' ';
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetFig::Linuxdoc(string &/*file*/) const
|
||||
|
@ -39,8 +39,10 @@ public:
|
||||
void Read(LyXLex & lex);
|
||||
///
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string & file) const;
|
||||
///
|
||||
|
@ -313,14 +313,52 @@ string InsetBibtex::getScreenLabel() const
|
||||
|
||||
int InsetBibtex::Latex(ostream & os, signed char /*fragile*/) const
|
||||
{
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
// this looks like an horrible hack and it is :) The problem
|
||||
// is that owner is not initialized correctly when the bib
|
||||
// inset is cut and pasted. Such hacks will not be needed
|
||||
// later (JMarc)
|
||||
if (!owner) {
|
||||
owner = current_view->buffer();
|
||||
}
|
||||
// If we generate in a temp dir, we might need to give an
|
||||
// absolute path there. This is a bit complicated since we can
|
||||
// have a comma-separated list of bibliographies
|
||||
string adb, db_out;
|
||||
string db_in = getContents();
|
||||
db_in = split(db_in, adb, ',');
|
||||
while(!adb.empty()) {
|
||||
if (!owner->niceFile &&
|
||||
IsFileReadable(MakeAbsPath(adb, owner->filepath)+".bib"))
|
||||
adb = MakeAbsPath(adb, owner->filepath);
|
||||
db_out += adb;
|
||||
db_out += ',';
|
||||
db_in= split(db_in, adb,',');
|
||||
}
|
||||
db_out = strip(db_out, ',');
|
||||
// Idem, but simpler
|
||||
string style;
|
||||
if (!owner->niceFile
|
||||
&& IsFileReadable(MakeAbsPath(getOptions(), owner->filepath)
|
||||
+ ".bst"))
|
||||
style = MakeAbsPath(getOptions(), owner->filepath);
|
||||
else
|
||||
style = getOptions();
|
||||
|
||||
os << "\\bibliographystyle{" << style << "}\n"
|
||||
<< "\\bibliography{" << db_out << "}\n";
|
||||
return 2;
|
||||
#else
|
||||
string bib;
|
||||
signed char dummy = 0;
|
||||
int result = Latex(bib, dummy);
|
||||
os << bib;
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetBibtex::Latex(string & file, signed char /*fragile*/) const
|
||||
{
|
||||
// this looks like an horrible hack and it is :) The problem
|
||||
@ -362,7 +400,7 @@ int InsetBibtex::Latex(string & file, signed char /*fragile*/) const
|
||||
file += "}\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// This method returns a comma separated list of Bibtex entries
|
||||
string InsetBibtex::getKeys(char delim)
|
||||
|
@ -128,8 +128,10 @@ public:
|
||||
void Edit(BufferView *, int x, int y, unsigned int button);
|
||||
///
|
||||
int Latex(ostream &, signed char) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
string getKeys(char delim);
|
||||
///
|
||||
|
@ -251,11 +251,13 @@ int InsetCommand::Latex(ostream & os, signed char /*fragile*/) const
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetCommand::Latex(string & file, signed char /*fragile*/) const
|
||||
{
|
||||
file += getCommand();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetCommand::Linuxdoc(string &/*file*/) const
|
||||
|
@ -48,8 +48,10 @@ public:
|
||||
void Read(LyXLex & lex);
|
||||
///
|
||||
virtual int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
virtual int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
virtual int Linuxdoc(string & file) const;
|
||||
///
|
||||
|
@ -107,10 +107,12 @@ int InsetError::Latex(ostream &, signed char /*fragile*/) const
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetError::Latex(string &, signed char /*fragile*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetError::Linuxdoc(string &) const
|
||||
|
@ -48,8 +48,10 @@ public:
|
||||
void Read(LyXLex & lex);
|
||||
///
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string & file) const;
|
||||
///
|
||||
|
@ -225,10 +225,12 @@ int InsetGraphics::Latex(ostream & os, signed char /*fragile*/) const
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetGraphics::Latex(string & /*file*/, signed char /*fragile*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetGraphics::Linuxdoc(string & /*file*/) const
|
||||
|
@ -46,8 +46,10 @@ public:
|
||||
fragile commands by adding a \protect before.
|
||||
*/
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string & /*file*/) const;
|
||||
///
|
||||
|
@ -317,24 +317,14 @@ bool InsetInclude::loadIfNeeded() const
|
||||
|
||||
int InsetInclude::Latex(ostream & os, signed char /*fragile*/) const
|
||||
{
|
||||
string include_file;
|
||||
signed char dummy = 0;
|
||||
Latex(include_file, dummy);
|
||||
os << include_file;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int InsetInclude::Latex(string & file, signed char /*fragile*/) const
|
||||
{
|
||||
string writefile, incfile;
|
||||
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
// Do nothing if no file name has been specified
|
||||
if (contents.empty())
|
||||
return 0;
|
||||
|
||||
// Use += to force a copy of contents (JMarc)
|
||||
incfile += contents;
|
||||
// How does that force anything? (Lgb)
|
||||
string incfile(contents);
|
||||
|
||||
if (loadIfNeeded()) {
|
||||
Buffer * tmp = bufferlist.getBuffer(getFileName());
|
||||
@ -351,7 +341,85 @@ int InsetInclude::Latex(string & file, signed char /*fragile*/) const
|
||||
}
|
||||
|
||||
// write it to a file (so far the complete file)
|
||||
writefile = ChangeExtension(getFileName(), ".tex", false);
|
||||
string writefile = ChangeExtension(getFileName(), ".tex", false);
|
||||
if (!master->tmppath.empty()
|
||||
&& !master->niceFile) {
|
||||
incfile = subst(incfile, '/','@');
|
||||
#ifdef __EMX__
|
||||
incfile = subst(incfile, ':', '$');
|
||||
#endif
|
||||
writefile = AddName(master->tmppath, incfile);
|
||||
} else
|
||||
writefile = getFileName();
|
||||
writefile = ChangeExtension(writefile, ".tex", false);
|
||||
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
|
||||
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
|
||||
|
||||
tmp->markDepClean(master->tmppath);
|
||||
|
||||
tmp->makeLaTeXFile(writefile,
|
||||
OnlyPath(getMasterFilename()),
|
||||
master->niceFile, true);
|
||||
}
|
||||
|
||||
if (isVerb()) {
|
||||
os << '\\' << command << '{' << incfile << '}';
|
||||
}
|
||||
else if (isInput()) {
|
||||
// \input wants file with extension (default is .tex)
|
||||
if (!IsLyXFilename(getFileName())) {
|
||||
os << '\\' << command << '{' << incfile << '}';
|
||||
} else {
|
||||
os << '\\' << command << '{'
|
||||
<< ChangeExtension(incfile, ".tex", false)
|
||||
<< '}';
|
||||
}
|
||||
} else {
|
||||
// \include don't want extension and demands that the
|
||||
// file really have .tex
|
||||
os << '\\' << command << '{'
|
||||
<< ChangeExtension(incfile, string(), false)
|
||||
<< '}';
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
string include_file;
|
||||
signed char dummy = 0;
|
||||
Latex(include_file, dummy);
|
||||
os << include_file;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetInclude::Latex(string & file, signed char /*fragile*/) const
|
||||
{
|
||||
// Do nothing if no file name has been specified
|
||||
if (contents.empty())
|
||||
return 0;
|
||||
|
||||
// Use += to force a copy of contents (JMarc)
|
||||
string incfile += contents;
|
||||
|
||||
if (loadIfNeeded()) {
|
||||
Buffer * tmp = bufferlist.getBuffer(getFileName());
|
||||
|
||||
if (tmp->params.textclass != master->params.textclass) {
|
||||
lyxerr << "ERROR: Cannot handle include file `"
|
||||
<< MakeDisplayPath(getFileName())
|
||||
<< "' which has textclass `"
|
||||
<< textclasslist.NameOfClass(tmp->params.textclass)
|
||||
<< "' instead of `"
|
||||
<< textclasslist.NameOfClass(master->params.textclass)
|
||||
<< "'." << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// write it to a file (so far the complete file)
|
||||
string writefile =
|
||||
ChangeExtension(getFileName(), ".tex", false);
|
||||
if (!master->tmppath.empty()
|
||||
&& !master->niceFile) {
|
||||
incfile = subst(incfile, '/','@');
|
||||
@ -400,6 +468,7 @@ int InsetInclude::Latex(string & file, signed char /*fragile*/) const
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void InsetInclude::Validate(LaTeXFeatures & features) const
|
||||
|
@ -59,9 +59,10 @@ public:
|
||||
void Read(LyXLex &);
|
||||
///
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
|
||||
#endif
|
||||
///
|
||||
void Validate(LaTeXFeatures &) const;
|
||||
|
||||
|
@ -132,10 +132,12 @@ int InsetInfo::Latex(ostream &, signed char /*fragile*/) const
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetInfo::Latex(string &, signed char /*fragile*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetInfo::Linuxdoc(string &) const
|
||||
|
@ -50,8 +50,10 @@ public:
|
||||
void Read(LyXLex & lex);
|
||||
///
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string & file) const;
|
||||
///
|
||||
|
@ -50,11 +50,13 @@ int InsetLabel::Latex(ostream & os, signed char /*fragile*/) const
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetLabel::Latex(string & file, signed char /*fragile*/) const
|
||||
{
|
||||
file += escape(getCommand());
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetLabel::Linuxdoc(string & file) const
|
||||
|
@ -40,8 +40,10 @@ public:
|
||||
unsigned char Editable() const { return 0; }
|
||||
///
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string & file) const;
|
||||
///
|
||||
|
@ -752,11 +752,13 @@ int InsetLatexAccent::Latex(ostream & os, signed char /*fragile*/) const
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetLatexAccent::Latex(string & file, signed char /*fragile*/) const
|
||||
{
|
||||
file += contents;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetLatexAccent::Linuxdoc(string & file) const
|
||||
|
@ -54,8 +54,10 @@ public:
|
||||
void Read(LyXLex & lex);
|
||||
///
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string & file) const;
|
||||
///
|
||||
|
@ -51,6 +51,7 @@ int InsetParent::Latex(ostream & os, signed char fragile) const
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
// LaTeX must just ignore this command
|
||||
int InsetParent::Latex(string & file, signed char fragile) const
|
||||
{
|
||||
@ -58,3 +59,4 @@ int InsetParent::Latex(string & file, signed char fragile) const
|
||||
InsetCommand::Latex(file, fragile);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -33,8 +33,10 @@ public:
|
||||
InsetParent(string const & fn, Buffer * owner = 0);
|
||||
///
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
Inset * Clone() const { return new InsetParent(getContents()); }
|
||||
///
|
||||
|
@ -226,13 +226,52 @@ void InsetQuotes::Read(LyXLex & lex)
|
||||
|
||||
int InsetQuotes::Latex(ostream & os, signed char /*fragile*/) const
|
||||
{
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
string doclang =
|
||||
current_view->buffer()->GetLanguage();
|
||||
int quoteind = quote_index[side][language];
|
||||
string qstr;
|
||||
|
||||
if (lyxrc->fontenc == "T1") {
|
||||
qstr = latex_quote_t1[times][quoteind];
|
||||
}
|
||||
else if (doclang == "default") {
|
||||
qstr = latex_quote_ot1[times][quoteind];
|
||||
}
|
||||
else if (language == InsetQuotes::FrenchQ
|
||||
&& times == InsetQuotes::DoubleQ
|
||||
&& doclang == "frenchb") {
|
||||
if (side == InsetQuotes::LeftQ)
|
||||
qstr = "\\og{}";
|
||||
else
|
||||
qstr = " \\fg{}";
|
||||
}
|
||||
else
|
||||
qstr = latex_quote_babel[times][quoteind];
|
||||
|
||||
// protect against !` and ?` ligatures.
|
||||
// Is it very bad of us to always protect against those ligatures?
|
||||
#if 0
|
||||
if ((suffixIs(file, '?') || suffixIs(file, '!'))
|
||||
&& qstr[0] == '`')
|
||||
qstr = "{}" + qstr;
|
||||
#else
|
||||
// Always guard against unfortunate ligatures (!` ?`)
|
||||
qstr.insert(0, "{}");
|
||||
#endif
|
||||
|
||||
os << qstr;
|
||||
return 0;
|
||||
#else
|
||||
string quote;
|
||||
int res = Latex(quote, 0);
|
||||
os << quote;
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetQuotes::Latex(string & file, signed char /*fragile*/) const
|
||||
{
|
||||
string doclang =
|
||||
@ -265,6 +304,7 @@ int InsetQuotes::Latex(string & file, signed char /*fragile*/) const
|
||||
file += qstr;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetQuotes::Linuxdoc(string & file) const
|
||||
|
@ -86,8 +86,10 @@ public:
|
||||
void Read(LyXLex & lex);
|
||||
///
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string & file) const;
|
||||
///
|
||||
|
@ -81,6 +81,7 @@ int InsetRef::Latex(ostream & os, signed char /*fragile*/) const
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetRef::Latex(string & file, signed char /*fragile*/) const
|
||||
{
|
||||
if(getOptions().empty())
|
||||
@ -93,6 +94,7 @@ int InsetRef::Latex(string & file, signed char /*fragile*/) const
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetRef::Linuxdoc(string & file) const
|
||||
|
@ -62,8 +62,10 @@ public:
|
||||
void gotoLabel();
|
||||
///
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string & file) const;
|
||||
///
|
||||
|
@ -189,14 +189,26 @@ void InsetSpecialChar::Read(LyXLex & lex)
|
||||
|
||||
int InsetSpecialChar::Latex(ostream & os, signed char /*fragile*/) const
|
||||
{
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
switch (kind) {
|
||||
case HYPHENATION: os << "\\-"; break;
|
||||
case END_OF_SENTENCE: os << "\\@."; break;
|
||||
case LDOTS: os << "\\ldots{}"; break;
|
||||
case MENU_SEPARATOR: os << "\\lyxarrow{}"; break;
|
||||
case PROTECTED_SEPARATOR: os << "~"; break;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
string command;
|
||||
signed char dummy = 0;
|
||||
Latex(command, dummy);
|
||||
os << command;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetSpecialChar::Latex(string & file, signed char /*fragile*/) const
|
||||
{
|
||||
switch (kind) {
|
||||
@ -208,6 +220,7 @@ int InsetSpecialChar::Latex(string & file, signed char /*fragile*/) const
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetSpecialChar::Linuxdoc(string & file) const
|
||||
|
@ -60,8 +60,10 @@ public:
|
||||
void Read(LyXLex & lex);
|
||||
///
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string & file) const;
|
||||
///
|
||||
|
@ -99,16 +99,18 @@ void InsetText::Write(ostream & os) const
|
||||
WriteParagraphData(os);
|
||||
}
|
||||
|
||||
|
||||
void InsetText::WriteParagraphData(ostream & os) const
|
||||
{
|
||||
par->writeFile(os, buffer->params, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
void InsetText::Read(LyXLex & lex)
|
||||
{
|
||||
string token, tmptok;
|
||||
int pos = 0;
|
||||
LyXParagraph *return_par = 0;
|
||||
LyXParagraph * return_par = 0;
|
||||
char depth = 0; // signed or unsigned?
|
||||
LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
|
||||
LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
|
||||
@ -425,8 +427,9 @@ void InsetText::InsetKeyPress(XKeyEvent * xke)
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT InsetText::LocalDispatch(BufferView * bv,
|
||||
int action, string const & arg)
|
||||
UpdatableInset::RESULT
|
||||
InsetText::LocalDispatch(BufferView * bv,
|
||||
int action, string const & arg)
|
||||
{
|
||||
no_selection = false;
|
||||
if (UpdatableInset::LocalDispatch(bv, action, arg)) {
|
||||
@ -590,22 +593,32 @@ UpdatableInset::RESULT InsetText::LocalDispatch(BufferView * bv,
|
||||
}
|
||||
|
||||
|
||||
int InsetText::Latex(ostream & os, signed char fragile) const
|
||||
int InsetText::Latex(ostream & os, signed char /*fragile*/) const
|
||||
{
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
string fstr;
|
||||
TexRow texrow;
|
||||
int ret = par->SimpleTeXOnePar(fstr, texrow);
|
||||
os << fstr;
|
||||
return ret;
|
||||
#else
|
||||
string fstr;
|
||||
|
||||
int i = Latex(fstr, fragile);
|
||||
os << fstr;
|
||||
return i;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetText::Latex(string & file, signed char /* fragile */) const
|
||||
{
|
||||
TexRow texrow;
|
||||
|
||||
return par->SimpleTeXOnePar(file, texrow);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void InsetText::Validate(LaTeXFeatures & features) const
|
||||
|
@ -81,8 +81,10 @@ public:
|
||||
UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
|
||||
///
|
||||
int Latex(ostream &, signed char) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string &, signed char) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string &) const { return 0; }
|
||||
///
|
||||
|
@ -168,14 +168,24 @@ string InsetUrl::getScreenLabel() const
|
||||
|
||||
int InsetUrl::Latex(ostream & os, signed char fragile) const
|
||||
{
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
if (!getOptions().empty())
|
||||
os << getOptions() + ' ';
|
||||
if (fragile)
|
||||
os << "\\protect";
|
||||
os << "\\url{" << getContents() << '}';
|
||||
return 0;
|
||||
#else
|
||||
string latex_output;
|
||||
int res = Latex(latex_output, fragile);
|
||||
os << latex_output;
|
||||
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetUrl::Latex(string & file, signed char fragile) const
|
||||
{
|
||||
if (!getOptions().empty())
|
||||
@ -187,6 +197,7 @@ int InsetUrl::Latex(string & file, signed char fragile) const
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetUrl::Linuxdoc(string & file) const
|
||||
|
@ -71,8 +71,10 @@ public:
|
||||
void gotoLabel();
|
||||
///
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string & file) const;
|
||||
///
|
||||
|
@ -26,6 +26,8 @@ class BufferView;
|
||||
|
||||
struct LaTeXFeatures;
|
||||
|
||||
#define USE_OSTREAM_ONLY 1
|
||||
|
||||
/// Insets
|
||||
class Inset {
|
||||
public:
|
||||
@ -113,8 +115,10 @@ public:
|
||||
fragile commands by adding a \protect before.
|
||||
*/
|
||||
virtual int Latex(ostream &, signed char fragile) const = 0;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
virtual int Latex(string & file, signed char fragile) const = 0;
|
||||
#endif
|
||||
///
|
||||
virtual int Linuxdoc(string & /*file*/) const = 0;
|
||||
///
|
||||
|
@ -20,6 +20,7 @@
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
#include <clocale>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
|
@ -59,7 +59,8 @@ int MathedInset::df_des;
|
||||
int MathedInset::df_width;
|
||||
|
||||
|
||||
inline bool IsMacro(short token, int id)
|
||||
inline
|
||||
bool IsMacro(short token, int id)
|
||||
{
|
||||
return (token != LM_TK_FRAC && token != LM_TK_SQRT &&
|
||||
!((token == LM_TK_SYM || token == LM_TC_BSYM) && id < 255));
|
||||
@ -147,7 +148,7 @@ void mathed_init_fonts() //removed 'static' because DEC cxx does not
|
||||
|
||||
Math_Fonts = new LyXFont[8]; //DEC cxx cannot initialize all fonts
|
||||
//at once (JMarc) rc
|
||||
for (int i = 0 ; i < 8 ; ++i){
|
||||
for (int i = 0 ; i < 8 ; ++i) {
|
||||
Math_Fonts[i] = LyXFont(LyXFont::ALL_SANE);
|
||||
}
|
||||
Math_Fonts[0].setShape(LyXFont::ITALIC_SHAPE);
|
||||
@ -307,12 +308,21 @@ int InsetFormula::Latex(ostream & os, signed char fragile) const
|
||||
//#warning Alejandro, the number of lines is not returned in this case
|
||||
// This problem will disapear at 0.13.
|
||||
string output;
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
if (fragile < 0)
|
||||
par->Write(output);
|
||||
else
|
||||
mathed_write(par, output, &ret, fragile, label.c_str());
|
||||
|
||||
#else
|
||||
InsetFormula::Latex(output, fragile);
|
||||
#endif
|
||||
os << output;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetFormula::Latex(string & file, signed char fragile) const
|
||||
{
|
||||
int ret = 0;
|
||||
@ -324,6 +334,7 @@ int InsetFormula::Latex(string & file, signed char fragile) const
|
||||
mathed_write(par, file, &ret, fragile, label.c_str());
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetFormula::Linuxdoc(string &/*file*/) const
|
||||
|
@ -50,8 +50,10 @@ public:
|
||||
void Read(LyXLex & lex);
|
||||
///
|
||||
int Latex(ostream &, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string & file) const;
|
||||
///
|
||||
|
@ -78,12 +78,14 @@ int InsetFormulaMacro::Latex(ostream & os, signed char /*fragile*/) const
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
int InsetFormulaMacro::Latex(string &file, signed char /*fragile*/) const
|
||||
{
|
||||
int ret = 1;
|
||||
tmacro->WriteDef(file);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int InsetFormulaMacro::Linuxdoc(string &/*file*/) const
|
||||
|
@ -49,8 +49,10 @@ public:
|
||||
void Write(ostream & os) const;
|
||||
///
|
||||
int Latex(ostream & os, signed char fragile) const;
|
||||
#ifndef USE_OSTREAM_ONLY
|
||||
///
|
||||
int Latex(string & file, signed char fragile) const;
|
||||
#endif
|
||||
///
|
||||
int Linuxdoc(string & file) const;
|
||||
///
|
||||
|
@ -65,11 +65,13 @@ binary_op_pair binary_op_table[] = {
|
||||
|
||||
struct compara {
|
||||
// used by sort
|
||||
inline
|
||||
int operator()(binary_op_pair const & a,
|
||||
binary_op_pair const & b) const {
|
||||
return a.id < b.id;
|
||||
}
|
||||
// used by lower_bound
|
||||
inline
|
||||
int operator()(binary_op_pair const & a, short int id) const {
|
||||
return a.id < id;
|
||||
}
|
||||
@ -78,7 +80,8 @@ struct compara {
|
||||
|
||||
int MathedLookupBOP(short id)
|
||||
{
|
||||
static int bopCount = sizeof(binary_op_table) / sizeof(binary_op_pair);
|
||||
static int const bopCount =
|
||||
sizeof(binary_op_table) / sizeof(binary_op_pair);
|
||||
static bool issorted = false;
|
||||
|
||||
if (!issorted) {
|
||||
@ -89,7 +92,7 @@ int MathedLookupBOP(short id)
|
||||
binary_op_pair * res = lower_bound(binary_op_table,
|
||||
binary_op_table + bopCount,
|
||||
id, compara());
|
||||
if (res->id == id)
|
||||
if (res != binary_op_table + bopCount && res->id == id)
|
||||
return res->isrel;
|
||||
else
|
||||
return LMB_NONE;
|
||||
|
@ -1930,9 +1930,24 @@ LyXParagraph * LyXParagraph::TeXOnePar(string & file, TexRow & texrow,
|
||||
file += style.latexparam();
|
||||
break;
|
||||
case LATEX_ITEM_ENVIRONMENT:
|
||||
if (bibkey)
|
||||
if (bibkey) {
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
#ifdef HAVE_SSTREAM
|
||||
ostringstream ost;
|
||||
bibkey->Latex(ost, false);
|
||||
file += ost.str().c_str();
|
||||
#else
|
||||
ostrstream ost;
|
||||
bibkey->Latex(ost, false);
|
||||
ost << '\0';
|
||||
char * tmp = ost.str();
|
||||
file += tmp;
|
||||
delete [] tmp;
|
||||
#endif
|
||||
#else
|
||||
bibkey->Latex(file, false);
|
||||
else
|
||||
#endif
|
||||
} else
|
||||
file += "\\item ";
|
||||
break;
|
||||
case LATEX_LIST_ENVIRONMENT:
|
||||
@ -2942,7 +2957,22 @@ void LyXParagraph::SimpleTeXSpecialChars(string & file, TexRow & texrow,
|
||||
file += "\\L{";
|
||||
close = true;
|
||||
}
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
#ifdef HAVE_SSTREAM
|
||||
ostringstream ost;
|
||||
int tmp = inset->Latex(ost, style.isCommand());
|
||||
file += ost.str().c_str();
|
||||
#else
|
||||
ostrstream ost;
|
||||
int tmp = inset->Latex(ost, style.isCommand());
|
||||
ost << '\0';
|
||||
char * chtmp = ost.str();
|
||||
file += chtmp;
|
||||
delete [] chtmp;
|
||||
#endif
|
||||
#else
|
||||
int tmp = inset->Latex(file, style.isCommand());
|
||||
#endif
|
||||
if (close)
|
||||
file += "}";
|
||||
|
||||
|
@ -1025,6 +1025,25 @@ string findtexfile(string const & fil, string const & /*format*/)
|
||||
return MakeAbsPath(fil);
|
||||
|
||||
// No we try to find it using kpsewhich.
|
||||
// It seems from the kpsewhich manual page that it is safe to use
|
||||
// kpsewhich without --format: "When the --format option is not
|
||||
// given, the search path used when looking for a file is inferred
|
||||
// from the name given, by looking for a known extension. If no
|
||||
// known extension is found, the search path for TeX source files
|
||||
// is used."
|
||||
// However, we want to take advantage of the format sine almost all
|
||||
// the different formats has environment variables that can be used
|
||||
// to controll which paths to search. f.ex. bib looks in
|
||||
// BIBINPUTS and TEXBIB. Small list follows:
|
||||
// bib - BIBINPUTS, TEXBIB
|
||||
// bst - BSTINPUTS
|
||||
// graphic/figure - TEXPICTS, TEXINPUTS
|
||||
// ist - TEXINDEXSTYLE, INDEXSTYLE
|
||||
// pk - PROGRAMFONTS, PKFONTS, TEXPKS, GLYPHFONTS, TEXFONTS
|
||||
// tex - TEXINPUTS
|
||||
// tfm - TFMFONTS, TEXFONTS
|
||||
// This means that to use kpsewhich in the best possible way we
|
||||
// should help it by setting additional path in the approp. envir.var.
|
||||
string kpsecmd = "kpsewhich " + fil;
|
||||
|
||||
cmdret c = do_popen(kpsecmd);
|
||||
|
63
src/text.C
63
src/text.C
@ -2958,18 +2958,39 @@ char * LyXText::SelectNextWord(float & value)
|
||||
/* Start the selection from here */
|
||||
sel_cursor = cursor;
|
||||
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
#ifdef HAVE_SSTREAM
|
||||
ostringstream latex;
|
||||
#else
|
||||
ostrstream latex;
|
||||
#endif
|
||||
#else
|
||||
string latex;
|
||||
|
||||
#endif
|
||||
/* and find the end of the word
|
||||
(optional hyphens are part of a word) */
|
||||
while (cursor.pos < cursor.par->Last()
|
||||
&& (cursor.par->IsLetter(cursor.pos))
|
||||
|| (cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET &&
|
||||
cursor.par->GetInset(cursor.pos) != 0 &&
|
||||
cursor.par->GetInset(cursor.pos)->Latex(latex, 0) == 0 &&
|
||||
latex == "\\-"))
|
||||
|| (cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET
|
||||
&& cursor.par->GetInset(cursor.pos) != 0
|
||||
&& cursor.par->GetInset(cursor.pos)->Latex(latex, 0) == 0
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
#ifdef HAVE_SSTREAM
|
||||
&& latex.str() == "\\-"
|
||||
#else
|
||||
&& string(latex.str(), 3) == "\\-" // this is not nice at all
|
||||
#endif
|
||||
#else
|
||||
&& latex == "\\-"
|
||||
#endif
|
||||
))
|
||||
cursor.pos++;
|
||||
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
#ifndef HAVE_SSTREAM
|
||||
delete [] latex.str();
|
||||
#endif
|
||||
#endif
|
||||
// Finally, we copy the word to a string and return it
|
||||
char * str = 0;
|
||||
|
||||
@ -2995,17 +3016,39 @@ void LyXText::SelectSelectedWord()
|
||||
/* set the sel cursor */
|
||||
sel_cursor = cursor;
|
||||
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
#ifdef HAVE_SSTREAM
|
||||
ostringstream latex;
|
||||
#else
|
||||
ostrstream latex;
|
||||
#endif
|
||||
#else
|
||||
string latex;
|
||||
#endif
|
||||
|
||||
/* now find the end of the word */
|
||||
while (cursor.pos < cursor.par->Last()
|
||||
&& (cursor.par->IsLetter(cursor.pos)
|
||||
|| (cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET &&
|
||||
cursor.par->GetInset(cursor.pos) != 0 &&
|
||||
cursor.par->GetInset(cursor.pos)->Latex(latex, 0) == 0 &&
|
||||
latex == "\\-")))
|
||||
|| (cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET
|
||||
&& cursor.par->GetInset(cursor.pos) != 0
|
||||
&& cursor.par->GetInset(cursor.pos)->Latex(latex, 0) == 0
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
#ifdef HAVE_SSTREAM
|
||||
&& latex.str() == "\\-"
|
||||
#else
|
||||
&& string(latex.str(), 3) == "\\-"
|
||||
#endif
|
||||
#else
|
||||
&& latex == "\\-"
|
||||
#endif
|
||||
)))
|
||||
cursor.pos++;
|
||||
|
||||
#ifdef USE_OSTREAM_ONLY
|
||||
#ifndef HAVE_SSTREAM
|
||||
delete [] latex.str();
|
||||
#endif
|
||||
#endif
|
||||
SetCursor(cursor.par, cursor.pos);
|
||||
|
||||
/* finally set the selection */
|
||||
@ -4149,7 +4192,7 @@ int LyXText::GetColumnNearX(Row * row, int & x) const
|
||||
LyXDirection direction = row->par->getParDirection();
|
||||
LyXParagraph::size_type vc = row->pos;
|
||||
LyXParagraph::size_type last = RowLast(row);
|
||||
LyXParagraph::size_type c;
|
||||
LyXParagraph::size_type c = 0;
|
||||
|
||||
LyXLayout const & layout = textclasslist.Style(parameters->textclass,
|
||||
row->par->GetLayout());
|
||||
|
Loading…
Reference in New Issue
Block a user