+2000-06-28 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/support/lyxsum.C (sum): '\0' teminate file read when using
+ strstream.
+
+ * src/insets/lyxinset.h: add FLOAT_CODE and MINIPAGE_CODE
+
+ * src/insets/insettext.C (Read): remove tmptok unused variable
+ (LocalDispatch): add not working LFUN_PARAGRAPH_SPACING
+ (InsertInset): change for new InsetInset code
+
+ * src/insets/insettext.h: add TEXT inline method
+
+ * src/insets/insettext.C: remove TEXT macro
+
+ * src/insets/insetmarginal.C (Write): new method
+ (Latex): change output slightly
+
+ * src/insets/insetfoot.C (Write): new method
+ (Latex): change output slightly (don't use endl when no need)
+
+ * src/insets/insetert.C (Write): new method
+
+ * src/insets/insetcollapsable.h: make button_length, button_top_y
+ and button_bottm_y protected.
+
+ * src/insets/insetcollapsable.C (Write): simplify code by using
+ tostr. Also do not output the float name, the children class
+ should to that to get control over own arguments
+
+ * src/insets/insetfloat.[Ch] src/insets/insetlist.[Ch]
+ src/insets/insetminipage.[Ch]:
+ new files
+
+ * src/insets/Makefile.am (libinsets_la_SOURCES): add new files
+
+ * src/lyxfunc.C (Dispatch): cases for new insets/commands
+
+ * src/Makefile.am (lyx_SOURCES): add the new files
+
+ * src/LyXAction.C (init): add LFUN_INSET_MARGINAL,
+ LFUN_INSET_MINIPAGE, LFUN_INSET_FLOAT, LFUN_INSET_LIST
+ * src/commandtags.h: ditto
+
+ * src/LaTeXFeatures.h: add a std::set of used floattypes
+
+ * src/LaTeXFeatures.C (getPackages): add basic support for float.sty
+
+ * src/FloatList.[Ch] src/Floating.h: new files
+
+ * src/CutAndPaste.C (SwitchLayoutsBetweenClasses): change call to
+ InsertInset.
+ * src/lyx_cb.C (TableApplyCB): ditto
+ * src/text.C: ditto
+ * src/text2.C: ditto
+ * src/buffer.C (SimpleLinuxDocOnePar): ditto
+ (parseSingleLyXformat2Token): ditto + add code for
+ backwards compability for old float styles + add code for new insets
+
+ * src/lyxparagraph.[Ch] (InsertChar(size_type, char, LyXFont)): new
+ method
+ (InsertInset(size_type, Inset *, LyXFont)): new method
+ (InsetChar(size_type, char)): changed to use the other InsetChar
+ with a LyXFont(ALL_INHERIT).
+ (InsetInset(size_type, Inset*)): changed to use InsetChar to
+ insert the META_INSET.
+
+ * sigc++/thread.cc (Privete<int>::operator int&): move definition
+ out of line.
+ * sigc++/thread.h (Threads): from here
+
+ * sigc++/scope.cc (ScopeIterator_::ScopeIterator_): move
+ definition out of line
+ * sigc++/scope.h: from here
+
2000-06-27 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/lyxrc.C (read): make sure the .kmap files exist when a keymap
return tmp;
}
+ScopeIterator_::ScopeIterator_(const ScopeIterator_ & n)
+ : node_(n.node_)
+{}
+
void ScopeList::swap_elements(Iterator p1,Iterator p2)
{
NodeType *loc1=p1.node();
return *this;
}
- ScopeIterator_(const ScopeIterator_ &n):node_(n.node_) {}
+ ScopeIterator_(const ScopeIterator_ &n);
+ //:node_(n.node_) {}
ScopeIterator_(NodeType *n):node_(n) {}
ScopeIterator_():node_(0) {}
};
#endif
}
+Private<int>::operator int&()
+{
+ int * value = static_cast<int*>(get());
+ if (!value)
+ set(static_cast<void*>(value = new int(0)));
+ return *(value);
+}
#ifdef SIGC_PTHREAD_DCE
MutexAttr Mutex::Default={pthread_mutexattr_default};
int& operator =(const int& t)
{return (((int&)*this)=t);}
- operator int& ()
- {
- int *value=(int*)get();
- if (!value)
- set((void*)(value=new int(0)));
- return *(value);
- }
+ operator int& ();
+ //{
+ // int *value=(int*)get();
+ // if (!value)
+ // set((void*)(value=new int(0)));
+ // return *(value);
+ //}
Private() { create(&dtor); }
~Private() { destroy(); }
+ textclasslist.NameOfClass(c1) + _(" to ")
+ textclasslist.NameOfClass(c2);
InsetError * new_inset = new InsetError(s);
+#ifdef NEW_WAY
+ par->InsertInset(0, new_inset);
+#else
par->InsertChar(0, LyXParagraph::META_INSET);
par->InsertInset(0, new_inset);
+#endif
}
par = par->next;
--- /dev/null
+#include <config.h>
+
+#include "FloatList.h"
+
+FloatList floatList;
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1998-2000 The LyX Team.
+ *
+ * ======================================================
+ */
+
+#ifndef FLOATLIST_H
+#define FLOATLIST_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <map>
+
+#include "LString.h"
+#include "Floating.h"
+
+///
+class FloatList {
+public:
+ ///
+ typedef std::map<string, Floating> List;
+ ///
+ FloatList() {
+ // Insert the latex builtin float-types
+ Floating table;
+ table.type = "table";
+ table.placement = "";
+ table.ext = "lot";
+ table.within = "";
+ table.style = "";
+ table.name = "";
+ table.builtin = true;
+ list[table.type] = table;
+ Floating figure;
+ figure.type = "figure";
+ figure.placement = "";
+ figure.ext = "lof";
+ figure.within = "";
+ figure.style = "";
+ figure.name = "";
+ figure.builtin = true;
+ list[figure.type] = figure;
+ // And we add algorithm too since LyX has
+ // supported that for a long time
+ Floating algorithm;
+ algorithm.type = "algorithm";
+ algorithm.placement = "htbp";
+ algorithm.ext = "loa";
+ algorithm.within = "";
+ algorithm.style = "ruled";
+ algorithm.name = "Algorithm";
+ algorithm.builtin = false;
+ list[algorithm.type] = algorithm;
+ }
+ ///
+ void newFloat(Floating const & fl) {
+ list[fl.type] = fl;
+ }
+ ///
+ string defaultPlacement(string const & t) const {
+ List::const_iterator cit = list.find(t);
+ if (cit != list.end())
+ return (*cit).second.placement;
+ return string();
+ }
+
+private:
+ ///
+ List list;
+};
+
+extern FloatList floatList;
+
+#endif
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1998-2000 The LyX Team.
+ *
+ * ======================================================
+ */
+
+#ifndef FLOATING_H
+#define FLOATING_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+class Floating {
+public:
+ ///
+ string type;
+ ///
+ string placement;
+ ///
+ string ext;
+ ///
+ string within;
+ ///
+ string style;
+ ///
+ string name;
+ ///
+ bool builtin;
+};
+#endif
if (prettyref)
packages += "\\usepackage{prettyref}\n";
+ // float.sty
+ // This is not correct and needs fixing.
+ // We don't need float.sty if we only use unchanged
+ // table and figure floats. (Lgb)
+ if (!usedFloats.empty())
+ packages += "\\usepackage{float}\n";
+
packages += externalPreambles;
return packages;
if (NeedLyXFootnoteCode)
macros += floatingfootnote_def;
+ // floats
+ // Here we will output the code to create the needed float styles.
+ // We will try to do this as minimal as possible.
+ // \floatstyle{ruled}
+ // \newfloat{algorithm}{htbp}{loa}
+ // \floatname{algorithm}{Algorithm}
return macros;
}
typedef std::set<Language const *> LanguageList;
///
LanguageList UsedLanguages;
+ ///
+ typedef std::set<string> FloatList;
+ ///
+ FloatList usedFloats;
//@}
BufferParams const & bufferParams() const;
private:
Noop },
{ LFUN_INSET_FOOTNOTE, "footnote-inset-insert",
N_("Insert Footnote"), Noop },
+ { LFUN_INSET_MARGINAL, "marginalnote-inset-insert",
+ N_("Insert Marginalnote"), Noop },
{ LFUN_RIGHTSEL, "forward-select", N_("Select next char"),
ReadOnly },
{ LFUN_HFILL, "hfill-insert",
{ LFUN_DATE_INSERT, "date-insert", "", Noop },
{ LFUN_PARAGRAPH_SPACING, "paragraph-spacing", "", Noop },
{ LFUN_SET_COLOR, "set-color", "", Noop },
+ { LFUN_INSET_MINIPAGE, "minipage-inset-insert", "", Noop },
+ { LFUN_INSET_FLOAT, "float-inset-insert", "", Noop },
+ { LFUN_INSET_LIST, "list-inset-insert", "", Noop },
{ LFUN_NOACTION, "", "", Noop }
};
CutAndPaste.h \
DepTable.C \
DepTable.h \
+ FloatList.C \
+ FloatList.h \
+ Floating.h \
FontInfo.C \
FontInfo.h \
FontLoader.C \
#include "insets/insetert.h"
#include "insets/insetgraphics.h"
#include "insets/insetfoot.h"
+#include "insets/insetmarginal.h"
+#include "insets/insetminipage.h"
+#include "insets/insetfloat.h"
+#include "insets/insetlist.h"
#include "insets/insettabular.h"
#include "support/filetools.h"
#include "support/path.h"
if (token[0] != '\\') {
for (string::const_iterator cit = token.begin();
cit != token.end(); ++cit) {
+#ifdef NEW_WAY
+ par->InsertChar(pos, (*cit), font);
+#else
par->InsertChar(pos, (*cit));
par->SetFont(pos, font);
+#endif
++pos;
}
} else if (token == "\\i") {
Inset * inset = new InsetLatexAccent;
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
} else if (token == "\\layout") {
if (!return_par)
font = LyXFont(LyXFont::ALL_INHERIT, params.language_info);
if (format < 2.16 && params.language == "hebrew")
font.setLanguage(default_language);
+#ifndef NEW_INSETS
} else if (token == "\\end_float") {
if (!return_par)
return_par = par;
footnoteflag = LyXParagraph::CLOSED_FOOTNOTE;
else
footnoteflag = LyXParagraph::OPEN_FOOTNOTE;
+#else
+ } else if (token == "\\begin_float") {
+ // This is the compability reader, unfinished but tested.
+ // (Lgb)
+ lex.next();
+ string tmptok = lex.GetString();
+ //lyxerr << "old float: " << tmptok << endl;
+
+ Inset * inset = 0;
+
+ if (tmptok == "footnote") {
+ inset = new InsetFoot;
+ } else if (tmptok == "margin") {
+ inset = new InsetMarginal;
+ } else if (tmptok == "fig") {
+ //inset = new InsetFigure;
+ } else if (tmptok == "tab") {
+ //inset = new InsetTable;
+ } else if (tmptok == "alg") {
+ //inset = new InsetAlgorithm;
+ } else if (tmptok == "wide-fig") {
+ //inset = new InsetFigure(true);
+ } else if (tmptok == "wide-tab") {
+ //inset = new InsetTable(true);
+ }
+
+ if (!inset) return false; // no end read yet
+
+ string old_float = "\ncollapsed true\n";
+ old_float += lex.getLongString("\\end_float");
+ old_float += "\n\\end_inset\n";
+ lyxerr << "float body: " << old_float << endl;
+
+ istrstream istr(old_float.c_str());
+ LyXLex nylex(0, 0);
+ nylex.setStream(istr);
+
+ inset->Read(this, nylex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
+ par->InsertChar(pos, LyXParagraph::META_INSET);
+ par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
+ ++pos;
+#endif
} else if (token == "\\begin_deeper") {
++depth;
} else if (token == "\\end_deeper") {
} else if (token == "\\float_placement") {
lex.nextToken();
params.float_placement = lex.GetString();
-#if 0
- } else if (token == "\\cursor") { // obsolete
- // this is obsolete, so we just skip it.
- lex.nextToken();
-#endif
} else if (token == "\\family") {
lex.next();
font.setLyXFamily(lex.GetString());
if (tmptok == "Quotes") {
Inset * inset = new InsetQuotes;
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
- ++pos;
-#if 0
- } else if (tmptok == "\\i") {
- Inset * inset = new InsetLatexAccent;
- inset->Read(this, lex);
- par->InsertChar(pos, LyXParagraph::META_INSET);
par->InsertInset(pos, inset);
- par->SetFont(pos, font);
- ++pos;
#endif
+ ++pos;
} else if (tmptok == "External") {
Inset * inset = new InsetExternal;
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
} else if (tmptok == "FormulaMacro") {
Inset * inset = new InsetFormulaMacro;
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
} else if (tmptok == "Formula") {
Inset * inset = new InsetFormula;
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
} else if (tmptok == "Figure") {
Inset * inset = new InsetFig(100, 100, this);
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
} else if (tmptok == "Info") {
Inset * inset = new InsetInfo;
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
} else if (tmptok == "Include") {
Inset * inset = new InsetInclude(string(), this);
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
} else if (tmptok == "ERT") {
- Inset * inset = new InsetERT();
+ Inset * inset = new InsetERT;
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
} else if (tmptok == "Tabular") {
Inset * inset = new InsetTabular(this);
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
} else if (tmptok == "Text") {
- Inset * inset = new InsetText();
+ Inset * inset = new InsetText;
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
} else if (tmptok == "Foot") {
- Inset * inset = new InsetFoot();
+ Inset * inset = new InsetFoot;
+ inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
+ par->InsertChar(pos, LyXParagraph::META_INSET);
+ par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
+ ++pos;
+ } else if (tmptok == "Marginal") {
+ Inset * inset = new InsetMarginal;
+ inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
+ par->InsertChar(pos, LyXParagraph::META_INSET);
+ par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
+ ++pos;
+ } else if (tmptok == "Minipage") {
+ Inset * inset = new InsetMinipage;
+ inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
+ par->InsertChar(pos, LyXParagraph::META_INSET);
+ par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
+ ++pos;
+ } else if (tmptok == "Float") {
+ Inset * inset = new InsetFloat;
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
+ par->SetFont(pos, font);
par->InsertInset(pos, inset);
+#endif
+ ++pos;
+ } else if (tmptok == "List") {
+ Inset * inset = new InsetList;
+ inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
+ par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
} else if (tmptok == "GRAPHICS") {
Inset * inset = new InsetGraphics;
//inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
} else if (tmptok == "LatexCommand") {
InsetCommand inscmd;
inscmd.Read(this, lex);
}
if (inset) {
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
}
}
lex.next();
next_token = lex.GetString();
if (next_token == "\\-") {
+#ifdef NEW_WAY
+ par->InsertChar(pos, '-', font);
+#else
par->InsertChar(pos, '-');
par->SetFont(pos, font);
+#endif
} else if (next_token == "\\protected_separator"
|| next_token == "~") {
+#ifdef NEW_WAY
+ par->InsertChar(pos, ' ', font);
+#else
par->InsertChar(pos, ' ');
par->SetFont(pos, font);
+#endif
} else {
lex.printError("Token `$$Token' "
"is in free space "
} else {
Inset * inset = new InsetSpecialChar;
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
}
++pos;
} else if (token == "\\newline") {
+#ifdef NEW_WAY
+ par->InsertChar(pos, LyXParagraph::META_NEWLINE, font);
+#else
par->InsertChar(pos, LyXParagraph::META_NEWLINE);
par->SetFont(pos, font);
+#endif
++pos;
} else if (token == "\\LyXTable") {
#ifdef USE_TABULAR_INSETS
Inset * inset = new InsetTabular(this);
inset->Read(this, lex);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
++pos;
#else
par->table = new LyXTable(lex);
#endif
} else if (token == "\\hfill") {
+#ifdef NEW_WAY
+ par->InsertChar(pos, LyXParagraph::META_HFILL, font);
+#else
par->InsertChar(pos, LyXParagraph::META_HFILL);
par->SetFont(pos, font);
+#endif
++pos;
} else if (token == "\\protected_separator") { // obsolete
// This is a backward compability thingie. (Lgb)
par->GetLayout());
if (layout.free_spacing) {
+#ifdef NEW_WAY
+ par->InsertChar(pos, ' ', font);
+#else
par->InsertChar(pos, ' ');
par->SetFont(pos, font);
+#endif
} else {
Inset * inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
+#ifdef NEW_WAY
+ par->InsertInset(pos, inset, font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
par->SetFont(pos, font);
+ par->InsertInset(pos, inset);
+#endif
}
++pos;
} else if (token == "\\bibitem") { // ale970302
par->bibkey = new InsetBibKey;
par->bibkey->Read(this, lex);
}else if (token == "\\backslash") {
+#ifdef NEW_WAY
+ par->InsertChar(pos, '\\', font);
+#else
par->InsertChar(pos, '\\');
par->SetFont(pos, font);
+#endif
++pos;
}else if (token == "\\the_end") {
the_end_read = true;
"Inserting as text.");
for(string::const_iterator cit = token.begin();
cit != token.end(); ++cit) {
+#ifdef NEW_WAY
+ par->InsertChar(pos, (*cit), font);
+#else
par->InsertChar(pos, (*cit));
par->SetFont(pos, font);
+#endif
++pos;
}
}
#ifndef NEW_TABULAR
/* It might be a table */
if (par->table){
-#if 0
- if (!lyxrc.ascii_roff_command.empty() &&
- lyxrc.ascii_roff_command != "none") {
- RoffAsciiTable(ofs, par);
- par = par->next;
- continue;
- }
-#endif
cell = 1;
actcell = 0;
cells = par->table->columns;
void Buffer::LinuxDocError(LyXParagraph * par, int pos,
char const * message)
{
- InsetError * new_inset;
-
// insert an error marker in text
- new_inset = new InsetError(message);
+ InsetError * new_inset = new InsetError(message);
+#ifdef NEW_WAY
+ par->InsertInset(pos, new_inset);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->InsertInset(pos, new_inset);
+#endif
}
// This constant defines the maximum number of
}
-#if 0
-void Buffer::RoffAsciiTable(ostream & os, LyXParagraph * par)
-{
- LyXFont font1(LyXFont::ALL_INHERIT,params.language_info);
- LyXFont font2;
- Inset * inset;
- LyXParagraph::size_type i;
- int j, cell = 0;
- char c;
-
- string fname1 = TmpFileName(string(), "RAT1");
- string fname2 = TmpFileName(string(), "RAT2");
-
- ofstream ofs(fname1.c_str());
- if (!ofs) {
- WriteAlert(_("LYX_ERROR:"),
- _("Cannot open temporary file:"), fname1);
- return;
- }
- par->table->RoffEndOfCell(ofs, -1);
- for (i = 0; i < par->size(); ++i) {
- c = par->GetChar(i);
- if (par->table->IsContRow(cell)) {
- if (c == LyXParagraph::META_NEWLINE)
- ++cell;
- continue;
- }
- font2 = par->GetFontSettings(i);
- if (font1.latex() != font2.latex()) {
- if (font2.latex() != LyXFont::OFF)
- continue;
- }
- switch (c) {
- case LyXParagraph::META_INSET:
- if ((inset = par->GetInset(i))) {
-#ifdef HAVE_SSTREAM
- stringstresm ss(ios::in | ios::out);
- inset->Ascii(this, ss);
- ss.seekp(0);
- ss.get(c);
- while (!ss) {
- if (c == '\\')
- ofs << "\\\\";
- else
- ofs << c;
- ss.get(c);
- }
-#else
- strstream ss;
- inset->Ascii(this, ss);
- ss.seekp(0);
- ss.get(c);
- while (!ss) {
- if (c == '\\')
- ofs << "\\\\";
- else
- ofs << c;
- ss.get(c);
- }
- delete [] ss.str();
-#endif
- }
- break;
- case LyXParagraph::META_NEWLINE:
- if (par->table->CellHasContRow(cell)>= 0)
- par->RoffContTableRows(ofs, i+1, cell);
- par->table->RoffEndOfCell(ofs, cell);
- ++cell;
- break;
- case LyXParagraph::META_HFILL:
- break;
- case '\\':
- ofs << "\\\\";
- break;
- default:
- if (c != '\0')
- ofs << c;
- else if (c == '\0')
- lyxerr.debug()
- << "RoffAsciiTable:"
- " NULL char in structure." << endl;
- break;
- }
- }
- par->table->RoffEndOfCell(ofs, cell);
- ofs.close();
- string cmd = lyxrc.ascii_roff_command + " >" + fname2;
- cmd = subst(cmd, "$$FName", fname1);
- Systemcalls one(Systemcalls::System, cmd);
- if (!(lyxerr.debugging(Debug::ROFF))) {
- remove(fname1.c_str());
- }
- ifstream ifs(fname2.c_str());
- if (!ifs) {
- WriteFSAlert(_("Error! Can't open temporary file:"), fname2);
- return;
- }
- // now output the produced file
- os << "\n\n";
- ifs.get(c);
- if (!ifs)
- WriteAlert(_("Error!"),
- _("Error executing *roff command on table"));
- // overread leading blank lines
- while(!ifs && (c == '\n'))
- ifs.get(c);
- while(!ifs) {
- for(j = 0; j < par->depth; ++j)
- os << " ";
- while(!ifs && (c != '\n')) {
- os << c;
- ifs.get(c);
- }
- os << '\n';
- // overread trailing blank lines
- while(!ifs && (c == '\n'))
- ifs.get(c);
- }
- ifs.close();
- remove(fname2.c_str());
-}
-#endif
-
-
void Buffer::validate(LaTeXFeatures & features) const
{
LyXParagraph * par = paragraph;
void pop_tag(std::ostream & os, char const * tag,
int & pos, char stack[5][3]);
-#if 0
- ///
- void RoffAsciiTable(std::ostream &, LyXParagraph * par);
-#endif
-
/// is save needed
mutable bool lyx_clean;
LFUN_LOAVIEW, // Dekel 20000519
LFUN_SET_COLOR, // SLior 20000611
LFUN_INSET_EXTERNAL, // Alstrup 20000609
+ LFUN_INSET_MARGINAL, // Lgb 20000626
+ LFUN_INSET_MINIPAGE, // Lgb 20000627
+ LFUN_INSET_FLOAT, // Lgb 20000627
+ LFUN_INSET_LIST, // Lgb 20000627
LFUN_LASTACTION /* this marks the end of the table */
};
insetert.h \
insetexternal.C \
insetexternal.h \
+ insetfloat.h \
+ insetfloat.C \
insetfoot.C \
insetfoot.h \
insetgraphics.C \
insetlabel.h \
insetlatexaccent.C \
insetlatexaccent.h \
+ insetlist.C \
+ insetlist.h \
insetloa.C \
insetloa.h \
insetlof.C \
insetlot.h \
insetmarginal.h \
insetmarginal.C \
+ insetminipage.C \
+ insetminipage.h \
insetparent.C \
insetparent.h \
insetquotes.C \
#include "BufferView.h"
#include "Painter.h"
#include "support/LOstream.h"
+#include "support/lstrings.h"
using std::ostream;
return result;
}
+
void InsetCollapsable::Write(Buffer const * buf, ostream & os) const
{
- os << getInsetName() << "\n\ncollapsed ";
- if (display())
- os << "false\n";
- else
- os << "true\n";
- WriteParagraphData(buf, os);
+ os << "collapsed " << tostr(!display()) << "\n";
+ WriteParagraphData(buf, os);
}
width_collapsed(pain, labelfont) - widthOffset;
}
-void InsetCollapsable::update(BufferView * bv, LyXFont const & font, bool dodraw)
+
+void InsetCollapsable::update(BufferView * bv,
+ LyXFont const & font, bool dodraw)
{
drawTextXOffset = width_collapsed(bv->painter(), font);
InsetText::update(bv, font, dodraw);
string label;
///
bool autocollapse;
+protected:
+ // Instead of making these ints protected we could have a
+ // protected method "clickInButton" (Lgb)
///
mutable int
button_length, button_top_y, button_bottom_y;
+private:
///
int widthOffset;
};
}
+void InsetERT::Write(Buffer const * buf, ostream & os) const
+{
+ os << getInsetName() << "\n";
+ InsetCollapsable::Write(buf, os);
+}
+
+
Inset * InsetERT::Clone() const
{
InsetERT * result = new InsetERT();
*/
class InsetERT : public InsetCollapsable {
public:
- ///
- InsetERT();
- ///
- ~InsetERT() {}
- ///
- Inset * Clone() const;
- ///
- char const * EditMessage() const;
- ///
- bool InsertInset(BufferView *, Inset *);
- ///
- void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
- ///
- void Edit(BufferView *, int, int, unsigned int);
- ///
+ ///
+ InsetERT();
+ ///
+ ~InsetERT() {}
+ ///
+ void Write(Buffer const * buf, ostream & os) const;
+ ///
+ Inset * Clone() const;
+ ///
+ char const * EditMessage() const;
+ ///
+ bool InsertInset(BufferView *, Inset *);
+ ///
+ void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+ ///
+ void Edit(BufferView *, int, int, unsigned int);
+ ///
};
#endif
--- /dev/null
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1998 The LyX Team.
+ *
+ *======================================================*/
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "insetfloat.h"
+#include "gettext.h"
+#include "lyxfont.h"
+#include "BufferView.h"
+#include "Painter.h"
+#include "lyxtext.h"
+#include "support/LOstream.h"
+#include "FloatList.h"
+#include "LaTeXFeatures.h"
+#include "debug.h"
+
+using std::ostream;
+using std::endl;
+
+// With this inset it will be possible to support the latex package
+// float.sty, and I am sure that with this and some additional support
+// classes we can support similar functionality in other formats
+// (read DocBook).
+// By using float.sty we will have the same handling for all floats, both
+// for those already in existance (table and figure) and all user created
+// ones¹. So suddenly we give the users the possibility of creating new
+// kinds of floats on the fly. (and with a uniform look)
+//
+// API to float.sty:
+// \newfloat{type}{placement}{ext}[within]
+// type - The "type" of the new class of floats, like program or
+// algorithm. After the appropriate \newfloat, commands
+// such as \begin{program} or \end{algorithm*} will be
+// available.
+// placement - The default placement for the given class of floats.
+// They are like in standard LaTeX: t, b, p and h for top,
+// bottom, page, and here, respectively. On top of that
+// there is a new type, H, which does not really correspond
+// to a float, since it means: put it "here" and nowhere else.
+// Note, however that the H specifier is special and, because
+// of implementation details cannot be used in the second
+// argument of \newfloat.
+// ext - The file name extension of an auxiliary file for the list
+// of figures (or whatever). LaTeX writes the captions to
+// this file.
+// within - This (optional) argument determines whether floats of this
+// class will be numbered within some sectional unit of the
+// document. For example, if within is equal to chapter, the
+// floats will be numbered within chapters.
+// \floatstyle{style}
+// style - plain, boxed, ruled
+// \floatname{float}{floatname}
+// float -
+// floatname -
+// \floatplacement{float}{placement}
+// float -
+// placement -
+// \restylefloat{float}
+// float -
+// \listof{type}{title}
+// title -
+
+// ¹ the algorithm float is defined using the float.sty package. Like this
+// \floatstyle{ruled}
+// \newfloat{algorithm}{htbp}{loa}[<sect>]
+// \floatname{algorithm}{Algorithm}
+//
+// Lgb
+
+InsetFloat::InsetFloat() : InsetCollapsable()
+{
+ setLabel(_("float"));
+ LyXFont font(LyXFont::ALL_SANE);
+ font.decSize();
+ font.decSize();
+ font.setColor(LColor::footnote);
+ setLabelFont(font);
+ setAutoCollapse(false);
+ setInsetName("Float");
+ floatType = "table";
+ floatPlacement = "H";
+}
+
+
+void InsetFloat::Write(Buffer const * buf, ostream & os) const
+{
+ os << getInsetName()
+ << "\ntype " << floatType
+ << "\nplacement " << floatPlacement << "\n";
+ InsetCollapsable::Write(buf, os);
+}
+
+
+void InsetFloat::Read(Buffer const * buf, LyXLex & lex)
+{
+ if (lex.IsOK()) {
+ lex.next();
+ string token = lex.GetString();
+ if (token == "type") {
+ lex.next();
+ floatType = lex.GetString();
+ }
+ lex.next();
+ token = lex.GetString();
+ if (token == "placement") {
+ lex.next();
+ floatPlacement = lex.GetString();
+ }
+ }
+ InsetCollapsable::Read(buf, lex);
+}
+
+
+void InsetFloat::Validate(LaTeXFeatures & features) const
+{
+ features.usedFloats.insert(floatType);
+}
+
+
+Inset * InsetFloat::Clone() const
+{
+ InsetFloat * result = new InsetFloat;
+ result->init(this);
+
+ result->collapsed = collapsed;
+ return result;
+}
+
+
+char const * InsetFloat::EditMessage() const
+{
+ return _("Opened Float Inset");
+}
+
+
+int InsetFloat::Latex(Buffer const * buf,
+ ostream & os, bool fragile, bool fp) const
+{
+ os << "\\begin{" << floatType << "}";
+ if (!floatPlacement.empty()
+ && floatPlacement != floatList.defaultPlacement(floatType))
+ os << "[" << floatPlacement << "]";
+ os << "%\n";
+
+ int i = InsetText::Latex(buf, os, fragile, fp);
+ os << "\\end{" << floatType << "}%\n";
+
+ return i + 2;
+}
+
+
+bool InsetFloat::InsertInset(BufferView * bv, Inset * inset)
+{
+ if (!InsertInsetAllowed(inset))
+ return false;
+
+ return InsetText::InsertInset(bv, inset);
+}
+
+
+bool InsetFloat::InsertInsetAllowed(Inset * inset) const
+{
+ if ((inset->LyxCode() == Inset::FOOT_CODE) ||
+ (inset->LyxCode() == Inset::MARGIN_CODE)) {
+ return false;
+ }
+ return true;
+}
+
+
+LyXFont InsetFloat::GetDrawFont(BufferView * bv,
+ LyXParagraph * p, int pos) const
+{
+ LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
+ fn.decSize().decSize();
+ return fn;
+}
+
+
+void InsetFloat::InsetButtonRelease(BufferView * bv, int x, int y, int button)
+{
+ if (x >= 0
+ && x < button_length
+ && y >= button_top_y
+ && y < button_bottom_y
+ && button == 3) {
+ // This obviously need to change.
+ lyxerr << "InsetFloat: Let's edit this floats parameters!"
+ << endl;
+ } else {
+ InsetCollapsable::InsetButtonRelease(bv, x, y, button);
+ }
+}
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1998 The LyX Team.
+ *
+ * ======================================================
+ */
+
+#ifndef InsetFloat_H
+#define InsetFloat_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "insetcollapsable.h"
+
+class Painter;
+
+/** The float inset
+
+*/
+class InsetFloat : public InsetCollapsable {
+public:
+ ///
+ explicit
+ InsetFloat();
+ ///
+ ~InsetFloat() {}
+ ///
+ void Write(Buffer const * buf, ostream & os) const;
+ ///
+ void Read(Buffer const * buf, LyXLex & lex);
+ ///
+ void Validate(LaTeXFeatures & features) const;
+ ///
+ Inset * Clone() const;
+ ///
+ Inset::Code LyxCode() const { return Inset::FLOAT_CODE; }
+ ///
+ int Latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
+ ///
+ const char * EditMessage() const;
+ ///
+ bool InsertInset(BufferView *, Inset * inset);
+ ///
+ bool InsertInsetAllowed(Inset * inset) const;
+ ///
+ LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
+ ///
+ void InsetButtonRelease(BufferView * bv, int x, int y, int button);
+private:
+ ///
+ string floatType;
+ ///
+ string floatPlacement;
+};
+
+#endif
}
+void InsetFoot::Write(Buffer const * buf, ostream & os) const
+{
+ os << getInsetName() << "\n";
+ InsetCollapsable::Write(buf, os);
+}
+
+
Inset * InsetFoot::Clone() const
{
InsetFoot * result = new InsetFoot;
int InsetFoot::Latex(Buffer const * buf, ostream & os, bool fragile, bool fp) const
{
- os << "\\footnote{%" << endl;
+ os << "\\footnote{%\n";
int i = InsetText::Latex(buf, os, fragile, fp);
- os << "}%" << endl;
+ os << "}%\n";
return i + 2;
}
*/
class InsetFoot : public InsetCollapsable {
public:
- ///
+ ///
explicit
- InsetFoot();
- ///
- ~InsetFoot() {}
- ///
- Inset * Clone() const;
- ///
- Inset::Code LyxCode() const { return Inset::FOOT_CODE; }
- ///
- int Latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
- ///
- const char * EditMessage() const;
- ///
- bool InsertInset(BufferView *, Inset * inset);
- ///
- bool InsertInsetAllowed(Inset * inset) const;
- ///
- LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
+ InsetFoot();
+ ///
+ ~InsetFoot() {}
+ ///
+ void Write(Buffer const * buf, ostream & os) const;
+ ///
+ Inset * Clone() const;
+ ///
+ Inset::Code LyxCode() const { return Inset::FOOT_CODE; }
+ ///
+ int Latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
+ ///
+ const char * EditMessage() const;
+ ///
+ bool InsertInset(BufferView *, Inset * inset);
+ ///
+ bool InsertInsetAllowed(Inset * inset) const;
+ ///
+ LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
};
#endif
--- /dev/null
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1998 The LyX Team.
+ *
+ * ====================================================== */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "insetlist.h"
+#include "gettext.h"
+#include "lyxfont.h"
+#include "BufferView.h"
+#include "Painter.h"
+#include "lyxtext.h"
+#include "support/LOstream.h"
+
+using std::ostream;
+using std::endl;
+
+// This class is _far_ from finished. I hope that we can have a inset to
+// handle the different lists that we have. It should also be possible
+// to create new lists on the fly.
+// Currently LyX only supports: itemize, enumerate, description and
+// lyxlist. All support for these should be moved to this class and other
+// helper classes.
+// It is also possible that we will need a baseclass and subclasses for
+// different types of lists. (and should they be collapsable?)
+//
+// Lgb
+
+InsetList::InsetList()
+ : InsetCollapsable()
+{
+ setLabel(_("list"));
+ LyXFont font(LyXFont::ALL_SANE);
+ font.decSize();
+ font.decSize();
+ font.setColor(LColor::footnote);
+ setLabelFont(font);
+ setAutoCollapse(false);
+ setInsetName("List");
+}
+
+
+void InsetList::Write(Buffer const * buf, ostream & os) const
+{
+ os << getInsetName() << "\n";
+ InsetCollapsable::Write(buf, os);
+}
+
+
+Inset * InsetList::Clone() const
+{
+ InsetList * result = new InsetList;
+ result->init(this);
+
+ result->collapsed = collapsed;
+ return result;
+}
+
+
+char const * InsetList::EditMessage() const
+{
+ return _("Opened List Inset");
+}
+
+
+int InsetList::Latex(Buffer const * buf,
+ ostream & os, bool fragile, bool fp) const
+{
+ os << "\\footnote{%\n";
+
+ int i = InsetText::Latex(buf, os, fragile, fp);
+ os << "}%\n";
+
+ return i + 2;
+}
+
+
+bool InsetList::InsertInset(BufferView * bv, Inset * inset)
+{
+ if (!InsertInsetAllowed(inset))
+ return false;
+
+ return InsetText::InsertInset(bv, inset);
+}
+
+
+bool InsetList::InsertInsetAllowed(Inset * inset) const
+{
+ if ((inset->LyxCode() == Inset::FOOT_CODE) ||
+ (inset->LyxCode() == Inset::MARGIN_CODE)) {
+ return false;
+ }
+ return true;
+}
+
+
+LyXFont InsetList::GetDrawFont(BufferView * bv,LyXParagraph * p, int pos) const
+{
+ LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
+ fn.decSize().decSize();
+ return fn;
+}
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1998 The LyX Team.
+ *
+ * ======================================================
+ */
+
+#ifndef InsetList_H
+#define InsetList_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "insetcollapsable.h"
+
+class Painter;
+
+/** The footnote inset
+
+*/
+class InsetList : public InsetCollapsable {
+public:
+ ///
+ explicit
+ InsetList();
+ ///
+ ~InsetList() {}
+ ///
+ void Write(Buffer const * buf, ostream & os) const;
+ ///
+ Inset * Clone() const;
+ ///
+ Inset::Code LyxCode() const { return Inset::FOOT_CODE; }
+ ///
+ int Latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
+ ///
+ const char * EditMessage() const;
+ ///
+ bool InsertInset(BufferView *, Inset * inset);
+ ///
+ bool InsertInsetAllowed(Inset * inset) const;
+ ///
+ LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
+};
+
+#endif
}
+void InsetMarginal::Write(Buffer const * buf, ostream & os) const
+{
+ os << getInsetName() << "\n";
+ InsetCollapsable::Write(buf, os);
+}
+
+
Inset * InsetMarginal::Clone() const
{
InsetMarginal * result = new InsetMarginal;
int InsetMarginal::Latex(Buffer const * buf,
ostream & os, bool fragile, bool fp) const
{
- os << "\\marginpar{%" << endl;
+ os << "\\marginpar{%\n";
int i = InsetText::Latex(buf, os, fragile, fp);
- os << "}%" << endl;
+ os << "}%\n";
return i + 2;
}
///
~InsetMarginal() {}
///
+ void Write(Buffer const * buf, ostream & os) const;
+ ///
Inset * Clone() const;
///
Inset::Code LyxCode() const { return Inset::MARGIN_CODE; }
--- /dev/null
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1998 The LyX Team.
+ *
+ *======================================================*/
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "insetminipage.h"
+#include "gettext.h"
+#include "lyxfont.h"
+#include "BufferView.h"
+#include "Painter.h"
+#include "lyxtext.h"
+#include "support/LOstream.h"
+
+using std::ostream;
+using std::endl;
+
+
+// Some information about Minipages in LaTeX:
+// A minipage is a complete miniversion of a page and can contain
+// its own footnotes, paragraphs, and array, tabular, and multicols
+// environments. However it cannot contain floats or \marginpar's,
+// but it can appear inside floats.
+//
+// The minipage environment is defined like this:
+//
+// \begin{minipage}[pos][height][inner-pos]{width} <text> \end{minipage}
+//
+// Where:
+// pos [opt] = is the vertical placement of the box with respect
+// to the text baseline, [c], [t] and [b].
+// height [opt] = the height of the box
+// inner-pos [opt] = the position of the text within the box.
+// It can be t, c, b or s, if unspecified the value
+// of pos is used.
+// width = the width of the box
+//
+// In LyX we should try to support all these parameters, settable in a
+// pop-up dialog.
+// In this pop-up diallog it should also be possible to set all margin
+// values that is usable in the minipage.
+// With regard to different formats (like DocBook) I guess a minipage
+// can be used there also. Perhaps not in the latex way, but we do not
+// have to output "" for minipages.
+// (Lgb)
+
+InsetMinipage::InsetMinipage()
+ : InsetCollapsable()
+{
+ setLabel(_("minipage"));
+ LyXFont font(LyXFont::ALL_SANE);
+ font.decSize();
+ font.decSize();
+ font.setColor(LColor::footnote);
+ setLabelFont(font);
+ setAutoCollapse(false);
+ setInsetName("Minipage");
+}
+
+
+void InsetMinipage::Write(Buffer const * buf, ostream & os) const
+{
+ os << getInsetName() << "\n";
+ InsetCollapsable::Write(buf, os);
+}
+
+
+Inset * InsetMinipage::Clone() const
+{
+ InsetMinipage * result = new InsetMinipage;
+ result->init(this);
+
+ result->collapsed = collapsed;
+ return result;
+}
+
+
+char const * InsetMinipage::EditMessage() const
+{
+ return _("Opened Minipage Inset");
+}
+
+
+int InsetMinipage::Latex(Buffer const * buf,
+ ostream & os, bool fragile, bool fp) const
+{
+ os << "\\begin{minipage}{\\columnwidth}%\n";
+
+ int i = InsetText::Latex(buf, os, fragile, fp);
+ os << "\\end{minipage}%\n";
+
+ return i + 2;
+}
+
+
+bool InsetMinipage::InsertInset(BufferView * bv, Inset * inset)
+{
+ if (!InsertInsetAllowed(inset))
+ return false;
+
+ return InsetText::InsertInset(bv, inset);
+}
+
+
+bool InsetMinipage::InsertInsetAllowed(Inset * inset) const
+{
+ if ((inset->LyxCode() == Inset::FLOAT_CODE) ||
+ (inset->LyxCode() == Inset::MARGIN_CODE)) {
+ return false;
+ }
+ return true;
+}
+
+
+LyXFont InsetMinipage::GetDrawFont(BufferView * bv,
+ LyXParagraph * p, int pos) const
+{
+ LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
+ fn.decSize().decSize();
+ return fn;
+}
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1998 The LyX Team.
+ *
+ *======================================================
+ */
+
+#ifndef InsetMinipage_H
+#define InsetMinipage_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "insetcollapsable.h"
+
+class Painter;
+
+/** The footnote inset
+
+*/
+class InsetMinipage : public InsetCollapsable {
+public:
+ ///
+ explicit
+ InsetMinipage();
+ ///
+ ~InsetMinipage() {}
+ ///
+ void Write(Buffer const * buf, ostream & os) const;
+ ///
+ Inset * Clone() const;
+ ///
+ Inset::Code LyxCode() const { return Inset::MINIPAGE_CODE; }
+ ///
+ int Latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
+ ///
+ const char * EditMessage() const;
+ ///
+ bool InsertInset(BufferView *, Inset * inset);
+ ///
+ bool InsertInsetAllowed(Inset * inset) const;
+ ///
+ LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
+};
+
+#endif
extern unsigned char getCurrentTextClass(Buffer *);
-#define TEXT(a) getLyXText(a)
+// Jürgen, we don't like macros, even small ones like this. (Lgb)
+//#define TEXT(a) getLyXText(a)
+// I created a inline function in insettext.h instead. (Lgb)
InsetText::InsetText()
{
void InsetText::Read(Buffer const * buf, LyXLex & lex)
{
- string token, tmptok;
+ string token;
int pos = 0;
LyXParagraph * return_par = 0;
char depth = 0; // signed or unsigned?
LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
LyXFont font(LyXFont::ALL_INHERIT);
- LyXParagraph * p;
- p = par->next;
+ LyXParagraph * p = par->next;
delete par;
while(p) {
par = p;
return insetWidth;
}
+
int InsetText::textWidth(Painter & pain) const
{
return getMaxTextWidth(pain, this) - drawTextXOffset;
}
}
break;
+ case LFUN_PARAGRAPH_SPACING:
+ // This one is absolutely not working. When fiddling with this
+ // it also seems to me that the paragraphs inside the insettext
+ // inherit bufferparams/paragraphparams in a strange way. (Lgb)
+ {
+ LyXParagraph * par = TEXT(bv)->cursor.par();
+ Spacing::Space cur_spacing = par->spacing.getSpace();
+ float cur_value = 1.0;
+ if (cur_spacing == Spacing::Other) {
+ cur_value = par->spacing.getValue();
+ }
+
+#ifdef HAVE_SSTREAM
+ istringstream istr(arg);
+#else
+ istrstream istr(arg.c_str());
+#endif
+ string tmp;
+ istr >> tmp;
+ Spacing::Space new_spacing = cur_spacing;
+ float new_value = cur_value;
+ if (tmp.empty()) {
+ lyxerr << "Missing argument to `paragraph-spacing'"
+ << endl;
+ } else if (tmp == "single") {
+ new_spacing = Spacing::Single;
+ } else if (tmp == "onehalf") {
+ new_spacing = Spacing::Onehalf;
+ } else if (tmp == "double") {
+ new_spacing = Spacing::Double;
+ } else if (tmp == "other") {
+ new_spacing = Spacing::Other;
+ float tmpval = 0.0;
+ istr >> tmpval;
+ lyxerr << "new_value = " << tmpval << endl;
+ if (tmpval != 0.0)
+ new_value = tmpval;
+ } else if (tmp == "default") {
+ new_spacing = Spacing::Default;
+ } else {
+ lyxerr << _("Unknown spacing argument: ")
+ << arg << endl;
+ }
+ if (cur_spacing != new_spacing || cur_value != new_value) {
+ par->spacing.set(new_spacing, new_value);
+ //TEXT(bv)->RedoParagraph(owner->view());
+ UpdateLocal(bv, CURSOR_PAR, true);
+ //bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ }
+ }
+ break;
+
default:
result = UNDISPATCHED;
break;
UpdatableInset * i = static_cast<UpdatableInset *>(inset);
i->setOwner(static_cast<UpdatableInset *>(this));
}
+#ifdef NEW_WAY
+ cpar(bv)->InsertInset(cpos(bv), inset);
+#else
cpar(bv)->InsertChar(cpos(bv), LyXParagraph::META_INSET);
cpar(bv)->InsertInset(cpos(bv), inset);
+#endif
TEXT(bv)->selection = 0;
UpdateLocal(bv, CURSOR_PAR, true);
static_cast<UpdatableInset*>(inset)->Edit(bv, 0, 0, 0);
}
-int InsetText::getMaxTextWidth(Painter & pain, UpdatableInset const * inset) const
+int InsetText::getMaxTextWidth(Painter & pain,
+ UpdatableInset const * inset) const
{
return getMaxWidth(pain, inset) - (2 * TEXT_TO_INSET_OFFSET);
}
+
void InsetText::SetParagraphData(LyXParagraph *p)
{
LyXParagraph * np;
need_update = INIT;
}
+
void InsetText::SetAutoBreakRows(bool flag)
{
if (flag != autoBreakRows) {
}
}
+
void InsetText::SetDrawLockedFrame(bool flag)
{
if (flag != drawLockedFrame)
drawLockedFrame = flag;
}
+
void InsetText::SetFrameColor(LColor::color col)
{
if (frame_color != col)
frame_color = col;
}
+
LyXFont InsetText::GetDrawFont(BufferView * bv, LyXParagraph * p, int pos) const
{
return TEXT(bv)->GetFont(bv->buffer(), p, pos);
}
+
int InsetText::cx(BufferView * bv) const
{
return TEXT(bv)->cursor.x() + top_x + 1;
}
+
int InsetText::cy(BufferView * bv) const
{
long int y_dummy = 0;
return TEXT(bv)->cursor.y() - tmprow->baseline();
}
+
int InsetText::cpos(BufferView * bv) const
{
return TEXT(bv)->cursor.pos();
}
+
LyXParagraph * InsetText::cpar(BufferView * bv) const
{
return TEXT(bv)->cursor.par();
}
+
Row * InsetText::crow(BufferView * bv) const
{
return TEXT(bv)->cursor.row();
}
+
LyXText * InsetText::getLyXText(BufferView * bv) const
{
if (cache.find(bv) != cache.end())
return cache[bv];
- LyXText *lt = new LyXText(const_cast<InsetText *>(this));
+ LyXText * lt = new LyXText(const_cast<InsetText *>(this));
lt->init(bv);
cache[bv] = lt;
return lt;
}
+
void InsetText::deleteLyXText(BufferView * bv)
{
cache.erase(bv);
int cpos(BufferView *) const;
LyXParagraph * cpar(BufferView *) const;
Row * crow(BufferView *) const;
+
+ /// This instead of a macro
+ LyXText * TEXT(BufferView * bv) const {
+ return getLyXText(bv);
+ }
/* Private structures and variables */
///
///
MARGIN_CODE,
///
+ FLOAT_CODE,
+ ///
+ MINIPAGE_CODE,
+ ///
SPECIALCHAR_CODE,
///
TABULAR_CODE,
};
-#if 0
-static keyword_item labelTypeTags[] = {
- { "bibliography", LA_BIBLIO },
- { "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
- { "counter_chapter", LA_COUNTER_CHAPTER },
- { "counter_enumi", LA_COUNTER_ENUMI },
- { "counter_enumii", LA_COUNTER_ENUMII },
- { "counter_enumiii", LA_COUNTER_ENUMIII },
- { "counter_enumiv", LA_COUNTER_ENUMIV },
- { "counter_paragraph", LA_COUNTER_PARAGRAPH },
- { "counter_section", LA_COUNTER_SECTION },
- { "counter_subparagraph", LA_COUNTER_SUBPARAGRAPH },
- { "counter_subsection", LA_COUNTER_SUBSECTION },
- { "counter_subsubsection", LA_COUNTER_SUBSUBSECTION },
- { "manual", LA_MANUAL },
- { "no_label", LA_NO_LABEL },
- { "sensitive", LA_SENSITIVE },
- { "static", LA_STATIC },
- { "top_environment", LA_TOP_ENVIRONMENT }
-};
-#endif
-
-
void LyXLayout::readLabelType(LyXLex & lexrc)
{
keyword_item labelTypeTags[] = {
}
}
-#if 0
-static keyword_item marginTags[] = {
- { "dynamic", MARGIN_DYNAMIC },
- { "first_dynamic", MARGIN_FIRST_DYNAMIC },
- { "manual", MARGIN_MANUAL },
- { "right_address_box", MARGIN_RIGHT_ADDRESS_BOX },
- { "static", MARGIN_STATIC }
-};
-#endif
void LyXLayout::readMargin(LyXLex & lexrc)
{
}
-#if 0
-static keyword_item latexTypeTags[] = {
- { "command", LATEX_COMMAND },
- { "environment", LATEX_ENVIRONMENT },
- { "item_environment", LATEX_ITEM_ENVIRONMENT },
- { "list_environment", LATEX_LIST_ENVIRONMENT },
- { "paragraph", LATEX_PARAGRAPH }
-};
-#endif
-
-
void LyXLayout::readLatexType(LyXLex & lexrc)
{
keyword_item latexTypeTags[] = {
};
-#if 0
-static keyword_item spacingTags[] = {
- {"double", ST_SPACING_DOUBLE },
- {"onehalf", ST_SPACING_ONEHALF },
- {"other", ST_OTHER },
- {"single", ST_SPACING_SINGLE }
-};
-#endif
-
-
void LyXLayout::readSpacing(LyXLex & lexrc)
{
keyword_item spacingTags[] = {
};
-#if 0
-static keyword_item textClassTags[] = {
- { "classoptions", TC_CLASSOPTIONS },
- { "columns", TC_COLUMNS },
- { "defaultfont", TC_DEFAULTFONT },
- { "input", TC_INPUT },
- { "leftmargin", TC_LEFTMARGIN },
- { "maxcounter", TC_MAXCOUNTER },
- { "nostyle", TC_NOSTYLE },
- { "outputtype", TC_OUTPUTTYPE },
- { "pagestyle", TC_PAGESTYLE },
- { "preamble", TC_PREAMBLE },
- { "providesamsmath", TC_PROVIDESAMSMATH },
- { "providesmakeidx", TC_PROVIDESMAKEIDX },
- { "providesurl", TC_PROVIDESURL },
- { "rightmargin", TC_RIGHTMARGIN },
- { "secnumdepth", TC_SECNUMDEPTH },
- { "sides", TC_SIDES },
- { "style", TC_STYLE },
- { "tocdepth", TC_TOCDEPTH }
-};
-#endif
-
-
// Reads a textclass structure from file.
bool LyXTextClass::Read(string const & filename, bool merge)
{
}
-#if 0
-static keyword_item outputTypeTags[] = {
- { "docbook", DOCBOOK },
- { "latex", LATEX },
- { "linuxdoc", LINUXDOC },
- { "literate", LITERATE }
-};
-#endif
-
void LyXTextClass::readOutputType(LyXLex & lexrc)
{
keyword_item outputTypeTags[] = {
};
-#if 0
-static keyword_item maxCounterTags[] = {
- {"counter_chapter", MC_COUNTER_CHAPTER },
- {"counter_enumi", MC_COUNTER_ENUMI },
- {"counter_enumii", MC_COUNTER_ENUMII },
- {"counter_enumiii", MC_COUNTER_ENUMIII },
- {"counter_enumiv", MC_COUNTER_ENUMIV },
- {"counter_paragraph", MC_COUNTER_PARAGRAPH },
- {"counter_section", MC_COUNTER_SECTION },
- {"counter_subparagraph", MC_COUNTER_SUBPARAGRAPH },
- {"counter_subsection", MC_COUNTER_SUBSECTION },
- {"counter_subsubsection", MC_COUNTER_SUBSUBSECTION }
-};
-#endif
-
-
void LyXTextClass::readMaxCounter(LyXLex & lexrc)
{
keyword_item maxCounterTags[] = {
};
-#if 0
-static keyword_item classOptionsTags[] = {
- {"end", CO_END },
- {"fontsize", CO_FONTSIZE },
- {"other", CO_OTHER },
- {"pagestyle", CO_PAGESTYLE }
-};
-#endif
-
-
void LyXTextClass::readClassOptions(LyXLex & lexrc)
{
keyword_item classOptionsTags[] = {
current_view->text->cursor.par()->getParLanguage(current_view->buffer()->params);
LyXFont font(LyXFont::ALL_INHERIT, lang);
for (int i = 0; i < xsize * ysize - 1; ++i) {
+#ifdef NEW_WAY
+ current_view->text->cursor.par()
+ ->InsertChar(0, LyXParagraph::META_NEWLINE, font);
+#else
current_view->text->cursor.par()->InsertChar(0, LyXParagraph::META_NEWLINE);
current_view->text->cursor.par()->SetFont(0, font);
+#endif
}
current_view->text->RedoParagraph(current_view);
#include "insets/insetexternal.h"
#include "insets/insetgraphics.h"
#include "insets/insetfoot.h"
+#include "insets/insetmarginal.h"
+#include "insets/insetminipage.h"
+#include "insets/insetfloat.h"
+#include "insets/insetlist.h"
#include "insets/insettabular.h"
#include "mathed/formulamacro.h"
#include "toolbar.h"
case LFUN_INSET_TEXT:
{
- InsetText * new_inset = new InsetText();
+ InsetText * new_inset = new InsetText;
if (owner->view()->insertInset(new_inset))
new_inset->Edit(owner->view(), 0, 0, 0);
else
delete new_inset;
}
break;
+
case LFUN_INSET_ERT:
{
- InsetERT * new_inset = new InsetERT();
+ InsetERT * new_inset = new InsetERT;
if (owner->view()->insertInset(new_inset))
new_inset->Edit(owner->view(), 0, 0, 0);
else
case LFUN_INSET_EXTERNAL:
{
- InsetExternal * new_inset = new InsetExternal();
+ InsetExternal * new_inset = new InsetExternal;
if (owner->view()->insertInset(new_inset))
new_inset->Edit(owner->view(), 0, 0, 0);
else
case LFUN_INSET_FOOTNOTE:
{
- InsetFoot * new_inset = new InsetFoot();
+ InsetFoot * new_inset = new InsetFoot;
+ if (owner->view()->insertInset(new_inset))
+ new_inset->Edit(owner->view(), 0, 0, 0);
+ else
+ delete new_inset;
+ }
+ break;
+
+ case LFUN_INSET_MARGINAL:
+ {
+ InsetMarginal * new_inset = new InsetMarginal;
+ if (owner->view()->insertInset(new_inset))
+ new_inset->Edit(owner->view(), 0, 0, 0);
+ else
+ delete new_inset;
+ }
+ break;
+
+ case LFUN_INSET_MINIPAGE:
+ {
+ InsetMinipage * new_inset = new InsetMinipage;
if (owner->view()->insertInset(new_inset))
new_inset->Edit(owner->view(), 0, 0, 0);
else
}
break;
+ case LFUN_INSET_FLOAT:
+ {
+ InsetFloat * new_inset = new InsetFloat;
+ if (owner->view()->insertInset(new_inset))
+ new_inset->Edit(owner->view(), 0, 0, 0);
+ else
+ delete new_inset;
+ }
+ break;
+
+ case LFUN_INSET_LIST:
+ {
+ InsetList * new_inset = new InsetList;
+ if (owner->view()->insertInset(new_inset))
+ new_inset->Edit(owner->view(), 0, 0, 0);
+ else
+ delete new_inset;
+ }
+ break;
+
case LFUN_INSET_TABULAR:
{
int r = 2, c = 2;
#include "support/block.h"
#include "language.h"
+#define NEW_WAY 1
+
class BufferParams;
class LyXBuffer;
class TexRow;
///
MINIPAGE_ALIGN_BOTTOM
};
+#ifndef NEW_INSETS
///
enum META_KIND {
///
///
WIDE_TAB // CFO-G, 971106
};
-
+#endif
///
typedef char value_type;
///
///
LyXTextClass::LayoutList::size_type layout;
-
+#ifndef NEW_INSETS
/**
\begin{itemize}
\item no footnote, closed footnote,
/// footnote, margin, fig, tab
footnote_kind footnotekind;
-
+#endif
//@Man: the LyX- DTP-switches
//@{
///
size_type endpos) const;
///
void InsertChar(size_type pos, char c);
+#ifdef NEW_WAY
+ ///
+ void InsertChar(size_type pos, char c, LyXFont const &);
+#endif
///
void InsertInset(size_type pos, Inset * inset);
+#ifdef NEW_WAY
+ ///
+ void InsertInset(size_type pos, Inset * inset, LyXFont const &);
+#endif
///
bool InsertInsetAllowed(Inset * inset);
///
int type, char const * width, char const * widthp);
///
void UnsetPExtraType(BufferParams const &);
-#if 0
- ///
- bool RoffContTableRows(std::ostream &, size_type i, int actcell);
-#endif
///
bool linuxDocConvertChar(char c, string & sgml_string);
///
#include <algorithm>
#include <fstream>
+#include <csignal>
#include "lyxparagraph.h"
#include "support/textutils.h"
itemdepth = 0;
next = 0;
previous = 0;
+#ifndef NEW_INSETS
footnoteflag = LyXParagraph::NO_FOOTNOTE;
footnotekind = LyXParagraph::FOOTNOTE; // should not be needed
-
+#endif
align = LYX_ALIGN_BLOCK;
#ifndef NEW_TABULAR
previous = par;
previous->next = this;
// end
+#ifndef NEW_INSETS
footnoteflag = LyXParagraph::NO_FOOTNOTE;
footnotekind = LyXParagraph::FOOTNOTE;
-
+#endif
#ifndef NEW_TABULAR
/* table stuff -- begin*/
table = 0;
if (footnoteflag != LyXParagraph::NO_FOOTNOTE
|| !previous
- || previous->footnoteflag == LyXParagraph::NO_FOOTNOTE){
+ || previous->footnoteflag == LyXParagraph::NO_FOOTNOTE) {
// The beginning or the end of a footnote environment?
if (footflag != footnoteflag) {
if ((minibuffer_char == LyXParagraph::META_INSET) &&
!InsertInsetAllowed(minibuffer_inset))
return false;
+#ifdef NEW_WAY
+ if (minibuffer_char == LyXParagraph::META_INSET)
+ InsertInset(pos, minibuffer_inset, minibuffer_font);
+ else
+ InsertChar(pos, minibuffer_char, minibuffer_font);
+#else
InsertChar(pos, minibuffer_char);
SetFont(pos, minibuffer_font);
if (minibuffer_char == LyXParagraph::META_INSET)
InsertInset(pos, minibuffer_inset);
+#endif
return true;
}
// > because last is the next unused position, and you can
// use it if you want
if (pos > size()) {
+#ifndef NEW_INSETS
if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
NextAfterFootnote()->Erase(pos - text.size() - 1);
else
+#endif
lyxerr.debug() << "ERROR (LyXParagraph::Erase): "
"position does not exist." << endl;
return;
void LyXParagraph::InsertChar(LyXParagraph::size_type pos, char c)
{
+#ifndef NEW_WAY
// > because last is the next unused position, and you can
// use it if you want
if (pos > size()) {
+#ifndef NEW_INSETS
if (next
&& next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
NextAfterFootnote()->InsertChar(pos - text.size() - 1,
c);
else
+#endif
lyxerr.debug() << "ERROR (LyXParagraph::InsertChar): "
"position does not exist." << endl;
return;
pos, matchIT());
it != insetlist.end(); ++it)
++(*it).pos;
+#else
+ LyXFont f(LyXFont::ALL_INHERIT);
+ InsertChar(pos, c, f);
+#endif
}
+#ifdef NEW_WAY
+void LyXParagraph::InsertChar(LyXParagraph::size_type pos,
+ char c, LyXFont const & font)
+{
+ // > because last is the next unused position, and you can
+ // use it if you want
+ if (pos > size()) {
+#ifndef NEW_INSETS
+ if (next
+ && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
+ NextAfterFootnote()->InsertChar(pos - text.size() - 1,
+ c);
+ else
+#endif
+ lyxerr.debug() << "ERROR (LyXParagraph::InsertChar): "
+ "position does not exist." << endl;
+ return;
+ }
+ text.insert(text.begin() + pos, c);
+ // Update the font table.
+ for (FontList::iterator it = lower_bound(fontlist.begin(),
+ fontlist.end(),
+ pos, matchFT());
+ it != fontlist.end(); ++it)
+ ++(*it).pos;
+
+ // Update the inset table.
+ for (InsetList::iterator it = lower_bound(insetlist.begin(),
+ insetlist.end(),
+ pos, matchIT());
+ it != insetlist.end(); ++it)
+ ++(*it).pos;
+
+ SetFont(pos, font);
+}
+#endif
+
+
void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
Inset * inset)
{
+#ifdef NEW_WAY
+ LyXFont f(LyXFont::ALL_INHERIT);
+ InsertInset(pos, inset, f);
+#else
// > because last is the next unused position, and you can
// use it if you want
if (pos > size()) {
+#ifndef NEW_INSETS
if (next
&& next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
NextAfterFootnote()
->InsertInset(pos - text.size() - 1, inset);
- else
+ else
+#endif
lyxerr << "ERROR (LyXParagraph::InsertInset): "
"position does not exist: " << pos << endl;
return;
if (inset_owner)
inset->setOwner(inset_owner);
}
+#endif
}
+#ifdef NEW_WAY
+void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
+ Inset * inset, LyXFont const & font)
+{
+ Assert(inset);
+
+ // > because last is the next unused position, and you can
+ // use it if you want
+ if (pos > size()) {
+#ifndef NEW_INSETS
+ if (next
+ && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
+ NextAfterFootnote()
+ ->InsertInset(pos - text.size() - 1,
+ inset, font);
+ else
+#endif
+ lyxerr << "ERROR (LyXParagraph::InsertInset): "
+ "position does not exist: " << pos << endl;
+ return;
+ }
+
+ InsertChar(pos, META_INSET, font);
+ Assert(text[pos] == META_INSET);
+
+ // Add a new entry in the inset table.
+ InsetList::iterator it = lower_bound(insetlist.begin(),
+ insetlist.end(),
+ pos, matchIT());
+ if (it != insetlist.end() && (*it).pos == pos)
+ lyxerr << "ERROR (LyXParagraph::InsertInset): "
+ "there is an inset in position: " << pos << endl;
+ else
+ insetlist.insert(it, InsetTable(pos, inset));
+ if (inset_owner)
+ inset->setOwner(inset_owner);
+}
+#endif
+
+
bool LyXParagraph::InsertInsetAllowed(Inset * inset)
{
if (inset_owner)
Inset * LyXParagraph::GetInset(LyXParagraph::size_type pos)
{
if (pos >= size()) {
+#ifndef NEW_INSETS
if (next
&& next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
return NextAfterFootnote()
->GetInset(pos - text.size() - 1);
- else {
+ else
+#endif
lyxerr << "ERROR (LyXParagraph::GetInset): "
"position does not exist: "
<< pos << endl;
- }
+
return 0;
}
// Find the inset.
lyxerr << "ERROR (LyXParagraph::GetInset): "
"Inset does not exist: " << pos << endl;
+ //::raise(SIGSTOP);
+
// text[pos] = ' '; // WHY!!! does this set the pos to ' '????
// Did this commenting out introduce a bug? So far I have not
// see any, please enlighten me. (Lgb)
Inset const * LyXParagraph::GetInset(LyXParagraph::size_type pos) const
{
if (pos >= size()) {
+#ifndef NEW_INSETS
if (next
&& next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
return NextAfterFootnote()
->GetInset(pos - text.size() - 1);
- else {
+ else
+#endif
lyxerr << "ERROR (LyXParagraph::GetInset): "
"position does not exist: "
<< pos << endl;
- }
+
return 0;
}
// Find the inset.
lyxerr << "ERROR (LyXParagraph::GetInset): "
"Inset does not exist: " << pos << endl;
+ //::raise(SIGSTOP);
//text[pos] = ' '; // WHY!!! does this set the pos to ' '????
// Did this commenting out introduce a bug? So far I have not
// see any, please enlighten me. (Lgb)
// > because last is the next unused position, and you can
// use it if you want
else if (pos > size()) {
+#ifndef NEW_INSETS
if (next
&& next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
return NextAfterFootnote()
->GetFontSettings(bparams,
pos - text.size() - 1);
- else {
+ else
+#endif
// Why is it an error to ask for the font of a
// position that does not exist? Would it be
// enough for this to be enabled on debug?
"position does not exist. "
<< pos << " (" << static_cast<int>(pos)
<< ")" << endl;
- }
} else if (pos > 0) {
return GetFontSettings(bparams, pos - 1);
} else // pos = size() = 0
if (size() > 0) {
if (!fontlist.empty())
return fontlist[0].font;
- } else if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
+ }
+
+#ifndef NEW_INSETS
+ else if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
return NextAfterFootnote()->GetFirstFontSettings();
+#endif
return LyXFont(LyXFont::ALL_INHERIT);
}
// > because last is the next unused position, and you can
// use it if you want
else if (pos > size()) {
+#ifndef NEW_INSETS
if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
return NextAfterFootnote()
->GetChar(pos - text.size() - 1);
- else {
+ else
+#endif
+ {
lyxerr << "ERROR (LyXParagraph::GetChar): "
"position does not exist."
<< pos << " (" << static_cast<int>(pos)
// Assert(false); // This triggers sometimes...
// Why?
}
+
return '\0';
- } else {
+ }
+
+#ifndef NEW_INSETS
+ else {
// We should have a footnote environment.
if (!next || next->footnoteflag == LyXParagraph::NO_FOOTNOTE) {
// Notice that LyX does request the
}
return '\0'; // to shut up gcc
}
+#endif
}
// > because last is the next unused position, and you can
// use it if you want
else if (pos > size()) {
+#ifndef NEW_INSETS
if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
return NextAfterFootnote()
->GetChar(pos - text.size() - 1);
- else {
+ else
+#endif
+ {
lyxerr << "ERROR (LyXParagraph::GetChar const): "
"position does not exist."
<< pos << " (" << static_cast<int>(pos)
Assert(false);
}
return '\0';
- } else {
+ }
+#ifndef NEW_INSETS
+ else {
// We should have a footnote environment.
if (!next || next->footnoteflag == LyXParagraph::NO_FOOTNOTE) {
// Notice that LyX does request the
}
return '\0'; // to shut up gcc
}
+#endif
}
LyXParagraph::size_type LyXParagraph::Last() const
{
+#ifndef NEW_INSETS
if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
return text.size() + NextAfterFootnote()->Last() + 1;
// the 1 is the symbol
// for the footnote
else
+#endif
return text.size();
}
// > because last is the next unused position, and you can
// use it if you want
if (pos > size()) {
+#ifndef NEW_INSETS
if (next
&& next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
return NextAfterFootnote()
->ParFromPos(pos - text.size() - 1);
- else
+ else
+#endif
lyxerr << "ERROR (LyXParagraph::ParFromPos): "
"position does not exist." << endl;
return this;
// > because last is the next unused position, and you can
// use it if you want
if (pos > size()) {
+#ifndef NEW_INSETS
if (next
&& next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
return NextAfterFootnote()
->PositionInParFromPos(pos - text.size() - 1);
- else
+ else
+#endif
lyxerr <<
"ERROR (LyXParagraph::PositionInParFromPos): "
"position does not exist." << endl;
// > because last is the next unused position, and you can
// use it if you want
if (pos > size()) {
+#ifndef NEW_INSETS
if (next &&
next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
NextAfterFootnote()->SetFont(pos - text.size() - 1,
font);
- } else {
+ } else
+#endif
lyxerr << "ERROR (LyXParagraph::SetFont): "
"position does not exist." << endl;
- }
+
return;
}
// This function is able to hide closed footnotes.
LyXParagraph * LyXParagraph::Next()
{
+#ifndef NEW_INSETS
if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
LyXParagraph * tmp = next;
while (tmp
else
return next; // This should never happen!
} else
+#endif
return next;
}
LyXParagraph * LyXParagraph::NextAfterFootnote()
{
+#ifndef NEW_INSETS
if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
LyXParagraph * tmp = next;
while (tmp && tmp->footnoteflag != LyXParagraph::NO_FOOTNOTE)
else
return next; // This should never happen!
} else
+#endif
return next;
}
LyXParagraph const * LyXParagraph::NextAfterFootnote() const
{
+#ifndef NEW_INSETS
if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
LyXParagraph * tmp = next;
while (tmp && tmp->footnoteflag != LyXParagraph::NO_FOOTNOTE)
else
return next; // This should never happen!
} else
+#endif
return next;
}
LyXParagraph * LyXParagraph::PreviousBeforeFootnote()
{
+#ifndef NEW_INSETS
LyXParagraph * tmp;
if (previous && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
tmp = previous;
else
return previous; // This should never happen!
} else
+#endif
return previous;
}
LyXParagraph * LyXParagraph::LastPhysicalPar()
{
+#ifndef NEW_INSETS
if (footnoteflag != LyXParagraph::NO_FOOTNOTE)
return this;
tmp = tmp->NextAfterFootnote();
return tmp;
+#else
+ return this;
+#endif
}
LyXParagraph const * LyXParagraph::LastPhysicalPar() const
{
+#ifndef NEW_INSETS
if (footnoteflag != LyXParagraph::NO_FOOTNOTE)
return this;
&& tmp->next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
tmp = tmp->NextAfterFootnote();
- return tmp;
+ return tmp;
+#else
+ return this;
+#endif
}
LyXParagraph * LyXParagraph::FirstPhysicalPar()
{
+#ifndef NEW_INSETS
if (!IsDummy())
return this;
LyXParagraph * tmppar = this;
return this;
} else
return tmppar;
+#else
+ return this;
+#endif
}
LyXParagraph const * LyXParagraph::FirstPhysicalPar() const
{
+#ifndef NEW_INSETS
if (!IsDummy())
return this;
LyXParagraph const * tmppar = this;
return this;
} else
return tmppar;
+#else
+ return this;
+#endif
}
LyXParagraph * tmp = previous;
if (!tmp)
return tmp;
-
+
+#ifndef NEW_INSETS
if (tmp->previous
&& tmp->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
tmp = tmp->previous;
else
return previous;
} else
+#endif
return previous;
}
LyXParagraph * tmp = previous;
if (!tmp)
return tmp;
-
+#ifndef NEW_INSETS
if (tmp->previous
&& tmp->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
tmp = tmp->previous;
else
return previous;
} else
+#endif
return previous;
}
LyXParagraph * firstpar = FirstPhysicalPar();
LyXParagraph * tmp = new LyXParagraph(par);
-
+
+#ifndef NEW_INSETS
tmp->footnoteflag = footnoteflag;
tmp->footnotekind = footnotekind;
-
+#endif
// this is an idea for a more userfriendly layout handling, I will
// see what the users say
void LyXParagraph::MakeSameLayout(LyXParagraph const * par)
{
par = par->FirstPhysicalPar();
+#ifndef NEW_INSETS
footnoteflag = par->footnoteflag;
footnotekind = par->footnotekind;
-
+#endif
layout = par->layout;
align = par-> align;
SetLabelWidthString(par->labelwidthstring);
}
+#ifndef NEW_INSETS
LyXParagraph * LyXParagraph::FirstSelfrowPar()
{
LyXParagraph * tmppar = this;
else
return tmppar;
}
+#endif
+
int LyXParagraph::StripLeadingSpaces(LyXTextClassList::size_type tclass)
{
par = par->FirstPhysicalPar();
return (
+#ifndef NEW_INSETS
par->footnoteflag == footnoteflag &&
par->footnotekind == footnotekind &&
-
+#endif
par->layout == layout &&
par->align == align &&
}
// delete the next paragraph
- LyXParagraph *ppar = the_next->previous;
- LyXParagraph *npar = the_next->next;
+ LyXParagraph * ppar = the_next->previous;
+ LyXParagraph * npar = the_next->next;
delete the_next;
ppar->next = npar;
}
+#ifndef NEW_INSETS
void LyXParagraph::OpenFootnote(LyXParagraph::size_type pos)
{
LyXParagraph * par = ParFromPos(pos);
par = par->next;
}
}
+#endif
int LyXParagraph::GetEndLabel(BufferParams const & bparams) const
{
bool need_par = SimpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
+#ifndef NEW_INSETS
// Spit out footnotes
LyXParagraph * par = next;
if (lyxrc.rtl_support) {
par = par->next;
}
}
+#endif
// Make sure that \\par is done with the font of the last
// character if this has another size as the default.
}
-#if 0
-bool LyXParagraph::RoffContTableRows(ostream & os,
- LyXParagraph::size_type i,
- int actcell)
-{
- if (!table)
- return false;
-
- LyXFont font1(LyXFont::ALL_INHERIT);
- LyXFont font2;
- Inset * inset;
- char c;
-
- string fname2 = TmpFileName(string(), "RAT2");
- int lastpos = i;
- int cell = table->CellHasContRow(actcell);
- ++actcell;
- while(cell >= 0) {
- // first find the right position
- i = lastpos;
- for (; i < size() && actcell < cell; ++i) {
- c = GetChar(i);
- if (c == LyXParagraph::META_NEWLINE)
- ++actcell;
- }
- lastpos = i;
- c = GetChar(i);
- if ((c != ' ') && (c != LyXParagraph::META_NEWLINE))
- os << " ";
- for (; i < size()
- && (c = GetChar(i)) != LyXParagraph::META_NEWLINE;
- ++i) {
- font2 = GetFontSettings(i);
- if (font1.latex() != font2.latex()) {
- if (font2.latex() != LyXFont::OFF)
- continue;
- }
- c = GetChar(i);
- switch (c) {
- case LyXParagraph::META_INSET:
- if ((inset = GetInset(i))) {
-#ifdef HAVE_SSTREAM
- stringstream ss(ios::in | ios::out);
- inset->Ascii(buffer, ss);
- ss.seekp(0);
- ss.get(c);
- while (!ss) {
- if (c == '\\')
- os << "\\\\";
- else
- os << c;
- ss.get(c);
- }
-#else
- strstream ss;
- inset->Ascii(buffer, ss);
- ss.seekp(0);
- ss.get(c);
- while (!ss) {
- if (c == '\\')
- os << "\\\\";
- else
- os << c;
- ss.get(c);
- }
- delete [] ss.str();
-#endif
- }
- break;
- case LyXParagraph::META_NEWLINE:
- break;
- case LyXParagraph::META_HFILL:
- break;
- case '\\':
- os << "\\\\";
- break;
- default:
- if (c != '\0')
- os << c;
- else
- lyxerr.debug() << "RoffAsciiTable: "
- "NULL char in structure."
- << endl;
- break;
- }
- }
- cell = table->CellHasContRow(actcell);
- }
- return true;
-}
-#endif
-
-
LyXParagraph * LyXParagraph::TeXDeeper(Buffer const * buf,
BufferParams const & bparams,
ostream & os, TexRow & texrow,
}
+#ifndef NEW_INSETS
LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf,
BufferParams const & bparams,
ostream & os, TexRow & texrow,
return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
&& previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
}
-
+#endif
void LyXParagraph::SetPExtraType(BufferParams const & bparams,
int type, char const * width,
}
}
+#ifndef NEW_INSETS
if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE
&& footnoteflag == LyXParagraph::NO_FOOTNOTE)
s += NextAfterFootnote()->String(buffer, false);
- if (!IsDummy()) {
+ if (!IsDummy())
+#endif
+ {
if (isRightToLeftPar(bparams))
reverse(s.begin() + len,s.end());
}
#else
ostrstream ostr;
ostr << ifs.rdbuf();
+ ostr << '\0';
char * tmp = ostr.str();
if (!tmp) return 0; // empty file
string w(tmp, ostr.tellp());
} else if (IsHfillChar(c)) {
return 3; /* Because of the representation
* as vertical lines */
+#ifndef NEW_INSETS
} else if (c == LyXParagraph::META_FOOTNOTE ||
c == LyXParagraph::META_MARGIN ||
c == LyXParagraph::META_FIG ||
font.decSize();
font.decSize();
return lyxfont::width(fs, font);
+#endif
} else if (c == LyXParagraph::META_INSET) {
Inset * tmpinset = par->GetInset(pos);
if (tmpinset) {
return rtl != rtl2;
}
+
bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par,
LyXParagraph::size_type pos,
LyXFont const & font) const
LyXFont font = GetFont(bview->buffer(), row->par(), pos);
LyXFont font2 = font;
-
+#ifndef NEW_INSETS
if (c == LyXParagraph::META_FOOTNOTE
|| c == LyXParagraph::META_MARGIN
|| c == LyXParagraph::META_FIG
++vpos;
return;
- } else if (c == LyXParagraph::META_INSET) {
+ } else
+#endif
+ if (c == LyXParagraph::META_INSET) {
Inset const * tmpinset = row->par()->GetInset(pos);
if (tmpinset) {
tmpinset->draw(bview, font, offset+row->baseline(), x,
textclasslist
.TextClass(bview->buffer()->params.textclass)
.defaultfont());
-
+#ifndef NEW_INSETS
if (row->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
LyXFont font(LyXFont::ALL_SANE);
font.setSize(LyXFont::SIZE_SMALL);
x += lyxfont::width("Mwide-figM", font)
+ LYX_PAPER_MARGIN/2;
}
-
+#endif
// this is the way, LyX handles the LaTeX-Environments.
// I have had this idea very late, so it seems to be a
// later added hack and this is true
textclasslist
.TextClass(buf->params.textclass)
.defaultfont());
-
+
+#ifndef NEW_INSETS
if (row->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
x += LYX_PAPER_MARGIN / 2;
}
-
+#endif
// this is the way, LyX handles the LaTeX-Environments.
// I have had this idea very late, so it seems to be a
// later added hack and this is true
}
+#ifndef NEW_TABULAR
/* table stuff -- begin*/
int LyXText::NumberOfCell(LyXParagraph * par,
LyXParagraph::size_type pos) const
}
-#ifndef NEW_TABULAR
bool LyXText::HitInTable(BufferView * bview, Row * row, int x) const
{
float tmpx;
fill_hfill, fill_label_hfill, false);
return (x > tmpx && x < tmpx + row->par()->table->WidthOfTable());
}
-#endif
bool LyXText::MouseHitInTable(BufferView * bview, int x, long y) const
/* table stuff -- end*/
+#endif
// get the next breakpoint in a given paragraph
}
+#ifndef NEW_INSETS
void LyXText::OpenFootnote(BufferView * bview)
{
LyXParagraph * endpar,* tmppar;
SetCursor(bview, par->next, 0);
sel_cursor = cursor;
}
-
+#endif
+
+#ifndef NEW_TABULAR
/* table stuff -- begin*/
void LyXText::TableFeatures(BufferView * bview, int feature, string const & val) const
Language const * lang = cursor.par()->getParLanguage(bview->buffer()->params);
LyXFont font(LyXFont::ALL_INHERIT,lang);
for (int i = 0; i < number; ++i) {
+#ifdef NEW_WAY
+ cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE, font);
+#else
cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE);
cursor.par()->SetFont(pos, font);
+#endif
}
/* append the row into the table */
Language const * lang = cursor.par()->getParLanguage(bview->buffer()->params);
LyXFont font(LyXFont::ALL_INHERIT,lang);
for (int i = 0; i < number; ++i) {
+#ifdef NEW_WAY
+ cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE, font);
+#else
cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE);
cursor.par()->SetFont(pos, font);
+#endif
}
/* append the row into the table */
do{
if (pos && (cursor.par()->IsNewline(pos-1))){
if (cursor.par()->table->AppendCellAfterCell(cell_org, cell)) {
+#ifdef NEW_WAY
+ cursor.par()->InsertChar(pos,
+ LyXParagraph::META_NEWLINE,
+ font);
+#else
cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE);
cursor.par()->SetFont(pos, font);
+#endif
if (pos <= cursor.pos())
cursor.pos(cursor.pos() + 1);
++pos;
This saves one byte memory per table ;-) */
if (cursor.par()->table->AppendCellAfterCell(cell_org, cell)) {
LyXParagraph::size_type last = cursor.par()->Last();
+#ifdef NEW_WAY
+ cursor.par()->InsertChar(last,
+ LyXParagraph::META_NEWLINE, font);
+#else
cursor.par()->InsertChar(last, LyXParagraph::META_NEWLINE);
cursor.par()->SetFont(last, font);
+#endif
}
/* append the column into the table */
}
/* table stuff -- end*/
+#endif
// Just a macro to make some thing easier.
}
}
+
void LyXText::PrepareToPrint(BufferView * bview,
Row * row, float & x,
float & fill_separator,
fill_separator = 0;
fill_label_hfill = 0;
+#ifndef NEW_INSETS
bool is_rtl = row->par()->isRightToLeftPar(bview->buffer()->params);
if (is_rtl) {
font.setSize(LyXFont::SIZE_SMALL);
x += lyxfont::width("Mwide-figM", font);
}
- } else if (workWidth(bview) > 0)
+ } else
+#endif
+ if (workWidth(bview) > 0)
x = LeftMargin(bview, row);
else
x = 0;
}
int box_x = 0;
+#ifndef NEW_INSETS
if (row_ptr->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
LyXFont font(LyXFont::ALL_SANE);
font.setSize(LyXFont::SIZE_FOOTNOTE);
workWidth(bview) - LYX_PAPER_MARGIN,
y_offset, LColor::footnote);
}
-
+#endif
// Draw appendix lines
LyXParagraph * firstpar = row_ptr->par()->FirstPhysicalPar();
if (firstpar->appendix){
return c;
}
-
+
+#ifndef NEW_INSETS
/* turn the selection into a new environment. If there is no selection,
* create an empty environment */
void LyXText::InsertFootnoteEnvironment(BufferView * bview,
ClearSelection();
}
-
+#endif
+
// returns pointer to a specified row
Row * LyXText::GetRow(LyXParagraph * par,
}
-#if 0
-void LyXText::owner(BufferView * bv)
-{
- if (bv_owner && bv) lyxerr << "LyXText::bv_owner already set!" << endl;
- bv_owner = bv;
-}
-#endif
-
// Gets the fully instantiated font at a given position in a paragraph
// Basically the same routine as LyXParagraph::getFont() in paragraph.C.
// The difference is that this one is used for displaying, and thus we
tmpfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+#ifndef NEW_INSETS
// Cosmetic improvement: If this is an open footnote, make the font
// smaller.
if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE) {
tmpfont.decSize();
}
-
+#endif
return tmpfont;
}
layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+#ifndef NEW_INSETS
if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE) {
layoutfont.decSize();
}
-
+#endif
// Now, reduce font against full layout font
font.reduce(layoutfont);
AppendParagraph(bview, row->next());
}
}
-
+
+#ifndef NEW_INSETS
void LyXText::ToggleFootnote(BufferView * bview)
{
LyXParagraph * par = cursor.par()->ParFromPos(cursor.pos());
CloseFootnote(bview);
}
}
+#endif
void LyXText::OpenStuff(BufferView * bview)
}
+#ifndef NEW_INSETS
void LyXText::CloseFootnote(BufferView * bview)
{
LyXParagraph * tmppar;
if (cursor.row()->next())
SetHeightOfRow(bview, cursor.row()->next());
}
+#endif
/* used in setlayout */
// Asger is not sure we want to do this...
-void LyXText::MakeFontEntriesLayoutSpecific(Buffer const * buf, LyXParagraph * par)
+void LyXText::MakeFontEntriesLayoutSpecific(Buffer const * buf,
+ LyXParagraph * par)
{
LyXLayout const & layout =
}
}
+
LyXParagraph * LyXText::SetLayout(BufferView * bview,
LyXCursor & cur, LyXCursor & sstart_cur,
LyXCursor & send_cur,
}
// We end at the next paragraph with depth 0
- LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
+ LyXParagraph * endpar =
+ sel_end_cursor.par()->LastPhysicalPar()->Next();
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
}
-void LyXText::ToggleFree(BufferView * bview, LyXFont const & font, bool toggleall)
+void LyXText::ToggleFree(BufferView * bview,
+ LyXFont const & font, bool toggleall)
{
// If the mask is completely neutral, tell user
if (font == LyXFont(LyXFont::ALL_IGNORE)) {
LyXParagraph::size_type
-LyXText::BeginningOfMainBody(Buffer const * buf, LyXParagraph const * par) const
+LyXText::BeginningOfMainBody(Buffer const * buf,
+ LyXParagraph const * par) const
{
if (textclasslist.Style(buf->params.textclass,
par->GetLayout()).labeltype != LABEL_MANUAL)
}
+#ifndef NEW_INSETS
/* if there is a selection, reset every environment you can find
* in the selection, otherwise just the environment you are in */
void LyXText::MeltFootnoteEnvironment(BufferView * bview)
ClearSelection();
}
+#endif
/* the DTP switches for paragraphs. LyX will store them in the
par->itemdepth = 0;
}
+#ifndef NEW_INSETS
// if this is an open marginnote and this is the first
// entry in the marginnote and the enclosing
// environment is an enum/item then correct for the
par->enumdepth++;
par->itemdepth++;
}
-
+#endif
/* Maybe we have to increment the enumeration depth.
* BUT, enumeration in a footnote is considered in isolation from its
* surrounding paragraph so don't increment if this is the
/* Rebreak the paragraph */
RemoveParagraph(row);
AppendParagraph(bview, row);
-
+
+#ifndef NEW_INSETS
/* think about the damned open footnotes! */
while (par->Next() &&
(par->Next()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
AppendParagraph(bview, row);
}
}
+#endif
}
par = par->LastPhysicalPar()->Next();
/* insets an inset. */
-void LyXText::InsertInset(BufferView * bview, Inset *inset)
+void LyXText::InsertInset(BufferView * bview, Inset * inset)
{
if (!cursor.par()->InsertInsetAllowed(inset))
return;
SetUndo(bview->buffer(), Undo::INSERT,
cursor.par()->ParFromPos(cursor.pos())->previous,
cursor.par()->ParFromPos(cursor.pos())->next);
+#ifdef NEW_WAY
+ cursor.par()->InsertInset(cursor.pos(), inset);
+#else
cursor.par()->InsertChar(cursor.pos(), LyXParagraph::META_INSET);
cursor.par()->InsertInset(cursor.pos(), inset);
+#endif
InsertChar(bview, LyXParagraph::META_INSET); /* just to rebreak and refresh correctly.
* The character will not be inserted a
* second time */
// OK, we have a selection. This is always between sel_start_cursor
// and sel_end cursor
LyXParagraph * tmppar;
-
+
+#ifndef NEW_INSETS
// Check whether there are half footnotes in the selection
if (sel_start_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE
|| sel_end_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
tmppar = tmppar->Next();
}
}
-
+#endif
#ifndef NEW_TABULAR
/* table stuff -- begin */
if (sel_start_cursor.par()->table || sel_end_cursor.par()->table) {
// ok we have a selection. This is always between sel_start_cursor
// and sel_end cursor
LyXParagraph * tmppar;
-
+
+#ifndef NEW_INSETS
/* check wether there are half footnotes in the selection */
if (sel_start_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE
|| sel_end_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
tmppar = tmppar->Next();
}
}
-
+#endif
#ifndef NEW_TABULAR
/* table stuff -- begin */
if (sel_start_cursor.par()->table || sel_end_cursor.par()->table){
// Insert the new string
for (int i = 0; str[i]; ++i) {
+#ifdef NEW_WAY
+ sel_end_cursor.par()->InsertChar(pos, str[i], font);
+#else
sel_end_cursor.par()->InsertChar(pos, str[i]);
sel_end_cursor.par()->SetFont(pos, font);
+#endif
++pos;
}
if (str[i] == ' '
&& i + 1 < str.length() && str[i + 1] != ' '
&& pos && par->GetChar(pos - 1)!= ' ') {
+#ifdef NEW_WAY
+ par->InsertChar(pos, ' ', current_font);
+#else
par->InsertChar(pos,' ');
par->SetFont(pos, current_font);
+#endif
++pos;
#ifndef NEW_TABLAR
} else if (par->table) {
break;
} else if ((str[i] != 13) &&
((str[i] & 127) >= ' ')) {
+#ifdef NEW_WAY
+ par->InsertChar(pos, str[i],
+ current_font);
+#else
par->InsertChar(pos, str[i]);
par->SetFont(pos, current_font);
+#endif
++pos;
}
#endif
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
+#ifdef NEW_WAY
+ par->InsertInset(pos, new_inset,
+ current_font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, current_font);
par->InsertInset(pos, new_inset);
+#endif
} else {
delete new_inset;
}
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
+#ifdef NEW_WAY
+ par->InsertInset(pos, new_inset,
+ current_font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, current_font);
par->InsertInset(pos, new_inset);
+#endif
} else {
delete new_inset;
}
} else if (str[i] != 13 &&
// Ignore unprintables
(str[i] & 127) >= ' ') {
+#ifdef NEW_WAY
+ par->InsertChar(pos, str[i], current_font);
+#else
par->InsertChar(pos, str[i]);
par->SetFont(pos, current_font);
+#endif
++pos;
}
} else {
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
+#ifdef NEW_WAY
+ par->InsertInset(pos,
+ new_inset,
+ current_font);
+#else
par->InsertChar(pos, LyXParagraph::META_INSET);
par->SetFont(pos, current_font);
par->InsertInset(pos, new_inset);
+#endif
} else {
delete new_inset;
}
pos = par->PositionInParFromPos(pos);
par = tmppar;
}
+#ifndef NEW_INSETS
if (par->IsDummy() && par->previous &&
par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
while (par->previous &&
}
pos += par->size() + 1;
}
-
+#endif
cur.par(par);
cur.pos(pos);
cur.boundary(boundary);
bool setfont, bool boundary) const
{
SetCursor(bview, cursor, par, pos, boundary);
-// #warning Remove this when verified working (Jug 20000413)
-#if 0
- // correct the cursor position if impossible
- if (pos > par->Last()){
- LyXParagraph * tmppar = par->ParFromPos(pos);
- pos = par->PositionInParFromPos(pos);
- par = tmppar;
- }
- if (par->IsDummy() && par->previous &&
- par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
- while (par->previous &&
- ((par->previous->IsDummy() && par->previous->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) ||
- (par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE))) {
- par = par->previous ;
- if (par->IsDummy() &&
- par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
- pos += par->size() + 1;
- }
- if (par->previous) {
- par = par->previous;
- }
- pos += par->size() + 1;
- }
-
- cursor.par() = par;
- cursor.pos() = pos;
-
- /* get the cursor y position in text */
- long y = 0;
- Row * row = GetRow(par, pos, y);
- /* y is now the beginning of the cursor row */
- y += row->baseline();
- /* y is now the cursor baseline */
- cursor.y() = y;
-
- /* now get the cursors x position */
- float x;
- float fill_separator, fill_hfill, fill_label_hfill;
- PrepareToPrint(row, x, fill_separator, fill_hfill, fill_label_hfill);
- LyXParagraph::size_type cursor_vpos;
- LyXParagraph::size_type last = RowLastPrintable(row);
-
- if (pos > last + 1) // This shouldn't happen.
- pos = last+1;
-
- if (last < row->pos())
- cursor_vpos = 0;
- else if (pos > last ||
- (pos - 1 >= row->pos() &&
- (row->par()->IsSeparator(pos) ||
- (row->par()->table && row->par()->IsNewline(pos))
- )))
- /// Place cursor after char at (logical) position pos-1
- cursor_vpos = (bidi_level(pos-1) % 2 == 0)
- ? log2vis(pos-1) + 1 : log2vis(pos-1);
- else
- /// Place cursor before char at (logical) position pos
- cursor_vpos = (bidi_level(pos) % 2 == 0)
- ? log2vis(pos) : log2vis(pos) + 1;
-
-#ifndef NEW_TABULAR
- /* table stuff -- begin*/
- if (row->par()->table) {
- int cell = NumberOfCell(row->par(), row->pos());
- float x_old = x;
- x += row->par()->table->GetBeginningOfTextInCell(cell);
- for (LyXParagraph::size_type vpos = row->pos(); vpos < cursor_vpos; ++vpos) {
- pos = vis2log(vpos);
- if (row->par()->IsNewline(pos)) {
- x = x_old + row->par()->table->WidthOfColumn(cell);
- x_old = x;
- ++cell;
- x += row->par()->table->GetBeginningOfTextInCell(cell);
- } else {
- x += SingleWidth(row->par(), pos);
- }
- }
- } else {
- /* table stuff -- end*/
-#endif
- LyXParagraph::size_type main_body =
- BeginningOfMainBody(row->par());
- if (main_body > 0 &&
- (main_body-1 > last ||
- !row->par()->IsLineSeparator(main_body-1)))
- main_body = 0;
-
- for (LyXParagraph::size_type vpos = row->pos(); vpos < cursor_vpos; ++vpos) {
- pos = vis2log(vpos);
- if (main_body > 0 && pos == main_body-1) {
- x += fill_label_hfill +
- lyxfont::width(textclasslist
- .Style(bview->buffer()->params.textclass,
- row->par()->GetLayout())
- .labelsep,
- GetFont(row->par(), -2));
- if (row->par()->IsLineSeparator(main_body-1))
- x -= SingleWidth(row->par(), main_body-1);
- }
- if (HfillExpansion(row, pos)) {
- x += SingleWidth(row->par(), pos);
- if (pos >= main_body)
- x += fill_hfill;
- else
- x += fill_label_hfill;
- }
- else if (row->par()->IsSeparator(pos)) {
- x += SingleWidth(row->par(), pos);
- if (pos >= main_body)
- x += fill_separator;
- } else
- x += SingleWidth(row->par(), pos);
- }
-#ifndef NEW_TABULAR
- }
-#endif
- cursor.x = int(x);
-
- cursor.x_fix = cursor.x;
- cursor.row() = row;
-#endif
if (setfont)
SetCurrentFont(bview);
}
}
}
- current_font = cursor.par()->GetFontSettings(bview->buffer()->params, pos);
+ current_font =
+ cursor.par()->GetFontSettings(bview->buffer()->params, pos);
real_current_font = GetFont(bview->buffer(), cursor.par(), pos);
}