tdf#160621 Variable field dialog size of value field
[LibreOffice.git] / editeng / inc / editdoc.hxx
blob5a8aa8054b8f5482de3e456d4789ebdac8146cdd
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 "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"
42 #include <cstddef>
43 #include <memory>
44 #include <string_view>
45 #include <vector>
47 class ImpEditEngine;
48 enum class TextRotation;
51 #define CHARPOSGROW 16
52 #define DEFTAB 720
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 );
60 class EditDoc;
62 class ContentAttribsInfo
64 private:
65 typedef std::vector<std::unique_ptr<EditCharAttrib> > CharAttribsType;
67 SfxItemSet aPrevParaAttribs;
68 CharAttribsType aPrevCharAttribs;
70 public:
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
85 class DeletedNodeInfo
87 private:
88 ContentNode* mpInvalidNode;
89 sal_Int32 nInvalidParagraph;
91 public:
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; }
103 /** Edit document
105 * Holder, responsible for the content nodes and the manipulation of those.
107 class EditDoc
109 private:
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!!
117 sal_uInt16 mnDefTab;
118 bool mbIsVertical:1;
119 TextRotation mnRotation;
120 bool mbIsFixedCellHeight:1;
122 bool mbModified:1;
123 bool mbDisableAttributeExpanding:1;
125 public:
126 EditDoc( SfxItemPool* pItemPool );
127 ~EditDoc();
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)
139 maModifyHdl = 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
152 return mnDefTab;
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;
171 EditPaM Clear();
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()
190 return *mpItemPool;
192 const SfxItemPool& GetItemPool() const
194 return *mpItemPool;
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);
209 /// deletes
210 void Remove(sal_Int32 nPos);
211 /// does not delete
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);
224 #endif
226 class EditEngineItemPool final : public SfxItemPool
228 public:
229 EditEngineItemPool();
230 private:
231 virtual ~EditEngineItemPool() override;
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */