Skip to main content

Метод Range::getBlocksEnumerator

Предоставляет возможность итерации по блокам.

Пример для текстового документа​


Range range = document.getRange();
std::shared_ptr<Enumerator<Block>> enumerator = range.getBlocksEnumerator();
while (enumerator->isValid())
{
Block block = enumerator->getCurrent();
std::printf("%s", block.getRange().extractText().c_str());
enumerator->goToNext();
}

Пример для табличного документа​


boost::optional<Table> tableOpt = document.getBlocks().getTable(0);
if (tableOpt.has_value())
{
Table table = tableOpt.get();
Cell cell = table.getCell("B2");
Range cellRange = cell.getRange();
std::shared_ptr<Enumerator<Block>> enumerator = cellRange.getBlocksEnumerator();
while (enumerator->isValid())
{
Block block = enumerator->getCurrent();
std::printf("%s", block.getRange().extractText().c_str());
enumerator->goToNext();
}
}