51#include <rtl/strbuf.hxx>
53#include <osl/diagnose.h>
63 static void Pixelize( sal_uInt16& rValue );
64 void PixelizeBorders();
71 bool bCellRowSpan )
const;
79 sal_uInt16& rSkipRows )
const;
82 bool bExpandedBefore, sal_uInt16 nDepth )
const override;
84 static bool HasTabBackground(
const SwTableLine& rLine,
85 bool bTop,
bool bBottom,
bool bLeft,
bool bRight );
86 static bool HasTabBackground(
const SwTableBox& rBox,
87 bool bTop,
bool bBottom,
bool bLeft,
bool bRight );
91 bool bRel, sal_uInt16 nLeftSub, sal_uInt16 nRightSub,
92 sal_uInt16 nNumOfRowsToRepeat );
97 const OUString *pCaption=
nullptr,
bool bTopCaption=
false,
98 sal_uInt16 nHSpace=0, sal_uInt16 nVSpace=0 )
const;
104 sal_uInt32 nBWidth,
bool bRel,
105 sal_uInt16 nLSub, sal_uInt16 nRSub,
106 sal_uInt16 nNumOfRowsToRepeat )
116 if( m_bCollectBorderWidth )
120void SwHTMLWrtTable::Pixelize( sal_uInt16& rValue )
124 Size aSz( rValue, 0 );
129 rValue = o3tl::narrowing<sal_uInt16>(aSz.Width());
133void SwHTMLWrtTable::PixelizeBorders()
135 Pixelize( m_nBorder );
136 Pixelize( m_nCellSpacing );
137 Pixelize( m_nCellPadding );
140bool SwHTMLWrtTable::HasTabBackground(
const SwTableBox& rBox,
141 bool bTop,
bool bBottom,
bool bLeft,
bool bRight )
143 OSL_ENSURE( bTop || bBottom || bLeft || bRight,
144 "HasTabBackground: cannot be called" );
149 std::unique_ptr<SvxBrushItem> aBrushItem =
155 !aBrushItem->GetGraphicLink().isEmpty() || aBrushItem->GetGraphic();
161 bool bLeftRight = bLeft || bRight;
164 bool bT = bTop && 0 ==
i;
165 bool bB = bBottom &&
nCount-1 ==
i;
166 if( bT || bB || bLeftRight )
167 bRet = HasTabBackground( *rLines[i], bT, bB, bLeft, bRight);
174bool SwHTMLWrtTable::HasTabBackground(
const SwTableLine& rLine,
175 bool bTop,
bool bBottom,
bool bLeft,
bool bRight )
177 OSL_ENSURE( bTop || bBottom || bLeft || bRight,
178 "HasTabBackground: cannot be called" );
184 !aBrushItem->GetGraphicLink().isEmpty() || aBrushItem->GetGraphic();
189 const SwTableBoxes::size_type
nCount = rBoxes.size();
190 bool bTopBottom = bTop || bBottom;
191 for( SwTableBoxes::size_type i=0; !bRet &&
i<
nCount; ++
i )
193 bool bL = bLeft && 0 ==
i;
194 bool bR = bRight &&
nCount-1 ==
i;
195 if( bTopBottom || bL || bR )
196 bRet = HasTabBackground( *rBoxes[i], bTop, bBottom, bL, bR );
243bool SwHTMLWrtTable::ShouldExpandSub(
const SwTableBox *pBox,
244 bool bExpandedBefore,
245 sal_uInt16 nDepth )
const
247 bool bExpand = !pBox->
GetSttNd() && nDepth>0;
248 if( bExpand && bExpandedBefore )
252 bool bBorders =
false;
255 bBorders = HasTabBackground( *pBox,
true,
true,
true,
true );
266 bool bCellRowSpan )
const
269 sal_uInt16 nRow = pCell->
GetRow();
270 sal_uInt16 nCol = pCell->
GetCol();
313 OStringBuffer sOut(
"<");
314 OString aTag(bHead ? OOO_STRING_SVTOOLS_HTML_tableheader : OOO_STRING_SVTOOLS_HTML_tabledata);
318 if (nRowSpan > 1 && bCellRowSpan)
320 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_rowspan
321 "=\"" + OString::number(nRowSpan) +
"\"");
325 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_colspan
326 "=\"" + OString::number(nColSpan) +
"\"");
330 bool bOutWidth =
true;
333 if( m_bLayoutExport )
349 nPercentWidth = GetPercentWidth(nCol, nColSpan);
351 nWidth = GetAbsWidth( nCol, nColSpan );
359 ? GetAbsHeight( pCell->
GetHeight(), nRow, nRowSpan )
361 Size aPixelSz( nWidth, nHeight );
366 Size aOldSz( aPixelSz );
369 if( aOldSz.Width() && !aPixelSz.Width() )
370 aPixelSz.setWidth( 1 );
371 if( aOldSz.Height() && !aPixelSz.Height() )
372 aPixelSz.setHeight( 1 );
378 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_width
"=\"");
379 if( nPercentWidth != SAL_MAX_UINT32 )
381 sOut.append(OString::number(
static_cast<sal_Int32
>(nPercentWidth)) +
"%");
385 sOut.append(
static_cast<sal_Int32
>(aPixelSz.Width()));
398 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_height
399 "=\"" + OString::number(aPixelSz.Height()) +
"\"");
410 if( text::VertOrientation::TOP==eVertOri || text::VertOrientation::BOTTOM==eVertOri )
412 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_valign
413 "=\"").append(text::VertOrientation::TOP==eVertOri ?
414 OOO_STRING_SVTOOLS_HTML_VA_top :
415 OOO_STRING_SVTOOLS_HTML_VA_bottom)
437 pBrushItem =
nullptr;
445 sal_uInt32 nNumFormat = 0;
447 bool bNumFormat =
false, bValue =
false;
450 nNumFormat = pItem->GetValue();
455 nValue = pItem->GetValue();
461 if ((bNumFormat || bValue) && !rWrt.
mbXHTML)
483 sal_uInt16 nLSub, nRSub;
487 nBWidth = GetRawWidth( nCol, nColSpan );
493 nTWidth = GetAbsWidth( nCol, nColSpan );
495 nLSub = GetLeftSpace( nCol );
496 nRSub = GetRightSpace( nCol, nColSpan );
499 SwHTMLWrtTable aTableWrt( pBox->
GetTabLines(), nTWidth,
500 nBWidth, HasRelWidths(), nLSub, nRSub, 0 );
501 aTableWrt.Write( rWrt );
517 sal_uInt16& rSkipRows )
const
522 if( rCells.size() > 1 )
524 for (SwWriteTableCells::size_type nCell = 0; nCell < rCells.size(); ++nCell)
526 sal_Int16 eCellVertOri = rCells[nCell]->GetVertOri();
529 eRowVertOri = eCellVertOri;
531 else if( eRowVertOri != eCellVertOri )
554 if( text::VertOrientation::TOP==eRowVertOri || text::VertOrientation::BOTTOM==eRowVertOri )
557 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_valign
558 "=\"").append(text::VertOrientation::TOP==eRowVertOri ? OOO_STRING_SVTOOLS_HTML_VA_top : OOO_STRING_SVTOOLS_HTML_VA_bottom)
568 bool bCellRowSpan =
true;
569 if (!rCells.empty() && rCells[0]->GetRowSpan() > 1)
572 bCellRowSpan = std::adjacent_find(rCells.begin(), rCells.end(),
573 [](
const std::unique_ptr<SwWriteTableCell>& pA,
574 const std::unique_ptr<SwWriteTableCell>& pB)
575 { return pA->GetRowSpan() != pB->GetRowSpan(); })
581 rSkipRows = rCells[0]->GetRowSpan() - 1;
585 for (
const auto &rpCell : rCells)
598 const OUString *pCaption,
bool bTopCaption,
599 sal_uInt16 nHSpace, sal_uInt16 nVSpace )
const
602 bool bRowsHaveBorder =
false;
603 bool bRowsHaveBorderOnly =
true;
609 bRowsHaveBorder |= bBorder;
610 bRowsHaveBorderOnly &= bBorder;
625 bool bColsHaveBorder =
false;
626 bool bColsHaveBorderOnly =
true;
632 bColsHaveBorder |= bBorder;
633 bColsHaveBorderOnly &= bBorder;
644 OStringBuffer sOut(
"<" + rWrt.
GetNamespace() + OOO_STRING_SVTOOLS_HTML_table);
657 if( text::HoriOrientation::RIGHT == eAlign )
659 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_align
660 "=\"" OOO_STRING_SVTOOLS_HTML_AL_right
"\"");
662 else if( text::HoriOrientation::CENTER == eAlign )
664 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_align
665 "=\"" OOO_STRING_SVTOOLS_HTML_AL_center
"\"");
667 else if( text::HoriOrientation::LEFT == eAlign )
669 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_align
670 "=\"" OOO_STRING_SVTOOLS_HTML_AL_left
"\"");
676 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_width
"=\"");
678 sOut.append(OString::number(
static_cast<sal_Int32
>(m_nTabWidth)) +
"%");
682 Size(m_nTabWidth,0),
MapMode(MapUnit::MapTwip) ).Width();
686 sOut.append(nPixWidth);
701 if( !aPixelSpc.
Width() && nHSpace )
703 if( !aPixelSpc.
Height() && nVSpace )
706 if( aPixelSpc.
Width() )
708 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_hspace
709 "=\"" + OString::number(aPixelSpc.
Width()) +
"\"");
714 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_vspace
715 "=\"" + OString::number(aPixelSpc.
Height()) +
"\"");
720 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_cellpadding
724 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_cellspacing
751 if( pCaption && !pCaption->isEmpty() )
754 OStringBuffer sOutStr(OOO_STRING_SVTOOLS_HTML_caption);
755 sOutStr.append(
" " OOO_STRING_SVTOOLS_HTML_O_align
"=\"")
756 .append(bTopCaption ? OOO_STRING_SVTOOLS_HTML_VA_top : OOO_STRING_SVTOOLS_HTML_VA_bottom)
767 bool bColGroups = (bColsHaveBorder && !bColsHaveBorderOnly);
785 html.prettyPrint(
false);
786 html.start(OOO_STRING_SVTOOLS_HTML_col);
790 if( m_bLayoutExport )
797 bRel = HasRelWidths();
798 nWidth = bRel ? GetRelWidth(nCol,1) : GetAbsWidth(nCol,1);
802 html.attribute(OOO_STRING_SVTOOLS_HTML_O_width, Concat2View(OString::number(nWidth) +
"*"));
804 html.attribute(OOO_STRING_SVTOOLS_HTML_O_width, OString::number(
SwHTMLWriter::ToPixel(nWidth,
false)));
831 bool bTSections = (bRowsHaveBorder && !bRowsHaveBorderOnly);
832 bool bTBody = bTSections;
837 (bTSections || bColGroups) &&
838 m_nHeadEndRow<m_aRows.size()-1 && !m_aRows[m_nHeadEndRow]->m_bBottomBorder )
842 bTSections |= bTHead;
853 sal_uInt16 nSkipRows = 0;
866 if( !m_nCellSpacing && nRow < m_aRows.size()-1 && pRow2->
m_bBottomBorder &&
877 if( ( (bTHead && nRow==m_nHeadEndRow) ||
879 nRow < m_aRows.size()-1 )
887 if( bTHead && nRow==m_nHeadEndRow )
915 const OUString *pCaption,
bool bTopCaption )
925 css::text::WrapTextMode eSurround = css::text::WrapTextMode_NONE;
928 sal_uInt16 nFlyHSpace = 0;
929 sal_uInt16 nFlyVSpace = 0;
930 if( pFlyFrameFormat )
939 eFlyHoriOri = text::HoriOrientation::LEFT;
942 nFlyHSpace =
static_cast< sal_uInt16
>((rLRSpace.
GetLeft() + rLRSpace.
GetRight()) / 2);
949 bool bPreserveForm =
false;
962 sal_uInt16 nBaseWidth = o3tl::narrowing<sal_uInt16>(nWidth);
967 sal_uInt16 nNewDefListLvl = 0;
968 bool bRelWidths =
false;
969 bool bCheckDefList =
false;
970 switch( eTabHoriOri )
972 case text::HoriOrientation::FULL:
976 eTabHoriOri = text::HoriOrientation::LEFT;
995 else if( nPercentWidth )
998 nWidth = nPercentWidth;
1007 nWidth = nRealWidth;
1009 bCheckDefList =
true;
1012 case text::HoriOrientation::LEFT_AND_WIDTH:
1013 eTabHoriOri = text::HoriOrientation::LEFT;
1014 bCheckDefList =
true;
1022 nWidth = nPercentWidth;
1028 if( bCheckDefList && !rWrt.
mbReqIF )
1032 "NumInfo for next paragraph is missing!" );
1044 nNewDefListLvl =
static_cast< sal_uInt16
>(
1057 eTabHoriOri = eFlyHoriOri;
1064 nWidth = nFlyPercentWidth ? nFlyPercentWidth : nFlyWidth;
1065 bRelWidths = nFlyPercentWidth > 0;
1070 switch( eTabHoriOri )
1072 case text::HoriOrientation::LEFT:
1075 if( eSurround==css::text::WrapTextMode_NONE || eSurround==css::text::WrapTextMode_LEFT )
1078 case text::HoriOrientation::RIGHT:
1081 if( eSurround==css::text::WrapTextMode_NONE || eSurround==css::text::WrapTextMode_RIGHT )
1083 eDivHoriOri = text::HoriOrientation::RIGHT;
1087 case text::HoriOrientation::CENTER:
1090 eDivHoriOri = text::HoriOrientation::CENTER;
1097 nFlyHSpace = nFlyVSpace = 0;
1099 if( !pFormat->
GetName().isEmpty() )
1106 if( text::HoriOrientation::CENTER==eDivHoriOri )
1121 " style=\"display: flex; flex-direction: column; align-items: flex-end\"";
1151 SwHTMLWrtTable aTableWrt( pLayout );
1153 pFormat, pCaption, bTopCaption,
1154 nFlyHSpace, nFlyVSpace );
1158 SwHTMLWrtTable aTableWrt( rTable.
GetTabLines(), nWidth,
1161 pFormat, pCaption, bTopCaption,
1162 nFlyHSpace, nFlyVSpace );
1173 OString aTag = text::HoriOrientation::CENTER == eDivHoriOri
1176 if (!rWrt.
mbXHTML || eDivHoriOri != text::HoriOrientation::CENTER)
static OutputDevice * GetDefaultDevice()
sal_uInt32 GetValue() const
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
SvStream & WriteOString(std::string_view rStr)
SvStream & WriteChar(char nChar)
static const sal_Int16 Thin
const editeng::SvxBorderLine * GetTop() const
const editeng::SvxBorderLine * GetRight() const
const editeng::SvxBorderLine * GetLeft() const
const editeng::SvxBorderLine * GetBottom() const
tools::Long GetRight() const
tools::Long GetLeft() const
const Size & GetSize() const
sal_uInt16 GetUpper() const
sal_uInt16 GetLower() const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
bool IsRestart(const SwHTMLNumRuleInfo &rPrev) const
bool IsExportable() const
bool mbXHTML
If XHTML markup should be written instead of HTML.
void OutAndSetDefList(sal_uInt16 nNewLvl)
void ChangeParaToken(HtmlTokenId nNew)
sal_Int32 m_nDefListMargin
void OutDirection(SvxFrameDirection nDir)
css::uno::Reference< css::container::XIndexContainer > mxFormComps
void OutCSS1_TableFrameFormatOptions(const SwFrameFormat &rFrameFormat)
Writes the formatting for tables.
SvxFrameDirection m_nDirection
OString GetNamespace() const
Determines the prefix string needed to respect the requested namespace alias.
bool mbReqIF
If the ReqIF subset of XHTML should be written.
SwHTMLNumRuleInfo & GetNumInfo()
void OutNewLine(bool bCheck=false)
static sal_uInt32 ToPixel(sal_uInt32 nVal, const bool bVert)
OString maNamespace
XML namespace, in case of XHTML.
SwHTMLNumRuleInfo * GetNextNumInfo()
SvxFrameDirection GetHTMLDirection(SvxFrameDirection nDir) const
void OutForm(bool bTagOn=true, const SwStartNode *pStNd=nullptr)
void OutImplicitMark(std::u16string_view rMark, const char *pMarkType)
void OutCSS1_TableCellBordersAndBG(const SwFrameFormat &rFrameFormat, const SvxBrushItem *pBrushItem)
Writes the borders and background for table cells.
void OutBackground(const SvxBrushItem *pBrushItem, bool bGraphic)
Base class of the Writer document model elements.
SwNodeOffset GetIndex() const
SwNodeOffset EndOfSectionIndex() const
const SwEndNode * EndOfSectionNode() const
void Width(tools::Long nNew)
Starts a section of nodes in the document model.
SwTableBox is one table cell in the document model.
SwFrameFormat * GetFrameFormat()
SwTableLines & GetTabLines()
const SwStartNode * GetSttNd() const
SwTableLine is one table row in the document model.
SwFrameFormat * GetFrameFormat()
SwTableBoxes & GetTabBoxes()
std::vector< SwTableLine * >::size_type size_type
const SwTable & GetTable() const
SwTable is one table in the document model, containing rows (which contain cells).
SwTableLines & GetTabLines()
SwTableFormat * GetFrameFormat()
SwHTMLTableLayout * GetHTMLTableLayout()
sal_uInt16 GetRowsToRepeat() const
SwTextNode is a paragraph in the document model.
const SwViewOption * GetViewOptions() const
tools::Long GetHeight() const
sal_uInt32 GetWidthOpt() const
sal_uInt16 GetRowSpan() const
bool HasPercentWidthOpt() const
sal_Int16 GetVertOri() const
const SwTableBox * GetBox() const
const SvxBrushItem * GetBackground() const
sal_uInt16 GetRow() const
sal_uInt16 GetCol() const
sal_uInt16 GetColSpan() const
bool HasRelWidthOpt() const
sal_uInt32 GetWidthOpt() const
sal_uInt16 m_nBottomBorder
const SvxBrushItem * GetBackground() const
const SwWriteTableCells & GetCells() const
virtual bool ShouldExpandSub(const SwTableBox *pBox, bool bExpandedBefore, sal_uInt16 nDepth) const
std::shared_ptr< SwUnoCursor > m_pCurrentPam
std::vector< Value >::size_type size_type
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
SwHTMLWriter & OutCSS1_TableBGStyleOpt(SwHTMLWriter &rWrt, const SfxPoolItem &rHt)
Writes the background of table rows.
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(158)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(111)
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(112)
#define OOO_STRING_SVTOOLS_HTML_O_align
#define OOO_STRING_SVTOOLS_HTML_tabledata
#define OOO_STRING_SVTOOLS_HTML_division
#define OOO_STRING_SVTOOLS_HTML_tableheader
#define OOO_STRING_SVTOOLS_HTML_tbody
#define OOO_STRING_SVTOOLS_HTML_center
#define OOO_STRING_SVTOOLS_HTML_AL_right
#define OOO_STRING_SVTOOLS_HTML_thead
SwHTMLWriter & OutHTML_NumberBulletListEnd(SwHTMLWriter &rWrt, const SwHTMLNumRuleInfo &rNextInfo)
SwHTMLWriter & OutHTML_SwTableNode(SwHTMLWriter &rWrt, SwTableNode &rNode, const SwFrameFormat *pFlyFrameFormat, const OUString *pCaption, bool bTopCaption)
static bool lcl_TableBox_HasTabBorders(const SwTableBox *pBox, bool *pBorders)
static bool lcl_TableLine_HasTabBorders(const SwTableLine *pLine, bool *pBorders)
static void Write(std::u16string_view aString, SvStream &rStream)
@ RES_POOLCOLL_TABLE
Subgroup table.
@ RES_POOLCOLL_TABLE_HDLN
Table of Contents - heading.
static SVT_DLLPUBLIC SvStream & Out_AsciiTag(SvStream &, std::string_view rStr, bool bOn=true)
static SVT_DLLPUBLIC SvStream & Out_String(SvStream &, const OUString &, OUString *pNonConvertableChars=nullptr)
static SVT_DLLPUBLIC OString CreateTableDataOptionsValNum(bool bValue, double fVal, sal_uInt32 nFormat, SvNumberFormatter &rFormatter, OUString *pNonConvertableChars=nullptr)
std::vector< SwTableBox * > SwTableBoxes
std::vector< std::unique_ptr< SwWriteTableCell > > SwWriteTableCells