28void FillStyle(
const OUString& rName, std::map<OUString, librevenge::RVNGPropertyList>& rStyles,
29 std::map<OUString, librevenge::RVNGPropertyList>& rAutomaticStyles,
30 std::map<OUString, librevenge::RVNGPropertyList>& rNamedStyles,
31 librevenge::RVNGPropertyList& rPropertyList)
33 auto itStyle = rStyles.find(rName);
34 if (itStyle == rStyles.end())
37 const librevenge::RVNGPropertyList& rStyle = itStyle->second;
38 if (rStyle[
"style:parent-style-name"])
41 OUString aParent = OStringToOUString(rStyle[
"style:parent-style-name"]->getStr().cstr(),
42 RTL_TEXTENCODING_UTF8);
43 if (!aParent.isEmpty())
48 librevenge::RVNGPropertyList::Iter itProp(rStyle);
49 for (itProp.rewind(); itProp.next();)
51 if (std::string_view(
"style:parent-style-name") != itProp.key())
52 rPropertyList.insert(itProp.key(), itProp()->
clone());
62class XMLTextSequenceContext :
public XMLImportContext
65 XMLTextSequenceContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList);
67 void SAL_CALL characters(
const OUString& rChars)
override;
74XMLTextSequenceContext::XMLTextSequenceContext(XMLImport& rImport,
75 const librevenge::RVNGPropertyList& rPropertyList)
76 : XMLImportContext(rImport)
79 librevenge::RVNGPropertyList::Iter itProp(rPropertyList);
80 for (itProp.rewind(); itProp.next();)
84void XMLTextSequenceContext::characters(
const OUString& rChars)
89 GetImport().GetGenerator().insertText(librevenge::RVNGString(sCharU8.getStr()));
91 GetImport().GetGenerator().closeSpan();
97class XMLSpanContext :
public XMLImportContext
100 XMLSpanContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList);
103 CreateChildContext(
const OUString& rName,
104 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
107 startElement(
const OUString& rName,
108 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
109 void SAL_CALL characters(
const OUString& rChars)
override;
116XMLSpanContext::XMLSpanContext(XMLImport& rImport,
117 const librevenge::RVNGPropertyList& rPropertyList)
118 : XMLImportContext(rImport)
121 librevenge::RVNGPropertyList::Iter itProp(rPropertyList);
122 for (itProp.rewind(); itProp.next();)
127 const OUString& rName,
const css::uno::Reference<css::xml::sax::XAttributeList>& )
132void XMLSpanContext::startElement(
133 const OUString& ,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
135 for (sal_Int16 i = 0;
i < xAttribs->getLength(); ++
i)
137 const OUString& rAttributeName = xAttribs->getNameByIndex(i);
138 const OUString& rAttributeValue = xAttribs->getValueByIndex(i);
139 if (rAttributeName ==
"text:style-name")
140 FillStyles(rAttributeValue, GetImport().GetAutomaticTextStyles(),
151void XMLSpanContext::characters(
const OUString& rChars)
156 GetImport().GetGenerator().insertText(librevenge::RVNGString(sCharU8.getStr()));
158 GetImport().GetGenerator().closeSpan();
164class XMLRubyContext :
public XMLImportContext
167 XMLRubyContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList);
170 CreateChildContext(
const OUString& rName,
171 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
173 void SAL_CALL endElement(
const OUString& rName)
override;
175 void SetRubyText(
const OUString& rRubyText) {
m_sRubyText = rRubyText; }
186class XMLRubyTextContext :
public XMLImportContext
189 XMLRubyTextContext(XMLImport& rImport, XMLRubyContext& rParent)
190 : XMLImportContext(rImport)
195 void SAL_CALL characters(
const OUString& rChars)
override {
m_rParent.SetRubyText(rChars); }
202class XMLRubyBaseContext :
public XMLImportContext
205 XMLRubyBaseContext(XMLImport& rImport, XMLRubyContext& rParent)
206 : XMLImportContext(rImport)
211 void SAL_CALL characters(
const OUString& rChars)
override {
m_rParent.GetRubyBase() += rChars; }
218XMLRubyContext::XMLRubyContext(XMLImport& rImport,
219 const librevenge::RVNGPropertyList& rPropertyList)
220 : XMLImportContext(rImport)
223 librevenge::RVNGPropertyList::Iter itProp(rPropertyList);
224 for (itProp.rewind(); itProp.next();)
229 const OUString& rName,
const css::uno::Reference<css::xml::sax::XAttributeList>& )
231 if (rName ==
"text:ruby-base")
232 return new XMLRubyBaseContext(GetImport(), *
this);
233 if (rName ==
"text:ruby-text")
234 return new XMLRubyTextContext(GetImport(), *
this);
238void XMLRubyContext::endElement(
const OUString& )
242 if (sRubyText.getLength())
245 GetImport().GetGenerator().insertText(sRubyBase.getStr());
246 GetImport().GetGenerator().closeSpan();
255 XMLCharContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList);
257 const librevenge::RVNGPropertyList& GetPropertyList()
const {
return m_aPropertyList; }
265 const librevenge::RVNGPropertyList& rPropertyList)
266 : XMLImportContext(rImport)
269 librevenge::RVNGPropertyList::Iter itProp(rPropertyList);
270 for (itProp.rewind(); itProp.next();)
280 XMLLineBreakContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList);
283 startElement(
const OUString& rName,
284 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
288XMLLineBreakContext::XMLLineBreakContext(XMLImport& rImport,
289 const librevenge::RVNGPropertyList& rPropertyList)
294void XMLLineBreakContext::startElement(
296 const css::uno::Reference<css::xml::sax::XAttributeList>& )
298 GetImport().GetGenerator().openSpan(GetPropertyList());
299 GetImport().GetGenerator().insertLineBreak();
300 GetImport().GetGenerator().closeSpan();
309 XMLSpaceContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList);
312 startElement(
const OUString& rName,
313 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
317XMLSpaceContext::XMLSpaceContext(XMLImport& rImport,
318 const librevenge::RVNGPropertyList& rPropertyList)
323void XMLSpaceContext::startElement(
325 const css::uno::Reference<css::xml::sax::XAttributeList>& )
327 GetImport().GetGenerator().openSpan(GetPropertyList());
328 GetImport().GetGenerator().insertSpace();
329 GetImport().GetGenerator().closeSpan();
338 XMLTabContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList);
341 startElement(
const OUString& rName,
342 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
346XMLTabContext::XMLTabContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList)
351void XMLTabContext::startElement(
353 const css::uno::Reference<css::xml::sax::XAttributeList>& )
355 GetImport().GetGenerator().openSpan(GetPropertyList());
356 GetImport().GetGenerator().insertTab();
357 GetImport().GetGenerator().closeSpan();
367 const librevenge::RVNGPropertyList& rPropertyList);
369 CreateChildContext(
const OUString& rName,
370 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
373 startElement(
const OUString& rName,
374 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
375 void SAL_CALL endElement(
const OUString& rName)
override;
376 void SAL_CALL
characters(
const OUString& rChars)
override;
385 XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList)
386 : XMLImportContext(rImport)
389 librevenge::RVNGPropertyList::Iter itProp(rPropertyList);
390 for (itProp.rewind(); itProp.next();)
395 const OUString& rName,
const css::uno::Reference<css::xml::sax::XAttributeList>& )
400void XMLTextFrameHyperlinkContext::startElement(
401 const OUString& ,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
403 librevenge::RVNGPropertyList aPropertyList;
404 for (sal_Int16 i = 0;
i < xAttribs->getLength(); ++
i)
406 const OUString& rAttributeName = xAttribs->getNameByIndex(i);
407 const OUString& rAttributeValue = xAttribs->getValueByIndex(i);
408 if (rAttributeName ==
"text:style-name")
414 if (rAttributeName ==
"xlink:href")
424 aPropertyList.insert(
sName.getStr(), sValue.getStr());
429 GetImport().GetGenerator().openLink(aPropertyList);
432void XMLTextFrameHyperlinkContext::endElement(
const OUString& )
443 GetImport().GetGenerator().insertText(librevenge::RVNGString(sCharU8.getStr()));
451class XMLHyperlinkContext :
public XMLImportContext
454 XMLHyperlinkContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList);
456 CreateChildContext(
const OUString& rName,
457 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
460 startElement(
const OUString& rName,
461 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
override;
462 void SAL_CALL endElement(
const OUString& rName)
override;
463 void SAL_CALL characters(
const OUString& rChars)
override;
471XMLHyperlinkContext::XMLHyperlinkContext(XMLImport& rImport,
472 const librevenge::RVNGPropertyList& rPropertyList)
473 : XMLImportContext(rImport)
476 librevenge::RVNGPropertyList::Iter itProp(rPropertyList);
477 for (itProp.rewind(); itProp.next();)
482 const OUString& rName,
const css::uno::Reference<css::xml::sax::XAttributeList>& )
487void XMLHyperlinkContext::startElement(
488 const OUString& ,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
490 librevenge::RVNGPropertyList aPropertyList;
491 for (sal_Int16 i = 0;
i < xAttribs->getLength(); ++
i)
493 const OUString& rAttributeName = xAttribs->getNameByIndex(i);
494 const OUString& rAttributeValue = xAttribs->getValueByIndex(i);
495 if (rAttributeName ==
"text:style-name")
497 FillStyles(rAttributeValue, GetImport().GetAutomaticTextStyles(),
501 if (rAttributeName ==
"xlink:href")
503 m_ePopupState = GetImport().FillPopupData(rAttributeValue, aPropertyList);
511 aPropertyList.insert(
sName.getStr(), sValue.getStr());
516 GetImport().GetGenerator().openLink(aPropertyList);
519void XMLHyperlinkContext::endElement(
const OUString& )
522 GetImport().GetGenerator().closeLink();
525void XMLHyperlinkContext::characters(
const OUString& rChars)
530 GetImport().GetGenerator().insertText(librevenge::RVNGString(sCharU8.getStr()));
532 GetImport().GetGenerator().closeSpan();
537 , m_bTopLevel(bTopLevel)
542 const OUString& rName,
const css::uno::Reference<css::xml::sax::XAttributeList>& )
544 if (rName ==
"text:a")
546 if (rName ==
"draw:a")
548 if (rName ==
"text:ruby")
554 const OUString& ,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
556 librevenge::RVNGPropertyList aPropertyList;
557 for (sal_Int16
i = 0;
i < xAttribs->getLength(); ++
i)
559 const OUString& rAttributeName = xAttribs->getNameByIndex(
i);
560 const OUString& rAttributeValue = xAttribs->getValueByIndex(
i);
561 if (rAttributeName ==
"text:style-name")
565 GetImport().GetParagraphStyles(), aPropertyList);
575 aPropertyList.insert(
sName.getStr(), sValue.getStr());
589 librevenge::RVNGPropertyList aPropertyList;
603 const librevenge::RVNGPropertyList& rTextPropertyList)
605 if (rName ==
"text:span")
606 return new XMLSpanContext(rImport, rTextPropertyList);
607 if (rName ==
"text:line-break")
608 return new XMLLineBreakContext(rImport, rTextPropertyList);
609 if (rName ==
"text:s")
610 return new XMLSpaceContext(rImport, rTextPropertyList);
611 if (rName ==
"text:tab")
612 return new XMLTabContext(rImport, rTextPropertyList);
613 if (rName ==
"draw:frame")
615 if (rName ==
"text:sequence")
616 return new XMLTextSequenceContext(rImport, rTextPropertyList);
617 if (rName ==
"text:note")
619 SAL_WARN(
"writerperfect",
"CreateParagraphOrSpanChildContext: unhandled " << rName);
624 std::map<OUString, librevenge::RVNGPropertyList>& rAutomaticStyles,
625 std::map<OUString, librevenge::RVNGPropertyList>& rNamedStyles,
626 librevenge::RVNGPropertyList& rPropertyList)
628 FillStyle(rName, rAutomaticStyles, rAutomaticStyles, rNamedStyles, rPropertyList);
629 FillStyle(rName, rNamedStyles, rAutomaticStyles, rNamedStyles, rPropertyList);
SvXMLImport & GetImport()
virtual void SAL_CALL characters(const OUString &aChars) override
XMLCharContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, sal_Unicode c, bool bCount)
XMLParaContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XMLTextFrameHyperlinkContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::text::TextContentAnchorType eDefaultAnchorType)
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
void SAL_CALL startElement(const OUString &rName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
void SAL_CALL characters(const OUString &rChars) override
void SAL_CALL endElement(const OUString &rName) override
bool m_bTopLevel
If the context is a direct child of XMLBodyContentContext.
rtl::Reference< XMLImportContext > CreateChildContext(const OUString &rName, const css::uno::Reference< css::xml::sax::XAttributeList > &) override
librevenge::RVNGPropertyList m_aTextPropertyList
List of properties spans should inherit from this paragraph.
Handler for <draw:frame>.
T * clone(T *const other)
#define SAL_WARN(area, stream)
enum SAL_DLLPUBLIC_RTTI FillStyle
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
rtl::Reference< XMLImportContext > CreateParagraphOrSpanChildContext(XMLImport &rImport, const OUString &rName, const librevenge::RVNGPropertyList &rTextPropertyList)
Shared child context factory for paragraph and span contexts.
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...
PopupState
States describing the result of a link -> popup conversion.
librevenge::RVNGPropertyList m_aPropertyList
XMLRubyContext & m_rParent