get Origin::Spreadsheet from container name (may be a spreadsheet or workbook)
| 203 | |
| 204 | // get Origin::Spreadsheet from container name (may be a spreadsheet or workbook) |
| 205 | Origin::SpreadSheet OriginProjectParser::getSpreadsheetByName(QString& containerName) { |
| 206 | DEBUG(Q_FUNC_INFO) |
| 207 | int sheetIndex = 0; // which sheet? "@X" |
| 208 | const int atIndex = containerName.indexOf(QLatin1Char('@')); |
| 209 | if (atIndex != -1) { |
| 210 | sheetIndex = containerName.mid(atIndex + 1).toInt() - 1; |
| 211 | containerName.truncate(atIndex); |
| 212 | } |
| 213 | // DEBUG("CONTAINER = " << STDSTRING(containerName) << ", SHEET = " << sheetIndex) |
| 214 | |
| 215 | // check if workbook |
| 216 | int workbookIndex = findWorkbookByName(containerName); |
| 217 | // if workbook not found, findWorkbookByName() returns 0: check this |
| 218 | if (workbookIndex == 0 && (m_originFile->excelCount() == 0 || containerName.toStdString() != m_originFile->excel(0).name)) |
| 219 | workbookIndex = -1; |
| 220 | // DEBUG("WORKBOOK index = " << workbookIndex) |
| 221 | |
| 222 | // comment of y column is used in legend (if not empty), else the column name |
| 223 | Origin::SpreadSheet sheet; |
| 224 | if (workbookIndex != -1) { // container is a workbook |
| 225 | sheet = m_originFile->excel(workbookIndex).sheets[sheetIndex]; |
| 226 | } else { // container is a spreadsheet? |
| 227 | int spreadsheetIndex = findSpreadsheetByName(containerName); |
| 228 | // if spreadsheet not found, findSpreadsheetByName() returns 0: check this |
| 229 | if (spreadsheetIndex == 0 && (m_originFile->spreadCount() == 0 || containerName.toStdString() != m_originFile->spread(0).name)) |
| 230 | spreadsheetIndex = -1; |
| 231 | if (spreadsheetIndex != -1) |
| 232 | sheet = m_originFile->spread(spreadsheetIndex); |
| 233 | } |
| 234 | |
| 235 | return sheet; |
| 236 | } |
| 237 | |
| 238 | // ############################################################################## |
| 239 | // ############## Deserialization from Origin's project tree #################### |
nothing calls this directly
no test coverage detected