#ifndef PARAGRAPH_H
#define PARAGRAPH_H
-#include "Changes.h"
-#include "Dimension.h"
-#include "InsetList.h"
#include "lyxlayout_ptr_fwd.h"
-#include "RowList_fwd.h"
-#include "insets/Inset.h" // only for Inset::Code
+#include "insets/InsetCode.h"
+#include "support/docstring.h"
+// FIXME: would be nice to forward declare odocstream instead of
+// including this:
+#include "support/docstream.h"
-namespace lyx {
+#include <vector>
+namespace lyx {
+class AuthorList;
class Buffer;
class BufferParams;
+class Change;
class Counters;
class Inset;
class InsetBibitem;
class LaTeXFeatures;
class Inset_code;
+class InsetList;
class Language;
-class LyXFont;
-class LyXFont_size;
+class Font;
+class Font_size;
class MetricsInfo;
class OutputParams;
class PainterInfo;
///
Language const * getParLanguage(BufferParams const &) const;
///
- bool isRightToLeftPar(BufferParams const &) const;
+ bool isRTL(BufferParams const &) const;
///
void changeLanguage(BufferParams const & bparams,
Language const * from, Language const * to);
void validate(LaTeXFeatures &) const;
///
- int startTeXParParams(BufferParams const &, odocstream &, TexRow &,
+ int startTeXParParams(BufferParams const &, odocstream &, TexRow &,
bool) const;
///
- int endTeXParParams(BufferParams const &, odocstream &, TexRow &,
+ int endTeXParParams(BufferParams const &, odocstream &, TexRow &,
bool) const;
///
bool simpleTeXOnePar(Buffer const &, BufferParams const &,
- LyXFont const & outerfont, odocstream &,
+ Font const & outerfont, odocstream &,
TexRow & texrow, OutputParams const &) const;
/// Can we drop the standard paragraph wrapper?
OutputParams const & runparams) const;
/// Checks if the paragraph contains only text and no inset or font change.
- bool onlyText(Buffer const & buf, LyXFont const & outerfont,
+ bool onlyText(Buffer const & buf, Font const & outerfont,
pos_type initial) const;
/// Writes to stream the docbook representation
void simpleDocBookOnePar(Buffer const & buf,
odocstream &,
OutputParams const & runparams,
- LyXFont const & outerfont,
+ Font const & outerfont,
pos_type initial = 0) const;
///
///
Inset * inInset() const;
///
- Inset::Code ownerCode() const;
+ InsetCode ownerCode() const;
///
bool forceDefaultParagraphs() const;
bool empty() const { return text_.empty(); }
///
- LyXLayout_ptr const & layout() const;
+ LayoutPtr const & layout() const;
///
- void layout(LyXLayout_ptr const & new_layout);
+ void layout(LayoutPtr const & new_layout);
/// This is the item depth, only used by enumerate and itemize
signed char itemdepth;
/// is there a change within the given range ?
bool isChanged(pos_type start, pos_type end) const;
/// is there an unchanged char at the given pos ?
- bool isUnchanged(pos_type pos) const {
- return lookupChange(pos).type == Change::UNCHANGED;
- }
+ bool isUnchanged(pos_type pos) const;
/// is there an insertion at the given pos ?
- bool isInserted(pos_type pos) const {
- return lookupChange(pos).type == Change::INSERTED;
- }
+ bool isInserted(pos_type pos) const;
/// is there a deletion at the given pos ?
- bool isDeleted(pos_type pos) const {
- return lookupChange(pos).type == Change::DELETED;
- }
+ bool isDeleted(pos_type pos) const;
/// will the paragraph be physically merged with the next
/// one if the imaginary end-of-par character is logically deleted?
docstring const translateIfPossible(docstring const & label,
BufferParams const & bparams) const;
/// Expand the counters for the labelstring of \c layout
- docstring expandLabel(LyXLayout_ptr const &, BufferParams const &,
+ docstring expandLabel(LayoutPtr const &, BufferParams const &,
bool process_appendix = true) const;
/// Actual paragraph alignment used
char getAlign() const;
/// The maximal possible depth of a paragraph after this one
depth_type getMaxDepthAfter() const;
///
- void applyLayout(LyXLayout_ptr const & new_layout);
+ void applyLayout(LayoutPtr const & new_layout);
/// (logically) erase the char at pos; return true if it was actually erased
bool eraseChar(pos_type pos, bool trackChanges);
between the characters font and the layoutfont.
This is what is stored in the fonttable
*/
- LyXFont const
+ Font const
getFontSettings(BufferParams const &, pos_type pos) const;
///
- LyXFont const getFirstFontSettings(BufferParams const &) const;
+ Font const getFirstFontSettings(BufferParams const &) const;
/** Get fully instantiated font. If pos == -1, use the layout
font attached to this paragraph.
If pos == -2, use the label font of the layout attached here.
In all cases, the font is instantiated, i.e. does not have any
- attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
- LyXFont::TOGGLE.
+ attributes with values Font::INHERIT, Font::IGNORE or
+ Font::TOGGLE.
*/
- LyXFont const getFont(BufferParams const &, pos_type pos,
- LyXFont const & outerfont) const;
- LyXFont const getLayoutFont(BufferParams const &,
- LyXFont const & outerfont) const;
- LyXFont const getLabelFont(BufferParams const &,
- LyXFont const & outerfont) const;
+ Font const getFont(BufferParams const &, pos_type pos,
+ Font const & outerfont) const;
+ Font const getLayoutFont(BufferParams const &,
+ Font const & outerfont) const;
+ Font const getLabelFont(BufferParams const &,
+ Font const & outerfont) const;
/**
* The font returned by the above functions is the same in a
* span of characters. This method will return the first and
/// Get the char, but mirror all bracket characters if it is right-to-left
value_type getUChar(BufferParams const &, pos_type pos) const;
/// pos <= size() (there is a dummy font change at the end of each par)
- void setFont(pos_type pos, LyXFont const & font);
+ void setFont(pos_type pos, Font const & font);
/// Returns the height of the highest font in range
- LyXFont_size highestFontInRange(pos_type startpos,
- pos_type endpos, LyXFont_size def_size) const;
+ Font_size highestFontInRange(pos_type startpos,
+ pos_type endpos, Font_size def_size) const;
///
void insert(pos_type pos, docstring const & str,
- LyXFont const & font, Change const & change);
+ Font const & font, Change const & change);
///
void insertChar(pos_type pos, value_type c, bool trackChanges);
///
void insertChar(pos_type pos, value_type c,
- LyXFont const &, bool trackChanges);
+ Font const &, bool trackChanges);
///
void insertChar(pos_type pos, value_type c,
- LyXFont const &, Change const & change);
+ Font const &, Change const & change);
///
void insertInset(pos_type pos, Inset * inset,
- Change const & change);
+ Change const & change);
///
void insertInset(pos_type pos, Inset * inset,
- LyXFont const &, Change const & change);
+ Font const &, Change const & change);
///
- bool insetAllowed(Inset_code code);
+ bool insetAllowed(InsetCode code);
///
- Inset * getInset(pos_type pos) {
- return insetlist.get(pos);
- }
+ Inset * getInset(pos_type pos);
///
- Inset const * getInset(pos_type pos) const {
- return insetlist.get(pos);
- }
+ Inset const * getInset(pos_type pos) const;
+
+ /// Release inset at given position.
+ /// \warning does not honour change tracking!
+ /// Therefore, it should only be used for breaking and merging
+ /// paragraphs
+ Inset * releaseInset(pos_type pos);
///
- bool isHfill(pos_type pos) const {
- return isInset(pos)
- && getInset(pos)->lyxCode() == Inset::HFILL_CODE;
- }
+ InsetList const & insetList() const;
+
+ ///
+ bool isHfill(pos_type pos) const;
+
/// hinted by profiler
bool isInset(pos_type pos) const {
return getChar(pos) == static_cast<value_type>(META_INSET);
/// returns -1 if inset not found
int getPositionOfInset(Inset const * inset) const;
- /// returns true if at least one line break or line separator has been deleted
+ /// returns true if at least one line break or line separator has been deleted
/// at the beginning of the paragraph (either physically or logically)
bool stripLeadingSpaces(bool trackChanges);
ParagraphParameters & params();
///
ParagraphParameters const & params() const;
- ///
- bool hfillExpansion(Row const & row, pos_type pos) const;
- /// Check if we are in a Biblio environment.
- /// \retval true if the cursor needs to be moved right.
- bool checkBiblio(bool track_changes);
+ /// Check if we are in a Biblio environment and insert or
+ /// delete InsetBibitems as necessary.
+ /// \retval int 1, if we had to add an inset, in which case
+ /// the cursor will need to move cursor forward; -pos, if we deleted
+ /// an inset, in which case pos is the position from which the inset
+ /// was deleted, and the cursor will need to be moved back one if it
+ /// was previously past that position. Return 0 otherwise.
+ int checkBiblio(bool track_changes);
-public:
- ///
- InsetList insetlist;
+ /// For each author, set 'used' to true if there is a change
+ /// by this author in the paragraph.
+ void checkAuthors(AuthorList const & authorList);
private:
///
- LyXLayout_ptr layout_;
+ LayoutPtr layout_;
/**
* Keeping this here instead of in the pimpl makes LyX >10% faster
* for average tasks as buffer loading/switching etc.