1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
24 #include <com/sun/star/uno/Reference.h>
25 #include <com/sun/star/i18n/CollatorOptions.hpp>
27 #include <o3tl/typed_flags_set.hxx>
28 #include <o3tl/unit_conversion.hxx>
29 #include <i18nlangtag/lang.h>
30 #include <vcl/outdev.hxx>
31 #include <unotools/resmgr.hxx>
33 namespace com::sun::star
{
34 namespace linguistic2
{
35 class XLinguProperties
;
42 class TransliterationWrapper
;
50 class CollatorWrapper
;
53 typedef tools::Long SwTwips
;
54 #define INVALID_TWIPS LONG_MAX
55 #define TWIPS_MAX (LONG_MAX - 1)
57 constexpr sal_Int32 COMPLETE_STRING
= SAL_MAX_INT32
;
59 constexpr SwTwips cMinHdFtHeight
= 56; // ~1mm
61 #define MINFLY 23 // Minimal size for FlyFrames.
62 #define MINLAY 23 // Minimal size for other Frames.
64 // Default column distance of two text columns corresponds to 0.3 cm.
65 constexpr SwTwips DEF_GUTTER_WIDTH
= o3tl::toTwips(3, o3tl::Length::mm
);
67 // Minimal distance (distance to text) for border attribute
68 // in order not to crock up aligned lines.
70 constexpr SwTwips MIN_BORDER_DIST
= 28; // ~0.5mm
72 // Minimal document border: 20mm.
73 constexpr tools::Long
lMinBorderInMm(20);
74 constexpr SwTwips lMinBorder
= o3tl::toTwips(lMinBorderInMm
, o3tl::Length::mm
);
76 // Margin left and above document.
77 // Half of it is gap between the pages.
78 //TODO: Replace with SwViewOption::defDocumentBorder
79 constexpr SwTwips DOCUMENTBORDER
= 284; // ~5mm
81 // For inserting of captions (what and where to insert).
82 // It's here because it is not big enough to justify its own hxx
83 // and does not seem to fit somewhere else.
84 enum class SwLabelType
86 Table
, // Caption for a table.
87 Object
, // Caption for a graphic or OLE.
88 Fly
, // Caption for a text frame.
89 Draw
// Caption for a draw object.
92 constexpr sal_uInt8 MAXLEVEL
= 10;
94 // Values for indents at numbering and bullet lists.
95 // (For more levels the values have to be multiplied with the levels+1;
98 constexpr short lBulletIndent
= o3tl::toTwips(25, o3tl::Length::in100
); // 0.25 inch
99 constexpr short lBulletFirstLineOffset
= -lBulletIndent
;
100 constexpr sal_uInt16 lNumberIndent
= o3tl::toTwips(25, o3tl::Length::in100
); // 0.25 inch
101 constexpr short lNumberFirstLineOffset
= -lNumberIndent
;
102 constexpr short lOutlineMinTextDistance
= o3tl::toTwips(15, o3tl::Length::in100
); // 0.15 inch = 0.38 cm
104 // Count of SystemField-types of SwDoc.
105 #define INIT_FLDTYPES 33
107 // Count of predefined Seq-field types. It is always the last
108 // fields before INIT_FLDTYPES.
109 #define INIT_SEQ_FLDTYPES 5
111 // defined in sw/source/uibase/app/swmodule.cxx
112 SW_DLLPUBLIC OUString
SwResId(TranslateId aId
);
113 OUString
SwResId(TranslateNId aContextSingularPlural
, int nCardinality
);
115 css::uno::Reference
< css::linguistic2::XSpellChecker1
> GetSpellChecker();
116 css::uno::Reference
< css::linguistic2::XHyphenator
> GetHyphenator();
117 css::uno::Reference
< css::linguistic2::XThesaurus
> GetThesaurus();
118 css::uno::Reference
< css::linguistic2::XLinguProperties
> GetLinguPropertySet();
120 // Returns the twip size of this graphic.
121 SW_DLLPUBLIC Size
GetGraphicSizeTwip( const Graphic
&, vcl::RenderContext
* pOutDev
);
123 // Separator for jumps to different content types in document.
124 const sal_Unicode cMarkSeparator
= '|';
125 // Sequences names for jumps are <name of sequence>!<no>
126 const char cSequenceMarkSeparator
= '!';
127 /// separator for toxmarks: #<no>%19<text>%19<type><typename>|toxmark
128 sal_Unicode
const toxMarkSeparator
= '\u0019';
130 #define DB_DELIM u'\x00ff' // Database <-> table separator.
132 enum class SetAttrMode
134 DEFAULT
= 0x0000, // Default.
135 /// @attention: DONTEXPAND does not work very well for CHARATR
136 /// because it can expand only the whole AUTOFMT or nothing
137 DONTEXPAND
= 0x0001, // Don't expand text attribute any further.
138 DONTREPLACE
= 0x0002, // Don't replace another text attribute.
140 NOTXTATRCHR
= 0x0004, // Don't insert 0xFF at attributes with no end.
141 /// attention: NOHINTADJUST prevents MergePortions!
142 /// when using this need to pay attention to ignore start/end flags of hint
143 NOHINTADJUST
= 0x0008, // No merging of ranges.
144 NOFORMATATTR
= 0x0010, // Do not change into format attribute.
145 APICALL
= 0x0020, // Called from API (all UI related
146 // functionality will be disabled).
147 /// Force hint expand (only matters for hints with CH_TXTATR).
148 FORCEHINTEXPAND
= 0x0040,
149 /// The inserted item is a copy -- intended for use in ndtxt.cxx.
151 /// for Undo, translated to SwInsertFlags::NOHINTEXPAND
152 NOHINTEXPAND
= 0x0100,
153 /// don't change the cursor position
154 NO_CURSOR_CHANGE
= 0x0200,
155 // remove all char attributes and char styles when para/char styles are applied
156 REMOVE_ALL_ATTR
= 0x0400
160 template<> struct typed_flags
<SetAttrMode
> : is_typed_flags
<SetAttrMode
, 0x7ff> {};
165 enum class GetTextAttrMode
{
166 Default
, /// DEFAULT: (Start <= nIndex < End)
167 Expand
, /// EXPAND : (Start < nIndex <= End)
168 Parent
, /// PARENT : (Start < nIndex < End)
173 constexpr bool SW_ISPRINTABLE(sal_Unicode c
) { return c
>= ' ' && 127 != c
; }
175 #define CHAR_HARDBLANK u'\x00A0'
176 #define CHAR_HARDHYPHEN u'\x2011'
177 #define CHAR_SOFTHYPHEN u'\x00AD'
178 #define CHAR_RLM u'\x200F'
179 #define CHAR_LRM u'\x200E'
180 #define CHAR_ZWSP u'\x200B'
181 #define CHAR_WJ u'\x2060'
182 #define CHAR_NNBSP u'\x202F' //NARROW NO-BREAK SPACE
184 inline constexpr OUString vEnSpaces
= u
"\u2002\u2002\u2002\u2002\u2002"_ustr
;
186 // Returns the APP - CharClass instance - used for all ToUpper/ToLower/...
187 SW_DLLPUBLIC CharClass
& GetAppCharClass();
188 SW_DLLPUBLIC LanguageType
GetAppLanguage();
189 SW_DLLPUBLIC
const LanguageTag
& GetAppLanguageTag();
192 // I18N doesn't get this right, can't specify more than one to ignore
193 #define SW_COLLATOR_IGNORES ( \
194 css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE | \
195 css::i18n::CollatorOptions::CollatorOptions_IGNORE_KANA | \
196 css::i18n::CollatorOptions::CollatorOptions_IGNORE_WIDTH )
198 #define SW_COLLATOR_IGNORES ( \
199 css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE )
202 SW_DLLPUBLIC CollatorWrapper
& GetAppCollator();
203 CollatorWrapper
& GetAppCaseCollator();
205 SW_DLLPUBLIC
const ::utl::TransliterationWrapper
& GetAppCmpStrIgnore();
207 // Official shortcut for Prepare() regarding notification of Content by the Layout.
208 // Content provides for calculation of minimal requirements at the next call of ::Format().
209 enum class PrepareHint
211 Clear
, // Reformat completely.
212 WidowsOrphans
, // Only check for widows and orphans and split in case of need.
213 FixSizeChanged
, // FixSize has changed.
214 FollowFollows
, // Follow is now possibly adjacent.
215 AdjustSizeWithoutFormatting
, // Adjust size via grow/shrink without formatting.
216 FlyFrameSizeChanged
, // A FlyFrame has changed its size.
217 FlyFrameAttributesChanged
, // A FlyFrame has changed its attributes (e. g. wrap).
218 FlyFrameArrive
, // A FlyFrame now overlaps range.
219 FlyFrameLeave
, // A FlyFrame has left range.
220 FootnoteInvalidation
, // Invalidation of footnotes.
221 FramePositionChanged
, // Position of Frame has changed.
222 // (Check for Fly-break). In void* of Prepare()
223 // a sal_Bool& is passed. If this is sal_True,
224 // it indicates that a format has been executed.
225 ULSpaceChanged
, // UL-Space has changed, TextFrames have to
226 // re-calculate line space.
227 MustFit
, // Make frm fit (split) even if the attributes do
228 // not allow that (e.g. "keep together").
229 Widows
, // A follow realizes that the orphan rule will be applied
230 // for it and sends a Widows to its predecessor
232 QuoVadis
, // If a footnote has to be split between two paragraphs
233 // the last on the page has to receive a QUOVADIS in
234 // order to format the text into it.
235 BossChanged
, // If a Frame changes its column/page this additional
236 // Prepare is sent to POS_CHGD in MoveFwd/Bwd
237 // (join Footnote-numbers etc.)
238 // Direction is communicated via pVoid:
239 // MoveFwd: pVoid == 0
240 // MoveBwd: pVoid == pOldPage
241 Register
, // Invalidate frames with registers.
242 FootnoteInvalidationGone
, // A Follow loses its footnote, possibly its first line can move up.
243 FootnoteMove
, // A footnote changes its page. Its contents receives at first a
244 // height of zero in order to avoid too much noise. At formatting
245 // it checks whether it fits and if necessary changes its page again.
246 ErgoSum
, // Needed because of movement in FootnoteFrames. Check QuoVadis/ErgoSum.
249 enum class FrameControlType
261 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */