tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sw / inc / hints.hxx
blob11589fb827ba61354a8e67378d98f89a22b997a3
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 .
19 #ifndef INCLUDED_SW_INC_HINTS_HXX
20 #define INCLUDED_SW_INC_HINTS_HXX
22 #include "swatrset.hxx"
23 #include "swtypes.hxx"
24 #include <utility>
25 #include <vcl/vclptr.hxx>
27 class SwFormat;
28 class OutputDevice;
29 class SwTable;
30 class SwNode;
31 class SwNodes;
32 class SwPageFrame;
33 class SwFrame;
34 class SwHistory;
35 class SwTextNode;
36 class SwTextFormatColl;
37 class SwFrameFormat;
38 class SwTableBox;
39 class SwTableBoxFormat;
40 class SwTableLine;
41 class SwTableLineFormat;
42 class SwTableBox;
44 // Base class for all Message-Hints:
45 // "Overhead" of SfxPoolItem is handled here
46 class SwMsgPoolItem : public SfxPoolItem
48 public:
49 SwMsgPoolItem( sal_uInt16 nWhich );
51 // "Overhead" of SfxPoolItem
52 virtual bool operator==( const SfxPoolItem& ) const override;
53 virtual SwMsgPoolItem* Clone( SfxItemPool* pPool = nullptr ) const override;
56 // SwPtrMsgPoolItem (old SwObjectDying!)
58 class SwPtrMsgPoolItem final : public SwMsgPoolItem
60 public:
61 void * pObject;
63 SwPtrMsgPoolItem( sal_uInt16 nId, void * pObj )
64 : SwMsgPoolItem( nId ), pObject( pObj )
68 /**
69 * SwFormatChg is sent when a format has changed to another format. 2 Hints are always sent
70 * the old and the new format
72 * This is typically owned by an sw::LegacyModifyHint, which knows if this pool item is the old or
73 * the new format.
75 class SwFormatChg final : public SwMsgPoolItem
77 public:
78 SwFormat *pChangedFormat;
79 SwFormatChg( SwFormat *pFormat );
84 namespace sw {
86 /// text is moved into pDestNode
87 class MoveText final : public SfxHint
89 public:
90 SwTextNode * pDestNode;
91 sal_Int32 nDestStart;
92 sal_Int32 nSourceStart;
93 sal_Int32 nLen;
95 MoveText(SwTextNode *pD, sal_Int32 nD, sal_Int32 nS, sal_Int32 nL)
96 : SfxHint(SfxHintId::SwMoveText), pDestNode(pD), nDestStart(nD), nSourceStart(nS), nLen(nL) {}
99 class InsertText final : public SfxHint
101 public:
102 const sal_Int32 nPos;
103 const sal_Int32 nLen;
104 const bool isInsideFieldmarkCommand;
105 const bool isInsideFieldmarkResult;
107 InsertText(sal_Int32 nP, sal_Int32 nL, bool isInFMCommand, bool isInFMResult);
110 class DeleteText final : public SfxHint
112 public:
113 const sal_Int32 nStart;
114 const sal_Int32 nLen;
116 DeleteText( sal_Int32 nS, sal_Int32 nL );
119 class DeleteChar final : public SfxHint
121 public:
122 const sal_Int32 m_nPos;
124 DeleteChar( const sal_Int32 nPos );
127 /// new delete redline is created
128 class RedlineDelText final : public SfxHint
130 public:
131 sal_Int32 nStart;
132 sal_Int32 nLen;
134 RedlineDelText(sal_Int32 nS, sal_Int32 nL) : SfxHint(SfxHintId::SwRedlineDelText), nStart(nS), nLen(nL) {}
137 /// delete redline is removed
138 class RedlineUnDelText final : public SfxHint
140 public:
141 sal_Int32 nStart;
142 sal_Int32 nLen;
144 RedlineUnDelText(sal_Int32 nS, sal_Int32 nL) : SfxHint(SfxHintId::SwRedlineUnDelText), nStart(nS), nLen(nL) {}
147 /** DocPosUpdate is sent to signal that only the frames from or to a specified document-global position
148 have to be updated. At the moment this is only needed when updating pagenumber fields. */
149 class DocPosUpdate final : public SfxHint
151 public:
152 const SwTwips m_nDocPos;
153 DocPosUpdate(const SwTwips nDocPos)
154 : SfxHint(SfxHintId::SwDocPosUpdate)
155 , m_nDocPos(nDocPos)
158 class DocPosUpdateAtIndex final : public SfxHint
160 public:
161 const SwTwips m_nDocPos;
162 const SwTextNode& m_rNode;
163 const sal_uInt32 m_nIndex;
164 DocPosUpdateAtIndex(const SwTwips nDocPos, const SwTextNode& rNode, sal_uInt32 nIndex)
165 : SfxHint(SfxHintId::SwDocPosUpdateAtIndex)
166 , m_nDocPos(nDocPos)
167 , m_rNode(rNode)
168 , m_nIndex(nIndex)
171 class CondCollCondChg final : public SfxHint
173 public:
174 const SwTextFormatColl& m_rColl;
175 CondCollCondChg(const SwTextFormatColl& rColl) : SfxHint(SfxHintId::SwCondCollCondChg), m_rColl(rColl) {};
178 class GrfRereadAndInCacheHint final : public SfxHint
180 public:
181 GrfRereadAndInCacheHint() : SfxHint(SfxHintId::SwGrfRereadAndInCache) {}
184 class PreGraphicArrivedHint final : public SfxHint
186 public:
187 PreGraphicArrivedHint() : SfxHint(SfxHintId::SwPreGraphicArrived) {}
190 class PostGraphicArrivedHint final : public SfxHint
192 public:
193 PostGraphicArrivedHint() : SfxHint(SfxHintId::SwPostGraphicArrived) {}
196 class GraphicPieceArrivedHint final : public SfxHint
198 public:
199 GraphicPieceArrivedHint() : SfxHint(SfxHintId::SwGraphicPieceArrived) {}
202 class LinkedGraphicStreamArrivedHint final : public SfxHint
204 public:
205 LinkedGraphicStreamArrivedHint() : SfxHint(SfxHintId::SwLinkedGraphicStreamArrived) {}
208 class MoveTableLineHint final : public SfxHint
210 public:
211 const SwFrameFormat& m_rNewFormat;
212 const SwTableLine& m_rTableLine;
213 MoveTableLineHint(const SwFrameFormat& rNewFormat, const SwTableLine& rTableLine)
214 : SfxHint(SfxHintId::SwMoveTableLine), m_rNewFormat(rNewFormat), m_rTableLine(rTableLine) {};
217 class MoveTableBoxHint final : public SfxHint
219 public:
220 const SwFrameFormat& m_rNewFormat;
221 const SwTableBox& m_rTableBox;
222 MoveTableBoxHint(const SwFrameFormat& rNewFormat, const SwTableBox& rTableBox)
223 : SfxHint(SfxHintId::SwMoveTableBox), m_rNewFormat(rNewFormat), m_rTableBox(rTableBox) {};
226 class DocumentDyingHint final : public SfxHint
228 public:
229 DocumentDyingHint() : SfxHint(SfxHintId::SwDocumentDying) {}
232 class TableLineFormatChanged final : public SfxHint
234 public:
235 const SwTableLineFormat& m_rNewFormat;
236 const SwTableLine& m_rTabLine;
237 TableLineFormatChanged(const SwTableLineFormat& rNewFormat, const SwTableLine& rTabLine)
238 : SfxHint(SfxHintId::SwTableLineFormatChanged), m_rNewFormat(rNewFormat), m_rTabLine(rTabLine) {};
240 class TableBoxFormatChanged final : public SfxHint
242 public:
243 const SwTableBoxFormat& m_rNewFormat;
244 const SwTableBox& m_rTableBox;
245 TableBoxFormatChanged(const SwTableBoxFormat& rNewFormat, const SwTableBox& rTableBox)
246 : SfxHint(SfxHintId::SwTableBoxFormatChanged), m_rNewFormat(rNewFormat), m_rTableBox(rTableBox) {};
248 class NameChanged final : public SfxHint
250 public:
251 const OUString m_sOld;
252 const OUString m_sNew;
253 NameChanged(const OUString& rOld, const OUString& rNew) : SfxHint(SfxHintId::SwNameChanged), m_sOld(rOld), m_sNew(rNew) {};
255 class TitleChanged final : public SfxHint
257 public:
258 const OUString m_sOld;
259 const OUString m_sNew;
260 TitleChanged(const OUString& rOld, const OUString& rNew) : SfxHint(SfxHintId::SwTitleChanged), m_sOld(rOld), m_sNew(rNew) {};
262 class DescriptionChanged final : public SfxHint
264 public:
265 DescriptionChanged() : SfxHint(SfxHintId::SwDescriptionChanged) {}
267 class SectionHidden final: public SfxHint
269 public:
270 const bool m_isHidden;
271 SectionHidden(const bool isHidden = true) : SfxHint(SfxHintId::SwSectionHidden), m_isHidden(isHidden) {};
273 class TableHeadingChange final: public SfxHint
275 public:
276 TableHeadingChange() : SfxHint(SfxHintId::SwTableHeadingChange) {};
278 class VirtPageNumHint final: public SfxHint
280 const SwPageFrame* m_pPage;
281 const SwPageFrame* m_pOrigPage;
282 const SwFrame* m_pFrame;
283 bool m_bFound;
284 /** Multiple attributes can be attached to a single paragraph / table
285 The frame, in the end, has to decide which attribute takes effect and which physical page it involves */
286 public:
287 VirtPageNumHint(const SwPageFrame* pPg);
288 const SwPageFrame* GetPage() const
289 { return m_pPage; }
290 const SwPageFrame* GetOrigPage() const
291 { return m_pOrigPage; }
292 const SwFrame* GetFrame() const
293 { return m_pFrame; }
294 void SetInfo(const SwPageFrame* pPg, const SwFrame *pF)
295 { m_pFrame = pF; m_pPage = pPg; }
296 void SetFound()
298 assert(!m_bFound);
299 m_bFound = true;
301 bool IsFound()
302 { return m_bFound; }
304 class AutoFormatUsedHint final : public SfxHint
306 bool& m_isUsed;
307 const SwNodes& m_rNodes;
308 public:
309 AutoFormatUsedHint(bool& isUsed, const SwNodes& rNodes) : SfxHint(SfxHintId::SwAutoFormatUsedHint), m_isUsed(isUsed), m_rNodes(rNodes) {}
310 void SetUsed() const { m_isUsed = true; }
311 void CheckNode(const SwNode*) const;
315 class SwUpdateAttr final : public SwMsgPoolItem
317 private:
318 sal_Int32 m_nStart;
319 sal_Int32 m_nEnd;
320 sal_uInt16 m_nWhichAttr;
321 std::vector<sal_uInt16> m_aWhichFmtAttrs; // attributes changed inside RES_TXTATR_AUTOFMT
323 public:
324 SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW );
325 SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW, std::vector<sal_uInt16> aW );
327 sal_Int32 getStart() const
329 return m_nStart;
332 sal_Int32 getEnd() const
334 return m_nEnd;
337 sal_uInt16 getWhichAttr() const
339 return m_nWhichAttr;
342 const std::vector<sal_uInt16>& getFmtAttrs() const
344 return m_aWhichFmtAttrs;
348 /// SwTableFormulaUpdate is sent when the table has to be newly calculated or when a table itself is merged or split
349 enum TableFormulaUpdateFlags { TBL_CALC = 0,
350 TBL_BOXNAME,
351 TBL_BOXPTR,
352 TBL_RELBOXNAME,
353 TBL_MERGETBL,
354 TBL_SPLITTBL
356 class SwTableFormulaUpdate final
358 public:
359 const SwTable* m_pTable; ///< Pointer to the current table
360 union {
361 const SwTable* pDelTable; ///< Merge: Pointer to the table to be removed
362 const OUString* pNewTableNm; ///< Split: the name of the new table
363 } m_aData;
364 sal_uInt16 m_nSplitLine; ///< Split: from this BaseLine on will be split
365 TableFormulaUpdateFlags m_eFlags;
366 bool m_bModified : 1;
367 bool m_bBehindSplitLine : 1;
369 /** Is sent if a table should be recalculated */
370 SwTableFormulaUpdate( const SwTable* );
374 * SwAttrSetChg is sent when something has changed in the SwAttrSet rTheChgdSet.
375 * 2 Hints are always sent, the old and the new items in the rTheChgdSet.
377 class SwAttrSetChg final : public SwMsgPoolItem
379 bool m_bDelSet;
380 SwAttrSet* m_pChgSet; ///< what has changed
381 const SwAttrSet* m_pTheChgdSet; ///< is only used to compare
382 public:
383 SwAttrSetChg( const SwAttrSet& rTheSet, SwAttrSet& rSet );
384 SwAttrSetChg( const SwAttrSetChg& );
385 virtual ~SwAttrSetChg() override;
387 /// What has changed
388 const SwAttrSet* GetChgSet() const { return m_pChgSet; }
389 SwAttrSet* GetChgSet() { return m_pChgSet; }
391 /// Where it has changed
392 const SwAttrSet* GetTheChgdSet() const { return m_pTheChgdSet; }
394 sal_uInt16 Count() const { return m_pChgSet->Count(); }
395 void ClearItem( sal_uInt16 nWhichL )
396 #ifdef DBG_UTIL
398 #else
399 { m_pChgSet->ClearItem( nWhichL ); }
400 #endif
404 class SwFindNearestNode final
406 const SwNode *m_pNode, *m_pFound;
407 public:
408 SwFindNearestNode( const SwNode& rNd ) : m_pNode(&rNd), m_pFound(nullptr) {}
409 void CheckNode( const SwNode& rNd );
411 const SwNode* GetFoundNode() const { return m_pFound; }
414 #endif
416 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */