typedef std::list<TagFilterElem> TagChildrenForPrune; void pruneEmpty(TagChildrenForPrune & aTagChildren, TagChildrenForPrune::iterator & aLastContainer) { if (aLastContainer != aTagChildren.end()) { for (auto vIt = aLastContainer->rTagValue.rChildren.rbegin(); vIt != aLastContainer->rTagValue.rChildren.rend(); /*vIt++*/) { if (!vIt->is_type_of(evd::id_TextPara)) break; if (DocumentFilter::ChildHasText(*vIt)) break; aLastContainer->rTagValue.rChildren.erase(--aLastContainer->rTagValue.rChildren.end()); vIt = aLastContainer->rTagValue.rChildren.rbegin(); } if (aLastContainer->rTagValue.rChildren.size() == 0) { aTagChildren.erase(aLastContainer); } } aLastContainer = aTagChildren.end(); } void PlainBlock (BlockStack::reference aChild) { if (aChild.is_type_of(evd::id_ContentsElement) || aChild.is_type_of(evd::id_Table)) { for (auto & vChild : aChild.rTagValue.rChildren) { PlainBlock(vChild); } if (IsMixed(aChild)) { // TagFilterElem::ElemData::TagChildren vTagChildren; TagChildrenForPrune vTagChildren; auto vLastContainer = vTagChildren.end(); auto vFlagsIt = aChild.rTagValue.rTags.find(evd::ti_Flags); for (auto & vChild : aChild.rTagValue.rChildren) { if (vChild.is_type_of(evd::id_ContentsElement)) { pruneEmpty(vTagChildren, vLastContainer); vTagChildren.push_back(vChild); } else // if (vChild.is_leaf_para()) { if (vLastContainer == vTagChildren.end()) { TagFilterElem vContainer (evd::id_Block); if (vFlagsIt != aChild.rTagValue.rTags.end()) { vContainer.rTagValue.rTags.insert(*vFlagsIt); long vFlags = vFlagsIt->second.IntValue() & ~(long)MASK_NEW_PAGE; if (vFlags) vFlagsIt->second = vFlags; else aChild.rTagValue.rTags.erase(vFlagsIt); vFlagsIt = aChild.rTagValue.rTags.end(); } vTagChildren.push_back(vContainer); vLastContainer = --vTagChildren.end(); } vLastContainer->rTagValue.rChildren.push_back(vChild); } // else // ASSERT_NO_MSG(false); } pruneEmpty(vTagChildren, vLastContainer); aChild.rTagValue.rChildren.clear(); aChild.rTagValue.rChildren.insert(aChild.rTagValue.rChildren.begin(), vTagChildren.begin(), vTagChildren.end()); ASSERT_NO_MSG(!IsMixed(aChild)); } } }
Заметки о тестировании, программировании и прочий "поток сознания", который жалко писать "в стол"
Комментариев нет:
Отправить комментарий