Beispiel #1
0
void Document::Qtf0(const char *s, bool append, byte charset) {
	QtfParser parser(s);
	for(;;) {
		switch(parser.Parse()) {
		case QtfParser::PARAGRAPH:
			if(append)
				Cat(parser.GetParagraph());
			else
				AddParagraph() = parser.PickParagraph();
			break;
		case QtfParser::TABLE:
			AddTable() = parser.PickTable();
			break;
		case QtfParser::END:
			return;
		}
		append = false;
	}
}
Beispiel #2
0
void Document::Cat(const Paragraph& p) {
	if(item.GetCount() && item.Top().type == PARAGRAPH)
		item.Top().data.LastCell().Par().Cat(p);
	else
		AddParagraph() <<= p;
}
Beispiel #3
0
    IZ_BOOL CParagraphGroupImpl::Init(
        IFontHost* host,
        CUString& str, 
        void* userData)
    {
        SAFE_REPLACE(m_FontHost, host);

        m_LineHeight = m_FontHost->GetPixelSize();
        m_Ascent = m_FontHost->GetAscender();

        IZ_UINT prev = 0;
        IZ_UINT code = 0;

        IZ_BOOL isSeparated = IZ_FALSE;

        const IZ_UINT8* start = str.GetTextPtr();
        IZ_UINT lastPos = 1;

        str.BeginIter();

        for (;;)
        {
            if (isSeparated)
            {
                start = str.GetIterPtr();

                isSeparated = IZ_FALSE;
            }

            code = str.GetNext();

            if (prev == CH_CR && code == CH_LF)
            {
                // skip
                code = str.GetNext();
            }

            prev = code;

            if (_IsSeparator(code) || code == 0)
            {
                IZ_UINT pos = static_cast<IZ_UINT>(str.GetIterDistance());
                IZ_UINT bytes = pos - lastPos;
                lastPos = pos;

                CParagraph* paragraph = CParagraphImpl::CreateParagraph(
                    m_Allocator,
                    host,
                    str.GetCharCode(),
                    start,
                    bytes,
                    userData);

                AddParagraph(paragraph);

                if (code == 0)
                {
                    break;
                }
                else
                {
                    isSeparated = IZ_TRUE;
                }
            }
        }

        str.EndIter();

        return IZ_TRUE;
    }