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
This commit is contained in:
committed by
Miklos Vajna
parent
9aca34a69f
commit
17d31e6fb3
@@ -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
|
||||
|
@@ -2885,6 +2885,7 @@ ky
|
||||
l
|
||||
lB
|
||||
lBounds
|
||||
lc
|
||||
lCtrCh
|
||||
lCtrDes
|
||||
lIns
|
||||
|
@@ -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;
|
||||
}
|
||||
|
BIN
sw/qa/extras/ooxmlexport/data/fdo76249.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/fdo76249.docx
Normal file
Binary file not shown.
@@ -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();
|
||||
|
@@ -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: */
|
||||
|
@@ -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()
|
||||
|
Reference in New Issue
Block a user