summaryrefslogtreecommitdiff
path: root/writerfilter/source/rtftok
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-07-23 14:45:45 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-07-23 14:53:19 +0200
commit4ad9e3f5be10bde030338f744d56ffa6c7736bd0 (patch)
treedd9372f5da03ecdd33ea6c23f34f74b5b6e2b3da /writerfilter/source/rtftok
parente7e2b7daadeb901bee3d644dd0faf701d3ca34a2 (diff)
implement import of RTF_{MOMATH,MR,MF,MFPR,MCTRLPR,MNUM,MDEN}
Change-Id: I4d0d9df26de1ef52a808c82d89a8404c98ef7bc4
Diffstat (limited to 'writerfilter/source/rtftok')
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx93
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx12
2 files changed, 104 insertions, 1 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 37da9c015805..187ae91cc721 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -48,11 +48,17 @@
#include <filter/msfilter/util.hxx>
#include <filter/msfilter/escherex.hxx>
#include <comphelper/string.hxx>
+#include <tools/globname.hxx>
+#include <comphelper/classids.hxx>
+#include <comphelper/embeddedobjectcontainer.hxx>
+#include <oox/mathml/import.hxx>
#include <doctok/sprmids.hxx> // NS_sprm namespace
#include <doctok/resourceids.hxx> // NS_rtf namespace
#include <ooxml/resourceids.hxx> // NS_ooxml namespace
#include <ooxml/OOXMLFastTokens.hxx> // ooxml namespace
+#include <oox/token/namespaces.hxx> // oox namespace
+#include <oox/token/tokens.hxx>
#include <rtfsdrimport.hxx>
#include <rtftokenizer.hxx>
@@ -943,6 +949,7 @@ void RTFDocumentImpl::text(OUString& rString)
case DESTINATION_SUBJECT:
case DESTINATION_DOCCOMM:
case DESTINATION_ATNID:
+ case DESTINATION_MR:
m_aStates.top().aDestinationText.append(rString);
break;
case DESTINATION_EQINSTRUCTION:
@@ -1390,6 +1397,54 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
case RTF_ATNID:
m_aStates.top().nDestinationState = DESTINATION_ATNID;
break;
+ case RTF_MMATH:
+ // 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;
+ }
+ 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;
+ }
+ 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;
+ }
+ 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;
+ }
+ 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;
+ }
+ 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;
+ }
+ 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
@@ -3443,6 +3498,44 @@ int RTFDocumentImpl::popState()
parBreak();
m_bNeedPap = true;
}
+ else if (m_aStates.top().nDestinationState == DESTINATION_MOMATH)
+ {
+ uno::Reference<xml::sax::XFastAttributeList> aAttribs;
+ m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_oMath);
+
+ SvGlobalName aGlobalName(SO3_SM_CLASSID);
+ comphelper::EmbeddedObjectContainer aContainer;
+ OUString aName;
+ uno::Reference<embed::XEmbeddedObject> xObject = aContainer.CreateEmbeddedObject(aGlobalName.GetByteSequence(), aName);
+ uno::Reference<util::XCloseable> xComponent(xObject->getComponent(), uno::UNO_QUERY);
+ if( oox::FormulaImportBase* pImport = dynamic_cast<oox::FormulaImportBase*>(xComponent.get()))
+ pImport->readFormulaOoxml(m_aMathBuffer);
+ RTFValue::Pointer_t pValue(new RTFValue(xObject));
+ RTFSprms aMathAttributes;
+ aMathAttributes.set(NS_ooxml::LN_starmath, pValue);
+ writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aMathAttributes));
+ Mapper().props(pProperties);
+ m_aMathBuffer = oox::formulaimport::XmlStreamBuilder();
+ }
+ 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.appendCharacters(m_aStates.top().aDestinationText.makeStringAndClear());
+ m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_t);
+ m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_r);
+ }
+ else if (m_aStates.top().nDestinationState == DESTINATION_MF)
+ m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_f);
+ else if (m_aStates.top().nDestinationState == DESTINATION_MFPR)
+ m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_fPr);
+ else if (m_aStates.top().nDestinationState == DESTINATION_MCTRLPR)
+ m_aMathBuffer.appendClosingTag(oox::NMSP_officeMath | oox::XML_ctrlPr);
+ else if (m_aStates.top().nDestinationState == DESTINATION_MNUM)
+ 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);
// 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 14ded59a416d..3483e0dbd814 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -35,6 +35,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <oox/helper/graphichelper.hxx>
+#include <oox/mathml/importutils.hxx>
#include <rtl/strbuf.hxx>
#include <rtftok/RTFDocument.hxx>
@@ -118,7 +119,14 @@ namespace writerfilter {
DESTINATION_TITLE,
DESTINATION_SUBJECT,
DESTINATION_DOCCOMM,
- DESTINATION_ATNID
+ DESTINATION_ATNID,
+ DESTINATION_MOMATH,
+ DESTINATION_MR,
+ DESTINATION_MF,
+ DESTINATION_MFPR,
+ DESTINATION_MCTRLPR,
+ DESTINATION_MNUM,
+ DESTINATION_MDEN
};
enum RTFBorderState
@@ -512,6 +520,8 @@ namespace writerfilter {
rtl::OUStringBuffer m_aUnicodeBuffer;
/// Same for hex characters.
rtl::OStringBuffer m_aHexBuffer;
+ /// Formula import.
+ oox::formulaimport::XmlStreamBuilder m_aMathBuffer;
};
} // namespace rtftok
} // namespace writerfilter