summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-07-27 15:38:54 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-07-27 16:00:13 +0200
commit7c661189f4ed77b691ef3d36dc47eec8dab9b804 (patch)
tree64c205521d1e1515d12ff5c25a7b10101a9bf389 /sw
parentd216c9fcbbbbd5b28912441567c2fa282b284a6a (diff)
implement import/export of RTF_MMATHPICT
to be compatible with readers not understanding RTF_MOMATH Change-Id: I8d6a28b03b740da372558f7aa245592be6ac70b9
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx42
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.hxx2
2 files changed, 39 insertions, 5 deletions
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index eceb6e05466d..73daf8053eef 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3374,7 +3374,7 @@ void RtfAttributeOutput::FlyFrameOLEData( SwOLENode& rOLENode )
}
}
-bool RtfAttributeOutput::FlyFrameOLEMath(SwOLENode& rOLENode)
+bool RtfAttributeOutput::FlyFrameOLEMath(const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize)
{
SAL_INFO("sw.rtf", OSL_THIS_FUNC);
@@ -3386,18 +3386,52 @@ bool RtfAttributeOutput::FlyFrameOLEMath(SwOLENode& rOLENode)
if (!SotExchange::IsMath(aObjName))
return false;
+ m_aRunText->append("{\\mmath");
uno::Reference<util::XCloseable> xClosable(xObj->getComponent(), uno::UNO_QUERY);
oox::FormulaExportBase* pBase = dynamic_cast<oox::FormulaExportBase*>(xClosable.get());
SAL_WARN_IF(!pBase, "sw.rtf", "Math OLE object cannot write out RTF");
if (pBase)
{
- m_aRunText->append("{\\mmath");
OStringBuffer aBuf;
pBase->writeFormulaRtf(aBuf, m_rExport.eCurrentEncoding);
m_aRunText->append(aBuf.makeStringAndClear());
- m_aRunText->append("}");
}
+ // Replacement graphic.
+ m_aRunText->append("{\\mmathPict");
+
+ m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
+ Size aSize(sw::util::GetSwappedInSize(rOLENode));
+ Size aRendered(aSize);
+ aRendered.Width() = rSize.Width();
+ aRendered.Height() = rSize.Height();
+ Graphic* pGraphic = rOLENode.GetGraphic();
+ Size aMapped(pGraphic->GetPrefSize());
+ const SwCropGrf &rCr = (const SwCropGrf &)rOLENode.GetAttr(RES_GRFATR_CROPGRF);
+ const sal_Char* pBLIPType = OOO_STRING_SVTOOLS_RTF_PNGBLIP;
+ const sal_uInt8* pGraphicAry = 0;
+ SvMemoryStream aStream;
+ if (GraphicConverter::Export(aStream, *pGraphic, CVT_PNG) != ERRCODE_NONE)
+ OSL_FAIL("failed to export the graphic");
+ aStream.Seek(STREAM_SEEK_TO_END);
+ sal_uInt32 nSize = aStream.Tell();
+ pGraphicAry = (sal_uInt8*)aStream.GetData();
+ m_aRunText->append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
+ m_aRunText->append("}"); // shppict
+ m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT);
+ pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
+ SvMemoryStream aWmfStream;
+ if (GraphicConverter::Export(aWmfStream, *pGraphic, CVT_WMF) != ERRCODE_NONE)
+ OSL_FAIL("failed to export the graphic");
+ aWmfStream.Seek(STREAM_SEEK_TO_END);
+ nSize = aWmfStream.Tell();
+ pGraphicAry = (sal_uInt8*)aStream.GetData();
+ m_aRunText->append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
+ m_aRunText->append("}"); // nonshppict
+
+ m_aRunText->append("}"); // mmathPict
+ m_aRunText->append("}"); // mmath
+
return true;
}
@@ -3405,7 +3439,7 @@ void RtfAttributeOutput::FlyFrameOLE( const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode&
{
SAL_INFO("sw.rtf", OSL_THIS_FUNC);
- if (FlyFrameOLEMath(rOLENode))
+ if (FlyFrameOLEMath(pFlyFrmFmt, rOLENode, rSize))
return;
SvMemoryStream aStream;
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index aa2d85dac137..dc97001cbb4f 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -421,7 +421,7 @@ private:
void FlyFrameOLE( const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize );
void FlyFrameOLEData( SwOLENode& rOLENode );
/// Math export.
- bool FlyFrameOLEMath(SwOLENode& rOLENode);
+ bool FlyFrameOLEMath(const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize);
/*
* Table methods.