HaikuDepot: MarkupParser: Added SetStyles().
* Also include the terminating \0 in the loop over the characters, in order to consume the last paragraph correctly when it's not finished by a line break.
This commit is contained in:
@@ -32,7 +32,7 @@ MarkupParser::MarkupParser()
|
|||||||
|
|
||||||
|
|
||||||
MarkupParser::MarkupParser(const CharacterStyle& characterStyle,
|
MarkupParser::MarkupParser(const CharacterStyle& characterStyle,
|
||||||
const ParagraphStyle& paragraphStyle)
|
const ParagraphStyle& paragraphStyle)
|
||||||
:
|
:
|
||||||
fNormalStyle(characterStyle),
|
fNormalStyle(characterStyle),
|
||||||
fBoldStyle(),
|
fBoldStyle(),
|
||||||
@@ -51,6 +51,16 @@ MarkupParser::MarkupParser(const CharacterStyle& characterStyle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MarkupParser::SetStyles(const CharacterStyle& characterStyle,
|
||||||
|
const ParagraphStyle& paragraphStyle)
|
||||||
|
{
|
||||||
|
fNormalStyle = characterStyle;
|
||||||
|
fParagraphStyle = paragraphStyle;
|
||||||
|
_InitStyles();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TextDocumentRef
|
TextDocumentRef
|
||||||
MarkupParser::CreateDocumentFromMarkup(const BString& text)
|
MarkupParser::CreateDocumentFromMarkup(const BString& text)
|
||||||
{
|
{
|
||||||
@@ -112,7 +122,7 @@ MarkupParser::_ParseText(const BString& text)
|
|||||||
int32 charCount = text.CountChars();
|
int32 charCount = text.CountChars();
|
||||||
const char* c = text.String();
|
const char* c = text.String();
|
||||||
|
|
||||||
while (offset < charCount) {
|
while (offset <= charCount) {
|
||||||
uint32 nextChar = UTF8ToCharCode(&c);
|
uint32 nextChar = UTF8ToCharCode(&c);
|
||||||
|
|
||||||
switch (nextChar) {
|
switch (nextChar) {
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ public:
|
|||||||
const CharacterStyle& characterStyle,
|
const CharacterStyle& characterStyle,
|
||||||
const ParagraphStyle& paragraphStyle);
|
const ParagraphStyle& paragraphStyle);
|
||||||
|
|
||||||
|
void SetStyles(
|
||||||
|
const CharacterStyle& characterStyle,
|
||||||
|
const ParagraphStyle& paragraphStyle);
|
||||||
|
|
||||||
TextDocumentRef CreateDocumentFromMarkup(const BString& text);
|
TextDocumentRef CreateDocumentFromMarkup(const BString& text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user