Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef SW_NDTXT_HXX
29 : : #define SW_NDTXT_HXX
30 : :
31 : : #include <cppuhelper/weakref.hxx>
32 : :
33 : : #include "swdllapi.h"
34 : : #include <node.hxx>
35 : : #include <hintids.hxx>
36 : : #include <ndhints.hxx>
37 : : #include <modeltoviewhelper.hxx>
38 : : #include <SwNumberTreeTypes.hxx>
39 : : #include <IDocumentContentOperations.hxx>
40 : : #include <osl/diagnose.h>
41 : :
42 : : #include <sfx2/Metadatable.hxx>
43 : :
44 : : #include <vector>
45 : : #include <set>
46 : :
47 : : class SfxHint;
48 : : class SwNumRule;
49 : : class SwNodeNum;
50 : : class SwList;
51 : : class SvxLRSpaceItem;
52 : :
53 : : namespace utl {
54 : : class TransliterationWrapper;
55 : : }
56 : :
57 : : class SwTxtFmtColl;
58 : : class SwCntntFrm;
59 : : class SwTxtFld; // For GetTxtFld().
60 : : class SfxItemSet;
61 : : class SwUndoTransliterate;
62 : :
63 : : struct SwSpellArgs; // for Spell(), splargs.hxx
64 : : struct SwConversionArgs; // for Convert(), splargs.hxx
65 : : class SwInterHyphInfo; // for Hyphenate(), splargs.hxx
66 : : class SwWrongList; // For OnlineSpelling.
67 : : class SwGrammarMarkUp;
68 : : class OutputDevice;
69 : : class SwScriptInfo;
70 : : struct SwDocStat;
71 : : struct SwParaIdleData_Impl;
72 : :
73 : : namespace com { namespace sun { namespace star {
74 : : namespace uno {
75 : : template < class > class Sequence;
76 : : }
77 : : namespace text { class XTextContent; }
78 : : } } }
79 : :
80 : : typedef std::set< xub_StrLen > SwSoftPageBreakList;
81 : :
82 : : /// SwTxtNode is a paragraph in the document model.
83 : : class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable
84 : : {
85 : :
86 : : // For creating the first TextNode.
87 : : friend class SwDoc; // CTOR and AppendTxtNode()
88 : : friend class SwNodes;
89 : : friend class SwTxtFrm;
90 : : friend class SwScriptInfo;
91 : :
92 : : // May be 0. It is only then not 0 if it contains hard attributes.
93 : : // Therefore: never access directly!
94 : : SwpHints *m_pSwpHints;
95 : :
96 : : mutable SwNodeNum* mpNodeNum; // Numbering for this paragraph.
97 : :
98 : : XubString m_Text;
99 : :
100 : : SwParaIdleData_Impl* m_pParaIdleData_Impl;
101 : :
102 : : // Some of the chars this para are hidden. Paragraph has to be reformatted
103 : : // on changing the view to print preview.
104 : : mutable bool m_bContainsHiddenChars : 1;
105 : : // The whole paragraph is hidden because of the hidden text attribute
106 : : mutable bool m_bHiddenCharsHidePara : 1;
107 : : // The last two flags have to be recalculated if this flag is set:
108 : : mutable bool m_bRecalcHiddenCharFlags : 1;
109 : :
110 : : mutable bool m_bLastOutlineState : 1;
111 : : bool m_bNotifiable;
112 : :
113 : : // sal_uInt8 nOutlineLevel; //#outline level, removed by zhaojianwei.
114 : : bool mbEmptyListStyleSetDueToSetOutlineLevelAttr;
115 : :
116 : : // boolean, indicating that a <SetAttr(..)> or <ResetAttr(..)> or
117 : : // <ResetAllAttr(..)> method is running.
118 : : // Needed to avoid duplicate handling of attribute change actions.
119 : : bool mbInSetOrResetAttr;
120 : :
121 : : // pointer to the list, to whose the text node is added to
122 : : SwList* mpList;
123 : :
124 : : ::std::auto_ptr< ::rtl::OUString > m_pNumStringCache;
125 : :
126 : : ::com::sun::star::uno::WeakReference<
127 : : ::com::sun::star::text::XTextContent> m_wXParagraph;
128 : :
129 : : SW_DLLPRIVATE SwTxtNode( const SwNodeIndex &rWhere, SwTxtFmtColl *pTxtColl,
130 : : const SfxItemSet* pAutoAttr = 0 );
131 : :
132 : : // Copies the attributes at nStart to pDest.
133 : : SW_DLLPRIVATE void CopyAttr( SwTxtNode *pDest, const xub_StrLen nStart, const xub_StrLen nOldPos);
134 : :
135 : : SW_DLLPRIVATE SwTxtNode* _MakeNewTxtNode( const SwNodeIndex&, sal_Bool bNext = sal_True,
136 : : sal_Bool bChgFollow = sal_True );
137 : :
138 : : SW_DLLPRIVATE void CutImpl(
139 : : SwTxtNode * const pDest, const SwIndex & rDestStart,
140 : : const SwIndex & rStart, /*const*/ xub_StrLen nLen,
141 : : const bool bUpdate = true );
142 : :
143 : : // Move all comprising hard attributes to the AttrSet of the paragraph.
144 : : SW_DLLPRIVATE void MoveTxtAttr_To_AttrSet(); // Called by SplitNode.
145 : :
146 : : // Create the specific AttrSet.
147 : : SW_DLLPRIVATE virtual void NewAttrSet( SwAttrPool& );
148 : :
149 : : SW_DLLPRIVATE void Replace0xFF( XubString& rTxt, xub_StrLen& rTxtStt,
150 : : xub_StrLen nEndPos, sal_Bool bExpandFlds ) const;
151 : :
152 : : // Optimization: Asking for information about hidden characters at SwScriptInfo
153 : : // updates these flags.
154 : 21821 : inline bool IsCalcHiddenCharFlags() const
155 : 21821 : { return m_bRecalcHiddenCharFlags; }
156 : 27716 : inline void SetHiddenCharAttribute( bool bNewHiddenCharsHidePara, bool bNewContainsHiddenChars ) const
157 : : {
158 : 27716 : m_bHiddenCharsHidePara = bNewHiddenCharsHidePara;
159 : 27716 : m_bContainsHiddenChars = bNewContainsHiddenChars;
160 : 27716 : m_bRecalcHiddenCharFlags = false;
161 : 27716 : }
162 : :
163 : : SW_DLLPRIVATE void CalcHiddenCharFlags() const;
164 : :
165 : : SW_DLLPRIVATE SwNumRule * _GetNumRule(sal_Bool bInParent = sal_True) const;
166 : :
167 : : SW_DLLPRIVATE void SetLanguageAndFont( const SwPaM &rPaM,
168 : : LanguageType nLang, sal_uInt16 nLangWhichId,
169 : : const Font *pFont, sal_uInt16 nFontWhichId );
170 : :
171 : : //
172 : : // Start: Data collected during idle time
173 : : //
174 : : SW_DLLPRIVATE void SetParaNumberOfWords( sal_uLong nTmpWords ) const;
175 : : SW_DLLPRIVATE sal_uLong GetParaNumberOfWords() const;
176 : : SW_DLLPRIVATE void SetParaNumberOfAsianWords( sal_uLong nTmpAsianWords ) const;
177 : : SW_DLLPRIVATE sal_uLong GetParaNumberOfAsianWords() const;
178 : : SW_DLLPRIVATE void SetParaNumberOfChars( sal_uLong nTmpChars ) const;
179 : : SW_DLLPRIVATE sal_uLong GetParaNumberOfChars() const;
180 : : SW_DLLPRIVATE void SetParaNumberOfCharsExcludingSpaces( sal_uLong nTmpChars ) const;
181 : : SW_DLLPRIVATE sal_uLong GetParaNumberOfCharsExcludingSpaces() const;
182 : : SW_DLLPRIVATE void InitSwParaStatistics( bool bNew );
183 : :
184 : : /** create number for this text node, if not already existing
185 : :
186 : : @return number of this node
187 : : */
188 : : SwNodeNum* CreateNum() const;
189 : :
190 : : inline void TryDeleteSwpHints();
191 : :
192 : : SW_DLLPRIVATE void impl_FmtToTxtAttr(const SfxItemSet& i_rAttrSet);
193 : :
194 : : public:
195 : : bool IsWordCountDirty() const;
196 : : bool IsWrongDirty() const;
197 : : bool IsGrammarCheckDirty() const;
198 : : bool IsSmartTagDirty() const; // SMARTTAGS
199 : : bool IsAutoCompleteWordDirty() const;
200 : : void SetWordCountDirty( bool bNew ) const;
201 : : void SetWrongDirty( bool bNew ) const;
202 : : void SetGrammarCheckDirty( bool bNew ) const;
203 : : void SetSmartTagDirty( bool bNew ) const; // SMARTTAGS
204 : : void SetAutoCompleteWordDirty( bool bNew ) const;
205 : : void SetWrong( SwWrongList* pNew, bool bDelete = true );
206 : : SwWrongList* GetWrong();
207 : : const SwWrongList* GetWrong() const;
208 : : void SetGrammarCheck( SwGrammarMarkUp* pNew, bool bDelete = true );
209 : : SwGrammarMarkUp* GetGrammarCheck();
210 : : // SMARTTAGS
211 : : void SetSmartTags( SwWrongList* pNew, bool bDelete = true );
212 : : SwWrongList* GetSmartTags();
213 : :
214 : : //
215 : : // End: Data collected during idle time
216 : : //
217 : : protected:
218 : : // fuers Umhaengen der TxtFmtCollections (Outline-Nummerierung!!)
219 : : virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
220 : : virtual void SwClientNotify( const SwModify&, const SfxHint& );
221 : :
222 : : public:
223 : : using SwCntntNode::GetAttr;
224 : :
225 : 902043 : const String& GetTxt() const { return m_Text; }
226 : :
227 : : // getters for SwpHints
228 : : inline SwpHints &GetSwpHints();
229 : : inline const SwpHints &GetSwpHints() const;
230 : 174911 : inline SwpHints *GetpSwpHints() { return m_pSwpHints; }
231 : 156180 : inline const SwpHints *GetpSwpHints() const { return m_pSwpHints; }
232 : 708175 : inline bool HasHints() const { return m_pSwpHints ? true : false; }
233 : : inline SwpHints &GetOrCreateSwpHints();
234 : :
235 : : virtual ~SwTxtNode();
236 : :
237 : : virtual xub_StrLen Len() const;
238 : :
239 : : // Is in itratr.
240 : : void GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rMax, sal_uLong &rAbs,
241 : : OutputDevice* pOut = 0 ) const;
242 : :
243 : : // overriding to handle change of certain paragraph attributes
244 : : virtual sal_Bool SetAttr( const SfxPoolItem& );
245 : : virtual sal_Bool SetAttr( const SfxItemSet& rSet );
246 : : virtual sal_Bool ResetAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
247 : : virtual sal_Bool ResetAttr( const std::vector<sal_uInt16>& rWhichArr );
248 : : virtual sal_uInt16 ResetAllAttr();
249 : :
250 : : /// insert text content
251 : : void InsertText( const XubString & rStr, const SwIndex & rIdx,
252 : : const enum IDocumentContentOperations::InsertFlags nMode
253 : : = IDocumentContentOperations::INS_DEFAULT );
254 : :
255 : : /** delete text content
256 : : ATTENTION: must not be called with a range that overlaps the start of
257 : : an attribute with both extent and dummy char
258 : : */
259 : : void EraseText ( const SwIndex &rIdx, const xub_StrLen nCount = STRING_LEN,
260 : : const enum IDocumentContentOperations::InsertFlags nMode
261 : : = IDocumentContentOperations::INS_DEFAULT );
262 : :
263 : : /** delete all attributes.
264 : : If neither pSet nor nWhich is given, delete all attributes (except
265 : : refmarks, toxmarks, meta) in range.
266 : : @param rIdx start position
267 : : @param nLen range in which attributes will be deleted
268 : : @param pSet if not 0, delete only attributes contained in pSet
269 : : @param nWhich if not 0, delete only attributes with matching which
270 : : @param bInclRefToxMark
271 : : refmarks, toxmarks, and metas will be ignored unless this is true
272 : : ATTENTION: setting bInclRefToxMark is only allowed from UNDO!
273 : : */
274 : : void RstAttr( const SwIndex &rIdx, xub_StrLen nLen, sal_uInt16 nWhich = 0,
275 : : const SfxItemSet* pSet = 0, sal_Bool bInclRefToxMark = sal_False );
276 : : void GCAttr();
277 : :
278 : : // Delete text attribute (needs to be deregistered at Pool!)
279 : : void DestroyAttr( SwTxtAttr* pAttr );
280 : :
281 : : // delete all attributes from SwpHintsArray.
282 : : void ClearSwpHintsArr( bool bDelFields );
283 : :
284 : : /// Insert pAttr into hints array. @return true iff inserted successfully
285 : : bool InsertHint( SwTxtAttr * const pAttr,
286 : : const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT );
287 : : /// create new text attribute from rAttr and insert it
288 : : /// @return inserted hint; 0 if not sure the hint is inserted
289 : : SwTxtAttr* InsertItem( SfxPoolItem& rAttr,
290 : : const xub_StrLen nStart, const xub_StrLen nEnd,
291 : : const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT );
292 : :
293 : : // Set these attributes at TextNode. If the whole range is comprised
294 : : // set them only in AutoAttrSet (SwCntntNode::SetAttr).
295 : : sal_Bool SetAttr( const SfxItemSet& rSet,
296 : : xub_StrLen nStt, xub_StrLen nEnd,
297 : : const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT );
298 : : // Query the attributes of textnode over the range.
299 : : // Introduce 4th optional parameter <bMergeIndentValuesOfNumRule>.
300 : : // If <bMergeIndentValuesOfNumRule> == sal_True, the indent attributes of
301 : : // the corresponding list level of an applied list style is merged into
302 : : // the requested item set as a LR-SPACE item, if <bOnlyTxtAttr> == sal_False,
303 : : // corresponding node has not its own indent attributes and the
304 : : // position-and-space mode of the list level is SvxNumberFormat::LABEL_ALIGNMENT.
305 : : sal_Bool GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd,
306 : : sal_Bool bOnlyTxtAttr = sal_False,
307 : : sal_Bool bGetFromChrFmt = sal_True,
308 : : const bool bMergeIndentValuesOfNumRule = false ) const;
309 : :
310 : : // Convey attributes of an AttrSet (AutoFmt) to SwpHintsArray.
311 : : void FmtToTxtAttr( SwTxtNode* pNd );
312 : :
313 : : /// delete all attributes of type nWhich at nStart (opt. end nEnd)
314 : : void DeleteAttributes( const sal_uInt16 nWhich,
315 : : const xub_StrLen nStart, const xub_StrLen nEnd = 0 );
316 : : /// delete the attribute pTxtAttr
317 : : void DeleteAttribute ( SwTxtAttr * const pTxtAttr );
318 : :
319 : : // Actions on text and attributes.
320 : : // introduce optional parameter to control, if all attributes have to be copied.
321 : : void CopyText( SwTxtNode * const pDest,
322 : : const SwIndex &rStart,
323 : : const xub_StrLen nLen,
324 : : const bool bForceCopyOfAllAttrs = false );
325 : : void CopyText( SwTxtNode * const pDest,
326 : : const SwIndex &rDestStart,
327 : : const SwIndex &rStart,
328 : : xub_StrLen nLen,
329 : : const bool bForceCopyOfAllAttrs = false );
330 : :
331 : : void CutText(SwTxtNode * const pDest,
332 : : const SwIndex & rStart, const xub_StrLen nLen);
333 : : inline void CutText(SwTxtNode * const pDest, const SwIndex &rDestStart,
334 : : const SwIndex & rStart, const xub_StrLen nLen);
335 : :
336 : : /// replace nDelLen characters at rStart with rText
337 : : void ReplaceText( const SwIndex& rStart, const xub_StrLen nDelLen,
338 : : const XubString& rText );
339 : : void ReplaceTextOnly( xub_StrLen nPos, xub_StrLen nLen, const XubString& rText,
340 : : const ::com::sun::star::uno::Sequence<sal_Int32>& rOffsets );
341 : :
342 : : // Virtual methods from CntntNode.
343 : : virtual SwCntntFrm *MakeFrm( SwFrm* );
344 : : virtual SwCntntNode *SplitCntntNode( const SwPosition & );
345 : : virtual SwCntntNode *JoinNext();
346 : : virtual SwCntntNode *JoinPrev();
347 : :
348 : : SwCntntNode *AppendNode( const SwPosition & );
349 : :
350 : : // When appropriate set DontExpand-flag at INet or character styles respectively.
351 : : sal_Bool DontExpandFmt( const SwIndex& rIdx, bool bFlag = true,
352 : : sal_Bool bFmtToTxtAttributes = sal_True );
353 : :
354 : : enum GetTxtAttrMode {
355 : : DEFAULT, /// DEFAULT: (Start < nIndex <= End)
356 : : EXPAND, /// EXPAND : (Start <= nIndex < End)
357 : : PARENT, /// PARENT : (Start < nIndex < End)
358 : : };
359 : :
360 : : /** get the innermost text attribute covering position nIndex.
361 : : @param nWhich only attribute with this id is returned.
362 : : @param eMode the predicate for matching (@see GetTxtAttrMode).
363 : :
364 : : ATTENTION: this function is not well-defined for those
365 : : hints of which several may cover a single position, like
366 : : RES_TXTATR_CHARFMT, RES_TXTATR_REFMARK, RES_TXTATR_TOXMARK
367 : : */
368 : : SwTxtAttr *GetTxtAttrAt(xub_StrLen const nIndex, RES_TXTATR const nWhich,
369 : : enum GetTxtAttrMode const eMode = DEFAULT) const;
370 : :
371 : : /** get the innermost text attributes covering position nIndex.
372 : : @param nWhich only attributes with this id are returned.
373 : : @param eMode the predicate for matching (@see GetTxtAttrMode).
374 : : */
375 : : ::std::vector<SwTxtAttr *> GetTxtAttrsAt(xub_StrLen const nIndex,
376 : : RES_TXTATR const nWhich,
377 : : enum GetTxtAttrMode const eMode = DEFAULT) const;
378 : :
379 : : /** get the text attribute at position nIndex which owns
380 : : the dummy character CH_TXTATR_* at that position, if one exists.
381 : : @param nIndex the position in the text
382 : : @param nWhich if different from RES_TXTATR_END, return only
383 : : attribute with given which id
384 : : @return the text attribute at nIndex of type nWhich, if it exists
385 : : */
386 : : SwTxtAttr *GetTxtAttrForCharAt( const xub_StrLen nIndex,
387 : : const RES_TXTATR nWhich = RES_TXTATR_END ) const;
388 : :
389 : : XubString GetCurWord(xub_StrLen) const;
390 : : sal_uInt16 Spell(SwSpellArgs*);
391 : : sal_uInt16 Convert( SwConversionArgs & );
392 : :
393 : : inline SwTxtFmtColl *GetTxtColl() const;
394 : : virtual SwFmtColl *ChgFmtColl( SwFmtColl* );
395 : : void _ChgTxtCollUpdateNum( const SwTxtFmtColl* pOld,
396 : : const SwTxtFmtColl* pNew );
397 : :
398 : : // Copy collection with all auto formats to dest-node.
399 : : // The latter might be in an other document!
400 : : // (Method in ndcopy.cxx!!).
401 : : void CopyCollFmt( SwTxtNode& rDestNd );
402 : :
403 : : //const SwNodeNum* _GetNodeNum() const { return pNdNum; }
404 : :
405 : : //
406 : : // BEGIN OF BULLET/NUMBERING/OUTLINE STUFF:
407 : : //
408 : :
409 : : /**
410 : : Returns numbering rule of this text node.
411 : :
412 : : @param bInParent serach in parent attributes, too
413 : :
414 : : @return numbering rule of this text node or NULL if none is set
415 : : */
416 : : SwNumRule *GetNumRule(sal_Bool bInParent = sal_True) const;
417 : :
418 : 1112636 : inline const SwNodeNum* GetNum() const
419 : : {
420 : 1112636 : return mpNodeNum;
421 : : }
422 : :
423 : : SwNumberTree::tNumberVector GetNumberVector() const;
424 : :
425 : : /**
426 : : Returns if this text node is an outline.
427 : :
428 : : @retval true this text node is an outline
429 : : @retval false else
430 : : */
431 : : bool IsOutline() const;
432 : :
433 : : bool IsOutlineStateChanged() const;
434 : :
435 : : void UpdateOutlineState();
436 : :
437 : : /** Returns if this text node may be numbered.
438 : :
439 : : A text node may be numbered if
440 : : - it has no SwNodeNum
441 : : - it has a SwNodeNum and it has a numbering rule and the according
442 : : SwNumFmt defines a numbering type that is an enumeration.
443 : :
444 : : @retval sal_True this text node may be numbered
445 : : @retval sal_False else
446 : : */
447 : : //sal_Bool MayBeNumbered() const;
448 : :
449 : : /**
450 : : Notify this textnode that its numbering rule has changed.
451 : : */
452 : : void NumRuleChgd();
453 : :
454 : : /** Returns outline of numbering string
455 : :
456 : : Introduce parameter <_bInclPrefixAndSuffixStrings> in order to control,
457 : : if the prefix and the suffix strings have to been included or not.
458 : :
459 : : @param _bInclPrefixAndSuffixStrings
460 : : optional input parameter - boolean indicating, if the prefix and the
461 : : suffix strings have to been included or not. default value = <true>
462 : :
463 : : @param _nRestrictToThisLevel
464 : : optional input parameter - unsigned integer indicating the maximum outline
465 : : level to which the output string must be restricted to. Default value is
466 : : MAXLEVEL
467 : : */
468 : : XubString GetNumString( const bool _bInclPrefixAndSuffixStrings = true, const unsigned int _nRestrictToThisLevel = MAXLEVEL ) const;
469 : :
470 : : /**
471 : : Returns the additional indents of this text node and its numbering.
472 : :
473 : : @param bTxtLeft ???
474 : :
475 : : @return additional indents
476 : : */
477 : : long GetLeftMarginWithNum( sal_Bool bTxtLeft = sal_False ) const;
478 : :
479 : : /**
480 : : Returns the combined first line indent of this text node and
481 : : its numbering.
482 : :
483 : : @param the first line indent of this text node taking the
484 : : numbering into account (return parameter)
485 : :
486 : : @retval sal_True this node has SwNodeNum and has numbering rule
487 : : @retval sal_False else
488 : : */
489 : : sal_Bool GetFirstLineOfsWithNum( short& rFirstOffset ) const;
490 : :
491 : : SwTwips GetAdditionalIndentForStartingNewList() const;
492 : :
493 : : void ClearLRSpaceItemDueToListLevelIndents( SvxLRSpaceItem& o_rLRSpaceItem ) const;
494 : :
495 : : /** return left margin for tab stop position calculation
496 : :
497 : : Needed for text formatting
498 : : Method considers new list level attributes, which also can provide a left margin value
499 : :
500 : : @author OD
501 : : */
502 : : long GetLeftMarginForTabCalculation() const;
503 : :
504 : : /** Returns if this text node has a number.
505 : :
506 : : This text node has a number if it has a SwNodeNum and a
507 : : numbering rule and the numbering format specified for the
508 : : level of the SwNodeNum is of an enumeration type.
509 : :
510 : : @retval sal_True This text node has a number.
511 : : @retval sal_False else
512 : : */
513 : : sal_Bool HasNumber() const;
514 : :
515 : : /** Returns if this text node has a bullet.
516 : :
517 : : This text node has a bullet if it has a SwNodeNum and a
518 : : numbering rule and the numbering format specified for the
519 : : level of the SwNodeNum is of a bullet type.
520 : :
521 : : @retval sal_True This text node has a bullet.
522 : : @retval sal_False else
523 : : */
524 : : sal_Bool HasBullet() const;
525 : :
526 : : /** Returns is this text node is numbered.
527 : :
528 : : This node is numbered if it has a SwNodeNum and it has a
529 : : numbering rule and has not a hidden SwNodeNum.
530 : :
531 : : ATTENTION: Returns sal_True even if the SwNumFmt has type
532 : : SVX_NUM_NUMBER_NONE.
533 : :
534 : : @retval sal_True This node is numbered.
535 : : @retval sal_False else
536 : : */
537 : : sal_Bool IsNumbered() const;
538 : :
539 : : /** Returns if this text node has a marked label.
540 : :
541 : : @retval true This text node has a marked label.
542 : : @retval false else
543 : : */
544 : : bool HasMarkedLabel() const;
545 : :
546 : : /** Sets the list level of this text node.
547 : :
548 : : Side effect, when the text node is a list item:
549 : : The text node's representation in the list tree (<SwNodeNum> instance)
550 : : is updated.
551 : :
552 : : @param nLevel level to set
553 : : */
554 : : void SetAttrListLevel(int nLevel);
555 : :
556 : : bool HasAttrListLevel() const;
557 : :
558 : : int GetAttrListLevel() const;
559 : :
560 : : /** Returns the actual list level of this text node, when it is a list item
561 : :
562 : : @return the actual list level of this text node, if it is a list item,
563 : : -1 otherwise
564 : : */
565 : : int GetActualListLevel() const;
566 : :
567 : : /**
568 : : Returns outline level of this text node.
569 : :
570 : : If a text node has an outline number (i.e. it has an SwNodeNum
571 : : and a outline numbering rule) the outline level is the level of
572 : : this SwNodeNum.
573 : :
574 : : If a text node has no outline number and has a paragraph style
575 : : attached the outline level is the outline level of the
576 : : paragraph style.
577 : :
578 : : Otherwise the text node has no outline level (NO_NUMBERING).
579 : :
580 : : NOTE: The outline level of text nodes is subject to change. The
581 : : plan is to have an SwTxtNode::nOutlineLevel member that is
582 : : updated from a paragraph style upon appliance of that paragraph
583 : : style.
584 : :
585 : : @return outline level or NO_NUMBERING if there is no outline level
586 : : */
587 : : int GetAttrOutlineLevel() const;//#OutlineLevel,added by zhaojianwei
588 : :
589 : : /**
590 : : Sets the out line level *at* a text node.
591 : :
592 : : @param nLevel the level to be set
593 : :
594 : : If the text node has an outline number the level is set at the
595 : : outline number.
596 : :
597 : : If the text node has no outline number but has a paragraph
598 : : style applied the outline level is set at the paragraph style.
599 : :
600 : : NOTE: This is subject to change, see GetOutlineLevel.
601 : : */
602 : : void SetAttrOutlineLevel(int nLevel);//#OutlineLevel,added by zhaojianwei
603 : :
604 : : bool IsEmptyListStyleDueToSetOutlineLevelAttr();
605 : : void SetEmptyListStyleDueToSetOutlineLevelAttr();
606 : : void ResetEmptyListStyleDueToResetOutlineLevelAttr();
607 : :
608 : : /**
609 : : Returns the width of leading tabs/blanks in this paragraph.
610 : : This space will be converted into numbering indent if the paragraph
611 : : is set to be numbered.
612 : :
613 : : @return the width of the leading whitespace
614 : : */
615 : : sal_uInt16 GetWidthOfLeadingTabs() const;
616 : :
617 : : /**
618 : : Returns if the paragraph has a visible numbering or bullet.
619 : : This includes all kinds of numbering/bullet/outlines.
620 : : Note: This function returns false, if the numbering format is
621 : : SVX_NUM_NUMBER_NONE or if the numbering/bullet has been deleted.
622 : :
623 : : @return sal_True if the paragraph has a visible numbering/bullet/outline
624 : : */
625 : : bool HasVisibleNumberingOrBullet() const;
626 : :
627 : : void SetListId( const String sListId );
628 : : String GetListId() const;
629 : :
630 : : /** Determines, if the list level indent attributes can be applied to the
631 : : paragraph.
632 : :
633 : : The list level indents can be applied to the paragraph under the one
634 : : of following conditions:
635 : : - the list style is directly applied to the paragraph and the paragraph
636 : : has no own indent attributes.
637 : : - the list style is applied to the paragraph through one of its paragraph
638 : : styles, the paragraph has no own indent attributes and on the paragraph
639 : : style hierarchy from the paragraph to the paragraph style with the
640 : : list style no indent attributes are found.
641 : :
642 : : @author OD
643 : :
644 : : @return boolean
645 : : */
646 : : bool AreListLevelIndentsApplicable() const;
647 : :
648 : : /** Retrieves the list tab stop position, if the paragraph's list level defines
649 : : one and this list tab stop has to merged into the tap stops of the paragraph
650 : :
651 : : @author OD
652 : :
653 : : @param nListTabStopPosition
654 : : output parameter - containing the list tab stop position
655 : :
656 : : @return boolean - indicating, if a list tab stop position is provided
657 : : */
658 : : bool GetListTabStopPosition( long& nListTabStopPosition ) const;
659 : :
660 : : /** Retrieves the character following the list label, if the paragraph's
661 : : list level defines one.
662 : :
663 : : @author OD
664 : :
665 : : @return XubString - the list tab stop position
666 : : */
667 : : XubString GetLabelFollowedBy() const;
668 : :
669 : : //
670 : : // END OF BULLET/NUMBERING/OUTLINE STUFF:
671 : : //
672 : :
673 : : void fillSoftPageBreakList( SwSoftPageBreakList& rBreak ) const;
674 : :
675 : : sal_uInt16 GetLang( const xub_StrLen nBegin, const xub_StrLen nLen = 0,
676 : : sal_uInt16 nScript = 0 ) const;
677 : :
678 : : // in ndcopy.cxx
679 : : sal_Bool IsSymbol( const xub_StrLen nBegin ) const; // In itratr.cxx.
680 : : virtual SwCntntNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const;
681 : :
682 : : // Interactive hyphenation: we find TxtFrm and call its CalcHyph.
683 : : sal_Bool Hyphenate( SwInterHyphInfo &rHyphInf );
684 : : void DelSoftHyph( const xub_StrLen nStart, const xub_StrLen nEnd );
685 : :
686 : : // add 4th optional parameter <bAddSpaceAfterListLabelStr> indicating,
687 : : // when <bWithNum = true> that a space is inserted after the string for
688 : : // the list label.
689 : : // add 5th optional parameter <bWithSpacesForLevel> indicating, if additional
690 : : // spaces are inserted in front of the expanded text string depending on
691 : : // the list level.
692 : : XubString GetExpandTxt( const xub_StrLen nIdx = 0,
693 : : const xub_StrLen nLen = STRING_LEN,
694 : : const bool bWithNum = false,
695 : : const bool bAddSpaceAfterListLabelStr = false,
696 : : const bool bWithSpacesForLevel = false ) const;
697 : : sal_Bool GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx = 0,
698 : : xub_StrLen nIdx = 0, xub_StrLen nLen = STRING_LEN,
699 : : sal_Bool bWithNum = sal_False, sal_Bool bWithFtn = sal_True,
700 : : sal_Bool bReplaceTabsWithSpaces = sal_False ) const;
701 : :
702 : : XubString GetRedlineTxt( xub_StrLen nIdx = 0,
703 : : xub_StrLen nLen = STRING_LEN,
704 : : sal_Bool bExpandFlds = sal_False,
705 : : sal_Bool bWithNum = sal_False ) const;
706 : :
707 : : // Returns actual count of initial chars for initial-function.
708 : : // If nWishLen == 0 that of first word.
709 : : sal_uInt16 GetDropLen( sal_uInt16 nWishLen) const;
710 : :
711 : : // Passes back info needed on the dropcap dimensions
712 : : bool GetDropSize(int& rFontHeight, int& rDropHeight, int& rDropDescent) const;
713 : :
714 : : // Hidden Paragraph Field:
715 : 268 : inline bool CalcHiddenParaField()
716 [ + - ]: 268 : { return m_pSwpHints ? m_pSwpHints->CalcHiddenParaField() : false; }
717 : : // set CalcVisible flags
718 : 0 : inline void SetCalcHiddenParaField()
719 [ # # ]: 0 : { if (m_pSwpHints) m_pSwpHints->SetCalcHiddenParaField(); }
720 : :
721 : : // is the paragraph visible?
722 : 257241 : inline bool HasHiddenParaField() const
723 [ + + ]: 257241 : { return m_pSwpHints ? m_pSwpHints->HasHiddenParaField() : false; }
724 : :
725 : : //
726 : : // Hidden Paragraph Field:
727 : : //
728 : 278813 : inline bool HasHiddenCharAttribute( bool bWholePara ) const
729 : : {
730 [ + + ]: 278813 : if ( m_bRecalcHiddenCharFlags )
731 : 14021 : CalcHiddenCharFlags();
732 [ + + ]: 278813 : return bWholePara ? m_bHiddenCharsHidePara : m_bContainsHiddenChars;
733 : : }
734 : :
735 : 155869 : inline void SetCalcHiddenCharFlags() const
736 : 155869 : { m_bRecalcHiddenCharFlags = true; }
737 : :
738 : : //
739 : : // Returns if the node is hidden due to
740 : : // 1. HiddenParaField
741 : : // 2. HiddenCharAttribute
742 : : // 3. HiddenSection
743 : : //
744 : : bool IsHidden() const;
745 : :
746 : : TYPEINFO(); // fuer rtti
747 : :
748 : : // override SwIndexReg
749 : : virtual void Update( SwIndex const & rPos, const xub_StrLen nChangeLen,
750 : : const bool bNegative = false, const bool bDelete = false );
751 : :
752 : : // change text to Upper/Lower/Hiragana/Katagana/...
753 : : void TransliterateText( utl::TransliterationWrapper& rTrans,
754 : : xub_StrLen nStart, xub_StrLen nEnd,
755 : : SwUndoTransliterate* pUndo = 0 );
756 : :
757 : : // count words in given range
758 : : void CountWords( SwDocStat& rStat, xub_StrLen nStart, xub_StrLen nEnd ) const;
759 : :
760 : : // Checks some global conditions like loading or destruction of document
761 : : // to economize notifications
762 : : bool IsNotificationEnabled() const;
763 : :
764 : : // Checks a temporary notification blocker and the global conditons of IsNotificationEnabled()
765 : : bool IsNotifiable() const;
766 : :
767 : : void SetListRestart( bool bRestart );
768 : : bool IsListRestart() const;
769 : :
770 : : void SetAttrListRestartValue( SwNumberTree::tSwNumTreeNumber nNum );
771 : : bool HasAttrListRestartValue() const;
772 : : SwNumberTree::tSwNumTreeNumber GetAttrListRestartValue() const;
773 : : SwNumberTree::tSwNumTreeNumber GetActualListStartValue() const;
774 : :
775 : : void SetCountedInList( bool bCounted );
776 : : bool IsCountedInList() const;
777 : :
778 : : void AddToList();
779 : : void RemoveFromList();
780 : : bool IsInList() const;
781 : :
782 : : bool IsFirstOfNumRule() const;
783 : :
784 : : sal_uInt16 GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) const;
785 : :
786 : : SW_DLLPRIVATE ::com::sun::star::uno::WeakReference<
787 : 4191 : ::com::sun::star::text::XTextContent> const& GetXParagraph() const
788 : 4191 : { return m_wXParagraph; }
789 : 3478 : SW_DLLPRIVATE void SetXParagraph(::com::sun::star::uno::Reference<
790 : : ::com::sun::star::text::XTextContent> const& xParagraph)
791 : 3478 : { m_wXParagraph = xParagraph; }
792 : :
793 : : // sfx2::Metadatable
794 : : virtual ::sfx2::IXmlIdRegistry& GetRegistry();
795 : : virtual bool IsInClipboard() const;
796 : : virtual bool IsInUndo() const;
797 : : virtual bool IsInContent() const;
798 : : virtual ::com::sun::star::uno::Reference<
799 : : ::com::sun::star::rdf::XMetadatable > MakeUnoObject();
800 : :
801 : : bool IsCollapse() const;
802 : :
803 : : virtual void dumpAsXml( xmlTextWriterPtr writer = NULL );
804 : :
805 : : sal_uInt32 GetRsid( xub_StrLen nStt, xub_StrLen nEnd ) const;
806 : : sal_uInt32 GetParRsid() const;
807 : :
808 : : bool CompareRsid( const SwTxtNode &rTxtNode, xub_StrLen nStt1, xub_StrLen nStt2,
809 : : xub_StrLen nEnd1 = 0, xub_StrLen nEnd2 = 0 ) const;
810 : : bool CompareParRsid( const SwTxtNode &rTxtNode ) const;
811 : :
812 [ + - ][ + - ]: 29429 : DECL_FIXEDMEMPOOL_NEWDEL(SwTxtNode)
813 : : };
814 : :
815 : : //-----------------------------------------------------------------------------
816 : :
817 : 734 : inline SwpHints & SwTxtNode::GetSwpHints()
818 : : {
819 : : OSL_ASSERT( m_pSwpHints );
820 : 734 : return *m_pSwpHints;
821 : : }
822 : 1822 : inline const SwpHints &SwTxtNode::GetSwpHints() const
823 : : {
824 : : OSL_ASSERT( m_pSwpHints );
825 : 1822 : return *m_pSwpHints;
826 : : }
827 : :
828 : 38797 : inline SwpHints& SwTxtNode::GetOrCreateSwpHints()
829 : : {
830 [ + + ]: 38797 : if ( !m_pSwpHints )
831 : : {
832 [ + - ]: 6621 : m_pSwpHints = new SwpHints;
833 : : }
834 : 38797 : return *m_pSwpHints;
835 : : }
836 : :
837 : 29439 : inline void SwTxtNode::TryDeleteSwpHints()
838 : : {
839 [ + + ][ + + ]: 29439 : if ( m_pSwpHints && m_pSwpHints->CanBeDeleted() )
[ + + ]
840 : : {
841 [ + - ]: 3577 : DELETEZ( m_pSwpHints );
842 : : }
843 : 29439 : }
844 : :
845 : 56276 : inline SwTxtFmtColl* SwTxtNode::GetTxtColl() const
846 : : {
847 : 56276 : return static_cast<SwTxtFmtColl*>(const_cast<SwModify*>(GetRegisteredIn()));
848 : : }
849 : :
850 : : // Inline methods from Node.hxx
851 : 685398 : inline SwTxtNode *SwNode::GetTxtNode()
852 : : {
853 [ + + ]: 685398 : return ND_TEXTNODE == nNodeType ? static_cast<SwTxtNode*>(this) : 0;
854 : : }
855 : :
856 : 332073 : inline const SwTxtNode *SwNode::GetTxtNode() const
857 : : {
858 [ + - ]: 332073 : return ND_TEXTNODE == nNodeType ? static_cast<const SwTxtNode*>(this) : 0;
859 : : }
860 : :
861 : : inline void
862 : 71 : SwTxtNode::CutText(SwTxtNode * const pDest, const SwIndex & rDestStart,
863 : : const SwIndex & rStart, const xub_StrLen nLen)
864 : : {
865 : 71 : CutImpl( pDest, rDestStart, rStart, nLen, true );
866 : 71 : }
867 : :
868 : : #endif
869 : :
870 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|