mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-30 05:00:06 +00:00
several changes and some new insets, read the Changelog
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@844 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
87b2869419
commit
ee72ce8774
75
ChangeLog
75
ChangeLog
@ -1,3 +1,78 @@
|
||||
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
|
||||
|
@ -225,6 +225,10 @@ ScopeIterator_ ScopeList::erase(Iterator pos)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
ScopeIterator_::ScopeIterator_(const ScopeIterator_ & n)
|
||||
: node_(n.node_)
|
||||
{}
|
||||
|
||||
void ScopeList::swap_elements(Iterator p1,Iterator p2)
|
||||
{
|
||||
NodeType *loc1=p1.node();
|
||||
|
@ -246,7 +246,8 @@ struct LIBSIGC_API ScopeIterator_
|
||||
return *this;
|
||||
}
|
||||
|
||||
ScopeIterator_(const ScopeIterator_ &n):node_(n.node_) {}
|
||||
ScopeIterator_(const ScopeIterator_ &n);
|
||||
//:node_(n.node_) {}
|
||||
ScopeIterator_(NodeType *n):node_(n) {}
|
||||
ScopeIterator_():node_(0) {}
|
||||
};
|
||||
|
@ -135,6 +135,13 @@ void Private_::destroy()
|
||||
#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};
|
||||
|
@ -191,13 +191,13 @@ class Private<int> : private Private_
|
||||
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(); }
|
||||
|
@ -412,8 +412,12 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1,
|
||||
+ 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;
|
||||
|
5
src/FloatList.C
Normal file
5
src/FloatList.C
Normal file
@ -0,0 +1,5 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "FloatList.h"
|
||||
|
||||
FloatList floatList;
|
81
src/FloatList.h
Normal file
81
src/FloatList.h
Normal file
@ -0,0 +1,81 @@
|
||||
// -*- 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
|
36
src/Floating.h
Normal file
36
src/Floating.h
Normal file
@ -0,0 +1,36 @@
|
||||
// -*- 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
|
@ -245,6 +245,13 @@ string LaTeXFeatures::getPackages()
|
||||
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;
|
||||
@ -298,6 +305,12 @@ string LaTeXFeatures::getMacros()
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -148,6 +148,10 @@ struct LaTeXFeatures {
|
||||
typedef std::set<Language const *> LanguageList;
|
||||
///
|
||||
LanguageList UsedLanguages;
|
||||
///
|
||||
typedef std::set<string> FloatList;
|
||||
///
|
||||
FloatList usedFloats;
|
||||
//@}
|
||||
BufferParams const & bufferParams() const;
|
||||
private:
|
||||
|
@ -218,6 +218,8 @@ void LyXAction::init()
|
||||
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",
|
||||
@ -394,6 +396,9 @@ void LyXAction::init()
|
||||
{ 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 }
|
||||
};
|
||||
|
||||
|
@ -29,6 +29,9 @@ lyx_SOURCES = \
|
||||
CutAndPaste.h \
|
||||
DepTable.C \
|
||||
DepTable.h \
|
||||
FloatList.C \
|
||||
FloatList.h \
|
||||
Floating.h \
|
||||
FontInfo.C \
|
||||
FontInfo.h \
|
||||
FontLoader.C \
|
||||
|
388
src/buffer.C
388
src/buffer.C
@ -66,6 +66,10 @@
|
||||
#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"
|
||||
@ -304,16 +308,24 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
||||
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)
|
||||
@ -348,6 +360,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& 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;
|
||||
@ -373,6 +386,53 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& 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") {
|
||||
@ -649,11 +709,6 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
||||
} 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());
|
||||
@ -761,95 +816,178 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
||||
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->InsertInset(pos, 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);
|
||||
@ -893,9 +1031,13 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -911,12 +1053,20 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
||||
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 "
|
||||
@ -927,29 +1077,45 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
||||
} 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)
|
||||
@ -960,13 +1126,21 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
||||
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
|
||||
@ -974,8 +1148,12 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
||||
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;
|
||||
@ -985,8 +1163,12 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
||||
"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;
|
||||
}
|
||||
}
|
||||
@ -1311,14 +1493,6 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
|
||||
#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;
|
||||
@ -2723,12 +2897,14 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par,
|
||||
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
|
||||
@ -3401,130 +3577,6 @@ int Buffer::runChktex()
|
||||
}
|
||||
|
||||
|
||||
#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;
|
||||
|
@ -375,11 +375,6 @@ private:
|
||||
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;
|
||||
|
||||
|
@ -255,6 +255,10 @@ enum kb_action {
|
||||
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 */
|
||||
};
|
||||
|
||||
|
@ -33,6 +33,8 @@ libinsets_la_SOURCES = \
|
||||
insetert.h \
|
||||
insetexternal.C \
|
||||
insetexternal.h \
|
||||
insetfloat.h \
|
||||
insetfloat.C \
|
||||
insetfoot.C \
|
||||
insetfoot.h \
|
||||
insetgraphics.C \
|
||||
@ -47,6 +49,8 @@ libinsets_la_SOURCES = \
|
||||
insetlabel.h \
|
||||
insetlatexaccent.C \
|
||||
insetlatexaccent.h \
|
||||
insetlist.C \
|
||||
insetlist.h \
|
||||
insetloa.C \
|
||||
insetloa.h \
|
||||
insetlof.C \
|
||||
@ -55,6 +59,8 @@ libinsets_la_SOURCES = \
|
||||
insetlot.h \
|
||||
insetmarginal.h \
|
||||
insetmarginal.C \
|
||||
insetminipage.C \
|
||||
insetminipage.h \
|
||||
insetparent.C \
|
||||
insetparent.h \
|
||||
insetquotes.C \
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "BufferView.h"
|
||||
#include "Painter.h"
|
||||
#include "support/LOstream.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using std::ostream;
|
||||
|
||||
@ -44,14 +45,11 @@ Inset * InsetCollapsable::Clone() const
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -251,7 +249,9 @@ int InsetCollapsable::getMaxTextWidth(Painter & pain,
|
||||
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);
|
||||
|
@ -101,9 +101,13 @@ private:
|
||||
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;
|
||||
};
|
||||
|
@ -37,6 +37,13 @@ InsetERT::InsetERT() : InsetCollapsable()
|
||||
}
|
||||
|
||||
|
||||
void InsetERT::Write(Buffer const * buf, ostream & os) const
|
||||
{
|
||||
os << getInsetName() << "\n";
|
||||
InsetCollapsable::Write(buf, os);
|
||||
}
|
||||
|
||||
|
||||
Inset * InsetERT::Clone() const
|
||||
{
|
||||
InsetERT * result = new InsetERT();
|
||||
|
@ -29,21 +29,23 @@ class Painter;
|
||||
*/
|
||||
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
|
||||
|
203
src/insets/insetfloat.C
Normal file
203
src/insets/insetfloat.C
Normal file
@ -0,0 +1,203 @@
|
||||
/* 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);
|
||||
}
|
||||
}
|
62
src/insets/insetfloat.h
Normal file
62
src/insets/insetfloat.h
Normal file
@ -0,0 +1,62 @@
|
||||
// -*- 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
|
@ -37,6 +37,13 @@ InsetFoot::InsetFoot() : InsetCollapsable()
|
||||
}
|
||||
|
||||
|
||||
void InsetFoot::Write(Buffer const * buf, ostream & os) const
|
||||
{
|
||||
os << getInsetName() << "\n";
|
||||
InsetCollapsable::Write(buf, os);
|
||||
}
|
||||
|
||||
|
||||
Inset * InsetFoot::Clone() const
|
||||
{
|
||||
InsetFoot * result = new InsetFoot;
|
||||
@ -55,10 +62,10 @@ char const * InsetFoot::EditMessage() const
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -27,25 +27,27 @@ class Painter;
|
||||
*/
|
||||
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
|
||||
|
111
src/insets/insetlist.C
Normal file
111
src/insets/insetlist.C
Normal file
@ -0,0 +1,111 @@
|
||||
/* 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;
|
||||
}
|
51
src/insets/insetlist.h
Normal file
51
src/insets/insetlist.h
Normal file
@ -0,0 +1,51 @@
|
||||
// -*- 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
|
@ -37,6 +37,13 @@ InsetMarginal::InsetMarginal() : InsetCollapsable()
|
||||
}
|
||||
|
||||
|
||||
void InsetMarginal::Write(Buffer const * buf, ostream & os) const
|
||||
{
|
||||
os << getInsetName() << "\n";
|
||||
InsetCollapsable::Write(buf, os);
|
||||
}
|
||||
|
||||
|
||||
Inset * InsetMarginal::Clone() const
|
||||
{
|
||||
InsetMarginal * result = new InsetMarginal;
|
||||
@ -56,10 +63,10 @@ char const * InsetMarginal::EditMessage() const
|
||||
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;
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ public:
|
||||
///
|
||||
~InsetMarginal() {}
|
||||
///
|
||||
void Write(Buffer const * buf, ostream & os) const;
|
||||
///
|
||||
Inset * Clone() const;
|
||||
///
|
||||
Inset::Code LyxCode() const { return Inset::MARGIN_CODE; }
|
||||
|
130
src/insets/insetminipage.C
Normal file
130
src/insets/insetminipage.C
Normal file
@ -0,0 +1,130 @@
|
||||
/* 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;
|
||||
}
|
51
src/insets/insetminipage.h
Normal file
51
src/insets/insetminipage.h
Normal file
@ -0,0 +1,51 @@
|
||||
// -*- 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
|
@ -56,7 +56,9 @@ using std::max;
|
||||
|
||||
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()
|
||||
{
|
||||
@ -140,7 +142,7 @@ void InsetText::WriteParagraphData(Buffer const * buf, ostream & os) const
|
||||
|
||||
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?
|
||||
@ -148,8 +150,7 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex)
|
||||
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;
|
||||
@ -206,6 +207,7 @@ int InsetText::width(Painter &, LyXFont const &) const
|
||||
return insetWidth;
|
||||
}
|
||||
|
||||
|
||||
int InsetText::textWidth(Painter & pain) const
|
||||
{
|
||||
return getMaxTextWidth(pain, this) - drawTextXOffset;
|
||||
@ -742,6 +744,58 @@ InsetText::LocalDispatch(BufferView * bv,
|
||||
}
|
||||
}
|
||||
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;
|
||||
@ -910,8 +964,12 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset)
|
||||
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);
|
||||
@ -979,11 +1037,13 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -1010,6 +1070,7 @@ void InsetText::SetParagraphData(LyXParagraph *p)
|
||||
need_update = INIT;
|
||||
}
|
||||
|
||||
|
||||
void InsetText::SetAutoBreakRows(bool flag)
|
||||
{
|
||||
if (flag != autoBreakRows) {
|
||||
@ -1018,28 +1079,33 @@ void InsetText::SetAutoBreakRows(bool flag)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -1047,31 +1113,36 @@ int InsetText::cy(BufferView * bv) const
|
||||
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);
|
||||
|
@ -195,6 +195,11 @@ private:
|
||||
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 */
|
||||
///
|
||||
|
@ -91,6 +91,10 @@ public:
|
||||
///
|
||||
MARGIN_CODE,
|
||||
///
|
||||
FLOAT_CODE,
|
||||
///
|
||||
MINIPAGE_CODE,
|
||||
///
|
||||
SPECIALCHAR_CODE,
|
||||
///
|
||||
TABULAR_CODE,
|
||||
|
112
src/layout.C
112
src/layout.C
@ -509,29 +509,6 @@ enum LabelTypeTags {
|
||||
};
|
||||
|
||||
|
||||
#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[] = {
|
||||
@ -646,15 +623,6 @@ void LyXLayout::readEndLabelType(LyXLex & lexrc)
|
||||
}
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
@ -688,17 +656,6 @@ 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[] = {
|
||||
@ -738,16 +695,6 @@ enum SpacingTags {
|
||||
};
|
||||
|
||||
|
||||
#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[] = {
|
||||
@ -842,30 +789,6 @@ enum TextClassTags {
|
||||
};
|
||||
|
||||
|
||||
#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)
|
||||
{
|
||||
@ -1064,15 +987,6 @@ 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[] = {
|
||||
@ -1118,22 +1032,6 @@ enum MaxCounterTags {
|
||||
};
|
||||
|
||||
|
||||
#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[] = {
|
||||
@ -1200,16 +1098,6 @@ enum ClassOptionsTags {
|
||||
};
|
||||
|
||||
|
||||
#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[] = {
|
||||
|
@ -2643,8 +2643,13 @@ extern "C" void TableApplyCB(FL_OBJECT *, long)
|
||||
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);
|
||||
|
||||
|
@ -56,6 +56,10 @@ using std::istringstream;
|
||||
#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"
|
||||
@ -1996,16 +2000,17 @@ string LyXFunc::Dispatch(int ac,
|
||||
|
||||
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
|
||||
@ -2015,7 +2020,7 @@ string LyXFunc::Dispatch(int ac,
|
||||
|
||||
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
|
||||
@ -2025,7 +2030,7 @@ string LyXFunc::Dispatch(int ac,
|
||||
|
||||
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
|
||||
@ -2033,6 +2038,46 @@ string LyXFunc::Dispatch(int ac,
|
||||
}
|
||||
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
|
||||
delete new_inset;
|
||||
}
|
||||
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;
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "support/block.h"
|
||||
#include "language.h"
|
||||
|
||||
#define NEW_WAY 1
|
||||
|
||||
class BufferParams;
|
||||
class LyXBuffer;
|
||||
class TexRow;
|
||||
@ -56,6 +58,7 @@ public:
|
||||
///
|
||||
MINIPAGE_ALIGN_BOTTOM
|
||||
};
|
||||
#ifndef NEW_INSETS
|
||||
///
|
||||
enum META_KIND {
|
||||
///
|
||||
@ -109,7 +112,7 @@ public:
|
||||
///
|
||||
WIDE_TAB // CFO-G, 971106
|
||||
};
|
||||
|
||||
#endif
|
||||
///
|
||||
typedef char value_type;
|
||||
///
|
||||
@ -230,7 +233,7 @@ public:
|
||||
|
||||
///
|
||||
LyXTextClass::LayoutList::size_type layout;
|
||||
|
||||
#ifndef NEW_INSETS
|
||||
/**
|
||||
\begin{itemize}
|
||||
\item no footnote, closed footnote,
|
||||
@ -242,7 +245,7 @@ public:
|
||||
|
||||
/// footnote, margin, fig, tab
|
||||
footnote_kind footnotekind;
|
||||
|
||||
#endif
|
||||
//@Man: the LyX- DTP-switches
|
||||
//@{
|
||||
///
|
||||
@ -421,8 +424,16 @@ public:
|
||||
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);
|
||||
///
|
||||
@ -502,10 +513,6 @@ public:
|
||||
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);
|
||||
///
|
||||
|
332
src/paragraph.C
332
src/paragraph.C
@ -16,6 +16,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <csignal>
|
||||
|
||||
#include "lyxparagraph.h"
|
||||
#include "support/textutils.h"
|
||||
@ -71,9 +72,10 @@ LyXParagraph::LyXParagraph()
|
||||
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
|
||||
@ -105,9 +107,10 @@ LyXParagraph::LyXParagraph(LyXParagraph * par)
|
||||
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;
|
||||
@ -133,7 +136,7 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os,
|
||||
|
||||
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) {
|
||||
@ -461,10 +464,17 @@ bool LyXParagraph::InsertFromMinibuffer(LyXParagraph::size_type pos)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -535,9 +545,11 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
|
||||
// > 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;
|
||||
@ -596,14 +608,17 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
|
||||
|
||||
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;
|
||||
@ -622,20 +637,68 @@ void LyXParagraph::InsertChar(LyXParagraph::size_type pos, char c)
|
||||
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;
|
||||
@ -659,9 +722,50 @@ void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
|
||||
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)
|
||||
@ -673,15 +777,17 @@ bool LyXParagraph::InsertInsetAllowed(Inset * inset)
|
||||
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.
|
||||
@ -693,6 +799,8 @@ Inset * LyXParagraph::GetInset(LyXParagraph::size_type pos)
|
||||
|
||||
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)
|
||||
@ -705,15 +813,17 @@ Inset * LyXParagraph::GetInset(LyXParagraph::size_type pos)
|
||||
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.
|
||||
@ -725,6 +835,7 @@ Inset const * LyXParagraph::GetInset(LyXParagraph::size_type pos) const
|
||||
|
||||
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)
|
||||
@ -749,12 +860,14 @@ LyXFont LyXParagraph::GetFontSettings(BufferParams const & bparams,
|
||||
// > 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?
|
||||
@ -764,7 +877,6 @@ LyXFont LyXParagraph::GetFontSettings(BufferParams const & bparams,
|
||||
"position does not exist. "
|
||||
<< pos << " (" << static_cast<int>(pos)
|
||||
<< ")" << endl;
|
||||
}
|
||||
} else if (pos > 0) {
|
||||
return GetFontSettings(bparams, pos - 1);
|
||||
} else // pos = size() = 0
|
||||
@ -779,8 +891,12 @@ LyXFont LyXParagraph::GetFirstFontSettings() const
|
||||
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);
|
||||
}
|
||||
|
||||
@ -877,10 +993,13 @@ char LyXParagraph::GetChar(LyXParagraph::size_type pos)
|
||||
// > 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)
|
||||
@ -888,8 +1007,12 @@ char LyXParagraph::GetChar(LyXParagraph::size_type 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
|
||||
@ -914,6 +1037,7 @@ char LyXParagraph::GetChar(LyXParagraph::size_type pos)
|
||||
}
|
||||
return '\0'; // to shut up gcc
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -927,10 +1051,13 @@ char LyXParagraph::GetChar(LyXParagraph::size_type pos) const
|
||||
// > 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)
|
||||
@ -938,7 +1065,9 @@ char LyXParagraph::GetChar(LyXParagraph::size_type pos) const
|
||||
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
|
||||
@ -963,6 +1092,7 @@ char LyXParagraph::GetChar(LyXParagraph::size_type pos) const
|
||||
}
|
||||
return '\0'; // to shut up gcc
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1015,11 +1145,13 @@ string LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -1029,11 +1161,13 @@ LyXParagraph * LyXParagraph::ParFromPos(LyXParagraph::size_type pos)
|
||||
// > 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;
|
||||
@ -1047,11 +1181,13 @@ int LyXParagraph::PositionInParFromPos(LyXParagraph::size_type pos) const
|
||||
// > 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;
|
||||
@ -1068,14 +1204,16 @@ void LyXParagraph::SetFont(LyXParagraph::size_type pos,
|
||||
// > 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;
|
||||
}
|
||||
|
||||
@ -1136,6 +1274,7 @@ void LyXParagraph::SetFont(LyXParagraph::size_type pos,
|
||||
// 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
|
||||
@ -1148,12 +1287,14 @@ LyXParagraph * LyXParagraph::Next()
|
||||
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)
|
||||
@ -1164,12 +1305,14 @@ LyXParagraph * LyXParagraph::NextAfterFootnote()
|
||||
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)
|
||||
@ -1180,12 +1323,14 @@ LyXParagraph const * LyXParagraph::NextAfterFootnote() const
|
||||
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;
|
||||
@ -1197,12 +1342,14 @@ LyXParagraph * LyXParagraph::PreviousBeforeFootnote()
|
||||
else
|
||||
return previous; // This should never happen!
|
||||
} else
|
||||
#endif
|
||||
return previous;
|
||||
}
|
||||
|
||||
|
||||
LyXParagraph * LyXParagraph::LastPhysicalPar()
|
||||
{
|
||||
#ifndef NEW_INSETS
|
||||
if (footnoteflag != LyXParagraph::NO_FOOTNOTE)
|
||||
return this;
|
||||
|
||||
@ -1212,10 +1359,14 @@ LyXParagraph * LyXParagraph::LastPhysicalPar()
|
||||
tmp = tmp->NextAfterFootnote();
|
||||
|
||||
return tmp;
|
||||
#else
|
||||
return this;
|
||||
#endif
|
||||
}
|
||||
|
||||
LyXParagraph const * LyXParagraph::LastPhysicalPar() const
|
||||
{
|
||||
#ifndef NEW_INSETS
|
||||
if (footnoteflag != LyXParagraph::NO_FOOTNOTE)
|
||||
return this;
|
||||
|
||||
@ -1224,11 +1375,15 @@ LyXParagraph const * LyXParagraph::LastPhysicalPar() const
|
||||
&& 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;
|
||||
@ -1242,11 +1397,15 @@ LyXParagraph * LyXParagraph::FirstPhysicalPar()
|
||||
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;
|
||||
@ -1260,6 +1419,9 @@ LyXParagraph const * LyXParagraph::FirstPhysicalPar() const
|
||||
return this;
|
||||
} else
|
||||
return tmppar;
|
||||
#else
|
||||
return this;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1269,7 +1431,8 @@ LyXParagraph * LyXParagraph::Previous()
|
||||
LyXParagraph * tmp = previous;
|
||||
if (!tmp)
|
||||
return tmp;
|
||||
|
||||
|
||||
#ifndef NEW_INSETS
|
||||
if (tmp->previous
|
||||
&& tmp->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
|
||||
tmp = tmp->previous;
|
||||
@ -1282,6 +1445,7 @@ LyXParagraph * LyXParagraph::Previous()
|
||||
else
|
||||
return previous;
|
||||
} else
|
||||
#endif
|
||||
return previous;
|
||||
}
|
||||
|
||||
@ -1292,7 +1456,7 @@ LyXParagraph const * LyXParagraph::Previous() const
|
||||
LyXParagraph * tmp = previous;
|
||||
if (!tmp)
|
||||
return tmp;
|
||||
|
||||
#ifndef NEW_INSETS
|
||||
if (tmp->previous
|
||||
&& tmp->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
|
||||
tmp = tmp->previous;
|
||||
@ -1305,6 +1469,7 @@ LyXParagraph const * LyXParagraph::Previous() const
|
||||
else
|
||||
return previous;
|
||||
} else
|
||||
#endif
|
||||
return previous;
|
||||
}
|
||||
|
||||
@ -1319,10 +1484,11 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams,
|
||||
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
|
||||
|
||||
@ -1387,9 +1553,10 @@ void LyXParagraph::BreakParagraph(BufferParams const & bparams,
|
||||
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);
|
||||
@ -1416,6 +1583,7 @@ void LyXParagraph::MakeSameLayout(LyXParagraph const * par)
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_INSETS
|
||||
LyXParagraph * LyXParagraph::FirstSelfrowPar()
|
||||
{
|
||||
LyXParagraph * tmppar = this;
|
||||
@ -1431,6 +1599,8 @@ LyXParagraph * LyXParagraph::FirstSelfrowPar()
|
||||
else
|
||||
return tmppar;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int LyXParagraph::StripLeadingSpaces(LyXTextClassList::size_type tclass)
|
||||
{
|
||||
@ -1491,9 +1661,10 @@ bool LyXParagraph::HasSameLayout(LyXParagraph const * par) const
|
||||
par = par->FirstPhysicalPar();
|
||||
|
||||
return (
|
||||
#ifndef NEW_INSETS
|
||||
par->footnoteflag == footnoteflag &&
|
||||
par->footnotekind == footnotekind &&
|
||||
|
||||
#endif
|
||||
par->layout == layout &&
|
||||
|
||||
par->align == align &&
|
||||
@ -1583,13 +1754,14 @@ void LyXParagraph::PasteParagraph(BufferParams const & bparams)
|
||||
}
|
||||
|
||||
// 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);
|
||||
@ -1610,6 +1782,7 @@ void LyXParagraph::CloseFootnote(LyXParagraph::size_type pos)
|
||||
par = par->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int LyXParagraph::GetEndLabel(BufferParams const & bparams) const
|
||||
{
|
||||
@ -2024,6 +2197,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
|
||||
|
||||
bool need_par = SimpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
|
||||
|
||||
#ifndef NEW_INSETS
|
||||
// Spit out footnotes
|
||||
LyXParagraph * par = next;
|
||||
if (lyxrc.rtl_support) {
|
||||
@ -2070,6 +2244,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf,
|
||||
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.
|
||||
@ -3376,99 +3551,6 @@ void LyXParagraph::SimpleTeXSpecialChars(Buffer const * buf,
|
||||
}
|
||||
|
||||
|
||||
#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,
|
||||
@ -3790,6 +3872,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf,
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_INSETS
|
||||
LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf,
|
||||
BufferParams const & bparams,
|
||||
ostream & os, TexRow & texrow,
|
||||
@ -4070,7 +4153,7 @@ bool LyXParagraph::IsDummy() const
|
||||
return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
|
||||
&& previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void LyXParagraph::SetPExtraType(BufferParams const & bparams,
|
||||
int type, char const * width,
|
||||
@ -4310,11 +4393,14 @@ string LyXParagraph::String(Buffer const * buffer, bool label)
|
||||
}
|
||||
}
|
||||
|
||||
#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());
|
||||
}
|
||||
|
@ -126,6 +126,7 @@ unsigned long lyx::sum(char const * file)
|
||||
#else
|
||||
ostrstream ostr;
|
||||
ostr << ifs.rdbuf();
|
||||
ostr << '\0';
|
||||
char * tmp = ostr.str();
|
||||
if (!tmp) return 0; // empty file
|
||||
string w(tmp, ostr.tellp());
|
||||
|
62
src/text.C
62
src/text.C
@ -207,6 +207,7 @@ int LyXText::SingleWidth(BufferView * bview, LyXParagraph * par,
|
||||
} 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 ||
|
||||
@ -241,6 +242,7 @@ int LyXText::SingleWidth(BufferView * bview, LyXParagraph * par,
|
||||
font.decSize();
|
||||
font.decSize();
|
||||
return lyxfont::width(fs, font);
|
||||
#endif
|
||||
} else if (c == LyXParagraph::META_INSET) {
|
||||
Inset * tmpinset = par->GetInset(pos);
|
||||
if (tmpinset) {
|
||||
@ -420,6 +422,7 @@ bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par,
|
||||
return rtl != rtl2;
|
||||
}
|
||||
|
||||
|
||||
bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par,
|
||||
LyXParagraph::size_type pos,
|
||||
LyXFont const & font) const
|
||||
@ -508,7 +511,7 @@ void LyXText::draw(BufferView * bview, Row const * row,
|
||||
|
||||
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
|
||||
@ -559,7 +562,9 @@ void LyXText::draw(BufferView * bview, Row const * row,
|
||||
|
||||
++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,
|
||||
@ -700,14 +705,14 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const
|
||||
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
|
||||
@ -916,11 +921,12 @@ int LyXText::RightMargin(Buffer const * buf, Row const * row) const
|
||||
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
|
||||
@ -982,6 +988,7 @@ int LyXText::LabelEnd (BufferView * bview, Row const * row) const
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_TABULAR
|
||||
/* table stuff -- begin*/
|
||||
int LyXText::NumberOfCell(LyXParagraph * par,
|
||||
LyXParagraph::size_type pos) const
|
||||
@ -1011,7 +1018,6 @@ int LyXText::WidthOfCell(BufferView * bview, LyXParagraph * par,
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_TABULAR
|
||||
bool LyXText::HitInTable(BufferView * bview, Row * row, int x) const
|
||||
{
|
||||
float tmpx;
|
||||
@ -1022,7 +1028,6 @@ bool LyXText::HitInTable(BufferView * bview, Row * row, int x) const
|
||||
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
|
||||
@ -1033,6 +1038,7 @@ bool LyXText::MouseHitInTable(BufferView * bview, int x, long y) const
|
||||
|
||||
|
||||
/* table stuff -- end*/
|
||||
#endif
|
||||
|
||||
|
||||
// get the next breakpoint in a given paragraph
|
||||
@ -1927,6 +1933,7 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout)
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_INSETS
|
||||
void LyXText::OpenFootnote(BufferView * bview)
|
||||
{
|
||||
LyXParagraph * endpar,* tmppar;
|
||||
@ -1981,8 +1988,10 @@ void LyXText::OpenFootnote(BufferView * bview)
|
||||
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
|
||||
@ -2086,8 +2095,12 @@ void LyXText::TableFeatures(BufferView * bview, int feature) 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 */
|
||||
@ -2125,8 +2138,12 @@ void LyXText::TableFeatures(BufferView * bview, int feature) 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 */
|
||||
@ -2143,8 +2160,14 @@ void LyXText::TableFeatures(BufferView * bview, int feature) const
|
||||
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;
|
||||
@ -2157,8 +2180,13 @@ void LyXText::TableFeatures(BufferView * bview, int feature) const
|
||||
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 */
|
||||
@ -2656,6 +2684,7 @@ void LyXText::BackspaceInTable(BufferView * bview)
|
||||
}
|
||||
|
||||
/* table stuff -- end*/
|
||||
#endif
|
||||
|
||||
|
||||
// Just a macro to make some thing easier.
|
||||
@ -2895,6 +2924,7 @@ void LyXText::charInserted()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LyXText::PrepareToPrint(BufferView * bview,
|
||||
Row * row, float & x,
|
||||
float & fill_separator,
|
||||
@ -2910,6 +2940,7 @@ void LyXText::PrepareToPrint(BufferView * bview,
|
||||
fill_separator = 0;
|
||||
fill_label_hfill = 0;
|
||||
|
||||
#ifndef NEW_INSETS
|
||||
bool is_rtl = row->par()->isRightToLeftPar(bview->buffer()->params);
|
||||
|
||||
if (is_rtl) {
|
||||
@ -2919,7 +2950,9 @@ void LyXText::PrepareToPrint(BufferView * bview,
|
||||
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;
|
||||
@ -3969,6 +4002,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
|
||||
}
|
||||
|
||||
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);
|
||||
@ -4086,7 +4120,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
|
||||
workWidth(bview) - LYX_PAPER_MARGIN,
|
||||
y_offset, LColor::footnote);
|
||||
}
|
||||
|
||||
#endif
|
||||
// Draw appendix lines
|
||||
LyXParagraph * firstpar = row_ptr->par()->FirstPhysicalPar();
|
||||
if (firstpar->appendix){
|
||||
@ -4800,7 +4834,8 @@ int LyXText::GetColumnNearX(BufferView * bview, Row * row, int & x,
|
||||
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,
|
||||
@ -4943,7 +4978,8 @@ void LyXText::InsertFootnoteEnvironment(BufferView * bview,
|
||||
|
||||
ClearSelection();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// returns pointer to a specified row
|
||||
Row * LyXText::GetRow(LyXParagraph * par,
|
||||
|
218
src/text2.C
218
src/text2.C
@ -162,14 +162,6 @@ LyXText::~LyXText()
|
||||
}
|
||||
|
||||
|
||||
#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
|
||||
@ -243,13 +235,14 @@ LyXFont LyXText::GetFont(Buffer const * buf, LyXParagraph * par,
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -291,11 +284,12 @@ void LyXText::SetCharFont(Buffer const * buf, LyXParagraph * par,
|
||||
|
||||
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);
|
||||
|
||||
@ -394,8 +388,9 @@ void LyXText::InsertParagraph(BufferView * bview, LyXParagraph * par,
|
||||
AppendParagraph(bview, row->next());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef NEW_INSETS
|
||||
void LyXText::ToggleFootnote(BufferView * bview)
|
||||
{
|
||||
LyXParagraph * par = cursor.par()->ParFromPos(cursor.pos());
|
||||
@ -408,6 +403,7 @@ void LyXText::ToggleFootnote(BufferView * bview)
|
||||
CloseFootnote(bview);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void LyXText::OpenStuff(BufferView * bview)
|
||||
@ -429,6 +425,7 @@ void LyXText::OpenStuff(BufferView * bview)
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_INSETS
|
||||
void LyXText::CloseFootnote(BufferView * bview)
|
||||
{
|
||||
LyXParagraph * tmppar;
|
||||
@ -498,11 +495,13 @@ void LyXText::CloseFootnote(BufferView * bview)
|
||||
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 =
|
||||
@ -522,6 +521,7 @@ void LyXText::MakeFontEntriesLayoutSpecific(Buffer const * buf, LyXParagraph * p
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LyXParagraph * LyXText::SetLayout(BufferView * bview,
|
||||
LyXCursor & cur, LyXCursor & sstart_cur,
|
||||
LyXCursor & send_cur,
|
||||
@ -701,7 +701,8 @@ void LyXText::IncDepth(BufferView * bview)
|
||||
}
|
||||
|
||||
// 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()) {
|
||||
@ -1238,7 +1239,8 @@ Row * LyXText::GetRowNearY(long & y) const
|
||||
}
|
||||
|
||||
|
||||
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)) {
|
||||
@ -1271,7 +1273,8 @@ void LyXText::ToggleFree(BufferView * bview, LyXFont const & font, bool toggleal
|
||||
|
||||
|
||||
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)
|
||||
@ -1281,6 +1284,7 @@ LyXText::BeginningOfMainBody(Buffer const * buf, LyXParagraph const * par) const
|
||||
}
|
||||
|
||||
|
||||
#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)
|
||||
@ -1375,6 +1379,7 @@ void LyXText::MeltFootnoteEnvironment(BufferView * bview)
|
||||
|
||||
ClearSelection();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* the DTP switches for paragraphs. LyX will store them in the
|
||||
@ -1618,6 +1623,7 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const
|
||||
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
|
||||
@ -1639,7 +1645,7 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const
|
||||
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
|
||||
@ -1991,7 +1997,8 @@ void LyXText::UpdateCounters(BufferView * bview, Row * row) const
|
||||
/* 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
|
||||
@ -2004,6 +2011,7 @@ void LyXText::UpdateCounters(BufferView * bview, Row * row) const
|
||||
AppendParagraph(bview, row);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
par = par->LastPhysicalPar()->Next();
|
||||
@ -2013,15 +2021,19 @@ void LyXText::UpdateCounters(BufferView * bview, Row * row) const
|
||||
|
||||
|
||||
/* 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 */
|
||||
@ -2059,7 +2071,8 @@ void LyXText::CutSelection(BufferView * bview, bool doclear)
|
||||
// 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) {
|
||||
@ -2074,7 +2087,7 @@ void LyXText::CutSelection(BufferView * bview, bool doclear)
|
||||
tmppar = tmppar->Next();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef NEW_TABULAR
|
||||
/* table stuff -- begin */
|
||||
if (sel_start_cursor.par()->table || sel_end_cursor.par()->table) {
|
||||
@ -2164,7 +2177,8 @@ void LyXText::CopySelection(BufferView * bview)
|
||||
// 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) {
|
||||
@ -2181,7 +2195,7 @@ void LyXText::CopySelection(BufferView * bview)
|
||||
tmppar = tmppar->Next();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef NEW_TABULAR
|
||||
/* table stuff -- begin */
|
||||
if (sel_start_cursor.par()->table || sel_end_cursor.par()->table){
|
||||
@ -2293,8 +2307,12 @@ void LyXText::ReplaceSelectionWithString(BufferView * bview, char const * str)
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -2378,8 +2396,12 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
|
||||
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) {
|
||||
@ -2393,8 +2415,13 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
|
||||
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
|
||||
@ -2402,9 +2429,14 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
|
||||
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;
|
||||
}
|
||||
@ -2414,9 +2446,14 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
|
||||
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;
|
||||
}
|
||||
@ -2425,8 +2462,12 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
|
||||
} 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 {
|
||||
@ -2460,9 +2501,15 @@ void LyXText::InsertStringA(BufferView * bview, string const & str)
|
||||
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;
|
||||
}
|
||||
@ -2704,6 +2751,7 @@ void LyXText::SetCursor(BufferView *bview, LyXCursor & cur, LyXParagraph * par,
|
||||
pos = par->PositionInParFromPos(pos);
|
||||
par = tmppar;
|
||||
}
|
||||
#ifndef NEW_INSETS
|
||||
if (par->IsDummy() && par->previous &&
|
||||
par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
|
||||
while (par->previous &&
|
||||
@ -2723,7 +2771,7 @@ void LyXText::SetCursor(BufferView *bview, LyXCursor & cur, LyXParagraph * par,
|
||||
}
|
||||
pos += par->size() + 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
cur.par(par);
|
||||
cur.pos(pos);
|
||||
cur.boundary(boundary);
|
||||
@ -2834,127 +2882,6 @@ void LyXText::SetCursorIntern(BufferView * bview, LyXParagraph * par,
|
||||
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);
|
||||
}
|
||||
@ -2979,7 +2906,8 @@ void LyXText::SetCurrentFont(BufferView * bview) const
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user