summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorPallavi Jadhav <pallavi.jadhav@synerzip.com>2014-08-13 18:14:47 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-08-18 12:52:30 +0200
commit8b9988163c0c0d158fc2d9f5272695ccfec92237 (patch)
treef9d2691b9837fc829a0fce96c879f10da6df9e75 /writerfilter
parenta18ff3d5c75c2b468c48bd19439dee0689d24d67 (diff)
fdo#82492 : DOCX: Corruption: File was getting corrupt fafter RT
Issue : - In issue file there were two runs(first run=SDT, second run=Shape). - These two runs were consecutive(no text/space/tab was there in between two runs). - Due to such scenario, "SdtEndBefore" was not getting set on Shape. - Hence at Export EndSdtBlock() was getting called from EndParagraph(). Due to this SDT was not getting end after first run. In order to end SDT after run, EndSdtBlock() should get called from EndRun() (as in Original file) Implementation : - Set "SdtEndBefore" on Shape in DomainMapper_Impl::PushShapeContext() - Retrieved same property at export. - Added export unit test case. Note : Added common functions at Import and Export with reference to https://gerrit.libreoffice.org/#/c/10827/ Conflicts: sw/source/filter/ww8/docxattributeoutput.cxx Reviewed on: https://gerrit.libreoffice.org/10912 Change-Id: I357d77cd179c83b8ae976db331ee46c8993b6cb8
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx91
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx3
2 files changed, 60 insertions, 34 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 9f203a951065..0428c8752520 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1906,6 +1906,24 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
m_vTextFramesForChaining.push_back(xShape);
}
}
+
+ if(IsSdtEndBefore())
+ {
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
+ if(xShapePropertySet.is())
+ {
+ xPropSetInfo = xShapePropertySet->getPropertySetInfo();
+ if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("InteropGrabBag"))
+ {
+ uno::Sequence<beans::PropertyValue> aShapeGrabBag(1);
+ beans::PropertyValue aRet;
+ aRet.Name = "SdtEndBefore";
+ aRet.Value <<= uno::makeAny(true);
+ aShapeGrabBag[0] = aRet;
+ xShapePropertySet->setPropertyValue("InteropGrabBag",uno::makeAny(aShapeGrabBag));
+ }
+ }
+ }
}
if (!m_bInHeaderFooterImport && !checkZOrderStatus)
xProps->setPropertyValue(
@@ -1981,6 +1999,32 @@ void DomainMapper_Impl::PopShapeContext()
m_bFrameBtLr = false;
}
+bool DomainMapper_Impl::IsSdtEndBefore()
+{
+ bool bIsSdtEndBefore = false;;
+ 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")
+ {
+ aCharGrabBag[j].Value >>= bIsSdtEndBefore;
+ }
+ }
+ }
+ }
+ }
+ return bIsSdtEndBefore;
+}
+
sal_Int16 lcl_ParseNumberingType( const OUString& rCommand )
{
sal_Int16 nRet = style::NumberingType::PAGE_DESCRIPTOR;
@@ -4399,43 +4443,22 @@ void DomainMapper_Impl::ImportGraphic(writerfilter::Reference< Properties >::Po
* 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)
+ if(IsSdtEndBefore())
{
- uno::Sequence< beans::PropertyValue > currentCharProps = pContext->GetPropertyValues();
- for (int i =0; i< currentCharProps.getLength(); i++)
+ uno::Reference< beans::XPropertySet > xGraphicObjectProperties(xTextContent,
+ uno::UNO_QUERY_THROW);
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
+ if(xGraphicObjectProperties.is())
{
- if (currentCharProps[i].Name == "CharInteropGrabBag")
+ xPropSetInfo = xGraphicObjectProperties->getPropertySetInfo();
+ if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
{
- uno::Sequence<beans::PropertyValue> aCharGrabBag;
- currentCharProps[i].Value >>= aCharGrabBag;
- for (int j=0; j < aCharGrabBag.getLength();j++)
- {
- if(aCharGrabBag[j].Name == "SdtEndBefore")
- {
- bool bIsSdtEndBefore = false;
- 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));
- }
- }
- }
- }
- }
+ 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));
}
}
}
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 2bb0478f2c2a..4bee8aceeedc 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -824,6 +824,9 @@ public:
/// If the document needs to split paragraph.
bool m_bIsSplitPara;
+ /// Check if "SdtEndBefore" property is set
+ bool IsSdtEndBefore();
+
private:
void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType);
std::vector<css::uno::Reference< css::drawing::XShape > > m_vTextFramesForChaining ;