}
-Paragraph::Paragraph(Paragraph const & lp)
- : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this))
+Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
+ : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
{
- for (int i = 0; i < 10; ++i) setCounter(i , 0);
+ for (int i = 0; i < 10; ++i)
+ setCounter(i , 0);
enumdepth = 0;
itemdepth = 0;
next_ = 0;
previous_ = 0;
- clear();
-
- makeSameLayout(&lp);
// this is because of the dummy layout of the paragraphs that
// follow footnotes
layout = lp.layout;
// ale970302
- if (lp.bibkey)
+ if (lp.bibkey) {
bibkey = static_cast<InsetBibKey *>
- (lp.bibkey->Clone(*current_view->buffer()));
- else
+ (lp.bibkey->clone(*current_view->buffer()));
+ } else {
bibkey = 0;
+ }
// 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());
+ {
+ it->inset = it->inset->clone(*current_view->buffer(), same_ids);
+ }
}
for (InsetList::iterator it = insetlist.begin();
it != insetlist.end(); ++it) {
- delete (*it).inset;
+ delete it->inset;
}
// ale970302
// bibitem ale970302
if (bibkey)
- bibkey->Write(buf, os);
+ bibkey->write(buf, os);
LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
{
Inset const * inset = getInset(i);
if (inset)
- if (inset->DirectWrite()) {
+ if (inset->directWrite()) {
// international char, let it write
// code directly so it's shorter in
// the file
- inset->Write(buf, os);
+ inset->write(buf, os);
} else {
os << "\n\\begin_inset ";
- inset->Write(buf, os);
+ inset->write(buf, os);
os << "\n\\end_inset \n\n";
column = 0;
}
for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
cit != pimpl_->fontlist.end(); ++cit) {
- if ((*cit).font().noun() == LyXFont::ON) {
+ if (cit->font().noun() == LyXFont::ON) {
lyxerr[Debug::LATEX] << "font.noun: "
- << (*cit).font().noun()
+ << cit->font().noun()
<< endl;
features.noun = true;
lyxerr[Debug::LATEX] << "Noun enabled. Font: "
- << (*cit).font().stateText(0)
+ << cit->font().stateText(0)
<< endl;
}
- switch ((*cit).font().color()) {
+ switch (cit->font().color()) {
case LColor::none:
case LColor::inherit:
case LColor::ignore:
default:
features.color = true;
lyxerr[Debug::LATEX] << "Color enabled. Font: "
- << (*cit).font().stateText(0)
+ << cit->font().stateText(0)
<< endl;
}
- Language const * language = (*cit).font().language();
+ Language const * language = cit->font().language();
if (language->babel() != doc_language->babel()) {
features.UsedLanguages.insert(language);
lyxerr[Debug::LATEX] << "Found language "
// then the insets
for (InsetList::const_iterator cit = insetlist.begin();
cit != insetlist.end(); ++cit) {
- if ((*cit).inset)
- (*cit).inset->Validate(features);
+ if (cit->inset)
+ cit->inset->validate(features);
}
}
minibuffer_inset = 0;
if (minibuffer_char == Paragraph::META_INSET) {
if (getInset(pos)) {
- minibuffer_inset = getInset(pos)->Clone(buffer);
+ minibuffer_inset = getInset(pos)->clone(buffer);
} else {
minibuffer_inset = 0;
minibuffer_char = ' ';
lower_bound(insetlist.begin(),
insetlist.end(),
search_elem, Pimpl::matchIT());
- if (it != insetlist.end() && (*it).pos == pos)
- (*it).inset = 0;
+ if (it != insetlist.end() && it->pos == pos)
+ it->inset = 0;
} else {
minibuffer_inset = 0;
minibuffer_char = ' ';
bool Paragraph::insertFromMinibuffer(Paragraph::size_type pos)
{
if ((minibuffer_char == Paragraph::META_INSET) &&
- !insertInsetAllowed(minibuffer_inset))
+ !insetAllowed(minibuffer_inset->lyxCode()))
return false;
if (minibuffer_char == Paragraph::META_INSET)
insertInset(pos, minibuffer_inset, minibuffer_font);
}
-bool Paragraph::insertInsetAllowed(Inset * inset)
+bool Paragraph::insetAllowed(Inset::Code code)
{
//lyxerr << "Paragraph::InsertInsetAllowed" << endl;
if (pimpl_->inset_owner)
- return pimpl_->inset_owner->InsertInsetAllowed(inset);
+ return pimpl_->inset_owner->insetAllowed(code);
return true;
}
InsetList::iterator it = lower_bound(insetlist.begin(),
insetlist.end(),
search_inset, Pimpl::matchIT());
- if (it != insetlist.end() && (*it).pos == pos)
- return (*it).inset;
+ if (it != insetlist.end() && it->pos == pos)
+ return it->inset;
lyxerr << "ERROR (Paragraph::GetInset): "
"Inset does not exist: " << pos << endl;
InsetList::const_iterator cit = lower_bound(insetlist.begin(),
insetlist.end(),
search_inset, Pimpl::matchIT());
- if (cit != insetlist.end() && (*cit).pos == pos)
- return (*cit).inset;
+ if (cit != insetlist.end() && cit->pos == pos)
+ return cit->inset;
lyxerr << "ERROR (Paragraph::GetInset): "
"Inset does not exist: " << pos << endl;
pimpl_->fontlist.end(),
search_font, Pimpl::matchFT());
if (cit != pimpl_->fontlist.end())
- return (*cit).font();
+ return cit->font();
if (pos == size() && size())
return getFontSettings(bparams, pos - 1);
pimpl_->fontlist.end(),
start_search, Pimpl::matchFT());
cit != end_it; ++cit) {
- LyXFont::FONT_SIZE size = (*cit).font().size();
+ LyXFont::FONT_SIZE size = cit->font().size();
if (size > maxsize && size <= LyXFont::SIZE_HUGER)
maxsize = size;
}
// create a new paragraph
Paragraph * tmp = new Paragraph(this);
// remember to set the inset_owner
- tmp->setInsetOwner(InInset());
+ tmp->setInsetOwner(inInset());
// this is an idea for a more userfriendly layout handling, I will
// see what the users say
void Paragraph::makeSameLayout(Paragraph const * par)
{
layout = par->layout;
- params().makeSame(par->params());
-
- // This can be changed after NEW_INSETS is in effect. (Lgb)
- setLabelWidthString(par->params().labelWidthString());
+ // move to pimpl?
+ params() = par->params();
}
int count = 0;
InsetList::size_type index = 0;
while (index < insetlist.size()) {
- if (insetlist[index].inset && insetlist[index].inset->AutoDelete()) {
+ if (insetlist[index].inset && insetlist[index].inset->autoDelete()) {
erase(insetlist[index].pos);
// Erase() calls to insetlist.erase(&insetlist[index])
// so index shouldn't be increased.
// Find the entry.
for (InsetList::const_iterator cit = insetlist.begin();
cit != insetlist.end(); ++cit) {
- if ((*cit).inset == inset) {
- return (*cit).pos;
+ if (cit->inset == inset) {
+ return cit->pos;
}
}
if (inset == bibkey)
break;
case LATEX_ITEM_ENVIRONMENT:
if (bibkey) {
- bibkey->Latex(buf, os, false, false);
+ bibkey->latex(buf, os, false, false);
} else
os << "\\item ";
break;
else
main_body = beginningOfMainBody();
+ int column = 0;
+
if (main_body > 0) {
os << '[';
+ ++column;
basefont = getFont(bparams, -2); // Get label font
} else {
basefont = getFont(bparams, -1); // Get layout font
}
- int column = 0;
-
if (main_body >= 0
&& !pimpl_->size()) {
if (style.isCommand()) {
os << '{';
++column;
- } else if (params().align() != LYX_ALIGN_LAYOUT) {
- os << '{';
- ++column;
- return_value = true;
}
}
if (style.isCommand()) {
os << '{';
++column;
- } else if (params().align() != LYX_ALIGN_LAYOUT && next_) {
- // We do not need \par here (Dekel)
- // os << "{\\par";
- os << "{";
- ++column;
- return_value = true;
}
if (params().noindent()) {
case LYX_ALIGN_SPECIAL:
break;
case LYX_ALIGN_LEFT:
- if (moving_arg)
- os << "\\protect";
if (getParLanguage(bparams)->babel() != "hebrew") {
- os << "\\raggedright ";
- column+= 13;
+ os << "\\begin{flushleft}";
+ column+= 17;
} else {
- os << "\\raggedleft ";
- column+= 12;
+ os << "\\begin{flushright}";
+ column+= 18;
}
break;
case LYX_ALIGN_RIGHT:
- if (moving_arg)
- os << "\\protect";
if (getParLanguage(bparams)->babel() != "hebrew") {
- os << "\\raggedleft ";
- column+= 12;
+ os << "\\begin{flushright}";
+ column+= 18;
} else {
- os << "\\raggedright ";
- column+= 13;
+ os << "\\begin{flushleft}";
+ column+= 17;
}
break;
case LYX_ALIGN_CENTER:
- if (moving_arg)
- os << "\\protect";
- os << "\\centering ";
- column+= 11;
+ os << "\\begin{center}";
+ column+= 14;
break;
}
}
// newlines are handled differently here than
// the default in SimpleTeXSpecialChars().
if (!style.newline_allowed
- || font.latex() == LyXFont::ON) {
+#ifndef NO_LATEX
+ || font.latex() == LyXFont::ON
+#endif
+ ) {
os << '\n';
} else {
if (open_font) {
return_value = false;
}
+ switch (params().align()) {
+ case LYX_ALIGN_NONE:
+ case LYX_ALIGN_BLOCK:
+ case LYX_ALIGN_LAYOUT:
+ case LYX_ALIGN_SPECIAL:
+ break;
+ case LYX_ALIGN_LEFT:
+ if (getParLanguage(bparams)->babel() != "hebrew") {
+ os << "\\end{flushleft}";
+ column+= 15;
+ } else {
+ os << "\\end{flushright}";
+ column+= 16;
+ }
+ break;
+ case LYX_ALIGN_RIGHT:
+ if (getParLanguage(bparams)->babel() != "hebrew") {
+ os << "\\end{flushright}";
+ column+= 16;
+ } else {
+ os << "\\end{flushleft}";
+ column+= 15;
+ }
+ break;
+ case LYX_ALIGN_CENTER:
+ os << "\\end{center}";
+ column+= 12;
+ break;
+ }
+
lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
return return_value;
}
Language const * doc_language = bparams.language;
for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
cit != pimpl_->fontlist.end(); ++cit)
- if ((*cit).font().language() != doc_language)
+ if (cit->font().language() != doc_language)
return true;
return false;
}
if (IsPrintable(c))
s += c;
else if (c == META_INSET &&
- getInset(i)->LyxCode() == Inset::MATH_CODE) {
- std::ostringstream ost;
- getInset(i)->Ascii(buffer, ost);
+ getInset(i)->lyxCode() == Inset::MATH_CODE) {
+ ostringstream ost;
+ getInset(i)->ascii(buffer, ost);
s += subst(ost.str().c_str(),'\n',' ');
}
}
Paragraph::size_type beg,
Paragraph::size_type end)
{
- std::ostringstream ost;
+ ostringstream ost;
if (beg == 0 && !params().labelString().empty())
ost << params().labelString() << ' ';
if (IsPrintable(c))
ost << c;
else if (c == META_INSET) {
- getInset(i)->Ascii(buffer, ost);
+ getInset(i)->ascii(buffer, ost);
}
}
pimpl_->inset_owner = i;
for (InsetList::const_iterator cit = insetlist.begin();
cit != insetlist.end(); ++cit) {
- if ((*cit).inset)
- (*cit).inset->setOwner(i);
+ if (cit->inset)
+ cit->inset->setOwner(i);
}
}
// then the insets
for (InsetList::const_iterator cit = insetlist.begin();
cit != insetlist.end(); ++cit) {
- if ((*cit).inset) {
- if ((*cit).inset->IsTextInset()) {
+ if (cit->inset) {
+ if (cit->inset->isTextInset()) {
static_cast<UpdatableInset *>
- ((*cit).inset)->deleteLyXText(bv, true);
+ (cit->inset)->deleteLyXText(bv, true);
}
}
}
// then the insets
for (InsetList::const_iterator cit = insetlist.begin();
cit != insetlist.end(); ++cit) {
- if ((*cit).inset) {
- if ((*cit).inset->IsTextInset()) {
+ if (cit->inset) {
+ if (cit->inset->isTextInset()) {
static_cast<UpdatableInset *>
- ((*cit).inset)->resizeLyXText(bv, true);
+ (cit->inset)->resizeLyXText(bv, true);
}
}
}
}
-LyXTextClass::size_type Paragraph::getLayout() const
+LyXTextClass::LayoutList::size_type Paragraph::getLayout() const
{
return layout;
}
}
-Inset * Paragraph::InInset()
+Inset * Paragraph::inInset() const
{
return pimpl_->inset_owner;
}
Paragraph::inset_iterator::inset_iterator(Paragraph::InsetList::iterator const & iter)
: it(iter)
-{
-
-}
+{}
Paragraph::inset_iterator Paragraph::inset_iterator_begin()
return pimpl_->params;
}
+
ParagraphParameters const & Paragraph::params() const
{
return pimpl_->params;
}
+
+
+Paragraph * Paragraph::getParFromID(int id) const
+{
+ return pimpl_->getParFromID(id);
+}