From 323476a9a4ec788ae563eb376ed8660f3a7d8cd4 Mon Sep 17 00:00:00 2001 From: xtemp09 Date: Sat, 25 Feb 2023 19:49:19 +0700 Subject: [PATCH] [TechDraw] Improved readability of DrawViewSpreadsheet.cpp I was stretching my fingers --- src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp | 42 +++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp index d5f75ba42a..a16dff18c9 100644 --- a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp +++ b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp @@ -111,23 +111,17 @@ App::DocumentObjectExecReturn *DrawViewSpreadsheet::execute() return TechDraw::DrawView::execute(); } -std::vector DrawViewSpreadsheet::getAvailColumns() +std::vector DrawViewSpreadsheet::getAvailColumns() { - // build a list of available columns: A, B, C, ... AA, AB, ... ZY, ZZ. - std::string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - std::vector availcolumns; - for (int i=0; i<26; ++i) { //A:Z - std::stringstream s; - s << alphabet[i]; - availcolumns.push_back(s.str()); - } - for (int i=0; i<26; ++i) { //AA:ZZ - for (int j=0; j<26; ++j) { - std::stringstream s; - s << alphabet[i] << alphabet[j]; - availcolumns.push_back(s.str()); - } - } + // builds a list of available columns: A, B, ... Y, Z, AA, AB, ... ZY, ZZ. + const std::string alphabet [] {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; + + std::vector availcolumns { std::begin (alphabet), std::end (alphabet) }; + + for (const std::string &left : alphabet) + for (const std::string &right : alphabet) + availcolumns.push_back(left + right); + return availcolumns; } @@ -200,7 +194,7 @@ std::string DrawViewSpreadsheet::getSheetImage() } } - std::vector availcolumns = getAvailColumns(); + const std::vector availcolumns = getAvailColumns(); //validate range start column in sheet's available columns int iAvailColStart = colInList(availcolumns, sColStart); @@ -309,11 +303,11 @@ std::string DrawViewSpreadsheet::getSheetImage() if (cell->getStyle(st)) { for (std::set::const_iterator i = st.begin(); i != st.end(); ++i) { if ((*i) == "bold") - textstyle = textstyle + "font-weight: bold; "; + textstyle += "font-weight: bold; "; else if ((*i) == "italic") - textstyle = textstyle + "font-style: italic; "; + textstyle += "font-style: italic; "; else if ((*i) == "underline") - textstyle = textstyle + "text-decoration: underline; "; + textstyle += "text-decoration: underline; "; } } if (cell->getSpans(rowspan, colspan)) { @@ -321,9 +315,9 @@ std::string DrawViewSpreadsheet::getSheetImage() for (int j=0; j 0) - cellwidth = cellwidth + sheet->getColumnWidth(nextcell.col()); + cellwidth += sheet->getColumnWidth(nextcell.col()); if (j > 0) - cellheight = cellheight + sheet->getRowHeight(nextcell.row()); + cellheight += sheet->getRowHeight(nextcell.row()); if ( (i > 0) || (j > 0) ) skiplist.push_back(nextcell.toString()); } @@ -357,11 +351,11 @@ std::string DrawViewSpreadsheet::getSheetImage() << " fill=\"" << fcolor << "\">" << celltext << "" << std::endl; } } - rowoffset = rowoffset + sheet->getRowHeight(address.row()); + rowoffset += sheet->getRowHeight(address.row()); } result << " " << std::endl; rowoffset = 0.0; - coloffset = coloffset + cellwidth; + coloffset += cellwidth; } // close the containing group