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;
783 OSL_ENSURE(
pE->nWidth,
"SetWidths: pE->nWidth == 0" );
799 if ( nCol < pE->nCol )
804 nColOffset =
static_cast<sal_uInt16
>((*pLocalColOffset)[nCol]);
849 OSL_FAIL(
"CloseEntry: EditEngine ESelection Start > End" );
860 switch ( rInfo.eState )
862 case HtmlImportState::NextToken:
865 case HtmlImportState::Start:
867 case HtmlImportState::End:
868 if ( rInfo.aSelection.nEndPos )
877 CloseEntry( &rInfo );
879 while ( nTableLevel > 0 )
882 case HtmlImportState::SetAttr:
884 case HtmlImportState::InsertText:
886 case HtmlImportState::InsertPara:
887 if ( nTableLevel < 1 )
889 CloseEntry( &rInfo );
893 case HtmlImportState::InsertField:
896 OSL_FAIL(
"HTMLImportHdl: unknown ImportInfo.eState");
906 OSL_FAIL(
"dumbo doc! <TH> or <TD> without previous <TABLE>" );
910 bool bHorJustifyCenterTH = (pInfo->
nToken == HtmlTokenId::TABLEHEADER_ON);
912 for (
const auto & rOption : rOptions)
914 switch( rOption.GetToken() )
916 case HtmlOptionId::COLSPAN:
918 mxActEntry->nColOverlap =
static_cast<SCCOL>(rOption.GetString().toInt32());
921 case HtmlOptionId::ROWSPAN:
923 mxActEntry->nRowOverlap =
static_cast<SCROW>(rOption.GetString().toInt32());
926 case HtmlOptionId::ALIGN:
928 bHorJustifyCenterTH =
false;
930 const OUString& rOptVal = rOption.GetString();
932 eVal = SvxCellHorJustify::Right;
934 eVal = SvxCellHorJustify::Center;
936 eVal = SvxCellHorJustify::Left;
938 eVal = SvxCellHorJustify::Standard;
939 if ( eVal != SvxCellHorJustify::Standard )
943 case HtmlOptionId::VALIGN:
946 const OUString& rOptVal = rOption.GetString();
948 eVal = SvxCellVerJustify::Top;
950 eVal = SvxCellVerJustify::Center;
952 eVal = SvxCellVerJustify::Bottom;
954 eVal = SvxCellVerJustify::Standard;
958 case HtmlOptionId::WIDTH:
963 case HtmlOptionId::BGCOLOR:
966 rOption.GetColor( aColor );
970 case HtmlOptionId::SDVAL:
975 case HtmlOptionId::SDNUM:
988 if ( bHorJustifyCenterTH )
1017 aTableStack.push( std::make_unique<ScHTMLTableStackEntry>(
1029 if ( pInfo->
nToken == HtmlTokenId::TABLE_ON )
1032 for (
const auto & rOption : rOptions)
1034 switch( rOption.GetToken() )
1036 case HtmlOptionId::WIDTH:
1041 case HtmlOptionId::BORDER:
1073 aTableStack.push( std::make_unique<ScHTMLTableStackEntry>(
1082 if ( pInfo->
nToken == HtmlTokenId::TABLE_ON )
1086 for (
const auto & rOption : rOptions)
1088 switch( rOption.GetToken() )
1090 case HtmlOptionId::WIDTH:
1095 case HtmlOptionId::BORDER:
1119 OSL_FAIL(
"dumbo doc! </TABLE> without opening <TABLE>" );
1126 std::unique_ptr<ScHTMLTableStackEntry>
pS = std::move(
aTableStack.top());
1129 auto&
pE =
pS->xCellEntry;
1134 sal_uInt16 nTab =
pS->nTable;
1138 OuterMap::const_iterator it =
pTables->find( nTab );
1143 (*pTables)[ nTab ] = pTab1;
1147 SCROW nRowSpan =
pE->nRowOverlap;
1153 nRowKGV = std::lcm( nRowSpan, nRows );
1154 nRowsPerRow1 = nRowKGV / nRowSpan;
1155 nRowsPerRow2 = nRowKGV / nRows;
1159 nRowKGV = nRowsPerRow1 = nRows;
1163 if ( nRowsPerRow2 > 1 )
1166 (*pTables)[
nTable ] = pTab2;
1171 if ( nRowsPerRow1 > 1 )
1173 for (
SCROW j=0; j < nRowSpan; j++ )
1176 SCROW nR = (*pTab1)[ nRowKey ];
1178 (*pTab1)[ nRowKey ] = nRowsPerRow1;
1179 else if ( nRowsPerRow1 > nR )
1180 (*pTab1)[ nRowKey ] = nRowsPerRow1;
1182 else if ( nRowsPerRow1 < nR && nRowSpan == 1
1185 SCROW nAdd = nRowsPerRow1 - (nR % nRowsPerRow1);
1187 if ( (nR % nRows) == 0 )
1189 SCROW nR2 = (*pTab1)[ nRowKey+1 ];
1192 (*pTab1)[ nRowKey ] = nR;
1193 (*pTab1)[ nRowKey+1 ] = nR2 - nAdd;
1194 nRowsPerRow2 = nR / nRows;
1200 if ( nRowsPerRow2 > 1 )
1205 (*pTables)[
nTable ] = pTab2;
1207 for (
SCROW j=0; j < nRows; j++ )
1210 (*pTab2)[ nRowKey ] = nRowsPerRow2;
1222 sal_uInt16 nOldOffset =
pE->nOffset +
pE->nWidth;
1225 sal_uInt16 nTmp = nNewOffset -
pE->nOffset -
pE->nWidth;
1226 pE->nWidth = nNewOffset -
pE->nOffset;
1227 pS->nTableWidth =
pS->nTableWidth + nTmp;
1228 if (
pS->nColOffset >= nOldOffset )
1229 pS->nColOffset =
pS->nColOffset + nTmp;
1268 mxActEntry->maImageList.push_back(std::make_unique<ScHTMLImage>());
1271 for (
const auto & rOption : rOptions)
1273 switch( rOption.GetToken() )
1275 case HtmlOptionId::SRC:
1280 case HtmlOptionId::ALT:
1291 case HtmlOptionId::WIDTH:
1296 case HtmlOptionId::HEIGHT:
1301 case HtmlOptionId::HSPACE:
1306 case HtmlOptionId::VSPACE:
1314 if (pImage->
aURL.isEmpty())
1316 OSL_FAIL(
"Image: graphic without URL ?!?" );
1321 std::optional<Graphic> oGraphic(std::in_place);
1324 *oGraphic, &rFilter, &nFormat ) )
1334 pImage->
oGraphic = std::move( oGraphic );
1339 pImage->
oGraphic->GetPrefMapMode() );
1345 for (
const std::unique_ptr<ScHTMLImage> & pI :
mxActEntry->maImageList)
1348 nWidth += pI->aSize.Width() + 2 * pI->aSpace.
X();
1361 for (
const auto & rOption : rOptions)
1363 if( rOption.GetToken() == HtmlOptionId::WIDTH )
1374 const OUString& rOptVal = rOption.
GetString();
1375 if ( rOptVal.indexOf(
'%') != -1 )
1378 return static_cast<sal_uInt16
>((rOption.
GetNumber() * nW) / 100);
1382 if ( rOptVal.indexOf(
'*') != -1 )
1388 return static_cast<sal_uInt16
>(rOption.
GetNumber());
1395 for (
const auto & rOption : rOptions)
1397 if( rOption.GetToken() == HtmlOptionId::NAME )
1417 for (
const auto & rOption : rOptions)
1419 switch( rOption.GetToken() )
1421 case HtmlOptionId::FACE :
1423 const OUString& rFace = rOption.GetString();
1424 OUStringBuffer aFontName;
1432 if( !aFontName.isEmpty() )
1433 aFontName.append(
";");
1434 aFontName.append(aFName);
1436 if ( !aFontName.isEmpty() )
1439 RTL_TEXTENCODING_DONTKNOW,
ATTR_FONT ) );
1442 case HtmlOptionId::SIZE :
1444 sal_uInt16 nSize =
static_cast<sal_uInt16
>(rOption.GetNumber());
1453 case HtmlOptionId::COLOR :
1456 rOption.GetColor( aColor );
1469 case HtmlTokenId::META:
1472 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1475 xDPS->getDocumentProperties(),
1479 case HtmlTokenId::TITLE_ON:
1485 case HtmlTokenId::TITLE_OFF:
1491 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1493 uno::UNO_QUERY_THROW);
1494 xDPS->getDocumentProperties()->setTitle(
aString);
1499 case HtmlTokenId::TABLE_ON:
1504 case HtmlTokenId::COL_ON:
1509 case HtmlTokenId::TABLEHEADER_ON:
1518 case HtmlTokenId::TABLEDATA_ON:
1523 case HtmlTokenId::TABLEHEADER_OFF:
1524 case HtmlTokenId::TABLEDATA_OFF:
1529 case HtmlTokenId::TABLEROW_ON:
1534 case HtmlTokenId::TABLEROW_OFF:
1539 case HtmlTokenId::TABLE_OFF:
1544 case HtmlTokenId::IMAGE:
1549 case HtmlTokenId::PARABREAK_OFF:
1555 case HtmlTokenId::ANCHOR_ON:
1560 case HtmlTokenId::FONT_ON :
1565 case HtmlTokenId::BIGPRINT_ON :
1573 case HtmlTokenId::SMALLPRINT_ON :
1581 case HtmlTokenId::BOLD_ON :
1582 case HtmlTokenId::STRONG_ON :
1589 case HtmlTokenId::ITALIC_ON :
1590 case HtmlTokenId::EMPHASIS_ON :
1591 case HtmlTokenId::ADDRESS_ON :
1592 case HtmlTokenId::BLOCKQUOTE_ON :
1593 case HtmlTokenId::BLOCKQUOTE30_ON :
1594 case HtmlTokenId::CITATION_ON :
1595 case HtmlTokenId::VARIABLE_ON :
1602 case HtmlTokenId::DEFINSTANCE_ON :
1613 case HtmlTokenId::UNDERLINE_ON :
1620 case HtmlTokenId::TEXTTOKEN:
1632template<
typename Type >
1634{
return std::clamp( rValue, rMin, rMax ); }
1638 mbImportAlways( false )
1666 "ScHTMLQueryParser::AdjustEntryEnd - invalid end position" );
1732 mrParentTable(rParentTable),
1733 mpCurrTable(nullptr)
1746 pResult = aFind->second.get();
1750 if( !pResult && bDeep )
1774class ScHTMLTableIterator
1781 bool is()
const {
return mpTableMap &&
maIter !=
maEnd; }
1793ScHTMLTableIterator::ScHTMLTableIterator(
const ScHTMLTableMap* pTableMap ) :
1794 mpTableMap(pTableMap)
1804 mnTableId( rnUnusedId ),
1805 mrnUnusedId( rnUnusedId )
1811 mpParentTable( &rParentTable ),
1812 maTableId( rParentTable.maTableId.mrnUnusedId ),
1813 maTableItemSet( rParentTable.GetCurrItemSet() ),
1814 mrEditEngine( rParentTable.mrEditEngine ),
1815 mrEEParseList( rParentTable.mrEEParseList ),
1816 mpCurrEntryVector( nullptr ),
1818 mpParser(rParentTable.mpParser),
1820 mbBorderOn( false ),
1821 mbPreFormText( bPreFormText ),
1824 mbPushEmptyLine( false ),
1825 mbCaptionOn ( false )
1836 for (
const auto& rOption : rOptions)
1838 switch( rOption.GetToken() )
1840 case HtmlOptionId::BORDER:
1841 mbBorderOn = rOption.GetString().isEmpty() || (rOption.GetNumber() != 0);
1843 case HtmlOptionId::ID:
1857 std::vector<std::shared_ptr<ScEEParseEntry>>& rEEParseList,
1860 mpParentTable( nullptr ),
1861 maTableId( rnUnusedId ),
1862 maTableItemSet( rPool ),
1863 mrEditEngine( rEditEngine ),
1864 mrEEParseList( rEEParseList ),
1865 mpCurrEntryVector( nullptr ),
1869 mbBorderOn( false ),
1870 mbPreFormText( false ),
1873 mbPushEmptyLine( false ),
1874 mbCaptionOn ( false )
1910 OSL_ENSURE(
mxCurrEntry,
"ScHTMLTable::PutItem - no current entry" );
1917 OSL_ENSURE(
mxCurrEntry,
"ScHTMLTable::PutText - no current entry" );
1959 OSL_ENSURE(
mxCurrEntry,
"ScHTMLTable::AnchorOn - no current entry" );
2026OUString decodeNumberFormat(
const OUString& rFmt)
2028 OUStringBuffer
aBuf;
2030 sal_Int32
n = rFmt.getLength();
2031 for (sal_Int32 i = 0;
i <
n; ++
i, ++
p)
2040 sal_Int32 nDigitCount = 0;
2042 for (;
i <
n; ++
i, ++
p, ++nDigitCount)
2044 if (*p <
'0' ||
'9' < *p)
2057 sal_uInt32 nVal = OUString(p1, nDigitCount).toUInt32(16);
2064 return aBuf.makeStringAndClear();
2076 std::optional<OUString> pValStr, pNumStr;
2079 for (
const auto& rOption : rOptions)
2081 switch (rOption.GetToken())
2083 case HtmlOptionId::COLSPAN:
2084 aSpanSize.
mnCols =
static_cast<SCCOL>( getLimitedValue<sal_Int32>( rOption.GetString().toInt32(), 1, 256 ) );
2086 case HtmlOptionId::ROWSPAN:
2087 aSpanSize.
mnRows =
static_cast<SCROW>( getLimitedValue<sal_Int32>( rOption.GetString().toInt32(), 1, 256 ) );
2089 case HtmlOptionId::SDVAL:
2090 pValStr = rOption.GetString();
2092 case HtmlOptionId::SDNUM:
2093 pNumStr = rOption.GetString();
2095 case HtmlOptionId::CLASS:
2099 OUString aClass = rOption.GetString();
2101 const OUString& rVal = rStyles.
getPropertyValue(
"td", aClass,
"mso-number-format");
2102 if (!rVal.isEmpty())
2104 OUString aNumFmt = decodeNumberFormat(rVal);
2109 sal_Int32 nErrPos = 0;
2189 size_t nIndex =
static_cast< size_t >( nCellPos );
2190 if(
nIndex >= rSizes.size() )
return 0;
2197 size_t nBeginIdx =
static_cast< size_t >( std::max< SCCOLROW >( nCellBegin, 0 ) );
2198 size_t nEndIdx =
static_cast< size_t >( std::min< SCCOLROW >( nCellEnd,
static_cast< SCCOLROW >( rSizes.size() ) ) );
2199 if (nBeginIdx >= nEndIdx )
return 0;
2200 return rSizes[ nEndIdx - 1 ] - ((nBeginIdx == 0) ? 0 : rSizes[ nBeginIdx - 1 ]);
2206 return rSizes.empty() ? 0 : rSizes.back();
2236 assert(!
"can't move");
2242 OSL_ENSURE( pDoc,
"ScHTMLTable::ApplyCellBorders - no document" );
2249 SvxBorderLine aOuterLine(
nullptr, nOuterLine, SvxBorderLineStyle::SOLID);
2250 SvxBorderLine aInnerLine(
nullptr, nInnerLine, SvxBorderLineStyle::SOLID);
2253 for(
SCCOL nCol = 0; nCol <= nLastCol; ++nCol )
2255 SvxBorderLine* pLeftLine = (nCol == 0) ? &aOuterLine : &aInnerLine;
2256 SvxBorderLine* pRightLine = (nCol == nLastCol) ? &aOuterLine : &aInnerLine;
2259 for(
SCROW nRow = 0; nRow <= nLastRow; ++nRow )
2261 SvxBorderLine* pTopLine = (nRow == 0) ? &aOuterLine : &aInnerLine;
2262 SvxBorderLine* pBottomLine = (nRow == nLastRow) ? &aOuterLine : &aInnerLine;
2265 for(
SCCOL nCellCol = nCellCol1; nCellCol <= nCellCol2; ++nCellCol )
2267 aBorderItem.
SetLine( (nCellCol == nCellCol1) ? pLeftLine :
nullptr, SvxBoxItemLine::LEFT );
2268 aBorderItem.
SetLine( (nCellCol == nCellCol2) ? pRightLine :
nullptr, SvxBoxItemLine::RIGHT );
2269 for(
SCROW nCellRow = nCellRow1; nCellRow <= nCellRow2; ++nCellRow )
2271 aBorderItem.
SetLine( (nCellRow == nCellRow1) ? pTopLine :
nullptr, SvxBoxItemLine::TOP );
2272 aBorderItem.
SetLine( (nCellRow == nCellRow2) ? pBottomLine :
nullptr, SvxBoxItemLine::BOTTOM );
2273 pDoc->
ApplyAttr( nCellCol, nCellRow, rFirstPos.
Tab(), aBorderItem );
2280 for( ScHTMLTableIterator aIter(
mxNestedTables.get() ); aIter.is(); ++aIter )
2281 aIter->ApplyCellBorders( pDoc, rFirstPos );
2296 return (rInfo.
nToken == HtmlTokenId::TEXTTOKEN) && (rInfo.
aText.getLength() == 1) && (rInfo.
aText[ 0 ] ==
' ');
2306 OSL_ENSURE( !
mxCurrEntry,
"ScHTMLTable::CreateNewEntry - old entry still present" );
2314 rEntryVector.push_back( rxEntry.get() );
2316 mrEEParseList.push_back(std::shared_ptr<ScEEParseEntry>(rxEntry.release()));
2321 bool bPushed =
false;
2322 if( rxEntry && rxEntry->HasContents() )
2341 OSL_FAIL(
"ScHTMLTable::PushEntry - cannot push entry, no parent found" );
2349 OSL_ENSURE(
mxCurrEntry,
"ScHTMLTable::PushEntry - no current entry" );
2350 bool bPushed =
false;
2373 OSL_ENSURE( nTableId !=
SC_HTML_GLOBAL_TABLE,
"ScHTMLTable::PushTableEntry - cannot push global table" );
2385 OSL_ENSURE( pTable || (nTableId ==
SC_HTML_GLOBAL_TABLE),
"ScHTMLTable::GetExistingTable - table not found" );
2428 assert(!
"can't move");
2430 if( rSpanSize.
mnRows > 1 )
2439 if( rSpanSize.
mnCols > 1 )
2499 if( rInfo.
nToken == HtmlTokenId::TABLEHEADER_ON )
2506 for (
const auto& rOption : rOptions)
2508 switch( rOption.GetToken() )
2510 case HtmlOptionId::ALIGN:
2513 const OUString& rOptVal = rOption.GetString();
2515 eVal = SvxCellHorJustify::Right;
2517 eVal = SvxCellHorJustify::Center;
2519 eVal = SvxCellHorJustify::Left;
2520 if( eVal != SvxCellHorJustify::Standard )
2525 case HtmlOptionId::VALIGN:
2528 const OUString& rOptVal = rOption.GetString();
2530 eVal = SvxCellVerJustify::Top;
2532 eVal = SvxCellVerJustify::Center;
2534 eVal = SvxCellVerJustify::Bottom;
2535 if( eVal != SvxCellVerJustify::Standard )
2540 case HtmlOptionId::BGCOLOR:
2543 rOption.GetColor( aColor );
2554 OSL_ENSURE( nCellPos >= 0,
"ScHTMLTable::SetDocSize - unexpected negative position" );
2556 size_t nIndex =
static_cast< size_t >( nCellPos );
2558 while(
nIndex >= rSizes.size() )
2559 rSizes.push_back( rSizes.empty() ? 1 : (rSizes.back() + 1) );
2564 std::for_each(rSizes.begin() +
nIndex, rSizes.end(), [&nDiff](
SCCOLROW& rSize) { rSize += nDiff; });
2572 while( nCellSpan > 1 )
2574 nDiffSize +=
GetDocSize( eOrient, nCellPos );
2579 nRealDocSize -= std::min< SCCOLROW >( nRealDocSize - 1, nDiffSize );
2580 SetDocSize( eOrient, nCellPos, nRealDocSize );
2585 for( ScHTMLTableIterator aIter(
mxNestedTables.get() ); aIter.is(); ++aIter )
2586 aIter->FillEmptyCells();
2597 for( aAddr.SetCol( 0 ); aAddr.Col() <
maSize.
mnCols; aAddr.IncCol() )
2622 for( ScHTMLTableIterator aIter(
mxNestedTables.get() ); aIter.is(); ++aIter )
2623 aIter->RecalcDocSize();
2628 static const sal_uInt16 PASS_SINGLE = 0;
2629 static const sal_uInt16 PASS_SPANNED = 1;
2630 for( sal_uInt16 nPass = PASS_SINGLE; nPass <= PASS_SPANNED; ++nPass )
2633 for(
const auto& [rCellPos, rEntryVector] :
maEntryMap )
2639 bool bProcessColWidth = ((nPass == PASS_SINGLE) == (aCellSpan.
mnCols == 1));
2640 bool bProcessRowHeight = ((nPass == PASS_SINGLE) == (aCellSpan.
mnRows == 1));
2641 if( bProcessColWidth || bProcessRowHeight )
2646 for(
const auto& rpEntry : rEntryVector )
2650 if( bProcessColWidth && pTable )
2653 if( bProcessRowHeight )
2659 if( bProcessColWidth )
2661 if( bProcessRowHeight )
2674 for(
auto& [rCellPos, rEntryVector] :
maEntryMap )
2685 for(
const auto& rpEntry : rEntryVector )
2690 pTable->RecalcDocPos( aEntryDocPos );
2693 SCROW nTableRows =
static_cast< SCROW >( pTable->GetDocSize(
tdRow ) );
2700 if( nStartCol < nNextCol )
2702 pEntry->
nCol = nStartCol;
2708 aEntryDocPos.
mnRow += nTableRows;
2716 ++aEntryDocPos.
mnRow;
2732 while( aEntryDocPos.
mnRow < nFirstUnusedRow )
2735 xDummyEntry->nCol = aEntryDocPos.
mnCol;
2736 xDummyEntry->nRow = aEntryDocPos.
mnRow;
2737 xDummyEntry->nColOverlap = aCellDocSize.
mnCols;
2739 ++aEntryDocPos.
mnRow;
2749 std::vector<std::shared_ptr<ScEEParseEntry>>& rEEParseVector,
2754 ScHTMLTable( rPool, rEditEngine, rEEParseVector, rnUnusedId, pParser, rDoc )
2800 const char* pCharSet = rtl_getBestMimeCharsetFromTextEncoding( RTL_TEXTENCODING_UTF8 );
2803 OUString aContentType =
"text/html; charset=" +
2804 OUString::createFromAscii( pCharSet );
2808 pAttributes = xValues.
get();
2834 case HtmlTokenId::META:
MetaOn( rInfo );
break;
2837 case HtmlTokenId::TITLE_ON:
TitleOn();
break;
2838 case HtmlTokenId::TITLE_OFF:
TitleOff( rInfo );
break;
2840 case HtmlTokenId::STYLE_ON:
break;
2848 case HtmlTokenId::TEXTTOKEN:
InsertText( rInfo );
break;
2850 case HtmlTokenId::HEAD1_ON:
2851 case HtmlTokenId::HEAD2_ON:
2852 case HtmlTokenId::HEAD3_ON:
2853 case HtmlTokenId::HEAD4_ON:
2854 case HtmlTokenId::HEAD5_ON:
2855 case HtmlTokenId::HEAD6_ON:
2862 case HtmlTokenId::TABLE_ON:
TableOn( rInfo );
break;
2863 case HtmlTokenId::TABLE_OFF:
TableOff( rInfo );
break;
2868 case HtmlTokenId::TABLEHEADER_ON:
2870 case HtmlTokenId::TABLEHEADER_OFF:
2872 case HtmlTokenId::PREFORMTXT_ON:
PreOn( rInfo );
break;
2873 case HtmlTokenId::PREFORMTXT_OFF:
PreOff( rInfo );
break;
2876 case HtmlTokenId::FONT_ON:
FontOn( rInfo );
break;
2878 case HtmlTokenId::BIGPRINT_ON:
2882 case HtmlTokenId::SMALLPRINT_ON:
2887 case HtmlTokenId::BOLD_ON:
2888 case HtmlTokenId::STRONG_ON:
2892 case HtmlTokenId::ITALIC_ON:
2893 case HtmlTokenId::EMPHASIS_ON:
2894 case HtmlTokenId::ADDRESS_ON:
2895 case HtmlTokenId::BLOCKQUOTE_ON:
2896 case HtmlTokenId::BLOCKQUOTE30_ON:
2897 case HtmlTokenId::CITATION_ON:
2898 case HtmlTokenId::VARIABLE_ON:
2902 case HtmlTokenId::DEFINSTANCE_ON:
2907 case HtmlTokenId::UNDERLINE_ON:
2924 for (
const auto& rOption : rOptions)
2926 switch( rOption.GetToken() )
2928 case HtmlOptionId::FACE :
2930 const OUString& rFace = rOption.GetString();
2939 if ( !aFontName.isEmpty() )
2942 RTL_TEXTENCODING_DONTKNOW,
ATTR_FONT ) );
2945 case HtmlOptionId::SIZE :
2947 sal_uInt32 nSize = getLimitedValue< sal_uInt32 >( rOption.GetNumber(), 1,
SC_HTML_FONTSIZES );
2951 case HtmlOptionId::COLOR :
2954 rOption.GetColor( aColor );
2969 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
2972 xDPS->getDocumentProperties(),
2988 OUString aTitle =
maTitle.makeStringAndClear().trim();
2991 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
2994 xDPS->getDocumentProperties()->setTitle(aTitle);
3030class CSSHandler:
public orcus::css_handler
3032 typedef std::pair<std::string_view, std::string_view> SelectorName;
3033 typedef std::vector<SelectorName> SelectorNames;
3035 SelectorNames maSelectorNames;
3036 std::string_view maPropName;
3037 std::string_view maPropValue;
3046 void simple_selector_type(std::string_view aElem)
3048 std::string_view aClass{};
3049 SelectorName
aName(aElem, aClass);
3051 maSelectorNames.push_back(aName);
3055 void simple_selector_class(std::string_view aClass)
3057 std::string_view aElem{};
3058 SelectorName
aName(aElem, aClass);
3060 maSelectorNames.push_back(aName);
3065 void property_name(std::string_view aPropName)
3070 void value(std::string_view aValue)
3072 maPropValue = aValue;
3077 maSelectorNames.clear();
3082 for (
const auto& rSelName : maSelectorNames)
3085 std::string_view aElem = rSelName.first;
3086 std::string_view aClass = rSelName.second;
3087 OUString
aName(maPropName.data(), maPropName.size(), RTL_TEXTENCODING_UTF8);
3088 OUString aValue(maPropValue.data(), maPropValue.size(), RTL_TEXTENCODING_UTF8);
3089 mrStyles.
add(aElem.data(), aElem.size(), aClass.data(), aClass.size(), aName, aValue);
3091 maPropName = std::string_view{};
3092 maPropValue = std::string_view{};
3103 orcus::css_parser<CSSHandler> aParser(
aStr, aHdl);
3108 catch (
const orcus::parse_error& rOrcusParseError)
3110 SAL_WARN(
"sc",
"ScHTMLQueryParser::ParseStyle: " << rOrcusParseError.what());
3117 switch( rInfo.eState )
3119 case HtmlImportState::Start:
3122 case HtmlImportState::NextToken:
3123 ProcessToken( rInfo );
3126 case HtmlImportState::InsertPara:
3127 mpCurrTable->InsertPara( rInfo );
3130 case HtmlImportState::SetAttr:
3131 case HtmlImportState::InsertText:
3132 case HtmlImportState::InsertField:
3135 case HtmlImportState::End:
3137 CloseTable( rInfo );
3141 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
void setX(tools::Long nX)
void setY(tools::Long nY)
constexpr tools::Long X() 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