]> git.lyx.org Git - lyx.git/blobdiff - src/Paragraph.h
Sanitize cursors after a buffer has been reloaded
[lyx.git] / src / Paragraph.h
index 297bff3847bcd7aa12d4c5ab8d27a8ae5d627a7a..ef94352f37a356c48177045f74f0e34aa9daaa5a 100644 (file)
 #ifndef PARAGRAPH_H
 #define PARAGRAPH_H
 
-#include "FontEnums.h"
 #include "LayoutEnums.h"
 #include "SpellChecker.h"
 
 #include "support/strfwd.h"
 #include "support/types.h"
 
+#include "insets/InsetCode.h"
+#include "insets/InsetLayout.h"
+
 #include <set>
+#include <vector>
 
 namespace lyx {
 
@@ -31,28 +34,26 @@ class AuthorList;
 class Buffer;
 class BufferParams;
 class Change;
-class Counters;
 class Cursor;
-class CursorSlice;
 class DocIterator;
 class docstring_list;
 class DocumentClass;
 class Inset;
-class InsetBibitem;
 class LaTeXFeatures;
 class InsetList;
 class Language;
 class Layout;
 class Font;
-class MetricsInfo;
 class OutputParams;
-class PainterInfo;
 class ParagraphParameters;
 class TocBackend;
 class WordLangTuple;
-class XHTMLStream;
+class XMLStream;
 class otexstream;
 
+/// Inset identifier (above 0x10ffff, for ucs-4)
+char_type const META_INSET = 0x200001;
+
 class FontSpan {
 public:
        /// Invalid font span containing no character
@@ -126,7 +127,8 @@ enum AsStringParameter
        AS_STR_INSETS = 2, ///< Go into insets.
        AS_STR_NEWLINES = 4, ///< Get also newline characters.
        AS_STR_SKIPDELETE = 8, ///< Skip deleted text in change tracking.
-       AS_STR_PLAINTEXT = 16 ///< Don't export formatting when descending into insets.
+       AS_STR_PLAINTEXT = 16, ///< Don't export formatting when descending into insets.
+       AS_STR_MATHED = 32 ///< Use a format suitable for mathed (eg. for InsetRef).
 };
 
 
@@ -196,30 +198,33 @@ public:
        /// Can we drop the standard paragraph wrapper?
        bool emptyTag() const;
 
-       /// Get the id of the paragraph, usefull for docbook
+       /// Get the id of the paragraph, useful for DocBook
        std::string getID(Buffer const & buf, OutputParams const & runparams) const;
 
        /// Output the first word of a paragraph, return the position where it left.
-       pos_type firstWordDocBook(odocstream & os, OutputParams const & runparams) const;
+       pos_type firstWordDocBook(XMLStream & xs, OutputParams const & runparams) const;
 
        /// Output the first word of a paragraph, return the position where it left.
-       pos_type firstWordLyXHTML(XHTMLStream & xs, OutputParams const & runparams) const;
-
-       /// Writes to stream the docbook representation
-       void simpleDocBookOnePar(Buffer const & buf,
-                                odocstream &,
-                                OutputParams const & runparams,
-                                Font const & outerfont,
-                                pos_type initial = 0) const;
+       pos_type firstWordLyXHTML(XMLStream & xs, OutputParams const & runparams) const;
+
+       /// Outputs to stream the DocBook representation, one element per paragraph.
+       std::tuple<std::vector<docstring>, std::vector<docstring>, std::vector<docstring>>
+       simpleDocBookOnePar(Buffer const & buf,
+                                                                          OutputParams const & runparams,
+                                                                          Font const & outerfont,
+                                                                          pos_type initial = 0,
+                                                                          bool is_last_par = false,
+                                                                          bool ignore_fonts = false) const;
+
        /// \return any material that has had to be deferred until after the
        /// paragraph has closed.
        docstring simpleLyXHTMLOnePar(Buffer const & buf,
-                                XHTMLStream & xs,
-                                OutputParams const & runparams,
-                                Font const & outerfont,
-                                bool start_paragraph = true,
-                                bool close_paragraph = true,
-                                pos_type initial = 0) const;
+                                                                 XMLStream & xs,
+                                                                 OutputParams const & runparams,
+                                                                 Font const & outerfont,
+                                                                 bool start_paragraph = true,
+                                                                 bool close_paragraph = true,
+                                                                 pos_type initial = 0) const;
 
        ///
        bool hasSameLayout(Paragraph const & par) const;
@@ -238,6 +243,12 @@ public:
        ///
        bool isPassThru() const;
        ///
+       bool parbreakIsNewline() const;
+       ///
+       bool allowedInContext(Cursor const & cur, InsetLayout const & il) const;
+       ///
+       bool isPartOfTextSequence() const;
+       ///
        pos_type size() const;
        ///
        bool empty() const;
@@ -262,6 +273,8 @@ public:
        /// is there a change within the given range (does not
        /// check contained paragraphs)
        bool isChanged(pos_type start, pos_type end) const;
+       /// Are there insets containing changes in the range?
+       bool hasChangedInsets(pos_type start, pos_type end) const;
        /// is there an unchanged char at the given pos ?
        bool isChanged(pos_type pos) const;
        /// is there a change in the paragraph ?
@@ -304,8 +317,6 @@ public:
        ///
        docstring expandLabel(Layout const &, BufferParams const &) const;
        ///
-       docstring expandDocBookLabel(Layout const &, BufferParams const &) const;
-       ///
        docstring const & labelString() const;
        /// the next two functions are for the manual labels
        docstring const getLabelWidthString() const;
@@ -339,12 +350,8 @@ public:
        ///
        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 FONT_INHERIT, FONT_IGNORE or
-           FONT_TOGGLE.
+       /** Get fully instantiated font, i.e., one that does not have any
+           attributes with values FONT_INHERIT, FONT_IGNORE or FONT_TOGGLE.
        */
        Font const getFont(BufferParams const &, pos_type pos,
                              Font const & outerfont) const;
@@ -527,6 +534,9 @@ private:
        void collectWords();
        ///
        void registerWords();
+       ///
+       int getInsetPos(InsetCode const code, int startpos,
+                       bool ignore_deleted=false) const;
 
        /// Pimpl away stuff
        class Private;