void OleStreamParser::processStyles(OleMainStream &stream) { const OleMainStream::StyleInfoList &styleInfoList = stream.getStyleInfoList(); if (!styleInfoList.empty()) { while (myNextStyleInfoIndex < styleInfoList.size() && styleInfoList.at(myNextStyleInfoIndex).first == myCurCharPos) { OleMainStream::Style info = styleInfoList.at(myNextStyleInfoIndex).second; handleParagraphStyle(info); ++myNextStyleInfoIndex; } } const OleMainStream::CharInfoList &charInfoList = stream.getCharInfoList(); if (!charInfoList.empty()) { while (myNextCharInfoIndex < charInfoList.size() && charInfoList.at(myNextCharInfoIndex).first == myCurCharPos) { OleMainStream::CharInfo info = charInfoList.at(myNextCharInfoIndex).second; handleFontStyle(info.FontStyle); ++myNextCharInfoIndex; } } const OleMainStream::BookmarksList &bookmarksList = stream.getBookmarks(); if (!bookmarksList.empty()) { while (myNextBookmarkIndex < bookmarksList.size() && bookmarksList.at(myNextBookmarkIndex).CharPosition == myCurCharPos) { OleMainStream::Bookmark bookmark = bookmarksList.at(myNextBookmarkIndex); handleBookmark(bookmark.Name); ++myNextBookmarkIndex; } } }
void DocBookReader::handleParagraphStyle(const OleMainStream::Style &styleInfo) { if (styleInfo.HasPageBreakBefore) { handlePageBreak(); } shared_ptr<ZLTextStyleEntry> entry = new ZLTextStyleEntry(ZLTextStyleEntry::STYLE_OTHER_ENTRY); switch (styleInfo.Alignment) { default: // in that case, use default alignment type break; case OleMainStream::Style::ALIGNMENT_LEFT: entry->setAlignmentType(ALIGN_LEFT); break; case OleMainStream::Style::ALIGNMENT_RIGHT: entry->setAlignmentType(ALIGN_RIGHT); break; case OleMainStream::Style::ALIGNMENT_CENTER: entry->setAlignmentType(ALIGN_CENTER); break; case OleMainStream::Style::ALIGNMENT_JUSTIFY: entry->setAlignmentType(ALIGN_JUSTIFY); break; } //TODO in case, where style is heading, but size is small it works wrong const ZLTextStyleEntry::SizeUnit unit = ZLTextStyleEntry::SIZE_UNIT_PERCENT; switch (styleInfo.StyleIdCurrent) { default: break; case OleMainStream::Style::STYLE_H1: entry->setLength(ZLTextStyleEntry::LENGTH_FONT_SIZE, 140, unit); break; case OleMainStream::Style::STYLE_H2: entry->setLength(ZLTextStyleEntry::LENGTH_FONT_SIZE, 120, unit); break; case OleMainStream::Style::STYLE_H3: entry->setLength(ZLTextStyleEntry::LENGTH_FONT_SIZE, 110, unit); break; } myCurrentStyleEntry = entry; myModelReader.addStyleEntry(*myCurrentStyleEntry); // we should have the same font style, as for the previous paragraph, // if it has the same StyleIdCurrent if (myCurrentStyleInfo.StyleIdCurrent != OleMainStream::Style::STYLE_INVALID && myCurrentStyleInfo.StyleIdCurrent == styleInfo.StyleIdCurrent) { for (std::size_t i = 0; i < myKindStack.size(); ++i) { myModelReader.addControl(myKindStack.at(i), true); } } else { myKindStack.clear(); // fill by the fontstyle, that was got from Stylesheet handleFontStyle(styleInfo.CurrentCharInfo.FontStyle); } myCurrentStyleInfo = styleInfo; }
void DocBookReader::handleParagraphStyle(const OleMainStream::Style &styleInfo) { if (styleInfo.hasPageBreakBefore) { handlePageBreak(); } shared_ptr<ZLTextStyleEntry> entry = new ZLTextStyleEntry(); if (styleInfo.alignment == OleMainStream::Style::LEFT) { entry->setAlignmentType(ALIGN_JUSTIFY); //force justify align } else if (styleInfo.alignment == OleMainStream::Style::CENTER) { entry->setAlignmentType(ALIGN_CENTER); } else if (styleInfo.alignment == OleMainStream::Style::RIGHT) { entry->setAlignmentType(ALIGN_RIGHT); } else if (styleInfo.alignment == OleMainStream::Style::JUSTIFY) { entry->setAlignmentType(ALIGN_JUSTIFY); } //TODO in case, where style is heading, but size is small it works wrong ZLTextStyleEntry::SizeUnit unit = ZLTextStyleEntry::SIZE_UNIT_PERCENT; if (styleInfo.istd == OleMainStream::H1) { entry->setLength(ZLTextStyleEntry::LENGTH_FONT_SIZE, 140, unit); } else if (styleInfo.istd == OleMainStream::H2) { entry->setLength(ZLTextStyleEntry::LENGTH_FONT_SIZE, 120, unit); } else if (styleInfo.istd == OleMainStream::H3) { entry->setLength(ZLTextStyleEntry::LENGTH_FONT_SIZE, 110, unit); } myCurStyleEntry = entry; myModelReader.addStyleEntry(*myCurStyleEntry); //we should have the same font style, as for the previous paragraph, if it has the same istd if (myCurStyleInfo.istd != OleMainStream::ISTD_INVALID && myCurStyleInfo.istd == styleInfo.istd) { for (size_t i = 0; i < myKindStack.size(); ++i) { myModelReader.addControl(myKindStack.at(i), true); } } else { myKindStack.clear(); handleFontStyle(styleInfo.charInfo.fontStyle); //fill by the fontstyle, that was got from Stylesheet } myCurStyleInfo = styleInfo; }