2001-06-25 00:06:33 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file paragraph_pimpl.h
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-02-08 19:18:01 +00:00
|
|
|
|
*/
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
#ifndef PARAGRAPH_PIMPL_H
|
|
|
|
|
#define PARAGRAPH_PIMPL_H
|
|
|
|
|
|
|
|
|
|
#include "paragraph.h"
|
2003-09-07 01:45:40 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
#include "changes.h"
|
2003-09-22 20:02:32 +00:00
|
|
|
|
#include "lyxfont.h"
|
2003-09-07 01:45:40 +00:00
|
|
|
|
#include "ParagraphParameters.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2001-12-28 13:26:54 +00:00
|
|
|
|
class LyXLayout;
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class Paragraph::Pimpl {
|
|
|
|
|
public:
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
|
|
|
|
Pimpl(Paragraph * owner);
|
2004-01-26 10:13:15 +00:00
|
|
|
|
/// "Copy constructor"
|
2003-05-25 08:49:48 +00:00
|
|
|
|
Pimpl(Pimpl const &, Paragraph * owner);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2003-04-29 10:39:08 +00:00
|
|
|
|
void setContentsFromPar(Paragraph const & par);
|
2004-01-26 10:13:15 +00:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Change tracking
|
|
|
|
|
//
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// look up change at given pos
|
2006-10-21 00:16:43 +00:00
|
|
|
|
Change const lookupChange(pos_type pos) const;
|
2006-05-08 20:30:52 +00:00
|
|
|
|
/// is there a change within the given range ?
|
2006-10-21 00:16:43 +00:00
|
|
|
|
bool isChanged(pos_type start, pos_type end) const;
|
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-21 00:16:43 +00:00
|
|
|
|
void setChange(pos_type pos, Change const & change);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// accept change
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void acceptChange(pos_type start, pos_type end);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// reject change
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void rejectChange(pos_type start, pos_type end);
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
value_type getChar(pos_type pos) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void insertChar(pos_type pos, value_type c, Change const & change);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void insertInset(pos_type pos, InsetBase * inset, Change const & change);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// definite erase
|
2006-10-21 17:05:20 +00:00
|
|
|
|
void eraseChar(pos_type pos);
|
2003-05-01 09:15:15 +00:00
|
|
|
|
/// erase the given position. Returns true if it was actually erased
|
2006-10-21 17:05:20 +00:00
|
|
|
|
bool eraseChar(pos_type pos, bool trackChanges);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// erase the given range
|
2006-10-21 00:16:43 +00:00
|
|
|
|
int erase(pos_type start, pos_type end, bool trackChanges);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2005-07-15 22:10:25 +00:00
|
|
|
|
InsetBase * inset_owner;
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/** A font entry covers a range of positions. Notice that the
|
|
|
|
|
entries in the list are inserted in random order.
|
|
|
|
|
I don't think it's worth the effort to implement a more effective
|
|
|
|
|
datastructure, because the number of different fonts in a paragraph
|
|
|
|
|
is limited. (Asger)
|
|
|
|
|
Nevertheless, I decided to store fontlist using a sorted vector:
|
|
|
|
|
fontlist = { {pos_1,font_1} , {pos_2,font_2} , ... } where
|
|
|
|
|
pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
|
|
|
|
|
and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
|
|
|
|
|
(font_1 covers the chars 0,...,pos_1) (Dekel)
|
|
|
|
|
*/
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class FontTable {
|
|
|
|
|
public:
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
FontTable(pos_type p, LyXFont const & f)
|
2004-09-26 08:24:08 +00:00
|
|
|
|
: pos_(p), font_(f)
|
2006-04-09 00:19:34 +00:00
|
|
|
|
{}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
pos_type pos() const { return pos_; }
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void pos(pos_type p) { pos_ = p; }
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2004-09-26 08:24:08 +00:00
|
|
|
|
LyXFont const & font() const { return font_; }
|
|
|
|
|
///
|
|
|
|
|
void font(LyXFont const & f) { font_ = f;}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
private:
|
|
|
|
|
/// End position of paragraph this font attribute covers
|
2006-10-21 00:16:43 +00:00
|
|
|
|
pos_type pos_;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/** Font. Interpretation of the font values:
|
2002-03-21 17:27:08 +00:00
|
|
|
|
If a value is LyXFont::INHERIT_*, it means that the font
|
2001-06-25 00:06:33 +00:00
|
|
|
|
attribute is inherited from either the layout of this
|
2002-03-21 17:27:08 +00:00
|
|
|
|
paragraph or, in the case of nested paragraphs, from the
|
|
|
|
|
layout in the environment one level up until completely
|
2001-06-25 00:06:33 +00:00
|
|
|
|
resolved.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
The values LyXFont::IGNORE_* and LyXFont::TOGGLE are NOT
|
2001-06-25 00:06:33 +00:00
|
|
|
|
allowed in these font tables.
|
|
|
|
|
*/
|
2004-09-26 08:24:08 +00:00
|
|
|
|
LyXFont font_;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
};
|
|
|
|
|
///
|
2005-01-19 15:03:31 +00:00
|
|
|
|
friend class matchFT;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class matchFT {
|
|
|
|
|
public:
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/// used by lower_bound and upper_bound
|
2001-11-26 16:42:04 +00:00
|
|
|
|
int operator()(FontTable const & a, FontTable const & b) const {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
return a.pos() < b.pos();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
typedef std::vector<FontTable> FontList;
|
|
|
|
|
///
|
|
|
|
|
FontList fontlist;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void simpleTeXBlanks(odocstream &, TexRow & texrow,
|
|
|
|
|
pos_type const i,
|
2003-01-08 09:03:32 +00:00
|
|
|
|
unsigned int & column,
|
|
|
|
|
LyXFont const & font,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
LyXLayout const & style);
|
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void simpleTeXSpecialChars(Buffer const &, BufferParams const &,
|
2006-10-21 00:16:43 +00:00
|
|
|
|
odocstream &, TexRow & texrow,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
LyXFont & font, LyXFont & running_font,
|
2003-04-15 00:49:11 +00:00
|
|
|
|
LyXFont & basefont,
|
|
|
|
|
LyXFont const & outerfont,
|
|
|
|
|
bool & open_font,
|
2003-02-08 19:18:01 +00:00
|
|
|
|
Change::Type & running_change,
|
2001-06-25 00:06:33 +00:00
|
|
|
|
LyXLayout const & style,
|
2006-10-21 00:16:43 +00:00
|
|
|
|
pos_type & i,
|
2003-01-08 09:03:32 +00:00
|
|
|
|
unsigned int & column, value_type const c);
|
2002-07-20 16:42:15 +00:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
void validate(LaTeXFeatures & features,
|
|
|
|
|
LyXLayout const & layout) const;
|
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
unsigned int id_;
|
|
|
|
|
///
|
|
|
|
|
static unsigned int paragraph_id;
|
|
|
|
|
///
|
|
|
|
|
ParagraphParameters params;
|
2002-08-12 20:24:10 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
private:
|
2003-09-16 14:08:05 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
pos_type size() const { return owner_->size(); }
|
2001-11-23 09:59:01 +00:00
|
|
|
|
/// match a string against a particular point in the paragraph
|
2006-10-21 00:16:43 +00:00
|
|
|
|
bool isTextAt(std::string const & str, pos_type pos) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-10-21 12:20:39 +00:00
|
|
|
|
/// for recording and looking up changes
|
|
|
|
|
Changes changes_;
|
2003-03-03 21:15:49 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/// Who owns us?
|
|
|
|
|
Paragraph * owner_;
|
|
|
|
|
};
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#endif
|