#pragma once #include "ITextItem.h" #include "ParagraphItem.h" namespace ASCDocFileFormat { class TextItem : public Aggregat { public: TextItem () : Aggregat() { } explicit TextItem (const ITextItem& oItem) : Aggregat(static_cast(oItem.Clone())) { } TextItem (const TextItem& oItem) { if (oItem.m_item.operator->()) { m_item.reset(static_cast(oItem.m_item->Clone())); } } TextItem& operator = (const TextItem& oItem) { if (m_item.operator->() != oItem.m_item.operator->()) { m_item.reset(static_cast(oItem.m_item->Clone())); } return *this; } TextItem& operator = (const ITextItem& oItem) { if (m_item.operator->() != &oItem) { m_item.reset(static_cast(oItem.Clone())); } return *this; } template vector GetAllRunItemsByType() const { std::vector allParagraphItems; std::vector paragraphsItemsOffsets; std::vector paragraphsItems = m_item->GetAllRunsCopy(¶graphsItemsOffsets); for (size_t i = 0; i < paragraphsItems.size(); ++i) { Run* run = dynamic_cast(paragraphsItems[i].operator->()); if (run) { for (std::list::const_iterator iter = run->begin(); iter != run->end(); ++iter) { if (iter->is()) { allParagraphItems.push_back(ParagraphItem(*run, paragraphsItemsOffsets[i])); } } } } return allParagraphItems; } template vector GetAllParagraphItemsByType() const { std::vector allParagraphItems; std::vector paragraphsItemsOffsets; std::vector paragraphsItems = m_item->GetAllParagraphItemsCopy(¶graphsItemsOffsets); for (size_t i = 0; i < paragraphsItems.size(); ++i) { T* paragraphItem = dynamic_cast(paragraphsItems[i].operator->()); if (paragraphItem) { allParagraphItems.push_back( ParagraphItem( *paragraphItem, paragraphsItemsOffsets[i] ) ); } } return allParagraphItems; } }; }