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 .
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>
35 #include <string_view>
40 enum class TextRotation
;
43 #define CHARPOSGROW 16
46 void CreateFont( SvxFont
& rFont
, const SfxItemSet
& rSet
, bool bSearchInParent
= true, SvtScriptType nScriptType
= SvtScriptType::NONE
);
47 sal_uInt16
GetScriptItemId( sal_uInt16 nItemId
, SvtScriptType nScriptType
);
48 bool IsScriptItemValid( sal_uInt16 nItemId
, short nScriptType
);
50 EditCharAttrib
* MakeCharAttrib( SfxItemPool
& rPool
, const SfxPoolItem
& rAttr
, sal_Int32 nS
, sal_Int32 nE
);
60 EPaM() : nPara(0), nIndex(0) {}
61 EPaM( sal_Int32 nP
, sal_Int32 nI
) : nPara(nP
), nIndex(nI
) {}
62 EPaM( const EPaM
& r
) : nPara(r
.nPara
), nIndex(r
.nIndex
) {}
63 EPaM
& operator = ( const EPaM
& r
) { nPara
= r
.nPara
; nIndex
= r
.nIndex
; return *this; }
64 inline bool operator == ( const EPaM
& r
) const;
65 inline bool operator < ( const EPaM
& r
) const;
68 inline bool EPaM::operator < ( const EPaM
& r
) const
70 return ( nPara
< r
.nPara
) || ( ( nPara
== r
.nPara
) && nIndex
< r
.nIndex
);
73 inline bool EPaM::operator == ( const EPaM
& r
) const
75 return ( nPara
== r
.nPara
) && ( nIndex
== r
.nIndex
);
78 struct ScriptTypePosInfo
84 ScriptTypePosInfo( short Type
, sal_Int32 Start
, sal_Int32 End
)
92 typedef std::vector
<ScriptTypePosInfo
> ScriptTypePosInfos
;
94 struct WritingDirectionInfo
100 WritingDirectionInfo( sal_uInt8 Type
, sal_Int32 Start
, sal_Int32 End
)
109 typedef std::vector
<WritingDirectionInfo
> WritingDirectionInfos
;
111 class ContentAttribsInfo
114 typedef std::vector
<std::unique_ptr
<EditCharAttrib
> > CharAttribsType
;
116 SfxItemSet aPrevParaAttribs
;
117 CharAttribsType aPrevCharAttribs
;
120 ContentAttribsInfo( SfxItemSet aParaAttribs
);
122 const SfxItemSet
& GetPrevParaAttribs() const { return aPrevParaAttribs
; }
123 const CharAttribsType
& GetPrevCharAttribs() const { return aPrevCharAttribs
; }
125 void RemoveAllCharAttribsFromPool(SfxItemPool
& rPool
) const;
126 void AppendCharAttrib(EditCharAttrib
* pNew
);
131 typedef std::vector
<Color
> SvxColorList
;
139 typedef std::vector
<const SfxPoolItem
*> DummyItemList
;
140 DummyItemList aItemPool
;
141 sal_Int32 CurrentItem
;
145 const SfxPoolItem
* First();
146 const SfxPoolItem
* Next();
147 sal_Int32
Count() const { return aItemPool
.size(); };
148 void Insert( const SfxPoolItem
* pItem
);
149 void Clear() { aItemPool
.clear(); };
157 SfxStyleSheet
* pStyle
;
158 SfxItemSetFixed
<EE_PARA_START
, EE_CHAR_END
> aAttribSet
;
161 ContentAttribs( SfxItemPool
& rItemPool
);
163 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
165 SvxTabStop
FindTabStop( sal_Int32 nCurPos
, sal_uInt16 nDefTab
);
166 SfxItemSet
& GetItems() { return aAttribSet
; }
167 const SfxItemSet
& GetItems() const { return aAttribSet
; }
168 const SfxStyleSheet
* GetStyleSheet() const { return pStyle
; }
169 SfxStyleSheet
* GetStyleSheet() { return pStyle
; }
170 void SetStyleSheet( SfxStyleSheet
* pS
);
172 const SfxPoolItem
& GetItem( sal_uInt16 nWhich
) const;
174 const T
& GetItem( TypedWhichId
<T
> nWhich
) const
176 return static_cast<const T
&>(GetItem(sal_uInt16(nWhich
)));
178 bool HasItem( sal_uInt16 nWhich
) const;
186 typedef std::vector
<std::unique_ptr
<EditCharAttrib
> > AttribsType
;
189 AttribsType aAttribs
;
190 SvxFont aDefFont
; // faster than ever from the pool!
191 bool bHasEmptyAttribs
;
197 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
199 void DeleteEmptyAttribs( SfxItemPool
& rItemPool
);
201 const EditCharAttrib
* FindAttrib( sal_uInt16 nWhich
, sal_Int32 nPos
) const;
202 EditCharAttrib
* FindAttrib( sal_uInt16 nWhich
, sal_Int32 nPos
);
203 const EditCharAttrib
* FindNextAttrib( sal_uInt16 nWhich
, sal_Int32 nFromPos
) const;
204 EditCharAttrib
* FindEmptyAttrib( sal_uInt16 nWhich
, sal_Int32 nPos
);
205 const EditCharAttrib
* FindFeature( sal_Int32 nPos
) const;
208 void ResortAttribs();
209 void OptimizeRanges( SfxItemPool
& rItemPool
);
211 sal_Int32
Count() const;
213 void InsertAttrib( EditCharAttrib
* pAttrib
);
215 SvxFont
& GetDefFont() { return aDefFont
; }
217 bool HasEmptyAttribs() const { return bHasEmptyAttribs
; }
218 void SetHasEmptyAttribs(bool b
);
219 bool HasBoundingAttrib( sal_Int32 nBound
) const;
220 bool HasAttrib( sal_Int32 nStartPos
, sal_Int32 nEndPos
) const;
222 AttribsType
& GetAttribs() { return aAttribs
;}
223 const AttribsType
& GetAttribs() const { return aAttribs
;}
225 void Remove(const EditCharAttrib
* p
);
226 void Remove(sal_Int32 nPos
);
228 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
229 static void DbgCheckAttribs(CharAttribList
const& rAttribs
);
239 ContentAttribs aContentAttribs
;
240 CharAttribList aCharAttribList
;
241 std::unique_ptr
<WrongList
> mpWrongList
;
243 void UnExpandPosition( sal_Int32
&rStartPos
, bool bBiasStart
);
246 ContentNode( SfxItemPool
& rItemPool
);
247 ContentNode( const OUString
& rStr
, const ContentAttribs
& rContentAttribs
);
249 ContentNode(const ContentNode
&) = delete;
250 ContentNode
& operator=(const ContentNode
&) = delete;
252 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
254 ContentAttribs
& GetContentAttribs() { return aContentAttribs
; }
255 const ContentAttribs
& GetContentAttribs() const { return aContentAttribs
; }
256 CharAttribList
& GetCharAttribs() { return aCharAttribList
; }
257 const CharAttribList
& GetCharAttribs() const { return aCharAttribList
; }
259 void ExpandAttribs( sal_Int32 nIndex
, sal_Int32 nNewChars
, SfxItemPool
& rItemPool
);
260 void CollapseAttribs( sal_Int32 nIndex
, sal_Int32 nDelChars
, SfxItemPool
& rItemPool
);
261 void AppendAttribs( ContentNode
* pNextNode
);
262 void CopyAndCutAttribs( ContentNode
* pPrevNode
, SfxItemPool
& rPool
, bool bKeepEndingAttribs
);
264 void SetStyleSheet( SfxStyleSheet
* pS
, bool bRecalcFont
= true );
265 void SetStyleSheet( SfxStyleSheet
* pS
, const SvxFont
& rFontFromStyle
);
266 SfxStyleSheet
* GetStyleSheet() { return aContentAttribs
.GetStyleSheet(); }
268 void CreateDefFont();
270 void EnsureWrongList();
271 WrongList
* GetWrongList();
272 const WrongList
* GetWrongList() const;
273 void SetWrongList( WrongList
* p
);
275 void CreateWrongList();
276 void DestroyWrongList();
278 bool IsFeature( sal_Int32 nPos
) const;
280 sal_Int32
Len() const;
281 const OUString
& GetString() const { return maString
;}
283 /// return length including expanded fields
284 sal_Int32
GetExpandedLen() const;
285 /// return content including expanded fields
286 OUString
GetExpandedText(sal_Int32 nStartPos
= 0, sal_Int32 nEndPos
= -1) const;
287 /// re-write offsets in the expanded text to string offsets
288 void UnExpandPositions( sal_Int32
&rStartPos
, sal_Int32
&rEndPos
);
290 void SetChar(sal_Int32 nPos
, sal_Unicode c
);
291 void Insert(std::u16string_view rStr
, sal_Int32 nPos
);
292 void Append(std::u16string_view rStr
);
293 void Erase(sal_Int32 nPos
);
294 void Erase(sal_Int32 nPos
, sal_Int32 nCount
);
295 OUString
Copy(sal_Int32 nPos
) const;
296 OUString
Copy(sal_Int32 nPos
, sal_Int32 nCount
) const;
297 sal_Unicode
GetChar(sal_Int32 nPos
) const;
310 EditPaM(ContentNode
* p
, sal_Int32 n
);
312 const ContentNode
* GetNode() const { return pNode
;}
313 ContentNode
* GetNode() { return pNode
;}
314 void SetNode(ContentNode
* p
);
316 sal_Int32
GetIndex() const { return nIndex
; }
317 void SetIndex( sal_Int32 n
) { nIndex
= n
; }
319 bool DbgIsBuggy( EditDoc
const & rDoc
) const;
321 friend bool operator == ( const EditPaM
& r1
, const EditPaM
& r2
);
322 friend bool operator != ( const EditPaM
& r1
, const EditPaM
& r2
);
323 bool operator !() const { return !pNode
&& !nIndex
; }
326 enum class PortionKind
335 enum class DeleteMode
{
336 Simple
, RestOfWord
, RestOfContent
339 enum class AsianCompressionFlags
{
342 PunctuationLeft
= 0x02,
343 PunctuationRight
= 0x04,
346 template<> struct typed_flags
<AsianCompressionFlags
> : is_typed_flags
<AsianCompressionFlags
, 0x07> {};
351 // struct ExtraPortionInfos
353 struct ExtraPortionInfo
355 tools::Long nOrgWidth
;
356 tools::Long nWidthFullCompression
;
358 tools::Long nPortionOffsetX
;
360 sal_uInt16 nMaxCompression100thPercent
;
362 AsianCompressionFlags nAsianCompressionTypes
;
363 bool bFirstCharIsRightPunktuation
;
366 std::unique_ptr
<sal_Int32
[]> pOrgDXArray
;
367 std::vector
< sal_Int32
> lineBreaksList
;
373 void SaveOrgDXArray( const sal_Int32
* pDXArray
, sal_Int32 nLen
);
381 std::unique_ptr
<ExtraPortionInfo
> xExtraInfos
;
385 sal_uInt8 nRightToLeftLevel
;
386 sal_Unicode nExtraValue
;
390 TextPortion( sal_Int32 nL
)
393 , nKind( PortionKind::TEXT
)
394 , nRightToLeftLevel( 0 )
399 TextPortion( const TextPortion
& r
)
403 , nRightToLeftLevel( r
.nRightToLeftLevel
)
404 , nExtraValue( r
.nExtraValue
)
409 sal_Int32
GetLen() const { return nLen
; }
410 void SetLen( sal_Int32 nL
) { nLen
= nL
; }
412 void setWidth(tools::Long nWidth
)
414 aOutSz
.setWidth(nWidth
);
417 void setHeight(tools::Long nHeight
)
419 aOutSz
.setHeight(nHeight
);
422 void adjustSize(tools::Long nDeltaX
, tools::Long nDeltaY
)
425 aOutSz
.AdjustWidth(nDeltaX
);
427 aOutSz
.AdjustHeight(nDeltaY
);
430 void SetSize(const Size
& rSize
)
435 const Size
& GetSize() const { return aOutSz
; }
437 void SetKind(PortionKind n
) { nKind
= n
; }
438 PortionKind
GetKind() const { return nKind
; }
440 void SetRightToLeftLevel( sal_uInt8 n
) { nRightToLeftLevel
= n
; }
441 sal_uInt8
GetRightToLeftLevel() const { return nRightToLeftLevel
; }
442 bool IsRightToLeft() const { return (nRightToLeftLevel
&1); }
444 sal_Unicode
GetExtraValue() const { return nExtraValue
; }
445 void SetExtraValue( sal_Unicode n
) { nExtraValue
= n
; }
447 ExtraPortionInfo
* GetExtraInfos() const { return xExtraInfos
.get(); }
448 void SetExtraInfos( ExtraPortionInfo
* p
) { xExtraInfos
.reset(p
); }
453 class TextPortionList
455 typedef std::vector
<std::unique_ptr
<TextPortion
> > PortionsType
;
456 PortionsType maPortions
;
463 sal_Int32
FindPortion(
464 sal_Int32 nCharPos
, sal_Int32
& rPortionStart
, bool bPreferStartingPortion
= false) const;
465 sal_Int32
GetStartPos(sal_Int32 nPortion
);
466 void DeleteFromPortion(sal_Int32 nDelFrom
);
467 sal_Int32
Count() const;
468 const TextPortion
& operator[](sal_Int32 nPos
) const;
469 TextPortion
& operator[](sal_Int32 nPos
);
471 void Append(TextPortion
* p
);
472 void Insert(sal_Int32 nPos
, TextPortion
* p
);
473 void Remove(sal_Int32 nPos
);
474 sal_Int32
GetPos(const TextPortion
* p
) const;
484 typedef std::vector
<sal_Int32
> CharPosArrayType
;
487 CharPosArrayType aPositions
;
488 std::vector
<sal_Bool
> aKashidaPositions
;
490 sal_Int32 nStartPosX
;
491 sal_Int32 nStart
; // could be replaced by nStartPortion
492 sal_Int32 nEnd
; // could be replaced by nEndPortion
493 sal_Int32 nStartPortion
;
494 sal_Int32 nEndPortion
;
495 sal_uInt16 nHeight
; // Total height of the line
496 sal_uInt16 nTxtHeight
; // Pure Text height
497 sal_uInt16 nMaxAscent
;
498 bool bHangingPunctuation
:1;
499 bool bInvalid
:1; // for skillful formatting
503 EditLine( const EditLine
& );
506 bool IsIn( sal_Int32 nIndex
) const
507 { return ( (nIndex
>= nStart
) && ( nIndex
< nEnd
) ); }
509 bool IsIn( sal_Int32 nIndex
, bool bInclEnd
) const
510 { return ( ( nIndex
>= nStart
) && ( bInclEnd
? ( nIndex
<= nEnd
) : ( nIndex
< nEnd
) ) ); }
512 void SetStart( sal_Int32 n
) { nStart
= n
; }
513 sal_Int32
GetStart() const { return nStart
; }
514 sal_Int32
& GetStart() { return nStart
; }
516 void SetEnd( sal_Int32 n
) { nEnd
= n
; }
517 sal_Int32
GetEnd() const { return nEnd
; }
518 sal_Int32
& GetEnd() { return nEnd
; }
520 void SetStartPortion( sal_Int32 n
) { nStartPortion
= n
; }
521 sal_Int32
GetStartPortion() const { return nStartPortion
; }
522 sal_Int32
& GetStartPortion() { return nStartPortion
; }
524 void SetEndPortion( sal_Int32 n
) { nEndPortion
= n
; }
525 sal_Int32
GetEndPortion() const { return nEndPortion
; }
526 sal_Int32
& GetEndPortion() { return nEndPortion
; }
528 void SetHeight( sal_uInt16 nH
, sal_uInt16 nTxtH
= 0 );
529 sal_uInt16
GetHeight() const { return nHeight
; }
530 sal_uInt16
GetTxtHeight() const { return nTxtHeight
; }
532 void SetTextWidth( sal_Int32 n
) { nTxtWidth
= n
; }
533 sal_Int32
GetTextWidth() const { return nTxtWidth
; }
535 void SetMaxAscent( sal_uInt16 n
) { nMaxAscent
= n
; }
536 sal_uInt16
GetMaxAscent() const { return nMaxAscent
; }
538 void SetHangingPunctuation( bool b
) { bHangingPunctuation
= b
; }
539 bool IsHangingPunctuation() const { return bHangingPunctuation
; }
541 sal_Int32
GetLen() const { return nEnd
- nStart
; }
543 sal_Int32
GetStartPosX() const { return nStartPosX
; }
544 void SetStartPosX( sal_Int32 start
);
545 Size
CalcTextSize( ParaPortion
& rParaPortion
);
547 bool IsInvalid() const { return bInvalid
; }
548 bool IsValid() const { return !bInvalid
; }
549 void SetInvalid() { bInvalid
= true; }
550 void SetValid() { bInvalid
= false; }
552 bool IsEmpty() const { return nEnd
<= nStart
; }
554 CharPosArrayType
& GetCharPosArray() { return aPositions
;}
555 const CharPosArrayType
& GetCharPosArray() const { return aPositions
;}
557 std::vector
<sal_Bool
>& GetKashidaArray() { return aKashidaPositions
; }
558 const std::vector
<sal_Bool
>& GetKashidaArray() const { return aKashidaPositions
; }
560 EditLine
* Clone() const;
562 EditLine
& operator = ( const EditLine
& rLine
);
563 friend bool operator == ( const EditLine
& r1
, const EditLine
& r2
);
570 typedef std::vector
<std::unique_ptr
<EditLine
> > LinesType
;
578 void DeleteFromLine(sal_Int32 nDelFrom
);
579 sal_Int32
FindLine(sal_Int32 nChar
, bool bInclEnd
);
580 sal_Int32
Count() const;
581 const EditLine
& operator[](sal_Int32 nPos
) const;
582 EditLine
& operator[](sal_Int32 nPos
);
584 void Append(EditLine
* p
);
585 void Insert(sal_Int32 nPos
, EditLine
* p
);
592 friend class ImpEditEngine
; // to adjust the height
594 EditLineList aLineList
;
595 TextPortionList aTextPortionList
;
599 ScriptTypePosInfos aScriptInfos
;
600 WritingDirectionInfos aWritingDirectionInfos
;
602 sal_Int32 nInvalidPosStart
;
603 sal_Int32 nFirstLineOffset
; // For Writer-LineSpacing-Interpretation
605 sal_Int32 nInvalidDiff
;
608 bool bSimple
: 1; // only linear Tap
609 bool bVisible
: 1; // Belongs to the node!
610 bool bForceRepaint
: 1;
612 ParaPortion( const ParaPortion
& ) = delete;
615 ParaPortion( ContentNode
* pNode
);
618 sal_Int32
GetLineNumber( sal_Int32 nIndex
) const;
620 EditLineList
& GetLines() { return aLineList
; }
621 const EditLineList
& GetLines() const { return aLineList
; }
623 bool IsInvalid() const { return bInvalid
; }
624 bool IsSimpleInvalid() const { return bSimple
; }
625 void SetValid() { bInvalid
= false; bSimple
= true;}
627 bool MustRepaint() const { return bForceRepaint
; }
628 void SetMustRepaint( bool bRP
) { bForceRepaint
= bRP
; }
630 sal_Int32
GetBulletX() const { return nBulletX
; }
631 void SetBulletX( sal_Int32 n
) { nBulletX
= n
; }
633 void MarkInvalid( sal_Int32 nStart
, sal_Int32 nDiff
);
634 void MarkSelectionInvalid( sal_Int32 nStart
);
636 void SetVisible( bool bVisible
);
637 bool IsVisible() const { return bVisible
; }
639 bool IsEmpty() { return GetTextPortions().Count() == 1 && GetTextPortions()[0].GetLen() == 0; }
641 tools::Long
GetHeight() const { return ( bVisible
? nHeight
: 0 ); }
642 sal_Int32
GetFirstLineOffset() const { return ( bVisible
? nFirstLineOffset
: 0 ); }
643 void ResetHeight() { nHeight
= 0; nFirstLineOffset
= 0; }
645 ContentNode
* GetNode() const { return pNode
; }
646 TextPortionList
& GetTextPortions() { return aTextPortionList
; }
647 const TextPortionList
& GetTextPortions() const { return aTextPortionList
; }
649 sal_Int32
GetInvalidPosStart() const { return nInvalidPosStart
; }
650 short GetInvalidDiff() const { return nInvalidDiff
; }
652 void CorrectValuesBehindLastFormattedLine( sal_Int32 nLastFormattedLine
);
653 #if OSL_DEBUG_LEVEL > 0
654 static bool DbgCheckTextPortions(ParaPortion
const&);
660 class ParaPortionList
662 mutable sal_Int32 nLastCache
;
663 std::vector
<std::unique_ptr
<ParaPortion
>> maPortions
;
669 tools::Long
GetYOffset(const ParaPortion
* pPPortion
) const;
670 sal_Int32
FindParagraph(tools::Long nYOffset
) const;
672 const ParaPortion
* SafeGetObject(sal_Int32 nPos
) const;
673 ParaPortion
* SafeGetObject(sal_Int32 nPos
);
675 sal_Int32
GetPos(const ParaPortion
* p
) const;
676 ParaPortion
* operator[](sal_Int32 nPos
);
677 const ParaPortion
* operator[](sal_Int32 nPos
) const;
679 std::unique_ptr
<ParaPortion
> Release(sal_Int32 nPos
);
680 void Remove(sal_Int32 nPos
);
681 void Insert(sal_Int32 nPos
, std::unique_ptr
<ParaPortion
> p
);
682 void Append(std::unique_ptr
<ParaPortion
> p
);
683 sal_Int32
Count() const;
685 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
687 static void DbgCheck(ParaPortionList
const&, EditDoc
const& rDoc
);
700 EditSelection(); // No constructor and destructor
701 // are automatically executed correctly!
702 EditSelection( const EditPaM
& rStartAndAnd
);
703 EditSelection( const EditPaM
& rStart
, const EditPaM
& rEnd
);
705 EditPaM
& Min() { return aStartPaM
; }
706 EditPaM
& Max() { return aEndPaM
; }
708 const EditPaM
& Min() const { return aStartPaM
; }
709 const EditPaM
& Max() const { return aEndPaM
; }
711 bool HasRange() const { return aStartPaM
!= aEndPaM
; }
712 bool IsInvalid() const { return !aStartPaM
|| !aEndPaM
; }
713 bool DbgIsBuggy( EditDoc
const & rDoc
) const;
715 void Adjust( const EditDoc
& rNodes
);
717 EditSelection
& operator = ( const EditPaM
& r
);
718 bool operator == ( const EditSelection
& r
) const
719 { return ( aStartPaM
== r
.aStartPaM
) && ( aEndPaM
== r
.aEndPaM
); }
720 bool operator != ( const EditSelection
& r
) const { return !( r
== *this ); }
725 class DeletedNodeInfo
728 ContentNode
* mpInvalidNode
;
729 sal_Int32 nInvalidParagraph
;
732 DeletedNodeInfo( ContentNode
* pNode
, sal_Int32 nPos
)
733 : mpInvalidNode(pNode
)
734 , nInvalidParagraph(nPos
)
738 ContentNode
* GetNode() const { return mpInvalidNode
; }
739 sal_Int32
GetPosition() const { return nInvalidParagraph
; }
747 mutable sal_Int32 nLastCache
;
748 std::vector
<std::unique_ptr
<ContentNode
> > maContents
;
750 rtl::Reference
<SfxItemPool
> pItemPool
;
751 Link
<LinkParamNone
*,void> aModifyHdl
;
753 SvxFont maDefFont
; //faster than ever from the pool!!
756 TextRotation mnRotation
;
757 bool bIsFixedCellHeight
:1;
760 bool bDisableAttributeExpanding
:1;
763 void ImplDestroyContents();
766 EditDoc( SfxItemPool
* pItemPool
);
769 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
770 void ClearSpellErrors();
772 bool IsModified() const { return bModified
; }
773 void SetModified( bool b
);
775 void DisableAttributeExpanding() { bDisableAttributeExpanding
= true; }
777 void SetModifyHdl( const Link
<LinkParamNone
*,void>& rLink
) { aModifyHdl
= rLink
; }
779 void CreateDefFont( bool bUseStyles
);
780 const SvxFont
& GetDefFont() const { return maDefFont
; }
782 void SetDefTab( sal_uInt16 nTab
) { nDefTab
= nTab
? nTab
: DEFTAB
; }
783 sal_uInt16
GetDefTab() const { return nDefTab
; }
785 void SetVertical( bool bVertical
) { bIsVertical
= bVertical
; }
786 bool IsEffectivelyVertical() const;
787 bool IsTopToBottom() const;
788 bool GetVertical() const;
789 void SetRotation( TextRotation nRotation
) { mnRotation
= nRotation
; }
790 TextRotation
GetRotation() const { return mnRotation
; }
792 void SetFixedCellHeight( bool bUseFixedCellHeight
) { bIsFixedCellHeight
= bUseFixedCellHeight
; }
793 bool IsFixedCellHeight() const { return bIsFixedCellHeight
; }
796 EditPaM
RemoveText();
797 void RemoveChars( EditPaM aPaM
, sal_Int32 nChars
);
798 EditPaM
InsertText( EditPaM aPaM
, std::u16string_view rStr
);
799 EditPaM
InsertParaBreak( EditPaM aPaM
, bool bKeepEndingAttribs
);
800 EditPaM
InsertFeature( EditPaM aPaM
, const SfxPoolItem
& rItem
);
801 EditPaM
ConnectParagraphs( ContentNode
* pLeft
, ContentNode
* pRight
);
803 OUString
GetText( LineEnd eEnd
) const;
804 sal_Int32
GetTextLen() const;
806 OUString
GetParaAsString( sal_Int32 nNode
) const;
807 static OUString
GetParaAsString(const ContentNode
* pNode
, sal_Int32 nStartPos
= 0, sal_Int32 nEndPos
= -1);
809 EditPaM
GetStartPaM() const;
810 EditPaM
GetEndPaM() const;
812 SfxItemPool
& GetItemPool() { return *pItemPool
; }
813 const SfxItemPool
& GetItemPool() const { return *pItemPool
; }
815 void RemoveItemsFromPool(const ContentNode
& rNode
);
817 void InsertAttrib( const SfxPoolItem
& rItem
, ContentNode
* pNode
, sal_Int32 nStart
, sal_Int32 nEnd
);
818 void InsertAttrib( ContentNode
* pNode
, sal_Int32 nStart
, sal_Int32 nEnd
, const SfxPoolItem
& rPoolItem
);
819 void InsertAttribInSelection( ContentNode
* pNode
, sal_Int32 nStart
, sal_Int32 nEnd
, const SfxPoolItem
& rPoolItem
);
820 bool RemoveAttribs( ContentNode
* pNode
, sal_Int32 nStart
, sal_Int32 nEnd
, sal_uInt16 nWhich
);
821 bool RemoveAttribs( ContentNode
* pNode
, sal_Int32 nStart
, sal_Int32 nEnd
, EditCharAttrib
*& rpStarting
, EditCharAttrib
*& rpEnding
, sal_uInt16 nWhich
);
822 static void FindAttribs( ContentNode
* pNode
, sal_Int32 nStartPos
, sal_Int32 nEndPos
, SfxItemSet
& rCurSet
);
824 sal_Int32
GetPos(const ContentNode
* pNode
) const;
825 const ContentNode
* GetObject(sal_Int32 nPos
) const;
826 ContentNode
* GetObject(sal_Int32 nPos
);
827 sal_Int32
Count() const;
828 const ContentNode
* operator[](sal_Int32 nPos
) const;
829 ContentNode
* operator[](sal_Int32 nPos
);
830 void Insert(sal_Int32 nPos
, ContentNode
* p
);
832 void Remove(sal_Int32 nPos
);
834 void Release(sal_Int32 nPos
);
836 static OUString
GetSepStr( LineEnd eEnd
);
839 inline EditCharAttrib
* GetAttrib(CharAttribList::AttribsType
& rAttribs
, std::size_t nAttr
)
841 return (nAttr
< rAttribs
.size()) ? rAttribs
[nAttr
].get() : nullptr;
844 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
845 void CheckOrderedList(const CharAttribList::AttribsType
& rAttribs
);
848 class EditEngineItemPool final
: public SfxItemPool
851 std::shared_ptr
<DefItems
> m_xDefItems
;
853 EditEngineItemPool();
855 virtual ~EditEngineItemPool() override
;
858 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */