Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / acorrect.hxx
blob0b9fce178739a97a0cf27bb4a0f23d12d734343c
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 #ifndef INCLUDED_SW_SOURCE_CORE_INC_ACORRECT_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_ACORRECT_HXX
23 #include <memory>
25 #include <svl/itemset.hxx>
26 #include <editeng/svxacorr.hxx>
27 #include <nodeoffset.hxx>
28 #include <ndindex.hxx>
29 #include <utility>
31 class SwEditShell;
32 class SwPaM;
33 struct SwPosition;
34 class SfxItemSet;
36 class SwDontExpandItem
38 std::unique_ptr<SfxItemSet> m_pDontExpandItems;
40 public:
41 SwDontExpandItem() {}
42 ~SwDontExpandItem();
44 void SaveDontExpandItems( const SwPosition& rPos );
45 void RestoreDontExpandItems( const SwPosition& rPos );
49 class SwAutoCorrDoc final : public SvxAutoCorrDoc
51 SwEditShell& m_rEditSh;
52 SwPaM& m_rCursor;
53 std::optional<SwNodeIndex> m_oIndex;
54 int m_nEndUndoCounter;
55 bool m_bUndoIdInitialized;
57 void DeleteSel( SwPaM& rDelPam );
58 void DeleteSelImpl(SwPaM & rDelPam);
60 public:
61 SwAutoCorrDoc( SwEditShell& rEditShell, SwPaM& rPam, sal_Unicode cIns = 0 );
62 virtual ~SwAutoCorrDoc() override;
64 virtual bool Delete( sal_Int32 nStt, sal_Int32 nEnd ) override;
65 virtual bool Insert( sal_Int32 nPos, const OUString& rText ) override;
66 virtual bool Replace( sal_Int32 nPos, const OUString& rText ) override;
67 virtual bool ReplaceRange( sal_Int32 nPos, sal_Int32 nLen, const OUString& rText ) override;
69 virtual void SetAttr( sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId,
70 SfxPoolItem& ) override;
72 virtual bool SetINetAttr( sal_Int32 nStt, sal_Int32 nEnd, const OUString& rURL ) override;
74 // return text of a previous paragraph
75 // If it does not exist or if there is nothing before, return blank.
76 // - true: paragraph before "normal" insertion position
77 // - false: paragraph in that the corrected word was inserted
78 // (does not need to be the same paragraph)
79 virtual OUString const* GetPrevPara(bool bAtNormalPos) override;
81 virtual bool ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
82 SvxAutoCorrect& rACorrect,
83 OUString* pPara ) override;
84 virtual bool TransliterateRTLWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
85 bool bApply = false ) override;
87 // Will be called after swapping characters by the functions
88 // - FnCapitalStartWord and
89 // - FnCapitalStartSentence.
90 // Afterwards the words can be added into exception list if needed.
91 virtual void SaveCpltSttWord( ACFlags nFlag, sal_Int32 nPos,
92 const OUString& rExceptWord, sal_Unicode cChar ) override;
93 virtual LanguageType GetLanguage( sal_Int32 nPos ) const override;
96 class SwAutoCorrExceptWord
98 OUString m_sWord;
99 SwNodeOffset m_nNode;
100 ACFlags m_nFlags;
101 sal_Int32 m_nContent;
102 sal_Unicode m_cChar;
103 LanguageType m_eLanguage;
104 bool m_bDeleted;
106 public:
107 SwAutoCorrExceptWord(ACFlags nAFlags, SwNodeOffset nNd, sal_Int32 nContent,
108 OUString aWord, sal_Unicode cChr,
109 LanguageType eLang)
110 : m_sWord(std::move(aWord)), m_nNode(nNd), m_nFlags(nAFlags), m_nContent(nContent),
111 m_cChar(cChr), m_eLanguage(eLang), m_bDeleted(false)
114 bool IsDeleted() const { return m_bDeleted; }
115 void CheckChar(const SwPosition& rPos, sal_Unicode cChar);
116 bool CheckDelChar(const SwPosition& rPos);
119 #endif
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */