HaikuDepot: TextDocument: Added Paragraph access by index.
This commit is contained in:
@@ -178,6 +178,15 @@ TextDocument::ParagraphAt(int32 textOffset, int32& paragraphOffset) const
|
||||
}
|
||||
|
||||
|
||||
const Paragraph&
|
||||
TextDocument::ParagraphAt(int32 index) const
|
||||
{
|
||||
if (index >= 0 && index < fParagraphs.CountItems())
|
||||
return fParagraphs.ItemAtFast(index);
|
||||
return fEmptyLastParagraph;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TextDocument::Append(const Paragraph& paragraph)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#ifndef TEXT_DOCUMENT_H
|
||||
#define TEXT_DOCUMENT_H
|
||||
|
||||
#include <Referenceable.h>
|
||||
|
||||
#include "CharacterStyle.h"
|
||||
#include "List.h"
|
||||
#include "Paragraph.h"
|
||||
@@ -13,7 +15,7 @@
|
||||
typedef List<Paragraph, false> ParagraphList;
|
||||
|
||||
|
||||
class TextDocument {
|
||||
class TextDocument : public BReferenceable {
|
||||
public:
|
||||
TextDocument();
|
||||
TextDocument(
|
||||
@@ -56,6 +58,8 @@ public:
|
||||
const Paragraph& ParagraphAt(int32 textOffset,
|
||||
int32& paragraphOffset) const;
|
||||
|
||||
const Paragraph& ParagraphAt(int32 index) const;
|
||||
|
||||
bool Append(const Paragraph& paragraph);
|
||||
|
||||
private:
|
||||
@@ -65,4 +69,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
typedef BReference<TextDocument> TextDocumentRef;
|
||||
|
||||
|
||||
#endif // TEXT_DOCUMENT_H
|
||||
|
||||
Reference in New Issue
Block a user