summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx30
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.hxx4
-rw-r--r--oox/source/drawingml/diagram/layoutnodecontext.cxx16
3 files changed, 40 insertions, 10 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index dc526803f8fe..e57a0115e129 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -489,12 +489,29 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
LayoutPropertyMap aProperties;
LayoutProperty& rParent = aProperties[""];
- rParent[XML_w] = rShape->getSize().Width;
- rParent[XML_h] = rShape->getSize().Height;
- rParent[XML_l] = 0;
- rParent[XML_t] = 0;
- rParent[XML_r] = rShape->getSize().Width;
- rParent[XML_b] = rShape->getSize().Height;
+
+ sal_Int32 nParentXOffset = 0;
+ if (mfAspectRatio != 1.0)
+ {
+ rParent[XML_w] = rShape->getSize().Width;
+ rParent[XML_h] = rShape->getSize().Height;
+ rParent[XML_l] = 0;
+ rParent[XML_t] = 0;
+ rParent[XML_r] = rShape->getSize().Width;
+ rParent[XML_b] = rShape->getSize().Height;
+ }
+ else
+ {
+ // Shrink width to be only as large as height.
+ rParent[XML_w] = std::min(rShape->getSize().Width, rShape->getSize().Height);
+ rParent[XML_h] = rShape->getSize().Height;
+ if (rParent[XML_w] < rShape->getSize().Width)
+ nParentXOffset = (rShape->getSize().Width - rParent[XML_w]) / 2;
+ rParent[XML_l] = nParentXOffset;
+ rParent[XML_t] = 0;
+ rParent[XML_r] = rShape->getSize().Width - rParent[XML_l];
+ rParent[XML_b] = rShape->getSize().Height;
+ }
for (const auto & rConstr : rConstraints)
{
@@ -556,6 +573,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
if ( (it = rProp.find(XML_t)) != rProp.end() && (it2 = rProp.find(XML_b)) != rProp.end() )
aSize.Height = it2->second - it->second;
+ aPos.X += nParentXOffset;
aSize.Width = std::min(aSize.Width, rShape->getSize().Width - aPos.X);
aSize.Height = std::min(aSize.Height, rShape->getSize().Height - aPos.Y);
}
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index 440db0ef21ed..f056e4f7e637 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -169,9 +169,13 @@ public:
/// Gives access to <dgm:param type="..." val="..."/>.
const ParamMap& getMap() const { return maMap; }
+ void setAspectRatio(double fAspectRatio) { mfAspectRatio = fAspectRatio; }
+
private:
sal_Int32 mnType;
ParamMap maMap;
+ /// Aspect ratio is not integer, so not part of maMap.
+ double mfAspectRatio = 0;
};
typedef std::shared_ptr< AlgAtom > AlgAtomPtr;
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx
index 2cfeec2e8db6..ff508a24fcae 100644
--- a/oox/source/drawingml/diagram/layoutnodecontext.cxx
+++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx
@@ -67,10 +67,18 @@ public:
{
case DGM_TOKEN( param ):
{
- const sal_Int32 nValTok = rAttribs.getToken( XML_val, 0 );
- mpNode->addParam(
- rAttribs.getToken( XML_type, 0 ),
- nValTok>0 ? nValTok : rAttribs.getInteger( XML_val, 0 ) );
+ sal_Int32 nType = rAttribs.getToken(XML_type, 0);
+ switch (nType)
+ {
+ case XML_ar:
+ mpNode->setAspectRatio(rAttribs.getDouble(XML_val, 0));
+ break;
+ default:
+ const sal_Int32 nValTok = rAttribs.getToken(XML_val, 0);
+ mpNode->addParam(nType, nValTok > 0 ? nValTok
+ : rAttribs.getInteger(XML_val, 0));
+ break;
+ }
break;
}
default: