Kaydet (Commit) 56b647b3 authored tarafından Miklos Vajna's avatar Miklos Vajna

DOCX filter: roundtrip SDT properties on Frame TextPortions

Change-Id: Icb3dc9595a025c4386577d858c8ca96e2f9bbef7
üst cb466794
......@@ -251,6 +251,18 @@ DECLARE_OOXMLEXPORT_TEST(testSdtIgnoredFooter, "sdt-ignored-footer.docx")
}
}
DECLARE_OOXMLEXPORT_TEST(testSdtRunPicture, "sdt-run-picture.docx")
{
// SDT around run was exported as SDT around paragraph
if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
{
// This was 1: there was an SDT around w:p.
assertXPath(pXmlDoc, "//w:body/w:sdt", 0);
// This was 0: there were no SDT around w:r.
assertXPath(pXmlDoc, "//w:body/w:p/w:sdt", 1);
}
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -4132,6 +4132,15 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
nImageType = XML_embed;
}
// In case there are any grab-bag items on the graphic frame, emit them now.
// These are always character grab-bags, as graphics are at-char or as-char in Word.
const SfxPoolItem* pItem = 0;
if (pFrmFmt->GetAttrSet().HasItem(RES_FRMATR_GRABBAG, &pItem))
{
const SfxGrabBagItem* pGrabBag = static_cast<const SfxGrabBagItem*>(pItem);
CharGrabBag(*pGrabBag);
}
m_rExport.SdrExporter().startDMLAnchorInline(pFrmFmt, rSize);
// picture description (used for pic:cNvPr later too)
......
......@@ -4455,6 +4455,22 @@ void DomainMapper_Impl::ImportGraphic(writerfilter::Reference< Properties >::Po
uno::Reference<text::XTextContent> xTextContent
(m_pGraphicImport->GetGraphicObject());
// In case the SDT starts with the text portion of the graphic, then set the SDT properties here.
bool bHasGrabBag = false;
uno::Reference<beans::XPropertySet> xPropertySet(xTextContent, uno::UNO_QUERY);
if (xPropertySet.is())
{
uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
bHasGrabBag = xPropertySetInfo->hasPropertyByName("FrameInteropGrabBag");
// In case we're outside a paragraph, then the SDT properties are stored in the paragraph grab-bag, not the frame one.
if (!m_pSdtHelper->isInteropGrabBagEmpty() && bHasGrabBag && !m_pSdtHelper->isOutsideAParagraph())
{
comphelper::SequenceAsHashMap aFrameGrabBag(xPropertySet->getPropertyValue("FrameInteropGrabBag"));
aFrameGrabBag["SdtPr"] = uno::makeAny(m_pSdtHelper->getInteropGrabBagAndClear());
xPropertySet->setPropertyValue("FrameInteropGrabBag", uno::makeAny(aFrameGrabBag.getAsConstPropertyValueList()));
}
}
/* 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.
......@@ -4462,20 +4478,16 @@ void DomainMapper_Impl::ImportGraphic(writerfilter::Reference< Properties >::Po
*/
if(IsSdtEndBefore())
{
uno::Reference< beans::XPropertySet > xGraphicObjectProperties(xTextContent,
uno::UNO_QUERY_THROW);
uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
if(xGraphicObjectProperties.is())
if(xPropertySet.is())
{
xPropSetInfo = xGraphicObjectProperties->getPropertySetInfo();
if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
if (bHasGrabBag)
{
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));
xPropertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aFrameGrabBag));
}
}
}
......
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