#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "paragraph.h"
#include "paragraph_pimpl.h"
#include "lyxrc.h"
#include "gettext.h"
#include "changes.h"
-#include "insets/insetbib.h"
+#include "insets/insetbibitem.h"
#include "insets/insetoptarg.h"
#include "support/filetools.h"
#endif
enumdepth = 0;
itemdepth = 0;
- bibkey = 0; // ale970302
params().clear();
}
previous_->next_ = this;
// end
- bibkey = 0; // ale970302
params().clear();
}
#endif
// follow footnotes
layout_ = lp.layout();
- // ale970302
- if (lp.bibkey) {
- bibkey = static_cast<InsetBibKey *>
- (lp.bibkey->clone(*current_view->buffer()));
- } else {
- bibkey = 0;
- }
-
// copy everything behind the break-position to the new paragraph
insetlist = lp.insetlist;
InsetList::iterator it = insetlist.begin();
next_->previous_ = previous_;
#endif
- // ale970302
- delete bibkey;
-
delete pimpl_;
//
//lyxerr << "Paragraph::paragraph_id = "
os << "\\align " << string_align[h] << ' ';
}
- // bibitem ale970302
- if (bibkey)
- bibkey->write(buf, os);
-
LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
Change running_change = Change(Change::UNCHANGED);
LyXLayout_ptr const & lout = layout();
- pos_type main_body = 0;
- if (lout->labeltype == LABEL_MANUAL)
- main_body = beginningOfMainBody();
+ pos_type const main_body = beginningOfMainBody();
LyXFont layoutfont;
if (pos < main_body)
int Paragraph::beginningOfMainBody() const
{
+ if (layout()->labeltype != LABEL_MANUAL)
+ return 0;
+
// Unroll the first two cycles of the loop
// and remember the previous character to
// remove unnecessary GetChar() calls
// Find the entry.
InsetList::iterator it = insetlist.begin();
InsetList::iterator end = insetlist.end();
- for (; it != end; ++it) {
- if (it.getInset() == inset) {
+ for (; it != end; ++it)
+ if (it.getInset() == inset)
return it.getPos();
- }
- }
- if (inset == bibkey)
- return 0;
-
return -1;
}
+
+InsetBibitem * Paragraph::bibitem()
+{
+ InsetList::iterator it = insetlist.begin();
+ if (it != insetlist.end() && it.getInset()->lyxCode() == Inset::BIBTEX_CODE)
+ return static_cast<InsetBibitem *>(it.getInset());
+ return 0;
+}
+
namespace {
InsetOptArg * optArgInset(Paragraph const & par)
switch (style->latextype) {
case LATEX_COMMAND:
- os << '\\'
- << style->latexname();
+ os << '\\' << style->latexname();
// Separate handling of optional argument inset.
if (style->optionalargs == 1) {
InsetOptArg * it = optArgInset(*this);
- if (it != 0)
+ if (it)
it->latexOptional(buf, os, false, false);
}
else
os << style->latexparam();
break;
case LATEX_ITEM_ENVIRONMENT:
- if (bibkey) {
- bibkey->latex(buf, os, false, false);
- } else
- os << "\\item ";
- break;
case LATEX_LIST_ENVIRONMENT:
os << "\\item ";
break;
+ case LATEX_BIB_ENVIRONMENT:
+ // ignore this, the inset will write itself
+ break;
default:
break;
}
// Maybe we have to create a optional argument.
pos_type main_body;
- if (style->labeltype != LABEL_MANUAL)
+
+ // FIXME: can we actually skip this check and just call
+ // beginningOfMainBody() ??
+ if (style->labeltype != LABEL_MANUAL) {
main_body = 0;
- else
+ } else {
main_body = beginningOfMainBody();
+ }
unsigned int column = 0;
// Used for building the table of contents
string const Paragraph::asString(Buffer const * buffer, bool label) const
{
- BufferParams const & bparams = buffer->params;
string s;
if (label && !params().labelString().empty())
s += params().labelString() + ' ';
- string::size_type const len = s.size();
for (pos_type i = 0; i < size(); ++i) {
value_type c = getChar(i);
}
-Paragraph * Paragraph::getParFromID(int id) const
-{
- return pimpl_->getParFromID(id);
-}
-
-
bool Paragraph::isFreeSpacing() const
{
// for now we just need this, later should we need this in some