[Libreoffice-commits] core.git: oox/source sw/qa sw/source
Vinaya Mandke
vinaya.mandke at synerzip.com
Tue Mar 18 06:30:46 PDT 2014
oox/source/drawingml/shape.cxx | 12 ++++--
oox/source/token/tokens.txt | 1
sw/qa/extras/inc/swmodeltestbase.hxx | 1
sw/qa/extras/ooxmlexport/data/fdo76249.docx |binary
sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 15 ++++++++
sw/source/filter/ww8/docxsdrexport.cxx | 49 +++++++++++++++++++++++++++-
sw/source/filter/ww8/docxsdrexport.hxx | 2 +
7 files changed, 75 insertions(+), 5 deletions(-)
New commits:
commit 17d31e6fb316da2bf1267c337eed88165dfa1a54
Author: Vinaya Mandke <vinaya.mandke at synerzip.com>
Date: Mon Mar 17 13:01:37 2014 +0530
fdo#76249 DOCX export DML Drawing as lockedCanvas if it's inside DMLTextFrame
The Locked Canvas is imported correctly,
but while exporting the drawing is exported inside a textbox.
However a locked Canvas has to be exported inside a text-box
for the RT file to work in MS Word 2010.
As dml drawing elements are not allowed in the dml textboxes.
Export as Locked Canvas iff the drawing was originally a Locked Canvas
and is now inside a DML Text Frame.
As otherwise the Locked Canvas is exported correctly as a DMLDrawing.
Reviewed on:
https://gerrit.libreoffice.org/8618
Change-Id: Ifa350d8922a22c4e480411530aa4d953bd3ed2ac
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 56342dd..c6f14e9 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -790,11 +790,15 @@ Reference< XShape > Shape::createAndInsert(
}
PropertySet( xSet ).setProperties( aShapeProps );
- if (mbLockedCanvas && aServiceName == "com.sun.star.drawing.LineShape")
+ if (mbLockedCanvas)
{
- // It seems the position and size for lines inside a locked canvas is absolute.
- mxShape->setPosition(awt::Point(aShapeRectHmm.X, aShapeRectHmm.Y));
- mxShape->setSize(awt::Size(aShapeRectHmm.Width, aShapeRectHmm.Height));
+ putPropertyToGrabBag( "LockedCanvas", Any( true ) );
+ if (aServiceName == "com.sun.star.drawing.LineShape")
+ {
+ // It seems the position and size for lines inside a locked canvas is absolute.
+ mxShape->setPosition(awt::Point(aShapeRectHmm.X, aShapeRectHmm.Y));
+ mxShape->setSize(awt::Size(aShapeRectHmm.Width, aShapeRectHmm.Height));
+ }
}
// Store original fill and line colors of the shape and the theme color name to InteropGrabBag
diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt
index 84f28c1..8d40a4b 100644
--- a/oox/source/token/tokens.txt
+++ b/oox/source/token/tokens.txt
@@ -2885,6 +2885,7 @@ ky
l
lB
lBounds
+lc
lCtrCh
lCtrDes
lIns
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index c82ae7c..e079810 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -553,6 +553,7 @@ protected:
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w14"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordml"));
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("m"), BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/math"));
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("ContentType"), BAD_CAST("http://schemas.openxmlformats.org/package/2006/content-types"));
+ xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("lc"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas"));
xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(rXPath.getStr()), pXmlXpathCtx);
return pXmlXpathObj->nodesetval;
}
diff --git a/sw/qa/extras/ooxmlexport/data/fdo76249.docx b/sw/qa/extras/ooxmlexport/data/fdo76249.docx
new file mode 100644
index 0000000..9b50f5d
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo76249.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index 361b523..918af37 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -937,6 +937,21 @@ DECLARE_OOXMLEXPORT_TEST(testPictureWatermark, "pictureWatermark.docx")
assertXPath(pXmlHeader1, "/w:hdr[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Fallback[1]/w:pict[1]/v:rect[1]","id","WordPictureWatermark11962361");
}
+
+DECLARE_OOXMLEXPORT_TEST(testFdo76249, "fdo76249.docx")
+{
+ /*
+ * The Locked Canvas is imported correctly, but while exporting
+ * the drawing element is exported inside a textbox. However a the drawing has to exported
+ * as a Locked Canvas inside a text-box for the RT file to work in MS Word, as drawing elements
+ * are not allowed inside the textboxes.
+ */
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ assertXPath(pXmlDoc, "//mc:Choice/w:drawing//w:txbxContent//w:drawing//lc:lockedCanvas", 1);
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 16e0a07..72f5724 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -111,6 +111,7 @@ struct DocxSdrExport::Impl
sax_fastparser::FastAttributeList* m_pFlyWrapAttrList;
sax_fastparser::FastAttributeList* m_pBodyPrAttrList;
sax_fastparser::FastAttributeList* m_pDashLineStyleAttr;
+ bool m_bIsInDMLTextFrame;
Impl(DocxSdrExport& rSdrExport, DocxExport& rExport, sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML)
: m_rSdrExport(rSdrExport),
@@ -127,7 +128,8 @@ struct DocxSdrExport::Impl
m_pFlyFillAttrList(0),
m_pFlyWrapAttrList(0),
m_pBodyPrAttrList(0),
- m_pDashLineStyleAttr(0)
+ m_pDashLineStyleAttr(0),
+ m_bIsInDMLTextFrame(false)
{
}
@@ -550,6 +552,31 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrmFmt*
uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObject)->getUnoShape(), uno::UNO_QUERY_THROW);
uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW);
+ uno::Reference< beans::XPropertySet > xPropertySet(xShape, uno::UNO_QUERY);
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
+ if (xPropertySet.is())
+ xPropSetInfo = xPropertySet->getPropertySetInfo();
+
+ bool bLockedCanvas = false;
+ if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("InteropGrabBag"))
+ {
+ uno::Sequence< beans::PropertyValue > propList;
+ xPropertySet->getPropertyValue("InteropGrabBag") >>= propList;
+ for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp)
+ {
+ OUString propName = propList[nProp].Name;
+ if (propName == "LockedCanvas")
+ {
+ /*
+ * Export as Locked Canvas only if the drawing
+ * was originally a Locked Canvas and is now inside a Text Frame.
+ */
+
+ bLockedCanvas = getIsInDMLTextFrame();
+ break;
+ }
+ }
+ }
const char* pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
if (xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
@@ -562,8 +589,15 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrmFmt*
XML_uri, pNamespace,
FSEND);
+ if (bLockedCanvas)
+ pFS->startElementNS(XML_lc, XML_lockedCanvas,
+ FSNS(XML_xmlns, XML_lc), "http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas",
+ FSEND);
+
m_pImpl->m_rExport.OutputDML(xShape);
+ if (bLockedCanvas)
+ pFS->endElementNS(XML_lc, XML_lockedCanvas);
pFS->endElementNS(XML_a, XML_graphicData);
pFS->endElementNS(XML_a, XML_graphic);
@@ -993,6 +1027,7 @@ void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const SwFrmFmt& rFr
void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId)
{
+ setIsInDMLTextFrame(true);
sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer;
const SwFrmFmt& rFrmFmt = pParentFrame->GetFrmFmt();
const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx();
@@ -1154,6 +1189,7 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId)
}
endDMLAnchorInline(&rFrmFmt);
+ setIsInDMLTextFrame(false);
}
void DocxSdrExport::writeVMLTextFrame(sw::Frame* pParentFrame)
@@ -1278,4 +1314,15 @@ bool DocxSdrExport::checkFrameBtlr(SwNode* pStartNode, sax_fastparser::FastAttri
}
return false;
}
+
+bool DocxSdrExport::getIsInDMLTextFrame()
+{
+ return m_pImpl->m_bIsInDMLTextFrame;
+}
+
+void DocxSdrExport::setIsInDMLTextFrame(bool bIsInDMLTextFrame)
+{
+ m_pImpl->m_bIsInDMLTextFrame = bIsInDMLTextFrame;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxsdrexport.hxx b/sw/source/filter/ww8/docxsdrexport.hxx
index dced28c..73c981f 100644
--- a/sw/source/filter/ww8/docxsdrexport.hxx
+++ b/sw/source/filter/ww8/docxsdrexport.hxx
@@ -90,6 +90,8 @@ public:
com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > xOutStream, const OUString& sGrabBagProperyName);
/// Writes text frame in DML format.
void writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId);
+ bool getIsInDMLTextFrame();
+ void setIsInDMLTextFrame(bool bIsInDMLTextFrame);
/// Writes text frame in VML format.
void writeVMLTextFrame(sw::Frame* pParentFrame);
/// Undo the text direction mangling done by the frame btLr handler in writerfilter::dmapper::DomainMapper::lcl_startCharacterGroup()
More information about the Libreoffice-commits
mailing list