diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-07-14 11:36:32 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2014-07-22 11:43:40 +0200 |
commit | f7a3447deef1bdab3bfd2c000aac3d1a10e4fe5a (patch) | |
tree | 96e3c2b4c0628de9d2320888a6e300fa2228aa0e /sw | |
parent | 477b5bda14c781ec6b2afb3590e4f66c85e1c62a (diff) |
Resolves: fdo#52226 swap in graphics on .docx and .rtf export
(cherry picked from commit 9dd5caac62083f7162d83319284df68ee83e3777)
Conflicts:
sw/source/filter/ww8/docxattributeoutput.cxx
sw/source/filter/ww8/rtfattributeoutput.cxx
sw/source/filter/ww8/wrtww8gr.cxx
Change-Id: Ie818b382c0b17760c720ff2f2c73a3697989f97e
Reviewed-on: https://gerrit.libreoffice.org/10296
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'sw')
-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 205686343ee1..22612f5f3a51 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2757,13 +2757,29 @@ 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(); 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 ); nImageType = XML_embed; diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index f73ab4d4164e..9b3887fffeb9 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -3610,17 +3610,24 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S 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()) @@ -3640,10 +3647,10 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S } } - 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) ? @@ -3654,7 +3661,7 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S } } - 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); @@ -3683,7 +3690,7 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S 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(); @@ -3697,7 +3704,7 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S m_rExport.Strm() << "}" "{" 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(); @@ -3708,6 +3715,9 @@ void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const S m_rExport.Strm() << '}'; } + if (bSwapped) + const_cast<Graphic&>(rGraphic).SwapOut(); + m_rExport.Strm() << SAL_NEWLINE_STRING; } diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx index 61a8c175e7da..5075a896f9ba 100644 --- a/sw/source/filter/ww8/wrtww8gr.cxx +++ b/sw/source/filter/ww8/wrtww8gr.cxx @@ -724,7 +724,7 @@ void SwWW8WrGrf::WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rGrfNd, { Graphic& rGrf = const_cast<Graphic&>(rGrfNd.GetGrf()); bool bSwapped = rGrf.IsSwapOut() ? true : false; - // immer ueber den Node einswappen! + // always swapin via the Node const_cast<SwGrfNode&>(rGrfNd).SwapIn(); GDIMetaFile aMeta; |