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