diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-03-26 13:35:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-03-26 18:02:19 +0100 |
commit | b624b13b3d5a8e573c7de8158cadc66b1982d157 (patch) | |
tree | 56948e6a5e8d7f5a7cbde6328a27f13ecd8a72bc /oox | |
parent | 8136620ff432bf17815bef1f88c7531edb839d23 (diff) |
loplugin:flatten
Change-Id: Ib7a895fba66f8dc9b6501e61631c02694053b7fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113157
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 18 | ||||
-rw-r--r-- | oox/source/export/chartexport.cxx | 176 |
2 files changed, 97 insertions, 97 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index bc24b0322059..f5191b54408a 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -712,17 +712,17 @@ void CompositeAlg::layoutShapeChildren(AlgAtom& rAlg, const ShapePtr& rShape, } // See if all vertical space is used or we have to center the content. - if (nVertMin >= 0 && nVertMin <= nVertMax && nVertMax <= rParent[XML_h]) + if (!(nVertMin >= 0 && nVertMin <= nVertMax && nVertMax <= rParent[XML_h])) + return; + + sal_Int32 nDiff = rParent[XML_h] - (nVertMax - nVertMin); + if (nDiff > 0) { - sal_Int32 nDiff = rParent[XML_h] - (nVertMax - nVertMin); - if (nDiff > 0) + for (auto& aCurrShape : rShape->getChildren()) { - for (auto& aCurrShape : rShape->getChildren()) - { - awt::Point aPosition = aCurrShape->getPosition(); - aPosition.Y += nDiff / 2; - aCurrShape->setPosition(aPosition); - } + awt::Point aPosition = aCurrShape->getPosition(); + aPosition.Y += nDiff / 2; + aCurrShape->setPosition(aPosition); } } } diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index e15e58a4f3ff..2b412d43430a 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -984,104 +984,104 @@ void ChartExport::exportExternalData( const Reference< css::chart::XChartDocumen void ChartExport::exportAdditionalShapes( const Reference< css::chart::XChartDocument >& xChartDoc ) { Reference< beans::XPropertySet > xDocPropSet(xChartDoc, uno::UNO_QUERY); - if (xDocPropSet.is()) + if (!xDocPropSet.is()) + return; + + css::uno::Reference< css::drawing::XShapes > mxAdditionalShapes; + // get a sequence of non-chart shapes + try { - css::uno::Reference< css::drawing::XShapes > mxAdditionalShapes; - // get a sequence of non-chart shapes - try + Any aShapesAny = xDocPropSet->getPropertyValue("AdditionalShapes"); + if( (aShapesAny >>= mxAdditionalShapes) && mxAdditionalShapes.is() ) { - Any aShapesAny = xDocPropSet->getPropertyValue("AdditionalShapes"); - if( (aShapesAny >>= mxAdditionalShapes) && mxAdditionalShapes.is() ) - { - OUString sId; - const char* sFullPath = nullptr; - const char* sRelativePath = nullptr; - sal_Int32 nDrawing = getNewDrawingUniqueId(); + OUString sId; + const char* sFullPath = nullptr; + const char* sRelativePath = nullptr; + sal_Int32 nDrawing = getNewDrawingUniqueId(); - switch (GetDocumentType()) + switch (GetDocumentType()) + { + case DOCUMENT_DOCX: { - case DOCUMENT_DOCX: - { - sFullPath = "word/drawings/drawing"; - sRelativePath = "../drawings/drawing"; - break; - } - case DOCUMENT_PPTX: - { - sFullPath = "ppt/drawings/drawing"; - sRelativePath = "../drawings/drawing"; - break; - } - case DOCUMENT_XLSX: - { - sFullPath = "xl/drawings/drawing"; - sRelativePath = "../drawings/drawing"; - break; - } - default: - { - sFullPath = "drawings/drawing"; - sRelativePath = "drawings/drawing"; - break; - } + sFullPath = "word/drawings/drawing"; + sRelativePath = "../drawings/drawing"; + break; } - OUString sFullStream = OUStringBuffer() - .appendAscii(sFullPath) - .append(nDrawing) - .append(".xml") - .makeStringAndClear(); - OUString sRelativeStream = OUStringBuffer() - .appendAscii(sRelativePath) - .append(nDrawing) - .append(".xml") - .makeStringAndClear(); - - sax_fastparser::FSHelperPtr pDrawing = CreateOutputStream( - sFullStream, - sRelativeStream, - GetFS()->getOutputStream(), - "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml", - OUStringToOString(oox::getRelationship(Relationship::CHARTUSERSHAPES), RTL_TEXTENCODING_UTF8).getStr(), - &sId); - - GetFS()->singleElementNS(XML_c, XML_userShapes, FSNS(XML_r, XML_id), sId); - - XmlFilterBase* pFB = GetFB(); - pDrawing->startElement(FSNS(XML_c, XML_userShapes), - FSNS(XML_xmlns, XML_cdr), pFB->getNamespaceURL(OOX_NS(dmlChartDr)), - FSNS(XML_xmlns, XML_a), pFB->getNamespaceURL(OOX_NS(dml)), - FSNS(XML_xmlns, XML_c), pFB->getNamespaceURL(OOX_NS(dmlChart))); - - const sal_Int32 nShapeCount(mxAdditionalShapes->getCount()); - for (sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++) + case DOCUMENT_PPTX: { - Reference< drawing::XShape > xShape; - mxAdditionalShapes->getByIndex(nShapeId) >>= xShape; - SAL_WARN_IF(!xShape.is(), "xmloff.chart", "Shape without an XShape?"); - if (!xShape.is()) - continue; - - // TODO: absSizeAnchor: we import both (absSizeAnchor and relSizeAnchor), but there is no essential difference between them. - pDrawing->startElement(FSNS(XML_cdr, XML_relSizeAnchor)); - uno::Reference< beans::XPropertySet > xShapeProperties(xShape, uno::UNO_QUERY); - if( xShapeProperties.is() ) - { - Reference<embed::XVisualObject> xVisObject(mxChartModel, uno::UNO_QUERY); - awt::Size aPageSize = xVisObject->getVisualAreaSize(embed::Aspects::MSOLE_CONTENT); - WriteFromTo( xShape, aPageSize, pDrawing ); + sFullPath = "ppt/drawings/drawing"; + sRelativePath = "../drawings/drawing"; + break; + } + case DOCUMENT_XLSX: + { + sFullPath = "xl/drawings/drawing"; + sRelativePath = "../drawings/drawing"; + break; + } + default: + { + sFullPath = "drawings/drawing"; + sRelativePath = "drawings/drawing"; + break; + } + } + OUString sFullStream = OUStringBuffer() + .appendAscii(sFullPath) + .append(nDrawing) + .append(".xml") + .makeStringAndClear(); + OUString sRelativeStream = OUStringBuffer() + .appendAscii(sRelativePath) + .append(nDrawing) + .append(".xml") + .makeStringAndClear(); + + sax_fastparser::FSHelperPtr pDrawing = CreateOutputStream( + sFullStream, + sRelativeStream, + GetFS()->getOutputStream(), + "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml", + OUStringToOString(oox::getRelationship(Relationship::CHARTUSERSHAPES), RTL_TEXTENCODING_UTF8).getStr(), + &sId); + + GetFS()->singleElementNS(XML_c, XML_userShapes, FSNS(XML_r, XML_id), sId); + + XmlFilterBase* pFB = GetFB(); + pDrawing->startElement(FSNS(XML_c, XML_userShapes), + FSNS(XML_xmlns, XML_cdr), pFB->getNamespaceURL(OOX_NS(dmlChartDr)), + FSNS(XML_xmlns, XML_a), pFB->getNamespaceURL(OOX_NS(dml)), + FSNS(XML_xmlns, XML_c), pFB->getNamespaceURL(OOX_NS(dmlChart))); + + const sal_Int32 nShapeCount(mxAdditionalShapes->getCount()); + for (sal_Int32 nShapeId = 0; nShapeId < nShapeCount; nShapeId++) + { + Reference< drawing::XShape > xShape; + mxAdditionalShapes->getByIndex(nShapeId) >>= xShape; + SAL_WARN_IF(!xShape.is(), "xmloff.chart", "Shape without an XShape?"); + if (!xShape.is()) + continue; - ShapeExport aExport(XML_cdr, pDrawing, nullptr, GetFB(), GetDocumentType()); - aExport.WriteShape(xShape); - } - pDrawing->endElement(FSNS(XML_cdr, XML_relSizeAnchor)); + // TODO: absSizeAnchor: we import both (absSizeAnchor and relSizeAnchor), but there is no essential difference between them. + pDrawing->startElement(FSNS(XML_cdr, XML_relSizeAnchor)); + uno::Reference< beans::XPropertySet > xShapeProperties(xShape, uno::UNO_QUERY); + if( xShapeProperties.is() ) + { + Reference<embed::XVisualObject> xVisObject(mxChartModel, uno::UNO_QUERY); + awt::Size aPageSize = xVisObject->getVisualAreaSize(embed::Aspects::MSOLE_CONTENT); + WriteFromTo( xShape, aPageSize, pDrawing ); + + ShapeExport aExport(XML_cdr, pDrawing, nullptr, GetFB(), GetDocumentType()); + aExport.WriteShape(xShape); } - pDrawing->endElement(FSNS(XML_c, XML_userShapes)); + pDrawing->endElement(FSNS(XML_cdr, XML_relSizeAnchor)); } + pDrawing->endElement(FSNS(XML_c, XML_userShapes)); } - catch (const uno::Exception&) - { - TOOLS_INFO_EXCEPTION("xmloff.chart", "AdditionalShapes not found"); - } + } + catch (const uno::Exception&) + { + TOOLS_INFO_EXCEPTION("xmloff.chart", "AdditionalShapes not found"); } } |