2001-06-25 00:06:33 +00:00
|
|
|
// -*- C++ -*-
|
2002-06-10 21:04:06 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
* \file Paragraph.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 Asger Alstrup
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author John Levon
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
|
|
|
* \author Jürgen Vigna
|
2003-08-23 00:17:00 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
2007-10-28 18:51:54 +00:00
|
|
|
#include "FontEnums.h"
|
2017-01-24 18:33:03 +00:00
|
|
|
#include "LayoutEnums.h"
|
2010-08-05 20:10:40 +00:00
|
|
|
#include "SpellChecker.h"
|
2002-08-07 16:31:45 +00:00
|
|
|
|
2007-10-31 22:40:34 +00:00
|
|
|
#include "support/strfwd.h"
|
|
|
|
#include "support/types.h"
|
2002-08-07 16:31:45 +00:00
|
|
|
|
2010-02-08 17:15:00 +00:00
|
|
|
#include <set>
|
|
|
|
|
2007-10-18 15:29:51 +00:00
|
|
|
namespace lyx {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2007-10-18 15:29:51 +00:00
|
|
|
class AuthorList;
|
2003-05-28 06:47:15 +00:00
|
|
|
class Buffer;
|
2001-06-25 00:06:33 +00:00
|
|
|
class BufferParams;
|
2007-10-18 15:29:51 +00:00
|
|
|
class Change;
|
2002-08-07 16:31:45 +00:00
|
|
|
class Counters;
|
2008-02-26 13:07:59 +00:00
|
|
|
class Cursor;
|
|
|
|
class CursorSlice;
|
2008-09-30 11:06:34 +00:00
|
|
|
class DocIterator;
|
2009-06-22 16:38:11 +00:00
|
|
|
class docstring_list;
|
2008-02-28 07:18:54 +00:00
|
|
|
class DocumentClass;
|
2007-04-29 13:39:47 +00:00
|
|
|
class Inset;
|
2003-02-21 09:20:18 +00:00
|
|
|
class InsetBibitem;
|
2004-11-30 01:59:49 +00:00
|
|
|
class LaTeXFeatures;
|
2007-10-18 15:29:51 +00:00
|
|
|
class InsetList;
|
2001-06-25 00:06:33 +00:00
|
|
|
class Language;
|
2010-01-21 18:49:08 +00:00
|
|
|
class Layout;
|
2007-04-29 18:17:15 +00:00
|
|
|
class Font;
|
2004-11-30 01:59:49 +00:00
|
|
|
class MetricsInfo;
|
|
|
|
class OutputParams;
|
|
|
|
class PainterInfo;
|
2002-08-07 16:31:45 +00:00
|
|
|
class ParagraphParameters;
|
2017-01-13 10:06:48 +00:00
|
|
|
class TocBackend;
|
2009-06-22 16:38:11 +00:00
|
|
|
class WordLangTuple;
|
2009-11-19 18:24:19 +00:00
|
|
|
class XHTMLStream;
|
Introduce a wrapper class for odocstream to help ensuring that no
blank lines may be inadvertently output. This is achieved by using two
special iomanip-like variables (breakln and safebreakln) in the lyx::
namespace. When they are inserted in the stream, a newline is output
only if not already at the beginning of a line. The difference between
breakln and safebreakln is that, if needed, the former outputs '\n'
and the latter "%\n".
In future, the new class will also be used for counting the number of
newlines issued. Even if the infractrure for doing that is already in
place, the counting is essentially still done the old way.
There are still places in the code where the functionality of the
class could be used, most probably. ATM, it is used for InsetTabular,
InsetListings, InsetFloat, and InsetText.
The Comment and GreyedOut insets required a special treatment and a
new InsetLayout parameter (Display) has been introduced. The default
for Display is "true", meaning that the corresponding latex
environment is of "display" type, i.e., it stands on its own, whereas
"false" means that the contents appear inline with the text. The
latter is the case for both Comment and GreyedOut insets.
Mostly, the only visible effects on latex exports should be the
disappearing of some redundant % chars and the appearing/disappearing
of null {} latex groups after a comment or lyxgreyedout environments
(they are related to the presence or absence of a space immediately
after those environments), as well as the fact that math environments
are now started on their own lines.
As a last thing, only the latex code between \begin{document} and
\end{document} goes through the new class, the preamble being directly
output through odocstream, as usual.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
|
|
|
class otexstream;
|
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
|
2006-10-21 00:16:43 +00:00
|
|
|
FontSpan(pos_type f, pos_type l) : first(f), last(l) {}
|
2005-07-18 14:25:20 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/// Range including first and last.
|
2006-10-21 00:16:43 +00:00
|
|
|
pos_type first, last;
|
2010-09-14 05:24:04 +00:00
|
|
|
|
|
|
|
inline bool operator<(FontSpan const & s) const
|
|
|
|
{
|
|
|
|
return first < s.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator==(FontSpan const & s) const
|
|
|
|
{
|
|
|
|
return first == s.first && last == s.last;
|
|
|
|
}
|
2011-02-03 17:27:13 +00:00
|
|
|
|
2014-07-28 18:41:01 +00:00
|
|
|
inline bool contains(pos_type p) const
|
2010-09-14 12:48:03 +00:00
|
|
|
{
|
|
|
|
return first <= p && p <= last;
|
|
|
|
}
|
|
|
|
|
2011-02-03 17:27:13 +00:00
|
|
|
inline size_t size() const
|
|
|
|
{
|
|
|
|
return empty() ? 0 : last - first;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline FontSpan intersect(FontSpan const & f) const
|
|
|
|
{
|
|
|
|
FontSpan result = FontSpan();
|
2014-07-28 18:41:01 +00:00
|
|
|
if (contains(f.first))
|
2011-02-03 17:27:13 +00:00
|
|
|
result.first = f.first;
|
2014-07-28 18:41:01 +00:00
|
|
|
else if (f.contains(first))
|
2011-02-03 17:27:13 +00:00
|
|
|
result.first = first;
|
|
|
|
else
|
|
|
|
return result;
|
2014-07-28 18:41:01 +00:00
|
|
|
if (contains(f.last))
|
2011-02-03 17:27:13 +00:00
|
|
|
result.last = f.last;
|
2014-07-28 18:41:01 +00:00
|
|
|
else if (f.contains(last))
|
2011-02-03 17:27:13 +00:00
|
|
|
result.last = last;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-01-07 15:20:58 +00:00
|
|
|
inline bool empty() const
|
|
|
|
{
|
|
|
|
return first > last;
|
|
|
|
}
|
2005-07-18 12:13:32 +00:00
|
|
|
};
|
|
|
|
|
2007-10-24 07:49:24 +00:00
|
|
|
///
|
|
|
|
enum TextCase {
|
|
|
|
///
|
|
|
|
text_lowercase = 0,
|
|
|
|
///
|
|
|
|
text_capitalization = 1,
|
|
|
|
///
|
|
|
|
text_uppercase = 2
|
|
|
|
};
|
|
|
|
|
2006-04-05 23:56:29 +00:00
|
|
|
|
2008-05-22 14:01:33 +00:00
|
|
|
///
|
|
|
|
enum AsStringParameter
|
|
|
|
{
|
|
|
|
AS_STR_NONE = 0, ///< No option, only printable characters.
|
|
|
|
AS_STR_LABEL = 1, ///< Prefix with paragraph label.
|
2008-10-19 20:55:54 +00:00
|
|
|
AS_STR_INSETS = 2, ///< Go into insets.
|
2010-09-29 19:31:16 +00:00
|
|
|
AS_STR_NEWLINES = 4, ///< Get also newline characters.
|
2014-03-27 23:12:56 +00:00
|
|
|
AS_STR_SKIPDELETE = 8, ///< Skip deleted text in change tracking.
|
|
|
|
AS_STR_PLAINTEXT = 16 ///< Don't export formatting when descending into insets.
|
2008-05-22 14:01:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
/// A Paragraph holds all text, attributes and insets in a text paragraph
|
2007-10-24 15:32:43 +00:00
|
|
|
class Paragraph
|
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
public:
|
|
|
|
///
|
|
|
|
Paragraph();
|
2010-01-05 13:16:55 +00:00
|
|
|
/// Copy constructor.
|
2003-05-25 08:49:48 +00:00
|
|
|
Paragraph(Paragraph const &);
|
2008-07-30 09:07:32 +00:00
|
|
|
/// Partial copy constructor.
|
|
|
|
/// Copy the Paragraph contents from \p beg to \p end (without end).
|
|
|
|
Paragraph(Paragraph const & par, pos_type beg, pos_type end);
|
2003-05-25 08:49:48 +00:00
|
|
|
///
|
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;
|
2010-01-05 13:16:55 +00:00
|
|
|
///
|
|
|
|
void setId(int id);
|
2003-10-14 13:01:49 +00:00
|
|
|
|
2008-09-30 11:06:34 +00:00
|
|
|
///
|
2013-03-08 21:18:26 +00:00
|
|
|
void addChangesToToc(DocIterator const & cdit, Buffer const & buf,
|
2017-01-13 10:06:48 +00:00
|
|
|
bool output_active, TocBackend & backend) const;
|
2016-01-30 23:14:36 +00:00
|
|
|
/// set the buffer flag if there are changes in the paragraph
|
|
|
|
void addChangesToBuffer(Buffer const & buf) const;
|
|
|
|
///
|
|
|
|
bool isChangeUpdateRequired() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
|
|
|
Language const * getParLanguage(BufferParams const &) const;
|
|
|
|
///
|
2007-09-04 10:27:55 +00:00
|
|
|
bool isRTL(BufferParams const &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
|
|
|
void changeLanguage(BufferParams const & bparams,
|
|
|
|
Language const * from, Language const * to);
|
|
|
|
///
|
2004-02-25 12:00:53 +00:00
|
|
|
bool isMultiLingual(BufferParams const &) const;
|
2010-02-08 17:15:00 +00:00
|
|
|
///
|
|
|
|
void getLanguages(std::set<Language const *> &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
/// Convert the paragraph to a string.
|
2008-05-22 14:01:33 +00:00
|
|
|
/// \param AsStringParameter options. This can contain any combination of
|
|
|
|
/// asStringParameter values. Valid examples:
|
|
|
|
/// asString(AS_STR_LABEL)
|
|
|
|
/// asString(AS_STR_LABEL | AS_STR_INSETS)
|
|
|
|
/// asString(AS_STR_INSETS)
|
|
|
|
docstring asString(int options = AS_STR_NONE) const;
|
2014-03-27 23:12:56 +00:00
|
|
|
|
|
|
|
/// Convert the paragraph to a string.
|
|
|
|
/// \note If options includes AS_STR_PLAINTEXT, then runparams must be != 0
|
2008-05-22 14:01:33 +00:00
|
|
|
docstring asString(pos_type beg, pos_type end,
|
2014-03-27 23:12:56 +00:00
|
|
|
int options = AS_STR_NONE,
|
|
|
|
const OutputParams *runparams = 0) const;
|
2010-12-20 21:55:09 +00:00
|
|
|
///
|
2017-01-08 20:57:02 +00:00
|
|
|
void forOutliner(docstring &, size_t maxlen, bool shorten = true,
|
|
|
|
bool label = true) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void write(std::ostream &, BufferParams const &,
|
2013-03-12 16:45:15 +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
|
|
|
|
2010-06-15 15:37:39 +00:00
|
|
|
/// \param force means: output even if layout.inpreamble is true.
|
Introduce a wrapper class for odocstream to help ensuring that no
blank lines may be inadvertently output. This is achieved by using two
special iomanip-like variables (breakln and safebreakln) in the lyx::
namespace. When they are inserted in the stream, a newline is output
only if not already at the beginning of a line. The difference between
breakln and safebreakln is that, if needed, the former outputs '\n'
and the latter "%\n".
In future, the new class will also be used for counting the number of
newlines issued. Even if the infractrure for doing that is already in
place, the counting is essentially still done the old way.
There are still places in the code where the functionality of the
class could be used, most probably. ATM, it is used for InsetTabular,
InsetListings, InsetFloat, and InsetText.
The Comment and GreyedOut insets required a special treatment and a
new InsetLayout parameter (Display) has been introduced. The default
for Display is "true", meaning that the corresponding latex
environment is of "display" type, i.e., it stands on its own, whereas
"false" means that the contents appear inline with the text. The
latter is the case for both Comment and GreyedOut insets.
Mostly, the only visible effects on latex exports should be the
disappearing of some redundant % chars and the appearing/disappearing
of null {} latex groups after a comment or lyxgreyedout environments
(they are related to the presence or absence of a space immediately
after those environments), as well as the fact that math environments
are now started on their own lines.
As a last thing, only the latex code between \begin{document} and
\end{document} goes through the new class, the preamble being directly
output through odocstream, as usual.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
|
|
|
void latex(BufferParams const &, Font const & outerfont, otexstream &,
|
2013-03-12 16:45:15 +00:00
|
|
|
OutputParams const &, int start_pos = 0, int end_pos = -1,
|
|
|
|
bool force = false) 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
|
2008-02-27 20:43:16 +00:00
|
|
|
std::string getID(Buffer const & buf, OutputParams const & runparams) const;
|
2004-05-14 15:47:35 +00:00
|
|
|
|
2009-06-05 17:44:35 +00:00
|
|
|
/// Output the first word of a paragraph, return the position where it left.
|
|
|
|
pos_type firstWordDocBook(odocstream & os, OutputParams const & runparams) const;
|
|
|
|
|
|
|
|
/// Output the first word of a paragraph, return the position where it left.
|
2009-11-19 18:24:19 +00:00
|
|
|
pos_type firstWordLyXHTML(XHTMLStream & xs, OutputParams const & runparams) 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,
|
2009-06-05 17:44:35 +00:00
|
|
|
odocstream &,
|
|
|
|
OutputParams const & runparams,
|
|
|
|
Font const & outerfont,
|
|
|
|
pos_type initial = 0) const;
|
2009-06-12 17:23:17 +00:00
|
|
|
/// \return any material that has had to be deferred until after the
|
|
|
|
/// paragraph has closed.
|
|
|
|
docstring simpleLyXHTMLOnePar(Buffer const & buf,
|
2009-11-19 18:24:19 +00:00
|
|
|
XHTMLStream & xs,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const & runparams,
|
2007-04-29 18:17:15 +00:00
|
|
|
Font const & outerfont,
|
2016-07-10 03:12:32 +00:00
|
|
|
bool start_paragraph = true,
|
|
|
|
bool close_paragraph = true,
|
2006-10-21 00:16:43 +00:00
|
|
|
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
|
|
|
///
|
2008-09-13 17:01:54 +00:00
|
|
|
void setInsetOwner(Inset const * inset);
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2008-09-13 17:01:54 +00:00
|
|
|
Inset const & inInset() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
Fix bug 4037 and related problems. The patch has been cleaned up a bit
from the one posted to the list.
The basic idea has two parts. First, we hard code an "empty layout"
(called PlainLayout, for want of a better name) in TextClass and read it
before doing anything else. It can therefore be customized by classes,
if they want---say, to make it left-aligned. Second, InsetText's are
divided into three types: (i) normal ones, that use the "default" layout
defined by the text class; (ii) highly restrictive ones, such as ERT and
(not quite an inset) table cells, which demand the empty layout; (iii)
middling ones, which default to an empty layout and use the empty layout
in place of the default. (This is so we don't get the same problem we
had with ERT in e.g. footnotes.) The type of inset is signaled by new
methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout().
(The latter might better be called: useEmptyLayoutInsteadOfDefault(),
but that's silly.) The old InsetText::forceDefaultParagraphs() has been
split into these, plus a new method InsetText::allowParagraphCustomization().
A lot of the changes just adapt to this change.
The other big change is in GuiToolbar: We want to show LyXDefault and
the "default" layout only when they're active.
There are a handful of places where I'm not entirely sure whether we
should be using forceEmptyLayout or !allowParagraphCustomization() or
both. The InsetCaption is one of these. These places, and some others,
are marked with FIXMEs, so I'd appreciate it if people would search
through the patch and let me know whether these need changing. If they
don't, the FIXMEs can be deleted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
|
|
|
bool allowParagraphCustomization() const;
|
|
|
|
///
|
2008-07-10 17:41:52 +00:00
|
|
|
bool usePlainLayout() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2011-01-26 11:04:42 +00:00
|
|
|
bool isPassThru() const;
|
|
|
|
///
|
2007-10-24 07:08:55 +00:00
|
|
|
pos_type size() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2007-10-24 07:08:55 +00:00
|
|
|
bool empty() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
///
|
2008-03-06 21:31:27 +00:00
|
|
|
Layout const & layout() const;
|
2008-03-08 03:00:13 +00:00
|
|
|
/// Do not pass a temporary to this!
|
2008-03-06 21:31:27 +00:00
|
|
|
void setLayout(Layout const & layout);
|
2008-03-06 20:01:30 +00:00
|
|
|
///
|
2008-07-10 17:41:52 +00:00
|
|
|
void setPlainOrDefaultLayout(DocumentClass const & tc);
|
2008-10-28 14:11:24 +00:00
|
|
|
///
|
|
|
|
void setDefaultLayout(DocumentClass const & tc);
|
|
|
|
///
|
|
|
|
void setPlainLayout(DocumentClass const & tc);
|
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
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
/// look up change at given pos
|
2007-01-08 22:21:57 +00:00
|
|
|
Change const & lookupChange(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 ?
|
2006-10-21 00:16:43 +00:00
|
|
|
bool isChanged(pos_type start, pos_type end) const;
|
2006-10-23 16:04:51 +00:00
|
|
|
/// is there an unchanged char at the given pos ?
|
2009-08-04 22:44:23 +00:00
|
|
|
bool isChanged(pos_type pos) const;
|
2006-10-22 17:02:23 +00:00
|
|
|
/// is there an insertion at the given pos ?
|
2007-10-18 15:29:51 +00:00
|
|
|
bool isInserted(pos_type pos) const;
|
2006-10-19 12:49:11 +00:00
|
|
|
/// is there a deletion at the given pos ?
|
2007-10-18 15:29:51 +00:00
|
|
|
bool isDeleted(pos_type pos) const;
|
2009-05-14 22:21:05 +00:00
|
|
|
/// is the whole paragraph deleted ?
|
2009-08-04 22:50:36 +00:00
|
|
|
bool isDeleted(pos_type start, pos_type end) const;
|
2003-03-03 21:15:49 +00:00
|
|
|
|
2006-11-24 21:16:46 +00:00
|
|
|
/// will the paragraph be physically merged with the next
|
|
|
|
/// one if the imaginary end-of-par character is logically deleted?
|
|
|
|
bool isMergedOnEndOfParDeletion(bool trackChanges) 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-03-04 19:52:35 +00:00
|
|
|
|
2006-10-24 06:11:45 +00:00
|
|
|
/// accept changes within the given range
|
2009-07-16 08:37:32 +00:00
|
|
|
void acceptChanges(pos_type start, pos_type end);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
2006-10-24 21:38:47 +00:00
|
|
|
/// reject changes within the given range
|
2009-07-16 08:37:32 +00:00
|
|
|
void rejectChanges(pos_type start, 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.
|
2006-10-21 00:16:43 +00:00
|
|
|
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
|
|
|
|
2010-01-21 18:46:20 +00:00
|
|
|
///
|
|
|
|
docstring expandLabel(Layout const &, BufferParams const &) const;
|
|
|
|
///
|
|
|
|
docstring expandDocBookLabel(Layout const &, BufferParams const &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2008-02-23 16:45:38 +00:00
|
|
|
docstring const & labelString() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
/// the next two functions are for the manual labels
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring const getLabelWidthString() const;
|
2007-01-15 16:58:14 +00:00
|
|
|
/// Set label width string.
|
2006-10-21 00:16:43 +00:00
|
|
|
void setLabelWidthString(docstring const & s);
|
2006-12-17 10:11:28 +00:00
|
|
|
/// Actual paragraph alignment used
|
2017-01-24 18:33:03 +00:00
|
|
|
LyXAlignment 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
|
|
|
///
|
2008-03-06 20:01:30 +00:00
|
|
|
void applyLayout(Layout const & new_layout);
|
2003-03-03 21:15:49 +00:00
|
|
|
|
2006-10-22 14:36:08 +00:00
|
|
|
/// (logically) erase the char at pos; return true if it was actually erased
|
2006-10-21 17:05:20 +00:00
|
|
|
bool eraseChar(pos_type pos, bool trackChanges);
|
2006-10-22 14:36:08 +00:00
|
|
|
/// (logically) erase the given range; return the number of chars actually erased
|
|
|
|
int eraseChars(pos_type start, pos_type end, bool trackChanges);
|
2003-03-03 21:15:49 +00:00
|
|
|
|
2007-10-28 18:51:54 +00:00
|
|
|
///
|
|
|
|
void resetFonts(Font const & font);
|
|
|
|
|
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
|
|
|
|
*/
|
2008-10-19 07:03:44 +00:00
|
|
|
Font const &
|
2006-10-21 00:16:43 +00:00
|
|
|
getFontSettings(BufferParams const &, pos_type pos) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2008-10-19 07:03:44 +00:00
|
|
|
Font 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
|
2007-10-28 18:51:54 +00:00
|
|
|
attributes with values FONT_INHERIT, FONT_IGNORE or
|
|
|
|
FONT_TOGGLE.
|
2001-06-25 00:06:33 +00:00
|
|
|
*/
|
2007-04-29 18:17:15 +00:00
|
|
|
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;
|
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
|
2006-12-28 16:19:22 +00:00
|
|
|
* the same. This can be used to avoid unnecessary calls to getFont.
|
2003-07-27 10:42:11 +00:00
|
|
|
*/
|
2006-10-21 00:16:43 +00:00
|
|
|
FontSpan fontSpan(pos_type pos) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2007-10-24 07:08:55 +00:00
|
|
|
char_type getChar(pos_type pos) const;
|
2005-01-31 16:29:48 +00:00
|
|
|
/// Get the char, but mirror all bracket characters if it is right-to-left
|
2007-10-24 07:08:55 +00:00
|
|
|
char_type getUChar(BufferParams const &, pos_type pos) const;
|
2002-05-30 03:37:24 +00:00
|
|
|
/// pos <= size() (there is a dummy font change at the end of each par)
|
2007-04-29 18:17:15 +00:00
|
|
|
void setFont(pos_type pos, Font const & font);
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
void insert(pos_type pos, docstring const & str,
|
2007-05-28 22:27:45 +00:00
|
|
|
Font const & font, Change const & change);
|
2007-10-22 13:09:16 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
void appendString(docstring const & s, Font const & font,
|
|
|
|
Change const & change);
|
|
|
|
///
|
2007-10-24 07:08:55 +00:00
|
|
|
void appendChar(char_type c, Font const & font, Change const & change);
|
2003-11-04 12:01:15 +00:00
|
|
|
///
|
2007-10-24 07:08:55 +00:00
|
|
|
void insertChar(pos_type pos, char_type c, bool trackChanges);
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2007-10-24 07:08:55 +00:00
|
|
|
void insertChar(pos_type pos, char_type c,
|
2007-05-28 22:27:45 +00:00
|
|
|
Font const &, bool trackChanges);
|
2006-10-20 11:44:58 +00:00
|
|
|
///
|
2007-10-24 07:08:55 +00:00
|
|
|
void insertChar(pos_type pos, char_type c,
|
2007-05-28 22:27:45 +00:00
|
|
|
Font const &, Change const & change);
|
2008-10-08 14:03:15 +00:00
|
|
|
/// Insert \p inset at position \p pos with \p change traking status and
|
|
|
|
/// \p font.
|
|
|
|
/// \return true if successful.
|
|
|
|
bool insertInset(pos_type pos, Inset * inset,
|
|
|
|
Font const & font, Change const & change);
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2007-10-18 15:29:51 +00:00
|
|
|
Inset * getInset(pos_type pos);
|
2005-01-31 16:29:48 +00:00
|
|
|
///
|
2007-10-18 15:29:51 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
///
|
|
|
|
InsetList const & insetList() const;
|
2008-07-23 12:49:22 +00:00
|
|
|
///
|
|
|
|
void setBuffer(Buffer &);
|
2016-12-05 13:47:13 +00:00
|
|
|
///
|
|
|
|
void resetBuffer();
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
///
|
2007-10-13 09:48:18 +00:00
|
|
|
bool isHfill(pos_type pos) const;
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
/// hinted by profiler
|
2007-10-24 07:08:55 +00:00
|
|
|
bool isInset(pos_type pos) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
bool isNewline(pos_type pos) const;
|
Fix bugs #8546 and #9055, and introduce new separator inset.
The algorithm used for breaking a paragraph in LaTeX export is changed
for avoiding spurious blank lines causing too much vertical space.
This change is tied to the introduction of a new inset (with two
different specializations) helping in either outputing LaTeX paragraph
breaks or separating environments in LyX. Both of the above goals were
previously achieved by the ---Separator--- layout and can now be
accomplished by the new inset in a more natural way. As an example,
after leaving an environment by hitting the Return key for two times,
a third return automatically inserts a parbreak inset, which is
equivalent to the old separator layout, i.e., it also introduces a
blank line in the output. If this blank line is not wanted, the
parbreak separator can be changed to a plain separator by a right
click of the mouse. Of course, an environment can still be separated
by the following one by using the Alt+P+Return shortcut (or the
corresponding menu key), but now the plain separator inset is used
instead of the old separator layout, such that no blank line occurs in
the LaTeX output.
Old documents are converted such that the LaTeX output remains unchanged.
As a result of this conversion, the old separator layout is replaced by
the new parbreak inset, which may also appear in places where the old
algorithm was introducing blank lines while the new one is not.
Note that not all blank lines were actually affecting the LaTeX output,
because a blank line is simply ignored by the TeX engine when it occurs
in the so called "vertical mode" (e.g., after an alignment environment).
The old ---Separator--- layout is now gone and old layout files using it
are also automatically converted.
Round trip conversions between old and new format should leave a document
unchanged. This means that the new behavior about paragraph breaking is
not "carried back" to the old format. Indeed, this would need introducing
special LaTeX commands in ERT that would accumulate in roundtrip
conversions, horribly cluttering the document. So, when converting a
modified document to old formats, the LaTeX output may slightly differ in
vertical spacing if the document is processed by an old version of LyX.
In other words, forward compatibility is guaranteed, but not backwards.
2014-05-10 21:25:11 +00:00
|
|
|
///
|
|
|
|
bool isEnvSeparator(pos_type pos) const;
|
2005-07-18 12:57:08 +00:00
|
|
|
/// return true if the char is a word separator
|
2007-10-24 07:08:55 +00:00
|
|
|
bool isSeparator(pos_type pos) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
bool isLineSeparator(pos_type pos) const;
|
2009-06-21 14:30:57 +00:00
|
|
|
/// True if the character/inset at this point is a word separator.
|
|
|
|
/// Note that digits in particular are not considered as word separator.
|
|
|
|
bool isWordSeparator(pos_type pos) const;
|
2008-06-24 09:19:52 +00:00
|
|
|
/// True if the element at this point is a character that is not a letter.
|
|
|
|
bool isChar(pos_type pos) const;
|
2008-07-01 14:42:32 +00:00
|
|
|
/// True if the element at this point is a space
|
|
|
|
bool isSpace(pos_type pos) const;
|
2011-04-08 13:20:26 +00:00
|
|
|
/// True if the element at this point is a hard hyphen or a apostrophe
|
|
|
|
/// If it is enclosed by spaces return false
|
|
|
|
bool isHardHyphenOrApostrophe(pos_type pos) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2007-05-28 22:27:45 +00:00
|
|
|
/// returns true if at least one line break or line separator has been deleted
|
2007-01-21 21:11:27 +00:00
|
|
|
/// at the beginning of the paragraph (either physically or logically)
|
|
|
|
bool stripLeadingSpaces(bool trackChanges);
|
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
|
|
|
///
|
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;
|
2006-04-05 23:56:29 +00:00
|
|
|
|
2012-07-17 21:59:04 +00:00
|
|
|
/// Check whether a call to fixBiblio is needed.
|
|
|
|
bool brokenBiblio() const;
|
2007-05-19 19:29:50 +00:00
|
|
|
/// 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.
|
2012-07-17 21:59:04 +00:00
|
|
|
int fixBiblio(Buffer const & buffer);
|
2006-12-29 23:54:48 +00:00
|
|
|
|
2007-07-09 20:52:34 +00:00
|
|
|
/// For each author, set 'used' to true if there is a change
|
|
|
|
/// by this author in the paragraph.
|
|
|
|
void checkAuthors(AuthorList const & authorList);
|
|
|
|
|
2007-10-24 07:49:24 +00:00
|
|
|
///
|
|
|
|
void changeCase(BufferParams const & bparams, pos_type pos,
|
2008-01-28 10:50:24 +00:00
|
|
|
pos_type & right, TextCase action);
|
2007-10-24 07:49:24 +00:00
|
|
|
|
2007-10-24 08:22:26 +00:00
|
|
|
/// find \param str string inside Paragraph.
|
2010-11-22 07:50:34 +00:00
|
|
|
/// \return non-zero if the specified string is at the specified
|
|
|
|
/// position; returned value is the actual match length in positions
|
2007-10-24 08:22:26 +00:00
|
|
|
/// \param del specifies whether deleted strings in ct mode will be considered
|
2010-11-22 07:50:34 +00:00
|
|
|
int find(
|
2007-10-24 08:22:26 +00:00
|
|
|
docstring const & str, ///< string to search
|
|
|
|
bool cs, ///<
|
|
|
|
bool mw, ///<
|
|
|
|
pos_type pos, ///< start from here.
|
|
|
|
bool del = true) const;
|
2008-02-26 13:07:59 +00:00
|
|
|
|
2009-05-01 07:26:12 +00:00
|
|
|
void locateWord(pos_type & from, pos_type & to,
|
|
|
|
word_location const loc) const;
|
2008-02-26 13:07:59 +00:00
|
|
|
///
|
2009-05-01 09:56:20 +00:00
|
|
|
void updateWords();
|
2009-06-22 16:38:11 +00:00
|
|
|
|
2009-08-02 10:09:29 +00:00
|
|
|
/// Spellcheck word at position \p from and fill in found misspelled word
|
|
|
|
/// and \p suggestions if \p do_suggestion is true.
|
2010-08-05 20:10:40 +00:00
|
|
|
/// \return result from spell checker, SpellChecker::UNKNOWN_WORD when misspelled.
|
|
|
|
SpellChecker::Result spellCheck(pos_type & from, pos_type & to, WordLangTuple & wl,
|
2010-09-14 05:24:04 +00:00
|
|
|
docstring_list & suggestions, bool do_suggestion = true,
|
|
|
|
bool check_learned = false) const;
|
2009-06-22 16:38:11 +00:00
|
|
|
|
2010-09-14 05:24:04 +00:00
|
|
|
/// Spell checker status at position \p pos.
|
2011-01-29 12:28:02 +00:00
|
|
|
/// If \p check_boundary is true the status of position immediately
|
|
|
|
/// before \p pos is tested too if it is at word boundary.
|
|
|
|
/// \return true if one of the tested positions is misspelled.
|
|
|
|
bool isMisspelled(pos_type pos, bool check_boundary = false) const;
|
2010-09-14 05:24:04 +00:00
|
|
|
|
2015-07-14 21:45:41 +00:00
|
|
|
/// \return the spell range (misspelled area) around position.
|
|
|
|
/// Range is empty if word at position is correctly spelled.
|
|
|
|
FontSpan const & getSpellRange(pos_type pos) const;
|
2010-12-22 07:29:16 +00:00
|
|
|
|
2010-09-14 05:24:04 +00:00
|
|
|
/// spell check of whole paragraph
|
|
|
|
/// remember results until call of requestSpellCheck()
|
|
|
|
void spellCheck() const;
|
|
|
|
|
|
|
|
/// query state of spell checker results
|
|
|
|
bool needsSpellCheck() const;
|
|
|
|
/// mark position of text manipulation to inform the spell checker
|
|
|
|
/// default value -1 marks the whole paragraph to be checked (again)
|
|
|
|
void requestSpellCheck(pos_type pos = -1);
|
|
|
|
|
2009-12-10 20:03:35 +00:00
|
|
|
/// an automatically generated identifying label for this paragraph.
|
|
|
|
/// presently used only in the XHTML output routines.
|
|
|
|
std::string magicLabel() const;
|
2007-10-24 08:22:26 +00:00
|
|
|
|
2007-10-21 10:50:56 +00:00
|
|
|
private:
|
2010-01-21 18:46:20 +00:00
|
|
|
/// Expand the counters for the labelstring of \c layout
|
|
|
|
docstring expandParagraphLabel(Layout const &, BufferParams const &,
|
|
|
|
bool process_appendix) const;
|
2008-02-26 13:07:59 +00:00
|
|
|
///
|
|
|
|
void deregisterWords();
|
|
|
|
///
|
2009-05-01 09:56:20 +00:00
|
|
|
void collectWords();
|
2008-02-26 13:07:59 +00:00
|
|
|
///
|
|
|
|
void registerWords();
|
|
|
|
|
2005-07-18 12:57:08 +00:00
|
|
|
/// Pimpl away stuff
|
2007-10-19 08:57:22 +00:00
|
|
|
class Private;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2007-10-19 08:57:22 +00:00
|
|
|
friend class Paragraph::Private;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2007-10-19 08:57:22 +00:00
|
|
|
Private * d;
|
2001-06-25 00:06:33 +00:00
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
#endif // PARAGRAPH_H
|