Kaydet (Commit) 101cc7a8 authored tarafından Joren De Cuyper's avatar Joren De Cuyper Kaydeden (comit) Caolán McNamara

Do not write v:fill properties on export of imagedata

See validation log of fdo73214:
ERROR cvc-complex-type.3.2.2: Attribute 'type' is not allowed to appear in element 'v:imagedata'.
ERROR cvc-complex-type.3.2.2: Attribute 'color2' is not allowed to appear in element 'v:imagedata'.

http://dev-builds.libreoffice.org/crashtest/d879d5346b525c478e93363b7ec06e797ce01461/validation/docx/fdo73214-1.docx.log

Change-Id: I99eacc05ed28c3cd848326fd08f3668a1ce0f4fb
Reviewed-on: https://gerrit.libreoffice.org/15668Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 8d74795e
......@@ -562,6 +562,28 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const Rectangle& rRect
sal_uInt32 nValue;
sax_fastparser::FastAttributeList *pAttrList = FastSerializerHelper::createAttrList();
bool imageData = false;
EscherPropSortStruct aStruct;
if ( rProps.GetOpt( ESCHER_Prop_fillBlip, aStruct ) && m_pTextExport)
{
SvMemoryStream aStream;
int nHeaderSize = 25; // The first bytes are WW8-specific, we're only interested in the PNG
aStream.Write(aStruct.pBuf + nHeaderSize, aStruct.nPropSize - nHeaderSize);
aStream.Seek(0);
Graphic aGraphic;
GraphicConverter::Import(aStream, aGraphic);
OUString aImageId = m_pTextExport->GetDrawingML().WriteImage( aGraphic );
pAttrList->add(FSNS(XML_r, XML_id), OUStringToOString(aImageId, RTL_TEXTENCODING_UTF8));
imageData = true;
}
if ( rProps.GetOpt( ESCHER_Prop_fNoFillHitTest, nValue ) )
impl_AddBool( pAttrList, FSNS(XML_o, XML_detectmouseclick), nValue != 0 );
if (imageData)
m_pSerializer->singleElementNS( XML_v, XML_imagedata, XFastAttributeListRef( pAttrList ) );
else
{
if ( rProps.GetOpt( ESCHER_Prop_fillType, nValue ) )
{
const char *pFillType = NULL;
......@@ -578,9 +600,9 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const Rectangle& rRect
// TODO case ESCHER_FillShadeTitle: pFillType = ""; break;
// TODO case ESCHER_FillBackground: pFillType = ""; break;
default:
#if OSL_DEBUG_LEVEL > 0
#if OSL_DEBUG_LEVEL > 0
fprintf( stderr, "TODO: unhandled fill type\n" );
#endif
#endif
break;
}
if ( pFillType )
......@@ -595,32 +617,13 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const Rectangle& rRect
if ( rProps.GetOpt( ESCHER_Prop_fillBackColor, nValue ) )
impl_AddColor( pAttrList, XML_color2, nValue );
bool imageData = false;
EscherPropSortStruct aStruct;
if ( rProps.GetOpt( ESCHER_Prop_fillBlip, aStruct ) && m_pTextExport)
{
SvMemoryStream aStream;
int nHeaderSize = 25; // The first bytes are WW8-specific, we're only interested in the PNG
aStream.Write(aStruct.pBuf + nHeaderSize, aStruct.nPropSize - nHeaderSize);
aStream.Seek(0);
Graphic aGraphic;
GraphicConverter::Import(aStream, aGraphic);
OUString aImageId = m_pTextExport->GetDrawingML().WriteImage( aGraphic );
pAttrList->add(FSNS(XML_r, XML_id), OUStringToOString(aImageId, RTL_TEXTENCODING_UTF8));
imageData = true;
}
if ( rProps.GetOpt( ESCHER_Prop_fNoFillHitTest, nValue ) )
impl_AddBool( pAttrList, FSNS(XML_o, XML_detectmouseclick), nValue != 0 );
if (rProps.GetOpt(ESCHER_Prop_fillOpacity, nValue))
// Partly undo the transformation at the end of EscherPropertyContainer::CreateFillProperties(): VML opacity is 0..1.
pAttrList->add(XML_opacity, OString::number(double((nValue * 100) >> 16) / 100));
if (imageData)
m_pSerializer->singleElementNS( XML_v, XML_imagedata, XFastAttributeListRef( pAttrList ) );
else
m_pSerializer->singleElementNS( XML_v, XML_fill, XFastAttributeListRef( pAttrList ) );
}
}
bAlreadyWritten[ ESCHER_Prop_fillType ] = true;
bAlreadyWritten[ ESCHER_Prop_fillColor ] = true;
......
......@@ -1108,6 +1108,17 @@ DECLARE_OOXMLEXPORT_TEST(testTransparentShadow, "transparent-shadow.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), nShadowTransparence);
}
DECLARE_OOXMLEXPORT_TEST(NoFillAttrInImagedata, "NoFillAttrInImagedata.docx")
{
//problem was that type and color2 which are v:fill attributes were written in 'v:imagedata'
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Fallback/w:pict/v:rect/v:imagedata", "type", "");
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent[2]/mc:Fallback/w:pict/v:rect/v:imagedata", "color2", "");
}
DECLARE_OOXMLEXPORT_TEST(testBnc837302, "bnc837302.docx")
{
// The problem was that text with empty author was not inserted as a redline
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment