LibreOffice Module sw (master) 1
acorrect.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SW_SOURCE_CORE_INC_ACORRECT_HXX
21#define INCLUDED_SW_SOURCE_CORE_INC_ACORRECT_HXX
22
23#include <memory>
24
25#include <svl/itemset.hxx>
26#include <editeng/svxacorr.hxx>
27#include <nodeoffset.hxx>
28#include <ndindex.hxx>
29#include <utility>
30
31class SwEditShell;
32class SwPaM;
33struct SwPosition;
34class SfxItemSet;
35
37{
38 std::unique_ptr<SfxItemSet> m_pDontExpandItems;
39
40public:
43
44 void SaveDontExpandItems( const SwPosition& rPos );
45 void RestoreDontExpandItems( const SwPosition& rPos );
46
47};
48
49class SwAutoCorrDoc final : public SvxAutoCorrDoc
50{
53 std::optional<SwNodeIndex> m_oIndex;
56
57 void DeleteSel( SwPaM& rDelPam );
58 void DeleteSelImpl(SwPaM & rDelPam);
59
60public:
61 SwAutoCorrDoc( SwEditShell& rEditShell, SwPaM& rPam, sal_Unicode cIns = 0 );
62 virtual ~SwAutoCorrDoc() override;
63
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;
68
69 virtual void SetAttr( sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId,
70 SfxPoolItem& ) override;
71
72 virtual bool SetINetAttr( sal_Int32 nStt, sal_Int32 nEnd, const OUString& rURL ) override;
73
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;
80
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;
86
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;
94};
95
97{
98 OUString m_sWord;
101 sal_Int32 m_nContent;
105
106public:
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)
112 {}
113
114 bool IsDeleted() const { return m_bDeleted; }
115 void CheckChar(const SwPosition& rPos, sal_Unicode cChar);
116 bool CheckDelChar(const SwPosition& rPos);
117};
118
119#endif
120
121/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual LanguageType GetLanguage(sal_Int32 nPos) const override
Definition: acorrect.cxx:607
virtual bool ReplaceRange(sal_Int32 nPos, sal_Int32 nLen, const OUString &rText) override
Definition: acorrect.cxx:184
int m_nEndUndoCounter
Definition: acorrect.hxx:54
virtual bool Replace(sal_Int32 nPos, const OUString &rText) override
Definition: acorrect.cxx:179
virtual bool TransliterateRTLWord(sal_Int32 &rSttPos, sal_Int32 nEndPos, bool bApply=false) override
Definition: acorrect.cxx:512
virtual void SaveCpltSttWord(ACFlags nFlag, sal_Int32 nPos, const OUString &rExceptWord, sal_Unicode cChar) override
Definition: acorrect.cxx:597
void DeleteSel(SwPaM &rDelPam)
Definition: acorrect.cxx:108
virtual bool SetINetAttr(sal_Int32 nStt, sal_Int32 nEnd, const OUString &rURL) override
Definition: acorrect.cxx:313
virtual bool Delete(sal_Int32 nStt, sal_Int32 nEnd) override
Definition: acorrect.cxx:144
virtual void SetAttr(sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId, SfxPoolItem &) override
Definition: acorrect.cxx:287
void DeleteSelImpl(SwPaM &rDelPam)
Definition: acorrect.cxx:126
virtual bool ChgAutoCorrWord(sal_Int32 &rSttPos, sal_Int32 nEndPos, SvxAutoCorrect &rACorrect, OUString *pPara) override
Definition: acorrect.cxx:371
virtual bool Insert(sal_Int32 nPos, const OUString &rText) override
Definition: acorrect.cxx:159
virtual ~SwAutoCorrDoc() override
Definition: acorrect.cxx:100
SwAutoCorrDoc(SwEditShell &rEditShell, SwPaM &rPam, sal_Unicode cIns=0)
Definition: acorrect.cxx:92
virtual OUString const * GetPrevPara(bool bAtNormalPos) override
Return the text of a previous paragraph.
Definition: acorrect.cxx:337
std::optional< SwNodeIndex > m_oIndex
Definition: acorrect.hxx:53
SwPaM & m_rCursor
Definition: acorrect.hxx:52
SwEditShell & m_rEditSh
Definition: acorrect.hxx:51
bool m_bUndoIdInitialized
Definition: acorrect.hxx:55
bool IsDeleted() const
Definition: acorrect.hxx:114
sal_Int32 m_nContent
Definition: acorrect.hxx:101
SwAutoCorrExceptWord(ACFlags nAFlags, SwNodeOffset nNd, sal_Int32 nContent, OUString aWord, sal_Unicode cChr, LanguageType eLang)
Definition: acorrect.hxx:107
SwNodeOffset m_nNode
Definition: acorrect.hxx:99
LanguageType m_eLanguage
Definition: acorrect.hxx:103
sal_Unicode m_cChar
Definition: acorrect.hxx:102
bool CheckDelChar(const SwPosition &rPos)
Definition: acorrect.cxx:642
void CheckChar(const SwPosition &rPos, sal_Unicode cChar)
Definition: acorrect.cxx:625
void RestoreDontExpandItems(const SwPosition &rPos)
Definition: acorrect.cxx:670
std::unique_ptr< SfxItemSet > m_pDontExpandItems
Definition: acorrect.hxx:38
void SaveDontExpandItems(const SwPosition &rPos)
Definition: acorrect.cxx:654
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
Marks a position in the document model.
Definition: pam.hxx:38
ACFlags
sal_uInt16 sal_Unicode