diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-07-14 11:36:32 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-07-14 11:48:32 +0100 |
commit | 9dd5caac62083f7162d83319284df68ee83e3777 (patch) | |
tree | e761004d6be6e429ea557d8a8da2366055e8e694 | |
parent | 33fd0d8ae6a6b4e5226991e39fe755d84cb78280 (diff) |
Resolves: fdo#52226 swap in graphics on .docx and .rtf export
Change-Id: Ie818b382c0b17760c720ff2f2c73a3697989f97e
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 18 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 28 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8gr.cxx | 2 |
3 files changed, 37 insertions, 11 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index b6d64afee0ed..30179bbc74b7 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3883,7 +3883,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size // inline, we also have to write the image itself const Graphic* pGraphic = 0; if (pGrfNode) - pGraphic = &const_cast< Graphic& >( pGrfNode->GetGrf() ); + pGraphic = &pGrfNode->GetGrf(); else pGraphic = pOLENode->GetGraphic(); @@ -3894,8 +3894,24 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size { // Not in cache, then need to write it. m_rDrawingML.SetFS( m_pSerializer ); // to be sure that we write to the right stream + + bool bSwapped = pGraphic->IsSwapOut(); + if (bSwapped) + { + if (pGrfNode) + { + // always swapin via the Node + const_cast<SwGrfNode*>(pGrfNode)->SwapIn(); + } + else + const_cast<Graphic*>(pGraphic)->SwapIn(); + } + OUString aImageId = m_rDrawingML.WriteImage( *pGraphic ); + if (bSwapped) + const_cast<Graphic*>(pGraphic)->SwapOut(); + aRelId = OUStringToOString( aImageId, RTL_TEXTENCODING_UTF8 ); m_aRelIdCache[pGraphic] = aRelId; } diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 3ac3a873f23b..482569d5c7af 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -3582,17 +3582,24 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw const sal_uInt8* pGraphicAry = 0; sal_uInt32 nSize = 0; - Graphic aGraphic(pGrfNode->GetGrf()); + const Graphic& rGraphic(pGrfNode->GetGrf()); // If there is no graphic there is not much point in parsing it - if (aGraphic.GetType()==GRAPHIC_NONE) + if (rGraphic.GetType()==GRAPHIC_NONE) return; + bool bSwapped = rGraphic.IsSwapOut(); + if (bSwapped) + { + // always swapin via the Node + const_cast<SwGrfNode*>(pGrfNode)->SwapIn(); + } + GfxLink aGraphicLink; const sal_Char* pBLIPType = 0; - if (aGraphic.IsLink()) + if (rGraphic.IsLink()) { - aGraphicLink = aGraphic.GetLink(); + aGraphicLink = rGraphic.GetLink(); nSize = aGraphicLink.GetDataSize(); pGraphicAry = aGraphicLink.GetData(); switch (aGraphicLink.GetType()) @@ -3625,10 +3632,10 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw } } - GraphicType eGraphicType = aGraphic.GetType(); + GraphicType eGraphicType = rGraphic.GetType(); if (!pGraphicAry) { - if (ERRCODE_NONE == GraphicConverter::Export(aStream, aGraphic, + if (ERRCODE_NONE == GraphicConverter::Export(aStream, rGraphic, (eGraphicType == GRAPHIC_BITMAP) ? CVT_PNG : CVT_WMF)) { pBLIPType = (eGraphicType == GRAPHIC_BITMAP) ? @@ -3639,7 +3646,7 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw } } - Size aMapped(eGraphicType == GRAPHIC_BITMAP ? aGraphic.GetSizePixel() : aGraphic.GetPrefSize()); + Size aMapped(eGraphicType == GRAPHIC_BITMAP ? rGraphic.GetSizePixel() : rGraphic.GetPrefSize()); const SwCropGrf& rCr = (const SwCropGrf&)pGrfNode->GetAttr(RES_GRFATR_CROPGRF); @@ -3668,7 +3675,7 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw else { aStream.Seek(0); - GraphicConverter::Export(aStream, aGraphic, CVT_WMF); + GraphicConverter::Export(aStream, rGraphic, CVT_WMF); pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE; aStream.Seek(STREAM_SEEK_TO_END); nSize = aStream.Tell(); @@ -3682,7 +3689,7 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw m_rExport.Strm().WriteCharPtr("}" "{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT); aStream.Seek(0); - GraphicConverter::Export(aStream, aGraphic, CVT_WMF); + GraphicConverter::Export(aStream, rGraphic, CVT_WMF); pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE; aStream.Seek(STREAM_SEEK_TO_END); nSize = aStream.Tell(); @@ -3693,6 +3700,9 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw m_rExport.Strm().WriteChar('}'); } + if (bSwapped) + const_cast<Graphic&>(rGraphic).SwapOut(); + m_rExport.Strm().WriteCharPtr(SAL_NEWLINE_STRING); } diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx index 53e9eb5d88fb..c022ad6e2695 100644 --- a/sw/source/filter/ww8/wrtww8gr.cxx +++ b/sw/source/filter/ww8/wrtww8gr.cxx @@ -726,7 +726,7 @@ void SwWW8WrGrf::WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rGrfNd, { Graphic& rGrf = const_cast<Graphic&>(rGrfNd.GetGrf()); bool bSwapped = rGrf.IsSwapOut(); - // immer ueber den Node einswappen! + // always swapin via the Node const_cast<SwGrfNode&>(rGrfNd).SwapIn(); GDIMetaFile aMeta; |