2001-06-25 00:06:33 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-06-10 21:04:06 +00:00
|
|
|
|
/**
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \file paragraph.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Asger Alstrup
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-10 21:04:06 +00:00
|
|
|
|
*/
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
#ifndef PARAGRAPH_H
|
|
|
|
|
#define PARAGRAPH_H
|
|
|
|
|
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "changes.h"
|
2004-11-30 01:59:49 +00:00
|
|
|
|
#include "dimension.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "InsetList.h"
|
2002-06-24 20:28:12 +00:00
|
|
|
|
#include "lyxlayout_ptr_fwd.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "RowList_fwd.h"
|
2002-08-07 16:31:45 +00:00
|
|
|
|
|
2004-04-08 15:03:33 +00:00
|
|
|
|
#include "insets/insetbase.h" // only for InsetBase::Code
|
|
|
|
|
|
2002-08-07 16:31:45 +00:00
|
|
|
|
|
2003-05-28 06:47:15 +00:00
|
|
|
|
class Buffer;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
class BufferParams;
|
|
|
|
|
class BufferView;
|
2002-08-07 16:31:45 +00:00
|
|
|
|
class Counters;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
class InsetBase;
|
2003-02-21 09:20:18 +00:00
|
|
|
|
class InsetBibitem;
|
2004-11-30 01:59:49 +00:00
|
|
|
|
class LaTeXFeatures;
|
2004-11-25 19:13:07 +00:00
|
|
|
|
class InsetBase_code;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
class Language;
|
2003-09-18 10:52:29 +00:00
|
|
|
|
class LyXFont;
|
2003-09-16 13:43:30 +00:00
|
|
|
|
class LyXFont_size;
|
2004-11-30 01:59:49 +00:00
|
|
|
|
class MetricsInfo;
|
|
|
|
|
class OutputParams;
|
|
|
|
|
class PainterInfo;
|
2002-08-07 16:31:45 +00:00
|
|
|
|
class ParagraphParameters;
|
|
|
|
|
class TexRow;
|
2005-07-15 22:10:25 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2005-07-18 12:13:32 +00:00
|
|
|
|
class FontSpan {
|
|
|
|
|
public:
|
2005-07-18 14:25:20 +00:00
|
|
|
|
/// Invalid font span containing no character
|
|
|
|
|
FontSpan() : first(0), last(-1) {}
|
|
|
|
|
/// Span including first and last
|
2005-07-18 12:13:32 +00:00
|
|
|
|
FontSpan(lyx::pos_type f, lyx::pos_type l) : first(f), last(l) {}
|
2005-07-18 14:25:20 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/// Range including first and last.
|
|
|
|
|
lyx::pos_type first, last;
|
2005-07-18 12:13:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
2006-04-05 23:56:29 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/// A Paragraph holds all text, attributes and insets in a text paragraph
|
|
|
|
|
class Paragraph {
|
|
|
|
|
public:
|
|
|
|
|
///
|
2004-01-26 10:13:15 +00:00
|
|
|
|
enum {
|
2003-03-12 19:16:42 +00:00
|
|
|
|
/// Note that this is 1 right now to avoid
|
|
|
|
|
/// crashes where getChar() is called wrongly
|
|
|
|
|
/// (returning 0) - if this was 0, then we'd
|
|
|
|
|
/// try getInset() and crash. We should fix
|
|
|
|
|
/// all these places.
|
2006-08-13 22:54:59 +00:00
|
|
|
|
//META_INSET = 1 // as in trunk
|
|
|
|
|
META_INSET = 0x200001 // above 0x10ffff, for ucs-4
|
2001-06-25 00:06:33 +00:00
|
|
|
|
};
|
|
|
|
|
///
|
2006-04-09 02:30:40 +00:00
|
|
|
|
typedef lyx::char_type value_type;
|
2003-09-06 17:23:08 +00:00
|
|
|
|
///
|
|
|
|
|
typedef lyx::depth_type depth_type;
|
2003-09-16 14:08:05 +00:00
|
|
|
|
///
|
|
|
|
|
typedef std::vector<value_type> TextContainer;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
Paragraph();
|
|
|
|
|
///
|
2003-05-25 08:49:48 +00:00
|
|
|
|
Paragraph(Paragraph const &);
|
|
|
|
|
///
|
2004-03-19 16:36:52 +00:00
|
|
|
|
Paragraph & operator=(Paragraph const &);
|
2004-01-26 10:13:15 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
~Paragraph();
|
2003-10-14 13:01:49 +00:00
|
|
|
|
///
|
|
|
|
|
int id() const;
|
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
|
|
|
|
Language const * getParLanguage(BufferParams const &) const;
|
|
|
|
|
///
|
|
|
|
|
bool isRightToLeftPar(BufferParams const &) const;
|
|
|
|
|
///
|
|
|
|
|
void changeLanguage(BufferParams const & bparams,
|
|
|
|
|
Language const * from, Language const * to);
|
|
|
|
|
///
|
2004-02-25 12:00:53 +00:00
|
|
|
|
bool isMultiLingual(BufferParams const &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-10-31 18:45:43 +00:00
|
|
|
|
///
|
2006-10-11 19:40:50 +00:00
|
|
|
|
lyx::docstring const asString(Buffer const &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams,
|
2003-10-31 18:45:43 +00:00
|
|
|
|
bool label) const;
|
2001-11-26 16:52:24 +00:00
|
|
|
|
///
|
2006-10-11 19:40:50 +00:00
|
|
|
|
lyx::docstring const asString(Buffer const &, bool label) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2006-10-11 19:40:50 +00:00
|
|
|
|
lyx::docstring const asString(Buffer const & buffer,
|
2006-01-01 20:28:05 +00:00
|
|
|
|
lyx::pos_type beg,
|
|
|
|
|
lyx::pos_type end,
|
|
|
|
|
bool label) const;
|
2003-10-31 18:45:43 +00:00
|
|
|
|
///
|
2006-10-11 19:40:50 +00:00
|
|
|
|
lyx::docstring const asString(Buffer const &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams,
|
2003-10-31 18:45:43 +00:00
|
|
|
|
lyx::pos_type beg,
|
|
|
|
|
lyx::pos_type end,
|
|
|
|
|
bool label) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void write(Buffer const &, std::ostream &, BufferParams const &,
|
2003-09-06 18:38:02 +00:00
|
|
|
|
depth_type & depth) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
|
|
|
|
void validate(LaTeXFeatures &) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
|
|
///
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int startTeXParParams(BufferParams const &, lyx::odocstream &, bool) const;
|
2002-01-19 20:24:04 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
///
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int endTeXParParams(BufferParams const &, lyx::odocstream &, bool) const;
|
2002-01-19 20:24:04 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
bool simpleTeXOnePar(Buffer const &, BufferParams const &,
|
2006-10-19 16:51:30 +00:00
|
|
|
|
LyXFont const & outerfont, lyx::odocstream &,
|
2004-05-17 11:28:31 +00:00
|
|
|
|
TexRow & texrow, OutputParams const &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2004-10-30 13:05:31 +00:00
|
|
|
|
/// Can we drop the standard paragraph wrapper?
|
2005-01-31 16:29:48 +00:00
|
|
|
|
bool emptyTag() const;
|
2004-10-30 13:05:31 +00:00
|
|
|
|
|
2006-08-23 11:16:08 +00:00
|
|
|
|
/// Get the id of the paragraph, usefull for docbook
|
2004-11-02 11:25:20 +00:00
|
|
|
|
std::string getID(Buffer const & buf,
|
|
|
|
|
OutputParams const & runparams) const;
|
2004-05-14 15:47:35 +00:00
|
|
|
|
|
2004-10-24 23:53:42 +00:00
|
|
|
|
// Get the first word of a paragraph, return the position where it left
|
|
|
|
|
lyx::pos_type getFirstWord(Buffer const & buf,
|
2006-10-19 21:00:33 +00:00
|
|
|
|
lyx::odocstream & os,
|
2004-10-24 23:53:42 +00:00
|
|
|
|
OutputParams const & runparams) const;
|
|
|
|
|
|
2004-10-30 22:14:02 +00:00
|
|
|
|
/// Checks if the paragraph contains only text and no inset or font change.
|
|
|
|
|
bool onlyText(Buffer const & buf, LyXFont const & outerfont,
|
|
|
|
|
lyx::pos_type initial) const;
|
|
|
|
|
|
2004-10-24 23:53:42 +00:00
|
|
|
|
/// Writes to stream the docbook representation
|
2003-10-30 08:47:16 +00:00
|
|
|
|
void simpleDocBookOnePar(Buffer const & buf,
|
2006-10-19 21:00:33 +00:00
|
|
|
|
lyx::odocstream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams,
|
2004-10-24 23:53:42 +00:00
|
|
|
|
LyXFont const & outerfont,
|
|
|
|
|
lyx::pos_type initial = 0) const;
|
2003-10-30 08:47:16 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2003-04-29 10:56:15 +00:00
|
|
|
|
bool hasSameLayout(Paragraph const & par) const;
|
2001-07-29 15:34:18 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2003-04-29 10:56:15 +00:00
|
|
|
|
void makeSameLayout(Paragraph const & par);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2004-04-08 15:03:33 +00:00
|
|
|
|
///
|
2005-07-15 22:10:25 +00:00
|
|
|
|
void setInsetOwner(InsetBase * inset);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2005-07-15 22:10:25 +00:00
|
|
|
|
InsetBase * inInset() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2004-04-08 15:03:33 +00:00
|
|
|
|
InsetBase::Code ownerCode() const;
|
|
|
|
|
///
|
|
|
|
|
bool forceDefaultParagraphs() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
///
|
2003-09-16 14:08:05 +00:00
|
|
|
|
lyx::pos_type size() const { return text_.size(); }
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2003-09-16 14:08:05 +00:00
|
|
|
|
bool empty() const { return text_.empty(); }
|
2002-08-10 15:21:07 +00:00
|
|
|
|
///
|
2003-04-29 10:39:08 +00:00
|
|
|
|
void setContentsFromPar(Paragraph const & par);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
|
|
|
|
void clearContents();
|
|
|
|
|
|
|
|
|
|
///
|
2002-06-24 20:28:12 +00:00
|
|
|
|
LyXLayout_ptr const & layout() const;
|
2002-03-02 16:39:54 +00:00
|
|
|
|
///
|
2002-06-24 20:28:12 +00:00
|
|
|
|
void layout(LyXLayout_ptr const & new_layout);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-10-08 17:44:32 +00:00
|
|
|
|
/// This is the item depth, only used by enumerate and itemize
|
|
|
|
|
signed char itemdepth;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
///
|
2003-05-27 22:41:04 +00:00
|
|
|
|
InsetBibitem * bibitem() const; // ale970302
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// look up change at given pos
|
2006-05-05 23:11:19 +00:00
|
|
|
|
Change const lookupChange(lyx::pos_type pos) const;
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// is there a change within the given range ?
|
|
|
|
|
bool isChanged(lyx::pos_type start, lyx::pos_type end) const;
|
2006-10-19 12:49:11 +00:00
|
|
|
|
/// is there a deletion at the given pos ?
|
|
|
|
|
bool isDeleted(lyx::pos_type pos) const {
|
|
|
|
|
return lookupChange(pos).type == Change::DELETED;
|
|
|
|
|
}
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2006-10-19 07:12:48 +00:00
|
|
|
|
/// set change for the entire par
|
|
|
|
|
void setChange(Change const & change);
|
|
|
|
|
|
2006-05-08 20:30:52 +00:00
|
|
|
|
/// set change at given pos
|
2006-10-19 07:12:48 +00:00
|
|
|
|
void setChange(lyx::pos_type pos, Change const & change);
|
2003-03-04 19:52:35 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// accept change
|
|
|
|
|
void acceptChange(lyx::pos_type start, lyx::pos_type end);
|
|
|
|
|
|
|
|
|
|
/// reject change
|
|
|
|
|
void rejectChange(lyx::pos_type start, lyx::pos_type end);
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-05-29 11:19:52 +00:00
|
|
|
|
/// Paragraphs can contain "manual labels", for example, Description
|
|
|
|
|
/// environment. The text for this user-editable label is stored in
|
|
|
|
|
/// the paragraph alongside the text of the rest of the paragraph
|
|
|
|
|
/// (the body). This function returns the starting position of the
|
|
|
|
|
/// body of the text in the paragraph.
|
2004-03-24 17:06:17 +00:00
|
|
|
|
lyx::pos_type beginOfBody() const;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
/// recompute this value
|
|
|
|
|
void setBeginOfBody();
|
2003-03-09 12:37:22 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2006-10-20 19:26:23 +00:00
|
|
|
|
lyx::docstring const & getLabelstring() const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/// the next two functions are for the manual labels
|
2006-10-20 19:26:23 +00:00
|
|
|
|
lyx::docstring const getLabelWidthString() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2006-10-20 19:26:23 +00:00
|
|
|
|
void setLabelWidthString(lyx::docstring const & s);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
|
|
|
|
char getAlign() const;
|
2002-02-28 15:07:11 +00:00
|
|
|
|
/// The nesting depth of a paragraph
|
2001-06-25 00:06:33 +00:00
|
|
|
|
depth_type getDepth() const;
|
2002-02-28 15:07:11 +00:00
|
|
|
|
/// The maximal possible depth of a paragraph after this one
|
2002-06-24 20:28:12 +00:00
|
|
|
|
depth_type getMaxDepthAfter() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2002-06-24 20:28:12 +00:00
|
|
|
|
void applyLayout(LyXLayout_ptr const & new_layout);
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// erase the char at the given position
|
2006-10-19 17:46:50 +00:00
|
|
|
|
bool erase(lyx::pos_type pos, bool trackChanges);
|
2003-04-29 09:40:49 +00:00
|
|
|
|
/// erase the given range. Returns the number of chars actually erased
|
2006-10-19 17:46:50 +00:00
|
|
|
|
int erase(lyx::pos_type start, lyx::pos_type end, bool trackChanges);
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/** Get uninstantiated font setting. Returns the difference
|
2001-06-25 00:06:33 +00:00
|
|
|
|
between the characters font and the layoutfont.
|
|
|
|
|
This is what is stored in the fonttable
|
|
|
|
|
*/
|
|
|
|
|
LyXFont const
|
2001-11-27 10:34:16 +00:00
|
|
|
|
getFontSettings(BufferParams const &, lyx::pos_type pos) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2006-02-05 13:20:16 +00:00
|
|
|
|
LyXFont const getFirstFontSettings(BufferParams const &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
/** 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
|
2002-03-21 17:27:08 +00:00
|
|
|
|
attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
|
2001-06-25 00:06:33 +00:00
|
|
|
|
LyXFont::TOGGLE.
|
|
|
|
|
*/
|
2003-04-15 00:11:03 +00:00
|
|
|
|
LyXFont const getFont(BufferParams const &, lyx::pos_type pos,
|
|
|
|
|
LyXFont const & outerfont) const;
|
2003-04-15 00:49:11 +00:00
|
|
|
|
LyXFont const getLayoutFont(BufferParams const &,
|
|
|
|
|
LyXFont const & outerfont) const;
|
|
|
|
|
LyXFont const getLabelFont(BufferParams const &,
|
|
|
|
|
LyXFont const & outerfont) const;
|
2003-07-27 10:42:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* The font returned by the above functions is the same in a
|
2005-06-10 14:55:01 +00:00
|
|
|
|
* span of characters. This method will return the first and
|
2005-07-18 12:13:32 +00:00
|
|
|
|
* the last positions in the paragraph for which that font is
|
|
|
|
|
* the same. This can be used to avoid unnecessary calls to
|
|
|
|
|
* getFont.
|
2003-07-27 10:42:11 +00:00
|
|
|
|
*/
|
2005-07-18 12:13:32 +00:00
|
|
|
|
FontSpan fontSpan(lyx::pos_type pos) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2004-08-14 19:55:00 +00:00
|
|
|
|
/// this is a bottleneck.
|
2005-07-16 09:40:16 +00:00
|
|
|
|
value_type getChar(lyx::pos_type pos) const { return text_[pos]; }
|
2005-01-31 16:29:48 +00:00
|
|
|
|
/// Get the char, but mirror all bracket characters if it is right-to-left
|
2001-11-27 10:34:16 +00:00
|
|
|
|
value_type getUChar(BufferParams const &, lyx::pos_type pos) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/// The position must already exist.
|
2001-11-27 10:34:16 +00:00
|
|
|
|
void setChar(lyx::pos_type pos, value_type c);
|
2002-05-30 03:37:24 +00:00
|
|
|
|
/// pos <= size() (there is a dummy font change at the end of each par)
|
2001-11-27 10:34:16 +00:00
|
|
|
|
void setFont(lyx::pos_type pos, LyXFont const & font);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/// Returns the height of the highest font in range
|
2003-09-16 13:43:30 +00:00
|
|
|
|
LyXFont_size highestFontInRange(lyx::pos_type startpos,
|
|
|
|
|
lyx::pos_type endpos,
|
|
|
|
|
LyXFont_size def_size) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2003-11-04 12:01:15 +00:00
|
|
|
|
void insert(lyx::pos_type pos, std::string const & str,
|
2006-10-20 11:44:58 +00:00
|
|
|
|
LyXFont const & font, Change const & change);
|
2003-11-04 12:01:15 +00:00
|
|
|
|
///
|
2006-10-20 11:44:58 +00:00
|
|
|
|
void insertChar(lyx::pos_type pos, value_type c, bool trackChanges);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2004-01-26 10:13:15 +00:00
|
|
|
|
void insertChar(lyx::pos_type pos, value_type c,
|
2006-10-20 11:44:58 +00:00
|
|
|
|
LyXFont const &, bool trackChanges);
|
|
|
|
|
///
|
|
|
|
|
void insertChar(lyx::pos_type pos, value_type c,
|
|
|
|
|
LyXFont const &, Change const & change);
|
2001-07-27 12:03:36 +00:00
|
|
|
|
///
|
2004-08-13 20:26:26 +00:00
|
|
|
|
void insertInset(lyx::pos_type pos, InsetBase * inset,
|
2006-10-19 07:12:48 +00:00
|
|
|
|
Change const & change);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2004-01-26 10:13:15 +00:00
|
|
|
|
void insertInset(lyx::pos_type pos, InsetBase * inset,
|
2006-10-20 11:44:58 +00:00
|
|
|
|
LyXFont const &, Change const & change);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2004-11-25 19:13:07 +00:00
|
|
|
|
bool insetAllowed(InsetBase_code code);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2005-07-18 12:57:08 +00:00
|
|
|
|
InsetBase * getInset(lyx::pos_type pos) {
|
|
|
|
|
return insetlist.get(pos);
|
|
|
|
|
}
|
2005-01-31 16:29:48 +00:00
|
|
|
|
///
|
2005-07-18 12:57:08 +00:00
|
|
|
|
InsetBase const * getInset(lyx::pos_type pos) const {
|
|
|
|
|
return insetlist.get(pos);
|
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
///
|
2005-07-18 12:57:08 +00:00
|
|
|
|
bool isHfill(lyx::pos_type pos) const {
|
2006-10-19 12:49:11 +00:00
|
|
|
|
return isInset(pos)
|
|
|
|
|
&& getInset(pos)->lyxCode() == InsetBase::HFILL_CODE;
|
2005-07-18 12:57:08 +00:00
|
|
|
|
}
|
2004-03-25 09:16:36 +00:00
|
|
|
|
/// hinted by profiler
|
2005-07-16 18:25:58 +00:00
|
|
|
|
bool isInset(lyx::pos_type pos) const {
|
|
|
|
|
return getChar(pos) == static_cast<value_type>(META_INSET);
|
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-11-27 10:34:16 +00:00
|
|
|
|
bool isNewline(lyx::pos_type pos) const;
|
2005-07-18 12:57:08 +00:00
|
|
|
|
/// return true if the char is a word separator
|
|
|
|
|
bool isSeparator(lyx::pos_type pos) const { return getChar(pos) == ' '; }
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-11-27 10:34:16 +00:00
|
|
|
|
bool isLineSeparator(lyx::pos_type pos) const;
|
2004-11-18 14:58:54 +00:00
|
|
|
|
/// True if the character/inset at this point can be part of a word
|
|
|
|
|
// Note that digits in particular are considered as letters
|
2001-11-27 10:34:16 +00:00
|
|
|
|
bool isLetter(lyx::pos_type pos) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
/// returns -1 if inset not found
|
2004-01-26 10:13:15 +00:00
|
|
|
|
int getPositionOfInset(InsetBase const * inset) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2005-01-31 16:29:48 +00:00
|
|
|
|
/// Returns the number of line breaks and white-space stripped at the start
|
2002-06-24 20:28:12 +00:00
|
|
|
|
int stripLeadingSpaces();
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-06-07 17:45:43 +00:00
|
|
|
|
/// return true if we allow multiple spaces
|
2001-11-29 16:29:30 +00:00
|
|
|
|
bool isFreeSpacing() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-06-07 17:45:43 +00:00
|
|
|
|
/// return true if we allow this par to stay empty
|
|
|
|
|
bool allowEmpty() const;
|
2005-04-26 11:12:20 +00:00
|
|
|
|
///
|
2006-08-13 22:54:59 +00:00
|
|
|
|
lyx::char_type transformChar(lyx::char_type c, lyx::pos_type pos) const;
|
2002-03-02 16:39:54 +00:00
|
|
|
|
///
|
2002-08-11 15:03:52 +00:00
|
|
|
|
ParagraphParameters & params();
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2002-08-11 15:03:52 +00:00
|
|
|
|
ParagraphParameters const & params() const;
|
2003-10-24 09:45:07 +00:00
|
|
|
|
|
|
|
|
|
///
|
2005-07-17 12:02:48 +00:00
|
|
|
|
Row & getRow(lyx::pos_type pos, bool boundary);
|
2004-02-03 08:56:28 +00:00
|
|
|
|
///
|
2005-07-17 12:02:48 +00:00
|
|
|
|
Row const & getRow(lyx::pos_type pos, bool boundary) const;
|
2004-02-12 16:36:01 +00:00
|
|
|
|
///
|
2004-11-30 01:59:49 +00:00
|
|
|
|
size_t pos2row(lyx::pos_type pos) const;
|
2003-10-24 09:45:07 +00:00
|
|
|
|
|
2003-10-23 08:15:57 +00:00
|
|
|
|
/// total height of paragraph
|
2004-11-30 01:59:49 +00:00
|
|
|
|
unsigned int height() const { return dim_.height(); }
|
2003-10-23 08:15:57 +00:00
|
|
|
|
/// total width of paragraph, may differ from workwidth
|
2004-11-30 01:59:49 +00:00
|
|
|
|
unsigned int width() const { return dim_.width(); }
|
2005-07-16 18:25:58 +00:00
|
|
|
|
/// ascend of paragraph above baseline
|
2004-11-30 01:59:49 +00:00
|
|
|
|
unsigned int ascent() const { return dim_.ascent(); }
|
2005-07-16 18:25:58 +00:00
|
|
|
|
/// descend of paragraph below baseline
|
2004-11-30 01:59:49 +00:00
|
|
|
|
unsigned int descent() const { return dim_.descent(); }
|
2005-01-31 16:29:48 +00:00
|
|
|
|
/// LyXText updates the rows using this access point
|
2004-11-30 01:59:49 +00:00
|
|
|
|
RowList & rows() { return rows_; }
|
2005-01-31 16:29:48 +00:00
|
|
|
|
/// The painter and others use this
|
2004-11-30 01:59:49 +00:00
|
|
|
|
RowList const & rows() const { return rows_; }
|
2005-12-30 19:02:52 +00:00
|
|
|
|
///
|
|
|
|
|
RowSignature & rowSignature() const { return rowSignature_; }
|
2006-04-05 23:56:29 +00:00
|
|
|
|
|
2005-01-31 16:29:48 +00:00
|
|
|
|
/// LyXText::redoParagraph updates this
|
|
|
|
|
Dimension & dim() { return dim_; }
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
2005-01-31 16:29:48 +00:00
|
|
|
|
/// dump some information to lyxerr
|
|
|
|
|
void dump() const;
|
2005-07-18 12:57:08 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
InsetList insetlist;
|
|
|
|
|
|
2005-01-31 16:29:48 +00:00
|
|
|
|
private:
|
2004-11-30 01:59:49 +00:00
|
|
|
|
/// cached dimensions of paragraph
|
|
|
|
|
Dimension dim_;
|
2003-08-15 08:03:54 +00:00
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
///
|
|
|
|
|
mutable RowList rows_;
|
2005-12-30 19:02:52 +00:00
|
|
|
|
///
|
|
|
|
|
mutable RowSignature rowSignature_;
|
|
|
|
|
|
2002-08-11 15:03:52 +00:00
|
|
|
|
///
|
|
|
|
|
LyXLayout_ptr layout_;
|
2005-01-31 16:29:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* Keeping this here instead of in the pimpl makes LyX >10% faster
|
|
|
|
|
* for average tasks as buffer loading/switching etc.
|
|
|
|
|
*/
|
2003-09-16 14:08:05 +00:00
|
|
|
|
TextContainer text_;
|
2003-11-13 13:43:44 +00:00
|
|
|
|
/// end of label
|
2004-03-24 17:06:17 +00:00
|
|
|
|
lyx::pos_type begin_of_body_;
|
2003-05-24 16:11:27 +00:00
|
|
|
|
|
2005-07-18 12:57:08 +00:00
|
|
|
|
/// Pimpl away stuff
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class Pimpl;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2005-01-19 15:03:31 +00:00
|
|
|
|
friend class Paragraph::Pimpl;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
|
|
|
|
Pimpl * pimpl_;
|
|
|
|
|
};
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
#endif // PARAGRAPH_H
|