Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / i18nutil / paper.hxx
blobb84d7b3af074efa7af81cc9f93f0e32067f681a7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_I18NUTIL_PAPER_HXX
21 #define INCLUDED_I18NUTIL_PAPER_HXX
23 #include <i18nutil/i18nutildllapi.h>
24 #include <rtl/string.hxx>
25 #include <tools/long.hxx>
27 namespace com::sun::star::lang
29 struct Locale;
32 //!! The values of the following enumerators must correspond to the array position
33 //!! of the respective paper size in the file i18nutil/source/utility/paper.cxx
34 //!! Thus don't reorder the enum values here without changing the code there as well.
36 //!! Also the RID_STR_PAPERNAMES array in vcl/inc/print.hrc and the
37 //!! PaperIndex array in Printer::GetPaperName() in
38 //!! vcl/source/gdi/print.cxx are parallel to this enum.
39 enum Paper : unsigned
41 PAPER_A0,
42 PAPER_A1,
43 PAPER_A2,
44 PAPER_A3,
45 PAPER_A4,
46 PAPER_A5,
47 PAPER_B4_ISO,
48 PAPER_B5_ISO,
49 PAPER_LETTER,
50 PAPER_LEGAL,
51 PAPER_TABLOID,
52 PAPER_USER,
53 PAPER_B6_ISO,
54 PAPER_ENV_C4,
55 PAPER_ENV_C5,
56 PAPER_ENV_C6,
57 PAPER_ENV_C65,
58 PAPER_ENV_DL,
59 PAPER_SLIDE_DIA,
60 PAPER_SCREEN_4_3,
61 PAPER_C,
62 PAPER_D,
63 PAPER_E,
64 PAPER_EXECUTIVE,
65 PAPER_FANFOLD_LEGAL_DE,
66 PAPER_ENV_MONARCH,
67 PAPER_ENV_PERSONAL,
68 PAPER_ENV_9,
69 PAPER_ENV_10,
70 PAPER_ENV_11,
71 PAPER_ENV_12,
72 PAPER_KAI16,
73 PAPER_KAI32,
74 PAPER_KAI32BIG,
75 PAPER_B4_JIS,
76 PAPER_B5_JIS,
77 PAPER_B6_JIS,
78 PAPER_LEDGER,
79 PAPER_STATEMENT,
80 PAPER_QUARTO,
81 PAPER_10x14,
82 PAPER_ENV_14,
83 PAPER_ENV_C3,
84 PAPER_ENV_ITALY,
85 PAPER_FANFOLD_US,
86 PAPER_FANFOLD_DE,
87 PAPER_POSTCARD_JP,
88 PAPER_9x11,
89 PAPER_10x11,
90 PAPER_15x11,
91 PAPER_ENV_INVITE,
92 PAPER_A_PLUS,
93 PAPER_B_PLUS,
94 PAPER_LETTER_PLUS,
95 PAPER_A4_PLUS,
96 PAPER_DOUBLEPOSTCARD_JP,
97 PAPER_A6,
98 PAPER_12x11,
99 PAPER_A7,
100 PAPER_A8,
101 PAPER_A9,
102 PAPER_A10,
103 PAPER_B0_ISO,
104 PAPER_B1_ISO,
105 PAPER_B2_ISO,
106 PAPER_B3_ISO,
107 PAPER_B7_ISO,
108 PAPER_B8_ISO,
109 PAPER_B9_ISO,
110 PAPER_B10_ISO,
111 PAPER_ENV_C2,
112 PAPER_ENV_C7,
113 PAPER_ENV_C8,
114 PAPER_ARCHA,
115 PAPER_ARCHB,
116 PAPER_ARCHC,
117 PAPER_ARCHD,
118 PAPER_ARCHE,
119 PAPER_SCREEN_16_9,
120 PAPER_SCREEN_16_10,
121 PAPER_16K_195x270,
122 PAPER_16K_197x273,
123 PAPER_WIDESCREEN, //PowerPoint Widescreen
124 PAPER_ONSCREENSHOW_4_3, //PowerPoint On-screen Show (4:3)
125 PAPER_ONSCREENSHOW_16_9, //PowerPoint On-screen Show (16:9)
126 PAPER_ONSCREENSHOW_16_10 //PowerPoint On-screen Show (16:10)
129 // defined for 'equal size' test with the implementation array
130 #define NUM_PAPER_ENTRIES (PAPER_ONSCREENSHOW_16_10 - PAPER_A0 + 1)
132 class I18NUTIL_DLLPUBLIC PaperInfo
134 Paper m_eType;
135 tools::Long m_nPaperWidth; // width in 100thMM
136 tools::Long m_nPaperHeight; // height in 100thMM
137 public:
138 PaperInfo(Paper eType);
139 PaperInfo(tools::Long nPaperWidth, tools::Long nPaperHeight);
141 Paper getPaper() const { return m_eType; }
142 tools::Long getWidth() const { return m_nPaperWidth; }
143 tools::Long getHeight() const { return m_nPaperHeight; }
144 bool sloppyEqual(const PaperInfo& rOther) const;
145 void doSloppyFit(bool bAlsoTryRotated = false);
147 static PaperInfo getSystemDefaultPaper();
148 static PaperInfo getDefaultPaperForLocale(const css::lang::Locale& rLocale);
150 static Paper fromPSName(const OString& rName);
151 static OString toPSName(Paper eType);
153 static tools::Long sloppyFitPageDimension(tools::Long nDimension);
156 #endif // INCLUDED_I18NUTIL_PAPER_HXX
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */