oox/inc/oox/mathml/importutils.hxx | 7 + oox/source/mathml/importutils.cxx | 16 ++++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 99 ++++++++++++++----------- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 6 + 4 files changed, 83 insertions(+), 45 deletions(-)
New commits: commit fd11c723d0bbaa50421baf98062933335ec079ab Author: Miklos Vajna <vmik...@suse.cz> Date: Mon Jul 23 17:15:21 2012 +0200 rtftok: cleanup - use M_TOKEN() macro Change-Id: If51def3c7c798104fd6dec9cf38473e5d70420fc diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 1338542..3581f30 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -68,6 +68,7 @@ #include <rtffly.hxx> #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L)) +#define M_TOKEN(token) OOX_TOKEN(officeMath, token) using std::make_pair; using rtl::OString; @@ -1402,73 +1403,46 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) // Nothing to do here (just enter the destination) till RTF_MMATHPR is implemented. break; case RTF_MOMATH: - { - uno::Reference<xml::sax::XFastAttributeList> aAttribs; - m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_oMath, aAttribs); - m_aStates.top().nDestinationState = DESTINATION_MOMATH; - } + m_aMathBuffer.appendOpeningTag(M_TOKEN(oMath)); + m_aStates.top().nDestinationState = DESTINATION_MOMATH; break; case RTF_MR: m_aStates.top().nDestinationState = DESTINATION_MR; break; case RTF_MF: - { - uno::Reference<xml::sax::XFastAttributeList> aAttribs; - m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_f, aAttribs); - m_aStates.top().nDestinationState = DESTINATION_MF; - } + m_aMathBuffer.appendOpeningTag(M_TOKEN(f)); + m_aStates.top().nDestinationState = DESTINATION_MF; break; case RTF_MFPR: - { - uno::Reference<xml::sax::XFastAttributeList> aAttribs; - m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_fPr, aAttribs); - m_aStates.top().nDestinationState = DESTINATION_MFPR; - } + m_aMathBuffer.appendOpeningTag(M_TOKEN(fPr)); + m_aStates.top().nDestinationState = DESTINATION_MFPR; break; case RTF_MCTRLPR: - { - uno::Reference<xml::sax::XFastAttributeList> aAttribs; - m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_ctrlPr, aAttribs); - m_aStates.top().nDestinationState = DESTINATION_MCTRLPR; - } + m_aMathBuffer.appendOpeningTag(M_TOKEN(ctrlPr)); + m_aStates.top().nDestinationState = DESTINATION_MCTRLPR; break; case RTF_MNUM: - { - uno::Reference<xml::sax::XFastAttributeList> aAttribs; - m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_num, aAttribs); - m_aStates.top().nDestinationState = DESTINATION_MNUM; - } + m_aMathBuffer.appendOpeningTag(M_TOKEN(num)); + m_aStates.top().nDestinationState = DESTINATION_MNUM; break; case RTF_MDEN: - { - uno::Reference<xml::sax::XFastAttributeList> aAttribs; - m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_den, aAttribs); - m_aStates.top().nDestinationState = DESTINATION_MDEN; - } + m_aMathBuffer.appendOpeningTag(M_TOKEN(den)); + m_aStates.top().nDestinationState = DESTINATION_MDEN; break; case RTF_MACC: - { - uno::Reference<xml::sax::XFastAttributeList> aAttribs; - m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_acc, aAttribs); - m_aStates.top().nDestinationState = DESTINATION_MACC; - } + m_aMathBuffer.appendOpeningTag(M_TOKEN(acc)); + m_aStates.top().nDestinationState = DESTINATION_MACC; break; case RTF_MACCPR: - { - uno::Reference<xml::sax::XFastAttributeList> aAttribs; - m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_accPr, aAttribs); - m_aStates.top().nDestinationState = DESTINATION_MACCPR; - } + m_aMathBuffer.appendOpeningTag(M_TOKEN(accPr)); + m_aStates.top().nDestinationState = DESTINATION_MACCPR; break; case RTF_MCHR: m_aStates.top().nDestinationState = DESTINATION_MCHR; break; case RTF_ME: - { - uno::Reference<xml::sax::XFastAttributeList> aAttribs; - m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_e, aAttribs); - m_aStates.top().nDestinationState = DESTINATION_ME; - } + m_aMathBuffer.appendOpeningTag(M_TOKEN(e)); + m_aStates.top().nDestinationState = DESTINATION_ME; break; default: SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle destination '" << lcl_RtfToString(nKeyword) << "'"); @@ -3528,8 +3502,7 @@ int RTFDocumentImpl::popState() } else if (m_aStates.top().nDestinationState == DESTINATION_MOMATH) { - uno::Reference<xml::sax::XFastAttributeList> aAttribs; - m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_oMath); + m_aMathBuffer.appendClosingTag(M_TOKEN(oMath)); SvGlobalName aGlobalName(SO3_SM_CLASSID); comphelper::EmbeddedObjectContainer aContainer; @@ -3547,36 +3520,35 @@ int RTFDocumentImpl::popState() } else if (m_aStates.top().nDestinationState == DESTINATION_MR) { - uno::Reference<xml::sax::XFastAttributeList> aAttribs; - m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_r, aAttribs); - m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_t, aAttribs); + m_aMathBuffer.appendOpeningTag(M_TOKEN(r)); + m_aMathBuffer.appendOpeningTag(M_TOKEN(t)); m_aMathBuffer.appendCharacters(m_aStates.top().aDestinationText.makeStringAndClear()); - m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_t); - m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_r); + m_aMathBuffer.appendClosingTag(M_TOKEN(t)); + m_aMathBuffer.appendClosingTag(M_TOKEN(r)); } else if (m_aStates.top().nDestinationState == DESTINATION_MF) - m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_f); + m_aMathBuffer.appendClosingTag(M_TOKEN(f)); else if (m_aStates.top().nDestinationState == DESTINATION_MFPR) - m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_fPr); + m_aMathBuffer.appendClosingTag(M_TOKEN(fPr)); else if (m_aStates.top().nDestinationState == DESTINATION_MCTRLPR) - m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_ctrlPr); + m_aMathBuffer.appendClosingTag(M_TOKEN(ctrlPr)); else if (m_aStates.top().nDestinationState == DESTINATION_MNUM) - m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_num); + m_aMathBuffer.appendClosingTag(M_TOKEN(num)); else if (m_aStates.top().nDestinationState == DESTINATION_MDEN) - m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_den); + m_aMathBuffer.appendClosingTag(M_TOKEN(den)); else if (m_aStates.top().nDestinationState == DESTINATION_MACC) - m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_acc); + m_aMathBuffer.appendClosingTag(M_TOKEN(acc)); else if (m_aStates.top().nDestinationState == DESTINATION_MACCPR) - m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_accPr); + m_aMathBuffer.appendClosingTag(M_TOKEN(accPr)); else if (m_aStates.top().nDestinationState == DESTINATION_MCHR) { oox::formulaimport::XmlStream::AttributeList aAttribs; - aAttribs[oox::NMSP_officeMath | oox::XML_val] = m_aStates.top().aDestinationText.makeStringAndClear(); - m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_chr, aAttribs); - m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_chr); + aAttribs[M_TOKEN(val)] = m_aStates.top().aDestinationText.makeStringAndClear(); + m_aMathBuffer.appendOpeningTag(M_TOKEN(chr), aAttribs); + m_aMathBuffer.appendClosingTag(M_TOKEN(chr)); } else if (m_aStates.top().nDestinationState == DESTINATION_ME) - m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_e); + m_aMathBuffer.appendClosingTag(M_TOKEN(e)); // See if we need to end a track change RTFValue::Pointer_t pTrackchange = m_aStates.top().aCharacterSprms.find(NS_ooxml::LN_trackchange); commit 2a7e3836733c0af54b9d337e55cc32cdf58cdd6d Author: Miklos Vajna <vmik...@suse.cz> Date: Mon Jul 23 17:00:10 2012 +0200 implement import of RTF_{MACC,MACCPR,MCHR,ME} Change-Id: I5521bc3dc58b096dd80746a0af9c9d5e24ffe4a3 diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 187ae91..1338542 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -950,6 +950,7 @@ void RTFDocumentImpl::text(OUString& rString) case DESTINATION_DOCCOMM: case DESTINATION_ATNID: case DESTINATION_MR: + case DESTINATION_MCHR: m_aStates.top().aDestinationText.append(rString); break; case DESTINATION_EQINSTRUCTION: @@ -1445,6 +1446,30 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) m_aStates.top().nDestinationState = DESTINATION_MDEN; } break; + case RTF_MACC: + { + uno::Reference<xml::sax::XFastAttributeList> aAttribs; + m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_acc, aAttribs); + m_aStates.top().nDestinationState = DESTINATION_MACC; + } + break; + case RTF_MACCPR: + { + uno::Reference<xml::sax::XFastAttributeList> aAttribs; + m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_accPr, aAttribs); + m_aStates.top().nDestinationState = DESTINATION_MACCPR; + } + break; + case RTF_MCHR: + m_aStates.top().nDestinationState = DESTINATION_MCHR; + break; + case RTF_ME: + { + uno::Reference<xml::sax::XFastAttributeList> aAttribs; + m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_e, aAttribs); + m_aStates.top().nDestinationState = DESTINATION_ME; + } + break; default: SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle destination '" << lcl_RtfToString(nKeyword) << "'"); // Make sure we skip destinations (even without \*) till we don't handle them @@ -3097,7 +3122,10 @@ int RTFDocumentImpl::pushState() else if (m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT || m_aStates.top().nDestinationState == DESTINATION_SHAPETEXT || m_aStates.top().nDestinationState == DESTINATION_FORMFIELD || - (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION && !m_bEq)) + (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION && !m_bEq) || + m_aStates.top().nDestinationState == DESTINATION_MOMATH || + m_aStates.top().nDestinationState == DESTINATION_MNUM || + m_aStates.top().nDestinationState == DESTINATION_MDEN) m_aStates.top().nDestinationState = DESTINATION_NORMAL; else if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION && m_bEq) m_aStates.top().nDestinationState = DESTINATION_EQINSTRUCTION; @@ -3536,6 +3564,19 @@ int RTFDocumentImpl::popState() m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_num); else if (m_aStates.top().nDestinationState == DESTINATION_MDEN) m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_den); + else if (m_aStates.top().nDestinationState == DESTINATION_MACC) + m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_acc); + else if (m_aStates.top().nDestinationState == DESTINATION_MACCPR) + m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_accPr); + else if (m_aStates.top().nDestinationState == DESTINATION_MCHR) + { + oox::formulaimport::XmlStream::AttributeList aAttribs; + aAttribs[oox::NMSP_officeMath | oox::XML_val] = m_aStates.top().aDestinationText.makeStringAndClear(); + m_aMathBuffer.appendOpeningTag(oox::NMSP_officeMath | oox::XML_chr, aAttribs); + m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_chr); + } + else if (m_aStates.top().nDestinationState == DESTINATION_ME) + m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_e); // See if we need to end a track change RTFValue::Pointer_t pTrackchange = m_aStates.top().aCharacterSprms.find(NS_ooxml::LN_trackchange); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 3483e0d..dd98a28 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -126,7 +126,11 @@ namespace writerfilter { DESTINATION_MFPR, DESTINATION_MCTRLPR, DESTINATION_MNUM, - DESTINATION_MDEN + DESTINATION_MDEN, + DESTINATION_MACC, + DESTINATION_MACCPR, + DESTINATION_MCHR, + DESTINATION_ME }; enum RTFBorderState commit 4a62512086fe71d98f3de95706ab1350625a7616 Author: Miklos Vajna <vmik...@suse.cz> Date: Mon Jul 23 16:59:13 2012 +0200 oox::formulaimport::XmlStream: allow avoiding XFastAttributeList Change-Id: Iba0ad5ae72920f27e8a443a043c5891b102aee98 diff --git a/oox/inc/oox/mathml/importutils.hxx b/oox/inc/oox/mathml/importutils.hxx index fc0e276..7718515 100644 --- a/oox/inc/oox/mathml/importutils.hxx +++ b/oox/inc/oox/mathml/importutils.hxx @@ -133,6 +133,7 @@ public: struct OOX_DLLPUBLIC AttributeList { bool hasAttribute( int token ) const; + OUString& operator[] (int token); rtl::OUString attribute( int token, const rtl::OUString& def = rtl::OUString()) const; bool attribute( int token, bool def ) const; sal_Unicode attribute( int token, sal_Unicode def ) const; @@ -148,6 +149,8 @@ public: Tag( int token = XML_TOKEN_INVALID, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastAttributeList >& attributes = com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastAttributeList >(), const rtl::OUString& text = rtl::OUString()); + Tag( int token, + const AttributeList& attribs); int token; ///< tag type, or XML_TOKEN_INVALID AttributeList attributes; rtl::OUString text; @@ -236,7 +239,9 @@ class OOX_DLLPUBLIC XmlStreamBuilder { public: void appendOpeningTag( int token, - const com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastAttributeList >& attributes ); + const com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastAttributeList >& attributes = com::sun::star::uno::Reference< com::sun::star::xml::sax::XFastAttributeList >()); + void appendOpeningTag( int token, + const AttributeList& attribs ); void appendClosingTag( int token ); // appends the characters after the last appended token void appendCharacters( const rtl::OUString& characters ); diff --git a/oox/source/mathml/importutils.cxx b/oox/source/mathml/importutils.cxx index 41a254d..01c2ba7 100644 --- a/oox/source/mathml/importutils.cxx +++ b/oox/source/mathml/importutils.cxx @@ -114,6 +114,11 @@ static OUString tokenToString( int token ) } // namespace +OUString& XmlStream::AttributeList::operator[] (int token) +{ + return attrs[token]; +} + rtl::OUString XmlStream::AttributeList::attribute( int token, const rtl::OUString& def ) const { std::map< int, rtl::OUString >::const_iterator find = attrs.find( token ); @@ -165,6 +170,12 @@ XmlStream::Tag::Tag( int t, const uno::Reference< xml::sax::XFastAttributeList > { } +XmlStream::Tag::Tag( int t, const AttributeList& a ) +: token( t ) +, attributes( a ) +{ +} + XmlStream::Tag::operator bool() const { @@ -337,6 +348,11 @@ void XmlStreamBuilder::appendOpeningTag( int token, const uno::Reference< xml::s tags.push_back( Tag( OPENING( token ), attrs )); } +void XmlStreamBuilder::appendOpeningTag( int token, const AttributeList& attrs ) +{ + tags.push_back( Tag( OPENING( token ), attrs )); +} + void XmlStreamBuilder::appendClosingTag( int token ) { tags.push_back( Tag( CLOSING( token ))); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits