summaryrefslogtreecommitdiffstats
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-11-07 17:35:50 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-11-07 19:36:12 +0100
commit924f01fdef73af88284e6629c6d3604f33d27f24 (patch)
tree37d78c204f83582dacb618ec5e083dcaa9042e30 /oox
parentuitest Title page dialog (diff)
downloadcore-924f01fdef73af88284e6629c6d3604f33d27f24.tar.gz
core-924f01fdef73af88284e6629c6d3604f33d27f24.zip
oox smartart, table list: fix too large width of children
It's possible all children request 100% of space, need to scale down in that case. This means that children other than the first one is now readable in the layout result. Change-Id: I86a05cd77510bbb6686a53e33f13a60034c8e8f6 Reviewed-on: https://gerrit.libreoffice.org/63037 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx61
1 files changed, 53 insertions, 8 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 2ef5ffef2151..763eca855d91 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -36,6 +36,27 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::xml::sax;
using namespace ::oox::core;
+namespace
+{
+/// Looks up the value of the rInternalName -> nProperty key in rProperties.
+oox::OptValue<sal_Int32> findProperty(const oox::drawingml::LayoutPropertyMap& rProperties,
+ const OUString& rInternalName, sal_Int32 nProperty)
+{
+ oox::OptValue<sal_Int32> oRet;
+
+ auto it = rProperties.find(rInternalName);
+ if (it != rProperties.end())
+ {
+ const oox::drawingml::LayoutProperty& rProperty = it->second;
+ auto itProperty = rProperty.find(nProperty);
+ if (itProperty != rProperty.end())
+ oRet = itProperty->second;
+ }
+
+ return oRet;
+}
+}
+
namespace oox { namespace drawingml {
IteratorAttr::IteratorAttr( )
@@ -436,24 +457,48 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
rProperty[XML_w] = rShape->getSize().Width * rConstraint.mfFactor;
}
+ // See if children requested more than 100% space in total: scale
+ // down in that case.
+ sal_Int32 nTotalWidth = 0;
+ bool bSpaceFromConstraints = false;
for (auto & aCurrShape : rShape->getChildren())
{
- // Extract properties relevant for this shape from constraints.
- oox::OptValue<sal_Int32> oWidth;
- auto it = aProperties.find(aCurrShape->getInternalName());
- if (it != aProperties.end())
+ oox::OptValue<sal_Int32> oWidth
+ = findProperty(aProperties, aCurrShape->getInternalName(), XML_w);
+
+ awt::Size aSize = aChildSize;
+ if (oWidth.has())
{
- LayoutProperty& rProperty = it->second;
- auto itProperty = rProperty.find(XML_w);
- if (itProperty != rProperty.end())
- oWidth = itProperty->second;
+ aSize.Width = oWidth.get();
+ bSpaceFromConstraints = true;
}
+ if (nDir == XML_fromL || nDir == XML_fromR)
+ nTotalWidth += aSize.Width;
+ }
+
+ double fWidthScale = 1.0;
+ if (nTotalWidth > rShape->getSize().Width && nTotalWidth)
+ {
+ fWidthScale = rShape->getSize().Width;
+ fWidthScale /= nTotalWidth;
+ }
+
+ // Don't add automatic space if we take space from constraints.
+ if (bSpaceFromConstraints)
+ fSpace = 0;
+
+ for (auto& aCurrShape : rShape->getChildren())
+ {
+ // Extract properties relevant for this shape from constraints.
+ oox::OptValue<sal_Int32> oWidth
+ = findProperty(aProperties, aCurrShape->getInternalName(), XML_w);
aCurrShape->setPosition(aCurrPos);
awt::Size aSize = aChildSize;
if (oWidth.has())
aSize.Width = oWidth.get();
+ aSize.Width *= fWidthScale;
aCurrShape->setSize(aSize);
aCurrShape->setChildSize(aChildSize);