21 #include <com/sun/star/text/HoriOrientation.hpp>
22 #include <osl/diagnose.h>
69 #define CHECK_TABLE(t) (t).CheckConsistency();
71 #define CHECK_TABLE(t)
83 explicit CpyTabFrame(
SwFrameFormat* pCurrentFrameFormat) : pNewFrameFormat(
nullptr )
84 { pFrameFormat = pCurrentFrameFormat; }
86 bool operator==(
const CpyTabFrame& rCpyTabFrame )
const
87 {
return pFrameFormat == rCpyTabFrame.pFrameFormat; }
88 bool operator<(
const CpyTabFrame& rCpyTabFrame )
const
89 {
return pFrameFormat < rCpyTabFrame.pFrameFormat; }
96 SwTwips nDiff, nSide, nMaxSize, nLowerDiff;
103 nDiff( nDif ), nSide( nSid ), nMaxSize( nMax ), nLowerDiff( 0 )
110 CR_SetBoxWidth(
const CR_SetBoxWidth& rCpy )
111 : pTableNd( rCpy.pTableNd ),
112 nDiff( rCpy.nDiff ), nSide( rCpy.nSide ),
113 nMaxSize( rCpy.nMaxSize ), nLowerDiff( 0 ),
115 bBigger( rCpy.bBigger ), bLeft( rCpy.bLeft )
136 #define CHECKBOXWIDTH \
138 SwTwips nSize = GetFrameFormat()->GetFrameSize().GetWidth(); \
139 for (size_t nTmp = 0; nTmp < m_aLines.size(); ++nTmp) \
140 ::CheckBoxWidth( *m_aLines[ nTmp ], nSize ); \
143 #define CHECKTABLELAYOUT \
145 for ( size_t i = 0; i < GetTabLines().size(); ++i ) \
147 SwFrameFormat* pFormat = GetTabLines()[i]->GetFrameFormat(); \
148 SwIterator<SwRowFrame,SwFormat> aIter( *pFormat ); \
149 for (SwRowFrame* pFrame=aIter.First(); pFrame; pFrame=aIter.Next())\
151 if ( pFrame->GetTabLine() == GetTabLines()[i] ) \
153 OSL_ENSURE( pFrame->GetUpper()->IsTabFrame(), \
154 "Table layout does not match table structure" ); \
162 #define CHECKBOXWIDTH
163 #define CHECKTABLELAYOUT
169 struct CR_SetLineHeight
178 nMaxSpace( 0 ), nMaxHeight( 0 )
183 CR_SetLineHeight(
const CR_SetLineHeight& rCpy )
184 : pTableNd( rCpy.pTableNd ),
185 nMaxSpace( rCpy.nMaxSpace ), nMaxHeight( rCpy.nMaxHeight ),
187 bBigger( rCpy.bBigger )
206 std::shared_ptr< std::vector< std::vector< sal_uLong > > > pWidths;
214 sal_uInt16 nCpyCnt, nInsPos;
215 sal_uInt16 nLnIdx, nBoxIdx;
220 : rDoc( pNd->
GetDoc() ), pTableNd( pNd ), rTabFrameArr(rFrameArr),
221 pInsLine(
nullptr), pInsBox(
nullptr), nOldSize(0), nNewSize(0),
222 nMinLeft(ULONG_MAX), nMaxRight(0),
223 nCpyCnt(nCopies), nInsPos(0),
224 nLnIdx(0), nBoxIdx(0),
225 nDelBorderFlag(0), bCpyContent(
true )
227 CpyPara(
const CpyPara& rPara,
SwTableLine* pLine )
228 : pWidths( rPara.pWidths ), rDoc(rPara.rDoc), pTableNd(rPara.pTableNd),
229 rTabFrameArr(rPara.rTabFrameArr), pInsLine(pLine), pInsBox(rPara.pInsBox),
230 nOldSize(0), nNewSize(rPara.nNewSize), nMinLeft( rPara.nMinLeft ),
231 nMaxRight( rPara.nMaxRight ), nCpyCnt(rPara.nCpyCnt), nInsPos(0),
232 nLnIdx( rPara.nLnIdx), nBoxIdx( rPara.nBoxIdx ),
233 nDelBorderFlag( rPara.nDelBorderFlag ), bCpyContent( rPara.bCpyContent )
235 CpyPara(
const CpyPara& rPara,
SwTableBox* pBox )
236 : pWidths( rPara.pWidths ), rDoc(rPara.rDoc), pTableNd(rPara.pTableNd),
237 rTabFrameArr(rPara.rTabFrameArr), pInsLine(rPara.pInsLine), pInsBox(pBox),
238 nOldSize(rPara.nOldSize), nNewSize(rPara.nNewSize),
239 nMinLeft( rPara.nMinLeft ), nMaxRight( rPara.nMaxRight ),
240 nCpyCnt(rPara.nCpyCnt), nInsPos(0), nLnIdx(rPara.nLnIdx), nBoxIdx(rPara.nBoxIdx),
241 nDelBorderFlag( rPara.nDelBorderFlag ), bCpyContent( rPara.bCpyContent )
255 if( pCpyPara->nCpyCnt )
259 nFndPos = itFind - pCpyPara->rTabFrameArr.begin();
260 if( itFind == pCpyPara->rTabFrameArr.end() || !(*itFind == aFindFrame) )
269 bool bDiffCount =
false;
272 pCmpLine = rFndBox.
GetLines().front().get();
282 for(
auto n = rFndBoxes.size();
n; )
284 nSz += rFndBoxes[--
n]->GetBox()->
285 GetFrameFormat()->GetFrameSize().GetWidth();
287 aFrameSz.SetWidth( aFrameSz.GetWidth() -
288 nSz / ( pCpyPara->nCpyCnt + 1 ) );
290 aFrameSz.SetWidth( nSz / ( pCpyPara->nCpyCnt + 1 ) );
294 MakeTableLineFormat());
295 *aFindFrame.pNewFrameFormat = *pNewFormat;
300 aFrameSz.SetWidth( aFrameSz.GetWidth() / ( pCpyPara->nCpyCnt + 1 ) );
303 aFindFrame.pNewFrameFormat = pNewFormat;
304 pCpyPara->rTabFrameArr.insert( aFindFrame );
305 aFindFrame.pFrameFormat = pNewFormat;
306 pCpyPara->rTabFrameArr.insert( aFindFrame );
311 aFindFrame = pCpyPara->rTabFrameArr[ nFndPos ];
318 if( pCpyPara->nDelBorderFlag &&
319 itFind != pCpyPara->rTabFrameArr.end() )
320 aFindFrame = *itFind;
327 pBox =
new SwTableBox( aFindFrame.pNewFrameFormat,
328 rFndBox.
GetLines().size(), pCpyPara->pInsLine );
329 pCpyPara->pInsLine->GetTabBoxes().insert( pCpyPara->pInsLine->GetTabBoxes().begin() + pCpyPara->nInsPos++, pBox );
330 CpyPara aPara( *pCpyPara, pBox );
331 aPara.nDelBorderFlag &= 7;
333 for (
auto const& pFndLine : rFndBox.
GetLines())
340 ::InsTableBox( pCpyPara->rDoc, pCpyPara->pTableNd, pCpyPara->pInsLine,
341 aFindFrame.pNewFrameFormat, pBox, pCpyPara->nInsPos++ );
344 if( 8 > pCpyPara->nDelBorderFlag
345 ? pCpyPara->nDelBorderFlag != 0
346 : &rFndBox == rFndBxs[rFndBxs.size() - 1].get())
349 if( 8 > pCpyPara->nDelBorderFlag
356 if( 8 > pCpyPara->nDelBorderFlag )
357 aNew.
SetLine(
nullptr, SvxBoxItemLine::TOP );
359 aNew.
SetLine(
nullptr, SvxBoxItemLine::RIGHT );
361 if( 1 == pCpyPara->nDelBorderFlag ||
362 8 == pCpyPara->nDelBorderFlag )
365 pBox = pCpyPara->pInsLine->GetTabBoxes()[
366 pCpyPara->nInsPos - 1 ];
375 if( !pCpyPara->nCpyCnt )
376 pCpyPara->rTabFrameArr.insert( aFindFrame );
386 rFndLine.
GetBoxes().size(), pCpyPara->pInsBox );
387 if( pCpyPara->pInsBox )
389 SwTableLines& rLines = pCpyPara->pInsBox->GetTabLines();
390 rLines.
insert( rLines.
begin() + pCpyPara->nInsPos++, pNewLine );
394 SwTableLines& rLines = pCpyPara->pTableNd->GetTable().GetTabLines();
395 rLines.
insert( rLines.
begin() + pCpyPara->nInsPos++, pNewLine );
398 CpyPara aPara( *pCpyPara, pNewLine );
399 for (
auto const& it : rFndLine.
GetBoxes())
404 pCpyPara->nDelBorderFlag &= 0xf8;
414 if( 1 == pFndLn->
GetBoxes().size() &&
415 !( pFBox = pFndLn->
GetBoxes()[0].get() )->GetBox()->GetSttNd() )
418 for (
auto &rpLine : pFBox->
GetLines())
420 lcl_InsCol( rpLine.get(), rCpyPara, nCpyCnt, bBehind );
425 rCpyPara.pInsLine = pFndLn->
GetLine();
427 pFndLn->
GetBoxes().size()-1 : 0 ]->GetBox();
432 for( sal_uInt16
n = 0;
n < nCpyCnt; ++
n )
434 if(
n + 1 == nCpyCnt && bBehind )
435 rCpyPara.nDelBorderFlag = 9;
437 rCpyPara.nDelBorderFlag = 8;
438 for (
auto const& it : pFndLn->
GetBoxes())
449 for(
SwRowFrame* pFrame = aIter.First(); pFrame; pFrame = aIter.Next() )
450 if( pFrame->GetTabLine() == &rLine )
457 OSL_ENSURE( !rBoxes.
empty() && nCnt,
"No valid Box List" );
464 bRes = NewInsertCol( rDoc, rBoxes, nCnt, bBehind );
468 FndBox_ aFndBox(
nullptr,
nullptr );
470 FndPara aPara( rBoxes, &aFndBox );
476 SetHTMLTableLayout(std::shared_ptr<SwHTMLTableLayout>());
486 CpyPara aCpyPara( pTableNd, nCnt, aTabFrameArr );
488 for (
auto & rpLine : aFndBox.
GetLines())
490 lcl_InsCol( rpLine.get(), aCpyPara, nCnt, bBehind );
506 pPCD->
AddRowCols( *
this, rBoxes, nCnt, bBehind );
515 sal_uInt16 nCnt,
bool bBehind )
517 OSL_ENSURE( pDoc && !rBoxes.
empty() && nCnt,
"No valid Box List" );
523 FndBox_ aFndBox(
nullptr,
nullptr );
525 FndPara aPara( rBoxes, &aFndBox );
531 SetHTMLTableLayout(std::shared_ptr<SwHTMLTableLayout>());
536 while( 1 == pFndBox->
GetLines().size() )
538 pFndLine = pFndBox->
GetLines()[0].get();
539 if( 1 != pFndLine->
GetBoxes().size() )
551 const bool bLayout = !IsNewModel() &&
557 if( pFndBox != &aFndBox )
564 CpyPara aCpyPara( pTableNd, 0, aTabFrameArr );
567 pFndBox->
GetLines().size()-1 : 0 ]->GetLine();
568 if( &aFndBox == pFndBox )
569 aCpyPara.nInsPos = GetTabLines().GetPos( pLine );
572 aCpyPara.pInsBox = pFndBox->
GetBox();
579 aCpyPara.nDelBorderFlag = 1;
582 aCpyPara.nDelBorderFlag = 2;
584 for( sal_uInt16 nCpyCnt = 0; nCpyCnt < nCnt; ++nCpyCnt )
587 aCpyPara.nDelBorderFlag = 1;
588 for (
auto & rpFndLine : pFndBox->
GetLines())
614 if( pFndBox != &aFndBox )
625 pPCD->
AddRowCols( *
this, rBoxes, nCnt, bBehind );
639 for (
auto pLine : rLines )
646 SwTableBox& rBox = *(bFirst ? rBoxes.front() : rBoxes.back());
649 bFirst, rShareFormats );
654 aNew.
SetWidth( aNew.GetWidth() + nOffset );
666 rShareFormats.
AddFormat( *pBoxFormat, *pFormat );
671 bool bCalcNewSize,
const bool bCorrBorder,
675 SwTwips nBoxSz = bCalcNewSize ?
679 sal_uInt16 nDelPos = pLine->
GetBoxPos( pBox );
683 if( bCorrBorder && 1 < rTableBoxes.size() )
693 if( nDelPos + 1 < o3tl::narrowing<sal_uInt16>(rTableBoxes.size()) )
695 SwTableBox* pNxtBox = rTableBoxes[ nDelPos + 1 ];
698 SwTableBox* pPrvBox = nDelPos ? rTableBoxes[ nDelPos - 1 ] :
nullptr;
706 SvxBoxItemLine::LEFT );
708 pShareFormats->
SetAttr( *pNxtBox, aTmp );
714 if( !bChgd && nDelPos )
716 SwTableBox* pPrvBox = rTableBoxes[ nDelPos - 1 ];
719 SwTableBox* pNxtBox = nDelPos + 1 < o3tl::narrowing<sal_uInt16>(rTableBoxes.size())
720 ? rTableBoxes[ nDelPos + 1 ] :
nullptr;
728 SvxBoxItemLine::RIGHT );
730 pShareFormats->
SetAttr( *pPrvBox, aTmp );
741 pShareFormats->
RemoveFormat( *rTableBoxes[ nDelPos ]->GetFrameFormat() );
745 delete rTableBoxes[nDelPos];
746 rTableBoxes.erase( rTableBoxes.begin() + nDelPos );
752 static_cast<SwUndoTableNdsChg*>(pUndo)->SaveSection( pSttNd );
758 if( !rTableBoxes.empty() )
761 bool bLastBox = nDelPos == rTableBoxes.size();
764 pBox = rTableBoxes[nDelPos];
768 aNew.
SetWidth( aNew.GetWidth() + nBoxSz );
770 pShareFormats->
SetSize( *pBox, aNew );
780 pShareFormats ? *pShareFormats
797 delete pTabLineToDelete;
811 delete pTabLineToDelete;
819 sal_uInt16 nLinePos,
bool bNxt,
820 SwSelBoxes* pAllDelBoxes,
size_t *
const pCurPos)
830 SwTwips nFndWidth = nBoxStt + nBoxWidth;
835 if ( nFndWidth <= 0 )
841 nFndWidth -= nFndBoxWidth;
857 else if( pAllDelBoxes )
861 if( aFndIt == pAllDelBoxes->
end() )
863 size_t const nFndPos = aFndIt - pAllDelBoxes->
begin() ;
868 if( nFndPos <= *pCurPos )
870 pAllDelBoxes->
erase( pAllDelBoxes->
begin() + nFndPos );
872 }
while( bNxt ? ( nLinePos + 1 < o3tl::narrowing<sal_uInt16>(rTableLns.
size()) ) : nLinePos != 0 );
880 size_t *
const pCurPos =
nullptr )
886 sal_uInt16 nDelPos = pLine->
GetBoxPos( pUpperBox );
901 sal_uInt16 nLnPos = pTableLns->
GetPos( pLine );
906 for( sal_uInt16
n = 0;
n < nDelPos; ++
n )
907 nBoxStt += rTableBoxes[
n ]->GetFrameFormat()->GetFrameSize().GetWidth();
910 SwTableBox *pPrvBox =
nullptr, *pNxtBox =
nullptr;
913 nLnPos,
false, pAllDelBoxes, pCurPos );
915 if( nLnPos + 1 < o3tl::narrowing<sal_uInt16>(pTableLns->
size()) )
917 nLnPos,
true, pAllDelBoxes, pCurPos );
919 if( pNxtBox && pNxtBox->GetSttNd() )
921 const SvxBoxItem& rNxtBoxItem = pNxtBox->GetFrameFormat()->GetBox();
922 if( !rNxtBoxItem.
GetTop() && ( !pPrvBox ||
928 SvxBoxItemLine::TOP );
929 rShareFormats.
SetAttr( *pNxtBox, aTmp );
933 if( !(!bChgd && pPrvBox && pPrvBox->
GetSttNd()) )
937 if( !rPrvBoxItem.
GetTop() && ( !pNxtBox ||
938 !pNxtBox->GetFrameFormat()->GetBox().GetTop()) )
943 SvxBoxItemLine::BOTTOM );
944 rShareFormats.
SetAttr( *pPrvBox, aTmp );
954 const bool bDelMakeFrames,
const bool bCorrBorder )
956 OSL_ENSURE( pDoc,
"No doc?" );
958 if( !rBoxes.
empty() )
960 pTableNd =
const_cast<SwTableNode*
>(rBoxes[0]->GetSttNd()->FindTableNode());
965 SetHTMLTableLayout(std::shared_ptr<SwHTMLTableLayout>());
968 FndBox_ aFndBox(
nullptr,
nullptr );
969 if ( bDelMakeFrames )
971 if( pMerged && !pMerged->
empty() )
973 else if( !rBoxes.
empty() )
984 for (
size_t n = 0;
n < aBoxes.
size(); ++
n)
991 PrepareDelBoxes( rBoxes );
995 for (
size_t n = 0;
n < rBoxes.
size(); ++
n)
997 size_t const nIdx = rBoxes.
size() - 1 -
n;
1002 if (pPCD && pTableNd)
1006 DeleteBox_( *
this, rBoxes[nIdx], pUndo,
true, bCorrBorder, &aShareFormats );
1027 OSL_ENSURE( !rBoxes.
empty() && nCnt,
"No valid values" );
1037 SetHTMLTableLayout(std::shared_ptr<SwHTMLTableLayout>());
1041 std::unique_ptr<tools::Long[]> pRowHeights;
1045 for (
size_t n = 0;
n < rBoxes.
size(); ++
n)
1049 OSL_ENSURE( pRow,
"Where is the SwTableLine's Frame?" );
1056 FndBox_ aFndBox(
nullptr,
nullptr );
1060 for (
size_t n = 0;
n < rBoxes.
size(); ++
n)
1063 OSL_ENSURE( pSelBox,
"Box is not within the Table" );
1074 bool bChgLineSz = 0 != aFSz.GetHeight() || bSameHeight;
1076 aFSz.SetHeight( ( bSameHeight ? pRowHeights[
n ] : aFSz.GetHeight() ) /
1080 sal_uInt16 nBoxPos = pInsLine->
GetBoxPos( pSelBox );
1087 bool bMoveNodes =
true;
1091 while( nSttNd < nEndNd )
1092 if( !rDoc.
GetNodes()[ nSttNd++ ]->IsTextNode() )
1100 bool bChkBorder =
nullptr != pCpyBoxFrameFormat->
GetBox().
GetTop();
1104 for( sal_uInt16
i = 0;
i <= nCnt; ++
i )
1108 static_cast<SwTableLineFormat*>(pInsLine->
GetFrameFormat()), 1, pNewBox );
1123 ::InsTableBox( rDoc, pTableNd, pNewLine, pCpyBoxFrameFormat,
1130 aTmp.
SetLine(
nullptr, SvxBoxItemLine::TOP );
1156 pRowHeights.reset();
1169 OSL_ENSURE( !rBoxes.
empty() && nCnt,
"No valid values" );
1179 SetHTMLTableLayout(std::shared_ptr<SwHTMLTableLayout>());
1181 ExpandSelection( aSelBoxes );
1184 FndBox_ aFndBox(
nullptr,
nullptr );
1189 std::vector<SwTableBoxFormat*> aLastBoxArr;
1190 for (
size_t n = 0;
n < aSelBoxes.
size(); ++
n)
1193 OSL_ENSURE( pSelBox,
"Box is not in the table" );
1201 sal_uInt16 nBoxPos = pInsLine->
GetBoxPos( pSelBox );
1205 CpyTabFrame aFindFrame( static_cast<SwTableBoxFormat*>(pSelBox->
GetFrameFormat()) );
1207 const size_t nFndPos = itFind - aFrameArr.
begin();
1208 if( itFind == aFrameArr.
end() || !(*itFind == aFindFrame) )
1212 SwTwips nBoxSz = aFindFrame.pNewFrameFormat->GetFrameSize().GetWidth();
1213 SwTwips nNewBoxSz = nBoxSz / ( nCnt + 1 );
1216 aFrameArr.
insert( aFindFrame );
1218 pLastBoxFormat = aFindFrame.pNewFrameFormat;
1219 if( nBoxSz != ( nNewBoxSz * (nCnt + 1)))
1225 nBoxSz - ( nNewBoxSz * nCnt ), 0 ) );
1227 aLastBoxArr.insert( aLastBoxArr.begin() + nFndPos, pLastBoxFormat );
1231 aFindFrame = aFrameArr[ nFndPos ];
1233 pLastBoxFormat = aLastBoxArr[ nFndPos ];
1237 for( sal_uInt16
i = 1;
i < nCnt; ++
i )
1238 ::
InsTableBox( rDoc, pTableNd, pInsLine, aFindFrame.pNewFrameFormat,
1239 pSelBox, nBoxPos +
i );
1242 pSelBox, nBoxPos + nCnt );
1245 const SvxBoxItem& aSelBoxItem = aFindFrame.pNewFrameFormat->GetBox();
1248 pInsLine->
GetTabBoxes()[ nBoxPos + nCnt ]->ClaimFrameFormat();
1251 aTmp.
SetLine(
nullptr, SvxBoxItemLine::RIGHT );
1252 aFindFrame.pNewFrameFormat->SetFormatAttr( aTmp );
1255 for(
auto i = aFrameArr.
size();
i; )
1257 const CpyTabFrame& rCTF = aFrameArr[ --
i ];
1258 if( rCTF.pNewFrameFormat == aFindFrame.pNewFrameFormat ||
1259 rCTF.pFrameFormat == aFindFrame.pNewFrameFormat )
1262 aLastBoxArr.erase( aLastBoxArr.begin() +
i );
1293 sal_uInt16 nPos = USHRT_MAX )
1295 for( sal_uInt16
n = nStt;
n < nEnd; ++
n )
1296 rLines[
n]->SetUpper( pInsBox );
1297 if( USHRT_MAX ==
nPos )
1300 rLines.
begin() + nStt, rLines.
begin() + nEnd );
1308 for( sal_uInt16
n = nStt;
n < nEnd; ++
n )
1309 rBoxes[
n]->SetUpper( pInsLine );
1312 rBoxes.begin() + nStt, rBoxes.begin() + nEnd );
1313 rBoxes.erase( rBoxes.begin() + nStt, rBoxes.begin() + nEnd );
1320 OSL_ENSURE( pBox->
GetTabLines().
size(),
"Box does not have any Lines" );
1323 OSL_ENSURE( pLine,
"Box is not within a Line" );
1326 for(
auto pTabBox : pLine->GetTabBoxes() )
1327 nWidth += pTabBox->GetFrameFormat()->GetFrameSize().GetWidth();
1351 : pTableNd( pTNd ), pInsLine( pLine ), pInsBox( nullptr ),
1353 { bUL_LR =
true; bUL =
true; }
1356 { bUL_LR =
false; bUL =
true;
if( pBox ) pInsBox = pBox; }
1358 { bUL_LR =
false; bUL =
false;
if( pBox ) pInsBox = pBox; }
1360 { bUL_LR =
true; bUL =
false;
if( pLine ) pInsLine = pLine; }
1371 sal_uInt16 nStt = 0, nEnd = rFndBox.
GetLines().size();
1372 sal_uInt16 nInsPos = USHRT_MAX;
1373 if( !pULPara->bUL_LR )
1389 if( nPos +1 < o3tl::narrowing<sal_uInt16>(pBoxes->size()) )
1391 nInsPos = pULPara->pInsLine->GetTabBoxes().size();
1393 *pBoxes, pULPara->pInsLine );
1398 else if (!rFndBox.
GetLines().empty())
1401 nStt = pULPara->bUL ? 0 : rFndBox.
GetLines().size()-1;
1405 pBoxes = &pULPara->pInsLine->GetTabBoxes();
1413 0, pULPara->pInsLine );
1414 InsULPara aPara( *pULPara );
1415 aPara.pInsBox = pBox;
1416 for (FndLines_t::iterator it = rFndBox.
GetLines().begin() + nStt;
1417 it != rFndBox.
GetLines().begin() + nEnd; ++it )
1423 if( USHRT_MAX == nInsPos )
1424 nInsPos = pBoxes->size();
1425 pBoxes->insert( pBoxes->begin() + nInsPos, pBox );
1436 sal_uInt16 nStt = 0, nEnd = rFndLine.
GetBoxes().size();
1437 sal_uInt16 nInsPos = USHRT_MAX;
1438 if( pULPara->bUL_LR )
1444 &pULPara->pTableNd->GetTable().GetTabLines();
1448 sal_uInt16 nLeft = pFndLn->
GetBoxPos( pLBx );
1449 sal_uInt16 nRight = pFndLn->
GetBoxPos( pRBx );
1451 if( !nLeft || nRight == pFndLn->
GetTabBoxes().size() )
1456 nPos = pLines->
GetPos( pFndLn );
1462 if( (nPos = pLines->
GetPos( pFndLn )) + 1 < o3tl::narrowing<sal_uInt16>(pLines->
size()) )
1464 nInsPos = pULPara->pInsBox->GetTabLines().size();
1475 SwTableLine* pInsLine = pULPara->pLeftBox->GetUpper();
1477 static_cast<SwTableBoxFormat*>(pULPara->pLeftBox->GetFrameFormat()), 0, pInsLine );
1479 static_cast<SwTableLineFormat*>(pInsLine->
GetFrameFormat()), 2, pLMBox );
1491 nPos = pLines->
GetPos( pFndLn );
1497 if( (nPos = pLines->
GetPos( pFndLn )) + 1 < o3tl::narrowing<sal_uInt16>(pLines->
size()) )
1507 nStt = pULPara->bUL ? 0 : rFndLine.
GetBoxes().size()-1;
1510 pLines = &pULPara->pInsBox->GetTabLines();
1514 InsULPara aPara( *pULPara );
1515 aPara.pInsLine = pNewLine;
1517 for (FndBoxes_t::iterator it = rLineBoxes.begin() + nStt;
1518 it != rLineBoxes.begin() + nEnd; ++it)
1525 if( USHRT_MAX == nInsPos )
1526 nInsPos = pLines->
size();
1527 pLines->
insert( pLines->
begin() + nInsPos, pNewLine );
1538 OSL_ENSURE( !rBoxes.
empty() && pMergeBox,
"no valid values" );
1544 FndBox_ aFndBox(
nullptr,
nullptr );
1546 FndPara aPara( rBoxes, &aFndBox );
1557 SetHTMLTableLayout(std::shared_ptr<SwHTMLTableLayout>());
1567 while( 1 == pFndBox->
GetLines().size() &&
1568 1 == pFndBox->
GetLines().front()->GetBoxes().size() )
1570 pFndBox = pFndBox->
GetLines().front()->GetBoxes().front().get();
1574 static_cast<SwTableLineFormat*>(pFndBox->
GetLines().front()->GetLine()->GetFrameFormat()), 0,
1583 sal_uInt16 nInsPos = pLines->
GetPos( pNewLine );
1584 pLines->
insert( pLines->
begin() + nInsPos, pInsLine );
1597 InsULPara aPara( pTableNd, pLeftBox, pInsLine );
1600 for (
auto & it : pFndBox->
GetLines().front()->GetBoxes())
1604 aPara.SetLower( pInsLine );
1605 const auto nEnd = pFndBox->
GetLines().size()-1;
1606 for (
auto & it : pFndBox->
GetLines()[nEnd]->GetBoxes())
1612 aPara.SetLeft( pLeftBox );
1613 for (
auto & rpFndLine : pFndBox->
GetLines())
1618 aPara.SetRight( pRightBox );
1619 for (
auto & rpFndLine : pFndBox->
GetLines())
1625 DeleteBox_( *
this, pLeftBox,
nullptr,
false,
false );
1629 if( pUndo && pLeftBox->
GetSttNd() )
1633 DeleteBox_( *
this, pRightBox,
nullptr,
false,
false );
1637 if( pUndo && pRightBox->
GetSttNd() )
1641 DeleteSel( pDoc, rBoxes,
nullptr,
nullptr,
false,
false );
1646 for(
const auto& rpBox : GetTabLines()[0]->GetTabBoxes() )
1668 if( nRowSpan > nMaxSpan )
1670 else if( nRowSpan < nMinSpan )
1671 pBox->
setRowSpan( nMinSpan > 0 ? nMaxSpan : nMinSpan );
1674 nMinSpan = -nMaxSpan;
1681 const FndBox_* pFirstBox = &rBox;
1682 while (!pFirstBox->
GetLines().empty())
1684 pFirstBox = pFirstBox->
GetLines().front()->GetBoxes().front().get();
1687 sal_uInt16 nRet = 0;
1692 for(
auto pCmp : rBoxes )
1696 nRet = nRet + o3tl::narrowing<sal_uInt16>(pCmp->GetFrameFormat()->GetFrameSize().GetWidth());
1705 sal_uInt16 nRet = 0;
1708 nRet = nRet + o3tl::narrowing<sal_uInt16>(rLine.
GetBoxes()[--
n]->GetBox()
1709 ->GetFrameFormat()->GetFrameSize().GetWidth());
1716 rPara.pWidths.reset();
1717 const size_t nLineCount = rFndLines.size();
1720 rPara.pWidths = std::make_shared< std::vector< std::vector< sal_uLong > > >
1724 for(
size_t nLine = 0; nLine < nLineCount; ++nLine )
1726 std::vector< sal_uLong > &rWidth = (*rPara.pWidths)[ nLine ];
1727 const FndLine_ *pFndLine = rFndLines[ nLine ].get();
1728 if( pFndLine && !pFndLine->
GetBoxes().empty() )
1737 pFndLine->
GetBoxes().front()->GetBox();
1740 while( nBox < nBoxCount )
1749 if( rPara.nMinLeft > nPos )
1750 rPara.nMinLeft = nPos;
1751 nBoxCount = pFndLine->
GetBoxes().size();
1752 rWidth = std::vector< sal_uLong >( nBoxCount+2 );
1756 for( nBox = 0; nBox < nBoxCount; )
1759 ->GetBox()->GetFrameFormat()->GetFrameSize().GetWidth();
1760 rWidth[ ++nBox ] = nPos;
1763 if( rPara.nMaxRight < nPos )
1764 rPara.nMaxRight = nPos;
1765 if( nPos <= rWidth[ 0 ] )
1772 sal_uLong nSelSize = rPara.nMaxRight - rPara.nMinLeft;
1776 for(
size_t nLine = 0; nLine < nLineCount; ++nLine )
1778 std::vector< sal_uLong > &rWidth = (*rPara.pWidths)[ nLine ];
1779 const size_t nCount = rWidth.size();
1782 rWidth[ nCount - 1 ] = rPara.nMaxRight;
1784 for(
size_t nBox = 0; nBox < nCount; ++nBox )
1786 sal_uInt64 nNextPos = rWidth[ nBox ];
1787 nNextPos -= rPara.nMinLeft;
1788 nNextPos *= rPara.nNewSize;
1789 nNextPos /= nSelSize;
1790 rWidth[ nBox ] =
static_cast<sal_uLong>(nNextPos - nLastPos);
1791 nLastPos =
static_cast<sal_uLong>(nNextPos);
1806 if( pCpyPara->pTableNd->GetTable().IsNewModel() )
1808 if( pCpyPara->nBoxIdx == 1 )
1809 nDummy1 = (*pCpyPara->pWidths)[pCpyPara->nLnIdx][0];
1810 nRealSize = (*pCpyPara->pWidths)[pCpyPara->nLnIdx][pCpyPara->nBoxIdx++];
1811 if( pCpyPara->nBoxIdx == (*pCpyPara->pWidths)[pCpyPara->nLnIdx].size()-1 )
1812 nDummy2 = (*pCpyPara->pWidths)[pCpyPara->nLnIdx][pCpyPara->nBoxIdx];
1816 nRealSize = pCpyPara->nNewSize;
1818 if (pCpyPara->nOldSize == 0)
1820 nRealSize /= pCpyPara->nOldSize;
1824 bool bDummy = nDummy1 > 0;
1837 std::shared_ptr<SwFormatFrameSize> aFrameSz(std::make_shared<SwFormatFrameSize>());
1851 bool DoCopyIt(itFind == pCpyPara->rTabFrameArr.end());
1855 DoCopyIt = !(*itFind == aFindFrame);
1860 aFindFrame = pCpyPara->rTabFrameArr[ nFndPos ];
1861 aFrameSz.reset(aFindFrame.pNewFrameFormat->GetFrameSize().Clone());
1862 DoCopyIt = aFrameSz->GetWidth() !=
static_cast<SwTwips>(nSize);
1868 aFindFrame.pNewFrameFormat = pCpyPara->rDoc.MakeTableBoxFormat();
1870 if( !pCpyPara->bCpyContent )
1872 aFrameSz->SetWidth( nSize );
1873 aFindFrame.pNewFrameFormat->SetFormatAttr( *aFrameSz );
1874 pCpyPara->rTabFrameArr.insert( aFindFrame );
1880 pBox =
new SwTableBox( aFindFrame.pNewFrameFormat,
1881 rFndBox.
GetLines().size(), pCpyPara->pInsLine );
1882 pCpyPara->pInsLine->GetTabBoxes().insert( pCpyPara->pInsLine->GetTabBoxes().begin() + pCpyPara->nInsPos++, pBox );
1883 CpyPara aPara( *pCpyPara, pBox );
1884 aPara.nNewSize = nSize;
1885 for (
auto const& rpFndLine : rFndBox.
GetLines())
1893 pCpyPara->rDoc.GetNodes().InsBoxen( pCpyPara->pTableNd, pCpyPara->pInsLine,
1894 aFindFrame.pNewFrameFormat,
1895 pCpyPara->rDoc.GetDfltTextFormatColl(),
1896 nullptr, pCpyPara->nInsPos );
1897 pBox = pCpyPara->pInsLine->GetTabBoxes()[ pCpyPara->nInsPos ];
1900 else if( pCpyPara->bCpyContent )
1909 if( aBoxAttrSet.Count() )
1918 if( nNewIdx != nOldIdx )
1931 pCpyPara->rDoc.GetNodes().Delete( aInsIdx );
1933 ++pCpyPara->nInsPos;
1957 if( itFind == pCpyPara->rTabFrameArr.end() )
1960 aFindFrame.pNewFrameFormat =
reinterpret_cast<SwTableBoxFormat*
>(pCpyPara->rDoc.MakeTableLineFormat());
1962 pCpyPara->rTabFrameArr.insert( aFindFrame );
1965 aFindFrame = *itFind;
1967 SwTableLine* pNewLine =
new SwTableLine( reinterpret_cast<SwTableLineFormat*>(aFindFrame.pNewFrameFormat),
1968 rFndLine.
GetBoxes().size(), pCpyPara->pInsBox );
1969 if( pCpyPara->pInsBox )
1971 SwTableLines& rLines = pCpyPara->pInsBox->GetTabLines();
1972 rLines.
insert( rLines.
begin() + pCpyPara->nInsPos++, pNewLine );
1976 SwTableLines& rLines = pCpyPara->pTableNd->GetTable().GetTabLines();
1977 rLines.
insert( rLines.
begin() + pCpyPara->nInsPos++, pNewLine);
1980 CpyPara aPara( *pCpyPara, pNewLine );
1982 if( pCpyPara->pTableNd->GetTable().IsNewModel() )
1987 else if( rFndLine.
GetBoxes().size() ==
1996 pFormat = pCpyPara->pTableNd->GetTable().GetFrameFormat();
2001 for (
auto &rpBox : rFndLine.
GetBoxes())
2003 aPara.nOldSize += rpBox->GetBox()->GetFrameFormat()->GetFrameSize().GetWidth();
2007 for (
auto const& it : rBoxes)
2011 if( pCpyPara->pTableNd->GetTable().IsNewModel() )
2021 SelLineFromBox( pBox, aSelBoxes );
2023 FndBox_ aFndBox(
nullptr,
nullptr );
2025 FndPara aPara( aSelBoxes, &aFndBox );
2035 GetFrameFormat()->GetDoc()->getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
2039 CpyPara aPara( &rTableNd, 1, aCpyFormat );
2044 for (
const auto & rpFndLine : aFndBox.
GetLines())
2051 OSL_ENSURE( !pLine->
GetTabBoxes().empty(),
"Empty Table Line" );
2054 OSL_ENSURE( pTableBox,
"Missing Table Box" );
2055 pTableBox->setRowSpan( 1 );
2062 bool bCpyName,
const OUString& rStyleName )
const
2065 FndBox_ aFndBox(
nullptr,
nullptr );
2067 FndPara aPara( rSelBoxes, &aFndBox );
2075 SwDoc* pSrcDoc = GetFrameFormat()->GetDoc();
2076 if( pSrcDoc != &rInsDoc )
2084 rPos, 1, 1, GetFrameFormat()->GetHoriOrient().GetHoriOrient(),
2085 nullptr,
nullptr,
false, IsNewModel() ));
2092 OSL_ENSURE( pTableNd,
"Where is the TableNode now?" );
2099 if(
auto pSwDDETable = dynamic_cast<const SwDDETable*>(
this) )
2104 *pSwDDETable->GetDDEFieldType() );
2105 OSL_ENSURE( pFieldType,
"unknown FieldType" );
2109 static_cast<SwDDEFieldType*>(pFieldType) );
2110 pTableNd->
SetNewTable( std::unique_ptr<SwTable>(pNewTable),
false );
2133 CpyPara aPara( pTableNd, 1, aCpyFormat );
2134 aPara.nNewSize = aPara.nOldSize = GetFrameFormat()->GetFrameSize().GetWidth();
2139 for (
const auto & rpFndLine : aFndBox.
GetLines())
2149 sal_uInt16 nLnPos = GetTabLines().GetPos( pTmp );
2150 if( USHRT_MAX != nLnPos && nLnPos )
2155 pLn = GetTabLines()[ nLnPos - 1 ];
2169 pFndLn = aFndBox.
GetLines().back().get();
2172 nLnPos = GetTabLines().GetPos( pTmp );
2173 if( nLnPos < GetTabLines().
size() - 1 )
2178 pLn = GetTabLines()[ nLnPos + 1 ];
2195 nullptr,
false,
false );
2211 const SwTableBox* pSrchBox,
bool bOvrTableLns )
const
2216 if( !GetTabBoxes().empty() && pSrchBox )
2218 nFndPos = GetBoxPos( pSrchBox );
2219 if( USHRT_MAX != nFndPos &&
2220 nFndPos + 1 != o3tl::narrowing<sal_uInt16>(GetTabBoxes().
size()) )
2222 pBox = GetTabBoxes()[ nFndPos + 1 ];
2232 OSL_ENSURE( USHRT_MAX != nFndPos,
"Line is not in the Table" );
2234 if( nFndPos+1 >= o3tl::narrowing<sal_uInt16>(GetUpper()->GetTabLines().
size()) )
2235 return GetUpper()->GetUpper()->FindNextBox( rTable, GetUpper(), bOvrTableLns );
2236 pLine = GetUpper()->GetTabLines()[nFndPos+1];
2238 else if( bOvrTableLns )
2242 if( nFndPos + 1 >= o3tl::narrowing<sal_uInt16>(rTable.
GetTabLines().
size()) )
2257 return pLine->
FindNextBox( rTable,
nullptr, bOvrTableLns );
2262 const SwTableBox* pSrchBox,
bool bOvrTableLns )
const
2267 if( !GetTabBoxes().empty() && pSrchBox )
2269 nFndPos = GetBoxPos( pSrchBox );
2270 if( USHRT_MAX != nFndPos && nFndPos )
2272 pBox = GetTabBoxes()[ nFndPos - 1 ];
2285 OSL_ENSURE( USHRT_MAX != nFndPos,
"Line is not in the Table" );
2288 return GetUpper()->GetUpper()->FindPreviousBox( rTable, GetUpper(), bOvrTableLns );
2289 pLine = GetUpper()->GetTabLines()[nFndPos-1];
2291 else if( bOvrTableLns )
2318 const SwTableBox* pSrchBox,
bool bOvrTableLns )
const
2320 if( !pSrchBox && GetTabLines().empty() )
2322 return GetUpper()->
FindNextBox( rTable, pSrchBox ? pSrchBox :
this,
2331 if( !pSrchBox && GetTabLines().empty() )
2333 return GetUpper()->
FindPreviousBox( rTable, pSrchBox ? pSrchBox :
this );
2365 if( bFirst && !bLeft )
2369 while( nStt <
nPos )
2370 nRet += pLine->
GetTabBoxes()[ nStt++ ]->GetFrameFormat()
2371 ->GetFrameSize().GetWidth();
2381 for(
auto pBox : rBoxes )
2386 bool bGreaterBox =
false;
2396 && ((nDist + (rParam.bLeft ? 0 : nWidth)) >= rParam.nSide);
2405 nLowerDiff = (nDist + ( rParam.bLeft ? 0 : nWidth ) ) - rParam.nSide;
2406 nLowerDiff *= rParam.nDiff;
2407 nLowerDiff /= rParam.nMaxSize;
2408 nLowerDiff = rParam.nDiff - nLowerDiff;
2411 nLowerDiff = rParam.nDiff;
2413 if( nWidth < nLowerDiff || nWidth - nLowerDiff <
MINLAY )
2419 SwTwips nLowerDiff = 0, nOldLower = rParam.nLowerDiff;
2422 rParam.nLowerDiff = 0;
2425 if( nLowerDiff < rParam.nLowerDiff )
2426 nLowerDiff = rParam.nLowerDiff;
2428 rParam.nLowerDiff = nOldLower;
2432 ( nDist + ( rParam.bLeft ? 0 : nWidth ) ) >= rParam.nSide) ||
2444 nLowerDiff = (nDist + ( rParam.bLeft ? 0 : nWidth ) ) - rParam.nSide;
2445 nLowerDiff *= rParam.nDiff;
2446 nLowerDiff /= rParam.nMaxSize;
2447 nLowerDiff = rParam.nDiff - nLowerDiff;
2450 nLowerDiff = rParam.nDiff;
2453 rParam.nLowerDiff += nLowerDiff;
2455 if( rParam.bBigger )
2456 aNew.
SetWidth( nWidth + nLowerDiff );
2458 aNew.
SetWidth( nWidth - nLowerDiff );
2459 rParam.aShareFormats.SetSize( *pBox, aNew );
2471 nDist >= rParam.nSide )
2481 for(
auto pBox : rBoxes )
2495 : ( rParam.bLeft ? nDist < rParam.nSide -
COLFUZZY
2496 : nDist >= rParam.nSide -
COLFUZZY )) )
2503 nDiff *= rParam.nDiff;
2504 nDiff /= rParam.nMaxSize;
2507 nDiff = rParam.nDiff;
2509 if( nWidth < nDiff || nWidth - nDiff <
MINLAY )
2515 SwTwips nLowerDiff = 0, nOldLower = rParam.nLowerDiff;
2518 rParam.nLowerDiff = 0;
2521 if( nLowerDiff < rParam.nLowerDiff )
2522 nLowerDiff = rParam.nLowerDiff;
2524 rParam.nLowerDiff = nOldLower;
2529 : ( rParam.bLeft ? nDist < rParam.nSide -
COLFUZZY
2530 : nDist >= rParam.nSide -
COLFUZZY)
2540 nLowerDiff = nWidth;
2541 nLowerDiff *= rParam.nDiff;
2542 nLowerDiff /= rParam.nMaxSize;
2545 nLowerDiff = rParam.nDiff;
2548 rParam.nLowerDiff += nLowerDiff;
2550 if( rParam.bBigger )
2551 aNew.
SetWidth( nWidth - nLowerDiff );
2553 aNew.
SetWidth( nWidth + nLowerDiff );
2555 rParam.aShareFormats.SetSize( *pBox, aNew );
2561 nDist > rParam.nSide )
2570 for(
auto pBox : rBoxes )
2574 nWidth *= rParam.nDiff;
2575 nWidth /= rParam.nMaxSize;
2576 aSz.SetWidth( nWidth );
2577 rParam.aShareFormats.SetSize( *pBox, aSz );
2594 nCurrentSize += nBoxW;
2600 if (sal::static_int_cast< tools::ULong >(
std::abs(nCurrentSize - nSize)) >
2603 OSL_FAIL(
"Line's Boxes are too small or too large" );
2609 SwTwips nAbsDiff,
SwTwips nRelDiff, std::unique_ptr<SwUndo>* ppUndo )
2611 SetHTMLTableLayout(std::shared_ptr<SwHTMLTableLayout>());
2625 CR_SetBoxWidth aParam( eType, nRelDiff, nDist,
2626 bLeft ? nDist : rSz.
GetWidth() - nDist,
2628 bBigger = aParam.bBigger;
2641 bool bChgLRSpace =
true;
2648 bRet = rSz.
GetWidth() <
static_cast<unsigned short>(USHRT_MAX) - nRelDiff;
2649 bChgLRSpace = bLeft ? rLR.
GetLeft() >= nAbsDiff
2653 bRet = bLeft ? rLR.
GetLeft() >= nAbsDiff
2662 bRet = SetColWidth( rCurrentBox, eType, nAbsDiff, nRelDiff,
2664 m_eTableChgMode = eOld;
2671 for(
auto const &
n: m_aLines )
2674 if( !(*fnSelBox)(
n, aParam, nDistStt,
true ))
2695 if( aSz.
GetWidth() + nRelDiff >
static_cast<unsigned short>(USHRT_MAX) )
2699 0, aSz.
GetWidth(), aParam.pTableNd );
2700 for(
size_t nLn = 0; nLn < m_aLines.size(); ++nLn )
2703 aParam.nDiff = nRelDiff /= 2;
2705 aParam.nMaxSize /= 2;
2719 GetFrameFormat()->SetFormatAttr( aLR );
2727 GetFrameFormat()->SetFormatAttr( aHOri );
2741 nFrameWidth += nAbsDiff;
2743 nFrameWidth -= nAbsDiff;
2757 GetFrameFormat()->SetFormatAttr( aSz );
2761 for( sal_uInt16
n = m_aLines.size();
n; )
2765 (*fnSelBox)( m_aLines[
n ], aParam, nDistStt,
false );
2775 GetFrameFormat()->SetFormatAttr( aAbsSz );
2783 aParam.bBigger = !bBigger;
2786 if( aParam.bBigger )
2788 for(
auto const &
n: m_aLines )
2791 if( !(*fnOtherBox)(
n, aParam, 0,
true ))
2800 for(
auto const &
n: m_aLines )
2803 if( !(*fnSelBox)(
n, aParam, nDistStt,
true ))
2814 CR_SetBoxWidth aParam1( aParam );
2820 for( sal_uInt16
n = m_aLines.size();
n; )
2824 aParam1.LoopClear();
2825 (*fnSelBox)( m_aLines[
n ], aParam, nDistStt,
false );
2826 (*fnOtherBox)( m_aLines[
n ], aParam1, nDistStt,
false );
2831 for( sal_uInt16
n = m_aLines.size();
n; )
2835 aParam1.LoopClear();
2836 (*fnOtherBox)( m_aLines[
n ], aParam1, nDistStt,
false );
2837 (*fnSelBox)( m_aLines[
n ], aParam, nDistStt,
false );
2852 bRet = SetColWidth( rCurrentBox, eType, nAbsDiff, nRelDiff,
2854 m_eTableChgMode = eOld;
2860 aParam.bBigger = !bBigger;
2867 const SwTableBoxes::size_type
nPos = pLine->
GetBoxPos( pBox );
2868 if( bLeft ? nPos != 0 : nPos + 1 != pLine->
GetTabBoxes().size() )
2881 aParam.nMaxSize = aParam.nSide;
2884 GetFrameSize().GetWidth() - aParam.nSide;
2889 bRet = (*fnTmp)( pLine, aParam, nDistStt, true );
2894 CR_SetBoxWidth aParam1( aParam );
2900 (*fnSelBox)( pLine, aParam, nDistStt,
false );
2901 (*fnOtherBox)( pLine, aParam1, nDistStt,
false );
2905 (*fnOtherBox)( pLine, aParam1, nDistStt,
false );
2906 (*fnSelBox)( pLine, aParam, nDistStt,
false );
2914 #if defined DBG_UTIL
2929 OSL_ENSURE( pLineFrame,
"Where is the Frame from the SwTableLine?" );
2935 nMyNewH = nMyOldH + nNewHeight;
2940 aTmp *=
Fraction( nNewHeight, nOldHeight );
2970 else if( !rParam.bBigger )
2974 OSL_ENSURE( pLineFrame,
"Where is the Frame from the SwTableLine?" );
2976 if( (nRstHeight +
ROWFUZZY) < nDist )
2988 if( rParam.bBigger )
2992 OSL_ENSURE( pLineFrame,
"Where is the Frame from the SwTableLine?" );
2997 nDist /= rParam.nMaxHeight;
3009 OSL_ENSURE( pLineFrame,
"Where is the Frame from the SwTableLine??" );
3017 nDist /= rParam.nMaxHeight;
3023 nDist /= rParam.nMaxSpace;
3033 SwTwips nAbsDiff,
SwTwips nRelDiff, std::unique_ptr<SwUndo>* ppUndo )
3044 sal_uInt16 nBaseLinePos = GetTabLines().GetPos( pBaseLine );
3046 CR_SetLineHeight aParam( eType,
3048 bBigger = aParam.bBigger;
3057 if( pLine == pBaseLine )
3062 nBaseLinePos = pLines->
GetPos( pLine );
3093 nEnd = nBaseLinePos;
3097 nStt = nBaseLinePos + 1;
3098 nEnd = pLines->
size();
3104 for(
auto n = nStt;
n < nEnd; ++
n )
3107 OSL_ENSURE( pLineFrame,
"Where is the Frame from the SwTableLine??" );
3111 if( bBigger && aParam.nMaxSpace < nAbsDiff )
3116 if( bTop ? nEnd != 0 : nStt < nEnd )
3131 for(
auto n = nStt;
n < nEnd; ++
n )
3152 CR_SetLineHeight aParam1( aParam );
3158 for(
auto n = nStt;
n < nEnd; ++
n )
3164 for(
auto n = nStt;
n < nEnd; ++
n )
3177 bRet = SetRowHeight( rCurrentBox, eType, nAbsDiff,
3180 m_eTableChgMode = eOld;
3196 for(
auto n = m_aNewFormats.size();
n; )
3197 if( ( pTmp = m_aNewFormats[ --
n ])->GetFrameSize().GetWidth()
3209 sal_uInt16 nWhich = rItem.
Which();
3212 for(
auto n = m_aNewFormats.size();
n; )
3213 if( SfxItemState::SET == ( pTmp = m_aNewFormats[ --
n ])->
3214 GetItemState( nWhich,
false, &pItem ) && *pItem == rItem &&
3215 pTmp->GetFormatAttr(
RES_FRM_SIZE,
false ) == rFrameSz )
3225 m_aNewFormats.push_back( &rNew );
3231 if( m_pOldFormat == &rFormat )
3234 std::vector<SwFrameFormat*>::iterator it = std::find( m_aNewFormats.begin(), m_aNewFormats.end(), &rFormat );
3235 if( m_aNewFormats.end() != it )
3236 m_aNewFormats.erase( it );
3237 return m_aNewFormats.empty();
3247 return Seek_Entry( rFormat, &nPos )
3248 ? m_ShareArr[ nPos ].GetFormat(nWidth)
3255 return Seek_Entry( rFormat, &nPos )
3256 ? m_ShareArr[ nPos ].GetFormat(rItem)
3263 if( !Seek_Entry( rOld, &nPos ))
3267 m_ShareArr.insert(m_ShareArr.begin() + nPos, aEntry);
3270 m_ShareArr[ nPos ].AddFormat(rNew);
3282 pBox->
ChgFrameFormat( static_cast<SwTableBoxFormat*>(&rFormat) );
3288 pLn->
ChgFrameFormat( static_cast<SwTableLineFormat*>(&rFormat) );
3292 RemoveFormat( *pOld );
3302 ChangeFrameFormat( &rBox,
nullptr, *pRet );
3307 AddFormat( *pBoxFormat, *pRet );
3314 *pRet =
GetFormat( *pBoxFormat, rItem );
3316 ChangeFrameFormat( &rBox,
nullptr, *pRet );
3321 AddFormat( *pBoxFormat, *pRet );
3328 *pRet =
GetFormat( *pLineFormat, rItem );
3330 ChangeFrameFormat(
nullptr, &rLine, *pRet );
3335 AddFormat( *pLineFormat, *pRet );
3341 for (
auto i = m_ShareArr.size();
i; )
3343 if (m_ShareArr[ --
i ].RemoveFormat(rFormat))
3345 m_ShareArr.erase( m_ShareArr.begin() +
i );
3352 sal_uIntPtr nIdx =
reinterpret_cast<sal_uIntPtr
>(&rFormat);
3353 auto nO = m_ShareArr.size();
3354 decltype(nO) nU = 0;
3360 const auto nM = nU + ( nO - nU ) / 2;
3361 sal_uIntPtr nFormat =
reinterpret_cast<sal_uIntPtr
>(&m_ShareArr[ nM ].GetOldFormat());
3362 if( nFormat == nIdx )
3368 else if( nFormat < nIdx )
void AddRowCols(const SwTable &rTable, const SwSelBoxes &rBoxes, sal_uInt16 nLines, bool bBehind)
SwChartDataProvider::AddRowCols tries to notify charts of added columns or rows and extends the value...
Instances of SwFields and those derived from it occur 0 to n times.
const SwEndNode * EndOfSectionNode() const
Starts a section of nodes in the document model.
std::vector< SwTableLine * >::size_type size_type
const FndLines_t & GetLines() const
tools::Long GetWidth() const
const SwTableLine * GetLine() const
const_iterator lower_bound(const Value &x) const
void Add(SwClient *pDepend)
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
SwNodeOffset EndOfSectionIndex() const
void SetRowsToRepeat(sal_uInt16 nNumOfRows)
Marks a position in the document model.
static SwTwips lcl_GetDistance(SwTableBox *pBox, bool bLeft)
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(98)
void DelFrames(SwRootFrame const *pLayout=nullptr)
Method deletes all views of document for the node.
static void lcl_CopyLineToDoc(FndLine_ const &rpFndLn, CpyPara *const pCpyPara)
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
void AddNewBox(SwNodeOffset nSttNdIdx)
SwDocShell * GetDocShell()
static void lcl_CopyCol(FndBox_ &rFndBox, CpyPara *const pCpyPara)
static void lcl_CpyLines(sal_uInt16 nStt, sal_uInt16 nEnd, SwTableLines &rLines, SwTableBox *pInsBox, sal_uInt16 nPos=USHRT_MAX)
static void lcl_LastBoxSetWidth(SwTableBoxes &rBoxes, const tools::Long nOffset, bool bFirst, SwShareBoxFormats &rShareFormats)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
tools::Long GetRight() const
const SwRect & getFramePrintArea() const
bool AreLinesToRestore(const SwTable &rTable) const
SwTabFrame is one table in the document layout, containing rows (which contain cells).
virtual void CreateChartInternalDataProviders(const SwTable *pTable)=0
calls createInternalDataProvider for all charts using the specified table
constexpr sal_uInt16 RES_FRMATR_END(133)
SwFrameFormat * ClaimFrameFormat()
constexpr sal_uInt16 RES_BOXATR_END(153)
void setDummyFlag(bool bDummy)
void DelFrames(SwTable &rTable)
bool OldSplitRow(SwDoc &, const SwSelBoxes &, sal_uInt16, bool)
const_iterator find(const Value &x) const
SwTableLine is one table row in the document model.
static sal_uInt16 lcl_GetLineWidth(const FndLine_ &rLine)
void CheckSectionCondColl() const
Call ChkCondcoll to all ContentNodes of section.
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(152)
const editeng::SvxBorderLine * GetRight() const
SwNodeOffset abs(const SwNodeOffset &a)
SwTableLine * front() const
IDocumentContentOperations const & getIDocumentContentOperations() const
bool OldMerge(SwDoc *, const SwSelBoxes &, SwTableBox *, SwUndoTableMerge *)
SwTableFormat * GetFrameFormat()
void SetValues(bool bFlag)
Value in Var-direction gives minimum (can be exceeded but not be less).
static bool lcl_SetOtherLineHeight(SwTableLine *pLine, const CR_SetLineHeight &rParam, SwTwips nDist, bool bCheck)
SwNodeOffset GetSttIdx() const
void ForEach_FndLineCopyCol(SwTableLines &rLines, FndPara *pFndPara)
This creates a structure mirroring the SwTable structure that contains all rows and non-leaf boxes (a...
sal_Int32 getRowSpan() const
SwTableBox * FindNextBox(const SwTable &, const SwTableBox *=nullptr, bool bOvrTableLns=true) const
SwTableLine * back() const
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
void ChgFrameFormat(SwTableLineFormat *pNewFormat)
bool UpdateTableStyleFormatting(SwTableNode *pTableNode=nullptr, bool bResetDirect=false, OUString const *pStyleName=nullptr)
Update the direct formatting according to the current table style.
const SwRect & getFrameArea() const
static void lcl_CheckRowSpan(SwTable &rTable)
void sw_LineSetHeadCondColl(const SwTableLine *pLine)
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
static void SetLineHeight(SwTableLine &rLine, SwTwips nOldHeight, SwTwips nNewHeight, bool bMinSize)
static bool IsRedlineOn(const RedlineFlags eM)
virtual void UpdateTableFields(SfxPoolItem *pHt)=0
static void lcl_Merge_MoveBox(FndBox_ &rFndBox, InsULPara *const pULPara)
void Width(tools::Long nNew)
const FndBoxes_t & GetBoxes() const
iterator insert(iterator aIt, SwTableLine *pLine)
SwTextFormatColl * CopyTextColl(const SwTextFormatColl &rColl)
copy TextNodes
void CopyHeadlineIntoTable(SwTableNode &rTableNd)
const SwTable & GetTable() const
virtual void DeleteSection(SwNode *pNode)=0
Delete section containing the node.
static void lcl_Merge_MoveLine(FndLine_ &rFndLine, InsULPara *const pULPara)
o3tl::sorted_vector< CpyTabFrame > CpyTabFrames
const OUString & GetTableStyleName() const
Return the table style name of this table.
virtual OUString GetName() const override
SwTableBox * FindPreviousBox(const SwTable &, const SwTableBox *) const
static void lcl_CalcWidth(SwTableBox *pBox)
void UpdateCharts(const OUString &rName) const
bool HasOnlyOneListener() const
bool SplitCol(SwDoc &rDoc, const SwSelBoxes &rBoxes, sal_uInt16 nCnt)
void sw_BoxSetSplitBoxFormats(SwTableBox *pBox, SwCollectTableLineBoxes *pSplPara)
void MakeFrames(SwTable &rTable)
static void lcl_CpyBoxes(sal_uInt16 nStt, sal_uInt16 nEnd, SwTableBoxes &rBoxes, SwTableLine *pInsLine)
static void lcl_LastBoxSetWidthLine(SwTableLines &rLines, const tools::Long nOffset, bool bFirst, SwShareBoxFormats &rShareFormats)
Class for SplitTable Collects the uppermost or lowermost Lines of a Box from a Line in an array...
void InsTableBox(SwDoc &rDoc, SwTableNode *pTableNd, SwTableLine *pLine, SwTableBoxFormat *pBoxFrameFormat, SwTableBox *pBox, sal_uInt16 nInsPos, sal_uInt16 nCnt=1)
Table of Contents - heading.
PaM is Point and Mark: a selection of the document model.
const editeng::SvxBorderLine * GetTop() const
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
#define CH_TXT_TRACKED_DUMMY_CHAR
bool SetColWidth(SwTableBox &rCurrentBox, TableChgWidthHeightType eType, SwTwips nAbsDiff, SwTwips nRelDiff, std::unique_ptr< SwUndo > *ppUndo)
bool(* FN_lcl_SetBoxWidth)(SwTableLine *, CR_SetBoxWidth &, SwTwips, bool)
virtual const SwExtraRedlineTable & GetExtraRedlineTable() const =0
const editeng::SvxBorderLine * GetLeft() const
static SwRowFrame * GetRowFrame(SwTableLine &rLine)
void SetTableLines(const SwSelBoxes &rBoxes, const SwTable &rTable)
const SwStartNode * StartOfSectionNode() const
bool DeleteSel(SwDoc *, const SwSelBoxes &rBoxes, const SwSelBoxes *pMerged, SwUndo *pUndo, const bool bDelMakeFrames, const bool bCorrBorder)
void CheckBoxWidth(const SwTableLine &rLine, SwTwips nSize)
virtual SwChartDataProvider * GetChartDataProvider(bool bCreate=false) const =0
returns or creates the data-provider for chart
static SwTableLine * lcl_CopyRow(FndLine_ &rFndLine, CpyPara *const pCpyPara)
::sw::DocumentContentOperationsManager const & GetDocumentContentOperationsManager() const
static void lcl_BoxSetHeadCondColl(const SwTableBox *pBox)
SwNodeOffset GetIndex() const
tools::Long GetHeight(const SwRect &rRect) const
void SetSelBoxes(const SwSelBoxes &rBoxes)
tools::Long GetLeft() const
static bool lcl_SetSelLineHeight(SwTableLine *pLine, const CR_SetLineHeight &rParam, SwTwips nDist, bool bCheck)
static SwTableBox * lcl_FndNxtPrvDelBox(const SwTableLines &rTableLns, SwTwips nBoxStt, SwTwips nBoxWidth, sal_uInt16 nLinePos, bool bNxt, SwSelBoxes *pAllDelBoxes, size_t *const pCurPos)
SwFrameFormat * GetFrameFormat()
bool SetRowHeight(SwTableBox &rCurrentBox, TableChgWidthHeightType eType, SwTwips nAbsDiff, SwTwips nRelDiff, std::unique_ptr< SwUndo > *ppUndo)
void MakeOwnFrames(SwNodeIndex *pIdxBehind)
Creates the frms for the table node (i.e. the TabFrames).
constexpr sal_uInt16 RES_BOXATR_BEGIN(RES_GRFATR_END)
Marks a node in the document model.
SwFrameFormat * GetFrameFormat()
const_iterator end() const
static bool lcl_SetSelBoxWidth(SwTableLine *pLine, CR_SetBoxWidth &rParam, SwTwips nDist, bool bCheck)
IDocumentChartDataProviderAccess const & getIDocumentChartDataProviderAccess() const
SwTableBox * FindPreviousBox(const SwTable &, const SwTableBox *=nullptr, bool bOvrTableLns=true) const
sal_uInt16 GetBoxPos(const SwTableBox *pBox) const
Frame cannot be moved in Var-direction.
SwTableLines & GetTabLines()
static void lcl_AjustLines(SwTableLine *pLine, CR_SetBoxWidth &rParam)
SwTable is one table in the document model, containing rows (which contain cells).
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
void SetWidth(tools::Long n)
SwTableLines & GetTabLines()
static sal_uInt16 lcl_GetBoxOffset(const FndBox_ &rBox)
const_iterator begin() const
void SetTableChgMode(TableChgMode eMode)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void MakeNewFrames(SwTable &rTable, const sal_uInt16 nNumber, const bool bBehind)
SwTableBoxes & GetTabBoxes()
static void lcl_InsCol(FndLine_ *pFndLn, CpyPara &rCpyPara, sal_uInt16 nCpyCnt, bool bBehind)
std::vector< SwTableBox * > SwTableBoxes
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
static void lcl_SaveUpperLowerBorder(SwTable &rTable, const SwTableBox &rBox, SwShareBoxFormats &rShareFormats, SwSelBoxes *pAllDelBoxes=nullptr, size_t *const pCurPos=nullptr)
std::vector< std::unique_ptr< FndBox_ > > FndBoxes_t
void sw_Box_CollectBox(const SwTableBox *pBox, SwCollectTableLineBoxes *pSplPara)
const SwStartNode * GetSttNd() const
static void lcl_CopyBoxToDoc(FndBox_ const &rFndBox, CpyPara *const pCpyPara)
bool operator<(TypeDescription const &left, TypeDescription const &right)
void ChgFrameFormat(SwTableBoxFormat *pNewFormat, bool bNeedToReregister=true)
bool(* FN_lcl_SetLineHeight)(SwTableLine *, CR_SetLineHeight &, SwTwips, bool)
void SetLeft(const tools::Long nL, const sal_uInt16 nProp=100)
void CopyWithFlyInFly(const SwNodeRange &rRg, const SwNodeIndex &rInsPos, const std::pair< const SwPaM &, const SwPosition & > *pCopiedPaM=nullptr, bool bMakeNewFrames=true, bool bDelRedlines=true, bool bCopyFlyAtFly=false, SwCopyFlags flags=SwCopyFlags::Default) const
note: rRg/rInsPos exclude a partially selected start text node; pCopiedPaM includes a partially selec...
virtual SwFieldType * InsertFieldType(const SwFieldType &)=0
void SetTableStyleName(const OUString &rName)
Set the new table style name for this table.
const SwTableBox * GetBox() const
bool InsertCol(SwDoc &, const SwSelBoxes &rBoxes, sal_uInt16 nCnt, bool bBehind)
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
void SetRowNotTracked(const SwCursor &rCursor, const SvxPrintItem &rNotTracked, bool bAll=false)
rNotTracked = false means that the row was deleted or inserted with its tracked cell content bAll: de...
constexpr TypedWhichId< SwTableBoxFormula > RES_BOXATR_FORMULA(151)
static bool lcl_SetOtherBoxWidth(SwTableLine *pLine, CR_SetBoxWidth &rParam, SwTwips nDist, bool bCheck)
SwTableBox is one table cell in the document model.
void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes=SwNodeOffset(1))
delete nodes
constexpr TableChgWidthHeightType extractPosition(TableChgWidthHeightType e)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
bool Resize(sal_uInt16 nOffset, sal_uInt16 nWidth)
SwFrameFormat * ClaimFrameFormat()
SwFEShell * GetFEShell()
For Core - it knows the DocShell but not the WrtShell!
std::vector< std::unique_ptr< FndLine_ > > FndLines_t
SwTableNode * FindTableNode()
Search table node, in which it is.
void DeleteBox_(SwTable &rTable, SwTableBox *pBox, SwUndo *pUndo, bool bCalcNewSize, const bool bCorrBorder, SwShareBoxFormats *pShareFormats)
void SetUpper(SwTableLine *pNew)
sal_uInt32 GetValue() const
SwTableBox * FindNextBox(const SwTable &, const SwTableBox *, bool bOvrTableLns=true) const
static void lcl_CalcNewWidths(const FndLines_t &rFndLines, CpyPara &rPara)
void setRowSpan(sal_Int32 nNewRowSpan)
sal_uInt16 GetPos(const SwTableLine *pBox) const
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Frame is variable in Var-direction.
const FndLine_ * GetUpper() const
void SetNewTable(std::unique_ptr< SwTable >, bool bNewFrames=true)
std::pair< const_iterator, bool > insert(Value &&x)
void DeleteBox(const SwTable *pTable, const SwTableBox &rBox)
std::vector< Value >::size_type size_type
const SwTable * InsertTable(const SwInsertTableOptions &rInsTableOpts, const SwPosition &rPos, sal_uInt16 nRows, sal_uInt16 nCols, sal_Int16 eAdjust, const SwTableAutoFormat *pTAFormat=nullptr, const std::vector< sal_uInt16 > *pColArr=nullptr, bool bCalledFromShell=false, bool bNewModel=true)
Insert new table at position.
void Height(tools::Long nNew)
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
bool InsertRow_(SwDoc *, const SwSelBoxes &, sal_uInt16 nCnt, bool bBehind)
const editeng::SvxBorderLine * GetBottom() const
TableChgMode GetTableChgMode() const
bool MakeCopy(SwDoc &, const SwPosition &, const SwSelBoxes &, bool bCpyName=false, const OUString &rStyleName="") const
iterator erase(iterator aIt)
std::vector< Value >::const_iterator const_iterator
size_type erase(const Value &x)
SwRowFrame is one table row in the document layout.
bool MoveNodes(const SwNodeRange &, SwNodes &rNodes, const SwNodeIndex &, bool bNewFrames=true)
move the node pointer
bool m_bDetectedRangeSegmentation false
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)
Base class of the Writer document model elements.