]> git.lyx.org Git - features.git/blobdiff - src/paragraph.h
parlist-22-a.diff
[features.git] / src / paragraph.h
index 7ffac04de6c137a66dfae74b1d1639f94f643b4d..5abcaf4d78324cabf8c451763d6b3b8de4d84d00 100644 (file)
 #include "support/types.h"
 #include "changes.h"
 
+#include "ParagraphList.h"
 #include "LString.h"
 
+#include <boost/optional.hpp>
+
 class BufferParams;
 class BufferView;
 class Counters;
 class InsetBibitem;
 class Language;
 class LaTeXFeatures;
+class LatexRunParams;
 class ParagraphParameters;
 class TexRow;
 
 // Define this if you want to try out the new storage container for
 // paragraphs. (Lgb)
 // This is non working and far from finished.
-// #define NO_NEXT 1
+#define NO_STD_LIST 1
 
 /// A Paragraph holds all text, attributes and insets in a text paragraph
 class Paragraph  {
 public:
+#ifdef NO_STD_LIST
+       // Remove this whan ParagraphList transition is over. (Lgb)
+       friend class ParagraphList;
+       friend class ParagraphList::iterator;
+#endif
        ///
        enum META_KIND {
-               ///
-               META_NEWLINE = 2,
-               ///
-               META_INSET
+               /// 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.
+               META_INSET = 1
        };
        ///
        typedef char value_type;
@@ -51,13 +62,11 @@ public:
 
        ///
        Paragraph();
-#ifndef NO_NEXT
-       /// this constructor inserts the new paragraph in a list
-       explicit
-       Paragraph(Paragraph * par);
-#endif
+
        ///
-       Paragraph(Paragraph const &, bool same_ids);
+       Paragraph(Paragraph const &);
+       ///
+       //void operator=(Paragraph const &);
        /// the destructor removes the new paragraph from the list
        ~Paragraph();
 
@@ -85,8 +94,8 @@ public:
 
        /// return the unique ID of this paragraph
        int id() const;
-       ///
-       void read();
+       /// Set the Id of this paragraph.
+       void id(int);
 
        ///
        int startTeXParParams(BufferParams const &, std::ostream &, bool) const;
@@ -97,20 +106,15 @@ public:
 
        ///
        bool simpleTeXOnePar(Buffer const *, BufferParams const &,
-                            std::ostream &, TexRow & texrow, bool moving_arg);
+                            LyXFont const & outerfont, std::ostream &,
+                            TexRow & texrow, LatexRunParams const &);
 
        ///
-       bool hasSameLayout(Paragraph const * par) const;
+       bool hasSameLayout(Paragraph const & par) const;
 
        ///
-       void makeSameLayout(Paragraph const * par);
+       void makeSameLayout(Paragraph const & par);
 
-       /// Is it the first par with same depth and layout?
-       bool isFirstInSequence() const;
-
-       /** Check if the current paragraph is the last paragraph in a
-           proof environment */
-       int getEndLabel() const;
        ///
        Inset * inInset() const;
        ///
@@ -125,7 +129,7 @@ public:
        ///
        bool empty() const;
        ///
-       void setContentsFromPar(Paragraph * par);
+       void setContentsFromPar(Paragraph const & par);
        ///
        void clearContents();
 
@@ -143,23 +147,6 @@ public:
        ///
        InsetBibitem * bibitem();  // ale970302
 
-#ifndef NO_NEXT
-       ///
-       void next(Paragraph *);
-       /** these function are able to hide closed footnotes
-        */
-       Paragraph * next();
-       ///
-       Paragraph const * next() const;
-
-       ///
-       void previous(Paragraph *);
-       ///
-       Paragraph * previous();
-       ///
-       Paragraph const * previous() const;
-#endif
-
        /// initialise tracking for this par
        void trackChanges(Change::Type = Change::UNCHANGED);
 
@@ -193,15 +180,6 @@ public:
        /// mark whole par as erased
        void markErased();
 
-       /// for the environments
-       Paragraph * depthHook(depth_type depth);
-       /// for the environments
-       Paragraph const * depthHook(depth_type depth) const;
-       ///
-       Paragraph * outerHook();
-       ///
-       Paragraph const * outerHook() const;
-
        /// 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
@@ -227,9 +205,9 @@ public:
        /// definite erase
        void eraseIntern(lyx::pos_type pos);
        /// erase the char at the given position
-       void erase(lyx::pos_type pos);
-       /// erase the given range. Returns true if actually erased.
-       bool erase(lyx::pos_type start, lyx::pos_type end);
+       bool erase(lyx::pos_type pos);
+       /// erase the given range. Returns the number of chars actually erased
+       int erase(lyx::pos_type start, lyx::pos_type end);
 
        /** Get uninstantiated font setting. Returns the difference
            between the characters font and the layoutfont.
@@ -247,9 +225,12 @@ public:
            attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
            LyXFont::TOGGLE.
        */
-       LyXFont const getFont(BufferParams const &, lyx::pos_type pos) const;
-       LyXFont const getLayoutFont(BufferParams const &) const;
-       LyXFont const getLabelFont(BufferParams const &) const;
+       LyXFont const getFont(BufferParams const &, lyx::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;
        ///
        value_type getChar(lyx::pos_type pos) const;
        ///
@@ -322,22 +303,26 @@ public:
        InsetList insetlist;
        ///
        //Counters & counters();
+       ///
+       void owningBuffer(Buffer const & b) {
+               buffer_.reset(&b);
+       }
 private:
        ///
        LyXLayout_ptr layout_;
-       /// if anything uses this we don't want it to.
-       Paragraph(Paragraph const &);
-#ifndef NO_NEXT
-       ///
-       Paragraph * next_;
-       ///
-       Paragraph * previous_;
+#ifdef NO_STD_LIST
+       Paragraph * next_par_;
+       Paragraph * prev_par_;
 #endif
+       ///
+       boost::optional<Buffer const *> buffer_;
+
        struct Pimpl;
        ///
        friend struct Paragraph::Pimpl;
        ///
        Pimpl * pimpl_;
+
 };
 
 
@@ -352,4 +337,6 @@ inline bool isDeletedText(Paragraph const & par, lyx::pos_type pos)
        return par.lookupChange(pos) == Change::DELETED;
 }
 
+bool operator==(Paragraph const & lhs, Paragraph const & rhs);
+
 #endif // PARAGRAPH_H