Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/i18nutil/source/utility/paper.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
#include <sal/config.h>
21
22
#include <o3tl/unit_conversion.hxx>
23
#include <o3tl/string_view.hxx>
24
#include <officecfg/Setup.hxx>
25
#include <officecfg/System.hxx>
26
#include <sal/macros.h>
27
#include <rtl/ustring.hxx>
28
#include <rtl/string.hxx>
29
#include <tools/long.hxx>
30
31
#include <i18nutil/paper.hxx>
32
33
#include <unotools/configmgr.hxx>
34
#include <com/sun/star/lang/Locale.hpp>
35
36
#ifdef UNX
37
#include <stdio.h>
38
#include <locale.h>
39
#if defined(LC_PAPER) && defined(_GNU_SOURCE)
40
#include <langinfo.h>
41
#endif
42
#endif
43
44
namespace {
45
46
struct PageDesc
47
{
48
    tools::Long m_nWidth;
49
    tools::Long m_nHeight;
50
    const char *m_pPSName;
51
    const char *m_pAltPSName;
52
};
53
54
4.18M
constexpr tools::Long PT2MM100(double v) { return o3tl::convert(v, o3tl::Length::pt, o3tl::Length::mm100) + 0.5; }
55
0
constexpr tools::Long IN2MM100(double v) { return o3tl::convert(v, o3tl::Length::in, o3tl::Length::mm100) + 0.5; }
56
0
constexpr tools::Long MM2MM100(double v) { return o3tl::convert(v, o3tl::Length::mm, o3tl::Length::mm100) + 0.5; }
57
}
58
59
//PostScript Printer Description File Format Specification
60
//http://partners.adobe.com/public/developer/en/ps/5003.PPD_Spec_v4.3.pdf
61
//https://web.archive.org/web/20040912070512/http://www.y-adagio.com/public/committees/docsii/doc_00-49/symp_ulaan/china_ppr.pdf (Kai)
62
//http://www.sls.psi.ch/controls/help/howto/Howto_Print_a_A0_Poster_at_WSLA_012_2.pdf (Dia)
63
64
//!! The order of these entries must correspond to enum Paper in <i18nutil/paper.hxx>
65
66
// see XclPaperSize pPaperSizeTable in calc and ApiPaperSize in filter
67
constexpr PageDesc aDinTab[] =
68
{
69
    { MM2MM100( 841 ),   MM2MM100( 1189 ),   "A0",  nullptr },
70
    { MM2MM100( 594 ),   MM2MM100( 841 ),    "A1",  nullptr },
71
    { MM2MM100( 420 ),   MM2MM100( 594 ),    "A2",  nullptr },
72
    { MM2MM100( 297 ),   MM2MM100( 420 ),    "A3",  nullptr },
73
    { MM2MM100( 210 ),   MM2MM100( 297 ),    "A4",  nullptr },
74
    { MM2MM100( 148 ),   MM2MM100( 210 ),    "A5",  nullptr },
75
    { MM2MM100( 250 ),   MM2MM100( 353 ),    "ISOB4",  nullptr },
76
    { MM2MM100( 176 ),   MM2MM100( 250 ),    "ISOB5",  nullptr },
77
    { IN2MM100( 8.5 ),   IN2MM100( 11 ),     "Letter",  "Note" },
78
    { IN2MM100( 8.5 ),   IN2MM100( 14 ),     "Legal",  nullptr },
79
    { IN2MM100( 11 ),    IN2MM100( 17 ),     "Tabloid",  "11x17" },
80
    { 0,                 0,                  nullptr, nullptr }, //User
81
    { MM2MM100( 125 ),   MM2MM100( 176 ),    "ISOB6",  nullptr },
82
    { MM2MM100( 229 ),   MM2MM100( 324 ),    "EnvC4",  "C4" },
83
    { MM2MM100( 162 ),   MM2MM100( 229 ),    "EnvC5",  "C5" },
84
    { MM2MM100( 114 ),   MM2MM100( 162 ),    "EnvC6",  "C6" },
85
    { MM2MM100( 114 ),   MM2MM100( 229 ),    "EnvC65", nullptr },
86
    { MM2MM100( 110 ),   MM2MM100( 220 ),    "EnvDL",  "DL" },
87
    { MM2MM100( 180),    MM2MM100( 270 ),    nullptr,  nullptr }, //Dia
88
    { MM2MM100( 210),    MM2MM100( 280 ),    nullptr,  nullptr }, //Screen 4:3
89
    { IN2MM100( 17 ),    IN2MM100( 22 ),     "AnsiC",  "CSheet" },
90
    { IN2MM100( 22 ),    IN2MM100( 34 ),     "AnsiD",  "DSheet" },
91
    { IN2MM100( 34 ),    IN2MM100( 44 ),     "AnsiE",  "ESheet" },
92
    { IN2MM100( 7.25 ),  IN2MM100( 10.5 ),   "Executive",  nullptr },
93
    //"Folio" is a different size in the PPD documentation than 8.5x11
94
    //This "FanFoldGermanLegal" is known in the Philippines as
95
    //"Legal" paper or "Long Bond Paper".  The "Legal" name causing untold
96
    //misery, given the differently sized US "Legal" paper
97
    { IN2MM100( 8.5 ),   IN2MM100( 13 ),     "FanFoldGermanLegal",  nullptr },
98
    { IN2MM100( 3.875 ), IN2MM100( 7.5 ),    "EnvMonarch", "Monarch" },
99
    { IN2MM100( 3.625 ), IN2MM100( 6.5 ),    "EnvPersonal",  "Personal" },
100
    { IN2MM100( 3.875 ), IN2MM100( 8.875 ),  "Env9",  nullptr },
101
    { IN2MM100( 4.125 ), IN2MM100( 9.5 ),    "Env10",  "Comm10" },
102
    { IN2MM100( 4.5 ),   IN2MM100( 10.375 ), "Env11",  nullptr },
103
    { IN2MM100( 4.75 ),  IN2MM100( 11 ),     "Env12",  nullptr },
104
    { MM2MM100( 184 ),   MM2MM100( 260 ),    nullptr,  nullptr }, //Kai16 / 16k
105
    { MM2MM100( 130 ),   MM2MM100( 184 ),    nullptr,  nullptr }, //Kai32
106
    { MM2MM100( 140 ),   MM2MM100( 203 ),    nullptr,  nullptr }, //BigKai32
107
    { MM2MM100( 257 ),   MM2MM100( 364 ),    "B4",  nullptr }, //JIS
108
    { MM2MM100( 182 ),   MM2MM100( 257 ),    "B5",  nullptr }, //JIS
109
    { MM2MM100( 128 ),   MM2MM100( 182 ),    "B6",  nullptr }, //JIS
110
    { IN2MM100( 17 ),    IN2MM100( 11 ),     "Ledger",  nullptr },
111
    { IN2MM100( 5.5 ),   IN2MM100( 8.5 ),    "Statement",  nullptr },
112
    { PT2MM100( 610 ),   PT2MM100( 780 ),    "Quarto",  nullptr },
113
    { IN2MM100( 10 ),    IN2MM100( 14 ),     "10x14",  nullptr },
114
    { IN2MM100( 5.5 ),   IN2MM100( 11.5 ),   "Env14",  nullptr },
115
    { MM2MM100( 324 ),   MM2MM100( 458 ),    "EnvC3",  "C3" },
116
    { MM2MM100( 110 ),   MM2MM100( 230 ),    "EnvItalian",  nullptr },
117
    { IN2MM100( 14.875 ),IN2MM100( 11 ),     "FanFoldUS",  nullptr },
118
    { IN2MM100( 8.5 ),   IN2MM100( 13 ),     "FanFoldGerman",  nullptr },
119
    { MM2MM100( 100 ),   MM2MM100( 148 ),    "Postcard",  nullptr },
120
    { IN2MM100( 9 ),     IN2MM100( 11 ),     "9x11",  nullptr },
121
    { IN2MM100( 10 ),    IN2MM100( 11 ),     "10x11",  nullptr },
122
    { IN2MM100( 15 ),    IN2MM100( 11 ),     "15x11",  nullptr },
123
    { MM2MM100( 220 ),   MM2MM100( 220 ),    "EnvInvite",  nullptr },
124
    { MM2MM100( 227 ),   MM2MM100( 356 ),    "SuperA",  nullptr },
125
    { MM2MM100( 305 ),   MM2MM100( 487 ),    "SuperB",  nullptr },
126
    { IN2MM100( 8.5 ),   IN2MM100( 12.69 ),  "LetterPlus",  nullptr },
127
    { MM2MM100( 210 ),   MM2MM100( 330 ),    "A4Plus",  nullptr },
128
    { MM2MM100( 200 ),   MM2MM100( 148 ),    "DoublePostcard",  nullptr },
129
    { MM2MM100( 105 ),   MM2MM100( 148 ),    "A6",  nullptr },
130
    { IN2MM100( 12 ),    IN2MM100( 11 ),     "12x11",  nullptr },
131
    { MM2MM100( 74 ),    MM2MM100( 105 ),    "A7",  nullptr },
132
    { MM2MM100( 52 ),    MM2MM100( 74 ),     "A8",  nullptr },
133
    { MM2MM100( 37 ),    MM2MM100( 52 ),     "A9",  nullptr },
134
    { MM2MM100( 26 ),    MM2MM100( 37 ),     "A10",  nullptr },
135
    { MM2MM100( 1000 ),  MM2MM100( 1414 ),   "ISOB0",  nullptr },
136
    { MM2MM100( 707 ),   MM2MM100( 1000 ),   "ISOB1",  nullptr },
137
    { MM2MM100( 500 ),   MM2MM100( 707 ),    "ISOB2",  nullptr },
138
    { MM2MM100( 353 ),   MM2MM100( 500 ),    "ISOB3",  nullptr },
139
    { MM2MM100( 88 ),    MM2MM100( 125 ),    "ISOB7",  nullptr },
140
    { MM2MM100( 62 ),    MM2MM100( 88 ),     "ISOB8",  nullptr },
141
    { MM2MM100( 44 ),    MM2MM100( 62 ),     "ISOB9",  nullptr },
142
    { MM2MM100( 31 ),    MM2MM100( 44 ),     "ISOB10", nullptr },
143
    { MM2MM100( 458 ),   MM2MM100( 648 ),    "EnvC2",  "C2" },
144
    { MM2MM100( 81 ),    MM2MM100( 114 ),    "EnvC7",  "C7" },
145
    { MM2MM100( 57 ),    MM2MM100( 81 ),     "EnvC8",  "C8" },
146
    { IN2MM100( 9 ),     IN2MM100( 12 ),     "ARCHA",  nullptr },
147
    { IN2MM100( 12 ),    IN2MM100( 18 ),     "ARCHB",  nullptr },
148
    { IN2MM100( 18 ),    IN2MM100( 24 ),     "ARCHC",  nullptr },
149
    { IN2MM100( 24 ),    IN2MM100( 36 ),     "ARCHD",  nullptr },
150
    { IN2MM100( 36 ),    IN2MM100( 48 ),     "ARCHE",  nullptr },
151
    { MM2MM100( 157.5),  MM2MM100( 280 ),    nullptr,  nullptr }, //Screen 16:9
152
    { MM2MM100( 175 ),   MM2MM100( 280 ),    nullptr,  nullptr }, //Screen 16:10
153
    { MM2MM100( 195 ),   MM2MM100( 270 ),    nullptr,  nullptr }, // 16k
154
    { MM2MM100( 197 ),   MM2MM100( 273 ),    nullptr,  nullptr }, // 16k
155
    { IN2MM100( 7.5 ),   IN2MM100( 13.333 ), nullptr,  nullptr }, //PowerPoint Widescreen
156
    { IN2MM100( 7.5 ),   IN2MM100( 10 ),     nullptr,  nullptr }, //PowerPoint On-screen Show (4:3)
157
    { IN2MM100( 5.625 ), IN2MM100( 10 ),     nullptr,  nullptr }, //PowerPoint On-screen Show (16:9)
158
    { IN2MM100( 6.25 ),  IN2MM100( 10 ),     nullptr,  nullptr }  //PowerPoint On-screen Show (16:10)
159
160
};
161
162
const size_t nTabSize = SAL_N_ELEMENTS(aDinTab);
163
164
// tdf#151107 make this not just large enough for rounding errors on our side
165
// but also large enough to match where the ppd side rounded up to the next
166
// point. Seen with C5/C6/C65 envelopes which can be found over 1 point away
167
// from the values in aDinTab
168
4.18M
#define MAXSLOPPY PT2MM100(1.25)
169
170
void PaperInfo::doSloppyFit(bool bAlsoTryRotated)
171
0
{
172
0
    if (m_eType != PAPER_USER)
173
0
        return;
174
175
0
    for ( size_t i = 0; i < nTabSize; ++i )
176
0
    {
177
0
        if (i == PAPER_USER) continue;
178
179
0
        tools::Long lDiffW = std::abs(aDinTab[i].m_nWidth - m_nPaperWidth);
180
0
        tools::Long lDiffH = std::abs(aDinTab[i].m_nHeight - m_nPaperHeight);
181
182
0
        if (lDiffW < MAXSLOPPY && lDiffH < MAXSLOPPY)
183
0
        {
184
0
            m_nPaperWidth = aDinTab[i].m_nWidth;
185
0
            m_nPaperHeight = aDinTab[i].m_nHeight;
186
0
            m_eType = static_cast<Paper>(i);
187
0
            return;
188
0
        }
189
0
    }
190
191
0
    if (bAlsoTryRotated)
192
0
    {
193
0
        std::swap(m_nPaperWidth, m_nPaperHeight);
194
0
        doSloppyFit();
195
0
        std::swap(m_nPaperWidth, m_nPaperHeight);
196
0
    }
197
0
}
198
199
bool PaperInfo::sloppyEqual(const PaperInfo &rOther) const
200
0
{
201
0
    return
202
0
    (
203
0
      (std::abs(m_nPaperWidth - rOther.m_nPaperWidth) < MAXSLOPPY) &&
204
0
      (std::abs(m_nPaperHeight - rOther.m_nPaperHeight) < MAXSLOPPY)
205
0
    );
206
0
}
207
208
tools::Long PaperInfo::sloppyFitPageDimension(tools::Long nDimension)
209
96.7k
{
210
2.15M
    for ( size_t i = 0; i < nTabSize; ++i )
211
2.13M
    {
212
2.13M
        if (i == PAPER_USER) continue;
213
2.11M
        tools::Long lDiff;
214
215
2.11M
        lDiff = std::abs(aDinTab[i].m_nWidth - nDimension);
216
2.11M
        if ( lDiff < MAXSLOPPY )
217
48.4k
            return aDinTab[i].m_nWidth;
218
219
2.06M
        lDiff = std::abs(aDinTab[i].m_nHeight - nDimension);
220
2.06M
        if ( lDiff < MAXSLOPPY )
221
31.3k
            return aDinTab[i].m_nHeight;
222
2.06M
    }
223
16.9k
    return nDimension;
224
96.7k
}
225
226
PaperInfo PaperInfo::getSystemDefaultPaper()
227
364k
{
228
364k
    if (comphelper::IsFuzzing())
229
364k
        return PaperInfo(PAPER_A4);
230
231
0
    OUString aLocaleStr = officecfg::Setup::L10N::ooSetupSystemLocale::get();
232
233
0
#ifdef UNX
234
    // if set to "use system", get papersize from system
235
0
    if (aLocaleStr.isEmpty())
236
0
    {
237
0
        static bool bInitialized = false;
238
0
        static PaperInfo aInstance(PAPER_A4);
239
240
0
        if (bInitialized)
241
0
            return aInstance;
242
243
0
#if ! defined(MACOSX) && ! defined(EMSCRIPTEN)
244
        // try libpaper
245
        // #i78617# workaround missing paperconf command
246
0
        FILE* pPipe = popen( "paperconf 2>/dev/null", "r" );
247
0
        if( pPipe )
248
0
        {
249
0
            Paper ePaper = PAPER_USER;
250
251
0
            char aBuffer[ 1024 ];
252
0
            aBuffer[0] = 0;
253
0
            char *pBuffer = fgets( aBuffer, sizeof(aBuffer), pPipe );
254
0
            bool bOk = pclose(pPipe) == 0;
255
256
0
            if (bOk && pBuffer && *pBuffer != 0)
257
0
            {
258
0
                std::string_view aPaper(pBuffer);
259
0
                aPaper = o3tl::trim(aPaper);
260
0
                static constexpr struct { std::string_view aName; Paper ePaper; } aCustoms [] =
261
0
                {
262
0
                    { "B0",   PAPER_B0_ISO },
263
0
                    { "B1",   PAPER_B1_ISO },
264
0
                    { "B2",   PAPER_B2_ISO },
265
0
                    { "B3",   PAPER_B3_ISO },
266
0
                    { "B4",   PAPER_B4_ISO },
267
0
                    { "B5",   PAPER_B5_ISO },
268
0
                    { "B6",   PAPER_B6_ISO },
269
0
                    { "B7",   PAPER_B7_ISO },
270
0
                    { "B8",   PAPER_B8_ISO },
271
0
                    { "B9",   PAPER_B9_ISO },
272
0
                    { "B10",  PAPER_B10_ISO },
273
0
                    { "folio", PAPER_FANFOLD_LEGAL_DE },
274
0
                    { "flsa",  PAPER_FANFOLD_LEGAL_DE },
275
0
                    { "flse",  PAPER_FANFOLD_LEGAL_DE }
276
0
                };
277
278
0
                bool bHalve = false;
279
280
0
                size_t const nExtraTabSize = SAL_N_ELEMENTS(aCustoms);
281
0
                for (size_t i = 0; i < nExtraTabSize; ++i)
282
0
                {
283
0
                    if (o3tl::equalsIgnoreAsciiCase(aCustoms[i].aName, aPaper))
284
0
                    {
285
0
                        ePaper = aCustoms[i].ePaper;
286
0
                        break;
287
0
                    }
288
0
                }
289
290
0
                if (ePaper == PAPER_USER)
291
0
                {
292
0
                    bHalve = o3tl::starts_with(aPaper, "half", &aPaper);
293
0
                    ePaper = PaperInfo::fromPSName(aPaper);
294
0
                }
295
296
0
                if (ePaper != PAPER_USER)
297
0
                {
298
0
                    aInstance = PaperInfo(ePaper);
299
0
                    if (bHalve)
300
0
                        aInstance = PaperInfo(aInstance.getHeight()/2, aInstance.getWidth());
301
0
                    bInitialized = true;
302
0
                    return aInstance;
303
0
                }
304
0
            }
305
0
        }
306
0
#endif
307
308
// _NL_PAPER_WIDTH / HEIGHT not available with android unified headers
309
0
#if defined(LC_PAPER) && defined(_GNU_SOURCE) && !defined(ANDROID)
310
        // try LC_PAPER
311
0
        locale_t loc = newlocale(LC_PAPER_MASK, "", static_cast<locale_t>(0));
312
0
        if (loc != static_cast<locale_t>(0))
313
0
        {
314
0
            union paperword { char *string; int word; };
315
0
            paperword w, h;
316
0
            w.string = nl_langinfo_l(_NL_PAPER_WIDTH, loc);
317
0
            h.string = nl_langinfo_l(_NL_PAPER_HEIGHT, loc);
318
319
0
            freelocale(loc);
320
321
            //glibc stores sizes as integer mm units
322
0
            w.word *= 100;
323
0
            h.word *= 100;
324
325
0
            for ( size_t i = 0; i < nTabSize; ++i )
326
0
            {
327
0
                if (i == PAPER_USER) continue;
328
329
                //glibc stores sizes as integer mm units, and so is inaccurate.
330
                //To find a standard paper size we calculate the standard paper
331
                //sizes into equally inaccurate mm and compare
332
0
                tools::Long width = (aDinTab[i].m_nWidth + 50) / 100;
333
0
                tools::Long height = (aDinTab[i].m_nHeight + 50) / 100;
334
335
0
                if (width == w.word/100 && height == h.word/100)
336
0
                {
337
0
                    w.word = aDinTab[i].m_nWidth;
338
0
                    h.word = aDinTab[i].m_nHeight;
339
0
                    break;
340
0
                }
341
0
            }
342
343
0
            aInstance = PaperInfo(w.word, h.word);
344
0
            bInitialized = true;
345
0
            return aInstance;
346
0
        }
347
0
#endif
348
0
    }
349
0
#endif
350
351
    // if set to "use system", try to get locale from system
352
0
    if (aLocaleStr.isEmpty())
353
0
        aLocaleStr = officecfg::System::L10N::Locale::get();
354
355
0
    static constexpr OUStringLiteral EN_US = u"en-US";
356
0
    if (aLocaleStr.isEmpty())
357
0
        aLocaleStr = EN_US;
358
359
    // convert locale string to locale struct
360
0
    css::lang::Locale aSysLocale;
361
0
    sal_Int32 nDashPos = aLocaleStr.indexOf( '-' );
362
0
    if( nDashPos < 0 ) nDashPos = aLocaleStr.getLength();
363
0
    aSysLocale.Language = aLocaleStr.copy( 0, nDashPos );
364
0
    if( nDashPos + 1 < aLocaleStr.getLength() )
365
0
        aSysLocale.Country = aLocaleStr.copy( nDashPos + 1 );
366
367
0
    return PaperInfo::getDefaultPaperForLocale(aSysLocale);
368
0
}
369
370
525k
PaperInfo::PaperInfo(Paper eType) : m_eType(eType)
371
525k
{
372
525k
    static_assert( SAL_N_ELEMENTS(aDinTab) == NUM_PAPER_ENTRIES,
373
525k
            "mismatch between array entries and enum values" );
374
375
525k
    m_nPaperWidth = aDinTab[m_eType].m_nWidth;
376
525k
    m_nPaperHeight = aDinTab[m_eType].m_nHeight;
377
525k
}
378
379
PaperInfo::PaperInfo(tools::Long nPaperWidth, tools::Long nPaperHeight)
380
0
    : m_eType(PAPER_USER),
