@@ -353,8 +353,8 @@ void Reformat::Cell::apply(const Cell& c)
353353 m_grouping = c.m_grouping ;
354354}
355355
356- // ! Test if we need to read the column data
357- bool Reformat::Column ::readdata () const
356+ // ! Test if we need to read the row/ column data
357+ bool Reformat::Line ::readdata () const
358358{
359359 if (m_min_format == MF_BOLD || m_min_format == MF_EMPH)
360360 return true ;
@@ -366,20 +366,20 @@ bool Reformat::Column::readdata() const
366366}
367367
368368// ! Check for valid min/max format
369- Reformat::Column ::minmax_format_type
370- Reformat::Column ::parse_minmax (const std::string& key, const std::string& value)
369+ Reformat::Line ::minmax_format_type
370+ Reformat::Line ::parse_minmax (const std::string& key, const std::string& value)
371371{
372372 if (value == " " ) return MF_NONE;
373373 if (value == " bold" || value == " bf" ) return MF_BOLD;
374374 if (value == " emph" || value == " em" ) return MF_EMPH;
375375
376- OUT_THROW (" Invalid formatting for column key " << key << " : " << value);
376+ OUT_THROW (" Invalid formatting for row/ column key " << key << " : " << value);
377377}
378378
379- // ! Parse column-level key=value format
380- bool Reformat::Column ::parse_keyformat (const std::string& key,
381- std::string::const_iterator& curr,
382- const std::string::const_iterator& end)
379+ // ! Parse row/ column-level key=value format
380+ bool Reformat::Line ::parse_keyformat (const std::string& key,
381+ std::string::const_iterator& curr,
382+ const std::string::const_iterator& end)
383383{
384384 if (key == " min" || key == " minimum" )
385385 {
@@ -399,30 +399,30 @@ bool Reformat::Column::parse_keyformat(const std::string& key,
399399 }
400400 else
401401 {
402- OUT_THROW (" Invalid column-level format key: " << key);
402+ OUT_THROW (" Invalid row/ column-level format key: " << key);
403403 }
404404
405405 return true ;
406406}
407407
408- // ! Parse column-level formating arguments
409- bool Reformat::Column ::parse_format (const std::string& format)
408+ // ! Parse row/ column-level formating arguments
409+ bool Reformat::Line ::parse_format (const std::string& format)
410410{
411411 std::string::const_iterator curr = format.begin ();
412412 std::string key;
413413
414414 while (parse_keyword (curr, format.end (), key))
415415 {
416- DBG (" column-level format key: " << key << " -" );
416+ DBG (" row/ column-level format key: " << key << " -" );
417417
418418 parse_keyformat (key, curr, format.end ());
419419 }
420420
421421 return true ;
422422}
423423
424- // ! Apply formats of other column-level object
425- void Reformat::Column ::apply (const Column & c)
424+ // ! Apply formats of other row/ column-level object
425+ void Reformat::Line ::apply (const Line & c)
426426{
427427 if (c.m_min_format != MF_UNDEF)
428428 {
@@ -494,13 +494,30 @@ bool Reformat::parse_format(const std::string& format)
494494
495495 std::set<unsigned > cols = parse_numbers (arg);
496496
497- Column cformat ;
498- cformat .parse_format (parse_keyvalue (curr, format.end ()));
497+ Line colfmt ;
498+ colfmt .parse_format (parse_keyvalue (curr, format.end ()));
499499
500500 for (std::set<unsigned >::iterator c = cols.begin ();
501501 c != cols.end (); ++c)
502502 {
503- m_colfmt[*c].apply (cformat);
503+ m_colfmt[*c].apply (colfmt);
504+ }
505+ }
506+ else if (key == " row" || key == " rows" )
507+ {
508+ std::string arg = parse_keyargument (curr, format.end ());
509+
510+ DBG (" top-level format key: " << key << " arg: " << arg << " -" );
511+
512+ std::set<unsigned > rows = parse_numbers (arg);
513+
514+ Line rowfmt;
515+ rowfmt.parse_format (parse_keyvalue (curr, format.end ()));
516+
517+ for (std::set<unsigned >::iterator r = rows.begin ();
518+ r != rows.end (); ++r)
519+ {
520+ m_rowfmt[*r].apply (rowfmt);
504521 }
505522 }
506523 else if (m_fmt.parse_keyformat (key, curr, format.end ()))
@@ -523,7 +540,8 @@ void Reformat::prepare(const SqlQuery& sql)
523540 {
524541 for (unsigned j = 0 ; j < sql->num_cols (); ++j)
525542 {
526- if (!m_colfmt[j].readdata () && !m_fmt.readdata ())
543+ if (!m_rowfmt[i].readdata () && !m_colfmt[j].readdata () &&
544+ !m_fmt.readdata ())
527545 continue ;
528546
529547 std::string text = sql->text (i,j);
@@ -532,6 +550,18 @@ void Reformat::prepare(const SqlQuery& sql)
532550 double v;
533551 if (from_str (text, v))
534552 {
553+ if (v < m_rowfmt[i].m_min_value )
554+ {
555+ m_rowfmt[i].m_min_value = v;
556+ m_rowfmt[i].m_min_text = text;
557+ }
558+
559+ if (v > m_rowfmt[i].m_max_value )
560+ {
561+ m_rowfmt[i].m_max_value = v;
562+ m_rowfmt[i].m_max_text = text;
563+ }
564+
535565 if (v < m_colfmt[j].m_min_value )
536566 {
537567 m_colfmt[j].m_min_value = v;
@@ -573,11 +603,17 @@ std::string Reformat::format(int row, int col, const std::string& in_text) const
573603 double v;
574604 if (from_str (text, v))
575605 {
576- Column fmt = m_fmt;
606+ Line fmt = m_fmt;
577607
578- colfmt_type::const_iterator colfmt = m_colfmt.find (col);
579- if (colfmt != m_colfmt.end ())
580- fmt.apply (colfmt->second );
608+ {
609+ linefmt_type::const_iterator rowfmt = m_rowfmt.find (row);
610+ if (rowfmt != m_rowfmt.end ())
611+ fmt.apply (rowfmt->second );
612+
613+ linefmt_type::const_iterator colfmt = m_colfmt.find (col);
614+ if (colfmt != m_colfmt.end ())
615+ fmt.apply (colfmt->second );
616+ }
581617
582618 // *** Round Double Number ***
583619
@@ -655,22 +691,22 @@ std::string Reformat::format(int row, int col, const std::string& in_text) const
655691
656692 text = replace_all (text, " ," , fmt.m_grouping );
657693
658- // *** check for column minimum or maximum formatting ***
694+ // *** check for row/ column minimum or maximum formatting ***
659695
660696 DBG (" fmt: " << in_text << " - " << fmt.m_min_text );
661697
662698 if (in_text == fmt.m_min_text )
663699 {
664- if (fmt.m_min_format == Column ::MF_BOLD)
700+ if (fmt.m_min_format == Line ::MF_BOLD)
665701 text = " \\ bf " + text;
666- else if (fmt.m_min_format == Column ::MF_EMPH)
702+ else if (fmt.m_min_format == Line ::MF_EMPH)
667703 text = " \\ em " + text;
668704 }
669705 else if (in_text == fmt.m_max_text )
670706 {
671- if (fmt.m_max_format == Column ::MF_BOLD)
707+ if (fmt.m_max_format == Line ::MF_BOLD)
672708 text = " \\ bf " + text;
673- else if (fmt.m_max_format == Column ::MF_EMPH)
709+ else if (fmt.m_max_format == Line ::MF_EMPH)
674710 text = " \\ em " + text;
675711 }
676712 }
0 commit comments