nss: upgrade to release 3.73
[LibreOffice.git] / editeng / inc / editdoc.hxx
blobff2681e3ca5ec710fed1fe9c338374954daa04b5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
22 #include "editattr.hxx"
23 #include "edtspell.hxx"
24 #include "eerdll2.hxx"
25 #include <editeng/svxfont.hxx>
26 #include <svl/itemset.hxx>
27 #include <svl/style.hxx>
28 #include <svl/itempool.hxx>
29 #include <svl/languageoptions.hxx>
30 #include <tools/lineend.hxx>
31 #include <o3tl/typed_flags_set.hxx>
33 #include <memory>
34 #include <vector>
36 class ImpEditEngine;
37 class SvxTabStop;
38 enum class TextRotation;
41 #define CHARPOSGROW 16
42 #define DEFTAB 720
44 void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent = true, SvtScriptType nScriptType = SvtScriptType::NONE );
45 sal_uInt16 GetScriptItemId( sal_uInt16 nItemId, SvtScriptType nScriptType );
46 bool IsScriptItemValid( sal_uInt16 nItemId, short nScriptType );
48 EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_Int32 nS, sal_Int32 nE );
50 class ContentNode;
51 class EditDoc;
53 struct EPaM
55 sal_Int32 nPara;
56 sal_Int32 nIndex;
58 EPaM() : nPara(0), nIndex(0) {}
59 EPaM( sal_Int32 nP, sal_Int32 nI ) : nPara(nP), nIndex(nI) {}
60 EPaM( const EPaM& r) : nPara(r.nPara), nIndex(r.nIndex) {}
61 EPaM& operator = ( const EPaM& r ) { nPara = r.nPara; nIndex = r.nIndex; return *this; }
62 inline bool operator == ( const EPaM& r ) const;
63 inline bool operator < ( const EPaM& r ) const;
66 inline bool EPaM::operator < ( const EPaM& r ) const
68 return ( nPara < r.nPara ) || ( ( nPara == r.nPara ) && nIndex < r.nIndex );
71 inline bool EPaM::operator == ( const EPaM& r ) const
73 return ( nPara == r.nPara ) && ( nIndex == r.nIndex );
76 struct ScriptTypePosInfo
78 short nScriptType;
79 sal_Int32 nStartPos;
80 sal_Int32 nEndPos;
82 ScriptTypePosInfo( short Type, sal_Int32 Start, sal_Int32 End )
83 : nScriptType(Type)
84 , nStartPos(Start)
85 , nEndPos(End)
90 typedef std::vector<ScriptTypePosInfo> ScriptTypePosInfos;
92 struct WritingDirectionInfo
94 sal_uInt8 nType;
95 sal_Int32 nStartPos;
96 sal_Int32 nEndPos;
98 WritingDirectionInfo( sal_uInt8 Type, sal_Int32 Start, sal_Int32 End )
99 : nType(Type)
100 , nStartPos(Start)
101 , nEndPos(End)
107 typedef std::vector<WritingDirectionInfo> WritingDirectionInfos;
109 class ContentAttribsInfo
111 private:
112 typedef std::vector<std::unique_ptr<EditCharAttrib> > CharAttribsType;
114 SfxItemSet aPrevParaAttribs;
115 CharAttribsType aPrevCharAttribs;
117 public:
118 ContentAttribsInfo( const SfxItemSet& rParaAttribs );
120 const SfxItemSet& GetPrevParaAttribs() const { return aPrevParaAttribs; }
121 const CharAttribsType& GetPrevCharAttribs() const { return aPrevCharAttribs; }
123 void RemoveAllCharAttribsFromPool(SfxItemPool& rPool) const;
124 void AppendCharAttrib(EditCharAttrib* pNew);
129 typedef std::vector<Color> SvxColorList;
134 class ItemList
136 private:
137 typedef std::vector<const SfxPoolItem*> DummyItemList;
138 DummyItemList aItemPool;
139 sal_Int32 CurrentItem;
141 public:
142 ItemList();
143 const SfxPoolItem* First();
144 const SfxPoolItem* Next();
145 sal_Int32 Count() { return aItemPool.size(); };
146 void Insert( const SfxPoolItem* pItem );
147 void Clear() { aItemPool.clear(); };
152 class ContentAttribs
154 private:
155 SfxStyleSheet* pStyle;
156 SfxItemSet aAttribSet;
158 public:
159 ContentAttribs( SfxItemPool& rItemPool );
161 void dumpAsXml(xmlTextWriterPtr pWriter) const;
163 SvxTabStop FindTabStop( sal_Int32 nCurPos, sal_uInt16 nDefTab );
164 SfxItemSet& GetItems() { return aAttribSet; }
165 const SfxItemSet& GetItems() const { return aAttribSet; }
166 const SfxStyleSheet* GetStyleSheet() const { return pStyle; }
167 SfxStyleSheet* GetStyleSheet() { return pStyle; }
168 void SetStyleSheet( SfxStyleSheet* pS );
170 const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const;
171 template<class T>
172 const T& GetItem( TypedWhichId<T> nWhich ) const
174 return static_cast<const T&>(GetItem(sal_uInt16(nWhich)));
176 bool HasItem( sal_uInt16 nWhich ) const;
181 class CharAttribList
183 public:
184 typedef std::vector<std::unique_ptr<EditCharAttrib> > AttribsType;
186 private:
187 AttribsType aAttribs;
188 SvxFont aDefFont; // faster than ever from the pool!
189 bool bHasEmptyAttribs;
191 public:
192 CharAttribList();
193 ~CharAttribList();
195 void dumpAsXml(xmlTextWriterPtr pWriter) const;
197 void DeleteEmptyAttribs( SfxItemPool& rItemPool );
199 const EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos ) const;
200 EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos );
201 const EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_Int32 nFromPos ) const;
202 EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_Int32 nPos );
203 const EditCharAttrib* FindFeature( sal_Int32 nPos ) const;
206 void ResortAttribs();
207 void OptimizeRanges( SfxItemPool& rItemPool );
209 sal_Int32 Count() const;
211 void InsertAttrib( EditCharAttrib* pAttrib );
213 SvxFont& GetDefFont() { return aDefFont; }
215 bool HasEmptyAttribs() const { return bHasEmptyAttribs; }
216 void SetHasEmptyAttribs(bool b);
217 bool HasBoundingAttrib( sal_Int32 nBound ) const;
218 bool HasAttrib( sal_Int32 nStartPos, sal_Int32 nEndPos ) const;
220 AttribsType& GetAttribs() { return aAttribs;}
221 const AttribsType& GetAttribs() const { return aAttribs;}
223 void Remove(const EditCharAttrib* p);
224 void Remove(sal_Int32 nPos);
226 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
227 static void DbgCheckAttribs(CharAttribList const& rAttribs);
228 #endif
233 class ContentNode
235 private:
236 OUString maString;
237 ContentAttribs aContentAttribs;
238 CharAttribList aCharAttribList;
239 std::unique_ptr<WrongList> mpWrongList;
241 void UnExpandPosition( sal_Int32 &rStartPos, bool bBiasStart );
243 public:
244 ContentNode( SfxItemPool& rItemPool );
245 ContentNode( const OUString& rStr, const ContentAttribs& rContentAttribs );
246 ~ContentNode();
247 ContentNode(const ContentNode&) = delete;
248 ContentNode& operator=(const ContentNode&) = delete;
250 void dumpAsXml(xmlTextWriterPtr pWriter) const;
252 ContentAttribs& GetContentAttribs() { return aContentAttribs; }
253 const ContentAttribs& GetContentAttribs() const { return aContentAttribs; }
254 CharAttribList& GetCharAttribs() { return aCharAttribList; }
255 const CharAttribList& GetCharAttribs() const { return aCharAttribList; }
257 void ExpandAttribs( sal_Int32 nIndex, sal_Int32 nNewChars, SfxItemPool& rItemPool );
258 void CollapseAttribs( sal_Int32 nIndex, sal_Int32 nDelChars, SfxItemPool& rItemPool );
259 void AppendAttribs( ContentNode* pNextNode );
260 void CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, bool bKeepEndingAttribs );
262 void SetStyleSheet( SfxStyleSheet* pS, bool bRecalcFont = true );
263 void SetStyleSheet( SfxStyleSheet* pS, const SvxFont& rFontFromStyle );
264 SfxStyleSheet* GetStyleSheet() { return aContentAttribs.GetStyleSheet(); }
266 void CreateDefFont();
268 void EnsureWrongList();
269 WrongList* GetWrongList();
270 const WrongList* GetWrongList() const;
271 void SetWrongList( WrongList* p );
273 void CreateWrongList();
274 void DestroyWrongList();
276 bool IsFeature( sal_Int32 nPos ) const;
278 sal_Int32 Len() const;
279 const OUString& GetString() const { return maString;}
281 /// return length including expanded fields
282 sal_uLong GetExpandedLen() const;
283 /// return content including expanded fields
284 OUString GetExpandedText(sal_Int32 nStartPos = 0, sal_Int32 nEndPos = -1) const;
285 /// re-write offsets in the expanded text to string offsets
286 void UnExpandPositions( sal_Int32 &rStartPos, sal_Int32 &rEndPos );
288 void SetChar(sal_Int32 nPos, sal_Unicode c);
289 void Insert(const OUString& rStr, sal_Int32 nPos);
290 void Append(const OUString& rStr);
291 void Erase(sal_Int32 nPos);
292 void Erase(sal_Int32 nPos, sal_Int32 nCount);
293 OUString Copy(sal_Int32 nPos) const;
294 OUString Copy(sal_Int32 nPos, sal_Int32 nCount) const;
295 sal_Unicode GetChar(sal_Int32 nPos) const;
300 class EditPaM
302 private:
303 ContentNode* pNode;
304 sal_Int32 nIndex;
306 public:
307 EditPaM();
308 EditPaM(ContentNode* p, sal_Int32 n);
310 const ContentNode* GetNode() const { return pNode;}
311 ContentNode* GetNode() { return pNode;}
312 void SetNode(ContentNode* p);
314 sal_Int32 GetIndex() const { return nIndex; }
315 void SetIndex( sal_Int32 n ) { nIndex = n; }
317 bool DbgIsBuggy( EditDoc const & rDoc ) const;
319 friend bool operator == ( const EditPaM& r1, const EditPaM& r2 );
320 friend bool operator != ( const EditPaM& r1, const EditPaM& r2 );
321 bool operator !() const { return !pNode && !nIndex; }
324 enum class PortionKind
326 TEXT = 0,
327 TAB = 1,
328 LINEBREAK = 2,
329 FIELD = 3,
330 HYPHENATOR = 4
333 enum class DeleteMode {
334 Simple, RestOfWord, RestOfContent
337 enum class AsianCompressionFlags {
338 Normal = 0x00,
339 Kana = 0x01,
340 PunctuationLeft = 0x02,
341 PunctuationRight = 0x04,
343 namespace o3tl {
344 template<> struct typed_flags<AsianCompressionFlags> : is_typed_flags<AsianCompressionFlags, 0x07> {};
349 // struct ExtraPortionInfos
351 struct ExtraPortionInfo
353 tools::Long nOrgWidth;
354 tools::Long nWidthFullCompression;
356 tools::Long nPortionOffsetX;
358 sal_uInt16 nMaxCompression100thPercent;
360 AsianCompressionFlags nAsianCompressionTypes;
361 bool bFirstCharIsRightPunktuation;
362 bool bCompressed;
364 std::unique_ptr<tools::Long[]> pOrgDXArray;
365 std::vector< sal_Int32 > lineBreaksList;
368 ExtraPortionInfo();
369 ~ExtraPortionInfo();
371 void SaveOrgDXArray( const tools::Long* pDXArray, sal_Int32 nLen );
376 class TextPortion
378 private:
379 std::unique_ptr<ExtraPortionInfo> xExtraInfos;
380 sal_Int32 nLen;
381 Size aOutSz;
382 PortionKind nKind;
383 sal_uInt8 nRightToLeftLevel;
384 sal_Unicode nExtraValue;
387 public:
388 TextPortion( sal_Int32 nL )
389 : nLen( nL )
390 , aOutSz( -1, -1 )
391 , nKind( PortionKind::TEXT )
392 , nRightToLeftLevel( 0 )
393 , nExtraValue( 0 )
397 TextPortion( const TextPortion& r )
398 : nLen( r.nLen )
399 , aOutSz( r.aOutSz )
400 , nKind( r.nKind )
401 , nRightToLeftLevel( r.nRightToLeftLevel )
402 , nExtraValue( r.nExtraValue )
407 sal_Int32 GetLen() const { return nLen; }
408 void SetLen( sal_Int32 nL ) { nLen = nL; }
410 Size& GetSize() { return aOutSz; }
411 const Size& GetSize() const { return aOutSz; }
413 void SetKind(PortionKind n) { nKind = n; }
414 PortionKind GetKind() const { return nKind; }
416 void SetRightToLeftLevel( sal_uInt8 n ) { nRightToLeftLevel = n; }
417 sal_uInt8 GetRightToLeftLevel() const { return nRightToLeftLevel; }
418 bool IsRightToLeft() const { return (nRightToLeftLevel&1); }
420 sal_Unicode GetExtraValue() const { return nExtraValue; }
421 void SetExtraValue( sal_Unicode n ) { nExtraValue = n; }
423 ExtraPortionInfo* GetExtraInfos() const { return xExtraInfos.get(); }
424 void SetExtraInfos( ExtraPortionInfo* p ) { xExtraInfos.reset(p); }
429 class TextPortionList
431 typedef std::vector<std::unique_ptr<TextPortion> > PortionsType;
432 PortionsType maPortions;
434 public:
435 TextPortionList();
436 ~TextPortionList();
438 void Reset();
439 sal_Int32 FindPortion(
440 sal_Int32 nCharPos, sal_Int32& rPortionStart, bool bPreferStartingPortion = false) const;
441 sal_Int32 GetStartPos(sal_Int32 nPortion);
442 void DeleteFromPortion(sal_Int32 nDelFrom);
443 sal_Int32 Count() const;
444 const TextPortion& operator[](sal_Int32 nPos) const;
445 TextPortion& operator[](sal_Int32 nPos);
447 void Append(TextPortion* p);
448 void Insert(sal_Int32 nPos, TextPortion* p);
449 void Remove(sal_Int32 nPos);
450 sal_Int32 GetPos(const TextPortion* p) const;
453 class ParaPortion;
457 class EditLine
459 public:
460 typedef std::vector<tools::Long> CharPosArrayType;
462 private:
463 CharPosArrayType aPositions;
464 tools::Long nTxtWidth;
465 tools::Long nStartPosX;
466 sal_Int32 nStart; // could be replaced by nStartPortion
467 sal_Int32 nEnd; // could be replaced by nEndPortion
468 sal_Int32 nStartPortion;
469 sal_Int32 nEndPortion;
470 sal_uInt16 nHeight; // Total height of the line
471 sal_uInt16 nTxtHeight; // Pure Text height
472 sal_uInt16 nMaxAscent;
473 bool bHangingPunctuation:1;
474 bool bInvalid:1; // for skillful formatting
476 public:
477 EditLine();
478 EditLine( const EditLine& );
479 ~EditLine();
481 bool IsIn( sal_Int32 nIndex ) const
482 { return ( (nIndex >= nStart ) && ( nIndex < nEnd ) ); }
484 bool IsIn( sal_Int32 nIndex, bool bInclEnd ) const
485 { return ( ( nIndex >= nStart ) && ( bInclEnd ? ( nIndex <= nEnd ) : ( nIndex < nEnd ) ) ); }
487 void SetStart( sal_Int32 n ) { nStart = n; }
488 sal_Int32 GetStart() const { return nStart; }
489 sal_Int32& GetStart() { return nStart; }
491 void SetEnd( sal_Int32 n ) { nEnd = n; }
492 sal_Int32 GetEnd() const { return nEnd; }
493 sal_Int32& GetEnd() { return nEnd; }
495 void SetStartPortion( sal_Int32 n ) { nStartPortion = n; }
496 sal_Int32 GetStartPortion() const { return nStartPortion; }
497 sal_Int32& GetStartPortion() { return nStartPortion; }
499 void SetEndPortion( sal_Int32 n ) { nEndPortion = n; }
500 sal_Int32 GetEndPortion() const { return nEndPortion; }
501 sal_Int32& GetEndPortion() { return nEndPortion; }
503 void SetHeight( sal_uInt16 nH, sal_uInt16 nTxtH = 0 );
504 sal_uInt16 GetHeight() const { return nHeight; }
505 sal_uInt16 GetTxtHeight() const { return nTxtHeight; }
507 void SetTextWidth( tools::Long n ) { nTxtWidth = n; }
508 tools::Long GetTextWidth() const { return nTxtWidth; }
510 void SetMaxAscent( sal_uInt16 n ) { nMaxAscent = n; }
511 sal_uInt16 GetMaxAscent() const { return nMaxAscent; }
513 void SetHangingPunctuation( bool b ) { bHangingPunctuation = b; }
514 bool IsHangingPunctuation() const { return bHangingPunctuation; }
516 sal_Int32 GetLen() const { return nEnd - nStart; }
518 tools::Long GetStartPosX() const { return nStartPosX; }
519 void SetStartPosX( tools::Long start );
520 Size CalcTextSize( ParaPortion& rParaPortion );
522 bool IsInvalid() const { return bInvalid; }
523 bool IsValid() const { return !bInvalid; }
524 void SetInvalid() { bInvalid = true; }
525 void SetValid() { bInvalid = false; }
527 bool IsEmpty() const { return nEnd <= nStart; }
529 CharPosArrayType& GetCharPosArray() { return aPositions;}
530 const CharPosArrayType& GetCharPosArray() const { return aPositions;}
532 EditLine* Clone() const;
534 EditLine& operator = ( const EditLine& rLine );
535 friend bool operator == ( const EditLine& r1, const EditLine& r2 );
540 class EditLineList
542 typedef std::vector<std::unique_ptr<EditLine> > LinesType;
543 LinesType maLines;
545 public:
546 EditLineList();
547 ~EditLineList();
549 void Reset();
550 void DeleteFromLine(sal_Int32 nDelFrom);
551 sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd);
552 sal_Int32 Count() const;
553 const EditLine& operator[](sal_Int32 nPos) const;
554 EditLine& operator[](sal_Int32 nPos);
556 void Append(EditLine* p);
557 void Insert(sal_Int32 nPos, EditLine* p);
562 class ParaPortion
564 friend class ImpEditEngine; // to adjust the height
565 private:
566 EditLineList aLineList;
567 TextPortionList aTextPortionList;
568 ContentNode* pNode;
569 tools::Long nHeight;
571 ScriptTypePosInfos aScriptInfos;
572 WritingDirectionInfos aWritingDirectionInfos;
574 sal_Int32 nInvalidPosStart;
575 sal_Int32 nFirstLineOffset; // For Writer-LineSpacing-Interpretation
576 sal_Int32 nBulletX;
577 sal_Int32 nInvalidDiff;
579 bool bInvalid : 1;
580 bool bSimple : 1; // only linear Tap
581 bool bVisible : 1; // Belongs to the node!
582 bool bForceRepaint : 1;
584 ParaPortion( const ParaPortion& ) = delete;
586 public:
587 ParaPortion( ContentNode* pNode );
588 ~ParaPortion();
590 sal_Int32 GetLineNumber( sal_Int32 nIndex ) const;
592 EditLineList& GetLines() { return aLineList; }
593 const EditLineList& GetLines() const { return aLineList; }
595 bool IsInvalid() const { return bInvalid; }
596 bool IsSimpleInvalid() const { return bSimple; }
597 void SetValid() { bInvalid = false; bSimple = true;}
599 bool MustRepaint() const { return bForceRepaint; }
600 void SetMustRepaint( bool bRP ) { bForceRepaint = bRP; }
602 sal_Int32 GetBulletX() const { return nBulletX; }
603 void SetBulletX( sal_Int32 n ) { nBulletX = n; }
605 void MarkInvalid( sal_Int32 nStart, sal_Int32 nDiff);
606 void MarkSelectionInvalid( sal_Int32 nStart );
608 void SetVisible( bool bVisible );
609 bool IsVisible() const { return bVisible; }
611 bool IsEmpty() { return GetTextPortions().Count() == 1 && GetTextPortions()[0].GetLen() == 0; }
613 tools::Long GetHeight() const { return ( bVisible ? nHeight : 0 ); }
614 sal_Int32 GetFirstLineOffset() const { return ( bVisible ? nFirstLineOffset : 0 ); }
615 void ResetHeight() { nHeight = 0; nFirstLineOffset = 0; }
617 ContentNode* GetNode() const { return pNode; }
618 TextPortionList& GetTextPortions() { return aTextPortionList; }
619 const TextPortionList& GetTextPortions() const { return aTextPortionList; }
621 sal_Int32 GetInvalidPosStart() const { return nInvalidPosStart; }
622 short GetInvalidDiff() const { return nInvalidDiff; }
624 void CorrectValuesBehindLastFormattedLine( sal_Int32 nLastFormattedLine );
625 #if OSL_DEBUG_LEVEL > 0
626 static bool DbgCheckTextPortions(ParaPortion const&);
627 #endif
632 class ParaPortionList
634 mutable sal_Int32 nLastCache;
635 std::vector<std::unique_ptr<ParaPortion>> maPortions;
636 public:
637 ParaPortionList();
638 ~ParaPortionList();
640 void Reset();
641 tools::Long GetYOffset(const ParaPortion* pPPortion) const;
642 sal_Int32 FindParagraph(tools::Long nYOffset) const;
644 const ParaPortion* SafeGetObject(sal_Int32 nPos) const;
645 ParaPortion* SafeGetObject(sal_Int32 nPos);
647 sal_Int32 GetPos(const ParaPortion* p) const;
648 ParaPortion* operator[](sal_Int32 nPos);
649 const ParaPortion* operator[](sal_Int32 nPos) const;
651 std::unique_ptr<ParaPortion> Release(sal_Int32 nPos);
652 void Remove(sal_Int32 nPos);
653 void Insert(sal_Int32 nPos, std::unique_ptr<ParaPortion> p);
654 void Append(std::unique_ptr<ParaPortion> p);
655 sal_Int32 Count() const;
657 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
658 // temporary:
659 static void DbgCheck(ParaPortionList const&, EditDoc const& rDoc);
660 #endif
665 class EditSelection
667 private:
668 EditPaM aStartPaM;
669 EditPaM aEndPaM;
671 public:
672 EditSelection(); // No constructor and destructor
673 // are automatically executed correctly!
674 EditSelection( const EditPaM& rStartAndAnd );
675 EditSelection( const EditPaM& rStart, const EditPaM& rEnd );
677 EditPaM& Min() { return aStartPaM; }
678 EditPaM& Max() { return aEndPaM; }
680 const EditPaM& Min() const { return aStartPaM; }
681 const EditPaM& Max() const { return aEndPaM; }
683 bool HasRange() const { return aStartPaM != aEndPaM; }
684 bool IsInvalid() const { return !aStartPaM || !aEndPaM; }
685 bool DbgIsBuggy( EditDoc const & rDoc ) const;
687 void Adjust( const EditDoc& rNodes );
689 EditSelection& operator = ( const EditPaM& r );
690 bool operator == ( const EditSelection& r ) const
691 { return ( aStartPaM == r.aStartPaM ) && ( aEndPaM == r.aEndPaM ); }
692 bool operator != ( const EditSelection& r ) const { return !( r == *this ); }
697 class DeletedNodeInfo
699 private:
700 ContentNode* mpInvalidNode;
701 sal_Int32 nInvalidParagraph;
703 public:
704 DeletedNodeInfo( ContentNode* pNode, sal_Int32 nPos )
705 : mpInvalidNode(pNode)
706 , nInvalidParagraph(nPos)
710 ContentNode* GetNode() const { return mpInvalidNode; }
711 sal_Int32 GetPosition() const { return nInvalidParagraph; }
716 class EditDoc
718 private:
719 mutable sal_Int32 nLastCache;
720 std::vector<std::unique_ptr<ContentNode> > maContents;
722 SfxItemPool* pItemPool;
723 Link<LinkParamNone*,void> aModifyHdl;
725 SvxFont aDefFont; //faster than ever from the pool!!
726 sal_uInt16 nDefTab;
727 bool bIsVertical:1;
728 TextRotation mnRotation;
729 bool bIsFixedCellHeight:1;
731 bool bOwnerOfPool:1;
732 bool bModified:1;
733 bool bDisableAttributeExpanding:1;
735 private:
736 void ImplDestroyContents();
738 public:
739 EditDoc( SfxItemPool* pItemPool );
740 ~EditDoc();
742 void dumpAsXml(xmlTextWriterPtr pWriter) const;
743 void ClearSpellErrors();
745 bool IsModified() const { return bModified; }
746 void SetModified( bool b );
748 void DisableAttributeExpanding() { bDisableAttributeExpanding = true; }
750 void SetModifyHdl( const Link<LinkParamNone*,void>& rLink ) { aModifyHdl = rLink; }
752 void CreateDefFont( bool bUseStyles );
753 const SvxFont& GetDefFont() const { return aDefFont; }
755 void SetDefTab( sal_uInt16 nTab ) { nDefTab = nTab ? nTab : DEFTAB; }
756 sal_uInt16 GetDefTab() const { return nDefTab; }
758 void SetVertical( bool bVertical ) { bIsVertical = bVertical; }
759 bool IsVertical() const;
760 bool IsTopToBottom() const;
761 bool GetDirectVertical() const;
762 void SetRotation( TextRotation nRotation ) { mnRotation = nRotation; }
763 TextRotation GetRotation() const { return mnRotation; }
765 void SetFixedCellHeight( bool bUseFixedCellHeight ) { bIsFixedCellHeight = bUseFixedCellHeight; }
766 bool IsFixedCellHeight() const { return bIsFixedCellHeight; }
768 EditPaM Clear();
769 EditPaM RemoveText();
770 void RemoveChars( EditPaM aPaM, sal_Int32 nChars );
771 EditPaM InsertText( EditPaM aPaM, const OUString& rStr );
772 EditPaM InsertParaBreak( EditPaM aPaM, bool bKeepEndingAttribs );
773 EditPaM InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem );
774 EditPaM ConnectParagraphs( ContentNode* pLeft, ContentNode* pRight );
776 OUString GetText( LineEnd eEnd ) const;
777 sal_uLong GetTextLen() const;
779 OUString GetParaAsString( sal_Int32 nNode ) const;
780 static OUString GetParaAsString(const ContentNode* pNode, sal_Int32 nStartPos = 0, sal_Int32 nEndPos = -1);
782 EditPaM GetStartPaM() const;
783 EditPaM GetEndPaM() const;
785 SfxItemPool& GetItemPool() { return *pItemPool; }
786 const SfxItemPool& GetItemPool() const { return *pItemPool; }
788 void RemoveItemsFromPool(const ContentNode& rNode);
790 void InsertAttrib( const SfxPoolItem& rItem, ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd );
791 void InsertAttrib( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, const SfxPoolItem& rPoolItem );
792 void InsertAttribInSelection( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, const SfxPoolItem& rPoolItem );
793 bool RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, sal_uInt16 nWhich );
794 bool RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, sal_uInt16 nWhich );
795 static void FindAttribs( ContentNode* pNode, sal_Int32 nStartPos, sal_Int32 nEndPos, SfxItemSet& rCurSet );
797 sal_Int32 GetPos(const ContentNode* pNode) const;
798 const ContentNode* GetObject(sal_Int32 nPos) const;
799 ContentNode* GetObject(sal_Int32 nPos);
800 sal_Int32 Count() const;
801 const ContentNode* operator[](sal_Int32 nPos) const;
802 ContentNode* operator[](sal_Int32 nPos);
803 void Insert(sal_Int32 nPos, ContentNode* p);
804 /// deletes
805 void Remove(sal_Int32 nPos);
806 /// does not delete
807 void Release(sal_Int32 nPos);
809 static OUString GetSepStr( LineEnd eEnd );
812 inline EditCharAttrib* GetAttrib(CharAttribList::AttribsType& rAttribs, sal_Int32 nAttr)
814 return (nAttr < static_cast<sal_Int32>(rAttribs.size())) ? rAttribs[nAttr].get() : nullptr;
817 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
818 void CheckOrderedList(const CharAttribList::AttribsType& rAttribs);
819 #endif
821 class EditEngineItemPool final : public SfxItemPool
823 private:
824 std::shared_ptr<DefItems> m_xDefItems;
825 public:
826 EditEngineItemPool();
827 private:
828 virtual ~EditEngineItemPool() override;
831 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */