51 #include <rtl/strbuf.hxx>
53 #include <osl/diagnose.h>
63 static void Pixelize( sal_uInt16& rValue );
64 void PixelizeBorders();
67 bool bOutVAlign )
const;
74 bool bExpandedBefore, sal_uInt16 nDepth )
const override;
76 static bool HasTabBackground(
const SwTableLine& rLine,
77 bool bTop,
bool bBottom,
bool bLeft,
bool bRight );
78 static bool HasTabBackground(
const SwTableBox& rBox,
79 bool bTop,
bool bBottom,
bool bLeft,
bool bRight );
83 bool bRel, sal_uInt16 nLeftSub, sal_uInt16 nRightSub,
84 sal_uInt16 nNumOfRowsToRepeat );
89 const OUString *pCaption=
nullptr,
bool bTopCaption=
false,
90 sal_uInt16 nHSpace=0, sal_uInt16 nVSpace=0 )
const;
96 sal_uInt32 nBWidth,
bool bRel,
97 sal_uInt16 nLSub, sal_uInt16 nRSub,
98 sal_uInt16 nNumOfRowsToRepeat )
108 if( m_bCollectBorderWidth )
112 void SwHTMLWrtTable::Pixelize( sal_uInt16& rValue )
116 Size aSz( rValue, 0 );
121 rValue = o3tl::narrowing<sal_uInt16>(aSz.Width());
125 void SwHTMLWrtTable::PixelizeBorders()
127 Pixelize( m_nBorder );
128 Pixelize( m_nCellSpacing );
129 Pixelize( m_nCellPadding );
132 bool SwHTMLWrtTable::HasTabBackground(
const SwTableBox& rBox,
133 bool bTop,
bool bBottom,
bool bLeft,
bool bRight )
135 OSL_ENSURE( bTop || bBottom || bLeft || bRight,
136 "HasTabBackground: cannot be called" );
141 std::unique_ptr<SvxBrushItem> aBrushItem =
147 !aBrushItem->GetGraphicLink().isEmpty() || aBrushItem->GetGraphic());
153 bool bLeftRight = bLeft || bRight;
156 bool bT = bTop && 0 ==
i;
157 bool bB = bBottom && nCount-1 ==
i;
158 if( bT || bB || bLeftRight )
159 bRet = HasTabBackground( *rLines[i], bT, bB, bLeft, bRight);
166 bool SwHTMLWrtTable::HasTabBackground(
const SwTableLine& rLine,
167 bool bTop,
bool bBottom,
bool bLeft,
bool bRight )
169 OSL_ENSURE( bTop || bBottom || bLeft || bRight,
170 "HasTabBackground: cannot be called" );
175 bool bRet = aBrushItem && (aBrushItem->GetColor() !=
COL_TRANSPARENT ||
176 !aBrushItem->GetGraphicLink().isEmpty() || aBrushItem->GetGraphic());
181 const SwTableBoxes::size_type nCount = rBoxes.size();
182 bool bTopBottom = bTop || bBottom;
183 for( SwTableBoxes::size_type i=0; !bRet &&
i<nCount; ++
i )
185 bool bL = bLeft && 0 ==
i;
186 bool bR = bRight && nCount-1 ==
i;
187 if( bTopBottom || bL || bR )
188 bRet = HasTabBackground( *rBoxes[i], bTop, bBottom, bL, bR );
235 bool SwHTMLWrtTable::ShouldExpandSub(
const SwTableBox *pBox,
236 bool bExpandedBefore,
237 sal_uInt16 nDepth )
const
239 bool bExpand = !pBox->
GetSttNd() && nDepth>0;
240 if( bExpand && bExpandedBefore )
244 bool bBorders =
false;
247 bBorders = HasTabBackground( *pBox,
true,
true,
true,
true );
257 bool bOutVAlign )
const
260 sal_uInt16 nRow = pCell->
GetRow();
261 sal_uInt16 nCol = pCell->
GetCol();
306 OString aTag(bHead ? OOO_STRING_SVTOOLS_HTML_tableheader : OOO_STRING_SVTOOLS_HTML_tabledata);
312 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_rowspan
313 "=\"" + OString::number(nRowSpan) +
"\"");
317 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_colspan
318 "=\"" + OString::number(nColSpan) +
"\"");
322 bool bOutWidth =
true;
325 if( m_bLayoutExport )
341 nPercentWidth = GetPercentWidth(nCol, nColSpan);
343 nWidth = GetAbsWidth( nCol, nColSpan );
351 ? GetAbsHeight( pCell->
GetHeight(), nRow, nRowSpan )
353 Size aPixelSz( nWidth, nHeight );
358 Size aOldSz( aPixelSz );
361 if( aOldSz.Width() && !aPixelSz.Width() )
362 aPixelSz.setWidth( 1 );
363 if( aOldSz.Height() && !aPixelSz.Height() )
364 aPixelSz.setHeight( 1 );
370 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_width
"=\"");
371 if( nPercentWidth != SAL_MAX_UINT32 )
373 sOut.append(static_cast<sal_Int32>(nPercentWidth)).append(
'%');
377 sOut.append(static_cast<sal_Int32>(aPixelSz.Width()));
390 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_height
391 "=\"" + OString::number(aPixelSz.Height()) +
"\"");
402 if( text::VertOrientation::TOP==eVertOri || text::VertOrientation::BOTTOM==eVertOri )
404 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_valign
405 "=\"").append(text::VertOrientation::TOP==eVertOri ?
406 OOO_STRING_SVTOOLS_HTML_VA_top :
407 OOO_STRING_SVTOOLS_HTML_VA_bottom)
428 pBrushItem =
nullptr;
436 sal_uInt32 nNumFormat = 0;
438 bool bNumFormat =
false, bValue =
false;
441 nNumFormat = pItem->GetValue();
446 nValue = pItem->GetValue();
452 if( bNumFormat || bValue )
473 sal_uInt16 nLSub, nRSub;
477 nBWidth = GetRawWidth( nCol, nColSpan );
483 nTWidth = GetAbsWidth( nCol, nColSpan );
485 nLSub = GetLeftSpace( nCol );
486 nRSub = GetRightSpace( nCol, nColSpan );
489 SwHTMLWrtTable aTableWrt( pBox->
GetTabLines(), nTWidth,
490 nBWidth, HasRelWidths(), nLSub, nRSub, 0 );
491 aTableWrt.Write( rWrt );
511 if( rCells.size() > 1 )
513 for (SwWriteTableCells::size_type nCell = 0; nCell < rCells.size(); ++nCell)
515 sal_Int16 eCellVertOri = rCells[nCell]->GetVertOri();
518 eRowVertOri = eCellVertOri;
520 else if( eRowVertOri != eCellVertOri )
543 if( text::VertOrientation::TOP==eRowVertOri || text::VertOrientation::BOTTOM==eRowVertOri )
546 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_valign
547 "=\"").append(text::VertOrientation::TOP==eRowVertOri ? OOO_STRING_SVTOOLS_HTML_VA_top : OOO_STRING_SVTOOLS_HTML_VA_bottom)
556 for (
const auto &rpCell : rCells)
569 const OUString *pCaption,
bool bTopCaption,
570 sal_uInt16 nHSpace, sal_uInt16 nVSpace )
const
573 bool bRowsHaveBorder =
false;
574 bool bRowsHaveBorderOnly =
true;
580 bRowsHaveBorder |= bBorder;
581 bRowsHaveBorderOnly &= bBorder;
596 bool bColsHaveBorder =
false;
597 bool bColsHaveBorderOnly =
true;
603 bColsHaveBorder |= bBorder;
604 bColsHaveBorderOnly &= bBorder;
628 if( text::HoriOrientation::RIGHT == eAlign )
630 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_align
631 "=\"" OOO_STRING_SVTOOLS_HTML_AL_right
"\"");
633 else if( text::HoriOrientation::CENTER == eAlign )
635 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_align
636 "=\"" OOO_STRING_SVTOOLS_HTML_AL_center
"\"");
638 else if( text::HoriOrientation::LEFT == eAlign )
640 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_align
641 "=\"" OOO_STRING_SVTOOLS_HTML_AL_left
"\"");
647 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_width
"=\"");
649 sOut.append(static_cast<sal_Int32>(m_nTabWidth)).append(
'%');
653 Size(m_nTabWidth,0),
MapMode(MapUnit::MapTwip) ).Width();
657 sOut.append(nPixWidth);
672 if( !aPixelSpc.
Width() && nHSpace )
674 if( !aPixelSpc.
Height() && nVSpace )
677 if( aPixelSpc.
Width() )
679 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_hspace
680 "=\"" + OString::number(aPixelSpc.
Width()) +
"\"");
685 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_vspace
686 "=\"" + OString::number(aPixelSpc.
Height()) +
"\"");
691 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_cellpadding
695 sOut.append(
" " OOO_STRING_SVTOOLS_HTML_O_cellspacing
720 if( pCaption && !pCaption->isEmpty() )
723 OStringBuffer sOutStr(OOO_STRING_SVTOOLS_HTML_caption);
724 sOutStr.append(
" " OOO_STRING_SVTOOLS_HTML_O_align
"=\"")
725 .append(bTopCaption ? OOO_STRING_SVTOOLS_HTML_VA_top : OOO_STRING_SVTOOLS_HTML_VA_bottom)
736 bool bColGroups = (bColsHaveBorder && !bColsHaveBorderOnly);
754 html.
start(OOO_STRING_SVTOOLS_HTML_col);
758 if( m_bLayoutExport )
765 bRel = HasRelWidths();
766 nWidth = bRel ? GetRelWidth(nCol,1) : GetAbsWidth(nCol,1);
770 html.attribute(OOO_STRING_SVTOOLS_HTML_O_width, OStringConcatenation(OString::number(nWidth) +
"*"));
772 html.attribute(OOO_STRING_SVTOOLS_HTML_O_width, OString::number(
SwHTMLWriter::ToPixel(nWidth,
false)));
799 bool bTSections = (bRowsHaveBorder && !bRowsHaveBorderOnly);
800 bool bTBody = bTSections;
805 (bTSections || bColGroups) &&
806 m_nHeadEndRow<m_aRows.size()-1 && !m_aRows[m_nHeadEndRow]->m_bBottomBorder )
810 bTSections |= bTHead;
826 if( !m_nCellSpacing && nRow < m_aRows.size()-1 && pRow2->
m_bBottomBorder &&
837 if( ( (bTHead && nRow==m_nHeadEndRow) ||
839 nRow < m_aRows.size()-1 )
847 if( bTHead && nRow==m_nHeadEndRow )
875 const OUString *pCaption,
bool bTopCaption )
886 css::text::WrapTextMode eSurround = css::text::WrapTextMode_NONE;
889 sal_uInt16 nFlyHSpace = 0;
890 sal_uInt16 nFlyVSpace = 0;
891 if( pFlyFrameFormat )
900 eFlyHoriOri = text::HoriOrientation::LEFT;
903 nFlyHSpace =
static_cast< sal_uInt16
>((rLRSpace.
GetLeft() + rLRSpace.
GetRight()) / 2);
910 bool bPreserveForm =
false;
913 rHTMLWrt.
OutForm(
true, &rNode );
923 sal_uInt16 nBaseWidth = o3tl::narrowing<sal_uInt16>(nWidth);
928 sal_uInt16 nNewDefListLvl = 0;
929 bool bRelWidths =
false;
930 bool bCheckDefList =
false;
931 switch( eTabHoriOri )
933 case text::HoriOrientation::FULL:
937 eTabHoriOri = text::HoriOrientation::LEFT;
956 else if( nPercentWidth )
959 nWidth = nPercentWidth;
970 bCheckDefList =
true;
973 case text::HoriOrientation::LEFT_AND_WIDTH:
974 eTabHoriOri = text::HoriOrientation::LEFT;
975 bCheckDefList =
true;
983 nWidth = nPercentWidth;
992 "NumInfo for next paragraph is missing!" );
1005 nNewDefListLvl =
static_cast< sal_uInt16
>(
1011 if( !pFlyFrameFormat && nNewDefListLvl != rHTMLWrt.
m_nDefListLvl )
1014 if( nNewDefListLvl )
1025 eTabHoriOri = eFlyHoriOri;
1032 nWidth = nFlyPercentWidth ? nFlyPercentWidth : nFlyWidth;
1033 bRelWidths = nFlyPercentWidth > 0;
1038 switch( eTabHoriOri )
1040 case text::HoriOrientation::LEFT:
1043 if( eSurround==css::text::WrapTextMode_NONE || eSurround==css::text::WrapTextMode_LEFT )
1046 case text::HoriOrientation::RIGHT:
1049 if( eSurround==css::text::WrapTextMode_NONE || eSurround==css::text::WrapTextMode_RIGHT )
1051 eDivHoriOri = text::HoriOrientation::RIGHT;
1055 case text::HoriOrientation::CENTER:
1058 eDivHoriOri = text::HoriOrientation::CENTER;
1065 nFlyHSpace = nFlyVSpace = 0;
1067 if( !pFormat->
GetName().isEmpty() )
1074 if( text::HoriOrientation::CENTER==eDivHoriOri )
1103 SwHTMLWrtTable aTableWrt( pLayout );
1105 pFormat, pCaption, bTopCaption,
1106 nFlyHSpace, nFlyVSpace );
1110 SwHTMLWrtTable aTableWrt( rTable.
GetTabLines(), nWidth,
1113 pFormat, pCaption, bTopCaption,
1114 nFlyHSpace, nFlyVSpace );
1125 OString aTag = text::HoriOrientation::CENTER == eDivHoriOri
bool HasPercentWidthOpt() const
const SwEndNode * EndOfSectionNode() const
Starts a section of nodes in the document model.
bool HasRelWidthOpt() const
std::vector< SwTableLine * >::size_type size_type
SwHTMLNumRuleInfo & GetNumInfo()
virtual bool ShouldExpandSub(const SwTableBox *pBox, bool bExpandedBefore, sal_uInt16 nDepth) const
SwNodeOffset EndOfSectionIndex() const
bool mbXHTML
If XHTML markup should be written instead of HTML.
sal_uInt16 GetRowSpan() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 GetLower() const
void setWidth(tools::Long nWidth)
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
#define OOO_STRING_SVTOOLS_HTML_caption
SwHTMLNumRuleInfo * GetNextNumInfo()
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
#define OOO_STRING_SVTOOLS_HTML_tableheader
tools::Long GetRight() const
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define OOO_STRING_SVTOOLS_HTML_tablerow
SwTableLine is one table row in the document model.
sal_uInt16 GetRowsToRepeat() const
static SVT_DLLPUBLIC SvStream & Out_AsciiTag(SvStream &, std::string_view rStr, bool bOn=true)
sal_Int32 m_nDefListMargin
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(152)
const editeng::SvxBorderLine * GetRight() const
#define OOO_STRING_SVTOOLS_HTML_thead
SwTableFormat * GetFrameFormat()
OString maNamespace
XML namespace, in case of XHTML.
sal_uInt32 GetWidthOpt() const
#define OOO_STRING_SVTOOLS_HTML_tbody
void OutBackground(const SvxBrushItem *pBrushItem, bool bGraphic)
static OutputDevice * GetDefaultDevice()
const SwTableBox * GetBox() const
constexpr tools::Long Width() const
void OutNewLine(bool bCheck=false)
#define OOO_STRING_SVTOOLS_HTML_tabledata
bool mbReqIF
If the ReqIF subset of XHTML should be written.
sal_uInt16 m_nBottomBorder
const SvxBrushItem * GetBackground() const
const SwWriteTableCells & GetCells() const
void Width(tools::Long nNew)
const SwTable & GetTable() const
sal_uInt32 GetWidthOpt() const
static SVT_DLLPUBLIC OString CreateTableDataOptionsValNum(bool bValue, double fVal, sal_uInt32 nFormat, SvNumberFormatter &rFormatter, OUString *pNonConvertableChars=nullptr)
tools::Long GetHeight() const
Writer & OutCSS1_TableBGStyleOpt(Writer &rWrt, const SfxPoolItem &rHt)
sal_Int16 GetVertOri() const
void ChangeParaToken(HtmlTokenId nNew)
#define OOO_STRING_SVTOOLS_HTML_colgroup
Table of Contents - heading.
void OutImplicitMark(std::u16string_view rMark, const char *pMarkType)
const editeng::SvxBorderLine * GetTop() const
css::uno::Reference< css::container::XIndexContainer > mxFormComps
const editeng::SvxBorderLine * GetLeft() const
Writer & OutHTML_SwTableNode(Writer &rWrt, SwTableNode &rNode, const SwFrameFormat *pFlyFrameFormat, const OUString *pCaption, bool bTopCaption)
#define OOO_STRING_SVTOOLS_HTML_table
SwNodeOffset GetIndex() const
tools::Long GetLeft() const
SwFrameFormat * GetFrameFormat()
const SvxBrushItem * GetBackground() const
sal_uInt16 GetCol() const
SwFrameFormat * GetFrameFormat()
sal_uInt16 GetRow() const
SwTableLines & GetTabLines()
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
SwTable is one table in the document model, containing rows (which contain cells).
std::vector< std::unique_ptr< SwWriteTableCell > > SwWriteTableCells
static sal_uInt32 ToPixel(sal_uInt32 nVal, const bool bVert)
SwTableLines & GetTabLines()
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
#define OOO_STRING_SVTOOLS_HTML_O_align
#define OOO_STRING_SVTOOLS_HTML_division
void OutCSS1_TableFrameFormatOptions(const SwFrameFormat &rFrameFormat)
SwTextNode is a paragraph in the document model.
SwTableBoxes & GetTabBoxes()
std::vector< SwTableBox * > SwTableBoxes
static bool lcl_TableBox_HasTabBorders(const SwTableBox *pBox, bool *pBorders)
const SwStartNode * GetSttNd() const
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
#define OOO_STRING_SVTOOLS_HTML_AL_right
static SVT_DLLPUBLIC SvStream & Out_String(SvStream &, const OUString &, OUString *pNonConvertableChars=nullptr)
void start(const OString &aElement)
void OutCSS1_TableCellBordersAndBG(const SwFrameFormat &rFrameFormat, const SvxBrushItem *pBrushItem)
SvStream & WriteOString(std::string_view rStr)
constexpr tools::Long Height() const
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
const SwViewOption * GetViewOptions() const
static const sal_Int16 Thin
void OutForm(bool bTagOn=true, const SwStartNode *pStNd=nullptr)
SwHTMLTableLayout * GetHTMLTableLayout()
#define OOO_STRING_SVTOOLS_HTML_center
sal_uInt16 GetColSpan() const
SvxFrameDirection GetHTMLDirection(SvxFrameDirection nDir) const
SwTableBox is one table cell in the document model.
OString GetNamespace() const
Determines the prefix string needed to respect the requested namespace alias.
SvStream & WriteChar(char nChar)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
std::shared_ptr< SwUnoCursor > m_pCurrentPam
bool IsExportable() const
void setHeight(tools::Long nHeight)
Writer & OutHTML_NumberBulletListEnd(SwHTMLWriter &rWrt, const SwHTMLNumRuleInfo &rNextInfo)
sal_uInt32 GetValue() const
void OutDirection(SvxFrameDirection nDir)
void OutAndSetDefList(sal_uInt16 nNewLvl)
std::vector< std::unique_ptr< SwWriteTableRow > >::size_type size_type
SvxFrameDirection m_nDirection
#define OOO_STRING_SVTOOLS_HTML_dd
static void Write(const OUString &rString, SvStream &rStream)
const editeng::SvxBorderLine * GetBottom() const
const Size & GetSize() const
static bool lcl_TableLine_HasTabBorders(const SwTableLine *pLine, bool *pBorders)
sal_uInt16 GetUpper() const
Base class of the Writer document model elements.