Kaydet (Commit) f6e7b940 authored tarafından Pallavi Jadhav's avatar Pallavi Jadhav Kaydeden (comit) Miklos Vajna

fdo#82123 : DOCX: Corruption: File was getting corrupt fafter RT

	Issue :
	- In issue file there were two runs(first run=SDT, second run=Image).
	- These two runs were consecutive(no text/space/tab was there in between two runs).
	- Due to such scenario, "SdtEndBefore" was not getting set.
	- Hence at Export EndSdtBlock() was getting called form EndParagraph()
	  Instead EndSdtBlock() should ge called from EndRun() in order to end
	  sdt after first run(as in Original file)

	Implementation :
	- Set "SdtEndBefore" on Graphic in DomainMapper_Impl::ImportGraphic()
	- Retrieved same property at export.
	- Added export unit test case.

Change-Id: Id514b91f1831af371924f94388f0a404d762c042
Reviewed-on: https://gerrit.libreoffice.org/10827Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst ba774649
......@@ -591,6 +591,16 @@ DECLARE_OOXMLEXPORT_TEST(testFdo81945, "fdo81945.docx")
assertXPath(pXmlDoc, "//w:sdt//w:sdt", 0);
}
DECLARE_OOXMLEXPORT_TEST(testfdo82123, "fdo82123.docx")
{
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
// make sure there is only one run inside first SDT after RT as in the Original file.
assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[2]/w:p/w:sdt[1]/w:sdtContent/w:r",1);
}
DECLARE_OOXMLEXPORT_TEST(testfdo81946, "fdo81946.docx")
{
xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
......
......@@ -4008,6 +4008,34 @@ void DocxAttributeOutput::ClearRelIdCache()
void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size& rSize, const SwFlyFrmFmt* pOLEFrmFmt, SwOLENode* pOLENode, const SdrObject* pSdrObj )
{
OSL_TRACE( "TODO DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size& rSize, const SwFlyFrmFmt* pOLEFrmFmt, SwOLENode* pOLENode, const SdrObject* pSdrObj ) - some stuff still missing" );
if (pSdrObj)
{
uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY_THROW);
if( xShape.is() )
{
uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
if( xPropSet.is() )
{
xPropSetInfo = xPropSet->getPropertySetInfo();
if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
{
uno::Sequence< beans::PropertyValue > aGrabBag;
xPropSet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
for (sal_Int32 nProp=0; nProp < aGrabBag.getLength(); ++nProp)
{
if ("SdtEndBefore" == aGrabBag[nProp].Name && m_bStartedCharSdt && !m_bEndCharSdt)
{
aGrabBag[nProp].Value >>= m_bEndCharSdt;
}
break;
}
}
}
}
}
// detect mis-use of the API
assert(pGrfNode || (pOLEFrmFmt && pOLENode));
const SwFrmFmt* pFrmFmt = pGrfNode ? pGrfNode->GetFlyFmt() : pOLEFrmFmt;
......
......@@ -4394,6 +4394,53 @@ void DomainMapper_Impl::ImportGraphic(writerfilter::Reference< Properties >::Po
uno::Reference<text::XTextContent> xTextContent
(m_pGraphicImport->GetGraphicObject());
/* Set "SdtEndBefore" property on Drawing.
* It is required in a case when Drawing appears immediately after first run i.e.
* there is no text/space/tab in between two runs.
* In this case "SdtEndBefore" property needs to be set on Drawing.
*/
PropertyMapPtr pContext = GetTopContextOfType(CONTEXT_CHARACTER);
if(pContext)
{
uno::Sequence< beans::PropertyValue > currentCharProps = pContext->GetPropertyValues();
for (int i =0; i< currentCharProps.getLength(); i++)
{
if (currentCharProps[i].Name == "CharInteropGrabBag")
{
uno::Sequence<beans::PropertyValue> aCharGrabBag;
currentCharProps[i].Value >>= aCharGrabBag;
for (int j=0; j < aCharGrabBag.getLength();j++)
{
if(aCharGrabBag[j].Name == "SdtEndBefore")
{
bool bIsSdtEndBefore;
aCharGrabBag[j].Value >>= bIsSdtEndBefore;
if (bIsSdtEndBefore)
{
uno::Reference< beans::XPropertySet > xGraphicObjectProperties(xTextContent,
uno::UNO_QUERY_THROW);
uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
if(xGraphicObjectProperties.is())
{
xPropSetInfo = xGraphicObjectProperties->getPropertySetInfo();
if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
{
uno::Sequence<beans::PropertyValue> aFrameGrabBag(1);
beans::PropertyValue aRet;
aRet.Name = "SdtEndBefore";
aRet.Value <<= uno::makeAny(true);
aFrameGrabBag[0] = aRet;
xGraphicObjectProperties->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aFrameGrabBag));
}
}
}
}
}
}
}
}
// Update the shape properties if it is embedded object.
if(m_xEmbedded.is()){
UpdateEmbeddedShapeProps(m_pGraphicImport->GetXShapeObject());
......
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