mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 13:04:58 +00:00
Create ParagraphParameters::read(). JMarc, please note the change to LyXLex - is this ok ?
Works for me anyhoo git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6463 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c070ede805
commit
c4bda8ac16
@ -1,3 +1,13 @@
|
||||
2003-03-12 John Levon <levon@movementarian.org>
|
||||
|
||||
* buffer.C:
|
||||
* ParagraphParameters.C: move par params input to
|
||||
a read() method
|
||||
|
||||
* lyxlex_pimpl.C: make nextToken()/next() after a pushToken()
|
||||
behave like a normal read from the stream wrt reading
|
||||
a line vs. a \\token
|
||||
|
||||
2003-03-12 John Levon <levon@movementarian.org>
|
||||
|
||||
* paragraph.C:
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "tex-strings.h"
|
||||
#include "lyxlex.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using std::ostream;
|
||||
@ -268,6 +270,86 @@ void ParagraphParameters::leftIndent(LyXLength const & li)
|
||||
|
||||
void ParagraphParameters::read(LyXLex & lex)
|
||||
{
|
||||
while (lex.isOK()) {
|
||||
lex.nextToken();
|
||||
string const token = lex.getString();
|
||||
|
||||
if (token.empty())
|
||||
continue;
|
||||
|
||||
if (token[0] != '\\') {
|
||||
lex.pushToken(token);
|
||||
break;
|
||||
}
|
||||
|
||||
if (token == "\\noindent") {
|
||||
noindent(true);
|
||||
} else if (token == "\\leftindent") {
|
||||
lex.nextToken();
|
||||
LyXLength value(lex.getString());
|
||||
leftIndent(value);
|
||||
} else if (token == "\\fill_top") {
|
||||
spaceTop(VSpace(VSpace::VFILL));
|
||||
} else if (token == "\\fill_bottom") {
|
||||
spaceBottom(VSpace(VSpace::VFILL));
|
||||
} else if (token == "\\line_top") {
|
||||
lineTop(true);
|
||||
} else if (token == "\\line_bottom") {
|
||||
lineBottom(true);
|
||||
} else if (token == "\\pagebreak_top") {
|
||||
pagebreakTop(true);
|
||||
} else if (token == "\\pagebreak_bottom") {
|
||||
pagebreakBottom(true);
|
||||
} else if (token == "\\start_of_appendix") {
|
||||
startOfAppendix(true);
|
||||
} else if (token == "\\paragraph_spacing") {
|
||||
lex.next();
|
||||
string const tmp = rtrim(lex.getString());
|
||||
if (tmp == "single") {
|
||||
spacing(Spacing(Spacing::Single));
|
||||
} else if (tmp == "onehalf") {
|
||||
spacing(Spacing(Spacing::Onehalf));
|
||||
} else if (tmp == "double") {
|
||||
spacing(Spacing(Spacing::Double));
|
||||
} else if (tmp == "other") {
|
||||
lex.next();
|
||||
spacing(Spacing(Spacing::Other,
|
||||
lex.getFloat()));
|
||||
} else {
|
||||
lex.printError("Unknown spacing token: '$$Token'");
|
||||
}
|
||||
} else if (token == "\\align") {
|
||||
int tmpret = lex.findToken(string_align);
|
||||
if (tmpret == -1)
|
||||
++tmpret;
|
||||
int const tmpret2 = int(pow(2.0, tmpret));
|
||||
align(LyXAlignment(tmpret2));
|
||||
} else if (token == "\\added_space_top") {
|
||||
lex.nextToken();
|
||||
VSpace value = VSpace(lex.getString());
|
||||
// only add the length when value > 0 or
|
||||
// with option keep
|
||||
if ((value.length().len().value() != 0) ||
|
||||
value.keep() ||
|
||||
(value.kind() != VSpace::LENGTH))
|
||||
spaceTop(value);
|
||||
} else if (token == "\\added_space_bottom") {
|
||||
lex.nextToken();
|
||||
VSpace value = VSpace(lex.getString());
|
||||
// only add the length when value > 0 or
|
||||
// with option keep
|
||||
if ((value.length().len().value() != 0) ||
|
||||
value.keep() ||
|
||||
(value.kind() != VSpace::LENGTH))
|
||||
spaceBottom(value);
|
||||
} else if (token == "\\labelwidthstring") {
|
||||
lex.eatLine();
|
||||
labelWidthString(lex.getString());
|
||||
} else {
|
||||
lex.pushToken(token);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
67
src/buffer.C
67
src/buffer.C
@ -536,7 +536,6 @@ Buffer::readToken(LyXLex & lex, ParagraphList & pars,
|
||||
} else {
|
||||
#endif
|
||||
Paragraph * par = new Paragraph();
|
||||
par->layout(params.getLyXTextClass().defaultLayout());
|
||||
if (params.tracking_changes)
|
||||
par->trackChanges();
|
||||
pos = 0;
|
||||
@ -546,6 +545,9 @@ Buffer::readToken(LyXLex & lex, ParagraphList & pars,
|
||||
if (!layout->obsoleted_by().empty())
|
||||
par->layout(params.getLyXTextClass()[layout->obsoleted_by()]);
|
||||
par->params().depth(depth);
|
||||
|
||||
par->params().read(lex);
|
||||
|
||||
// insert after
|
||||
if (pit != pars.end())
|
||||
++pit;
|
||||
@ -652,69 +654,6 @@ Buffer::readToken(LyXLex & lex, ParagraphList & pars,
|
||||
}
|
||||
else
|
||||
--depth;
|
||||
} else if (token == "\\noindent") {
|
||||
pit->params().noindent(true);
|
||||
} else if (token == "\\leftindent") {
|
||||
lex.nextToken();
|
||||
LyXLength value(lex.getString());
|
||||
pit->params().leftIndent(value);
|
||||
} else if (token == "\\fill_top") {
|
||||
pit->params().spaceTop(VSpace(VSpace::VFILL));
|
||||
} else if (token == "\\fill_bottom") {
|
||||
pit->params().spaceBottom(VSpace(VSpace::VFILL));
|
||||
} else if (token == "\\line_top") {
|
||||
pit->params().lineTop(true);
|
||||
} else if (token == "\\line_bottom") {
|
||||
pit->params().lineBottom(true);
|
||||
} else if (token == "\\pagebreak_top") {
|
||||
pit->params().pagebreakTop(true);
|
||||
} else if (token == "\\pagebreak_bottom") {
|
||||
pit->params().pagebreakBottom(true);
|
||||
} else if (token == "\\start_of_appendix") {
|
||||
pit->params().startOfAppendix(true);
|
||||
} else if (token == "\\paragraph_spacing") {
|
||||
lex.next();
|
||||
string const tmp = rtrim(lex.getString());
|
||||
if (tmp == "single") {
|
||||
pit->params().spacing(Spacing(Spacing::Single));
|
||||
} else if (tmp == "onehalf") {
|
||||
pit->params().spacing(Spacing(Spacing::Onehalf));
|
||||
} else if (tmp == "double") {
|
||||
pit->params().spacing(Spacing(Spacing::Double));
|
||||
} else if (tmp == "other") {
|
||||
lex.next();
|
||||
pit->params().spacing(Spacing(Spacing::Other,
|
||||
lex.getFloat()));
|
||||
} else {
|
||||
lex.printError("Unknown spacing token: '$$Token'");
|
||||
}
|
||||
} else if (token == "\\align") {
|
||||
int tmpret = lex.findToken(string_align);
|
||||
if (tmpret == -1)
|
||||
++tmpret;
|
||||
int const tmpret2 = int(pow(2.0, tmpret));
|
||||
pit->params().align(LyXAlignment(tmpret2));
|
||||
} else if (token == "\\added_space_top") {
|
||||
lex.nextToken();
|
||||
VSpace value = VSpace(lex.getString());
|
||||
// only add the length when value > 0 or
|
||||
// with option keep
|
||||
if ((value.length().len().value() != 0) ||
|
||||
value.keep() ||
|
||||
(value.kind() != VSpace::LENGTH))
|
||||
pit->params().spaceTop(value);
|
||||
} else if (token == "\\added_space_bottom") {
|
||||
lex.nextToken();
|
||||
VSpace value = VSpace(lex.getString());
|
||||
// only add the length when value > 0 or
|
||||
// with option keep
|
||||
if ((value.length().len().value() != 0) ||
|
||||
value.keep() ||
|
||||
(value.kind() != VSpace::LENGTH))
|
||||
pit->params().spaceBottom(value);
|
||||
} else if (token == "\\labelwidthstring") {
|
||||
lex.eatLine();
|
||||
pit->params().labelWidthString(lex.getString());
|
||||
// do not delete this token, it is still needed!
|
||||
} else if (token == "\\newline") {
|
||||
pit->insertChar(pos, Paragraph::META_NEWLINE, font, current_change);
|
||||
|
@ -144,7 +144,7 @@ bool LyXLex::Pimpl::next(bool esc /* = false */)
|
||||
// There can have been a whole line pushed so
|
||||
// we extract the first word and leaves the rest
|
||||
// in pushTok. (Lgb)
|
||||
if (pushTok.find(' ') != string::npos) {
|
||||
if (pushTok.find(' ') != string::npos && pushTok[0] == '\\') {
|
||||
string tmp;
|
||||
pushTok = split(pushTok, tmp, ' ');
|
||||
tmp.copy(buff, string::npos);
|
||||
@ -434,7 +434,7 @@ bool LyXLex::Pimpl::nextToken()
|
||||
// There can have been a whole line pushed so
|
||||
// we extract the first word and leaves the rest
|
||||
// in pushTok. (Lgb)
|
||||
if (pushTok.find(' ') != string::npos) {
|
||||
if (pushTok.find(' ') != string::npos && pushTok[0] == '\\') {
|
||||
string tmp;
|
||||
pushTok = split(pushTok, tmp, ' ');
|
||||
tmp.copy(buff, string::npos);
|
||||
|
Loading…
Reference in New Issue
Block a user