20#include <libxml/xmlwriter.h>
28#include <osl/diagnose.h>
67#define CHECK_TABLE(t) (t).CheckConsistency();
101 for(
n = 0;
n < rText.getLength() &&
' ' >= ( c = rText[
n] ); ++
n )
103 rText = rText.replaceAt(
n, 1,
u" " );
104 for(
n = rText.getLength();
n &&
' ' >= ( c = rText[--
n] ); )
106 rText = rText.replaceAt(
n, 1,
u" " );
114 OUStringBuffer sBuff(rText);
116 for(
n = 0;
n < sBuff.getLength() &&
' ' >= ( c = sBuff[
n ]); ++
n )
119 sBuff.remove(
n--, 1 );
121 for(
n = sBuff.getLength();
n &&
' ' >= ( c = sBuff[ --
n ]); )
124 sBuff.remove(
n, 1 );
126 rText = sBuff.makeStringAndClear();
133 sal_uInt16 nInsPos, sal_uInt16 nCnt )
135 OSL_ENSURE( pBox->
GetSttNd(),
"Box with no start node" );
140 OSL_ENSURE( pCNd,
"Box with no content node" );
150 const std::shared_ptr<SfxItemSet>& handle = format.
GetStyleHandle();
151 aAttrSet.
Put(*handle);
161 static_cast<SwTextNode*
>(pCNd)->GetTextColl(),
162 &aAttrSet, nInsPos, nCnt );
166 static_cast<SwTextNode*
>(pCNd)->GetTextColl(),
178 for( sal_uInt16
i = 0;
i < nCnt; ++
i )
180 pBox = rTableBoxes[
i + nInsPos ];
188 m_pTableNode( nullptr ),
189 m_nGraphicsThatResize( 0 ),
190 m_nRowsToRepeat( 1 ),
191 m_bModifyLocked( false ),
199 :
SwClient( rTable.GetFrameFormat() ),
200 m_pTableNode( nullptr ),
201 m_eTableChgMode( rTable.m_eTableChgMode ),
202 m_nGraphicsThatResize( 0 ),
203 m_nRowsToRepeat( rTable.GetRowsToRepeat() ),
204 maTableStyleName(rTable.maTableStyleName),
205 m_bModifyLocked( false ),
206 m_bNewModel( rTable.m_bNewModel )
212 for (
size_t n = 0;
n < rSortCntBoxes.
size(); ++
n)
214 rSortCntBoxes[
n ]->m_pStartNode =
nullptr;
231 pFormat->Remove(
this );
233 if( !pFormat->HasWriterListeners() )
248T lcl_MulDiv64(sal_uInt64 nA, sal_uInt64 nM, sal_uInt64 nD)
251 return nD == 0 ?
static_cast<T
>(nA*nM) :
static_cast<T
>((nA*nM)/nD);
258 std::vector<SwFormat*>::const_iterator it = std::find( rFormatArr.begin(), rFormatArr.end(), pBoxFormat );
259 if ( it == rFormatArr.end() )
260 rFormatArr.push_back( pBoxFormat );
264 const tools::Long nNew, std::vector<SwFormat*>& rFormatArr );
267 const tools::Long nNew, std::vector<SwFormat*>& rFormatArr,
const bool bCheckSum )
269 for (
auto &rLine : rLines)
275 const SwTwips nBox = lcl_MulDiv64<SwTwips>(pFormat->GetFrameSize().GetWidth(), nNew, nOld);
277 pFormat->LockModify();
278 pFormat->SetFormatAttr( aNewBox );
279 pFormat->UnlockModify();
285 const tools::Long nNew, std::vector<SwFormat*>& rFormatArr )
288 sal_uInt64 nOriginalSum = 0;
289 for (
size_t i = 0;
i < rBoxes.size(); ++
i )
300 nOriginalSum += nBox;
301 nBox = lcl_MulDiv64<sal_uInt64>(nBox, nNew, nOld);
302 const sal_uInt64 nWishedSum = lcl_MulDiv64<sal_uInt64>(nOriginalSum, nNew, nOld) - nSum;
305 if( nBox == nWishedSum )
312 pFormat->LockModify();
314 pFormat->UnlockModify();
318 OSL_FAIL(
"Rounding error" );
326 if (rHint.
GetId() != SfxHintId::SwLegacyModify)
330 const sal_uInt16 nWhich = pLegacy->
GetWhich();
336 if (pLegacy->m_pOld && pLegacy->m_pNew
341 pOldSize = &
static_cast<const SwAttrSetChg*
>(pLegacy->m_pOld)->GetChgSet()->GetFrameSize();
360 std::vector<SwFormat*> aFormatArr;
361 aFormatArr.reserve(
m_aLines[0]->GetTabBoxes().
size() );
367 for (
size_t i = 0;
i < rToFill.
Count(); ++
i )
379 const bool bRefreshHidden )
382 OSL_ENSURE(nWish,
"weird <= 0 width frmfrm");
399 for (
size_t i = 0;
i < rBoxes.size(); ++
i )
401 const SwTwips nWidth = rBoxes[
i]->GetFrameFormat()->GetFrameSize().GetWidth();
403 const tools::Long nTmp = lcl_MulDiv64<tools::Long>(nSum, nAct, nWish);
405 if (rBoxes[
i] != pCur)
407 if ( pLine == pBox->
GetUpper() || 0 == nLeftMin )
408 nLeftMin = nTmp -
nPos;
414 if ( 0 == nRightMax )
415 nRightMax = nTmp -
nPos;
420 pLine = pCur ? pCur->
GetUpper() :
nullptr;
424 bool bInsert = !bRefreshHidden;
425 for (
size_t j = 0; bInsert && (j < rToFill.
Count()); ++j )
433 else if (
nPos < nCmp )
441 else if ( bRefreshHidden )
444 if ( !bHidden || bRefreshHidden )
448 nLeftMin =
nPos - nLeftMin;
449 nRightMax =
nPos + nRightMax;
452 bool bFoundPos =
false;
453 bool bFoundMax =
false;
454 for (
size_t j = 0; !(bFoundPos && bFoundMax ) && j < rToFill.
Count(); ++j )
464 if ( nLeftMin > nOldMin )
465 rEntry.
nMin = nLeftMin;
468 if ( nRightMax < nOldMax )
469 rEntry.
nMax = nRightMax;
478 if (
nPos > nOldMin )
492 for (
size_t i = 0;
i < rLines.
size(); ++
i )
495 for (
size_t j = 0; j < rBoxes.size(); ++j )
518 bool bRefreshHidden,
bool bCurRowOnly )
const
521 if ( bRefreshHidden )
524 for (
size_t i = 0;
i < rToFill.
Count(); ++
i )
533 for (
size_t i = 0;
i < rToFill.
Count(); ++
i )
560 for (
size_t i = 0;
i < rBoxes.size(); ++
i )
569 for (
size_t k = 0; k < rBoxes2.size(); ++k )
571 pTabFormat,
false, bRefreshHidden );
575 if ( !bRefreshHidden )
591 for (
size_t i = 0;
i < rToFill.
Count(); ++
i )
620 for (
size_t i = rBoxes.size();
i > 0; )
632 for (
size_t i = rLines.
size();
i > 0; )
657 for (
size_t i = 0; (
i < rBoxes.size()) && (rBoxes[
i] != pCur); ++
i)
659 nLeft += lcl_MulDiv64<tools::Long>(
660 rBoxes[
i]->GetFrameFormat()->GetFrameSize().GetWidth(),
664 pLine = pCur ? pCur->
GetUpper() :
nullptr;
671 const tools::Long nWidth = lcl_MulDiv64<tools::Long>(
676 size_t nRightPos = 0;
677 bool bFoundLeftPos =
false;
678 bool bFoundRightPos =
false;
685 bFoundLeftPos =
true;
691 bFoundRightPos =
true;
694 nLeftDiff = bFoundLeftPos ?
695 rParm.
rOld[nLeftPos] - rParm.
rNew[nLeftPos] : 0;
696 nRightDiff= bFoundRightPos ?
697 rParm.
rNew[nRightPos] - rParm.
rOld[nRightPos] : 0;
705 const tools::Long nWidth = lcl_MulDiv64<tools::Long>(
725 if(
nPos && rTableBoxes[
nPos - 1 ]->getRowSpan() != 1 )
727 if(
nPos + 1 < o3tl::narrowing<sal_uInt16>(rTableBoxes.size()) &&
728 rTableBoxes[
nPos + 1 ]->getRowSpan() != 1 )
732 nLeftDiff = nRightDiff = 0;
734 if ( nLeftDiff || nRightDiff )
752 if ( aFormatFrameSize.
GetWidth() < 0 )
785 for (
size_t i = 0;
i < rLines.
size(); ++
i )
788 for (
size_t j = 0; j < rBoxes.size(); ++j )
793 rBoxArr.push_front( pBox );
795 rBoxArr.push_back( pBox );
802 for (
size_t i = 0;
i < rLines.
size(); ++
i )
805 [rLines[
i]->GetTabBoxes().
size()-1];
833 Parm aParm( rNew, rOld );
835 OSL_ENSURE( rOld.
Count() == rNew.
Count(),
"Number of columns changed.");
864 const bool bLeftDist = rNew.
GetLeft() != nShLeft;
866 if(!bLeftDist && !bRightDist)
868 else if(!bRightDist && rNew.
GetLeft() > nShLeft )
935 for (
size_t i = 0;
i < rBoxes.size(); ++
i )
945 for (
size_t i = 0;
i < rBoxes2.size(); ++
i )
947 if ( rBoxes2[
i] != pExcl )
957 for (
int j = aParm.
aBoxArr.size()-1; j >= 0; --j )
969 for (
size_t i = rLines.
size();
i > 0; )
993 Parm& rParm, sal_uInt16 nColFuzzy )
995 ChangeList::iterator pCurr = rOldNew.begin();
996 if( pCurr == rOldNew.end() )
1005 SwTwips nNewWidth = nWidth - nRest;
1008 if( pCurr != rOldNew.end() &&
nBorder + nColFuzzy >= pCurr->first )
1011 while( pCurr != rOldNew.end() &&
nBorder > pCurr->first )
1013 if( pCurr != rOldNew.end() )
1016 if(
nBorder + nColFuzzy >= pCurr->first )
1018 if( pCurr->second == pCurr->first )
1021 nRest = pCurr->second -
nBorder;
1027 if( nNewWidth != nWidth )
1031 nRest += 1 - nNewWidth;
1035 aFormatFrameSize.
SetWidth( nNewWidth );
1044 if( rChanges.empty() )
1049 if( rSpanPos.empty() )
1054 std::vector<sal_uInt16> aNewSpanPos;
1055 ChangeList::iterator pCurr = rChanges.begin();
1057 std::vector<sal_uInt16>::iterator pSpan = rSpanPos.begin();
1058 sal_uInt16 nCurr = 0;
1060 bool bRowSpan =
false;
1061 sal_uInt16 nRowSpanCount = 0;
1063 for(
size_t nCurrBox = 0; nCurrBox <
nCount; ++nCurrBox )
1067 const sal_Int32 nRowSpan = pBox->
getRowSpan();
1068 const bool bCurrRowSpan = bTop ? nRowSpan < 0 :
1069 ( nRowSpan > 1 || nRowSpan < -1 );
1070 if( bRowSpan || bCurrRowSpan )
1071 aNewSpanPos.push_back( nRowSpanCount );
1072 bRowSpan = bCurrRowSpan;
1073 nOrgSum += nCurrWidth;
1074 const sal_uInt16
nPos = lcl_MulDiv64<sal_uInt16>(
1075 lcl_MulDiv64<sal_uInt64>(nOrgSum, nWidth, nWish),
1077 while( pCurr != rChanges.end() && pCurr->first <
nPos )
1083 if( pCurr != rChanges.end() && pCurr->first <=
nPos &&
1084 pCurr->first != pCurr->second )
1086 pSpan = std::find_if(pSpan, rSpanPos.end(),
1087 [nCurr](
const sal_uInt16 nSpan) { return nSpan >= nCurr; });
1088 if( pSpan != rSpanPos.end() && *pSpan == nCurr )
1090 aNewChanges.push_back( *pCurr );
1098 aNewChanges.push_back( aTmp );
1103 pCurr = aNewChanges.begin();
1104 ChangeList::iterator pLast = pCurr;
1105 ChangeList::iterator pLeftMove = pCurr;
1106 while( pCurr != aNewChanges.end() )
1108 if( pLeftMove == pCurr )
1110 while( ++pLeftMove != aNewChanges.end() && pLeftMove->first <= pLeftMove->second )
1113 if( pCurr->second == pCurr->first )
1115 if( pLeftMove != aNewChanges.end() && pCurr->second > pLeftMove->second )
1117 if( pLeftMove->first == pLast->first )
1118 pCurr->second = pLeftMove->second;
1121 pCurr->second = lcl_MulDiv64<sal_uInt16>(
1122 pCurr->first - pLast->first,
1123 pLeftMove->second - pLast->second,
1124 pLeftMove->first - pLast->first) + pLast->second;
1130 else if( pCurr->second > pCurr->first )
1134 ChangeList::iterator pNext = pCurr;
1135 while( pNext != pLeftMove && pNext->second == pNext->first &&
1136 pNext->second < pLast->second )
1138 while( pCurr != pNext )
1140 if( pNext == aNewChanges.end() || pNext->first == pLast->first )
1141 pCurr->second = pLast->second;
1144 pCurr->second = lcl_MulDiv64<sal_uInt16>(
1145 pCurr->first - pLast->first,
1146 pNext->second - pLast->second,
1147 pNext->first - pLast->first) + pLast->second;
1160 rChanges.swap(aNewChanges);
1161 rSpanPos.swap(aNewSpanPos);
1167#if OSL_DEBUG_LEVEL > 1
1168 static int nCallCount = 0;
1175 if( nNewWidth < 1 || nOldWidth < 1 )
1177 for(
size_t i = 0;
i <= rOld.
Count(); ++
i )
1191 nNewPos = lcl_MulDiv64<tools::Long>(nNewPos, rParm.
nNewWish, nNewWidth);
1192 nOldPos = lcl_MulDiv64<tools::Long>(nOldPos, rParm.
nOldWish, nOldWidth);
1193 if( nOldPos != nNewPos && nNewPos > 0 && nOldPos > 0 )
1195 ColChange aChg( o3tl::narrowing<sal_uInt16>(nOldPos), o3tl::narrowing<sal_uInt16>(nNewPos) );
1196 aOldNew.push_back( aChg );
1200 int nCount = aOldNew.size();
1207 sal_uInt16 nCurr = rLines.
GetPos( pCurrLine );
1208 if( nCurr >= USHRT_MAX )
1212 aOldNew.push_front( aChg );
1213 std::vector<sal_uInt16> aRowSpanPos;
1217 sal_uInt16
nPos = 0;
1218 for(
const auto& rCop : aOldNew )
1220 aCopy.push_back( rCop );
1221 aRowSpanPos.push_back(
nPos++ );
1225 bool bGoOn = !aRowSpanPos.empty();
1226 sal_uInt16 j = nCurr;
1232 bGoOn = !aRowSpanPos.empty() && j > 0;
1234 aRowSpanPos.clear();
1236 if( nCurr+1 < o3tl::narrowing<sal_uInt16>(rLines.
size()) )
1239 sal_uInt16
nPos = 0;
1240 for(
const auto& rCop : aOldNew )
1242 aCopy.push_back( rCop );
1243 aRowSpanPos.push_back(
nPos++ );
1246 rParm.
nOldWish, nOldWidth,
false );
1247 bool bGoOn = !aRowSpanPos.empty();
1248 sal_uInt16 j = nCurr;
1252 rParm.
nOldWish, nOldWidth,
false );
1254 bGoOn = !aRowSpanPos.empty() && j+1 < o3tl::narrowing<sal_uInt16>(rLines.
size());
1261 for(
size_t i = 0;
i < rLines.
size(); ++
i )
1270 bool bIsValid =
true;
1271 size_t nLen = rStr.size();
1272 for(
size_t i = 0;
i < nLen && bIsValid; ++
i )
1275 if (cChar < '0' || cChar >
'9')
1284 const bool bPerformValidCheck )
1286 sal_uInt16 nRet = 0;
1293 bool overflow =
false;
1294 while (
nPos<rStr.getLength())
1297 if ((cChar<'A' || cChar>
'Z') && (cChar<'a' || cChar>
'z'))
1306 num = num * 52 + cChar;
1313 rStr = rStr.copy(
nPos );
1317 const sal_Int32
nPos = rStr.indexOf(
"." );
1323 nRet = o3tl::narrowing<sal_uInt16>(rStr.toInt32());
1330 const std::u16string_view aText( rStr.subView( 0,
nPos ) );
1335 rStr = rStr.copy(
nPos+1 );
1344 const bool bPerformValidCheck )
const
1350 sal_uInt16 nLine, nBox;
1351 OUString aNm( rName );
1352 while( !aNm.isEmpty() )
1368 if( !nLine || nLine > pLines->
size() )
1370 pLine = (*pLines)[ nLine-1 ];
1374 if( nBox >= pBoxes->size() )
1376 pBox = (*pBoxes)[ nBox ];
1382 OSL_FAIL(
"Box without content, looking for the next one!" );
1405 pTableNd = rNds[
nIndex ]->GetTableNode();
1409 pCNd = rNds[
nIndex ]->GetContentNode();
1416 if ( pCNd || pTableNd )
1418 sw::BroadcastingModify* pModify = pCNd;
1476 pMod->Remove(
this );
1477 if( !pMod->HasWriterListeners() )
1491 if ( pLast !=
this )
1496 *pNewFormat = *pRet;
1501 if( pFrame->GetTabLine() ==
this )
1502 pFrame->RegisterToFormat( *pNewFormat );
1505 pNewFormat->Add(
this );
1519 pNewFormat->Add(
this);
1520 if(!pOld->HasWriterListeners())
1527 bLayoutAvailable =
false;
1534 if (pLast->GetTabLine() !=
this)
1547 if (!pChain || pChain->IsAnFollow( pTab ) || pTab->IsAnFollow(pChain))
1553 nRet += pLast->getFrameArea().Height();
1555 if( !pTab->HasFollow() && !pTab->IsFollow() )
1589 if ( aRedlineTable.
empty() )
1604 if ( aRedlineTable.
empty() )
1622 std::vector<SwFormatField*> vFields;
1624 for(
auto pFormatField : vFields)
1631 if(pTableNd ==
nullptr || &pTableNd->
GetTable() !=
this)
1661 if(pBoxFormula && pBoxFormula->GetDefinedIn())
1666 pBoxFormula->ChangeState(&aHint);
1673 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwTable"));
1674 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
1675 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"table-format"),
"%p",
GetFrameFormat());
1678 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwTableLine"));
1679 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p", pLine);
1680 pLine->GetFrameFormat()->dumpAsXml(pWriter);
1681 (void)xmlTextWriterEndElement(pWriter);
1683 (void)xmlTextWriterEndElement(pWriter);
1701 if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() )
1704 size_t nBoxes = rBoxes.size();
1705 bool bInsertion =
false;
1706 bool bPlainTextInLine =
false;
1709 for (
size_t nBoxIndex = 0; nBoxIndex < nBoxes && rRedlinePos < aRedlineTable.
size(); ++nBoxIndex)
1711 auto pBox = rBoxes[nBoxIndex];
1712 if ( pBox->IsEmpty(
false ) )
1718 bool bHasRedlineInBox =
false;
1723 for( ; rRedlinePos < aRedlineTable.
size(); ++rRedlinePos )
1735 if ( aCellStart <= *pRedline->
Start() )
1737 if ( !bHasRedlineInBox )
1739 bHasRedlineInBox =
true;
1742 bPlainTextInLine =
true;
1750 if ( RedlineType::Insert ==
nType )
1757 if ( pPreviousDeleteRedline &&
1758 *pPreviousDeleteRedline->
End() < *pRedline->
Start() &&
1763 bPlainTextInLine =
true;
1771 aRedlineTable[nNewestRedline]->GetRedlineData().GetTimeStamp() <
1774 nNewestRedline = rRedlinePos;
1777 aRedlineTable[nOldestRedline]->GetRedlineData().GetTimeStamp() >
1780 nOldestRedline = rRedlinePos;
1786 if ( !bInsertion && ( !bHasRedlineInBox || ( pPreviousDeleteRedline &&
1794 bPlainTextInLine =
true;
1803 RedlineType::Insert == aRedlineTable[ nOldestRedline ]->GetType() )
1806 nRet = nOldestRedline;
1809 RedlineType::Delete == aRedlineTable[ nNewestRedline ]->GetType() )
1814 nRet = nNewestRedline;
1823 if ( bUpdateProperty )
1827 pFormat->LockModify();
1829 pFormat->UnlockModify();
1837 : aRedlineTable[ nRet ]->GetType());
1849 if ( RedlineType::Delete == aRedlineTable[
nPos]->GetType() )
1858 if ( aRedlineTable.
empty() )
1859 return RedlineType::None;
1865 if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() )
1873 return aRedlineTable[
nPos]->GetType();
1879 return RedlineType::None;
1885 , m_pStartNode(nullptr)
1888 , mbDummyFlag(false)
1889 , mbDirectFormatting(false)
1901 , mbDummyFlag(false)
1902 , mbDirectFormatting(false)
1910 assert(pTableNd &&
"In which table is that box?");
1920 , m_pStartNode(&rSttNd)
1923 , mbDummyFlag(false)
1924 , mbDirectFormatting(false)
1930 OSL_ENSURE( pTableNd,
"In which table is the box?" );
1943 assert(pTableNd &&
"In which table is that box?");
1961 pMod->Remove(
this );
1962 if( !pMod->HasWriterListeners() )
1977 pNewFormat->LockModify();
1978 *pNewFormat = *pFormat;
1982 pNewFormat->UnlockModify();
1984 pFormat = pNewFormat;
2000 if ( pLast !=
this )
2006 pNewFormat->LockModify();
2007 *pNewFormat = *pRet;
2009 pNewFormat->UnlockModify();
2014 if( pCell->GetTabBox() ==
this )
2015 pCell->RegisterToFormat( *pNewFormat );
2018 pNewFormat->Add(
this );
2032 if(bNeedToReregister)
2035 pNewFormat->Add(
this);
2036 if(!pOld->HasWriterListeners())
2044 const sal_uInt16 coDiff = 52;
2047 const sal_uInt16 nCalc = nCol % coDiff;
2049 rNm = OUStringChar(
sal_Unicode(
'a' - 26 + nCalc) ) + rNm;
2051 rNm = OUStringChar(
sal_Unicode(
'A' + nCalc) ) + rNm;
2053 nCol = nCol - nCalc;
2066 return Point( 0, 0 );
2078 nY = pLines->
GetPos( pLine ) + 1 ;
2082 return Point( nX, nY );
2104 sTmp = OUString::number(
nPos );
2105 if( !sNm.isEmpty() )
2106 sNm = sTmp +
"." + sNm;
2111 sTmp = OUString::number(
nPos + 1);
2113 if(
nullptr != pBox )
2114 sNm = sTmp +
"." + sNm;
2156 if ( pCNd && !pCNd->
Len() )
2159 else if ( bWithRemainingNestedTable )
2166 return pTableNode->GetTable().IsEmpty();
2176 switch( rInfo.
Which() )
2257 if( SvxAdjust::Left == eAdjust || SvxAdjust::Block == eAdjust )
2271 std::optional<Color> pNewUserColor;
2273 pNewUserColor = pColorItem->
GetValue();
2275 if( ( pNewUserColor && pOldNumFormatColor &&
2276 *pNewUserColor == *pOldNumFormatColor ) ||
2277 ( !pNewUserColor && !pOldNumFormatColor ))
2283 else if( pColorItem )
2295 rBox.
SetSaveUserColor( pNewUserColor ? *pNewUserColor : std::optional<Color>() );
2304 if( pTNd->
GetText() != rText )
2307 const OUString& rOrig = pTNd->
GetText();
2312 for( ;
n < rOrig.getLength() &&
'\x01' == rOrig[
n]; ++
n )
2317 sal_Int32 nEndPos =
n;
2328 SwPaM aTemp(*pTNd, 0, *pTNd, rOrig.getLength());
2334 while( nCommentPos > aIdx.
GetIndex() )
2340 nEndPos = nCommentPos;
2345 while( nCommentPos > aIdx.
GetIndex() && nCommentPos == nEndPos );
2353 SwPaM aTemp(*pTNd, 0, *pTNd, rText.getLength());
2362 text::VertOrientation::TOP == pVertOrientItem->
GetVertOrient() ))
2379 const Color * pCol =
nullptr;
2384 const OUString sText( pTNd->
GetText() );
2401 if( bChgAlign && pAttrSet &&
2403 SvxAdjust::Right == pAdjustItem->
GetAdjust() )
2414 std::optional<Color> pNewUserColor;
2416 pNewUserColor = pColorItem->
GetValue();
2418 if( ( pNewUserColor && pOldNumFormatColor &&
2419 *pNewUserColor == *pOldNumFormatColor ) ||
2420 ( !pNewUserColor && !pOldNumFormatColor ))
2426 else if( pColorItem )
2451 text::VertOrientation::BOTTOM == pVertOrientItem->
GetVertOrient() )
2462 nNewFormat = pNewFormat->
GetValue();
2466 pNewFormat =
nullptr;
2473 nNewFormat = pNewFormat ? pNewFormat->
GetValue() : nOldFormat;
2479 if(
GetDoc()->GetNumberFormatter()->IsTextFormat(nNewFormat))
2501 bool bNewIsTextFormat = pNumFormatr->
IsTextFormat(nNewFormat);
2503 if((!bNewIsTextFormat && nOldFormat != nNewFormat) || pNewFormula)
2505 bool bIsNumFormat =
false;
2507 bool bChgText =
true;
2517 sal_uInt32 nTmpFormatIdx = nNewFormat;
2518 OUString aText(
GetDoc()->GetNodes()[nNdPos] ->GetTextNode()->GetRedlineText());
2529 if(SvNumFormatType::PERCENT == pNumFormatr->
GetType(nNewFormat))
2531 sal_uInt32 nTmpFormat = 0;
2532 if(
GetDoc()->IsNumberFormat(aText, nTmpFormat, fVal))
2534 if(SvNumFormatType::NUMBER == pNumFormatr->
GetType( nTmpFormat))
2546 bool bIsLockMod = IsModifyLocked();
2558 bIsNumFormat =
true;
2562 const Color* pCol =
nullptr;
2564 bool bChangeFormat =
true;
2587 sNewText = aOrigText;
2595 bChangeFormat =
false;
2608 else if(bNewIsTextFormat && nOldFormat != nNewFormat)
2612SwTableBox* SwTableBoxFormat::SwTableBoxFormat::GetTableBox()
2615 auto pBox = aIter.First();
2616 SAL_INFO_IF(!pBox,
"sw.core",
"no box found at format");
2617 SAL_WARN_IF(pBox && aIter.Next(),
"sw.core",
"more than one box found at format");
2624 if(rHint.
GetId() != SfxHintId::SwLegacyModify)
2637 switch(pLegacy->m_pNew ? pLegacy->m_pNew->Which() : 0)
2662 if( pNewFormat || pNewFormula || pNewVal )
2694 bool& rIsEmptyTextNd )
const
2703 rIsEmptyTextNd = aText.isEmpty();
2708 rFormatIndex = pItem->GetValue();
2710 if( !rIsEmptyTextNd && SvNumFormatType::PERCENT == pNumFormatr->
GetType( rFormatIndex ))
2712 sal_uInt32 nTmpFormat = 0;
2713 if(
GetFrameFormat()->GetDoc()->IsNumberFormat( aText, nTmpFormat, rNum ) &&
2714 SvNumFormatType::NUMBER == pNumFormatr->
GetType( nTmpFormat ))
2724 rIsEmptyTextNd =
false;
2741 GetTextNode()->GetRedlineText() );
2744 const Color* pCol =
nullptr;
2748 bRet = sNewText != sOldText ||
2766 while( ++
nIndex < nIndexEnd )
2771 pTextNode =
nullptr;
2778 pTextNode =
nullptr;
2797 sal_Int32 nNextSetField = 0;
2798 for(
size_t n = 0;
n < pHts->
Count(); ++
n )
2801 if( RES_TXTATR_NOEND_BEGIN <= pAttr->Which() )
2803 if ( (pAttr->
GetStart() == nNextSetField)
2817 nNextSetField = pAttr->
GetStart() + 1;
2842 sal_uInt16 nWhich = 0;
2853 ->GetTextNode() ) && pTNd->
GetText().isEmpty())
2876 double fVal = pValItem->
GetValue();
2877 const Color* pCol =
nullptr;
2882 if( rText != sNewText )
2920 const SwFrame * pResult =
nullptr;
2928 while (pFrame->
GetUpper() !=
nullptr)
2953 while ((pFrame = getNextFrameInTable(pFrame)) !=
nullptr)
2957 pResult =
static_cast<const SwCellFrame *
>(pFrame);
2969 while ((pFrame = getNextCellFrame(pFrame)) !=
nullptr)
2973 auto aIt = m_HandledTableBoxes.insert(pTabBox);
2976 pResult = pCellFrame;
2986 return m_pImpl->getCellFrame();
2991 if (m_pCellFrame ==
nullptr)
2993 if (m_pTabFrame !=
nullptr)
2999 return m_pCellFrame !=
nullptr;
3039 rFormat.Add(
this );
3051 rFormat.Add(
this );
constexpr sal_uInt32 getSwDefaultTextFormat()
The number formatter's default locale's @ Text format.
sal_uInt32 GetValue() const
virtual bool SetFieldsDirty(bool b, const SwNode *pChk, SwNodeOffset nLen)=0
virtual SwFieldType * GetFieldType(SwFieldIds nResId, const OUString &rName, bool bDbFieldMatching) const =0
virtual sfx2::LinkManager & GetLinkManager()=0
virtual bool IsIgnoreRedline() const =0
virtual bool DeleteRedline(const SwPaM &rPam, bool bSaveInUndo, RedlineType nDelType)=0
static bool IsRedlineOn(const RedlineFlags eM)
virtual const SwRedlineTable & GetRedlineTable() const =0
virtual AppendResult AppendRedline(SwRangeRedline *pNewRedl, bool bCallDelete)=0
Append a new redline.
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SvxAdjust GetAdjust() const
void SetAdjust(const SvxAdjust eType)
const Color & GetValue() const
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
void SetLeft(const tools::Long nL, const sal_uInt16 nProp=100)
sal_uInt16 CalcShadowSpace(SvxShadowItemSide nShadow) const
tools::Long GetWidth() const
void SetWidth(tools::Long n)
const SwAttrSet * GetChgSet() const
What has changed.
SwCellFrame is one table cell in the document layout.
const SwTableBox * GetTabBox() const
std::optional< sw::ModifyChangedHint > CheckRegistration(const SfxPoolItem *pOldValue)
Marks a character position inside a document model content node (SwContentNode)
sal_Int32 GetIndex() const
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
virtual sal_Int32 Len() const
const SwAttrSet * GetpSwAttrSet() const
bool IsNumberFormat(std::u16string_view aString, sal_uInt32 &F_Index, double &fOutNumber)
SwTableBoxFormat * MakeTableBoxFormat()
SwTableLineFormat * MakeTableLineFormat()
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
const SwTextFormatColl * GetDfltTextFormatColl() const
void DelTableFrameFormat(SwTableFormat *pFormat)
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
bool IsInsTableAlignNum() const
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
Base class of all fields.
SwFieldTypesEnum GetTypeId() const
const SwRect & getFrameArea() const
Base class of the Writer layout elements.
SwTabFrame * FindTabFrame()
SwLayoutFrame * GetUpper()
Marks a node in the document model.
SwNodeOffset GetIndex() const
Base class of the Writer document model elements.
SwStartNode * GetStartNode()
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwNodeOffset GetIndex() const
SwNodes & GetNodes()
Node is in which nodes-array/doc?
SwTableNode * FindTableNode()
Search table node, in which it is.
const SwStartNode * StartOfSectionNode() const
SwNodeOffset EndOfSectionIndex() const
SwContentNode * GetContentNode()
SwTableNode * GetTableNode()
bool InsBoxen(SwTableNode *, SwTableLine *, SwTableBoxFormat *, SwTextFormatColl *, const SfxItemSet *pAutoAttr, sal_uInt16 nInsPos, sal_uInt16 nCnt=1)
Insert a new box in the line before InsPos.
SwContentNode * GoNext(SwNodeIndex *) const
SwNodeOffset Count() const
PaM is Point and Mark: a selection of the document model.
const SwPosition * End() const
const SwPosition * Start() const
RedlineType GetType(sal_uInt16 nPos=0) const
const SwRedlineData & GetRedlineData(sal_uInt16 nPos=0) const
Of course Writer needs its own rectangles.
void Height(tools::Long nNew)
void Width(tools::Long nNew)
const DateTime & GetTimeStamp() const
static constexpr size_type npos
vector_type::size_type size_type
SwRowFrame is one table row in the document layout.
virtual sal_uInt16 GetSubType() const override
Starts a section of nodes in the document model.
const SwTabColsEntry & GetEntry(size_t nPos) const
void Remove(size_t nPos, size_t nCount=1)
tools::Long GetLeft() const
tools::Long GetRight() const
tools::Long GetRightMax() const
void SetHidden(size_t nPos, bool bValue)
void Insert(tools::Long nValue, bool bValue, size_t nPos)
SwTabFrame is one table in the document layout, containing rows (which contain cells).
SwTabFrame * FindMaster(bool bFirstMaster=false) const
bool IsInHeadline(const SwFrame &rFrame) const
SwTableBox is one table cell in the document model.
SwNodeOffset IsValidNumTextNd(bool bCheckAttr=true) const
void SetSaveUserColor(std::optional< Color > p)
bool IsEmpty(bool bWithRemainingNestedTable=true) const
sal_uInt16 IsFormulaOrValueBox() const
bool IsNumberChanged() const
sal_Int32 getRowSpan() const
SwNodeOffset GetSttIdx() const
const std::optional< Color > & GetSaveUserColor() const
void setRowSpan(sal_Int32 nNewRowSpan)
const SwStartNode * m_pStartNode
static SwTableBoxFormat * CheckBoxFormat(SwTableBoxFormat *)
void SetSaveNumFormatColor(std::optional< Color > p)
SwFrameFormat * GetFrameFormat()
SwTableLines & GetTabLines()
bool getDummyFlag() const
void setDummyFlag(bool bDummy)
bool HasNumContent(double &rNum, sal_uInt32 &rFormatIndex, bool &rIsEmptyTextNd) const
Point GetCoordinates() const
bool IsInHeadline(const SwTable *pTable) const
virtual ~SwTableBox() override
const std::optional< Color > & GetSaveNumFormatColor() const
const SwStartNode * GetSttNd() const
void RegisterToFormat(SwFormat &rFormat)
void ChgFrameFormat(SwTableBoxFormat *pNewFormat, bool bNeedToReregister=true)
SwTableBox(const SwTableBox &)=delete
SwFrameFormat * ClaimFrameFormat()
const SwCellFrame * getCellFrame() const
std::unique_ptr< Impl > m_pImpl
SwTableCellInfo(SwTableCellInfo const &)=delete
const SwTableBox * getTableBox() const
SwTableLine is one table row in the document model.
SwFrameFormat * GetFrameFormat()
SwTableLine(SwTableLineFormat *, sal_uInt16 nBoxes, SwTableBox *pUp)
SwRedlineTable::size_type UpdateTextChangesOnly(SwRedlineTable::size_type &rRedlinePos, bool bUpdateProperty=true) const
void ChgFrameFormat(SwTableLineFormat *pNewFormat)
SwTwips GetTableLineHeight(bool &bLayoutAvailable) const
SwFrameFormat * ClaimFrameFormat()
void SetRedlineType(RedlineType eType)
SwTableBoxes & GetTabBoxes()
RedlineType GetRedlineType() const
bool IsDeleted(SwRedlineTable::size_type &rRedlinePos) const
RedlineType m_eRedlineType
sal_uInt16 GetBoxPos(const SwTableBox *pBox) const
virtual ~SwTableLine() override
std::vector< SwTableLine * >::const_iterator const_iterator
SwTableLine * back() const
SwTableLine * front() const
void reserve(size_type nSize)
sal_uInt16 GetPos(const SwTableLine *pBox) const
const SwTable & GetTable() const
SwTable is one table in the document model, containing rows (which contain cells).
void SetTabCols(const SwTabCols &rNew, const SwTabCols &rOld, const SwTableBox *pStart, bool bCurRowOnly)
virtual ~SwTable() override
SwTableNode * GetTableNode() const
void SetHTMLTableLayout(std::shared_ptr< SwHTMLTableLayout > const &r)
std::shared_ptr< SwHTMLTableLayout > m_xHTMLLayout
SwTableSortBoxes m_TabSortContentBoxes
void AdjustWidths(const tools::Long nOld, const tools::Long nNew)
SwTableNode * m_pTableNode
SwTableLines & GetTabLines()
SwTableFormat * GetFrameFormat()
bool IsTableComplex() const
void RegisterToFormat(SwFormat &rFormat)
TableChgMode m_eTableChgMode
const SwTableBox * GetTableBox(const OUString &rName, const bool bPerformValidCheck=false) const
bool HasDeletedRow() const
void dumpAsXml(xmlTextWriterPtr pWriter) const
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
virtual bool GetInfo(SfxPoolItem &) const override
static SwTable * FindTable(SwFrameFormat const *const pFormat)
static sal_uInt16 GetBoxNum(OUString &rStr, bool bFirst=false, const bool bPerformValidCheck=false)
SwTableSortBoxes & GetTabSortBoxes()
void GetTabCols(SwTabCols &rToFill, const SwTableBox *pStart, bool bHidden=false, bool bCurRowOnly=false) const
tools::SvRef< SwServerObject > m_xRefObj
void NewSetTabCols(Parm &rP, const SwTabCols &rNew, const SwTabCols &rOld, const SwTableBox *pStart, bool bCurRowOnly)
void SetRefObject(SwServerObject *)
void UpdateFields(TableFormulaUpdateFlags eFlags)
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
sal_Int32 GetStart() const
const SwFormatField & GetFormatField() const
SwTextNode is a paragraph in the document model.
virtual bool SetAttr(const SfxPoolItem &) override
overriding to handle change of certain paragraph attributes
void EraseText(const SwContentIndex &rIdx, const sal_Int32 nCount=SAL_MAX_INT32, const SwInsertFlags nMode=SwInsertFlags::DEFAULT)
delete text content ATTENTION: must not be called with a range that overlaps the start of an attribut...
OUString InsertText(const OUString &rStr, const SwContentIndex &rIdx, const SwInsertFlags nMode=SwInsertFlags::DEFAULT)
insert text content
SwpHints * GetpSwpHints()
const OUString & GetText() const
bool DontExpandFormat(sal_Int32 nContentIdx, bool bFlag=true, bool bFormatToTextAttributes=true)
When appropriate set DontExpand-flag at INet or character styles respectively.
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
static ShellResource * GetShellRes()
An SwTextAttr container, stores all directly formatted text portions for a text node.
SwTextAttr * Get(size_t nPos) const
size_type erase(const Value &x)
std::pair< const_iterator, bool > insert(Value &&x)
void RemoveServer(SvLinkSource *rObj)
struct _xmlTextWriter * xmlTextWriterPtr
TableChgMode GetTableChgDefaultMode()
EmbeddedObjectRef * pObject
@ Variable
Frame is variable in Var-direction.
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(59)
constexpr TypedWhichId< SwFindNearestNode > RES_FINDNEARESTNODE(184)
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(158)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(108)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
constexpr TypedWhichId< SvxAdjustItem > RES_PARATR_ADJUST(64)
constexpr TypedWhichId< SwTableBoxFormula > RES_BOXATR_FORMULA(157)
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(169)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(60)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
constexpr TypedWhichId< SwFormatAutoFormat > RES_PARATR_LIST_AUTOFMT(87)
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_CONTENT_VISIBLE(185)
constexpr TypedWhichId< SwAutoFormatGetDocNode > RES_AUTOFMT_DOCNODE(176)
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(104)
TableFormulaUpdateFlags
SwTableFormulaUpdate is sent when the table has to be newly calculated or when a table itself is merg...
#define SAL_INFO_IF(condition, area, stream)
#define SAL_WARN_IF(condition, area, stream)
tools::Long const nBorder
const SwExtendedSubType SUB_INVISIBLE
Invisible.
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
constexpr SwNodeOffset NODE_OFFSET_MAX(SAL_MAX_INT32)
SwNodeOffset abs(const SwNodeOffset &a)
SwShareBoxFormats aShareFormats
std::deque< SwTableBox * > aBoxArr
Parm(const SwTabCols &rN, const SwTabCols &rO)
Marks a position in the document model.
SwNodeOffset GetNodeIndex() const
sal_Int32 GetContentIndex() const
TableBoxes_t m_HandledTableBoxes
const SwTabFrame * m_pTabFrame
const SwCellFrame * m_pCellFrame
const SwCellFrame * getNextCellFrame(const SwFrame *pFrame)
void setTable(const SwTable *pTable)
const SwCellFrame * getNextTableBoxsCellFrame(const SwFrame *pFrame)
const SwCellFrame * getCellFrame() const
o3tl::sorted_vector< const SwTableBox * > TableBoxes_t
const SwFrame * getNextFrameInTable(const SwFrame *pFrame)
sal_uInt16 GetWhich() const
std::list< ColChange > ChangeList
static void lcl_AdjustWidthsInLine(SwTableLine *pLine, ChangeList &rOldNew, Parm &rParm, sal_uInt16 nColFuzzy)
static void lcl_ProcessBoxPtr(SwTableBox *pBox, std::deque< SwTableBox * > &rBoxArr, bool bBefore)
std::pair< sal_uInt16, sal_uInt16 > ColChange
static void lcl_ProcessLine(SwTableLine *pLine, Parm &rParm)
static OUString & lcl_TabToBlankAtSttEnd(OUString &rText)
static void lcl_ProcessLineGet(const SwTableLine *pLine, SwTabCols &rToFill, const SwFrameFormat *pTabFormat)
static void ChgNumToText(SwTableBox &rBox, sal_uLong nFormat)
static void lcl_ProcessBoxSet(SwTableBox *pBox, Parm &rParm)
static void lcl_ModifyLines(SwTableLines &rLines, const tools::Long nOld, const tools::Long nNew, std::vector< SwFormat * > &rFormatArr, const bool bCheckSum)
static void lcl_ModifyBoxes(SwTableBoxes &rBoxes, const tools::Long nOld, const tools::Long nNew, std::vector< SwFormat * > &rFormatArr)
static void lcl_ProcessBoxGet(const SwTableBox *pBox, SwTabCols &rToFill, const SwFrameFormat *pTabFormat, bool bRefreshHidden)
static void lcl_AdjustBox(SwTableBox *pBox, const tools::Long nDiff, Parm &rParm)
static void lcl_AdjustLines(SwTableLines &rLines, const tools::Long nDiff, Parm &rParm)
static void FormatInArr(std::vector< SwFormat * > &rFormatArr, SwFormat *pBoxFormat)
static void lcl_CalcNewWidths(std::vector< sal_uInt16 > &rSpanPos, ChangeList &rChanges, SwTableLine *pLine, tools::Long nWish, tools::Long nWidth, bool bTop)
static bool lcl_IsValidRowName(std::u16string_view rStr)
static void ChgTextToNum(SwTableBox &rBox, const OUString &rText, const Color *pCol, bool bChgAlign, SwNodeOffset nNdPos)
static void lcl_RefreshHidden(SwTabCols &rToFill, size_t nPos)
void DelBoxNode(SwTableSortBoxes const &rSortCntBoxes)
static void lcl_SortedTabColInsert(SwTabCols &rToFill, const SwTableBox *pBox, const SwFrameFormat *pTabFormat, const bool bHidden, const bool bRefreshHidden)
static OUString & lcl_DelTabsAtSttEnd(OUString &rText)
void sw_GetTableBoxColStr(sal_uInt16 nCol, OUString &rNm)
void InsTableBox(SwDoc &rDoc, SwTableNode *pTableNd, SwTableLine *pLine, SwTableBoxFormat *pBoxFrameFormat, SwTableBox *pBox, sal_uInt16 nInsPos, sal_uInt16 nCnt)
std::vector< SwTableBox * > SwTableBoxes
void CheckBoxWidth(const SwTableLine &rLine, SwTwips nSize)