summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-01-15 15:26:43 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-01-21 08:13:49 +0000
commit68d351fff469d0ab75f817a4e217194735258da8 (patch)
treef09be82d59b855a7904536ac0fbd38189639fa0a /oox
parentacc3d942e1db108ebca3e9e0c086ab361acc3695 (diff)
oox: export Math objects to PPTX files
These hit the assert in lcl_StoreOwnAsOOXML now so better implement some export. (cherry picked from commit cb890ae43bacd2be24bc74fad2e2e5cce8910995) ugh, forgot to git add the test document (cherry picked from commit fc4fba0c77c849cf19d9c0e1b9270b745db60b89) Change-Id: I10c005a547e8a85f2a82198a49f9a03fc46a61d7 Reviewed-on: https://gerrit.libreoffice.org/21495 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/shapes.cxx67
1 files changed, 64 insertions, 3 deletions
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 7558feb4d5e3..c3b8b8e9353e 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -93,6 +93,7 @@
#include <editeng/svxenum.hxx>
#include <svx/unoapi.hxx>
#include <oox/export/chartexport.hxx>
+#include <oox/mathml/export.hxx>
using namespace ::css;
using namespace ::css::beans;
@@ -1579,13 +1580,64 @@ ShapeExport& ShapeExport::WriteTextShape( Reference< XShape > xShape )
return *this;
}
+void ShapeExport::WriteMathShape(Reference<XShape> const& xShape)
+{
+ Reference<XPropertySet> const xPropSet(xShape, UNO_QUERY);
+ assert(xPropSet.is());
+ Reference<XModel> xMathModel;
+ xPropSet->getPropertyValue("Model") >>= xMathModel;
+ assert(xMathModel.is());
+ assert(GetDocumentType() != DOCUMENT_DOCX); // should be written in DocxAttributeOutput
+ SAL_WARN_IF(GetDocumentType() == DOCUMENT_XLSX, "oox", "Math export to XLSX isn't tested, should it happen here?");
+
+ // ECMA standard does not actually allow oMath outside of
+ // WordProcessingML so write a MCE like PPT 2010 does
+ mpFS->startElementNS(XML_mc, XML_AlternateContent, FSEND);
+ mpFS->startElementNS(XML_mc, XML_Choice,
+ FSNS(XML_xmlns, XML_a14), "http://schemas.microsoft.com/office/drawing/2010/main",
+ XML_Requires, "a14",
+ FSEND);
+ mpFS->startElementNS(mnXmlNamespace, XML_sp, FSEND);
+ mpFS->startElementNS(mnXmlNamespace, XML_nvSpPr, FSEND);
+ mpFS->singleElementNS(mnXmlNamespace, XML_cNvPr,
+ XML_id, OString::number(GetNewShapeID(xShape)).getStr(),
+ XML_name, OString("Formula " + OString::number(mnShapeIdMax++)).getStr(),
+ FSEND);
+ mpFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr, XML_txBox, "1", FSEND);
+ mpFS->singleElementNS(mnXmlNamespace, XML_nvPr, FSEND);
+ mpFS->endElementNS(mnXmlNamespace, XML_nvSpPr);
+ mpFS->startElementNS(mnXmlNamespace, XML_spPr, FSEND);
+ WriteShapeTransformation(xShape, XML_a);
+ WritePresetShape("rect");
+ mpFS->endElementNS(mnXmlNamespace, XML_spPr);
+ mpFS->startElementNS(mnXmlNamespace, XML_txBody, FSEND);
+ mpFS->startElementNS(XML_a, XML_bodyPr, FSEND);
+ mpFS->endElementNS(XML_a, XML_bodyPr);
+ mpFS->startElementNS(XML_a, XML_p, FSEND);
+ mpFS->startElementNS(XML_a14, XML_m, FSEND);
+
+ oox::FormulaExportBase *const pMagic(dynamic_cast<oox::FormulaExportBase*>(xMathModel.get()));
+ assert(pMagic);
+ pMagic->writeFormulaOoxml(GetFS(), GetFB()->getVersion(), GetDocumentType());
+
+ mpFS->endElementNS(XML_a14, XML_m);
+ mpFS->endElementNS(XML_a, XML_p);
+ mpFS->endElementNS(mnXmlNamespace, XML_txBody);
+ mpFS->endElementNS(mnXmlNamespace, XML_sp);
+ mpFS->endElementNS(XML_mc, XML_Choice);
+ mpFS->startElementNS(XML_mc, XML_Fallback, FSEND);
+ // TODO: export bitmap shape as fallback
+ mpFS->endElementNS(XML_mc, XML_Fallback);
+ mpFS->endElementNS(XML_mc, XML_AlternateContent);
+}
+
ShapeExport& ShapeExport::WriteOLE2Shape( Reference< XShape > xShape )
{
Reference< XPropertySet > xPropSet( xShape, UNO_QUERY );
if (!xPropSet.is())
return *this;
- bool bIsChart(false);
+ enum { CHART, MATH, OTHER } eType(OTHER);
OUString clsid;
xPropSet->getPropertyValue("CLSID") >>= clsid;
if (!clsid.isEmpty())
@@ -1593,10 +1645,13 @@ ShapeExport& ShapeExport::WriteOLE2Shape( Reference< XShape > xShape )
SvGlobalName aClassID;
bool const isValid = aClassID.MakeId(clsid);
assert(isValid); (void)isValid;
- bIsChart = SotExchange::IsChart(aClassID);
+ if (SotExchange::IsChart(aClassID))
+ eType = CHART;
+ else if (SotExchange::IsMath(aClassID))
+ eType = MATH;
}
- if (bIsChart)
+ if (CHART == eType)
{
Reference< XChartDocument > xChartDoc;
xPropSet->getPropertyValue("Model") >>= xChartDoc;
@@ -1609,6 +1664,12 @@ ShapeExport& ShapeExport::WriteOLE2Shape( Reference< XShape > xShape )
return *this;
}
+ if (MATH == eType)
+ {
+ WriteMathShape(xShape);
+ return *this;
+ }
+
uno::Reference<embed::XEmbeddedObject> const xObj(
xPropSet->getPropertyValue("EmbeddedObject"), uno::UNO_QUERY);