using std::upper_bound;
using std::reverse;
+using lyx::pos_type;
+using lyx::layout_type;
+
int tex_code_break_column = 72; // needs non-zero initialization. set later.
// this is a bad idea, but how can Paragraph find its buffer to get
// parameters? (JMarc)
Paragraph::Paragraph()
- : pimpl_(new Paragraph::Pimpl(this))
+ : layout(0), pimpl_(new Paragraph::Pimpl(this))
{
- for (int i = 0; i < 10; ++i) setCounter(i , 0);
+ for (int i = 0; i < 10; ++i)
+ setCounter(i, 0);
next_ = 0;
previous_ = 0;
enumdepth = 0;
itemdepth = 0;
- bibkey = 0; // ale970302
+ bibkey = 0; // ale970302
clear();
}
-// This konstruktor inserts the new paragraph in a list.
+// This constructor inserts the new paragraph in a list.
Paragraph::Paragraph(Paragraph * par)
- : pimpl_(new Paragraph::Pimpl(this))
+ : layout(0), pimpl_(new Paragraph::Pimpl(this))
{
for (int i = 0; i < 10; ++i)
setCounter(i, 0);
previous_->next_ = this;
// end
- bibkey = 0; // ale970302
-
+ bibkey = 0; // ale970302
+
clear();
}
Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
- : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
+ : layout(0), pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
{
for (int i = 0; i < 10; ++i)
- setCounter(i , 0);
+ setCounter(i, 0);
enumdepth = 0;
itemdepth = 0;
- next_ = 0;
+ next_ = 0;
previous_ = 0;
// this is because of the dummy layout of the paragraphs that
// follow footnotes
layout = lp.layout;
- // ale970302
+ // ale970302
if (lp.bibkey) {
bibkey = static_cast<InsetBibKey *>
(lp.bibkey->clone(*current_view->buffer()));
}
// copy everything behind the break-position to the new paragraph
-
insetlist = lp.insetlist;
for (InsetList::iterator it = insetlist.begin();
it != insetlist.end(); ++it)
{
it->inset = it->inset->clone(*current_view->buffer(), same_ids);
+ // tell the new inset who is the boss now
+ it->inset->parOwner(this);
}
}
delete it->inset;
}
- // ale970302
+ // ale970302
delete bibkey;
delete pimpl_;
// then the insets
LyXLayout const & layout =
- textclasslist.Style(bparams.textclass,
- getLayout());
+ textclasslist.Style(bparams.textclass, getLayout());
for (InsetList::const_iterator cit = insetlist.begin();
cit != insetlist.end(); ++cit) {
search_elem, Pimpl::matchIT());
if (it != insetlist.end() && it->pos == pos)
it->inset = 0;
+ // the inset is not in a paragraph anymore
+ minibuffer_inset->parOwner(0);
} else {
minibuffer_inset = 0;
minibuffer_char = ' ';
// Gets uninstantiated font setting at position 0
LyXFont const Paragraph::getFirstFontSettings() const
{
- if (size() > 0) {
- if (!pimpl_->fontlist.empty())
- return pimpl_->fontlist[0].font();
- }
+ if (size() > 0 && !pimpl_->fontlist.empty())
+ return pimpl_->fontlist[0].font();
return LyXFont(LyXFont::ALL_INHERIT);
}
}
-int Paragraph::stripLeadingSpaces(LyXTextClassList::size_type tclass)
+int Paragraph::stripLeadingSpaces(lyx::textclass_type tclass)
{
- if (textclasslist.Style(tclass, getLayout()).free_spacing)
+ if (textclasslist.Style(tclass, getLayout()).free_spacing ||
+ isFreeSpacing())
+ {
return 0;
+ }
int i = 0;
- while (size()
- && (isNewline(0) || isLineSeparator(0))){
+ while (size() && (isNewline(0) || isLineSeparator(0))) {
erase(0);
++i;
}
}
}
}
-
+
// Be carefull, this does not make any check at all.
// This method has wrong name, it combined this par with the next par.
{
// copy the next paragraph to this one
Paragraph * the_next = next();
-
+
// first the DTP-stuff
params().lineBottom(the_next->params().lineBottom());
params().spaceBottom(the_next->params().spaceBottom());
if (insertFromMinibuffer(pos_insert + j))
++j;
}
-
+
// delete the next paragraph
Paragraph * ppar = the_next->previous_;
Paragraph * npar = the_next->next_;
Paragraph const * par = this;
depth_type par_depth = getDepth();
while (par) {
- Paragraph::layout_type layout = par->getLayout();
+ layout_type layout = par->getLayout();
int const endlabeltype =
textclasslist.Style(bparams.textclass,
layout).endlabeltype;
Paragraph * Paragraph::depthHook(depth_type depth)
{
Paragraph * newpar = this;
-
+
do {
newpar = newpar->previous();
} while (newpar && newpar->getDepth() > depth);
-
+
if (!newpar) {
if (previous() || getDepth())
lyxerr << "ERROR (Paragraph::DepthHook): "
Paragraph const * Paragraph::depthHook(depth_type depth) const
{
Paragraph const * newpar = this;
-
+
do {
newpar = newpar->previous();
} while (newpar && newpar->getDepth() > depth);
-
+
if (!newpar) {
if (previous() || getDepth())
lyxerr << "ERROR (Paragraph::DepthHook): "
while (index < insetlist.size()) {
if (insetlist[index].inset && insetlist[index].inset->autoDelete()) {
erase(insetlist[index].pos);
- // Erase() calls to insetlist.erase(&insetlist[index])
+ // erase() calls to insetlist.erase(&insetlist[index])
// so index shouldn't be increased.
++count;
} else
// returns -1 if inset not found
-int Paragraph::getPositionOfInset(Inset * inset) const
+int Paragraph::getPositionOfInset(Inset const * inset) const
{
// Find the entry.
for (InsetList::const_iterator cit = insetlist.begin();
os << params().spaceTop().asLatexCommand(bparams);
further_blank_line = true;
}
-
+
if (params().lineTop()) {
os << "\\lyxline{\\" << getFont(bparams, 0).latexSize() << '}'
<< "\\vspace{-1\\parskip}";
switch (style.latextype) {
case LATEX_ITEM_ENVIRONMENT:
case LATEX_LIST_ENVIRONMENT:
- if (next_ && (params().depth() < next_->params().depth())) {
- os << '\n';
- texrow.newline();
- }
+ if (next_ && (params().depth() < next_->params().depth())) {
+ os << '\n';
+ texrow.newline();
+ }
break;
case LATEX_ENVIRONMENT:
// if its the last paragraph of the current environment
&& (next_->layout != layout
|| next_->params().depth() != params().depth()))
break;
+ // fall through possible
default:
// we don't need it for the last paragraph!!!
if (next_) {
os << params().spaceBottom().asLatexCommand(bparams);
further_blank_line = true;
}
-
+
if (params().pagebreakBottom()) {
os << "\\newpage";
further_blank_line = true;
if (style.isEnvironment()) {
os << "\\end{" << style.latexname() << "}\n";
+ texrow.newline();
}
lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
}
-Paragraph::pos_type Paragraph::size() const
+lyx::pos_type Paragraph::size() const
{
return pimpl_->size();
}
}
-Paragraph::layout_type Paragraph::getLayout() const
+layout_type Paragraph::getLayout() const
{
return layout;
}
{
return pimpl_->getParFromID(id);
}
+
+
+bool Paragraph::isFreeSpacing() const
+{
+ // for now we just need this, later should we need this in some
+ // other way we can always add a function to Inset::() too.
+ if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
+ return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);
+ return false;
+}