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>
22 #include <tools/resid.hxx>
23 #include <tools/solar.h>
24 #include <tools/mapunit.hxx>
25 #include <SwGetPoolIdFromName.hxx>
28 #include <com/sun/star/uno/Reference.h>
30 #include <i18nlangtag/languagetag.hxx>
31 #include <o3tl/typed_flags_set.hxx>
32 #include <svx/swframetypes.hxx>
34 namespace com
{ namespace sun
{ namespace star
{
35 namespace linguistic2
{
36 class XDictionaryList
;
37 class XLinguProperties
;
47 class TransliterationWrapper
;
56 class LocaleDataWrapper
;
57 class CollatorWrapper
;
60 #define INVALID_TWIPS LONG_MAX
61 #define TWIPS_MAX (LONG_MAX - 1)
63 // Converts Millimeters to Twips (1 mm == 56.905479 twips).
64 template <typename T
= SwTwips
>
65 constexpr T
MmToTwips(const double mm
) { return static_cast<T
>(mm
/ 0.017573); }
67 #define MM50 283 // 1/2 cm in TWIPS.
69 const sal_Int32 COMPLETE_STRING
= SAL_MAX_INT32
;
71 const SwTwips cMinHdFtHeight
= 56;
73 #define MINFLY 23 // Minimal size for FlyFrames.
74 #define MINLAY 23 // Minimal size for other Frames.
76 // Default column distance of two text columns corresponds to 0.3 cm.
77 #define DEF_GUTTER_WIDTH (MM50 / 5 * 3)
79 // Minimal distance (distance to text) for border attribute
80 // in order not to crock up aligned lines.
82 #define MIN_BORDER_DIST 28
84 // Minimal document border: 20mm.
85 const SwTwips lMinBorder
= 1134;
87 // Margin left and above document.
88 // Half of it is gap between the pages.
89 //TODO: Replace with SwViewOption::defDocumentBorder
90 #define DOCUMENTBORDER 284L
93 SW_DLLPUBLIC
extern OUString aEmptyOUStr
; // remove once aEmptyOUStr can be changed to OUString
95 // For inserting of captions (what and where to insert).
96 // It's here because it is not big enough to justify its own hxx
97 // and does not seem to fit somewhere else.
100 LTYPE_TABLE
, // Caption for a table.
101 LTYPE_OBJECT
, // Caption for a graphic or OLE.
102 LTYPE_FLY
, // Caption for a text frame.
103 LTYPE_DRAW
// Caption for a draw object.
106 const sal_uInt8 MAXLEVEL
= 10;
108 const sal_uInt8 NO_NUMLEVEL
= 0x20; // "or" with the levels.
110 // Some helper functions as macros or inlines.
112 #define SET_CURR_SHELL( shell ) CurrShell aCurr( shell )
114 // pPathFinder is initialized by the UI.
115 // The class delivers all paths needed.
116 extern SwPathFinder
*pPathFinder
;
118 // Values for indents at numbering and bullet lists.
119 // (For more levels the values have to be multiplied with the levels+1;
122 const sal_uInt16 lBullIndent
= 1440/4;
123 const short lBullFirstLineOffset
= -lBullIndent
;
124 const sal_uInt16 lNumIndent
= 1440/4;
125 const short lNumFirstLineOffset
= -lNumIndent
;
126 const short lOutlineMinTextDistance
= 216; // 0.15 inch = 0.38 cm
128 // Count of SystemField-types of SwDoc.
129 #define INIT_FLDTYPES 32
131 // Count of predefined Seq-field types. It is always the last
132 // fields before INIT_FLDTYPES.
133 #define INIT_SEQ_FLDTYPES 4
135 extern ResMgr
* pSwResMgr
;
136 // defined in sw/source/uibase/app/swmodule.cxx for the sw library and in
137 // sw/source/ui/dialog/swdialmgr.cxx for the swui library
138 inline OUString
SwResId(sal_uInt16 nId
)
140 return ResId(nId
, *pSwResMgr
);
143 css::uno::Reference
< css::linguistic2::XSpellChecker1
> GetSpellChecker();
144 css::uno::Reference
< css::linguistic2::XHyphenator
> GetHyphenator();
145 css::uno::Reference
< css::linguistic2::XThesaurus
> GetThesaurus();
146 css::uno::Reference
< css::linguistic2::XLinguProperties
> GetLinguPropertySet();
148 // Returns the twip size of this graphic.
149 SW_DLLPUBLIC Size
GetGraphicSizeTwip( const Graphic
&, OutputDevice
* pOutDev
);
151 // Separator for jumps to different content types in document.
152 const sal_Unicode cMarkSeparator
= '|';
153 // Sequences names for jumps are <name of sequence>!<no>
154 const char cSequenceMarkSeparator
= '!';
156 #define DB_DELIM u'\x00ff' // Database <-> table separator.
158 enum class SetAttrMode
160 DEFAULT
= 0x0000, // Default.
161 /// @attention: DONTEXPAND does not work very well for CHARATR
162 /// because it can expand only the whole AUTOFMT or nothing
163 DONTEXPAND
= 0x0001, // Don't expand text attribute any further.
164 DONTREPLACE
= 0x0002, // Don't replace another text attribute.
166 NOTXTATRCHR
= 0x0004, // Don't insert 0xFF at attributes with no end.
167 /// attention: NOHINTADJUST prevents MergePortions!
168 /// when using this need to pay attention to ignore start/end flags of hint
169 NOHINTADJUST
= 0x0008, // No merging of ranges.
170 NOFORMATATTR
= 0x0010, // Do not change into format attribute.
171 APICALL
= 0x0020, // Called from API (all UI related
172 // functionality will be disabled).
173 /// Force hint expand (only matters for hints with CH_TXTATR).
174 FORCEHINTEXPAND
= 0x0040,
175 /// The inserted item is a copy -- intended for use in ndtxt.cxx.
177 /// for Undo, translated to SwInsertFlags::NOHINTEXPAND
178 NOHINTEXPAND
= 0x0100,
182 template<> struct typed_flags
<SetAttrMode
> : is_typed_flags
<SetAttrMode
, 0x1ff> {};
185 #define SW_ISPRINTABLE( c ) ( c >= ' ' && 127 != c )
187 #define CHAR_HARDBLANK u'\x00A0'
188 #define CHAR_HARDHYPHEN u'\x2011'
189 #define CHAR_SOFTHYPHEN u'\x00AD'
190 #define CHAR_RLM u'\x200F'
191 #define CHAR_LRM u'\x200E'
192 #define CHAR_ZWSP u'\x200B'
193 #define CHAR_ZWNBSP u'\x2060'
195 // Returns the APP - CharClass instance - used for all ToUpper/ToLower/...
196 SW_DLLPUBLIC CharClass
& GetAppCharClass();
197 SW_DLLPUBLIC LanguageType
GetAppLanguage();
198 SW_DLLPUBLIC
const LanguageTag
& GetAppLanguageTag();
201 // I18N doesn't get this right, can't specify more than one to ignore
202 #define SW_COLLATOR_IGNORES ( \
203 css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE | \
204 css::i18n::CollatorOptions::CollatorOptions_IGNORE_KANA | \
205 css::i18n::CollatorOptions::CollatorOptions_IGNORE_WIDTH )
207 #define SW_COLLATOR_IGNORES ( \
208 css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE )
211 SW_DLLPUBLIC CollatorWrapper
& GetAppCollator();
212 SW_DLLPUBLIC CollatorWrapper
& GetAppCaseCollator();
214 SW_DLLPUBLIC
const ::utl::TransliterationWrapper
& GetAppCmpStrIgnore();
216 // Official shortcut for Prepare() regarding notification of Content by the Layout.
217 // Content provides for calculation of minimal requirements at the next call of ::Format().
220 PREP_BEGIN
, // BEGIN.
221 PREP_CLEAR
= PREP_BEGIN
,// Reformat completely.
222 PREP_WIDOWS_ORPHANS
, // Only check for widows and orphans and split in case of need.
223 PREP_FIXSIZE_CHG
, // FixSize has changed.
224 PREP_FOLLOW_FOLLOWS
, // Follow is now possibly adjacent.
225 PREP_ADJUST_FRM
, // Adjust size via grow/shrink without formatting.
226 PREP_FLY_CHGD
, // A FlyFrame has changed its size.
227 PREP_FLY_ATTR_CHG
, // A FlyFrame hat has changed its attributes
229 PREP_FLY_ARRIVE
, // A FlyFrame now overlaps range.
230 PREP_FLY_LEAVE
, // A FlyFrame has left range.
231 PREP_FTN
, // Invalidation of footnotes.
232 PREP_POS_CHGD
, // Position of Frame has changed.
233 // (Check for Fly-break). In void* of Prepare()
234 // a sal_Bool& is passed. If this is sal_True,
235 // it indicates that a format has been executed.
236 PREP_UL_SPACE
, // UL-Space has changed, TextFrames have to
237 // re-calculate line space.
238 PREP_MUST_FIT
, // Make frm fit (split) even if the attributes do
239 // not allow that (e.g. "keep together").
240 PREP_WIDOWS
, // A follow realizes that the orphan rule will be applied
241 // for it and sends a PREP_WIDOWS to its predecessor
243 PREP_QUOVADIS
, // If a footnote has to be split between two paragraphs
244 // the last on the page has to receive a QUOVADIS in
245 // order to format the text into it.
246 PREP_BOSS_CHGD
, // If a Frame changes its column/page this additional
247 // Prepare is sended to POS_CHGD in MoveFwd/Bwd
248 // (join Footnote-numbers etc.)
249 // Direction is communicated via pVoid:
250 // MoveFwd: pVoid == 0
251 // MoveBwd: pVoid == pOldPage
252 PREP_REGISTER
, // Invalidate frames with registers.
253 PREP_FTN_GONE
, // A Follow loses its footnote, possibly its first line can move up.
254 PREP_MOVEFTN
, // A footnote changes its page. Its contents receives at first a
255 // height of zero in order to avoid too much noise. At formatting
256 // it checks whether it fits and if necessary changes its page again.
257 PREP_ERGOSUM
, // Needed because of movement in FootnoteFrames. Check QuoVadis/ErgoSum.
260 enum FrameControlType
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */