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 "ParagraphPortionList.hxx"
23 #include "editattr.hxx"
24 #include "edtspell.hxx"
25 #include "eerdll2.hxx"
26 #include <editeng/svxfont.hxx>
27 #include <editeng/EPaM.hxx>
28 #include <svl/itemset.hxx>
29 #include <svl/style.hxx>
30 #include <svl/itempool.hxx>
31 #include <svl/languageoptions.hxx>
32 #include <tools/lineend.hxx>
33 #include <o3tl/typed_flags_set.hxx>
34 #include "TextPortion.hxx"
35 #include "TextPortionList.hxx"
36 #include "ItemList.hxx"
37 #include "ContentNode.hxx"
38 #include "EditLineList.hxx"
39 #include "EditPaM.hxx"
40 #include "EditSelection.hxx"
44 #include <string_view>
48 enum class TextRotation
;
51 #define CHARPOSGROW 16
54 void CreateFont( SvxFont
& rFont
, const SfxItemSet
& rSet
, bool bSearchInParent
= true, SvtScriptType nScriptType
= SvtScriptType::NONE
);
55 sal_uInt16
GetScriptItemId( sal_uInt16 nItemId
, SvtScriptType nScriptType
);
56 bool IsScriptItemValid( sal_uInt16 nItemId
, short nScriptType
);
58 EditCharAttrib
* MakeCharAttrib( SfxItemPool
& rPool
, const SfxPoolItem
& rAttr
, sal_Int32 nS
, sal_Int32 nE
);
62 class ContentAttribsInfo
65 typedef std::vector
<std::unique_ptr
<EditCharAttrib
> > CharAttribsType
;
67 SfxItemSet aPrevParaAttribs
;
68 CharAttribsType aPrevCharAttribs
;
71 ContentAttribsInfo( SfxItemSet aParaAttribs
);
73 const SfxItemSet
& GetPrevParaAttribs() const { return aPrevParaAttribs
; }
74 const CharAttribsType
& GetPrevCharAttribs() const { return aPrevCharAttribs
; }
76 void AppendCharAttrib(EditCharAttrib
* pNew
);
79 typedef std::vector
<Color
> SvxColorList
;
81 enum class DeleteMode
{
82 Simple
, RestOfWord
, RestOfContent
88 ContentNode
* mpInvalidNode
;
89 sal_Int32 nInvalidParagraph
;
92 DeletedNodeInfo( ContentNode
* pNode
, sal_Int32 nPos
)
93 : mpInvalidNode(pNode
)
94 , nInvalidParagraph(nPos
)
98 ContentNode
* GetNode() const { return mpInvalidNode
; }
99 sal_Int32
GetPosition() const { return nInvalidParagraph
; }
105 * Holder, responsible for the content nodes and the manipulation of those.
110 mutable sal_Int32 mnLastCache
;
111 std::vector
<std::unique_ptr
<ContentNode
>> maContents
;
113 rtl::Reference
<SfxItemPool
> mpItemPool
;
114 Link
<LinkParamNone
*,void> maModifyHdl
;
116 SvxFont maDefFont
; //faster than ever from the pool!!
119 TextRotation mnRotation
;
120 bool mbIsFixedCellHeight
:1;
123 bool mbDisableAttributeExpanding
:1;
126 EditDoc( SfxItemPool
* pItemPool
);
129 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
130 void ClearSpellErrors();
132 bool IsModified() const { return mbModified
; }
133 void SetModified( bool b
);
135 void DisableAttributeExpanding() { mbDisableAttributeExpanding
= true; }
137 void SetModifyHdl(const Link
<LinkParamNone
*,void>& rLink
)
142 void CreateDefFont( bool bUseStyles
);
143 const SvxFont
& GetDefFont() const { return maDefFont
; }
145 void SetDefTab(sal_uInt16 nTab
)
147 mnDefTab
= nTab
? nTab
: DEFTAB
;
150 sal_uInt16
GetDefTab() const
155 void SetVertical( bool bVertical
) { mbIsVertical
= bVertical
; }
156 bool IsEffectivelyVertical() const;
157 bool IsTopToBottom() const;
158 bool GetVertical() const;
159 void SetRotation( TextRotation nRotation
) { mnRotation
= nRotation
; }
160 TextRotation
GetRotation() const { return mnRotation
; }
162 void SetFixedCellHeight( bool bUseFixedCellHeight
)
164 mbIsFixedCellHeight
= bUseFixedCellHeight
;
166 bool IsFixedCellHeight() const
168 return mbIsFixedCellHeight
;
172 EditPaM
RemoveText();
173 void RemoveChars( EditPaM aPaM
, sal_Int32 nChars
);
174 EditPaM
InsertText( EditPaM aPaM
, const OUString
& rStr
);
175 EditPaM
InsertParaBreak( EditPaM aPaM
, bool bKeepEndingAttribs
);
176 EditPaM
InsertFeature( EditPaM aPaM
, const SfxPoolItem
& rItem
);
177 EditPaM
ConnectParagraphs( ContentNode
* pLeft
, ContentNode
* pRight
);
179 OUString
GetText( LineEnd eEnd
) const;
180 sal_Int32
GetTextLen() const;
182 OUString
GetParaAsString( sal_Int32 nNode
) const;
183 static OUString
GetParaAsString(const ContentNode
* pNode
, sal_Int32 nStartPos
= 0, sal_Int32 nEndPos
= -1);
185 EditPaM
GetStartPaM() const;
186 EditPaM
GetEndPaM() const;
188 SfxItemPool
& GetItemPool()
192 const SfxItemPool
& GetItemPool() const
197 void InsertAttrib( const SfxPoolItem
& rItem
, ContentNode
* pNode
, sal_Int32 nStart
, sal_Int32 nEnd
);
198 void InsertAttrib( ContentNode
* pNode
, sal_Int32 nStart
, sal_Int32 nEnd
, const SfxPoolItem
& rPoolItem
);
199 void InsertAttribInSelection( ContentNode
* pNode
, sal_Int32 nStart
, sal_Int32 nEnd
, const SfxPoolItem
& rPoolItem
);
200 bool RemoveAttribs( ContentNode
* pNode
, sal_Int32 nStart
, sal_Int32 nEnd
, sal_uInt16 nWhich
);
201 bool RemoveAttribs( ContentNode
* pNode
, sal_Int32 nStart
, sal_Int32 nEnd
, EditCharAttrib
*& rpStarting
, EditCharAttrib
*& rpEnding
, sal_uInt16 nWhich
);
202 static void FindAttribs( ContentNode
* pNode
, sal_Int32 nStartPos
, sal_Int32 nEndPos
, SfxItemSet
& rCurSet
);
204 sal_Int32
GetPos(const ContentNode
* pNode
) const;
205 const ContentNode
* GetObject(sal_Int32 nPos
) const;
206 ContentNode
* GetObject(sal_Int32 nPos
);
207 sal_Int32
Count() const;
208 void Insert(sal_Int32 nPos
, std::unique_ptr
<ContentNode
> p
);
210 void Remove(sal_Int32 nPos
);
212 std::unique_ptr
<ContentNode
> Release(sal_Int32 nPos
);
214 static OUString
GetSepStr( LineEnd eEnd
);
217 inline EditCharAttrib
* GetAttrib(CharAttribList::AttribsType
& rAttribs
, std::size_t nAttr
)
219 return (nAttr
< rAttribs
.size()) ? rAttribs
[nAttr
].get() : nullptr;
222 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
223 void CheckOrderedList(const CharAttribList::AttribsType
& rAttribs
);
226 class EditEngineItemPool final
: public SfxItemPool
229 EditEngineItemPool();
231 virtual ~EditEngineItemPool() override
;
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */