diff options
author | Pallavi Jadhav <pallavi.jadhav@synerzip.com> | 2014-08-08 17:20:31 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-11 08:28:57 +0000 |
commit | f6e7b94042070241cd1cfb1d7f8610fe1801b4f2 (patch) | |
tree | c723d3680b05f35a468371db60508115f7500915 | |
parent | ba774649fb6f53c8d3251d417c4537ae7c495881 (diff) |
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/10827
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo82123.docx | bin | 0 -> 36087 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 28 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 47 |
4 files changed, 85 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo82123.docx b/sw/qa/extras/ooxmlexport/data/fdo82123.docx Binary files differnew file mode 100644 index 000000000000..fc2632cb6abd --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo82123.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index be347b5134b1..9ab1ba22c80a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -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"); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index b0447cfbef2b..edd69c254b8f 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -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; diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 1bf28fac2627..feb11e028efb 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -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()); |