Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
template-paper.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Contain internal sizes of paper which can be used in various
4 * functions to make and size pages.
5 *
6 * Authors:
7 * Martin Owens <doctormo@geek-2.com>
8 *
9 * Copyright (C) 2022 Authors
10 *
11 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
12 */
13
14#include "template-paper.h"
15
16#include "clear-n_.h"
17#include "extension/system.h"
18#include "extension/template.h"
19
21
26{
27 std::string orient = tmod->get_param_optiongroup("orientation", "port");
28 double min = tmod->get_param_float("min");
29 double max = tmod->get_param_float("max");
30 if (orient == "port") {
31 return Geom::Point(min, max);
32 } else if (orient == "land") {
33 return Geom::Point(max, min);
34 }
35 g_warning("Unknown orientation for paper! '%s'", orient.c_str());
36 return Geom::Point(100, 100);
37}
38
40{
41 // clang-format off
43 "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">"
44 "<id>org.inkscape.template.paper</id>"
45 "<name>" N_("Paper Sizes") "</name>"
46 "<description>" N_("Standard paper document formats") "</description>"
47 "<category>" NC_("TemplateCategory", "Print") "</category>"
48
49 "<param name='unit' gui-text='" N_("Unit") "' type='string'>mm</param>"
50 "<param name='min' gui-text='" N_("Shortest Side") "' type='float' min='1.0' max='100000.0'>210.0</param>"
51 "<param name='max' gui-text='" N_("Longest Side") "' type='float' min='1.0' max='100000.0'>297.0</param>"
52 "<param name='orientation' gui-text='" N_("Orientation") "' type='optiongroup' appearance='radio'>"
53 "<option value='port'>" N_("Portrait") "</option>"
54 "<option value='land'>" N_("Landscape") "</option>"
55 "</param>"
56
57 "<template unit='mm' icon='print_portrait' priority='-100' visibility='search'>"
58"<preset name='" N_("A4 (Portrait)") "' label='210 × 297 mm' min='210' max='297' orientation='port' priority='-110' visibility='icon'/>"
59"<preset name='" N_("A4 (Landscape)") "' label='297 × 210 mm' min='210' max='297' orientation='land' icon='print_landscape' priority='-109' visibility='icon'/>"
60"<preset name='" N_("US Letter (Portrait)") "' label='8.5 × 11 in' min='8.5' max='11' unit='in' orientation='port' icon='print_US_portrait' priority='-108' visibility='icon'/>"
61"<preset name='" N_("US Letter (Landscape)") "' label='11 × 8.5 in' min='8.5' max='11' unit='in' orientation='land' icon='print_US_landscape' priority='-107' visibility='icon'/>"
62"<preset name='" N_("A0") "' label='841 × 1189 mm' min='841' max='1189' visibility='all'/>"
63"<preset name='" N_("A1") "' label='594 × 841 mm' min='594' max='841' visibility='all'/>"
64"<preset name='" N_("A2") "' label='420 × 594 mm' min='420' max='594' visibility='all'/>"
65"<preset name='" N_("A3") "' label='297 × 420 mm' min='297' max='420' visibility='all'/>"
66"<preset name='" N_("A4") "' label='210 × 297 mm' min='210' max='297' visibility='list,search'/>"
67"<preset name='" N_("A5") "' label='148 × 210 mm' min='148' max='210' visibility='all'/>"
68"<preset name='" N_("A6") "' label='105 × 148 mm' min='105' max='148' />"
69"<preset name='" N_("A7") "' label='74 × 105 mm' min='74' max='105' />"
70"<preset name='" N_("A8") "' label='52 × 74 mm' min='52' max='74' />"
71"<preset name='" N_("A9") "' label='37 × 52 mm' min='37' max='52' />"
72"<preset name='" N_("A10") "' label='26 × 37 mm' min='26' max='37' />"
73"<preset name='" N_("B0") "' label='1000 × 1414 mm' min='1000' max='1414' />"
74"<preset name='" N_("B1") "' label='707 × 1000 mm' min='707' max='1000' />"
75"<preset name='" N_("B2") "' label='500 × 707 mm' min='500' max='707' />"
76"<preset name='" N_("B3") "' label='353 × 500 mm' min='353' max='500' />"
77"<preset name='" N_("B4") "' label='250 × 353 mm' min='250' max='353' />"
78"<preset name='" N_("B5") "' label='176 × 250 mm' min='176' max='250' />"
79"<preset name='" N_("B6") "' label='125 × 176 mm' min='125' max='176' />"
80"<preset name='" N_("B7") "' label='88 × 125 mm' min='88' max='125' />"
81"<preset name='" N_("B8") "' label='62 × 88 mm' min='62' max='88' />"
82"<preset name='" N_("B9") "' label='44 × 62 mm' min='44' max='62' />"
83"<preset name='" N_("B10") "' label='31 × 44 mm' min='31' max='44' />"
84"<preset name='" N_("C0") "' label='917 × 1297 mm' min='917' max='1297' />"
85"<preset name='" N_("C1") "' label='648 × 917 mm' min='648' max='917' />"
86"<preset name='" N_("C2") "' label='458 × 648 mm' min='458' max='648' />"
87"<preset name='" N_("C3") "' label='324 × 458 mm' min='324' max='458' />"
88"<preset name='" N_("C4") "' label='229 × 324 mm' min='229' max='324' />"
89"<preset name='" N_("C5") "' label='162 × 229 mm' min='162' max='229' />"
90"<preset name='" N_("C6") "' label='114 × 162 mm' min='114' max='162' />"
91"<preset name='" N_("C7") "' label='81 × 114 mm' min='81' max='114' />"
92"<preset name='" N_("C8") "' label='57 × 81 mm' min='57' max='81' />"
93"<preset name='" N_("C9") "' label='40 × 57 mm' min='40' max='57' />"
94"<preset name='" N_("C10") "' label='28 × 40 mm' min='28' max='40' />"
95"<preset name='" N_("D1") "' label='545 × 771 mm' min='545' max='771' />"
96"<preset name='" N_("D2") "' label='385 × 545 mm' min='385' max='545' />"
97"<preset name='" N_("D3") "' label='272 × 385 mm' min='272' max='385' />"
98"<preset name='" N_("D4") "' label='192 × 272 mm' min='192' max='272' />"
99"<preset name='" N_("D5") "' label='136 × 192 mm' min='136' max='192' />"
100"<preset name='" N_("D6") "' label='96 × 136 mm' min='96' max='136' />"
101"<preset name='" N_("D7") "' label='68 × 96 mm' min='68' max='96' />"
102"<preset name='" N_("E3") "' label='400 × 560 mm' min='400' max='560' />"
103"<preset name='" N_("E4") "' label='280 × 400 mm' min='280' max='400' />"
104"<preset name='" N_("E5") "' label='200 × 280 mm' min='200' max='280' />"
105"<preset name='" N_("E6") "' label='140 × 200 mm' min='140' max='200' />"
106"<preset name='" N_("Ledger/Tabloid") "' label='11 × 17 in' min='11' max='17' unit='in' visibility='all'/>"
107"<preset name='" N_("US Executive") "' label='7.25 × 10.5 in' min='7.25' max='10.5' unit='in' icon='print_US_portrait' visibility='all'/>"
108"<preset name='" N_("US Legal") "' label='8.5 × 14 in' min='8.5' max='14' unit='in' icon='print_US_portrait' visibility='all'/>"
109"<preset name='" N_("US Letter") "' label='8.5 × 11 in' min='8.5' max='11' unit='in' visibility='list,search'/>"
110"<preset name='" N_("DL Envelope") "' label='220 × 110 mm' min='110' max='220' orientation='land' icon='envelope_landscape' visibility='all'/>"
111"<preset name='" N_("US #10 Envelope") "' label='9.5 × 4.125 in' min='4.125' max='9.5' unit='in' orientation='land' icon='envelope_landscape' visibility='all'/>"
112"<preset name='" N_("Arch A") "' label='9 × 12 in' min='9' max='12' unit='in' />"
113"<preset name='" N_("Arch B") "' label='12 × 18 in' min='12' max='18' unit='in' />"
114"<preset name='" N_("Arch C") "' label='18 × 24 in' min='18' max='24' unit='in' />"
115"<preset name='" N_("Arch D") "' label='24 × 36 in' min='24' max='36' unit='in' />"
116"<preset name='" N_("Arch E") "' label='36 × 48 in' min='36' max='48' unit='in' />"
117"<preset name='" N_("Arch E1") "' label='30 × 42 in' min='30' max='42' unit='in' />"
118 "</template>"
119 "</inkscape-extension>",
120 std::make_unique<TemplatePaper>());
121 // clang-format on
122}
123
124} // namespace Inkscape::Extension::Internal
125
126/*
127 Local Variables:
128 mode:c++
129 c-file-style:"stroustrup"
130 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
131 indent-tabs-mode:nil
132 fill-column:99
133 End:
134*/
135// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Two-dimensional point that doubles as a vector.
Definition point.h:66
char const * get_param_optiongroup(char const *name, char const *alt) const
Like get_param_optiongroup but with a default on param_not_exist error.
double get_param_float(char const *name) const
Gets a float parameter identified by name with the double placed in value.
Geom::Point get_template_size(Inkscape::Extension::Template *tmod) const override
Return the width and height of the new page with the orientation.
A way to clear the N_ macro, which is defined as an inline function.
void build_from_mem(gchar const *buffer, std::unique_ptr< Implementation::Implementation > in_imp)
Create a module from a buffer holding an XML description.
Definition system.cpp:459