27#include <unordered_map>
51 typedef std::unordered_map<OUString, OUString>
PropsType;
53 typedef ::std::map<OUString, NamePropsType>
ElemsType;
62 void add(
const char* pElemName,
size_t nElemName,
const char* pClassName,
size_t nClassName,
63 const OUString& aProp,
const OUString& aValue);
69 const OUString& rElem,
const OUString& rClass,
const OUString& rPropName)
const;
74 const OUString& aProp,
const OUString& aValue);
119 sal_uInt16 nTW, sal_uInt16 nCO, sal_uInt16 nCOS,
157 ::std::stack< std::unique_ptr<ScHTMLTableStackEntry> >
187 SCCOL* pCol, sal_uInt16 nOffsetTol );
189 sal_uInt16& nWidth, sal_uInt16 nOffsetTol,
190 sal_uInt16 nWidthTol );
192 sal_uInt16 nWidth, sal_uInt16 nOffsetTol,
193 sal_uInt16 nWidthTol );
195 sal_uInt16& nNewOffset, sal_uInt16 nOffsetTol );
439 std::vector<std::shared_ptr<ScEEParseEntry>>& rEEParseList,
564 std::vector<std::shared_ptr<ScEEParseEntry>>& rEEParseList,
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
DECL_LINK(HTMLImportHdl, HtmlImportInfo &, void)
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
virtual const ScHTMLTable * GetGlobalTable() const =0
Returns the "global table" which contains the entire HTML document.
virtual ErrCode Read(SvStream &rStrm, const OUString &rBaseURL) override=0
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.
::std::unique_ptr< ScHTMLGlobalTable > ScHTMLGlobalTablePtr
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.
DECL_LINK(HTMLImportHdl, HtmlImportInfo &, void)
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::map< OUString, NamePropsType > ElemsType
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.
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
const OUString & GetTableName() const
Returns the name of the table, specified in the TABLE tag.
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 .
const OUString & GetTableCaption() const
Returns the caption of the table, specified in the tag.
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.
::std::unique_ptr< ScHTMLTableMap > ScHTMLTableMapPtr
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 (
ScHTMLTableAutoId maTableId
Caption buffer of the table from
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 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
bool operator<(const ScHTMLPos &rPos1, const ScHTMLPos &rPos2)
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.
ScHTMLAdjustStackEntry(SCCOL nLCol, SCROW nNRow, SCROW nCRow)
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.
const SfxItemSet & GetItemSet() const
Returns read-only access to the item set of this entry.
bool IsEmpty() const
Returns true, if the selection of the entry is empty.
void SetImportAlways()
Sets or clears the import always state.
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.
A 2D cell position in an HTML table.
ScHTMLPos(SCCOL nCol, SCROW nRow)
ScHTMLPos(const ScAddress &rAddr)
ScAddress MakeAddr() const
void Set(SCCOL nCol, SCROW nRow)
void Set(const ScAddress &rAddr)
SCCOLROW Get(ScHTMLOrient eOrient) const
A 2D cell size in an HTML table.
void Set(SCCOL nCols, SCROW nRows)
ScHTMLSize(SCCOL nCols, SCROW nRows)
This struct handles creation of unique table identifiers.
ScHTMLTableAutoId(ScHTMLTableId &rnUnusedId)
Reference to global unused identifier variable.
const ScHTMLTableId mnTableId
ScHTMLTableId & mrnUnusedId
The created unique table identifier.
std::shared_ptr< ScEEParseEntry > xCellEntry
sal_uLong nFirstTableCell
ScHTMLTableStackEntry(std::shared_ptr< ScEEParseEntry > xE, ScRangeListRef xL, ScHTMLColOffset *pTO, sal_uLong nFTC, SCROW nRow, SCCOL nStart, SCCOL nMax, sal_uInt16 nTab, sal_uInt16 nTW, sal_uInt16 nCO, sal_uInt16 nCOS, bool bFR)
ScRangeListRef xLockedList
ScHTMLColOffset * pLocalColOffset
sal_uInt16 nColOffsetStart
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW