HaikuDepot: Make MarkupParser a bit more flexible...
... by allowing to append markup to an existing document.
This commit is contained in:
parent
97c332e107
commit
cb97f2349f
@ -64,9 +64,20 @@ MarkupParser::SetStyles(const CharacterStyle& characterStyle,
|
||||
TextDocumentRef
|
||||
MarkupParser::CreateDocumentFromMarkup(const BString& text)
|
||||
{
|
||||
fTextDocument.SetTo(new(std::nothrow) TextDocument(), true);
|
||||
if (fTextDocument.Get() == NULL)
|
||||
return fTextDocument;
|
||||
TextDocumentRef document(new(std::nothrow) TextDocument(), true);
|
||||
if (document.Get() == NULL)
|
||||
return document;
|
||||
|
||||
AppendMarkup(document, text);
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MarkupParser::AppendMarkup(const TextDocumentRef& document, const BString& text)
|
||||
{
|
||||
fTextDocument.SetTo(document);
|
||||
|
||||
fCurrentCharacterStyle = &fNormalStyle;
|
||||
fCurrentParagraphStyle = &fParagraphStyle;
|
||||
@ -76,7 +87,7 @@ MarkupParser::CreateDocumentFromMarkup(const BString& text)
|
||||
|
||||
_ParseText(text);
|
||||
|
||||
return fTextDocument;
|
||||
fTextDocument.Unset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,7 +19,14 @@ public:
|
||||
const CharacterStyle& characterStyle,
|
||||
const ParagraphStyle& paragraphStyle);
|
||||
|
||||
const CharacterStyle& HeadingCharacterStyle() const
|
||||
{ return fHeadingStyle; }
|
||||
const ParagraphStyle& HeadingParagraphStyle() const
|
||||
{ return fHeadingParagraphStyle; }
|
||||
|
||||
TextDocumentRef CreateDocumentFromMarkup(const BString& text);
|
||||
void AppendMarkup(const TextDocumentRef& document,
|
||||
const BString& text);
|
||||
|
||||
private:
|
||||
void _InitStyles();
|
||||
|
Loading…
Reference in New Issue
Block a user