27 #include <osl/diagnose.h>
35 using ::editeng::SvxBorderLine;
40 sal_Int16 eCellVertOri = text::VertOrientation::TOP;
47 sal_Int16 eBoxVertOri =
49 if( text::VertOrientation::CENTER==eBoxVertOri || text::VertOrientation::BOTTOM==eBoxVertOri)
50 eCellVertOri = eBoxVertOri;
58 : pBackground(nullptr),
nPos(nPosition), mbUseLayoutHeights(bUseLayoutHeights),
65 sal_uInt16 nRow, sal_uInt16 nCol,
66 sal_uInt16 nRowSpan, sal_uInt16 nColSpan,
72 nHeight, pBackgroundBrush );
73 m_Cells.push_back(std::unique_ptr<SwWriteTableCell>(pCell));
79 :
nPos(nPosition), nWidthOpt(0), bRelWidthOpt(false),
80 bLeftBorder(true), bRightBorder(true)
90 return sal::static_int_cast<sal_uInt32>(aFrameSize.
GetSize().
Width());
104 bool bLayoutAvailable =
false;
116 SAL_WARN_IF( !bLayoutAvailable && bOldGetLineHeightCalled,
"sw",
"Layout invalid?" );
121 for(
auto pBox : rBoxes )
123 if( pBox->GetSttNd() )
132 for(
size_t nLine=0; nLine<rLines.
size(); nLine++ )
157 nHeight = static_cast<const SwFormatFrameSize*>(pItem)->GetHeight();
179 pRow->
SetBackground( static_cast<const SvxBrushItem *>(pItem) );
187 pLine = pBox ? pBox->
GetUpper() :
nullptr;
198 if( !pBorderLine->GetColor().IsRGBEqual(
COL_GRAY ) )
205 const sal_uInt16 nOutWidth = pBorderLine->GetOutWidth();
217 const sal_uInt16 nDist = pBorderLine->GetInWidth() ? pBorderLine->GetDistance()
224 size_t const nRow,
size_t const nCol,
225 sal_uInt16 nRowSpan, sal_uInt16 nColSpan,
226 sal_uInt16& rTopBorder,
227 sal_uInt16 &rBottomBorder )
229 sal_uInt16 nBorderMask = 0;
265 sal_uInt16 nDist = rBoxItem.
GetDistance( SvxBoxItemLine::TOP );
268 nDist = rBoxItem.
GetDistance( SvxBoxItemLine::BOTTOM );
271 nDist = rBoxItem.
GetDistance( SvxBoxItemLine::LEFT );
274 nDist = rBoxItem.
GetDistance( SvxBoxItemLine::RIGHT );
284 sal_uInt32 nWidth =
m_aCols[nCol+nColSpan-1]->GetPos();
286 nWidth = nWidth -
m_aCols[nCol-1]->GetPos();
338 OSL_ENSURE( nWidth > 0,
"Column Width <= 0. OK?" );
339 return nWidth > 0 ?
static_cast<sal_uInt16
>(nWidth) : 0;
361 sal_uInt16 nRowSpan )
const
379 if( !pRow || nRowSpan > 1 )
380 pRow =
m_aRows[nRow+nRowSpan-1].get();
385 OSL_ENSURE( nRawHeight > 0,
"Row Height <= 0. OK?" );
386 return std::max<tools::Long>(nRawHeight, 0);
390 sal_uInt16 nDepth)
const
392 return !pBox->
GetSttNd() && nDepth > 0;
400 sal_uInt32 nStartCPos,
402 sal_uInt32 nParentLineWidth,
406 bool bSubExpanded =
false;
409 #if OSL_DEBUG_LEVEL > 0
410 sal_uInt32 nEndCPos = 0;
420 if( nLine < nLines-1 || nParentLineHeight==0 )
423 nRPos += nLineHeight;
424 if( nParentLineHeight && nStartRPos + nParentLineHeight <= nRPos )
430 OSL_FAIL(
"Corrupt line height I" );
431 nRPos -= nLineHeight;
432 nLineHeight = nStartRPos + nParentLineHeight - nRPos;
433 nLineHeight /= nLines - nLine;
434 nRPos += nLineHeight;
441 #if OSL_DEBUG_LEVEL > 0
444 nRPos = nStartRPos + nParentLineHeight;
445 #if OSL_DEBUG_LEVEL > 0
448 [&](std::unique_ptr<SwWriteTableRow>
const &
p)
449 {
return *
p == aSrchRow; }) !=
m_aRows.
end(),
"Parent-Row not found" );
453 aRowCheckPos == aRowRPos,
454 "Height of the rows does not correspond with the parent" );
460 const SwTableBoxes::size_type nBoxes = rBoxes.size();
462 sal_uInt32 nCPos = nStartCPos;
463 for( SwTableBoxes::size_type nBox=0; nBox<nBoxes; ++nBox )
467 sal_uInt32 nOldCPos = nCPos;
469 if( nBox < nBoxes-1 || (nParentLineWidth==0 && nLine==0) )
478 OSL_ENSURE( nLine==0 && nParentLineWidth==0,
479 "Now the parent width will be flattened!" );
480 nParentLineWidth = nCPos-nStartCPos;
485 #if OSL_DEBUG_LEVEL > 0
486 sal_uInt32 nCheckPos = nCPos +
GetBoxWidth( pBox );
489 nEndCPos = nCheckPos;
495 "Cell includes rows of different widths" );
498 nCPos = nStartCPos + nParentLineWidth;
500 #if OSL_DEBUG_LEVEL > 0
503 "Parent-Cell not found" );
506 "Width of the cells does not correspond with the parent" );
524 sal_uInt32 nStartCPos, sal_uInt16 nStartCol,
526 sal_uInt32 nParentLineWidth,
530 sal_uInt16 nNumOfHeaderRows )
533 bool bSubExpanded =
false;
537 sal_uInt16 nRow = nStartRow;
545 if( nLine < nLines-1 || nParentLineHeight==0 )
548 nRPos += nLineHeight;
549 if( nParentLineHeight && nStartRPos + nParentLineHeight <= nRPos )
552 OSL_FAIL(
"Corrupt line height II" );
553 nRPos -= nLineHeight;
554 nLineHeight = nStartRPos + nParentLineHeight - nRPos;
555 nLineHeight /= nLines - nLine;
556 nRPos += nLineHeight;
560 nRPos = nStartRPos + nParentLineHeight;
563 sal_uInt16 nOldRow = nRow;
566 [&](std::unique_ptr<SwWriteTableRow>
const &
p)
567 {
return *
p == aSrchRow; });
573 OSL_ENSURE( nOldRow <= nRow,
"Don't look back!" );
583 if( nLine+1==nNumOfHeaderRows && nParentLineHeight==0 )
594 nHeight = static_cast<const SwFormatFrameSize*>(pItem)->GetHeight();
596 const SvxBrushItem *pBrushItem, *pLineBrush = pParentBrush;
605 bool bOutAtRow = !nParentLineWidth;
606 if( !bOutAtRow && nStartCPos==0 )
614 pBrushItem =
nullptr;
617 pBrushItem = pLineBrush;
622 pBrushItem =
nullptr;
625 const SwTableBoxes::size_type nBoxes = rBoxes.size();
626 sal_uInt32 nCPos = nStartCPos;
627 sal_uInt16 nCol = nStartCol;
629 for( SwTableBoxes::size_type nBox=0; nBox<nBoxes; ++nBox )
634 sal_uInt32 nOldCPos = nCPos;
635 if( nBox < nBoxes-1 || (nParentLineWidth==0 && nLine==0) )
639 nParentLineWidth = nCPos - nStartCPos;
642 nCPos = nStartCPos + nParentLineWidth;
645 sal_uInt16 nOldCol = nCol;
648 OSL_ENSURE( it !=
m_aCols.
end(),
"missing column" );
657 sal_uInt16 nRowSpan = nRow - nOldRow + 1;
660 const sal_Int32 nAttrRowSpan = pBox->
getRowSpan();
661 if ( 1 < nAttrRowSpan )
662 nRowSpan =
static_cast<sal_uInt16
>(nAttrRowSpan);
663 else if ( nAttrRowSpan < 1 )
666 SAL_WARN_IF(nCol < nOldCol,
"sw.filter",
"unexpected " << nCol <<
" < " << nOldCol);
667 sal_uInt16 nColSpan = nCol >= nOldCol ? nCol - nOldCol + 1 : 1;
668 pRow->
AddCell( pBox, nOldRow, nOldCol,
669 nRowSpan, nColSpan, nHeight,
677 nRowSpan, nColSpan, nTopBorder, nBottomBorder);
682 if (!(nBorderMask & 4) && nOldCol <
m_aCols.
size())
685 OSL_ENSURE(pCol,
"No TableCol found, panic!");
690 if (!(nBorderMask & 8))
693 OSL_ENSURE(pCol,
"No TableCol found, panic!");
698 if (!(nBorderMask & 1))
700 else if (!pRow->
nTopBorder || nTopBorder < pRow->nTopBorder)
703 if (!(nBorderMask & 2))
707 nBottomBorder < pEndRow->nBottomBorder
717 nRPos-nOldRPos, nCPos-nOldCPos,
719 pLineBrush, nDepth-1,
732 sal_uInt32 nBWidth,
bool bRel, sal_uInt16 nMaxDepth, sal_uInt16 nLSub, sal_uInt16 nRSub, sal_uInt32 nNumOfRowsToRepeat)
733 : m_pTable(pTable), m_nBorderColor(
ColorTransparency, sal_uInt32(-1)), m_nCellSpacing(0), m_nCellPadding(0), m_nBorder(0),
734 m_nInnerBorder(0), m_nBaseWidth(nBWidth), m_nHeadEndRow(
USHRT_MAX),
735 m_nLeftSub(nLSub), m_nRightSub(nRSub), m_nTabWidth(nWidth), m_bRelWidths(bRel),
736 m_bUseLayoutHeights(true),
738 m_bGetLineHeightCalled(false),
740 m_bColTags(true), m_bLayoutExport(false),
741 m_bCollectBorderWidth(true)
747 std::unique_ptr<SwWriteTableCol> pCol(
new SwWriteTableCol( nParentWidth ));
758 FillTableRowsCols( 0, 0, 0, 0, 0, nParentWidth, rLines,
nullptr, nMaxDepth - 1, static_cast< sal_uInt16 >(nNumOfRowsToRepeat) );
766 : m_pTable(pTable), m_nBorderColor(
ColorTransparency, sal_uInt32(-1)), m_nCellSpacing(0), m_nCellPadding(0), m_nBorder(0),
767 m_nInnerBorder(0), m_nBaseWidth(pLayoutInfo->GetWidthOption()), m_nHeadEndRow(0),
768 m_nLeftSub(0), m_nRightSub(0), m_nTabWidth(pLayoutInfo->GetWidthOption()),
769 m_bRelWidths(pLayoutInfo->HasPercentWidthOption()), m_bUseLayoutHeights(false),
771 m_bGetLineHeightCalled(false),
773 m_bColTags(pLayoutInfo->HasColTags()), m_bLayoutExport(true),
774 m_bCollectBorderWidth(pLayoutInfo->HaveBordersChanged())
783 const sal_uInt16 nCols = pLayoutInfo->
GetColCount();
784 const sal_uInt16 nRows = pLayoutInfo->
GetRowCount();
787 for( sal_uInt16 nCol=0; nCol<nCols; ++nCol )
789 std::unique_ptr<SwWriteTableCol> pCol(
803 for( sal_uInt16 nRow=0; nRow<nRows; ++nRow )
805 std::unique_ptr<SwWriteTableRow> pRow(
807 pRow->nTopBorder = 0;
808 pRow->nBottomBorder = 0;
813 for( sal_uInt16 nRow=0; nRow<nRows; ++nRow )
817 bool bHeightExported =
false;
818 for( sal_uInt16 nCol=0; nCol<nCols; nCol++ )
821 pLayoutInfo->
GetCell( nRow, nCol );
827 if( ( nRow>0 && pLayoutCnts == pLayoutInfo->
GetCell(nRow-1,nCol)
829 ( nCol>0 && pLayoutCnts == pLayoutInfo->
GetCell(nRow,nCol-1)
835 const sal_uInt16 nRowSpan = pLayoutCell->
GetRowSpan();
836 const sal_uInt16 nColSpan = pLayoutCell->
GetColSpan();
839 "Table in Table can not be exported over layout" );
845 pRow->
AddCell( pBox, nRow, nCol, nRowSpan, nColSpan,
846 nHeight, pBrushItem );
851 sal_uInt16 nBorderMask =
853 nTopBorder, nBottomBorder );
856 if( !(nBorderMask & 4) )
859 pCol =
m_aCols[nCol+nColSpan-1].get();
860 if( !(nBorderMask & 8) )
863 if( !(nBorderMask & 1) )
867 if( !(nBorderMask & 2) )
872 bHeightExported =
true;
std::vector< SwTableLine * >::size_type size_type
SwTwips GetTableLineHeight(bool &bLayoutAvailable) const
sal_uInt16 GetCellPadding() const
void CollectTableRowsCols(tools::Long nStartRPos, sal_uInt32 nStartCPos, tools::Long nParentLineHeight, sal_uInt32 nParentLineWidth, const SwTableLines &rLines, sal_uInt16 nDepth)
bool HasRightBorder() const
virtual bool ShouldExpandSub(const SwTableBox *pBox, bool bExpandedBefore, sal_uInt16 nDepth) const
sal_uInt16 GetLeftSpace(sal_uInt16 nCol) const
void SetWidthOpt(sal_uInt16 nWidth, bool bPercent)
sal_uInt32 GetRawWidth(sal_uInt16 nCol, sal_uInt16 nColSpan) const
sal_uInt16 m_nInnerBorder
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
SwTableBox * GetTableBox() const
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
static sal_uInt32 GetBoxWidth(const SwTableBox *pBox)
const_iterator find(const Value &x) const
SwTableLine is one table row in the document model.
sal_uInt16 GetBorder() const
const editeng::SvxBorderLine * GetRight() const
sal_uInt16 GetRelWidth(sal_uInt16 nCol, sal_uInt16 nColSpan) const
sal_uInt16 MergeBoxBorders(const SwTableBox *pBox, size_t nRow, size_t nCol, sal_uInt16 nRowSpan, sal_uInt16 nColSpan, sal_uInt16 &rTopBorder, sal_uInt16 &rBottomBorder)
sal_Int32 getRowSpan() const
constexpr tools::Long Width() const
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
sal_uInt32 GetBaseWidth() const
bool HasTopBorder() const
sal_uInt16 GetColSpan() const
sal_uInt16 GetOutWidth() const
sal_uInt16 GetAbsWidth(sal_uInt16 nCol, sal_uInt16 nColSpan) const
sal_uInt16 GetRowCount() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
const SvxBrushItem * GetBackground() const
sal_uInt16 GetWidthOption() const
sal_uInt16 GetColCount() const
sal_uInt16 GetPercentWidth(sal_uInt16 nCol, sal_uInt16 nColSpan) const
bool HasLeftBorder() const
sal_Int16 GetVertOri() const
sal_uInt16 m_nCellSpacing
SwWriteTableCells m_Cells
all cells of the rows
const editeng::SvxBorderLine * GetTop() const
SwWriteTableCell * AddCell(const SwTableBox *pBox, sal_uInt16 nRow, sal_uInt16 nCol, sal_uInt16 nRowSpan, sal_uInt16 nColSpan, tools::Long nHeight, const SvxBrushItem *pBackground)
SwHTMLTableLayoutCell * GetCell(sal_uInt16 nRow, sal_uInt16 nCol) const
bool IsPercentWidthOption() const
const editeng::SvxBorderLine * GetLeft() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
bool IsRelWidthOption() const
static const SvxBrushItem * GetLineBrush(const SwTableBox *pBox, SwWriteTableRow *pRow)
tools::Long GetAbsHeight(tools::Long nRawWidth, size_t nRow, sal_uInt16 nRowSpan) const
sal_uInt16 m_nCellPadding
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_GRAY
const std::shared_ptr< SwHTMLTableLayoutCnts > & GetContents() const
SwFrameFormat * GetFrameFormat()
SwFrameFormat * GetFrameFormat()
const_iterator end() const
void SetBackground(const SvxBrushItem *pBGround)
SwTable is one table in the document model, containing rows (which contain cells).
SwTableLines & GetTabLines()
const_iterator begin() const
bool m_bCollectBorderWidth
SwTableBoxes & GetTabBoxes()
std::vector< SwTableBox * > SwTableBoxes
const SwStartNode * GetSttNd() const
sal_uInt16 GetCellSpacing() const
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
#define SAL_WARN_IF(condition, area, stream)
SwWriteTableRow(const SwWriteTableRow &)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
SwWriteTableCol(sal_uInt32 nPosition)
void MergeBorders(const editeng::SvxBorderLine *pBorderLine, bool bTable)
bool HasBottomBorder() const
void FillTableRowsCols(tools::Long nStartRPos, sal_uInt16 nStartRow, sal_uInt32 nStartCPos, sal_uInt16 nStartCol, tools::Long nParentLineHeight, sal_uInt32 nParentLineWidth, const SwTableLines &rLines, const SvxBrushItem *pLineBrush, sal_uInt16 nDepth, sal_uInt16 nNumOfHeaderRows)
sal_uInt16 GetRightSpace(size_t nCol, sal_uInt16 nColSpan) const
SwTableBox is one table cell in the document model.
sal_uInt16 GetRowSpan() const
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
tools::Long GetLineHeight(const SwTableLine *pLine)
bool m_bGetLineHeightCalled
SwHTMLTableLayoutColumn * GetColumn(sal_uInt16 nCol) const
sal_uInt16 GetWidthOption() const
std::pair< const_iterator, bool > insert(Value &&x)
SwWriteTable(const SwTable *pTable, const SwTableLines &rLines, tools::Long nWidth, sal_uInt32 nBWidth, bool bRel, sal_uInt16 nMaxDepth=USHRT_MAX, sal_uInt16 nLeftSub=0, sal_uInt16 nRightSub=0, sal_uInt32 nNumOfRowsToRepeat=0)
const editeng::SvxBorderLine * GetBottom() const
const Size & GetSize() const
std::vector< std::unique_ptr< SwWriteTableRow > >::const_iterator const_iterator