LibreOffice Module sw (master)  1
acorrect.cxx
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 #include <hintids.hxx>
21 
22 #include <fmtinfmt.hxx>
23 #include <editsh.hxx>
24 #include <doc.hxx>
25 #include <pam.hxx>
26 #include <unocrsr.hxx>
27 #include <txatbase.hxx>
28 #include <txtfrm.hxx>
29 #include <ndtxt.hxx>
30 #include <acorrect.hxx>
31 #include <shellio.hxx>
32 #include <swundo.hxx>
33 #include <viscrs.hxx>
34 
35 #include <editeng/acorrcfg.hxx>
36 
37 using namespace ::com::sun::star;
38 
39 namespace {
40 
41 class PaMIntoCursorShellRing
42 {
43  SwCursorShell& rSh;
44  SwPaM &rDelPam, &rCursor;
45  SwPaM* pPrevDelPam;
46  SwPaM* pPrevCursor;
47 
48  static void RemoveFromRing( SwPaM& rPam, SwPaM const * pPrev );
49 public:
50  PaMIntoCursorShellRing( SwCursorShell& rSh, SwPaM& rCursor, SwPaM& rPam );
51  ~PaMIntoCursorShellRing();
52 };
53 
54 }
55 
56 PaMIntoCursorShellRing::PaMIntoCursorShellRing( SwCursorShell& rCSh,
57  SwPaM& rShCursor, SwPaM& rPam )
58  : rSh( rCSh ), rDelPam( rPam ), rCursor( rShCursor )
59 {
60  SwPaM* pShCursor = rSh.GetCursor_();
61 
62  pPrevDelPam = rDelPam.GetPrev();
63  pPrevCursor = rCursor.GetPrev();
64 
65  rDelPam.GetRingContainer().merge( pShCursor->GetRingContainer() );
66  rCursor.GetRingContainer().merge( pShCursor->GetRingContainer() );
67 }
68 
69 PaMIntoCursorShellRing::~PaMIntoCursorShellRing()
70 {
71  // and take out the Pam again:
72  RemoveFromRing( rDelPam, pPrevDelPam );
73  RemoveFromRing( rCursor, pPrevCursor );
74 }
75 
76 void PaMIntoCursorShellRing::RemoveFromRing( SwPaM& rPam, SwPaM const * pPrev )
77 {
78  SwPaM* p;
79  SwPaM* pNext = &rPam;
80  do {
81  p = pNext;
82  pNext = p->GetNext();
83  p->MoveTo( &rPam );
84  } while( p != pPrev );
85 }
86 
88  sal_Unicode cIns )
89  : rEditSh( rEditShell ), rCursor( rPam )
90  , m_nEndUndoCounter(0)
91  , bUndoIdInitialized( cIns == 0 )
92 {
93 }
94 
96 {
97  for (int i = 0; i < m_nEndUndoCounter; ++i)
98  {
99  rEditSh.EndUndo();
100  }
101 }
102 
104 {
105  // this should work with plain SwPaM as well because start and end
106  // are always in same node, but since there is GetRanges already...
107  std::vector<std::shared_ptr<SwUnoCursor>> ranges;
108  if (sw::GetRanges(ranges, *rEditSh.GetDoc(), rDelPam))
109  {
110  DeleteSelImpl(rDelPam);
111  }
112  else
113  {
114  for (auto const& pCursor : ranges)
115  {
116  DeleteSelImpl(*pCursor);
117  }
118  }
119 }
120 
122 {
123  SwDoc* pDoc = rEditSh.GetDoc();
124  if( pDoc->IsAutoFormatRedline() )
125  {
126  // so that also the DelPam be moved, include it in the
127  // Shell-Cursr-Ring !!
128  // ??? is that really necessary - this should never join nodes, so Update should be enough?
129 // PaMIntoCursorShellRing aTmp( rEditSh, rCursor, rDelPam );
130  assert(rDelPam.GetPoint()->nNode == rDelPam.GetMark()->nNode);
131  pDoc->getIDocumentContentOperations().DeleteAndJoin( rDelPam );
132  }
133  else
134  {
135  pDoc->getIDocumentContentOperations().DeleteRange( rDelPam );
136  }
137 }
138 
139 bool SwAutoCorrDoc::Delete( sal_Int32 nStt, sal_Int32 nEnd )
140 {
141  SwTextNode const*const pTextNd = rCursor.GetNode().GetTextNode();
142  SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(
143  pTextNd->getLayoutFrame(rEditSh.GetLayout())));
144  assert(pFrame);
145  SwPaM aSel(pFrame->MapViewToModelPos(TextFrameIndex(nStt)),
146  pFrame->MapViewToModelPos(TextFrameIndex(nEnd)));
147  DeleteSel( aSel );
148 
149  if( bUndoIdInitialized )
150  bUndoIdInitialized = true;
151  return true;
152 }
153 
154 bool SwAutoCorrDoc::Insert( sal_Int32 nPos, const OUString& rText )
155 {
156  SwTextNode const*const pTextNd = rCursor.GetNode().GetTextNode();
157  SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(
158  pTextNd->getLayoutFrame(rEditSh.GetLayout())));
159  assert(pFrame);
160  SwPaM aPam(pFrame->MapViewToModelPos(TextFrameIndex(nPos)));
162  if( !bUndoIdInitialized )
163  {
164  bUndoIdInitialized = true;
165  if( 1 == rText.getLength() )
166  {
169  }
170  }
171  return true;
172 }
173 
174 bool SwAutoCorrDoc::Replace( sal_Int32 nPos, const OUString& rText )
175 {
176  return ReplaceRange( nPos, rText.getLength(), rText );
177 }
178 
179 bool SwAutoCorrDoc::ReplaceRange( sal_Int32 nPos, sal_Int32 nSourceLength, const OUString& rText )
180 {
181  assert(nSourceLength == 1); // sw_redlinehide: this is currently the case,
182  // and ensures that the replace range cannot *contain* delete redlines,
183  // so we don't need something along the lines of:
184  // if (sw::GetRanges(ranges, *rEditSh.GetDoc(), aPam))
185  // ReplaceImpl(...)
186  // else
187  // ReplaceImpl(ranges.begin())
188  // for (ranges.begin() + 1; ranges.end(); )
189  // DeleteImpl(*it)
190 
191  SwTextNode * const pNd = rCursor.GetNode().GetTextNode();
192  if ( !pNd )
193  {
194  return false;
195  }
196 
197  SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(
198  pNd->getLayoutFrame(rEditSh.GetLayout())));
199  assert(pFrame);
200  std::pair<SwTextNode *, sal_Int32> const pos(pFrame->MapViewToModel(TextFrameIndex(nPos)));
201 
202  SwPaM* pPam = &rCursor;
203  if (pPam->GetPoint()->nNode != *pos.first
204  || pPam->GetPoint()->nContent != pos.second)
205  {
206  pPam = new SwPaM(*pos.first, pos.second);
207  }
208 
209  // text attributes with dummy characters must not be replaced!
210  bool bDoReplace = true;
211  sal_Int32 const nLen = rText.getLength();
212  for (sal_Int32 n = 0; n < nLen && n + nPos < pFrame->GetText().getLength(); ++n)
213  {
214  sal_Unicode const Char = pFrame->GetText()[n + nPos];
215  if (CH_TXTATR_BREAKWORD == Char || CH_TXTATR_INWORD == Char)
216  {
217  assert(pFrame->MapViewToModel(TextFrameIndex(n+nPos)).first->GetTextAttrForCharAt(pFrame->MapViewToModel(TextFrameIndex(n+nPos)).second));
218  bDoReplace = false;
219  break;
220  }
221  }
222 
223  if ( bDoReplace )
224  {
225  SwDoc* pDoc = rEditSh.GetDoc();
226 
227  if( pDoc->IsAutoFormatRedline() )
228  {
229  if (nPos == pFrame->GetText().getLength()) // at the End do an Insert
230  {
231  pDoc->getIDocumentContentOperations().InsertString( *pPam, rText );
232  }
233  else
234  {
235  assert(pos.second != pos.first->Len()); // must be _before_ char
236  PaMIntoCursorShellRing aTmp( rEditSh, rCursor, *pPam );
237 
238  pPam->SetMark();
239  pPam->GetPoint()->nContent = std::min<sal_Int32>(
240  pos.first->GetText().getLength(), pos.second + nSourceLength);
241  pDoc->getIDocumentContentOperations().ReplaceRange( *pPam, rText, false );
242  pPam->Exchange();
243  pPam->DeleteMark();
244  }
245  }
246  else
247  {
248  if( nSourceLength != rText.getLength() )
249  {
250  pPam->SetMark();
251  pPam->GetPoint()->nContent = std::min<sal_Int32>(
252  pos.first->GetText().getLength(), pos.second + nSourceLength);
253  pDoc->getIDocumentContentOperations().ReplaceRange( *pPam, rText, false );
254  pPam->Exchange();
255  pPam->DeleteMark();
256  }
257  else
258  pDoc->getIDocumentContentOperations().Overwrite( *pPam, rText );
259  }
260 
261  if( bUndoIdInitialized )
262  {
263  bUndoIdInitialized = true;
264  if( 1 == rText.getLength() )
265  {
268  }
269  }
270  }
271 
272  if( pPam != &rCursor )
273  delete pPam;
274 
275  return true;
276 }
277 
278 void SwAutoCorrDoc::SetAttr( sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId,
279  SfxPoolItem& rItem )
280 {
281  SwTextNode const*const pTextNd = rCursor.GetNode().GetTextNode();
282  SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(
283  pTextNd->getLayoutFrame(rEditSh.GetLayout())));
284  assert(pFrame);
285  SwPaM aPam(pFrame->MapViewToModelPos(TextFrameIndex(nStt)),
286  pFrame->MapViewToModelPos(TextFrameIndex(nEnd)));
287 
288  SfxItemPool& rPool = rEditSh.GetDoc()->GetAttrPool();
289  sal_uInt16 nWhich = rPool.GetWhich( nSlotId, false );
290  if( nWhich )
291  {
292  rItem.SetWhich( nWhich );
293 
294  SfxItemSet aSet( rPool, aCharFormatSetRange );
295  SetAllScriptItem( aSet, rItem );
296 
297  rEditSh.GetDoc()->SetFormatItemByAutoFormat( aPam, aSet );
298 
299  if( bUndoIdInitialized )
300  bUndoIdInitialized = true;
301  }
302 }
303 
304 bool SwAutoCorrDoc::SetINetAttr( sal_Int32 nStt, sal_Int32 nEnd, const OUString& rURL )
305 {
306  SwTextNode const*const pTextNd = rCursor.GetNode().GetTextNode();
307  SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(
308  pTextNd->getLayoutFrame(rEditSh.GetLayout())));
309  assert(pFrame);
310  SwPaM aPam(pFrame->MapViewToModelPos(TextFrameIndex(nStt)),
311  pFrame->MapViewToModelPos(TextFrameIndex(nEnd)));
312 
315  aSet.Put( SwFormatINetFormat( rURL, OUString() ));
316  rEditSh.GetDoc()->SetFormatItemByAutoFormat( aPam, aSet );
317  if( bUndoIdInitialized )
318  bUndoIdInitialized = true;
319  return true;
320 }
321 
328 OUString const* SwAutoCorrDoc::GetPrevPara(bool const bAtNormalPos)
329 {
330  OUString const* pStr(nullptr);
331 
332  if( bAtNormalPos || !pIdx )
333  {
334  pIdx.reset(new SwNodeIndex(rCursor.GetPoint()->nNode));
335  }
337 
338  SwTextFrame const* pFrame(nullptr);
339  for (SwTextNode * pTextNd = pIdx->GetNode().GetTextNode();
340  pTextNd; pTextNd = pIdx->GetNode().GetTextNode())
341  {
342  pFrame = static_cast<SwTextFrame const*>(
343  pTextNd->getLayoutFrame(rEditSh.GetLayout()));
344  if (pFrame && !pFrame->GetText().isEmpty())
345  {
346  break;
347  }
349  }
350  if (pFrame && 0 == pFrame->GetTextNodeForParaProps()->GetAttrOutlineLevel())
351  pStr = & pFrame->GetText();
352 
353  if( bUndoIdInitialized )
354  bUndoIdInitialized = true;
355 
356  return pStr;
357 }
358 
359 bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
360  SvxAutoCorrect& rACorrect,
361  OUString* pPara )
362 {
363  if( bUndoIdInitialized )
364  bUndoIdInitialized = true;
365 
366  // Found a beginning of a paragraph or a Blank,
367  // search for the word Kuerzel (Shortcut) in the Auto
368  SwTextNode* pTextNd = rCursor.GetNode().GetTextNode();
369  OSL_ENSURE( pTextNd, "where is the TextNode?" );
370 
371  bool bRet = false;
372  if( nEndPos == rSttPos )
373  return bRet;
374 
375  LanguageType eLang = GetLanguage(nEndPos);
376  if(LANGUAGE_SYSTEM == eLang)
377  eLang = GetAppLanguage();
378  LanguageTag aLanguageTag( eLang);
379 
380  SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(
381  pTextNd->getLayoutFrame(rEditSh.GetLayout())));
382  assert(pFrame);
383 
384  const OUString sFrameText = pFrame->GetText();
385  const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList(
386  sFrameText, rSttPos, nEndPos, *this, aLanguageTag);
387  SwDoc* pDoc = rEditSh.GetDoc();
388  if( pFnd )
389  {
390  // replace also last colon of keywords surrounded by colons (for example, ":name:")
391  const bool replaceLastChar = sFrameText.getLength() > nEndPos && pFnd->GetShort()[0] == ':'
392  && pFnd->GetShort().endsWith(":");
393 
394  SwPaM aPam(pFrame->MapViewToModelPos(TextFrameIndex(rSttPos)),
395  pFrame->MapViewToModelPos(TextFrameIndex(nEndPos + (replaceLastChar ? 1 : 0))));
396 
397  if( pFnd->IsTextOnly() )
398  {
399  //JP 22.04.99: Bug 63883 - Special treatment for dots.
400  const bool bLastCharIsPoint
401  = nEndPos < sFrameText.getLength() && ('.' == sFrameText[nEndPos]);
402  if( !bLastCharIsPoint || pFnd->GetLong().isEmpty() ||
403  '.' != pFnd->GetLong()[ pFnd->GetLong().getLength() - 1 ] )
404  {
405  // replace the selection
406  std::vector<std::shared_ptr<SwUnoCursor>> ranges;
407  if (sw::GetRanges(ranges, *rEditSh.GetDoc(), aPam))
408  {
409  pDoc->getIDocumentContentOperations().ReplaceRange(aPam, pFnd->GetLong(), false);
410  }
411  else
412  {
413  assert(!ranges.empty());
414  assert(ranges.front()->GetPoint()->nNode == ranges.front()->GetMark()->nNode);
416  *ranges.front(), pFnd->GetLong(), false);
417  for (auto it = ranges.begin() + 1; it != ranges.end(); ++it)
418  {
419  DeleteSelImpl(**it);
420  }
421  }
422 
423  // tdf#83260 After calling sw::DocumentContentOperationsManager::ReplaceRange
424  // pTextNd may become invalid when change tracking is on and Edit -> Track Changes -> Show == OFF.
425  // ReplaceRange shows changes, this moves deleted nodes from special section to document.
426  // Then Show mode is disabled again. As a result pTextNd may be invalidated.
427  pTextNd = rCursor.GetNode().GetTextNode();
428 
429  bRet = true;
430  }
431  }
432  else
433  {
434  SwTextBlocks aTBlks( rACorrect.GetAutoCorrFileName( aLanguageTag, false, true ));
435  sal_uInt16 nPos = aTBlks.GetIndex( pFnd->GetShort() );
436  if( USHRT_MAX != nPos && aTBlks.BeginGetDoc( nPos ) )
437  {
438  DeleteSel( aPam );
439  pDoc->DontExpandFormat( *aPam.GetPoint() );
440 
441  if( pPara )
442  {
443  OSL_ENSURE( !pIdx, "who has not deleted his Index?" );
444  pIdx.reset(new SwNodeIndex( rCursor.GetPoint()->nNode ));
446  }
447 
448  SwDoc* pAutoDoc = aTBlks.GetDoc();
449  SwNodeIndex aSttIdx( pAutoDoc->GetNodes().GetEndOfExtras(), 1 );
450  SwContentNode* pContentNd = pAutoDoc->GetNodes().GoNext( &aSttIdx );
451  SwPaM aCpyPam( aSttIdx );
452 
453  const SwTableNode* pTableNd = pContentNd->FindTableNode();
454  if( pTableNd )
455  {
456  aCpyPam.GetPoint()->nContent.Assign( nullptr, 0 );
457  aCpyPam.GetPoint()->nNode = *pTableNd;
458  }
459  aCpyPam.SetMark();
460 
461  // then until the end of the Nodes Array
462  aCpyPam.GetPoint()->nNode.Assign( pAutoDoc->GetNodes().GetEndOfContent(), -1 );
463  pContentNd = aCpyPam.GetContentNode();
464  aCpyPam.GetPoint()->nContent.Assign(
465  pContentNd, pContentNd ? pContentNd->Len() : 0);
466 
467  SwDontExpandItem aExpItem;
468  aExpItem.SaveDontExpandItems( *aPam.GetPoint() );
469 
470  pAutoDoc->getIDocumentContentOperations().CopyRange( aCpyPam, *aPam.GetPoint(), /*bCopyAll=*/false, /*bCheckPos=*/true, /*bCopyText=*/false );
471 
472  aExpItem.RestoreDontExpandItems( *aPam.GetPoint() );
473 
474  if( pPara )
475  {
477  pTextNd = pIdx->GetNode().GetTextNode();
478  }
479  bRet = true;
480  }
481  aTBlks.EndGetDoc();
482  }
483  }
484 
485  if( bRet && pPara && pTextNd )
486  {
487  SwTextFrame const*const pNewFrame(static_cast<SwTextFrame const*>(
488  pTextNd->getLayoutFrame(rEditSh.GetLayout())));
489  *pPara = pNewFrame->GetText();
490  }
491 
492  return bRet;
493 }
494 
495 // Called by the functions:
496 // - FnCapitalStartWord
497 // - FnCapitalStartSentence
498 // after the exchange of characters. Then the words, if necessary, can be inserted
499 // into the exception list.
500 void SwAutoCorrDoc::SaveCpltSttWord( ACFlags nFlag, sal_Int32 nPos,
501  const OUString& rExceptWord,
502  sal_Unicode cChar )
503 {
504  sal_uLong nNode = pIdx ? pIdx->GetIndex() : rCursor.GetPoint()->nNode.GetIndex();
505  LanguageType eLang = GetLanguage(nPos);
506  rEditSh.GetDoc()->SetAutoCorrExceptWord( std::make_unique<SwAutoCorrExceptWord>( nFlag,
507  nNode, nPos, rExceptWord, cChar, eLang ));
508 }
509 
511 {
513 
515 
516  if( pNd )
517  {
518  SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(
519  pNd->getLayoutFrame(rEditSh.GetLayout())));
520  assert(pFrame);
521  eRet = pFrame->GetLangOfChar(TextFrameIndex(nPos), 0, true);
522  }
523  if(LANGUAGE_SYSTEM == eRet)
524  eRet = GetAppLanguage();
525  return eRet;
526 }
527 
529 {
530  // test only if this is an improvement.
531  // If yes, then add the word to the list.
532  if (m_cChar == cChr && rPos.nNode.GetIndex() == m_nNode && rPos.nContent.GetIndex() == m_nContent)
533  {
534  // get the current autocorrection:
536 
537  // then add to the list:
538  if (ACFlags::CapitalStartWord & m_nFlags)
540  else if (ACFlags::CapitalStartSentence & m_nFlags)
542  }
543 }
544 
546 {
547  bool bRet = false;
548  if (!m_bDeleted && rPos.nNode.GetIndex() == m_nNode && rPos.nContent.GetIndex() == m_nContent)
549  m_bDeleted = bRet = true;
550  return bRet;
551 }
552 
554 {
555 }
556 
558 {
559  const SwTextNode* pTextNd = rPos.nNode.GetNode().GetTextNode();
560  if( pTextNd )
561  {
562  pDontExpItems.reset( new SfxItemSet( const_cast<SwDoc*>(pTextNd->GetDoc())->GetAttrPool(),
564  const sal_Int32 n = rPos.nContent.GetIndex();
565  if (!pTextNd->GetParaAttr( *pDontExpItems, n, n,
566  n != pTextNd->GetText().getLength() ))
567  {
568  pDontExpItems.reset();
569  }
570  }
571 }
572 
574 {
575  SwTextNode* pTextNd = rPos.nNode.GetNode().GetTextNode();
576  if( pTextNd )
577  {
578  const sal_Int32 nStart = rPos.nContent.GetIndex();
579  if( nStart == pTextNd->GetText().getLength() )
580  pTextNd->FormatToTextAttr( pTextNd );
581 
582  if( pTextNd->GetpSwpHints() && pTextNd->GetpSwpHints()->Count() )
583  {
584  const size_t nSize = pTextNd->GetpSwpHints()->Count();
585  sal_Int32 nAttrStart;
586 
587  for( size_t n = 0; n < nSize; ++n )
588  {
589  SwTextAttr* pHt = pTextNd->GetpSwpHints()->Get( n );
590  nAttrStart = pHt->GetStart();
591  if( nAttrStart > nStart ) // beyond the area
592  break;
593 
594  const sal_Int32* pAttrEnd;
595  if( nullptr != ( pAttrEnd = pHt->End() ) &&
596  ( ( nAttrStart < nStart &&
597  ( pHt->DontExpand() ? nStart < *pAttrEnd
598  : nStart <= *pAttrEnd )) ||
599  ( nStart == nAttrStart &&
600  ( nAttrStart == *pAttrEnd || !nStart ))) )
601  {
602  const SfxPoolItem* pItem;
603  if( !pDontExpItems || SfxItemState::SET != pDontExpItems->
604  GetItemState( pHt->Which(), false, &pItem ) ||
605  *pItem != pHt->GetAttr() )
606  {
607  // The attribute was not previously set in this form in the
608  // paragraph, so it can only be created through insert/copy
609  // Because of that it is a candidate for DontExpand
610  pHt->SetDontExpand( true );
611  }
612  }
613  }
614  }
615  }
616 }
617 
618 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool ReplaceRange(sal_Int32 nPos, sal_Int32 nLen, const OUString &rText) override
Definition: acorrect.cxx:179
void merge(RingContainer< value_type > aDestRing)
Merges two ring containers.
Definition: ring.hxx:182
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
void SetDontExpand(bool bDontExpand)
Definition: txatbase.hxx:171
static SvxAutoCorrCfg & Get()
bool GetRanges(std::vector< std::shared_ptr< SwUnoCursor >> &rRanges, SwDoc &rDoc, SwPaM const &rDelPam)
Definition: autofmt.cxx:1116
Marks a position in the document model.
Definition: pam.hxx:35
const OUString & GetText() const
Definition: ndtxt.hxx:210
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:218
SwNodeIndex nNode
Definition: pam.hxx:37
sal_uIntPtr sal_uLong
virtual bool SetINetAttr(sal_Int32 nStt, sal_Int32 nEnd, const OUString &rURL) override
Definition: acorrect.cxx:304
const SwPosition * GetMark() const
Definition: pam.hxx:209
OUString const m_sWord
Definition: acorrect.hxx:95
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1147
sal_Int64 n
Definition: doc.hxx:185
const SvxAutocorrWord * SearchWordsInList(const OUString &rTxt, sal_Int32 &rStt, sal_Int32 nEndPos, SvxAutoCorrDoc &rDoc, LanguageTag &rLang)
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:233
virtual void DeleteRange(SwPaM &)=0
Delete a range SwFlyFrameFormat.
SwNode & GetNode() const
Definition: ndindex.hxx:119
LanguageType const m_eLanguage
Definition: acorrect.hxx:100
virtual bool CopyRange(SwPaM &rPam, SwPosition &rPos, const bool bCopyAll, bool bCheckPos, bool bCopyText) const =0
Copy a selected content range to a position.
sal_uInt16 Which() const
Definition: txatbase.hxx:110
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1280
virtual bool DeleteAndJoin(SwPaM &, const bool bForceJoinNext=false)=0
complete delete of a given PaM
bool AddCplSttException(const OUString &rNew, LanguageType eLang)
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:314
const OUString & GetShort() const
virtual ~SwAutoCorrDoc() override
Definition: acorrect.cxx:95
void MoveTo(value_type *pDestRing)
Removes this item from its current ring container and adds it to another ring container.
Definition: ring.hxx:135
virtual void SaveCpltSttWord(ACFlags nFlag, sal_Int32 nPos, const OUString &rExceptWord, sal_Unicode cChar) override
Definition: acorrect.cxx:500
bool IsTextOnly() const
OUString GetAutoCorrFileName(const LanguageTag &rLanguageTag, bool bNewFile=false, bool bTstUserExist=false, bool bUnlocalized=false) const
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
#define CH_TXTATR_BREAKWORD
Definition: hintids.hxx:136
void DeleteSel(SwPaM &rDelPam)
Definition: acorrect.cxx:103
sal_uInt16 sal_Unicode
ACFlags const m_nFlags
Definition: acorrect.hxx:96
#define CH_TXTATR_INWORD
Definition: hintids.hxx:137
ACFlags
int m_nEndUndoCounter
Definition: acorrect.hxx:53
SwIndex nContent
Definition: pam.hxx:38
size_t pos
void RestoreDontExpandItems(const SwPosition &rPos)
Definition: acorrect.cxx:573
void SetAllScriptItem(SfxItemSet &rSet, const SfxPoolItem &rItem)
Definition: poolfmt.cxx:39
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
sal_Int32 GetStart() const
Definition: txatbase.hxx:82
void SetFormatItemByAutoFormat(const SwPaM &rPam, const SfxItemSet &)
Definition: docfmt.cxx:1793
void SaveDontExpandItems(const SwPosition &rPos)
Definition: acorrect.cxx:557
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
sal_Unicode const m_cChar
Definition: acorrect.hxx:99
void GotoNextLayoutTextFrame(SwNodeIndex &rIndex, SwRootFrame const *const pLayout)
Definition: docnum.cxx:1472
sal_Int32 const m_nContent
Definition: acorrect.hxx:98
SwPaM * GetNext()
Definition: pam.hxx:264
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
virtual bool Insert(sal_Int32 nPos, const OUString &rText) override
Definition: acorrect.cxx:154
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
virtual bool Overwrite(const SwPaM &rRg, const OUString &rStr)=0
Overwrite string in an existing text node.
bool bUndoIdInitialized
Definition: acorrect.hxx:54
size_t Count() const
Definition: ndhints.hxx:142
SwTextAttr * Get(size_t nPos) const
Definition: ndhints.hxx:144
std::unique_ptr< SfxItemSet > pDontExpItems
Definition: acorrect.hxx:37
const SwPosition * GetPoint() const
Definition: pam.hxx:207
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:198
#define LANGUAGE_SYSTEM
bool GetParaAttr(SfxItemSet &rSet, sal_Int32 nStt, sal_Int32 nEnd, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true, const bool bMergeIndentValuesOfNumRule=false, SwRootFrame const *pLayout=nullptr) const
Query the attributes of textnode over the range.
Definition: thints.cxx:2095
SvxAutoCorrect * GetAutoCorrect()
int i
SwDoc * GetDoc()
Definition: node.hxx:702
void DeleteSelImpl(SwPaM &rDelPam)
Definition: acorrect.cxx:121
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:222
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
virtual bool ReplaceRange(SwPaM &rPam, const OUString &rNewStr, const bool bRegExReplace)=0
Replace selected range in a TextNode with string.
ring_container GetRingContainer()
Definition: ring.hxx:240
void CheckChar(const SwPosition &rPos, sal_Unicode cChar)
Definition: acorrect.cxx:528
SwPaM * GetPrev()
Definition: pam.hxx:268
bool AddWrtSttException(const OUString &rNew, LanguageType eLang)
void SetAutoCorrExceptWord(std::unique_ptr< SwAutoCorrExceptWord > pNew)
Definition: docedt.cxx:831
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
virtual OUString const * GetPrevPara(bool bAtNormalPos) override
Return the text of a previous paragraph.
Definition: acorrect.cxx:328
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
virtual LanguageType GetLanguage(sal_Int32 nPos) const override
Definition: acorrect.cxx:510
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:253
bool CheckDelChar(const SwPosition &rPos)
Definition: acorrect.cxx:545
bool DontExpandFormat(const SwPosition &rPos, bool bFlag=true)
Definition: docfmt.cxx:1681
void SetWhich(sal_uInt16 nId)
sal_Int32 GetIndex() const
Definition: index.hxx:95
LanguageType GetAppLanguage()
Definition: init.cxx:729
SwNodes & GetNodes()
Definition: doc.hxx:403
sal_uInt16 const aCharFormatSetRange[]
Definition: init.cxx:245
const sal_Int32 * End() const
Definition: txatbase.hxx:148
virtual bool ChgAutoCorrWord(sal_Int32 &rSttPos, sal_Int32 nEndPos, SvxAutoCorrect &rACorrect, OUString *pPara) override
Definition: acorrect.cxx:359
void * p
SwEditShell & rEditSh
Definition: acorrect.hxx:50
std::unique_ptr< SwNodeIndex > pIdx
Definition: acorrect.hxx:52
bool IsAutoFormatRedline() const
Definition: doc.hxx:1440
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:349
void GotoPrevLayoutTextFrame(SwNodeIndex &rIndex, SwRootFrame const *const pLayout)
Definition: docnum.cxx:1444
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:159
bool DontExpand() const
Definition: txatbase.hxx:92
virtual void SetAttr(sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId, SfxPoolItem &) override
Definition: acorrect.cxx:278
virtual bool Delete(sal_Int32 nStt, sal_Int32 nEnd) override
Definition: acorrect.cxx:139
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:469
const OUString & GetLong() const
void FormatToTextAttr(SwTextNode *pNd)
Convey attributes of an AttrSet (AutoFormat) to SwpHintsArray.
Definition: thints.cxx:2495
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:161
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2062
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
SwAutoCorrDoc(SwEditShell &rEditShell, SwPaM &rPam, sal_Unicode cIns=0)
Definition: acorrect.cxx:87
virtual bool Replace(sal_Int32 nPos, const OUString &rText) override
Definition: acorrect.cxx:174
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1277
sal_uInt16 nPos
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1313
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:842
SwNodeIndex & Assign(SwNodes const &rNds, sal_uLong)
Definition: ndindex.hxx:272