[Libreoffice-commits] .: 2 commits - writerfilter/source
Miklos Vajna
vmiklos at kemper.freedesktop.org
Mon Jul 23 05:53:21 PDT 2012
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 93 +++++++++++++++++++++++++
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 12 ++-
writerfilter/source/rtftok/rtfvalue.cxx | 25 ++++++
writerfilter/source/rtftok/rtfvalue.hxx | 5 +
4 files changed, 131 insertions(+), 4 deletions(-)
New commits:
commit 4ad9e3f5be10bde030338f744d56ffa6c7736bd0
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Mon Jul 23 14:45:45 2012 +0200
implement import of RTF_{MOMATH,MR,MF,MFPR,MCTRLPR,MNUM,MDEN}
Change-Id: I4d0d9df26de1ef52a808c82d89a8404c98ef7bc4
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 37da9c0..187ae91 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 14ded59..3483e0d 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
commit e7e2b7daadeb901bee3d644dd0faf701d3ca34a2
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Mon Jul 23 13:38:52 2012 +0200
RTFValue: extend to be able to store embed::XEmbeddedObject
Change-Id: I6218be1f4afe22665ab85f7d731e1c1567bb2c8e
diff --git a/writerfilter/source/rtftok/rtfvalue.cxx b/writerfilter/source/rtftok/rtfvalue.cxx
index 13613fa..4882522 100644
--- a/writerfilter/source/rtftok/rtfvalue.cxx
+++ b/writerfilter/source/rtftok/rtfvalue.cxx
@@ -35,11 +35,12 @@ using rtl::OUString;
RTFValue::RTFValue(int nValue, rtl::OUString sValue, RTFSprms rAttributes,
RTFSprms rSprms, uno::Reference<drawing::XShape> xShape,
- uno::Reference<io::XInputStream> xStream, bool bForceString)
+ uno::Reference<io::XInputStream> xStream, uno::Reference<embed::XEmbeddedObject> xObject, bool bForceString)
: m_nValue(nValue),
m_sValue(sValue),
m_xShape(xShape),
m_xStream(xStream),
+ m_xObject(xObject),
m_bForceString(bForceString)
{
m_pAttributes.reset(new RTFSprms(rAttributes));
@@ -51,6 +52,7 @@ RTFValue::RTFValue(int nValue)
m_sValue(),
m_xShape(),
m_xStream(),
+ m_xObject(),
m_bForceString(false)
{
m_pAttributes.reset(new RTFSprms());
@@ -62,6 +64,7 @@ RTFValue::RTFValue(OUString sValue, bool bForce)
m_sValue(sValue),
m_xShape(),
m_xStream(),
+ m_xObject(),
m_bForceString(bForce)
{
m_pAttributes.reset(new RTFSprms());
@@ -73,6 +76,7 @@ RTFValue::RTFValue(RTFSprms rAttributes)
m_sValue(),
m_xShape(),
m_xStream(),
+ m_xObject(),
m_bForceString(false)
{
m_pAttributes.reset(new RTFSprms(rAttributes));
@@ -84,6 +88,7 @@ RTFValue::RTFValue(RTFSprms rAttributes, RTFSprms rSprms)
m_sValue(),
m_xShape(),
m_xStream(),
+ m_xObject(),
m_bForceString(false)
{
m_pAttributes.reset(new RTFSprms(rAttributes));
@@ -95,6 +100,7 @@ RTFValue::RTFValue(uno::Reference<drawing::XShape> rShape)
m_sValue(),
m_xShape(rShape),
m_xStream(),
+ m_xObject(),
m_bForceString(false)
{
m_pAttributes.reset(new RTFSprms());
@@ -106,6 +112,19 @@ RTFValue::RTFValue(uno::Reference<io::XInputStream> rStream)
m_sValue(),
m_xShape(),
m_xStream(rStream),
+ m_xObject(),
+ m_bForceString(false)
+{
+ m_pAttributes.reset(new RTFSprms());
+ m_pSprms.reset(new RTFSprms());
+}
+
+RTFValue::RTFValue(uno::Reference<embed::XEmbeddedObject> xObject)
+ : m_nValue(),
+ m_sValue(),
+ m_xShape(),
+ m_xStream(),
+ m_xObject(xObject),
m_bForceString(false)
{
m_pAttributes.reset(new RTFSprms());
@@ -143,6 +162,8 @@ uno::Any RTFValue::getAny() const
ret <<= m_xShape;
else if (m_xStream.is())
ret <<= m_xStream;
+ else if (m_xObject.is())
+ ret <<= m_xObject;
else
ret <<= static_cast<sal_Int32>(m_nValue);
return ret;
@@ -176,7 +197,7 @@ std::string RTFValue::toString() const
RTFValue* RTFValue::Clone()
{
- return new RTFValue(m_nValue, m_sValue, *m_pAttributes, *m_pSprms, m_xShape, m_xStream, m_bForceString);
+ return new RTFValue(m_nValue, m_sValue, *m_pAttributes, *m_pSprms, m_xShape, m_xStream, m_xObject, m_bForceString);
}
RTFSprms& RTFValue::getAttributes()
diff --git a/writerfilter/source/rtftok/rtfvalue.hxx b/writerfilter/source/rtftok/rtfvalue.hxx
index 8a14ef5..6751126 100644
--- a/writerfilter/source/rtftok/rtfvalue.hxx
+++ b/writerfilter/source/rtftok/rtfvalue.hxx
@@ -30,6 +30,7 @@
#include <resourcemodel/WW8ResourceModel.hxx>
#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
namespace writerfilter {
namespace rtftok {
@@ -41,13 +42,14 @@ namespace writerfilter {
public:
typedef boost::shared_ptr<RTFValue> Pointer_t;
RTFValue(int nValue, rtl::OUString sValue, RTFSprms rAttributes, RTFSprms rSprms, uno::Reference<drawing::XShape> rShape,
- uno::Reference<io::XInputStream> rStream, bool bForceString);
+ uno::Reference<io::XInputStream> rStream, uno::Reference<embed::XEmbeddedObject> rObject, bool bForceString);
RTFValue(int nValue);
RTFValue(rtl::OUString sValue, bool bForce = false);
RTFValue(RTFSprms rAttributes);
RTFValue(RTFSprms rAttributes, RTFSprms rSprms);
RTFValue(uno::Reference<drawing::XShape> rShape);
RTFValue(uno::Reference<io::XInputStream> rStream);
+ RTFValue(uno::Reference<embed::XEmbeddedObject> rObject);
virtual ~RTFValue();
void setString(rtl::OUString sValue);
virtual int getInt() const;
@@ -68,6 +70,7 @@ namespace writerfilter {
boost::shared_ptr<RTFSprms> m_pSprms;
uno::Reference<drawing::XShape> m_xShape;
uno::Reference<io::XInputStream> m_xStream;
+ uno::Reference<embed::XEmbeddedObject> m_xObject;
bool m_bForceString;
};
} // namespace rtftok
More information about the Libreoffice-commits
mailing list