tdf#66822 - refactor HTML export of image bullet list
removed garbage in svg-base64, added svg close tag, fixed ul tag. Added test case for the added code. Change-Id: I4f07036300031e1e97b118466ebf75d8b9c46e01 Reviewed-on: https://gerrit.libreoffice.org/21218 Tested-by: jan iversen <jani@documentfoundation.org> Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: jan iversen <jani@documentfoundation.org>
This commit is contained in:
@@ -364,7 +364,25 @@ bool XOutBitmap::GraphicToBase64(const Graphic& rGraphic, OUString& rOUString)
|
||||
css::uno::Sequence<sal_Int8> aOStmSeq( static_cast<sal_Int8 const *>(aOStm.GetData()),aOStm.Tell() );
|
||||
OUStringBuffer aStrBuffer;
|
||||
::sax::Converter::encodeBase64(aStrBuffer,aOStmSeq);
|
||||
rOUString = aMimeType + ";base64," + aStrBuffer.makeStringAndClear();
|
||||
OUString aEncodedBase64Image = aStrBuffer.makeStringAndClear();
|
||||
if( aLink.GetType() == GFX_LINK_TYPE_NATIVE_SVG )
|
||||
{
|
||||
sal_Int32 ite(8);
|
||||
sal_Int32 nBufferLength(aOStmSeq.getLength());
|
||||
const sal_Int8* pBuffer = aOStmSeq.getConstArray();
|
||||
css::uno::Sequence<sal_Int8> newTempSeq = aOStmSeq; // creates new Sequence to remove front 8 bits of garbage and encodes in base64
|
||||
sal_Int8 *pOutBuffer = newTempSeq.getArray();
|
||||
while(ite < nBufferLength)
|
||||
{
|
||||
*pOutBuffer++ = pBuffer[ite];
|
||||
ite++;
|
||||
}
|
||||
::sax::Converter::encodeBase64(aStrBuffer, newTempSeq);
|
||||
aEncodedBase64Image = aStrBuffer.makeStringAndClear();
|
||||
sal_Int32 SVGFixLength = aEncodedBase64Image.getLength();
|
||||
aEncodedBase64Image = aEncodedBase64Image.replaceAt(SVGFixLength - 12, SVGFixLength, "") + "PC9zdmc+Cg=="; // removes rear 12 bits of garbage and adds svg closing tag in base64
|
||||
}
|
||||
rOUString = aMimeType + ";base64," + aEncodedBase64Image;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
BIN
sw/qa/extras/htmlexport/data/tdf66822.odt
Normal file
BIN
sw/qa/extras/htmlexport/data/tdf66822.odt
Normal file
Binary file not shown.
@@ -254,6 +254,16 @@ DECLARE_HTMLEXPORT_TEST(testExportInternalUrl, "tdf90905.odt")
|
||||
assertXPath(pDoc, "/html/body/p[2]/a", "href", "#bookmark");
|
||||
}
|
||||
|
||||
DECLARE_HTMLEXPORT_TEST(testExportImageBulletList, "tdf66822.odt")
|
||||
{
|
||||
htmlDocPtr pDoc = parseHtml(maTempFile);
|
||||
CPPUNIT_ASSERT(pDoc);
|
||||
|
||||
// Encoded base64 SVG bullet should match and render on browser
|
||||
assertXPath(pDoc, "/html/body/ul", 1);
|
||||
assertXPath(pDoc, "/html/body/ul", "style", "list-style-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxMi4wLjEsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDUxNDQ4KSAgLS0+DQo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiIFsNCgk8IUVOVElUWSBuc19zdmcgImh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCgk8IUVOVElUWSBuc194bGluayAiaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+DQpdPg0KPHN2ZyAgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9IiZuc19zdmc7IiB4bWxuczp4bGluaz0iJm5zX3hsaW5rOyIgd2lkdGg9IjE0LjAwOCIgaGVpZ2h0PSIxNC4wMSINCgkgdmlld0JveD0iMCAwIDE0LjAwOCAx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CBpZD0iWE1MSURfNl8iIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiB4MT0iNy4xMjIxIiB5MT0iMC4xMDMiIHgyPSI3LjEyMjEiIHkyPSI1LjIzNDQiPg0KCQkJCTxzdG9wICBvZmZzZXQ9IjAiIHN0eWxlPSJzdG9wLWNvbG9yOiNGRkZGRkYiLz4NCgkJCQk8c3RvcCAgb2Zmc2V0PSIxIiBzdHlsZT0ic3RvcC1jb2xvcjojMDAwMDAwIi8+DQoJCQk8L2xpbmVhckdyYWRpZW50Pg0KCQkJPHJlY3QgeD0iMy4xOTkiIHk9IjAuMzM5IiBvcGFjaXR5PSIwLjciIGZpbGw9InVybCgjWE1MSURfNl8pIiB3aWR0aD0iNy44NDYiIGhlaWdodD0iNC42MDEiLz4NCgkJPC9nPg0KCTwvbWFzaz4NCgk8ZWxsaXBzZSBtYXNrPSJ1cmwoI1hNTElEXzVfKSIgZmlsbD0iI0ZGRkZGRiIgY3g9IjYuOTc1IiBjeT0iMi42NCIgcng9IjMuNDk0IiByeT0iMS45NDYiLz4NCjwvZz4NPC9zdmc+Cg==);");
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -266,7 +266,7 @@ Writer& OutHTML_NumBulListStart( SwHTMLWriter& rWrt,
|
||||
}
|
||||
}
|
||||
|
||||
if (!sOut.isEmpty())
|
||||
if (!sOut.isEmpty() && SVX_NUM_BITMAP != eType) // second condition to avoid adding extra ul, already done before.
|
||||
rWrt.Strm().WriteOString( sOut );
|
||||
|
||||
if( rWrt.m_bCfgOutStyles )
|
||||
|
Reference in New Issue
Block a user