Example #1
0
cell_reference worksheet::get_point_pos(int left, int top) const
{
    static const double DefaultColumnWidth = 51.85;
    static const double DefaultRowHeight = 15.0;

    auto points_to_pixels = [](long double value, long double dpi)
    {
        return static_cast<int>(std::ceil(value * dpi / 72));
    };

    auto default_height = points_to_pixels(DefaultRowHeight, 96.0);
    auto default_width = points_to_pixels(DefaultColumnWidth, 96.0);

    column_t current_column = 1;
    row_t current_row = 1;

    int left_pos = 0;
    int top_pos = 0;

    while (left_pos <= left)
    {
        current_column++;

        if (has_column_properties(current_column))
        {
            auto cdw = get_column_properties(current_column).width;

            if (cdw >= 0)
            {
                left_pos += points_to_pixels(cdw, 96.0);
                continue;
            }
        }

        left_pos += default_width;
    }

    while (top_pos <= top)
    {
        current_row++;

        if (has_row_properties(current_row))
        {
            auto cdh = get_row_properties(current_row).height;

            if (cdh >= 0)
            {
                top_pos += points_to_pixels(cdh, 96.0);
                continue;
            }
        }

        top_pos += default_height;
    }

    return { current_column - 1, current_row - 1 };
}
Example #2
0
double worksheet::column_width(column_t column) const
{
    static const auto DefaultColumnWidth = 51.85;

    if (has_column_properties(column))
    {
        return column_properties(column).width.get();
    }
    else
    {
        return points_to_pixels(DefaultColumnWidth, 96.0);
    }
}