writerfilter/source/dmapper/DomainMapper.cxx | 26 ------------ writerfilter/source/dmapper/StyleSheetTable.cxx | 11 ----- writerfilter/source/doctok/resources.xmi | 46 ---------------------- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 49 +++++++++++++++--------- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 6 ++ writerfilter/source/rtftok/rtfsprm.cxx | 9 +--- 6 files changed, 39 insertions(+), 108 deletions(-)
New commits: commit f453cf1d328f96dd5ad8e94b102bff3124e06154 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Jan 24 21:44:57 2014 +0100 writerfilter: refactor to avoid redundant Papx class in doctok Change-Id: Ic65e750bab99fb6b4c862418ccc53aa4b1f1298e diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 5ef81cf..7b4d782 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -179,28 +179,6 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) PropertyMap::iterator oldPropValue; switch( nName ) { - case NS_rtf::LN_ISTD: //index of applied style - { - //search for the style with the given id and apply it - //as CharStyleName or ParaStyleName - //if the style is a user defined style then it must have an ISTD - built-in styles might not have it - StyleSheetTablePtr pStyleSheets = m_pImpl->GetStyleSheetTable(); - OUString sValue = OUString::number(nIntValue, 16); - const StyleSheetEntryPtr pEntry = pStyleSheets->FindStyleSheetByISTD(sValue); - if( pEntry.get( ) ) - { - bool bParaStyle = (pEntry->nStyleTypeCode == STYLE_TYPE_PARA); - if(bParaStyle) - m_pImpl->SetCurrentParaStyleId(OUString::number(nIntValue, 16)); - if (m_pImpl->GetTopContext() && m_pImpl->GetTopContextType() != CONTEXT_SECTION) - m_pImpl->GetTopContext()->Insert( - bParaStyle ? - PROP_PARA_STYLE_NAME : PROP_CHAR_STYLE_NAME, - uno::makeAny( - m_pImpl->GetStyleSheetTable()->ConvertStyleName( pEntry->sStyleName ) ) ); - } - } - break; case NS_ooxml::LN_CT_Lvl_start: break; case NS_ooxml::LN_CT_Lvl_numFmt: @@ -223,12 +201,8 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) break; case NS_rtf::LN_FMASSCOPY: break; - case NS_rtf::LN_ISTDBASE: - break; case NS_rtf::LN_CUPX: break; - case NS_rtf::LN_ISTDNEXT: - break; case NS_rtf::LN_BCHUPE: break; case NS_rtf::LN_FAUTOREDEF: diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 0ced6b0..f698951 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -419,9 +419,6 @@ void StyleSheetTable::lcl_attribute(Id Name, Value & val) } switch(Name) { - case NS_rtf::LN_ISTD: - m_pImpl->m_pCurrentEntry->sStyleIdentifierD = OUString::number(nIntValue, 16); - break; case NS_rtf::LN_STI: { OUString tempStyleIdentifier = GetStyleIdFromIndex(static_cast<sal_uInt32>(nIntValue)); @@ -431,14 +428,6 @@ void StyleSheetTable::lcl_attribute(Id Name, Value & val) m_pImpl->m_pCurrentEntry->bIsDefaultStyle = true; } break; - case NS_rtf::LN_ISTDBASE: - if (static_cast<sal_uInt32>(nIntValue) != 0xfff) - m_pImpl->m_pCurrentEntry->sBaseStyleIdentifier = OUString::number(nIntValue, 16); - break; - case NS_rtf::LN_ISTDNEXT: - if (static_cast<sal_uInt32>(nIntValue) != 0xfff) - m_pImpl->m_pCurrentEntry->sNextStyleIdentifier = OUString::number(nIntValue, 16); - break; case NS_rtf::LN_FSCRATCH: case NS_rtf::LN_FINVALHEIGHT: case NS_rtf::LN_FHASUPE: diff --git a/writerfilter/source/doctok/resources.xmi b/writerfilter/source/doctok/resources.xmi index 869d155..434e984 100644 --- a/writerfilter/source/doctok/resources.xmi +++ b/writerfilter/source/doctok/resources.xmi @@ -139,28 +139,6 @@ </UML:Generalization.parent> </UML:Generalization> <!--Class SEPX--> - <!--Class Papx--> - <UML:Class xmi.id="Papx" name="Papx"> - <UML:Classifier.feature> - <UML:Attribute name="istd"> - <UML:ModelElement.taggedValue> - <UML:TaggedValue> - <UML:TaggedValue.dataValue>rtf:ISTD</UML:TaggedValue.dataValue> - <UML:TaggedValue.type> - <UML:TagDefinition xmi.idref="attrid"/> - </UML:TaggedValue.type> - </UML:TaggedValue> - </UML:ModelElement.taggedValue> - <UML:StructuralFeature.type> - <UML:DataType xmi.idref="U16"/> - </UML:StructuralFeature.type> - <UML:ModelElement.stereotype> - <UML:Stereotype xmi.idref="attribute"/> - </UML:ModelElement.stereotype> - </UML:Attribute> - </UML:Classifier.feature> - </UML:Class> - <!--Class Papx--> <!--Classes without stereotype--> <!--Resources--> <UML:Class xmi.id="Properties" name="Properties"> @@ -248,18 +226,6 @@ </UML:Attribute> </UML:Classifier.feature> <UML:Classifier.feature> - <UML:Attribute name="istdBase"> - <UML:ModelElement.taggedValue> - <UML:TaggedValue> - <UML:TaggedValue.dataValue>rtf:ISTDBASE</UML:TaggedValue.dataValue> - <UML:TaggedValue.type> - <UML:TagDefinition xmi.idref="attrid"/> - </UML:TaggedValue.type> - </UML:TaggedValue> - </UML:ModelElement.taggedValue> - </UML:Attribute> - </UML:Classifier.feature> - <UML:Classifier.feature> <UML:Attribute name="cupx"> <UML:ModelElement.taggedValue> <UML:TaggedValue> @@ -272,18 +238,6 @@ </UML:Attribute> </UML:Classifier.feature> <UML:Classifier.feature> - <UML:Attribute name="istdNext"> - <UML:ModelElement.taggedValue> - <UML:TaggedValue> - <UML:TaggedValue.dataValue>rtf:ISTDNEXT</UML:TaggedValue.dataValue> - <UML:TaggedValue.type> - <UML:TagDefinition xmi.idref="attrid"/> - </UML:TaggedValue.type> - </UML:TaggedValue> - </UML:ModelElement.taggedValue> - </UML:Attribute> - </UML:Classifier.feature> - <UML:Classifier.feature> <UML:Attribute name="bchUpe"> <UML:ModelElement.taggedValue> <UML:TaggedValue> diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index a73c903..0c6c8d5 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -613,6 +613,19 @@ int RTFDocumentImpl::getFontIndex(int nIndex) return m_pSuperstream->getFontIndex(nIndex); } +OUString RTFDocumentImpl::getStyleName(int nIndex) +{ + if (!m_pSuperstream) + { + OUString aRet; + if (m_aStyleNames.find(nIndex) != m_aStyleNames.end()) + aRet = m_aStyleNames[nIndex]; + return aRet; + } + else + return m_pSuperstream->getStyleName(nIndex); +} + RTFParserState& RTFDocumentImpl::getDefaultState() { if (!m_pSuperstream) @@ -1059,7 +1072,10 @@ void RTFDocumentImpl::text(OUString& rString) case DESTINATION_STYLEENTRY: if (m_aStates.top().aTableAttributes.find(NS_ooxml::LN_CT_Style_type)) { - RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aDestinationText.makeStringAndClear())); + OUString aName = m_aStates.top().aDestinationText.makeStringAndClear(); + m_aStyleNames[m_nCurrentStyleIndex] = aName; + RTFValue::Pointer_t pValue(new RTFValue(aName)); + m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Style_styleId, pValue); m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_name, pValue); writerfilter::Reference<Properties>::Pointer_t const pProp( @@ -2831,6 +2847,10 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) case RTF_RI: nSprm = NS_sprm::LN_PDxaRight; break; case RTF_RIN: nSprm = 0x845d; break; case RTF_ITAP: nSprm = NS_sprm::LN_PTableDepth; break; + case RTF_SBASEDON: + nSprm = (nKeyword == RTF_SBASEDON) ? NS_ooxml::LN_CT_Style_basedOn : NS_ooxml::LN_CT_Style_next; + pIntValue.reset(new RTFValue(getStyleName(nParam))); + break; default: break; } if (nSprm > 0) @@ -2842,19 +2862,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) return 0; } - // Trivial table attributes. - switch (nKeyword) - { - case RTF_SBASEDON: nSprm = NS_rtf::LN_ISTDBASE; break; - case RTF_SNEXT: nSprm = NS_rtf::LN_ISTDNEXT; break; - default: break; - } - if (nSprm > 0) - { - m_aStates.top().aTableAttributes.set(nSprm, pIntValue); - return 0; - } - // Info group. switch (nKeyword) { @@ -3014,24 +3021,30 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) if (m_aStates.top().nDestinationState == DESTINATION_STYLESHEET || m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY) { m_nCurrentStyleIndex = nParam; - m_aStates.top().aTableAttributes.set(NS_rtf::LN_ISTD, pIntValue); RTFValue::Pointer_t pValue(new RTFValue(1)); m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Style_type, pValue); // paragraph style } else - m_aStates.top().aParagraphAttributes.set(NS_rtf::LN_ISTD, pIntValue); + { + OUString aName = getStyleName(nParam); + if (!aName.isEmpty()) + m_aStates.top().aParagraphSprms.set(NS_ooxml::LN_CT_PPrBase_pStyle, RTFValue::Pointer_t(new RTFValue(aName))); + } } break; case RTF_CS: if (m_aStates.top().nDestinationState == DESTINATION_STYLESHEET || m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY) { m_nCurrentStyleIndex = nParam; - m_aStates.top().aTableAttributes.set(NS_rtf::LN_ISTD, pIntValue); RTFValue::Pointer_t pValue(new RTFValue(2)); m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Style_type, pValue); // character style } else - m_aStates.top().aCharacterAttributes.set(NS_rtf::LN_ISTD, pIntValue); + { + OUString aName = getStyleName(nParam); + if (!aName.isEmpty()) + m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_RPrBase_rStyle, RTFValue::Pointer_t(new RTFValue(aName))); + } break; case RTF_DEFF: m_aDefaultState.aCharacterSprms.set(NS_sprm::LN_CRgFtc0, pIntValue); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index eada5fa..c7e5a21 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -250,7 +250,7 @@ namespace writerfilter { /// Text from special destinations. OUStringBuffer aDestinationText; - /// Same as the int value of NS_rtf::LN_ISTD in aParagraphAttributes, for performance reasons. + /// Index of the current style. int nCurrentStyleIndex; /// Points to the active buffer, if there is one. @@ -332,6 +332,8 @@ namespace writerfilter { void setNeedPar(bool bNeedPar); /// Return the dmapper index of an RTF index for fonts. int getFontIndex(int nIndex); + /// Return the style name of an RTF style index. + OUString getStyleName(int nIndex); /// Return the encoding associated with a dmapper font index. rtl_TextEncoding getEncoding(sal_uInt32 nFontIndex); /// Get the default parser state. @@ -384,6 +386,8 @@ namespace writerfilter { std::map<int, rtl_TextEncoding> m_aFontEncodings; /// Maps the non-continious font indexes to the continous dmapper indexes. std::vector<int> m_aFontIndexes; + /// Maps style indexes to style names. + std::map<int, OUString> m_aStyleNames; /// Color index <-> RGB color value map std::vector<sal_uInt32> m_aColorTable; bool m_bFirstRun; diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx index ace6735..e9fc3ab 100644 --- a/writerfilter/source/rtftok/rtfsprm.cxx +++ b/writerfilter/source/rtftok/rtfsprm.cxx @@ -129,12 +129,9 @@ void RTFSprms::deduplicate(RTFSprms& rReference) while (i != m_pSprms->end()) { bool bIgnore = false; - if (i->first != NS_rtf::LN_ISTD) - { - RTFValue::Pointer_t pValue(rReference.find(i->first)); - if (pValue.get() && i->second->equals(*pValue)) - bIgnore = true; - } + RTFValue::Pointer_t pValue(rReference.find(i->first)); + if (pValue.get() && i->second->equals(*pValue)) + bIgnore = true; if (bIgnore) i = m_pSprms->erase(i); else _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits