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 .
21 #include <rtl/ustring.hxx>
22 #include <tools/solar.h>
23 #include <SwGetPoolIdFromName.hxx>
25 #include <limits.h> //For LONG_MAX.
26 #include <com/sun/star/uno/Reference.h>
28 #include <i18nlangtag/languagetag.hxx>
30 namespace com
{ namespace sun
{ namespace star
{
31 namespace linguistic2
{
32 class XDictionaryList
;
33 class XLinguProperties
;
43 class TransliterationWrapper
;
53 class LocaleDataWrapper
;
54 class CollatorWrapper
;
57 #define INVALID_TWIPS LONG_MAX
58 #define TWIPS_MAX (LONG_MAX - 1)
60 #define MM50 283 // 1/2 cm in TWIPS.
62 const SwTwips cMinHdFtHeight
= 56;
64 #define MINFLY 23 // Minimal size for FlyFrms.
65 #define MINLAY 23 // Minimal size for other Frms.
67 // Default column distance of two text columns corresponds to 0.3 cm.
68 #define DEF_GUTTER_WIDTH (MM50 / 5 * 3)
70 // Minimal distance (distance to text) for border attribute
71 // in order not to crock up aligned lines.
73 #define MIN_BORDER_DIST 28
75 // Minimal document border.
76 const SwTwips lMinBorder
= 1134;
78 // Margin left and above document.
79 // Half of it is gap between the pages.
80 #define DOCUMENTBORDER 284L
81 #define GAPBETWEENPAGES 284L
84 SW_DLLPUBLIC
extern String aEmptyStr
; // ""
85 SW_DLLPUBLIC
extern OUString aEmptyOUStr
; // remove once aEmptyStr can be changed to OUString
86 SW_DLLPUBLIC
extern OUString aDotStr
; // '.'
88 // For inserting of captions (what and where to insert).
89 // It's here because it is not big enough to justify its own hxx
90 // and does not seem to fit somewhere else.
93 LTYPE_TABLE
, // Caption for a table.
94 LTYPE_OBJECT
, // Caption for a graphic or OLE.
95 LTYPE_FLY
, // Caption for a text frame.
96 LTYPE_DRAW
// Caption for a draw object.
100 const sal_uInt8 MAXLEVEL
= 10;
102 const sal_uInt8 NO_NUMLEVEL
= 0x20; // "or" with the levels.
104 // Some helper functions as macros or inlines.
106 // One kilobyte is 1024 bytes:
109 #define SET_CURR_SHELL( shell ) CurrShell aCurr( shell )
111 // pPathFinder is initialized by the UI.
112 // The class delivers all paths needed.
113 extern SwPathFinder
*pPathFinder
;
115 // Values for indents at numbering and bullet lists.
116 // (For more levels the values have to be multiplied with the levels+1;
119 const sal_uInt16 lBullIndent
= 1440/4;
120 const short lBullFirstLineOffset
= -lBullIndent
;
121 const sal_uInt16 lNumIndent
= 1440/4;
122 const short lNumFirstLineOffset
= -lNumIndent
;
123 const short lOutlineMinTextDistance
= 216; // 0.15 inch = 0.38 cm
125 // Count of SystemField-types of SwDoc.
126 #define INIT_FLDTYPES 32
128 // Count of predefined Seq-field types. It is always the last
129 // fields before INIT_FLDTYPES.
130 #define INIT_SEQ_FLDTYPES 4
132 // The former Rendevouz-IDs live on:
133 // There are IDs for the anchors (SwFmtAnchor) and some others
134 // that are only of importance for interfaces (SwDoc).
137 FLY_AT_PARA
, // Anchored at paragraph.
138 FLY_AS_CHAR
, // Anchored as character.
139 FLY_AT_PAGE
, // Anchored at page.
140 FLY_AT_FLY
, // Anchored at frame.
141 FLY_AT_CHAR
, // Anchored at character.
150 RND_DRAW_OBJECT
// A draw-Object! For the SwDoc-interface only!
154 extern ResMgr
* pSwResMgr
; // Is in swapp0.cxx.
155 #define SW_RES(i) ResId(i,*pSwResMgr)
156 #define SW_RESSTR(i) SW_RES(i).toString()
158 ::com::sun::star::uno::Reference
<
159 ::com::sun::star::linguistic2::XSpellChecker1
> GetSpellChecker();
160 ::com::sun::star::uno::Reference
<
161 ::com::sun::star::linguistic2::XHyphenator
> GetHyphenator();
162 ::com::sun::star::uno::Reference
<
163 ::com::sun::star::linguistic2::XThesaurus
> GetThesaurus();
164 ::com::sun::star::uno::Reference
<
165 ::com::sun::star::linguistic2::XLinguProperties
> GetLinguPropertySet();
167 // Returns the twip size of this graphic.
168 SW_DLLPUBLIC Size
GetGraphicSizeTwip( const Graphic
&, OutputDevice
* pOutDev
);
171 // Separator for jumps to different content types in document.
172 const sal_Unicode cMarkSeparator
= '|';
173 // Sequences names for jumps are <name of sequence>!<no>
174 const sal_Unicode cSequenceMarkSeparator
= '!';
175 extern const sal_Char
* pMarkToTable
; // Strings are
176 extern const sal_Char
* pMarkToFrame
; // in Init.cxx.
177 extern const sal_Char
* pMarkToRegion
;
178 SW_DLLPUBLIC
extern const sal_Char
* pMarkToOutline
;
179 extern const sal_Char
* pMarkToText
;
180 extern const sal_Char
* pMarkToGraphic
;
181 extern const sal_Char
* pMarkToOLE
;
182 extern const sal_Char
* pMarkToSequence
;
184 #ifndef DB_DELIM // This is defined in OFA!
185 #define DB_DELIM ((sal_Unicode)0xff) // Database <-> table separator.
189 typedef sal_uInt16 SetAttrMode
;
191 namespace nsSetAttrMode
193 const SetAttrMode SETATTR_DEFAULT
= 0x0000; // Default.
194 /// @attention: DONTEXPAND does not work very well for CHARATR
195 /// because it can expand only the whole AUTOFMT or nothing
196 const SetAttrMode SETATTR_DONTEXPAND
= 0x0001; // Don't expand text attribute any further.
197 const SetAttrMode SETATTR_DONTREPLACE
= 0x0002; // Don't replace another text attribute.
199 const SetAttrMode SETATTR_NOTXTATRCHR
= 0x0004; // Don't insert 0xFF at attributes with no end.
200 /// attention: NOHINTADJUST prevents MergePortions!
201 /// when using this need to pay attention to ignore start/end flags of hint
202 const SetAttrMode SETATTR_NOHINTADJUST
= 0x0008; // No merging of ranges.
203 const SetAttrMode SETATTR_NOFORMATATTR
= 0x0010; // Do not change into format attribute.
204 const SetAttrMode SETATTR_DONTCHGNUMRULE
= 0x0020; // Do not change NumRule.
205 const SetAttrMode SETATTR_APICALL
= 0x0040; // Called from API (all UI related
206 // functionality will be disabled).
207 /// Force hint expand (only matters for hints with CH_TXTATR).
208 const SetAttrMode SETATTR_FORCEHINTEXPAND
= 0x0080;
209 /// The inserted item is a copy -- intended for use in ndtxt.cxx.
210 const SetAttrMode SETATTR_IS_COPY
= 0x0100;
213 // Conversion Twip <-> 1/100 mm for UNO
215 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
216 #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
217 #define TWIP_TO_MM100_UNSIGNED(TWIP) ((((TWIP)*127L+36L)/72L))
218 #define MM100_TO_TWIP_UNSIGNED(MM100) ((((MM100)*72L+63L)/127L))
220 #define SW_ISPRINTABLE( c ) ( c >= ' ' && 127 != c )
222 #ifndef SW_CONSTASCII_DECL
223 #define SW_CONSTASCII_DECL( n, s ) n[sizeof(s)]
225 #ifndef SW_CONSTASCII_DEF
226 #define SW_CONSTASCII_DEF( n, s ) n[sizeof(s)] = s
230 #define CHAR_HARDBLANK ((sal_Unicode)0x00A0)
231 #define CHAR_HARDHYPHEN ((sal_Unicode)0x2011)
232 #define CHAR_SOFTHYPHEN ((sal_Unicode)0x00AD)
233 #define CHAR_RLM ((sal_Unicode)0x200F)
234 #define CHAR_LRM ((sal_Unicode)0x200E)
235 #define CHAR_ZWSP ((sal_Unicode)0x200B)
236 #define CHAR_ZWNBSP ((sal_Unicode)0x2060)
239 // Returns the APP - CharClass instance - used for all ToUpper/ToLower/...
240 SW_DLLPUBLIC CharClass
& GetAppCharClass();
241 SW_DLLPUBLIC LanguageType
GetAppLanguage();
242 SW_DLLPUBLIC
const LanguageTag
& GetAppLanguageTag();
246 // I18N doesn't get this right, can't specify more than one to ignore
247 #define SW_COLLATOR_IGNORES ( \
248 ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE | \
249 ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_KANA | \
250 ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_WIDTH )
252 #define SW_COLLATOR_IGNORES ( \
253 ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE )
256 SW_DLLPUBLIC CollatorWrapper
& GetAppCollator();
257 SW_DLLPUBLIC CollatorWrapper
& GetAppCaseCollator();
259 SW_DLLPUBLIC
const ::utl::TransliterationWrapper
& GetAppCmpStrIgnore();
261 // Official shortcut for Prepare() regarding notification of Content by the Layout.
262 // Content provides for calculation of minimal requirements at the next call of ::Format().
265 PREP_BEGIN
, // BEGIN.
266 PREP_CLEAR
= PREP_BEGIN
,// Reformat completely.
267 PREP_WIDOWS_ORPHANS
, // Only check for widows and orphans and split in case of need.
268 PREP_FIXSIZE_CHG
, // FixSize has changed.
269 PREP_FOLLOW_FOLLOWS
, // Follow is now possibly adjacent.
270 PREP_ADJUST_FRM
, // Adjust size via grow/shrink without formating.
271 PREP_FLY_CHGD
, // A FlyFrm has changed its size.
272 PREP_FLY_ATTR_CHG
, // A FlyFrm hat has changed its attributes
274 PREP_FLY_ARRIVE
, // A FlyFrm now overlaps range.
275 PREP_FLY_LEAVE
, // A FlyFrm has left range.
276 PREP_FTN
, // Invalidation of footnotes.
277 PREP_POS_CHGD
, // Position of Frm has changed.
278 // (Check for Fly-break). In void* of Prepare()
279 // a sal_Bool& is passed. If this is sal_True,
280 // it indicateds that a format has been executed.
281 PREP_UL_SPACE
, // UL-Space has changed, TxtFrms have to
282 // re-calculate line space.
283 PREP_MUST_FIT
, // Make frm fit (split) even if the attributes do
284 // not allow that (e.g. "keep together").
285 PREP_WIDOWS
, // A follow realizes that the orphan rule will be applied
286 // for it and sends a PREP_WIDOWS to its predecessor
288 PREP_QUOVADIS
, // If a footnote has to be split between two paragraphs
289 // the last on the page has to receive a QUOVADIS in
290 // order to format the text into it.
291 PREP_BOSS_CHGD
, // If a Frm changes its column/page this additional
292 // Prepare is sended to POS_CHGD in MoveFwd/Bwd
293 // (join Ftn-numbers etc.)
294 // Direction is communicated via pVoid:
295 // MoveFwd: pVoid == 0
296 // MoveBwd: pVoid == pOldPage
297 PREP_SWAP
, // Swap graphic; for graphics in visible area.
298 PREP_REGISTER
, // Invalidate frames with registers.
299 PREP_FTN_GONE
, // A Follow loses its footnote, possibly its first line can move up.
300 PREP_MOVEFTN
, // A footnote changes its page. Its contents receives at first a
301 // height of zero in order to avoid too much noise. At formating
302 // it checks whether it fits and if necessary changes its page again.
303 PREP_ERGOSUM
, // Needed because of movement in FtnFrms. Check QuoVadis/ErgoSum.
309 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */