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 ) && !bExactRange)
445 const sal_Int32*
const pAttrEnd = pHt->
GetEnd();
446 const bool bKeepAttrWithoutEnd =
448 && ( !bInclRefToxMark
453 if ( bKeepAttrWithoutEnd )
467 bool bSkipAttr =
false;
468 std::shared_ptr<SfxItemSet> pStyleHandle;
485 bSkipAttr = nWhich != pHt->
Which();
491 else if ( !bInclRefToxMark )
508 if (nStt <= nAttrStart)
510 const sal_Int32 nAttrEnd = pAttrEnd !=
nullptr
513 if (nEnd > nAttrStart
514 || (nEnd == nAttrEnd && nEnd == nAttrStart))
516 if ( nMin > nAttrStart )
518 if ( nMax < nAttrEnd )
521 bChanged = bChanged || nEnd > nAttrStart || bNoLen;
522 if (nAttrEnd <= nEnd)
524 delAttributes.push_back(pHt);
529 *pStyleHandle, nAttrStart, nAttrEnd );
530 newAttributes.push_back(pNew);
541 if ( pStyleHandle && nAttrStart < nEnd )
544 *pStyleHandle, nAttrStart, nEnd );
545 newAttributes.push_back(pNew);
550 else if (pAttrEnd !=
nullptr)
552 if (*pAttrEnd > nStt)
554 if (*pAttrEnd < nEnd)
556 if ( nMin > nAttrStart )
558 if ( nMax < *pAttrEnd )
562 const sal_Int32 nAttrEnd = *pAttrEnd;
572 *pStyleHandle, nStt, nAttrEnd );
573 newAttributes.push_back(pNew);
580 if ( nMin > nAttrStart )
582 if ( nMax < *pAttrEnd )
585 const sal_Int32 nTmpEnd = *pAttrEnd;
591 if ( pStyleHandle && nStt < nEnd )
594 *pStyleHandle, nStt, nEnd );
595 newAttributes.push_back(pNew);
601 pHt->
GetAttr(), nEnd, nTmpEnd );
608 newAttributes.push_back(pNew);
627 const sal_Int32* pHintEnd = pHint->
GetEnd();
628 if (!pHintEnd || *pHintEnd != nEnd)
631 delAttributes.push_back(pHint);
635 if (bChanged && !delAttributes.empty())
692 OUString
const& rText(
GetText());
693 assert(sal_Int32(
nPos) <= rText.getLength());
700 sal_Int16 nWordType = WordType::DICTIONARY_WORD;
703 rxBreak->getWordBoundary(rText, sal_Int32(
nPos), aLocale, nWordType,
true);
706 if (aBndry.startPos == aBndry.endPos)
708 aBndry = rxBreak->previousWord(rText, sal_Int32(
nPos), aLocale, nWordType);
713 if (aBndry.endPos != aBndry.startPos
716 aBndry.endPos = aBndry.startPos;
723 return rText.copy(aBndry.startPos,
724 aBndry.endPos - aBndry.startPos);
729 sal_uInt16 nType, sal_Int32 nStart, sal_Int32 nEnd,
bool bClp )
731 [&rNd](sal_Int32 const nBegin, sal_uInt16 const nScript, bool const bNoChar)
732 {
return rNd.
GetLang(nBegin, bNoChar ? 0 : 1, nScript); }
733 , rText, pLang, rConvMap,
nType, nStart, nEnd, bClp)
740 sal_Int32 nEnd,
bool bClp)
741 : m_pGetLangOfChar(
std::move(aGetLangOfChar))
742 , m_aPreDashReplacementText(
std::move(aText))
746 , m_nOverriddenDashCount(0)
767 if (sDashes.indexOf(cChar) != -1)
795 sal_Int32 forceEachAsianCodePointToWord(
const OUString &rText, sal_Int32 nBegin, sal_Int32 nLen)
801 sal_uInt16 nCurrScript = rxBreak->getScriptType( rText, nBegin );
803 sal_Int32 indexUtf16 = nBegin;
804 rText.iterateCodePoints(&indexUtf16);
807 if (nCurrScript == i18n::ScriptType::ASIAN)
809 nLen = indexUtf16 - nBegin;
815 while (indexUtf16 < nBegin + nLen)
817 nCurrScript = rxBreak->getScriptType( rText, indexUtf16 );
818 if (nCurrScript == i18n::ScriptType::ASIAN)
820 nLen = indexUtf16 - nBegin;
823 rText.iterateCodePoints(&indexUtf16);
836 std::optional<CharClass> xLocalCharClass;
856 pCC = &*xLocalCharClass;
872 OSL_ENSURE( aBound.endPos >= aBound.startPos,
"broken aBound result" );
882 if(aBound.endPos == aBound.startPos)
905 OSL_ENSURE( aBound.endPos >=
m_nBegin,
"Unexpected aBound result" );
910 const sal_Int32 nScriptEnd =
m_nBegin +
912 const sal_Int32 nEnd =
std::min( aBound.endPos, nScriptEnd );
915 sal_Int32 nScriptBegin = 0;
919 aTmpWord =
m_aText.copy( aBound.startPos,
921 nScriptBegin = aBound.startPos +
926 m_nBegin = std::max( aBound.startPos, nScriptBegin );
932 OUString aTmpWord =
m_aText.copy( aBound.startPos,
933 aBound.endPos - aBound.startPos );
934 const sal_Int32 nScriptEnd = aBound.startPos +
936 const sal_Int32 nEnd =
std::min( aBound.endPos, nScriptEnd );
945 aBound.startPos = std::max( aBound.startPos,
m_nStartPos );
947 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,
1041 const OUString& rWord = aScanner.
GetWord();
1054 pArgs->
xSpellAlt = pArgs->
xSpeller->spell( rWord,
static_cast<sal_uInt16
>(eActLang),
1055 Sequence< PropertyValue >() );
1063 ( (bRestoreString || bContainsComments) && pArgs->
xSpeller->isValid( rWord.replaceAll(OUStringChar(
CH_TXTATR_INWORD),
""),
1064 static_cast<sal_uInt16
>(eActLang), Sequence< PropertyValue >() ) ) )
1076 sal_Int32 nLeft = 0;
1079 pChar = rWord.getLength() ? rWord.getStr() + rWord.getLength() - 1 :
nullptr;
1080 sal_Int32 nRight = 0;
1093 if ( bRestoreString )
1103 const vcl::Font *pFont, sal_uInt16 nFontWhichId )
1113 OSL_ENSURE( pFont,
"target font missing?" );
1122 aSet.
Put( aFontItem );
1149 const OUString aOldText(
m_Text );
1150 OUStringBuffer buf(
m_Text);
1151 const bool bRestoreString =
1155 m_Text = buf.makeStringAndClear();
1158 bool bFound =
false;
1159 sal_Int32 nBegin = nTextBegin;
1168 SwPaM aCurPaM( *
this, 0 );
1182 typedef std::pair<sal_Int32, sal_Int32> ImplicitChangesRange;
1183 std::vector<ImplicitChangesRange> aImplicitChanges;
1195 assert(nChPos != -1);
1198 nChPos =
m_Text.getLength();
1201 nLen = nChPos - nBegin;
1202 bFound = bLangOk && nLen > 0;
1207 SwPaM aCurPaM( *
this, nBegin );
1215 pEditShell->SetSelection( aCurPaM );
1216 bool bIsAsianScript = (SvtScriptType::ASIAN == pEditShell->GetScriptType());
1222 aImplicitChanges.emplace_back(nBegin, nBegin+nLen);
1227 }
while (!bFound && aIter.
Next());
1230 for (
const auto& rImplicitChange : aImplicitChanges)
1232 SwPaM aPaM( *
this, rImplicitChange.first );
1241 if (nBegin < nTextBegin)
1242 nBegin = nTextBegin;
1243 if (nBegin + nLen > nTextEnd)
1244 nLen = nTextEnd - nBegin;
1245 bool bInSelection = nBegin < nTextEnd;
1247 if (bFound && bInSelection)
1249 OSL_ENSURE( !
m_Text.isEmpty(),
"convertible text portion missing!" );
1260 if ( bRestoreString )
1280 const OUString aOldText( pNode->
GetText() );
1281 OUStringBuffer buf(pNode->
m_Text);
1283 const bool bRestoreString =
1287 pNode->
m_Text = buf.makeStringAndClear();
1292 sal_Int32 nBegin = 0;
1293 sal_Int32 nEnd = pNode->
GetText().getLength();
1294 sal_Int32 nInsertPos = 0;
1296 sal_Int32 nChgEnd = 0;
1298 sal_Int32 nInvEnd = 0;
1321 WordType::DICTIONARY_WORD,
true );
1322 nBegin = aBound.startPos;
1329 if( nInsertPos < pNode->GetWrong()->
Count() &&
1335 bool bFresh = nBegin < nEnd;
1336 bool bPending(
false);
1344 WordType::DICTIONARY_WORD, nBegin, nEnd);
1348 const OUString& rWord = aScanner.
GetWord();
1350 sal_Int32 nLen = aScanner.
GetLen();
1355 DetectAndMarkMissingDictionaries( rDoc, xSpell, eActLang );
1357 bool bSpell = xSpell.is() && xSpell->hasLanguage(
static_cast<sal_uInt16
>(eActLang) );
1358 if( bSpell && !rWord.isEmpty() && !
lcl_IsURL(rWord, *pNode, nBegin, nLen) )
1361 OSL_ENSURE(!bSpell || xSpell.is(),
"NULL pointer");
1362 if( !xSpell->isValid( rWord,
static_cast<sal_uInt16
>(eActLang), Sequence< PropertyValue >() ) &&
1366 ((!bRestoreString && !bContainsComments) || !xSpell->isValid( rWord.replaceAll(OUStringChar(
CH_TXTATR_INWORD),
""),
1367 static_cast<sal_uInt16
>(eActLang), Sequence< PropertyValue >() ) ) )
1369 sal_Int32 nSmartTagStt = nBegin;
1370 sal_Int32 nDummy = 1;
1379 nChgStart, nChgEnd, nBegin, nLen, nInsertPos, nActPos));
1383 pNode->
GetWrong()->
Insert(OUString(),
nullptr, nBegin, nLen, nInsertPos++);
1390 nInvEnd = nBegin + nLen;
1395 else if( bAddAutoCmpl && rACW.
GetMinWordLen() <= rWord.getLength() )
1399 bool bCursorOutsideWord = nActPos > nBegin + nLen || nActPos < nBegin;
1400 if (bCursorOutsideWord)
1409 if ( bRestoreString )
1411 pNode->
m_Text = aOldText;
1417 nEnd, 0, nInsertPos, nActPos );
1421 if( nChgStart < nChgEnd )
1426#if !ENABLE_WASM_STRIP_ACCESSIBILITY
1467 const OUString& rText = pNode->
GetText();
1474 sal_Int32 nBegin = 0;
1475 sal_Int32 nEnd = rText.getLength();
1477 if ( pSmartTagList )
1484 if ( nBegin < nEnd )
1490 if (nEnd > rText.getLength() || nEnd < 0)
1491 nEnd = rText.getLength();
1496 const sal_uInt16 nNumberOfEntries = pSmartTagList ? pSmartTagList->
Count() : 0;
1497 sal_uInt16 nNumberOfRemovedEntries = 0;
1498 sal_uInt16 nNumberOfInsertedEntries = 0;
1501 if ( 0 != nNumberOfEntries )
1504 sal_Int32 nChgEnd = 0;
1505 const sal_uInt16 nCurrentIndex = pSmartTagList->
GetWrongPos( nBegin );
1506 pSmartTagList->
Fresh( nChgStart, nChgEnd, nBegin, nEnd - nBegin, nCurrentIndex,
COMPLETE_STRING );
1507 nNumberOfRemovedEntries = nNumberOfEntries - pSmartTagList->
Count();
1510 if ( nBegin < nEnd )
1514 const OUString& aExpandText = aConversionMap.
getViewText();
1517 uno::Reference<text::XTextMarkup>
const xTextMarkup =
1528 sal_Int32 nLangBegin = nBegin;
1538 nLangEnd = std::min<sal_Int32>( nEnd, aIter.
GetChgPos() );
1545 nLangBegin = nLangEnd;
1547 while ( aIter.
Next() && nLangEnd < nEnd );
1551 const sal_uInt16 nNumberOfEntriesAfterRecognize = pSmartTagList ? pSmartTagList->
Count() : 0;
1552 nNumberOfInsertedEntries = nNumberOfEntriesAfterRecognize - ( nNumberOfEntries - nNumberOfRemovedEntries );
1565 if ( nBegin < nEnd && ( 0 != nNumberOfRemovedEntries ||
1566 0 != nNumberOfInsertedEntries ) )
1587 sal_Int32 nBegin = 0;
1588 sal_Int32 nEnd = pNode->
GetText().getLength();
1590 bool bACWDirty =
false;
1596 WordType::DICTIONARY_WORD, nBegin, nEnd );
1600 nLen = aScanner.
GetLen();
1603 const OUString& rWord = aScanner.
GetWord();
1605 if( nActPos < nBegin || ( nBegin + nLen ) < nActPos )
1642 if (wordStart.first != &rNode || wordEnd.first != &rNode)
1644 SAL_WARN(
"sw.core",
"UpdateTextNodeHyphInfo: outside of node");
1648 o_rHyphInfo.
m_nWordLen = wordEnd.second - wordStart.second;
1663 [&rHyphInf,
this]() {
1664 std::pair<Point, bool> tmp;
1668 tmp.first = *pPoint;
1673 nullptr, pPoint ? &tmp :
nullptr));
1680 OSL_ENSURE( pFrame,
"!SwTextNode::Hyphenate: can't find any frame" );
1709 struct swTransliterationChgData
1714 Sequence< sal_Int32 > aOffsets;
1721 sal_Int32 nStt, sal_Int32 nEnd,
1727 const sal_Int32 selStart = nStt;
1728 const sal_Int32 selEnd = nEnd;
1735 const sal_Int16 nWordType = WordType::ANYWORD_IGNOREWHITESPACES;
1743 std::vector< swTransliterationChgData > aChanges;
1744 swTransliterationChgData aChgData;
1746 if (rTrans.
getType() == TransliterationFlags::TITLE_CASE)
1764 if (aSttBndry.endPos <= nStt)
1772 if (aEndBndry.startPos >= nEnd)
1775 GetText(), aEndBndry.startPos,
1782 if (aSttBndry.startPos >= selEnd || aEndBndry.endPos <= selStart) {
1788 aSttBndry.startPos = std::max(aSttBndry.startPos, selStart);
1789 aEndBndry.startPos = std::max(aSttBndry.startPos, aEndBndry.startPos);
1791 Boundary aCurWordBndry( aSttBndry );
1792 while (aCurWordBndry.startPos <= aEndBndry.startPos)
1794 nStt = aCurWordBndry.startPos;
1795 nEnd = aCurWordBndry.endPos;
1796 const sal_Int32 nLen = nEnd - nStt;
1797 OSL_ENSURE( nLen > 0,
"invalid word length of 0" );
1799 Sequence <sal_Int32> aOffsets;
1803 assert(nStt <
m_Text.getLength());
1804 if (0 != rtl_ustr_shortenedCompare_WithLength(
1806 sChgd.getStr(), sChgd.getLength(), nLen))
1808 aChgData.nStart = nStt;
1809 aChgData.nLen = nLen;
1810 aChgData.sChanged = sChgd;
1811 aChgData.aOffsets = aOffsets;
1812 aChanges.push_back( aChgData );
1821 else if (rTrans.
getType() == TransliterationFlags::SENTENCE_CASE)
1835 sal_Int32 nCurrentStart = nStt;
1842 if (nCurrentEnd <= nStt)
1851 i18n::WordType::DICTIONARY_WORD);
1862 if (nLastStart >= nEnd)
1871 i18n::WordType::DICTIONARY_WORD);
1875 if (nCurrentEnd > nLastEnd)
1876 nCurrentEnd = nLastEnd;
1880 nCurrentStart = std::max(selStart, nCurrentStart);
1881 nCurrentEnd =
std::min(selEnd, nCurrentEnd);
1882 nLastEnd =
std::min(selEnd, nLastEnd);
1884 while (nCurrentStart < nLastEnd)
1886 sal_Int32 nLen = nCurrentEnd - nCurrentStart;
1887 OSL_ENSURE( nLen > 0,
"invalid word length of 0" );
1889 Sequence <sal_Int32> aOffsets;
1891 GetLang(nCurrentStart), nCurrentStart, nLen, &aOffsets) );
1893 assert(nStt <
m_Text.getLength());
1894 if (0 != rtl_ustr_shortenedCompare_WithLength(
1896 sChgd.getStr(), sChgd.getLength(), nLen))
1898 aChgData.nStart = nCurrentStart;
1899 aChgData.nLen = nLen;
1900 aChgData.sChanged = sChgd;
1901 aChgData.aOffsets = aOffsets;
1902 aChanges.push_back( aChgData );
1909 nCurrentStart = aFirstWordBndry.startPos;
1919 std::unique_ptr<SwLanguageIterator> pIter;
1923 sal_Int32 nEndPos = 0;
1928 nLang = pIter->GetLanguage();
1929 nEndPos = pIter->GetChgPos();
1930 if( nEndPos > nEnd )
1938 const sal_Int32 nLen = nEndPos - nStt;
1940 Sequence <sal_Int32> aOffsets;
1944 assert(nStt <
m_Text.getLength());
1945 if (0 != rtl_ustr_shortenedCompare_WithLength(
1947 sChgd.getStr(), sChgd.getLength(), nLen))
1949 aChgData.nStart = nStt;
1950 aChgData.nLen = nLen;
1951 aChgData.sChanged = sChgd;
1952 aChgData.aOffsets = aOffsets;
1953 aChanges.push_back( aChgData );
1957 }
while( nEndPos < nEnd && pIter && pIter->
Next() );
1960 if (aChanges.empty())
1967 for (
size_t i = 0;
i < aChanges.size(); ++
i)
1970 swTransliterationChgData & rData =
1971 aChanges[ aChanges.size() - 1 -
i ];
1973 nSum += rData.sChanged.getLength() - rData.nLen;
1976 SAL_WARN(
"sw.core",
"SwTextNode::ReplaceTextOnly: "
1977 "node text with insertion > node capacity.");
1981 if ( bUseRedlining )
1985 SwPaM aCurPaM( *
this, rData.nStart );
1989 if ( aCurPaM.
GetText() != rData.sChanged )
1995 pUndo->
AddChanges( *
this, rData.nStart, rData.nLen, rData.aOffsets );
1996 ReplaceTextOnly( rData.nStart, rData.nLen, rData.sChanged, rData.aOffsets );
2002 std::u16string_view aText,
2003 const Sequence<sal_Int32>& rOffsets )
2005 assert(sal_Int32(aText.size()) - nLen <=
GetSpaceLeft());
2009 sal_Int32 nTLen = aText.size();
2010 const sal_Int32* pOffsets = rOffsets.getConstArray();
2012 sal_Int32 nMyOff =
nPos;
2013 for( sal_Int32 nI = 0; nI < nTLen; ++nI )
2015 const sal_Int32 nOff = pOffsets[ nI ];
2020 while( nI + nCnt < nTLen && nOff == pOffsets[ nI + nCnt ] )
2028 else if( nOff > nMyOff )
2042 CallSwClientNotify(aDelHint);
2045 CallSwClientNotify(aInsHint);
2051 sal_Int32 nStt, sal_Int32 nEnd )
const
2061 bool bCountAll = ( (0 == nStt) && (
GetText().getLength() == nEnd) );
2068 bool bCountNumbering = nStt == 0;
2069 bool bHasBullet =
false, bHasNumbering =
false;
2070 OUString sNumString;
2071 if (bCountNumbering)
2074 bHasNumbering = !sNumString.isEmpty();
2077 bCountNumbering = bHasNumbering || bHasBullet;
2080 if( nStt == nEnd && !bCountNumbering)
2108 const OUString& aExpandText = aConversionMap.
getViewText();
2110 if (aExpandText.isEmpty() && !bCountNumbering)
2127 sal_uInt32 nTmpWords = 0;
2128 sal_uInt32 nTmpAsianWords = 0;
2129 sal_uInt32 nTmpChars = 0;
2130 sal_uInt32 nTmpCharsExcludingSpaces = 0;
2133 if (!aExpandText.isEmpty())
2138 SwScanner aScanner( *
this, aExpandText,
nullptr, aConversionMap, i18n::WordType::WORD_COUNT,
2139 nExpandBegin, nExpandEnd,
true );
2146 if( !aExpandText.match(aBreakWord, aScanner.
GetBegin() ))
2149 const OUString &rWord = aScanner.
GetWord();
2171 i18n::WordType::WORD_COUNT, 0, sNumString.getLength(),
true );
2176 const OUString &rWord = aScanner.
GetWord();
2185 else if ( bHasBullet )
2189 ++nTmpCharsExcludingSpaces;
2202 rStat.
nWord += nTmpWords;
2204 rStat.
nChar += nTmpChars;
2264 "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)
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
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
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
CharClass & GetAppCharClass()
#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.