fix lyxalgo.h, dra pagebreak with text on line, change the math_deco_search a bit

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@597 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-03-09 23:58:55 +00:00
parent 8dbf9d296e
commit fa492d6bf0
63 changed files with 1135 additions and 5689 deletions

View File

@ -1,3 +1,19 @@
2000-03-10 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/mathed/math_delim.C (search_deco): return a
math_deco_struct* instead of index.
2000-03-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* All files with a USE_OSTREAM_ONLY within: removed all code that
was unused when USE_OSTREAM_ONLY is defined.
* src/support/lyxalgo.h (sorted): rewrote to use plain '<' instead
of any less. Removed header and using.
* src/text.C (GetVisibleRow): draw the string "Page Break
(top/bottom)" on screen when drawing a pagebreak line.
2000-03-09 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* lib/doc/LaTeXConfig.lyx.in: add description of textclass llncs.

View File

@ -184,7 +184,7 @@ dnl Check the version of g++
elif test $ac_cv_prog_cxx_g = yes; then
case $gxx_version in
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
2.95.*) CXXFLAGS="-g $lyx_opt";;
2.96*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
*2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;

View File

@ -25,6 +25,7 @@ src/form1.C
src/gettext.h
src/insets/figinset.C
src/insets/figinset.h
src/insets/form_graphics.C
src/insets/form_url.C
src/insets/insetbib.C
src/insets/inseterror.C
@ -32,6 +33,7 @@ src/insets/inseterror.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetfoot.C
src/insets/insetgraphics.C
src/insets/insetinclude.C
src/insets/insetindex.C
src/insets/insetinfo.C

1707
po/no.po

File diff suppressed because it is too large Load Diff

View File

@ -1576,7 +1576,6 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
}
#ifdef USE_OSTREAM_ONLY
void Buffer::makeLaTeXFile(string const & fname,
string const & original_path,
bool nice, bool only_body)
@ -2108,531 +2107,6 @@ void Buffer::makeLaTeXFile(string const & fname,
lyxerr.debug() << "Finished making latex file." << endl;
}
#else
void Buffer::makeLaTeXFile(string const & fname,
string const & original_path,
bool nice, bool only_body)
{
lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
niceFile = nice; // this will be used by Insetincludes.
tex_code_break_column = lyxrc->ascii_linelen;
LyXTextClass const & tclass =
textclasslist.TextClass(params.textclass);
ofstream ofs(fname.c_str());
if (!ofs) {
WriteFSAlert(_("Error: Cannot open file: "), fname);
return;
}
// validate the buffer.
lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
LaTeXFeatures features(tclass.numLayouts());
validate(features);
lyxerr[Debug::LATEX] << " Buffer validation done." << endl;
texrow.reset();
// The starting paragraph of the coming rows is the
// first paragraph of the document. (Asger)
texrow.start(paragraph, 0);
string LFile;
if (!only_body && nice) {
LFile += "%% " LYX_DOCVERSION " created this file. "
"For more info, see http://www.lyx.org/.\n";
LFile += "%% Do not edit unless you really know what you are doing.\n";
texrow.newline();
texrow.newline();
}
lyxerr.debug() << "lyx header finished" << endl;
// There are a few differences between nice LaTeX and usual files:
// usual is \batchmode and has a
// special input@path to allow the including of figures
// with either \input or \includegraphics (what figinsets do).
// batchmode is not set if there is a tex_code_break_column.
// In this case somebody is interested in the generated LaTeX,
// so this is OK. input@path is set when the actual parameter
// original_path is set. This is done for usual tex-file, but not
// for nice-latex-file. (Matthias 250696)
if (!only_body) {
if (!nice){
// code for usual, NOT nice-latex-file
LFile += "\\batchmode\n"; // changed
// from \nonstopmode
texrow.newline();
}
if (!original_path.empty()) {
LFile += "\\makeatletter\n";
texrow.newline();
LFile += "\\def\\input@path{{" + original_path
+ "/}}\n";
texrow.newline();
LFile += "\\makeatother\n";
texrow.newline();
}
LFile += "\\documentclass";
string options; // the document class options.
if (tokenPos(tclass.opt_fontsize(), '|', params.fontsize) >= 0) {
// only write if existing in list (and not default)
options += params.fontsize;
options += "pt,";
}
if (!params.use_geometry &&
(params.paperpackage == BufferParams::PACKAGE_NONE)) {
switch (params.papersize) {
case BufferParams::PAPER_A4PAPER:
options += "a4paper,";
break;
case BufferParams::PAPER_USLETTER:
options += "letterpaper,";
break;
case BufferParams::PAPER_A5PAPER:
options += "a5paper,";
break;
case BufferParams::PAPER_B5PAPER:
options += "b5paper,";
break;
case BufferParams::PAPER_EXECUTIVEPAPER:
options += "executivepaper,";
break;
case BufferParams::PAPER_LEGALPAPER:
options += "legalpaper,";
break;
}
}
// if needed
if (params.sides != tclass.sides()) {
switch (params.sides) {
case LyXTextClass::OneSide:
options += "oneside,";
break;
case LyXTextClass::TwoSides:
options += "twoside,";
break;
}
}
// if needed
if (params.columns != tclass.columns()) {
if (params.columns == 2)
options += "twocolumn,";
else
options += "onecolumn,";
}
if (!params.use_geometry
&& params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
options += "landscape,";
// language should be a parameter to \documentclass
if (params.language != "default") {
if (params.language == "hebrew")
options += "english,";
else if (lyxrc->rtl_support)
options += "hebrew,";
options += params.language + ',';
} else if (lyxrc->rtl_support)
options += "hebrew,english,";
// the user-defined options
if (!params.options.empty()) {
options += params.options + ',';
}
if (!options.empty()){
options = strip(options, ',');
LFile += '[';
LFile += options;
LFile += ']';
}
LFile += '{';
LFile += textclasslist.LatexnameOfClass(params.textclass);
LFile += "}\n";
texrow.newline();
// end of \documentclass defs
// font selection must be done before loading fontenc.sty
if (params.fonts != "default") {
LFile += "\\usepackage{" + params.fonts + "}\n";
texrow.newline();
}
// this one is not per buffer
if (lyxrc->fontenc != "default") {
LFile += "\\usepackage[" + lyxrc->fontenc
+ "]{fontenc}\n";
texrow.newline();
}
if (params.inputenc != "default") {
LFile += "\\usepackage[" + params.inputenc
+ "]{inputenc}\n";
texrow.newline();
}
/* at the very beginning the text parameters */
if (params.paperpackage != BufferParams::PACKAGE_NONE) {
switch (params.paperpackage) {
case BufferParams::PACKAGE_A4:
LFile += "\\usepackage{a4}\n";
texrow.newline();
break;
case BufferParams::PACKAGE_A4WIDE:
LFile += "\\usepackage{a4wide}\n";
texrow.newline();
break;
case BufferParams::PACKAGE_WIDEMARGINSA4:
LFile += "\\usepackage[widemargins]{a4}\n";
texrow.newline();
break;
}
}
if (params.use_geometry) {
LFile += "\\usepackage{geometry}\n";
texrow.newline();
LFile += "\\geometry{verbose";
if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
LFile += ",landscape";
switch (params.papersize2) {
case BufferParams::VM_PAPER_CUSTOM:
if (!params.paperwidth.empty())
LFile += ",paperwidth="
+ params.paperwidth;
if (!params.paperheight.empty())
LFile += ",paperheight="
+ params.paperheight;
break;
case BufferParams::VM_PAPER_USLETTER:
LFile += ",letterpaper";
break;
case BufferParams::VM_PAPER_USLEGAL:
LFile += ",legalpaper";
break;
case BufferParams::VM_PAPER_USEXECUTIVE:
LFile += ",executivepaper";
break;
case BufferParams::VM_PAPER_A3:
LFile += ",a3paper";
break;
case BufferParams::VM_PAPER_A4:
LFile += ",a4paper";
break;
case BufferParams::VM_PAPER_A5:
LFile += ",a5paper";
break;
case BufferParams::VM_PAPER_B3:
LFile += ",b3paper";
break;
case BufferParams::VM_PAPER_B4:
LFile += ",b4paper";
break;
case BufferParams::VM_PAPER_B5:
LFile += ",b5paper";
break;
default:
// default papersize ie BufferParams::VM_PAPER_DEFAULT
switch (lyxrc->default_papersize) {
case BufferParams::PAPER_DEFAULT: // keep compiler happy
case BufferParams::PAPER_USLETTER:
LFile += ",letterpaper";
break;
case BufferParams::PAPER_LEGALPAPER:
LFile += ",legalpaper";
break;
case BufferParams::PAPER_EXECUTIVEPAPER:
LFile += ",executivepaper";
break;
case BufferParams::PAPER_A3PAPER:
LFile += ",a3paper";
break;
case BufferParams::PAPER_A4PAPER:
LFile += ",a4paper";
break;
case BufferParams::PAPER_A5PAPER:
LFile += ",a5paper";
break;
case BufferParams::PAPER_B5PAPER:
LFile += ",b5paper";
break;
}
}
if (!params.topmargin.empty())
LFile += ",tmargin=" + params.topmargin;
if (!params.bottommargin.empty())
LFile += ",bmargin=" + params.bottommargin;
if (!params.leftmargin.empty())
LFile += ",lmargin=" + params.leftmargin;
if (!params.rightmargin.empty())
LFile += ",rmargin=" + params.rightmargin;
if (!params.headheight.empty())
LFile += ",headheight=" + params.headheight;
if (!params.headsep.empty())
LFile += ",headsep=" + params.headsep;
if (!params.footskip.empty())
LFile += ",footskip=" + params.footskip;
LFile += "}\n";
texrow.newline();
}
if (params.use_amsmath
&& !prefixIs(textclasslist.LatexnameOfClass(params.textclass), "ams")) {
LFile += "\\usepackage{amsmath}\n";
}
if (tokenPos(tclass.opt_pagestyle(), '|', params.pagestyle) >= 0) {
if (params.pagestyle == "fancy") {
LFile += "\\usepackage{fancyhdr}\n";
texrow.newline();
}
LFile += "\\pagestyle{" + params.pagestyle + "}\n";
texrow.newline();
}
// We try to load babel late, in case it interferes
// with other packages.
if (params.language != "default" || lyxrc->rtl_support ) {
LFile += "\\usepackage{babel}\n";
texrow.newline();
}
if (params.secnumdepth != tclass.secnumdepth()) {
LFile += "\\setcounter{secnumdepth}{";
LFile += tostr(params.secnumdepth);
LFile += "}\n";
texrow.newline();
}
if (params.tocdepth != tclass.tocdepth()) {
LFile += "\\setcounter{tocdepth}{";
LFile += tostr(params.tocdepth);
LFile += "}\n";
texrow.newline();
}
if (params.paragraph_separation) {
switch (params.defskip.kind()) {
case VSpace::SMALLSKIP:
LFile += "\\setlength\\parskip{\\smallskipamount}\n";
break;
case VSpace::MEDSKIP:
LFile += "\\setlength\\parskip{\\medskipamount}\n";
break;
case VSpace::BIGSKIP:
LFile += "\\setlength\\parskip{\\bigskipamount}\n";
break;
case VSpace::LENGTH:
LFile += "\\setlength\\parskip{"
+ params.defskip.length().asLatexString()
+ "}\n";
break;
default: // should never happen // Then delete it.
LFile += "\\setlength\\parskip{\\medskipamount}\n";
break;
}
texrow.newline();
LFile += "\\setlength\\parindent{0pt}\n";
texrow.newline();
}
// Write out what we've generated so far...and reset LFile
ofs << LFile;
LFile.clear();
// Now insert the LyX specific LaTeX commands...
string preamble, tmppreamble;
// The optional packages;
preamble = features.getPackages(params);
// this might be useful...
preamble += "\n\\makeatletter\n\n";
// Some macros LyX will need
tmppreamble = features.getMacros(params);
if (!tmppreamble.empty()) {
preamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
"LyX specific LaTeX commands.\n"
+ tmppreamble + '\n';
}
// the text class specific preamble
tmppreamble = features.getTClassPreamble(params);
if (!tmppreamble.empty()) {
preamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
"Textclass specific LaTeX commands.\n"
+ tmppreamble + '\n';
}
/* the user-defined preamble */
if (!params.preamble.empty()) {
preamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
"User specified LaTeX commands.\n"
+ params.preamble + '\n';
}
preamble += "\\makeatother\n\n";
// Itemize bullet settings need to be last in case the user
// defines their own bullets that use a package included
// in the user-defined preamble -- ARRae
// Actually it has to be done much later than that
// since some packages like frenchb make modifications
// at \begin{document} time -- JMarc
string bullets_def;
for (int i = 0; i < 4; ++i) {
if (params.user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
if (bullets_def.empty())
bullets_def="\\AtBeginDocument{\n";
bullets_def += " \\renewcommand{\\labelitemi";
switch (i) {
// `i' is one less than the item to modify
case 0:
break;
case 1:
bullets_def += 'i';
break;
case 2:
bullets_def += "ii";
break;
case 3:
bullets_def += 'v';
break;
}
bullets_def += "}{" +
params.user_defined_bullets[i].getText()
+ "}\n";
}
}
if (!bullets_def.empty())
preamble += bullets_def + "}\n\n";
for (int j = countChar(preamble, '\n'); j-- ;) {
texrow.newline();
}
ofs << preamble;
// make the body.
LFile += "\\begin{document}\n\n";
texrow.newline();
texrow.newline();
} // only_body
lyxerr.debug() << "preamble finished, now the body." << endl;
bool was_title = false;
bool already_title = false;
string ftnote;
TexRow ft_texrow;
int ftcount = 0;
int loop_count = 0;
LyXParagraph * par = paragraph;
// if only_body
while (par) {
++loop_count;
if (par->IsDummy())
lyxerr[Debug::LATEX] << "Error in MakeLateXFile."
<< endl;
LyXLayout const & layout =
textclasslist.Style(params.textclass,
par->layout);
if (layout.intitle) {
if (already_title) {
lyxerr <<"Error in MakeLatexFile: You"
" should not mix title layouts"
" with normal ones." << endl;
} else
was_title = true;
} else if (was_title && !already_title) {
LFile += "\\maketitle\n";
texrow.newline();
already_title = true;
was_title = false;
}
// We are at depth 0 so we can just use
// ordinary \footnote{} generation
// flag this with ftcount
ftcount = -1;
if (layout.isEnvironment()
|| par->pextra_type != LyXParagraph::PEXTRA_NONE) {
par = par->TeXEnvironment(LFile, texrow,
ftnote, ft_texrow, ftcount);
} else {
par = par->TeXOnePar(LFile, texrow,
ftnote, ft_texrow, ftcount);
}
// Write out what we've generated...and reset LFile
if (ftcount >= 1) {
if (ftcount > 1) {
LFile += "\\addtocounter{footnote}{-";
LFile += tostr(ftcount - 1);
LFile += '}';
}
LFile += ftnote;
texrow += ft_texrow;
ftnote.clear();
ft_texrow.reset();
ftcount = 0;
}
if (loop_count == 2) {
// fwrite()ing every second time through the loop
// gains a few extra % of speed; going higher than
// 2 will slow things down again. I'll look at
// LFile.length() in a future revision. ARRae
ofs << LFile;
LFile.clear();
loop_count = 0;
}
}
// It might be that we only have a title in this document
if (was_title && !already_title) {
LFile += "\\maketitle\n";
texrow.newline();
}
if (!only_body) {
LFile += "\\end{document}\n";
texrow.newline();
lyxerr[Debug::LATEX] << "makeLaTeXFile...done" << endl;
} else {
lyxerr[Debug::LATEX] << "LaTeXFile for inclusion made."
<< endl;
}
// Just to be sure. (Asger)
texrow.newline();
// Write out what we've generated...and reset LFile
ofs << LFile;
LFile.clear();
// tex_code_break_column's value is used to decide
// if we are in batchmode or not (within mathed_write()
// in math_write.C) so we must set it to a non-zero
// value when we leave otherwise we save incorrect .lyx files.
tex_code_break_column = lyxrc->ascii_linelen;
// How to check if the close went ok when using fstreams
ofs.close();
lyxerr.debug() << "Finished making latex file." << endl;
}
#endif
bool Buffer::isLatex() const
@ -2878,24 +2352,12 @@ void Buffer::DocBookHandleCaption(ostream & os, string & inner_tag,
tpar->layout == textclasslist.NumberOfLayout(params.textclass,
"Caption").second) {
sgmlOpenTag(os, depth + 1, inner_tag);
#ifdef USE_OSTREAM_ONLY
string extra_par;
SimpleDocBookOnePar(os, extra_par, tpar,
desc_on, depth + 2);
sgmlCloseTag(os, depth+1, inner_tag);
if(!extra_par.empty())
os << extra_par;
#else
string tmp_par, extra_par;
SimpleDocBookOnePar(tmp_par, extra_par, tpar,
desc_on, depth + 2);
tmp_par = strip(tmp_par);
tmp_par = frontStrip(tmp_par);
os << tmp_par;
sgmlCloseTag(os, depth+1, inner_tag);
if(!extra_par.empty())
os << extra_par;
#endif
}
}
@ -2981,7 +2443,6 @@ void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par,
if (par->layout != textclasslist
.NumberOfLayout(params.textclass,
"Caption").second) {
#ifdef USE_OSTREAM_ONLY
#ifdef HAVE_SSTREAM
ostringstream ost;
#else
@ -2996,8 +2457,6 @@ void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par,
char * ctmp = ost.str();
tmp_par += ctmp;
delete [] ctmp;
#endif
#else
#endif
}
tmp_par = frontStrip(strip(tmp_par));
@ -3209,15 +2668,8 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par,
++char_line_count;
} else if (c == LyXParagraph::META_INSET) {
inset = par->GetInset(i);
#ifdef USE_OSTREAM_ONLY
inset->Linuxdoc(os);
#else
string tmp_out;
inset->Linuxdoc(tmp_out);
os << tmp_out;
#endif
}
else {
} else {
string sgml_string;
if (par->linuxDocConvertChar(c, sgml_string)
&& !style.free_spacing) { // in freespacing
@ -3503,24 +2955,12 @@ void Buffer::makeDocBookFile(string const & fname, int column)
}
do {
#ifdef USE_OSTREAM_ONLY
string extra_par;
SimpleDocBookOnePar(ofs, extra_par, par, desc_on,
depth + 1 + command_depth);
par = par->next;
DocBookHandleFootnote(ofs, par,
depth + 1 + command_depth);
#else
string tmp_par, extra_par;
SimpleDocBookOnePar(tmp_par, extra_par, par, desc_on,
depth + 1 + command_depth);
ofs << tmp_par;
par = par->next;
DocBookHandleFootnote(ofs, par,
depth + 1 + command_depth);
#endif
}
while(par && par->IsDummy());
@ -3582,7 +3022,6 @@ void Buffer::makeDocBookFile(string const & fname, int column)
}
#ifdef USE_OSTREAM_ONLY
void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
LyXParagraph * par, int & desc_on,
int const depth)
@ -3713,133 +3152,6 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
}
os << '\n';
}
#else
void Buffer::SimpleDocBookOnePar(string & file, string & extra,
LyXParagraph * par, int & desc_on,
int const depth)
{
if (par->table) {
par->SimpleDocBookOneTablePar(file, extra, desc_on, depth);
return;
}
LyXFont font1, font2;
char c;
Inset * inset;
LyXParagraph::size_type main_body;
int j;
string emph= "emphasis";
bool emph_flag= false;
LyXLayout const & style = textclasslist.Style(params.textclass,
par->GetLayout());
if (style.labeltype != LABEL_MANUAL)
main_body = 0;
else
main_body = par->BeginningOfMainBody();
/* gets paragraph main font */
if (main_body > 0)
font1 = style.labelfont;
else
font1 = style.font;
int char_line_count = depth;
if(!style.free_spacing)
for (j = 0; j < depth; ++j)
file += ' ';
/* parsing main loop */
for (LyXParagraph::size_type i = 0;
i < par->size(); ++i) {
font2 = par->getFont(i);
/* handle <emphasis> tag */
if (font1.emph() != font2.emph() && i) {
if (font2.emph() == LyXFont::ON) {
file += "<emphasis>";
emph_flag= true;
}else {
file += "</emphasis>";
emph_flag= false;
}
}
c = par->GetChar(i);
if (c == LyXParagraph::META_INSET) {
inset = par->GetInset(i);
string tmp_out;
inset->DocBook(tmp_out);
//
// This code needs some explanation:
// Two insets are treated specially
// label if it is the first element in a command paragraph
// desc_on == 3
// graphics inside tables or figure floats can't go on
// title (the equivalente in latex for this case is caption
// and title should come first
// desc_on == 4
//
if(desc_on!= 3 || i!= 0) {
if(!tmp_out.empty() && tmp_out[0] == '@') {
if(desc_on == 4)
extra += frontStrip(tmp_out, '@');
else
file += frontStrip(tmp_out, '@');
}
else
file += tmp_out;
}
} else if (font2.latex() == LyXFont::ON) {
// "TeX"-Mode on ==> SGML-Mode on.
if (c!= '\0')
file += c;
++char_line_count;
}
else {
string sgml_string;
if (par->linuxDocConvertChar(c, sgml_string)
&& !style.free_spacing) { // in freespacing
// mode, spaces are
// non-breaking characters
// char is ' '
if (desc_on == 1) {
++char_line_count;
file += '\n';
file += "</term><listitem><para>";
desc_on = 2;
}
else {
file += c;
}
}
else {
file += sgml_string;
}
}
font1 = font2;
}
/* needed if there is an optional argument but no contents */
if (main_body > 0 && main_body == par->size()) {
font1 = style.font;
}
if (emph_flag) {
file += "</emphasis>";
}
/* resets description flag correctly */
switch(desc_on){
case 1:
/* <term> not closed... */
file += "</term>";
break;
}
file += '\n';
}
#endif
int Buffer::runLaTeX()

