summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-08-02 18:55:55 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-08-03 19:43:19 +0000
commitaed0f1e27be04ecd43b2edd3885c1f2eea0a3de9 (patch)
treea9aed1a7e6706988d1d1e8fdce211f49925a74bb /writerfilter
parentd2dd174ac05d7c2844c5e60169128e2a02d4311b (diff)
fdo#81944: writerfilter: RTF import: don't drop fonts in stylesheet
The font definitions in the style sheet meet an untimely death in StyleSheetTable::lcl_sprm(), which special-cases LN_EG_RPrBase_rFonts, routing it into TblStylePrHandler. Avoid this by sending style entries to the domain mapper in the same way as the OOXML tokenizer, i.e., with paragraph and run properties nested below CT_Style_pPr/rPr. This reveals that the CT_Style_basedOn was wrongly handled as paragraph property. Change-Id: Ic724ba48fe36bf782b1b430bdafdb1df480d5ad3 (cherry picked from commit f8e8e476aa0a5576234dbb4daac9dc299e044e61) Reviewed-on: https://gerrit.libreoffice.org/10698 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx6
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx51
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx3
3 files changed, 24 insertions, 36 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f6dc73ea1527..f44b2bd78a87 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4663,15 +4663,17 @@ uno::Reference<container::XIndexAccess> DomainMapper_Impl::GetCurrentNumberingRu
// So we are in a paragraph style and it has numbering. Look up the relevant numbering rules.
OUString aListName = ListDef::GetStyleName(nListId);
- uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY);
+ uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY_THROW);
uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies();
uno::Reference<container::XNameAccess> xNumberingStyles;
xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles;
uno::Reference<beans::XPropertySet> xStyle(xNumberingStyles->getByName(aListName), uno::UNO_QUERY);
xRet.set(xStyle->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
}
- catch( const uno::Exception& )
+ catch (const uno::Exception& e)
{
+ SAL_WARN("writerfilter.dmapper",
+ "GetCurrentNumberingRules: exception caught: " << e.Message);
}
return xRet;
}
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 21708cc8553f..c716b2fac5d8 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1164,7 +1164,7 @@ void RTFDocumentImpl::text(OUString& rString)
m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_name, pValue);
writerfilter::Reference<Properties>::Pointer_t const pProp(
- new RTFReferenceProperties(mergeAttributes(), mergeSprms())
+ createStyleProperties()
);
m_aStyleTableEntries.insert(make_pair(m_nCurrentStyleIndex, pProp));
}
@@ -3387,6 +3387,10 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
case RTF_LEVELPICTURE:
nSprm = NS_ooxml::LN_CT_Lvl_lvlPicBulletId;
break;
+ case RTF_SBASEDON:
+ nSprm = NS_ooxml::LN_CT_Style_basedOn;
+ pIntValue.reset(new RTFValue(getStyleName(nParam)));
+ break;
default:
break;
}
@@ -3466,10 +3470,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
case RTF_ITAP:
nSprm = NS_ooxml::LN_tblDepth;
break;
- case RTF_SBASEDON:
- nSprm = NS_ooxml::LN_CT_Style_basedOn;
- pIntValue.reset(new RTFValue(getStyleName(nParam)));
- break;
default:
break;
}
@@ -4792,19 +4792,21 @@ int RTFDocumentImpl::pushState()
return 0;
}
-RTFSprms RTFDocumentImpl::mergeSprms()
+writerfilter::Reference<Properties>::Pointer_t
+RTFDocumentImpl::createStyleProperties()
{
- RTFSprms aSprms;
- for (RTFSprms::Iterator_t i = m_aStates.top().aTableSprms.begin();
- i != m_aStates.top().aTableSprms.end(); ++i)
- aSprms.set(i->first, i->second);
- for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterSprms.begin();
- i != m_aStates.top().aCharacterSprms.end(); ++i)
- aSprms.set(i->first, i->second);
- for (RTFSprms::Iterator_t i = m_aStates.top().aParagraphSprms.begin();
- i != m_aStates.top().aParagraphSprms.end(); ++i)
- aSprms.set(i->first, i->second);
- return aSprms;
+ RTFValue::Pointer_t const pParaProps(
+ new RTFValue(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms));
+ RTFValue::Pointer_t const pCharProps(
+ new RTFValue(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms));
+
+ // resetSprms will clean up this modification
+ m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_pPr, pParaProps);
+ m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_rPr, pCharProps);
+
+ writerfilter::Reference<Properties>::Pointer_t const pProps(
+ new RTFReferenceProperties(m_aStates.top().aTableAttributes, m_aStates.top().aTableSprms));
+ return pProps;
}
void RTFDocumentImpl::resetSprms()
@@ -4814,21 +4816,6 @@ void RTFDocumentImpl::resetSprms()
m_aStates.top().aParagraphSprms.clear();
}
-RTFSprms RTFDocumentImpl::mergeAttributes()
-{
- RTFSprms aAttributes;
- for (RTFSprms::Iterator_t i = m_aStates.top().aTableAttributes.begin();
- i != m_aStates.top().aTableAttributes.end(); ++i)
- aAttributes.set(i->first, i->second);
- for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterAttributes.begin();
- i != m_aStates.top().aCharacterAttributes.end(); ++i)
- aAttributes.set(i->first, i->second);
- for (RTFSprms::Iterator_t i = m_aStates.top().aParagraphAttributes.begin();
- i != m_aStates.top().aParagraphAttributes.end(); ++i)
- aAttributes.set(i->first, i->second);
- return aAttributes;
-}
-
void RTFDocumentImpl::resetAttributes()
{
m_aStates.top().aTableAttributes.clear();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 437ab48cb36c..98a5523c3152 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -382,8 +382,7 @@ public:
private:
SvStream& Strm();
sal_uInt32 getColorTable(sal_uInt32 nIndex);
- RTFSprms mergeSprms();
- RTFSprms mergeAttributes();
+ writerfilter::Reference<Properties>::Pointer_t createStyleProperties();
void resetSprms();
void resetAttributes();
void resolveSubstream(sal_Size nPos, Id nId);