#include "Paragraph.h"
-#include "BaseClassList.h"
+#include "LayoutFile.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "Changes.h"
#include "insets/InsetBibitem.h"
#include "insets/InsetLabel.h"
+#include "support/assert.h"
#include "support/convert.h"
#include "support/debug.h"
#include "support/gettext.h"
///
InsetList insetlist_;
- // This little bit of indirection is needed so that we can protect
- // the layout as const but still be able to change layout_.
- ///
- Layout const & layout() const { return *layout_; }
- ///
- void setLayout(Layout const & layout) { layout_ = &layout; }
-
/// end of label
pos_type begin_of_body_;
typedef std::set<docstring> Words;
///
Words words_;
-private:
///
Layout const * layout_;
};
bool Paragraph::isChanged(pos_type start, pos_type end) const
{
- BOOST_ASSERT(start >= 0 && start <= size());
- BOOST_ASSERT(end > start && end <= size() + 1);
+ LASSERT(start >= 0 && start <= size(), /**/);
+ LASSERT(end > start && end <= size() + 1, /**/);
return d->changes_.isChanged(start, end);
}
void Paragraph::setChange(pos_type pos, Change const & change)
{
- BOOST_ASSERT(pos >= 0 && pos <= size());
+ LASSERT(pos >= 0 && pos <= size(), /**/);
d->changes_.set(change, pos);
// see comment in setChange(Change const &) above
Change const & Paragraph::lookupChange(pos_type pos) const
{
- BOOST_ASSERT(pos >= 0 && pos <= size());
+ LASSERT(pos >= 0 && pos <= size(), /**/);
return d->changes_.lookup(pos);
}
void Paragraph::acceptChanges(BufferParams const & bparams, pos_type start,
pos_type end)
{
- BOOST_ASSERT(start >= 0 && start <= size());
- BOOST_ASSERT(end > start && end <= size() + 1);
+ LASSERT(start >= 0 && start <= size(), /**/);
+ LASSERT(end > start && end <= size() + 1, /**/);
for (pos_type pos = start; pos < end; ++pos) {
switch (lookupChange(pos).type) {
void Paragraph::rejectChanges(BufferParams const & bparams,
pos_type start, pos_type end)
{
- BOOST_ASSERT(start >= 0 && start <= size());
- BOOST_ASSERT(end > start && end <= size() + 1);
+ LASSERT(start >= 0 && start <= size(), /**/);
+ LASSERT(end > start && end <= size() + 1, /**/);
for (pos_type pos = start; pos < end; ++pos) {
switch (lookupChange(pos).type) {
void Paragraph::Private::insertChar(pos_type pos, char_type c,
Change const & change)
{
- BOOST_ASSERT(pos >= 0 && pos <= int(text_.size()));
+ LASSERT(pos >= 0 && pos <= int(text_.size()), /**/);
// track change
changes_.insert(change, pos);
void Paragraph::insertInset(pos_type pos, Inset * inset,
Change const & change)
{
- BOOST_ASSERT(inset);
- BOOST_ASSERT(pos >= 0 && pos <= size());
+ LASSERT(inset, /**/);
+ LASSERT(pos >= 0 && pos <= size(), /**/);
d->insertChar(pos, META_INSET, change);
- BOOST_ASSERT(d->text_[pos] == META_INSET);
+ LASSERT(d->text_[pos] == META_INSET, /**/);
// Add a new entry in the insetlist_.
d->insetlist_.insert(inset, pos);
bool Paragraph::eraseChar(pos_type pos, bool trackChanges)
{
- BOOST_ASSERT(pos >= 0 && pos <= size());
+ LASSERT(pos >= 0 && pos <= size(), /**/);
// keep the logic here in sync with the logic of isMergedOnEndOfParDeletion()
int Paragraph::eraseChars(pos_type start, pos_type end, bool trackChanges)
{
- BOOST_ASSERT(start >= 0 && start <= size());
- BOOST_ASSERT(end >= start && end <= size() + 1);
+ LASSERT(start >= 0 && start <= size(), /**/);
+ LASSERT(end >= start && end <= size() + 1, /**/);
pos_type i = start;
for (pos_type count = end - start; count; --count) {
unsigned int & column)
{
Inset * inset = owner_->getInset(i);
- BOOST_ASSERT(inset);
+ LASSERT(inset, /**/);
if (style.pass_thru) {
inset->plaintext(os, runparams);
}
// First write the layout
- os << "\n\\begin_layout " << to_utf8(d->layout().name()) << '\n';
+ os << "\n\\begin_layout " << to_utf8(d->layout_->name()) << '\n';
d->params_.write(os);
if (c != '\0')
os << to_utf8(docstring(1, c));
else
- lyxerr << "ERROR (Paragraph::writeFile):"
- " NULL char in structure." << endl;
+ LYXERR0("NUL char in structure.");
++column;
break;
}
void Paragraph::validate(LaTeXFeatures & features) const
{
- d->validate(features, d->layout());
+ d->validate(features, *d->layout_);
}
pos_type pos) const
{
if (pos > size()) {
- lyxerr << " pos: " << pos << " size: " << size() << endl;
- BOOST_ASSERT(pos <= size());
+ LYXERR0("pos: " << pos << " size: " << size());
+ LASSERT(pos <= size(), /**/);
}
FontList::const_iterator cit = d->fontlist_.fontIterator(pos);
FontSpan Paragraph::fontSpan(pos_type pos) const
{
- BOOST_ASSERT(pos <= size());
+ LASSERT(pos <= size(), /**/);
pos_type start = 0;
FontList::const_iterator cit = d->fontlist_.begin();
}
// This should not happen, but if so, we take no chances.
- //lyxerr << "Paragraph::getEndPosOfFontSpan: This should not happen!"
- // << endl;
+ // LYXERR0("Paragraph::getEndPosOfFontSpan: This should not happen!");
return FontSpan(pos, pos);
}
Font const Paragraph::getFont(BufferParams const & bparams, pos_type pos,
Font const & outerfont) const
{
- BOOST_ASSERT(pos >= 0);
+ LASSERT(pos >= 0, /**/);
Font font = getFontSettings(bparams, pos);
pos_type const body_pos = beginOfBody();
if (pos < body_pos)
- font.fontInfo().realize(d->layout().labelfont);
+ font.fontInfo().realize(d->layout_->labelfont);
else
- font.fontInfo().realize(d->layout().font);
+ font.fontInfo().realize(d->layout_->font);
font.fontInfo().realize(outerfont.fontInfo());
font.fontInfo().realize(bparams.getFont().fontInfo());
Font const Paragraph::getLabelFont
(BufferParams const & bparams, Font const & outerfont) const
{
- FontInfo tmpfont = d->layout().labelfont;
+ FontInfo tmpfont = d->layout_->labelfont;
tmpfont.realize(outerfont.fontInfo());
tmpfont.realize(bparams.getFont().fontInfo());
return Font(tmpfont, getParLanguage(bparams));
Font const Paragraph::getLayoutFont
(BufferParams const & bparams, Font const & outerfont) const
{
- FontInfo tmpfont = d->layout().font;
+ FontInfo tmpfont = d->layout_->font;
tmpfont.realize(outerfont.fontInfo());
tmpfont.realize(bparams.getFont().fontInfo());
return Font(tmpfont, getParLanguage(bparams));
}
-char_type
-Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
+char_type Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
{
char_type c = d->text_[pos];
if (!lyxrc.rtl_support)
}
if (uc != c && getFontSettings(bparams, pos).isRightToLeft())
return uc;
- else
- return c;
+ return c;
}
void Paragraph::setFont(pos_type pos, Font const & font)
{
- BOOST_ASSERT(pos <= size());
+ LASSERT(pos <= size(), /**/);
// First, reduce font against layout/label font
// Update: The setCharFont() routine in text2.cpp already
void Paragraph::makeSameLayout(Paragraph const & par)
{
- d->setLayout(par.d->layout());
+ d->layout_ = par.d->layout_;
d->params_ = par.d->params_;
}
bool Paragraph::hasSameLayout(Paragraph const & par) const
{
- return par.d->layout() == d->layout()
+ return par.d->layout_ == d->layout_
&& d->params_.sameLayout(par.d->params_);
}
depth_type Paragraph::getMaxDepthAfter() const
{
- if (d->layout().isEnvironment())
+ if (d->layout_->isEnvironment())
return d->params_.depth() + 1;
else
return d->params_.depth();
char Paragraph::getAlign() const
{
if (d->params_.align() == LYX_ALIGN_LAYOUT)
- return d->layout().align;
+ return d->layout_->align;
else
return d->params_.align();
}
// the next two functions are for the manual labels
docstring const Paragraph::getLabelWidthString() const
{
- if (d->layout().margintype == MARGIN_MANUAL)
+ if (d->layout_->margintype == MARGIN_MANUAL)
return d->params_.labelWidthString();
else
return _("Senseless with this layout!");
void Paragraph::applyLayout(Layout const & new_layout)
{
- d->setLayout(new_layout);
+ d->layout_ = &new_layout;
LyXAlignment const oldAlign = d->params_.align();
- if (!(oldAlign & d->layout().alignpossible)) {
+ if (!(oldAlign & d->layout_->alignpossible)) {
frontend::Alert::warning(_("Alignment not permitted"),
_("The new layout does not permit the alignment previously used.\nSetting to default."));
d->params_.align(LYX_ALIGN_LAYOUT);
void Paragraph::setBeginOfBody()
{
- if (d->layout().labeltype != LABEL_MANUAL) {
+ if (d->layout_->labeltype != LABEL_MANUAL) {
d->begin_of_body_ = 0;
return;
}
bool Paragraph::forceEmptyLayout() const
{
- return inInset() && inInset()->forceEmptyLayout();
+ Inset const * const inset = inInset();
+ if (!inset)
+ return true;
+ return inset->forceEmptyLayout();
}
bool Paragraph::allowParagraphCustomization() const
{
- return inInset() && inInset()->allowParagraphCustomization(0);
+ Inset const * const inset = inInset();
+ if (!inset)
+ return true;
+ return inset->allowParagraphCustomization();
}
bool Paragraph::useEmptyLayout() const
{
- return inInset() && inInset()->useEmptyLayout();
+ Inset const * const inset = inInset();
+ if (!inset)
+ return false;
+ return inset->useEmptyLayout();
}
bool return_value = false;
- Layout style;
-
bool asdefault = forceEmptyLayout();
- if (asdefault)
- style = bparams.documentClass().emptyLayout();
- else
- style = d->layout();
+ Layout const & style = asdefault ?
+ bparams.documentClass().emptyLayout() :
+ *d->layout_;
// Current base font for all inherited font changes, without any
// change caused by an individual character, except for the language:
{
bool emph_flag = false;
- Layout const & style = d->layout();
+ Layout const & style = *d->layout_;
FontInfo font_old =
style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
bool Paragraph::isHfill(pos_type pos) const
{
Inset const * inset = getInset(pos);
- return inset && inset->lyxCode() == HFILL_CODE;
+ return inset && (inset->lyxCode() == SPACE_CODE &&
+ inset->isStretchableSpace());
}
Layout const & Paragraph::layout() const
{
- return d->layout();
+ return *d->layout_;
}
void Paragraph::setLayout(Layout const & layout)
{
- d->setLayout(layout);
+ d->layout_ = &layout;
}
bool Paragraph::isFreeSpacing() const
{
- if (d->layout().free_spacing)
+ if (d->layout_->free_spacing)
return true;
return d->inset_owner_ && d->inset_owner_->isFreeSpacing();
}
bool Paragraph::allowEmpty() const
{
- if (d->layout().keepempty)
+ if (d->layout_->keepempty)
return true;
return d->inset_owner_ && d->inset_owner_->allowEmpty();
}
char_type Paragraph::transformChar(char_type c, pos_type pos) const
{
- if (!Encodings::is_arabic(c))
+ if (!Encodings::isArabicChar(c))
return c;
char_type prev_char = ' ';
for (pos_type i = pos - 1; i >= 0; --i) {
char_type const par_char = d->text_[i];
- if (!Encodings::isComposeChar_arabic(par_char)) {
+ if (!Encodings::isArabicComposeChar(par_char)) {
prev_char = par_char;
break;
}
for (pos_type i = pos + 1, end = size(); i < end; ++i) {
char_type const par_char = d->text_[i];
- if (!Encodings::isComposeChar_arabic(par_char)) {
+ if (!Encodings::isArabicComposeChar(par_char)) {
next_char = par_char;
break;
}
}
- if (Encodings::is_arabic(next_char)) {
- if (Encodings::is_arabic(prev_char) &&
- !Encodings::is_arabic_special(prev_char))
+ if (Encodings::isArabicChar(next_char)) {
+ if (Encodings::isArabicChar(prev_char) &&
+ !Encodings::isArabicSpecialChar(prev_char))
return Encodings::transformChar(c, Encodings::FORM_MEDIAL);
else
return Encodings::transformChar(c, Encodings::FORM_INITIAL);
} else {
- if (Encodings::is_arabic(prev_char) &&
- !Encodings::is_arabic_special(prev_char))
+ if (Encodings::isArabicChar(prev_char) &&
+ !Encodings::isArabicSpecialChar(prev_char))
return Encodings::transformChar(c, Encodings::FORM_FINAL);
else
return Encodings::transformChar(c, Encodings::FORM_ISOLATED);
// up this bibitem issue for 1.6. See also bug 2743.
// Add bibitem insets if necessary
- if (d->layout().labeltype != LABEL_BIBLIO)
+ if (d->layout_->labeltype != LABEL_BIBLIO)
return 0;
bool hasbibitem = !d->insetlist_.empty()
void Paragraph::updateWords(CursorSlice const & sl)
{
- BOOST_ASSERT(&sl.paragraph() == this);
+ LASSERT(&sl.paragraph() == this, /**/);
deregisterWords();
collectWords(sl);
registerWords();