sw/qa/extras/ooxmlexport/data/fdo82123.docx |binary sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 10 ++++ sw/source/filter/ww8/docxattributeoutput.cxx | 28 +++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 47 ++++++++++++++++++++++ 4 files changed, 85 insertions(+)
New commits: commit f6e7b94042070241cd1cfb1d7f8610fe1801b4f2 Author: Pallavi Jadhav <pallavi.jad...@synerzip.com> Date: Fri Aug 8 17:20:31 2014 +0530 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 <vmik...@collabora.co.uk> Tested-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/qa/extras/ooxmlexport/data/fdo82123.docx b/sw/qa/extras/ooxmlexport/data/fdo82123.docx new file mode 100644 index 0000000..fc2632c Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo82123.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index be347b5..9ab1ba2 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 b0447cf..edd69c2 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 1bf28fa..feb11e0 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()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits