14#include <glibmm/i18n.h>
29 static std::vector<PaperSize> ret;
33 if (!g_file_test(path.c_str(), G_FILE_TEST_EXISTS)) {
34 if (!g_file_set_contents(path.c_str(),
pages_skeleton, -1,
nullptr)) {
35 g_warning(
"%s", _(
"Failed to create the page file."));
38 gchar *content =
nullptr;
39 if (g_file_get_contents(path.c_str(), &content,
nullptr,
nullptr)) {
40 gchar **lines = g_strsplit_set(content,
"\n", 0);
42 for (
int i = 0; lines && lines[i]; ++i) {
43 gchar **line = g_strsplit_set(lines[i],
",", 5);
44 if (!line[0] || !line[1] || !line[2] || !line[3] || line[0][0]==
'#')
48 double width = g_ascii_strtod(line[1],
nullptr);
49 double height = g_ascii_strtod(line[2],
nullptr);
52 Glib::ustring
name = line[0];
98 snprintf(
buf, 19,
"%0.1f", val);
99 auto ret = std::string(
buf);
101 if ((ret.length() > 2) && (ret.back() ==
'0')) {
102 ret = ret.substr(0, ret.length() - 2);
112 auto [smaller, larger] = std::minmax(
width,
height);
122 auto [smaller, larger] = std::minmax(
width,
height);
132 auto tollerance = px->convert(0.5, page_size.unit);
static bool cmp(std::pair< Glib::ustring, Glib::ustring > const &a, std::pair< Glib::ustring, Glib::ustring > const &b)
Compare function.
Two-dimensional point that doubles as a vector.
Data class used to store common paper dimensions from pages.csv.
Inkscape::Util::Unit const * unit
static const std::vector< PaperSize > & getPageSizes()
Returns a list of page sizes.
static std::string toDescription(std::string name, double x, double y, Inkscape::Util::Unit const *unit)
static std::string toDimsString(double x, double y, Util::Unit const *unit)
std::string getDescription(bool landscape) const
pointer to object in UnitTable, do not delete
static const PaperSize * findPaperSize(double width, double height, Inkscape::Util::Unit const *unit)
Returns a matching paper size, if possible.
static std::string formatNumber(double val)
void assign(const PaperSize &other)
Unit const * getUnit(Glib::ustring const &name) const
Retrieve a given unit based on its string identifier.
double convert(double from_dist, Unit const *to) const
Convert value from this unit.
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)
std::string profile_path()
Helper class to stream background task notifications as a series of messages.
static char const pages_skeleton[]
Inkscape::IO::Resource - simple resource API.