Bump version to 21.06.18.1
[LibreOffice.git] / sw / inc / swtypes.hxx
blob24e9c248b1677fcd93ef8ba4318f6828ad0e6ae3
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 .
19 #ifndef INCLUDED_SW_INC_SWTYPES_HXX
20 #define INCLUDED_SW_INC_SWTYPES_HXX
21 #include <rtl/ustring.hxx>
23 #include <limits.h>
24 #include <com/sun/star/uno/Reference.h>
25 #include <com/sun/star/i18n/CollatorOptions.hpp>
26 #include "swdllapi.h"
27 #include <o3tl/typed_flags_set.hxx>
28 #include <i18nlangtag/lang.h>
29 #include <vcl/outdev.hxx>
31 namespace com::sun::star {
32 namespace linguistic2{
33 class XLinguProperties;
34 class XSpellChecker1;
35 class XHyphenator;
36 class XThesaurus;
39 namespace utl{
40 class TransliterationWrapper;
43 class Size;
44 class SwPathFinder;
45 class Graphic;
46 class OutputDevice;
47 class CharClass;
48 class CollatorWrapper;
49 class LanguageTag;
51 typedef tools::Long SwTwips;
52 #define INVALID_TWIPS LONG_MAX
53 #define TWIPS_MAX (LONG_MAX - 1)
55 // Converts Millimeters to Twips (1 mm == 56.905479 twips).
56 template <typename T = SwTwips>
57 constexpr T MmToTwips(const double mm) { return static_cast<T>(mm / 0.017573); }
59 #define MM50 283 // 1/2 cm in TWIPS.
61 const sal_Int32 COMPLETE_STRING = SAL_MAX_INT32;
63 const SwTwips cMinHdFtHeight = 56;
65 #define MINFLY 23 // Minimal size for FlyFrames.
66 #define MINLAY 23 // Minimal size for other Frames.
68 // Default column distance of two text columns corresponds to 0.3 cm.
69 #define DEF_GUTTER_WIDTH (MM50 / 5 * 3)
71 // Minimal distance (distance to text) for border attribute
72 // in order not to crock up aligned lines.
73 // 28 Twips == 0,4mm
74 #define MIN_BORDER_DIST 28
76 // Minimal document border: 20mm.
77 const SwTwips lMinBorder = 1134;
79 // Margin left and above document.
80 // Half of it is gap between the pages.
81 //TODO: Replace with SwViewOption::defDocumentBorder
82 #define DOCUMENTBORDER 284
84 // For inserting of captions (what and where to insert).
85 // It's here because it is not big enough to justify its own hxx
86 // and does not seem to fit somewhere else.
87 enum class SwLabelType
89 Table, // Caption for a table.
90 Object, // Caption for a graphic or OLE.
91 Fly, // Caption for a text frame.
92 Draw // Caption for a draw object.
95 const sal_uInt8 MAXLEVEL = 10;
97 const sal_uInt8 NO_NUMLEVEL = 0x20; // "or" with the levels.
99 // Values for indents at numbering and bullet lists.
100 // (For more levels the values have to be multiplied with the levels+1;
101 // levels 0 ..4!)
103 const short lBulletIndent = 1440/4;
104 const short lBulletFirstLineOffset = -lBulletIndent;
105 const sal_uInt16 lNumberIndent = 1440/4;
106 const short lNumberFirstLineOffset = -lNumberIndent;
107 const short lOutlineMinTextDistance = 216; // 0.15 inch = 0.38 cm
109 // Count of SystemField-types of SwDoc.
110 #define INIT_FLDTYPES 33
112 // Count of predefined Seq-field types. It is always the last
113 // fields before INIT_FLDTYPES.
114 #define INIT_SEQ_FLDTYPES 5
116 // defined in sw/source/uibase/app/swmodule.cxx
117 SW_DLLPUBLIC OUString SwResId(const char* pId);
118 OUString SwResId(const char* pId, int nCardinality);
120 css::uno::Reference< css::linguistic2::XSpellChecker1 > GetSpellChecker();
121 css::uno::Reference< css::linguistic2::XHyphenator > GetHyphenator();
122 css::uno::Reference< css::linguistic2::XThesaurus > GetThesaurus();
123 css::uno::Reference< css::linguistic2::XLinguProperties > GetLinguPropertySet();
125 // Returns the twip size of this graphic.
126 SW_DLLPUBLIC Size GetGraphicSizeTwip( const Graphic&, vcl::RenderContext* pOutDev );
128 // Separator for jumps to different content types in document.
129 const sal_Unicode cMarkSeparator = '|';
130 // Sequences names for jumps are <name of sequence>!<no>
131 const char cSequenceMarkSeparator = '!';
133 #define DB_DELIM u'\x00ff' // Database <-> table separator.
135 enum class SetAttrMode
137 DEFAULT = 0x0000, // Default.
138 /// @attention: DONTEXPAND does not work very well for CHARATR
139 /// because it can expand only the whole AUTOFMT or nothing
140 DONTEXPAND = 0x0001, // Don't expand text attribute any further.
141 DONTREPLACE = 0x0002, // Don't replace another text attribute.
143 NOTXTATRCHR = 0x0004, // Don't insert 0xFF at attributes with no end.
144 /// attention: NOHINTADJUST prevents MergePortions!
145 /// when using this need to pay attention to ignore start/end flags of hint
146 NOHINTADJUST = 0x0008, // No merging of ranges.
147 NOFORMATATTR = 0x0010, // Do not change into format attribute.
148 APICALL = 0x0020, // Called from API (all UI related
149 // functionality will be disabled).
150 /// Force hint expand (only matters for hints with CH_TXTATR).
151 FORCEHINTEXPAND = 0x0040,
152 /// The inserted item is a copy -- intended for use in ndtxt.cxx.
153 IS_COPY = 0x0080,
154 /// for Undo, translated to SwInsertFlags::NOHINTEXPAND
155 NOHINTEXPAND = 0x0100,
157 namespace o3tl
159 template<> struct typed_flags<SetAttrMode> : is_typed_flags<SetAttrMode, 0x1ff> {};
162 constexpr bool SW_ISPRINTABLE(sal_Unicode c) { return c >= ' ' && 127 != c; }
164 #define CHAR_HARDBLANK u'\x00A0'
165 #define CHAR_HARDHYPHEN u'\x2011'
166 #define CHAR_SOFTHYPHEN u'\x00AD'
167 #define CHAR_RLM u'\x200F'
168 #define CHAR_LRM u'\x200E'
169 #define CHAR_ZWSP u'\x200B'
170 #define CHAR_ZWNBSP u'\x2060'
171 #define CHAR_NNBSP u'\x202F' //NARROW NO-BREAK SPACE
173 // Returns the APP - CharClass instance - used for all ToUpper/ToLower/...
174 SW_DLLPUBLIC CharClass& GetAppCharClass();
175 SW_DLLPUBLIC LanguageType GetAppLanguage();
176 SW_DLLPUBLIC const LanguageTag& GetAppLanguageTag();
178 #if 0
179 // I18N doesn't get this right, can't specify more than one to ignore
180 #define SW_COLLATOR_IGNORES ( \
181 css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE | \
182 css::i18n::CollatorOptions::CollatorOptions_IGNORE_KANA | \
183 css::i18n::CollatorOptions::CollatorOptions_IGNORE_WIDTH )
184 #else
185 #define SW_COLLATOR_IGNORES ( \
186 css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE )
187 #endif
189 SW_DLLPUBLIC CollatorWrapper& GetAppCollator();
190 CollatorWrapper& GetAppCaseCollator();
192 SW_DLLPUBLIC const ::utl::TransliterationWrapper& GetAppCmpStrIgnore();
194 // Official shortcut for Prepare() regarding notification of Content by the Layout.
195 // Content provides for calculation of minimal requirements at the next call of ::Format().
196 enum class PrepareHint
198 Clear, // Reformat completely.
199 WidowsOrphans, // Only check for widows and orphans and split in case of need.
200 FixSizeChanged, // FixSize has changed.
201 FollowFollows, // Follow is now possibly adjacent.
202 AdjustSizeWithoutFormatting, // Adjust size via grow/shrink without formatting.
203 FlyFrameSizeChanged, // A FlyFrame has changed its size.
204 FlyFrameAttributesChanged, // A FlyFrame has changed its attributes (e. g. wrap).
205 FlyFrameArrive, // A FlyFrame now overlaps range.
206 FlyFrameLeave, // A FlyFrame has left range.
207 FootnoteInvalidation, // Invalidation of footnotes.
208 FramePositionChanged, // Position of Frame has changed.
209 // (Check for Fly-break). In void* of Prepare()
210 // a sal_Bool& is passed. If this is sal_True,
211 // it indicates that a format has been executed.
212 ULSpaceChanged, // UL-Space has changed, TextFrames have to
213 // re-calculate line space.
214 MustFit, // Make frm fit (split) even if the attributes do
215 // not allow that (e.g. "keep together").
216 Widows, // A follow realizes that the orphan rule will be applied
217 // for it and sends a Widows to its predecessor
218 // (Master/Follow).
219 QuoVadis, // If a footnote has to be split between two paragraphs
220 // the last on the page has to receive a QUOVADIS in
221 // order to format the text into it.
222 BossChanged, // If a Frame changes its column/page this additional
223 // Prepare is sent to POS_CHGD in MoveFwd/Bwd
224 // (join Footnote-numbers etc.)
225 // Direction is communicated via pVoid:
226 // MoveFwd: pVoid == 0
227 // MoveBwd: pVoid == pOldPage
228 Register, // Invalidate frames with registers.
229 FootnoteInvalidationGone, // A Follow loses its footnote, possibly its first line can move up.
230 FootnoteMove, // A footnote changes its page. Its contents receives at first a
231 // height of zero in order to avoid too much noise. At formatting
232 // it checks whether it fits and if necessary changes its page again.
233 ErgoSum, // Needed because of movement in FootnoteFrames. Check QuoVadis/ErgoSum.
236 enum class FrameControlType
238 PageBreak,
239 Header,
240 Footer,
241 FloatingTable,
242 Outline
245 #endif
247 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */