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 <tools/solar.h>
27 #include <editeng/svxacorr.hxx>
28 
29 class SwEditShell;
30 class SwPaM;
31 class SwNodeIndex;
32 struct SwPosition;
33 class SfxItemSet;
34 
36 {
37  std::unique_ptr<SfxItemSet> pDontExpItems;
38 
39 public:
42 
43  void SaveDontExpandItems( const SwPosition& rPos );
44  void RestoreDontExpandItems( const SwPosition& rPos );
45 
46 };
47 
49 {
52  std::unique_ptr<SwNodeIndex> pIdx;
55 
56  void DeleteSel( SwPaM& rDelPam );
57  void DeleteSelImpl(SwPaM & rDelPam);
58 
59 public:
60  SwAutoCorrDoc( SwEditShell& rEditShell, SwPaM& rPam, sal_Unicode cIns = 0 );
61  virtual ~SwAutoCorrDoc() override;
62 
63  virtual bool Delete( sal_Int32 nStt, sal_Int32 nEnd ) override;
64  virtual bool Insert( sal_Int32 nPos, const OUString& rText ) override;
65  virtual bool Replace( sal_Int32 nPos, const OUString& rText ) override;
66  virtual bool ReplaceRange( sal_Int32 nPos, sal_Int32 nLen, const OUString& rText ) override;
67 
68  virtual void SetAttr( sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId,
69  SfxPoolItem& ) override;
70 
71  virtual bool SetINetAttr( sal_Int32 nStt, sal_Int32 nEnd, const OUString& rURL ) override;
72 
73  // return text of a previous paragraph
74  // If it does not exist or if there is nothing before, return blank.
75  // - true: paragraph before "normal" insertion position
76  // - false: paragraph in that the corrected word was inserted
77  // (does not need to be the same paragraph)
78  virtual OUString const* GetPrevPara(bool bAtNormalPos) override;
79 
80  virtual bool ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
81  SvxAutoCorrect& rACorrect,
82  OUString* pPara ) override;
83 
84  // Will be called after swapping characters by the functions
85  // - FnCapitalStartWord and
86  // - FnCapitalStartSentence.
87  // Afterwards the words can be added into exception list if needed.
88  virtual void SaveCpltSttWord( ACFlags nFlag, sal_Int32 nPos,
89  const OUString& rExceptWord, sal_Unicode cChar ) override;
90  virtual LanguageType GetLanguage( sal_Int32 nPos ) const override;
91 };
92 
94 {
95  OUString const m_sWord;
98  sal_Int32 const m_nContent;
102 
103 public:
104  SwAutoCorrExceptWord(ACFlags nAFlags, sal_uLong nNd, sal_Int32 nContent,
105  const OUString& rWord, sal_Unicode cChr,
106  LanguageType eLang)
107  : m_sWord(rWord), m_nFlags(nAFlags), m_nNode(nNd), m_nContent(nContent),
108  m_cChar(cChr), m_eLanguage(eLang), m_bDeleted(false)
109  {}
110 
111  bool IsDeleted() const { return m_bDeleted; }
112  void CheckChar(const SwPosition& rPos, sal_Unicode cChar);
113  bool CheckDelChar(const SwPosition& rPos);
114 };
115 
116 #endif
117 
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool ReplaceRange(sal_Int32 nPos, sal_Int32 nLen, const OUString &rText) override
Definition: acorrect.cxx:178
Marks a position in the document model.
Definition: pam.hxx:35
sal_uIntPtr sal_uLong
virtual bool SetINetAttr(sal_Int32 nStt, sal_Int32 nEnd, const OUString &rURL) override
Definition: acorrect.cxx:303
OUString const m_sWord
Definition: acorrect.hxx:95
LanguageType const m_eLanguage
Definition: acorrect.hxx:100
virtual ~SwAutoCorrDoc() override
Definition: acorrect.cxx:94
virtual void SaveCpltSttWord(ACFlags nFlag, sal_Int32 nPos, const OUString &rExceptWord, sal_Unicode cChar) override
Definition: acorrect.cxx:499
void DeleteSel(SwPaM &rDelPam)
Definition: acorrect.cxx:102
sal_uInt16 sal_Unicode
ACFlags const m_nFlags
Definition: acorrect.hxx:96
ACFlags
int m_nEndUndoCounter
Definition: acorrect.hxx:53
void RestoreDontExpandItems(const SwPosition &rPos)
Definition: acorrect.cxx:572
void SaveDontExpandItems(const SwPosition &rPos)
Definition: acorrect.cxx:556
sal_Unicode const m_cChar
Definition: acorrect.hxx:99
sal_Int32 const m_nContent
Definition: acorrect.hxx:98
virtual bool Insert(sal_Int32 nPos, const OUString &rText) override
Definition: acorrect.cxx:153
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
bool bUndoIdInitialized
Definition: acorrect.hxx:54
std::unique_ptr< SfxItemSet > pDontExpItems
Definition: acorrect.hxx:37
void DeleteSelImpl(SwPaM &rDelPam)
Definition: acorrect.cxx:120
sal_uLong const m_nNode
Definition: acorrect.hxx:97
SwPaM & rCursor
Definition: acorrect.hxx:51
Marks a node in the document model.
Definition: ndindex.hxx:31
void CheckChar(const SwPosition &rPos, sal_Unicode cChar)
Definition: acorrect.cxx:527
virtual OUString const * GetPrevPara(bool bAtNormalPos) override
Return the text of a previous paragraph.
Definition: acorrect.cxx:327
SwAutoCorrExceptWord(ACFlags nAFlags, sal_uLong nNd, sal_Int32 nContent, const OUString &rWord, sal_Unicode cChr, LanguageType eLang)
Definition: acorrect.hxx:104
virtual LanguageType GetLanguage(sal_Int32 nPos) const override
Definition: acorrect.cxx:509
bool CheckDelChar(const SwPosition &rPos)
Definition: acorrect.cxx:544
virtual bool ChgAutoCorrWord(sal_Int32 &rSttPos, sal_Int32 nEndPos, SvxAutoCorrect &rACorrect, OUString *pPara) override
Definition: acorrect.cxx:358
SwEditShell & rEditSh
Definition: acorrect.hxx:50
std::unique_ptr< SwNodeIndex > pIdx
Definition: acorrect.hxx:52
virtual void SetAttr(sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId, SfxPoolItem &) override
Definition: acorrect.cxx:277
virtual bool Delete(sal_Int32 nStt, sal_Int32 nEnd) override
Definition: acorrect.cxx:138
SwAutoCorrDoc(SwEditShell &rEditShell, SwPaM &rPam, sal_Unicode cIns=0)
Definition: acorrect.cxx:86
virtual bool Replace(sal_Int32 nPos, const OUString &rText) override
Definition: acorrect.cxx:173
bool IsDeleted() const
Definition: acorrect.hxx:111