void ZLTextParagraphCursor::Builder::fill() { myBidiCharType = (myBaseBidiLevel == 1) ? FRIBIDI_TYPE_RTL : FRIBIDI_TYPE_LTR; myCurrentBidiLevel = myBaseBidiLevel; myLatestBidiLevel = myBaseBidiLevel; for (ZLTextParagraph::Iterator it = myParagraph; !it.isEnd(); it.next()) { switch (it.entryKind()) { case ZLTextParagraphEntry::STYLE_ENTRY: myElements.push_back(new ZLTextStyleElement(it.entry())); break; case ZLTextParagraphEntry::FIXED_HSPACE_ENTRY: myElements.push_back(new ZLTextFixedHSpaceElement(((ZLTextFixedHSpaceEntry&)*it.entry()).length())); break; case ZLTextParagraphEntry::CONTROL_ENTRY: case ZLTextParagraphEntry::HYPERLINK_CONTROL_ENTRY: myElements.push_back(myTextElementPool.getControlElement(it.entry())); break; case ZLTextParagraphEntry::IMAGE_ENTRY: { ImageEntry &imageEntry = (ImageEntry&)*it.entry(); shared_ptr<const ZLImage> image = imageEntry.image(); if (!image.isNull()) { shared_ptr<ZLImageData> data = ZLImageManager::Instance().imageData(*image); if (!data.isNull()) { myElements.push_back(new ZLTextImageElement(imageEntry.id(), data)); } } break; } case ZLTextParagraphEntry::TEXT_ENTRY: processTextEntry((const ZLTextEntry&)*it.entry()); break; case ZLTextParagraphEntry::RESET_BIDI_ENTRY: updateBidiLevel(myBaseBidiLevel); myLatestBidiLevel = myBaseBidiLevel; break; case ZLTextParagraphEntry::LINE_BREAK_ENTRY: myElements.push_back(myTextElementPool.LineBreakElement); break; } } updateBidiLevel(myBaseBidiLevel); }
void ZLTextModel::search(const std::string &text, size_t startIndex, size_t endIndex, bool ignoreCase) const { ZLSearchPattern pattern(text, ignoreCase); myMarks.clear(); std::vector<ZLTextParagraph*>::const_iterator start = (startIndex < myParagraphs.size()) ? myParagraphs.begin() + startIndex : myParagraphs.end(); std::vector<ZLTextParagraph*>::const_iterator end = (endIndex < myParagraphs.size()) ? myParagraphs.begin() + endIndex : myParagraphs.end(); for (std::vector<ZLTextParagraph*>::const_iterator it = start; it < end; ++it) { int offset = 0; for (ZLTextParagraph::Iterator jt = **it; !jt.isEnd(); jt.next()) { if (jt.entryKind() == ZLTextParagraphEntry::TEXT_ENTRY) { const ZLTextEntry& textEntry = (ZLTextEntry&)*jt.entry(); const char *str = textEntry.data(); const size_t len = textEntry.dataLength(); for (int pos = ZLSearchUtil::find(str, len, pattern); pos != -1; pos = ZLSearchUtil::find(str, len, pattern, pos + 1)) { myMarks.push_back(ZLTextMark(it - myParagraphs.begin(), offset + pos, pattern.length())); } offset += len; } } } }