TextDocument: Added Length()
This commit is contained in:
parent
a681c327ed
commit
586ec1c10b
@ -165,6 +165,8 @@ TextDocument::ParagraphStyleAt(int32 textOffset) const
|
||||
const Paragraph&
|
||||
TextDocument::ParagraphAt(int32 textOffset, int32& paragraphOffset) const
|
||||
{
|
||||
// TODO: Could binary search the Paragraphs if they were wrapped in classes
|
||||
// that knew there text offset in the document.
|
||||
int32 textLength = 0;
|
||||
paragraphOffset = 0;
|
||||
int32 count = fParagraphs.CountItems();
|
||||
@ -194,3 +196,18 @@ TextDocument::Append(const Paragraph& paragraph)
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
TextDocument::Length() const
|
||||
{
|
||||
// TODO: Could be O(1) if the Paragraphs were wrapped in classes that
|
||||
// knew there text offset in the document.
|
||||
int32 textLength = 0;
|
||||
int32 count = fParagraphs.CountItems();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
const Paragraph& paragraph = fParagraphs.ItemAtFast(i);
|
||||
textLength += paragraph.Length();
|
||||
}
|
||||
return textLength;
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,6 +62,9 @@ public:
|
||||
|
||||
bool Append(const Paragraph& paragraph);
|
||||
|
||||
// Query information
|
||||
int32 Length() const;
|
||||
|
||||
private:
|
||||
ParagraphList fParagraphs;
|
||||
Paragraph fEmptyLastParagraph;
|
||||
|
Loading…
Reference in New Issue
Block a user