const TXshCell &TXsheet::getCell(int row, int col) const { static const TXshCell emptyCell; TXshColumnP column = m_imp->m_columnSet.getColumn(col); if (!column) return emptyCell; TXshCellColumn *xshColumn = column->getCellColumn(); if (!xshColumn) return emptyCell; return xshColumn->getCell(row); }
void TXsheet::getUsedLevels(set<TXshLevel *> &levels) const { set<const TXsheet *> visitedXshs; vector<const TXsheet *> todoXshs; visitedXshs.insert(this); todoXshs.push_back(this); while (!todoXshs.empty()) { const TXsheet *xsh = todoXshs.back(); todoXshs.pop_back(); int c0 = 0, c1 = xsh->getColumnCount() - 1; for (int c = c0; c <= c1; ++c) { TXshColumnP column = const_cast<TXsheet *>(xsh)->getColumn(c); if (!column) continue; TXshCellColumn *cellColumn = column->getCellColumn(); if (!cellColumn) continue; int r0, r1; if (!cellColumn->getRange(r0, r1)) continue; TXshLevel *level = 0; for (int r = r0; r <= r1; r++) { TXshCell cell = cellColumn->getCell(r); if (cell.isEmpty() || !cell.m_level) continue; if (level != cell.m_level.getPointer()) { level = cell.m_level.getPointer(); levels.insert(level); if (level->getChildLevel()) { TXsheet *childXsh = level->getChildLevel()->getXsheet(); if (visitedXshs.count(childXsh) == 0) { visitedXshs.insert(childXsh); todoXshs.push_back(childXsh); } } } } } } }