#include "insets/insetlatexaccent.h"
#include "insets/insettabular.h"
#include "insets/insethfill.h"
-#include "insets/inseterror.h"
#include "insets/insetnewline.h"
extern string bibitemWidest(Buffer const *);
+using namespace lyx::support;
+
using lyx::pos_type;
//using lyx::layout_type;
using std::endl;
tmp->setLabelWidthString(par->params().labelWidthString());
}
- bool const isempty = (par->layout()->keepempty && par->empty());
+ bool const isempty = (par->allowEmpty() && par->empty());
if (!isempty && (par->size() > pos || par->empty() || flag == 2)) {
tmp->layout(par->layout());
Paragraph::depth_type depth)
{
ParagraphList::iterator newpit = pit;
- ParagraphList::iterator beg = plist.begin();
+ ParagraphList::iterator beg = const_cast<ParagraphList&>(plist).begin();
if (newpit != beg)
--newpit;
ParagraphList const & plist)
{
if (!pit->getDepth())
- return plist.end();
+ return const_cast<ParagraphList&>(plist).end();
return depthHook(pit, plist,
Paragraph::depth_type(pit->getDepth() - 1));
}
{
ParagraphList::iterator pit = p;
Paragraph::depth_type par_depth = p->getDepth();
- while (pit != plist.end()) {
+ while (pit != const_cast<ParagraphList&>(plist).end()) {
LyXLayout_ptr const & layout = pit->layout();
int const endlabeltype = layout->endlabeltype;
if (endlabeltype != END_LABEL_NO_LABEL) {
- if (boost::next(p) == plist.end())
+ if (boost::next(p) == const_cast<ParagraphList&>(plist).end())
return endlabeltype;
Paragraph::depth_type const next_depth = boost::next(p)->getDepth();
if (par_depth == 0)
break;
pit = outerHook(pit, plist);
- if (pit != plist.end())
+ if (pit != const_cast<ParagraphList&>(plist).end())
par_depth = pit->getDepth();
}
return END_LABEL_NO_LABEL;
lyxerr[Debug::LATEX] << "TeXDeeper... " << &*pit << endl;
ParagraphList::iterator par = pit;
- while (par != paragraphs.end() &&
+ while (par != const_cast<ParagraphList&>(paragraphs).end() &&
par->params().depth() == pit->params().depth()) {
if (par->layout()->isEnvironment()) {
par = TeXEnvironment(buf, paragraphs, par,
Language const * language = pit->getParLanguage(bparams);
Language const * doc_language = bparams.language;
Language const * previous_language =
- (pit != paragraphs.begin())
+ (pit != const_cast<ParagraphList&>(paragraphs).begin())
? boost::prior(pit)->getParLanguage(bparams)
: doc_language;
if (language->babel() != previous_language->babel()) {
do {
par = TeXOnePar(buf, paragraphs, par, os, texrow, runparams);
- if (par != paragraphs.end()&& par->params().depth() > pit->params().depth()) {
+ if (par != const_cast<ParagraphList&>(paragraphs).end() && par->params().depth() > pit->params().depth()) {
if (par->layout()->isParagraph()) {
// Thinko!
par = TeXDeeper(buf, paragraphs, par, os, texrow,
runparams);
}
- } while (par != paragraphs.end()
+ } while (par != const_cast<ParagraphList&>(paragraphs).end()
&& par->layout() == pit->layout()
&& par->params().depth() == pit->params().depth()
&& par->params().leftIndent() == pit->params().leftIndent());
InsetOptArg * optArgInset(Paragraph const & par)
{
// Find the entry.
- InsetList::iterator it = par.insetlist.begin();
- InsetList::iterator end = par.insetlist.end();
+ InsetList::const_iterator it = par.insetlist.begin();
+ InsetList::const_iterator end = par.insetlist.end();
for (; it != end; ++it) {
- Inset * ins = it.getInset();
+ Inset * ins = it->inset;
if (ins->lyxCode() == Inset::OPTARG_CODE) {
return static_cast<InsetOptArg *>(ins);
}
}
if (!pit->params().spacing().isDefault()
- && (pit == paragraphs.begin() || !boost::prior(pit)->hasSameLayout(*pit))) {
+ && (pit == const_cast<ParagraphList&>(paragraphs).begin() || !boost::prior(pit)->hasSameLayout(*pit))) {
os << pit->params().spacing().writeEnvirBegin() << '\n';
texrow.newline();
}
Language const * language = pit->getParLanguage(bparams);
Language const * doc_language = bparams.language;
Language const * previous_language =
- (pit != paragraphs.begin())
+ (pit != const_cast<ParagraphList&>(paragraphs).begin())
? boost::prior(pit)->getParLanguage(bparams)
: doc_language;
if (language->babel() != previous_language->babel()
// check if we already put language command in TeXEnvironment()
&& !(style->isEnvironment()
- && (pit == paragraphs.begin() ||
+ && (pit == const_cast<ParagraphList&>(paragraphs).begin() ||
(boost::prior(pit)->layout() != pit->layout() &&
boost::prior(pit)->getDepth() <= pit->getDepth())
|| boost::prior(pit)->getDepth() < pit->getDepth())))
bool is_command = style->isCommand();
if (style->resfont.size() != font.size()
- && boost::next(pit) != paragraphs.end()
+ && boost::next(pit) != const_cast<ParagraphList&>(paragraphs).end()
&& !is_command) {
if (!need_par)
os << '{';
switch (style->latextype) {
case LATEX_ITEM_ENVIRONMENT:
case LATEX_LIST_ENVIRONMENT:
- if (boost::next(pit) != paragraphs.end()
+ if (boost::next(pit) != const_cast<ParagraphList&>(paragraphs).end()
&& (pit->params().depth() < boost::next(pit)->params().depth())) {
os << '\n';
texrow.newline();
}
break;
- case LATEX_ENVIRONMENT:
+ case LATEX_ENVIRONMENT: {
// if its the last paragraph of the current environment
// skip it otherwise fall through
- if (boost::next(pit) != paragraphs.end()
- && (boost::next(pit)->layout() != pit->layout()
- || boost::next(pit)->params().depth() != pit->params().depth()))
+ ParagraphList::iterator next = boost::next(pit);
+
+ if (next != const_cast<ParagraphList&>(paragraphs).end()
+ && (next->layout() != pit->layout()
+ || next->params().depth() != pit->params().depth()))
break;
+ }
+
// fall through possible
default:
// we don't need it for the last paragraph!!!
- if (boost::next(pit) != paragraphs.end()) {
+ if (boost::next(pit) != const_cast<ParagraphList&>(paragraphs).end()) {
os << '\n';
texrow.newline();
}
}
if (!pit->params().spacing().isDefault()
- && (boost::next(pit) == paragraphs.end()|| !boost::next(pit)->hasSameLayout(*pit))) {
+ && (boost::next(pit) == const_cast<ParagraphList&>(paragraphs).end()|| !boost::next(pit)->hasSameLayout(*pit))) {
os << pit->params().spacing().writeEnvirEnd() << '\n';
texrow.newline();
}
}
// we don't need it for the last paragraph!!!
- if (boost::next(pit) != paragraphs.end()) {
+ if (boost::next(pit) != const_cast<ParagraphList&>(paragraphs).end()) {
os << '\n';
texrow.newline();
} else {
bool was_title = false;
bool already_title = false;
LyXTextClass const & tclass = buf->params.getLyXTextClass();
- ParagraphList::iterator par = paragraphs.begin();
- ParagraphList::iterator endpar = paragraphs.end();
+ ParagraphList::iterator par = const_cast<ParagraphList&>(paragraphs).begin();
+ ParagraphList::iterator endpar = const_cast<ParagraphList&>(paragraphs).end();
// if only_body
while (par != endpar) {
lex.next();
font.setLyXColor(lex.getString());
} else if (token == "\\InsetSpace" || token == "\\SpecialChar") {
- LyXLayout_ptr const & layout = par.layout();
// Insets don't make sense in a free-spacing context! ---Kayvan
- if (layout->free_spacing || par.isFreeSpacing()) {
+ if (par.isFreeSpacing()) {
if (token == "\\InsetSpace")
par.insertChar(par.size(), ' ', font, change);
else if (lex.isOK()) {
lex.eatLine();
string const s = bformat(_("Unknown token: %1$s %2$s\n"),
token, lex.getString());
- // we can do this here this way because we're actually reading
- // the buffer and don't care about LyXText right now.
- par.insertInset(par.size(), new InsetError(s), font);
+
+ buf.parseError(ErrorItem(_("Unknown token"), s,
+ par.id(), 0, par.size()));
return 1;
}
return 0;
LyXFont tmpfont(LyXFont::ALL_INHERIT);
// Resolve against environment font information
- while (pit != plist.end() &&
+ while (pit != const_cast<ParagraphList&>(plist).end() &&
par_depth && !tmpfont.resolved()) {
pit = outerHook(pit, plist);
- if (pit != plist.end()) {
+ if (pit != const_cast<ParagraphList&>(plist).end()) {
tmpfont.realize(pit->layout()->font);
par_depth = pit->getDepth();
}