double AdjustColumnRowManipulator::adjustRowHelper(const Cell& cell)
{
    double long_max = 0.0;
    const Style style = cell.effectiveStyle();
    const QSizeF size = textSize(cell.displayText(), style);
    if (size.height() > long_max)
        long_max = size.height() + style.topBorderPen().width() + style.bottomBorderPen().width();
    //  add 1 because long_max is the height of the text
    //  but row has borders
    if (long_max == 0.0)
        return -1.0;
    else
        return long_max + 1.0;
}
bool BorderColorCommand::mainProcessing()
{
    if (!m_reverse) {
        // change colors
        Style style;
        for (int i = 0; i < m_undoData.count(); ++i) {
            style.clear();
            style.insertSubStyle(m_undoData[i].second);
            QPen pen;
            if (m_undoData[i].second->type() == Style::LeftPen) {
                pen = style.leftBorderPen();
                pen.setColor(m_color);
                style.setLeftBorderPen(pen);
            }
            if (m_undoData[i].second->type() == Style::RightPen) {
                pen = style.rightBorderPen();
                pen.setColor(m_color);
                style.setRightBorderPen(pen);
            }
            if (m_undoData[i].second->type() == Style::TopPen) {
                pen = style.topBorderPen();
                pen.setColor(m_color);
                style.setTopBorderPen(pen);
            }
            if (m_undoData[i].second->type() == Style::BottomPen) {
                pen = style.bottomBorderPen();
                pen.setColor(m_color);
                style.setBottomBorderPen(pen);
            }
            if (m_undoData[i].second->type() == Style::FallDiagonalPen) {
                pen = style.fallDiagonalPen();
                pen.setColor(m_color);
                style.setFallDiagonalPen(pen);
            }
            if (m_undoData[i].second->type() == Style::GoUpDiagonalPen) {
                pen = style.goUpDiagonalPen();
                pen.setColor(m_color);
                style.setGoUpDiagonalPen(pen);
            }
            m_sheet->cellStorage()->setStyle(Region(m_undoData[i].first.toRect()), style);
        }
    } else { // m_reverse
        for (int i = 0; i < m_undoData.count(); ++i) {
            Style style;
            style.insertSubStyle(m_undoData[i].second);
            m_sheet->cellStorage()->setStyle(Region(m_undoData[i].first.toRect()), style);
        }
    }
    return true;
}