summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2023-07-06 16:57:08 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2023-07-06 22:14:34 +0200
commit2f75278ff1f437228d39cc3f71d6fa98d58fc1c1 (patch)
tree253d9b63bc971ee51cbac9168ef123322d543464 /oox
parent14f166d30c43f7e9a0386e17b2be525dc06765d9 (diff)
tdf#141058 oox,sw: OOXML import/export of decorative on shapes
Also add a test for PPTX (using the oox filters), and add a SdrObject to the testTdf143311 for DOCX (using the writerfilter/docxsdrexport). Change-Id: Iccee46c0d30316c33c0947b117e2604c96fa0182 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154137 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit e751d59264c369cfc342dab5f0759be12341d306) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154125
Diffstat (limited to 'oox')
-rw-r--r--oox/source/core/xmlfilterbase.cxx1
-rw-r--r--oox/source/drawingml/connectorshapecontext.cxx8
-rw-r--r--oox/source/drawingml/shape.cxx4
-rw-r--r--oox/source/drawingml/shapecontext.cxx8
-rw-r--r--oox/source/drawingml/shapegroupcontext.cxx8
-rw-r--r--oox/source/export/shapes.cxx73
-rw-r--r--oox/source/ppt/pptshapegroupcontext.cxx8
7 files changed, 97 insertions, 13 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index c2911a756047..0c95980accd4 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -148,6 +148,7 @@ const Sequence< beans::Pair< OUString, sal_Int32 > >& NamespaceIds()
NMSP_c15},
{"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2",
NMSP_xr2},
+ {"http://schemas.microsoft.com/office/drawing/2017/decorative", NMSP_adec},
};
return SINGLETON;
};
diff --git a/oox/source/drawingml/connectorshapecontext.cxx b/oox/source/drawingml/connectorshapecontext.cxx
index 8ea0bcca6965..018ca95c648d 100644
--- a/oox/source/drawingml/connectorshapecontext.cxx
+++ b/oox/source/drawingml/connectorshapecontext.cxx
@@ -69,6 +69,14 @@ ConnectorShapePropertiesContext::onCreateContext(sal_Int32 aElementToken,
{
switch (getBaseToken(aElementToken))
{
+ case XML_extLst:
+ case XML_ext:
+ break;
+ case XML_decorative:
+ {
+ mpConnectorShapePtr->setDecorative(rAttribs.getBool(XML_val, false));
+ break;
+ }
case XML_cNvPr:
mpConnectorShapePtr->setId(rAttribs.getStringDefaulted(XML_id));
mpConnectorShapePtr->setName(rAttribs.getStringDefaulted(XML_name));
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index b9aebab1b31d..3318198123e6 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1144,6 +1144,10 @@ Reference< XShape > const & Shape::createAndInsert(
{
xSet->setPropertyValue( "Description", Any( msDescription ) );
}
+ if (m_isDecorative)
+ {
+ xSet->setPropertyValue("Decorative", Any(m_isDecorative));
+ }
if (aServiceName != "com.sun.star.text.TextFrame")
rxShapes->add( mxShape );
diff --git a/oox/source/drawingml/shapecontext.cxx b/oox/source/drawingml/shapecontext.cxx
index 3ac32abd11aa..289cda8dfd66 100644
--- a/oox/source/drawingml/shapecontext.cxx
+++ b/oox/source/drawingml/shapecontext.cxx
@@ -66,6 +66,14 @@ ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 aElementToken, const
// nvSpPr CT_ShapeNonVisual begin
// case XML_drElemPr:
// break;
+ case XML_extLst:
+ case XML_ext:
+ break;
+ case XML_decorative:
+ {
+ mpShapePtr->setDecorative(rAttribs.getBool(XML_val, false));
+ }
+ break;
case XML_cNvPr:
{
mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
diff --git a/oox/source/drawingml/shapegroupcontext.cxx b/oox/source/drawingml/shapegroupcontext.cxx
index 02ce5917e682..d810b0448b9a 100644
--- a/oox/source/drawingml/shapegroupcontext.cxx
+++ b/oox/source/drawingml/shapegroupcontext.cxx
@@ -58,6 +58,14 @@ ContextHandlerRef ShapeGroupContext::onCreateContext( sal_Int32 aElementToken, c
{
switch( getBaseToken( aElementToken ) )
{
+ case XML_extLst:
+ case XML_ext:
+ break;
+ case XML_decorative:
+ {
+ mpGroupShapePtr->setDecorative(rAttribs.getBool(XML_val, false));
+ }
+ break;
case XML_cNvPr:
{
mpGroupShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index cfc980f95b96..b7b1a912aa0f 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -394,6 +394,24 @@ bool ShapeExport::NonEmptyText( const Reference< XInterface >& xIface )
return IsNonEmptySimpleText(xIface);
}
+static void AddExtLst(FSHelperPtr const& pFS, Reference<XPropertySet> const& xShape)
+{
+ if (xShape->getPropertySetInfo()->hasPropertyByName("Decorative")
+ && xShape->getPropertyValue("Decorative").get<bool>())
+ {
+ pFS->startElementNS(XML_a, XML_extLst);
+// FSNS(XML_xmlns, XML_a), GetExport().GetFilter().getNamespaceURL(OOX_NS(dml)));
+ pFS->startElementNS(XML_a, XML_ext,
+ // MSO uses this "URI" which is obviously not a URI
+ XML_uri, "{C183D7F6-B498-43B3-948B-1728B52AA6E4}");
+ pFS->singleElementNS(XML_adec, XML_decorative,
+ FSNS(XML_xmlns, XML_adec), "http://schemas.microsoft.com/office/drawing/2017/decorative",
+ XML_val, "1");
+ pFS->endElementNS(XML_a, XML_ext);
+ pFS->endElementNS(XML_a, XML_extLst);
+ }
+}
+
ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& xShape, const bool bClosed )
{
SAL_INFO("oox.shape", "write polypolygon shape");
@@ -419,13 +437,16 @@ ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& xSha
SAL_INFO("oox.shape", "size: " << size.Width << " x " << size.Height);
#endif
+ Reference<XPropertySet> const xProps(xShape, UNO_QUERY);
// non visual shape properties
if (GetDocumentType() != DOCUMENT_DOCX || mbUserShapes)
{
pFS->startElementNS(mnXmlNamespace, XML_nvSpPr);
- pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
+ pFS->startElementNS(mnXmlNamespace, XML_cNvPr,
XML_id, OString::number(GetNewShapeID(xShape)),
XML_name, GetShapeName(xShape));
+ AddExtLst(pFS, xProps);
+ pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
}
pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr);
if (GetDocumentType() != DOCUMENT_DOCX || mbUserShapes)
@@ -438,7 +459,6 @@ ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& xSha
pFS->startElementNS(mnXmlNamespace, XML_spPr);
WriteTransformation( xShape, aRect, XML_a );
WritePolyPolygon(xShape, bClosed);
- Reference< XPropertySet > xProps( xShape, UNO_QUERY );
if( xProps.is() ) {
if( bClosed )
WriteFill(xProps, aSize);
@@ -484,9 +504,12 @@ ShapeExport& ShapeExport::WriteGroupShape(const uno::Reference<drawing::XShape>&
if (GetDocumentType() != DOCUMENT_DOCX || mbUserShapes)
{
pFS->startElementNS(mnXmlNamespace, XML_nvGrpSpPr);
- pFS->singleElementNS(mnXmlNamespace, XML_cNvPr,
+ pFS->startElementNS(mnXmlNamespace, XML_cNvPr,
XML_id, OString::number(GetNewShapeID(xShape)),
XML_name, GetShapeName(xShape));
+ uno::Reference<beans::XPropertySet> const xShapeProps(xShape, uno::UNO_QUERY_THROW);
+ AddExtLst(pFS, xShapeProps);
+ pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
pFS->singleElementNS(mnXmlNamespace, XML_cNvGrpSpPr);
WriteNonVisualProperties(xShape );
pFS->endElementNS(mnXmlNamespace, XML_nvGrpSpPr);
@@ -894,6 +917,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId,
XML_action, "ppaction://hlinksldjump");
}
+ AddExtLst(pFS, rXPropSet);
pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr);
WriteNonVisualProperties( xShape );
@@ -923,6 +947,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId);
}
}
+ AddExtLst(pFS, rXPropSet);
pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
}
pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr);
@@ -1151,13 +1176,16 @@ ShapeExport& ShapeExport::WriteEllipseShape( const Reference< XShape >& xShape )
// TODO: connector ?
+ Reference<XPropertySet> const xProps(xShape, UNO_QUERY);
// non visual shape properties
if (GetDocumentType() != DOCUMENT_DOCX || mbUserShapes)
{
pFS->startElementNS(mnXmlNamespace, XML_nvSpPr);
- pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
+ pFS->startElementNS(mnXmlNamespace, XML_cNvPr,
XML_id, OString::number(GetNewShapeID(xShape)),
XML_name, GetShapeName(xShape));
+ AddExtLst(pFS, xProps);
+ pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr );
WriteNonVisualProperties( xShape );
pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
@@ -1165,7 +1193,6 @@ ShapeExport& ShapeExport::WriteEllipseShape( const Reference< XShape >& xShape )
else
pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr);
- Reference< XPropertySet > xProps( xShape, UNO_QUERY );
CircleKind eCircleKind(CircleKind_FULL);
if (xProps.is())
xProps->getPropertyValue("CircleKind" ) >>= eCircleKind;
@@ -1369,6 +1396,7 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape
mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId, XML_action,
"ppaction://hlinksldjump");
}
+ AddExtLst(pFS, xShapeProps);
pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
pFS->singleElementNS(mnXmlNamespace, XML_cNvPicPr
@@ -1822,9 +1850,11 @@ ShapeExport& ShapeExport::WriteConnectorShape( const Reference< XShape >& xShape
{
// non visual shape properties
pFS->startElementNS(mnXmlNamespace, XML_nvCxnSpPr);
- pFS->singleElementNS(mnXmlNamespace, XML_cNvPr,
+ pFS->startElementNS(mnXmlNamespace, XML_cNvPr,
XML_id, OString::number(GetNewShapeID(xShape)),
XML_name, GetShapeName(xShape));
+ AddExtLst(pFS, rXPropSet);
+ pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
// non visual connector shape drawing properties
pFS->startElementNS(mnXmlNamespace, XML_cNvCxnSpPr);
@@ -1881,13 +1911,16 @@ ShapeExport& ShapeExport::WriteLineShape( const Reference< XShape >& xShape )
bFlipV = ( rPoly[ 0 ].Y() > rPoly[ 1 ].Y() );
}
+ Reference<XPropertySet> const xShapeProps(xShape, UNO_QUERY);
// non visual shape properties
if (GetDocumentType() != DOCUMENT_DOCX || mbUserShapes)
{
pFS->startElementNS(mnXmlNamespace, XML_nvSpPr);
- pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
+ pFS->startElementNS(mnXmlNamespace, XML_cNvPr,
XML_id, OString::number(GetNewShapeID(xShape)),
XML_name, GetShapeName(xShape));
+ AddExtLst(pFS, xShapeProps);
+ pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
}
pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr );
if (GetDocumentType() != DOCUMENT_DOCX || mbUserShapes)
@@ -1900,7 +1933,6 @@ ShapeExport& ShapeExport::WriteLineShape( const Reference< XShape >& xShape )
pFS->startElementNS(mnXmlNamespace, XML_spPr);
WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV, true);
WritePresetShape( "line" );
- Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
if( xShapeProps.is() )
WriteOutline( xShapeProps );
pFS->endElementNS( mnXmlNamespace, XML_spPr );
@@ -1920,9 +1952,14 @@ ShapeExport& ShapeExport::WriteLineShape( const Reference< XShape >& xShape )
ShapeExport& ShapeExport::WriteNonVisualDrawingProperties( const Reference< XShape >& xShape, const char* pName )
{
- GetFS()->singleElementNS( mnXmlNamespace, XML_cNvPr,
+ FSHelperPtr pFS = GetFS();
+
+ Reference<XPropertySet> const xShapeProps(xShape, UNO_QUERY);
+ pFS->startElementNS(mnXmlNamespace, XML_cNvPr,
XML_id, OString::number(GetNewShapeID(xShape)),
XML_name, pName );
+ AddExtLst(pFS, xShapeProps);
+ pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
return *this;
}
@@ -1960,9 +1997,11 @@ ShapeExport& ShapeExport::WriteRectangleShape( const Reference< XShape >& xShape
if (GetDocumentType() == DOCUMENT_DOCX && !mbUserShapes)
pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr);
pFS->startElementNS(mnXmlNamespace, XML_nvSpPr);
- pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
+ pFS->startElementNS(mnXmlNamespace, XML_cNvPr,
XML_id, OString::number(GetNewShapeID(xShape)),
XML_name, GetShapeName(xShape));
+ AddExtLst(pFS, xShapeProps);
+ pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr);
WriteNonVisualProperties( xShape );
pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
@@ -2425,9 +2464,12 @@ ShapeExport& ShapeExport::WriteTableShape( const Reference< XShape >& xShape )
pFS->startElementNS(mnXmlNamespace, XML_nvGraphicFramePr);
- pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
+ Reference<XPropertySet> const xShapeProps(xShape, UNO_QUERY);
+ pFS->startElementNS(mnXmlNamespace, XML_cNvPr,
XML_id, OString::number(GetNewShapeID(xShape)),
XML_name, GetShapeName(xShape));
+ AddExtLst(pFS, xShapeProps);
+ pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
pFS->singleElementNS(mnXmlNamespace, XML_cNvGraphicFramePr);
@@ -2470,6 +2512,7 @@ ShapeExport& ShapeExport::WriteTextShape( const Reference< XShape >& xShape )
mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId);
}
+ AddExtLst(pFS, xShapeProps);
pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
}
pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr, XML_txBox, "1");
@@ -2517,9 +2560,11 @@ void ShapeExport::WriteMathShape(Reference<XShape> const& xShape)
XML_Requires, "a14");
mpFS->startElementNS(mnXmlNamespace, XML_sp);
mpFS->startElementNS(mnXmlNamespace, XML_nvSpPr);
- mpFS->singleElementNS(mnXmlNamespace, XML_cNvPr,
+ mpFS->startElementNS(mnXmlNamespace, XML_cNvPr,
XML_id, OString::number(GetNewShapeID(xShape)),
XML_name, GetShapeName(xShape));
+ AddExtLst(mpFS, xPropSet);
+ mpFS->endElementNS(mnXmlNamespace, XML_cNvPr);
mpFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr, XML_txBox, "1");
mpFS->singleElementNS(mnXmlNamespace, XML_nvPr);
mpFS->endElementNS(mnXmlNamespace, XML_nvSpPr);
@@ -2720,9 +2765,11 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape )
mpFS->startElementNS(mnXmlNamespace, XML_nvGraphicFramePr);
- mpFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
+ mpFS->startElementNS(mnXmlNamespace, XML_cNvPr,
XML_id, OString::number(GetNewShapeID(xShape)),
XML_name, GetShapeName(xShape));
+ AddExtLst(mpFS, xPropSet);
+ mpFS->endElementNS(mnXmlNamespace, XML_cNvPr);
mpFS->singleElementNS(mnXmlNamespace, XML_cNvGraphicFramePr);
diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx
index dcce466fefd2..49a5f5ce4ba6 100644
--- a/oox/source/ppt/pptshapegroupcontext.cxx
+++ b/oox/source/ppt/pptshapegroupcontext.cxx
@@ -65,6 +65,14 @@ ContextHandlerRef PPTShapeGroupContext::onCreateContext( sal_Int32 aElementToken
switch( aElementToken )
{
+ case OOX_TOKEN(dml, extLst):
+ case OOX_TOKEN(dml, ext):
+ break;
+ case OOX_TOKEN(adec, decorative):
+ {
+ mpGroupShapePtr->setDecorative(rAttribs.getBool(XML_val, false));
+ }
+ break;
case PPT_TOKEN( cNvPr ):
{
// don't override SmartArt properties for embedded drawing's spTree