View File

@ -357,17 +357,10 @@ private:
///
void SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par,
int desc_on, int const depth);
#ifdef USE_OSTREAM_ONLY
///
void SimpleDocBookOnePar(ostream &, string & extra,
LyXParagraph * par, int & desc_on,
int const depth);
#else
///
void SimpleDocBookOnePar(string & file, string & extra,
LyXParagraph * par, int & desc_on,
int const depth);
#endif
/// LinuxDoc.
void push_tag(ostream & os, char const * tag,

View File

@ -9,6 +9,8 @@ libinsets_la_SOURCES = \
BoundingBox.h \
figinset.C \
figinset.h \
form_graphics.C \
form_graphics.h \
form_url.C \
form_url.h \
inset.C \

View File

@ -109,9 +109,6 @@ static int gs_allcolors; // number of all colors
static list<int> pidwaitlist; // pid wait list
//extern Colormap color_map;
static
GC createGC()
@ -149,8 +146,9 @@ void addpidwait(int pid)
}
extern "C" int GhostscriptMsg(FL_OBJECT *, Window, int, int,
XEvent * ev, void *)
extern "C"
int GhostscriptMsg(FL_OBJECT *, Window, int, int,
XEvent * ev, void *)
{
char tmp[128];
@ -1202,34 +1200,6 @@ int InsetFig::Latex(ostream & os, signed char /* fragile*/, bool /* fs*/) const
}
#ifndef USE_OSTREAM_ONLY
int InsetFig::Latex(string & file, signed char /* fragile*/, bool/* fs*/) const
{
Regenerate();
file += cmd + ' ';
return 0;
}
int InsetFig::Linuxdoc(string &/*file*/) const
{
return 0;
}
int InsetFig::DocBook(string & file) const
{
string figurename = fname;
if(suffixIs(figurename, ".eps"))
figurename.erase(fname.length() - 5);
file += "@<graphic fileref=\"" + figurename + "\"></graphic>";
return 0;
}
#else
int InsetFig::Linuxdoc(ostream &) const
{
return 0;
@ -1246,7 +1216,6 @@ int InsetFig::DocBook(ostream & os) const
os << "@<graphic fileref=\"" << figurename << "\"></graphic>";
return 0;
}
#endif
void InsetFig::Validate(LaTeXFeatures & features) const

View File

@ -39,19 +39,10 @@ public:
void Read(LyXLex & lex);
///
int Latex(ostream &, signed char fragile, bool free_space) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_space) const;
///
int Linuxdoc(string & file) const;
///
int DocBook(string & file) const;
#else
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#endif
/// Updates needed features for this inset.
void Validate(LaTeXFeatures & features) const;

View File

@ -239,7 +239,6 @@ void InsetBibKey::setCounter(int c)
// of time cause LyX3 won't use lyxlex anyway. (ale)
void InsetBibKey::Write(ostream & os) const
{
#ifdef USE_OSTREAM_ONLY
os << "\\bibitem ";
if (!options.empty()) {
os << '['
@ -247,16 +246,6 @@ void InsetBibKey::Write(ostream & os) const
}
os << '{'
<< contents << "}\n";
#else
string s;
if (!options.empty()) {
s += '[';
s += options + ']';
}
s += '{';
s += contents + '}';
os << "\\bibitem " << s << "\n";
#endif
}
@ -323,7 +312,6 @@ string InsetBibtex::getScreenLabel() const
int InsetBibtex::Latex(ostream & os, signed char /*fragile*/, bool/*fs*/) 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
@ -358,60 +346,9 @@ int InsetBibtex::Latex(ostream & os, signed char /*fragile*/, bool/*fs*/) const
os << "\\bibliographystyle{" << style << "}\n"
<< "\\bibliography{" << db_out << "}\n";
return 2;
#else
string bib;
signed char dummy = 0;
int result = Latex(bib, dummy, 0);
os << bib;
return result;
#endif
}
#ifndef USE_OSTREAM_ONLY
int InsetBibtex::Latex(string & file, signed char /*fragile*/, bool/*fs*/) const
{
// 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();
file += "\\bibliographystyle{";
file += style;
file += "}\n";
file += "\\bibliography{";
file += db_out;
file += "}\n";
return 2;
}
#endif
// This method returns a comma separated list of Bibtex entries
string InsetBibtex::getKeys(char delim)
{

View File

@ -128,10 +128,6 @@ public:
void Edit(BufferView *, int x, int y, unsigned int button);
///
int Latex(ostream &, signed char, bool) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool) const;
#endif
///
string getKeys(char delim);
///

View File

@ -251,27 +251,6 @@ int InsetCommand::Latex(ostream & os, signed char /*fragile*/, bool/*fs*/) const
}
#ifndef USE_OSTREAM_ONLY
int InsetCommand::Latex(string & file, signed char /*fragile*/, bool/*fs*/) const
{
file += getCommand();
return 0;
}
int InsetCommand::Linuxdoc(string &/*file*/) const
{
return 0;
}
int InsetCommand::DocBook(string &/*file*/) const
{
return 0;
}
#else
int InsetCommand::Linuxdoc(ostream &) const
{
return 0;
@ -282,7 +261,6 @@ int InsetCommand::DocBook(ostream &) const
{
return 0;
}
#endif
Inset * InsetCommand::Clone() const

View File

@ -48,19 +48,10 @@ public:
void Read(LyXLex & lex);
///
virtual int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
virtual int Latex(string & file, signed char fragile, bool free_spc) const;
///
virtual int Linuxdoc(string & file) const;
///
virtual int DocBook(string & file) const;
#else
///
virtual int Linuxdoc(ostream &) const;
///
virtual int DocBook(ostream &) const;
#endif
///
Inset * Clone() const;
///

View File

@ -107,26 +107,6 @@ int InsetError::Latex(ostream &, signed char /*fragile*/, bool /*fs*/) const
}
#ifndef USE_OSTREAM_ONLY
int InsetError::Latex(string &, signed char /*fragile*/, bool /*fs*/) const
{
return 0;
}
int InsetError::Linuxdoc(string &) const
{
return 0;
}
int InsetError::DocBook(string &) const
{
return 0;
}
#else
int InsetError::Linuxdoc(ostream &) const
{
return 0;
@ -137,7 +117,6 @@ int InsetError::DocBook(ostream &) const
{
return 0;
}
#endif
bool InsetError::AutoDelete() const

View File

@ -48,19 +48,10 @@ public:
void Read(LyXLex & lex);
///
int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
///
int Linuxdoc(string & file) const;
///
int DocBook(string & file) const;
#else
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#endif
///
bool AutoDelete() const;
/// what appears in the minibuffer when opening

View File

@ -3,7 +3,7 @@
*
* LyX, The Document Processor
*
* Copyright (C) 1998 The LyX Team.
* Copyright 1998 The LyX Team.
*
*======================================================*/
@ -40,62 +40,43 @@ Inset * InsetFoot::Clone() const
}
const char * InsetFoot::EditMessage() const
char const * InsetFoot::EditMessage() const
{
return _("Opened Footnote Inset");
}
#ifndef USE_OSTREAM_ONLY
int InsetFoot::Latex(string & l, signed char fragile) const
{
int i;
if (fragile)
l += "\\footnotetext{";
else
l += "\\footnote{";
i = InsetText::Latex(l, fragile);
l += "}";
return i;
}
#endif
int InsetFoot::Latex(ostream & os, signed char fragile, bool fp) const
{
int i;
if (fragile)
os << "\\footnotetext{";
else
os << "\\footnote{";
i = InsetText::Latex(os, fragile, fp);
os << "}";
return i;
if (fragile)
os << "\\footnotetext{";
else
os << "\\footnote{";
int i = InsetText::Latex(os, fragile, fp);
os << "}";
return i;
}
void InsetFoot::Write(ostream & os) const
{
os << "Foot\n";
os << "\ncollapsed ";
if (display())
os << "false";
else
os << "true";
os << "\n";
WriteParagraphData(os);
os << "Foot\n"
<< "\ncollapsed ";
if (display())
os << "false\n";
else
os << "true\n";
WriteParagraphData(os);
}
void InsetFoot::Read(LyXLex & lex)
{
if (lex.IsOK()) {
string token, tmptok;
lex.next();
token = lex.GetString();
string token = lex.GetString();
if (token == "collapsed") {
lex.next();
collapsed = lex.GetBool();
@ -104,7 +85,8 @@ void InsetFoot::Read(LyXLex & lex)
InsetText::Read(lex);
}
bool InsetFoot::InsertInset(BufferView *bv, Inset * inset)
bool InsetFoot::InsertInset(BufferView * bv, Inset * inset)
{
if ((inset->LyxCode() == Inset::FOOT_CODE) ||
(inset->LyxCode() == Inset::MARGIN_CODE)) {

View File

@ -36,10 +36,6 @@ public:
Inset * Clone() const;
///
Inset::Code LyxCode() const { return Inset::FOOT_CODE; }
#ifndef USE_OSTREAM_ONLY
///
int Latex(string &, signed char) const;
#endif
///
int Latex(ostream &, signed char, bool fp) const;
///

View File

@ -16,6 +16,95 @@
#include "insets/insetgraphics.h"
#include "Painter.h"
#include "form_graphics.h"
#include "lyx_gui_misc.h"
#include "filedlg.h"
#include "support/FileInfo.h"
#include "support/filetools.h"
extern string system_lyxdir;
extern string user_lyxdir;
extern string system_tempdir;
string browseFile();
void GraphicxCB(FL_OBJECT * obj, long arg)
{
lyxerr << "GraphicxCB: obj = " << obj << " arg = " << arg << endl;
switch (arg) {
case 0: // The graphics file
lyxerr << "Set the graphics file in InsetGraphics" << endl;
break;
case 1: // The file browser
browseFile();
break;
case 2: // The Apply button
lyxerr << "Scan the form and set the "
"InsetGraphics accordingly." << endl;
break;
case 3: // The OK button
GraphicxCB(obj, 2); // do the apply
GraphicxCB(obj, 4); // do the cancel
break;
case 4: // The Cancel button
lyxerr << "Just hide the form and do nothing else!" << endl;
break;
case 99:
lyxerr << "Not implemented yet..." << endl;
break;
default:
lyxerr << "Unknown callback value!" << endl;
break;
}
}
string browseFile()
{
// This function is probably not good enough yet, and does need some
// arguemnts to tell what dir to start looking in.
static string current_figure_path = ".";
LyXFileDlg fileDlg;
// Does user clipart directory exist?
string bufclip = AddName (user_lyxdir, "clipart");
FileInfo fileInfo(bufclip);
if (!(fileInfo.isOK() && fileInfo.isDir()))
// No - bail out to system clipart directory
bufclip = AddName (system_lyxdir, "clipart");
fileDlg.SetButton(0, _("Clipart"), bufclip);
bool error = false;
string buf;
do {
string p = fileDlg.Select(_("Graphics"),
current_figure_path,
"*ps", string());
if (p.empty()) return p;
current_figure_path = OnlyPath(p);
if (p.find_first_of("#~$% ") != string::npos) {
WriteAlert(_("Filename can't contain any "
"of these characters:"),
// xgettext:no-c-format
_("space, '#', '~', '$' or '%'."));
error = true;
}
} while (error);
return buf;
}
InsetGraphics::InsetGraphics()
: form(0)
{}
int InsetGraphics::ascent(Painter &, LyXFont const &) const
@ -54,8 +143,22 @@ void InsetGraphics::draw(Painter & pain, LyXFont const & font,
void InsetGraphics::Edit(BufferView *, int, int, unsigned int)
{
// Here we want to popup a dialog from which we get the
// graphics paramters.
lyxerr.debug() << "InsetGraphics::Edit" << endl;
if (!form) {
form = create_form_Graphics();
fl_set_form_atclose(form->Graphics, CancelCloseBoxCB, 0);
fl_set_object_return(form->Angle, FL_RETURN_ALWAYS);
fl_set_object_return(form->Width, FL_RETURN_ALWAYS);
fl_set_object_return(form->Height, FL_RETURN_ALWAYS);
}
if (form->Graphics->visible) {
fl_raise_form(form->Graphics);
} else {
fl_show_form(form->Graphics, FL_PLACE_MOUSE | FL_PLACE_SIZE,
FL_FULLBORDER, _("Graphics"));
}
}
@ -69,6 +172,8 @@ void InsetGraphics::Write(ostream & os) const
{
// The question on the file format is still open.
// Suggestions?
// perhaps a format that is xml-parsable
//<graphics name="test.eps"/>
os << "GRAPHICS\n";
}
@ -225,26 +330,6 @@ int InsetGraphics::Latex(ostream & os, signed char /*fragile*/, bool/*fs*/) cons
}
#ifndef USE_OSTREAM_ONLY
int InsetGraphics::Latex(string & /*file*/, signed char /*fragile*/, bool/*fs*/) const
{
return 0;
}
int InsetGraphics::Linuxdoc(string & /*file*/) const
{
return 0;
}
int InsetGraphics::DocBook(string & /*file*/) const
{
return 0;
}
#else
int InsetGraphics::Linuxdoc(ostream &) const
{
return 0;
@ -255,7 +340,6 @@ int InsetGraphics::DocBook(ostream &) const
{
return 0;
}
#endif
void InsetGraphics::Validate(LaTeXFeatures & /*features*/) const

View File

@ -21,9 +21,13 @@
#include "vspace.h"
#include "insets/BoundingBox.h"
struct FD_Graphics;
///
class InsetGraphics : public Inset {
public:
///
InsetGraphics();
///
int ascent(Painter &, LyXFont const &) const;
///
@ -46,19 +50,11 @@ public:
fragile commands by adding a \protect before.
*/
int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
///
int Linuxdoc(string & /*file*/) const;
///
int DocBook(string & /*file*/) const;
#else
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#endif
/// Updates needed features for this inset.
void Validate(LaTeXFeatures & features) const;
@ -67,7 +63,17 @@ public:
///
Inset * Clone() const;
/// Set the graphics file
void graphicsFile(string const & f) {
graphicsfile = f;
}
/// Get the graphics file
string const & graphicsFile() const {
return graphicsfile;
}
private:
///
FD_Graphics * form;
///
string graphicsfile;
///

View File

@ -317,7 +317,6 @@ bool InsetInclude::loadIfNeeded() const
int InsetInclude::Latex(ostream & os, signed char /*fragile*/, bool /*fs*/) const
{
#ifdef USE_OSTREAM_ONLY
// Do nothing if no file name has been specified
if (contents.empty())
return 0;
@ -383,94 +382,9 @@ int InsetInclude::Latex(ostream & os, signed char /*fragile*/, bool /*fs*/) cons
}
return 0;
#else
string include_file;
signed char dummy = 0;
Latex(include_file, dummy, 0);
os << include_file;
return 0;
#endif
}
#ifndef USE_OSTREAM_ONLY
int InsetInclude::Latex(string & file, signed char /*fragile*/, bool /*fs*/) 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, '/','@');
#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()) {
file += '\\';
file += command + '{';
file += incfile + '}';
}
else if (isInput()) {
// \input wants file with extension (default is .tex)
if (!IsLyXFilename(getFileName())) {
file += '\\';
file += command + '{';
file += incfile + '}';
} else {
file += '\\';
file += command + '{';
file += ChangeExtension(incfile, ".tex", false)
+ '}';
}
} else {
// \include don't want extension and demands that the
// file really have .tex
file += '\\';
file += command + '{';
file += ChangeExtension(incfile, string(), false)
+ '}';
}
return 0;
}
#endif
void InsetInclude::Validate(LaTeXFeatures & features) const
{
if (isVerb())

View File

@ -59,10 +59,6 @@ public:
void Read(LyXLex &);
///
int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
#endif
///
void Validate(LaTeXFeatures &) const;

View File

@ -132,26 +132,6 @@ int InsetInfo::Latex(ostream &, signed char /*fragile*/, bool /*free_spc*/) cons
}
#ifndef USE_OSTREAM_ONLY
int InsetInfo::Latex(string &, signed char /*fragile*/, bool /*free_spc*/) const
{
return 0;
}
int InsetInfo::Linuxdoc(string &) const
{
return 0;
}
int InsetInfo::DocBook(string &) const
{
return 0;
}
#else
int InsetInfo::Linuxdoc(ostream &) const
{
return 0;
@ -162,7 +142,6 @@ int InsetInfo::DocBook(ostream &) const
{
return 0;
}
#endif
Inset::EDITABLE InsetInfo::Editable() const

View File

@ -50,19 +50,10 @@ public:
void Read(LyXLex & lex);
///
int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
///
int Linuxdoc(string & file) const;
///
int DocBook(string & file) const;
#else
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#endif
/// what appears in the minibuffer when opening
const char * EditMessage() const {return _("Opened note");}
///

View File

@ -50,29 +50,6 @@ int InsetLabel::Latex(ostream & os, signed char /*fragile*/, bool /*fs*/) const
}
#ifndef USE_OSTREAM_ONLY
int InsetLabel::Latex(string & file, signed char /*fragile*/, bool /*fs*/) const
{
file += escape(getCommand());
return 0;
}
int InsetLabel::Linuxdoc(string & file) const
{
file += "<label id=\"" + getContents() +"\" >";
return 0;
}
int InsetLabel::DocBook(string & file) const
{
file += "<anchor id=\"" + getContents() +"\" >";
return 0;
}
#else
int InsetLabel::Linuxdoc(ostream & os) const
{
os << "<label id=\"" << getContents() << "\" >";
@ -85,9 +62,6 @@ int InsetLabel::DocBook(ostream & os) const
os << "<anchor id=\"" << getContents() << "\" >";
return 0;
}
#endif
// This function escapes 8-bit characters and other problematic characters

View File

@ -40,19 +40,10 @@ public:
EDITABLE Editable() const { return NOT_EDITABLE; }
///
int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
///
int Linuxdoc(string & file) const;
///
int DocBook(string & file) const;
#else
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#endif
private:
/// This function escapes 8-bit characters
string escape(string const &) const;

View File

@ -752,29 +752,6 @@ int InsetLatexAccent::Latex(ostream & os, signed char /*fragile*/, bool/*fs*/) c
}
#ifndef USE_OSTREAM_ONLY
int InsetLatexAccent::Latex(string & file, signed char /*fragile*/, bool /*fs*/) const
{
file += contents;
return 0;
}
int InsetLatexAccent::Linuxdoc(string & file) const
{
file += contents;
return 0;
}
int InsetLatexAccent::DocBook(string & file) const
{
file += contents;
return 0;
}
#else
int InsetLatexAccent::Linuxdoc(ostream & os) const
{
os << contents;
@ -787,7 +764,6 @@ int InsetLatexAccent::DocBook(ostream & os) const
os << contents;
return 0;
}
#endif
bool InsetLatexAccent::Deletable() const

View File

@ -54,19 +54,10 @@ public:
void Read(LyXLex & lex);
///
int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
///
int Linuxdoc(string & file) const;
///
int DocBook(string & file) const;
#else
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#endif
///
bool Deletable() const;
///

View File

@ -49,14 +49,3 @@ int InsetParent::Latex(ostream & os, signed char fragile, bool free_spc) const
InsetCommand::Latex(os, fragile, free_spc);
return 0;
}
#ifndef USE_OSTREAM_ONLY
// LaTeX must just ignore this command
int InsetParent::Latex(string & file, signed char fragile, bool free_spc) const
{
file += "%%#{lyx}";
InsetCommand::Latex(file, fragile, free_spc);
return 0;
}
#endif

View File

@ -33,10 +33,6 @@ public:
InsetParent(string const & fn, Buffer * owner = 0);
///
int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
#endif
///
Inset * Clone() const { return new InsetParent(getContents()); }
///

View File

@ -226,7 +226,6 @@ void InsetQuotes::Read(LyXLex & lex)
int InsetQuotes::Latex(ostream & os, signed char /*fragile*/, bool) const
{
#ifdef USE_OSTREAM_ONLY
string doclang =
current_view->buffer()->GetLanguage();
int quoteind = quote_index[side][language];
@ -262,76 +261,9 @@ int InsetQuotes::Latex(ostream & os, signed char /*fragile*/, bool) const
os << qstr;
return 0;
#else
string quote;
int res = Latex(quote, 0, 0);
os << quote;
return res;
#endif
}
#ifndef USE_OSTREAM_ONLY
int InsetQuotes::Latex(string & file, signed char /*fragile*/, bool /*free_spc*/) const
{
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.
if ((suffixIs(file, '?') || suffixIs(file, '!'))
&& qstr[0] == '`')
qstr = "{}" + qstr;
file += qstr;
return 0;
}
int InsetQuotes::Linuxdoc(string & file) const
{
file += "\"";
return 0;
}
int InsetQuotes::DocBook(string & file) const
{
if(times == InsetQuotes::DoubleQ) {
if (side == InsetQuotes::LeftQ)
file += "&ldquo;";
else
file += "&rdquo;";
} else {
if (side == InsetQuotes::LeftQ)
file += "&lsquo;";
else
file += "&rsquo;";
}
return 0;
}
#else
int InsetQuotes::Linuxdoc(ostream & os) const
{
os << "\"";
@ -354,7 +286,6 @@ int InsetQuotes::DocBook(ostream & os) const
}
return 0;
}
#endif
void InsetQuotes::Validate(LaTeXFeatures & features) const

View File

@ -86,19 +86,10 @@ public:
void Read(LyXLex & lex);
///
int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
///
int Linuxdoc(string & file) const;
///
int DocBook(string & file) const;
#else
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#endif
///
void Validate(LaTeXFeatures &) const;
///

View File

@ -81,40 +81,6 @@ int InsetRef::Latex(ostream & os, signed char /*fragile*/, bool /*fs*/) const
}
#ifndef USE_OSTREAM_ONLY
int InsetRef::Latex(string & file, signed char /*fragile*/, bool /*fs*/) const
{
if(getOptions().empty())
file += escape(getCommand());
else {
string ns;
InsetCommand clone = InsetCommand(getCmdName(),
getContents(), ns);
file += escape(clone.getCommand());
}
return 0;
}
int InsetRef::Linuxdoc(string & file) const
{
file += "<ref id=\"" + getContents()
+ "\" name=\""+ getOptions() +"\" >" ;
return 0;
}
int InsetRef::DocBook(string & file) const
{
file += "<link linkend=\"" + getContents()
+ "\">"+ getOptions() +"</link>" ;
return 0;
}
#else
int InsetRef::Linuxdoc(ostream & os) const
{
os << "<ref id=\"" << getContents()
@ -129,7 +95,6 @@ int InsetRef::DocBook(ostream & os) const
<< "\">" << getOptions() << "</link>";
return 0;
}
#endif
// This function escapes 8-bit characters and other problematic characters

View File

@ -62,19 +62,10 @@ public:
void gotoLabel();
///
int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
///
int Linuxdoc(string & file) const;
///
int DocBook(string & file) const;
#else
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#endif
private:
/// This function escapes 8-bit characters
string escape(string const &) const;

View File

@ -191,7 +191,6 @@ void InsetSpecialChar::Read(LyXLex & lex)
int InsetSpecialChar::Latex(ostream & os, signed char /*fragile*/,
bool free_space) const
{
#ifdef USE_OSTREAM_ONLY
switch (kind) {
case HYPHENATION: os << "\\-"; break;
case END_OF_SENTENCE: os << "\\@."; break;
@ -200,58 +199,9 @@ int InsetSpecialChar::Latex(ostream & os, signed char /*fragile*/,
case PROTECTED_SEPARATOR: os << (free_space ? " " : "~"); break;
}
return 0;
#else
string command;
signed char dummy = 0;
Latex(command, dummy, free_space);
os << command;
return 0;
#endif
}
#ifndef USE_OSTREAM_ONLY
int InsetSpecialChar::Latex(string & file, signed char /*fragile*/,
bool free_space) const
{
switch (kind) {
case HYPHENATION: file += "\\-"; break;
case END_OF_SENTENCE: file += "\\@."; break;
case LDOTS: file += "\\ldots{}"; break;
case MENU_SEPARATOR: file += "\\lyxarrow{}"; break;
case PROTECTED_SEPARATOR: file += (free_space ? " " : "~"); break;
}
return 0;
}
int InsetSpecialChar::Linuxdoc(string & file) const
{
switch (kind) {
case HYPHENATION: file += ""; break;
case END_OF_SENTENCE: file += ""; break;
case LDOTS: file += "..."; break;
case MENU_SEPARATOR: file += "->"; break;
case PROTECTED_SEPARATOR: file += " "; break;
}
return 0;
}
int InsetSpecialChar::DocBook(string & file) const
{
switch (kind) {
case HYPHENATION: file += ""; break;
case END_OF_SENTENCE: file += ""; break;
case LDOTS: file += "..."; break;
case MENU_SEPARATOR: file += "->"; break;
case PROTECTED_SEPARATOR: file += " "; break;
}
return 0;
}
#else
int InsetSpecialChar::Linuxdoc(ostream & os) const
{
switch (kind) {
@ -276,7 +226,6 @@ int InsetSpecialChar::DocBook(ostream & os) const
}
return 0;
}
#endif
Inset * InsetSpecialChar::Clone() const

View File

@ -60,19 +60,10 @@ public:
void Read(LyXLex & lex);
///
int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
///
int Linuxdoc(string & file) const;
///
int DocBook(string & file) const;
#else
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#endif
///
Inset * Clone() const;
///

View File

@ -626,37 +626,14 @@ InsetText::LocalDispatch(BufferView * bv,
}
int InsetText::Latex(ostream & os, signed char /*fragile*/,
#ifdef USE_OSTREAM_ONLY
bool) const
#else
bool free_spc) const
#endif
int InsetText::Latex(ostream & os, signed char /*fragile*/, bool) const
{
#ifdef USE_OSTREAM_ONLY
TexRow texrow;
int ret = par->SimpleTeXOnePar(os, texrow);
return ret;
#else
string fstr;
int i = Latex(fstr, fragile, free_spc);
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
{
par->validate(features);

View File

@ -78,19 +78,10 @@ public:
UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
///
int Latex(ostream &, signed char, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string &, signed char, bool free_spc) const;
///
int Linuxdoc(string &) const { return 0; }
///
int DocBook(string &) const { return 0; }
#else
///
int Linuxdoc(ostream &) const { return 0; }
///
int DocBook(ostream &) const { return 0; }
#endif
///
void Validate(LaTeXFeatures & features) const;
///

View File

@ -17,22 +17,6 @@ void InsetTOC::Edit(BufferView * bv, int, int, unsigned int)
bv->owner()->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
}
#ifndef USE_OSTREAM_ONLY
int InsetTOC::Linuxdoc(string & file) const
{
file += "<toc>";
return 0;
}
int InsetTOC::DocBook(string & file) const
{
file += "<toc></toc>";
return 0;
}
#else
int InsetTOC::Linuxdoc(ostream & os) const
{
os << "<toc>";
@ -45,4 +29,3 @@ int InsetTOC::DocBook(ostream & os) const
os << "<toc></toc>";
return 0;
}
#endif

View File

@ -43,17 +43,10 @@ public:
bool display() const { return true; }
///
Inset::Code LyxCode() const { return Inset::TOC_CODE; }
#ifdef USE_OSTREAM_ONLY
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#else
///
int Linuxdoc(string & file) const;
///
int DocBook(string & file) const;
#endif
private:
///
Buffer * owner;

View File

@ -168,57 +168,15 @@ string InsetUrl::getScreenLabel() const
int InsetUrl::Latex(ostream & os, signed char fragile, bool free_spc) 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, free_spc);
os << latex_output;
return res;
#endif
}
#ifndef USE_OSTREAM_ONLY
int InsetUrl::Latex(string & file, signed char fragile, bool /*free_spc*/) const
{
if (!getOptions().empty())
file += getOptions() + ' ';
if (fragile)
file += "\\protect";
file += "\\url{" + getContents() + '}';
return 0;
}
int InsetUrl::Linuxdoc(string & file) const
{
file += "<"+ getCmdName() +
" url=\"" + getContents()+"\"" +
" name=\"" + getOptions() +"\">";
return 0;
}
int InsetUrl::DocBook(string & file) const
{
file += "<ulink url=\"" + getContents() + "\">" +
getOptions() +"</ulink>";
return 0;
}
#else
int InsetUrl::Linuxdoc(ostream & os) const
{
os << "<" << getCmdName()
@ -235,7 +193,6 @@ int InsetUrl::DocBook(ostream & os) const
<< getOptions() << "</ulink>";
return 0;
}
#endif
void InsetUrl::Validate(LaTeXFeatures & features) const

View File

@ -71,19 +71,10 @@ public:
void gotoLabel();
///
int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
///
int Linuxdoc(string & file) const;
///
int DocBook(string & file) const;
#else
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#endif
///
static void CloseUrlCB(FL_OBJECT *, long data);
private:

View File

@ -26,7 +26,6 @@ class BufferView;
struct LaTeXFeatures;
#define USE_OSTREAM_ONLY 1
/// Insets
class Inset {
@ -126,21 +125,13 @@ public:
If the freee_spc (freespacing) variable is set, then this inset
is in a free-spacing paragraph.
*/
virtual int Latex(ostream &, signed char fragile, bool free_spc) const = 0;
virtual int Latex(ostream &, signed char fragile,
bool free_spc) const = 0;
#ifndef USE_OSTREAM_ONLY
///
virtual int Latex(string & file, signed char fragile, bool free_spc) const = 0;
///
virtual int Linuxdoc(string & /*file*/) const = 0;
///
virtual int DocBook(string & /*file*/) const = 0;
#else
///
virtual int Linuxdoc(ostream &) const = 0;
///
virtual int DocBook(ostream &) const = 0;
#endif
/// Updates needed features for this inset.
virtual void Validate(LaTeXFeatures & features) const;
///

View File

@ -3549,18 +3549,3 @@ extern "C" void RefHideCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_ref->form_ref);
}
#ifndef USE_OSTREAM_ONLY
#ifdef WITH_WARNINGS
#warning UGLY!!
#endif
// I know we shouldn't put anything in here but this seems the fastest
// way to do this (and the cleanest for now). This function just inserts
// a newline in the string and the inserts 'depth'-spaces so that the
// code is indented in the right way!!!
void addNewlineAndDepth(string & file, int depth)
{
file += '\n';
file.append(depth, ' ');
}
#endif

View File

@ -663,7 +663,6 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const
/// Writes the head of the LaTeX needed to impose this font
// Returns number of chars written.
#ifdef USE_OSTREAM_ONLY
int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
LyXFont const & prev) const
{
@ -747,165 +746,8 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
}
return count;
}
#else
int LyXFont::latexWriteStartChanges(string & file, LyXFont const & base,
LyXFont const & prev) const
{
LyXFont f = *this;
f.reduce(base);
if (f.bits == inherit)
return 0;
int count = 0;
bool env = false;
FONT_DIRECTION direction = f.direction();
if (direction != prev.direction()) {
if (direction == LTR_DIR) {
file += "\\L{";
count += 3;
env = true; //We have opened a new environment
}
if (direction == RTL_DIR) {
file += "\\R{";
count += 3;
env = true; //We have opened a new environment
}
}
if (f.family() != INHERIT_FAMILY) {
file += '\\';
file += LaTeXFamilyNames[f.family()];
file += '{';
count += LaTeXFamilyNames[f.family()].length() + 2;
env = true; //We have opened a new environment
}
if (f.series() != INHERIT_SERIES) {
file += '\\';
file += LaTeXSeriesNames[f.series()];
file += '{';
count += LaTeXSeriesNames[f.series()].length() + 2;
env = true; //We have opened a new environment
}
if (f.shape() != INHERIT_SHAPE) {
file += '\\';
file += LaTeXShapeNames[f.shape()];
file += '{';
count += LaTeXShapeNames[f.shape()].length() + 2;
env = true; //We have opened a new environment
}
if (f.color() != LColor::inherit) {
file += "\\textcolor{";
file += lcolor.getLaTeXName(f.color());
file += "}{";
count += lcolor.getLaTeXName(f.color()).length() + 13;
env = true; //We have opened a new environment
}
if (f.emph() == ON) {
file += "\\emph{";
count += 6;
env = true; //We have opened a new environment
}
if (f.underbar() == ON) {
file += "\\underbar{";
count += 10;
env = true; //We have opened a new environment
}
// \noun{} is a LyX special macro
if (f.noun() == ON) {
file += "\\noun{";
count += 8;
env = true; //We have opened a new environment
}
if (f.size() != INHERIT_SIZE) {
// If we didn't open an environment above, we open one here
if (!env) {
file += '{';
++count;
}
file += '\\';
file += LaTeXSizeNames[f.size()];
file += ' ';
count += LaTeXSizeNames[f.size()].length() + 2;
}
return count;
}
#endif
#ifndef USE_OSTREAM_ONLY
/// Writes ending block of LaTeX needed to close use of this font
// Returns number of chars written
// This one corresponds to latexWriteStartChanges(). (Asger)
int LyXFont::latexWriteEndChanges(string & file, LyXFont const & base,
LyXFont const & next) const
{
LyXFont f = *this; // why do you need this?
f.reduce(base); // why isn't this just "reduce(base);" (Lgb)
// Because this function is const. Everything breaks if this
// method changes the font it represents. There is no speed penalty
// by using the temporary. (Asger)
if (f.bits == inherit)
return 0;
int count = 0;
bool env = false;
FONT_DIRECTION direction = f.direction();
if ( direction != next.direction()
&& (direction == RTL_DIR || direction == LTR_DIR) ) {
file += '}';
++count;
env = true; // Size change need not bother about closing env.
}
if (f.family() != INHERIT_FAMILY) {
file += '}';
++count;
env = true; // Size change need not bother about closing env.
}
if (f.series() != INHERIT_SERIES) {
file += '}';
++count;
env = true; // Size change need not bother about closing env.
}
if (f.shape() != INHERIT_SHAPE) {
file += '}';
++count;
env = true; // Size change need not bother about closing env.
}
if (f.color() != LColor::inherit) {
file += '}';
++count;
env = true; // Size change need not bother about closing env.
}
if (f.emph() == ON) {
file += '}';
++count;
env = true; // Size change need not bother about closing env.
}
if (f.underbar() == ON) {
file += '}';
++count;
env = true; // Size change need not bother about closing env.
}
if (f.noun() == ON) {
file += '}';
++count;
env = true; // Size change need not bother about closing env.
}
if (f.size() != INHERIT_SIZE) {
// We only have to close if only size changed
if (!env) {
file += '}';
++count;
}
}
return count;
}
#else
/// Writes ending block of LaTeX needed to close use of this font
// Returns number of chars written
// This one corresponds to latexWriteStartChanges(). (Asger)
@ -976,7 +818,6 @@ int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base,
}
return count;
}
#endif
LColor::color LyXFont::realColor() const

View File

@ -35,7 +35,6 @@
#undef OFF
#endif
#define USE_OSTREAM_ONLY 1
class LyXLex;
@ -295,7 +294,6 @@ public:
void lyxWriteChanges(LyXFont const & orgfont, ostream &) const;
#ifdef USE_OSTREAM_ONLY
/** Writes the head of the LaTeX needed to change to this font.
Writes to string, the head of the LaTeX needed to change
to this font. Returns number of chars written. Base is the
@ -309,21 +307,7 @@ public:
*/
int latexWriteEndChanges(ostream &, LyXFont const & base,
LyXFont const & next) const;
#else
/** Writes the head of the LaTeX needed to change to this font.
Writes to string, the head of the LaTeX needed to change
to this font. Returns number of chars written. Base is the
font state active now.
*/
int latexWriteStartChanges(string &, LyXFont const & base,
LyXFont const & prev) const;
/** Writes tha tail of the LaTeX needed to chagne to this font.
Returns number of chars written. Base is the font state we want
to achieve.
*/
int latexWriteEndChanges(string &, LyXFont const & base,
LyXFont const & next) const;
#endif
/// Build GUI description of font state
string stateText() const;

View File

@ -150,7 +150,6 @@ public:
///
void readSimpleWholeFile(istream &);
#ifdef USE_OSTREAM_ONLY
///
LyXParagraph * TeXOnePar(ostream &, TexRow & texrow,
ostream & foot, TexRow & foot_texrow,
@ -162,19 +161,6 @@ public:
LyXParagraph * TeXEnvironment(ostream &, TexRow & texrow,
ostream & foot, TexRow & foot_texrow,
int & foot_count);
#else
///
LyXParagraph * TeXOnePar(string & file, TexRow & texrow,
string & foot, TexRow & foot_texrow,
int & foot_count);
///
bool SimpleTeXOnePar(string & file, TexRow & texrow);
///
LyXParagraph * TeXEnvironment(string & file, TexRow & texrow,
string & foot, TexRow & foot_texrow,
int & foot_count);
#endif
///
LyXParagraph * Clone() const;
@ -484,7 +470,6 @@ public:
#endif
///
bool linuxDocConvertChar(char c, string & sgml_string);
#ifdef USE_OSTREAM_ONLY
///
void DocBookContTableRows(ostream &, string & extra, int & desc_on,
size_type i,
@ -492,15 +477,6 @@ public:
///
void SimpleDocBookOneTablePar(ostream &, string & extra,
int & desc_on, int depth);
#else
///
void DocBookContTableRows(string & file, string & extra, int & desc_on,
size_type i,
int current_cell_number, int & column);
///
void SimpleDocBookOneTablePar(string & file, string & extra,
int & desc_on, int depth);
#endif
private:
/** A font entry covers a range of positions. Notice that the
entries in the list are inserted in random order.
@ -539,7 +515,6 @@ private:
typedef list<InsetTable> InsetList;
///
InsetList insetlist;
#ifdef USE_OSTREAM_ONLY
///
LyXParagraph * TeXDeeper(ostream &, TexRow & texrow,
ostream & foot, TexRow & foot_texrow,
@ -567,35 +542,6 @@ private:
LyXLayout const & style,
size_type & i,
int & column, char const c);
#else
///
LyXParagraph * TeXDeeper(string & file, TexRow & texrow,
string & foot, TexRow & foot_texrow,
int & foot_count);
///
LyXParagraph * TeXFootnote(string & file, TexRow & texrow,
string & foot, TexRow & foot_texrow,
int & foot_count,
LyXDirection par_direction);
///
bool SimpleTeXOneTablePar(string & file, TexRow & texrow);
///
bool TeXContTableRows(string & file, size_type i,
int current_cell_number,
int & column, TexRow & texrow);
///
void SimpleTeXBlanks(string & file, TexRow & texrow,
size_type const i,
int & column, LyXFont const & font,
LyXLayout const & style);
///
void SimpleTeXSpecialChars(string & file, TexRow & texrow,
LyXFont & font, LyXFont & running_font,
LyXFont & basefont, bool & open_font,
LyXLayout const & style,
size_type & i,
int & column, char const c);
#endif
///
unsigned int id_;
///

View File

@ -299,58 +299,19 @@ void InsetFormula::Write(ostream & os) const
}
int InsetFormula::Latex(ostream & os, signed char fragile,
#ifdef USE_OSTREAM_ONLY
bool) const
#else
bool free_spc) const
#endif
int InsetFormula::Latex(ostream & os, signed char fragile, bool) const
{
int ret = 0;
//#warning Alejandro, the number of lines is not returned in this case
// This problem will disapear at 0.13.
#ifdef USE_OSTREAM_ONLY
if (fragile < 0)
par->Write(os);
else
mathed_write(par, os, &ret, fragile, label.c_str());
#else
string output;
InsetFormula::Latex(output, fragile, free_spc);
os << output;
#endif
return ret;
}
#ifndef USE_OSTREAM_ONLY
int InsetFormula::Latex(string & file, signed char fragile) const
{
int ret = 0;
//#warning Alejandro, the number of lines is not returned in this case
// This problem will disapear at 0.13.
if (fragile < 0)
par->Write(file);
else
mathed_write(par, file, &ret, fragile, label.c_str());
return ret;
}
int InsetFormula::Linuxdoc(string &/*file*/) const
{
return 0;
}
int InsetFormula::DocBook(string &/*file*/) const
{
return 0;
}
#else
int InsetFormula::Linuxdoc(ostream &) const
{
return 0;
@ -361,7 +322,6 @@ int InsetFormula::DocBook(ostream&) const
{
return 0;
}
#endif
// Check if uses AMS macros

View File

@ -50,19 +50,10 @@ public:
void Read(LyXLex & lex);
///
int Latex(ostream &, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
///
int Linuxdoc(string & file) const;
///
int DocBook(string & file) const;
#else
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#endif
///
void Validate(LaTeXFeatures &) const;
///

View File

@ -79,29 +79,6 @@ int InsetFormulaMacro::Latex(ostream & os, signed char /*fragile*/,
}
#ifndef USE_OSTREAM_ONLY
int InsetFormulaMacro::Latex(string &file, signed char /*fragile*/,
bool /*free_spacing*/) const
{
int ret = 1;
tmacro->WriteDef(file);
return ret;
}
int InsetFormulaMacro::Linuxdoc(string &/*file*/) const
{
return 0;
}
int InsetFormulaMacro::DocBook(string &/*file*/) const
{
return 0;
}
#else
int InsetFormulaMacro::Linuxdoc(ostream &) const
{
return 0;
@ -112,7 +89,6 @@ int InsetFormulaMacro::DocBook(ostream &) const
{
return 0;
}
#endif
void InsetFormulaMacro::Read(LyXLex & lex)

View File

@ -49,19 +49,10 @@ public:
void Write(ostream & os) const;
///
int Latex(ostream & os, signed char fragile, bool free_spc) const;
#ifndef USE_OSTREAM_ONLY
///
int Latex(string & file, signed char fragile, bool free_spc) const;
///
int Linuxdoc(string & file) const;
///
int DocBook(string & file) const;
#else
///
int Linuxdoc(ostream &) const;
///
int DocBook(ostream &) const;
#endif
///
Inset * Clone() const;

View File

@ -33,8 +33,6 @@
class Painter;
#define USE_OSTREAM_ONLY 1
///
enum math_align {
///
@ -234,11 +232,6 @@ class MathedInset {
/// Write LaTeX and Lyx code
virtual void Write(ostream &) = 0;
#ifndef USE_OSTREAM_ONLY
/// Write LaTeX and Lyx code
virtual void Write(string & file) = 0;
#endif
/// Reproduces itself
virtual MathedInset * Clone() = 0;
@ -336,11 +329,6 @@ class MathParInset: public MathedInset {
/// Write LaTeX code
virtual void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
/// Write LaTeX code
virtual void Write(string & file);
#endif
///
virtual void Metrics();
///
@ -496,12 +484,6 @@ class MathMatrixInset: public MathParInset {
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///
@ -551,12 +533,6 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * data,
void mathed_write(MathParInset *, ostream &, int *, char fragile,
char const * label = 0);
#ifndef USE_OSTREAM_ONLY
///
void mathed_write(MathParInset *, string &, int *, char fragile,
char const * label = 0);
#endif
///
void mathed_parser_file(istream &, int);
///

View File

@ -331,8 +331,15 @@ private:
bool init_deco_table::init = false;
static init_deco_table idt;
// If we had exceptions we could return a reference in stead and not
// have to check for a null pointer in mathed_draw_deco
#define USE_EXCEPTIONS 0
#if USE_EXCEPTIONS
struct deco_not_found {};
static
int search_deco(int code)
math_deco_struct const & search_deco(int code)
{
math_deco_struct * res =
lower_bound(math_deco_table,
@ -340,26 +347,65 @@ int search_deco(int code)
code, math_deco_compare());
if (res != math_deco_table + math_deco_table_size &&
res->code == code)
return res - math_deco_table;
return -1;
return *res;
throw deco_not_found();
}
#else
static
math_deco_struct const * search_deco(int code)
{
math_deco_struct * res =
lower_bound(math_deco_table,
math_deco_table + math_deco_table_size,
code, math_deco_compare());
if (res != math_deco_table + math_deco_table_size &&
res->code == code)
return res;
return 0;
}
#endif
void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code)
{
Matriz mt, sqmt;
float xx, yy, x2, y2;
int i = 0;
#if USE_EXCEPTIONS
math_deco_struct mds;
try {
mds = search_deco(code);
}
catch (deco_not_found) {
// Should this ever happen?
lyxerr << "Deco was not found. Programming error?" << endl;
return;
}
int j = search_deco(code);
if (j < 0) return;
int r = math_deco_table[j].angle;
float * d = math_deco_table[j].data;
int r = mds.angle;
float * d = mds.data;
if (h > 70 && (math_deco_table[j].code == int('(')
|| math_deco_table[j].code == int(')')))
if (h > 70 && (mds.code == int('(')
|| mds.code == int(')')))
d = parenthHigh;
#else
math_deco_struct const * mds = search_deco(code);
if (!mds) {
// Should this ever happen?
lyxerr << "Deco was not found. Programming error?" << endl;
return;
}
int r = mds->angle;
float * d = mds->data;
if (h > 70 && (mds->code == int('(')
|| mds->code == int(')')))
d = parenthHigh;
#endif
mt.rota(r);
mt.escala(w, h);
@ -393,7 +439,7 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code)
{
int xp[32], yp[32];
n = int(d[i++]);
for (j = 0; j < n; ++j) {
for (int j = 0; j < n; ++j) {
xx = d[i++]; yy = d[i++];
// lyxerr << " " << xx << " " << yy << " ";
if (code == 4)

View File

@ -47,10 +47,6 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///
@ -80,10 +76,6 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///
@ -114,10 +106,6 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
protected:
@ -137,10 +125,6 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
inline void Metrics();
///
@ -164,10 +148,6 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///
@ -195,10 +175,6 @@ public:
void draw(Painter &, int x, int baseline);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///
@ -222,10 +198,6 @@ public:
void draw(Painter &, int x, int baseline);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
@ -272,10 +244,6 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
protected:
@ -297,10 +265,6 @@ public:
void draw(Painter &, int, int);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///
@ -339,17 +303,6 @@ void MathFuncInset::Write(ostream & os)
}
#ifndef USE_OSTREAM_ONLY
inline
void MathFuncInset::Write(string & file)
{
file += '\\';
file += name;
file += ' ';
}
#endif
inline
void MathSpaceInset::Metrics()
{

View File

@ -158,7 +158,6 @@ void MathMacro::SetFocus(int x, int y)
void MathMacro::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
if (tmplate->flags & MMF_Exp) {
lyxerr[Debug::MATHED] << "Expand " << tmplate->flags
<< ' ' << MMF_Exp << endl;
@ -198,61 +197,9 @@ void MathMacro::Write(ostream & os)
os << ' ';
}
}
#else
string output;
MathMacro::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathMacro::Write(string &file)
{
if (tmplate->flags & MMF_Exp) {
lyxerr[Debug::MATHED] << "Expand " << tmplate->flags
<< ' ' << MMF_Exp << endl;
tmplate->update(this);
tmplate->Write(file);
} else {
if (tmplate->flags & MMF_Env) {
file += "\\begin{";
file += name;
file += "} ";
} else {
file += '\\';
file += name;
}
// if (options) {
// file += '[';
// file += options;
// file += ']';
// }
if (!(tmplate->flags & MMF_Env) && nargs > 0)
file += '{';
for (int i = 0; i < nargs; ++i) {
array = args[i].array;
MathParInset::Write(file);
if (i < nargs - 1)
file += "}{";
}
if (tmplate->flags & MMF_Env) {
file += "\\end{";
file += name;
file += '}';
} else {
if (nargs > 0)
file += '}';
else
file += ' ';
}
}
}
#endif
/*--------------- Macro argument -----------------------------------*/
MathMacroArgument::MathMacroArgument(int n)
@ -314,34 +261,14 @@ void MathMacroArgument::Metrics()
void MathMacroArgument::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
if (expnd_mode) {
MathParInset::Write(os);
} else {
os << '#' << number << ' ';
}
#else
string output;
MathMacroArgument::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathMacroArgument::Write(string & file)
{
if (expnd_mode) {
MathParInset::Write(file);
} else {
file += '#';
file += tostr(number);
file += ' ';
}
}
#endif
/* --------------------- MathMacroTemplate ---------------------------*/
MathMacroTemplate::MathMacroTemplate(char const * nm, int na, int flg):
@ -463,30 +390,6 @@ void MathMacroTemplate::WriteDef(ostream & os)
}
#ifndef USE_OSTREAM_ONLY
void MathMacroTemplate::WriteDef(string & file)
{
file += "\n\\newcommand{\\";
file += name;
file += '}';
if (nargs > 0 ) {
file += '[';
file += tostr(nargs);
file += ']';
}
file += '{';
for (int i = 0; i < nargs; ++i) {
args[i].setExpand(false);
}
Write(file);
file += "}\n";
}
#endif
void MathMacroTemplate::setArgument(LyxArrayBase * a, int i)
{
args[i].SetData(a);

View File

@ -50,10 +50,6 @@ public:
MathedInset * Clone();
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string &);
#endif
///
bool setArgumentIdx(int);
///
@ -120,17 +116,12 @@ public:
void draw(Painter &, int x, int baseline);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string &);
#endif
///
void setNumber(int n) { number = n; }
/// Is expanded or not
void setExpand(bool e) { expnd_mode = e; }
/// Is expanded or not
bool getExpand() { return expnd_mode; }
private:
///
bool expnd_mode;
@ -152,10 +143,6 @@ public:
void Metrics();
///
void WriteDef(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void WriteDef(string &);
#endif
/// useful for special insets
void setTCode(MathedTextCodes t) { tcode = t; }
///

View File

@ -136,29 +136,9 @@ void MathRootInset::SetFocus(int x, int)
void MathRootInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
os << '\\' << name << '[';
uroot->Write(os);
os << "]{";
MathParInset::Write(os);
os << '}';
#else
string output;
MathRootInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathRootInset::Write(string & outf)
{
outf += '\\';
outf += name;
outf += '[';
uroot->Write(outf);
outf += "]{";
MathParInset::Write(outf);
outf += '}';
}
#endif

View File

@ -40,12 +40,6 @@ class MathRootInset: public MathSqrtInset {
void draw(Painter &, int x, int baseline);
///
void Write(ostream &);
#ifndef USE_OSTREAM_ONLY
///
void Write(string & file);
#endif
///
void Metrics();
///

View File

@ -44,86 +44,29 @@ char const * math_font_name[] = {
void
MathSpaceInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
if (space >= 0 && space < 6) {
os << '\\' << latex_mathspace[space] << ' ';
}
#else
if (space >= 0 && space < 6) {
string output;
MathSpaceInset::Write(output);
os << output;
}
#endif
}
#ifndef USE_OSTREAM_ONLY
void
MathSpaceInset::Write(string & outf)
{
if (space >= 0 && space < 6) {
outf += '\\';
outf += latex_mathspace[space];
outf += ' ';
}
}
#endif
void
MathDotsInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
os << '\\' << name << ' ';
#else
string output;
MathDotsInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void
MathDotsInset::Write(string & outf)
{
outf += '\\';
outf += name;
outf += ' ';
}
#endif
void MathSqrtInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
os << '\\' << name << '{';
MathParInset::Write(os);
os << '}';
#else
string output;
MathSqrtInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathSqrtInset::Write(string & outf)
{
outf += '\\';
outf += name;
outf += '{';
MathParInset::Write(outf);
outf += '}';
}
#endif
void MathDelimInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
latexkeys * l = (left != '|') ? lm_get_key_by_id(left, LM_TK_SYM): 0;
latexkeys * r = (right != '|') ? lm_get_key_by_id(right, LM_TK_SYM): 0;
os << "\\left";
@ -147,85 +90,20 @@ void MathDelimInset::Write(ostream & os)
os << char(right) << ' ';
}
}
#else
string output;
MathDelimInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathDelimInset::Write(string & outf)
{
latexkeys * l = (left != '|') ? lm_get_key_by_id(left, LM_TK_SYM): 0;
latexkeys * r = (right != '|') ? lm_get_key_by_id(right, LM_TK_SYM): 0;
outf += "\\left";
if (l) {
outf += '\\';
outf += l->name;
outf += ' ';
} else {
if (left == '{' || left == '}') {
outf += '\\';
outf += char(left);
outf += ' ';
} else {
outf += char(left);
outf += ' ';
}
}
MathParInset::Write(outf);
outf += "\\right";
if (r) {
outf += '\\';
outf += r->name;
outf += ' ';
} else {
if (right == '{' || right == '}') {
outf += '\\';
outf += char(right);
outf += ' ';
} else {
outf += char(right);
outf += ' ';
}
}
}
#endif
void MathDecorationInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
latexkeys * l = lm_get_key_by_id(deco, LM_TK_WIDE);
os << '\\' << l->name << '{';
MathParInset::Write(os);
os << '}';
#else
string output;
MathDecorationInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathDecorationInset::Write(string & outf)
{
latexkeys * l = lm_get_key_by_id(deco, LM_TK_WIDE);
outf += '\\';
outf += l->name;
outf += '{';
MathParInset::Write(outf);
outf += '}';
}
#endif
void MathAccentInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
latexkeys * l = lm_get_key_by_id(code, LM_TK_ACCENT);
os << '\\' << l->name;
if (code!= LM_not)
@ -255,56 +133,11 @@ void MathAccentInset::Write(ostream & os)
if (code!= LM_not)
os << '}';
#else
string output;
MathAccentInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathAccentInset::Write(string & outf)
{
latexkeys * l = lm_get_key_by_id(code, LM_TK_ACCENT);
outf += '\\';
outf += l->name;
if (code!= LM_not)
outf += '{';
else
outf += ' ';
if (inset) {
inset->Write(outf);
} else {
if (fn>= LM_TC_RM && fn<= LM_TC_TEXTRM) {
outf += '\\';
outf += math_font_name[fn-LM_TC_RM];
outf += '{';
}
if (MathIsSymbol(fn)) {
latexkeys *l = lm_get_key_by_id(c, LM_TK_SYM);
if (l) {
outf += '\\';
outf += l->name;
outf += ' ';
}
} else
outf += char(c);
if (fn>= LM_TC_RM && fn<= LM_TC_TEXTRM)
outf += '}';
}
if (code!= LM_not)
outf += '}';
}
#endif
void MathBigopInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
bool limp = GetLimits();
os << '\\' << name;
@ -318,66 +151,21 @@ void MathBigopInset::Write(ostream & os)
os << "\\nolimits ";
else
os << ' ';
#else
string output;
MathBigopInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathBigopInset::Write(string & outf)
{
bool limp = GetLimits();
outf += '\\';
outf += name;
if (limp && !(sym!= LM_int && sym!= LM_oint && (GetStyle() == LM_ST_DISPLAY)))
outf += "\\limits ";
else
if (!limp && (sym!= LM_int && sym!= LM_oint && (GetStyle() == LM_ST_DISPLAY)))
outf += "\\nolimits ";
else
outf += ' ';
}
#endif
void MathFracInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
os << '\\' << name << '{';
MathParInset::Write(os);
os << "}{";
den->Write(os);
os << '}';
#else
string output;
MathFracInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathFracInset::Write(string & outf)
{
outf += '\\';
outf += name;
outf += '{';
MathParInset::Write(outf);
outf += "}{";
den->Write(outf);
outf += '}';
}
#endif
void MathParInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
if (!array) return;
int brace = 0;
latexkeys * l;
@ -492,139 +280,11 @@ void MathParInset::Write(ostream & os)
// Something like this should work too:
os << string(brace, '}'); // not one-off error I hope.
#endif
#else
if (!array) return;
string output;
MathParInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathParInset::Write(string & outf)
{
if (!array) return;
int brace = 0;
latexkeys * l;
MathedIter data(array);
// hack
MathedRowSt const * crow = getRowSt();
data.Reset();
if (!Permit(LMPF_FIXED_SIZE)) {
l = lm_get_key_by_id(size, LM_TK_STY);
if (l) {
outf += '\\';
outf += l->name;
outf += ' ';
}
}
while (data.OK()) {
byte cx = data.GetChar();
if (cx>= ' ') {
int ls;
byte * s = data.GetString(ls);
if (data.FCode()>= LM_TC_RM && data.FCode()<= LM_TC_TEXTRM) {
outf += '\\';
outf += math_font_name[data.FCode()-LM_TC_RM];
outf += '{';
}
while (ls>0) {
if (MathIsSymbol(data.FCode())) {
l = lm_get_key_by_id(*s,(data.FCode() == LM_TC_BSYM)?LM_TK_BIGSYM:LM_TK_SYM);
if (l) {
outf += '\\';
outf += l->name;
outf += ' ';
} else {
lyxerr << "Illegal symbol code[" << *s
<< " " << ls << " " << data.FCode() << "]";
}
} else {
// Is there a standard logical XOR?
if ((data.FCode() == LM_TC_TEX && *s!= '{' && *s!= '}') ||
(data.FCode() == LM_TC_SPECIAL))
outf += '\\';
else {
if (*s == '{') ++brace;
if (*s == '}') --brace;
}
if (*s == '}' && data.FCode() == LM_TC_TEX && brace<0)
lyxerr <<"Math warning: Unexpected closing brace."
<< endl;
else
outf += char(*s);
}
++s; --ls;
}
if (data.FCode()>= LM_TC_RM && data.FCode()<= LM_TC_TEXTRM)
outf += '}';
} else
if (MathIsInset(cx)) {
MathedInset *p = data.GetInset();
if (cx == LM_TC_UP)
outf += "^{";
if (cx == LM_TC_DOWN)
outf += "_{";
p->Write(outf);
if (cx == LM_TC_UP || cx == LM_TC_DOWN)
outf += '}';
data.Next();
} else
switch(cx) {
case LM_TC_TAB:
{
outf += " & ";
data.Next();
break;
}
case LM_TC_CR:
{
if (crow) {
if (!crow->isNumbered()) {
outf += "\\nonumber ";
}
if (crow->getLabel()) {
outf += "\\label{";
outf += crow->getLabel();
outf += "} ";
}
crow = crow->getNext();
}
outf += "\\\\\n";
++number_of_newlines;
data.Next();
break;
}
default:
lyxerr << "WMath Error: unrecognized code[" << cx << "]";
return;
}
}
if (crow) {
if (!crow->isNumbered()) {
outf += "\\nonumber ";
}
if (crow->getLabel()) {
outf += "\\label{";
outf += crow->getLabel();
outf += "} ";
}
}
while (brace>0) {
outf += '}';
--brace;
}
}
#endif
void MathMatrixInset::Write(ostream & os)
{
#ifdef USE_OSTREAM_ONLY
if (GetType() == LM_OT_MATRIX){
os << "\\begin{"
<< name
@ -646,46 +306,12 @@ void MathMatrixInset::Write(ostream & os)
<< '}';
++number_of_newlines;
}
#else
string output;
MathMatrixInset::Write(output);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void MathMatrixInset::Write(string & outf)
{
if (GetType() == LM_OT_MATRIX){
outf += "\\begin{";
outf += name;
outf += '}';
if (v_align == 't' || v_align == 'b') {
outf += '[';
outf += char(v_align);
outf += ']';
}
outf += '{';
outf += h_align;
outf += "}\n";
++number_of_newlines;
}
MathParInset::Write(outf);
if (GetType() == LM_OT_MATRIX){
outf += "\n\\end{";
outf += name;
outf += '}';
++number_of_newlines;
}
}
#endif
void mathed_write(MathParInset * p, ostream & os, int * newlines,
char fragile, char const * label)
{
#ifdef USE_OSTREAM_ONLY
number_of_newlines = 0;
short mathed_env = p->GetType();
@ -744,70 +370,4 @@ void mathed_write(MathParInset * p, ostream & os, int * newlines,
number_of_newlines += 2;
}
*newlines = number_of_newlines;
#else
string output;
mathed_write(p, output, newlines, fragile, label);
os << output;
#endif
}
#ifndef USE_OSTREAM_ONLY
void mathed_write(MathParInset * p, string & outf, int * newlines,
char fragile, char const * label)
{
number_of_newlines = 0;
short mathed_env = p->GetType();
if (mathed_env == LM_EN_INTEXT) {
if (fragile) outf += "\\protect";
outf += "\\( "; // changed from " \\( " (Albrecht Dress)
}
else {
if (!suffixIs(outf, '\n')) {
// in batchmode we need to make sure
// a space before an equation doesn't
// make the LaTeX output different
// compared to "Exported LaTeX" ARRae
// Modified to work in a cleaner and hopefully more general way
// (JMarc)
outf += "\n";
++number_of_newlines;
}
if (mathed_env == LM_EN_DISPLAY){
outf += "\\[\n";
}
else {
outf += "\\begin{";
outf += latex_mathenv[mathed_env];
outf += "}\n";
}
++number_of_newlines;
}
if (label && label[0]>' ' && mathed_env == LM_EN_EQUATION){
outf += "\\label{";
outf += label;
outf += "}\n";
++number_of_newlines;
}
p->Write(outf);
if (mathed_env == LM_EN_INTEXT){
if (fragile) outf += "\\protect";
outf += " \\)";
}
else if (mathed_env == LM_EN_DISPLAY){
outf += "\\]\n";
++number_of_newlines;
}
else {
outf += "\n\\end{";
outf += latex_mathenv[mathed_env];
outf += "}\n";
number_of_newlines += 2;
}
*newlines = number_of_newlines;
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -3,10 +3,6 @@
#ifndef LYX_ALGO_H
#define LYX_ALGO_H
#include <algorithm>
// using std::less;
// Both these functions should ideally be placed into namespace lyx.
// Also the using std::less should not be used.
@ -19,7 +15,7 @@ bool sorted(For first, For last)
if (first == last) return true;
For tmp = first;
while (++tmp != last) {
if (less(*tmp, *first++)) return false;
if (*tmp < *first++) return false;
}
return true;
}

View File

@ -11,26 +11,24 @@
#include <config.h>
#include <cstdlib>
#include "table.h"
#include "vspace.h"
#include "layout.h"
#include "support/lstrings.h"
#include <algorithm>
using std::max;
#include <cstdlib>
#ifdef __GNUG__
#pragma implementation
#endif
#ifdef USE_OSTREAM_ONLY
#include "table.h"
#include "vspace.h"
#include "layout.h"
#include "support/lstrings.h"
#include "support/lyxmanip.h"
#else
extern void addNewlineAndDepth(string & file, int depth); // Jug 990923
#endif
using std::max;
static int const WIDTH_OF_LINE = 5;
/* konstruktor */
LyXTable::LyXTable(int rows_arg, int columns_arg)
{
@ -956,7 +954,6 @@ void LyXTable::Read(istream & is)
}
#ifdef USE_OSTREAM_ONLY
// cell <0 will tex the preamble
// returns the number of printed newlines
int LyXTable::TexEndOfCell(ostream & os, int cell)
@ -1293,342 +1290,6 @@ int LyXTable::TexEndOfCell(ostream & os, int cell)
}
return ret;
}
#else
// cell <0 will tex the preamble
// returns the number of printed newlines
int LyXTable::TexEndOfCell(string & file, int cell)
{
int i;
int ret = 0;
int tmp; // tmp2;
int fcell, nvcell;
if (ShouldBeVeryLastCell(cell)) {
// the very end at the very beginning
if (Linebreaks(cell))
file += "\\smallskip{}}";
if (IsMultiColumn(cell))
file += '}';
if (RotateCell(cell)) {
file += "\n\\end{sideways}";
++ret;
}
file += "\\\\\n";
++ret;
tmp = 0;
fcell = cell;
while (!IsFirstCell(fcell)) --fcell;
for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
if (BottomLine(fcell + i))
++tmp;
}
if (tmp == NumberOfCellsInRow(fcell)) {
file += "\\hline ";
} else {
tmp = 0;
for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
if (BottomLine(fcell + i)) {
file += "\\cline{";
file += tostr(column_of_cell(fcell + i) + 1);
file += '-';
file += tostr(right_column_of_cell(fcell + i) + 1);
file += "} ";
tmp = 1;
}
}
}
if (tmp){
file += '\n';
++ret;
}
if (is_long_table)
file += "\\end{longtable}";
else
file += "\\end{tabular}";
if (rotate) {
file += "\n\\end{sideways}";
++ret;
}
} else {
nvcell = NextVirtualCell(cell + 1);
if (cell < 0){
// preamble
if (rotate) {
file += "\\begin{sideways}\n";
++ret;
}
if (is_long_table)
file += "\\begin{longtable}{";
else
file += "\\begin{tabular}{";
for (i = 0; i < columns; ++i) {
if (column_info[i].left_line)
file += '|';
if (!column_info[i].align_special.empty()) {
file += column_info[i].align_special.c_str();
} else if (!column_info[i].p_width.empty()) {
file += "p{";
file += column_info[i].p_width;
file += '}';
} else {
switch (column_info[i].alignment) {
case LYX_ALIGN_LEFT:
file += 'l';
break;
case LYX_ALIGN_RIGHT:
file += 'r';
break;
default:
file += 'c';
break;
}
}
if (column_info[i].right_line)
file += '|';
}
file += "}\n";
++ret;
tmp = 0;
if (GetNumberOfCells()) {
fcell = 0;
for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
if (TopLine(fcell + i))
++tmp;
}
if (tmp == NumberOfCellsInRow(fcell)){
file += "\\hline ";
} else {
tmp = 0;
for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
if (TopLine(fcell + i)) {
file += "\\cline{";
file += tostr(column_of_cell(fcell + i) + 1);
file += '-';
file += tostr(right_column_of_cell(fcell + i) + 1);
file += "} ";
tmp = 1;
}
}
}
if (tmp){
file += '\n';
++ret;
}
}
if (RotateCell(0)) {
file += "\\begin{sideways}\n";
++ret;
}
} else {
// usual cells
if (Linebreaks(cell))
file += "\\smallskip{}}";
if (IsMultiColumn(cell)){
file += '}';
}
if (RotateCell(cell)) {
file += "\n\\end{sideways}";
++ret;
}
if (IsLastCell(cell)) {
int row = row_of_cell(cell);
string hline1, hline2;
bool print_hline = true;
bool flag1 = IsLongTable() &&
((row == endhead) || (row == endfirsthead) ||
(row == endfoot) || (row == endlastfoot));
++row;
bool flag2 = IsLongTable() &&
((row <= endhead) || (row <= endfirsthead) ||
(row <= endfoot) || (row <= endlastfoot));
--row;
// print the bottom hline only if (otherwise it is doubled):
// - is no LongTable
// - there IS a first-header
// - the next row is no special header/footer
// & this row is no special header/footer
// - the next row is a special header/footer
// & this row is a special header/footer
bool pr_top_hline = (flag1 && flag2) || (!flag1 && !flag2) ||
(endfirsthead == endhead);
file += "\\\\\n";
++ret;
tmp = 0;
fcell = cell;
while (!IsFirstCell(fcell))
--fcell;
for (i = 0; i < NumberOfCellsInRow(cell); ++i) {
if (BottomLine(fcell + i))
++tmp;
}
if (tmp == NumberOfCellsInRow(cell)){
file += "\\hline ";
hline1 = "\\hline ";
} else {
tmp = 0;
for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
if (BottomLine(fcell + i)){
file += "\\cline{";
file += tostr(column_of_cell(fcell + i) + 1);
file += '-';
file += tostr(right_column_of_cell(fcell + i) + 1);
file += "} ";
hline1 += "\\cline{";
hline1 += tostr(column_of_cell(fcell + i) + 1);
hline1 += '-';
hline1 += tostr(right_column_of_cell(fcell + i) + 1);
hline1 += "} ";
tmp = 1;
}
}
}
if (tmp){
file += '\n';
++ret;
}
if (IsLongTable() && (row == endfoot)) {
file += "\\endfoot\n";
++ret;
print_hline = false; // no double line below footer
}
if (IsLongTable() && (row == endlastfoot)) {
file += "\\endlastfoot\n";
++ret;
print_hline = false; // no double line below footer
}
if (IsLongTable() && row_info[row].newpage) {
file += "\\newpage\n";
++ret;
print_hline = false; // no line below a \\newpage-command
}
tmp = 0;
if (nvcell < numberofcells && (cell < GetNumberOfCells() - 1) &&
!ShouldBeVeryLastCell(cell)) {
fcell = nvcell;
for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
if (TopLine(fcell + i))
++tmp;
}
if (tmp == NumberOfCellsInRow(fcell)) {
if (print_hline)
file += "\\hline ";
hline2 = "\\hline ";
} else {
tmp = 0;
for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
if (TopLine(fcell + i)) {
if (print_hline) {
file += "\\cline{";
file += tostr(column_of_cell(fcell+i)+1);
file += '-';
file += tostr(right_column_of_cell(fcell+i)+1);
file += "} ";
}
hline2 += "\\cline{";
hline2 += tostr(column_of_cell(fcell+i)+1);
hline2 += '-';
hline2 += tostr(right_column_of_cell(fcell+i)+1);
hline2 += "} ";
tmp = 1;
}
}
}
if (tmp && print_hline){
file += '\n';
++ret;
}
}
// the order here is important as if one defines two
// or more things in one line only the first entry is
// displayed the other are set to an empty-row. This
// is important if I have a footer and want that the
// lastfooter is NOT displayed!!!
bool sflag2 = (row == endhead) || (row == endfirsthead) ||
(row == endfoot) || (row == endlastfoot);
--row;
// sflag2 = IsLongTable() && (row >= 0) &&
// (sflag2 || (row == endhead) || (row == endfirsthead));
row += 2;
bool sflag1 = IsLongTable() && (row != endhead) &&
(row != endfirsthead) &&
((row == endfoot) || (row == endlastfoot));
--row;
if (IsLongTable() && (row == endhead)) {
file += "\\endhead\n";
++ret;
}
if (IsLongTable() && (row == endfirsthead)) {
file += "\\endfirsthead\n";
++ret;
}
if (sflag1) { // add the \hline for next foot row
if (!hline1.empty()) {
file += hline1 + '\n';
++ret;
}
}
// add the \hline for the first row
if (pr_top_hline && sflag2) {
if (!hline2.empty()) {
file += hline2 + '\n';
++ret;
}
}
if (nvcell < numberofcells && RotateCell(nvcell)) {
file += "\\begin{sideways}\n";
++ret;
}
} else {
file += "&\n";
++ret;
if (nvcell < numberofcells && RotateCell(nvcell)) {
file += "\\begin{sideways}\n";
++ret;
}
}
}
if (nvcell < numberofcells && IsMultiColumn(nvcell)) {
file += "\\multicolumn{";
file += tostr(cells_in_multicolumn(nvcell));
file += "}{";
if (!cellinfo_of_cell(cell+1)->align_special.empty()) {
file += cellinfo_of_cell(cell+1)->align_special;
file += "}{";
} else {
if (LeftLine(nvcell))
file += '|';
if (!GetPWidth(nvcell).empty()) {
file += "p{";
file += GetPWidth(nvcell);
file += '}';
} else {
switch (GetAlignment(nvcell)) {
case LYX_ALIGN_LEFT: file += 'l'; break;
case LYX_ALIGN_RIGHT: file += 'r'; break;
default: file += 'c'; break;
}
}
if (RightLine(nvcell))
file += '|';
//if (column_of_cell(cell+2)!= 0 && LeftLine(cell+2))
if (((nvcell+1) < numberofcells) &&
(NextVirtualCell(nvcell+1) < numberofcells) &&
(column_of_cell(NextVirtualCell(nvcell+1))!= 0) &&
LeftLine(NextVirtualCell(nvcell+1)))
file += '|';
file += "}{";
}
}
if (nvcell < numberofcells && Linebreaks(nvcell)) {
// !column_info[column_of_cell(nvcell)].p_width.empty()) {
file += "\\parbox{";
file += GetPWidth(nvcell);
file += "}{\\smallskip{}";
}
}
return ret;
}
#endif
#if 0
@ -1772,7 +1433,6 @@ char const *LyXTable::getDocBookAlign(int cell, bool isColumn)
}
#ifdef USE_OSTREAM_ONLY
// cell <0 will tex the preamble
// returns the number of printed newlines
int LyXTable::DocBookEndOfCell(ostream & os, int cell, int &depth)
@ -1894,129 +1554,6 @@ int LyXTable::DocBookEndOfCell(ostream & os, int cell, int &depth)
}
return ret;
}
#else
// cell <0 will tex the preamble
// returns the number of printed newlines
int LyXTable::DocBookEndOfCell(string & file, int cell, int &depth)
{
int i;
int ret = 0;
//int tmp; // tmp2; // unused
int nvcell; // fcell; // unused
if (ShouldBeVeryLastCell(cell)) {
addNewlineAndDepth(file,--depth);
file += "</ENTRY>";
addNewlineAndDepth(file,--depth);
file += "</ROW>";
addNewlineAndDepth(file,--depth);
file += "</TBODY>";
addNewlineAndDepth(file,--depth);
if (is_long_table)
file += "</TGROUP>";
else
file += "</TGROUP>";
addNewlineAndDepth(file,--depth);
ret += 4;
} else {
nvcell = NextVirtualCell(cell+1);
if (cell < 0) {
// preamble
if (is_long_table)
file += "<TGROUP ";
else
file += "<TGROUP ";
file += "COLS='";
file += tostr(columns);
file += "' COLSEP='1' ROWSEP='1'>";
addNewlineAndDepth(file,++depth);
++ret;
for (i = 0; i < columns; ++i) {
file += "<COLSPEC ALIGN='";
file += getDocBookAlign(i, true);
file += "' COLNAME='col";
file += tostr(i+1);
file += "' COLNUM='";
file += tostr(i+1);
file += "' COLSEP='";
if (i == (columns-1)) {
file += '1';
} else {
if (column_info[i].right_line ||
column_info[i+1].left_line)
file += '1';
else
file += '0';
}
file += "'>";
addNewlineAndDepth(file, depth);
++ret;
#ifdef NOT_HANDLED_YET_AS_I_DONT_KNOW_HOW
if (column_info[i].left_line)
file += '|';
#endif
}
file += "<TBODY>";
addNewlineAndDepth(file,++depth);
file += "<ROW>";
addNewlineAndDepth(file,++depth);
file += "<ENTRY ALIGN='";
file += getDocBookAlign(0);
file += "'";
if (IsMultiColumn(0)) {
file += " NAMEST='col1' NAMEEND='col";
file += tostr(cells_in_multicolumn(0));
file += "'";
}
file += ">";
addNewlineAndDepth(file,++depth);
ret += 3;
} else {
if (IsLastCell(cell)) {
addNewlineAndDepth(file,--depth);
file += "</ENTRY>";
addNewlineAndDepth(file,--depth);
file += "</ROW>";
addNewlineAndDepth(file, depth);
file += "<ROW>";
addNewlineAndDepth(file,++depth);
file += "<ENTRY ALIGN='";
file += getDocBookAlign(cell+1);
file += "' VALIGN='middle'";
if (IsMultiColumn(cell+1)) {
file += " NAMEST='col";
file += tostr(column_of_cell(cell+1) + 1);
file += "' NAMEEND='col";
file += tostr(column_of_cell(cell+1) +
cells_in_multicolumn(cell+1));
file += "'";
}
file += ">";
addNewlineAndDepth(file,++depth);
ret += 4;
} else {
addNewlineAndDepth(file,--depth);
file += "</ENTRY>";
addNewlineAndDepth(file, depth);
file += "<ENTRY ALIGN='";
file += getDocBookAlign(cell+1);
file += "' VALIGN='middle'";
if (IsMultiColumn(cell+1)) {
file += " NAMEST='col";
file += tostr(column_of_cell(cell+1) + 1);
file += "' NAMEEND='col";
file += tostr(column_of_cell(cell+1) +
cells_in_multicolumn(cell+1));
file += "'";
}
file += ">";
addNewlineAndDepth(file,++depth);
ret += 3;
}
}
}
return ret;
}
#endif
bool LyXTable::IsMultiColumn(int cell)

View File

@ -19,7 +19,6 @@
#include "LString.h"
#include "support/LOstream.h"
#define USE_OSTREAM_ONLY 1
/* The features the text class offers for tables */
@ -167,17 +166,10 @@ public:
// cell <0 will tex the preamble
// returns the number of printed newlines
#ifdef USE_OSTREAM_ONLY
///
int TexEndOfCell(ostream &, int cell);
///
int DocBookEndOfCell(ostream &, int cell, int & depth);
#else
///
int TexEndOfCell(string & file, int cell);
///
int DocBookEndOfCell(string & file, int cell, int & depth);
#endif
#if 0
///
int RoffEndOfCell(ostream &, int cell);

View File

@ -2966,14 +2966,10 @@ 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) */
@ -2982,22 +2978,16 @@ char * LyXText::SelectNextWord(float & value)
|| (cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET
&& cursor.par->GetInset(cursor.pos) != 0
&& cursor.par->GetInset(cursor.pos)->Latex(latex, 0, false) == 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;
@ -3024,15 +3014,11 @@ 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()
@ -3040,22 +3026,16 @@ void LyXText::SelectSelectedWord()
|| (cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET
&& cursor.par->GetInset(cursor.pos) != 0
&& cursor.par->GetInset(cursor.pos)->Latex(latex, 0, false) == 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);
@ -3732,10 +3712,33 @@ void LyXText::GetVisibleRow(int offset,
y_top += LYX_PAPER_MARGIN;
if (row_ptr->par->pagebreak_top){ /* draw a top pagebreak */
#if 0
pain.line(0, offset + y_top + 2 * DefaultHeight(),
paperwidth,
offset + y_top + 2 * DefaultHeight(),
LColor::pagebreak, Painter::line_onoffdash);
#else
LyXFont pb_font;
pb_font.setColor(LColor::pagebreak).decSize();
int w = 0, a = 0, d = 0;
pain.line(0, offset + y_top + 2*DefaultHeight(),
paperwidth,
offset + y_top + 2*DefaultHeight(),
LColor::pagebreak,
Painter::line_onoffdash)
.rectText(0,
0,
_("Page Break (top)"),
pb_font,
LColor::background,
LColor::background, false, w, a, d);
pain.rectText((paperwidth - w)/2,
offset +y_top + 2*DefaultHeight() +d,
_("Page Break (top)"),
pb_font,
LColor::background,
LColor::background);
#endif
y_top += 3 * DefaultHeight();
}
@ -3885,10 +3888,34 @@ void LyXText::GetVisibleRow(int offset,
/* draw a bottom pagebreak */
if (firstpar->pagebreak_bottom) {
#if 0
pain.line(0, offset + y_bottom - 2 * DefaultHeight(),
paperwidth,
offset + y_bottom - 2 * DefaultHeight(),
LColor::pagebreak, Painter::line_onoffdash);
#else
LyXFont pb_font;
pb_font.setColor(LColor::pagebreak).decSize();
int w = 0, a = 0, d = 0;
pain.line(0,
offset + y_bottom - 2 * DefaultHeight(),
paperwidth,
offset + y_bottom - 2 * DefaultHeight(),
LColor::pagebreak,
Painter::line_onoffdash)
.rectText(0,
0,
_("Page Break (bottom)"),
pb_font,
LColor::background,
LColor::background, false, w, a, d);
pain.rectText((paperwidth - w)/2,
offset +y_top + 2*DefaultHeight() +d,
_("Page Break (bottom)"),
pb_font,
LColor::background,
LColor::background);
#endif
y_bottom -= 3 * DefaultHeight();
}