381
0
      m_nPaperWidth(nPaperWidth),
382
0
      m_nPaperHeight(nPaperHeight)
383
0
{
384
0
    for ( size_t i = 0; i < nTabSize; ++i )
385
0
    {
386
0
        if (
387
0
             (nPaperWidth == aDinTab[i].m_nWidth) &&
388
0
             (nPaperHeight == aDinTab[i].m_nHeight)
389
0
           )
390
0
        {
391
0
            m_eType = static_cast<Paper>(i);
392
0
            break;
393
0
        }
394
0
    }
395
0
}
396
397
OString PaperInfo::toPSName(Paper ePaper)
398
0
{
399
0
    return static_cast<size_t>(ePaper) < nTabSize && aDinTab[ePaper].m_pPSName ?  OString(aDinTab[ePaper].m_pPSName) : OString();
400
0
}
401
402
Paper PaperInfo::fromPSName(std::string_view rName)
403
0
{
404
0
    if (rName.empty())
405
0
        return PAPER_USER;
406
407
0
    for ( size_t i = 0; i < nTabSize; ++i )
408
0
    {
409
0
        if (aDinTab[i].m_pPSName &&
410
0
          o3tl::equalsIgnoreAsciiCase(aDinTab[i].m_pPSName, rName))
411
0
        {
412
0
            return static_cast<Paper>(i);
413
0
        }
414
0
        else if (aDinTab[i].m_pAltPSName &&
415
0
          o3tl::equalsIgnoreAsciiCase(aDinTab[i].m_pAltPSName, rName))
416
0
        {
417
0
            return static_cast<Paper>(i);
418
0
        }
419
0
    }
420
421
0
    return PAPER_USER;
422
0
}
423
424
//http://wiki.openoffice.org/wiki/DefaultPaperSize
425
//http://www.unicode.org/cldr/data/charts/supplemental/territory_language_information.html
426
//http://sourceware.org/git/?p=glibc.git;a=tree;f=localedata/locales
427
//http://en.wikipedia.org/wiki/Paper_size
428
//http://msdn.microsoft.com/en-us/library/cc195164.aspx
429
PaperInfo PaperInfo::getDefaultPaperForLocale( const css::lang::Locale & rLocale )
430
0
{
431
0
    Paper eType = PAPER_A4;
432
433
0
    if (
434
        //United States, Letter
435
0
        rLocale.Country == "US" ||
436
        //Puerto Rico:
437
        //    http://unicode.org/cldr/trac/ticket/1710
438
        //    http://sources.redhat.com/ml/libc-hacker/2001-07/msg00046.html
439
0
        rLocale.Country == "PR" ||
440
        //Canada:
441
        //    http://sources.redhat.com/ml/libc-hacker/2001-07/msg00053.html
442
0
        rLocale.Country == "CA" ||
443
        //Venuzuela:
444
        //    http://unicode.org/cldr/trac/ticket/1710
445
        //    https://www.redhat.com/archives/fedora-devel-list/2008-August/msg00019.html
446
0
        rLocale.Country == "VE" ||
447
        //Chile:
448
        //    http://unicode.org/cldr/trac/ticket/1710
449
        //    https://www.redhat.com/archives/fedora-devel-list/2008-August/msg00240.html
450
0
        rLocale.Country == "CL" ||
451
        //Mexico:
452
        //    http://unicode.org/cldr/trac/ticket/1710
453
        //    http://qa.openoffice.org/issues/show_bug.cgi?id=49739
454
0
        rLocale.Country == "MX" ||
455
        //Colombia:
456
        //    http://unicode.org/cldr/trac/ticket/1710
457
        //    http://qa.openoffice.org/issues/show_bug.cgi?id=69703
458
0
        rLocale.Country == "CO" ||
459
        //Philippines:
460
        //    http://unicode.org/cldr/trac/ticket/1710
461
        //    http://ubuntuliving.blogspot.com/2008/07/default-paper-size-in-evince.html
462
        //    http://www.gov.ph/faqs/driverslicense.asp
463
0
        rLocale.Country == "PH" ||
464
        //Belize:
465
        //    http://unicode.org/cldr/trac/ticket/2585
466
        //    http://www.belize.gov.bz/ct.asp?xItem=1666&ctNode=486&mp=27
467
0
        rLocale.Country == "BZ" ||
468
        //Costa Rica:
469
        //    http://unicode.org/cldr/trac/ticket/2585
470
        //    http://sources.redhat.com/bugzilla/show_bug.cgi?id=11258
471
0
        rLocale.Country == "CR" ||
472
        //Guatemala:
473
        //    http://unicode.org/cldr/trac/ticket/2585
474
        //    http://sources.redhat.com/bugzilla/show_bug.cgi?id=10936
475
0
        rLocale.Country == "GT" ||
476
        //Nicaragua:
477
        //    http://unicode.org/cldr/trac/ticket/2585
478
0
        rLocale.Country == "NI" ||
479
        //Panama:
480
        //    http://unicode.org/cldr/trac/ticket/2585
481
        //    http://www.minsa.gob.pa/minsa/tl_files/documents/baner_informativo/INSTRUMENTO%20DE%20INVESTIGACION%20DE%20RAAV%202009.pdf
482
0
        rLocale.Country == "PA" ||
483
        //El Salvador:
484
        //    http://unicode.org/cldr/trac/ticket/2585
485
        //    http://www.tse.gob.sv
486
0
        rLocale.Country == "SV"
487
0
       )
488
0
    {
489
0
        eType = PAPER_LETTER;
490
0
    }
491
492
0
    return eType;
493
0
}
494
495
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */