29#include <editeng/editeng.hxx>
51#include <osl/diagnose.h>
54#include <rtl/tencinfo.h>
59#include <document.hxx>
62#include <orcus/css_parser.hpp>
64#include <com/sun/star/document/XDocumentProperties.hpp>
65#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
66#include <com/sun/star/frame/XModel.hpp>
68#include <officecfg/Office/Common.hxx>
70using ::editeng::SvxBorderLine;
75void ScHTMLStyles::add(
const char* pElemName,
size_t nElemName,
const char* pClassName,
size_t nClassName,
76 const OUString& aProp,
const OUString& aValue)
80 OUString aElem(pElemName, nElemName, RTL_TEXTENCODING_UTF8);
81 aElem = aElem.toAsciiLowerCase();
85 ElemsType::iterator itrElem =
m_ElemProps.find(aElem);
89 std::pair<ElemsType::iterator, bool> r =
98 OUString aClass(pClassName, nClassName, RTL_TEXTENCODING_UTF8);
99 aClass = aClass.toAsciiLowerCase();
113 OUString aClass(pClassName, nClassName, RTL_TEXTENCODING_UTF8);
114 aClass = aClass.toAsciiLowerCase();
121 const OUString& rElem,
const OUString& rClass,
const OUString& rPropName)
const
129 NamePropsType::const_iterator itr2 = rClasses.find(rClass);
130 if (itr2 != rClasses.end())
133 PropsType::const_iterator itr3 = rProps.find(rPropName);
134 if (itr3 != rProps.end())
145 PropsType::const_iterator itr2 = rProps.find(rPropName);
146 if (itr2 != rProps.end())
156 PropsType::const_iterator itr2 = rProps.find(rPropName);
157 if (itr2 != rProps.end())
167 const OUString& aProp,
const OUString& aValue)
169 NamePropsType::iterator itr = rStore.find(
aName);
170 if (itr == rStore.end())
173 std::pair<NamePropsType::iterator, bool> r =
183 rProps.emplace(aProp, aValue);
192 maFontHeights[0] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::get() * 20;
193 maFontHeights[1] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::get() * 20;
194 maFontHeights[2] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::get() * 20;
195 maFontHeights[3] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::get() * 20;
196 maFontHeights[4] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::get() * 20;
197 maFontHeights[5] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::get() * 20;
198 maFontHeights[6] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::get() * 20;
209 aPageSize( aPageSizeP ),
210 aBaseURL(
std::move( _aBaseURL )),
224 bTabInTabCell( false ),
238 delete pS->pLocalColOffset;
244 for(
const auto& rEntry : *
pTables)
245 delete rEntry.second;
256 bool bLoading = pObjSh && pObjSh->
IsLoading();
266 const char* pCharSet = rtl_getBestMimeCharsetFromTextEncoding( RTL_TEXTENCODING_UTF8 );
269 OUString aContentType =
"text/html; charset=" +
270 OUString::createFromAscii( pCharSet );
274 pAttributes = xValues.
get();
278 ErrCode nErr =
pEdit->
Read( rStream, rBaseURL, EETextFormat::Html, pAttributes );
287 for ( sal_uInt16 j = 1; j <
nCount; j++ )
307 if ( !
pE->aSel.HasRange() )
324 else if ( rSel.
nStartPara ==
pE->aSel.nStartPara - 1 && !
pE->aSel.HasRange() )
329 OSL_FAIL(
"EntryEnd: EditEngine ESelection End < Start" );
345 SCCOL* pCol, sal_uInt16 nOffsetTol )
347 OSL_ENSURE( pOffset,
"ScHTMLLayoutParser::SeekOffset - illegal call" );
349 bool bFound = it != pOffset->
end();
358 if (
nPos <
nCount && (((*pOffset)[
nPos] - nOffsetTol) <= nOffset) )
361 else if (
nPos && (((*pOffset)[
nPos-1] + nOffsetTol) >= nOffset) )
370 sal_uInt16& nWidth, sal_uInt16 nOffsetTol, sal_uInt16 nWidthTol )
372 OSL_ENSURE( pOffset,
"ScHTMLLayoutParser::MakeCol - illegal call" );
375 nOffset =
static_cast<sal_uInt16
>((*pOffset)[
nPos]);
377 pOffset->
insert( nOffset );
381 nWidth =
static_cast<sal_uInt16
>((*pOffset)[
nPos]) - nOffset;
383 pOffset->
insert( nOffset + nWidth );
388 sal_uInt16 nWidth, sal_uInt16 nOffsetTol, sal_uInt16 nWidthTol )
390 OSL_ENSURE( pOffset,
"ScHTMLLayoutParser::MakeColNoRef - illegal call" );
393 nOffset =
static_cast<sal_uInt16
>((*pOffset)[
nPos]);
395 pOffset->
insert( nOffset );
399 pOffset->
insert( nOffset + nWidth );
404 sal_uInt16& nNewOffset, sal_uInt16 nOffsetTol )
406 OSL_ENSURE( pOffset,
"ScHTMLLayoutParser::ModifyOffset - illegal call" );
411 nNewOffset =
static_cast<sal_uInt16
>((*pOffset)[
nPos]);
413 pOffset->
insert( nNewOffset );
416 nOldOffset =
static_cast<sal_uInt16
>((*pOffset)[
nPos]);
418 if (
SeekOffset( pOffset, nNewOffset, &nPos2, nOffsetTol ) )
420 nNewOffset =
static_cast<sal_uInt16
>((*pOffset)[nPos2]);
436 }
while ( ++
nPos <
static_cast<sal_uInt16
>(pOffset->
size()) );
446 bool bBadCol =
false;
449 pE->nCol +
pE->nColOverlap - 1,
pE->nRow +
pE->nRowOverlap - 1, 0 );
453 for (
size_t i = 0, nRanges =
xLockedList->size();
i < nRanges; ++
i )
459 SCCOL nTmp =
pE->nCol +
pE->nColOverlap - 1;
472 if ( bJoin && !bBadCol )
480 std::stack< std::unique_ptr<ScHTMLAdjustStackEntry> > aStack;
485 sal_uInt16 nPageWidth =
static_cast<sal_uInt16
>(
aPageSize.
Width());
489 if (
pE->nTab < nTab )
491 if ( !aStack.empty() )
493 std::unique_ptr<ScHTMLAdjustStackEntry>
pS = std::move(aStack.top());
496 nLastCol =
pS->nLastCol;
497 nNextRow =
pS->nNextRow;
498 nCurRow =
pS->nCurRow;
503 OuterMap::const_iterator it =
pTables->find( nTab );
510 if (
pE->nCol <= nLastCol )
512 if (
pE->nRow < nNextRow )
513 pE->nRow = nCurRow = nNextRow;
515 nCurRow = nNextRow =
pE->nRow;
519 InnerMap::const_iterator it = pTab->find( nCurRow );
520 if ( it != pTab->end() )
531 if (
pE->nTab > nTab )
533 aStack.push( std::make_unique<ScHTMLAdjustStackEntry>(
534 nLastCol, nNextRow, nCurRow ) );
538 OuterMap::const_iterator it =
pTables->find( nTab );
546 InnerMap::const_iterator it = pTab->find( nCurRow );
547 if ( it != pTab->end() )
551 nNextRow = nCurRow + nR;
553 nNextRow = nCurRow + 1;
556 pE->nWidth = nPageWidth;
561 SCROW nRowSpan =
pE->nRowOverlap;
562 for (
SCROW j=0; j < nRowSpan; j++ )
565 InnerMap::const_iterator it = pTab->find( nRow+j );
566 if ( it != pTab->end() )
570 pE->nRowOverlap += nRows - 1;
573 SCROW nTmp = nCurRow + nRows;
574 if ( nNextRow < nTmp )
583 SCCOL nColBeforeSkip =
pE->nCol;
585 if (
pE->nCol != nColBeforeSkip )
588 if ( nCount <= pE->nCol )
607 pE->nCol +
pE->nColOverlap - 1,
pE->nRow +
pE->nRowOverlap - 1, 0 ) );
609 SCCOL nColTmp =
pE->nCol +
pE->nColOverlap;
612 SCROW nRowTmp =
pE->nRow +
pE->nRowOverlap;
622 sal_Int32 nTmp = std::min(
static_cast<sal_Int32
>(
pE->nCol -
625 SCCOL nPos = (nTmp < 0 ? 0 : static_cast<SCCOL>(nTmp));
626 sal_uInt16 nOff2 =
static_cast<sal_uInt16
>((*pLocalColOffset)[
nPos]);
627 if (
pE->nOffset < nOff2 )
628 return nOff2 -
pE->nOffset;
638 if ( nColsPerRow <= 0 )
642 sal_uInt16 nWidth =
nTableWidth /
static_cast<sal_uInt16
>(nColsPerRow);
645 for ( nCol = 0; nCol <= nColsPerRow; ++nCol, nOff = nOff + nWidth )
655 pE->nOffset =
static_cast<sal_uInt16
>((*pLocalColOffset)[
pE->nCol -
nColCntStart]);
665 std::unique_ptr<sal_uInt16[]> pOffsets(
new sal_uInt16[ nColsPerRow+1 ]);
666 memset( pOffsets.get(), 0, (nColsPerRow+1) *
sizeof(sal_uInt16) );
667 std::unique_ptr<sal_uInt16[]> pWidths(
new sal_uInt16[ nColsPerRow ]);
668 memset( pWidths.get(), 0, nColsPerRow *
sizeof(sal_uInt16) );
676 if ( nCol < nColsPerRow )
678 if (
pE->nColOverlap == 1 )
680 if ( pWidths[nCol] <
pE->nWidth )
681 pWidths[nCol] =
pE->nWidth;
685 sal_uInt16 nTotal = 0;
688 SCCOL nStop = std::min(
static_cast<SCCOL>(nCol +
pE->nColOverlap), nColsPerRow );
689 for ( ; nCol < nStop; nCol++ )
692 nTotal = nTotal + pWidths[nCol];
704 if ( bFound &&
pE->nWidth > nTotal )
705 pWidths[nHere] =
pE->nWidth - nTotal;
710 sal_uInt16 nWidths = 0;
711 sal_uInt16 nUnknown = 0;
712 for ( nCol = 0; nCol < nColsPerRow; nCol++ )
715 nWidths = nWidths + pWidths[nCol];
724 for ( nCol = 0; nCol < nColsPerRow; nCol++ )
726 if ( !pWidths[nCol] )
730 for ( nCol = 1; nCol <= nColsPerRow; nCol++ )
732 pOffsets[nCol] = pOffsets[nCol-1] + pWidths[nCol-1];
735 for ( nCol = 0; nCol <= nColsPerRow; nCol++ )
747 OSL_ENSURE( nCol < nColsPerRow,
"ScHTMLLayoutParser::SetWidths: column overflow" );
748 if ( nCol < nColsPerRow )
750 pE->nOffset = pOffsets[nCol];
751 nCol = nCol +
pE->nColOverlap;
752 if ( nCol > nColsPerRow )
754 pE->nWidth = pOffsets[nCol] -
pE->nOffset;
784 OSL_ENSURE(
pE->nWidth,
"SetWidths: pE->nWidth == 0" );
800 if ( nCol < pE->nCol )
805 nColOffset =
static_cast<sal_uInt16
>((*pLocalColOffset)[nCol]);
850 OSL_FAIL(
"CloseEntry: EditEngine ESelection Start > End" );
861 switch ( rInfo.eState )
863 case HtmlImportState::NextToken:
866 case HtmlImportState::Start:
868 case HtmlImportState::End:
869 if ( rInfo.aSelection.nEndPos )
878 CloseEntry( &rInfo );
880 while ( nTableLevel > 0 )
883 case HtmlImportState::SetAttr:
885 case HtmlImportState::InsertText:
887 case HtmlImportState::InsertPara:
888 if ( nTableLevel < 1 )
890 CloseEntry( &rInfo );
894 case HtmlImportState::InsertField:
897 OSL_FAIL(
"HTMLImportHdl: unknown ImportInfo.eState");
907 OSL_FAIL(
"dumbo doc! <TH> or <TD> without previous <TABLE>" );
911 bool bHorJustifyCenterTH = (pInfo->
nToken == HtmlTokenId::TABLEHEADER_ON);
913 for (
const auto & rOption : rOptions)
915 switch( rOption.GetToken() )
917 case HtmlOptionId::COLSPAN:
919 mxActEntry->nColOverlap =
static_cast<SCCOL>(rOption.GetString().toInt32());
922 case HtmlOptionId::ROWSPAN:
924 mxActEntry->nRowOverlap =
static_cast<SCROW>(rOption.GetString().toInt32());
927 case HtmlOptionId::ALIGN:
929 bHorJustifyCenterTH =
false;
931 const OUString& rOptVal = rOption.GetString();
933 eVal = SvxCellHorJustify::Right;
935 eVal = SvxCellHorJustify::Center;
937 eVal = SvxCellHorJustify::Left;
939 eVal = SvxCellHorJustify::Standard;
940 if ( eVal != SvxCellHorJustify::Standard )
944 case HtmlOptionId::VALIGN:
947 const OUString& rOptVal = rOption.GetString();
949 eVal = SvxCellVerJustify::Top;
951 eVal = SvxCellVerJustify::Center;
953 eVal = SvxCellVerJustify::Bottom;
955 eVal = SvxCellVerJustify::Standard;
959 case HtmlOptionId::WIDTH:
964 case HtmlOptionId::BGCOLOR:
967 rOption.GetColor( aColor );
971 case HtmlOptionId::SDVAL:
976 case HtmlOptionId::SDNUM:
989 if ( bHorJustifyCenterTH )
1018 aTableStack.push( std::make_unique<ScHTMLTableStackEntry>(
1030 if ( pInfo->
nToken == HtmlTokenId::TABLE_ON )
1033 for (
const auto & rOption : rOptions)
1035 switch( rOption.GetToken() )
1037 case HtmlOptionId::WIDTH:
1042 case HtmlOptionId::BORDER:
1074 aTableStack.push( std::make_unique<ScHTMLTableStackEntry>(
1083 if ( pInfo->
nToken == HtmlTokenId::TABLE_ON )
1087 for (
const auto & rOption : rOptions)
1089 switch( rOption.GetToken() )
1091 case HtmlOptionId::WIDTH:
1096 case HtmlOptionId::BORDER:
1120 OSL_FAIL(
"dumbo doc! </TABLE> without opening <TABLE>" );
1127 std::unique_ptr<ScHTMLTableStackEntry>
pS = std::move(
aTableStack.top());
1130 auto&
pE =
pS->xCellEntry;
1135 sal_uInt16 nTab =
pS->nTable;
1139 OuterMap::const_iterator it =
pTables->find( nTab );
1144 (*pTables)[ nTab ] = pTab1;
1148 SCROW nRowSpan =
pE->nRowOverlap;
1154 nRowKGV = std::lcm( nRowSpan, nRows );
1155 nRowsPerRow1 = nRowKGV / nRowSpan;
1156 nRowsPerRow2 = nRowKGV / nRows;
1160 nRowKGV = nRowsPerRow1 = nRows;
1164 if ( nRowsPerRow2 > 1 )
1167 (*pTables)[
nTable ] = pTab2;
1172 if ( nRowsPerRow1 > 1 )
1174 for (
SCROW j=0; j < nRowSpan; j++ )
1177 SCROW nR = (*pTab1)[ nRowKey ];
1179 (*pTab1)[ nRowKey ] = nRowsPerRow1;
1180 else if ( nRowsPerRow1 > nR )
1181 (*pTab1)[ nRowKey ] = nRowsPerRow1;
1183 else if ( nRowsPerRow1 < nR && nRowSpan == 1
1186 SCROW nAdd = nRowsPerRow1 - (nR % nRowsPerRow1);
1188 if ( (nR % nRows) == 0 )
1190 SCROW nR2 = (*pTab1)[ nRowKey+1 ];
1193 (*pTab1)[ nRowKey ] = nR;
1194 (*pTab1)[ nRowKey+1 ] = nR2 - nAdd;
1195 nRowsPerRow2 = nR / nRows;
1201 if ( nRowsPerRow2 > 1 )
1206 (*pTables)[
nTable ] = pTab2;
1208 for (
SCROW j=0; j < nRows; j++ )
1211 (*pTab2)[ nRowKey ] = nRowsPerRow2;
1223 sal_uInt16 nOldOffset =
pE->nOffset +
pE->nWidth;
1226 sal_uInt16 nTmp = nNewOffset -
pE->nOffset -
pE->nWidth;
1227 pE->nWidth = nNewOffset -
pE->nOffset;
1228 pS->nTableWidth =
pS->nTableWidth + nTmp;
1229 if (
pS->nColOffset >= nOldOffset )
1230 pS->nColOffset =
pS->nColOffset + nTmp;
1269 mxActEntry->maImageList.push_back(std::make_unique<ScHTMLImage>());
1272 for (
const auto & rOption : rOptions)
1274 switch( rOption.GetToken() )
1276 case HtmlOptionId::SRC:
1281 case HtmlOptionId::ALT:
1292 case HtmlOptionId::WIDTH:
1297 case HtmlOptionId::HEIGHT:
1302 case HtmlOptionId::HSPACE:
1307 case HtmlOptionId::VSPACE:
1315 if (pImage->
aURL.isEmpty())
1317 OSL_FAIL(
"Image: graphic without URL ?!?" );
1322 std::optional<Graphic> oGraphic(std::in_place);
1325 *oGraphic, &rFilter, &nFormat ) )
1335 pImage->
oGraphic = std::move( oGraphic );
1340 pImage->
oGraphic->GetPrefMapMode() );
1346 for (
const std::unique_ptr<ScHTMLImage> & pI :
mxActEntry->maImageList)
1349 nWidth += pI->aSize.Width() + 2 * pI->aSpace.X();
1362 for (
const auto & rOption : rOptions)
1364 if( rOption.GetToken() == HtmlOptionId::WIDTH )
1375 const OUString& rOptVal = rOption.
GetString();
1376 if ( rOptVal.indexOf(
'%') != -1 )
1379 return static_cast<sal_uInt16
>((rOption.
GetNumber() * nW) / 100);
1383 if ( rOptVal.indexOf(
'*') != -1 )
1389 return static_cast<sal_uInt16
>(rOption.
GetNumber());
1396 for (
const auto & rOption : rOptions)
1398 if( rOption.GetToken() == HtmlOptionId::NAME )
1418 for (
const auto & rOption : rOptions)
1420 switch( rOption.GetToken() )
1422 case HtmlOptionId::FACE :
1424 const OUString& rFace = rOption.GetString();
1425 OUStringBuffer aFontName;
1433 if( !aFontName.isEmpty() )
1434 aFontName.append(
";");
1435 aFontName.append(aFName);
1437 if ( !aFontName.isEmpty() )
1440 RTL_TEXTENCODING_DONTKNOW,
ATTR_FONT ) );
1443 case HtmlOptionId::SIZE :
1445 sal_uInt16 nSize =
static_cast<sal_uInt16
>(rOption.GetNumber());
1454 case HtmlOptionId::COLOR :
1457 rOption.GetColor( aColor );
1470 case HtmlTokenId::META:
1473 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1476 xDPS->getDocumentProperties(),
1480 case HtmlTokenId::TITLE_ON:
1486 case HtmlTokenId::TITLE_OFF:
1492 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1494 uno::UNO_QUERY_THROW);
1495 xDPS->getDocumentProperties()->setTitle(
aString);
1500 case HtmlTokenId::TABLE_ON:
1505 case HtmlTokenId::COL_ON:
1510 case HtmlTokenId::TABLEHEADER_ON:
1519 case HtmlTokenId::TABLEDATA_ON:
1524 case HtmlTokenId::TABLEHEADER_OFF:
1525 case HtmlTokenId::TABLEDATA_OFF:
1530 case HtmlTokenId::TABLEROW_ON:
1535 case HtmlTokenId::TABLEROW_OFF:
1540 case HtmlTokenId::TABLE_OFF:
1545 case HtmlTokenId::IMAGE:
1550 case HtmlTokenId::PARABREAK_OFF:
1556 case HtmlTokenId::ANCHOR_ON:
1561 case HtmlTokenId::FONT_ON :
1566 case HtmlTokenId::BIGPRINT_ON :
1574 case HtmlTokenId::SMALLPRINT_ON :
1582 case HtmlTokenId::BOLD_ON :
1583 case HtmlTokenId::STRONG_ON :
1590 case HtmlTokenId::ITALIC_ON :
1591 case HtmlTokenId::EMPHASIS_ON :
1592 case HtmlTokenId::ADDRESS_ON :
1593 case HtmlTokenId::BLOCKQUOTE_ON :
1594 case HtmlTokenId::BLOCKQUOTE30_ON :
1595 case HtmlTokenId::CITATION_ON :
1596 case HtmlTokenId::VARIABLE_ON :
1603 case HtmlTokenId::DEFINSTANCE_ON :
1614 case HtmlTokenId::UNDERLINE_ON :
1621 case HtmlTokenId::TEXTTOKEN:
1633template<
typename Type >
1635{
return std::clamp( rValue, rMin, rMax ); }
1639 mbImportAlways( false )
1667 "ScHTMLQueryParser::AdjustEntryEnd - invalid end position" );
1733 mrParentTable(rParentTable),
1734 mpCurrTable(nullptr)
1747 pResult = aFind->second.get();
1751 if( !pResult && bDeep )
1775class ScHTMLTableIterator
1782 bool is()
const {
return mpTableMap &&
maIter !=
maEnd; }
1794ScHTMLTableIterator::ScHTMLTableIterator(
const ScHTMLTableMap* pTableMap ) :
1795 mpTableMap(pTableMap)
1805 mnTableId( rnUnusedId ),
1806 mrnUnusedId( rnUnusedId )
1812 mpParentTable( &rParentTable ),
1813 maTableId( rParentTable.maTableId.mrnUnusedId ),
1814 maTableItemSet( rParentTable.GetCurrItemSet() ),
1815 mrEditEngine( rParentTable.mrEditEngine ),
1816 mrEEParseList( rParentTable.mrEEParseList ),
1817 mpCurrEntryVector( nullptr ),
1819 mpParser(rParentTable.mpParser),
1821 mbBorderOn( false ),
1822 mbPreFormText( bPreFormText ),
1825 mbPushEmptyLine( false ),
1826 mbCaptionOn ( false )
1837 for (
const auto& rOption : rOptions)
1839 switch( rOption.GetToken() )
1841 case HtmlOptionId::BORDER:
1842 mbBorderOn = rOption.GetString().isEmpty() || (rOption.GetNumber() != 0);
1844 case HtmlOptionId::ID:
1858 std::vector<std::shared_ptr<ScEEParseEntry>>& rEEParseList,
1861 mpParentTable( nullptr ),
1862 maTableId( rnUnusedId ),
1863 maTableItemSet( rPool ),
1864 mrEditEngine( rEditEngine ),
1865 mrEEParseList( rEEParseList ),
1866 mpCurrEntryVector( nullptr ),
1870 mbBorderOn( false ),
1871 mbPreFormText( false ),
1874 mbPushEmptyLine( false ),
1875 mbCaptionOn ( false )
1911 OSL_ENSURE(
mxCurrEntry,
"ScHTMLTable::PutItem - no current entry" );
1918 OSL_ENSURE(
mxCurrEntry,
"ScHTMLTable::PutText - no current entry" );
1960 OSL_ENSURE(
mxCurrEntry,
"ScHTMLTable::AnchorOn - no current entry" );
2027OUString decodeNumberFormat(
const OUString& rFmt)
2029 OUStringBuffer
aBuf;
2031 sal_Int32
n = rFmt.getLength();
2032 for (sal_Int32 i = 0;
i <
n; ++
i, ++
p)
2041 sal_Int32 nDigitCount = 0;
2043 for (;
i <
n; ++
i, ++
p, ++nDigitCount)
2045 if (*p <
'0' ||
'9' < *p)
2058 sal_uInt32 nVal = OUString(p1, nDigitCount).toUInt32(16);
2065 return aBuf.makeStringAndClear();
2077 std::optional<OUString> pValStr, pNumStr;
2080 for (
const auto& rOption : rOptions)
2082 switch (rOption.GetToken())
2084 case HtmlOptionId::COLSPAN:
2085 aSpanSize.
mnCols =
static_cast<SCCOL>( getLimitedValue<sal_Int32>( rOption.GetString().toInt32(), 1, 256 ) );
2087 case HtmlOptionId::ROWSPAN:
2088 aSpanSize.
mnRows =
static_cast<SCROW>( getLimitedValue<sal_Int32>( rOption.GetString().toInt32(), 1, 256 ) );
2090 case HtmlOptionId::SDVAL:
2091 pValStr = rOption.GetString();
2093 case HtmlOptionId::SDNUM:
2094 pNumStr = rOption.GetString();
2096 case HtmlOptionId::CLASS:
2100 OUString aClass = rOption.GetString();
2102 const OUString& rVal = rStyles.
getPropertyValue(
"td", aClass,
"mso-number-format");
2103 if (!rVal.isEmpty())
2105 OUString aNumFmt = decodeNumberFormat(rVal);
2110 sal_Int32 nErrPos = 0;
2190 size_t nIndex =
static_cast< size_t >( nCellPos );
2191 if(
nIndex >= rSizes.size() )
return 0;
2198 size_t nBeginIdx =
static_cast< size_t >( std::max< SCCOLROW >( nCellBegin, 0 ) );
2199 size_t nEndIdx =
static_cast< size_t >( std::min< SCCOLROW >( nCellEnd,
static_cast< SCCOLROW >( rSizes.size() ) ) );
2200 if (nBeginIdx >= nEndIdx )
return 0;
2201 return rSizes[ nEndIdx - 1 ] - ((nBeginIdx == 0) ? 0 : rSizes[ nBeginIdx - 1 ]);
2207 return rSizes.empty() ? 0 : rSizes.back();
2237 assert(!
"can't move");
2243 OSL_ENSURE( pDoc,
"ScHTMLTable::ApplyCellBorders - no document" );
2250 SvxBorderLine aOuterLine(
nullptr, nOuterLine, SvxBorderLineStyle::SOLID);
2251 SvxBorderLine aInnerLine(
nullptr, nInnerLine, SvxBorderLineStyle::SOLID);
2254 for(
SCCOL nCol = 0; nCol <= nLastCol; ++nCol )
2256 SvxBorderLine* pLeftLine = (nCol == 0) ? &aOuterLine : &aInnerLine;
2257 SvxBorderLine* pRightLine = (nCol == nLastCol) ? &aOuterLine : &aInnerLine;
2260 for(
SCROW nRow = 0; nRow <= nLastRow; ++nRow )
2262 SvxBorderLine* pTopLine = (nRow == 0) ? &aOuterLine : &aInnerLine;
2263 SvxBorderLine* pBottomLine = (nRow == nLastRow) ? &aOuterLine : &aInnerLine;
2266 for(
SCCOL nCellCol = nCellCol1; nCellCol <= nCellCol2; ++nCellCol )
2268 aBorderItem.
SetLine( (nCellCol == nCellCol1) ? pLeftLine :
nullptr, SvxBoxItemLine::LEFT );
2269 aBorderItem.
SetLine( (nCellCol == nCellCol2) ? pRightLine :
nullptr, SvxBoxItemLine::RIGHT );
2270 for(
SCROW nCellRow = nCellRow1; nCellRow <= nCellRow2; ++nCellRow )
2272 aBorderItem.
SetLine( (nCellRow == nCellRow1) ? pTopLine :
nullptr, SvxBoxItemLine::TOP );
2273 aBorderItem.
SetLine( (nCellRow == nCellRow2) ? pBottomLine :
nullptr, SvxBoxItemLine::BOTTOM );
2274 pDoc->
ApplyAttr( nCellCol, nCellRow, rFirstPos.
Tab(), aBorderItem );
2281 for( ScHTMLTableIterator aIter(
mxNestedTables.get() ); aIter.is(); ++aIter )
2282 aIter->ApplyCellBorders( pDoc, rFirstPos );
2297 return (rInfo.
nToken == HtmlTokenId::TEXTTOKEN) && (rInfo.
aText.getLength() == 1) && (rInfo.
aText[ 0 ] ==
' ');
2307 OSL_ENSURE( !
mxCurrEntry,
"ScHTMLTable::CreateNewEntry - old entry still present" );
2315 rEntryVector.push_back( rxEntry.get() );
2317 mrEEParseList.push_back(std::shared_ptr<ScEEParseEntry>(rxEntry.release()));
2322 bool bPushed =
false;
2323 if( rxEntry && rxEntry->HasContents() )
2342 OSL_FAIL(
"ScHTMLTable::PushEntry - cannot push entry, no parent found" );
2350 OSL_ENSURE(
mxCurrEntry,
"ScHTMLTable::PushEntry - no current entry" );
2351 bool bPushed =
false;
2374 OSL_ENSURE( nTableId !=
SC_HTML_GLOBAL_TABLE,
"ScHTMLTable::PushTableEntry - cannot push global table" );
2386 OSL_ENSURE( pTable || (nTableId ==
SC_HTML_GLOBAL_TABLE),
"ScHTMLTable::GetExistingTable - table not found" );
2429 assert(!
"can't move");
2431 if( rSpanSize.
mnRows > 1 )
2440 if( rSpanSize.
mnCols > 1 )
2500 if( rInfo.
nToken == HtmlTokenId::TABLEHEADER_ON )
2507 for (
const auto& rOption : rOptions)
2509 switch( rOption.GetToken() )
2511 case HtmlOptionId::ALIGN:
2514 const OUString& rOptVal = rOption.GetString();
2516 eVal = SvxCellHorJustify::Right;
2518 eVal = SvxCellHorJustify::Center;
2520 eVal = SvxCellHorJustify::Left;
2521 if( eVal != SvxCellHorJustify::Standard )
2526 case HtmlOptionId::VALIGN:
2529 const OUString& rOptVal = rOption.GetString();
2531 eVal = SvxCellVerJustify::Top;
2533 eVal = SvxCellVerJustify::Center;
2535 eVal = SvxCellVerJustify::Bottom;
2536 if( eVal != SvxCellVerJustify::Standard )
2541 case HtmlOptionId::BGCOLOR:
2544 rOption.GetColor( aColor );
2555 OSL_ENSURE( nCellPos >= 0,
"ScHTMLTable::SetDocSize - unexpected negative position" );
2557 size_t nIndex =
static_cast< size_t >( nCellPos );
2559 while(
nIndex >= rSizes.size() )
2560 rSizes.push_back( rSizes.empty() ? 1 : (rSizes.back() + 1) );
2565 std::for_each(rSizes.begin() +
nIndex, rSizes.end(), [&nDiff](
SCCOLROW& rSize) { rSize += nDiff; });
2573 while( nCellSpan > 1 )
2575 nDiffSize +=
GetDocSize( eOrient, nCellPos );
2580 nRealDocSize -= std::min< SCCOLROW >( nRealDocSize - 1, nDiffSize );
2581 SetDocSize( eOrient, nCellPos, nRealDocSize );
2586 for( ScHTMLTableIterator aIter(
mxNestedTables.get() ); aIter.is(); ++aIter )
2587 aIter->FillEmptyCells();
2598 for( aAddr.SetCol( 0 ); aAddr.Col() <
maSize.
mnCols; aAddr.IncCol() )
2623 for( ScHTMLTableIterator aIter(
mxNestedTables.get() ); aIter.is(); ++aIter )
2624 aIter->RecalcDocSize();
2629 static const sal_uInt16 PASS_SINGLE = 0;
2630 static const sal_uInt16 PASS_SPANNED = 1;
2631 for( sal_uInt16 nPass = PASS_SINGLE; nPass <= PASS_SPANNED; ++nPass )
2634 for(
const auto& [rCellPos, rEntryVector] :
maEntryMap )
2640 bool bProcessColWidth = ((nPass == PASS_SINGLE) == (aCellSpan.
mnCols == 1));
2641 bool bProcessRowHeight = ((nPass == PASS_SINGLE) == (aCellSpan.
mnRows == 1));
2642 if( bProcessColWidth || bProcessRowHeight )
2647 for(
const auto& rpEntry : rEntryVector )
2651 if( bProcessColWidth && pTable )
2654 if( bProcessRowHeight )
2660 if( bProcessColWidth )
2662 if( bProcessRowHeight )
2675 for(
auto& [rCellPos, rEntryVector] :
maEntryMap )
2686 for(
const auto& rpEntry : rEntryVector )
2691 pTable->RecalcDocPos( aEntryDocPos );
2694 SCROW nTableRows =
static_cast< SCROW >( pTable->GetDocSize(
tdRow ) );
2701 if( nStartCol < nNextCol )
2703 pEntry->
nCol = nStartCol;
2709 aEntryDocPos.
mnRow += nTableRows;
2717 ++aEntryDocPos.
mnRow;
2733 while( aEntryDocPos.
mnRow < nFirstUnusedRow )
2736 xDummyEntry->nCol = aEntryDocPos.
mnCol;
2737 xDummyEntry->nRow = aEntryDocPos.
mnRow;
2738 xDummyEntry->nColOverlap = aCellDocSize.
mnCols;
2740 ++aEntryDocPos.
mnRow;
2750 std::vector<std::shared_ptr<ScEEParseEntry>>& rEEParseVector,
2755 ScHTMLTable( rPool, rEditEngine, rEEParseVector, rnUnusedId, pParser, rDoc )
2801 const char* pCharSet = rtl_getBestMimeCharsetFromTextEncoding( RTL_TEXTENCODING_UTF8 );
2804 OUString aContentType =
"text/html; charset=" +
2805 OUString::createFromAscii( pCharSet );
2809 pAttributes = xValues.
get();
2835 case HtmlTokenId::META:
MetaOn( rInfo );
break;
2838 case HtmlTokenId::TITLE_ON:
TitleOn();
break;
2839 case HtmlTokenId::TITLE_OFF:
TitleOff( rInfo );
break;
2841 case HtmlTokenId::STYLE_ON:
break;
2849 case HtmlTokenId::TEXTTOKEN:
InsertText( rInfo );
break;
2851 case HtmlTokenId::HEAD1_ON:
2852 case HtmlTokenId::HEAD2_ON:
2853 case HtmlTokenId::HEAD3_ON:
2854 case HtmlTokenId::HEAD4_ON:
2855 case HtmlTokenId::HEAD5_ON:
2856 case HtmlTokenId::HEAD6_ON:
2863 case HtmlTokenId::TABLE_ON:
TableOn( rInfo );
break;
2864 case HtmlTokenId::TABLE_OFF:
TableOff( rInfo );
break;
2869 case HtmlTokenId::TABLEHEADER_ON:
2871 case HtmlTokenId::TABLEHEADER_OFF:
2873 case HtmlTokenId::PREFORMTXT_ON:
PreOn( rInfo );
break;
2874 case HtmlTokenId::PREFORMTXT_OFF:
PreOff( rInfo );
break;
2877 case HtmlTokenId::FONT_ON:
FontOn( rInfo );
break;
2879 case HtmlTokenId::BIGPRINT_ON:
2883 case HtmlTokenId::SMALLPRINT_ON:
2888 case HtmlTokenId::BOLD_ON:
2889 case HtmlTokenId::STRONG_ON:
2893 case HtmlTokenId::ITALIC_ON:
2894 case HtmlTokenId::EMPHASIS_ON:
2895 case HtmlTokenId::ADDRESS_ON:
2896 case HtmlTokenId::BLOCKQUOTE_ON:
2897 case HtmlTokenId::BLOCKQUOTE30_ON:
2898 case HtmlTokenId::CITATION_ON:
2899 case HtmlTokenId::VARIABLE_ON:
2903 case HtmlTokenId::DEFINSTANCE_ON:
2908 case HtmlTokenId::UNDERLINE_ON:
2925 for (
const auto& rOption : rOptions)
2927 switch( rOption.GetToken() )
2929 case HtmlOptionId::FACE :
2931 const OUString& rFace = rOption.GetString();
2940 if ( !aFontName.isEmpty() )
2943 RTL_TEXTENCODING_DONTKNOW,
ATTR_FONT ) );
2946 case HtmlOptionId::SIZE :
2948 sal_uInt32 nSize = getLimitedValue< sal_uInt32 >( rOption.GetNumber(), 1,
SC_HTML_FONTSIZES );
2952 case HtmlOptionId::COLOR :
2955 rOption.GetColor( aColor );
2970 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
2973 xDPS->getDocumentProperties(),
2989 OUString aTitle =
maTitle.makeStringAndClear().trim();
2992 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
2995 xDPS->getDocumentProperties()->setTitle(aTitle);
3031class CSSHandler:
public orcus::css_handler
3033 typedef std::pair<std::string_view, std::string_view> SelectorName;
3034 typedef std::vector<SelectorName> SelectorNames;
3036 SelectorNames maSelectorNames;
3037 std::string_view maPropName;
3038 std::string_view maPropValue;
3047 void simple_selector_type(std::string_view aElem)
3049 std::string_view aClass{};
3050 SelectorName
aName(aElem, aClass);
3052 maSelectorNames.push_back(aName);
3056 void simple_selector_class(std::string_view aClass)
3058 std::string_view aElem{};
3059 SelectorName
aName(aElem, aClass);
3061 maSelectorNames.push_back(aName);
3066 void property_name(std::string_view aPropName)
3071 void value(std::string_view aValue)
3073 maPropValue = aValue;
3078 maSelectorNames.clear();
3083 for (
const auto& rSelName : maSelectorNames)
3086 std::string_view aElem = rSelName.first;
3087 std::string_view aClass = rSelName.second;
3088 OUString
aName(maPropName.data(), maPropName.size(), RTL_TEXTENCODING_UTF8);
3089 OUString aValue(maPropValue.data(), maPropValue.size(), RTL_TEXTENCODING_UTF8);
3090 mrStyles.
add(aElem.data(), aElem.size(), aClass.data(), aClass.size(), aName, aValue);
3092 maPropName = std::string_view{};
3093 maPropValue = std::string_view{};
3104 orcus::css_parser<CSSHandler> aParser(
aStr, aHdl);
3109 catch (
const orcus::parse_error& rOrcusParseError)
3111 SAL_WARN(
"sc",
"ScHTMLQueryParser::ParseStyle: " << rOrcusParseError.what());
3118 switch( rInfo.eState )
3120 case HtmlImportState::Start:
3123 case HtmlImportState::NextToken:
3124 ProcessToken( rInfo );
3127 case HtmlImportState::InsertPara:
3128 mpCurrTable->InsertPara( rInfo );
3131 case HtmlImportState::SetAttr:
3132 case HtmlImportState::InsertText:
3133 case HtmlImportState::InsertField:
3136 case HtmlImportState::End:
3138 CloseTable( rInfo );
3142 OSL_FAIL(
"ScHTMLQueryParser::HTMLImportHdl - unknown ImportInfo::eState" );
geometry::RealSize2D maSize
std::vector< Reference< XAnimationNode > >::iterator maIter
static OutputDevice * GetDefaultDevice()
ErrCode Read(SvStream &rInput, const OUString &rBaseURL, EETextFormat, SvKeyValueIterator *pHTTPHeaderAttrs=nullptr)
sal_Int32 GetTextLen() const
void SetHtmlImportHdl(const Link< HtmlImportInfo &, void > &rLink)
const Link< HtmlImportInfo &, void > & GetHtmlImportHdl() const
static GraphicFilter & GetGraphicFilter()
OUString GetImportFormatName(sal_uInt16 nFormat)
static ErrCode LoadGraphic(const OUString &rPath, const OUString &rFilter, Graphic &rGraphic, GraphicFilter *pFilter=nullptr, sal_uInt16 *pDeterminedFormat=nullptr)
const OUString & GetString() const
sal_uInt32 GetNumber() const
virtual bool ParseMetaOptions(const css::uno::Reference< css::document::XDocumentProperties > &, SvKeyValueIterator *)
static OUString GetAbsURL(std::u16string_view rTheBaseURIRef, OUString const &rTheRelURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
SC_DLLPUBLIC bool Move(SCCOL nDeltaX, SCROW nDeltaY, SCTAB nDeltaZ, ScAddress &rErrorPos, const ScDocument &rDoc)
void IncCol(SCCOL nDelta=1)
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
SfxObjectShell * GetDocumentShell() const
bool ValidCol(SCCOL nCol) const
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
void NewActEntry(const ScEEParseEntry *)
std::vector< std::shared_ptr< ScEEParseEntry > > maList
std::shared_ptr< ScEEParseEntry > mxActEntry
rtl::Reference< SfxItemPool > pPool
static SC_DLLPUBLIC OUString addToken(std::u16string_view rTokenList, std::u16string_view rToken, sal_Unicode cSep, sal_Int32 nSepCount=1, bool bForceSep=false)
Adds the string rToken to rTokenList, using a list separator character.
The "global table" representing the entire HTML document.
ScHTMLGlobalTable(SfxItemPool &rPool, EditEngine &rEditEngine, std::vector< std::shared_ptr< ScEEParseEntry > > &rEEParseList, ScHTMLTableId &rnUnusedId, ScHTMLParser *pParser, const ScDocument &rDoc)
void Recalc()
Recalculates sizes and resulting positions of all document entries.
virtual ~ScHTMLGlobalTable() override
ScRangeListRef xLockedList
void AnchorOn(HtmlImportInfo *)
static void EntryEnd(ScEEParseEntry *, const ESelection &)
void ProcToken(HtmlImportInfo *)
virtual ~ScHTMLLayoutParser() override
sal_uInt16 nOffsetTolerance
ScHTMLLayoutParser(EditEngine *, OUString aBaseURL, const Size &aPageSize, ScDocument *)
ScHTMLColOffset * pLocalColOffset
void Image(HtmlImportInfo *)
void NextRow(const HtmlImportInfo *)
virtual const ScHTMLTable * GetGlobalTable() const override
Returns the "global table" which contains the entire HTML document.
::std::stack< std::unique_ptr< ScHTMLTableStackEntry > > aTableStack
void TableOn(HtmlImportInfo *)
sal_uInt16 GetWidth(const ScEEParseEntry *)
void TableRowOff(const HtmlImportInfo *)
void TableRowOn(const HtmlImportInfo *)
std::unique_ptr< OuterMap > pTables
static bool SeekOffset(const ScHTMLColOffset *, sal_uInt16 nOffset, SCCOL *pCol, sal_uInt16 nOffsetTol)
void FontOn(HtmlImportInfo *)
void Colonize(ScEEParseEntry *)
static void ModifyOffset(ScHTMLColOffset *, sal_uInt16 &nOldOffset, sal_uInt16 &nNewOffset, sal_uInt16 nOffsetTol)
void SkipLocked(ScEEParseEntry *, bool bJoin=true)
void CloseEntry(const HtmlImportInfo *)
bool IsAtBeginningOfText(const HtmlImportInfo *)
sal_uInt16 GetWidthPixel(const HTMLOption &)
void NewActEntry(const ScEEParseEntry *)
void TableDataOff(const HtmlImportInfo *)
sal_uLong nFirstTableCell
ScHTMLColOffset maColOffset
void TableOff(const HtmlImportInfo *)
virtual ErrCode Read(SvStream &, const OUString &rBaseURL) override
static void MakeCol(ScHTMLColOffset *, sal_uInt16 &nOffset, sal_uInt16 &nWidth, sal_uInt16 nOffsetTol, sal_uInt16 nWidthTol)
sal_uInt16 nColOffsetStart
static void MakeColNoRef(ScHTMLColOffset *, sal_uInt16 nOffset, sal_uInt16 nWidth, sal_uInt16 nOffsetTol, sal_uInt16 nWidthTol)
void ColOn(HtmlImportInfo *)
void TableDataOn(HtmlImportInfo *)
Base class for HTML parser classes.
ScHTMLParser(EditEngine *pEditEngine, ScDocument *pDoc)
The destination document.
sal_uInt32 maFontHeights[SC_HTML_FONTSIZES]
ScHTMLStyles & GetStyles()
virtual ~ScHTMLParser() override
The HTML parser for data queries.
void PreOn(const HtmlImportInfo &rInfo)
Opens a new table based on preformatted text.
void TitleOff(const HtmlImportInfo &rInfo)
Closes the title of the HTML document (</title> tag).
void TableOff(const HtmlImportInfo &rInfo)
Closes the current table.
ScHTMLTable * mpCurrTable
Contains the entire imported document.
virtual ~ScHTMLQueryParser() override
virtual ErrCode Read(SvStream &rStrm, const OUString &rBaseURL) override
void PreOff(const HtmlImportInfo &rInfo)
Closes the current preformatted text table.
bool mbTitleOn
First unused table identifier.
void ParseStyle(std::u16string_view rStrm)
void ProcessToken(const HtmlImportInfo &rInfo)
Handles all possible tags in the HTML document.
ScHTMLGlobalTablePtr mxGlobTable
The title of the document.
void FontOn(const HtmlImportInfo &rInfo)
Processes the <font> tag.
ScHTMLQueryParser(EditEngine *pEditEngine, ScDocument *pDoc)
void CloseTable(const HtmlImportInfo &rInfo)
Closes the current table, regardless on opening tag.
void TitleOn()
Opens the title of the HTML document (<title> tag).
void InsertText(const HtmlImportInfo &rInfo)
Inserts a text portion into current entry.
virtual const ScHTMLTable * GetGlobalTable() const override
Returns the "global table" which contains the entire HTML document.
void MetaOn(const HtmlImportInfo &rInfo)
Processes the <meta> tag.
ScHTMLTableId mnUnusedId
Pointer to current table (performance).
void TableOn(const HtmlImportInfo &rInfo)
Opens a new table at the current position.
Collection of HTML style data parsed from the content of <style> elements.
::std::map< OUString, PropsType > NamePropsType
void add(const char *pElemName, size_t nElemName, const char *pClassName, size_t nClassName, const OUString &aProp, const OUString &aValue)
const OUString & getPropertyValue(const OUString &rElem, const OUString &rClass, const OUString &rPropName) const
Find best-matching property value for given element and class names.
ElemsType m_ElemProps
element global properties (no class specified)
ScHTMLStyles()
just a persistent empty string.
NamePropsType m_GlobalProps
NamePropsType m_ElemGlobalProps
global properties (for a given class for all elements)
std::unordered_map< OUString, OUString > PropsType
const OUString maEmpty
element to class to properties (both element and class are given)
static void insertProp(NamePropsType &rProps, const OUString &aName, const OUString &aProp, const OUString &aValue)
A map of ScHTMLTable objects.
ScHTMLTableStdMap maTables
Reference to parent table.
ScHTMLTable & mrParentTable
std::shared_ptr< ScHTMLTable > ScHTMLTablePtr
ScHTMLTable * mpCurrTable
Container for all table objects.
std::map< ScHTMLTableId, ScHTMLTablePtr > ScHTMLTableStdMap
ScHTMLTableMap(ScHTMLTable &rParentTable)
Current table, used for fast search.
ScHTMLTableStdMap::iterator iterator
ScHTMLTable * FindTable(ScHTMLTableId nTableId, bool bDeep=true) const
Returns the specified table.
ScHTMLTable * CreateTable(const HtmlImportInfo &rInfo, bool bPreFormText, const ScDocument &rDoc)
Inserts a new table into the container.
ScHTMLTableStdMap::const_iterator const_iterator
void SetCurrTable(ScHTMLTable *pTable) const
Sets a working table with its index for search optimization.
const_iterator begin() const
const_iterator end() const
Stores data for one table in an HTML document.
ScHTMLTable * PreOn(const HtmlImportInfo &rInfo)
Starts a new table based on preformatted text (.
EditEngine & mrEditEngine
List of all used cells.
static bool IsSpaceCharInfo(const HtmlImportInfo &rInfo)
Returns true, if import info represents a space character.
void RowOn(const HtmlImportInfo &rInfo)
Starts next row (tag).
ScHTMLTableId GetTableId() const
Returns the unique identifier of the table.
std::optional< SfxItemSet > moRowItemSet
Items for the entire table.
::std::unique_ptr< ScHTMLEntry > ScHTMLEntryPtr
ScHTMLEntryVector * mpCurrEntryVector
List of entries for each cell.
ScHTMLSize maSize
Cumulated cell counts for each HTML table column/row.
bool PushEntry(ScHTMLEntryPtr &rxEntry)
Tries to insert the entry into the current cell.
ScRangeList maUsedCells
List of all vertically merged cells.
void CalcNeededDocSize(ScHTMLOrient eOrient, SCCOLROW nCellPos, SCCOLROW nCellSpan, SCCOLROW nRealDocSize)
Calculates and sets the resulting size the cell needs in the document.
void ImplPushEntryToVector(ScHTMLEntryVector &rEntryVector, ScHTMLEntryPtr &rxEntry)
Pushes the passed entry into the list of the current cell.
void InsertPara(const HtmlImportInfo &rInfo)
Inserts a new line, if in preformatted text, else does nothing.
SvNumberFormatter * GetFormatTable()
static void ProcessFormatOptions(SfxItemSet &rItemSet, const HtmlImportInfo &rInfo)
Inserts additional formatting options from import info into the item set.
ScHTMLTable * mpParentTable
void ImplDataOn(const ScHTMLSize &rSpanSize)
Set internal states for entering a new table cell.
void DataOn(const HtmlImportInfo &rInfo)
Starts the next cell (or tag).
ScRangeList maVMergedCells
List of all horizontally merged cells.
ScHTMLTableMapPtr mxNestedTables
Pointer to parent table.
void DataOff(const HtmlImportInfo &rInfo)
Closes the current cell ( or tag).
void InsertNewCell(const ScHTMLSize &rSpanSize)
Inserts a new cell in an unused position, starting from current cell position.
ScRangeList maHMergedCells
Items for the current cell.
void BodyOff(const HtmlImportInfo &rInfo)
Closes the body of the HTML document (</body> tag).
void FillEmptyCells()
Fills all empty cells in this and nested tables with dummy parse entries.
ScHTMLEntryPtr CreateEntry() const
Creates and returns a new empty flying entry at position (0,0).
void PutText(const HtmlImportInfo &rInfo)
Inserts a text portion into current entry.
void SetDocSize(ScHTMLOrient eOrient, SCCOLROW nCellPos, SCCOLROW nSize)
Updates the document column/row size of the specified column or row.
OUStringBuffer maCaptionBuffer
Caption name of the table from
void RecalcDocSize()
Recalculates the size of all columns/rows in the table, regarding nested tables.
void ApplyCellBorders(ScDocument *pDoc, const ScAddress &rFirstPos) const
Applies border formatting to the passed document.
ScHTMLPos maDocBasePos
Address of current cell to fill.
std::map< ScHTMLPos, ScHTMLEntryVector > maEntryMap
List that owns the parse entries (from ScEEParser).
void CaptionOn()
Processes the caption of the table ( tag).
::std::vector< SCCOLROW > ScSizeVec
ScHTMLEntryPtr mxCurrEntry
Current entry vector from map for faster access.
void BreakOn()
Inserts a line break ( tag).
const SfxItemSet & GetCurrItemSet() const
Returns the item set from cell, row, or table, depending on current state.
bool mbCaptionOn
true = Insert empty line before current entry.
void HeadingOn()
Inserts a heading line (.
void CreateNewEntry(const HtmlImportInfo &rInfo)
Creates a new flying entry.
std::optional< SfxItemSet > moDataItemSet
Items for the current table row.
void InsertLeadingEmptyLine()
Inserts an empty line in front of the next entry.
ScHTMLParser * mpParser
Resulting base address in a Calc document.
OUString maTableName
Table of nested HTML tables.
ScHTMLTable * PreOff(const HtmlImportInfo &rInfo)
Closes this table based on preformatted text ( tag).
const ScHTMLPos & GetDocPos() const
Returns the resulting Calc position of the top left edge of the table.
void PutItem(const SfxPoolItem &rItem)
Puts the item into the item set of the current entry.
ScHTMLTable(ScHTMLTable &rParentTable, const HtmlImportInfo &rInfo, bool bPreFormText, const ScDocument &rDoc)
Creates a new HTML table without content.
void AnchorOn()
Processes a hyperlink ( tag).
std::vector< std::shared_ptr< ScEEParseEntry > > & mrEEParseList
Edit engine (from ScEEParser).
void BodyOn(const HtmlImportInfo &rInfo)
Starts the body of the HTML document (<body> tag).
void ImplDataOff()
Set internal states for leaving a table cell.
ScHTMLPos maCurrCell
Size of the table.
bool mbPushEmptyLine
true = Inside of or .
ScHTMLTable * TableOn(const HtmlImportInfo &rInfo)
Starts a new table nested in this table (.
ScSizeVec maCumSizes[2]
Working entry, not yet inserted in a list.
ScHTMLTable * FindNestedTable(ScHTMLTableId nTableId) const
Searches in all nested tables for the specified table.
void RowOff(const HtmlImportInfo &rInfo)
Closes the current row (tag).
bool mbPreFormText
true = Table borders on.
void ImplRowOn()
Set internal states for a new table row.
ScHTMLSize GetSpan(const ScHTMLPos &rCellPos) const
Returns the cell spanning of the specified cell.
ScHTMLTable * CloseTable(const HtmlImportInfo &rInfo)
Closes this table (tag) or preformatted text ( tag).
SCCOLROW GetDocSize(ScHTMLOrient eOrient, SCCOLROW nCellPos) const
Returns the resulting document row/column count of the specified HTML row/column.
OUString maCaption
Table name from.
::std::vector< ScHTMLEntry * > ScHTMLEntryVector
void ImplRowOff()
Set internal states for leaving a table row.
void RecalcDocPos(const ScHTMLPos &rBasePos)
Recalculates the position of all cell entries and nested tables.
bool IsEmptyCell() const
Returns true, if the current cell does not contain an entry yet.
SfxItemSet maTableItemSet
Unique identifier of this table.
ScHTMLTable * GetExistingTable(ScHTMLTableId nTableId) const
Tries to find a table from the table container.
ScHTMLTable * InsertNestedTable(const HtmlImportInfo &rInfo, bool bPreFormText)
Inserts a nested table in the current cell at the specified position.
ScHTMLTable * TableOff(const HtmlImportInfo &rInfo)
Closes this table (tag).
void CaptionOff()
Processes the caption of the table ( tag).
bool mbRowOn
true = Table from preformatted text (
void PushTableEntry(ScHTMLTableId nTableId)
Pushes a new entry into current cell which references a nested table.
void GetDocRange(ScRange &rRange) const
Calculates the current Calc document area of this table.
bool mbDataOn
true = Inside of .
const ScRange * Find(const ScAddress &) const
void Join(const ScRange &, bool bIsInList=false)
void push_back(const ScRange &rRange)
bool Intersects(const ScRange &rRange) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SvKeyValueIterator * GetHeaderAttributes()
css::uno::Reference< css::frame::XModel3 > GetModel() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
static const sal_Int16 Medium
static const sal_Int16 Hairline
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)
const Value & back() const
const_iterator begin() const
std::vector< Value >::const_iterator const_iterator
const_iterator find(const Value &x) const
const_iterator end() const
const Value & front() const
std::pair< const_iterator, bool > insert(Value &&x)
#define OOO_STRING_SVTOOLS_HTML_AL_left
#define OOO_STRING_SVTOOLS_HTML_VA_middle
#define OOO_STRING_SVTOOLS_HTML_VA_bottom
#define OOO_STRING_SVTOOLS_HTML_AL_center
#define OOO_STRING_SVTOOLS_HTML_VA_top
#define OOO_STRING_SVTOOLS_HTML_AL_right
#define OOO_STRING_SVTOOLS_HTML_META_content_type
IMPL_LINK(ScHTMLLayoutParser, HTMLImportHdl, HtmlImportInfo &, rInfo, void)
static Type getLimitedValue(const Type &rValue, const Type &rMin, const Type &rMax)
const ScHTMLTableId SC_HTML_NO_TABLE
Used as table index for normal (non-table) entries in ScHTMLEntry structs.
o3tl::sorted_vector< sal_uLong > ScHTMLColOffset
::std::map< sal_uInt16, InnerMap * > OuterMap
ScHTMLOrient
Declares the orientation in or for a table: column or row.
::std::map< SCROW, SCROW > InnerMap
const sal_uInt32 SC_HTML_FONTSIZES
const ScHTMLTableId SC_HTML_GLOBAL_TABLE
Identifier of the "global table" (the entire HTML document).
const sal_uInt16 SC_HTML_OFFSET_TOLERANCE_SMALL
const sal_uInt16 SC_HTML_OFFSET_TOLERANCE_LARGE
sal_uInt16 ScHTMLTableId
Type for a unique identifier for each table.
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
OString strip(const OString &rIn, char c)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
::std::vector< HTMLOption > HTMLOptions
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
constexpr TypedWhichId< SvxPostureItem > ATTR_FONT_POSTURE(103)
constexpr TypedWhichId< SvxWeightItem > ATTR_FONT_WEIGHT(102)
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
constexpr TypedWhichId< SvxVerJustifyItem > ATTR_VER_JUSTIFY(132)
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
constexpr TypedWhichId< SvxUnderlineItem > ATTR_FONT_UNDERLINE(104)
SvParser< HtmlTokenId > * pParser
A single entry containing a line of text or representing a table.
void AdjustStart(const HtmlImportInfo &rInfo)
Sets start point of the entry selection to the start of the import info object.
bool HasContents() const
Returns true, if the entry has any content to be imported.
ScHTMLEntry(const SfxItemSet &rItemSet, ScHTMLTableId nTableId=SC_HTML_NO_TABLE)
bool IsTable() const
Returns true, if the entry represents a table.
ScHTMLTableId GetTableId() const
Returns true, if the entry represents a table.
void AdjustEnd(const HtmlImportInfo &rInfo)
Sets end point of the entry selection to the end of the import info object.
void Strip(const EditEngine &rEditEngine)
Deletes leading and trailing empty paragraphs from the entry.
SfxItemSet & GetItemSet()
Returns read/write access to the item set of this entry.
std::optional< Graphic > oGraphic
A 2D cell position in an HTML table.
ScAddress MakeAddr() const
SCCOLROW Get(ScHTMLOrient eOrient) const
A 2D cell size in an HTML table.
void Set(SCCOL nCols, SCROW nRows)
ScHTMLTableAutoId(ScHTMLTableId &rnUnusedId)
Reference to global unused identifier variable.
ScHTMLTableId & mrnUnusedId
The created unique table identifier.
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND