Line data Source code
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_SOURCE_CORE_INC_TXTFRM_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_INC_TXTFRM_HXX
21 :
22 : #include <com/sun/star/uno/Sequence.hxx>
23 : #include <tools/mempool.hxx>
24 : #include "cntfrm.hxx"
25 : #include "ndtxt.hxx"
26 :
27 : class SwCharRange;
28 : class SwTextNode;
29 : class SwTextFormatter;
30 : class SwTextFormatInfo;
31 : class SwParaPortion;
32 : class WidowsAndOrphans;
33 : class SwBodyFrm;
34 : class SwTextFootnote;
35 : class SwInterHyphInfo; // Hyphenate()
36 : class SwCache;
37 : class SwBorderAttrs;
38 : class SwFrameFormat;
39 : class OutputDevice;
40 : class SwTestFormat;
41 : struct SwCrsrMoveState;
42 : struct SwFillData;
43 : class SwPortionHandler;
44 : class SwScriptInfo;
45 : class SwViewOption;
46 : class SwWrongList;
47 :
48 : #define NON_PRINTING_CHARACTER_COLOR RGB_COLORDATA(0x26, 0x8b, 0xd2)
49 :
50 : /// Represents the visualization of a paragraph.
51 : class SwTextFrm: public SwContentFrm
52 : {
53 : friend class SwTextIter;
54 : friend class SwTestFormat;
55 : friend class WidowsAndOrphans;
56 : friend class TextFrmLockGuard; // May Lock()/Unlock()
57 : friend bool sw_ChangeOffset( SwTextFrm* pFrm, sal_Int32 nNew );
58 :
59 : static SwCache *pTextCache; // Pointer to the Line Cache
60 : static long nMinPrtLine; // This Line must not be underrun when printing
61 : // Hack for table cells stretching multiple pages
62 :
63 : sal_uLong nAllLines :24; // Line count for the Paint (including nThisLines)
64 : sal_uLong nThisLines :8; // Count of Lines of the Frame
65 :
66 : // The x position for flys anchored at this paragraph.
67 : // These values are calculated in SwTextFrm::CalcBaseOfstForFly()
68 : SwTwips mnFlyAnchorOfst;
69 : // The x position for wrap-through flys anchored at this paragraph.
70 : SwTwips mnFlyAnchorOfstNoWrap;
71 : SwTwips mnFootnoteLine;
72 : // OD 2004-03-17 #i11860# - re-factoring of #i11859#
73 : // member for height of last line (value needed for proportional line spacing)
74 : SwTwips mnHeightOfLastLine;
75 : // member for the additional first line offset, which is caused by the list
76 : // label alignment for list level position and space mode LABEL_ALIGNMENT.
77 : // This additional first line offset is used for the text formatting.
78 : // It is NOT used for the determination of printing area.
79 : SwTwips mnAdditionalFirstLineOffset;
80 :
81 : sal_Int32 nOfst; // Is the offset in the Content (character count)
82 :
83 : sal_uInt16 nCacheIdx; // Index into the cache, USHRT_MAX if there's definitely no fitting object in the cache
84 :
85 : // Separates the Master and creates a Follow or adjusts the data in the Follow
86 : void _AdjustFollow( SwTextFormatter &rLine, const sal_Int32 nOffset,
87 : const sal_Int32 nStrEnd, const sal_uInt8 nMode );
88 : inline void AdjustFollow( SwTextFormatter &rLine, const sal_Int32 nOffset,
89 : const sal_Int32 nStrEnd, const sal_uInt8 nMode );
90 :
91 : // Iterates all Lines and sets the line spacing using the attribute
92 : void CalcLineSpace();
93 :
94 : // Only called in Format
95 : void AdjustFrm( const SwTwips nChgHeight, bool bHasToFit = false );
96 :
97 : // Evaluates the Preps in Format()
98 : bool CalcPreps();
99 : void PrepWidows( const sal_uInt16 nNeed, bool bNotify = true );
100 : void _InvalidateRange( const SwCharRange &, const long = 0);
101 : inline void InvalidateRange( const SwCharRange &, const long = 0);
102 :
103 : // WidowsAndOrphans, AdjustFrm, AdjustFollow
104 : void FormatAdjust( SwTextFormatter &rLine, WidowsAndOrphans &rFrmBreak,
105 : const sal_Int32 nStrLen, const bool bDummy );
106 :
107 : bool bLocked : 1; // In the Format?
108 : bool bWidow : 1; // Are we a Widow?
109 : bool bJustWidow : 1; // Did we just request to be a Widow?
110 : bool bEmpty : 1; // Are we an empty paragraph?
111 : bool bInFootnoteConnect : 1; // Is in Connect at the moment
112 : bool bFootnote : 1; // Has at least one footnote
113 : bool bRepaint : 1; // TextFrm: Repaint is ready to be fetched
114 : bool bBlinkPor : 1; // Contains Blink Portions
115 : bool bFieldFollow : 1; // Start with Field rest of the Master
116 : bool bHasAnimation : 1; // Contains animated SwGrfNumPortion
117 : bool bIsSwapped : 1; // during text formatting we swap the
118 : // width and height for vertical formatting
119 : // OD 14.03.2003 #i11760# - flag to control, if follow is formatted in
120 : // method <CalcFollow(..)>.
121 : // E.g., avoid formatting of follow, if method <SwLayoutFrm::FormatWidthCols(..)>
122 : // is running.
123 : bool mbFollowFormatAllowed : 1;
124 :
125 : void ResetPreps();
126 74101 : inline void Lock() { bLocked = true; }
127 73517 : inline void Unlock() { bLocked = false; }
128 16065 : inline void SetWidow( const bool bNew ) { bWidow = bNew; }
129 17 : inline void SetJustWidow( const bool bNew ) { bJustWidow = bNew; }
130 67352 : inline void SetEmpty( const bool bNew ) { bEmpty = bNew; }
131 1142 : inline void SetFieldFollow( const bool bNew ) { bFieldFollow = bNew; }
132 :
133 : bool IsIdxInside( const sal_Int32 nPos, const sal_Int32 nLen ) const;
134 :
135 : // Changes the Frame or not (cf. FlyCnt)
136 : bool _GetCrsrOfst(SwPosition *pPos, const Point &rPoint,
137 : const bool bChgFrm, SwCrsrMoveState* = 0 ) const;
138 : void FillCrsrPos( SwFillData &rFill ) const;
139 :
140 : // Format exactly one Line
141 : bool FormatLine( SwTextFormatter &rLine, const bool bPrev );
142 :
143 : // In order to safe stack space, we split this method:
144 : // _Format calls _Format with parameters
145 : void _Format( SwParaPortion *pPara );
146 : void _Format( SwTextFormatter &rLine, SwTextFormatInfo &rInf,
147 : const bool bAdjust = false );
148 : void FormatOnceMore( SwTextFormatter &rLine, SwTextFormatInfo &rInf );
149 :
150 : // Formats the Follow and ensures disposing on orphans
151 : bool CalcFollow( const sal_Int32 nTextOfst );
152 :
153 : // Corrects the position from which we need to format
154 : static sal_Int32 FindBrk(const OUString &rText, const sal_Int32 nStart,
155 : const sal_Int32 nEnd);
156 :
157 : // inline branch
158 : SwTwips _GetFootnoteFrmHeight() const;
159 :
160 : // Outsourced to CalcPreps
161 : bool CalcPrepFootnoteAdjust();
162 :
163 : // For Footnote and WidOrp: Forced validation
164 : void ValidateFrm();
165 : void ValidateBodyFrm();
166 :
167 : bool _GetDropRect( SwRect &rRect ) const;
168 :
169 : void SetPara( SwParaPortion *pNew, bool bDelete = true );
170 :
171 : bool _IsFootnoteNumFrm() const;
172 :
173 : // Refresh formatting information
174 : bool FormatQuick( bool bForceQuickFormat );
175 :
176 : // Opt: Format empty paragraphs
177 : bool FormatEmpty();
178 : SwTwips EmptyHeight() const;
179 :
180 : // Opt: Paint empty paragraphs
181 : bool PaintEmpty( const SwRect &, bool bCheck ) const;
182 :
183 : void ChgThisLines(); // Must always be called if the Line count could have changed
184 :
185 : // required for 'new' relative anchor position
186 : void CalcBaseOfstForFly();
187 :
188 : /** method to determine height of last line, needed for proportional line spacing
189 :
190 : OD 2004-03-17 #i11860#
191 : OD 2005-05-20 #i47162# - introduce new optional parameter <_bUseFont>
192 : in order to force the usage of the former algorithm to determine the
193 : height of the last line, which uses the font.
194 :
195 : @param _bUseFont
196 : optional input parameter - boolean indicating, if the font has to be
197 : used to determine the height of the last line. default value: false
198 : */
199 : void _CalcHeightOfLastLine( const bool _bUseFont = false );
200 :
201 : // ST2
202 : SwWrongList* _SmartTagScan ( const OUString& aTextToScan, SwWrongList *pSmartTagList,
203 : sal_Int32 nBegin,sal_Int32 nEnd,
204 : sal_Int32 nInsertPos, sal_Int32 nActPos,
205 : sal_Int32 &nChgStart, sal_Int32 &nChgEnd,
206 : sal_Int32 &nInvStart, sal_Int32 &nInvEnd);
207 :
208 : virtual void DestroyImpl() SAL_OVERRIDE;
209 : virtual ~SwTextFrm();
210 :
211 : protected:
212 : virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) SAL_OVERRIDE;
213 :
214 : public:
215 :
216 : com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop > GetTabStopInfo( SwTwips CurrentPos ) SAL_OVERRIDE;
217 :
218 : /**
219 : * This is public, as it needs to be called by some methods in order to save the Prepare
220 : * USE WITH CAUTION!
221 : */
222 : void Init();
223 :
224 : /// Is called by FormatSpelling()
225 : SwRect _AutoSpell( const SwContentNode*, sal_Int32 );
226 :
227 : /// Is called by FormatSpelling()
228 : SwRect SmartTagScan( SwContentNode* , sal_Int32 );
229 :
230 : /// Is called by CollectAutoCmplWords()
231 : void CollectAutoCmplWrds( SwContentNode* , sal_Int32 );
232 :
233 : /**
234 : * Returns the screen position of rPos. The values are relative to the upper
235 : * left position of the page frame.
236 : * Additional information can be obtained by passing an SwCrsrMoveState object.
237 : * Returns false if rPos > number of character is string
238 : */
239 : virtual bool GetCharRect( SwRect& rRect, const SwPosition& rPos,
240 : SwCrsrMoveState* pCMS = 0 ) const SAL_OVERRIDE;
241 :
242 : /// A slimmer version of GetCharRect for autopositioning Frames
243 : bool GetAutoPos( SwRect &, const SwPosition& ) const;
244 :
245 : /**
246 : * Determine top of line for given position in the text frame
247 : *
248 : * OD 11.11.2003 #i22341#
249 : * Assumption: given position exists in the text frame or in a follow of it
250 : * OD 2004-02-02 - adjustment
251 : * Top of first paragraph line is the top of the paragraph.
252 : * OD 2004-03-18 #i11860# - Consider upper space amount considered for
253 : * previous frame and the page grid.
254 : *
255 : * @param _onTopOfLine
256 : * output parameter - top of line, if the given position is found in the
257 : * text frame.
258 : *
259 : * @param _rPos
260 : * input parameter - reference to the position in the text frame
261 : *
262 : * @return boolean indicating, if the top of line for the given position
263 : * has been determined or not.
264 : */
265 : bool GetTopOfLine( SwTwips& _onTopOfLine,
266 : const SwPosition& _rPos ) const;
267 :
268 : virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const SAL_OVERRIDE;
269 :
270 : /**
271 : * In nOffset returns the offset of the char within the set
272 : * text buffer, which is closest to the position provided by
273 : * aPoint within the layout's SSize.
274 : *
275 : * @returns false if the SPoint is outside of the SSize else
276 : * returns true
277 : */
278 : virtual bool GetCrsrOfst( SwPosition *, Point&,
279 : SwCrsrMoveState* = 0, bool bTestBackground = false ) const SAL_OVERRIDE;
280 :
281 : /**
282 : * Makes sure that the Frame is not switched (e.g. switched for a
283 : * character-bound Frame)
284 : */
285 0 : inline bool GetKeyCrsrOfst(SwPosition *pPos, const Point &rPoint ) const
286 0 : { return _GetCrsrOfst( pPos, rPoint, false ); }
287 :
288 : void PaintExtraData( const SwRect & rRect ) const; /// Page number etc.
289 : SwRect Paint();
290 : virtual void Paint( SwRect const&,
291 : SwPrintData const*const pPrintData = NULL ) const SAL_OVERRIDE;
292 : virtual bool GetInfo( SfxPoolItem & ) const SAL_OVERRIDE;
293 :
294 : /**
295 : * Layout oriented cursor travelling:
296 : * Left border, right border, previous Line, following Line,
297 : * same horizontal position
298 : */
299 : virtual bool LeftMargin(SwPaM *) const SAL_OVERRIDE;
300 : virtual bool RightMargin(SwPaM *, bool bAPI = false) const SAL_OVERRIDE;
301 :
302 : virtual bool UnitUp(SwPaM *, const SwTwips nOffset = 0,
303 : bool bSetInReadOnly = false ) const SAL_OVERRIDE;
304 : virtual bool UnitDown(SwPaM *, const SwTwips nOffset = 0,
305 : bool bSetInReadOnly = false ) const SAL_OVERRIDE;
306 : bool _UnitUp(SwPaM *, const SwTwips nOffset = 0,
307 : bool bSetInReadOnly = false ) const;
308 : bool _UnitDown(SwPaM *, const SwTwips nOffset = 0,
309 : bool bSetInReadOnly = false ) const;
310 :
311 : /**
312 : * Prepares the cursor position for a visual cursor move (BiDi).
313 : * The behaviour is different for insert and overwrite cursors
314 : */
315 : void PrepareVisualMove( sal_Int32& nPos, sal_uInt8& nCrsrLevel,
316 : bool& bRight, bool bInsertCrsr );
317 :
318 : /// Methods to manage the FollowFrame
319 : SwContentFrm *SplitFrm( const sal_Int32 nTextPos );
320 : SwContentFrm *JoinFrm();
321 553678 : inline sal_Int32 GetOfst() const { return nOfst; }
322 : void _SetOfst( const sal_Int32 nNewOfst );
323 : inline void SetOfst ( const sal_Int32 nNewOfst );
324 4699 : inline void ManipOfst ( const sal_Int32 nNewOfst ){ nOfst = nNewOfst; }
325 : SwTextFrm *GetFrmAtPos ( const SwPosition &rPos);
326 : inline const SwTextFrm *GetFrmAtPos ( const SwPosition &rPos) const;
327 : SwTextFrm& GetFrmAtOfst( const sal_Int32 nOfst );
328 : /// If there's a Follow and we don't contain text ourselves
329 58113 : inline bool IsEmptyMaster() const
330 58113 : { return GetFollow() && !GetFollow()->GetOfst(); }
331 :
332 : /// Returns the text portion we want to edit (for inline see underneath)
333 : const OUString& GetText() const;
334 51751074 : inline SwTextNode *GetTextNode()
335 51751074 : { return static_cast< SwTextNode* >( SwContentFrm::GetNode()); }
336 2926439 : inline const SwTextNode *GetTextNode() const
337 2926439 : { return static_cast< const SwTextNode* >( SwContentFrm::GetNode()); }
338 :
339 : SwTextFrm(SwTextNode * const, SwFrm* );
340 :
341 : /**
342 : * SwContentFrm: the shortcut for the Frames
343 : * If the void* casts wrongly, it's its own fault!
344 : * The void* must be checked for 0 in any case!
345 : *
346 : * return true if the Portion associated with this SwTxtFrm was
347 : * potentially destroyed and replaced by Prepare
348 : */
349 : virtual bool Prepare( const PrepareHint ePrep = PREP_CLEAR,
350 : const void *pVoid = 0, bool bNotify = true ) SAL_OVERRIDE;
351 :
352 : /**
353 : * nMaxHeight is the required height
354 : * bSplit indicates, that the paragraph has to be split
355 : * bTst indicates, that we are currently doing a test formatting
356 : */
357 : virtual bool WouldFit( SwTwips &nMaxHeight, bool &bSplit, bool bTst ) SAL_OVERRIDE;
358 :
359 : /**
360 : * The WouldFit equivalent for temporarily rewired TextFrames
361 : * nMaxHeight returns the required size here too and bSplit
362 : * determines whether the paragraph needs to be split.
363 : * We pass the potential predecessor for the distance calculation
364 : */
365 : bool TestFormat( const SwFrm* pPrv, SwTwips &nMaxHeight, bool &bSplit );
366 :
367 : /**
368 : * We format a Line for interactive hyphenation
369 : * @return found
370 : */
371 : bool Hyphenate( SwInterHyphInfo &rInf );
372 :
373 : /// Test grow
374 : inline SwTwips GrowTst( const SwTwips nGrow );
375 :
376 : SwParaPortion *GetPara();
377 : inline const SwParaPortion *GetPara() const;
378 : inline bool HasPara() const;
379 : bool _HasPara() const;
380 :
381 : // If there are any hanging punctuation portions in the margin
382 : // the offset will be returned.
383 : SwTwips HangingMargin() const;
384 :
385 : // RTTI
386 : TYPEINFO_OVERRIDE();
387 73128 : DECL_FIXEDMEMPOOL_NEWDEL(SwTextFrm)
388 :
389 : // Locking
390 505205 : inline bool IsLocked() const { return bLocked; }
391 :
392 47673 : inline bool IsWidow() const { return bWidow; }
393 76 : inline bool IsJustWidow() const { return bJustWidow; }
394 374657 : inline bool IsEmpty() const { return bEmpty; }
395 111524 : inline bool HasFootnote() const { return bFootnote; }
396 514 : inline bool IsInFootnoteConnect()const { return bInFootnoteConnect;}
397 2546 : inline bool IsFieldFollow() const { return bFieldFollow;}
398 :
399 : inline void SetRepaint() const;
400 : inline void ResetRepaint() const;
401 6292 : inline bool HasRepaint() const { return bRepaint; }
402 : inline void SetBlinkPor() const;
403 : inline void ResetBlinkPor() const;
404 18377 : inline bool HasBlinkPor() const { return bBlinkPor; }
405 0 : inline void SetAnimation() const
406 0 : { const_cast<SwTextFrm*>(this)->bHasAnimation = true; }
407 2982 : inline bool HasAnimation() const { return bHasAnimation; }
408 :
409 826461 : inline bool IsSwapped() const { return bIsSwapped; }
410 :
411 : /// Does the Frm have a local footnote (in this Frm or Follow)?
412 : #ifdef DBG_UTIL
413 : void CalcFootnoteFlag( sal_Int32 nStop = COMPLETE_STRING ); //For testing SplitFrm
414 : #else
415 : void CalcFootnoteFlag();
416 : #endif
417 :
418 : /// Hidden
419 : bool IsHiddenNow() const; // bHidden && pOut == pPrt
420 : void HideHidden(); // Remove appendage if Hidden
421 : void HideFootnotes( sal_Int32 nStart, sal_Int32 nEnd );
422 :
423 : /**
424 : * Hides respectively shows objects, which are anchored at paragraph,
425 : * at/as a character of the paragraph, corresponding to the paragraph and
426 : * paragraph portion visibility.
427 : */
428 : void HideAndShowObjects();
429 :
430 : /// Footnote
431 : void RemoveFootnote( const sal_Int32 nStart = 0,
432 : const sal_Int32 nLen = COMPLETE_STRING );
433 : inline SwTwips GetFootnoteFrmHeight() const;
434 : SwTextFrm *FindFootnoteRef( const SwTextFootnote *pFootnote );
435 : inline const SwTextFrm *FindFootnoteRef( const SwTextFootnote *pFootnote ) const
436 : { return const_cast<SwTextFrm *>(this)->FindFootnoteRef( pFootnote ); }
437 : void ConnectFootnote( SwTextFootnote *pFootnote, const SwTwips nDeadLine );
438 :
439 : /**
440 : * If we're a Footnote that grows towards its reference ...
441 : * public, because it's needed by SwContentFrm::MakeAll
442 : */
443 : SwTwips GetFootnoteLine( const SwTextFootnote *pFootnote ) const;
444 :
445 : /**
446 : * Returns the left and the right margin document coordinates
447 : * (taking the paragraph attributes into account)
448 : */
449 : inline SwTwips GetLeftMargin() const;
450 : inline SwTwips GetRightMargin() const;
451 :
452 : virtual void Format( const SwBorderAttrs *pAttrs = 0 ) SAL_OVERRIDE;
453 : virtual void CheckDirection( bool bVert ) SAL_OVERRIDE;
454 :
455 : /// Returns the sum of line height in pLine
456 : sal_uInt16 GetParHeight() const;
457 :
458 : /// Returns the remaining height
459 : inline SwTwips GetRstHeight() const;
460 :
461 : inline SwTextFrm *GetFollow();
462 : inline const SwTextFrm *GetFollow() const;
463 :
464 : /// Find the page number of ErgoSum and QuoVadis
465 : SwTextFrm *FindQuoVadisFrm();
466 :
467 : /**
468 : * Makes up for formatting if the Idle Handler has struck
469 : *
470 : * #i29062# GetFormatted() can trigger a full formatting
471 : * of the paragraph, causing other layout frames to become invalid. This
472 : * has to be avoided during painting. Therefore we need to pass the
473 : * information that we are currently in the paint process.
474 : */
475 : SwTextFrm* GetFormatted( bool bForceQuickFormat = false );
476 :
477 : /// Will be moved soon
478 564 : inline void SetFootnote( const bool bNew ) { bFootnote = bNew; }
479 :
480 : /// Respect the Follows
481 : inline bool IsInside( const sal_Int32 nPos ) const;
482 :
483 : const SwBodyFrm *FindBodyFrm() const;
484 :
485 : /// DropCaps and selections
486 1145 : inline bool GetDropRect( SwRect &rRect ) const
487 1145 : { return HasPara() && _GetDropRect( rRect ); }
488 :
489 54835036 : static SwCache *GetTextCache() { return pTextCache; }
490 59 : static void SetTextCache( SwCache *pNew ) { pTextCache = pNew; }
491 :
492 13816 : static long GetMinPrtLine() { return nMinPrtLine; }
493 : static void SetMinPrtLine( long nNew ) { nMinPrtLine = nNew; }
494 :
495 2180500 : inline sal_uInt16 GetCacheIdx() const { return nCacheIdx; }
496 41711 : inline void SetCacheIdx( const sal_uInt16 nNew ) { nCacheIdx = nNew; }
497 :
498 : /// Removes the Line information from the Cache
499 : void ClearPara();
500 :
501 : /// Am I a FootnoteFrm, with a number at the start of the paragraph?
502 57296 : inline bool IsFootnoteNumFrm() const
503 57296 : { return IsInFootnote() && !GetIndPrev() && _IsFootnoteNumFrm(); }
504 :
505 : /**
506 : * Simulates a formatting as if there were not right margin or Flys or other
507 : * obstacles and returns the width
508 : */
509 : SwTwips CalcFitToContent();
510 :
511 : /**
512 : * Simulate format for a list item paragraph, whose list level attributes
513 : * are in LABEL_ALIGNMENT mode, in order to determine additional first
514 : * line offset for the real text formatting due to the value of label
515 : * adjustment attribute of the list level.
516 : */
517 : void CalcAdditionalFirstLineOffset();
518 :
519 168603 : inline SwTwips GetAdditionalFirstLineOffset() const
520 : {
521 168603 : return mnAdditionalFirstLineOffset;
522 : }
523 :
524 : /**
525 : * Returns the additional line spacing for the next paragraph
526 : * @param _bNoPropLineSpacing: control, whether the value of a
527 : * proportional line spacing is returned or not
528 : */
529 : long GetLineSpace( const bool _bNoPropLineSpacing = false ) const;
530 :
531 : /// Returns the first line height
532 : sal_uInt16 FirstLineHeight() const;
533 :
534 : /// Rewires FlyInCntFrm, if nEnd > Index >= nStart
535 : void MoveFlyInCnt( SwTextFrm *pNew, sal_Int32 nStart, sal_Int32 nEnd );
536 :
537 : /// Calculates the position of FlyInCntFrms
538 : sal_Int32 CalcFlyPos( SwFrameFormat* pSearch );
539 :
540 : /// Determines the start position and step size of the register
541 : bool FillRegister( SwTwips& rRegStart, sal_uInt16& rRegDiff );
542 :
543 : /// Determines the line count
544 : sal_uInt16 GetLineCount( sal_Int32 nPos );
545 :
546 : /// For displaying the line numbers
547 83939 : sal_uLong GetAllLines() const { return nAllLines; }
548 26137 : sal_uLong GetThisLines() const { return nThisLines;}
549 : void RecalcAllLines();
550 :
551 : /// Stops the animations within numberings
552 : void StopAnimation( OutputDevice *pOut );
553 :
554 : /// Visit all portions for Accessibility
555 : void VisitPortions( SwPortionHandler& rPH ) const;
556 :
557 : /// Returns the script info stored at the paraportion
558 : const SwScriptInfo* GetScriptInfo() const;
559 :
560 : /// Swaps width and height of the text frame
561 : void SwapWidthAndHeight();
562 :
563 : /**
564 : * Calculates the coordinates of a rectangle when switching from
565 : * horizontal to vertical layout
566 : */
567 : void SwitchHorizontalToVertical( SwRect& rRect ) const;
568 :
569 : /**
570 : * Calculates the coordinates of a point when switching from
571 : * horizontal to vertical layout
572 : */
573 : void SwitchHorizontalToVertical( Point& rPoint ) const;
574 :
575 : /**
576 : * Calculates the a limit value when switching from
577 : * horizontal to vertical layout
578 : */
579 : long SwitchHorizontalToVertical( long nLimit ) const;
580 :
581 : /**
582 : * Calculates the coordinates of a rectangle when switching from
583 : * vertical to horizontal layout
584 : */
585 : void SwitchVerticalToHorizontal( SwRect& rRect ) const;
586 :
587 : /**
588 : * Calculates the coordinates of a point when switching from
589 : * vertical to horizontal layout
590 : */
591 : void SwitchVerticalToHorizontal( Point& rPoint ) const;
592 :
593 : /**
594 : * Calculates the a limit value when switching from
595 : * vertical to horizontal layout
596 : */
597 : long SwitchVerticalToHorizontal( long nLimit ) const;
598 :
599 : /**
600 : * Calculates the coordinates of a rectangle when switching from
601 : * LTR to RTL layout
602 : */
603 : void SwitchLTRtoRTL( SwRect& rRect ) const;
604 :
605 : /**
606 : * Calculates the coordinates of a point when switching from
607 : * LTR to RTL layout
608 : */
609 : void SwitchLTRtoRTL( Point& rPoint ) const;
610 :
611 : /**
612 : * Calculates the coordinates of a rectangle when switching from
613 : * RTL to LTR layout
614 : */
615 36 : inline void SwitchRTLtoLTR( SwRect& rRect ) const { SwitchLTRtoRTL( rRect ); }
616 :
617 : /**
618 : * Calculates the coordinates of a point when switching from
619 : * RTL to LTR layout
620 : */
621 0 : inline void SwitchRTLtoLTR( Point& rPoint ) const { SwitchLTRtoRTL( rPoint ); };
622 :
623 1875 : inline bool FollowFormatAllowed() const
624 : {
625 1875 : return mbFollowFormatAllowed;
626 : }
627 :
628 6501 : inline void AllowFollowFormat()
629 : {
630 6501 : mbFollowFormatAllowed = true;
631 6501 : }
632 :
633 994 : inline void ForbidFollowFormat()
634 : {
635 994 : mbFollowFormatAllowed = false;
636 994 : }
637 :
638 282832 : SwTwips GetBaseOfstForFly( bool bIgnoreFlysAnchoredAtThisFrame ) const
639 : {
640 : return ( bIgnoreFlysAnchoredAtThisFrame ?
641 : mnFlyAnchorOfst :
642 282832 : mnFlyAnchorOfstNoWrap );
643 : }
644 :
645 29037 : inline SwTwips GetHeightOfLastLine() const
646 : {
647 29037 : return mnHeightOfLastLine;
648 : }
649 :
650 : static void repaintTextFrames( const SwTextNode& rNode );
651 :
652 : virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const SAL_OVERRIDE;
653 : };
654 :
655 : //use this to protect a SwTextFrm for a given scope from getting merged with
656 : //its neighbour and thus deleted
657 : class TextFrmLockGuard
658 : {
659 : private:
660 : SwTextFrm *m_pTextFrm;
661 : bool m_bOldLocked;
662 : public:
663 : //Lock pFrm for the lifetime of the Cut/Paste call, etc. to avoid
664 : //SwTextFrm::_AdjustFollow removing the pFrm we're trying to Make
665 74101 : TextFrmLockGuard(SwFrm* pFrm)
666 : {
667 74101 : m_pTextFrm = pFrm->IsTextFrm() ? static_cast<SwTextFrm*>(pFrm) : 0;
668 74101 : if (m_pTextFrm)
669 : {
670 74101 : m_bOldLocked = m_pTextFrm->IsLocked();
671 74101 : m_pTextFrm->Lock();
672 : }
673 : else
674 : {
675 0 : m_bOldLocked = false;
676 : }
677 74101 : }
678 :
679 74101 : ~TextFrmLockGuard()
680 : {
681 74101 : if (m_pTextFrm && !m_bOldLocked)
682 73517 : m_pTextFrm->Unlock();
683 74101 : }
684 : };
685 :
686 148395 : inline const SwParaPortion *SwTextFrm::GetPara() const
687 : {
688 148395 : return const_cast<SwTextFrm*>(this)->GetPara();
689 : }
690 :
691 599633 : inline bool SwTextFrm::HasPara() const
692 : {
693 599633 : return nCacheIdx!=USHRT_MAX && _HasPara();
694 : }
695 :
696 : /// 9104: Frm().Height() - Prt().Height(), see widorp.cxx and 7455, 6114, 7908
697 : inline SwTwips SwTextFrm::GetRstHeight() const
698 : {
699 : return !GetUpper() ? 0 : static_cast<const SwFrm*>(GetUpper())->Frm().Top()
700 : + static_cast<const SwFrm*>(GetUpper())->Prt().Top()
701 : + static_cast<const SwFrm*>(GetUpper())->Prt().Height()
702 : - Frm().Top() - (Frm().Height() - Prt().Height());
703 : }
704 :
705 : inline SwTwips SwTextFrm::GetLeftMargin() const
706 : {
707 : return Frm().Left() + Prt().Left();
708 : }
709 : inline SwTwips SwTextFrm::GetRightMargin() const
710 : {
711 : return Frm().Left() + Prt().Left() + Prt().Width();
712 : }
713 6389 : inline SwTwips SwTextFrm::GrowTst( const SwTwips nGrow )
714 : {
715 6389 : return Grow( nGrow, true );
716 : }
717 :
718 11 : inline bool SwTextFrm::IsInside( const sal_Int32 nPos ) const
719 : {
720 11 : bool bRet = true;
721 11 : if( nPos < GetOfst() )
722 0 : bRet = false;
723 : else
724 : {
725 11 : const SwTextFrm *pFoll = GetFollow();
726 11 : if( pFoll && nPos >= pFoll->GetOfst() )
727 0 : bRet = false;
728 : }
729 11 : return bRet;
730 : }
731 :
732 392 : inline SwTwips SwTextFrm::GetFootnoteFrmHeight() const
733 : {
734 392 : if( !IsFollow() && IsInFootnote() && HasPara() )
735 392 : return _GetFootnoteFrmHeight();
736 : else
737 0 : return 0;
738 : }
739 :
740 82954 : inline const SwTextFrm *SwTextFrm::GetFollow() const
741 : {
742 82954 : return static_cast<const SwTextFrm*>(SwContentFrm::GetFollow());
743 : }
744 614385 : inline SwTextFrm *SwTextFrm::GetFollow()
745 : {
746 614385 : return static_cast<SwTextFrm*>(SwContentFrm::GetFollow());
747 : }
748 :
749 : inline const SwTextFrm *SwTextFrm::GetFrmAtPos( const SwPosition &rPos) const
750 : {
751 : return const_cast<SwTextFrm*>(this)->GetFrmAtPos( rPos );
752 : }
753 :
754 : inline void SwTextFrm::AdjustFollow( SwTextFormatter &rLine,
755 : const sal_Int32 nOffset, const sal_Int32 nStrEnd, const sal_uInt8 nMode )
756 : {
757 : if ( HasFollow() )
758 : _AdjustFollow( rLine, nOffset, nStrEnd, nMode );
759 : }
760 :
761 26 : inline void SwTextFrm::SetOfst( const sal_Int32 nNewOfst )
762 : {
763 26 : if ( nOfst != nNewOfst )
764 26 : _SetOfst( nNewOfst );
765 26 : }
766 :
767 46435 : inline void SwTextFrm::SetRepaint() const
768 : {
769 46435 : const_cast<SwTextFrm*>(this)->bRepaint = true;
770 46435 : }
771 28664 : inline void SwTextFrm::ResetRepaint() const
772 : {
773 28664 : const_cast<SwTextFrm*>(this)->bRepaint = false;
774 28664 : }
775 :
776 54 : inline void SwTextFrm::SetBlinkPor() const
777 : {
778 54 : const_cast<SwTextFrm*>(this)->bBlinkPor = true;
779 54 : }
780 15371 : inline void SwTextFrm::ResetBlinkPor() const
781 : {
782 15371 : const_cast<SwTextFrm*>(this)->bBlinkPor = false;
783 15371 : }
784 :
785 : class TemporarySwap {
786 : protected:
787 826427 : explicit TemporarySwap(SwTextFrm * frame, bool swap):
788 826427 : frame_(frame), undo_(false)
789 : {
790 826427 : if (frame_->IsVertical() && swap) {
791 28 : undo_ = true;
792 28 : frame_->SwapWidthAndHeight();
793 : }
794 826427 : }
795 :
796 826427 : ~TemporarySwap() {
797 826427 : if (undo_) {
798 28 : frame_->SwapWidthAndHeight();
799 : }
800 826427 : }
801 :
802 : private:
803 : TemporarySwap(TemporarySwap &) = delete;
804 : void operator =(TemporarySwap &) = delete;
805 :
806 : SwTextFrm * frame_;
807 : bool undo_;
808 : };
809 :
810 752640 : class SWAP_IF_SWAPPED: private TemporarySwap {
811 : public:
812 752640 : explicit SWAP_IF_SWAPPED(SwTextFrm * frame):
813 752640 : TemporarySwap(frame, frame->IsSwapped()) {}
814 : };
815 :
816 73787 : class SWAP_IF_NOT_SWAPPED: private TemporarySwap {
817 : public:
818 73787 : explicit SWAP_IF_NOT_SWAPPED(SwTextFrm * frame):
819 73787 : TemporarySwap(frame, !frame->IsSwapped()) {}
820 : };
821 :
822 : /**
823 : * Helper class which can be used instead of the macros if a function
824 : * has too many returns
825 : */
826 : class SwFrmSwapper
827 : {
828 : const SwTextFrm* pFrm;
829 : bool bUndo;
830 : public:
831 : SwFrmSwapper( const SwTextFrm* pFrm, bool bSwapIfNotSwapped );
832 : ~SwFrmSwapper();
833 : };
834 :
835 : class SwLayoutModeModifier
836 : {
837 : const OutputDevice& rOut;
838 : ComplexTextLayoutMode nOldLayoutMode;
839 : public:
840 : SwLayoutModeModifier( const OutputDevice& rOutp );
841 : ~SwLayoutModeModifier();
842 : void Modify( bool bChgToRTL );
843 : void SetAuto();
844 : };
845 :
846 : class SwDigitModeModifier
847 : {
848 : const OutputDevice& rOut;
849 : LanguageType nOldLanguageType;
850 : public:
851 : SwDigitModeModifier( const OutputDevice& rOutp, LanguageType eCurLang );
852 : ~SwDigitModeModifier();
853 : };
854 :
855 : #endif
856 :
857 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|