summaryrefslogtreecommitdiff
path: root/writerperfect/source/writer/exp/txtparai.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-08-29 17:56:28 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-08-30 10:02:32 +0200
commitdfdc113bbd852e8f4b4863db457e2938aaad0c64 (patch)
treeb6b0b5304a7fe1a345b69951448f46d9fec013fc /writerperfect/source/writer/exp/txtparai.cxx
parent0be2ac10cb4baf14e8ba9f30a10c5b5ad3a7197d (diff)
EPUB export: support char props on text outside a span
The librevenge model is simpler: text is always in a span, and paragraph (automatic) styles don't contain char props, either. So handle this complexity on our side. Change-Id: I017222539d8981d2bbbc632258662444bf3a79c8 Reviewed-on: https://gerrit.libreoffice.org/41705 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerperfect/source/writer/exp/txtparai.cxx')
-rw-r--r--writerperfect/source/writer/exp/txtparai.cxx33
1 files changed, 26 insertions, 7 deletions
diff --git a/writerperfect/source/writer/exp/txtparai.cxx b/writerperfect/source/writer/exp/txtparai.cxx
index 50ff36352ad5..293fb10eb3d3 100644
--- a/writerperfect/source/writer/exp/txtparai.cxx
+++ b/writerperfect/source/writer/exp/txtparai.cxx
@@ -53,9 +53,9 @@ void XMLSpanContext::startElement(const OUString &/*rName*/, const css::uno::Ref
const OUString &rAttributeValue = xAttribs->getValueByIndex(i);
if (rAttributeName == "text:style-name")
{
- // Reference to an automatic style, try to look it up.
- auto itStyle = mrImport.GetAutomaticStyles().find(rAttributeValue);
- if (itStyle == mrImport.GetAutomaticStyles().end())
+ // Reference to an automatic text style, try to look it up.
+ auto itStyle = mrImport.GetAutomaticTextStyles().find(rAttributeValue);
+ if (itStyle == mrImport.GetAutomaticTextStyles().end())
continue;
// Apply properties directly, librevenge has no notion of automatic styles.
@@ -152,15 +152,17 @@ void XMLParaContext::startElement(const OUString &/*rName*/, const css::uno::Ref
const OUString &rAttributeValue = xAttribs->getValueByIndex(i);
if (rAttributeName == "text:style-name")
{
+ m_aStyleName = rAttributeValue;
+
// Reference to an automatic style, try to look it up.
- auto itStyle = mrImport.GetAutomaticStyles().find(rAttributeValue);
- if (itStyle == mrImport.GetAutomaticStyles().end())
+ auto itStyle = mrImport.GetAutomaticParagraphStyles().find(m_aStyleName);
+ if (itStyle == mrImport.GetAutomaticParagraphStyles().end())
continue;
- // Apply properties directly, librevenge has no notion of automatic styles.
+ // Found an automatic paragraph style.
librevenge::RVNGPropertyList::Iter itProp(itStyle->second);
for (itProp.rewind(); itProp.next();)
- aPropertyList.insert(itProp.key(), itProp());
+ aPropertyList.insert(itProp.key(), itProp()->clone());
}
else
{
@@ -180,8 +182,25 @@ void XMLParaContext::endElement(const OUString &/*rName*/)
void XMLParaContext::characters(const OUString &rChars)
{
+ librevenge::RVNGPropertyList aPropertyList;
+ if (!m_aStyleName.isEmpty())
+ {
+ // Reference to an automatic style, try to look it up.
+ auto itStyle = mrImport.GetAutomaticTextStyles().find(m_aStyleName);
+ if (itStyle != mrImport.GetAutomaticTextStyles().end())
+ {
+ // Found an automatic text style.
+ librevenge::RVNGPropertyList::Iter itProp(itStyle->second);
+ for (itProp.rewind(); itProp.next();)
+ aPropertyList.insert(itProp.key(), itProp()->clone());
+ }
+ }
+ mrImport.GetGenerator().openSpan(aPropertyList);
+
OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8);
mrImport.GetGenerator().insertText(librevenge::RVNGString(sCharU8.getStr()));
+
+ mrImport.GetGenerator().closeSpan();
}
} // namespace exp