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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_ACORRECT_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_ACORRECT_HXX
25 #include <svl/itemset.hxx>
26 #include <editeng/svxacorr.hxx>
27 #include <nodeoffset.hxx>
28 #include <ndindex.hxx>
36 class SwDontExpandItem
38 std::unique_ptr
<SfxItemSet
> m_pDontExpandItems
;
44 void SaveDontExpandItems( const SwPosition
& rPos
);
45 void RestoreDontExpandItems( const SwPosition
& rPos
);
49 class SwAutoCorrDoc final
: public SvxAutoCorrDoc
51 SwEditShell
& m_rEditSh
;
53 std::optional
<SwNodeIndex
> m_oIndex
;
54 int m_nEndUndoCounter
;
55 bool m_bUndoIdInitialized
;
57 void DeleteSel( SwPaM
& rDelPam
);
58 void DeleteSelImpl(SwPaM
& rDelPam
);
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
101 sal_Int32 m_nContent
;
103 LanguageType m_eLanguage
;
107 SwAutoCorrExceptWord(ACFlags nAFlags
, SwNodeOffset nNd
, sal_Int32 nContent
,
108 OUString aWord
, sal_Unicode cChr
,
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
);
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */