summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-09-06 18:26:02 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-09-06 18:55:15 +0200
commit321d7ec2071472b3765a00806715e7ad9f8a306f (patch)
tree716df73e4f71ea6f0b7107855d15f331456e7bea /writerfilter
parent9e6221f114ba4422caa79f38ee0a20fb8a8931cd (diff)
fdo#82078 RTF import: fix bold text spilling over to non-bold text
Regression from commit 41890bf714803969515578b47e63fa9730ea7090 (fdo#54473 fdo#57133 fix RTF import of character styles, 2012-12-04), the problem was that the style undoing magic introduced in 1be0a3fa9ebb22b607c54b47739d4467acfed259 (n#825305: writerfilter RTF import: override style properties like Word, 2014-06-17) was not used for character styles. Change-Id: Id31cfd5574a83bcf2895f0c2fd496fa60791cbb3
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx27
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx2
-rw-r--r--writerfilter/source/rtftok/rtfsprm.cxx1
3 files changed, 28 insertions, 2 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index c16b59fc47ed..a4bd1ddeca16 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -445,9 +445,29 @@ writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::getProperties(RT
if (it != m_aStyleTableEntries.end())
{
RTFReferenceProperties& rProps = *(RTFReferenceProperties*)it->second.get();
+
+ // cloneAndDeduplicate() wants to know about only a single "style", so
+ // let's merge paragraph and character style properties here.
+ int nCharStyle = m_aStates.top().nCurrentCharacterStyleIndex;
+ RTFReferenceTable::Entries_t::iterator itChar = m_aStyleTableEntries.find(nCharStyle);
+ RTFSprms aStyleSprms = rProps.getSprms();
+ RTFSprms aStyleAttributes = rProps.getAttributes();
+ if (itChar != m_aStyleTableEntries.end())
+ {
+ // Found active character style, then update aStyleSprms/Attributes.
+ RTFReferenceProperties& rCharProps = *(RTFReferenceProperties*)itChar->second.get();
+ RTFSprms& rCharStyleSprms = rCharProps.getSprms();
+ for (RTFSprms::Iterator_t itSprm = rCharStyleSprms.begin(); itSprm != rCharStyleSprms.end(); ++itSprm)
+ aStyleSprms.set(itSprm->first, itSprm->second);
+
+ RTFSprms& rCharStyleAttributes = rCharProps.getAttributes();
+ for (RTFSprms::Iterator_t itAttr = rCharStyleAttributes.begin(); itAttr != rCharStyleAttributes.end(); ++itAttr)
+ aStyleAttributes.set(itAttr->first, itAttr->second);
+ }
+
// Get rid of direct formatting what is already in the style.
- RTFSprms const sprms(rSprms.cloneAndDeduplicate(rProps.getSprms()));
- RTFSprms const attributes(rAttributes.cloneAndDeduplicate(rProps.getAttributes()));
+ RTFSprms const sprms(rSprms.cloneAndDeduplicate(aStyleSprms));
+ RTFSprms const attributes(rAttributes.cloneAndDeduplicate(aStyleAttributes));
return writerfilter::Reference<Properties>::Pointer_t(new RTFReferenceProperties(attributes, sprms));
}
writerfilter::Reference<Properties>::Pointer_t pRet(new RTFReferenceProperties(rAttributes, rSprms));
@@ -2807,6 +2827,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
m_aStates.top().aCharacterSprms = getDefaultState().aCharacterSprms;
m_aStates.top().nCurrentEncoding = getEncoding(getFontIndex(m_nDefaultFontIndex));
m_aStates.top().aCharacterAttributes = getDefaultState().aCharacterAttributes;
+ m_aStates.top().nCurrentCharacterStyleIndex = -1;
}
break;
case RTF_PARD:
@@ -3692,6 +3713,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
}
break;
case RTF_CS:
+ m_aStates.top().nCurrentCharacterStyleIndex = nParam;
if (m_aStates.top().nDestinationState == DESTINATION_STYLESHEET || m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY)
{
m_nCurrentStyleIndex = nParam;
@@ -5937,6 +5959,7 @@ RTFParserState::RTFParserState(RTFDocumentImpl* pDocumentImpl)
nMinute(0),
pDestinationText(0),
nCurrentStyleIndex(-1),
+ nCurrentCharacterStyleIndex(-1),
pCurrentBuffer(0),
bInListpicture(false),
bInBackground(false),
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 7a720f5b1814..c0f606777d8a 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -279,6 +279,8 @@ public:
/// Index of the current style.
int nCurrentStyleIndex;
+ /// Index of the current character style.
+ int nCurrentCharacterStyleIndex;
/// Points to the active buffer, if there is one.
RTFBuffer_t* pCurrentBuffer;
diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index bf2b597d1a35..b2fd96c6e5a0 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -143,6 +143,7 @@ static RTFValue::Pointer_t getDefaultSPRM(Id const id)
{
case NS_ooxml::LN_CT_Spacing_before:
case NS_ooxml::LN_CT_Spacing_after:
+ case NS_ooxml::LN_EG_RPrBase_b:
return RTFValue::Pointer_t(new RTFValue(0));
default: