20#include <config_wasm_strip.h>
34#include <osl/diagnose.h>
35#include <officecfg/Office/Writer.hxx>
70#include <unicode/uchar.h>
73#include <com/sun/star/i18n/WordType.hpp>
74#include <com/sun/star/i18n/ScriptType.hpp>
75#include <com/sun/star/i18n/XBreakIterator.hpp>
91 void DetectAndMarkMissingDictionaries(
SwDoc& rDoc,
92 const uno::Reference< XSpellChecker1 >& xSpell,
95 if( xSpell.is() && !xSpell->hasLanguage( eActLang.
get() ) )
105 while (nPosition != -1)
118 return '#' == c ||
'$' == c ||
'%' == c ||
'&' == c ||
'+' == c ||
119 ',' == c ||
'-' == c ||
'.' == c ||
'/' == c ||
':' == c ||
120 ';' == c ||
'=' == c ||
'?' == c ||
'@' == c ||
'_' == c;
125 SwTextNode &rNode, sal_Int32 nBegin, sal_Int32 nLen)
132 const size_t nPosAt = rWord.find(
'.');
133 if (nPosAt != std::u16string_view::npos && nPosAt < rWord.length() - 1)
137 if ( rWord.find(
'@') != std::u16string_view::npos )
140 const OUString& rText = rNode.
GetText();
144 if ( nBegin + nLen + 2 <= rText.getLength() &&
':' == rText[nBegin + nLen] )
153 if ( 2 <= nBegin &&
lcl_IsDelim(rText[nBegin - 1]) )
170 sal_Int32 nStt, sal_Int32 nEnd,
173 sal_Int32 nNumOfMaskedRedlines = 0;
184 if( RedlineType::Delete == pRed->
GetType() )
186 sal_Int32 nRedlineEnd;
187 sal_Int32 nRedlineStart;
191 if ( nRedlineEnd < nStt || nRedlineStart > nEnd )
194 while ( nRedlineStart < nRedlineEnd && nRedlineStart < nEnd )
196 if (nRedlineStart >= nStt)
198 rText[nRedlineStart] = cChar;
199 ++nNumOfMaskedRedlines;
206 return nNumOfMaskedRedlines;
214 sal_Int32 nStt, sal_Int32 nEnd,
217 sal_Int32 nRedlinesMasked = 0;
218 sal_Int32 nHiddenCharsMasked = 0;
240 return (nRedlinesMasked > 0) || (nHiddenCharsMasked > 0);
248 sal_Int32
const nChgStart, sal_Int32
const nChgEnd)
257 while( pStartFrame->HasFollow() &&
261 while( pEndFrame->HasFollow() &&
265 bool bSameFrame =
true;
267 if( rTextFrame.HasFollow() )
269 if( pEndFrame != pStartFrame )
282 aRectFnSet.
SetTop( aRect, aRectFnSet.
GetTop(aStFrame) );
290 if( pStartFrame == pEndFrame )
299 if( aRectFnSet.
GetTop(aTmp) == aRectFnSet.
GetTop(aRect) )
323 std::shared_ptr<SfxItemSet>& pStyleHandle )
327 std::unique_ptr<SfxItemSet> pNewSet;
331 OSL_ENSURE( nWhichId,
"lcl_HaveCommonAttributes not used correctly" );
332 if ( SfxItemState::SET == rSet2.
GetItemState( nWhichId,
false ) )
334 pNewSet = rSet2.
Clone();
335 pNewSet->ClearItem( nWhichId );
338 else if ( pSet1->
Count() )
347 pNewSet = rSet2.
Clone();
348 pNewSet->ClearItem( pItem->
Which() );
357 if ( pNewSet->Count() )
390 const sal_Int32 nLen,
391 const sal_uInt16 nWhich,
393 const bool bInclRefToxMark,
394 const bool bExactRange )
399 sal_Int32 nEnd = nStt + nLen;
403 if ( pTextInputField ==
nullptr )
407 if ( pTextInputField !=
nullptr )
409 if ( nStt > pTextInputField->
GetStart() )
413 if ( nEnd < *(pTextInputField->
End()) )
415 nEnd = *(pTextInputField->
End());
420 bool bChanged =
false;
423 sal_Int32 nMin =
m_Text.getLength();
424 sal_Int32 nMax = nStt;
425 const bool bNoLen = nMin == 0;
429 std::vector<SwTextAttr *> newAttributes;
430 std::vector<SwTextAttr *> delAttributes;
435 sal_Int32 nAttrStart = sal_Int32();
437 while ( (i < m_pSwpHints->
Count())
438 && ( ( ( nAttrStart =
m_pSwpHints->GetWithoutResorting(
i)->GetStart()) < nEnd )
439 || nLen==0 || (nEnd == nAttrStart && nAttrStart ==
m_Text.getLength()))
446 const sal_Int32*
const pAttrEnd = pHt->
GetEnd();
447 const bool bKeepAttrWithoutEnd =
449 && ( !bInclRefToxMark
454 if ( bKeepAttrWithoutEnd )
468 bool bSkipAttr =
false;
469 std::shared_ptr<SfxItemSet> pStyleHandle;
486 bSkipAttr = nWhich != pHt->
Which();
492 else if ( !bInclRefToxMark )
509 if (nStt <= nAttrStart)
511 const sal_Int32 nAttrEnd = pAttrEnd !=
nullptr
514 if (nEnd > nAttrStart
515 || (nEnd == nAttrEnd && nEnd == nAttrStart))
517 if ( nMin > nAttrStart )
519 if ( nMax < nAttrEnd )
522 bChanged = bChanged || nEnd > nAttrStart || bNoLen;
523 if (nAttrEnd <= nEnd)
525 delAttributes.push_back(pHt);
530 *pStyleHandle, nAttrStart, nAttrEnd );
531 newAttributes.push_back(pNew);
542 if ( pStyleHandle && nAttrStart < nEnd )
545 *pStyleHandle, nAttrStart, nEnd );
546 newAttributes.push_back(pNew);
551 else if (pAttrEnd !=
nullptr)
553 if (*pAttrEnd > nStt)
555 if (*pAttrEnd < nEnd)
557 if ( nMin > nAttrStart )
559 if ( nMax < *pAttrEnd )
563 const sal_Int32 nAttrEnd = *pAttrEnd;
573 *pStyleHandle, nStt, nAttrEnd );
574 newAttributes.push_back(pNew);
581 if ( nMin > nAttrStart )
583 if ( nMax < *pAttrEnd )
586 const sal_Int32 nTmpEnd = *pAttrEnd;
592 if ( pStyleHandle && nStt < nEnd )
595 *pStyleHandle, nStt, nEnd );
596 newAttributes.push_back(pNew);
602 pHt->
GetAttr(), nEnd, nTmpEnd );
609 newAttributes.push_back(pNew);
628 const sal_Int32* pHintEnd = pHint->
GetEnd();
629 if (!pHintEnd || *pHintEnd != nEnd)
632 delAttributes.push_back(pHint);
636 if (bChanged && !delAttributes.empty())
693 OUString
const& rText(
GetText());
694 assert(sal_Int32(
nPos) <= rText.getLength());
701 sal_Int16 nWordType = WordType::DICTIONARY_WORD;
704 rxBreak->getWordBoundary(rText, sal_Int32(
nPos), aLocale, nWordType,
true);
707 if (aBndry.startPos == aBndry.endPos)
709 aBndry = rxBreak->previousWord(rText, sal_Int32(
nPos), aLocale, nWordType);
714 if (aBndry.endPos != aBndry.startPos
717 aBndry.endPos = aBndry.startPos;
724 return rText.copy(aBndry.startPos,
725 aBndry.endPos - aBndry.startPos);
730 sal_uInt16 nType, sal_Int32 nStart, sal_Int32 nEnd,
bool bClp )
732 [&rNd](sal_Int32 const nBegin, sal_uInt16 const nScript, bool const bNoChar)
733 {
return rNd.
GetLang(nBegin, bNoChar ? 0 : 1, nScript); }
734 , rText, pLang, rConvMap,
nType, nStart, nEnd, bClp)
741 sal_Int32 nEnd,
bool bClp)
742 : m_pGetLangOfChar(
std::move(aGetLangOfChar))
743 , m_aPreDashReplacementText(
std::move(aText))
747 , m_nOverriddenDashCount(0)
768 if (sDashes.indexOf(cChar) != -1)
796 sal_Int32 forceEachAsianCodePointToWord(
const OUString &rText, sal_Int32 nBegin, sal_Int32 nLen)
802 sal_uInt16 nCurrScript = rxBreak->getScriptType( rText, nBegin );
804 sal_Int32 indexUtf16 = nBegin;
805 rText.iterateCodePoints(&indexUtf16);
808 if (nCurrScript == i18n::ScriptType::ASIAN)
810 nLen = indexUtf16 - nBegin;
816 while (indexUtf16 < nBegin + nLen)
818 nCurrScript = rxBreak->getScriptType( rText, indexUtf16 );
819 if (nCurrScript == i18n::ScriptType::ASIAN)
821 nLen = indexUtf16 - nBegin;
824 rText.iterateCodePoints(&indexUtf16);
836 std::optional<CharClass> xLocalCharClass;
871 OSL_ENSURE( aBound.endPos >= aBound.startPos,
"broken aBound result" );
881 if(aBound.endPos == aBound.startPos)
904 OSL_ENSURE( aBound.endPos >=
m_nBegin,
"Unexpected aBound result" );
909 const sal_Int32 nScriptEnd =
m_nBegin +
911 const sal_Int32 nEnd =
std::min( aBound.endPos, nScriptEnd );
914 sal_Int32 nScriptBegin = 0;
918 aTmpWord =
m_aText.copy( aBound.startPos,
920 nScriptBegin = aBound.startPos +
925 m_nBegin = std::max( aBound.startPos, nScriptBegin );
931 OUString aTmpWord =
m_aText.copy( aBound.startPos,
932 aBound.endPos - aBound.startPos );
933 const sal_Int32 nScriptEnd = aBound.startPos +
935 const sal_Int32 nEnd =
std::min( aBound.endPos, nScriptEnd );
944 aBound.startPos = std::max( aBound.startPos,
m_nStartPos );
946 if (aBound.endPos < aBound.startPos)
974 const OUString aOldText(
m_Text );
975 OUStringBuffer buf(
m_Text);
977 const bool bRestoreString =
981 m_Text = buf.makeStringAndClear();
1008 if (nBegin >
m_Text.getLength())
1010 nBegin =
m_Text.getLength();
1012 if (nEnd >
m_Text.getLength())
1014 nEnd =
m_Text.getLength();
1023 if ( bRestoreString )
1037 WordType::DICTIONARY_WORD,
1039 bool bNextWord = aScanner.
NextWord();
1040 while( !pArgs->
xSpellAlt.is() && bNextWord )
1042 bool bCalledNextWord =
false;
1044 const OUString& rWord = aScanner.
GetWord();
1057 pArgs->
xSpellAlt = pArgs->
xSpeller->spell( rWord,
static_cast<sal_uInt16
>(eActLang),
1058 Sequence< PropertyValue >() );
1066 ( (bRestoreString || bContainsComments) && pArgs->
xSpeller->isValid( rWord.replaceAll(OUStringChar(
CH_TXTATR_INWORD),
""),
1067 static_cast<sal_uInt16
>(eActLang), Sequence< PropertyValue >() ) ) )
1074 auto nWordBegin = aScanner.
GetBegin();
1075 auto nWordEnd = aScanner.
GetEnd();
1077 const OUString& rActualWord = aScanner.
GetPrevWord();
1078 bCalledNextWord =
true;
1080 if ( !((bNextWord && pArgs->
xSpeller->isValid( rActualWord +
" " + aScanner.
GetWord(),
1081 static_cast<sal_uInt16
>(eActLang), Sequence< PropertyValue >() )) ||
1082 ( !sPrevWord.isEmpty() && pArgs->
xSpeller->isValid( sPrevWord +
" " + rActualWord,
1083 static_cast<sal_uInt16
>(eActLang), Sequence< PropertyValue >() ))) )
1091 sal_Int32 nLeft = 0;
1094 pChar = rActualWord.getLength() ? rActualWord.getStr() + rActualWord.getLength() - 1 :
nullptr;
1095 sal_Int32 nRight = 0;
1110 if ( !bCalledNextWord )
1116 if ( bRestoreString )
1126 const vcl::Font *pFont, sal_uInt16 nFontWhichId )
1136 OSL_ENSURE( pFont,
"target font missing?" );
1145 aSet.
Put( aFontItem );
1172 const OUString aOldText(
m_Text );
1173 OUStringBuffer buf(
m_Text);
1174 const bool bRestoreString =
1178 m_Text = buf.makeStringAndClear();
1181 bool bFound =
false;
1182 sal_Int32 nBegin = nTextBegin;
1191 SwPaM aCurPaM( *
this, 0 );
1205 typedef std::pair<sal_Int32, sal_Int32> ImplicitChangesRange;
1206 std::vector<ImplicitChangesRange> aImplicitChanges;
1218 assert(nChPos != -1);
1221 nChPos =
m_Text.getLength();
1224 nLen = nChPos - nBegin;
1225 bFound = bLangOk && nLen > 0;
1230 SwPaM aCurPaM( *
this, nBegin );
1238 pEditShell->SetSelection( aCurPaM );
1239 bool bIsAsianScript = (SvtScriptType::ASIAN == pEditShell->GetScriptType());
1245 aImplicitChanges.emplace_back(nBegin, nBegin+nLen);
1250 }
while (!bFound && aIter.
Next());
1253 for (
const auto& rImplicitChange : aImplicitChanges)
1255 SwPaM aPaM( *
this, rImplicitChange.first );
1264 if (nBegin < nTextBegin)
1265 nBegin = nTextBegin;
1266 if (nBegin + nLen > nTextEnd)
1267 nLen = nTextEnd - nBegin;
1268 bool bInSelection = nBegin < nTextEnd;
1270 if (bFound && bInSelection)
1272 OSL_ENSURE( !
m_Text.isEmpty(),
"convertible text portion missing!" );
1283 if ( bRestoreString )
1303 const OUString aOldText( pNode->
GetText() );
1304 OUStringBuffer buf(pNode->
m_Text);
1306 const bool bRestoreString =
1310 pNode->
m_Text = buf.makeStringAndClear();
1315 sal_Int32 nBegin = 0;
1316 sal_Int32 nEnd = pNode->
GetText().getLength();
1317 sal_Int32 nInsertPos = 0;
1319 sal_Int32 nChgEnd = 0;
1321 sal_Int32 nInvEnd = 0;
1344 WordType::DICTIONARY_WORD,
true );
1345 nBegin = aBound.startPos;
1352 if( nInsertPos < pNode->GetWrong()->
Count() &&
1358 bool bFresh = nBegin < nEnd;
1359 bool bPending(
false);
1367 WordType::DICTIONARY_WORD, nBegin, nEnd);
1369 bool bNextWord = aScanner.
NextWord();
1372 const OUString& rWord = aScanner.
GetWord();
1374 sal_Int32 nLen = aScanner.
GetLen();
1375 bool bCalledNextWord =
false;
1380 DetectAndMarkMissingDictionaries( rDoc, xSpell, eActLang );
1382 bool bSpell = xSpell.is() && xSpell->hasLanguage(
static_cast<sal_uInt16
>(eActLang) );
1383 if( bSpell && !rWord.isEmpty() && !
lcl_IsURL(rWord, *pNode, nBegin, nLen) )
1386 OSL_ENSURE(!bSpell || xSpell.is(),
"NULL pointer");
1387 if( !xSpell->isValid( rWord,
static_cast<sal_uInt16
>(eActLang), Sequence< PropertyValue >() ) &&
1391 ((!bRestoreString && !bContainsComments) || !xSpell->isValid( rWord.replaceAll(OUStringChar(
CH_TXTATR_INWORD),
""),
1392 static_cast<sal_uInt16
>(eActLang), Sequence< PropertyValue >() ) ) )
1396 bCalledNextWord =
true;
1398 if ( !((bNextWord && xSpell->isValid( aScanner.
GetPrevWord() +
" " + aScanner.
GetWord(),
1399 static_cast<sal_uInt16
>(eActLang), Sequence< PropertyValue >() )) ||
1400 (!sPrevWord.isEmpty() && xSpell->isValid( sPrevWord +
" " + aScanner.
GetPrevWord(),
1401 static_cast<sal_uInt16
>(eActLang), Sequence< PropertyValue >() ))) )
1403 sal_Int32 nSmartTagStt = nBegin;
1404 sal_Int32 nDummy = 1;
1413 nChgStart, nChgEnd, nBegin, nLen, nInsertPos, nActPos));
1417 pNode->
GetWrong()->
Insert(OUString(),
nullptr, nBegin, nLen, nInsertPos++);
1424 nInvEnd = nBegin + nLen;
1433 bool bCursorOutsideWord = nActPos > nBegin + nLen || nActPos < nBegin;
1434 if (bCursorOutsideWord)
1438 else if( bAddAutoCmpl && rACW.
GetMinWordLen() <= rWord.getLength() )
1442 bool bCursorOutsideWord = nActPos > nBegin + nLen || nActPos < nBegin;
1443 if (bCursorOutsideWord)
1448 if ( !bCalledNextWord )
1455 if ( bRestoreString )
1457 pNode->
m_Text = aOldText;
1463 nEnd, 0, nInsertPos, nActPos );
1467 if( nChgStart < nChgEnd )
1472#if !ENABLE_WASM_STRIP_ACCESSIBILITY
1513 const OUString& rText = pNode->
GetText();
1520 sal_Int32 nBegin = 0;
1521 sal_Int32 nEnd = rText.getLength();
1523 if ( pSmartTagList )
1530 if ( nBegin < nEnd )
1536 if (nEnd > rText.getLength() || nEnd < 0)
1537 nEnd = rText.getLength();
1542 const sal_uInt16 nNumberOfEntries = pSmartTagList ? pSmartTagList->
Count() : 0;
1543 sal_uInt16 nNumberOfRemovedEntries = 0;
1544 sal_uInt16 nNumberOfInsertedEntries = 0;
1547 if ( 0 != nNumberOfEntries )
1550 sal_Int32 nChgEnd = 0;
1551 const sal_uInt16 nCurrentIndex = pSmartTagList->
GetWrongPos( nBegin );
1552 pSmartTagList->
Fresh( nChgStart, nChgEnd, nBegin, nEnd - nBegin, nCurrentIndex,
COMPLETE_STRING );
1553 nNumberOfRemovedEntries = nNumberOfEntries - pSmartTagList->
Count();
1556 if ( nBegin < nEnd )
1560 const OUString& aExpandText = aConversionMap.
getViewText();
1563 uno::Reference<text::XTextMarkup>
const xTextMarkup =
1574 sal_Int32 nLangBegin = nBegin;
1584 nLangEnd = std::min<sal_Int32>( nEnd, aIter.
GetChgPos() );
1591 nLangBegin = nLangEnd;
1593 while ( aIter.
Next() && nLangEnd < nEnd );
1597 const sal_uInt16 nNumberOfEntriesAfterRecognize = pSmartTagList ? pSmartTagList->
Count() : 0;
1598 nNumberOfInsertedEntries = nNumberOfEntriesAfterRecognize - ( nNumberOfEntries - nNumberOfRemovedEntries );
1611 if ( nBegin < nEnd && ( 0 != nNumberOfRemovedEntries ||
1612 0 != nNumberOfInsertedEntries ) )
1633 sal_Int32 nBegin = 0;
1634 sal_Int32 nEnd = pNode->
GetText().getLength();
1636 bool bACWDirty =
false;
1642 WordType::DICTIONARY_WORD, nBegin, nEnd );
1646 nLen = aScanner.
GetLen();
1649 const OUString& rWord = aScanner.
GetWord();
1651 if( nActPos < nBegin || ( nBegin + nLen ) < nActPos )
1688 if (wordStart.first != &rNode || wordEnd.first != &rNode)
1690 SAL_WARN(
"sw.core",
"UpdateTextNodeHyphInfo: outside of node");
1694 o_rHyphInfo.
m_nWordLen = wordEnd.second - wordStart.second;
1709 [&rHyphInf,
this]() {
1710 std::pair<Point, bool> tmp;
1714 tmp.first = *pPoint;
1719 nullptr, pPoint ? &tmp :
nullptr));
1726 OSL_ENSURE( pFrame,
"!SwTextNode::Hyphenate: can't find any frame" );
1755 struct swTransliterationChgData
1760 Sequence< sal_Int32 > aOffsets;
1767 sal_Int32 nStt, sal_Int32 nEnd,
1773 const sal_Int32 selStart = nStt;
1774 const sal_Int32 selEnd = nEnd;
1781 const sal_Int16 nWordType = WordType::ANYWORD_IGNOREWHITESPACES;
1789 std::vector< swTransliterationChgData > aChanges;
1790 swTransliterationChgData aChgData;
1792 if (rTrans.
getType() == TransliterationFlags::TITLE_CASE)
1810 if (aSttBndry.endPos <= nStt)
1818 if (aEndBndry.startPos >= nEnd)
1821 GetText(), aEndBndry.startPos,
1828 if (aSttBndry.startPos >= selEnd || aEndBndry.endPos <= selStart) {
1834 aSttBndry.startPos = std::max(aSttBndry.startPos, selStart);
1835 aEndBndry.startPos = std::max(aSttBndry.startPos, aEndBndry.startPos);
1837 Boundary aCurWordBndry( aSttBndry );
1838 while (aCurWordBndry.startPos <= aEndBndry.startPos)
1840 nStt = aCurWordBndry.startPos;
1841 nEnd = aCurWordBndry.endPos;
1842 const sal_Int32 nLen = nEnd - nStt;
1843 OSL_ENSURE( nLen > 0,
"invalid word length of 0" );
1845 Sequence <sal_Int32> aOffsets;
1849 assert(nStt <
m_Text.getLength());
1850 if (0 != rtl_ustr_shortenedCompare_WithLength(
1852 sChgd.getStr(), sChgd.getLength(), nLen))
1854 aChgData.nStart = nStt;
1855 aChgData.nLen = nLen;
1856 aChgData.sChanged = sChgd;
1857 aChgData.aOffsets = aOffsets;
1858 aChanges.push_back( aChgData );
1867 else if (rTrans.
getType() == TransliterationFlags::SENTENCE_CASE)
1881 sal_Int32 nCurrentStart = nStt;
1888 if (nCurrentEnd <= nStt)
1897 i18n::WordType::DICTIONARY_WORD);
1908 if (nLastStart >= nEnd)
1917 i18n::WordType::DICTIONARY_WORD);
1921 if (nCurrentEnd > nLastEnd)
1922 nCurrentEnd = nLastEnd;
1926 nCurrentStart = std::max(selStart, nCurrentStart);
1927 nCurrentEnd =
std::min(selEnd, nCurrentEnd);
1928 nLastEnd =
std::min(selEnd, nLastEnd);
1930 while (nCurrentStart < nLastEnd)
1932 sal_Int32 nLen = nCurrentEnd - nCurrentStart;
1933 OSL_ENSURE( nLen > 0,
"invalid word length of 0" );
1935 Sequence <sal_Int32> aOffsets;
1937 GetLang(nCurrentStart), nCurrentStart, nLen, &aOffsets) );
1939 assert(nStt <
m_Text.getLength());
1940 if (0 != rtl_ustr_shortenedCompare_WithLength(
1942 sChgd.getStr(), sChgd.getLength(), nLen))
1944 aChgData.nStart = nCurrentStart;
1945 aChgData.nLen = nLen;
1946 aChgData.sChanged = sChgd;
1947 aChgData.aOffsets = aOffsets;
1948 aChanges.push_back( aChgData );
1955 nCurrentStart = aFirstWordBndry.startPos;
1965 std::unique_ptr<SwLanguageIterator> pIter;
1969 sal_Int32 nEndPos = 0;
1974 nLang = pIter->GetLanguage();
1975 nEndPos = pIter->GetChgPos();
1976 if( nEndPos > nEnd )
1984 const sal_Int32 nLen = nEndPos - nStt;
1986 Sequence <sal_Int32> aOffsets;
1990 assert(nStt <
m_Text.getLength());
1991 if (0 != rtl_ustr_shortenedCompare_WithLength(
1993 sChgd.getStr(), sChgd.getLength(), nLen))
1995 aChgData.nStart = nStt;
1996 aChgData.nLen = nLen;
1997 aChgData.sChanged = sChgd;
1998 aChgData.aOffsets = aOffsets;
1999 aChanges.push_back( aChgData );
2003 }
while( nEndPos < nEnd && pIter && pIter->
Next() );
2006 if (aChanges.empty())
2013 for (
size_t i = 0;
i < aChanges.size(); ++
i)
2016 swTransliterationChgData & rData =
2017 aChanges[ aChanges.size() - 1 -
i ];
2019 nSum += rData.sChanged.getLength() - rData.nLen;
2022 SAL_WARN(
"sw.core",
"SwTextNode::ReplaceTextOnly: "
2023 "node text with insertion > node capacity.");
2027 if ( bUseRedlining )
2031 SwPaM aCurPaM( *
this, rData.nStart );
2035 if ( aCurPaM.
GetText() != rData.sChanged )
2041 pUndo->
AddChanges( *
this, rData.nStart, rData.nLen, rData.aOffsets );
2042 ReplaceTextOnly( rData.nStart, rData.nLen, rData.sChanged, rData.aOffsets );
2048 std::u16string_view aText,
2049 const Sequence<sal_Int32>& rOffsets )
2051 assert(sal_Int32(aText.size()) - nLen <=
GetSpaceLeft());
2055 sal_Int32 nTLen = aText.size();
2056 const sal_Int32* pOffsets = rOffsets.getConstArray();
2058 sal_Int32 nMyOff =
nPos;
2059 for( sal_Int32 nI = 0; nI < nTLen; ++nI )
2061 const sal_Int32 nOff = pOffsets[ nI ];
2066 while( nI + nCnt < nTLen && nOff == pOffsets[ nI + nCnt ] )
2074 else if( nOff > nMyOff )
2088 CallSwClientNotify(aDelHint);
2091 CallSwClientNotify(aInsHint);
2097 sal_Int32 nStt, sal_Int32 nEnd )
const
2107 bool bCountAll = ( (0 == nStt) && (
GetText().getLength() == nEnd) );
2114 bool bCountNumbering = nStt == 0;
2115 bool bHasBullet =
false, bHasNumbering =
false;
2116 OUString sNumString;
2117 if (bCountNumbering)
2120 bHasNumbering = !sNumString.isEmpty();
2123 bCountNumbering = bHasNumbering || bHasBullet;
2126 if( nStt == nEnd && !bCountNumbering)
2154 const OUString& aExpandText = aConversionMap.
getViewText();
2156 if (aExpandText.isEmpty() && !bCountNumbering)
2173 sal_uInt32 nTmpWords = 0;
2174 sal_uInt32 nTmpAsianWords = 0;
2175 sal_uInt32 nTmpChars = 0;
2176 sal_uInt32 nTmpCharsExcludingSpaces = 0;
2179 if (!aExpandText.isEmpty())
2184 SwScanner aScanner( *
this, aExpandText,
nullptr, aConversionMap, i18n::WordType::WORD_COUNT,
2185 nExpandBegin, nExpandEnd,
true );
2192 if( !aExpandText.match(aBreakWord, aScanner.
GetBegin() ))
2195 const OUString &rWord = aScanner.
GetWord();
2217 i18n::WordType::WORD_COUNT, 0, sNumString.getLength(),
true );
2222 const OUString &rWord = aScanner.
GetWord();
2231 else if ( bHasBullet )
2235 ++nTmpCharsExcludingSpaces;
2248 rStat.
nWord += nTmpWords;
2250 rStat.
nChar += nTmpChars;
2310 "Weird - we have a smart tag list without any recognizers?" );
const sal_Int32 m_nLength
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...
static bool AnyInput(VclInputFlags nType=VCL_INPUT_ANY)
virtual bool ReplaceRange(SwPaM &rPam, const OUString &rNewStr, const bool bRegExReplace)=0
Replace selected range in a TextNode with string.
virtual void InsertItemSet(const SwPaM &rRg, const SfxItemSet &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr)=0
static bool IsShowChanges(const RedlineFlags eM)
virtual SwRedlineTable::size_type GetRedlinePos(const SwNode &rNode, RedlineType nType) const =0
virtual const SwRedlineTable & GetRedlineTable() const =0
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
virtual std::shared_ptr< SfxItemSet > getAutomaticStyle(const SfxItemSet &rSet, SwAutoStyleFamily eFamily, const OUString *pParentName=nullptr)=0
ModelPosition ConvertToModelPosition(sal_Int32 nViewPos) const
Converts a view position into a model position.
const OUString & getViewText() const
sal_Int32 ConvertToViewPosition(sal_Int32 nModelPos) const
Converts a model position into a view position.
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
virtual std::unique_ptr< SfxItemSet > Clone(bool bItems=true, SfxItemPool *pToPool=nullptr) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo)
void RecognizeTextRange(const css::uno::Reference< css::text::XTextRange > &rRange, const css::uno::Reference< css::text::XTextMarkup > &rMarkup, const css::uno::Reference< css::frame::XController > &rController) const
void RecognizeString(const OUString &rText, const css::uno::Reference< css::text::XTextMarkup > &rMarkup, const css::uno::Reference< css::frame::XController > &rController, const css::lang::Locale &rLocale, sal_uInt32 nStart, sal_uInt32 nLen) const
void SetStyleName(const OUString &rStyleName)
void SetFamily(FontFamily _eFamily)
void SetPitch(FontPitch _ePitch)
void SetFamilyName(const OUString &rFamilyName)
void SetCharSet(rtl_TextEncoding _eEncoding)
static sal_Int16 CheckSpellLang(css::uno::Reference< css::linguistic2::XSpellChecker1 > const &xSpell, LanguageType nLang)
bool InsertWord(const OUString &rWord, SwDoc &rDoc)
sal_uInt16 GetMinWordLen() const
sal_Int32 getGraphemeCount(const OUString &rStr, sal_Int32 nStart, sal_Int32 nEnd) const
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
const css::lang::Locale & GetLocale(const LanguageType aLang)
Marks a character position inside a document model content node (SwContentNode)
SwFormatColl * GetFormatColl() const
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
css::uno::Reference< css::frame::XController > GetController()
static SwAutoCompleteWord & GetAutoCompleteWords()
void SetMissingDictionaries(bool bIsMissing)
Use to notify if the dictionary can be found for a single content portion (has to be called for all p...
IDocumentContentOperations const & getIDocumentContentOperations() const
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
SwEditShell const * GetEditShell() const
::sw::DocumentSettingManager & GetDocumentSettingManager()
SwDocShell * GetDocShell()
SwRect GetPaintArea() const
|* The paintarea is the area, in which the content of a frame is allowed |* to be displayed.
SwRootFrame * getRootFrame()
void SetCompletePaint() const
a clone of SwInterHyphInfo, but with TextFrameIndex instead of node index
TextFrameIndex m_nWordLen
SwInterHyphInfoTextFrame(SwTextFrame const &rFrame, SwTextNode const &rNode, SwInterHyphInfo const &rHyphInfo)
TextFrameIndex m_nStart
input: requested range to hyphenate
css::uno::Reference< css::linguistic2::XHyphenatedWord > m_xHyphWord
output: hyphenated word
void UpdateTextNodeHyphInfo(SwTextFrame const &rFrame, SwTextNode const &rNode, SwInterHyphInfo &o_rHyphInfo)
TextFrameIndex m_nWordStart
output: found word
void SetHyphWord(const css::uno::Reference< css::linguistic2::XHyphenatedWord > &rxHW)
sal_Int32 m_nWordStart
output: found word
const Point * GetCursorPos() const
LanguageType GetLanguage() const
sal_Int32 GetChgPos() const
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwNodeOffset GetIndex() const
bool IsInRedlines() const
Checks if this node is in redlines.
IStyleAccess & getIDocumentStyleAccess()
Provides access to the document automatic styles interface.
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
PaM is Point and Mark: a selection of the document model.
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
const SwPosition * GetPoint() const
const SwPosition * Start() const
void CalcStartEnd(SwNodeOffset nNdIdx, sal_Int32 &rStart, sal_Int32 &rEnd) const
Calculates the intersection with text node number nNdIdx.
RedlineType GetType(sal_uInt16 nPos=0) const
void SetBottom(SwRect &rRect, tools::Long nNew) const
void SetRight(SwRect &rRect, tools::Long nNew) const
tools::Long GetTop(const SwRect &rRect) const
tools::Long GetLeft(const SwRect &rRect) const
tools::Long GetBottom(const SwRect &rRect) const
void SetTop(SwRect &rRect, tools::Long nNew) const
tools::Long GetRight(const SwRect &rRect) const
void SetLeft(SwRect &rRect, tools::Long nNew) const
Of course Writer needs its own rectangles.
void Height(tools::Long nNew)
SwRect & Union(const SwRect &rRect)
vector_type::size_type size_type
SwViewShell * GetCurrShell() const
const LanguageType * m_pLanguage
const ModelToViewHelper m_ModelToView
const OUString m_aPreDashReplacementText
LanguageType m_aCurrentLang
sal_Int32 GetBegin() const
const OUString & GetWord() const
sal_Int32 getOverriddenDashCount() const
std::function< LanguageType(sal_Int32, sal_Int32, bool)> m_pGetLangOfChar
SwScanner(std::function< LanguageType(sal_Int32, sal_Int32, bool)> pGetLangOfChar, OUString aText, const LanguageType *pLang, ModelToViewHelper aConvMap, sal_uInt16 nWordType, sal_Int32 nStart, sal_Int32 nEnd, bool bClip=false)
sal_Int32 m_nOverriddenDashCount
const OUString & GetPrevWord() const
LanguageType GetCurrentLanguage() const
static sal_Int32 MaskHiddenRanges(const SwTextNode &rNode, OUStringBuffer &rText, const sal_Int32 nStt, const sal_Int32 nEnd, const sal_Unicode cChar)
Hidden text attribute handling.
static SwSmartTagMgr & Get()
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
const SfxPoolItem & GetAttr() const
virtual const sal_Int32 * GetEnd() const
end position
const sal_Int32 * End() const
sal_Int32 GetStart() const
virtual void SetEnd(sal_Int32)
void SetStart(sal_Int32 n)
start position
void SetSortNumber(sal_uInt16 nSortNumber)
sal_uInt16 GetSortNumber() const
Represents the visualization of a paragraph.
SwTextFrame * GetFollow()
TextFrameIndex GetOffset() const
std::pair< SwTextNode *, sal_Int32 > MapViewToModel(TextFrameIndex nIndex) const
map position in potentially merged text frame to SwPosition
void CollectAutoCmplWrds(SwTextNode &, sal_Int32)
Is called by DoIdleJob_()
SwRect SmartTagScan(SwTextNode &)
Is called by DoIdleJob_()
bool Hyphenate(SwInterHyphInfoTextFrame &rInf)
We format a Line for interactive hyphenation.
TextFrameIndex MapModelToView(SwTextNode const *pNode, sal_Int32 nIndex) const
bool IsSymbolAt(TextFrameIndex) const
SwRect AutoSpell_(SwTextNode &, sal_Int32)
Is called by DoIdleJob_(), ExecSpellPopup() and UpDown()
TextFrameIndex MapModelToViewPos(SwPosition const &rPos) const
bool IsHiddenNow() const
Hidden.
SwTextFrame & GetFrameAtOfst(TextFrameIndex nOfst)
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
OUString GetCurWord(SwPosition const &) const
SwTextNode is a paragraph in the document model.
bool HasBullet() const
Returns if this text node has a bullet.
sw::ParagraphIdleData m_aParagraphIdleData
void SetWrongDirty(sw::WrongState eNew) const
SAL_DLLPRIVATE void SetLanguageAndFont(const SwPaM &rPaM, LanguageType nLang, sal_uInt16 nLangWhichId, const vcl::Font *pFont, sal_uInt16 nFontWhichId)
sal_Int32 GetSpaceLeft() const
bool IsSmartTagDirty() const
SwWrongList * GetSmartTags()
void RstTextAttr(const sal_Int32 nContentStart, const sal_Int32 nLen, const sal_uInt16 nWhich=0, const SfxItemSet *pSet=nullptr, const bool bInclRefToxMark=false, const bool bExactRange=false)
delete all attributes.
bool IsGrammarCheckDirty() const
void DestroyAttr(SwTextAttr *pAttr)
bool IsAutoCompleteWordDirty() const
void SetWordCountDirty(bool bNew) const
void SetGrammarCheckDirty(bool bNew) const
void SetSmartTags(std::unique_ptr< SwWrongList > pNew)
void SetSmartTagDirty(bool bNew) const
void ReplaceTextOnly(sal_Int32 nPos, sal_Int32 nLen, std::u16string_view aText, const css::uno::Sequence< sal_Int32 > &rOffsets)
std::unique_ptr< SwpHints > m_pSwpHints
May be 0.
void SetAutoCompleteWordDirty(bool bNew) const
std::unique_ptr< SwWrongList > ReleaseSmartTags()
bool CountWords(SwDocStat &rStat, sal_Int32 nStart, sal_Int32 nEnd) const
count words in given range - returns true if we refreshed out count
bool Convert(SwConversionArgs &)
bool IsSymbolAt(sal_Int32 nBegin) const
in ndcopy.cxx
bool IsWordCountDirty() const
std::unique_ptr< SwGrammarMarkUp > ReleaseGrammarCheck()
SwGrammarMarkUp * GetGrammarCheck()
virtual void Update(SwContentIndex const &rPos, const sal_Int32 nChangeLen, UpdateMode eMode) override
override SwContentIndexReg
sw::WrongState GetWrongDirty() const
OUString GetNumString(const bool _bInclPrefixAndSuffixStrings=true, const unsigned int _nRestrictToThisLevel=MAXLEVEL, SwRootFrame const *pLayout=nullptr, SwListRedlineType eRedline=SwListRedlineType::SHOW) const
Returns outline of numbering string.
bool Spell(SwSpellArgs *)
SwTextAttr * GetTextAttrAt(sal_Int32 const nIndex, sal_uInt16 const nWhich, ::sw::GetTextAttrMode const eMode=::sw::GetTextAttrMode::Default) const
get the innermost text attribute covering position nIndex.
bool IsWrongDirty() const
SwpHints * GetpSwpHints()
void SetWrong(std::unique_ptr< SwWrongList > pNew)
const OUString & GetText() const
void TransliterateText(utl::TransliterationWrapper &rTrans, sal_Int32 nStart, sal_Int32 nEnd, SwUndoTransliterate *pUndo, bool bUseRedlining=false)
change text to Upper/Lower/Hiragana/Katakana/...
bool InsertHint(SwTextAttr *const pAttr, const SetAttrMode nMode=SetAttrMode::DEFAULT)
Insert pAttr into hints array.
LanguageType GetLang(const sal_Int32 nBegin, const sal_Int32 nLen=0, sal_uInt16 nScript=0) const
void SetGrammarCheck(std::unique_ptr< SwGrammarMarkUp > pNew)
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...
bool Hyphenate(SwInterHyphInfo &rHyphInf)
Interactive hyphenation: we find TextFrame and call its CalcHyph.
std::unique_ptr< SwWrongList > ReleaseWrong()
void AddChanges(SwTextNode &rTNd, sal_Int32 nStart, sal_Int32 nLen, css::uno::Sequence< sal_Int32 > const &rOffsets)
static bool IsAutoCompleteWords()
void InvalidateAccessibleParaAttrs(const SwTextFrame &rTextFrame)
invalidate attributes for paragraphs and paragraph's characters
const SfxItemPool & GetAttrPool() const
sal_Int32 GetEndInv() const
sal_Int32 Pos(sal_uInt16 nIdx) const
FreshState Fresh(sal_Int32 &rStart, sal_Int32 &rEnd, sal_Int32 nPos, sal_Int32 nLen, sal_uInt16 nIndex, sal_Int32 nCursorPos)
Remove given range of entries.
sal_uInt16 GetWrongPos(sal_Int32 nValue) const
Find the first position that is greater or equal to the given value.
bool InWrongWord(sal_Int32 &rChk, sal_Int32 &rLn) const
If a word is incorrectly selected, this method returns begin and length of it.
void SetInvalid(sal_Int32 nBegin, sal_Int32 nEnd)
void Insert(sal_uInt16 nWhere, std::vector< SwWrongArea >::iterator startPos, std::vector< SwWrongArea >::iterator const &endPos)
sal_Int32 GetBeginInv() const
sal_Int32 Len(sal_uInt16 nIdx) const
sal_Int32 NextWrong(sal_Int32 nChk) const
Find next incorrectly selected position.
Implementation of the css::text::XTextMarkup interface.
static bool IsChinese(LanguageType nLang)
virtual bool get(DocumentSettingId id) const override
Return the specified document setting.
OUString transliterate(const OUString &rStr, sal_Int32 nStart, sal_Int32 nLen) const
bool needLanguageForTheMode() const
TransliterationFlags getType() const
FontFamily GetFamilyType()
const OUString & GetStyleName() const
const OUString & GetFamilyName() const
rtl_TextEncoding GetCharSet() const
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
bool isTXTATR_WITHEND(const sal_uInt16 nWhich)
constexpr TypedWhichId< SwFormatAutoFormat > RES_TXTATR_AUTOFMT(50)
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(60)
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_METAFIELD(49)
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_META(48)
constexpr TypedWhichId< SwTOXMark > RES_TXTATR_TOXMARK(47)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
#define CH_TXTATR_BREAKWORD
#define SAL_WARN(area, stream)
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SwTextFrame * SwHyphIterCacheLastTextFrame(SwTextNode const *pNode, const sw::Creator &create)
bool FrameContainsNode(SwContentFrame const &rFrame, SwNodeOffset nNodeIndex)
TextFrameIndex MapModelToView(MergedPara const &, SwTextNode const *pNode, sal_Int32 nIndex)
InsertText MakeInsertText(SwTextNode &rNode, const sal_Int32 nPos, const sal_Int32 nLen)
@ Parent
EXPAND : (Start < nIndex <= End)
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
static LanguageType nLang
This struct defines a position in the model string.
bool bAllowImplicitChangesForNotConvertibleText
LanguageType nConvSrcLang
LanguageType nConvTargetLang
const vcl::Font * pTargetFont
LanguageType nConvTextLang
sal_uLong nCharExcludingSpaces
sal_uLong nPara
paragraphs for document statistic: non-empty and non-hidden ones
sal_uLong nAllPara
all paragraphs, including empty/hidden ones
Marks a position in the document model.
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
sal_Int32 GetContentIndex() const
css::uno::Reference< css::linguistic2::XSpellAlternatives > xSpellAlt
css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpeller
UNDERLYING_TYPE get() const
sal_uLong nNumberOfAsianWords
WrongState eWrongDirty
online spell checking needed/done?
sal_uLong nNumberOfCharsExcludingSpaces
std::unique_ptr< SwWrongList > pWrong
std::unique_ptr< SwWrongList > pSmartTags
std::unique_ptr< SwGrammarMarkUp > pGrammarCheck
bool bAutoComplDirty
auto complete list dirty
Reference< XController > xController
uno::Reference< linguistic2::XSpellChecker1 > GetSpellChecker()
@ NOHINTADJUST
attention: NOHINTADJUST prevents MergePortions! when using this need to pay attention to ignore start...
constexpr sal_Int32 COMPLETE_STRING
SwTextAttr * MakeTextAttr(SwDoc &rDoc, SfxPoolItem &rAttr, sal_Int32 const nStt, sal_Int32 const nEnd, CopyOrNewType const bIsCopy, SwTextNode *const pTextNode)
if COPY then pTextNode must be given!
const formula::FormulaGrammar::AddressConvention aConvMap[]
static bool lcl_IsDelim(const sal_Unicode c)
static bool lcl_MaskRedlinesAndHiddenText(const SwTextNode &rNode, OUStringBuffer &rText, sal_Int32 nStt, sal_Int32 nEnd, const sal_Unicode cChar=CH_TXTATR_INWORD)
Used for spell checking.
static SwRect lcl_CalculateRepaintRect(const SwTextFrame &rTextFrame, const SwTextNode &rNode, sal_Int32 const nChgStart, sal_Int32 const nChgEnd)
Used for spell checking.
static bool lcl_IsURL(std::u16string_view rWord, SwTextNode &rNode, sal_Int32 nBegin, sal_Int32 nLen)
static sal_Int32 clipIndexBounds(std::u16string_view aStr, sal_Int32 nPos)
static sal_Int32 lcl_MaskRedlines(const SwTextNode &rNode, OUStringBuffer &rText, sal_Int32 nStt, sal_Int32 nEnd, const sal_Unicode cChar)
static bool lcl_HasComments(const SwTextNode &rNode)
static bool lcl_HaveCommonAttributes(IStyleAccess &rStyleAccess, const SfxItemSet *pSet1, sal_uInt16 nWhichId, const SfxItemSet &rSet2, std::shared_ptr< SfxItemSet > &pStyleHandle)
Used for automatic styles.