summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-09-23 10:27:10 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-09-23 11:06:52 +0200
commit56b647b3a384db53bc55c56b2ae70e08c20e148b (patch)
tree83854f4c7afde3bffeb9d14ae8b359d3b3344fba
parentcb466794aff56cc9cf2c83d26f5cda9dacdd6c81 (diff)
DOCX filter: roundtrip SDT properties on Frame TextPortions
Change-Id: Icb3dc9595a025c4386577d858c8ca96e2f9bbef7
-rw-r--r--sw/qa/extras/ooxmlexport/data/sdt-run-picture.docxbin0 -> 15444 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx12
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx9
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx26
4 files changed, 40 insertions, 7 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/sdt-run-picture.docx b/sw/qa/extras/ooxmlexport/data/sdt-run-picture.docx
new file mode 100644
index 000000000000..fa2d57c2b34e
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/sdt-run-picture.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 0bb68e87d66c..dd458e942777 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -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: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index a4b11f4d3fb7..4bdb9db2e003 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -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)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 7e68473c4eaa..bf5a748a3ea6 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -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));
}
}
}