X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fparagraph.h;h=0e23ea727ed91b076f213b70dece0718f56c2c2b;hb=52eb91c94fb70d58dceef430659c8781de2eccda;hp=5f302f4d869e8c8b0a78575468cca3298da3e87c;hpb=30f8a6327f0b8fcfa8cff36faa123c9a3b4c7669;p=lyx.git diff --git a/src/paragraph.h b/src/paragraph.h index 5f302f4d86..0e23ea727e 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -30,7 +30,6 @@ namespace lyx { class Buffer; class BufferParams; -class BufferView; class Counters; class InsetBase; class InsetBibitem; @@ -58,56 +57,11 @@ public: pos_type first, last; }; -/// Helper class for Paragraph Metrics. -/// \todo FIXME: this class deserves its own .[Ch] files. -/// Then, the storage of such object should be done in \c BufferView -/// (most probably in the \c CoordCache class along \c Point objects). -class ParagraphMetrics { -public: - ParagraphMetrics(); - ParagraphMetrics(ParagraphMetrics const & pm); - ParagraphMetrics & operator=(ParagraphMetrics const & pm); - /// - Row & getRow(pos_type pos, bool boundary); - /// - Row const & getRow(pos_type pos, bool boundary) const; - /// - size_t pos2row(pos_type pos) const; - - /// LyXText::redoParagraph updates this - Dimension & dim() { return dim_; } - /// total height of paragraph - unsigned int height() const { return dim_.height(); } - /// total width of paragraph, may differ from workwidth - unsigned int width() const { return dim_.width(); } - /// ascend of paragraph above baseline - unsigned int ascent() const { return dim_.ascent(); } - /// descend of paragraph below baseline - unsigned int descent() const { return dim_.descent(); } - /// LyXText updates the rows using this access point - RowList & rows() { return rows_; } - /// The painter and others use this - RowList const & rows() const { return rows_; } - /// - RowSignature & rowSignature() const { return rowSignature_; } - - /// dump some information to lyxerr - void dump() const; - -private: - /// - mutable RowList rows_; - /// - mutable RowSignature rowSignature_; - /// cached dimensions of paragraph - Dimension dim_; -}; - /// A Paragraph holds all text, attributes and insets in a text paragraph /// \todo FIXME: any reference to ParagraphMetrics (including inheritance) /// should go in order to complete the Model/View separation of this class. -class Paragraph: public ParagraphMetrics { +class Paragraph { public: /// enum { @@ -146,10 +100,6 @@ public: /// bool isMultiLingual(BufferParams const &) const; - /// - docstring const asString(Buffer const &, - OutputParams const & runparams, - bool label) const; /// docstring const asString(Buffer const &, bool label) const; /// @@ -157,12 +107,6 @@ public: pos_type beg, pos_type end, bool label) const; - /// - docstring const asString(Buffer const &, - OutputParams const & runparams, - pos_type beg, - pos_type end, - bool label) const; /// void write(Buffer const &, std::ostream &, BufferParams const &, @@ -171,10 +115,12 @@ public: void validate(LaTeXFeatures &) const; /// - int startTeXParParams(BufferParams const &, odocstream &, bool) const; + int startTeXParParams(BufferParams const &, odocstream &, TexRow &, + bool) const; /// - int endTeXParParams(BufferParams const &, odocstream &, bool) const; + int endTeXParParams(BufferParams const &, odocstream &, TexRow &, + bool) const; /// @@ -189,7 +135,7 @@ public: std::string getID(Buffer const & buf, OutputParams const & runparams) const; - // Get the first word of a paragraph, return the position where it left + /// Get the first word of a paragraph, return the position where it left pos_type getFirstWord(Buffer const & buf, odocstream & os, OutputParams const & runparams) const; @@ -224,8 +170,6 @@ public: pos_type size() const { return text_.size(); } /// bool empty() const { return text_.empty(); } - /// - void clearContents(); /// LyXLayout_ptr const & layout() const; @@ -239,7 +183,7 @@ public: InsetBibitem * bibitem() const; // ale970302 /// look up change at given pos - Change const lookupChange(pos_type pos) const; + Change const & lookupChange(pos_type pos) const; /// is there a change within the given range ? bool isChanged(pos_type start, pos_type end) const; @@ -267,10 +211,10 @@ public: void setChange(pos_type pos, Change const & change); /// accept changes within the given range - void acceptChanges(pos_type start, pos_type end); + void acceptChanges(BufferParams const & bparams, pos_type start, pos_type end); /// reject changes within the given range - void rejectChanges(pos_type start, pos_type end); + void rejectChanges(BufferParams const & bparams, pos_type start, pos_type end); /// Paragraphs can contain "manual labels", for example, Description /// environment. The text for this user-editable label is stored in @@ -286,8 +230,14 @@ public: /// the next two functions are for the manual labels docstring const getLabelWidthString() const; - /// + /// Set label width string. void setLabelWidthString(docstring const & s); + /// translate \p label to the paragraph language if possible. + docstring const translateIfPossible(docstring const & label, + BufferParams const & bparams) const; + /// Expand the counters for the labelstring of \c layout + docstring expandLabel(LyXLayout_ptr const &, BufferParams const &, + bool process_appendix = true) const; /// Actual paragraph alignment used char getAlign() const; /// The nesting depth of a paragraph @@ -328,8 +278,7 @@ public: * The font returned by the above functions is the same in a * span of characters. This method will return the first and * the last positions in the paragraph for which that font is - * the same. This can be used to avoid unnecessary calls to - * getFont. + * the same. This can be used to avoid unnecessary calls to getFont. */ FontSpan fontSpan(pos_type pos) const; /// @@ -385,15 +334,16 @@ public: bool isSeparator(pos_type pos) const { return getChar(pos) == ' '; } /// bool isLineSeparator(pos_type pos) const; - /// True if the character/inset at this point can be part of a word - // Note that digits in particular are considered as letters + /// True if the character/inset at this point can be part of a word. + /// Note that digits in particular are considered as letters bool isLetter(pos_type pos) const; /// returns -1 if inset not found int getPositionOfInset(InsetBase const * inset) const; - /// Returns the number of line breaks and white-space stripped at the start - int stripLeadingSpaces(); + /// returns true if at least one line break or line separator has been deleted + /// at the beginning of the paragraph (either physically or logically) + bool stripLeadingSpaces(bool trackChanges); /// return true if we allow multiple spaces bool isFreeSpacing() const; @@ -409,6 +359,10 @@ public: /// bool hfillExpansion(Row const & row, pos_type pos) const; + /// Check if we are in a Biblio environment. + /// \retval true if the cursor needs to be moved right. + bool checkBiblio(bool track_changes); + public: /// InsetList insetlist;