LibreOffice Module sw (master)  1
swtypes.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_SW_INC_SWTYPES_HXX
20 #define INCLUDED_SW_INC_SWTYPES_HXX
21 #include <rtl/ustring.hxx>
22 
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>
30 
31 namespace com { namespace sun { namespace star {
32  namespace linguistic2{
33  class XLinguProperties;
34  class XSpellChecker1;
35  class XHyphenator;
36  class XThesaurus;
37  }
38 }}}
39 namespace utl{
40  class TransliterationWrapper;
41 }
42 
43 class Size;
44 class SwPathFinder;
45 class Graphic;
46 class OutputDevice;
47 class CharClass;
48 class CollatorWrapper;
50 
51 typedef long SwTwips;
52 #define INVALID_TWIPS LONG_MAX
53 #define TWIPS_MAX (LONG_MAX - 1)
54 
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); }
58 
59 #define MM50 283 // 1/2 cm in TWIPS.
60 
61 const sal_Int32 COMPLETE_STRING = SAL_MAX_INT32;
62 
64 
65 #define MINFLY 23 // Minimal size for FlyFrames.
66 #define MINLAY 23 // Minimal size for other Frames.
67 
68 // Default column distance of two text columns corresponds to 0.3 cm.
69 #define DEF_GUTTER_WIDTH (MM50 / 5 * 3)
70 
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
75 
76 // Minimal document border: 20mm.
77 const SwTwips lMinBorder = 1134;
78 
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
83 
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.
88 {
89  LTYPE_TABLE, // Caption for a table.
90  LTYPE_OBJECT, // Caption for a graphic or OLE.
91  LTYPE_FLY, // Caption for a text frame.
92  LTYPE_DRAW // Caption for a draw object.
93 };
94 
95 const sal_uInt8 MAXLEVEL = 10;
96 
97 const sal_uInt8 NO_NUMLEVEL = 0x20; // "or" with the levels.
98 
99 // Some helper functions as macros or inlines.
100 
101 #define SET_CURR_SHELL( shell ) CurrShell aCurr( shell )
102 
103 // pPathFinder is initialized by the UI.
104 // The class delivers all paths needed.
105 extern SwPathFinder *pPathFinder;
106 
107 // Values for indents at numbering and bullet lists.
108 // (For more levels the values have to be multiplied with the levels+1;
109 // levels 0 ..4!)
110 
111 const short lBullIndent = 1440/4;
113 const sal_uInt16 lNumIndent = 1440/4;
115 const short lOutlineMinTextDistance = 216; // 0.15 inch = 0.38 cm
116 
117 // Count of SystemField-types of SwDoc.
118 #define INIT_FLDTYPES 33
119 
120 // Count of predefined Seq-field types. It is always the last
121 // fields before INIT_FLDTYPES.
122 #define INIT_SEQ_FLDTYPES 5
123 
124 // defined in sw/source/uibase/app/swmodule.cxx
125 SW_DLLPUBLIC OUString SwResId(const char* pId);
126 SW_DLLPUBLIC OUString SwResId(const char* pId, int nCardinality);
127 
128 css::uno::Reference< css::linguistic2::XSpellChecker1 > GetSpellChecker();
129 css::uno::Reference< css::linguistic2::XHyphenator > GetHyphenator();
130 css::uno::Reference< css::linguistic2::XThesaurus > GetThesaurus();
131 css::uno::Reference< css::linguistic2::XLinguProperties > GetLinguPropertySet();
132 
133 // Returns the twip size of this graphic.
135 
136 // Separator for jumps to different content types in document.
138 // Sequences names for jumps are <name of sequence>!<no>
139 const char cSequenceMarkSeparator = '!';
140 
141 #define DB_DELIM u'\x00ff' // Database <-> table separator.
142 
143 enum class SetAttrMode
144 {
145  DEFAULT = 0x0000, // Default.
148  DONTEXPAND = 0x0001, // Don't expand text attribute any further.
149  DONTREPLACE = 0x0002, // Don't replace another text attribute.
150 
151  NOTXTATRCHR = 0x0004, // Don't insert 0xFF at attributes with no end.
154  NOHINTADJUST = 0x0008, // No merging of ranges.
155  NOFORMATATTR = 0x0010, // Do not change into format attribute.
156  APICALL = 0x0020, // Called from API (all UI related
157  // functionality will be disabled).
159  FORCEHINTEXPAND = 0x0040,
161  IS_COPY = 0x0080,
163  NOHINTEXPAND = 0x0100,
164 };
165 namespace o3tl
166 {
167  template<> struct typed_flags<SetAttrMode> : is_typed_flags<SetAttrMode, 0x1ff> {};
168 }
169 
170 constexpr bool SW_ISPRINTABLE(sal_Unicode c) { return c >= ' ' && 127 != c; }
171 
172 #define CHAR_HARDBLANK u'\x00A0'
173 #define CHAR_HARDHYPHEN u'\x2011'
174 #define CHAR_SOFTHYPHEN u'\x00AD'
175 #define CHAR_RLM u'\x200F'
176 #define CHAR_LRM u'\x200E'
177 #define CHAR_ZWSP u'\x200B'
178 #define CHAR_ZWNBSP u'\x2060'
179 #define CHAR_NNBSP u'\x202F' //NARROW NO-BREAK SPACE
180 
181 // Returns the APP - CharClass instance - used for all ToUpper/ToLower/...
185 
186 #if 0
187 // I18N doesn't get this right, can't specify more than one to ignore
188 #define SW_COLLATOR_IGNORES ( \
189  css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE | \
190  css::i18n::CollatorOptions::CollatorOptions_IGNORE_KANA | \
191  css::i18n::CollatorOptions::CollatorOptions_IGNORE_WIDTH )
192 #else
193 #define SW_COLLATOR_IGNORES ( \
194  css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE )
195 #endif
196 
199 
200 SW_DLLPUBLIC const ::utl::TransliterationWrapper& GetAppCmpStrIgnore();
201 
202 // Official shortcut for Prepare() regarding notification of Content by the Layout.
203 // Content provides for calculation of minimal requirements at the next call of ::Format().
205 {
206  PREP_BEGIN, // BEGIN.
207  PREP_CLEAR = PREP_BEGIN,// Reformat completely.
208  PREP_WIDOWS_ORPHANS, // Only check for widows and orphans and split in case of need.
209  PREP_FIXSIZE_CHG, // FixSize has changed.
210  PREP_FOLLOW_FOLLOWS, // Follow is now possibly adjacent.
211  PREP_ADJUST_FRM, // Adjust size via grow/shrink without formatting.
212  PREP_FLY_CHGD, // A FlyFrame has changed its size.
213  PREP_FLY_ATTR_CHG, // A FlyFrame has changed its attributes
214  // (e. g. wrap).
215  PREP_FLY_ARRIVE, // A FlyFrame now overlaps range.
216  PREP_FLY_LEAVE, // A FlyFrame has left range.
217  PREP_FTN, // Invalidation of footnotes.
218  PREP_POS_CHGD, // Position of Frame has changed.
219  // (Check for Fly-break). In void* of Prepare()
220  // a sal_Bool& is passed. If this is sal_True,
221  // it indicates that a format has been executed.
222  PREP_UL_SPACE, // UL-Space has changed, TextFrames have to
223  // re-calculate line space.
224  PREP_MUST_FIT, // Make frm fit (split) even if the attributes do
225  // not allow that (e.g. "keep together").
226  PREP_WIDOWS, // A follow realizes that the orphan rule will be applied
227  // for it and sends a PREP_WIDOWS to its predecessor
228  // (Master/Follow).
229  PREP_QUOVADIS, // If a footnote has to be split between two paragraphs
230  // the last on the page has to receive a QUOVADIS in
231  // order to format the text into it.
232  PREP_BOSS_CHGD, // If a Frame changes its column/page this additional
233  // Prepare is sended to POS_CHGD in MoveFwd/Bwd
234  // (join Footnote-numbers etc.)
235  // Direction is communicated via pVoid:
236  // MoveFwd: pVoid == 0
237  // MoveBwd: pVoid == pOldPage
238  PREP_REGISTER, // Invalidate frames with registers.
239  PREP_FTN_GONE, // A Follow loses its footnote, possibly its first line can move up.
240  PREP_MOVEFTN, // A footnote changes its page. Its contents receives at first a
241  // height of zero in order to avoid too much noise. At formatting
242  // it checks whether it fits and if necessary changes its page again.
243  PREP_ERGOSUM, // Needed because of movement in FootnoteFrames. Check QuoVadis/ErgoSum.
244 };
245 
247 {
252 };
253 
254 #endif
255 
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SwTwips lMinBorder
Definition: swtypes.hxx:77
SwPathFinder * pPathFinder
SW_DLLPUBLIC Size GetGraphicSizeTwip(const Graphic &, vcl::RenderContext *pOutDev)
Definition: swtypes.cxx:49
SwLabelType
Definition: swtypes.hxx:87
The inserted item is a copy – intended for use in ndtxt.cxx.
SW_DLLPUBLICconst::utl::TransliterationWrapper & GetAppCmpStrIgnore()
Definition: init.cxx:834
SW_DLLPUBLIC CollatorWrapper & GetAppCaseCollator()
Definition: init.cxx:795
constexpr T MmToTwips(const double mm)
Definition: swtypes.hxx:57
long SwTwips
Definition: swtypes.hxx:49
SW_DLLPUBLIC const LanguageTag & GetAppLanguageTag()
Definition: init.cxx:778
SW_DLLPUBLIC CollatorWrapper & GetAppCollator()
Definition: init.cxx:783
css::uno::Reference< css::linguistic2::XHyphenator > GetHyphenator()
Definition: swtypes.cxx:71
const sal_uInt16 lNumIndent
Definition: swtypes.hxx:113
sal_uInt16 sal_Unicode
SW_DLLPUBLIC OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
css::uno::Reference< css::linguistic2::XSpellChecker1 > GetSpellChecker()
Definition: swtypes.cxx:66
const short lNumFirstLineOffset
Definition: swtypes.hxx:114
PrepareHint
Definition: swtypes.hxx:204
#define SAL_MAX_INT32
const short lBullFirstLineOffset
Definition: swtypes.hxx:112
SetAttrMode
Definition: swtypes.hxx:143
css::uno::Reference< css::linguistic2::XLinguProperties > GetLinguPropertySet()
Definition: swtypes.cxx:81
const short lOutlineMinTextDistance
Definition: swtypes.hxx:115
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
const SwTwips cMinHdFtHeight
Definition: swtypes.hxx:63
const sal_Unicode cMarkSeparator
Definition: swtypes.hxx:137
attention: NOHINTADJUST prevents MergePortions! when using this need to pay attention to ignore start...
FrameControlType
Definition: swtypes.hxx:246
constexpr bool SW_ISPRINTABLE(sal_Unicode c)
Definition: swtypes.hxx:170
unsigned char sal_uInt8
css::uno::Reference< css::linguistic2::XThesaurus > GetThesaurus()
Definition: swtypes.cxx:76
const char cSequenceMarkSeparator
Definition: swtypes.hxx:139
SW_DLLPUBLIC CharClass & GetAppCharClass()
Definition: init.cxx:751
const sal_uInt8 NO_NUMLEVEL
Definition: swtypes.hxx:97
const short lBullIndent
Definition: swtypes.hxx:111
SW_DLLPUBLIC LanguageType GetAppLanguage()
Definition: init.cxx:771
const sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:61