X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fparagraph.h;h=8f1d5acd1f5d717aa2b1a31d7dddf6f4664510c7;hb=3f8fa07c6ed38218d6a4048f2993a512aa942c96;hp=7543feec687cfacdcccef29a7eceb3ea0d32e084;hpb=6c300f72a217722652dc27db9108e1050028979c;p=lyx.git diff --git a/src/paragraph.h b/src/paragraph.h index 7543feec68..8f1d5acd1f 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; @@ -60,6 +59,8 @@ public: /// 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: /// @@ -99,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; /// @@ -110,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 &, @@ -142,7 +133,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; @@ -178,8 +169,6 @@ public: /// bool empty() const { return text_.empty(); } /// - void setContentsFromPar(Paragraph const & par); - /// void clearContents(); /// @@ -194,26 +183,38 @@ 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; + /// is there an unchanged char at the given pos ? + bool isUnchanged(pos_type pos) const { + return lookupChange(pos).type == Change::UNCHANGED; + } + /// is there an insertion at the given pos ? + bool isInserted(pos_type pos) const { + return lookupChange(pos).type == Change::INSERTED; + } /// is there a deletion at the given pos ? bool isDeleted(pos_type pos) const { return lookupChange(pos).type == Change::DELETED; } + /// 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; + /// set change for the entire par void setChange(Change const & change); /// set change at given pos void setChange(pos_type pos, Change const & change); - /// accept change - void acceptChange(pos_type start, pos_type end); + /// accept changes within the given range + void acceptChanges(BufferParams const & bparams, pos_type start, pos_type end); - /// reject change - void rejectChange(pos_type start, pos_type end); + /// reject changes within the given range + 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 @@ -229,9 +230,15 @@ 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 depth_type getDepth() const; @@ -240,10 +247,10 @@ public: /// void applyLayout(LyXLayout_ptr const & new_layout); - /// erase the char at the given position - bool erase(pos_type pos, bool trackChanges); - /// erase the given range. Returns the number of chars actually erased - int erase(pos_type start, pos_type end, bool trackChanges); + /// (logically) erase the char at pos; return true if it was actually erased + bool eraseChar(pos_type pos, bool trackChanges); + /// (logically) erase the given range; return the number of chars actually erased + int eraseChars(pos_type start, pos_type end, bool trackChanges); /** Get uninstantiated font setting. Returns the difference between the characters font and the layoutfont. @@ -271,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; /// @@ -280,15 +286,13 @@ public: value_type getChar(pos_type pos) const { return text_[pos]; } /// Get the char, but mirror all bracket characters if it is right-to-left value_type getUChar(BufferParams const &, pos_type pos) const; - /// The position must already exist. - void setChar(pos_type pos, value_type c); /// pos <= size() (there is a dummy font change at the end of each par) void setFont(pos_type pos, LyXFont const & font); /// Returns the height of the highest font in range LyXFont_size highestFontInRange(pos_type startpos, pos_type endpos, LyXFont_size def_size) const; /// - void insert(pos_type pos, std::string const & str, + void insert(pos_type pos, docstring const & str, LyXFont const & font, Change const & change); /// void insertChar(pos_type pos, value_type c, bool trackChanges); @@ -300,10 +304,10 @@ public: LyXFont const &, Change const & change); /// void insertInset(pos_type pos, InsetBase * inset, - Change const & change); + Change const & change); /// void insertInset(pos_type pos, InsetBase * inset, - LyXFont const &, Change const & change); + LyXFont const &, Change const & change); /// bool insetAllowed(InsetBase_code code); /// @@ -330,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; @@ -351,47 +356,18 @@ public: ParagraphParameters & params(); /// ParagraphParameters const & params() const; - - /// - Row & getRow(pos_type pos, bool boundary); - /// - Row const & getRow(pos_type pos, bool boundary) const; - /// - size_t pos2row(pos_type pos) const; - - /// 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_; } + bool hfillExpansion(Row const & row, pos_type pos) const; - /// LyXText::redoParagraph updates this - Dimension & dim() { return dim_; } - - /// dump some information to lyxerr - void dump() 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; private: - /// cached dimensions of paragraph - Dimension dim_; - - /// - mutable RowList rows_; - /// - mutable RowSignature rowSignature_; /// LyXLayout_ptr layout_; @@ -411,7 +387,6 @@ private: Pimpl * pimpl_; }; - } // namespace lyx #endif // PARAGRAPH_H