svx/source/svdraw/svdoashp.cxx | 19 - sw/source/core/doc/docbm.cxx | 9 sw/source/filter/ww8/rtfsdrexport.cxx | 565 +++++++++++++++++----------------- sw/source/filter/ww8/rtfsdrexport.hxx | 26 - 4 files changed, 315 insertions(+), 304 deletions(-)
New commits: commit 1a4d24b3a430ed7f75e76e64fb0e22d05a1fad0d Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sun May 11 18:24:44 2014 +0200 sw: fix indentation in rtfsdrexport Change-Id: I5499007c88659b2d235c765ba352e2bc4a8a3eb8 diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index c64629c..34fa98e 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -33,18 +33,18 @@ using namespace sw::util; using namespace css; -RtfSdrExport::RtfSdrExport( RtfExport &rExport ) - : EscherEx( EscherExGlobalRef( new EscherExGlobal ), 0 ), - m_rExport( rExport ), - m_rAttrOutput( (RtfAttributeOutput&)m_rExport.AttrOutput() ), - m_pSdrObject( NULL ), - m_nShapeType( ESCHER_ShpInst_Nil ), - m_nShapeFlags ( 0 ) , - m_pShapeStyle( new OStringBuffer( 200 ) ), - m_pShapeTypeWritten( new bool[ ESCHER_ShpInst_COUNT ] ) +RtfSdrExport::RtfSdrExport(RtfExport& rExport) + : EscherEx(EscherExGlobalRef(new EscherExGlobal), 0), + m_rExport(rExport), + m_rAttrOutput((RtfAttributeOutput&)m_rExport.AttrOutput()), + m_pSdrObject(NULL), + m_nShapeType(ESCHER_ShpInst_Nil), + m_nShapeFlags(0) , + m_pShapeStyle(new OStringBuffer(200)), + m_pShapeTypeWritten(new bool[ ESCHER_ShpInst_COUNT ]) { mnGroupLevel = 1; - memset( m_pShapeTypeWritten, 0, ESCHER_ShpInst_COUNT * sizeof( bool ) ); + memset(m_pShapeTypeWritten, 0, ESCHER_ShpInst_COUNT * sizeof(bool)); } RtfSdrExport::~RtfSdrExport() @@ -54,18 +54,18 @@ RtfSdrExport::~RtfSdrExport() delete[] m_pShapeTypeWritten, m_pShapeTypeWritten = NULL; } -void RtfSdrExport::OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance ) +void RtfSdrExport::OpenContainer(sal_uInt16 nEscherContainer, int nRecInstance) { SAL_INFO("sw.rtf", OSL_THIS_FUNC); - EscherEx::OpenContainer( nEscherContainer, nRecInstance ); + EscherEx::OpenContainer(nEscherContainer, nRecInstance); - if ( nEscherContainer == ESCHER_SpContainer ) + if (nEscherContainer == ESCHER_SpContainer) { m_nShapeType = ESCHER_ShpInst_Nil; - if ( !m_pShapeStyle->isEmpty() ) + if (!m_pShapeStyle->isEmpty()) m_pShapeStyle->makeStringAndClear(); - m_pShapeStyle->ensureCapacity( 200 ); + m_pShapeStyle->ensureCapacity(200); m_aShapeProps.clear(); } } @@ -74,11 +74,11 @@ void RtfSdrExport::CloseContainer() { SAL_INFO("sw.rtf", OSL_THIS_FUNC); - if ( mRecTypes.back() == ESCHER_SpContainer ) + if (mRecTypes.back() == ESCHER_SpContainer) { // write the shape now when we have all the info sal_Int32 nShapeElement = StartShape(); - EndShape( nShapeElement ); + EndShape(nShapeElement); // cleanup m_nShapeType = ESCHER_ShpInst_Nil; @@ -87,7 +87,7 @@ void RtfSdrExport::CloseContainer() EscherEx::CloseContainer(); } -sal_uInt32 RtfSdrExport::EnterGroup( const OUString& /*rShapeName*/, const Rectangle* /*pRect*/ ) +sal_uInt32 RtfSdrExport::EnterGroup(const OUString& /*rShapeName*/, const Rectangle* /*pRect*/) { SAL_INFO("sw.rtf", OSL_THIS_FUNC); @@ -101,7 +101,7 @@ void RtfSdrExport::LeaveGroup() /* noop */ } -void RtfSdrExport::AddShape( sal_uInt32 nShapeType, sal_uInt32 nShapeFlags, sal_uInt32 /*nShapeId*/ ) +void RtfSdrExport::AddShape(sal_uInt32 nShapeType, sal_uInt32 nShapeFlags, sal_uInt32 /*nShapeId*/) { SAL_INFO("sw.rtf", OSL_THIS_FUNC); @@ -109,30 +109,30 @@ void RtfSdrExport::AddShape( sal_uInt32 nShapeType, sal_uInt32 nShapeFlags, sal_ m_nShapeFlags = nShapeFlags; } -inline sal_uInt16 impl_GetUInt16( const sal_uInt8* &pVal ) +inline sal_uInt16 impl_GetUInt16(const sal_uInt8*& pVal) { sal_uInt16 nRet = *pVal++; - nRet += ( *pVal++ ) << 8; + nRet += (*pVal++) << 8; return nRet; } -inline sal_Int32 impl_GetPointComponent( const sal_uInt8* &pVal, sal_Size& rVerticesPos, sal_uInt16 nPointSize ) +inline sal_Int32 impl_GetPointComponent(const sal_uInt8*& pVal, sal_Size& rVerticesPos, sal_uInt16 nPointSize) { sal_Int32 nRet = 0; - if ( ( nPointSize == 0xfff0 ) || ( nPointSize == 4 ) ) + if ((nPointSize == 0xfff0) || (nPointSize == 4)) { sal_uInt16 nUnsigned = *pVal++; - nUnsigned += ( *pVal++ ) << 8; + nUnsigned += (*pVal++) << 8; rVerticesPos += 2; - nRet = sal_Int16( nUnsigned ); + nRet = sal_Int16(nUnsigned); } - else if ( nPointSize == 8 ) + else if (nPointSize == 8) { sal_uInt32 nUnsigned = *pVal++; - nUnsigned += ( *pVal++ ) << 8; - nUnsigned += ( *pVal++ ) << 16; - nUnsigned += ( *pVal++ ) << 24; + nUnsigned += (*pVal++) << 8; + nUnsigned += (*pVal++) << 16; + nUnsigned += (*pVal++) << 24; rVerticesPos += 4; nRet = nUnsigned; @@ -141,273 +141,283 @@ inline sal_Int32 impl_GetPointComponent( const sal_uInt8* &pVal, sal_Size& rVert return nRet; } -void RtfSdrExport::Commit( EscherPropertyContainer& rProps, const Rectangle& rRect ) +void RtfSdrExport::Commit(EscherPropertyContainer& rProps, const Rectangle& rRect) { SAL_INFO("sw.rtf", OSL_THIS_FUNC); - if ( m_nShapeType == ESCHER_ShpInst_Nil ) + if (m_nShapeType == ESCHER_ShpInst_Nil) return; - if ( m_nShapeType == ESCHER_ShpInst_Line ) - AddLineDimensions( rRect ); + if (m_nShapeType == ESCHER_ShpInst_Line) + AddLineDimensions(rRect); else - AddRectangleDimensions( *m_pShapeStyle, rRect ); + AddRectangleDimensions(*m_pShapeStyle, rRect); // properties - const EscherProperties &rOpts = rProps.GetOpts(); - for ( EscherProperties::const_iterator it = rOpts.begin(); it != rOpts.end(); ++it ) + const EscherProperties& rOpts = rProps.GetOpts(); + for (EscherProperties::const_iterator it = rOpts.begin(); it != rOpts.end(); ++it) { - sal_uInt16 nId = ( it->nPropId & 0x0FFF ); + sal_uInt16 nId = (it->nPropId & 0x0FFF); - switch ( nId ) + switch (nId) { - case ESCHER_Prop_WrapText: - { - int nWrapType = 0; - switch ( it->nPropValue ) - { - case ESCHER_WrapSquare: nWrapType = 2; break; - case ESCHER_WrapByPoints: nWrapType = 4; break; - case ESCHER_WrapNone: nWrapType = 3; break; - case ESCHER_WrapTopBottom: nWrapType = 1; break; - case ESCHER_WrapThrough: nWrapType = 5; break; - } - if ( nWrapType ) - m_pShapeStyle->append(OOO_STRING_SVTOOLS_RTF_SHPWR).append((sal_Int32)nWrapType); - } - break; - case ESCHER_Prop_fillColor: - m_aShapeProps.insert(std::pair<OString,OString>("fillColor", OString::number(it->nPropValue))); - break; - case ESCHER_Prop_fillBackColor: - m_aShapeProps.insert(std::pair<OString,OString>("fillBackColor", OString::number(it->nPropValue))); - break; - case ESCHER_Prop_AnchorText: - m_aShapeProps.insert(std::pair<OString,OString>("anchorText", OString::number(it->nPropValue))); - break; - case ESCHER_Prop_fNoFillHitTest: - if (it->nPropValue) - m_aShapeProps.insert(std::pair<OString,OString>("fNoFillHitTest", OString::number(1))); - break; - case ESCHER_Prop_fNoLineDrawDash: - // for some reason the value is set to 0x90000 if lines are switched off - if( it->nPropValue == 0x90000 ) - m_aShapeProps.insert(std::pair<OString,OString>("fLine", OString::number(0))); + case ESCHER_Prop_WrapText: + { + int nWrapType = 0; + switch (it->nPropValue) + { + case ESCHER_WrapSquare: + nWrapType = 2; break; - case ESCHER_Prop_lineColor: - m_aShapeProps.insert(std::pair<OString,OString>("lineColor", OString::number(it->nPropValue))); + case ESCHER_WrapByPoints: + nWrapType = 4; break; - case ESCHER_Prop_lineBackColor: - m_aShapeProps.insert(std::pair<OString,OString>("lineBackColor", OString::number(it->nPropValue))); + case ESCHER_WrapNone: + nWrapType = 3; break; - case ESCHER_Prop_lineJoinStyle: - m_aShapeProps.insert(std::pair<OString,OString>("lineJoinStyle", OString::number(it->nPropValue))); + case ESCHER_WrapTopBottom: + nWrapType = 1; break; - case ESCHER_Prop_fshadowObscured: - if (it->nPropValue) - m_aShapeProps.insert(std::pair<OString,OString>("fshadowObscured", "1")); + case ESCHER_WrapThrough: + nWrapType = 5; break; - case ESCHER_Prop_geoLeft: - case ESCHER_Prop_geoTop: - { - sal_uInt32 nLeft = 0, nTop = 0; + } + if (nWrapType) + m_pShapeStyle->append(OOO_STRING_SVTOOLS_RTF_SHPWR).append((sal_Int32)nWrapType); + } + break; + case ESCHER_Prop_fillColor: + m_aShapeProps.insert(std::pair<OString,OString>("fillColor", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_fillBackColor: + m_aShapeProps.insert(std::pair<OString,OString>("fillBackColor", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_AnchorText: + m_aShapeProps.insert(std::pair<OString,OString>("anchorText", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_fNoFillHitTest: + if (it->nPropValue) + m_aShapeProps.insert(std::pair<OString,OString>("fNoFillHitTest", OString::number(1))); + break; + case ESCHER_Prop_fNoLineDrawDash: + // for some reason the value is set to 0x90000 if lines are switched off + if (it->nPropValue == 0x90000) + m_aShapeProps.insert(std::pair<OString,OString>("fLine", OString::number(0))); + break; + case ESCHER_Prop_lineColor: + m_aShapeProps.insert(std::pair<OString,OString>("lineColor", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_lineBackColor: + m_aShapeProps.insert(std::pair<OString,OString>("lineBackColor", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_lineJoinStyle: + m_aShapeProps.insert(std::pair<OString,OString>("lineJoinStyle", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_fshadowObscured: + if (it->nPropValue) + m_aShapeProps.insert(std::pair<OString,OString>("fshadowObscured", "1")); + break; + case ESCHER_Prop_geoLeft: + case ESCHER_Prop_geoTop: + { + sal_uInt32 nLeft = 0, nTop = 0; - if ( nId == ESCHER_Prop_geoLeft ) - { - nLeft = it->nPropValue; - rProps.GetOpt( ESCHER_Prop_geoTop, nTop ); - } - else - { - nTop = it->nPropValue; - rProps.GetOpt( ESCHER_Prop_geoLeft, nLeft ); - } + if (nId == ESCHER_Prop_geoLeft) + { + nLeft = it->nPropValue; + rProps.GetOpt(ESCHER_Prop_geoTop, nTop); + } + else + { + nTop = it->nPropValue; + rProps.GetOpt(ESCHER_Prop_geoLeft, nLeft); + } - m_aShapeProps.insert(std::pair<OString,OString>("geoLeft", - OString::number(sal_Int32( nLeft )))); - m_aShapeProps.insert(std::pair<OString,OString>("geoTop", - OString::number(sal_Int32( nTop )))); - } - break; + m_aShapeProps.insert(std::pair<OString,OString>("geoLeft", + OString::number(sal_Int32(nLeft)))); + m_aShapeProps.insert(std::pair<OString,OString>("geoTop", + OString::number(sal_Int32(nTop)))); + } + break; - case ESCHER_Prop_geoRight: - case ESCHER_Prop_geoBottom: - { - sal_uInt32 nLeft = 0, nRight = 0, nTop = 0, nBottom = 0; - rProps.GetOpt( ESCHER_Prop_geoLeft, nLeft ); - rProps.GetOpt( ESCHER_Prop_geoTop, nTop ); + case ESCHER_Prop_geoRight: + case ESCHER_Prop_geoBottom: + { + sal_uInt32 nLeft = 0, nRight = 0, nTop = 0, nBottom = 0; + rProps.GetOpt(ESCHER_Prop_geoLeft, nLeft); + rProps.GetOpt(ESCHER_Prop_geoTop, nTop); - if ( nId == ESCHER_Prop_geoRight ) - { - nRight = it->nPropValue; - rProps.GetOpt( ESCHER_Prop_geoBottom, nBottom ); - } - else - { - nBottom = it->nPropValue; - rProps.GetOpt( ESCHER_Prop_geoRight, nRight ); - } + if (nId == ESCHER_Prop_geoRight) + { + nRight = it->nPropValue; + rProps.GetOpt(ESCHER_Prop_geoBottom, nBottom); + } + else + { + nBottom = it->nPropValue; + rProps.GetOpt(ESCHER_Prop_geoRight, nRight); + } - m_aShapeProps.insert(std::pair<OString,OString>("geoRight", - OString::number(sal_Int32( nRight ) - sal_Int32( nLeft )))); - m_aShapeProps.insert(std::pair<OString,OString>("geoBottom", - OString::number(sal_Int32( nBottom ) - sal_Int32( nTop )))); - } - break; - case ESCHER_Prop_pVertices: - case ESCHER_Prop_pSegmentInfo: - { - EscherPropSortStruct aVertices; - EscherPropSortStruct aSegments; + m_aShapeProps.insert(std::pair<OString,OString>("geoRight", + OString::number(sal_Int32(nRight) - sal_Int32(nLeft)))); + m_aShapeProps.insert(std::pair<OString,OString>("geoBottom", + OString::number(sal_Int32(nBottom) - sal_Int32(nTop)))); + } + break; + case ESCHER_Prop_pVertices: + case ESCHER_Prop_pSegmentInfo: + { + EscherPropSortStruct aVertices; + EscherPropSortStruct aSegments; - if ( rProps.GetOpt( ESCHER_Prop_pVertices, aVertices ) && - rProps.GetOpt( ESCHER_Prop_pSegmentInfo, aSegments ) ) - { - const sal_uInt8 *pVerticesIt = aVertices.pBuf + 6; - sal_Size nVerticesPos = 6; - const sal_uInt8 *pSegmentIt = aSegments.pBuf; + if (rProps.GetOpt(ESCHER_Prop_pVertices, aVertices) && + rProps.GetOpt(ESCHER_Prop_pSegmentInfo, aSegments)) + { + const sal_uInt8* pVerticesIt = aVertices.pBuf + 6; + sal_Size nVerticesPos = 6; + const sal_uInt8* pSegmentIt = aSegments.pBuf; - OStringBuffer aSegmentInfo( 512 ); - OStringBuffer aVerticies( 512 ); + OStringBuffer aSegmentInfo(512); + OStringBuffer aVerticies(512); - sal_uInt16 nPointSize = aVertices.pBuf[4] + ( aVertices.pBuf[5] << 8 ); + sal_uInt16 nPointSize = aVertices.pBuf[4] + (aVertices.pBuf[5] << 8); - // number of segments - sal_uInt16 nSegments = impl_GetUInt16( pSegmentIt ); - sal_Int32 nVertices = 0; - aSegmentInfo.append("2;").append((sal_Int32)nSegments); - pSegmentIt += 4; + // number of segments + sal_uInt16 nSegments = impl_GetUInt16(pSegmentIt); + sal_Int32 nVertices = 0; + aSegmentInfo.append("2;").append((sal_Int32)nSegments); + pSegmentIt += 4; - for ( ; nSegments; --nSegments ) + for (; nSegments; --nSegments) + { + sal_uInt16 nSeg = impl_GetUInt16(pSegmentIt); + aSegmentInfo.append(';').append((sal_Int32)nSeg); + switch (nSeg) + { + case 0x0001: // lineto + case 0x4000: // moveto + { + sal_Int32 nX = impl_GetPointComponent(pVerticesIt, nVerticesPos, nPointSize); + sal_Int32 nY = impl_GetPointComponent(pVerticesIt, nVerticesPos, nPointSize); + aVerticies.append(";(").append(nX).append(",").append(nY).append(")"); + nVertices ++; + } + break; + case 0x2001: // curveto + { + for (int i = 0; i < 3; i++) { - sal_uInt16 nSeg = impl_GetUInt16( pSegmentIt ); - aSegmentInfo.append(';').append((sal_Int32)nSeg); - switch ( nSeg ) - { - case 0x0001: // lineto - case 0x4000: // moveto - { - sal_Int32 nX = impl_GetPointComponent( pVerticesIt, nVerticesPos, nPointSize ); - sal_Int32 nY = impl_GetPointComponent( pVerticesIt, nVerticesPos, nPointSize ); - aVerticies.append( ";(" ).append( nX ).append( "," ).append( nY ).append( ")" ); - nVertices ++; - } - break; - case 0x2001: // curveto - { - for (int i = 0; i < 3; i++) - { - sal_Int32 nX = impl_GetPointComponent( pVerticesIt, nVerticesPos, nPointSize ); - sal_Int32 nY = impl_GetPointComponent( pVerticesIt, nVerticesPos, nPointSize ); - aVerticies.append( ";(" ).append( nX ).append( "," ).append( nY ).append( ")" ); - nVertices ++; - } - } - break; - case 0xb300: - case 0xac00: - case 0xaa00: // nofill - case 0xab00: // nostroke - case 0x6001: // close - case 0x8000: // end - break; - default: - // See EscherPropertyContainer::CreateCustomShapeProperties, by default nSeg is simply the number of points. - for (int i = 0; i < nSeg; ++i) - { - if (nVerticesPos >= aVertices.nPropSize) - break; - sal_Int32 nX = impl_GetPointComponent(pVerticesIt, nVerticesPos, nPointSize); - sal_Int32 nY = impl_GetPointComponent(pVerticesIt, nVerticesPos, nPointSize); - aVerticies.append(";(").append(nX).append(",").append(nY).append(")"); - ++nVertices; - } - break; - } + sal_Int32 nX = impl_GetPointComponent(pVerticesIt, nVerticesPos, nPointSize); + sal_Int32 nY = impl_GetPointComponent(pVerticesIt, nVerticesPos, nPointSize); + aVerticies.append(";(").append(nX).append(",").append(nY).append(")"); + nVertices ++; } - - if (!aVerticies.isEmpty() ) + } + break; + case 0xb300: + case 0xac00: + case 0xaa00: // nofill + case 0xab00: // nostroke + case 0x6001: // close + case 0x8000: // end + break; + default: + // See EscherPropertyContainer::CreateCustomShapeProperties, by default nSeg is simply the number of points. + for (int i = 0; i < nSeg; ++i) { - // We know the number of vertices at the end only, so we have to prepend them here. - m_aShapeProps.insert(std::pair<OString,OString>("pVerticies", "8;" + OString::number(nVertices) + aVerticies.makeStringAndClear())); + if (nVerticesPos >= aVertices.nPropSize) + break; + sal_Int32 nX = impl_GetPointComponent(pVerticesIt, nVerticesPos, nPointSize); + sal_Int32 nY = impl_GetPointComponent(pVerticesIt, nVerticesPos, nPointSize); + aVerticies.append(";(").append(nX).append(",").append(nY).append(")"); + ++nVertices; } - if ( !aSegmentInfo.isEmpty() ) - m_aShapeProps.insert(std::pair<OString,OString>("pSegmentInfo", aSegmentInfo.makeStringAndClear())); + break; } - else - SAL_INFO("sw.rtf", OSL_THIS_FUNC << ": unhandled shape path, missing either pVertices or pSegmentInfo"); } - break; - case ESCHER_Prop_shapePath: - // noop, we use pSegmentInfo instead - break; - case ESCHER_Prop_fFillOK: - if (!it->nPropValue) - m_aShapeProps.insert(std::pair<OString,OString>("fFillOK", "0")); - break; - case ESCHER_Prop_dxTextLeft: - m_aShapeProps.insert(std::pair<OString,OString>("dxTextLeft", OString::number(it->nPropValue))); - break; - case ESCHER_Prop_dyTextTop: - m_aShapeProps.insert(std::pair<OString,OString>("dyTextTop", OString::number(it->nPropValue))); - break; - case ESCHER_Prop_dxTextRight: - m_aShapeProps.insert(std::pair<OString,OString>("dxTextRight", OString::number(it->nPropValue))); - break; - case ESCHER_Prop_dyTextBottom: - m_aShapeProps.insert(std::pair<OString,OString>("dyTextBottom", OString::number(it->nPropValue))); - break; - case ESCHER_Prop_FitTextToShape: - // Size text to fit shape size: not supported by RTF - break; - case ESCHER_Prop_adjustValue: - m_aShapeProps.insert(std::pair<OString,OString>("adjustValue", OString::number(it->nPropValue))); - break; - case ESCHER_Prop_txflTextFlow: - m_aShapeProps.insert(std::pair<OString,OString>("txflTextFlow", OString::number(it->nPropValue))); - break; - case ESCHER_Prop_fillType: - m_aShapeProps.insert(std::pair<OString,OString>("fillType", OString::number(it->nPropValue))); - break; - case ESCHER_Prop_fillOpacity: - m_aShapeProps.insert(std::pair<OString,OString>("fillOpacity", OString::number(it->nPropValue))); - break; - case ESCHER_Prop_fillBlip: + + if (!aVerticies.isEmpty()) { - OStringBuffer aBuf; - aBuf.append('{').append(OOO_STRING_SVTOOLS_RTF_PICT).append(OOO_STRING_SVTOOLS_RTF_PNGBLIP).append(SAL_NEWLINE_STRING); - int nHeaderSize = 25; // The first bytes are WW8-specific, we're only interested in the PNG - aBuf.append(RtfAttributeOutput::WriteHex(it->pBuf + nHeaderSize, it->nPropSize - nHeaderSize)); - aBuf.append('}'); - m_aShapeProps.insert(std::pair<OString,OString>("fillBlip", aBuf.makeStringAndClear())); + // We know the number of vertices at the end only, so we have to prepend them here. + m_aShapeProps.insert(std::pair<OString,OString>("pVerticies", "8;" + OString::number(nVertices) + aVerticies.makeStringAndClear())); } - break; - default: - SAL_INFO("sw.rtf", OSL_THIS_FUNC << ": unhandled property: " << nId << " (value: " << it->nPropValue << ")"); - break; + if (!aSegmentInfo.isEmpty()) + m_aShapeProps.insert(std::pair<OString,OString>("pSegmentInfo", aSegmentInfo.makeStringAndClear())); + } + else + SAL_INFO("sw.rtf", OSL_THIS_FUNC << ": unhandled shape path, missing either pVertices or pSegmentInfo"); + } + break; + case ESCHER_Prop_shapePath: + // noop, we use pSegmentInfo instead + break; + case ESCHER_Prop_fFillOK: + if (!it->nPropValue) + m_aShapeProps.insert(std::pair<OString,OString>("fFillOK", "0")); + break; + case ESCHER_Prop_dxTextLeft: + m_aShapeProps.insert(std::pair<OString,OString>("dxTextLeft", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_dyTextTop: + m_aShapeProps.insert(std::pair<OString,OString>("dyTextTop", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_dxTextRight: + m_aShapeProps.insert(std::pair<OString,OString>("dxTextRight", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_dyTextBottom: + m_aShapeProps.insert(std::pair<OString,OString>("dyTextBottom", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_FitTextToShape: + // Size text to fit shape size: not supported by RTF + break; + case ESCHER_Prop_adjustValue: + m_aShapeProps.insert(std::pair<OString,OString>("adjustValue", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_txflTextFlow: + m_aShapeProps.insert(std::pair<OString,OString>("txflTextFlow", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_fillType: + m_aShapeProps.insert(std::pair<OString,OString>("fillType", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_fillOpacity: + m_aShapeProps.insert(std::pair<OString,OString>("fillOpacity", OString::number(it->nPropValue))); + break; + case ESCHER_Prop_fillBlip: + { + OStringBuffer aBuf; + aBuf.append('{').append(OOO_STRING_SVTOOLS_RTF_PICT).append(OOO_STRING_SVTOOLS_RTF_PNGBLIP).append(SAL_NEWLINE_STRING); + int nHeaderSize = 25; // The first bytes are WW8-specific, we're only interested in the PNG + aBuf.append(RtfAttributeOutput::WriteHex(it->pBuf + nHeaderSize, it->nPropSize - nHeaderSize)); + aBuf.append('}'); + m_aShapeProps.insert(std::pair<OString,OString>("fillBlip", aBuf.makeStringAndClear())); + } + break; + default: + SAL_INFO("sw.rtf", OSL_THIS_FUNC << ": unhandled property: " << nId << " (value: " << it->nPropValue << ")"); + break; } } } -void RtfSdrExport::AddLineDimensions( const Rectangle& rRectangle ) +void RtfSdrExport::AddLineDimensions(const Rectangle& rRectangle) { SAL_INFO("sw.rtf", OSL_THIS_FUNC); // We get the position relative to (the current?) character m_aShapeProps.insert(std::pair<OString,OString>("posrelh", "3")); - switch ( m_nShapeFlags & 0xC0 ) + switch (m_nShapeFlags & 0xC0) { - case 0x40: - m_aShapeProps.insert(std::pair<OString,OString>("fFlipV", "1")); - break; - case 0x80: - m_aShapeProps.insert(std::pair<OString,OString>("fFlipH", "1")); - break; - case 0xC0: - m_aShapeProps.insert(std::pair<OString,OString>("fFlipV", "1")); - m_aShapeProps.insert(std::pair<OString,OString>("fFlipH", "1")); - break; + case 0x40: + m_aShapeProps.insert(std::pair<OString,OString>("fFlipV", "1")); + break; + case 0x80: + m_aShapeProps.insert(std::pair<OString,OString>("fFlipH", "1")); + break; + case 0xC0: + m_aShapeProps.insert(std::pair<OString,OString>("fFlipV", "1")); + m_aShapeProps.insert(std::pair<OString,OString>("fFlipH", "1")); + break; } // the actual dimensions @@ -417,7 +427,7 @@ void RtfSdrExport::AddLineDimensions( const Rectangle& rRectangle ) m_pShapeStyle->append(OOO_STRING_SVTOOLS_RTF_SHPBOTTOM).append(rRectangle.Bottom()); } -void RtfSdrExport::AddRectangleDimensions( OStringBuffer& rBuffer, const Rectangle& rRectangle ) +void RtfSdrExport::AddRectangleDimensions(OStringBuffer& rBuffer, const Rectangle& rRectangle) { SAL_INFO("sw.rtf", OSL_THIS_FUNC); @@ -432,12 +442,12 @@ void RtfSdrExport::AddRectangleDimensions( OStringBuffer& rBuffer, const Rectang extern const char* pShapeTypes[]; -static void lcl_AppendSP( OStringBuffer& rRunText, const char cName[], const OString& rValue) +static void lcl_AppendSP(OStringBuffer& rRunText, const char cName[], const OString& rValue) { rRunText.append('{').append(OOO_STRING_SVTOOLS_RTF_SP) - .append('{').append(OOO_STRING_SVTOOLS_RTF_SN " ").append(cName).append('}') - .append('{').append(OOO_STRING_SVTOOLS_RTF_SV " ").append(rValue).append('}') - .append('}'); + .append('{').append(OOO_STRING_SVTOOLS_RTF_SN " ").append(cName).append('}') + .append('{').append(OOO_STRING_SVTOOLS_RTF_SV " ").append(rValue).append('}') + .append('}'); } void RtfSdrExport::impl_writeGraphic() @@ -483,7 +493,7 @@ sal_Int32 RtfSdrExport::StartShape() { SAL_INFO("sw.rtf", OSL_THIS_FUNC); - if ( m_nShapeType == ESCHER_ShpInst_Nil ) + if (m_nShapeType == ESCHER_ShpInst_Nil) return -1; m_aShapeProps.insert(std::pair<OString,OString>("shapeType", OString::number(m_nShapeType))); @@ -499,11 +509,11 @@ sal_Int32 RtfSdrExport::StartShape() // Ignore \shpbypage, \shpbymargin, and \shpbycolumn, in favor of the posrelh property. m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE); - for(std::map<OString,OString>::reverse_iterator i = m_aShapeProps.rbegin(); i != m_aShapeProps.rend(); ++i) - lcl_AppendSP(m_rAttrOutput.RunText(), (*i).first.getStr(), (*i).second ); + for (std::map<OString,OString>::reverse_iterator i = m_aShapeProps.rbegin(); i != m_aShapeProps.rend(); ++i) + lcl_AppendSP(m_rAttrOutput.RunText(), (*i).first.getStr(), (*i).second); - lcl_AppendSP(m_rAttrOutput.RunText(), "wzDescription", msfilter::rtfutil::OutString( m_pSdrObject->GetDescription(), m_rExport.eCurrentEncoding)); - lcl_AppendSP(m_rAttrOutput.RunText(), "wzName", msfilter::rtfutil::OutString( m_pSdrObject->GetTitle(), m_rExport.eCurrentEncoding)); + lcl_AppendSP(m_rAttrOutput.RunText(), "wzDescription", msfilter::rtfutil::OutString(m_pSdrObject->GetDescription(), m_rExport.eCurrentEncoding)); + lcl_AppendSP(m_rAttrOutput.RunText(), "wzName", msfilter::rtfutil::OutString(m_pSdrObject->GetTitle(), m_rExport.eCurrentEncoding)); // now check if we have some text const SdrTextObj* pTxtObj = PTR_CAST(SdrTextObj, m_pSdrObject); @@ -527,11 +537,11 @@ sal_Int32 RtfSdrExport::StartShape() pParaObj = pTxtObj->GetOutlinerParaObject(); } - if( pParaObj ) + if (pParaObj) { // this is reached only in case some text is attached to the shape WriteOutliner(*pParaObj); - if( bOwnParaObj ) + if (bOwnParaObj) delete pParaObj; } } @@ -544,36 +554,37 @@ void RtfSdrExport::WriteOutliner(const OutlinerParaObject& rParaObj) SAL_INFO("sw.rtf", OSL_THIS_FUNC << " start"); const EditTextObject& rEditObj = rParaObj.GetTextObject(); - MSWord_SdrAttrIter aAttrIter( m_rExport, rEditObj, TXT_HFTXTBOX ); + MSWord_SdrAttrIter aAttrIter(m_rExport, rEditObj, TXT_HFTXTBOX); sal_Int32 nPara = rEditObj.GetParagraphCount(); m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_SHPTXT).append(' '); for (sal_Int32 n = 0; n < nPara; ++n) { - if( n ) - aAttrIter.NextPara( n ); + if (n) + aAttrIter.NextPara(n); rtl_TextEncoding eChrSet = aAttrIter.GetNodeCharSet(); - OUString aStr( rEditObj.GetText( n )); + OUString aStr(rEditObj.GetText(n)); sal_Int32 nAktPos = 0; const sal_Int32 nEnd = aStr.getLength(); aAttrIter.OutParaAttr(false); m_rAttrOutput.RunText().append(m_rAttrOutput.Styles().makeStringAndClear()); - do { + do + { const sal_Int32 nNextAttr = std::min(aAttrIter.WhereNext(), nEnd); rtl_TextEncoding eNextChrSet = aAttrIter.GetNextCharSet(); - aAttrIter.OutAttr( nAktPos ); + aAttrIter.OutAttr(nAktPos); m_rAttrOutput.RunText().append('{').append(m_rAttrOutput.Styles().makeStringAndClear()).append(SAL_NEWLINE_STRING); - bool bTxtAtr = aAttrIter.IsTxtAttr( nAktPos ); - if( !bTxtAtr ) + bool bTxtAtr = aAttrIter.IsTxtAttr(nAktPos); + if (!bTxtAtr) { - OUString aOut( aStr.copy( nAktPos, nNextAttr - nAktPos ) ); - m_rAttrOutput.RunText().append( msfilter::rtfutil::OutString( aOut, eChrSet ) ); + OUString aOut(aStr.copy(nAktPos, nNextAttr - nAktPos)); + m_rAttrOutput.RunText().append(msfilter::rtfutil::OutString(aOut, eChrSet)); } m_rAttrOutput.RunText().append('}'); @@ -582,25 +593,25 @@ void RtfSdrExport::WriteOutliner(const OutlinerParaObject& rParaObj) eChrSet = eNextChrSet; aAttrIter.NextPos(); } - while( nAktPos < nEnd ); + while (nAktPos < nEnd); } m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_PAR).append('}'); SAL_INFO("sw.rtf", OSL_THIS_FUNC << " end"); } -void RtfSdrExport::EndShape( sal_Int32 nShapeElement ) +void RtfSdrExport::EndShape(sal_Int32 nShapeElement) { SAL_INFO("sw.rtf", OSL_THIS_FUNC); - if ( nShapeElement >= 0 ) + if (nShapeElement >= 0) { // end of the shape m_rAttrOutput.RunText().append('}').append('}'); } } -sal_uInt32 RtfSdrExport::AddSdrObject( const SdrObject& rObj ) +sal_uInt32 RtfSdrExport::AddSdrObject(const SdrObject& rObj) { m_pSdrObject = &rObj; return EscherEx::AddSdrObject(rObj); diff --git a/sw/source/filter/ww8/rtfsdrexport.hxx b/sw/source/filter/ww8/rtfsdrexport.hxx index c2e82d9..449a538 100644 --- a/sw/source/filter/ww8/rtfsdrexport.hxx +++ b/sw/source/filter/ww8/rtfsdrexport.hxx @@ -32,9 +32,9 @@ class RtfAttributeOutput; /// Handles export of drawings using RTF markup class RtfSdrExport : public EscherEx { - RtfExport &m_rExport; + RtfExport& m_rExport; - RtfAttributeOutput &m_rAttrOutput; + RtfAttributeOutput& m_rAttrOutput; const SdrObject* m_pSdrObject; @@ -45,21 +45,21 @@ class RtfSdrExport : public EscherEx sal_uInt32 m_nShapeFlags; /// Remember style, the most important shape attribute ;-) - OStringBuffer *m_pShapeStyle; + OStringBuffer* m_pShapeStyle; std::map<OString,OString> m_aShapeProps; /// Remember which shape types we had already written. - bool *m_pShapeTypeWritten; + bool* m_pShapeTypeWritten; public: - RtfSdrExport( RtfExport &rExport ); + RtfSdrExport(RtfExport& rExport); virtual ~RtfSdrExport(); /// Export the sdr object as Sdr. /// /// Call this when you need to export the object as Sdr in RTF. - sal_uInt32 AddSdrObject( const SdrObject& rObj ); + sal_uInt32 AddSdrObject(const SdrObject& rObj); protected: /// Start the shape for which we just collected the information. @@ -72,26 +72,26 @@ protected: /// /// The parameter is just what we got from StartShape(). using EscherEx::EndShape; - void EndShape( sal_Int32 nShapeElement ); + void EndShape(sal_Int32 nShapeElement); - virtual void Commit( EscherPropertyContainer& rProps, const Rectangle& rRect ) SAL_OVERRIDE; + virtual void Commit(EscherPropertyContainer& rProps, const Rectangle& rRect) SAL_OVERRIDE; private: - virtual void OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance = 0 ) SAL_OVERRIDE; + virtual void OpenContainer(sal_uInt16 nEscherContainer, int nRecInstance = 0) SAL_OVERRIDE; virtual void CloseContainer() SAL_OVERRIDE; - virtual sal_uInt32 EnterGroup( const OUString& rShapeName, const Rectangle* pBoundRect = 0 ) SAL_OVERRIDE; + virtual sal_uInt32 EnterGroup(const OUString& rShapeName, const Rectangle* pBoundRect = 0) SAL_OVERRIDE; virtual void LeaveGroup() SAL_OVERRIDE; - virtual void AddShape( sal_uInt32 nShapeType, sal_uInt32 nShapeFlags, sal_uInt32 nShapeId = 0 ) SAL_OVERRIDE; + virtual void AddShape(sal_uInt32 nShapeType, sal_uInt32 nShapeFlags, sal_uInt32 nShapeId = 0) SAL_OVERRIDE; private: /// Add starting and ending point of a line to the m_pShapeAttrList. - void AddLineDimensions( const Rectangle& rRectangle ); + void AddLineDimensions(const Rectangle& rRectangle); /// Add position and size to the OStringBuffer. - void AddRectangleDimensions( OStringBuffer& rBuffer, const Rectangle& rRectangle ); + void AddRectangleDimensions(OStringBuffer& rBuffer, const Rectangle& rRectangle); void WriteOutliner(const OutlinerParaObject& rParaObj); commit b05778b9c0e21e3b8fd9d8baa03864e6f0b9b407 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sun May 11 18:23:25 2014 +0200 coverity#704860 Unchecked dynamic_cast Change-Id: I4a6cf43eaf9626bdb1d486476d3e797fcab5ab13 diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 8da3bb1..45a00d6 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -541,9 +541,12 @@ namespace sw { namespace mark return true; if ( findMark(rNewName) != m_vAllMarks.end() ) return false; - m_aMarkNamesSet.erase(dynamic_cast< ::sw::mark::MarkBase* >(io_pMark)->GetName()); - m_aMarkNamesSet.insert(rNewName); - dynamic_cast< ::sw::mark::MarkBase* >(io_pMark)->SetName(rNewName); + if (::sw::mark::MarkBase* pMarkBase = dynamic_cast< ::sw::mark::MarkBase* >(io_pMark)) + { + m_aMarkNamesSet.erase(pMarkBase->GetName()); + m_aMarkNamesSet.insert(rNewName); + pMarkBase->SetName(rNewName); + } return true; } commit 01a4dba8e9a43791d4f472d6c473398aee5034fe Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sun May 11 18:18:15 2014 +0200 SdrObjCustomShape::GetCustomShapeEngine: aEngine can't be empty at this point Change-Id: I7c656c461ab6bdf53d14ec5804ac82e219c0aef1 diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index c08039f..8f7b0e2 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -419,17 +419,14 @@ Reference< XCustomShapeEngine > SdrObjCustomShape::GetCustomShapeEngine() const Reference< XShape > aXShape = GetXShapeForSdrObject(const_cast<SdrObjCustomShape*>(this)); if ( aXShape.is() ) { - if ( !aEngine.isEmpty() ) - { - Sequence< Any > aArgument( 1 ); - Sequence< PropertyValue > aPropValues( 1 ); - aPropValues[ 0 ].Name = "CustomShape"; - aPropValues[ 0 ].Value <<= aXShape; - aArgument[ 0 ] <<= aPropValues; - Reference< XInterface > xInterface( xContext->getServiceManager()->createInstanceWithArgumentsAndContext( aEngine, aArgument, xContext ) ); - if ( xInterface.is() ) - mxCustomShapeEngine = Reference< XCustomShapeEngine >( xInterface, UNO_QUERY ); - } + Sequence< Any > aArgument( 1 ); + Sequence< PropertyValue > aPropValues( 1 ); + aPropValues[ 0 ].Name = "CustomShape"; + aPropValues[ 0 ].Value <<= aXShape; + aArgument[ 0 ] <<= aPropValues; + Reference< XInterface > xInterface( xContext->getServiceManager()->createInstanceWithArgumentsAndContext( aEngine, aArgument, xContext ) ); + if ( xInterface.is() ) + mxCustomShapeEngine = Reference< XCustomShapeEngine >( xInterface, UNO_QUERY ); } return mxCustomShapeEngine; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits