25class XMLTableRowContext :
public XMLImportContext
28 XMLTableRowContext(XMLImport& rImport);
31 CreateChildContext(
const OUString& rName,
32 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
33 int GetColumn()
const;
34 void SetColumn(
int nColumn);
37 startElement(
const OUString& rName,
38 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
39 void SAL_CALL endElement(
const OUString& rName)
override;
46class XMLTableCellContext :
public XMLImportContext
49 XMLTableCellContext(XMLImport& rImport, XMLTableRowContext& rRow);
52 CreateChildContext(
const OUString& rName,
53 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
56 startElement(
const OUString& rName,
57 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
58 void SAL_CALL endElement(
const OUString& rName)
override;
65XMLTableCellContext::XMLTableCellContext(XMLImport& rImport, XMLTableRowContext& rRow)
66 : XMLImportContext(rImport)
72 const OUString& rName,
const css::uno::Reference<css::xml::sax::XAttributeList>& )
77void XMLTableCellContext::startElement(
78 const OUString& ,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
80 librevenge::RVNGPropertyList aPropertyList;
81 for (sal_Int16 i = 0;
i < xAttribs->getLength(); ++
i)
83 const OUString& rAttributeName = xAttribs->getNameByIndex(i);
84 const OUString& rAttributeValue = xAttribs->getValueByIndex(i);
86 if (rAttributeName ==
"table:style-name")
87 FillStyles(rAttributeValue, GetImport().GetAutomaticCellStyles(),
88 GetImport().GetCellStyles(), aPropertyList);
93 aPropertyList.insert(
sName.getStr(), sValue.getStr());
96 aPropertyList.insert(
"librevenge:column",
m_rRow.GetColumn());
97 GetImport().GetGenerator().openTableCell(aPropertyList);
101void XMLTableCellContext::endElement(
const OUString& )
103 GetImport().GetGenerator().closeTableCell();
109class XMLTableColumnContext :
public XMLImportContext
112 XMLTableColumnContext(XMLImport& rImport, librevenge::RVNGPropertyListVector& rColumns);
115 startElement(
const OUString& rName,
116 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
123XMLTableColumnContext::XMLTableColumnContext(XMLImport& rImport,
124 librevenge::RVNGPropertyListVector& rColumns)
125 : XMLImportContext(rImport)
130void XMLTableColumnContext::startElement(
131 const OUString& ,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
133 librevenge::RVNGPropertyList aPropertyList;
134 for (sal_Int16 i = 0;
i < xAttribs->getLength(); ++
i)
136 const OUString& rAttributeName = xAttribs->getNameByIndex(i);
137 const OUString& rAttributeValue = xAttribs->getValueByIndex(i);
139 if (rAttributeName ==
"table:style-name")
140 FillStyles(rAttributeValue, GetImport().GetAutomaticColumnStyles(),
141 GetImport().GetColumnStyles(), aPropertyList);
146XMLTableRowContext::XMLTableRowContext(XMLImport& rImport)
147 : XMLImportContext(rImport)
152 const OUString& rName,
const css::uno::Reference<css::xml::sax::XAttributeList>& )
154 if (rName ==
"table:table-cell")
155 return new XMLTableCellContext(GetImport(), *
this);
156 if (rName ==
"table:covered-table-cell")
159 GetImport().GetGenerator().insertCoveredTableCell(librevenge::RVNGPropertyList());
162 SAL_WARN(
"writerperfect",
"XMLTableRowContext::CreateChildContext: unhandled " << rName);
166void XMLTableRowContext::startElement(
167 const OUString& ,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
169 librevenge::RVNGPropertyList aPropertyList;
170 for (sal_Int16 i = 0;
i < xAttribs->getLength(); ++
i)
172 const OUString& rAttributeName = xAttribs->getNameByIndex(i);
173 const OUString& rAttributeValue = xAttribs->getValueByIndex(i);
175 if (rAttributeName ==
"table:style-name")
176 FillStyles(rAttributeValue, GetImport().GetAutomaticRowStyles(),
177 GetImport().GetRowStyles(), aPropertyList);
179 GetImport().GetGenerator().openTableRow(aPropertyList);
182void XMLTableRowContext::endElement(
const OUString& )
184 GetImport().GetGenerator().closeTableRow();
187int XMLTableRowContext::GetColumn()
const {
return m_nColumn; }
189void XMLTableRowContext::SetColumn(
int nColumn) {
m_nColumn = nColumn; }
191XMLTableContext::XMLTableContext(
XMLImport& rImport,
bool bTopLevel)
193 , m_bTopLevel(bTopLevel)
198 const OUString& rName,
const css::uno::Reference<css::xml::sax::XAttributeList>& )
200 if (rName ==
"table:table-column")
212 if (rName ==
"table:table-row")
213 return new XMLTableRowContext(
GetImport());
215 SAL_WARN(
"writerperfect",
"XMLTableContext::CreateChildContext: unhandled " << rName);
221 const OUString& ,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
223 for (sal_Int16
i = 0;
i < xAttribs->getLength(); ++
i)
225 const OUString& rAttributeName = xAttribs->getNameByIndex(
i);
226 const OUString& rAttributeValue = xAttribs->getValueByIndex(
i);
228 if (rAttributeName ==
"table:style-name")
Base class for a handler of a single XML element during ODF -> librevenge conversion.
ODT export feeds this class to make librevenge calls.
void HandlePageSpan(const librevenge::RVNGPropertyList &rPropertyList)
librevenge::RVNGTextInterface & GetGenerator() const
librevenge::RVNGPropertyList m_aPropertyList
bool m_bTopLevel
If the context is a direct child of XMLBodyContentContext.
void SAL_CALL endElement(const OUString &rName) override
rtl::Reference< XMLImportContext > CreateChildContext(const OUString &rName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
librevenge::RVNGPropertyListVector m_aColumns
void SAL_CALL startElement(const OUString &rName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
#define SAL_WARN(area, stream)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
void FillStyles(const OUString &rName, std::map< OUString, librevenge::RVNGPropertyList > &rAutomaticStyles, std::map< OUString, librevenge::RVNGPropertyList > &rNamedStyles, librevenge::RVNGPropertyList &rPropertyList)
Looks for rName in rAutomaticStyles (and failing that, in rNamedStyles) and fills rPropertyList based...
rtl::Reference< XMLImportContext > CreateTextChildContext(XMLImport &rImport, std::u16string_view rName, bool bTopLevel)
Context factory for body text, section, table cell, etc.
XMLTableRowContext & m_rRow
librevenge::RVNGPropertyListVector & m_rColumns