Loading editor/widgets/table/table.cpp +46 −0 Original line number Diff line number Diff line Loading @@ -87,11 +87,26 @@ extern "C" { // Cell data stored as row-major flat vector std::vector<std::string> cellData; // Original HTML-import `class` attribute of each cell/row, kept // alongside cellData so the CSS rules preserved in customCss // (see htmlimport.cpp's collectTableStructureCss) that target // those classes -- e.g. ".eigen"/".ja" or "thead th.eigen" -- // still have a matching element to apply to once rendered. // Empty for rows/cells not created via HTML import. std::vector<std::string> cellClassData; std::vector<std::string> rowClassData; void ensureCellData() { size_t needed = static_cast<size_t>(numRows * numCols); if (cellData.size() < needed) { cellData.resize(needed, ""); } if (cellClassData.size() < needed) { cellClassData.resize(needed, ""); } if (rowClassData.size() < static_cast<size_t>(numRows)) { rowClassData.resize(static_cast<size_t>(numRows), ""); } } std::string& getCellRef(int row, int col) { Loading @@ -106,6 +121,25 @@ extern "C" { return empty; } std::string& getCellClassRef(int row, int col) { ensureCellData(); return cellClassData[static_cast<size_t>(row * numCols + col)]; } const std::string& getCellClassVal(int row, int col) const { static const std::string empty; size_t idx = static_cast<size_t>(row * numCols + col); if (idx < cellClassData.size()) return cellClassData[idx]; return empty; } const std::string& getRowClassVal(int row) const { static const std::string empty; if (row >= 0 && static_cast<size_t>(row) < rowClassData.size()) return rowClassData[static_cast<size_t>(row)]; return empty; } public: Table() { Type = "d55dabe2-3g76-5f4g-b5d7-0g67e2c767d5"; Loading Loading @@ -390,9 +424,13 @@ extern "C" { for (int r = 0; r < numRows; ++r) { tinyxml2::XMLElement* rowEl = doc->NewElement("Row"); rowEl->SetAttribute("index", r); if (!getRowClassVal(r).empty()) rowEl->SetAttribute("css_class", getRowClassVal(r).c_str()); for (int c = 0; c < numCols; ++c) { tinyxml2::XMLElement* cellEl = doc->NewElement("Cell"); cellEl->SetAttribute("col", c); if (!getCellClassVal(r, c).empty()) cellEl->SetAttribute("css_class", getCellClassVal(r, c).c_str()); cellEl->SetText(getCellVal(r, c).c_str()); rowEl->InsertEndChild(cellEl); } Loading Loading @@ -493,6 +531,10 @@ extern "C" { while (rowEl) { int r = 0; rowEl->QueryIntAttribute("index", &r); const char* rowClassVal = rowEl->Attribute("css_class"); if (rowClassVal && r >= 0 && r < numRows) { rowClassData[static_cast<size_t>(r)] = rowClassVal; } tinyxml2::XMLElement* cellEl = rowEl->FirstChildElement("Cell"); while (cellEl) { int c = 0; Loading @@ -501,6 +543,10 @@ extern "C" { if (text && r >= 0 && r < numRows && c >= 0 && c < numCols) { getCellRef(r, c) = text; } const char* cellClassVal = cellEl->Attribute("css_class"); if (cellClassVal && r >= 0 && r < numRows && c >= 0 && c < numCols) { getCellClassRef(r, c) = cellClassVal; } cellEl = cellEl->NextSiblingElement("Cell"); } rowEl = rowEl->NextSiblingElement("Row"); Loading Loading
editor/widgets/table/table.cpp +46 −0 Original line number Diff line number Diff line Loading @@ -87,11 +87,26 @@ extern "C" { // Cell data stored as row-major flat vector std::vector<std::string> cellData; // Original HTML-import `class` attribute of each cell/row, kept // alongside cellData so the CSS rules preserved in customCss // (see htmlimport.cpp's collectTableStructureCss) that target // those classes -- e.g. ".eigen"/".ja" or "thead th.eigen" -- // still have a matching element to apply to once rendered. // Empty for rows/cells not created via HTML import. std::vector<std::string> cellClassData; std::vector<std::string> rowClassData; void ensureCellData() { size_t needed = static_cast<size_t>(numRows * numCols); if (cellData.size() < needed) { cellData.resize(needed, ""); } if (cellClassData.size() < needed) { cellClassData.resize(needed, ""); } if (rowClassData.size() < static_cast<size_t>(numRows)) { rowClassData.resize(static_cast<size_t>(numRows), ""); } } std::string& getCellRef(int row, int col) { Loading @@ -106,6 +121,25 @@ extern "C" { return empty; } std::string& getCellClassRef(int row, int col) { ensureCellData(); return cellClassData[static_cast<size_t>(row * numCols + col)]; } const std::string& getCellClassVal(int row, int col) const { static const std::string empty; size_t idx = static_cast<size_t>(row * numCols + col); if (idx < cellClassData.size()) return cellClassData[idx]; return empty; } const std::string& getRowClassVal(int row) const { static const std::string empty; if (row >= 0 && static_cast<size_t>(row) < rowClassData.size()) return rowClassData[static_cast<size_t>(row)]; return empty; } public: Table() { Type = "d55dabe2-3g76-5f4g-b5d7-0g67e2c767d5"; Loading Loading @@ -390,9 +424,13 @@ extern "C" { for (int r = 0; r < numRows; ++r) { tinyxml2::XMLElement* rowEl = doc->NewElement("Row"); rowEl->SetAttribute("index", r); if (!getRowClassVal(r).empty()) rowEl->SetAttribute("css_class", getRowClassVal(r).c_str()); for (int c = 0; c < numCols; ++c) { tinyxml2::XMLElement* cellEl = doc->NewElement("Cell"); cellEl->SetAttribute("col", c); if (!getCellClassVal(r, c).empty()) cellEl->SetAttribute("css_class", getCellClassVal(r, c).c_str()); cellEl->SetText(getCellVal(r, c).c_str()); rowEl->InsertEndChild(cellEl); } Loading Loading @@ -493,6 +531,10 @@ extern "C" { while (rowEl) { int r = 0; rowEl->QueryIntAttribute("index", &r); const char* rowClassVal = rowEl->Attribute("css_class"); if (rowClassVal && r >= 0 && r < numRows) { rowClassData[static_cast<size_t>(r)] = rowClassVal; } tinyxml2::XMLElement* cellEl = rowEl->FirstChildElement("Cell"); while (cellEl) { int c = 0; Loading @@ -501,6 +543,10 @@ extern "C" { if (text && r >= 0 && r < numRows && c >= 0 && c < numCols) { getCellRef(r, c) = text; } const char* cellClassVal = cellEl->Attribute("css_class"); if (cellClassVal && r >= 0 && r < numRows && c >= 0 && c < numCols) { getCellClassRef(r, c) = cellClassVal; } cellEl = cellEl->NextSiblingElement("Cell"); } rowEl = rowEl->NextSiblingElement("Row"); Loading