20 #include <com/sun/star/linguistic2/ProofreadingResult.hpp>
21 #include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
22 #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
23 #include <com/sun/star/linguistic2/XLinguProperties.hpp>
24 #include <com/sun/star/text/XFlatParagraph.hpp>
25 #include <com/sun/star/i18n/ScriptType.hpp>
26 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <strings.hrc>
33 #include <osl/diagnose.h>
59 using namespace ::
svx;
70 std::unique_ptr<SwPosition> m_pStart;
71 std::unique_ptr<SwPosition> m_pEnd;
72 std::unique_ptr<SwPosition> m_pCurr;
73 std::unique_ptr<SwPosition> m_pCurrX;
74 sal_uInt16 m_nCursorCount;
81 const SwPosition *GetEnd()
const {
return m_pEnd.get(); }
82 void SetEnd(
SwPosition* pNew) { m_pEnd.reset(pNew); }
84 const SwPosition *GetStart()
const {
return m_pStart.get(); }
85 void SetStart(
SwPosition* pNew) { m_pStart.reset(pNew); }
87 const SwPosition *GetCurr()
const {
return m_pCurr.get(); }
88 void SetCurr(
SwPosition* pNew) { m_pCurr.reset(pNew); }
90 const SwPosition *GetCurrX()
const {
return m_pCurrX.get(); }
91 void SetCurrX(
SwPosition* pNew) { m_pCurrX.reset(pNew); }
93 sal_uInt16& GetCursorCnt() {
return m_nCursorCount; }
98 void End_(
bool bRestoreSelection =
true);
103 struct SpellContentPosition
115 class SwSpellIter :
public SwLinguIter
117 uno::Reference<XSpellChecker1> m_xSpeller;
120 SpellContentPositions m_aLastPositions;
121 bool m_bBackToStartOfSentence;
123 void CreatePortion(uno::Reference< XSpellAlternatives >
const & xAlt,
124 const linguistic2::ProofreadingResult* pGrammarResult,
125 bool bIsField,
bool bIsHidden);
127 void AddPortion(uno::Reference< XSpellAlternatives >
const & xAlt,
128 const linguistic2::ProofreadingResult* pGrammarResult,
129 const SpellContentPositions& rDeletedRedlines);
132 : m_bBackToStartOfSentence(
false)
141 void ToSentenceStart();
143 const SpellContentPositions& GetLastPositions()
const {
return m_aLastPositions; }
147 class SwConvIter :
public SwLinguIter
162 class SwHyphIter :
public SwLinguIter
170 static void DelSoftHyph(
SwPaM &rPam );
174 : m_pLastNode(
nullptr)
175 , m_pLastFrame(
nullptr)
187 static bool IsAuto();
188 void InsertSoftHyph(
const sal_Int32 nHyphPos );
189 void ShowSelection();
198 SwLinguIter::SwLinguIter()
218 OSL_ENSURE(!m_pEnd,
"SwLinguIter::Start_ without End?");
224 bSetCurr =
nullptr != GetCurr();
231 for (n = 0; n < m_nCursorCount; ++n)
263 void SwLinguIter::End_(
bool bRestoreSelection)
268 OSL_ENSURE(m_pEnd,
"SwLinguIter::End_ without end?");
269 if(bRestoreSelection)
271 while (m_nCursorCount--)
293 Start_( pShell, eStart, eEnd );
294 m_aLastPortions.clear();
295 m_aLastPositions.clear();
299 uno::Any SwSpellIter::Continue( sal_uInt16* pPageCnt, sal_uInt16* pPageSt )
310 OSL_ENSURE( GetEnd(),
"SwSpellIter::Continue without start?");
312 uno::Reference< uno::XInterface > xSpellRet;
324 bGoOn = GetCursorCnt() > 1;
330 SetCurr( pNewPoint );
331 SetCurrX( pNewMark );
351 aSpellRet <<= xSpellRet;
360 Start_( pShell, eStart, eEnd );
363 uno::Any SwConvIter::Continue( sal_uInt16* pPageCnt, sal_uInt16* pPageSt )
374 OSL_ENSURE( GetEnd(),
"SwConvIter::Continue() without Start?");
387 uno::Reference< linguistic2::XSpellChecker1 > xEmpty;
392 bGoOn = GetCursorCnt() > 1;
393 if( !aConvText.isEmpty() )
399 SetCurr( pNewPoint );
400 SetCurrX( pNewMark );
420 return Any( aConvText );
423 bool SwHyphIter::IsAuto()
426 return xProp.is() && *o3tl::doAccess<bool>(xProp->getPropertyValue(
430 void SwHyphIter::ShowSelection()
445 if( GetSh() || GetEnd() )
447 OSL_ENSURE( !GetSh(),
"SwHyphIter::Start: missing HyphEnd()" );
454 Start_( pShell, eStart, eEnd );
458 void SwHyphIter::End()
462 GetSh()->GetViewOptions()->SetIdle(m_bOldIdle);
466 uno::Any SwHyphIter::Continue( sal_uInt16* pPageCnt, sal_uInt16* pPageSt )
473 const bool bAuto = IsAuto();
474 uno::Reference< XHyphenatedWord > xHyphWord;
479 OSL_ENSURE( GetEnd(),
"SwHyphIter::Continue without Start?" );
489 if ( *pCursor->
End() <= *GetEnd() )
491 *pCursor->
GetMark() = *GetEnd();
499 if( bAuto && xHyphWord.is() )
503 }
while( bAuto && xHyphWord.is() );
504 bGoOn = !xHyphWord.is() && GetCursorCnt() > 1;
518 aHyphRet <<= xHyphWord;
523 void SwHyphIter::Ignore()
529 DelSoftHyph( *pCursor );
536 void SwHyphIter::DelSoftHyph(
SwPaM &rPam )
545 void SwHyphIter::InsertSoftHyph(
const sal_Int32 nHyphPos )
548 OSL_ENSURE( pMySh,
"SwHyphIter::InsertSoftHyph: missing HyphStart()");
559 if( pSttPos->
nNode != pEndPos->
nNode || !nLastHyphLen )
562 "SwHyphIter::InsertSoftHyph: node warp during hyphenation" );
563 OSL_ENSURE(nLastHyphLen,
"SwHyphIter::InsertSoftHyph: missing HyphContinue()");
571 DelSoftHyph( *pCursor );
573 SwPaM aRg( *pSttPos );
588 if (pNode != g_pHyphIter->m_pLastNode || !g_pHyphIter->m_pLastFrame)
590 g_pHyphIter->m_pLastNode = pNode;
591 g_pHyphIter->m_pLastFrame = create();
593 return g_pHyphIter->m_pLastFrame;
600 bool bTextWasGrammarChecked =
false;
604 for (
size_t i = 0;
i < aLastPortions.size() && !bTextWasGrammarChecked; ++
i)
609 if (aLastPortions[
i].bIsGrammarError)
610 bTextWasGrammarChecked =
true;
613 return bTextWasGrammarChecked;
638 SwLinguIter *pLinguIter =
nullptr;
641 if (!pConvArgs && !g_pSpellIter)
643 g_pSpellIter =
new SwSpellIter;
647 if (pConvArgs && !g_pConvIter)
649 g_pConvIter =
new SwConvIter( *pConvArgs );
659 pLinguIter->SetCurr( pTmp );
662 pLinguIter->SetCurrX( pTmp );
665 if (!pConvArgs && g_pSpellIter)
666 g_pSpellIter->Start(
this, eStart, eEnd );
667 if (pConvArgs && g_pConvIter)
668 g_pConvIter->Start(
this, eStart, eEnd );
673 if (!pConvArgs && g_pSpellIter && g_pSpellIter->GetSh() ==
this)
675 g_pSpellIter->End_(bRestoreSelection);
677 g_pSpellIter =
nullptr;
679 if (pConvArgs && g_pConvIter && g_pConvIter->GetSh() ==
this)
683 g_pConvIter =
nullptr;
689 sal_uInt16* pPageCnt, sal_uInt16* pPageSt,
694 if ((!pConvArgs && g_pSpellIter->GetSh() !=
this) ||
695 ( pConvArgs && g_pConvIter->GetSh() !=
this))
698 if( pPageCnt && !*pPageCnt )
701 nEndPage += nEndPage * 10 / 100;
702 *pPageCnt = nEndPage;
707 OSL_ENSURE( pConvArgs || g_pSpellIter,
"SpellIter missing" );
708 OSL_ENSURE( !pConvArgs || g_pConvIter,
"ConvIter missing" );
713 uno::Reference< uno::XInterface > xRet;
716 g_pConvIter->Continue( pPageCnt, pPageSt ) >>= aRet;
721 g_pSpellIter->Continue( pPageCnt, pPageSt ) >>= xRet;
726 if( !aRet.isEmpty() || xRet.is() )
763 g_pHyphIter =
new SwHyphIter;
764 g_pHyphIter->Start(
this, eStart, eEnd );
772 if (g_pHyphIter->GetSh() ==
this)
776 g_pHyphIter =
nullptr;
781 uno::Reference< uno::XInterface >
785 if (g_pHyphIter->GetSh() !=
this)
788 if( pPageCnt && !*pPageCnt && !*pPageSt )
791 nEndPage += nEndPage * 10 / 100;
794 *pPageCnt = nEndPage;
804 uno::Reference< uno::XInterface > xRet;
805 g_pHyphIter->Continue( pPageCnt, pPageSt ) >>= xRet;
809 g_pHyphIter->ShowSelection();
821 g_pHyphIter->InsertSoftHyph( nHyphPos );
831 g_pHyphIter->Ignore();
834 g_pHyphIter->ShowSelection();
838 sal_Int32 nLen,
const Point* pPt,
851 : rNode.GetTextNode()->Len();
862 pChar = aText.getLength() ? aText.getStr() + aText.getLength() - 1 :
nullptr;
863 sal_Int32 nRight = 0;
873 const sal_Int32 nWordStart = (nBegin + nLeft) < nLineStart ? nLineStart : nBegin + nLeft;
875 const sal_Int32 nWordEnd = (nBegin + nLen - nLeft - nRight) > nLineEnd
876 ? nLineEnd : (nBegin + nLen - nLeft - nRight);
880 rContent = nWordStart;
885 std::pair<Point, bool> tmp;
894 rContent = nWordEnd - 1;
897 rSelectRect = aStartRect.
Union( aEndRect );
909 uno::Reference< XSpellAlternatives >
912 uno::Reference< XSpellAlternatives > xSpellAlt;
921 if (pPt &&
GetLayout()->GetModelPositionForViewPoint( &aPos, *const_cast<Point*>(pPt), &eTmpState ))
923 if (
nullptr == pNode)
925 if (
nullptr != pNode)
929 sal_Int32 nBegin = aPos.nContent.GetIndex();
933 const OUString aText(pNode->
GetText().copy(nBegin, nLen));
939 auto const nBeginView(aConversionMap.ConvertToViewPosition(nBegin));
940 OUString
const aWord(aConversionMap.getViewText().copy(nBeginView,
941 aConversionMap.ConvertToViewPosition(nBegin+nLen) - nBeginView));
947 if( xSpell->hasLanguage( static_cast<sal_uInt16>(eActLang) ))
961 xSpellAlt = xSpell->spell( aWord, static_cast<sal_uInt16>(eActLang), aPropVals );
965 if ( xSpellAlt.is() )
975 linguistic2::ProofreadingResult &rResult,
976 sal_Int32 &rErrorPosInText,
977 sal_Int32 &rErrorIndexInResult,
978 uno::Sequence< OUString > &rSuggestions,
979 const Point *pPt,
SwRect &rSelectRect )
991 if (pPt &&
GetLayout()->GetModelPositionForViewPoint( &aPos, *const_cast<Point*>(pPt), &eTmpState ))
993 if (
nullptr == pNode)
995 if (
nullptr != pNode)
999 sal_Int32 nBegin = aPos.nContent.GetIndex();
1003 const OUString aText(pNode->
GetText().copy(nBegin, nLen));
1005 uno::Reference< linguistic2::XProofreadingIterator > xGCIterator(
mxDoc->GetGCIterator() );
1006 if (xGCIterator.is())
1008 uno::Reference< lang::XComponent > xDoc =
mxDoc->GetDocShell()->GetBaseModel();
1012 const OUString& aExpandText = aConversionMap.
getViewText();
1014 uno::Reference< text::XFlatParagraph > xFlatPara =
new SwXFlatParagraph( *pNode, aExpandText, aConversionMap );
1022 rResult = xGCIterator->checkSentenceAtPosition(
1023 xDoc, xFlatPara, aExpandText, lang::Locale(), nStartOfSentence,
1024 nEndOfSentence ==
COMPLETE_STRING ? aExpandText.getLength() : nEndOfSentence,
1029 rSuggestions.realloc( 0 );
1031 auto pError = std::find_if(std::cbegin(rResult.aErrors), std::cend(rResult.aErrors),
1032 [rErrorPosInText, nLen](
const linguistic2::SingleProofreadingError &rError) {
1033 return rError.nErrorStart <= rErrorPosInText
1034 && rErrorPosInText + nLen <= rError.nErrorStart + rError.nErrorLength; });
1035 if (pError != std::cend(rResult.aErrors))
1037 rSuggestions = pError->aSuggestions;
1038 rErrorIndexInResult =
static_cast<sal_Int32
>(std::distance(std::cbegin(rResult.aErrors), pError));
1042 if (rResult.aErrors.hasElements())
1054 OSL_ENSURE( g_pSpellIter,
"SpellIter missing" );
1057 bool bRet = g_pSpellIter->SpellSentence(rPortions, bIsGrammarCheck);
1069 OSL_ENSURE( g_pSpellIter,
"SpellIter missing" );
1072 g_pSpellIter->ToSentenceStart();
1077 return static_cast<sal_uInt32
>(std::count_if(rLastPortions.begin(), rLastPortions.end(),
1087 g_pSpellIter->SetCurr(
new SwPosition( *g_pSpellIter->GetCurrX() ) );
1096 OSL_ENSURE( g_pSpellIter,
"SpellIter missing" );
1097 if (!g_pSpellIter ||
1098 g_pSpellIter->GetLastPortions().empty())
1101 const SpellPortions& rLastPortions = g_pSpellIter->GetLastPortions();
1102 const SpellContentPositions rLastPositions = g_pSpellIter->GetLastPositions();
1103 OSL_ENSURE(!rLastPortions.empty() &&
1104 rLastPortions.size() == rLastPositions.size(),
1105 "last vectors of spelling results are not set or not equal");
1119 if((rLastPortions.size() - nRedlinePortions) == rNewPortions.size())
1121 OSL_ENSURE( !rNewPortions.empty(),
"rNewPortions should not be empty here" );
1122 OSL_ENSURE( !rLastPortions.empty(),
"rLastPortions should not be empty here" );
1123 OSL_ENSURE( !rLastPositions.empty(),
"rLastPositions should not be empty here" );
1127 svx::SpellPortions::const_iterator aCurrentNewPortion = rNewPortions.end();
1128 SpellPortions::const_iterator aCurrentOldPortion = rLastPortions.end();
1129 SpellContentPositions::const_iterator aCurrentOldPosition = rLastPositions.end();
1132 --aCurrentNewPortion;
1133 --aCurrentOldPortion;
1134 --aCurrentOldPosition;
1136 while(aCurrentOldPortion->bIsHidden)
1138 if (aCurrentOldPortion != rLastPortions.begin() &&
1139 aCurrentOldPosition != rLastPositions.begin())
1141 --aCurrentOldPortion;
1142 --aCurrentOldPosition;
1146 OSL_FAIL(
"ApplyChangedSentence: iterator positions broken" );
1161 if(aCurrentNewPortion->sText != aCurrentOldPortion->sText)
1165 if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage)
1167 mxDoc->getIDocumentContentOperations().ReplaceRange(*pCursor, aCurrentNewPortion->sText,
false);
1169 else if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage)
1174 else if( aCurrentNewPortion->bIgnoreThisError )
1178 OSL_FAIL(
"TODO: add ignore mark to text node");
1181 while(aCurrentNewPortion != rNewPortions.begin());
1185 OSL_ENSURE( !rLastPositions.empty(),
"rLastPositions should not be empty here" );
1188 SpellContentPositions::const_iterator aCurrentEndPosition = rLastPositions.end();
1189 --aCurrentEndPosition;
1190 SpellContentPositions::const_iterator aCurrentStartPosition = rLastPositions.begin();
1195 mxDoc->getIDocumentContentOperations().DeleteAndJoin(*pCursor);
1196 for(
const auto& rCurrentNewPortion : rNewPortions)
1210 if(rLang.
GetLanguage() != rCurrentNewPortion.eLanguage)
1213 mxDoc->getIDocumentContentOperations().InsertString(*pCursor, rCurrentNewPortion.sText);
1216 *pCursor->
Start() = *pCursor->
End();
1226 *pCursor->
Start() = *pCursor->
End();
1244 SpellContentPositions aRedlines;
1262 if( RedlineType::Delete == pRed->
GetType() )
1264 sal_Int32 nStart_, nEnd_;
1266 sal_Int32 nStart = nStart_;
1267 sal_Int32 nEnd = nEnd_;
1268 if(nStart >= nStartIndex || nEnd >= nStartIndex)
1270 SpellContentPosition aAdd;
1271 aAdd.nLeft = nStart;
1273 aRedlines.push_back(aAdd);
1284 if(!aDeletedRedlines.empty())
1289 while(!aDeletedRedlines.empty() &&
1290 aDeletedRedlines.back().nLeft > nEnd)
1292 aDeletedRedlines.pop_back();
1298 const SpellContentPositions& rDeletedRedlines,
1299 sal_Int32 nSearchFrom )
1301 SpellContentPosition aRet;
1303 if(!rDeletedRedlines.empty())
1305 auto aIter = std::find_if_not(rDeletedRedlines.begin(), rDeletedRedlines.end(),
1306 [nSearchFrom](
const SpellContentPosition& rPos) {
return rPos.nLeft < nSearchFrom; });
1307 if (aIter != rDeletedRedlines.end())
1316 m_aLastPortions.clear();
1317 m_aLastPositions.clear();
1323 OSL_ENSURE( GetEnd(),
"SwSpellIter::SpellSentence without Start?");
1325 uno::Reference< XSpellAlternatives > xSpellRet;
1326 linguistic2::ProofreadingResult aGrammarResult;
1328 bool bGrammarErrorFound =
false;
1335 *pCursor->
GetMark() = *GetEnd();
1337 if (m_bBackToStartOfSentence)
1340 m_bBackToStartOfSentence =
false;
1344 aSpellRet >>= xSpellRet;
1345 aSpellRet >>= aGrammarResult;
1346 bGoOn = GetCursorCnt() > 1;
1347 bGrammarErrorFound = aGrammarResult.aErrors.hasElements();
1348 if( xSpellRet.is() || bGrammarErrorFound )
1354 SetCurr( pNewPoint );
1355 SetCurrX( pNewMark );
1376 if(xSpellRet.is() || bGrammarErrorFound)
1392 AddPortion(
nullptr,
nullptr, aDeletedRedlines);
1395 *pCursor->
GetPoint() = *GetCurrX();
1396 *pCursor->
GetMark() = *GetCurr();
1397 AddPortion(xSpellRet, &aGrammarResult, aDeletedRedlines);
1409 if( bGrammarErrorFound )
1412 const OUString& aExpandText = aConversionMap.
getViewText();
1413 sal_Int32 nSentenceEnd =
1414 aConversionMap.ConvertToViewPosition( aGrammarResult.nBehindEndOfSentencePosition );
1416 if( aExpandText[nSentenceEnd - 1] ==
' ' )
1431 *pCursor->
GetPoint() = aSaveStartPos;
1432 *pCursor->
GetMark() = *GetEnd();
1436 if( !bGrammarErrorFound )
1440 xSpellRet =
nullptr;
1442 pMySh->
GetDoc()->
Spell(*pCursor, m_xSpeller,
nullptr,
nullptr,
false,
1453 *pCursor->
GetPoint() = aSaveStartPos;
1454 *pCursor->
GetMark() = *GetCurr();
1457 AddPortion(
nullptr,
nullptr, aDeletedRedlines);
1462 *pCursor->
GetMark() = *GetCurrX();
1463 AddPortion(xSpellRet,
nullptr, aDeletedRedlines);
1465 *pCursor->
GetPoint() = *GetCurrX();
1467 aSaveStartPos = *GetCurrX();
1469 *pCursor->
GetMark() = *GetEnd();
1472 if(*GetCurrX() >= *GetEnd())
1475 while(xSpellRet.is());
1488 if(*GetCurrX() < *GetEnd())
1490 AddPortion(
nullptr,
nullptr, aDeletedRedlines);
1493 *pCursor->
GetMark() = *GetEnd();
1494 if( !bIsGrammarCheck )
1501 rPortions = m_aLastPortions;
1514 void SwSpellIter::ToSentenceStart() { m_bBackToStartOfSentence =
true; }
1534 void SwSpellIter::CreatePortion(uno::Reference< XSpellAlternatives >
const & xAlt,
1535 const linguistic2::ProofreadingResult* pGrammarResult,
1536 bool bIsField,
bool bIsHidden)
1540 GetSh()->GetSelectedText( sText );
1546 aPortion.
sText = xAlt->getWord();
1547 else if(pGrammarResult)
1550 if(pGrammarResult->aErrors.hasElements())
1555 auto pProperty = std::find_if(std::cbegin(pGrammarResult->aProperties), std::cend(pGrammarResult->aProperties),
1556 [](
const beans::PropertyValue& rProperty) { return rProperty.Name ==
"DialogTitle"; });
1557 if (pProperty != std::cend(pGrammarResult->aProperties))
1562 aPortion.
sText = sText;
1567 SpellContentPosition aPosition;
1568 SwPaM *pCursor = GetSh()->GetCursor();
1571 m_aLastPortions.push_back(aPortion);
1572 m_aLastPositions.push_back(aPosition);
1575 void SwSpellIter::AddPortion(uno::Reference< XSpellAlternatives >
const & xAlt,
1576 const linguistic2::ProofreadingResult* pGrammarResult,
1577 const SpellContentPositions& rDeletedRedlines)
1585 if(xAlt.is() || pGrammarResult !=
nullptr)
1587 CreatePortion(xAlt, pGrammarResult,
false,
false);
1591 SwPaM *pCursor = GetSh()->GetCursor();
1603 rDeletedRedlines, aStart.nContent.GetIndex() );
1604 if( aNextRedline.nLeft == aStart.nContent.GetIndex() )
1607 const sal_Int32 nEnd = aEnd.nContent.GetIndex() < aNextRedline.nRight ?
1608 aEnd.nContent.GetIndex() : aNextRedline.nRight;
1610 CreatePortion(xAlt, pGrammarResult,
false,
true);
1611 aStart = *pCursor->
End();
1614 rDeletedRedlines, aStart.nContent.GetIndex() );
1622 bool bField =
false;
1630 const sal_uInt16 nWhich = pTextAttr
1631 ? pTextAttr->
Which()
1655 if(bField || bRedline || eCurLanguage != eStartLanguage)
1657 eStartLanguage = eCurLanguage;
1661 if(eCurLanguage != eStartLanguage || bField)
1667 if(*pCursor->
Start() != *pCursor->
End())
1668 CreatePortion(xAlt, pGrammarResult,
false,
false);
1669 aStart = *pCursor->
End();
1675 CreatePortion(xAlt, pGrammarResult,
true,
false);
1676 aStart = *pCursor->
End();
1685 aEnd.nContent.GetIndex() : aNextRedline.nRight;
1687 CreatePortion(xAlt, pGrammarResult,
false,
true);
1688 aStart = *pCursor->
End();
1691 rDeletedRedlines, aStart.nContent.GetIndex() );
1697 CreatePortion(xAlt, pGrammarResult,
false,
false);
1709 while( aIdx <= aEndIdx )
1713 if( aIdx == aEndIdx )
Represents the visualization of a paragraph.
std::function< SwTextFrame *()> Creator
do not expand to content, but replace with zwsp
SwNode & GetNode(bool bPoint=true) const
Marks a position in the document model.
void DelSoftHyph(const sal_Int32 nStart, const sal_Int32 nEnd)
void FillFindPos(SwDocPositions ePos, SwPosition &rPos) const
SwRect & Union(const SwRect &rRect)
const OUString & GetText() const
static bool HasConvIter()
Is text conversion active somewhere else?
css::uno::Any Spell(SwPaM &, css::uno::Reference< css::linguistic2::XSpellChecker1 > const &, sal_uInt16 *pPageCnt, sal_uInt16 *pPageSt, bool bGrammarCheck, SwRootFrame const *pLayout, SwConversionArgs *pConvArgs=nullptr) const
Operations on the content of the document e.g.
void GetSelectedText(OUString &rBuf, ParaBreakType nHndlParaBreak=ParaBreakType::ToBlank)
Query text within selection.
static void repaintTextFrames(const SwTextNode &rNode)
Repaint all text frames of the given text node.
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
static bool HasLastSentenceGotGrammarChecked()
Check SwSpellIter data to see if the last sentence got grammar checked.
const SwPosition * GetMark() const
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
bool SpellSentence(svx::SpellPortions &rToFill, bool bIsGrammarCheck)
Spells on a sentence basis - the SpellPortions are needed.
bool m_bRealWidth
Calculation of the width required.
void CalcStartEnd(SwNodeOffset nNdIdx, sal_Int32 &rStart, sal_Int32 &rEnd) const
Calculates the intersection with text node number nNdIdx.
css::uno::Reference< css::linguistic2::XProofreader > xGrammarChecker
void DestroyCursor()
transform TableCursor to normal cursor, nullify Tablemode
void Pos(const Point &rNew)
IDocumentMarkAccess * getIDocumentMarkAccess()
Dialog to specify the properties of date form field.
void HyphIgnore()
ignore hyphenation
Of course Writer needs its own rectangles.
void ApplyChangedSentence(const svx::SpellPortions &rNewPortions, bool bRecheck)
Applies a changed sentence.
static bool HasHyphIter()
Is hyphenation active somewhere else?
void StartProgress(TranslateId pMessResId, tools::Long nStartValue, tools::Long nEndValue, SwDocShell *pDocShell)
IDocumentContentOperations const & getIDocumentContentOperations() const
virtual ::sw::mark::IFieldmark * getDropDownFor(const SwPosition &pos) const =0
void RemoveEntry(sal_Int32 nBegin, sal_Int32 nEnd)
#define CH_TXT_ATR_FORMELEMENT
static SwConvIter * g_pConvIter
bool HasSelection() const
Does the current cursor create a selection?
static bool IsShowChanges(const RedlineFlags eM)
bool IsSymbolAt(sal_Int32 nBegin) const
in ndcopy.cxx
SwMoveFnCollection const & MakeFindRange(SwDocPositions, SwDocPositions, SwPaM *) const
SwContentNode * GetContentNode(bool bPoint=true) const
SwTextAttr * GetTextAttrForCharAt(const sal_Int32 nIndex, const sal_uInt16 nWhich=RES_TXTATR_END) const
get the text attribute at position nIndex which owns the dummy character CH_TXTATR_* at that position...
#define CH_TXTATR_BREAKWORD
void HyphStart(SwDocPositions eStart, SwDocPositions eEnd)
Save selections.
static void InsertSoftHyph(const sal_Int32 nHyphPos)
For Inserting SoftHyphen. Position is offset within the syllabificated word.
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(59)
rtl::Reference< SwDoc > mxDoc
The document; never 0.
sal_Int32 ConvertToViewPosition(sal_Int32 nModelPos) const
Converts a model position into a view position.
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
css::uno::Reference< css::uno::XInterface > HyphContinue(sal_uInt16 *pPageCnt, sal_uInt16 *pPageSt)
sal_Int16 GetI18NScriptTypeOfLanguage(LanguageType nLang)
virtual bool GetCharRect(SwRect &, const SwPosition &, SwCursorMoveState *=nullptr, bool bAllowFarAway=true) const
constexpr OUStringLiteral UPN_MAX_NUMBER_OF_SUGGESTIONS
bool GetGrammarCorrection(css::linguistic2::ProofreadingResult &rResult, sal_Int32 &rErrorPosInText, sal_Int32 &rErrorIndexInResult, css::uno::Sequence< OUString > &rSuggestions, const Point *pPt, SwRect &rSelectRect)
PaM is Point and Mark: a selection of the document model.
const SfxItemPool & GetAttrPool() const
virtual SwRedlineTable::size_type GetRedlinePos(const SwNode &rNode, RedlineType nType) const =0
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
const OUString & getViewText() const
SvtScriptType GetScriptType() const
returns the script type of the selection
void SpellEnd(SwConversionArgs const *pConvArgs=nullptr, bool bRestoreSelection=true)
Restore selections.
const SwPosition * GetPoint() const
SwIndex & Assign(SwIndexReg *, sal_Int32)
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(58)
void Push()
store a copy of the current cursor on the cursor stack
void SetAttrItem(const SfxPoolItem &, SetAttrMode nFlags=SetAttrMode::DEFAULT, const bool bParagraphSetting=false)
SwContentNode * GetContentNode()
SwNodeOffset GetIndex() const
css::uno::Reference< css::linguistic2::XSpellAlternatives > GetCorrection(const Point *pPt, SwRect &rSelectRect)
Get a list of potential corrections for misspelled word.
vector_type::size_type size_type
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
css::uno::Any SpellContinue(sal_uInt16 *pPageCnt, sal_uInt16 *pPageSt, SwConversionArgs const *pConvArgs)
bool RightMargin(bool bAPI=false)
Marks a character position inside a document model node.
SwGrammarMarkUp * GetGrammarCheck()
sal_uInt16 GetCursorCnt(bool bAll=true) const
Get the number of elements in the ring of cursors.
Marks a node in the document model.
static LanguageType lcl_GetLanguage(SwEditShell &rSh)
static SpellContentPositions lcl_CollectDeletedRedlines(SwEditShell const *pSh)
Collect all deleted redlines of the current text node beginning at the start of the cursor position...
void TableCursorToCursor()
enter block mode, change normal cursor into block cursor
stay with the cursor inside text
const SwPosition * Start() const
void HandleCorrectionError(const OUString &aText, SwPosition aPos, sal_Int32 nBegin, sal_Int32 nLen, const Point *pPt, SwRect &rSelectRect)
static void MoveContinuationPosToEndOfCheckedSentence()
Moves the continuation position to the end of the currently checked sentence.
bool IsInProtectSect() const
Is node in a protected area?
void SetLinguRange(SwDocPositions eStart, SwDocPositions eEnd)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(60)
uno::Reference< linguistic2::XSpellChecker1 > GetSpellChecker()
const sal_uInt16 CRSR_SKIP_CELLS
static SwSpellIter * g_pSpellIter
sal_Int32 getSentenceStart(sal_Int32 nPos)
SwTextNode is a paragraph in the document model.
LanguageType GetLanguage() const
ExpandMode
Some helpers for converting model strings to view strings.
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
constexpr sal_uInt16 RES_TXTATR_END(RES_TXTATR_NOEND_END)
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
const SwViewOption * GetViewOptions() const
bool ExtendSelection(bool bEnd=true, sal_Int32 nCount=1)
extend current SSelection by n characters
void SetIdle(bool b) const
std::vector< SpellContentPosition > SpellContentPositions
css::uno::Reference< css::linguistic2::XSpellAlternatives > xAlternatives
sal_Int32 GetIndex() const
bool InWrongWord(sal_Int32 &rChk, sal_Int32 &rLn) const
If a word is incorrectly selected, this method returns begin and length of it.
static SwHyphIter * g_pHyphIter
const SwPosition * End() const
static void IgnoreGrammarErrorAt(SwPaM &rErrorPosition)
void SpellStart(SwDocPositions eStart, SwDocPositions eEnd, SwDocPositions eCurr, SwConversionArgs *pConvArgs=nullptr)
Functions used for spell checking and text conversion.
LanguageType GetLang(const sal_Int32 nBegin, const sal_Int32 nLen=0, sal_uInt16 nScript=0) const
const SwRect & GetCharRect() const
RedlineType GetType(sal_uInt16 nPos=0) const
void HyphEnd()
restore selections.
static SpellContentPosition lcl_FindNextDeletedRedline(const SpellContentPositions &rDeletedRedlines, sal_Int32 nSearchFrom)
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
static sal_uInt32 lcl_CountRedlines(const svx::SpellPortions &rLastPortions)
sal_Int32 getSentenceEnd(sal_Int32 nPos)
css::linguistic2::SingleProofreadingError aGrammarError
constexpr sal_Int32 COMPLETE_STRING
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
static void PutSpellingToSentenceStart()
Make SpellIter start with the current sentence when called next time.
std::vector< SpellPortion > SpellPortions
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
SwTextFrame * SwHyphIterCacheLastTextFrame(SwTextNode const *pNode, const sw::Creator &create)
bool Pop(PopMode)
delete cursor
static void lcl_CutRedlines(SpellContentPositions &aDeletedRedlines, SwEditShell const *pSh)
remove the redline positions after the current selection
virtual const SwRedlineTable & GetRedlineTable() const =0
SwRootFrame * GetLayout() const
sal_uInt16 GetPageNum() const
uno::Reference< linguistic2::XLinguProperties > GetLinguPropertySet()
sal_uInt16 mnStartAction
!= 0 if at least one Action is active.
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
css::uno::Reference< css::linguistic2::XHyphenatedWord > Hyphenate(SwPaM *pPam, const Point &rCursorPos, sal_uInt16 *pPageCnt, sal_uInt16 *pPageSt)
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
void EndAction(const bool bIdleEnd=false)
Base class of the Writer document model elements.